Skip to content

Instantly share code, notes, and snippets.


Jesse Panganiban jpanganiban

View GitHub Profile
jpanganiban /
Last active Aug 29, 2015
MVC pattern.
from flask import Flask, render_template
app = Flask(__name__)
def api_posts(user_id):
"""Displays a page that returns all the posts created by this user."""
jpanganiban / windmovehooks.el
Last active Aug 29, 2015
Emacs Windmove Hooks
View windmovehooks.el
(defcustom windmove-pre-move-hook nil
"Hook run before windmove select is triggered."
:group 'windmove
:type 'hook)
(defcustom windmove-post-move-hook nil
"Hook run after windmove select is triggered."
:group 'windmove
:type 'hook)
jpanganiban /
Created Dec 6, 2012
A Very Simple Reactor Pattern Implementation in Python (with Gevent)
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all() # Patch everything
import gevent
import time
class Hub(object):
"""A simple reactor hub... In async!"""
jpanganiban / asyncnode.js
Created Nov 24, 2012
A short demonstration on asynchronous processing with node.
View asyncnode.js
* A short demonstration on asynchronous processing with node.
// Asynchronous adding method
var add = function(a, b, timeout, callback) {
setTimeout(function() {
callback(a + b);
}, timeout * 1000); // Sleeps for <timeout> miliseconds.
jpanganiban / class.js
Created Nov 13, 2012
Backbone.js inspired Class
View class.js
(function() {
* Class: Javascript Baseclass. Inspired by Underscore.js and Backbone.js
* NOTE: Hard dependency on Underscore.js
// Safely import underscore
var _ = this._;
jpanganiban / gist:3844261
Created Oct 6, 2012
Pygame + OpenCV Real-time Face Detection
View gist:3844261
#!/usr/bin/env python
from pygame import camera
import pygame
import time
import cv
import os
# Recognition
jpanganiban / gist:3826762
Created Oct 3, 2012
Unleash the Cracken
View gist:3826762
import requests
from bs4 import BeautifulSoup
url = ''
while True:
response = requests.get('')
soup = BeautifulSoup(response.text)
jpanganiban / gist:3826675
Created Oct 3, 2012
Scale an image by max_width and/or max_height using Wand
View gist:3826675
from wand.image import Image
def scale_image(filename, max_width=0, max_height=0, replace=False):
"""Resize an image by filename using wand (Imagemagick)
Returns tuple of filename, width and height."""
# Get filename and file format unsafely.
fname, fmat = filename.split('.')
# Create or use current filename