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
<?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)) { |
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 |
-- 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%' |
# 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 |
# 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 |
#!/bin/sh | |
exec < /dev/tty | |
./.git/hooks/validate_commit.rb $1 |
# name: discourse-steam | |
# about: VALVE's Steam login support for Discourse | |
# version: 0.0.1 | |
# authors: Colin Shea | |
auth_provider :title => 'with Steam', | |
:authenticator => Auth::OpenIdAuthenticator.new('steam','http://steamcommunity.com/openid', trusted: true), | |
:message => 'Authenticating with Steam (make sure pop up blockers are not enabled)', | |
:frame_width => 1000, # the frame size used for the pop up window, overrides default | |
:frame_height => 800 |
<?php | |
// Requires PHP 5.3+ | |
// Found here: http://stackoverflow.com/a/1320156 | |
function flatten_array(array $array) { | |
$flattened_array = array(); | |
array_walk_recursive($array, function($a) use (&$flattened_array) { $flattened_array[] = $a; }); | |
return $flattened_array; | |
} |
// takes a {} object and returns a FormData object | |
var objectToFormData = function(obj, form, namespace) { | |
var fd = form || new FormData(); | |
var formKey; | |
for(var property in obj) { | |
if(obj.hasOwnProperty(property)) { | |
if(namespace) { |