Skip to content

Instantly share code, notes, and snippets.

:shipit:
ship it

Michael Scott Hertzberg moimikey

:shipit:
ship it
Block or report user

Report or block moimikey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View encode.coffee
Util.encodeRFC5987 = (string) ->
encodeURIComponent(string)
# Note that although RFC3986 reserves "!", RFC5987 does not,
# so we do not need to escape it
.replace(/['()]/g, escape)
.replace(/\*/g, '%2A')
# The following are not required for percent-encoding per RFC5987,
# so we can allow for a little better readability over the wire: |`^
.replace(/%(?:7C|60|5E)/g, unescape)
View gist:9838739
 ⌘ ★ “ ” ‘ ’ ❝ ❞ ✔ × ✖ ✗ ✕ ⓧ ⊗ ⊕ ⊖ ⊙ ⊠ ⊡ ≠ ℻ © ® ← ↑ ↓ → ❮ ❯ ◄ ◂ ▸ ▷ ▹ ⌃ ¹ ² ³ ⁂ ▣ ⬚ Ⓜ ⓜ ⒨ ꟿ ṃ ♻ ♺
View fof.coffee
# Hide elements via selectors.
#
# Works wonderfully to block facebook ads which are
# pre-loaded ;o zomg
#
# Probably won't often update this gist, but selectors
# simply need to be added to @patterns
#
# You can avoid the transpile if you run this using
# the Injector, chrome extension. s'what I use.
View toHMS.coffee
# Convert int|float from seconds into formatted
# duration timestamp
#
# deps: underscore or lodash or any other library
# that takes over window._ and provides a
# #.compact() method. dep could ultimately
# be removed...
#
# uses double bitwise not `~~` as `Math.floor`
# uses `+` as type coercion to `int`
View dataToCanvas.coffee
# Converts a data image uri to canvas image
#
# reader = new FileReader()
# reader.onload = (evt) =>
# App.Util.dataToCanvas evt, el: @ui.thumb, width: 80, height: 40
# reader.readAsDataURL(...)
#
# @ui.thumb = jquery selector
# ultimately the jquery dependency can be 86ed from this...
#
View scaleProportion.coffee
# Returns an object with a new width and height
# constraining the proportions of the given max width
# and max height
#
# examples:
# Util.scaleProportion(200, 200, 2000, 2000);
# > Object {width: 200, height: 200}
# scaleProportion(200, 200, 2582, 2394)
# > Object {width: 200, height: 185}
#
@moimikey
moimikey / array_reverse.js
Last active Aug 29, 2015
reversing an array, the fast and simple way!
View array_reverse.js
var i, arr = [1, 2, 3, 4, 5, 6, 7, 8];
for(i = 0; i < arr.length / 2; i++) {
var temp = arr[i];
arr[i] = arr[arr.length - i - 1]
arr[arr.length - i - 1] = tmp
}
/*
passes:
@moimikey
moimikey / app.coffee
Last active Aug 29, 2015
Basic grunt + browserify + coffeescript + backbone + marionette
View app.coffee
'use strict'
$ = require('jquery')
Backbone = require('backbone')
Backbone.$ = $
Marionette = require('backbone.marionette')
View = require('./view')
$ ->
View createDummyGif.coffee
##
# create an insanely tiny placeholder gif
# output in base64
#
# i'm still working the bytes... so this is
# a working proto but it needs to be further
# edited...
#
# as much as possible in accordance to GIF spec.
class Dick
View gist:650c3218a02ff640e3ce
# Detect `y` scroll direction of mousewheel event
Util.scrollDirection = (evt) ->
if evt.detail < 0 or evt.wheelDelta > 0 then 'up' else 'down'
You can’t perform that action at this time.