Skip to content

Instantly share code, notes, and snippets.

View jankuca's full-sized avatar

Jan Kuča jankuca

  • Prague, Czech Republic
  • 02:32 (UTC +02:00)
View GitHub Profile
@jankuca
jankuca / uuid.js
Created January 21, 2011 08:20
UUID JavaScript library; based on the current timestamp, the user's browser, the current URL and a random number
goog.provide('uuid');
var uuid = function () {
var parts = new Array(4);
// a - unix timestamp
var time = Math.round(new Date().getTime() / 1000);
parts[0] = time.toString(16).substring(0, 8);
@jankuca
jankuca / example.js
Created November 12, 2011 16:40
gzip for native node.js http.Server
var http = require('http');
var gzip = require('http-gzip');
var server = http.createServer(function (req, res) {
gzip(req, res);
res.writeHead(200, {
'content-type': 'text/plain'
});
res.write('I am gonna be gzip encoded, dude!');
@jankuca
jankuca / injector.js
Created May 14, 2012 23:05
Injector.js
/**
* @constructor
*/
function Injector() {
/**
* @type {!Object.<string, function(Injector=): !Object>}
*/
this.factories = {};
@jankuca
jankuca / utils.js
Created March 16, 2011 00:09
JavaScript Kit
(function () {
if (!Object.defineProperty) return;
Object.defineProperty(Function.prototype, 'initializing', {
value: false,
writable: true
});
Object.defineProperty(Function.prototype, '$super', {
value: function () {
@jankuca
jankuca / shortcut.js
Created February 3, 2011 19:12
Shortcut JavaScript library
/**
* Shortcut Library
* --
* @version 2.01.B
* @author Binny V A
* @modifier Jan Kuča <jan@jankuca.com>
* @license BSD
*/
(function (window) {
var document = window.document;
@jankuca
jankuca / index.js
Created March 17, 2011 09:48
Simple Facebook Graph API Node.js Client
var HTTPS = require('https');
var QueryString = require('querystring');
/**
* Facebook API Wrapper
* @constructor
* @param {Object} info Info about the Facebook application
*/
var Client = function (info) {
if (!info.id) {
#!/bin/sh
REPO_DIRNAME=$PWD
REPO_BASENAME=$(basename $REPO_DIRNAME)
REPO_BASENAME=${REPO_BASENAME%.git}
if [ $REPO_BASENAME = "gitolite-admin" ]; then
$a = function () {
echo 'x';
};
$a();
@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;
};
- (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];