Skip to content

Instantly share code, notes, and snippets.

View dalcib's full-sized avatar

Dalci de Jesus Bagolin dalcib

View GitHub Profile
@kof
kof / bootstrap.js
Created March 30, 2011 22:52
bootstrap file for mongoose models
var fs = require('fs'),
m = require('mongoose');
fs.readdirSync(__dirname).forEach(function(filename) {
var schamaName = filename.replace(/\.js$/, ''),
Schema = require('./' + schemaName);
m.model(schemaName, Schema);
});
@madhums
madhums / mapreduce.js
Created August 3, 2011 20:33
mapreduce using mongodb and mongoose
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/db_name');
// map function
var map = function(){
emit(this.field_to_group_by, {
other_fields: this.other_fields
// list other fields like above to select them
})
}
@timoxley
timoxley / m.js
Created December 20, 2011 18:31
mongoose oplog
'use strict'
GLOBAL.DEBUG = true;
var mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/groupdock_development')
mongoose.connection.on('open', function() {
var test = require("assert");
var Slave = function() {
this.running = false;
@bjhess
bjhess / st_cheat.txt
Created January 11, 2012 21:39
Sublime Text Cheatsheet
Navigation:
cmd-p Goto Anything ('@' for functions, ':' for line number)
cmd-r Function finder
ctl-g Goto line number
cmd-sft-p Command palette
cmd-sft-f Find in Files
cmd-opt-r Toggle regex when finding
cmd-opt-# Columns
ctr-# Switch columns
@abtris
abtris / widgets.js
Created January 29, 2012 10:38
mapy.cz
/**
* Input type - address with autocomplete and reverse geocoding using Seznam maps API.
*/
angular.inputType('address', function(element) {
var scope = this;
// full address data from geocoder for angular model
var address = {};
// parse input value and set into model
@ThomasBurleson
ThomasBurleson / gist:1723823
Created February 2, 2012 14:54
Node HTTP-PROXY Server
#
# ******************************************************************************************************
#
# HTTP-Proxy development server
#
# This server listens on http://locahost:8080 and proxies requests based on partial paths.
#
# 1) `http://localhost:8080/api/json/` will be proxied to `http://xxx.dev.yourCompany.com/api/json/`
# 2) All other `http://localhost:8080` requests will be proxied to `http://localhost:8000`
#
@ThomasBurleson
ThomasBurleson / gist:1723834
Created February 2, 2012 14:57
Node HTTP & HTTP-Proxy Server
#!/usr/bin/env node
/**
* ******************************************************************************
*
* This modified Node script creates two (2) lightweight, local web servers:
*
* - standard web server running on http://localhost:8000
* - proxy web server running on http://localhost:8080
*
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@dongyuwei
dongyuwei / node-reader.js
Created March 14, 2012 04:58
google reader api for nodejs
/*
This library was developed by Will Honey.
It is licensed under the GPLv3 Open Source License
This library requires the underscore library found at http://documentcloud.github.com/underscore/
This library requires the underscore string library found at http://edtsech.github.com/underscore.string/
This library requires the support of localStorage. Updates could be easily made to change that.
*/
/* jslint adsafe: false, devel: true, regexp: true, browser: true, vars: true, nomen: true, maxerr: 50, indent: 4 */
@domenic
domenic / portable-node.md
Created May 25, 2012 21:03
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation