Skip to content

Instantly share code, notes, and snippets.

View pishen's full-sized avatar

Pishen Tsai pishen

View GitHub Profile
@pishen
pishen / Token.scala
Created March 31, 2023 08:18
Token Refresher with lazy Future
class Token() {
def newToken(): Eval[Future[AccessToken]] = Eval.later(Future(???))
val tokenRef: AtomicReference[Eval[Future[AccessToken]]] = AtomicReference(newToken())
def get(): Future[AccessToken] = {
val eval = tokenRef.get()
eval.value.flatMap { token =>
if (token.isExpiring) {
tokenRef.compareAndSet(eval, newToken())
sbt:circe_akka_js_sbt> fastOptJS
[info] Compiling 1 Scala source to /Users/pishen/code/vpon/circe_akka_js_sbt/target/scala-2.12/classes ...
[info] Fast optimizing /Users/pishen/code/vpon/circe_akka_js_sbt/target/scala-2.12/circe_akka_js_sbt-fastopt.js
[error] Referring to non-existent method java.time.chrono.Chronology$.from(java.time.temporal.TemporalAccessor)java.time.chrono.Chronology
[error] called from java.time.temporal.IsoFields$Field$.java$time$temporal$IsoFields$Field$$isIso(java.time.temporal.TemporalAccessor)scala.Boolean
[error] called from java.time.temporal.IsoFields$Field$$anon$3.isSupportedBy(java.time.temporal.TemporalAccessor)scala.Boolean
[error] called from java.time.chrono.ChronoLocalDate.isSupported(java.time.temporal.TemporalField)scala.Boolean
[error] called from java.time.LocalDate.isSupported(java.time.temporal.TemporalField)scala.Boolean
[error] called from java.time.temporal.IsoFields$Field$$anon$2.getFrom(java.time.temporal.TemporalAccessor)scala.Long
[error] called fr
0,user1,songA
1,user4,songA
2,user1,songB
3,user2,songC
4,user4,songC
5,user3,songC
6,user1,songB
7,user3,songE
8,user2,songD
9,user4,songD

Keybase proof

I hereby claim:

  • I am pishen on github.
  • I am pishen (https://keybase.io/pishen) on keybase.
  • I have a public key ASBf2qZSIU6H4Y-jSzKHAVcmAhyQNTd8rePf5x_f_lJV6go

To claim this, I am signing this object:

@pishen
pishen / init.el
Last active August 25, 2017 08:01
.emacs.d/init.el (macOS)
;; use space instead of tab
(setq-default indent-tabs-mode nil)
;; use custom auto indent
(electric-indent-mode 0)
(global-set-key (kbd "RET")
(lambda ()
(interactive)
(newline)
(if (save-excursion (re-search-backward "^[^\n]" nil t))
@pishen
pishen / Dockerfile
Last active March 17, 2017 03:17
shiny-plotly docker
FROM ubuntu:latest
RUN apt-get update && apt-get install -y \
cron \
gdebi-core \
libcurl4-openssl-dev \
libfreetype6-dev \
libpq-dev \
libssl-dev \
libxml2-dev \