博文

目前显示的是 六月, 2016的博文

ubuntu install remarkable

wget https://remarkableapp.github.io/files/remarkable_1.62_all.deb sudo dpkg -i remarkable_1.62_all.deb  sudo apt-get upgrade -f

python 阶乘

def fact(n): if n<= 1 : return 1 else : return n*fact(n- 1 ) print fact( 8 )

python 学习

# -*- coding: utf-8 -*- import math import matplotlib.pyplot as plt if __name__=="__main__":     x=[float(i)/100 for i in range(1,300)]     y=[math.log(i) for i in x]     plt.plot(x,y,'r-',linewidth=3,label='log Curve')     a=[x[20],x[175]]     b=[y[20],y[175]]     plt.plot(a,b,'g-',linewidth=2)     plt.plot(a,b,'b+',markersize=15,alpha=0.75)     plt.legend(loc='upper left') #左上角     plt.xlabel('x')     plt.ylabel('log(x)')     plt.show

生日悖论

dupli <- function(result){   for (i in 1:length(result)){     if (duplicated(result)[i]==T){       return(1)       break()     }   } } sampl <- function(N){   Num <-0   for(j in 1:N){     set.seed(j)     result <- sample(1:365,50,replace = T)     Num <- sum(Num,dupli(result),na.rm = T)     if (j==N){       return(Num)     }   } } sampl(1000)/1000

python 学习(一)

# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import random def rand7():     return random.randint(1,7)         def rand10():     result=0     while True:         a1=rand7()-1         a2=rand7()-1         r=a1*7+a2         if r<40:             result=r/4+1             break     return result print rand10()  

python 2.7 中文编码

import之前添加 #encoding:utf-8 或 # -*- coding: utf-8 -*-

Google Drive 同步工具(grive)安装

sudo add-apt-repository ppa:nilarimogard/webupd8 sudo add-apt-repository ppa:thefanclub/grive-tools sudo apt-get update sudo apt-get install grive grive-tools search grive setup

用树莓派3做无线路由器

1、sudo apt-get install hostapd dnsmasq 2、在/etc/dnsmasq.conf末加入 interface=wlan0 dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h 3、新建/etc/hostapd/hostapd.conf,加入 interface=wlan0 hw_mode=g channel=10 auth_algs=1 wpa=2 wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP rsn_pairwise=CCMP wpa_passphrase=xuefiang ssid=xuefliang 4、修改/etc/sysctl.conf,使得 net.ipv4.ip_forward=1 5、将下面脚本加入到/etc/rc.local的exit 0前: ifconfig wlan0 down ifconfig wlan0 10.0.0.1 netmask 255.255.255.0 up iwconfig wlan0 power off service dnsmasq restart hostapd -B /etc/hostapd/hostapd.conf & > /dev/null 2>&1 sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT 6、重启树莓派