Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Hank Bao hankbao

🎯
Focusing
Block or report user

Report or block hankbao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hankbao
hankbao / ClosureStackOverflow.swift
Created May 13, 2015
call() and get a stack overflow
View ClosureStackOverflow.swift
import Swift
class ClosureStackOverflow {
private var b: Bool = false
private func callClosure1(callback: Void -> Void) {
println("in closure 1")
callback()
}
private func callClosure2(callback: Void -> Void) {
View GCDMulticastDelegate.h
#import <Foundation/Foundation.h>
@class GCDMulticastDelegateEnumerator;
/**
* This class provides multicast delegate functionality. That is:
* - it provides a means for managing a list of delegates
* - any method invocations to an instance of this class are automatically forwarded to all delegates
*
* For example:
@hankbao
hankbao / UIDeivce+Processes.m
Created Sep 18, 2015
UIDevice Category For Processes
View UIDeivce+Processes.m
// .h
@interface UIDevice (ProcessesAdditions)
- (NSArray *)runningProcesses;
@end
// .m
#import <sys/sysctl.h>
@implementation UIDevice (ProcessesAdditions)
View image_replacer.js
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@hankbao
hankbao / Fuckgfw.conf
Created Oct 12, 2015 — forked from jason5ng32/surge.conf
Surge Config
View Fuckgfw.conf
[General]
loglevel = notify
bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12,127.0.0.0/24
[Proxy]
// ADD YOUR PROXY HERE, DON'T FORGET TO REMOVE #
# Proxy = http,$IP,$PORT,$USERNAME,$PASSWORD
# Proxy = https,$IP,$PORT,$USERNAME,$PASSWORD
@hankbao
hankbao / sudoku.hs
Created Oct 30, 2015 — forked from kristopherjohnson/sudoku.hs
Sudoku solver in Haskell
View sudoku.hs
#!/usr/bin/env runhaskell
-- Note: For a slight improvement in performance, import the non-portable
-- Data.Array.Unboxed module instead of Data.Array, and change the Board
-- type below to use "UArray" instead of "Array".
import Data.Array
-- Solve the example puzzle specified below
-- TODO: read puzzle from input
main = do
@hankbao
hankbao / gist:4378943
Created Dec 26, 2012
Get a CGAffineTransform from a UIInterfaceOrientation
View gist:4378943
#define DEGREES_TO_RADIANS(degrees) (degrees * M_PI / 180)
static CGAffineTransform transformForOrientation(UIInterfaceOrientation orientation)
{
switch (orientation) {
case UIInterfaceOrientationLandscapeLeft:
return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90));
case UIInterfaceOrientationLandscapeRight:
return CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90));
View RVNReceiptValidation.m
//
// RVNReceiptValidation.m
//
// Created by Satoshi Numata on 12/06/30.
// Copyright (c) 2012 Sazameki and Satoshi Numata, Ph.D. All rights reserved.
//
// This sample shows how to write the Mac App Store receipt validation code.
// Replace kRVNBundleID and kRVNBundleVersion with your own ones.
//
// This sample is provided because the coding sample found in "Validating Mac App Store Receipts"
@hankbao
hankbao / gist:5194309
Created Mar 19, 2013
Chop a rectangle from another rectangle on iOS
View gist:5194309
static
void divide_rect_from_rects(CGRect rect1, CGRect rect2, CGRect *slice, CGRect *remainder, CGRectEdge edge)
{
NSCParameterAssert(slice);
NSCParameterAssert(remainder);
CGRect intersected = CGRectIntersection(rect1, rect2);
if (CGRectIsEmpty(intersected)) {
*slice = CGRectNull;
return;
@hankbao
hankbao / reset_nic.sh
Created Apr 11, 2013
Reset network interfaces on OS X
View reset_nic.sh
#!/bin/sh
sudo ifconfig en0 down
sudo ifconfig en1 down
sudo route -n flush
sudo ifconfig en0 up
sudo ifconfig en1 up
You can’t perform that action at this time.