Skip to content

Instantly share code, notes, and snippets.

View romainhuet's full-sized avatar

Romain Huet romainhuet

View GitHub Profile
@jeremys
jeremys / conflict.js
Created June 22, 2011 16:19
Index/Save conflict
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
mongoose.connect('mongodb://localhost/db');
var User = new Schema({
email: { 'type': String, 'required': true, 'index': { 'unique': true, 'background': true } },
});
User = mongoose.model('User', User);
@madrobby
madrobby / i18n.coffee
Created November 14, 2011 15:45
Backbone i18n with CoffeeScript
# before this file is loaded, a locale should be set:
#
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
#
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
# make a tar
ok 1 reader ok
ok 2 pack ok
ok 3 writer ok
ok 4 it finished!
1..4
# tests 4
# pass 4
@joefitzgerald
joefitzgerald / gist:1990736
Created March 7, 2012 03:32
Handlebars JST Grunt Task
/*
* Grunt Task File
* ---------------
*
* Task: JST-HB
* Description: Compile handlebars templates to JST file.
* Dependencies: underscore@1.2.4
*
*/
@latentflip
latentflip / 1.1_directory_structure.txt
Created May 3, 2012 09:24
In Lieu of doing this properly
./frontend
├── /coffee
│   ├── /models
│   | └── MyBaseModel.coffee
│   | └── MyModel.coffee
│   ├── /routers
│   | └── MyRouter.coffee
│   ├── /templates
| │   ├── /tmpl-dir1
@juliocesar
juliocesar / awesome_router.coffee
Created May 21, 2012 17:00
AwesomeRouter: a cool Backbone.js router class
# AwesomeRouter: A class that I've been using throughout a few Backbone.js apps I've built.
#
# It adds 2 features: an event that gets fired when one calls `navigate` (aptly named
# "navigate"), so you can bind things to when a URL gets triggered. And a "before filter"
# method `before`, which you can use to run things before every a route gets triggered.
#
# This could easily be extended to have after filters too, or to only trigger a route
# upon @before returning something that's not false.
class AwesomeRouter extends Backbone.Router
export AR=arm-unknown-linux-gnueabi-ar
export CC=arm-unknown-linux-gnueabi-gcc
export CXX=arm-unknown-linux-gnueabi-g++
export LINK=arm-unknown-linux-gnueabi-g++
node-gyp --target=v0.8.11 --arch=arm configure build --nodedir=/path/to/node/checkout
@max-mapper
max-mapper / helloworld.js
Created November 27, 2012 06:55
droneduino
var serialport = require('node-serialport')
var sp = new serialport.SerialPort("/dev/ttyO3", {
parser: serialport.parsers.raw,
baud: 9600
})
sp.on('data', function(chunk) {
console.log(chunk.toString('hex'), chunk.toString(), chunk)
})
@adamcooke
adamcooke / cloudapp-export.rb
Created January 11, 2013 15:45
Export all your drops from CloudApp using this quick Ruby script
#!/usr/bin/env ruby
# A quick script to download all your files from CloudApp.
# To run this just run the script passing your e-mail & password
# to the script, for example:
#
# gem install cloudapp_api
# ruby cloudapp-export.rb adam@atechmedia.com mypassword
#
@domenic
domenic / interop.md
Last active July 7, 2022 19:47
`module.exports =` and ES6 Module Interop in Node.js

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.