Skip to content

Instantly share code, notes, and snippets.

@mahemoff
mahemoff / unicorn
Last active August 29, 2015 13:57 — forked from ethier/gist:7190310
Update the upgrade function - it captures the old PID before it's overwritten by the upgrade (ie USR2 signal), then kills it once the upgrade has succeeded
#!/bin/sh
# forked from https://gist.github.com/ethier/7190310
# via http://uncorruptedstate.com/blog/2013/10/27/zero-downtime-deployment-with-rails-and-unicorn/
### Unicorn variables ###
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/web/current
UNICORN=$APP_ROOT/bin/unicorn
TMP_PATH=$APP_ROOT/tmp
PID_PATH=$APP_ROOT/tmp/pids
@mahemoff
mahemoff / ask-wikipedia.rb
Last active August 29, 2015 13:56 — forked from emad-elsaid/ask-wikipedia.rb
Refactor processing, make script standalone with initial env, add command-line argument
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
language = 'en'
article = ARGV[0] ||
begin
print 'What do you need to know? : '
URI::encode gets.chomp
@mahemoff
mahemoff / private.xml
Last active December 15, 2015 16:19 — forked from burtlo/private.xml
(1) Updated to support iTerm (2) Added second mapping for backtick -> ctrl-A. This is useful for running an "inner" tmux session on remote shell. You'll need to ensure the remote shell's .tmux.conf is setup for ctrl-A as prefix (https://wiki.archlinux.org/index.php/tmux#Key_bindings) (3) Since we can no longer use backtick key, we need another m…
<?xml version="1.0"?>
<root>
<appdef>
<appname>Terminal</appname>
<equal>com.apple.Terminal</equal>
<equal>iTerm</equal>
<equal>net.sourceforge.iTerm</equal>
<equal>com.googlecode.iterm2</equal>
</appdef>
<item>
@mahemoff
mahemoff / mousetrap-bind.js
Created November 6, 2012 00:42 — forked from ccampbell/mousetrap-bind.js
Extends mousetrap.js to support passing a dictionary into bind method. Just include this js after you include mousetrap.
/**
* Overwrites default Mousetrap.bind method to optionally accept
* an object to bind multiple key events in a single call
*
* You can pass it in like:
*
* Mousetrap.bind({
* 'a': function() { console.log('a'); },
* 'b': function() { console.log('b'); }
* });
@mahemoff
mahemoff / elasticsearch.rake
Created September 19, 2012 19:36 — forked from jarosan/elasticsearch.rake
Elasticsearch reindex task
# Run with: rake environment elasticsearch:reindex
# Begins by creating the index using tire:import command. This will create the "official" index name, e.g. "person" each time.
# Then we rename it to, e.g. "person20121001" and alias "person" to it.
namespace :elasticsearch do
desc "re-index elasticsearch"
task :reindex => :environment do
klasses = [Place, Person, Caption]
@mahemoff
mahemoff / grunt-wat.js
Created April 25, 2012 00:05 — forked from cowboy/grunt-wat.js
I'm not even joking.
// This was what I got, pasted into an email.
// v0.0.0.2 Robust version with namespacing
module.exports = function(grunt) {
//Grunt Globals
com.wtfjs.constants = new Array();
com.wtfjs.constants.ConcatOutputFileNameAndLocation="c:\\TestOutput.js";
com.wtfjs.constants.JavascriptDirectory = 'C:\\Work\\Patch29\\StaticContent\\RootAssets\\JsLib'
com.wtfjs.constants.MessageTaskStart = "StartingTask_";
com.wtfjs.constants.MessageTaskEnd = "EndingTask_";
@mahemoff
mahemoff / LICENSE.txt
Created November 19, 2011 01:28 — forked from sebastien-p/LICENSE.txt
base62 encode
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Sebastien P. https://twitter.com/#!/_sebastienp
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE