Skip to content

Instantly share code, notes, and snippets.

@shubik
shubik / reactjs1.js
Created Mar 24, 2015
Reactjs demo slide 1
View reactjs1.js
/** @jsx React.DOM */
define([
'require',
'react'
], function (require) {
var React = require('react');
View requirejs.js
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-requirejs');
var debug = !grunt.option('prod');
return {
all: {
options: {
locale : 'en-us',
View prep-rjs-modules.js
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 Apr 17, 2014
requirejs onBuildWrite to remove jsx!
View gist:10955038
onBuildWrite: function (moduleName, path, contents) {
return contents.replace(/jsx!/g, '');
}
@shubik
shubik / gist:10954882
Created Apr 17, 2014
Example of defining JSX dependency with JSX transformer
View gist:10954882
/** @jsx React.DOM */
define([
'require',
'react',
'jsx!views/components/grid'
], function (require) {
var React = require('react'),
GridView = require('jsx!views/components/grid');
View gist:10954124
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(' && '),
View JS static - new
└── src
├── js
| ├── app
| │   ├── collections
| │   ├── config
| │   ├── controllers
| │   ├── libs
| │   └── models
| └── vendor
└── jsx
View JS static - old
└── src
└── js
├── app
│   ├── collections
│   ├── config
│   ├── controllers
│   ├── libs
│   ├── models
│   └── views
└── vendor
View dispatcher.js
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 Jun 10, 2013
Defining permissions and custom roles for Prometheus ORM models
View gist:5746313
permissions: {
'create' : ['admin'],
'read' : ['admin', 'owner', 'company'],
'update' : ['admin', 'owner'],
'destroy' : ['admin', 'owner'],
'transfer' : ['admin', 'owner']
},
roles: {
company: {