Skip to content

Instantly share code, notes, and snippets.

View pangkalizer's full-sized avatar

Allan Andal pangkalizer

  • Sydney, Australia
View GitHub Profile
@pangkalizer
pangkalizer / docker_cheats
Last active June 28, 2017 10:01
docker cheats
Online liner commit running container, then squashed image
docker save $(docker commit supatest supatest) | docker-squash -t supatest -verbose | docker load
One liner to stop / remove all of Docker containers:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
Remove all non-running container
sudo docker ps -a | grep 'Exited' | awk '{print $1}' | xargs --no-run-if-empty sudo docker rm
wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian precise non-free contrib" >> /etc/apt/sources.list.d/virtualbox.org.list'
sudo apt-get update
sudo apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.3 dkms
cd /tmp
wget http://download.virtualbox.org/virtualbox/4.3.20/Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack
wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.deb
sudo dpkg -i vagrant_1.7.2_x86_64.deb
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host me.bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/pangkalizer
desc "tail production log files"
task :tail_logs, :roles => :app do
trap("INT") { puts 'Interupted'; exit 0; }
run "tail -f /var/log/nginx/access.log" do |channel, stream, data|
puts # for an extra line break before the host name
puts "#{channel[:host]}: #{data}"
break if stream == :err
end
end
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@pangkalizer
pangkalizer / gist:480296b030740d8f93f0
Last active August 29, 2015 14:04
reverse ssh tunnel

eg: api.countrycars.com.au tunnel through norm.omg.com.au

on local machine

ssh -f aandal@localhost -L 1337:api.countrycars.com.au:80 -N

-L: -N: no commands

create ssh tunnel to target website

@pangkalizer
pangkalizer / gist:bc0ee5521489e3b23908
Created July 23, 2014 07:43
elasticsearch on ubuntu 14.14
sudo apt-get install openjdk-7-jre-headless -y
sudo wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add -
# add the following line to /etc/apt/sources.list
deb http://packages.elasticsearch.org/elasticsearch/1.2/debian stable main
sudo apt-get update
sudo apt-get install elasticsearch
sudo update-rc.d elasticsearch defaults 95 10
@pangkalizer
pangkalizer / gist:fe12759c0cf661490a1a
Created July 17, 2014 07:11
oath2 flow-doorkeeper
http://localhost:3000/oauth/authorize?redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&client_id=e0788a7508a06408a6bf7ea9addbea21c1f54a6b1110e70cd13bd8c53c329ede&response_type=code
http://localhost:3000/oauth/token?redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&client_id=e0788a7508a06408a6bf7ea9addbea21c1f54a6b1110e70cd13bd8c53c329ede&client_secret=1cfe817fb9b4ed9dfffe48cd62c4a58385879eb445c42e3a61bbf4f33eb0f4bc&grant_type=authorization_code&code=f1dd6a64b8ac478275bf7f29830404c9a3fb79f29fc2f29e17637ebed1f8ac8d
$ brew install libmagic
$ brew link libmagic (if the link is already created is going to fail, don't worry about that)
$ env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."