Skip to content

Instantly share code, notes, and snippets.

View aredridel's full-sized avatar
💭
See my social media for status.

Aria Stewart aredridel

💭
See my social media for status.
View GitHub Profile
require.extensions[".json"] = function (module, filename) {
module.exports = JSON.parse(require("fs").readFileSync(filename, "utf8"))
}
@tj
tj / struct.js
Created June 23, 2011 17:43
idea for someone who wants to play with node-ctype
// construct an object
// that will work with
// node-ctype from a c struct string:
var struct = new Struct('struct { int8_t r, g, b; }');
var rgb = struct.parse(buf);
console.log(rgb.r, rgb.b, rgb.b);
@andyhd
andyhd / lens.js
Created February 11, 2012 01:48
Javascript Lenses
function lens(get, set) {
var f = function (a) { return get(a); };
f.set = set;
f.mod = function (f, a) { return set(a, f(get(a))); };
return f;
}
var first = lens(
function (a) { return a[0]; },
function (a, b) { return [b].concat(a.slice(1)); }
@masak
masak / explanation.md
Last active June 19, 2025 13:01
How is git commit sha1 formed

Ok, I geeked out, and this is probably more information than you need. But it completely answers the question. Sorry. ☺

Locally, I'm at this commit:

$ git show
commit d6cd1e2bd19e03a81132a23b2025920577f84e37
Author: jnthn <[email protected]>
Date:   Sun Apr 15 16:35:03 2012 +0200

When I added FIRST/NEXT/LAST, it was idiomatic but not quite so fast. This makes it faster. Another little bit of masak++'s program.

@polotek
polotek / backbone_plus_cs.md
Created July 29, 2012 18:07
Some thoughts on a small project with Backbone and CoffeeScript

I spent some time on a little scripting project yesterday and decided to use Backbone and CoffeeScript. I've been looking for a reason to use Backbone just to become more familiar. I don't really use CoffeeScript, and even went through my periods as a CS hater. But it's always a good idea to stay familiar with what's out there. At the very least it'll make sure you're not full of shit when you talk to people about pros and cons. Anyway, this isn't comprehensive or even useful per se. I just thought I'd jot down some thoughts.

I should make a disclaimer that this wasn't a traditional project for Backbone. It was a node script that only uses models a collections. I needed to perform a bunch of actions on a dataset by hitting a REST api. I've been thinking for a while that tasks like this are often nicer if you can mock up a quick model domain around the api. Then you can work with Forum and Topic models and just do update and delete operations on them. Once you set these up, the scripting tasks become much mor

@undoZen
undoZen / less-middleware-with-sourcemap.js
Last active December 18, 2015 15:49
a simple less middleware with source map, usage: app.use(lessMiddleware(path.join(__dirname))); -- only works for __dirname right now.
var less = require('less');
var fs = require('fs');
var path = require('path');
var SourceMapGenerator = require('source-map').SourceMapGenerator
function errfn(callback) {
return function (err) {
if (err) callback.call(this, err);
else callback.apply(this, [].slice.apply(arguments).slice(1));
}
@dherman
dherman / template-literals.md
Last active July 4, 2021 10:41
What can you do with ES6 string template literals?

DOM selectors

var elements = query`.${className}`;

Localization

var message = l10n`Hello ${name}; you are visitor number ${visitor}:n!
include Math;R1=1.0; R2=2.0;K2=5.0
SS=40;K1=SS*K2*3/(8*(R1+R2));def rf(a, b)
cosA=cos(a);sinA=sin(a);cosB=cos(b);sinB=sin(b)
o=Array.new(SS).fill{Array.new(SS).fill(' ')};b=Array.
new(SS).fill{ Array.new(SS).fill(0)}; t=0.0;while t<2*PI
cost=cos(t);sint=sin(t);p=0.0;while p<2*PI;cosp=cos(p);sinp=
sin(p);cx=R2+R1*cost;cy=R1* sint;x=cx*(cosB*cosp+sinA*
sinB*sinp)-cy*cosA*sinB; y=cx*(sinB*cosp-sinA*##
cosB*sinp)+cy*cosA*cosB ;z=K2+cosA*cx*sinp+cy*
sinA;ooz=1/z;xp=(SS/2+K1* ooz*x).to_i ;yp= (SS/2-
@AlainODea
AlainODea / install-isc-smf.sh
Last active December 21, 2015 14:39
An SMF manifest for ISC DHCP on SmartOS
#!/bin/bash
curl https://gist.githubusercontent.com/AlainODea/6321603/raw/760ebf43a2f48a78d99b8ca6dbc98a4b84684647/isc-dhcpd-smf.xml > /opt/local/lib/svc/manifest/isc-dhcpd-smf.xml
svccfg import /opt/local/lib/svc/manifest/isc-dhcpd-smf.xml
echo Run 'svcadm enable svc:/pkgsrc/isc-dhcpd:default' to enable ISC DHCP Daemon after configuration
@mikeal
mikeal / gist:7738226
Last active December 29, 2015 22:39
The road ahead.

When Ryan was the only committer and most of the regular node contributors were in the bay area we'd assemble 8 or so people together when we wanted to deal with a new challenge to node. At first we went to the Old Oakland office of CouchOne where I worked but then we upgraded to Matt Ranney's much nicer San Francisco Voxer office.

We scaled out of that pretty quickly, the contributors and stake holders spreading across the world made impromptu local meetings intangible. At first I put together a closed node core meeting before the first NodeConf but it didn't go as well as we'd hoped. Then I ran an unconference, NodeConf Summer Camp, at Walker Creek Ranch, and that served as a much better environment to hammer out the details of streams and seeds of ideas like domains.

Today there are a handful of regular committers to core. They do a regular conference call and contribute consistently. There is a loose structure that appears to be working for them. I decided to end the unconferences and bring NodeConf pro