Skip to content

Instantly share code, notes, and snippets.

@comfuture
comfuture / hello.js
Created September 10, 2010 13:56
nano framework for node.js
with (require('./nano')) {
get('/hello', 'Hello, world');
get('/index.html', readfile('index.html'));
static_file('/about.html');
get('/bye', function() {
return 'Bye~ ' + request.args['name'];
});
@comfuture
comfuture / ajaxize.js
Created September 16, 2010 11:31
ajaxize.js
function ajaxize(selector) {
$(selector).each(function(idx, el) {
el = $(el);
var opts = (el.attr('rel') || '').split(' ');
var hasOption = function(opt) { return opts.indexOf(opt) > -1 }
var pos = hasOption('before') ? 'Before' : 'After';
var toggle = hasOption('toggle');
var increase = hasOption('increase');
var inherit = hasOption('inherit');
var target_name = el.attr('target');
@comfuture
comfuture / jquery.oop.js
Created October 13, 2010 09:05
jQuery OOP extension
(function($){
$.Class = function(code){
var klass = function() {
var instance = (arguments[0] !== null && this.__init__ && typeof this.__init__ == 'function') ? this.__init__.apply(this, arguments) : this;
return instance;
};
$.extend(klass, this);
$.extend(klass.prototype, {
'bind': function(type, fn) {
this.__events__ = this.__events__ || {};
@comfuture
comfuture / manage-daemon
Created November 11, 2010 06:28
init script sample for gunicorn daemonized flask app
#!/bin/bash
gunicorn="/usr/local/bin/gunicorn"
prog="dev.maroo.info"
PROJECT_HOME="/home/maroo/sites/$prog"
pid="/var/lock/$prog"
RETVAL=0
start() {
@comfuture
comfuture / gist:672902
Created November 11, 2010 17:56
sync local added file to remote git repository
on adding folder items to dropbox after receiving added_files
set firstFileName to the name of item 1 of added_files
set numFiles to count items in added_files
repeat with i from 1 to number of items in added_files
set posixPath to POSIX path of (item i of added_files as string) as string
do shell script "git add " & posixPath
end repeat
do shell script "git commit -a -m'added " & firstFileName & "...'"
do shell script "git push"
end adding folder items to
@comfuture
comfuture / juice.sample.js
Created December 2, 2010 05:30
sample juice usage
juice.namespace('sample');
juice.include('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js')
.css('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/flick/jquery-ui.css')
.require('ui.Form')
(function() {
juice.sample.Calendar = Class({
__init__: function() {
@comfuture
comfuture / __init__.py
Created December 17, 2010 09:25
minimal set of delicious.com backup source (using mongodb)
from pymongo import Connection
from BeautifulSoup import BeautifulSoup
from flask import Flask, render_template, request, redirect, url_for
from .util import normalize_url
app = Flask(__name__)
conn = Connection('localhost')
db = conn.test
bookmarkr = db.bookmarkr
@comfuture
comfuture / AlignBall.as
Created December 24, 2010 05:02
as3 coding convention and example
/**
* 객체들끼리 서로 밀어내며 자리를 찾아 지속적으로 동일한 간격을 유지하게 하는 프로그램 예제
* @author 거친마루 <comfuture@_GMAIL_COM_>
*/
package
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
@comfuture
comfuture / BMPDecoder.as
Created December 27, 2010 09:42
window BMP file format decoder - bigger but supports more
package jp.plaync.image.codec
{
import flash.display.BitmapData;
import flash.errors.IOError;
import flash.utils.ByteArray;
import flash.utils.Endian;
/**
* Windows BMP file decoder
* @see http://ntt.cc/2008/10/01/using-bmpdecoder-class-to-load-an-external-bmp-file-rle-compression-support.html
import urllib
import urlparse
import oauth2 as oauth
import time
consumer_key = 'YOUR_CONSUMER_KEY'
consumer_secret = 'YOUR_CONSUMER_SECRET'
class Latitude(oauth.Client):