Skip to content

Instantly share code, notes, and snippets.

View marshall007's full-sized avatar

Marshall Cottrell marshall007

View GitHub Profile
ico($c, $aliases...)
&.{join(',&.', $aliases)}
&:before
content $c
i
ico('\E211', 'arrow-left') /* formerly left-arrow */
ico('\E212', 'arrow-right') /* formerly right-arrow */
ico('\E200', 'ban', 'restricted')
ico('\E090', 'building')
&.nxt
$size = 22px
font-size $size
height $size
width $size
display inline-block
overflow hidden
position relative
@marshall007
marshall007 / retry-promise.coffee
Created July 28, 2014 20:15
Retries with exponential backoff using Bluebird
_ = require 'lodash'
Promise = require 'bluebird'
Promise.retry = (action, options = {}) ->
_.merge
max: 5
backoff: 500
, options
d = Promise.defer()
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>

using .coerceTo('array')

  • Collections.get: 12561ms
  • Collections.get: 12592ms
  • Collections.get: 12242ms
  • Collections.get: 13111ms
  • Collections.get: 12918ms

# before
r.table('replications')
.getAll(lab_id, index: 'lab_id')
.groupedMapReduce(
r.row('source_id'),
r.row.pluck('id', 'created'),
(acc, row) ->
r.branch acc('created').gt(row('created')), acc, row
)
WILL_REJECT = true
a = ->
foo = q.defer()
if WILL_REJECT
foo.reject()
else
foo.resolve()
return foo.promise
angular.module('catalog-diff')
.directive 'scheduleHeatmap', ->
margin =
top: 30
right: 0
bottom: 30
left: 30
@marshall007
marshall007 / .slate
Last active November 17, 2016 22:46
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# bind tab:cmd switch
# Push Bindings
bind right:ctrl;alt;cmd push right bar-resize:screenSizeX/2
bind left:ctrl;alt;cmd push left bar-resize:screenSizeX/2
@marshall007
marshall007 / acronym.coffee
Last active March 6, 2016 15:30
AngularJS filter for displaying acronyms.
## Examples
#
# "Turn Around Low" | acronym -> "TAL"
# "turn_around.low" | acronym -> "TAL"
# "list_price" | acronym -> "LP"
# "name" | acronym -> "N"
# "name" | acronym:2 -> "NA"