[sql]
CREATE table temp as select max(id) as id FROM city_15 GROUP BY cityname ;
delete from city_15 where id not in (SELECT id from temp );
[/sql]
[sql]
CREATE table temp as select max(id) as id FROM city_15 GROUP BY cityname ;
delete from city_15 where id not in (SELECT id from temp );
[/sql]
queue.h
[c]
#include <stdlib.h>
#define QUEUE_TYPE int
void delete(void);
void insert(QUEUE_TYPE value);
QUEUE_TYPE first(void);
int is_empty(void);
int is_full(void);
void create_queue(size_t size);
void destory_queue(void);
[/c]
a_queue.c
[c]
/*
**队列的循环数组实现
*/
#include "queue.h"
#include <stdio.h>
#include <malloc.h>
#include <assert.h>
#define QUEUE_SIZE 100
#define ARRAY_SIZE QUEUE_SIZE
static QUEUE_TYPE queue[ARRAY_SIZE];
static front =1;
static rear=0;
void create_queue(size_t size){
}
void destroy_queue(void){
}
void insert(QUEUE_TYPE value){
assert(!is_full());
rear=(rear+1)%ARRAY_SIZE;
queue[rear]=value;
}
void delete(void){
assert(!is_empty());
front=(front+1)%ARRAY_SIZE;
}
QUEUE_TYPE first(void){
assert(!is_empty());
return queue[front];
}
int is_empty(void){
return (front+1)%ARRAY_SIZE==rear;
}
int is_full(void){
return (rear+2)%ARRAY_SIZE==front;
}
void p(void){
int i=0;
int m;
if(rear<front)
rear+=ARRAY_SIZE;
for(i=front;i<rear+1;i++){
m=i;
if(i>=ARRAY_SIZE)
m=i-ARRAY_SIZE;
printf("%dn",queue[m]);
}
}
int main(void){
int j=1;
for(;j<ARRAY_SIZE;j++)
insert(j);
delete();
insert(100);
p();
return 0;
}
[/c]
假设有两台机器A、B,使A自动登录B
在A机器输入
[shell]
ssh-keygen -t rsa
[/shell]
得到id_rsa.pub文件
然后将该文件追加到B机器的~/.ssh/authorized_keys文件上即可
地址http://docs.python-requests.org/en/latest/
很方便的进行网络编程
例如:
[python]
import requests
payload = {‘key1’: ‘value1’, ‘key2’: ‘value2’}
r = requests.get("http://httpbin.org/get", params=payload)
print r.url
u’http://httpbin.org/get?key2=value2&key1=value1′</pre>
[/python]
拨号安装几个包就行了
[shell]
sudo apt-get install pppoe pppoeconf
[/shell]
然后设置下
[shell]
sudo pppoeconf
[/shell]
动态域名解析,用的dnspod
[python]
#!/usr/bin/python
#coding=utf-8
import httplib, urllib
import socket
import time
params_www = dict(
login_email="xx@163.com", # replace with your email
login_password="xx", # replace with your password
format="json",
domain_id=2783079, # replace with your domain_od, can get it by API Domain.List
record_id=19154942, # replace with your record_id, can get it by API Record.List
sub_domain="www", # replace with your sub_domain
record_line=u"默认".encode("utf-8"),
)
current_ip = None
def ddns(ip):
params_www.update(dict(value=ip))
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/json"}
conn = httplib.HTTPSConnection("dnsapi.cn")
conn.request("POST", "/Record.Ddns", urllib.urlencode(params_a), headers)
response = conn.getresponse()
data = response.read()
conn.close()
def getip():
sock = socket.create_connection((‘ns1.dnspod.net’, 6666))
ip = sock.recv(16)
sock.close()
return ip
if __name__ == ‘__main__’:
while True:
try:
ip = getip()
if current_ip != ip:
if ddns(ip):
current_ip = ip
except Exception, e:
print e
pass
time.sleep(30)
[/python]