Skip to content

Instantly share code, notes, and snippets.

View shubik's full-sized avatar

Alexander shubik

  • Teradek LLC
  • Irvine, CA
  • 12:39 (UTC +03:00)
View GitHub Profile
var UserModel = require('./_user_model'),
user = new UserModel();
user(function(model) {
model.set({
name: 'Shubik',
email: 'farennikov@gmail.com'
});
model.save()(function(model) {
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;
@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: {
@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
}));
var ModelConstructor = function(id) {
// some code...
this._loading = deferred();
this._ready = this._loading.promise;
// more code...
}
@shubik
shubik / reactjs1.js
Created March 24, 2015 17:24
Reactjs demo slide 1
/** @jsx React.DOM */
define([
'require',
'react'
], function (require) {
var React = require('react');
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-requirejs');
var debug = !grunt.option('prod');
return {
all: {
options: {
locale : 'en-us',
var _ = require('lodash');
module.exports = function(grunt) {
var prod = !!grunt.option('prod'),
path = grunt.config.get('src_path') + '/js/app/',
paths = [],
modules;
grunt.file.recurse(path, function(abspath, rootdir, subdir, filename) {
if (abspath.match(/\.js$/gi)) {
@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, '');
}
@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');