Skip to content

Instantly share code, notes, and snippets.

View trekdemo's full-sized avatar

Gergő Sulymosi trekdemo

View GitHub Profile
@trekdemo
trekdemo / case_eg.rb
Created April 7, 2015 14:46
How to mimic fall through with ruby
# Usage:
# foo('Near the intersection of Lexington Ave and E 40th St')
# # => ['Lexington Ave', 'E 40th St']
# foo('Between Lexington Ave and E 40th St')
# # => ['Lexington Ave', 'E 40th St']
#
def foo(value)
case value
when (re = /^Near the intersection of (.*) and (.*)$/)
when (re = /^Between (.*) and (.*)$/)
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y
sudo apt-get install postgresql-9.3-postgis pgadmin3 postgresql-contrib -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
@trekdemo
trekdemo / git_time_since_commit.fish
Created May 11, 2014 19:48
Fish Shell Snippet to add time since last commit
function _git_branch_name
echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function _git_initialized_repo
test (git rev-parse --git-dir ^/dev/null | wc -l) -gt 0
end
function _git_commit_exists
test (git log ^&1 | grep --count "^fatal") -eq 0
/*
*
* Mongo-Hacker
* MongoDB Shell Enhancements for Hackers
*
* Tyler J. Brock - 2013
*
* http://tylerbrock.github.com/mongo-hacker
*
*/
Before do |scenario|
DeferredGarbageCollection.start
end
After do |scenario|
DeferredGarbageCollection.reconsider
end
at_exit do
DeferredGarbageCollection.stop
@trekdemo
trekdemo / gist:5048069
Created February 27, 2013 13:57
Jobsworth migrations sorted by git authored date
for file in db/migrate/*; do
echo "$(date -r $(git log --format=%at $file | tail -n1) +%Y%m%d%H%M%S) $file";
done;
20070401155320 db/migrate/004_add_timezone.rb
20070401155320 db/migrate/005_user_interface_type.rb
20070401155320 db/migrate/006_user_external_clients.rb
20070401155320 db/migrate/007_user_show_calendar.rb
20070401155320 db/migrate/008_client_css.rb
20070401155320 db/migrate/009_add_tasks_company_id.rb
@trekdemo
trekdemo / cuc
Created February 8, 2013 11:31
Run cucumber and rspec from vim
#!/bin/sh
#
# Run specs with great speed and daring-do.
#
if [ -f zeus.json ]; then
zeus cucumber "$@"
else
bundle exec cucumber "$@"
fi
var canvas, ctx,
W, H, color, c_last;
function init() {
canvas = document.getElementById('c');
ctx = canvas.getContext('2d');
W = window.innerWidth;
H = window.innerHeight;
@trekdemo
trekdemo / aliases.sh
Last active December 12, 2015 00:18
DB dump/restore tools and aliases
# PSQL commands
alias psql-connect-development='psql `basename $PWD`_development'
alias psql-connect-test='psql `basename $PWD`_test'
alias psql-connect='psql-connect-development'
# Bundler aliases
alias be="bundle exec"
alias bi="bundle install"
alias bl="bundle list"
alias bp="bundle package"