Skip to content

Instantly share code, notes, and snippets.

@caseyw
caseyw / index.php
Created October 10, 2012 15:25
Implementing Twitter sign-in with Silex and PHP
<?php
define('CONS_KEY', 'Application consumer key');
define('CONS_SECRET', 'Application consumer secret');
require_once __DIR__.'/silex.phar';
$app = new Silex\Application();
// register the session extension
$app->register(new Silex\Extension\SessionExtension());
@caseyw
caseyw / gist:5071512
Created March 2, 2013 15:21
Add swap space to AWS EC2 micro server
# sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
# sudo /sbin/mkswap /var/swap.1
# sudo /sbin/swapon /var/swap.1
@caseyw
caseyw / gist:5071615
Created March 2, 2013 15:47
Symfony2 Permissions - Nabbed of a page to ensure I can find the damn thing.
Install and enable ACL
First you need to install ACL, preferrably through your package manager; aptitude on Ubuntu, pacman on Arch, yum on Fedora, etc:
$ sudo aptitude install acl
Then you edit your /etc/fstab to enable ACL for your partition. Simply add acl to the list of options.
/dev/sda1 / ext4 rw,auto,acl 0 1
Then lastly remount the partition to have the new options take effect.
@caseyw
caseyw / gist:9057036
Created February 17, 2014 19:14
Create XML file for use with PHPUnit
mysql -u -p --xml -e 'SELECT * FROM foo WHERE bar="law"' > dump.xml
@caseyw
caseyw / gist:9057085
Created February 17, 2014 19:17
Dump InnoDB database in a single transaction
mysqldump --single-transaction -uUSERNAME -p DBNAME > dump.sql
@caseyw
caseyw / bkup
Created February 18, 2014 14:30
Backup directory under a pretty unique name
#!/usr/bin/env bash
now=$(date +"%Y%m%d_%H%M%S")
if [[ $1 == "" ]]
then
echo "You need to specify the directory you need to backup: bkup PROJECT"
else
dir="$1"
To terminate user sessions or queries on DB instances, Amazon RDS provides the following commands:
PROMPT> CALL mysql.rds_kill(thread-ID)
PROMPT> CALL mysql.rds_kill_query(thread-ID)
For example, to kill the session that is running on thread 99, you would type the following:
PROMPT> CALL mysql.rds_kill(99);
To kill the query that is running on thread 99, you would type the following:
@caseyw
caseyw / gist:9490640
Created March 11, 2014 17:25
error hostonlyif create
I had an issue with VB/Vagrant today. Here's the error, and the fix:
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "create"]
Stderr: 0%...
Progress state: NS_ERROR_FAILURE
@caseyw
caseyw / total in file
Created March 19, 2014 18:04
print total of numbers found, can pipe into
awk '{ sum += $1 } END { print sum }' file
@caseyw
caseyw / delete_logs
Last active May 23, 2016 17:19
delete old logs
sudo find /var/log -type f -name "*.gz" -delete