Skip to content

Instantly share code, notes, and snippets.

View snowman-repos's full-sized avatar

James snowman-repos

View GitHub Profile
clearfix()
*zoom 1
&:before
content " "
display table
&:after
content " "
display table
clear both
@snowman-repos
snowman-repos / svg-background.styl
Created February 13, 2014 03:19
SVG background images with PNG and retina fallback
$image-path = "../img"
$fallback-extension = "png"
$retina-suffix = "@2x"
background-image($name, $size = false)
background-image url($image-path/$name.svg)
if($size)
background-size $size
.no-svg &
@snowman-repos
snowman-repos / breakpoints.styl
Created February 13, 2014 03:02
Breakpoints
small-width = 30em
medium-width = 60em
large-width = 90em
small = "only screen and (min-width: " + small-width + ")"
medium = "only screen and (min-width: " + medium-width + ")"
large = "only screen and (min-width: " + large-width + ")"
@snowman-repos
snowman-repos / font-size.styl
Created February 13, 2014 02:51
Set a rem font size with pixel fallback
font-size($size = 16)
font-size $size px
font-size ($size / 16) rem
line-height ($size / 16) * 1.624
line-height ($size / 16) * 1.624 rem
@snowman-repos
snowman-repos / telephone-regex.js
Created February 8, 2014 10:47
Telephone number regex
^(\(?\+?[0-9]*\)?\s?)*([0-9]*(\s?\-?)*[0-9]+)+(\s?#[0-9]+)?$
@snowman-repos
snowman-repos / typography.styl
Created February 6, 2014 09:28
Typographic scale
//BODY
body
font-size 100%
body,
h1,
h2,
h3,
h4,
@snowman-repos
snowman-repos / Deal with WebSocket timeout.coffee
Created February 6, 2014 09:08
Deal with WebSocket timeout
timerID = 0
keepAlive = ->
timeout = 15000
webSocket.send "" if webSocket.readyState is webSocket.OPEN
timerId = setTimeout(keepAlive, timeout)
cancelKeepAlive = ->
cancelTimeout timerId if timerId
@snowman-repos
snowman-repos / Rounding number to N decimal place
Created February 6, 2014 08:56
Rounding number to N decimal place
num = 2.443242342
num = num.toFixed(4) # num will be equal to 2.4432
@snowman-repos
snowman-repos / Get the max or the min in an array of numbers
Created February 6, 2014 08:55
Get the max or the min in an array of numbers
numbers = [
5
458
120
-215
228
400
122205
-85411
]
@snowman-repos
snowman-repos / Verify that a given argument is an array
Created February 6, 2014 08:54
Verify that a given argument is an array
isArray = (obj) ->
Object::toString.call(obj) is "[object Array]"