Skip to content

Instantly share code, notes, and snippets.

View temojin's full-sized avatar

Hung Q Tran temojin

View GitHub Profile
NSString *timestampAsStringFromEpochTime = [[NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]]
@temojin
temojin / uinavigationbar-uibarbuttonitem
Created February 22, 2013 08:04
Debugging to find which property of the UINavigationBar to change the title of the back button text on the top nav bar. Refer context: http://stackoverflow.com/questions/7237826/how-to-change-uinavigationbar-back-button-text/15018046#15018046
- (void)viewWillAppear:(BOOL)animated
{
self.navigationItem.backBarButtonItem.title = @"foo";
self.navigationItem.leftBarButtonItem.title = @"fii";
[self.navigationController.navigationBar.items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
UINavigationItem *item = (UINavigationItem *) obj;
NSLog(@" item: %@", item.title);
}];
@temojin
temojin / dbextract script
Created April 13, 2011 08:15
script extracts hidden iphone backup files
#!/usr/bin/perl -w
#origin: http://pastie.textmate.org/89891
use strict;
# This file clumsily extracts the DB's hidden in the iPhone backup files
# Usage: perl -w bkupextract.pl /Users/flip/Library/Application\ Support/MobileSync/Backup/*/*
@temojin
temojin / savon no wsdl test
Created March 25, 2011 05:42
Non working savon SOAP request without WSDL
require 'rubygems'
require 'savon'
Savon.configure do |config|
config.log_level = :debug
end
client = Savon::Client.new do
wsdl.endpoint = "http://www.webservicex.net/globalweather.asmx"
# in padrino 0.9.15 it not able to get params[username] in before filter.
before do
logger.debug "before"
logger.debug params
logger.debug params[:username] # empty in 0.9.15 but works in 0.9.14
logger.debug "request"
logger.debug request.params
end
@temojin
temojin / gist:264925
Created December 28, 2009 20:41 — forked from jruby/gist:259743
~/projects/jruby ➔ jirb
irb(main):001:0> require 'java'
=> true
irb(main):002:0> import com.sun.tools.attach.VirtualMachine
=> Java::ComSunToolsAttach::VirtualMachine
irb(main):003:0> vm = VirtualMachine.attach($$.to_s)
=> sun.tools.attach.MacosxAttachProvider@47875da7: 3294
irb(main):004:0> histo = vm.heap_histo([].to_java).to_io
=> #<IO:0x32b95f72>
irb(main):005:0> histo.lines.first(25).each {|line| puts line}; nil