Skip to content

Instantly share code, notes, and snippets.

View kevin-lee's full-sized avatar
🏠
Working from home

Kevin Lee kevin-lee

🏠
Working from home
View GitHub Profile
@kevin-lee
kevin-lee / mvn-dep-tree.sh
Last active December 11, 2015 05:48
Simple script to get a maven dependency tree without using maven's options which are hard to remember.
#!/bin/bash
##########################################################
## Simple script to get maven dependency tree ##
## @author Lee, SeongHyun (Kevin) ##
## @veraion 0.0.1 (2013-01-17) ##
## ##
## To change the option 'include' and 'output', change ##
## the values of INCLUDE_NAME and OUTPUT_NAME ##
## respectively. ##
## e.g.) to change 'include' to 'inc' and 'output' to ##
@kevin-lee
kevin-lee / WebConfiguration.java
Last active December 22, 2015 16:09
A solution or at least a workaround to the problem described at https://github.com/webjars/jquery/pull/8 for Spring framework users. To use this, you shouldn't use <mvc:resources> or ResourceHandler. It works for both name-version.number.extension and name.extension. e.g.) /webjars/jquery/1.10.2/jquery-1.10.2.min.map, /webjars/jquery/1.10.2/jque…
/**
* Copyright 2013 Lee, Seong Hyun (Kevin)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@kevin-lee
kevin-lee / WordCount.scala
Last active January 15, 2016 12:16
Word Count Code Examples
/**
* @author Kevin Lee
* @since 2016-01-15
*/
object WordCount extends App {
def wordCount(lines: String): Map[String, Array[Int]] =
lines.split('\n')
.map(_.trim)
.map(_.split("[\\s]+"))
.zipWithIndex
let primes :: [Integer]
primes = sieve [2..]
where sieve :: [Integer] -> [Integer]
sieve (x : xs) = x : sieve [n | n <- xs, n `mod` x /= 0]
-- It works even without parameter types specified yet it is always good to have the type information
-- as it tells the users of the function how to use it.
-- It can also help you implement the function.
-- primes without parameter types (Uncomment it if you want to try).
@kevin-lee
kevin-lee / gitpullall
Last active January 12, 2017 17:08
Git pull from multiple remote git repositories
Copyright 2015 Lee, Seong Hyun (Kevin)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@kevin-lee
kevin-lee / OverridingAndHidingTest.java
Last active March 24, 2017 03:07
Example code of overriding and hiding methods. Check out my comments on http://goo.gl/wZL96
class SuperClass
{
public static void runStatic(String code)
{
System.out.println(code + ": I am the runStatic method in SuperClass.");
}
public static void runStatic2(String code)
{
System.out.println(code + ": I am the runStatic2 method in SuperClass.");
@kevin-lee
kevin-lee / StringInterpolation.scala
Last active August 26, 2017 07:15
Customized String interpolation example
/**
* @author Kevin Lee
* @since 2016-04-09
*/
object StringInterpolation extends App {
implicit class EscapeNewLineAndDoubleQuote(val sc: StringContext) extends AnyVal {
def esc(args: Any*): String = {
val strings = sc.parts.iterator
val expression = args.iterator
@kevin-lee
kevin-lee / InstallCert.java
Last active May 16, 2018 04:52
Tool to add an untrusted (self-signed) SSL certificate to JVM.
/*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
@kevin-lee
kevin-lee / fibonacci.hs
Last active June 14, 2018 14:32
Examples of Fibonacci number function
fib 0 = 0
fib 1 = 1
fib 2 = 1
fib n = fib (n - 1) + fib (n - 2)
-- Get the 100th number
fib 100
-- But it takes too long.
-- You can do it with zipWith like the following line and it works much faster
fibs = 0 : 1 : 1 : zipWith (+) (drop 1 fibs) (drop 2 fibs)