Skip to content

Instantly share code, notes, and snippets.

@sfantree
sfantree / cookieshandle.py
Created April 13, 2020 09:33
Python cookies with Chrome EditThisCookie
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
you can find a test web login interface like: https://gist.github.com/mschoebel/9398202
download and install EditThisCookie
https://chrome.google.com/webstore/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg
click the icon and copy the cookie string
'''
@sfantree
sfantree / readme.md
Last active March 29, 2020 05:47
convert web page to kindle
@sfantree
sfantree / 字符串去转义.py
Created January 7, 2017 03:12
字符串去转义
import re
a='\\xe3\\x82\\xae\\xe3\\x83\\xaa\\xe3\\x82\\xae\\xe3\\x83\\xaaeye'
print repr(a)[1:-1]
b = eval("'%s'" % a)
print b
@sfantree
sfantree / sqlite.py
Created October 22, 2016 08:17
Python向Sqlite批量插入数据,测试硬盘性能
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sqlite3
from faker import Faker
conn = sqlite3.connect('test.db')
print "Opened database successfully";
cur = conn.cursor()
cur.execute("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'person'")
#!/usr/bin/python
import re
import urllib
def getHtml(url):
page=urllib.urlopen(url)
html=page.read()
return html
def getMp4(html):
r=r"href='(http.*\.mp4)'"
re_mp4=re.compile(r)
@sfantree
sfantree / erchashu.c
Last active October 20, 2016 10:08
erchashu.c
#define MaxSize 20
#include<iostream>
#include<cstdlib>
using namespace std;
//1、定义二叉链表(P121)
typedef struct BiTNode{
char data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
#include <iostream>
#include <cstdlib>
using namespace std;
typedef struct Lnode{
char name[20];
float num;
struct Lnode *next;
}Lnode,*Linklist;
void CreateList(Linklist &L,int n)//尾插法,p38页
{
一 实验介绍
本项目带领你学习用 C 语言实现 ping 命令。通过本项目中你可以更深入地理解 TCP/IP 协议,掌握 C 语言进行网络编程的技巧方法。
1.1 知识点
TCP/IP 协议介绍
获取系统运行时间
原始套接字
1.2 效果截图
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <netdb.h>
#define ICMP_SIZE (sizeof(struct icmp))
#define ICMP_ECHO 8
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<errno.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#define DEFAULT_PORT 8000
#define MAXLINE 4096
int main(int argc, char** argv)