Skip to content

Instantly share code, notes, and snippets.

View dalang's full-sized avatar

大浪 dalang

  • Dada Group
  • Shanghai
View GitHub Profile
@dalang
dalang / build_teamlogo_css.pl
Created May 11, 2013 17:00
load data from a array, ouput css code into a file
#!/usr/bin/perl
@NBAABB = ('atl', 'bos', 'bkn', 'cha', 'chi', 'cle', 'dal', 'den', 'det', 'gsw', 'hou', 'ind', 'lac', 'lal', 'mem', 'mia', 'mil', 'min', 'nor', 'nyk', 'okc', 'orl', 'phi', 'pho', 'por', 'sac', 'sas', 'tor', 'uth', 'was');
open(FILE, ">_1tmpfile.txt");
foreach (@NBAABB) {
chomp;
#syswrite(FILE, '.' .$_. "-theme {\n");
@dalang
dalang / get_baidu_poi.pl
Created May 11, 2013 17:18
parse data from baidu map, parse for "苍南合作银行" sites info and output these info into a file
#! /usr/bin/perl
use HTML::Element;
use HTML::TreeBuilder;
use Encode;
#binmode DATA, "utf8";
#$tree->parse_file(\*DATA);
#print Dumper($tree), "\n";
@dalang
dalang / contact_excel.pl
Created May 11, 2013 17:12
edit excel file and save as a new file with ParseExcel Package parse crscy contact excel file and output contact info in xml format
#! /usr/bin/perl
use strict;
use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::FmtUnicode; #◊÷∑˚±‡¬Î
open(FILE, '>_ftn.txt');
syswrite(FILE, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n
<list>\n");
@dalang
dalang / add_extension_name.pl
Created May 11, 2013 17:09
##file operation## delete tmp bakup files under windows(file name end with '~') add extension name to all file under dir .
#! usr/bin/perl
@files = <*>;
if (!$_[0]) {
$extension = '.png';
} else {
$extension = $_[0];
}
foreach $file (@files) {
@dalang
dalang / helloworld
Created May 8, 2013 03:18
farbox markdown syntax showing code block
# Hello World
This is your first post!
:::python
import this
print 'life is short, we need python!'
...
@dalang
dalang / AndroidManifest.xml
Created September 28, 2012 08:10
For Android basic knowledge training in CRSCY
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.dalang.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
@dalang
dalang / yanghui_triangle.py
Created May 11, 2015 17:07
print yanghui triangle
def yanghui_triangle():
def safe_get_value(l, index):
length = len(l)
return 0<= index < length and l[index] or 0
tmp = [1]
while True:
yield tmp
length = len(tmp)
new = []
@dalang
dalang / retry_decorator.py
Created April 21, 2015 05:30
decorator for retrying function in specific times
def retry(attempt, raise_on_fail=False):
def decorator(func):
def wrapper(*args, **kw):
att = 0
last_except = None
while att < attempt:
try:
return func(*args, **kw)
except Exception as e:
att += 1