Skip to content

Instantly share code, notes, and snippets.

View bhcleek's full-sized avatar

Billie Cleek bhcleek

View GitHub Profile
@bhcleek
bhcleek / edit-in-place.coffee
Created January 7, 2013 17:56
Edit in Place
# tlInPlaceEdit controls toggling between a view mode and an edit mode by specifying an edit and a view template.
#
# Before using the tlInPlaceEdit directive, consider whether it would be better to use proper routing to control the client
#
# <tl-in-place-edit success-event-object="object" success-event-key="interpolated string" success-event="event that is raised when save succeeds">
# <editor></editor>
# <view></view>
# </tl-in-place-editor>
# tl-in-place-edit@successEvent = The name of the event to which an event listener will be hooked up to switch
# back to view mode after the submit method succeeds.
@bhcleek
bhcleek / sync.sh
Created January 8, 2013 05:43 — forked from anonymous/sync.sh
Create a directory of hardlinks to files referenced in an m3u playlist.
#/bin/sh
ROOTDIR=/media/storage/sounds
pushd "${ROOTDIR}"
grep -v '^#' music/Checked.m3u | sed -e 's./Volumes/storage/sounds/..' | \
while read TRACK
do
if [ -e "${TRACK}" ]
then
@bhcleek
bhcleek / gist:5120162
Created March 8, 2013 21:47
Platform agnostic example of grunt-exec
exec:
run_server_tests:
command: () ->
path = require 'path'
testCommand = path.resolve 'path', 'to', 'something'
testCommandArgs = []
testCommandArgs.push 'arg1'
testCommandArgs.push 'arg2'
testCommandArgs.push 'arg3'
@bhcleek
bhcleek / recover-index.md
Last active November 6, 2022 11:09
recover lost index

to recover files that were added to the index but whose changes were lost (e.g. git reset --hard)

git fsck --unreachable | grep commit | cut -d\  -f3 | xargs git show
  1. git fsck --unreachable to get all the items that are unreachable
  2. grep commit to filter out all entries except for commits (the index will show up as a commit)
  3. cut -d\ -f3 to filter out all but the SHA1s
  4. xargs git show to show all of the contents of the objects.

Once you've identified the SHA1 that contains the changes that were lost, check it out to get the working tree back into the state of the index at the time git reset --hard was run.

#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
#cloud-config
hostname: core0
ssh_authorized _keys:
- ssh-rsa AAAAB3NzaC1yc2...
coreos:
etcd:
# generate a new token for each unique cluster from https://discovery.etcd.io/new
name: core0
discovery: https://discovery.etcd.io/dead0b52c8704ad95ac9681b4550247e
@bhcleek
bhcleek / Makefile
Last active October 2, 2018 16:42
Go TeamCity Reporter
SHELL = /bin/sh
PKGS := $(shell go list ./... | grep -v /vendor/)
CMDS := $(notdir $(shell go list -f '{{if eq .Name "main"}}{{.ImportPath}}{{end}}' ./cmd/...))
GO_FILES := $(shell go list -f '{{$$dir := .Dir}}{{range .GoFiles}}{{print $$dir "/" . "\n"}}{{end}}{{range .TestGoFiles}}{{print $$dir "/" . "\n"}}{{end}}' ./... | grep -v /vendor/)
GO_VENDOR_FILES := $(shell go list -f '{{$$dir := .Dir}}{{range .GoFiles}}{{print $$dir "/" . "\n"}}{{end}}' ./vendor/...)
WORK := $(shell mktemp -d)
CMD_ROOT := __MY_PROJECT__
go_cmd_deps = $(shell go list -f '{{$$dir := .Dir}}{{range .GoFiles}}{{print $$dir "/" . "\n"}}{{end}}' ./cmd/$(1)) $(shell go list -f '{{join .Deps "\n"}}' ./cmd/$(1) | grep -E '^$(CMD_ROOT)(/.*)?$$' | xargs go list -f '{{$$dir := .Dir}}{{range .GoFiles}}{{print $$dir "/" . "\n"}}{{end}}')
@bhcleek
bhcleek / waitfor.sh
Last active August 29, 2015 14:14
waitfor.sh
PIPE=$(mktemp -d -t pipe.XXXXXX) && mkfifo $PIPE/pipe && exec 3<> $PIPE/pipe && rm -rf $PIPE
OUTPUTTER &>&3 & # substitute OUTPUTTER for the command whose output should be awaited
LOG_PID=$!
grep -m1 "$1" <&3
kill -SIGTERM $LOG_PID
exec 3<&- #close our pipe
@bhcleek
bhcleek / linux-osx.mktemp.sh
Last active April 19, 2016 04:12
linux-osx.mktemp.sh
# try to create a temporary directory on osx first.
# `mktemp -d` works on OSX and Linux The basename will be random:
TMPDIR=$(mktemp -d)
# `mktemp -d -t FOO` is valid on OSX and uses TMPDIR, but will cause an error on Linux.
# `mktemp -d -t FOO.XXXXXX is valid on both: on Linux will do substitution of the Xs; but on OSX, the Xs are taken literally.
TMPDIR=$(mktemp -d -t ${PREFIX} 2>/dev/null || mktemp -d -t ${PREFIX}.XXXXXX)
# this can be shorted to
TMPDIR=$(mktemp -d "${TMPDIR-:/tmp/}$PREFIX.XXXXXX")