Skip to content

Instantly share code, notes, and snippets.

Avatar

Soo Philip Jason Kim philipjkim

View GitHub Profile
@philipjkim
philipjkim / context_demo.go
Created Apr 24, 2019
Demo: Using context to cancel heavy jobs after timeout
View context_demo.go
package main
import (
"context"
"fmt"
"time"
)
// DemoTimeout .
func DemoTimeout(ctxTimeout time.Duration, workDuration time.Duration) error {
@philipjkim
philipjkim / git-amend-author.sh
Last active Mar 13, 2019
Bash scripts for amending author of commits at once
View git-amend-author.sh
#!/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 May 4, 2022
Rust: Difference between iter(), into_iter(), and iter_mut()
View iter_test.rs
#[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);
View vscode-user-settings.json
{
"editor.fontSize": 14,
"[go]": {},
"[python]": {
"editor.formatOnSave": true
},
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
@philipjkim
philipjkim / template.go
Created Feb 12, 2018
genny sample template for list
View template.go
package list
import (
"github.com/cheekybits/genny/generic"
)
// Something .
type Something generic.Type
// SomethingList .
View StreamSample.java
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.*;
@philipjkim
philipjkim / gcj2004_qr_p1.py
Last active Feb 7, 2017
Google Code Jam 2004 QR Problem 1
View gcj2004_qr_p1.py
import sys
# Problem: https://code.google.com/codejam/contest/2974486/dashboard#s=p0
# Reference: http://codereview.stackexchange.com/a/154360/73051
def main():
submit = False
filename = "A-small-practice"
@philipjkim
philipjkim / main.go
Created Feb 3, 2017
Startup template for Google Code Jam
View main.go
package main
import (
"io/ioutil"
"os"
"strconv"
"strings"
"text/scanner"
)