Skip to content

Instantly share code, notes, and snippets.

View shubik's full-sized avatar

Alexander shubik

  • Teradek LLC
  • Irvine, CA
  • 21:17 (UTC +03:00)
View GitHub Profile
var ModelConstructor = function(id) {
// some code...
this._loading = deferred();
this._ready = this._loading.promise;
// more code...
}
var UserModel = require('./_user_model'),
user = new UserModel();
user(function(model) {
model.set({
name: 'Shubik',
email: 'farennikov@gmail.com'
});
model.save()(function(model) {
@shubik
shubik / gist:5723868
Created June 6, 2013 18:42
Using RedisStore with Socketio
var RedisStore = require('socket.io/lib/stores/redis'),
pub = redis.createClient(),
sub = redis.createClient(),
cmd = redis.createClient();
io.set('store', new RedisStore({
redisPub: pub,
redisSub: sub,
redisClient: cmd
}));
@shubik
shubik / gist:5746313
Created June 10, 2013 03:17
Defining permissions and custom roles for Prometheus ORM models
permissions: {
'create' : ['admin'],
'read' : ['admin', 'owner', 'company'],
'update' : ['admin', 'owner'],
'destroy' : ['admin', 'owner'],
'transfer' : ['admin', 'owner']
},
roles: {
company: {
var _ = require('underscore'),
redis = require('redis'),
redis_conf = require('../../servers/config/redis.json'),
cached = {},
Dispatcher = function(key) {
var self = this,
key_base = 'app:dispatcher:';
this.key = key_base + key;
└── src
└── js
├── app
│   ├── collections
│   ├── config
│   ├── controllers
│   ├── libs
│   ├── models
│   └── views
└── vendor
└── src
├── js
| ├── app
| │   ├── collections
| │   ├── config
| │   ├── controllers
| │   ├── libs
| │   └── models
| └── vendor
└── jsx
@shubik
shubik / gist:10954124
Created April 17, 2014 05:04
JSX Grunt task
grunt.initConfig({
srcPath: 'src',
buildPath: 'public',
shell: {
'build-jsx': {
command: [
'jsx -x jsx <%= srcPath %>/jsx/ <%= srcPath %>/js/app/views/',
'rm -rf <%= src_path %>/js/app/views/.module-cache/'
].join(' && '),
@shubik
shubik / gist:10954882
Created April 17, 2014 05:24
Example of defining JSX dependency with JSX transformer
/** @jsx React.DOM */
define([
'require',
'react',
'jsx!views/components/grid'
], function (require) {
var React = require('react'),
GridView = require('jsx!views/components/grid');
@shubik
shubik / gist:10955038
Created April 17, 2014 05:28
requirejs onBuildWrite to remove jsx!
onBuildWrite: function (moduleName, path, contents) {
return contents.replace(/jsx!/g, '');
}