Skip to content

Instantly share code, notes, and snippets.

// bower_components
-- angular.js
-- annyang.js
// static
-- index.html
server.js
function basic( callback ){
console.log( 'do something here' );
var result = 'i am the result of `do something` to be past to the callback';
// if callback exist execute it
callback && callback( result );
}
@1dolinski
1dolinski / code.js
Created February 11, 2014 05:28
not best practice?
function js(str, callback) {
console.log("Code");
callback && callback(str);
}
js("JavaScript", function (str) {
console.log(str);
});
var foo, bar = null;
foo = {
setBar: function(value) {
bar = value;
}
};
foo.setBar(123);
console.log(bar);
function Person(gender) {
this.gender = gender;
alert('Person instantiated');
}
// What does this line do?
Person.prototype.gender = '';
var person1 = new Person('Male');
var cheerio = require('cheerio');
var request = require('request');
arry = []
base_url = "https://weworkremotely.com"
function job_hrefs(i, url, arry, callback) {
return request(url, function(err, res, body) {
var jobs = [];
> x = {};
{}
> x['0'].first_obj = "cool";
TypeError: Cannot set property 'first_obj' of undefined
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
var geocoder = require("geocoder");
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error: Make sure thatmongod is running'));
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
var geocoder = require("geocoder");
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error: Make sure thatmongod is running'));
db.once('open', function callback() {
// Scenario 1
// run these sequentially, the google map closes
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.clearInstanceListeners(window, 'load');
// Scenario 2
function run() {
google.maps.event.clearInstanceListeners(window, 'load');
}