Skip to content

Instantly share code, notes, and snippets.

View jamesyang124's full-sized avatar

James Yang jamesyang124

View GitHub Profile
@jamesyang124
jamesyang124 / twjug_04_15_2016.md
Last active April 16, 2016 16:32
digest of the topic: Event Sourcing and Microservices.

Event Sourcing and Microservices

talked by Ralph Winzinger


###Microservices I
  • fault-tolerant /resilient

> through docker or other container services to supoprt backup/restore/launch-up when an instance is down.

@jamesyang124
jamesyang124 / .gitignore
Created July 30, 2016 05:12 — forked from adamgit/.gitignore
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
#####
# OS X temporary files that should never be committed
.DS_Store
*.swp
*.lock
profile
#####
# DotEnv files
.env
@jamesyang124
jamesyang124 / security_algorithms.md
Last active August 22, 2016 15:46
security algorithms for refactoring.

Review of Effective Ruby

Item 2

All Objects Could Be nil

All objects are mutable by default. It can be nil, using nil?, is_a?, to_a, etc. to help the value validaiton for method input.

Item 3

@jamesyang124
jamesyang124 / main.go
Created March 10, 2017 10:59 — forked from sogko/main.go
[graphql-go] Mutation example with `graphql-go/handler`
package main
import (
"github.com/graphql-go/graphql"
"github.com/graphql-go/handler"
"net/http"
)
type Todo struct {
ID string `json:"id"`
@jamesyang124
jamesyang124 / slick_3.2.0_inner_case_class_error.md
Last active March 15, 2017 07:36
slick-3.2.0 inner case class with final keyword

Slick 3.2.0 source code generator prepend final key word for Entity type case class generation, this leads the issue have not been resolved since years:

https://issues.scala-lang.org/browse/SI-4440

The workaround is to create custom source code generator then override that def caseClassFinal = true to false instead.

Related thread:

slick/slick#1665

@jamesyang124
jamesyang124 / scala_collection_guide.md
Last active February 15, 2023 11:21
Scala Collection Guide

Traversabel#flatten

If a type class extend or transform to GenTraversableOnce type, then it is flattenable. But you have to write your own GenTraversableOnce rule

import scala.language.implicitConversions
implicit def int2Traversable[T <: Any](n: T): Traversable[Any] = n match {
  case x: List[Any] => x
  case c => Traversable[T](c)
}

Why typeclass?

Polymorphism and Decoupling.

Polymorphism

  1. Parametric

List of Int, list of Double, types are as type parameters in a context(List), not as types of direct values(without context) which infer the idea of ad-hoc polymorphism