Skip to content

Instantly share code, notes, and snippets.

View whs's full-sized avatar

Manatsawin Hanmongkolchai whs

View GitHub Profile
#!/usr/bin/env python
import re, sys
def seperate(e):
"""seperate the equalization:
eg. 2x^2+3x-2 -> ["2x^2", "3x", "-2"]"""
s = re.split(r"([+-])", e)
opt = []
nextMinus=False
if s[0] == "":
<?php
$allowed = array("Solve", "Simplify", "Factor", "Think");
if(!in_array($_REQUEST['method'], $allowed)) die("Bad method!");
if(strstr(";", $_REQUEST['input'])) die("Hack?");
$input = $_REQUEST['input'];
$input = str_replace("=", "==", $input);
$path = "C:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\math.exe";
$cmd = $_REQUEST['method'] . "[".$input."]";
if($_REQUEST['method'] == "Think"){
$cmd = $_REQUEST['input'];
@whs
whs / twitter.js
Created October 21, 2010 17:10
Twitter OAuth helper
/**
* @license The Twitter library is licensed under the GNU Lesser General Public License version 3
* Portions from the Prototype JavaScript library
*/
/* prototypejs/src/lang/function.js */
function prototype_update(array, args) {
var arrayLength = array.length, length = args.length;
while (length--) array[arrayLength + length] = args[length];
return array;
@whs
whs / index.html
Created October 23, 2010 08:55
Barcampbangkok4 twitter client
<!doctype html>
<html>
<head>
<title>Barcampbangkok 4 -Twitter client</title>
<script src="jquery.js"></script>
<script src="sha1.js"></script>
<script src="oauth.js"></script>
<script src="twitter.js"></script>
<script src="render.js"></script>
<link rel="stylesheet" href="render.css">
@whs
whs / imageloader.js
Created April 3, 2011 03:57
libimageloader loads image from photo upload services
/**
* @license The imageloader.js library is licensed under GNU Lesser General Public License v3 or later
*/
(function(){
/**
* TwitPic Image Loader
* Example: ldr = new TwitPicLoader("http://twitpic.com/asdf123");
* @param {string} URL of the TwitPic page. Eg. http://twitpic.com/asdf123
* @constructor
*/
@whs
whs / glados-focus
Created April 17, 2011 11:42
@gladosAtHome source
TWEND
Kit
AAAAA
RUSH
C
TTori
BEAT
TB
AS
Amnesia
@whs
whs / gladosalarm.py
Created April 18, 2011 13:44
GLaDOS@Home alarm clock
#!/usr/bin/python
# READ FIRST
# This software poll HP2LY every 5 minutes and will play
# any ffmpeg supported file 20 times after 95%.
# To quit press Ctrl+C in Terminal.
# Closing ffplay would just respawn it.
#
# Dependency:
# Ubuntu: sudo apt-get install ffmpeg
# Fedora: su -c 'yum install ffmpeg'
@whs
whs / reader.py
Created April 24, 2011 14:04
Source Closed Captions <> PO Files
import re, sys, os, codecs
from polib import *
try:
from collections import OrderedDict
except ImportError:
## {{{ http://code.activestate.com/recipes/576693/ (r9)
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates.
try:
@whs
whs / bottrust.py
Created May 8, 2011 07:52
Code Jam 2011
import threading, time, sys, re
inData = open('a-small.in').read().strip()
#inData = """3
#4 O 2 B 1 B 2 O 4
#3 O 5 O 8 B 100
#2 B 2 B 1"""
class Awesome(threading.Thread):
def __init__(self, i):
threading.Thread.__init__(self)
self.i = i
@whs
whs / nodetracker.js
Created May 15, 2011 18:40
Keyword tracker
// (C) 2011 Manatsawin Hanmongkolchai
// GNU GPL v3
var twitter = require('twitter');
var growl = require('growl');
var twit = new twitter({
consumer_key: '',
consumer_secret: '',
access_token_key: '',
access_token_secret: '',
});