Skip to content

Instantly share code, notes, and snippets.

Kevin Lee Kevin-Lee

Block or report user

Report or block Kevin-Lee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Kevin-Lee
Kevin-Lee / 1-XShapeIn2DCollection.md
Last active Oct 13, 2019
Fill 2D collection to draw X shape / Multiplication table
View 1-XShapeIn2DCollection.md

Drawing X shape in 2D collection

Common Error Type

case class Error(message: String)
@Kevin-Lee
Kevin-Lee / fibonacci.hs
Last active Jun 14, 2018
Examples of Fibonacci number function
View fibonacci.hs
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)
@Kevin-Lee
Kevin-Lee / README.md
Created Feb 25, 2017
Shellscript to install fonts for macOS and Linux
View README.md

How to Use

# Move the the folder where the fonts are available. This script supports only otf and ttf.
# Then simply run the script like
$ ./path/to/script/install-fonts.sh 

Or you can add an alias to the ~/.bashrc or ~/.zshrc

alias install-fonts='/path/to/script/install-fonts.sh' 
View JProfiler-with-Docker.md

JProfiler with Docker

Docker

DockerFile

DockerFile should have JProfiler installation.

RUN wget <JProfiler file location> -P /tmp/ && \
  tar -xzf /tmp/<JProfiler file> -C /usr/local && \
  rm /tmp/<JProfiler file>
@Kevin-Lee
Kevin-Lee / StringInterpolation.scala
Last active Aug 26, 2017
Customized String interpolation example
View StringInterpolation.scala
/**
* @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
View HaskellPrimes.hs
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 / WordCount.scala
Last active Jan 15, 2016
Word Count Code Examples
View WordCount.scala
/**
* @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
@Kevin-Lee
Kevin-Lee / TakeLinks.md
Last active Sep 7, 2015
Take all the names and URLs from HTML
View TakeLinks.md
@Kevin-Lee
Kevin-Lee / SomeMapExample.java
Last active Aug 29, 2015
Some Java 8 example code
View SomeMapExample.java
package cc.kevinlee.examples;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import static cc.kevinlee.examples.KeyValPair.*;
/**
You can’t perform that action at this time.