Skip to content

Instantly share code, notes, and snippets.

View defaye's full-sized avatar

Jono Feist defaye

  • England
View GitHub Profile
@sunny
sunny / git-checkout.rake
Last active August 19, 2022 10:04 — forked from skyriverbend/rails_switch_branch.py
Task to checkout a branch in rails and apply or rollback the migrations between the two.
# encoding: UTF-8
#
# $ rake checkout new_branch_name
#
# Via https://gist.github.com/jonlemmon/4076864
#
# 1. Roll back any migrations on your current branch which do not exist on the
# other branch
# 2. Discard any changes to the db/schema.rb file
# 3. Check out the other branch
@jordelver
jordelver / gist:3790808
Created September 26, 2012 21:45
Destructuring assignment in Ruby and splats!
# Destructuring assignment in Ruby
# http://po-ru.com/diary/destructuring-assignment-in-ruby/
numbers = [ 1, 2, 3, 4, 5]
=> [1, 2, 3, 4, 5]
# Destructuring assignment
a, b, c = numbers
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active April 23, 2024 19:14
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@kinopyo
kinopyo / gist:2343176
Created April 9, 2012 12:37
Override Devise RegistrationsController, override redirect path after updating user

Override Devise RegistrationsController

Overview

Here I'll show you

  • How to override devise registrations_controller(related to create/update user account)
  • How to change redirect path after updating user

Override RegistrationsController

@jcamenisch
jcamenisch / .profile fragment
Created January 24, 2012 19:19
Lightning-fast project-wide find/replace with git grep and sed
gg_replace() {
if [[ "$#" == "0" ]]; then
echo 'Usage:'
echo ' gg_replace term replacement file_mask'
echo
echo 'Example:'
echo ' gg_replace cappuchino cappuccino *.html'
echo
else
find=$1; shift
@basuke
basuke / gen-security.php
Created April 20, 2011 10:08
Generate CakePHP configuration value for security, Security.salt and Security.cipherSeed.
<?php
$salt = genrandom(40);
$seed = genrandom(29, "0123456789");
echo "\tConfigure::write('Security.salt', '$salt');\n";
echo "\tConfigure::write('Security.cipherSeed', '$seed');\n";
function genrandom($len, $salt = null) {
if (empty($salt)) {