Skip to content

Instantly share code, notes, and snippets.

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

Arief Bayu Purwanto ariefbayu

🏠
Working from home
View GitHub Profile
@ariefbayu
ariefbayu / phonegap-create-android
Created March 14, 2013 11:53
helper script for phonegap create tools: save it in your $PATH
#! /bin/bash
/Users/ariefbayu/Documents/Applications/phonegap-2.5.0/lib/android/bin/create $1 $2 $3
@ariefbayu
ariefbayu / gist:3857656
Created October 9, 2012 09:37
get model relations in fuelphp
class Model_CatalogImage extends Orm\Model {
public static function getRelations() {
$return = array();
if(isset(Model_CatalogImage::$_belongs_to)){
$return['belongto'] = Model_CatalogImage::$_belongs_to;
}
if(isset(Model_CatalogImage::$_has_many)){
$return['hasmany'] = Model_CatalogImage::$_has_many;
}
@ariefbayu
ariefbayu / gist:3857511
Created October 9, 2012 09:04 — forked from danmatthews/gist:3240064
Solution to doing some processing for every method of FuelPHP REST controller. Also add limit supported data type.
<?php
class ExampleRestController extends Controller_Rest {
/**
* @var array List all supported methods
*/
protected $_supported_formats = array(
'xml' => 'application/xml',
// 'rawxml' => 'application/xml',
@ariefbayu
ariefbayu / doodle-download.py
Created March 12, 2012 07:59
Google Doodle Downloader by @pengelana
#!/usr/bin/env python
import os
import urllib2
import datetime
import time
try:
import json
except:
@ariefbayu
ariefbayu / data_en.json
Last active October 1, 2015 12:27
Pure HTML+JSON i18n page
{"title": "this is title", "content": "this is english content"}
@ariefbayu
ariefbayu / custom_jquery_selector.js
Created September 27, 2011 18:10
Custom JQuery Selector
//taken from: http://stackoverflow.com/questions/182630/jquery-tips-and-tricks/382922#382922
$.extend($.expr[":"], {
over100pixels: function (e)
{
return $(e).height() > 100;
}
});
$(".box:over100pixels").click(function ()
{
@ariefbayu
ariefbayu / gist:1202815
Created September 8, 2011 06:54
To create header image with background repeated image.
//require line
var SceneView = require('ui').SceneView;
//`:load` line
var scene = new SceneView({ style: { width: 'fill-parent', height: 36 }});
scene.setLayers(sceneLayers.count);
scene.defineSpritesheet('headerImage', app.imageURL('header_image.png'), 128, 36);
scene.add({
sprite: 'headerImage',
@ariefbayu
ariefbayu / snippet.java
Last active August 29, 2015 14:27
OkHttp recipe for uploading files with additional form inputs
File file1 = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/Master/CAM_" + s.getType() + "_" + s.getJobCode() + ".jpg");
File file2 = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/Master/SIGN_" + s.getType() + "_" + s.getJobCode() + ".jpg");
Log.d("LOG", "File1: "+ (file1.exists() ? "E" : "N") + " -> " + file1.getAbsolutePath());
Log.d("LOG", "File2: "+ (file2.exists() ? "E" : "N") + " -> " + file2.getAbsolutePath());
RequestBody requestBody = new MultipartBuilder()
.type(MultipartBuilder.FORM)
.addFormDataPart("gambar1", file1.getName(),
RequestBody.create(MEDIA_TYPE_IMAGE, file1))
@ariefbayu
ariefbayu / convert-flac-to-mp3.sh
Created July 26, 2015 22:24
Snippet to convert all *.flac in a directory to *.mp3 while preserving its id3 medatas
(for FILE in *.flac ; do ffmpeg -i "$FILE" -f mp3 -ab 320000 -map_metadata 0 -id3v2_version 3 "`basename "$FILE" .flac`.mp3" || break; done)
@ariefbayu
ariefbayu / gist:12c8bef435dd5b14e94c
Last active August 29, 2015 14:22
SmartLocation to account Genymotion or other devices without google play services installed
SmartLocation.with(getApplicationContext()).location()
.oneFix()
.config(LocationParams.NAVIGATION)
.provider(new LocationGooglePlayServicesWithFallbackProvider(getApplicationContext()))
.start(new OnLocationUpdatedListener() {
@Override
public void onLocationUpdated(Location location) {
latitude = location.getLatitude();
longitude = location.getLongitude();