Skip to content

Instantly share code, notes, and snippets.

View hboon's full-sized avatar
Hacking

Hwee-Boon Yar hboon

Hacking
View GitHub Profile
-- Adapted from http://www.macosxhints.com/article.php?story=20031018154841400
tell application "System Preferences"
activate
end tell
tell application "System Events"
tell process "System Preferences"
click menu item "Sharing" of menu "View" of menu bar 1
delay 2
$ ./configure
Checking for program g++,c++ : ok /usr/bin/g++
Checking for program cpp : ok /usr/bin/cpp
Checking for program ar : ok /usr/bin/ar
Checking for program ranlib : ok /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc,cc : ok /usr/bin/gcc
Checking for gcc : ok
Checking for library dl : ok
Checking for library execinfo : not found
@hboon
hboon / gist:278281
Created January 15, 2010 18:12
Script to Remove Core Data's SQLite Database File During Development Cycles
#!/bin/sh
# Adapted from http://furbo.org/2009/03/03/open-sesame/
if [ -z "$1" ]; then
echo "usage: $0 <app> [ Preferences | <document> ]"
else
app=`ls -1td ~/Library/Application\ Support/iPhone\ Simulator/User/Applications/*/$1.app | head -1`
dir=`dirname "$app"`
if [ "$2" = "Preferences" ]; then
@hboon
hboon / gist:285098
Created January 24, 2010 08:27
CSS to disable callout for links on iPhone/iPod touch UIWebView
<a href="foo:somevalue" style='-webkit-touch-callout:none;'>Press and hold this link on iPhone will not highlight and show a callout</a>
import socket
from twisted.internet import reactor
from twisted.web import server, resource
class S(resource.Resource):
isLeaf = True
def render_POST(self, request):
print request.args
print dir(request)
; a macro in redis-clojure.
(defmacro with-connection [name pool server-spec & body]
`(let [~name (get-connection ~pool ~server-spec)]
(try
~@body
(catch Exception e#
; if we reach here, i.e. an exception, we don't want to run (release-connection) in finally
(release-connection ~pool ~name e#)
(throw e#))
(finally
@hboon
hboon / new-textdrive-email
Created October 29, 2012 15:58
"New" TextDrive email
Dear <recipient>
As you know, Joyent will soon cease providing shared hosting services. In recent weeks I've been readying the relaunch of TextDrive (the company I started in 2004, which subsequently became Joyent) as a shared hosting provider open to the public. The new TextDrive shall also offer replacement hosting to existing Joyent accounts.
The process has been exciting and chaotic, and I can say things are looking great: I've been serving websites and data feeds from the new infrastructure for some time now, and the speed and responsiveness are fantastic. If, like me, you enjoy exploring the nuts and bolts of how things get published online, you'll be impressed.
We're making available some conveniences that may be new to you, such as one-click software installers for popular content management systems, wikis, and so forth. Of course there is a web interface for account and data administration, but these are early days, and for the time being you'll be best off knowing your way around the command lin
@hboon
hboon / opensim
Created November 7, 2012 03:03
Open app in Simulator with Finder
#!/bin/sh
#Modified from http://furbo.org/2009/03/03/open-sesame/
if [ -z "$1" ]; then
echo "usage: $0 <app> [ Preferences | <document> ]"
else
app=`ls -1td ~/Library/Application\ Support/iPhone\ Simulator/*/Applications/*/$1.app | head -1`
#app=`ls -1td ~/Library/Application\ Support/iPhone\ Simulator/User/Applications/*/$1.app | head -1`
dir=`dirname "$app"`
@hboon
hboon / gist:4205927
Created December 4, 2012 16:37
Write a string to a Campfire room synchronously.
// This goes into the header file.
void moCampfireSpeak(NSString* aString, NSString* aRoomIDString, NSString* aSubdomainString, NSString* aTokenString);
// This goes into the implementation file.
// You need the room ID, not room name. You can get it from the campfire room URL.
void moCampfireSpeak(NSString* aString, NSString* aRoomIDString, NSString* aSubdomainString, NSString* aTokenString) {
NSString* url = [NSString stringWithFormat:@"https://%@.campfirenow.com/room/%@/speak.json", aSubdomainString, aRoomIDString];
NSString* postString = [NSString stringWithFormat:@"<message><type>%@</type><body>%@</body></message>", @"TextMessage", aString];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
@hboon
hboon / RubyMotionViewcontrollerOrientation.rb
Created April 5, 2013 06:03
Implementing mixed-orientation in RubyMotion for iOS
#In Rakefile, set something like app.interface_orientations = [:portrait, :landscape_left, :landscape_right]
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
application.setStatusBarStyle(UIStatusBarStyleBlackOpaque, animated:true)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.rootViewController = NavigationController.alloc.initWithRootViewController(PortraitViewController.alloc.init)
@window.makeKeyAndVisible
true
end