Skip to content

Instantly share code, notes, and snippets.

View jamesyang124's full-sized avatar

James Yang jamesyang124

  • HTC
  • Richmond, California
View GitHub Profile
@jamesyang124
jamesyang124 / ExampleServer.scala
Created December 13, 2018 17:33 — forked from vastdevblog/ExampleServer.scala
Example of a Finagle server
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}

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
jamesyang124 / type-bounds.scala
Created July 1, 2018 17:44 — forked from retronym/type-bounds.scala
Tour of Scala Type Bounds
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 June 22, 2018 08:24 — forked from anoopelias/Manifest.md
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

@jamesyang124
jamesyang124 / jenkins-script
Created March 27, 2018 08:56 — forked from justengland/jenkins-script
Add mochawesome to jenkins
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 February 11, 2018 16:08 — forked from cvrebert/css_regression_testing.md
Survey of screenshot-based CSS testing tools

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 November 2, 2017 02:41 — 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
=begin
Useage:
#assets/locales/en.js.erb
```js
//= depend_on_config 'locales/es.yml'
```
=end
@jamesyang124
jamesyang124 / Jenkinsfile.groovy
Created August 8, 2017 12:05 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
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'
@jamesyang124
jamesyang124 / Base64.md
Created May 25, 2017 08:36 — forked from barrysteyn/Base64.md
OpenSSL Base64 En/Decode: Portable and binary safe.

OpenSSL Base64 Encoding: Binary Safe and Portable

Herewith is an example of encoding to and from base64 using OpenSSL's C library. Code presented here is both binary safe, and portable (i.e. it should work on any Posix compliant system e.g. FreeBSD and Linux).

License

The MIT License (MIT)

Copyright (c) 2013 Barry Steyn