Skip to content

Instantly share code, notes, and snippets.

View vitojeng's full-sized avatar
🇹🇼
Awesome

Vito Jeng vitojeng

🇹🇼
Awesome
View GitHub Profile
@vitojeng
vitojeng / Message.scala
Last active February 26, 2022 07:25
hello_world
object Messages {
def hello = "Hello"
}
@vitojeng
vitojeng / learning-akka-stream-source-api.scala
Last active November 19, 2019 02:27
[WIP]Learning Akka Stream Source API
import akka.actor.ActorSystem
import akka.stream.Attributes.name
import akka.stream.scaladsl._
import akka.stream.stage.{GraphStage, GraphStageLogic, OutHandler}
import akka.stream.{ActorMaterializer, Attributes, Outlet, SourceShape}
class BaseStreamApp extends App {
implicit val system = ActorSystem("stream-test")
implicit val materializer = ActorMaterializer()
@vitojeng
vitojeng / curl.md
Created March 27, 2019 13:51 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@vitojeng
vitojeng / scala-typeclass-intro-0.md
Last active January 12, 2018 06:50
Type classes in Scala sample code

Sample code from Type classes in Scala

object TypeClasses0 {

  trait Show[A] {
    def show(a: A): String
  }

 object Show {
@vitojeng
vitojeng / StaticFile.scala
Created September 1, 2017 13:24 — forked from bmc/StaticFile.scala
I needed code to serve static files from an Akka HTTP server. I wanted to use fs2 to read the static file. Michael Pilquist recommended using streamz to convert from an fs2 Task to an Akka Source. This is what I came up with. (It does actually work.)
object StaticFile {
// Various necessary imports. Notes:
//
// 1. fs2 is necessary. See https://github.com/functional-streams-for-scala/fs2
// 2. streamz is necessary. See https://github.com/krasserm/streamz
// 3. Apache Tika is used to infer MIME types from file names, because it's more reliable and
// fully-featured than using java.nio.file.Files.probeContentType().
//
// If using SBT, you'll want these library dependencies and resolvers:
@vitojeng
vitojeng / list-all-docker-container-name-and-ip.md
Last active June 1, 2017 03:42
List all docker container name and ip address
function docker_container_ip() {
  container_ids=$(docker ps -aq)
  for cid in ${container_ids}
  do
    info=$(docker inspect -f 'name={{.Name}}  ip={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${cid})
    echo -e "$cid \t $info"
  done
}
@vitojeng
vitojeng / Plugin.scala
Last active December 16, 2016 01:23 — forked from lihaoyi/Plugin.scala
A #Scala compiler plugin to add a nice banner
package demo
import scala.tools.nsc.io.AbstractFile
import scala.tools.nsc.{Global, Phase}
import scala.tools.nsc.plugins.{Plugin, PluginComponent}
class DemoPlugin(val global: Global) extends Plugin {
import global._
override def init(options: List[String], error: String => Unit): Boolean = true
@vitojeng
vitojeng / .bash_profile
Last active December 13, 2016 05:51
My .bash_profile for mac os
alias ll="ls -lh"
alias untgz="tar zxvf"
alias simpleHttpServer="python -m SimpleHTTPServer 8008"
alias treeprj="tree -d -I 'target|project'"
# seperate different part in following files.
@vitojeng
vitojeng / getting-started-in-scala.md
Last active February 27, 2019 09:10 — forked from djspiewak/getting-started-in-scala.md
untitled Getting Started in Scala

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

@vitojeng
vitojeng / _useful_linux_commands.md
Last active August 28, 2018 09:15
Useful linux commands

Account

# 建立帳號, 並建立 home dir
$ sudo useradd -m [account]

# 更改密碼, 會詢問
$ sudo passwd [account]