Skip to content

Instantly share code, notes, and snippets.

# from https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/git.zsh
function git_current_branch() {
local ref
ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}

Keybase proof

I hereby claim:

  • I am camerond on github.
  • I am camerondaigle (https://keybase.io/camerondaigle) on keybase.
  • I have a public key ASBjtz752LKaEFZ2gsZDOzKJAYFrgfbz1yehNSkI67DLUwo

To claim this, I am signing this object:

@camerond
camerond / tinygrid.sass
Last active September 22, 2015 20:03
tinygrid
// tiny grid system
// generates ad-hoc responsive columns
// used along with cask.sass
// proof-of-concept at best
$row-class-name: row !default
$row-gutter: 2rem !default
%column-base
display: table-cell
@camerond
camerond / gist:2c914aff621e9e0d4673
Created June 17, 2015 17:29
Static UI for default Kaminari markup
%nav.pagination
%span.first= link_to "« First".html_safe, "#"
%span.prev= link_to "‹ Prev".html_safe, "#"
%span.page.gap …
- (5..8).each do |n|
%span.page= link_to n, "#"
%span.page.current 9
- (10..13).each do |n|
%span.page= link_to n, "#"
%span.page.gap …
@camerond
camerond / _inheritance.sass
Last active January 31, 2016 17:53
Classical mixin inheritance in Sass
$global_store: ()
= override($args:(), $is_child:true)
@if $is_child
$global_store: () !global
$global_store: map-merge($global_store, $args) !global
= default($key_or_map, $value:null)
@if $value
+store-default($key_or_map, $value)
@camerond
camerond / gist:9003958
Created February 14, 2014 16:17
$(':absfocus') selector for inactive windows
// Finds focused elements on page even if the browser window isn't active.
// Useful for headless testing or QUnit tests or whatever.
//
// I couldn't get https://github.com/mattheworiordan/jquery-focus-selenium-webkit-fix
// to behave in jQuery 2.0, so this is a secondary selector created using
// Sizzle's (relatively) new createPseudo method.
//
// I'd prefer to rewrite :focus but couldn't get that to work either.
// Look, this works and I'm moving on.
@camerond
camerond / cask.sass
Last active December 31, 2015 18:59
// cask.sass
// simple responsive mixins
$site-width-max: 1400px !default
$site-width-mid: 800px !default
$site-width-narrow: 480px !default
= min-width($width)
@media screen and (min-width: #{$width})
@content
@camerond
camerond / whitespace-reset.sass
Last active March 5, 2016 21:39
Tantek Celik's Whitespace Reset in SASS
// Tantek Celik's Whitespace Reset
// Author: Tantek Celik, Shane Riley
// Version: (CC) 2010 Some Rights Reserved - http://creativecommons.org/licenses/by/2.0
// Description: Resets default styling of common browsers to a common base
ul,ol
list-style: none
h1,h2,h3,h4,h5,h6,pre,code
font-size: 1em
ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input,dl,dt,dd, figure, figcaption, button
@camerond
camerond / qunit_helpers.coffee
Last active December 29, 2015 00:19
Qunit helper assertions, e.g. $.shouldBe('.awesome')
# Used by assertions.
# $("<div class='hammer'>Pants</div>").selectorText()
# outputs the following:
# "%div.hammer with text of 'Pants'"
$.fn.selectorText = () ->
selector = "%#{@[0].tagName.toLowerCase()}"
@attr('id') && selector += "##{@.attr('id')}"
@attr('class') && selector += ".#{@.attr('class')}"
text = if @text().length > 20 then "#{@text().slice(0, 20)}..." else @text()
@camerond
camerond / spectrum.sass
Created November 1, 2013 15:43
Color spectrum from grey through to pink (weather radar style), from .h0 to .h100
$colors: #a0a0a0, #4fb848, #d2be11, #e51b24, #f749fa
@for $i from 0 through 3
@for $j from 0 through 25
.h#{25*$i+$j}
background: mix(nth($colors, $i+2), nth($colors, $i+1), (($j/25) * 100))