Skip to content

Instantly share code, notes, and snippets.

View magicshui's full-sized avatar

Magicshui magicshui

View GitHub Profile
@magicshui
magicshui / README.md
Last active August 29, 2015 14:12 — forked from lowstz/README.md

4 step to upadte the dev environment with docker-web

  1. Replace the user-data file on your coreos-vagrant directory.
  2. Run command: vagrant provision
  3. Run command: vagrant reload
  4. Open the docker-web site, have fun :)

btw: upgrade the coreos to latest stable version if possible. You need a vpn to complete this task, because the googleapis site was blocked in China.

@magicshui
magicshui / check_same_files.py
Created September 26, 2014 10:03
Check if there same images in the folder
#coding: utf-8
import os
import hashlib
my_path = os.path.dirname(os.path.abspath(__file__))+'/qrcodes'
def get_all_files_from_directory():
files = os.listdir(my_path)
return files
def caculate_file_md5(file):
@magicshui
magicshui / hello.md
Created March 3, 2014 15:38
使用通知

亲爱的用户, 你好!欢迎使用PingMedium!

@magicshui
magicshui / tsji.py
Last active December 31, 2015 19:58
字数统计
#!/usr/bin/python
# -*- coding: utf-8 -*-
# 分别统计中文和英文的字数,不包括标点符号。
# Author: Pan Junyong from zopen.cn, panjy at zopen dot cn
import re
import sys
from types import StringType
import operator
import urllib2
@magicshui
magicshui / application.coffee
Last active December 31, 2015 10:49
nested menu list
App.ApplicationRoute = Ember.Route.extend
setupController: (controller,model)->
this._super(controller,model)
controller.set('menu',App.Menu.find())
return
@magicshui
magicshui / pickcode.py
Last active December 10, 2015 02:38
提取网页中的code渲染成图片
#coding: utf-8
import requests
import re
from requests import *
import pyquery
from pyquery import PyQuery as pq
from lxml import etree
import urllib
import sys
reload(sys)
@magicshui
magicshui / gmimap.py
Created September 26, 2012 13:23 — forked from davesteele/gmimap.py
Class and example for using the Gmail IMAP Extensions
#!/usr/bin/python -tt
""" Example of how to use Google IMAP Extensions using Python
http://code.google.com/apis/gmail/imap/
"""
import imaplib
import re
class GmailIMAP4_SSL( imaplib.IMAP4_SSL ):
@magicshui
magicshui / gist:3150835
Created July 20, 2012 13:49
河北大学校外查成绩的原理

##前言 什么是自由?自由不是想做什么都能做什么,而是当你不想做什么的时候可以选择不做。 ##正题 其实你知道,所有的成绩都是以数据的形式存放在学校的数据库中,而学校通过IP显示、网络端口的限制等一系列手段来保证数据的安全,当然,这些做法是无可厚非的,但是你不然学生查到自己的成绩就有点……

首先看下学校的查成绩方式:

  1. 登陆学校的教务系统。在这一次的登陆中,你会输入用户名、密码,学校的后台程序在接收到你的登陆请求以后就会验证,通过验证则会在本地保存一个cookie,在服务器端维护一个session。这些是你已经登陆的证明。

  2. 点击查成绩。学校的教务系统使用的iframe的嵌入方式,也就是说他其实就是外边一个框,当你点击里面链接的时候只变换里面的内容。但是你会发现这样页面的url地址并没有变化,然后就有异步刷新的假象……额,这种方式多年以前很流行,我只能这样说

NSMutableURLRequest *request;
NSError *error;
NSURLResponse* response;
NSData *receivedData;
NSString*result;
static NSString* url_pic =@"http://douban.fm/misc/captcha?size=m&id=";
request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:url_fav_song]];
[request setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" forHTTPHeaderField:@"Accept"];
[request setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20100101 Firefox/11.0" forHTTPHeaderField:@"User-Agent"];
receivedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];