Skip to content

Instantly share code, notes, and snippets.

Brooks Swinnerton bswinnerton

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am bswinnerton on github.
  • I am bswinnerton (https://keybase.io/bswinnerton) on keybase.
  • I have a public key whose fingerprint is B157 7B86 DC69 A3D1 AA57 3178 7274 3B7D E552 E25A

To claim this, I am signing this object:

@bswinnerton
bswinnerton / git-commit-editor.vim
Created Feb 18, 2017 — forked from aroben/git-commit-editor.vim
Vim script to show git commit diff in vertical split while writing commit messages
View git-commit-editor.vim
" Put this in your .vimrc and whenever you `git commit` you'll see the diff of your commit next to your commit message.
" For the most accurate diffs, use `git config --global commit.verbose true`
" BufRead seems more appropriate here but for some reason the final `wincmd p` doesn't work if we do that.
autocmd VimEnter COMMIT_EDITMSG call OpenCommitMessageDiff()
function OpenCommitMessageDiff()
" Save the contents of the z register
let old_z = getreg("z")
let old_z_type = getregtype("z")
View serializable_attributes.rb
module SerializableAttributes
extend ActiveSupport::Concern
included do
class << self
attr_reader :serializable_column
end
before_save :update_serializable_column
View warden_jwt.rb
require 'jwt'
require 'warden'
class JWTStrategy < Warden::Strategies::Base
# All of the below constants would be defined in a configuration initializer
ENCRYPTION_ALGORITHM = 'HS256'
RETRIEVE_USER = Proc.new { |guid| User.find_by(user_guid: guid) }
SHARED_SECRET = 'kittens'
USER_IDENTIFIER_CLAIM = 'guid'
View jwt_with_shared_secret.rb
################################################################################
# On Authorization Server #
################################################################################
require 'jwt'
SHARED_SECRET = 'kittens'
SIGNING_ALGORITHM = 'HS256'
# User has authenticated: we know who they are
View jwt_with_assymetric_keys.rb
################################################################################
# On Authorization Server #
################################################################################
require 'openssl'
require 'jwt'
SIGNING_ALGORITHM = 'RS256'
KEY = OpenSSL::PKey::RSA.generate(2048)
View daniella.cypher
MATCH (user)--(connection)
WHERE user:FacebookAccount OR user:GeneralAssemblyAccount
AND user.user_id = 246
RETURN user, connection;
View symbolizer.rb
# Toto, we're not in Kansas anymore.
#
# This singleton is used to deeply convert all instances of a String into a
# Symbol given an Array, Hash, or a lonesome String.
module Symbolizer
def self.deep_symbolize(object)
case object
when Array
deep_symbolize_array(object)
when Hash
@bswinnerton
bswinnerton / README.md
Last active Aug 29, 2015
Google Maps partial for Rails
View README.md

Google Maps partial for Rails

In your view:

app/views/cats/index.html.erb

<%= render 'map', collection: @cats %>
View .bash_history
sudo apt-get update
sudo apt-get upgrade
exit
sudo apt-get install build-essential git-core curl vim
curl -sSL https://get.rvm.io | bash -s stable --ruby
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
sudo apt-get install zsh
rm -rf ~/.oh-my-zsh/
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
chsh `which zsh`
You can’t perform that action at this time.