Skip to content

Instantly share code, notes, and snippets.

View anatoliychakkaev's full-sized avatar

Anatoliy Chakkaev anatoliychakkaev

View GitHub Profile
@anatoliychakkaev
anatoliychakkaev / grab.js
Created April 1, 2013 22:34
Example of using streams
var fs = require('fs');
var express = require('express');
var spawn = require('child_process').spawn;
var icecast = require('icecast');
// URL to a known Icecast stream
var url = 'http://ice.somafm.com/spacestation';
// connect to the remote stream
icecast.get(url, function (res) {
@anatoliychakkaev
anatoliychakkaev / shell.log
Created March 25, 2013 10:17
Generators working fine
~: ) cd /tmp
14:15:13 anatoliy@mac /tmp
~: ) compound init gen
create gen
create gen/app/
create gen/app/assets/
create gen/app/assets/coffeescripts/
create gen/app/assets/stylesheets/
create gen/app/models/
create gen/app/controllers/
var migrate = require('migrate')
, join = require('path').join
, fs = require('fs');
module.exports = function(compound) {
var app = compound.app;
var options = {args: []};
/**
* Migration template.
@anatoliychakkaev
anatoliychakkaev / README.md
Last active December 10, 2015 17:49
Experimental compound events + common controllers API.

About

This is example of using compound API with any express application. Every part of compound could be accessed via API. Directories structure is optional: you can do everything in single file using compount events API.

Insallation

npm install compound jugglingdb express

Running

@anatoliychakkaev
anatoliychakkaev / application.js
Last active December 10, 2015 03:08
Another way of controllers describing
var Application = module.exports = function Application(init) {
init.before(function protectFromForgery(c) {
c.protectFromForgery('74be5145ccc6b731ee2d6f08990cc4f43c2bc800');
});
};
Application.prototype.someAction = function (c) {
c.send('hello');
};
@anatoliychakkaev
anatoliychakkaev / driver.js
Last active December 10, 2015 03:08
Commonjs-style controller for 1602/kontroller
var Driver = module.exports = require('kontroller').BaseController.constructClass();
Driver.init = function (c) {
c.extendWith(require('./application'));
};
Driver.before(function think(c) {
this.allok = true;
c.next();
}, {only: 'accelerate'});
@anatoliychakkaev
anatoliychakkaev / gist:4353750
Created December 21, 2012 16:13
Git summary for compoundjs, 21 dec 2012
project: compound
commits: 735
files : 105
authors:
594 Anatoliy Chakkaev 80.8%
41 Sascha Gehlich 5.6%
24 1602 3.3%
11 Uli 1.5%
10 Taliesin Sisson 1.4%
6 Dale Tan 0.8%
@anatoliychakkaev
anatoliychakkaev / benchmark.js
Created October 18, 2012 14:35
Jugglingdb benchmark
var limit = 10;
var success = 0;
var Schema = require('./').Schema;
var AC = require('./').AbstractClass;
var s = new Schema('redis2', {});
var util = require('util');
s.setMaxListeners(100);
var Model = s.define('Model', {
@anatoliychakkaev
anatoliychakkaev / benchmark.js
Created October 12, 2012 12:54
Benchmark sample
var score = 0;
var started = 0;
var http = require('http');
require('./server');
function request(params, callback) {
var req = new http.IncomingMessage;
req.headers = {host: params.host};
req.url = params.path;
@anatoliychakkaev
anatoliychakkaev / server.js
Created July 31, 2012 06:00 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {