How to recursive delete files and directories with PHP
This is an example how you could recursive delete directories with PHP.
Keep in mind that you ALWAYS define a root where this function should do its action.
This can seriously remove all your files.
define('UPLOADFILES', dirname(dirname(__FILE__)) . '/uploadfiles'); function recursiveDelete($path) { if (strpos($path, UPLOADFILES) === false) { exit('Trying to remove from wrong path to uploadfiles!'); } if (is_file($path)) { return unlink($path); } elseif ( is_dir($path) ){ $objects = scandir($path); foreach ($objects as $object) { if($object != '.' && $object != '..'){ recursiveDelete($path . '/' . $object); } } reset($objects); return rmdir($path); } }
How to show hidden .htaccess files in Eclipse and Aptana
Most webdevelopers require .htaccess files to be visible in their projects, since by default Eclipse and Aptana both hide files starting with a . (=period) this can be quite irritating since you have to open the file from your operating system file explorer.
The fix to make .htaccess files visible is quite simple, you have to modify the file browser view filter to show hidden files but hide certain file types so you won't get a mess in your view.
First goto the filters menu by clicking the little arrow on the top right of the file browser and click 'Filters...'.
When you are at the filter menu you will see the following window:

In this window uncheck '.* resources' and check 'Name filter patterns (matching names will be hidden):'.
Now you have to add a filter because you will be flooded by hidden files in your file explorer.
The filter I used is:
._*, .svn, .cvsignore, _notes, .*.swp, .DS_Store, .AppleDouble, .project, .buildpath, .settings, .git, .nbproject
You might append more filters to your needs.
In case you have a remote filesystem plugin installed you might need to check 'Show hidden files' in your preferences.
This is an example how this window might look:

Another handy thing to know, never edit the .project file!
That was about it for now, happy coding!
How to download a range of files with Curl and Bash
This is a really simple sniped how to download a range of files.
I found this very useful to download an image range of my old avatar script.
I lost my images but remembered an url where I uploaded them once. Happy me
1 2 3 4 5 6 7 | #!/usr/local/bin/bash # Range 1 to 75 for x in {1..75} do curl -O http://my.server.com/media/images_${x}.jpg done |
How to install Transmission BitTorrent client on FreeBSD
Transmission is a fast, easy and free BitTorrent client.
This manual is for Transmission 2.00 and higher. Our plan is running it as a daemon with a web interface.
Installation
Install required ports:
cd /usr/ports/net-p2p/transmission-daemon ; make install clean
Login to unpriv account and start transmission-daemon.
su - mariusvw transmission-daemon
Now transmission created the default configuration kill it.
# Get current pid: ps aux |grep transmission # Kill it: kill <PID>
Edit the configuration to your needs:
vi .config/transmission-daemon/settings.json
You can view an example config here:
{
"alt-speed-down": 1500,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 62,
"alt-speed-time-enabled": true,
"alt-speed-time-end": 1020,
"alt-speed-up": 100,
"bind-address-ipv4": "",
"bind-address-ipv6": "",
"blocklist-enabled": true,
"blocklist-url": "http://www.bluetack.co.uk/config/level1.gz",
"cache-size-mb": 4,
"dht-enabled": true,
"download-dir": "/usr/home/mariusvw/Downloads",
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/usr/home/mariusvw/Downloads",
"incomplete-dir-enabled": false,
"lazy-bitfield-enabled": true,
"lpd-enabled": false,
"message-level": 2,
"open-file-limit": 32,
"peer-congestion-algorithm": "",
"peer-limit-global": 240,
"peer-limit-per-torrent": 60,
"peer-port": 53945,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"port-forwarding-enabled": true,
"preallocation": 1,
"prefetch-enabled": 1,
"ratio-limit": 2,
"ratio-limit-enabled": true,
"rename-partial-files": true,
"rpc-authentication-required": true,
"rpc-bind-address": "192.168.1.2",
"rpc-enabled": true,
"rpc-password": "{2f9f20kco80wef8f02do20020488fc49626615IeDMuk3",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "mariusvw",
"rpc-whitelist": "127.0.0.1,192.168.1.40,2001:0000:0000::fe35:",
"rpc-whitelist-enabled": true,
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 100,
"speed-limit-up-enabled": false,
"start-added-torrents": true,
"trash-original-torrent-files": true,
"umask": 18,
"upload-slots-per-torrent": 14,
"utp-enabled": true,
"watch-dir": "/usr/home/mariusvw/Downloads/__WATCH",
"watch-dir-enabled": true
}Create download directories
mkdir /usr/home/mariusvw/Downloads mkdir /usr/home/mariusvw/Downloads/__WATCH
Restart the daemon:
transmission-daemon
Surfto:
http://192.168.1.2:9091/transmission/web/
Have fun downloading!
Optional and OLD scripts:
Dynamic Speed Script
Change maximum speeds on time period:
0 23 * * * /home/mariusvw/transmission-speed.sh fast > /dev/null 2>&1 0 8 * * * /home/mariusvw/transmission-speed.sh slow > /dev/null 2>&1
Create speed-change script: transmission-speed.sh
#!/bin/sh action=$1 case $action in 'slow') /usr/local/bin/transmission-remote -n mariusvw:<yourpassword> -d 100 -u 10 ;; 'fast') /usr/local/bin/transmission-remote -n mariusvw:<yourpassword> -d 500 -u 50 ;; esac
Easy commands
You can use this to easily enter transmission-daemon commands without having to enter your username and password every time.
#!/bin/sh action=$1 if [ -n "$action" ] then /usr/local/bin/transmission-remote -n mariusvw:<yourpassword> $action fi
I hope this is useful for the ones who like to work with Torrents and share easy without leaving on your desktop PC if you have a server available.





