Skip to content

Instantly share code, notes, and snippets.

@obiwong
obiwong / getTimeZoneOffset.java
Created November 25, 2013 14:40
get time zone offset
import java.util.TimeZone;
public class Main {
public static void main(String[] args) {
System.out.println("tz: " + TimeZone.getDefault().getRawOffset() / (60 * 60 * 1000));
}
}
@obiwong
obiwong / epwd
Created October 30, 2013 05:35
copy current path to clipboard and switch to emacs
#!/bin/bash
if [ $# == 1 ]; then
echo -n `pwd`/$1 | xclip
wmctrl -a @Emacs || emacs23
else
echo -n `pwd` | xclip
wmctrl -a @Emacs || emacs23
fi
@obiwong
obiwong / cpwd
Created October 30, 2013 05:34
copy current path to clipboard
#!/bin/bash
if [ $# == 1 ]; then
echo -n `pwd`/$1 | xclip
else
echo -n `pwd` | xclip
fi
@obiwong
obiwong / gist:3108898
Created July 14, 2012 02:36
custom view test long press
/* usage:
<com.ht.longpresstest.ItemView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/ic_launcher"
/>
*/
public class ItemView extends View {
- (void)applicationWillTerminate:(NSNotification *)notification {
NSLog(@"on applicationWillTerminate");
}
- (void)viewDidLoad {
UIApplication *app = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillTerminate:)
name:UIApplicationWillTerminateNotification
object:app];
@obiwong
obiwong / gist:975988
Created May 17, 2011 05:14
auto clock out org-mode
(run-at-time "11:30" (* 60 60 24)
(lambda ()
(when (org-clock-is-active)
(org-clock-out))))