This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$usage = array( | |
'min_args' => '5', | |
'message' => "$argv[0] --host=example.com --schema=MyDB --user=user_name [--pass=\"secret\"] --search=\"any string\"" | |
); | |
if( $argc < $usage['min_args'] ){ | |
exit("{$usage['message']}\n"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Did you know that:"; whatis $(ls -1 /bin | head -$(echo "$RANDOM % `ls -1 /bin | wc -l`" | bc) | tail -1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prompt_for_password(prompt = "Enter Password:") | |
print prompt | |
`stty -echo` | |
password = STDIN.gets | |
`stty echo` | |
print "\n" | |
password.chomp | |
end | |
password = prompt_for_password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ARGV.empty? | |
puts "ERROR: missing arguments | |
usage: ruby #{$0} file [output] | |
\tfile\tthe file to scan; could be a regular file, disc image or block device | |
\toutput\t(optional) directory to save extracted files to. Default value is ./jpeg-files" | |
exit 1 | |
end | |
file_path = ARGV[0] | |
file = File.open(file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo $(grep processor /proc/cpuinfo | wc -l)"x" $(grep 'model name' /proc/cpuinfo | head --lines=1 | awk -F':' '{gsub(/^[ ]+/, "", $2);print $2}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set hostname to lower in /etc/hosts file | |
sed -i "s/$(hostname)/$(hostname | tr '[:upper:]' '[:lower:]')/" /etc/hosts | |
# set runtime hostname to lowercase | |
hostname $(hostname | tr '[:upper:]' '[:lower:]') | |
# save lowercase hostname to /etc/hostname file | |
hostname > /etc/hostname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# transfer mysql database to different server with a new name | |
# such as production database to test database | |
read -p "source host:" SRC_HOST | |
read -p "user for host $SRC_HOST:" SRC_USER | |
read -p "password for $SRC_USER@$SRC_HOST:" -s SRC_PW; echo | |
read -p "source database name:" SRC_DB | |
read -p "target host:" TGT_HOST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
/* convert Multi Site Manager (MSM) ExpressionEngine (EE) database to single site database. | |
* used to split a site to own EE instance without MSM. | |
* Deletes all sites other than site_id specified then changes specified sites id to 1. | |
* Ignores site_id 0, although I don't rememeber why. | |
* I ran it from Linux command line, no idea if it will run the same on Window or Mac. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "\$# is the number of arguments" | |
echo "$# arguments" | |
echo | |
echo "\$* is list of arguments joined into a string" | |
echo $* | |
echo | |
echo "\$@ is a sequence of strings, well suited to a for loop" | |
echo $@ |
OlderNewer