Skip to content

Instantly share code, notes, and snippets.

@comfuture
comfuture / PList.as
Created January 27, 2011 01:49
simple plist parser for actionscript
package maroo.codec
{
import flash.utils.ByteArray;
import mx.utils.Base64Decoder;
public class PList
{
public static function parse(source:XML):Object
{
switch (source.name().localName) {
@comfuture
comfuture / decorator.py
Created January 15, 2011 06:51
python decorator trick (can have options or not)
def fb_session_required(arg1=True):
verify = arg1 is True
def decorate(f):
@wraps(f)
def check(*args, **kwargs):
if not request.values.has_key('fb_sig_session_key'):
return "Requires facebook session", 403
if verify and get_access_token(use_cache=False):
return "Requires valid facebook session", 403
return f(*args, **kwargs)
import urllib
import urlparse
import oauth2 as oauth
import time
consumer_key = 'YOUR_CONSUMER_KEY'
consumer_secret = 'YOUR_CONSUMER_SECRET'
class Latitude(oauth.Client):
@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
@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 / __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 / 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 / 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 / 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 / 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__ || {};