Skip to content

Instantly share code, notes, and snippets.

@jeswang-gist
jeswang-gist / gist:2373486
Created April 13, 2012 03:43 — forked from Jeswang/tianyabook.py
python: download tianyabook to TXT
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
from BeautifulSoup import *
import urllib2
import codecs
def urlToTxt(url):
bookUrl = url
suffix = "html"
@jeswang-gist
jeswang-gist / gist:2373487
Created April 13, 2012 03:43 — forked from Jeswang/getMV.py
python: Download MV from 音悦台
# coding=utf-8
from BeautifulSoup import *
import sys, httplib
import re
import os
import urllib,urllib2
def getMVName(url):
c=urllib2.urlopen(url)
@jeswang-gist
jeswang-gist / gist:2373524
Created April 13, 2012 03:47
python: GMusicDownloader
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
# auther: jeswang
# finished time: 2011.7.29
import os
import stat
import urllib2
import urllib
import time,datetime
@jeswang-gist
jeswang-gist / encoding_gbk.m
Created July 6, 2012 04:10
Obj-C: encoding_gbk
NSString *encode_feature_name = [feature_name stringByAddingPercentEscapesUsingEncoding:
CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000)];
NSString *feature_str = [[NSString alloc] initWithFormat:@"&s_review=%@", encode_feature_name];
//NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
//NSData *data = [[[NSString alloc] initWithFormat:@"&s_review=%@", feature_name] dataUsingEncoding:NSUTF8StringEncoding];:
@jeswang-gist
jeswang-gist / highlightBule.m
Created July 10, 2012 04:10
Obj-C: stimulate the highlightBule
+ (UIImage *) imageForSelectedBlue {
CGRect rect = CGRectMake(0, 0, 10, 10);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
size_t num_locations = 2;
CGFloat locations[2] = { 0.0, 1.0 };
CGFloat components[8] = { 0.021, 0.548, 0.962, 1.000, 0.008, 0.364, 0.900, 1.000 };
CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
+(NSString*)stringByURLEncodingStringParameter:(NSString*)originalStr
{
// NSURL's stringByAddingPercentEscapesUsingEncoding: does not escape
// some characters that should be escaped in URL parameters, like / and ?;
// we'll use CFURL to force the encoding of those
//
// We'll explicitly leave spaces unescaped now, and replace them with +'s
//
// Reference: [url]http://www.ietf.org/rfc/rfc3986.txt[/url]