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
#!/bin/bash | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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
Felix Krull runs a PPA offering basically any version of Python (seriously, there is 2.3.7 build for vivid...) for many Ubuntu releases at | |
https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes | |
Do the usual: | |
sudo add-apt-repository ppa:fkrull/deadsnakes | |
sudo apt-get update | |
sudo apt-get install python3.5 | |
It will not overwrite your existing python3.4 which is still symlinked as python3. If you want python3.5 to be the default python3, change the symlink |
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
Class Stack(): | |
def __init__(self,size): | |
self.size=size | |
self.stack=[] | |
self.top=-1 | |
def push(self,n): | |
if self.isfull(): | |
print "Out of range" | |
else: |
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 allperm(inputstr): | |
for i in range(len(inputstr)): | |
yield(inputstr[i]) | |
for s in allperm(inputstr[:i] + inputstr[i+1:]): | |
yield(inputstr[i] + s) | |
inputstr = "abc" | |
for n in allperm(inputstr): | |
print n | |
import sys | |
from itertools import permutations |
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
<html> | |
<head> | |
<title>Line Chart</title> | |
<script src="scripts/Chart.js"></script> | |
</head> | |
<body> | |
<div style="width:60%"> | |
<div> | |
<canvas id="canvas" height="450" width="600"></canvas> | |
</div> |
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
awk 用法:awk ' pattern {action} ' | |
变量名 含义 | |
ARGC 命令行变元个数 | |
ARGV 命令行变元数组 | |
FILENAME 当前输入文件名 | |
FNR 当前文件中的记录号 | |
FS 输入域分隔符,默认为一个空格 | |
RS 输入记录分隔符 | |
NF 当前记录里域个数 |
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
date +%s 可以得到UNIX的时间戳; | |
用shell将时间字符串与时间戳互转: | |
date -d "2010-10-18 00:00:00" +%s 输出形如:1287331200 | |
而时间戳转换为字符串可以这样做: | |
date -d @1287331200 "+%Y-%m-%d" 输出形如:2010-10-18 | |
如果需要得到指定日期的前后几天,可以: | |
1、seconds=`date -d "2010-10-18 00:00:00" +%s` #得到时间戳 | |
2、seconds_new=`expr $seconds + 86400` #加上一天的秒数86400 | |
3、date_new=`date -d @$seconds_new "+%Y-%m-%d"` #获得指定日前加上一天的日前 |