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 / 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 / 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 / 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 / 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 / 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
// 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 / 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 / android_studio_shortcuts.md
Created November 22, 2016 09:54 — forked from stkent/android_studio_shortcuts.md
Android Studio Shortcuts (Mac)

Android Studio Shortcuts (Mac)

Notes:

  • Two of the most useful shortcuts utilize the Fn (function) keys. It is therefore recommended that you enable the "Use all F1, F2, etc. keys as standard function keys" option [System Preferences > Keyboard].
  • Be sure to enable the Mac OS X 10.5+ keymap in Android Studio [Preferences > Keymap].
  • A fairly complete shortcut list can be found here.

Useful symbols:

@hendrawd
hendrawd / Base64Image
Last active May 30, 2022 14:16
Helper class to easily encode and decode image with base64
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Base64;
import java.io.ByteArrayOutputStream;
/**
* Helper class to easily encode and decode image with base64
*
@hendrawd
hendrawd / NecrobotMultipleRunner.bat
Last active August 3, 2016 06:36
A runner script to run multiple Necrobot.exe files
@echo off
FOR /D %%s IN (.\*) DO (cd %%s & start Necrobot.exe & cd ..)
exit