Skip to content

Instantly share code, notes, and snippets.

View larrycai's full-sized avatar
💭
I may be slow to respond.

Larry Cai larrycai

💭
I may be slow to respond.
View GitHub Profile
@larrycai
larrycai / cross-execution.py
Created September 21, 2010 04:52
cross platform execution in python
# call markdown to convert markdown -> html in memory
def mkd2html(inFilename):
#
# and there are different ways to handle windows and unix
# also subprocess.check_output exist in python27 only.
#
cmd = []
# mostly msysgit is used, cygwin, it is win32 platform
if sys.platform == "win32":
# i may need to check cygwin as well
@larrycai
larrycai / pom.xml
Created April 28, 2011 07:08
embed winstone for web application in maven
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- file is based on jenkin's solution https://github.com/jenkinsci/jenkins/commit/f0fa10bd63487e8754c678f2984e5bd655a51aa6
& latest pom.xml
https://github.com/jenkinsci/jenkins/blob/master/war/pom.xml
-->
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.demo</groupId>
<artifactId>helloworld2-war</artifactId>
@larrycai
larrycai / boot.sh
Created July 11, 2011 05:05
create virtual machine (kvm) for ubuntu
# This script will run as root the first time the virtual machine boots
#
# set proxy if needed
sudo echo "http_proxy=http://proxy.server/" >> /etc/environment
export http_proxy=http://proxy.server:8080/
## #Expire the user account
apt-get update
apt-get upgrade
@larrycai
larrycai / p1.py
Created October 13, 2011 00:47
solution for problem 1
# http://projecteuler.net/problem=1
total = 0;
for i in range(1,1000):
if (i % 3 == 0) or (i % 5 ==0):
# print i;
total += i;
print "the sum of all the multiples of 3 or 5 below 1000: " , total
@larrycai
larrycai / p2.py
Created October 13, 2011 01:02
solution for problem 2
# http://projecteuler.net/problem=2
total = 0;
a,b = 0,1
while a<4000000:
a,b = b,a+b
if a %2 == 0:
print a;
total += a;
print total
@larrycai
larrycai / p1.py
Created October 13, 2011 02:04
http://projecteuler.net solutions in python
# solution from http://weibo.com/1937408130
total = sum([x for x in range(1,1000) if x % 3 == 0 or x % 5 == 0])
print total
@larrycai
larrycai / sample1.tex
Created February 1, 2012 14:25
regex in ruby to convert from sample1.tex to sample2.tex ?
\begin{enumerate}\setlength{\itemsep}{1pt}\setlength{\parskip}{0pt}\setlength{\parsep}{0pt}
\item
item1
\item
item2
\end{enumerate}
\begin{enumerate}\setlength{\itemsep}{1pt}\setlength{\parskip}{0pt}\setlength{\parsep}{0pt}
\item
@larrycai
larrycai / env.rb
Created March 12, 2012 14:37
make aruba work for unix and windows under cucumber
require 'aruba/cucumber'
module ArubaOverrides
def detect_ruby(cmd)
processor, platform, *rest = RUBY_PLATFORM.split("-")
#puts platform
if platform =~ /w32$/ && cmd =~ /^mkbok / #mkbok is the real command in features
"ruby -I../../lib -S ../../bin/#{cmd}"
else
"#{cmd}"
end
@larrycai
larrycai / redmine2tuleap.py
Created October 16, 2012 07:18
covert the issues from redmine to tuleap
#!/usr/bin/env python
import csv
import sys
# read sample tuleap csv header to avoid some field changes
tuleapcsvfile = open('tuleap.csv', 'rb')
reader = csv.DictReader(tuleapcsvfile)
# open stdout for output
@larrycai
larrycai / hello2.py
Created December 16, 2012 15:56 — forked from anonymous/hello2.py
update the bug for passing parameter
#!/usr/bin/env python
"""
hello2.py hello world sample
Usage: hello2.py [options]
Options:
-m messages message list, separare by ','
-h this help
Mail bug reports and suggestion to : Larry Cai <larry.caiyu AT gmail.com>