Skip to content

Instantly share code, notes, and snippets.

View bogardon's full-sized avatar

John Z Wu bogardon

  • Google
  • San Mateo, CA
View GitHub Profile
@bogardon
bogardon / keybase.md
Last active September 16, 2019 18:28

Keybase proof

I hereby claim:

  • I am bogardon on github.
  • I am bogardon (https://keybase.io/bogardon) on keybase.
  • I have a public key ASBStiOygv-K63_17Fcl7nDccUXVcmcZH9JR7LOt6hArjQo

To claim this, I am signing this object:

# -*- coding: utf-8 -*-
$:.unshift(ENV["RUBYMOTION_LIB"] || "/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require 'bundler'
require 'sugarcube-attributedstring'
Bundler.require
Motion::Project::App.setup do |app|
app.xcode_dir = "/Applications/Xcode.app/Contents/Developer"
@bogardon
bogardon / model.rb
Last active December 19, 2015 02:09
shitty model baseclass
class User < Model
set_attributes :username => :string,
:email => :string,
:api_token => :string,
:avatar_url_thumb => :url,
:avatar_url_full => :url
set_relationships :answers => :Answer,
:spots => :Spot
@bogardon
bogardon / gist:5553003
Created May 10, 2013 07:45
UIActionSheet WTF?
(lldb) po [[UIApplication sharedApplication] windows]
$13 = 0x09ee0630 <__NSArrayM 0x9ee0630>(
<UIWindow: 0x9e8ff00; frame = (0 0; 320 568); layer = <UIWindowLayer: 0x9e90300>>,
<UITextEffectsWindow: 0x9a77be0; frame = (0 0; 320 568); hidden = YES; opaque = NO; layer = <UIWindowLayer: 0x9a77d30>>,
<_UIAlertOverlayWindow: 0x9edf900; frame = (0 0; 320 568); layer = <UIWindowLayer: 0x9edf9d0>>
)
(lldb) po [[[UIApplication sharedApplication] windows] lastObject]
$14 = 0x09edf900 <_UIAlertOverlayWindow: 0x9edf900; frame = (0 0; 320 568); layer = <UIWindowLayer: 0x9edf9d0>>
(lldb) po [[[[UIApplication sharedApplication] windows] lastObject] subviews]
@bogardon
bogardon / gist:5328018
Last active December 15, 2015 21:49
Programming Question
So there's this game called Monster Hunter. Think of it like the Japanese WOW. It is extremely addicting and can ruin your life.
In the game, there are items called Charms, which you can think of like any other game accessory.
A Charm has two components. It has --
1. Slots
2. Skills
The game is constrained in such a way that every charm has 1-2 to skills and 0-3 slots.
@bogardon
bogardon / gist:3245415
Created August 3, 2012 07:32
Taking Advantage of iOS5 Built-In HTTP DiskCache
- (NSCachedURLResponse *) cachedResponseForRequest:(NSURLRequest *)request {
NSCachedURLResponse *cachedURLResponse = [super cachedResponseForRequest:request];
if (cachedURLResponse == nil && [request.HTTPMethod isEqualToString:@"GET"]) {
//[db executeQuery:@"select * from test where a = ?", @"hi'", nil];
FMResultSet *cfurl_cache_response = [self.db executeQuery:@"select * from cfurl_cache_response where request_key = ? limit 1", request.URL.absoluteString, nil];
if ([cfurl_cache_response next]) {
id entry_ID = [cfurl_cache_response objectForColumnName:@"entry_ID"];
[cfurl_cache_response close];
if (entry_ID != [NSNull null]) {
FMResultSet *cfurl_cache_blob_data = [self.db executeQuery:@"select * from cfurl_cache_blob_data where entry_ID = ? limit 1", entry_ID, nil];
@bogardon
bogardon / gist:2323766
Created April 6, 2012 23:01
NSCachedURLResponse data leak
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.organicshoppermag.com/assets/images/miso_img_large.gif"]];
NSURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:NULL];
NSCachedURLResponse *cachedResponse = [[[NSCachedURLResponse alloc] initWithResponse:response data:data] autorelease];
NSLog(@"%u",cachedResponse.data.length);