Skip to content

Instantly share code, notes, and snippets.

View jcblw's full-sized avatar
💤
Don't wake me, my computer is sleeping in.

Jacob Lowe jcblw

💤
Don't wake me, my computer is sleeping in.
View GitHub Profile
{
"watch" : [
"./",
"lib",
"src",
"plugins"
],
"ext" : ".js|.css|.html",
"ignore" : [
"/vendor/*",
@jcblw
jcblw / apiabilities.js
Last active December 15, 2015 18:28
how to handle errors with api constructor
// you dont need new but can have new
var api = apiConstructor();
var success = function(res){
console.log(res);
};
//passes error object eg. -> new Error("this is an error")
var error = function(err){
console.log(err.message);
};
@jcblw
jcblw / anon.js
Created May 26, 2013 00:39
Tildes FTW
~function(){
console.log("Works!")
}()
@jcblw
jcblw / foreach.js
Created May 26, 2013 02:05
If I decide to add forEach to Marrow
Marrow.prototype.forEach = function(obj, fn){
if("forEach" in obj){
obj.forEach(fn); // native knows best
}else if("length" in obj){ // array
for(var i = 0; i < obj.length; i += 1){
fn(obj[i], i);
}
}else if(typeof obj === "object"){ // object
for(var key in obj){
function disqus_config() {
this.callbacks.afterRender.push(function() { // push to aviod any overwrites
jQuery(window).trigger("resize"); // trigger a resize
});
}
@jcblw
jcblw / mangos-models.js
Last active December 18, 2015 07:19
New methods for Mangos
// eg.
var
Mangos = require("mangos"),
connection = new Mangos("supercooldb", "127.0.0.1", 27101),
model = {
//when adding or updating or returning
defaults : { // default values for model
first_name : "Bob",
last_name : "Hope",
notifications : true
@jcblw
jcblw / connect-asset-helpers.js
Last active December 1, 2019 23:28
This is some useful helpers that allow you to use handlebar templates with connect-assets in node.js
module.exports = function( hbs ){
hbs.registerHelper( "js", function( context ){
if( typeof js === "function" ){
return js( context );
}else{
return ""
}
});
@jcblw
jcblw / notes.js
Created July 11, 2013 04:25
Advanced Caching for multi model calls in rendr to make them look a bunch of single model calls
// this is to direct check the model store
// App.fetcher.modelStore.get("user", "bork", true);
// ^ ^ ^
// model userid should return
// to store a collection and to 'fake' a call
// you create a collection with the options the fetch params
// then you say collection.store();
// that should fake an individual call so if one is made
// bam we have the model
@jcblw
jcblw / change.js
Created August 8, 2013 21:35
how you can change fields based off of user updates
this.listenTo( user, 'change:invites', function(){
self.$invites.text( user.get( 'invites' ) );
});
@jcblw
jcblw / checkit
Created August 23, 2013 18:33
ajax
ajax( 'url', { /*data */ }, function ( err, res ) {
if ( err ){
// handle
return null;
}
// good
})