Skip to content

Instantly share code, notes, and snippets.

View shubik's full-sized avatar

Alexander shubik

  • Teradek LLC
  • Irvine, CA
  • 08:33 (UTC +03:00)
View GitHub Profile
└── 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, '');
}
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)) {
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-requirejs');
var debug = !grunt.option('prod');
return {
all: {
options: {
locale : 'en-us',
@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');
var ModelConstructor = function(id) {
// some code...
this._loading = deferred();
this._ready = this._loading.promise;
// more code...
}
@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
}));