Skip to content

Instantly share code, notes, and snippets.

@bianle
bianle / python-lunar.py
Created December 28, 2015 01:18
python 日期处理
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
def GetDayOf(st):
#-天干名称
cTianGan = ["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"]
#-地支名称
cDiZhi = ["子","丑","寅","卯","辰","巳","午", "未","申","酉","戌","亥"]
#-属相名称
@bianle
bianle / ubuntu-static-ip.md
Last active December 10, 2015 08:17
ubuntu静态ip设置
sudo vim /etc/network/interfaces
auto lo
iface lo inet loopback
# Assgin static IP 
iface eno16777736 inet static
address 192.168.81.222 #change to your static IP
netmask 255.255.255.0 #change to your netmask
@bianle
bianle / Native2Ascii.java
Created December 3, 2015 13:01
java 编码解码
/**
* native2ascii.exe Java code implementation.
*
* @author
* @version 1.0
*/
public class Native2Ascii {
/**
* prefix of ascii string of native character
@bianle
bianle / 0_ascii_directory_tree.sh
Last active September 2, 2016 09:05
ascii directory tre
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
@bianle
bianle / 0-java-date.java
Last active January 5, 2016 02:46
java日期操作
/**
*
* @Title: getWeekDays
* @Description: 通过给定日期返回所在周的起止日期
* @return List
* @throws
*/
public static List<Date> getWeekDays(Date arg){
List list = new ArrayList();
Calendar cal = Calendar.getInstance();
@bianle
bianle / 0-sae-bucket.py
Created November 19, 2015 14:55
python sae
# 创建一个bucket的instance
>>> from sae.storage import Bucket
>>> bucket = Bucket('t')
>>> # 创建该bucket
>>> bucket.put()
>>> # 修改该bucket的acl和缓存过期时间。
>>> bucket.post(acl='.r:.sinaapp.com,.r:sae.sina.com.cn', metadata={'expires': '1d'})
@bianle
bianle / 0-webpy-json.py
Last active November 19, 2015 14:56
web.py
import web
import json
class index:
def GET(self):
pyDict = {'one':1,'two':2}
web.header('Content-Type', 'application/json')
return json.dumps(pyDict)
@bianle
bianle / 0-str2list.py
Last active November 19, 2015 14:57
python处理字符串
## str转list
str='x7tQ3'
lst = list(str)
print lst
## ['x', '7', 't', 'Q', '3']
## list转str
str = ''.join(lst)
print str
## x7tQ3
<script>
function randomNum(min,max)
{
var range = max - min;
var rand = Math.random();
return(min + Math.round(rand * range));
}
function randomStr(len){
var ret = "";
var abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
@bianle
bianle / 0-punycode.py
Last active November 19, 2015 14:57
python encode decode
>>> unicode(u'谷歌.cn').encode('idna')
'xn--flw351e.cn'
>>> unicode('xn--flw351e.cn').decode('idna')
u'\u8c37\u6b4c.cn'
## Not support narow Python
## Cause `ValueError: unichr() arg not in range(0x10000) (narrow Python build)`
>>> b'ls8h'.decode('punycode')
'\U0001f4a9'