Skip to content

Instantly share code, notes, and snippets.

View hadihammurabi's full-sized avatar
😎
Let's code with me!

Hadi Hidayat Hammurabi hadihammurabi

😎
Let's code with me!
View GitHub Profile
import java.util.Scanner;
public class SegitigaBintang {
public static void main(String[] args) {
System.out.print("Mau berapa bintang? ");
Scanner scanner = new Scanner(System.in);
int bintang = scanner.nextInt();
// int bintang = 5;
@hadihammurabi
hadihammurabi / InterAbs.java
Created June 20, 2019 04:18
Example for Interface and Abstrac Class in Java
abstract class Makhluk {
abstract void berjalan();
void tidur() {
System.out.println("Kucing sedang tidur");
}
}
interface Hewan {
void makan();
}
@hadihammurabi
hadihammurabi / HTTPRequest.java
Created June 25, 2019 07:49
Example for simple HTTP Request in Java
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.net.URL;
import java.net.HttpURLConnection;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class HTTPRequest {
public static void main(String[] args) {
@hadihammurabi
hadihammurabi / GetAPI.java
Created June 28, 2019 03:53
Getting data from Rest API Server with concurrency
import java.lang.Runnable;
import java.net.URL;
import java.net.HttpURLConnection;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class DataCollector implements Runnable {
StringBuffer result;

1. Clone repository hasil dari fork:

git clone git@github.com:USERNAME-KAMU/REPOSITORY-HASIL-FORK.git

2. Tambahkan alamat remote repository asli ke repository lokal hasil fork:

cd REPOSITORY-HASIL-FORK
git remote add upstream https://github.com/USERNAME-PEMILIK-ASLI/REPOSITORY-ASLI.git
git fetch upstream
@hadihammurabi
hadihammurabi / micro-frontend-stitching.html
Created July 10, 2019 16:22
Example for micro frontends stitching layer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Toko Online</title>
</head>
<body>
<div id="katalog"></div>
@hadihammurabi
hadihammurabi / npm-global-updater.sh
Last active July 15, 2019 03:15
Shell script to update all npm outdated global package
sudo npm i -g $(npm outdated -g --depth=0 --parseable | cut -d: -f2 | awk -F'\n' ' { printf "%s ", $1 } ')
@hadihammurabi
hadihammurabi / xrandr-multiscreen.sh
Last active July 23, 2019 09:02
Multiscreen control from CLI using XRandR
#!/bin/bash
# connect to screen using HDMI
xrandr --output HDMI-1 --mode 1360x768 --auto --above eDP-1
# disconnect
xrandr --output HDMI-1 --off
@hadihammurabi
hadihammurabi / etc-init.d-mongodb
Created July 23, 2019 19:37
OpenRC init file for MongoDB
#!/usr/bin/openrc-run
# MONGOHOME="/usr/local/mongodb"
CONFIGFILE="/etc/mongodb.conf"
DBPATH=`awk -F= '/^dbpath[ ]*=/{print $2}' "$CONFIGFILE" |sed -e 's/^[ ]*//'`
COMMAND="mongod"
OPT="--config $CONFIGFILE"
mongod=$COMMAND
PIDPATH="/var/run/mongodb/mongodb.pid"
@hadihammurabi
hadihammurabi / README.md
Created August 11, 2019 15:42
Tmux Cheat Sheet

Tmux Cheat Sheet

Session Sharing

Create session with socket file:

tmux -S /tmp/shareds new -s shared

Allow another user to access the socket file: