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
function sign_s3(access_key, private_key, bucket, object_name, validity, base_url) { | |
if(!base_url) { | |
base_url = "http://s3.amazonaws.com"; | |
} | |
if(!validity) { | |
validity = 60; | |
} | |
expires = Math.floor((new Date()).getTime() / 1000) + validity; | |
object_name = encodeURIComponent(object_name); | |
stringToSign = "GET\n\n\n"+expires+"\n/"+bucket+"/"+object_name; |
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/php | |
<?php | |
$mysqli = new mysqli('hostname', 'username', 'password'); | |
$result = $mysqli->query( | |
"SELECT `TABLE_SCHEMA`, `TABLE_NAME` FROM `information_schema`.`TABLES` | |
WHERE | |
`TABLE_COLLATION` != 'utf8_general_ci' | |
AND `TABLE_SCHEMA` != 'mysql' | |
AND `TABLE_SCHEMA` != 'information_schema'"); |
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
#!/bin/bash -e | |
# These need to be set. | |
#export EC2_HOME="/path/to/ec2-api-tools" | |
#export AWS_ACCESS_KEY='XXXXXXXXXXXXXXXXXXXX' | |
#export AWS_SECRET_KEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
#export PATH="$PATH:${EC2_HOME}/bin" | |
ami_id='ami-123abc12' | |
availability_zone='eu-west-1a' | |
keypair="johndoe@example.com" |
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
#!/bin/sh | |
## backup each mysql db into a different file, rather than one big file | |
## as with --all-databases. This will make restores easier. | |
## To backup a single database simply add the db name as a parameter (or multiple dbs) | |
## Putting the script in /var/backups/mysql seems sensible... on a debian machine that is | |
## Create the user and directories | |
# mkdir -p /var/backups/mysql/databases | |
# useradd --home-dir /var/backups/mysql --gid backup --no-create-home mysql-backup | |
## Remember to make the script executable, and unreadable by others |
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
SELECT CONCAT('DROP TABLE `', `t`.`TABLE_SCHEMA`, '`.`', `t`.`TABLE_NAME`, '`;') | |
FROM `information_schema`.`TABLES` t | |
LEFT JOIN `information_schema`.`REFERENTIAL_CONSTRAINTS` rc | |
ON `rc`.`CONSTRAINT_SCHEMA` = `t`.`TABLE_SCHEMA` | |
AND `rc`.`REFERENCED_TABLE_NAME` = `t`.`TABLE_NAME` | |
WHERE `TABLE_SCHEMA` = 'dbname' | |
GROUP BY `t`.`TABLE_NAME` | |
ORDER BY COUNT(`t`.`TABLE_NAME`) ASC; |
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
#!/bin/bash | |
url='http://apple-tv.anders.local' | |
menu="$url/remoteAction=1" | |
menuhold="$url/remoteAction=2" | |
up="$url/remoteAction=3" | |
down="$url/remoteAction=4" | |
select="$url/remoteAction=5" | |
left="$url/remoteAction=6" | |
right="$url/remoteAction=7" | |
playpause="$url/remoteAction=10" |
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
#!/bin/bash -ex | |
# Paste this into ssh | |
# curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex | |
# When forking, you can get the URL from the raw (<>) button. | |
### Set some command variables depending on whether we are root or not ### | |
# This assumes you use a debian derivate, replace with yum, pacman etc. | |
aptget='sudo apt-get' | |
chsh='sudo chsh' |
NewerOlder