Skip to content

Instantly share code, notes, and snippets.

View sunuslee's full-sized avatar

sunus sunuslee

  • Hangzhou, China
View GitHub Profile
@sunuslee
sunuslee / PSPDFThreadSafeMutableDictionary.m
Created January 1, 2016 16:45 — forked from steipete/PSPDFThreadSafeMutableDictionary.m
Simple implementation of a thread safe mutable dictionary. In most cases, you want NSCache instead, but it can be useful in situations where you want to manually control what is evicted from the cache in low memory situations. **Warning:** I only use this for setting/getting keys. Enumeration is not thread safe here and will still throw exceptio…
//
// PSPDFThreadSafeMutableDictionary.m
//
// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@sunuslee
sunuslee / PSPDFUIKitMainThreadGuard.m
Created January 1, 2016 16:34 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@sunuslee
sunuslee / hw.md
Created June 22, 2013 14:50
homework

Linux Homeworks

Execise 5

###求和

#!/bin/bash
read a
read b
echo $[$a+$b]
# Generated by iptables-save v1.4.6 on Tue May 8 19:22:59 2012
*nat
:PREROUTING ACCEPT [860:71419]
:POSTROUTING ACCEPT [167:12400]
:OUTPUT ACCEPT [357:25377]
:nat_reflection_in - [0:0]
:nat_reflection_out - [0:0]
:postrouting_rule - [0:0]
:prerouting_lan - [0:0]
:prerouting_rule - [0:0]
@sunuslee
sunuslee / gist:4155207
Created November 27, 2012 16:21
linux download tool with firefox addon:cliwget
#!/usr/bin/env python
# encoding=utf-8
import sys
import os
import datetime
SHEBANG = "#!/bin/bash\n\n"
def get_cmd(editor, initial=""):
@sunuslee
sunuslee / README.md
Created August 28, 2011 16:55 — forked from zhuowei/README.md
Demo: A Python CGI URL Shortener

A simple CGI-based web server. first, run createDatabase.py, then run run.py.

Then navigate to http://127.0.0.1:8080/ in a web browser.