This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ftools' | |
# DirInit::Manager handles directory initialization and clean-up when | |
# there are many concurrent processes that wants to modify the | |
# directory in the same way. | |
# | |
# An example usage is when each process wants to copy some temporary | |
# files to the directory and delete these files after finishing its | |
# job. Problems may occur when the first process delete the files | |
# while the second process is still using the files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Console login script for Kasetsart University Internet login page. | |
# It uses Curl to load pages and post data. | |
# To use it, you need ruby (sure!) and curl installed. | |
def build_hidden_option_list(html) | |
list = [] | |
tags = html.scan(/<input[^>]*hidden[^>]*>/) | |
tags.each do |tag| | |
res = tag.match(/name='([^']*)' .*value='(.*)'/) | |
list << [res[1],res[2]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Another console login script for Kasetsart University Internet login page. | |
# This one allows you to login for other machine (by specifying the IP). | |
# It uses Curl to load pages and post data. | |
def build_hidden_option_list(html) | |
list = [] | |
tags = html.scan(/<input[^>]*hidden[^>]*>/) | |
tags.each do |tag| | |
res = tag.match(/name='([^']*)' .*value='(.*)'/) | |
list << [res[1],res[2]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# This script checks the current dir for sass files, | |
# and if some of them get updated, recompiles it into css. | |
CHECK_PERIOD = 5 # in seconds | |
def find_sass_files | |
return Dir["*.sass"] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'open-uri' | |
require 'optparse' | |
DEFAULT_RECURSE_LEVEL = 2 | |
BAD_STARTERS = ['template','portal','user','book'] | |
URL_BASE = 'http://en.wikipedia.org/wiki/' | |
rlevel = DEFAULT_RECURSE_LEVEL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_roman(a): | |
if a >= '๐' and a <= '๙': | |
return chr(ord(a) - ord('๐') + ord('0')) | |
return a | |
def is_same_digit(a,b): | |
if a < '0' and a > '9': | |
return False | |
aa = to_roman(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import getpass | |
import requests | |
import codecs | |
from bs4 import BeautifulSoup | |
CAMPUS = 'B' | |
def login(username, password): | |
logindata = { 'UserName': username, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_line(line): | |
""" | |
>>> extract_line("* hello world") | |
('hello world', 1) | |
>>> extract_line("** this is a ** test!!") | |
('this is a ** test!!', 2) | |
""" | |
depth = 0 | |
l = len(line) | |
while (depth < l) and (line[depth] == '*'): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Box: | |
def __init__(self,r,c,board): | |
pass | |
class Player: | |
def __init__(self,r,c,board): | |
pass | |
def move_up(self): | |
pass |
OlderNewer