Skip to content

Instantly share code, notes, and snippets.

☺️
Happy

Hendra Wijaya Djiono hendrawd

☺️
Happy
Block or report user

Report or block hendrawd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hendrawd
hendrawd / StringPermutation.kt
Created May 10, 2019
Permutasi String dengan Metode Rekursif Menggunakan Bahasa Pemrograman Kotlin
View StringPermutation.kt
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>()
@hendrawd
hendrawd / ByteUrlGenerator.java
Created Aug 15, 2018
An helper method for creating byte url from a string url, then we can copy the result from the console to the actual code
View ByteUrlGenerator.java
/**
* 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 / DeviceInformation.java
Last active Jul 13, 2019
Helper class for getting Device Information
View DeviceInformation.java
package your.app.util;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
View LocalDateTimeYesterdayChecker.java
// 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 / ballot.sol
Created Mar 19, 2018
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/
View ballot.sol
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {
@hendrawd
hendrawd / dragonstone.sol
Created Mar 19, 2018
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/
View dragonstone.sol
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 / hodor.sol
Last active Mar 19, 2018
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/
View hodor.sol
pragma solidity ^0.4.0;
/*
Simple contract that returns a greeting
*/
contract Hodor {
address creator;
string greeting;
@hendrawd
hendrawd / CompetitiveProgrammingKotlin.kt
Last active Feb 2, 2018
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.
View CompetitiveProgrammingKotlin.kt
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 / Singleton.java
Created Dec 29, 2017
Example of how to create class and access private constructor of the class using reflection and how to prevent it
View Singleton.java
/**
* @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 / BukaReksaAnnualPercentageFrom3MonthsCalculator.kt
Created Dec 27, 2017
BukaReksaAnnualPercentageFrom3MonthsCalculator.kt
View 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)}")
}
/**
You can’t perform that action at this time.