Skip to content

Instantly share code, notes, and snippets.

View jfountain's full-sized avatar

James Fountain jfountain

View GitHub Profile
<?php
/**
* Attempt to wrap Http Authentication into a separate class...
*
* Ideas and some code from FuelPHP Controller_Rest
* https://github.com/fuel/fuel/blob/develop/fuel/core/classes/controller/rest.php
*
*/
@jfountain
jfountain / Git Notes
Last active December 15, 2015 10:29
#add existing to git
git init
git add .
git remote add origin git@github.com:USERNAME/REPONAME.git
git push -u origin master
#remove svn
find . -name '.svn' -type d -print0 | xargs -0 rm -rf
git commit -a -m 'removing svn files'
@jfountain
jfountain / gist:5073331
Last active December 14, 2015 10:39
svn->git cheat sheet
svn | git
svn revert | git reset --hard ;git pull OR git stash;git pull;git stash pop
svn commit -m 'message' | git commit -m 'message';git push
svn update | git pull
@jfountain
jfountain / gist:3761655
Created September 21, 2012 14:07
restrict access to port from a single ip address with iptables
iptables -I INPUT \! --src {ip address} -m tcp -p tcp --dport {port number} -j DROP
@jfountain
jfountain / gist:3057155
Created July 5, 2012 23:44
memcache tester
public function action_memcache(){
$memcache_enabled = extension_loaded("memcache");
dump("Memcache enabled: ".$memcache_enabled);
//memcached simple test
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$key = md5('9000'); //something unique
for ($k=0; $k<5; $k++) {
$data = $memcache->get($key);
@jfountain
jfountain / gist:2991671
Created June 25, 2012 22:07
Get only column names from mysql
select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='table'
@jfountain
jfountain / gist:2418589
Created April 19, 2012 04:36
update guest addition for virtualbox
wget -c \
http://download.virtualbox.org/virtualbox/4.1.12/VBoxGuestAdditions_4.1.12.iso \
-O VBoxGuestAdditions_4.1.12.iso
sudo apt-get install build-essential linux-headers-`uname -r`
sudo mount VBoxGuestAdditions_4.1.12.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run --nox11
rm *.iso
@jfountain
jfountain / gist:2208884
Created March 26, 2012 19:19
Block Ip Range with iptables
sudo iptables -I INPUT -s 138.162.8.0/24 -j DROP
@jfountain
jfountain / gist:2061186
Created March 17, 2012 15:27
Delete iptable rule by rule number
iptables -D INPUT {rule #}
@jfountain
jfountain / gist:2046384
Created March 15, 2012 19:45
Restore a deleted file from svn
svn copy -r [version #] [svnurl]@[version #] .