Skip to content

Instantly share code, notes, and snippets.

View mlawrie's full-sized avatar

Michael Lawrie mlawrie

View GitHub Profile
#Prompt that doesn't call git
PS1='\[\e[0;36m\]\u\[\e[m\] \[\e[0;36m\]\w\[\e[m\] \[\e[0;35m\]\$\[\e[m\] \[\e[0;37m\]'
alias subl='/c/Program\ Files/Sublime\ Text\ 3/sublime_text.exe'
alias gw='gradlew'
git config --global alias.st status
git config --global alias.lo 'log --oneline'
git config --global alias.pr 'pull --rebase'
git config --global core.editor "'c:\Program Files\Sublime Text 3\sublime_text.exe' -w"
@mlawrie
mlawrie / install_weinre.sh
Created February 12, 2013 20:27
Script to install weire and set it up for unrestricted access. To run: curl https://gist.github.com/mlawrie/4773083/raw/install_weinre.sh | sh
#!/bin/bash
path=`which npm`;
if [ "$path" == "" ];
then
curl https://npmjs.org/install.sh | sh
fi
npm -g install weinre
@mlawrie
mlawrie / jquery_current_element.js
Created January 7, 2013 05:45
Get a jquery reference to the element the cursor is on in CKEditor
$(CKEDITOR.instances.my_instance.getSelection().getStartElement().$)
@mlawrie
mlawrie / ssl_setup_example.sh
Last active October 18, 2018 12:49
Create an SSL Certificate Signing Request on OSX with wildcard and alternate names
# First, generate the key. You will be prompted to enter a password, but we will strip it out in the next step:
openssl genrsa -des3 -out server.orig.key 2048
# Then, stip out the password:
openssl rsa -in server.orig.key -out server.key
# Edit the OSX openssl config file to include your alternate names.
# Edit the 'subjectAltName' field. E.g.:
@mlawrie
mlawrie / backdoor.php
Created December 5, 2012 07:13
backdoor left by hacker
<?php
/*
Special thanks to:
Ryan Duff and Firas Durri, authors of WP-ContactForm, to which this
plugins' initial concept and some parts of code was built based on.
modernmethod inc, for SAJAX Toolkit, which was used to build this
plugins' AJAX implementation
*/
@mlawrie
mlawrie / curdir.sh
Created October 17, 2012 14:51
bash script current directory following symlinks
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
DIR="$( dirname "$SOURCE" )"
while [ -h "$SOURCE" ]
do
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@mlawrie
mlawrie / .bash_profile
Last active October 11, 2015 14:08
My .bash_profile
#Android SDK
M2_HOME=/usr/local/apache-maven
ANDROID_HOME=/usr/local/android-sdk-macosx
PATH=$PATH:$M2_HOME:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
#RVM
PATH=$PATH:$HOME/.rvm/bin
#Local bin
PATH=$PATH:$HOME/bin
@mlawrie
mlawrie / gist:3710389
Created September 12, 2012 22:20
Simple encrypted backup for a Rails mysql database
#Generates aes-256 encrypted bz2-compressed mysql dumps named "[app name] ([timestamp]).backup"
#To decrypt:
#cat backupname.backup | openssl enc -d -aes-256-cbc -salt -pass pass:[password] > backupname.sql
require 'yaml'
require 'encryptor'
def backup(src, name)