Skip to content

Instantly share code, notes, and snippets.

@joecwu
joecwu / Blog-Scala-ReaderMonad-DI.md
Last active June 23, 2023 06:41
Scala中使用Reader Monad來實現Dependency Injection
title published tags
Scala中使用Reader Monad來實現Dependency Injection
true
ScaVaToScala
Scala
Scalaz
Programming
shortener

[ScaVa->Scala] Scala中使用Reader Monad來實現Dependency Injection

前言

此篇文章同時發步於BlogGist

@joecwu
joecwu / Blog-Docker-Private-Registry.md
Last active July 11, 2020 07:03
[Docker] Private Registry
published tags
true
Docker

[Docker] Private Registry

這篇同步發佈在我的BlogGist

前言

最近開始run startup,非常忙碌,沒什麼時間寫blog,但是有些難找的東西,還是要記錄一下,看看能不能幫到別人。

@joecwu
joecwu / elasticsearch.yml
Created October 14, 2019 01:16 — forked from reyjrar/elasticsearch.yml
ElasticSearch config for a write-heavy cluster
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: logng
# Node can have abritrary attributes we can use for routing
#!/bin/bash
if [ -z $1 ]; then
echo "usage: $0 APP_SEARCH_HOST APP_SEARCH_AUTH ES_HOST ENGINE_NAME"
exit 1
else
APP_SEARCH_HOST=$1
fi
if [ -z $2 ]; then
@joecwu
joecwu / es-artist-converter.scala
Created March 29, 2019 12:39
Elasticsearch search result convert to MeCab-IPADIC format
import $ivy.`org.scalaz::scalaz-core:7.2.+`
import $ivy.`org.json4s::json4s-jackson:3.+`
import $ivy.`org.json4s::json4s-ext:3.+`
import $ivy.`com.github.nscala-time::nscala-time:2.18.+`
import scalaz._
import Scalaz._
import com.github.nscala_time.time.Imports._
import scala.io.Source
import org.json4s._
import org.json4s.jackson.JsonMethods._
@joecwu
joecwu / introduction-to-scala-dev.md
Last active July 30, 2018 21:10
[ScaVa->Scala] Introduction to Scala Development
published tags
true
ScaVaToScala
Scala
Scalaz
Programming

[ScaVa->Scala] Introduction to Scala Development

前言

這件文件是在公司內部向一些新踏入Scala領域的同事們介紹所使用的資料,因此適合有程式開發經驗,並且想Scala領域中的朋友們。 底下列了一些學習Scala的資源、並列出一些我們自己開發常用到的Libraries並適合新手來學習使用的。

Category theory(範疇論)之什麼是Functor, Applicative, Monad, Semigroup, Monoid?

之前曾經寫過一篇 什麼是Monad? ,裡面提到了對於Monad的解釋,而今天進一步解釋這些在Functional Programming中常見到的詞:Functor, Applicative, Monad, Semigroup, Monoid。 透過放在一起比較,讓我們更清楚這些之間的差別與關係。

##Functor

在提到Functor之前,請先了解一下scala中map的作用,map可以讓你傳入一個function,而透過這個function是可以從F[A]轉換成F[B],這裡的F不管他(就是代表外面的包裝不會變),而裡面的A型態轉成B型態。

例如:

@joecwu
joecwu / docker-compose-es-cluster.yml
Created March 2, 2018 19:53
docker-compose.yml for starting basic es cluster
version: '2'
services:
elasticsearch1:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.2
container_name: es1
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
@joecwu
joecwu / mongodb-s3-backup.sh
Created July 6, 2017 06:18 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@joecwu
joecwu / Blog-ScalaInDepth-Scala-Case-Classes.md
Last active December 19, 2016 06:13
[Scala In Depth] Scala Case Classes
published tags
true
ScalaInDepth
Scala
Programming

[Scala In Depth] Scala Case Classes

這篇同步發佈在我的BlogGist

這篇文章,基本上是參考這篇Scala Case Classes In Depth來寫的,閱讀吸收後以我的例子與描述方式以中文寫下。