Skip to content

Instantly share code, notes, and snippets.

from functools import wraps
class instancemethod(object):
def __init__(self, f):
self.f = f
def __get__(self, obj, cls=None):
if obj is None:
obj = cls.instance()
@wraps(self.f)
@zipcode
zipcode / keybase.md
Last active November 22, 2016 03:20

Keybase proof

I hereby claim:

  • I am zipcode on github.
  • I am zip (https://keybase.io/zip) on keybase.
  • I have a public key whose fingerprint is E325 AF9C 1358 75E7 5804 F35F DE6C 800D 57DC E9F4

To claim this, I am signing this object:

javascript:(function(){var g="#gamergate";var f=function(t){return t.split(' ').map(function(w){return w.toLowerCase()==g?w:'butt'}).join(' ')};var es=document.getElementsByClassName("tweet-text");for(var i=0;i<es.length;i++){if(es[i].innerText.toLowerCase().indexOf(g)>0)es[i].innerText=f(es[i].innerText)}})()

Using the html5 scaffold with the open source sync engine

In this guide, I will walk you through the process of adding the html5 scaffold to the vagrant box that the sync engine ships with. This will allow you to try out the app without using our API endpoints.

WARNING: User authentication does not ship with the open source version. Anybody who can see your endpoint can access the API and any emails you have synced to it.

The fast way

If you're not making changes to the scaffold, why not use the latest and greatest online? Once you've got your API endpoint set up, as per the README head on over to http://inboxapp.github.io/inbox-scaffold-html5/set-app-id.html and use localhost as your app. It'll connect to your local copy of Inbox.

@zipcode
zipcode / postMessage.js
Last active August 29, 2015 14:07
Calling remote functions with postMessage
'use strict';
/*
* WARNING: this is TOTALLY INSECURE
*
* An attacker who can embed your page within an iFrame can make arbitrary
* requests. Make sure you're okay with that, or start origin checking.
*/
/*
@zipcode
zipcode / primes.coffee
Last active August 29, 2015 14:08
Corecursive primes
divisor = (x) ->
c = 0
r = Math.sqrt(x)
p = primes(c)
while p <= r
return p if x % p == 0
p = primes(++c)
x
isPrime = (x) -> divisor(x) == x
@zipcode
zipcode / irc.d.ts
Created February 21, 2015 22:55
node-irc typescript definition
declare module "irc" {
import events = require('events');
export interface Client extends events.EventEmitter {
send(command: string, ...args: string[]): void;
join(channel: string, callback: (arg: any)=>void): void;
part(channel: string, message: string): void;
part(channel: string, callback: (arg: any)=>void, message: string): void;
say(target: string, message: string): void;
ctcp(target: string, type: string, text: string): void;
@zipcode
zipcode / parsing.coffee
Created March 15, 2015 20:55
messing about with parsimmon
{string, lazy, alt, regex, optWhitespace, seq, succeed} = require "Parsimmon"
lbrace = string '<'
rbrace = string '>'
slash = string '/'
identifier = regex /[a-z-]+/i
opentag = lbrace.then(identifier).skip(optWhitespace).skip(rbrace)
closetag = (tag) -> lbrace.then(slash).then(string tag).skip(rbrace)
selftag = lbrace.then(identifier).skip(optWhitespace).skip(slash).skip(rbrace).map (s) -> "<#{s}/>"
@zipcode
zipcode / pulse.js
Created August 10, 2015 05:45
Pulse inserted nodes in the DOM
function pulse(node, time) {
if (!node) throw new Error("node was falsy");
if (node.constructor && node.constructor == NodeList) {
var nodes = Array.prototype.slice.call(node);
nodes.forEach(function (node) { pulse(node, time); });
return;
}
if (!node.style) return;
@zipcode
zipcode / slackemoji.user.js
Created September 10, 2015 17:43
Clicking on an emoji in the emoji list opens the original image
// ==UserScript==
// @name Slack emoji downloader
// @namespace http://zip.sexy
// @version 0.1
// @description Clickable slack emoji on the config page
// @author @zip
// @match https://*.slack.com/customize/emoji
// @grant none
// ==/UserScript==