View slack-custom.css
/* | |
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 |
View rails_session_decoding.rb
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) |
View call_original_method_method.rb
#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) |
View csrf.js
$.ajaxSetup( { | |
beforeSend: function ( xhr ) { | |
var token = $( 'meta[name="csrf-token"]' ).attr('content'); | |
xhr.setRequestHeader( 'X-CSRF-Token', token ); | |
} | |
}); |
View .slate
# 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 |
View named_and_not_params.rb
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] |
View github.com.js
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'); | |
View .ruby-gemset
gemset_empty_bug |
View heroku-github-aliases
#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' |
View custom_gemfile_name.sh
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