Skip to content

Instantly share code, notes, and snippets.

View jollychang's full-sized avatar
🎼
Focusing

William Zhang jollychang

🎼
Focusing
View GitHub Profile
@jollychang
jollychang / convert.sh
Created March 26, 2012 08:41
change all file format from dos to unix
find . -name '*.txt' -exec perl -i.org -pe 's/\r\n/\n/' {} \;
@jollychang
jollychang / webdriver_video.py
Created April 14, 2012 06:35 — forked from adamgoucher/webdriver_video.py
a basic example of using webdriver with html 5's video tag
# Copyright 2008-2009 WebDriver committers
# Copyright 2008-2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@jollychang
jollychang / rm2weeks_folders
Created April 16, 2012 05:45
remove 2 weeks ago folder
find . -maxdepth 1 -mtime +15 -print -type d| xargs rm -rf
@jollychang
jollychang / git-hook-functions.sh
Created April 17, 2012 07:21 — forked from evilchili/git-hook-functions.sh
function library for git hooks & a post-receive hook for automatic branch building
#!/bin/bash
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
if [ -z "$GIT_DIR" ]; then
echo >&2 "fatal: hooks/functions: GIT_DIR not set"
exit 1
fi
read oldrev newrev refname
@jollychang
jollychang / unzip.sh
Created April 23, 2012 09:52
unzip all zip file with password
find . -name 'Legends*.zip' -exec unzip -P 'www.zasv.com-JVC' {} \;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
import urllib2
URL = "http://www.douban.com/people/jollychang/miniblogs?start=%d&type=saying"
@jollychang
jollychang / config.py
Created May 8, 2012 06:48
generate weekly svn commit messages
svn = 'http://svn/trunk'
username = 'test'
password = 'test'
try:
from local_config import *
except ImportError:
pass
@jollychang
jollychang / ipython.log
Created May 9, 2012 07:17
BeautifulSoup4 parse xml format issue
In [199]: xml
Out[199]: '<?xml version="1.0" encoding="UTF-8"?><project>\n <actions/>\n <description>9999</description>\n <keepDependencies>false</keepDependencies>\n <properties/>\n <scm class="hudson.scm.NullSCM"/>\n <canRoam>true</canRoam>\n <disabled>false</disabled>\n <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>\n <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>\n <triggers class="vector"/>\n <concurrentBuild>false</concurrentBuild>\n <builders/>\n <publishers/>\n <buildWrappers/>\n</project>'
In [200]: print xml
<?xml version="1.0" encoding="UTF-8"?><project>
<actions/>
<description>9999</description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
@jollychang
jollychang / updatescm.py
Created May 28, 2012 08:00
update scm(svn) url for jenkins/husdon jobs
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
def replace_svn(config, new_scm_url):
soup = BeautifulSoup(config, 'xml')
soup.remote.string.replaceWith(new_scm_url)
xml = str(soup)
return xml
@jollychang
jollychang / copy_file_to_subfolder.sh
Created June 6, 2012 08:16
copy file to subfolder
find -mindepth 1 -maxdepth 1 -type d | while read d
do
cp -rf local_gunicorn_config.py $d
done