Skip to content

Instantly share code, notes, and snippets.

James Yang jamesyang124

View GitHub Profile
jamesyang124 / ExampleServer.scala
Created Dec 13, 2018 — forked from vastdevblog/ExampleServer.scala
Example of a Finagle server
View ExampleServer.scala
package com.vast.example
import java.util.UUID
import java.util.concurrent.{Executors, TimeUnit}
import com.twitter.finagle.http.Http
import com.twitter.finagle.builder.{Server, ServerBuilder}
import com.twitter.finagle.service.TimeoutFilter
import com.twitter.finagle.{Service, SimpleFilter, GlobalRequestTimeoutException}

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.


Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
jamesyang124 / type-bounds.scala
Created Jul 1, 2018 — forked from retronym/type-bounds.scala
Tour of Scala Type Bounds
View type-bounds.scala
class A
class A2 extends A
class B
trait M[X]
// Upper Type Bound
def upperTypeBound[AA <: A](x: AA): A = x
jamesyang124 /
Created Jun 22, 2018 — forked from anoopelias/
Using Manifest to get around with type erasure in scala

Typically, you can't use a 'new' operator on a generic type. This is because of type erasure.

scala> def create[T] = new T
<console>:7: error: class type required but T found
   def create[T] = new T

Scala gives a way of getting around this problem, with the Manifest class.

scala> def create[T](implicit m:Manifest[T]) = m.erasure.newInstance

Logical Operator

  • ^ as XOR operator
  • & is AND operator
  • | is OR operator
  • && and || are short-circuit operators.

Bitwise Operation

  • 2's complement represent negative number x as its (abs(x) - 1) binary format, then flip each 0 and 1 bit.
jamesyang124 / jenkins-script
Created Mar 27, 2018 — forked from justengland/jenkins-script
Add mochawesome to jenkins
View jenkins-script
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src 'none'; script-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self'; style-src 'self'; font-src 'self';")
jamesyang124 /
Created Feb 11, 2018 — forked from cvrebert/
Survey of screenshot-based CSS testing tools

Currently considering

Core Goals:

  • Can test in up-to-date versions of all major browsers
  • Can test on up-to-date versions of all major OSes
  • Can test in IE9 (because Bootstrap v4 will support IE9+)
  • Don't want to have to setup/maintain our own cluster of VMs running all the necessary OSes (and all the versions of Windows)
  • Workflow for management of reference/baseline/norm screenshots
jamesyang124 / 0. sprockets_depend_on_config.rb
Created Nov 2, 2017 — forked from dylanjha/0. sprockets_depend_on_config.rb
Adds Sprockets Directive `depend_on_config`. I'm using this to load .yml locale translations on the server into the client in json
View 0. sprockets_depend_on_config.rb
//= depend_on_config 'locales/es.yml'
jamesyang124 / Jenkinsfile.groovy
Created Aug 8, 2017 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
View Jenkinsfile.groovy
node {
echo 'No quotes in single backticks'
sh 'echo $BUILD_NUMBER'
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"'
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"'
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"'
echo 'Using three backslashes still results in preserving the single quotes'
You can’t perform that action at this time.