Skip to content

Instantly share code, notes, and snippets.

View jankuca's full-sized avatar

Jan Kuča jankuca

  • Prague, Czech Republic
  • 03:26 (UTC +02:00)
View GitHub Profile
@jankuca
jankuca / client.js
Created July 5, 2012 17:10
OT in JS
var area = document.getElementById('area');
var buffer = [];
var position = 0;
var last_id = 1;
var socket = io.connect('http://localhost:5000');
socket.on('operation', function (operation) {
@jankuca
jankuca / compose.js
Created July 14, 2012 17:50
OT Composition in JS
var assert = require('assert');
function dump(actions, graph) {
console.log();
actions.forEach(function (action) {
if (graph) {
switch (action[0]) {
case 'retain':
process.stdout.write(new Array(action[1] + 1).join('>') + ' | ');
var darkside = require('darkside');
var DashboardController = function (users) {
darkside.base(darkside.ViewController, this);
this.$users = users;
};
require('util').inherits(DashboardController, darkside.ViewController);
var darkside = require('darkside');
var SignController = function (users) {
darkside.base(darkside.ViewController, this);
this.$users = users;
};
require('util').inherits(SignController, darkside.ViewController);
init: function (done) {
// 1
if (this.$session['user_id'] == null) {
return this.redirectTo('backend:sign:login');
}
// 2
this.$users.one(this.$session['user_id'], function (err, user) {
// 4
if (!err) {
this.current_user = user;
@jankuca
jankuca / IndexController.js
Created July 27, 2012 12:12
Darkside Form Implementation Draft
var darkside = require('darkside');
var IndexController = function () {
darkside.base(this, darkside.ViewController);
};
util.inherits(IndexController, darkside.ViewController);
@jankuca
jankuca / api-controller.js
Created August 27, 2012 19:22
Controller proposal
function ApiController() {
Controller.call(this);
}
ApiController.prototype = Object.create(Controller.prototype);
ApiController.prototype.error = function (status, message) {
this.render(status, { 'error': message });
};
- (void)connect {
NSHost *host = [NSHost hostWithName:@"example.com"];
// iStream and oStream are instance variables
[NSStream getStreamsToHost:host port:2000 inputStream:&iStream
outputStream:&oStream];
[iStream retain];
[oStream retain];
[iStream setDelegate:self];
[oStream setDelegate:self];
@jankuca
jankuca / vkontakte.js
Created September 18, 2012 08:19
VKontakte Audio Search
goog.provide('VKontakte');
goog.require('goog.crypt.Md5');
VKontakte = function (user_id, app_id, app_secret) {
this.user_id_ = user_id;
this.app_id_ = app_id;
this.app_secret_ = app_secret;
};
$a = function () {
echo 'x';
};
$a();