Skip to content

Instantly share code, notes, and snippets.

View brysgo's full-sized avatar

Bryan Goldstein brysgo

View GitHub Profile
@brysgo
brysgo / ndb_json.py
Created January 6, 2012 21:47
(THIS IS REALLY OLD AND OUTDATED) A port of the app engine json serializer for NDB.
# Copyright 2008 Google Inc.
#
# 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
# distributed under the License is distributed on an "AS IS" BASIS,
@brysgo
brysgo / gist:5555285
Created May 10, 2013 15:46
Ruby Array XOR
class Array
def xor(other)
self + other - (self & other)
end
end
@brysgo
brysgo / install_command_line_tools_no_prompt
Created February 14, 2014 19:43
Install xcode command line tools without prompt
do shell script "xcode-select --install"
do shell script "sleep 1"
tell application "System Events"
tell process "Install Command Line Developer Tools"
keystroke return
click button "Agree" of window "License Agreement"
end tell
end tell
@brysgo
brysgo / ng_use_default.js.coffee
Last active August 29, 2015 13:57 — forked from nl5887/ng_initial.js
Directive to use the value of the DOM element as the default for an ngModel instead of having to bootstrap from the controller.
@app.directive 'ngUseDefault', ->
restrict: 'A'
controller: ['$scope', '$element', '$attrs', '$parse', ($scope, $element, $attrs, $parse) ->
initialValue = $element.val()
getter = $parse($attrs.ngModel)
setter = getter.assign
setter($scope, initialValue)
]
@brysgo
brysgo / post_checkout_migrations.sh
Last active October 5, 2019 11:13 — forked from skyriverbend/rails_switch_branch.py
Post checkout hook for managing rails migrations and bundle install
CHECKING_OUT_BRANCH=$3
OLD_BRANCH=$1
NEW_BRANCH=$2
if [ $CHECKING_OUT_BRANCH -eq 1 ]
then
FILES_CHANGED=`git diff $OLD_BRANCH $NEW_BRANCH --name-status`
MIGRATIONS_REMOVED=`echo "$FILES_CHANGED" | egrep 'D\tdb/migrate/([0-9]+)' | sort -r`
MIGRATIONS_ADDED=`echo "$FILES_CHANGED" | egrep 'A\tdb/migrate/([0-9]+)'`
@brysgo
brysgo / git_related
Last active August 29, 2015 14:02
List files in git that have historically been changed in the same commit as a given file
@brysgo
brysgo / deliver_tracker_stories.rb
Created November 6, 2014 14:47
Deliver tracker stories finished since last staging deploy
#!/usr/bin/env ruby
require 'pivotal-tracker'
TRACKER_TOKEN = ENV.fetch("TRACKER_TOKEN")
TRACKER_PROJECT_ID = ENV.fetch("TRACKER_PROJECT_ID")
PivotalTracker::Client.token = TRACKER_TOKEN
PivotalTracker::Client.use_ssl = true
project = PivotalTracker::Project.find(TRACKER_PROJECT_ID)
@brysgo
brysgo / yaml_html_table.rb
Last active August 29, 2015 14:11
Parses a yaml file into nested HTML tables with the inline comments displayed as documentation
require 'yaml'
def insert_comments(file)
result = ""
i = 0
file.each_line do |line|
leading_indentation = line[/^\s*/]
comment_split = line.split("#").reverse
if comment_split.length == 2
result += "\n#{leading_indentation}__comment_#{i}: "
@brysgo
brysgo / behavior.rb
Last active August 29, 2015 14:12
Linearly dependant tests in rspec
module BehaviorDSL
def behavior(name, &block)
metadata[:description_args].push(name)
refresh_description
yield
metadata[:description_args].pop
refresh_description
end
private
@brysgo
brysgo / gist:0183a8dded41b1356107
Last active December 27, 2015 23:08 — forked from zmalltalker/gist:5900206
Install ruby-install, chruby and ruby 2.2.0 on Centos - Install puppet - Run `puppet apply <(curl -S https://gist.githubusercontent.com/brysgo/0183a8dded41b1356107/raw/103f4a87ecd143285da444c4e5c24b70680256cb/gistfile1.pp)`
# chruby
# ruby-install
# ruby 2.2.0
# /etc/profile.d/chruby.sh
Exec {
path => ["/bin","/usr/bin", "/usr/local/bin"]
}
file { "/etc/profile.d/chruby.sh":
ensure => present,