Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -e
# cd to /vagrant on login
if ! grep -q 'cd \/vagrant' /home/vagrant/.bashrc; then
echo 'cd /vagrant' >> /home/vagrant/.bashrc
fi
cd /vagrant
#!/usr/bin/env ruby
# Map endpoint names to regexes that match them
Endpoints = {
'/api/users/{user_id}/count_pending_messages' => /^\/api\/users\/(?<user_id>\d+)\/count_pending_messages$/,
'/api/users/{user_id}/get_messages' => /^\/api\/users\/(?<user_id>\d+)\/get_messages$/,
'/api/users/{user_id}/get_friends_progress' => /^\/api\/users\/(?<user_id>\d+)\/get_friends_progress$/,
'/api/users/{user_id}/get_friends_score' => /^\/api\/users\/(?<user_id>\d+)\/get_friends_score$/,
'/api/users/{user_id}' => /^\/api\/users\/(?<user_id>\d+)$/,
}
@omarkhan
omarkhan / yaml2json
Created May 20, 2014 04:14
yaml in, json out
#!/usr/bin/env python
import json
import yaml
def convert(stream):
return json.dumps(yaml.load(stream), indent=2)
if __name__ == '__main__':
import sys
@omarkhan
omarkhan / gist:4233634
Created December 7, 2012 14:36
Procfile parsing in python
import shlex
def parse_procfile(filename):
"""
Return a dict of procfile process names to commands, e.g.
{'web': ['python', './manage.py', 'runserver']}
"""
commands = {}
@omarkhan
omarkhan / gist:2843912
Created May 31, 2012 14:49
Elasticsearch: very long snippets
# Put a document into the index
curl -s -XPUT 'localhost:9200/test/doc/1' -d '{
"text": "Search Advanced Search NAVIGATION Home Government in Action Economy Infrastructures Power, Oil & Gas National Security Rule of Law & Good Governance Education Healthcare Delivery Food Security Diplomacy Anti Corruption Politics and Power Environment Other News News Summary Matters of the Moment Photographs Speeches Last Updated: May 11th, 2012 - 16:13:24 Photographs President Goodluck Jonathan at the 2012 World Economic Forum on Africa in Addis Ababa Photographs of President Goodluck Jonathan at the 2012 World Economic Forum on Africa, in Addis Ababa, Ethiopia, May 9 - 11, 2012 May 11, 2012, 14:22 President Goodluck Jonathan in Abidjan for a one-day visit Photograph of President Goodluck Jonathan in Abidjan, Cote d'\''Ivoire, on a one-day visit, on Wednesday, May 9, 2012 May 9, 2012, 20:58 President Goodluck Jonathan at the Presidential workshop on Power President Goodluck Jonathan at the Presidential Workshop on Power
@omarkhan
omarkhan / .ctags
Created July 28, 2011 13:17
ctags definition for CoffeeScript, including only top-level classes and functions
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/^class ([A-Za-z.]+)( extends [A-Za-z.]+)?$/\1/c,class/
--regex-coffee=/^([A-Za-z.]+) = .*[-=]>.*$/\1/f,function/