This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright 2017 Bryan Keller (https://github.com/widget-) | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decrypt_session(session_cookie) | |
secret_key_base = Rails.application.secrets.secret_key_base | |
cookie = CGI::unescape(session_cookie) | |
salt = 'encrypted cookie' | |
signed_salt = 'signed encrypted cookie' | |
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000) | |
secret = key_generator.generate_key(salt) | |
sign_secret = key_generator.generate_key(signed_salt) | |
encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I want to call @request.method(:remote_ip) to find out where it's defined using Object#method method. | |
#But that's been overriden so that you can find out which HTTP verb was used (GET/POST/etc) | |
module ObjectMethod | |
def object_method(name) | |
Object.instance_method(:method).bind(self).call(name) | |
end | |
end | |
Object.include(ObjectMethod) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajaxSetup( { | |
beforeSend: function ( xhr ) { | |
var token = $( 'meta[name="csrf-token"]' ).attr('content'); | |
xhr.setRequestHeader( 'X-CSRF-Token', token ); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the default .slate file. | |
# If no ~/.slate file exists this is the file that will be used. | |
config defaultToCurrentScreen true | |
config nudgePercentOf screenSize | |
config resizePercentOf screenSize | |
config windowHintsShowIcons true | |
#config windowHintsIgnoreHiddenWindows false | |
config windowHintsDuration 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(x=nil, a: x, b: nil) | |
[a,b] | |
end | |
#one, un-named arg assigns to a | |
foo("a val") # => ["a val", nil] | |
#named parameter "a" assigns to a | |
foo(a: "a val") # => ["a val", nil] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var num_commits = parseInt($('#commits_tab_counter').text()); | |
var button = $("div.merge-message > button"); | |
if (num_commits > 1) { | |
console.log("disabling"); | |
button.attr('disabled','disabled'); | |
button.text("Squash those commits!"); | |
div = $("div.merge-message"); | |
div.append("<button class='btn btn-primary' id='enable_merge' style='float:right;' type='button'>Override</button>"); | |
enable_button = $('button#enable_merge'); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gemset_empty_bug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Usage: | |
#git heroku-prod-diff #display a diff locally | |
#git compare-heroku #displays a diff on github, requires hub (https://hub.github.com/) | |
heroku-prod-deployed-commit = !sh -c 'heroku releases -r production | grep Deploy | tr -s \" \" | cut -d \" \" -f 3 | head -n 1' - | |
heroku-prod-diff = !sh -c 'git diff $(git heroku-prod-deployed-commit)..master' | |
#requires hub | |
compare-heroku = !sh -c 'hub compare $(git heroku-prod-deployed-commit)..master' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p ~/tmp/testapp | |
cd ~/tmp/testapp | |
echo "source 'https://rubygems.org'" >> Gemfile | |
echo "gem 'rake'" >> Gemfile | |
ln -sf Gemfile MyGemfile | |
bundle config --local gemfile ~/tmp/testapp/MyGemfile |
NewerOlder