Skip to content

Instantly share code, notes, and snippets.

View MosakujiHokuto's full-sized avatar

Youkou Tenhouin MosakujiHokuto

View GitHub Profile
@MosakujiHokuto
MosakujiHokuto / top.py
Created May 11, 2013 10:12
前N头像抓取器
#!/usr/bin/python2.7
import urllib2
import httplib
import re
import sys
import PIL.Image
usernamere = re.compile('username="?(.*)"')
portraitre = re.compile(r"'portrait' : '?(.*)',")
@MosakujiHokuto
MosakujiHokuto / genphoto.sh
Created May 11, 2013 10:14
贴吧头像拼接脚本
if [ $# -lt 2 ] ;then
echo 'usage:genphoto.sh column rows'
exit -1
fi
column=$1
rows=$2
for i in `seq 1 $(($column*$rows))`;do
if [ "`identify $i.jpg | cut -d' ' -f2 | head -n1`" = "GIF" ];then
<html>
<head>
<script type="text/javascript">
if(navigator.platform.indexOf("Linux")==0){
window.location.href="http://localhost/linux.html";
} else {
window.location.href="http://localhost/other.html";
}
</script>
</head>
# coding:utf8
users_id = [600411795]
threads = 8
import os
import pickle
import requests
import threading
def getToken(session):
session.get('http://www.baidu.com')
token = session.get('https://passport.baidu.com/v2/api/?getapi&class=login&tpl=pp&tangram=false').text
token_index = token.index('login_token')+len('login_token')+2
token = token[token_index:-1]
token = token[0:token.index("'")]
return token
def getvcode(codestring):
url = 'https://passport.baidu.com/cgi-bin/genimage?'+codestring
#!/usr/bin/python
# Simple grep
# usage: simple_grep.py <regex> <filename>
import sys
import re
if __name__ == "__main__":
try:
regex = sys.argv[1]
@MosakujiHokuto
MosakujiHokuto / statichttp.py
Last active December 21, 2015 04:38
simple static file http server
import socket,select
import argparse
import os
import mimetypes
import time
class IOLoop:
def __init__(self,server):
self.clients = {}
self.server = server
#!/usr/bin/python
from os.path import *
import socket,select
import mimetypes
import argparse
import os
class httpBadRequestError(Exception):
pass
@MosakujiHokuto
MosakujiHokuto / chatroom.erl
Last active April 28, 2024 23:14
A Simple Telnet Chatroom in Erlang
-module(chatroom).
-export([run/1,worker/2,client_listener/2]).
client_listener(Client,Sock) ->
case gen_tcp:recv(Sock,0) of
{ok,Pack} ->
Client ! {sendmsg,Pack},
client_listener(Client,Sock);
Other ->
Other
@MosakujiHokuto
MosakujiHokuto / http_parser.erl
Created May 2, 2014 10:14
Static File Server in Erlang
-module(http_parser).
-export([run/1,continue/2]).
-define(PATH_RESERVED_CHARS,"!*'();:@&=+$,/?%#[]").
is_ctl(C) ->
(((0 =< C) and (8 >= C))
or ((11 =< C) and (31 >= C))
or (C == 127)).