http://www.openfoundry.org/tw/activities/details/301-happy-learning-ruby day1: http://goo.gl/Gq8My day2: http://goo.gl/A96TI
http://www.ruby-lang.org/zh_TW http://tryruby.org https://github.com/styleguide/ruby
| # using python-hidapi | |
| import hid | |
| import time | |
| VENDOR_ID = 0x0483 | |
| PRODUCT_ID = 0x5032 | |
| TOTAL_KEY_COUNT = 68 | |
| h = hid.device() | |
| keyboard_path = [ a['path'] for a in hid.enumerate(VENDOR_ID, PRODUCT_ID) if a['interface_number']==1][0] |
| # coding: utf-8 | |
| import json | |
| import os | |
| import sys | |
| import re | |
| import fnmatch | |
| import concurrent.futures | |
| # https://stackoverflow.com/a/5141829/554150 | |
| def find_logs(target_path): |
| /* | |
| * To change this template, choose Tools | Templates | |
| * and open the template in the editor. | |
| */ | |
| package testsnmp4j; | |
| import java.io.IOException; | |
| import java.net.InetAddress; | |
| import java.net.UnknownHostException; | |
| import java.util.Vector; |
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| import urllib2 | |
| from HTMLParser import HTMLParser | |
| def write(value=''): | |
| sys.stdout.write(str(value)) | |
| class MyHTMLParser(HTMLParser): |
| #!/usr/bin/python | |
| from pprint import pprint as p;import subprocess as s; | |
| def loop_list_print(cmds): | |
| oo = [ s.Popen(['/bin/sh','-c', cmd], stdout=s.PIPE).communicate()[0] for cmd in cmds] | |
| ooo = [ ( o, o.decode('unicode_escape',errors='replace'), o.decode('big5') ) for o in oo ] | |
| for oo in ooo: | |
| for o in oo: | |
| print(o.strip()) |
| #!/bin/bash | |
| # playdeb builds a debian package of the play framework. playdeb downloads | |
| # the playframework by itself. You run it by | |
| # playdeb.sh <version> <maintainer> | |
| # Example: | |
| # playdeb.sh 1.2.3 "Denny Colt <[email protected]>" | |
| # | |
| # The script has been tested with version 1.2.3. | |
| if [ -z $1 ] |
| #!/usr/bin/env python2.7 | |
| import urllib2 | |
| import time | |
| _ITERATIONS = 200 | |
| start_time = time.time() | |
| for i in range(0, _ITERATIONS): |
| %define release liu_mdk | |
| %define prefix /usr | |
| %define name gcin | |
| %define version 2.6.8 | |
| Summary: gcin : Chinese input method server | |
| Name: %{name} | |
| Version: %{version} | |
| Release: %{release} |