Skip to content

Instantly share code, notes, and snippets.

View ratbeard's full-sized avatar

Mike Frawley ratbeard

View GitHub Profile
module.exports = (generate) ->
{register, copy, mkdir, set, camelcase} = generate
# Register all generators in 1 file
# Templates are run through a <%= %>
# args are automatically 'set' and available inside templates
# extend string prototype w/ handy helpers
# need a --dry-run options
register(name: "bot", args: "<name>", run: (args) ->
mkdir("src/bots/<%= name.camelcase %>")
@ratbeard
ratbeard / rat.coffee
Last active August 29, 2015 13:56
measure angular digest times and periodically log out stats
application.config(($provide) ->
# Add timing around $digest()
window.digestStats = new DigestStats
$provide.decorator("$rootScope", ($delegate) ->
$digest = $delegate.$digest.bind($delegate)
$delegate.$digest = ->
startedAt = performance.now()
$digest()
digestStats.addDuration(performance.now() - startedAt)
@ratbeard
ratbeard / gulpfile.coffee
Last active August 29, 2015 13:56
gulp if issue
src("coffee")
# For source maps we also need to move the coffee files into build
.pipe(gulpif(isDev, dest("build.coffee")))
.pipe(plumber())
.pipe(print())
.pipe(logErrors(coffee(sourceMap: isDev)))
.pipe(dest("build.coffee"))
# When isDev is true, only .coffee files ends up in build dir, no .js or .map files.
# print() prints out no files, its as if the pipeline chain halts
qrequest = require("request")
http = require('http')
fs = require('fs')
through = require('through')
split = require('split')
concat = require('concat-stream')
ws = require("websocket-stream")
trumpet = require('trumpet')()
spawn = require('child_process').spawn
duplexer = require('duplexer')
@ratbeard
ratbeard / gist:2655811a397c361746f9
Created July 8, 2014 21:04
disable-ng-animate classNameFilter
// This allows adding a class of `disable-ng-animate` to an element so that
// $animate won't attempt to add its animation hooks. This is useful when an
// element has animations applied via css classes, which can confuse
// directives like ng-repeat and ng-show sometimes.
app.config( [
'$animateProvider',
function ($animateProvider) {
$animateProvider.classNameFilter(/^((?!disable-ng-animate).)*$/)
link: function( $scope, $element ) {
var initialize, initializeRounds, initializeQuestionsCarousel // <--- dese are functions
var gameResult, didUserWin, user, opponent, questionsCarouselElement, userPointsPerRound, opponentPointsPerRound // <-- dese are data
@ratbeard
ratbeard / _.md
Last active August 29, 2015 14:05
Clean up jasmine output with sed

before: before

after: after

GET /people.json
[
{
// global props
id: 1
name: 'foo',
image: '...',
# Fetch latest and prints the branch name with the most recent commit¬
br = "!git fetch && git for-each-ref --count=1 --sort=-committerdate refs/remotes/ --format='%(refname:short)' | sed -e \"s/^.*\\//
¬
# Switch to branch with most recent commit¬
cor = "!git checkout `git br`"¬
¬
#!/bin/bash
if [ -z "${SAUCE_USERNAME}" ] || [ -z "${SAUCE_ACCESS_KEY}" ]; then
echo "This script can't run without your Sauce credentials"
echo "Please set SAUCE_USERNAME and SAUCE_ACCESS_KEY env variables"
echo "export SAUCE_USERNAME=ur-username"
echo "export SAUCE_ACCESS_KEY=ur-access-key"
exit 1
fi
SAUCE_TMP_DIR="$(mktemp -d -t sc.XXXX)"