Skip to content

Instantly share code, notes, and snippets.

View robwormald's full-sized avatar

Rob Wormald robwormald

View GitHub Profile
toJSON: function() {
var obj = this.toObject();
delete obj.password;
delete obj.credentials;
delete obj.email;
delete obj.identifier;
return obj;
},
- (void) socketIODidConnect:(SocketIO *)socket
{
NSLog(@"socket.io connected.");
SocketIOCallback cb = ^(id argsData) {
NSDictionary *response = argsData;
NSLog(@"%@",response);
/**
* 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:
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
/**
* Module dependencies
*/
var util = require('util');
/**
* Find Records
*
blas.queryAndGroup = function (permissions) {
var deferred = $q.defer()
// load accounts from backend and group by owner
var foobar = $resource(
'/api/accounts', {
}, {
query: {
method: 'GET',
var user = User.get({userId:123},shitWentRight,shitWentWrong);
function shitWentRight(){}
function shitWentWrong(){}
//1st way
module.exports.foo = function(){
console.log('foo!')
}
module.exports.bar = function(){
console.log('bar!')
}
function getFoos(){
//create your promise here
var myPromise = $q.defer()
//do something async
$http.get('/foos').then(function(response){
//if successful
if(response.data){
beforeUpdate: function(values, next) {
if (values.password) {
hashPassword(values, next);
}
else {
User.findOne(values.id).done(function(err, user) {
if (err) {
next(err);
}
else {