Skip to content

Instantly share code, notes, and snippets.

View matehat's full-sized avatar

Mathieu D'Amours matehat

View GitHub Profile
@matehat
matehat / Install_tmux
Created February 27, 2014 01:43 — forked from simme/Install_tmux
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@matehat
matehat / LevelDB.m
Last active August 29, 2015 14:04 — forked from jpsim/LevelDB.m
#import <Objective-LevelDB/LevelDB.h>
#import <Objective-LevelDB/LDBWriteBatch.h>
#include <mach/mach_time.h>
#include <stdint.h>
NSString *randomString(NSUInteger length) {
NSMutableString *string = [NSMutableString stringWithCapacity:length];
for (int i = 0; i < length; i++) {
[string appendFormat:@"%C", (unichar)('a' + arc4random_uniform(25))];
}
asyncFunction: (x, y, z) ~>
yield
readFirstFile: (dir, ~, error) ~>
[err, files]: fs.readdir dir, ~
return error(err) if err
[err, out]: fs.readFile files[o], ~
return error(err) if err
yield content
(function(){
var asyncFunction, cacheData, map, readFirstFile;
asyncFunction = function asyncFunction(x, y, z, __callback) {
// some code, and eventually ...
return __callback();
// initiated with an empty `yield`
};
readFirstFile = function readFirstFile(dir, __callback, error) {
return fs.readdir(dir, (function(__this) {
var __func = function(err, files) {
[err, files]: fs.readdir 'test', defer
files.forEach (file) ->
return unless file.ext is '.coffee'
[err, code]: fs.readFile file, defer
CoffeeScript.run code
=>
fs.readdir('test', (function(__this) {
var __func = function() {
handleerr: (fn, args...) ->>
if ([err, out]: fn args..., defer)[0] then throw error(err)
else resume out
safe_readdir: handleerr <- {}, fs.readdir
safe_readfile: handleerr <- {}, fs.readFile
readFirstFile: (dir) ->>
try:
files: safe_readdir dir, defer
handleerr: (fn, arg) ->>
if ([err, out]: fn arg, defer)[0] then throw error(err)
else resume out
safe_readdir: handleerr <- {}, fs.readdir
safe_readfile: handleerr <- {}, fs.readFile
readFirstFile: (dir) ->>
try:
files: safe_readdir dir, defer
class UsingNode extends BaseNode
type: 'Using'
constructor: (object, methods) ->
@object: object
@methods: methods
compile_node: (o) ->
if @methods[0] == "*"
"for(var p in $@object) eval('var ' + p + '=' + $@object[p])"
exports.Backend: class RedisBackend extends Backend
CONTENT: 'content'
DEPS: 'dependencies'
DATE: 'date'
constructor: (config) ->
@host: config.host || '127.0.0.1'
@port: config.port || 6379
@db: config.db || 0
@client: new redis.Client(@port, @host)
cache: (file) ->
@test file, =>
file.group: @name
@getPreparedContent file, =>
@resolveDependencies file, =>
@emit "resolvedDependencies", file
@backend.set file, (err) =>
sys.puts "Could not cache file $file.path" if err
@emit "cachedFile", file