Skip to content

Instantly share code, notes, and snippets.

@mrmurphy
mrmurphy / command.js
Last active December 28, 2015 02:09 — forked from JoelBesada/README.md
A Delicious option for Backtick chrome extension
javascript:(function(e,t){var n=e.document;setTimeout(function(){function a(e){if(e.data==="destroy_bookmarklet"){var r=n.getElementById(t);if(r){n.body.removeChild(r);r=null}}}var t="DELI_bookmarklet_iframe",r=n.getElementById(t);if(r){return}var i="https://delicious.com/save?source=bookmarklet&",s=n.createElement("iframe");s.id=t;s.src=i+"url="+encodeURIComponent(e.location.href)+"&title="+encodeURIComponent(n.title)+"&note="+encodeURIComponent(""+(e.getSelection?e.getSelection():n.getSelection?n.getSelection():n.selection.createRange().text))+"&v=1.1";s.style.position="fixed";s.style.top="0";s.style.left="0";s.style.height="100%25";s.style.width="100%25";s.style.zIndex="16777270";s.style.border="none";s.style.visibility="hidden";s.onload=function(){this.style.visibility="visible"};n.body.appendChild(s);var o=e.addEventListener?"addEventListener":"attachEvent";var u=o=="attachEvent"?"onmessage":"message";e[o](u,a,false)},1)})(window)
@mrmurphy
mrmurphy / scrollNotifier.coffee
Created November 15, 2013 23:23
Handy object to call any number of functions when a user has stopped scrolling. Uses jQuery
scrollNotifier = do ->
TIMEOUTINTERVAL = 50
scrollTimer = null
returnable = {}
callbacks = []
bound = false
mainCallback = ->
clearTimeout(scrollTimer)
scrollTimer = setTimeout( ->
@mrmurphy
mrmurphy / Example.coffee
Last active December 30, 2015 10:38
This is some sample code for a presentation on Snap.svg. It's just a snippet, not a functional example!
anims = []
class Slide
constructor: (@snap, @play, @reset, @animatables = []) ->
@snap = Snap.select @snap
addImage: (path, etc...) ->
e = @snap.image retinizePath(path), etc...
@animatables.push e
return e
@mrmurphy
mrmurphy / RetinaExample.coffee
Created December 6, 2013 01:00
An example of some Coffeescript to swap out retina images for 1x images.
retinizePath = (path) ->
path_split = path.split(".")
prefix = path_split[0..-2].join(".")
suffix = path_split[path_split.length - 1]
if window.devicePixelRatio > 1
return [prefix, suffix].join("@2x.")
else
return [prefix, suffix].join(".")
var dict = ["a", "s", "d", "f"]
itoa = function (n) {
retstr = ""
while (n !== 0) {
digit = dict[(n % (dict.length + 1)) - 1]
retstr = digit + retstr
n = Math.floor(n / dict.length)
@mrmurphy
mrmurphy / twit.js
Created January 2, 2014 03:18 — forked from 1dolinski/new.js
https://github.com/ttezel/twit
T.post('statuses/update', { status: 'hello world!' }, function(err, reply) {
// ...
})
// Question: how can I put this into a function such that the function returns reply?
// I tried:
@mrmurphy
mrmurphy / twit.js
Last active January 1, 2016 23:09 — forked from 1dolinski/new.js
https://github.com/ttezel/twit
T.post('statuses/update', { status: 'hello world!' }, function(err, reply) {
// ...
})
function TWEET(username, count,){
var returnReply;
T.get('statuses/home_timeline', { count: count, screen_name: username, trim_user: true, exclude_replies: true }, function (err, reply) {
returnReply = reply;
db = require "../lib/db"
Q = require "q"
_ = require "lodash"
GROUP = "messages"
class Message
constructor: (obj) ->
# Assign all properties of the object to this.
_.extend(this, obj)
# Remember, this is wrong!
describe 'A simple Angular app testing suite', ->
it "should load a module from an app, and mock the module's dependency.", ->
module 'NameOfApp', ($provide) ->
$provide.value 'bar',
baz: -> true
inject 'foo', (foo) ->
expect(foo).not.toBe(null)
# Remember, this is wrong!
describe 'A simple Angular app testing suite', ->
it "should load a module from an app, and mock the module's dependency.", ->
module 'NameOfApp', ($provide) ->
$provide.value 'bar',
baz: -> true
return null
inject 'foo', (foo) ->