Skip to content

Instantly share code, notes, and snippets.

View adityapurwa's full-sized avatar
🚀
Relearning everything

Aditya Purwa adityapurwa

🚀
Relearning everything
View GitHub Profile
@adityapurwa
adityapurwa / TableArray.java
Created October 2, 2018 11:54
Tabel Java Gan
import java.util.Scanner;
public class TableArray {
public static void main(String[] args) {
String[][] table = new String[4][5];
String kols[] = {"NRP", "Nama", "Alamat", "Telp", "Email"};
Scanner scan = new Scanner(System.in);
for (int bar = 0; bar < table.length; bar++) {
for (int kol = 0; kol < table[bar].length; kol++) {
@adityapurwa
adityapurwa / LTM.js
Created September 20, 2018 14:41
LTM Ho
const A = [
[ 0, 0, 0, 1, 0, 0 , 0],
[ 0, 0, 1, 0, 1, 0 , 0],
[ 0, 1, 0, 0, 0, 1 , 0],
[ 1, 0, 0, 0, 0, 0 , 1],
[ 1, 1, 1, 1, 1, 1 , 1],
[ 1, 0, 0, 0, 0, 0 , 1],
[ 1, 0, 0, 0, 0, 0 , 1],
]
@adityapurwa
adityapurwa / assertNever.ts
Created July 11, 2018 14:50
Utility function to check for nevertype.
export function assertNever(never: never) {
console.error("Never touched");
}
@adityapurwa
adityapurwa / setTokenNoAction.ts
Created July 4, 2018 16:32
Set Token Without Action Creator
// Notice here that we have to keep passing the type
store.dispatch<SetTokenAction>({
type: "auth/set-token", // However, TypeScript will force you to use the correct type for SetTokenAction
payload: "userToken"
});
@adityapurwa
adityapurwa / setTokenAction.ts
Created July 4, 2018 16:27
SetTokenAction Looks
const setTokenAction(payload: string){
return {
type: "auth/set-token",
payload
}
}
@adityapurwa
adityapurwa / action.ts
Created July 4, 2018 16:26
Using Action Creator
export const setTokenAction = createAction<SetTokenAction>("auth/set-token");
export const flushTokenAction = createAction<FlushTokenAction>(
"auth/flush-token"
);
@adityapurwa
adityapurwa / creator.ts
Last active July 4, 2018 17:04
Action Creator
export interface PayloadedAction<TType, TPayload> {
type: TType;
payload: TPayload;
}
export interface Action<TType> {
type: TType;
}
export function createPayloadedAction<
@adityapurwa
adityapurwa / types.ts
Created July 4, 2018 16:20
SetTokenAction
interface SetTokenAction {
type: "auth/set-token";
payload: string;
}
@adityapurwa
adityapurwa / reducer.ts
Last active July 4, 2018 17:10
TypeScript Reducer with Types
const token = (
state: AuthStore["token"] = null,
action: Auth.TokenActions
): AuthStore["token"] => {
switch (action.type) {
case "auth/set-token":
return action.payload;
case "auth/flush-token":
return null;
default:
@adityapurwa
adityapurwa / action.ts
Last active July 4, 2018 17:08
TypeScript Action Interface
export interface PayloadedAction<TType, TPayload> {
type: TType;
payload: TPayload;
}
export interface Action<TType> {
type: TType;
}