Skip to content

Instantly share code, notes, and snippets.

View ngpestelos's full-sized avatar

Nestor G Pestelos Jr ngpestelos

View GitHub Profile
Problem: You want to access Futon on a remote server but do not want port 5984 to listen for outside connections.
Solution: Tunnel through a local port using SSH. [1]
Example:
ssh -L5984:127.0.0.1:5984 ssh.example.com
[1] http://wiki.apache.org/couchdb/Frequently_asked_questions
Had some time during the weekend to tinker with CouchApps and Evently.
0 - Preliminaries
* setup couchdb 0.11 and couchapp
* remove old couchdb versions lying around your system
* there's a current issue with ubuntu 9.10 and javascript libraries (installing libmozjs removes firefox)
* a CouchApp is a wrapper for a design doc
1 - Where to start?
var sys = require("sys"), http = require('http'), encode = require('./encoding');
function createAuthorization(username, password) {
return "Basic " + encode.base64(username + ":" + password);
}
Object.prototype.filter = function(fn) {
var result = {};
for (var name in this) {
if (this.hasOwnProperty(name)) {
var sys = require('sys'), http = require('http'), twitter = require('./twitter'), couch = require("./node-couch");
Array.prototype.each = function(fn) {
for (var i = 0; i < this.length; i++) {
var item = this[i];
fn.call(null, item);
}
return this;
};
(as of iOS 4.0.1) attaching the player to a view:
[[player view] setFrame: [viewForMovie bounds]];
[self.viewForMovie addSubview:player.view];
Header scan and Function scan [1]
Reading code is like reading the Talmud [2]
Writing readable code
* function names
* variable names
* loops (hard to debug)
* short code (when to split functions)
@ngpestelos
ngpestelos / gist:865365
Created March 11, 2011 02:41
Mobile VLC
iOS app running on armv7.
MobileVLCAppDelegate
MVLCMovieViewController
* creates a VLCMediaPlayer (sets delegate to itself and drawable surface to movieView)
* sets media to the URL provided
* tells media player to play
@ngpestelos
ngpestelos / gist:865375
Created March 11, 2011 02:53
MobileVLCKit
Objective-C classes interfacing with libvlc.
VLCLibrary
* sharedInstance
* creates default params
* calls libvlc_new_with_builtins by passing lib_vlc_params
VLCMedia mediaWithPath:
* uses a shared instance to create a VLCMedia object (see initWithURL; VLCLibrary)
* libvlc_media_new_location (see media.c)
@ngpestelos
ngpestelos / gist:865406
Created March 11, 2011 03:29
VLC input
access
decoder
* DecoderThread
* DecoderProcess
demux
stream
@ngpestelos
ngpestelos / gist:890125
Created March 28, 2011 07:48
libsrtp crypto kernel
(see crypto/include/crypto_kernel.h)
Types
* crypto_kernel_state_t
* cipher_type_id_t
* auth_type_id_t
* crypto_kernel_t (at most one instance)
Functions
* crypto_kernel_init