Posted 27 Jan 2010 — by admin
Category php
Listing all files and directories using PHP 5.
<?php
$files = array(); $dir = dir(".");
while(false!==($file=$dir->read())):
if(($file{0}!=".") && ($file{0}!="~") && (substr($file, -3)!="LCK")
&& ($file!=basename($_SERVER["PHP_SELF"]))):
$files[$file] = stat($file); //
endif;
endwhile;
$dir->close(); ksort($files); ?>
<table border=1 cellpadding=5>
<tr><th>Name</th><th>Size</th><th>Date</th></tr>
<?php foreach($files as $name => $stats): ?>
<tr>
<td><?php print $name;?></td>
<td><?php print $stats['size']; ?></td>
<td><?php print date("m-d-Y h:ia", $stats['mtime']); ?></td>
</tr>
<?php endforeach; ?></table>
Posted 30 Nov 2009 — by admin
Category ruby
These aren’t all of them, but I think they are some of the most useful.
# making a directory in another directory that doesn't yet exist...
FileUtils.mkdir_p '/path/to/your/directory/that/doesnt/exist/yet'
# recursively remove a directory and the contents
FileUtils.rm_rf("/path/to/directory/you/want/to/delete")
# write a file from the contents of another file...
File.open("/path/to/the/file.ext", "wb") {|f| f.write(@your_other_file.read)}
Git can track the file permissions on your source. This can be good, but for small projects on a webserver where permissions change from time to time, and permissions on development app don’t match or matter anyway, it’s often easier to just skip this check alltogether. For the application in question look in the .git directory in the application root. You’ll see a config file with the application specific directives. Open the file with your editor of choice and change the filemode to false. It’s set to true by default.
[core]
repositoryformatversion = 0
filemode = false