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 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 |
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 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 = [] |
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
<?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" |
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
# Hello World | |
This is your first post! | |
:::python | |
import this | |
print 'life is short, we need python!' | |
... |
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/perl | |
@files = <*>; | |
if (!$_[0]) { | |
$extension = '.png'; | |
} else { | |
$extension = $_[0]; | |
} | |
foreach $file (@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
#! /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"); |
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/perl | |
use HTML::Element; | |
use HTML::TreeBuilder; | |
use Encode; | |
#binmode DATA, "utf8"; | |
#$tree->parse_file(\*DATA); | |
#print Dumper($tree), "\n"; |
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/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"); |
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/perl | |
open(IFILE, "<index.html"); | |
open(FILE, ">_tmpfile.txt"); | |
while(<IFILE>) { | |
chomp(); | |
syswrite(FILE, $_); | |
syswrite(FILE, "\n"); | |
} |
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/perl | |
open(IFILE, "<fullteamname.html"); | |
open(FILE, ">_ftn.txt"); | |
while(<IFILE>) { | |
chomp(); | |
if ($_ =~ /<h4>(\w+?)<\/h4>/) { | |
$sec = $1; | |
print $sec; |
OlderNewer