Skip to content

Instantly share code, notes, and snippets.

View hendrawd's full-sized avatar
☺️
Happy

Hendra Wijaya Djiono hendrawd

☺️
Happy
View GitHub Profile
// Copyright (c) ${YEAR}, ${USER}, ITHENA BVBA @ http://www.ithena.be
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
@hendrawd
hendrawd / SpeechToTextActivity.java
Created December 15, 2016 08:45
Simple working test of IBM Watson Speech To Text capability on Android platform
/**
* Copyright (C) 2016 hendrawd
*
* 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
@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;
@hendrawd
hendrawd / IoUtils.java
Created August 24, 2017 08:21
Read files with Okio
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.internal.io.FileSystem;
import okio.BufferedSource;
import okio.Okio;
@hendrawd
hendrawd / LocalBroadcastExampleActivity.java
Created September 9, 2017 08:31 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@hendrawd
hendrawd / BukaReksaAnnualPercentageFrom3MonthsCalculator.kt
Created December 27, 2017 05:24
BukaReksaAnnualPercentageFrom3MonthsCalculator.kt
fun main(args: Array<String>) {
println("This program will calculate annual interest of BukaReksa based on 3 months price")
println("Input start price")
val startPrice = readLine()!!.toDouble()
println("Input end price")
val endPrice = readLine()!!.toDouble()
println("Annual interest is ${calculateAnnualInterest(startPrice, endPrice)}")
}
/**
@hendrawd
hendrawd / Singleton.java
Created December 29, 2017 04:14
Example of how to create class and access private constructor of the class using reflection and how to prevent it
/**
* @author hendrawd on 22/12/17
*/
public class Singleton {
// some singleton creation mechanisms
private Singleton(){
// throwing an exception here is needed to avoid developer cheating by creating this class with reflection
throw new UnsupportedOperationException("Should not create instance of Util class. Please use as static..");
@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