Skip to content

Instantly share code, notes, and snippets.

View philipjkim's full-sized avatar

Soo Philip Jason Kim philipjkim

View GitHub Profile
package com.github.philipjkim.demo.hexagonal
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import com.tngtech.archunit.core.importer.ClassFileImporter
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
@philipjkim
philipjkim / FunctionalVsIemerativeTransformationTest.java
Created December 2, 2022 01:46
Java - Transformation from 2 arrays to a map - Imperative vs. Functional
import static org.junit.jupiter.api.Assertions.*;
class FunctionalVsIemerativeTransformationTest {
@Test
void functionalVersusImperative() {
// Imperative
var parameterNames = new String[]{"aaa", "bbb"};
var args = new Object[]{"arg1", "arg2"};
Map<String, Object> params1 = new HashMap<>();
@philipjkim
philipjkim / context_demo.go
Created April 24, 2019 06:02
Demo: Using context to cancel heavy jobs after timeout
package main
import (
"context"
"fmt"
"time"
)
// DemoTimeout .
func DemoTimeout(ctxTimeout time.Duration, workDuration time.Duration) error {
@philipjkim
philipjkim / git-amend-author.sh
Last active March 13, 2019 01:11
Bash scripts for amending author of commits at once
#!/bin/bash
# (for example, your previous author name contains `Anonymous`)
# @ PROJECT_ROOT dir: run
#
# git log | grep -B 1 "Anonymous" | grep commit | awk '{print $2}' | xargs -L 1 ./git-amend-author.sh
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters: $#"
exit 1
@philipjkim
philipjkim / iter_test.rs
Last active March 15, 2024 00:15
Rust: Difference between iter(), into_iter(), and iter_mut()
#[test]
fn iter_demo() {
let v1 = vec![1, 2, 3];
let mut v1_iter = v1.iter();
// iter() returns an iterator of slices.
assert_eq!(v1_iter.next(), Some(&1));
assert_eq!(v1_iter.next(), Some(&2));
assert_eq!(v1_iter.next(), Some(&3));
assert_eq!(v1_iter.next(), None);
@philipjkim
philipjkim / vscode-user-settings.json
Created June 4, 2018 03:18
VS Code user settings
{
"editor.fontSize": 14,
"[go]": {},
"[python]": {
"editor.formatOnSave": true
},
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
@philipjkim
philipjkim / template.go
Created February 12, 2018 09:51
genny sample template for list
package list
import (
"github.com/cheekybits/genny/generic"
)
// Something .
type Something generic.Type
// SomethingList .
package bar.foo;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ThreadLocalRandom;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.util.Comparator.*;