Skip to content

Instantly share code, notes, and snippets.

View amrishodiq's full-sized avatar

Amri Shodiq amrishodiq

  • Depok, Jawa Barat, Indonesia
View GitHub Profile
public class OldPhone {
public static void main(String[] args) {
OldPhone phone = new OldPhone();
System.out.println(phone.reverse_t9("999337777"));
}
public class Hoop {
public static void main(String[] args) {
Hoop hoop = new Hoop();
int n = 3, m = 8;
int[] turns = new int[] {1, 2, 3, 4, 4, 0, 0, 0};
int[] result = hoop.hoop(n, m, turns);
int i = 0;
<!DOCTYPE html>
<html>
<head>
<title>How To Use Lazy Repo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="LazyRepo.js"></script>
</head>
<body>
<script type="text/javascript">
jkt.findLike(
"address",
"cilandak",
datasourcePusatBelanja,
function(results) {
if (results == null) {
console.log("Empty");
return;
}
var len = results.rows.length;
@amrishodiq
amrishodiq / gist:5d204f2d4397890a252d076c028b42ab
Created May 10, 2016 11:00
JavaScript: Instance of LazyRepo
var jkt = new LazyRepo(databaseconfig);
@amrishodiq
amrishodiq / databaseconfig.js
Created May 10, 2016 10:58
JavaScript: Konfigurasi Database untuk Lazy Repo
var databaseconfig = {
name: 'dummydatabase',
version: '1.0',
realName: 'Dummy Database',
size: 2 * 1024 * 1024
};
@amrishodiq
amrishodiq / datasourceterminal.js
Last active May 10, 2016 11:29
JavaScript: Data Source Pusat Belanja di Jakarta
var datasourcePusatBelanja = {
table: "pusatbelanja",
uri: "http://crop.jakarta.go.id/ajax/apps_command.php?Z2V0UGxhY2VtYXJrfjIwMTYwNTEwU200UlRDMXRZfkxTLTI=",
fields: ["placemark_id", "category_id", "user_id", "package_id", "name", "address", "description",
"lat", "lng", "created", "icon", "icon_placemark", "contact", "email", "website", "banner",
"twitter_account", "counter", "counterx", "marketing_by", "is_parent", "child_of", "display"]
}
@amrishodiq
amrishodiq / LazyRepo.js
Created May 10, 2016 10:52
JavaScript: LazyRepo, Instantly cache JSON array REST API response into WebSQL.
/**
* Copyright 2016 Amri Shodiq
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@amrishodiq
amrishodiq / gist:1c6e296088ab23d822e843e928eec980
Last active May 9, 2016 04:04
Write Data to Table with JavaScript
// places should be array of object as a result from internet
function writeDatas(places) {
getDatabase().transaction(function(trx) {
createTableIfNotExists(trx, function() {
var religion = "";
$.each(places, function(index, element) {
// parse the data and do insert to table
if (element.name.indexOf("MASJID")>=0 || element.name.indexOf("MUSALA")>=0) {
religion = "ISLAM";
} else if (element.name.indexOf("GEREJA")>=0 ||
@amrishodiq
amrishodiq / gist:cdcd91a5ee5dd984ddc1b424210c7a9e
Created May 9, 2016 03:55
Create Database Tabel Only If Not Exists with JavaScript
// after this function is executed, it will return true/false to callback
// callback should be a function that require a boolean parameter
function isDataExists(callback) {
getDatabase().transaction(function(trx) {
worship.createTableIfNotExists(trx, function() {
var sql = "SELECT * FROM worshipPlaces";
console.log("Executing "+sql);
trx.executeSql(sql, null, function(trx, results) {
console.log("Results: "+results.rows.length);