Skip to content

Instantly share code, notes, and snippets.

View jerram's full-sized avatar

Jerram Watters jerram

  • Teamfactory.io
  • Byron Bay
View GitHub Profile
@jerram
jerram / gist:0dea6180f7f89bc230566e2270a41224
Created March 22, 2020 23:49
git stage non white space changes
git diff -U0 -w --no-color -- controllers/UserController.php | git apply --cached --ignore-whitespace --unidiff-zero
@jerram
jerram / vagrant-box-sideload.sh
Created April 10, 2019 04:12
Slow vagrant box downloads - manually downoad and add to vagrant
# pull url from vagrant up
wget https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20190406.0.0/providers/virtualbox.box
vagrant box add ubuntu/xenial64 ~/virtualbox.box
cd ~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-xenial64/
mv 0 20190406.0.0
echo 'https://vagrantcloud.com/ubuntu/boxes/xenial64' > metadata_url
perl -pe 'chomp if eof' metadata_url > metadata_url
vagrant box update
@jerram
jerram / versions.sh
Created February 10, 2017 08:01
get versions of lamp stack
uname -a > /tmp/lamp-versions.txt
lsb_release -a >> /tmp/lamp-versions.txt
apache2 -v >> /tmp/lamp-versions.txt
mysql --version >> /tmp/lamp-versions.txt
php -v >> /tmp/lamp-versions.txt
cat /tmp/lamp-versions.txt
@jerram
jerram / Git prune merged remote features
Last active September 22, 2015 06:59
Git prune merged remote features
# list local merged feature branches
git branch --merged | grep feature | grep -v '>' | xargs -L1
git branch --merged | grep hotfix | grep -v '>' | xargs -L1
# delete local merged feature branches
git branch --merged | grep feature | grep -v '>' | xargs -L1 | xargs git branch -D
git branch --merged | grep hotfix | grep -v '>' | xargs -L1 | xargs git branch -D
# list what will be removed - check me
git branch -r --merged | grep origin | grep -v '>' | grep -v epic/reporting | xargs -L1 | cut -d"/" -f2- | grep feature
@jerram
jerram / pke-encrypt-files
Last active August 29, 2015 14:23
Encrypt and decrypt text files with openssl
Encrypt file with key pair
http://krisjordan.com/essays/encrypting-with-rsa-key-pairs
data to encrypt
vim plain.txt
Create the PEM (I wish I could avoid this step and use a .pub file)
openssl rsa -in ~/.ssh/id_rsa -pubout > ~/.ssh/id_rsa.pub.pem
Encrypt
@jerram
jerram / ssh key generate
Last active February 22, 2017 21:53
SSH keys in 1 second
# change 'id_rsa' to your key name
ssh-keygen -b 4096 -t rsa -f id_rsa -q -N "" -C your@email.com
chmod 400 ~/.ssh/id_rsa
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub
@jerram
jerram / gist:733c06e8927bf23f75e3
Last active August 29, 2015 14:21
Tessel Camera Module doesnt run takePicture()
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
/*********************************************
This camera example takes a picture. If a
directory is specified with the --upload-dir
flag, the picture is saved to that directory.
*********************************************/
var tessel = require('tessel');
@jerram
jerram / bash-dev-mysql
Created May 8, 2015 06:52
Create a dev mysql user and db
#!/bin/bash
if [ -z "$1" -a "$1"=" " ]; then
echo "Creates a dev mysql user, pass and db with the same name"
echo "Usage: make-db.sh name"
exit
fi
# mysql user and table naming restriction
regex='^[A-Za-z][A-Za-z0-9_]*$'
@jerram
jerram / i can haz adminer mysql
Last active August 29, 2015 14:20
i can haz adminer mysql
sudo mkdir /usr/share/adminer
sudo wget "http://www.adminer.org/latest.php" -O /usr/share/adminer/latest.php
sudo ln -s /usr/share/adminer/latest.php /usr/share/adminer/adminer.php
echo "Alias /adminer.php /usr/share/adminer/adminer.php" | sudo tee /etc/apache2/conf-available/adminer.conf
echo "Alias /adminer /usr/share/adminer/adminer.php" | sudo tee -a /etc/apache2/conf-available/adminer.conf
sudo a2enconf adminer.conf
sudo service apache2 restart
@jerram
jerram / Reset MYSQL root password
Created May 4, 2015 05:46
Reset MYSQL root password
If mysql is started with Upstart, you cant kill it any way but this - it will continue to respawn
sudo service mysql stop
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
mysql -u root
FLUSH PRIVILEGES;
SET PASSWORD FOR root@'localhost' = PASSWORD('');
FLUSH PRIVILEGES;
QUIT