Skip to content

Instantly share code, notes, and snippets.

View cloudhead's full-sized avatar
🌴
On vacation

Alexis Sellier cloudhead

🌴
On vacation
View GitHub Profile
var sys = require('sys');
process.delay = function (fun) {
return setTimeout(fun, 0);
};
var func = function () {
var promise = new process.Promise();
@@ -3,7 +3,14 @@ module ActiveSupport
inflect.plural(/$/, 's')
inflect.plural(/s$/i, 's')
inflect.plural(/(ax|test)is$/i, '\1es')
- inflect.plural(/(octop|vir)us$/i, '\1i')
+
+ # Note that 'octopuses' is equally correct
+ inflect.plural(/(octop)us$/i, '\1i')
+
+ # The correct plural of 'virus' is actually 'viruses',
" .vimrc
" How to pwn javascript's syntax without anyone ever knowing:
" substitutes `function` with `->` on file load, and reverses it on write.
autocmd BufRead,BufWritePost *.js silent %s/function/->/
autocmd BufWritePre *.js silent %s/->/function/
require.paths.unshift(
__filename.split('/').slice(0, -1).concat('vendor').join('/'));
@cloudhead
cloudhead / gist:303324
Created February 13, 2010 07:45
substitution plugin for talker
//
// A Talker plugin to do live substitutions of previous message
//
// string example: s/wordl/world
// regexp example: r/^w/W
//
plugin.onMessageReceived = function (event) {
var match, row, messages, search;
if (match = event.content.match(/^([sr])\/(.+?)\/([^\/]*)(?:\/([gi])?)?$/)) {
row = $("#log tr[author='" + event.user.name + "'].message:last");
var posix = require("posix");
var sys = require("sys");
var continuables = require('continuables');
function writeFile(filename, value, mode) {
if (typeof value !== "string") {
throw new Error('Value must be a string');
}
if (typeof mode === "undefined") {
mode = 0600;
This file lays out my planned open-source projects for the next year or so.
These projects are interdependent upon eachother in complex ways, hence the
complexity of this graph. The *overall*, eventual goal, is a set of my own
clients I can use with Google Wave, a web framework I *actually like*, and a
JavaScript development environment/ecosystem I can stomache.
This list is ordered bottom-up, and right-to-left. Items below and indented
another item *must* be completed (or have portions thereof completed) before
their parent item can be worked on.
@cloudhead
cloudhead / up-wp-toto.rb
Created February 18, 2010 22:08
script used to import usabilitypost.com posts from wp to toto
i = 0
File.read("wp_posts2.csv").split('$$')[1..-1].each do |entry|
next if entry.gsub(/\n/,'').empty?
print '.'
date, body, title, slug = entry.split('||').map {|e| e.sub(/^""/, '').sub(/""$/, '') }
puts title if title.include? ':'
slug = title.downcase.gsub('[^a-z0-9]+', '-') if slug.empty?
date = date.split(/ +/).first
File.open("articles/#{date}-#{slug}.txt", "w") do |file|
file.write("title: #{title}\ndate: #{date.gsub('-', '/')}\nslug: #{slug}\n\n#{body}\n")
@cloudhead
cloudhead / promise.js
Created February 22, 2010 18:26 — forked from tmpvar/promise.js
var events = require('events');
exports.Promise = function () {
exports.EventEmitter.call(this);
this._blocking = false;
this.hasFired = false;
this._values = undefined;
};
process.inherits(exports.Promise, events.EventEmitter);
//
// JS Prompt - a Talker plugin <http://talkerapp.com>
//
// to activate/deactivate the js prompt: /prompt
// to share variables amongst users: this.foo = 1;
//
plugin.usage = '/prompt';
plugin.command = 'prompt';
plugin.evalMode = false;