Skip to content

Instantly share code, notes, and snippets.

// This version calls the _write callback after the data is sent.
Duplex = require('stream').Duplex;
var BCSocket = function(...) {
Duplex.call(this, {objectMode: true});
this.buffer = [];
};
BCSession.prototype = Object.create(Duplex.prototype);
<!DOCTYPE html>
<title>Cool game</title>
<style>
.centerbox {
/* flexbox, por favor */
display: flex;
align-items: center;
justify-content: center;
width: 100%;
assert = require 'assert'
_a = 'a'.charCodeAt(0)
_f = 'f'.charCodeAt(0)
_A = 'A'.charCodeAt(0)
_F = 'F'.charCodeAt(0)
hexForChar = (c, pos = 0) ->
ascii = c.charCodeAt pos
switch
@josephg
josephg / generator.coffee
Created June 24, 2014 22:25
quill rich text stuff
{Delta} = require 'tandem-core'
utils = require('tandem-core/build/delta_generator').getUtils()
tandem = require './tandem'
tandem.generateRandomDoc = ->
Delta.getInitial 'abcde'
tandem.generateRandomOp = (delta) ->
newDelta = utils.getRandomDelta delta, 0
@josephg
josephg / test.coffee
Last active August 29, 2015 14:04
ShareJS query bug repro
{Duplex} = require 'stream'
livedb = require 'livedb'
sharejs = require './lib'
backend = livedb.client livedb.memory()
#backend = livedb.client livedbMongo('localhost:27017/test?auto_reconnect', safe:false)
share = sharejs.server.createClient {backend}
# Get your word list:
# curl 'http://www-01.sil.org/linguistics/wordlists/english/wordlist/wordsEn.txt' -O
fs = require 'fs'
words = for word in fs.readFileSync('wordsEn.txt', 'utf8').split '\n' when word != ''
if word[word.length - 1] is '\r'
word[...word.length - 1]
else
word
@josephg
josephg / gist:23a795bf8c1f9f93e166
Created October 17, 2014 21:11
Yosemite wifi problems
$ ping 192.168.1.254
PING 192.168.1.254 (192.168.1.254): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
@josephg
josephg / gist:b32c04287334c629809f
Last active August 29, 2015 14:07
Object move v1
# Simple idea: Think of the process in a set of phases which happen in order:
#
# First the pickup phase marks objects for pickup. After the pickup phase runs,
# we go through and pick up all the objects. (Notably, you can still decend
# into picked up objects after marking them during the pickup phase).
#
# Then maybe we have an edit phase where we make all the normal edits.
#
# Finally we have a drop phase where we go through and insert back all the
# things we picked up.
@josephg
josephg / harness.c
Created December 14, 2014 08:28
AFL harness for joyent/http-parser
#include <stdio.h>
#include <stdlib.h>
#include "http_parser.h"
int on_message_begin(http_parser *parser) {
printf("on_message_begin\n");
return 0;
}
int W(const char *name, const char *at, size_t length) {

New components:

  • (i) insert (was di:)

  • (d) drop

  • (dn) drop if null

  • (r) remove (was p:null)

  • (p) pick up

  • (e) edit