Skip to content

Instantly share code, notes, and snippets.

View whs's full-sized avatar

Manatsawin Hanmongkolchai whs

View GitHub Profile
@whs
whs / code.py
Created July 11, 2011 14:39
Hackathon R1
import math, struct
from PIL import Image
fName = "file1039"
D = open(fName, "rb").read()
width = int(math.sqrt(len(D)/8))
#print width
# split image to two parts
Img = D[:width*width*4]
Img2 = D[width*width*4:]
@whs
whs / code.py
Created July 12, 2011 10:06
HLP Hackathon Thursday round
import json, sys
inp = json.load(open("input.json"))
#inp = json.load(open("file145"))
#print inp
turn = 0
curPage = 0
lastPage = 0
while turn <= inp['time']:
if len(inp['switches']) > 0:
@whs
whs / code.py
Created July 14, 2011 17:17
HLP Hackathon r1-3
from __future__ import division
import datetime, hashlib, math
inp = open("file1325.txt").read().strip()
# split to sections
inp = inp.split("\r\n\r\n")
timeRate = []
inp[0] = inp[0].split("\r\n")
for x,i in enumerate(inp[0]):
@whs
whs / 7.py
Created July 23, 2011 16:21
Hackathon r2-7
input = "\x4c\x9a\x59\x3a\x35\x89\x91\x24\x5a\x9a\x5d\x3a\x35\x29\x95\x2b\x53\x8c\x35\xba\x94\xca\xd5\x2d\x4d\xae\x59\x92\x45\x6a\xd1\x21\x4c\x9a\x59"
#input="\x53\xac\x3d\x7a\xc4"
pos = 0
out=""
for i in input:
# do a circular right shift
b = list(bin(ord(i)).split("0b")[1])
# pad to 8 bits
while len(b) < 8:
b.insert(0, "0")
@whs
whs / render.py
Created July 30, 2011 12:41
WMC Renderer
from jinja2 import Environment, FileSystemLoader
from glob import glob
from os.path import basename
env = Environment(loader=FileSystemLoader('template'))
for i in glob("template/*.j.html"):
output = env.get_template(basename(i)).render()
open("output/" + basename(i).replace(".j.html", ".html"), "w").write(output)
@whs
whs / tirkxfeed.php
Created August 14, 2011 09:56
Tirkx new anime notifier
<?php
$WANT = array(
"65902", // Kami-sama no Memo-chou
"68218", // Mayo Chiki!
"50052", // Madoka Magica
"53225", // Hidan no Aria
"69900", // Mawaru Penguindrum
"50459", // GOSICK
"58315", // Steins;Gate
);
@whs
whs / grade.c
Created September 15, 2011 15:23
Grader
#include <stdio.h>
int score;
int main(void){
printf("Your score: ");
scanf("%d", &score);
if(score>100){
printf("You cheat!");
}else{
if(score>79){
printf("Grade 4");
@whs
whs / chmod.py
Created October 21, 2011 06:36
chmodder
import commands, os,stat
c=commands.getoutput("find .")
c=c.split("\n")
#644
ro = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH
#775
rw = stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH
for i in c:
#if i == ".": continue
if os.path.isfile(i):
@whs
whs / X3 input generator.py
Created October 22, 2011 17:01
COCI 2011/2012
import random
print "1000000"
for i in range(1000000):
print random.randrange(1,1000000)
whs-macbook-pro :: ~ 1 » brew doctor
/usr/local/Library/Homebrew/global.rb:43: warning: Insecure world writable dir /usr/local/share in PATH, mode 040777
/usr/local/bin/brew:74: warning: Insecure world writable dir /usr/local/share in PATH, mode 040777
/usr/local/Library/Homebrew/global.rb:43: warning: Insecure world writable dir /usr/local/share in PATH, mode 040777
/usr/local/bin/brew:74: warning: Insecure world writable dir /usr/local/share in PATH, mode 040777
Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.