Skip to content

Instantly share code, notes, and snippets.

@dschneider
dschneider / kill_process_by_name.sh
Created October 26, 2013 16:08
Kill process by name with shell
ps aux | grep PROCESS_NAME | grep -v grep | awk '{print $2}' | xargs kill -9
@dschneider
dschneider / vim_clipboard_instructions
Last active December 26, 2015 12:59
VIM - User system clipboard on Mac OS X
1.) Run in terminal: 'vim --version | grep clipboard'
2.) Make sure the output says +clipboard (-clipboard means it is not installed)
3.) Put the following in your vimrc:
" Enabling clipboard
set clipboard=unnamed
4.) Install vim through homebrew: 'brew install vim'
5.) Put an alias on vim in your bashrc/zshrc: alias vim="/usr/local/Cellar/vim/7.4.052/bin/vim"
6.) Check vim --version for clipboard value again
@dschneider
dschneider / make_s3_dump.sh
Created October 25, 2013 13:56
Make a dump from redis and put it on S3
/opt/redis/bin/redis-cli save
sudo s3cmd put /redis/dump.rdb s3://elastic-cache-snapshots
echo "I AM AMAZING"
@dschneider
dschneider / ruby_magic.rb
Created October 25, 2013 11:44
Mindblowing Ruby magic
tail -f /var/log/app/current |grep ip-11-26-26-121|grep total=|ruby -ane 'p $F.grep(/total/)'
@dschneider
dschneider / nginx_with_lua.sh
Created October 23, 2013 15:20
Install Nginx with Lua module
#!/usr/bin/bash
#
# (Original gist from https://gist.github.com/jmervine/5407622/raw/nginx_w_lua.bash)
set -x
cd /tmp
if ! test -d /usr/local/include/luajit-2.0; then
echo "Installing LuaJIT-2.0.1."
wget "http://luajit.org/download/LuaJIT-2.0.1.tar.gz"
@dschneider
dschneider / sed_replace.sh
Last active December 25, 2015 21:09
Replace value in file with SED
sudo sed -n -i 's/pool\: [0-9]/pool\: '$SIZE'/g' /opt/app/config/database.yml
@dschneider
dschneider / package_installed.sh
Created October 16, 2013 08:44
Determine whether a package is installed or not in a shell script
if dpkg-query -W mysql-client &> /dev/null; then
echo "INSTALLED"
else
echo "NOT INSTALLED"
fi
@dschneider
dschneider / ProviderCallbackApp.rb
Created October 3, 2013 14:17
A small Sinatra app that can be used to catch a service provider callback (e. g. from Facebook, Twitter or Google) using OmniAuth.
require 'sinatra'
require 'omniauth'
# A small Sinatra app that can be used to catch a service provider
# callback (e. g. from Facebook, Twitter or Google) using OmniAuth.
# It can be mounted in the routes. This Sinatra app can be useful
# if you have a Rails API app without any cookies / sessions.
#
# Examples
#
@dschneider
dschneider / Install VIM with X Window support
Created May 12, 2013 11:18
I prefer to use VIM with the system clipboard instead of the regular yank register. Most often this is not enabled on X based systems - here is how to compile it with X support.
# Check for xterm_clipboard support
vim --version
# Get the compile-dependencies of vim
sudo apt-get build-dep vim
# If you haven't got mercurial, get it
sudo apt-get install mercurial
# Get the source
@dschneider
dschneider / rbtrace.txt
Created November 29, 2012 08:00
rbtrace
Redis::Client#process
Redis::Client#logging
Redis::Client#ensure_connected
Redis::Client#connected?
Redis::Connection::Ruby#connected? <0.000003>
Redis::Client#connected? <0.000010>
Process.pid <0.000004>
Array#each
Array#first <0.000003>
Redis::Client#write