Skip to content

Instantly share code, notes, and snippets.

View philipjkim's full-sized avatar

Soo Philip Jason Kim philipjkim

View GitHub Profile
@philipjkim
philipjkim / gcj2004_qr_p1.py
Last active February 7, 2017 05:43
Google Code Jam 2004 QR Problem 1
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 February 3, 2017 04:48
Startup template for Google Code Jam
package main
import (
"io/ioutil"
"os"
"strconv"
"strings"
"text/scanner"
)
@philipjkim
philipjkim / LinkedList.java
Created December 23, 2016 01:35
Removing duplications in a single linked list
package bar.foo;
public class LinkedList {
Node head;
// Push i to the first index of the linked list, so i becomes the new head.
void push(int i) {
Node n = new Node(i);
n.next = this.head;
this.head = n;
@philipjkim
philipjkim / Ch1.java
Created December 15, 2016 08:29
Removing duplicated chararters in char[]
package org.sooo;
public class Ch1 {
public static char[] removeDup(char[] str) {
if (str == null || str.length == 1) {
return str;
}
// mark duplicated characters to special character (a.k.a. dupChar).
char dupChar = '\0';
@philipjkim
philipjkim / BST.java
Created December 13, 2016 05:17
Finding sum of n elements after kth smallest element in BST
package com.foo;
import java.util.Stack;
/*
Find sum of n elements after kth smallest element in BST.
Tree is very large, you are not allowed to traverse the tree.
*/
public class BST {
@philipjkim
philipjkim / settings.json
Created December 1, 2016 06:47
Custom settings for VS code
// Place your settings in this file to overwrite the default settings
{
"files.autoSave": "onWindowChange",
"files.associations": {
"*.tac": "python",
"*.ace": "jade"
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
@philipjkim
philipjkim / elastic_aggregator.go
Last active June 16, 2021 18:02
Go Elasticsearch aggregation example
package main
import (
"fmt"
"time"
"encoding/json"
elastic "gopkg.in/olivere/elastic.v3"
)
@philipjkim
philipjkim / docker-clean.sh
Created October 26, 2016 01:26
Docker clean-up
#!/bin/sh
# Reference: http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/
docker rm -v $(docker ps -a -q -f status=exited)
docker rmi $(docker images -f "dangling=true" -q)
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes
@philipjkim
philipjkim / concurrency.go
Created April 8, 2016 06:26
Go Concurrency Example
package main
import (
"fmt"
"math/rand"
"time"
)
/*
This code is based on sample codes from 'Go Concurrency Patterns', Rob Pike's Google I/O 2012 presentation.
@philipjkim
philipjkim / my-reverse.clj
Created February 12, 2016 01:05
Reversing nested sequences in Clojure
(defn my-reverse-v1 [input]
(let [head (first input)
tail (rest input)]
(if head
(conj (my-reverse-v1 (vec tail))
(if (sequential? head)
(my-reverse-v1 (vec head))
head))
[])))