Skip to content

Instantly share code, notes, and snippets.

View wongzigii's full-sized avatar
🎯
Focusing

Wong wongzigii

🎯
Focusing
View GitHub Profile
@wongzigii
wongzigii / IEJudge
Last active August 29, 2015 14:05
IE judge
<script>
var=(!-[1,]),
if (var)
{
alert(This is not IE explorer.)
}else{
alert(This is IE explorer.)
}
</script>
@wongzigii
wongzigii / Benchmark of Lock Performance Test
Last active October 7, 2016 14:18
Benchmark of Lock Performance Test
#import <objc/runtime.h>
#import <objc/message.h>
#import <libkern/OSAtomic.h>
#import <pthread.h>
#define ITERATIONS (1024*1024*32)
- (void)testLock
{
double then, now;
unsigned int i, count;
@wongzigii
wongzigii / introrx.md
Created November 1, 2015 15:50 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@wongzigii
wongzigii / turbo-qiniu.sh
Created March 10, 2016 13:35 — forked from trawor/turbo-qiniu.sh
本脚本解决部分地区七牛上传速度慢的问题
#!/bin/bash
#
# 通过对比 ping 响应时间,找到本机最快的上传ip
# [email protected]
#
function refresh_host()
{
IP="$1"
UPLOAD_HOST="upload.qiniu.com"
// Origin from http://mjtsai.com/blog/2016/05/24/swift-tuples-arent-equatable/
extension SequenceType {
/// Returns `true` iff an element in `self` satisfies `predicate`.
@warn_unused_result
public func contains(@noescape predicate: (Self.Generator.Element) throws -> Bool) rethrows -> Bool
}
@wongzigii
wongzigii / Profiling your Swift compilation times
Last active October 7, 2016 14:17
Profiling your Swift compilation times
// Steal from http://irace.me/swift-profiling
xcodebuild -workspace App.xcworkspace -scheme App clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt
@wongzigii
wongzigii / Find out the most commonly use linux command
Last active October 7, 2016 14:18
Find out the most commonly use linux command
history | awk '{CMD[$2]++;count++;}END { for (a in CMD) print CMD[a] "" CMD[a]/count*100"% "a;}' | grep -v "./" | column -c3 -s "" -t | sort -nr | nl | head -n 30
[
{
"coordinates":null,
"truncated":false,
"created_at":"Tue Aug 28 21:16:23 +0000 2012",
"favorited":false,
"id_str":"240558470661799936",
"in_reply_to_user_id_str":null,
"entities":{
"urls":[
This was nice and fast... but it takes up WAY TOO MUCH space. And it's annoying to write.
(I like the way I can just step into the function that calls the delegate for debugging)
What's a better way to not make me call respondsToSelector in the middle of my code? Some proxy?
struct {
unsigned int delegateWillDisplayDocument:1;
unsigned int delegateDidDisplayDocument:1;
unsigned int delegateDidShowPageView:1;
unsigned int delegateDidRenderPageView:1;
@wongzigii
wongzigii / magicalrecord_reset_coredata.m
Created March 21, 2017 02:42 — forked from binho/magicalrecord_reset_coredata.m
MagicalRecord remove and reset CoreData
- (void)resetCoreData {
DDLogInfo(@"[RESET-COREDATA] Started.");
[MagicalRecord cleanUp];
NSURL *storeURL = [NSPersistentStore MR_urlForStoreName:kMobilStoreName];
NSURL *walURL = [[storeURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-wal"];
NSURL *shmURL = [[storeURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-shm"];