Skip to content

Instantly share code, notes, and snippets.

View brysgo's full-sized avatar

Bryan Goldstein brysgo

View GitHub Profile
@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 / 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 / Wavy Loading Animations.markdown
Created July 10, 2015 16:08
Wavy Loading Animations
@brysgo
brysgo / Advert.js
Created July 26, 2015 02:40
Example of using Relay inspired framework `react-transmit` with temporary client side state.
// src/views/Advert.js
import __fetch from "isomorphic-fetch";
import React from "react";
import Transmit from "react-transmit";
import AdvertStore from "stores/AdvertStore";
import _ from "utils/Utils";
class Advert extends React.Component {
render () {
return (
@brysgo
brysgo / graffitiMongoose.js
Created July 31, 2015 16:31
Hack to add subdocuments to graffiti schema.
import {getTypes} from '@risingstack/graffiti-mongoose';
import Models, { User } from '../mongoose';
import Subdocuments from './subdocuments';
let types = getTypes(Models)
let UserType = types.User;
// FIXME: Hack subdocument for now
Object.assign(UserType._typeConfig.fields, {
bestFriend: Subdocuments.singular(User, UserType),
@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:e414fb63752f07736aa0
Last active October 15, 2015 19:43
_bitriseCustomScript.sh
#!/bin/bash
npm install react-native
echo "."