Skip to content

Instantly share code, notes, and snippets.

View trekdemo's full-sized avatar

Gergő Sulymosi trekdemo

View GitHub Profile
@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"
@trekdemo
trekdemo / rendering.rb
Last active December 11, 2015 04:58
Override rails 3.0.17 partial rendering to get information about the partial we render
# Override rails 3.0.17 partial rendering to get information
# about the partial we render
# put it into config/initializers/rendering.rb
module ActionView
module Rendering
def _render_partial(options, &block)
"<b style='float:left;' title='h#{CGI::escapeHTML options.inspect.html_safe}'>*</b>".html_safe +
super
end
end
@trekdemo
trekdemo / drop_connections.rake
Created November 13, 2012 13:11
Drop postgres connections to a database in a Rails application
namespace :db do
desc 'Drop all database connections'
task :drop_connections => :environment do
database = Rails::Application.config.database_configuration[RAILS_ENV]["database"]
field = if ActiveRecord::Base.connection.send( :postgresql_version ) < 90200
'pg_stat_activity.procpic' # PostgreSQL <= 9.1.x
else
'pg_stat_activity.pid' # PostgreSQL >= 9.2.x
end