Skip to content

Instantly share code, notes, and snippets.

View beyoung's full-sized avatar
🥋
Focusing

beyoung beyoung

🥋
Focusing
View GitHub Profile
test
@beyoung
beyoung / 99.py
Last active December 27, 2015 20:19
9*9
def V199():
seq=(1,2,3,4,5,6,7,8,9)
for i in seq:
row=''
for j in xrange(i):
row=row+'%s*%s=%s\t'%(i,j+1,i*(j+1))
print row
if __name__=='__main__':
V199()
import requests
url = "https://www.douban.com/accounts/login"
params =
{
"form_email":"***",
"form_password":"***",
"source":"index_nav"
}
with requests.Session() as c:
// clear stringbuffer
/*
** first method
*/
StringBuffer sb = new StringBuffer("HelloWorld");
// after many iterations and manipulations
sb.setLength(0);
/*
** second method
private static void copyFileUsingJava7Files(File source, File dest)
throws IOException {
Files.copy(source.toPath(), dest.toPath());
}
private static void copyFileUsingFileStreams(File source, File dest)
throws IOException {
InputStream input = null;
import glob
for gif in glob.glob('*.gif'):
pass
import time
import datetime
print "Time in seconds since the epoch: %s" %time.time()
print "Current date and time: " , datetime.datetime.now()
print "Or like this: " ,datetime.datetime.now().strftime("%y-%m-%d-%H-%M")
print "Current year: ", datetime.date.today().strftime("%Y")
print "Month of year: ", datetime.date.today().strftime("%B")
@beyoung
beyoung / remover.java
Created March 16, 2015 09:30
java删除一个目录及其下的所有文件
/*
Method 1
*/
import org.apache.commons.io.FileUtils;
File f = new File("/dir");
FileUtils.cleanDirectory(f);
/*
Method 2
*/
@beyoung
beyoung / python_yield.py
Created April 14, 2015 02:10
python yield comprehension
A=[1,2,3,4,5]
def K():
while 1 in A:
print 'begin'
yield A[0]
print A.pop()
print 'end'
for i in K():
@beyoung
beyoung / arcpy-batch-image-clip.py
Created April 14, 2015 02:11
arcpy-batch-image-clip
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: youth
# @Date: 2015-04-11 09:20:01
# @Last Modified time: 2015-04-11 10:14:58
'''
该代码用于遥感影像的批量裁剪,其中运用到了多进程的处理模式
'''
import os
import glob