Skip to content

Instantly share code, notes, and snippets.

View hendrawd's full-sized avatar
☺️
Happy

Hendra Wijaya Djiono hendrawd

☺️
Happy
View GitHub Profile
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 / 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>()
@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 / DeviceInformation.java
Last active June 28, 2023 04:22
Helper class for getting Device Information
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;
// 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 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 {
@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 / 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 / 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 / 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..");