Skip to content

Instantly share code, notes, and snippets.

View hendrawd's full-sized avatar
☺️
Happy

Hendra Wijaya Djiono hendrawd

☺️
Happy
View GitHub Profile
@hendrawd
hendrawd / MainActivity.java
Last active December 29, 2017 04:16 — forked from hbcafe/gist:e6d53488acfdf6ae0fdf81caea0d2dfe
Simpler implementation for connecting native Android app to Watson Text to Speech in under 10 minutes (TTS interface)
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.ibm.watson.developer_cloud.android.library.audio.StreamPlayer;
import com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech;
@hendrawd
hendrawd / CompetitiveProgrammingKotlin.kt
Last active February 2, 2018 16:36
As Uwi's recommendation to create my own libary, so i create an IntelliJ File Template in kotlin for faster solve competitive programming problem. This use the fastest I/O that we can achieve in kotlin.
import java.io.PrintWriter
import java.math.BigInteger
/**
* ${Website}
* Created on ${DAY} ${MONTH_NAME_FULL} ${YEAR}
* @author ${USER}
*/
fun main(args: Array<String>) {
@hendrawd
hendrawd / hodor.sol
Last active March 19, 2018 04:37
Hello world code for solidity, a programming language to deploy smart contract to ethereum platform. Online IDE can be found here: http://remix.ethereum.org/
pragma solidity ^0.4.0;
/*
Simple contract that returns a greeting
*/
contract Hodor {
address creator;
string greeting;
@hendrawd
hendrawd / dragonstone.sol
Created March 19, 2018 04:40
Code for solidity, a programming language to deploy smart contract to ethereum platform. This demonstrate how to create, and transfer balance from one account to other account. Online IDE can be found here: http://remix.ethereum.org/
pragma solidity ^0.4.0;
/*
Currency that can only be issued by its creator and transferred to anyone
*/
contract DragonStone {
address public creator;
mapping (address => uint) public balances;
// event that notifies when a transfer has completed
@hendrawd
hendrawd / ballot.sol
Created March 19, 2018 04:43
Code for solidity, a programming language to deploy smart contract to ethereum platform. This demonstrate about case for election that voters can vote and then can show the winning proposal after the election done. Online IDE can be found here: http://remix.ethereum.org/
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {
// implementation 'com.github.ThreeTen:threetenbp:v1.3.6'
// https://github.com/ThreeTen/threetenbp
// similar to java8, but support jdk6 and jdk7
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.temporal.ChronoUnit;
public class LocalDateTimeYesterdayChecker {
public static LocalDateTime getYesterday() {
@hendrawd
hendrawd / ByteUrlGenerator.java
Created August 15, 2018 13:07
An helper method for creating byte url from a string url, then we can copy the result from the console to the actual code
/**
* An helper method for creating byte url from a string url,
* then we can copy the result from the console to the actual code.
* This is useful for fighting against reverse engineering in java/android apps.
* Can be combined with other methods to make your apps more secure.
* Just keep in mind that there is no ways to win against a determined hacker,
* so do all of critical processes in server
*/
public final class ByteUrlGenerator {
@hendrawd
hendrawd / StringPermutation.kt
Created May 10, 2019 14:54
Permutasi String dengan Metode Rekursif Menggunakan Bahasa Pemrograman Kotlin
import java.util.*
fun main(args: Array<String>) {
println("Masukkan Kata/String")
// Mendapatkan kata dari
val word = Scanner(System.`in`).next()
// Membuat list kosong
val indices = mutableListOf<Int>()
class MyFragment private constructor() : Fragment(){
companion object{
private val ARG_CAUGHT = "myFragment_caught"
fun newInstance(caught: Pokemon):MyFragment{
val args: Bundle = Bundle()
args.putSerializable(ARG_CAUGHT, caught)
val fragment = MyFragment()
fragment.arguments = args
return fragment
@hendrawd
hendrawd / OkHttp3Stack.java
Last active October 15, 2019 22:56
latest volley singleton
import com.android.volley.Request;
import com.android.volley.error.AuthFailureError;
import com.android.volley.toolbox.HttpStack;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;
import org.apache.http.entity.BasicHttpEntity;
import org.apache.http.message.BasicHeader;