Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View eiffelqiu's full-sized avatar

Eiffel.GM eiffelqiu

  • Beijing, P.R.China
View GitHub Profile
@eiffelqiu
eiffelqiu / index.js
Last active August 29, 2015 14:14 — forked from edokeh/index.js
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@eiffelqiu
eiffelqiu / web2pdf.rb
Created October 1, 2012 08:01
Convert html web to pdf
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://learnyousomeerlang.com/content'))
urls = [ 'http://learnyousomeerlang.com/content' ] + doc.xpath('//h3/a').map { |n| n.attribute('href').to_s }
exec("./wkhtmltopdf -s A4 #{ urls.join(' ') } learnyousomeerlang.pdf")
@eiffelqiu
eiffelqiu / nodejs_perf_v2.js
Created September 15, 2012 06:40
improved version test nodejs performance
var fs = require('fs');
var from = new Date().getTime();
var waiting = 0;
fs.readFile("test.mp4",function(err, data) {
if(err)
console.log("read error: ", err);
else {
for (var i = 1; i <= 10; i++) {
waiting ++;
fs.writeFile(__dirname + "/new.mp4", data , function(err) {
@eiffelqiu
eiffelqiu / nodejs_perf.js
Created September 15, 2012 05:05
Test Nodejs read and write file performance
var fs = require('fs');
var from = new Date().getTime();
for (var i = 1; i <= 10; i++) {
fs.readFile("test.mp4",function(err, data) {
if(err)
console.log("read error: ", err);
else {
fs.writeFile(__dirname + "/new.mp4", data , function(err) {
if(err) {
console.log("write error: ", err);
@eiffelqiu
eiffelqiu / check_if_simulator.m
Created May 27, 2011 00:43
Check If Simulator
#define CHECKIFSIMULATOR(MSG) { \
if ([[[UIDevice currentDevice] model] rangeOfString:@"Simulator"].location != NSNotFound) { \
UIAlertView *simError = [[UIAlertView alloc] initWithTitle:@"iOS Simulator" \
message:MSG \
delegate:self \
cancelButtonTitle:@"Okay" \
otherButtonTitles:nil]; \
[simError show]; \
[simError release]; \
} \
@eiffelqiu
eiffelqiu / UIColor+ColorCategoryg.m
Created May 27, 2011 00:31
Hex color to UIColor
// Usage: [self.navigationBar setTintColor: [AppDelegate colorWithHexString:@"4891CC"]];
@interface UIColor (ColorCategory)
+(UIColor *) colorWithHexString:(NSString *)hex;
@end
@implementation UIColor (ColorCategory)
//
// NPReachability+Backward.h
//
// NPReachability+Backward is a category over the NPReachability class.
//
// It implements some of the Reachability methods and thus makes it easy to integrate with existing projects.
//
#import <Foundation/Foundation.h>
#import "NPReachability.h"
@eiffelqiu
eiffelqiu / StrippingHTML.m
Created May 25, 2011 01:46
Stripping HTML
- (NSString *)flattenHTML:(NSString *)html trimWhiteSpace:(BOOL)trim {
NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:html];
while ([theScanner isAtEnd] == NO) {
// find start of tag
@eiffelqiu
eiffelqiu / UIDeviceHardware.h
Created May 25, 2011 01:36
Determine device (iPhone, iPod Touch) with iPhone SDK
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@eiffelqiu
eiffelqiu / NSString+MD5.m
Created May 25, 2011 01:24
NSString MD5
@interface NSString (MD5)
-(NSString *) MD5;
@end
@implementation NSString (MD5)
- (NSString *) MD5{
const char* string = [self UTF8String];