Skip to content

Instantly share code, notes, and snippets.

View sumardi's full-sized avatar
🏠
Working from home

Sumardi Shukor sumardi

🏠
Working from home
View GitHub Profile
@sumardi
sumardi / gist:8922624
Created February 10, 2014 19:35
Build your OWN Apple iBeacon with a Raspberry Pi.
$ sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
$ sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.14.tar.xz
$ sudo unxz bluez-5.14.tar.xz
$ sudo tar xvf bluez-5.14.tar
$ cd bluez-5.14
$ sudo ./configure --disable-systemd
$ sudo make
$ sudo make install
@sumardi
sumardi / Gruntfile.js
Created March 21, 2014 04:02
Building Pebble watchapps with Grunt and Grunt-Shell.
module.exports = function(grunt) {
grunt.initConfig({
phoneIP: '192.168.1.100',
// set logs: '' to turn off logging
logs: '--logs',
shell: {
buildAndInstall: {
options: {
stdout: true,
stderr: true

Keybase proof

I hereby claim:

  • I am sumardi on github.
  • I am sumardi (https://keybase.io/sumardi) on keybase.
  • I have a public key whose fingerprint is 6085 8A97 69AD 9949 30A5 D10F 80D7 1397 3FD6 D917

To claim this, I am signing this object:

@sumardi
sumardi / gist:794644
Created January 25, 2011 08:01
How to convert an sqlite 2 database into an sqlite 3
sqlite2 path/to/olddb .dump > backupfile
sqlite3 path/to/newdb < backupfile
@sumardi
sumardi / gist:805694
Created February 1, 2011 10:45
iPhoneDev - Change views to landspace mode
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
@sumardi
sumardi / gist:805697
Created February 1, 2011 10:49
iPhoneDev - An example of UIActionSheet
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"What to do?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Remove" otherButtonTitles:@"Landscape", @"Portrait", nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery showInView:self.view];
[popupQuery release];
@sumardi
sumardi / gist:805738
Created February 1, 2011 11:33
iPhoneDev - Creating and showing an alert.
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Really reset?" message:@"Do you really want to reset this game?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil] autorelease];
[alert addButtonWithTitle:@"Yes"];
[alert show];
@sumardi
sumardi / gist:807496
Created February 2, 2011 10:10
iPhoneDev - Custom background for navigation bar
- (void)viewDidLoad {
self.navigationItem.title = @"Title Here"
// for landscape mode use - CGRectMake(0.0, 0.0, 480, 44.0)];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320, 44.0)];
[imgView setImage:[UIImage imageNamed:@"navbar_bg.png"]];
// this puts image view under all other views and all the default elements (title, buttons etc)
[self.navigationController.navigationBar insertSubview:imgView atIndex:0];
@sumardi
sumardi / gist:830908
Created February 17, 2011 03:27
iPhoneDev - Tint color
- (void)viewDidLoad {
[super viewDidLoad];
// Navigation bar
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:.6 green:.3 blue:.2 alpha:1];
// Search bar
self.searchDisplayController.searchBar.tintColor = [UIColor colorWithRed:.6 green:.3 blue:.2 alpha:1];
}
@sumardi
sumardi / gist:893020
Created March 29, 2011 19:04
PHP : Extract user agent
<?php
$browser = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27";
function extract_user_agent($agent)
{
$found = array();
$pattern = "([^/[:space:]]*)" . "(/([^[:space:]]*))?";
$pattern .= "([[:space:]]*\[[a-zA-Z][a-zA-Z]\])?" . "[[:space:]]*";
$pattern .= "(\\((([^()]|(\\([^()]*\\)))*)\\))?" . "[[:space:]]*";