Skip to content

Instantly share code, notes, and snippets.

View bigeasy's full-sized avatar

Alan Gutierrez bigeasy

  • New Orleans, LA
View GitHub Profile
write = (buffer) ->
offset = if arguments.length > 1 then arguments[1] else 0
length = if arguments.length > 2 then arguments[2] else buffer.length
OUTER: while machine != null && offset < length
pattern = machine.definition.pattern[machine.index]
if (pattern.arrayed)
INNER: loop
buffer[offset] = machine.value[machine.offset]
machine.offset += machine.increment
bytesWritten++
@bigeasy
bigeasy / gist:584692
Created September 17, 2010 18:28 — forked from jashkenas/gist:584679
write = (buffer) ->
offset = if arguments.length > 1 then arguments[1] else 0
length = if arguments.length > 2 then arguments[2] else buffer.length
while machine isnt null and offset < length
pattern = machine.definition.pattern[machine.index]
if pattern.arrayed
loop
buffer[offset] = machine.value[machine.offset]
machine.offset += machine.increment
bytesWritten++
write = (buffer, offset, length) ->
offset or= 0
length or= buffer.length
while machine and offset < length
pattern = machine.definition.pattern[machine.index]
if pattern.arrayed
loop
buffer[offset] = machine.value[machine.offset]
machine.offset += machine.increment
bytesWritten++
fields = []
bytesRead = 0
bytesWritten = 0
engine =
next: next
get bytesRead: () -> bytesRead
get bytesWritten: () -> bytesWritten

CoffeeScript Project Structure

One of the great benefits of picking up on Coffee on the 16th of this month, two days ago, has been that the onerous task of establishing a development enviornment was simplified by simply copying the CoffeeScript project structure.

Starting on the 16th, and starting with getting Vows to work for testing and Expresso to work for coverage of JavaScript, I created beautiful literate programming articles using docco which gave me an incredible sense of accomplishment. I created an Node.js executable, created an npm installation,

[alan@piran:~/git/ecma/stack$] coffee sudo.coffee
undefinedudo
[alan@piran:~/git/ecma/stack$]
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
@bigeasy
bigeasy / mysql.coffee
Created October 14, 2010 23:02
MySQL Utilities
fs = require "fs"
Client = require("mysql").Client
createClient = ->
client = new Client()
client.user = "user"
client.password = "password"
client.database = "database"
client
@bigeasy
bigeasy / configure.out
Created March 27, 2011 23:42
Build Node.js v0.4.4 on Fedora 13 x86
[alan@dvor:~/src/node-v0.4.4$] ./configure --prefix=/opt
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc
Checking for gcc : ok
Checking for library dl : yes
Checking for openssl : yes
@bigeasy
bigeasy / parse.js
Created March 28, 2011 04:28
Parse an HTTP Cookie
function setCookie(cookies, value) {
var values = value.split(/;\s+/);
var split = values.shift().split(/=/);
var key = split.shift();
cookies[key] = { value: split.join("=") };
values.forEach(function (n) {
var split = n.split(/=/);
var property = split.shift();
cookies[key][property] = split.length == 0 ? true : split.join("\n");
});