Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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.
*/
/*

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.

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)}})()
@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:

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)
function setps1 {
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
# "(root) " in red if root
# Hostname (if SSH_TTY is set)
# Directory
# Git branch, if in git and available
# Last command exit status
# $ times shlvl, or # if root
@zipcode
zipcode / Monads.scala
Created June 5, 2014 22:52
A shitty explanation of Monads in Scala
import scalaz._
import Scalaz._
object HowMonadsWork {
/*
You may have found yourself asking, what is a Monad, anyway?
Some kinda burrito-spacesuit-magical-wavy thing, if you ask the internet.
The internet isn't very helpful. This probably isn't, either.
@zipcode
zipcode / BetterBooly.scala
Created June 4, 2014 18:26
How Scalaz uses implicits to augment objects.
import scala.language.implicitConversions
/*
So earlier this week I was reading about how scalaz implements the "enhance my library"
pattern. It's a pretty nifty way to add methods to existing objects in a type-safe way.
However, this is @zip here, so of course I'm gonna use it for something gross.
So, I'm a fan of Javascript, inexplicably. Javascript has a… looser… notion of types.
In particular, all sorts of things can be true or false! Empty lists are false, full
ones are true. Who wouldn't want the following capability?