Skip to content

Instantly share code, notes, and snippets.

@keithbro
keithbro / commit-msg
Last active November 16, 2017 22:08
Auto-append JIRA ticket codes from the branch name in to commit messages
# Put this in ~/.git-templates/hooks/commit-msg and re-init your git repo.
NAME=$(git branch | grep '* ' | grep -m 1 -o '[A-Z]\+-\d\+')
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$NAME" ] && [ -n "$TEXT" ]
then
echo $(cat "$1" | sed '/^#.*/d')' ['"$NAME"']' > "$1"
fi
@keithbro
keithbro / transduce.t
Created February 6, 2017 13:46
transduce.t
use Test::Most;
use Yoda qw(append compose divide filter flip take transduce);
my $is_even = sub { $_[0] % 2 == 0 };
my $dividend = 100;
my $divisors = [ -25, -20, -10, -5, -2, 0 ];
throws_ok(
sub { Yoda::map(divide($dividend), $divisors) },
@keithbro
keithbro / Ember.Enumerable.invoke.md
Last active October 27, 2015 21:14
Use of .invoke() instead of .forEach()

Did you know?

array.forEach(function(element) {
  element.doSomething(arg1, arg2);
});

Is equivalent to...

@keithbro
keithbro / prepare-commit-msg
Created January 22, 2015 18:48
Automatically add branch ID to commit
#!/bin/bash
# Inspired by http://blog.bartoszmajsak.com/blog/2012/11/07/lazy-developers-toolbox-number-1-prepend-git-commit-messages/
# This way you can customize which branches should be skipped when
# prepending commit message.
#if [ -z "$BRANCHES_TO_SKIP" ]; then
# BRANCHES_TO_SKIP=(master develop test)
#fi
@keithbro
keithbro / index-test.js
Created January 20, 2015 11:23
Example Ember CLI integration test which should pass after running "ember new"
import Ember from "ember";
import { test } from 'ember-qunit';
import startApp from '../helpers/start-app';
var App;
module('An Integration test', {
setup: function() {
App = startApp();
},
teardown: function() {