Skip to content

Instantly share code, notes, and snippets.

Avatar

Rob Wormald robwormald

View GitHub Profile
View gist:8693500
toJSON: function() {
var obj = this.toObject();
delete obj.password;
delete obj.credentials;
delete obj.email;
delete obj.identifier;
return obj;
},
View gist:8716544
/**
* sails.io.js
*
* This file is completely optional, and merely here for your convenience.
*
* It reduces the amount of browser code necessary to send and receive messages
* to & from Sails by simulating a REST client interface on top of socket.io.
* It models its API after the pattern in jQuery you might be familiar with.
*
* So to switch from using AJAX to Socket.io, instead of:
View gist:8716404
- (void) socketIODidConnect:(SocketIO *)socket
{
NSLog(@"socket.io connected.");
SocketIOCallback cb = ^(id argsData) {
NSDictionary *response = argsData;
NSLog(@"%@",response);
View gist:8722803
angular.module('BBPlnkr').factory 'Widget', ($templateCache, Restangular) ->
_baseWidgets
_baseWidgets = Restangular.all('api/widgets')
widget = {
name: 'someWidget' #This needs to fuck off
}
#Added extra param to saveWidget
saveWidget: (snippets, fileName) ->
//or whatever
widget.file_name = fileName
View gist:8746479
/**
* Module dependencies
*/
var util = require('util');
/**
* Find Records
*
View gist:8826141
blas.queryAndGroup = function (permissions) {
var deferred = $q.defer()
// load accounts from backend and group by owner
var foobar = $resource(
'/api/accounts', {
}, {
query: {
method: 'GET',
View gist:8829910
var user = User.get({userId:123},shitWentRight,shitWentWrong);
function shitWentRight(){}
function shitWentWrong(){}
View gist:8851642
function getFoos(){
//create your promise here
var myPromise = $q.defer()
//do something async
$http.get('/foos').then(function(response){
//if successful
if(response.data){
View FooService.js
//1st way
module.exports.foo = function(){
console.log('foo!')
}
module.exports.bar = function(){
console.log('bar!')
}
View gist:8944501
beforeUpdate: function(values, next) {
if (values.password) {
hashPassword(values, next);
}
else {
User.findOne(values.id).done(function(err, user) {
if (err) {
next(err);
}
else {