Skip to content

Instantly share code, notes, and snippets.

James Yang jamesyang124

Block or report user

Report or block jamesyang124

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
@jamesyang124
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.net.InetSocketAddress
import java.util.UUID
import java.util.concurrent.{Executors, TimeUnit}
import com.google.common.base.Splitter
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}
View thread-pools.md

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.

View Applied-FP-with-Scala.md

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
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
jamesyang124 / Manifest.md
Created Jun 22, 2018 — forked from anoopelias/Manifest.md
Using Manifest to get around with type erasure in scala
View Manifest.md

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
View java-operations.md

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
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
jamesyang124 / css_regression_testing.md
Created Feb 11, 2018 — forked from cvrebert/css_regression_testing.md
Survey of screenshot-based CSS testing tools
View css_regression_testing.md

Currently considering https://github.com/webdriverio/webdrivercss


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
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
=begin
Useage:
#assets/locales/en.js.erb
```js
//= depend_on_config 'locales/es.yml'
```
=end
@jamesyang124
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.