Skip to content

Instantly share code, notes, and snippets.

View nwtgck's full-sized avatar
:octocat:
Feel free to make my English natural by native speakers

Ryo Ota nwtgck

:octocat:
Feel free to make my English natural by native speakers
View GitHub Profile
@gakuzzzz
gakuzzzz / design_pattern_in_scala.md
Last active February 12, 2024 02:05
Design Patterns in Scala (ScalaMatsuri 2018 Unconfoerence)

Design Patterns in Scala

Scala でよく見るパターン

Type-Safe Builder

Javaで多引数のコンストラクタを避けるために使われる Builder パターンは、Scala では名前付き引数呼び出しが使えるので必要ありません。

Builderパターンに制約を加えて条件に合わない場合、コンパイルエラーにしたい。

@bowin
bowin / node.js PassThrough stream.md
Last active November 15, 2022 00:02
Node.js Stream PassThrough Usage
const {PassThrough} = require('stream')
const fs = require('fs')

const d = new PassThrough()  

fs.createReadStream('tt2.js').pipe(d)  // can be piped from reaable stream

d.pipe(process.stdout)                 // can pipe to writable stream 
d.on('data', console.log) // also like readable
@gakuzzzz
gakuzzzz / sbt-coursier.md
Last active June 27, 2019 03:23
あなたの sbt update を爆速にする sbt-coursier の紹介

あなたの sbt update を爆速にする sbt-coursier の紹介

この記事は Scala Advent Calendar 2016(Adventar) 10日目の記事です。

今は 12/10 の 625時です。年明けなんて無かった。いいね?

さてさて、sbt の依存jarのダウンロードが遅い、というのは割とよく言われる事であります。

で、この原因の一旦に、sbtが Apache Ivy を使っている、という点があります。

@arxdsilva
arxdsilva / URLvalidatorExample.go
Last active June 24, 2021 09:17
Golang - How to validate URL
import (
"fmt"
"github.com/asaskevich/govalidator"
)
// You can use as well instead of *url.URL a string with your URL, in this case you might drop `u.String()`
// - transformation to string in method call.
func validateURL(u *url.URL) error {
valid := govalidator.IsRequestURL(u.String())
if valid == false {
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@PhilOwen
PhilOwen / FirmataApp.scala
Last active July 9, 2017 03:18
ArduinoをFirmataでScalaから制御
import processing.core._
import processing.serial._
import cc.arduino._
class FirmataApp extends PApplet {
var ard: Arduino = null
override def settings() {
size(300, 300)
}
@timothyklim
timothyklim / Crypto.scala
Last active March 21, 2021 19:18
AES encryption/decryption with akka stream
package utils
import akka.stream._
import akka.stream.scaladsl._
import akka.stream.stage._
import akka.util.{ByteString, ByteStringBuilder}
import scala.annotation.tailrec
import java.security.SecureRandom
import java.security.{Key, KeyFactory, PublicKey, PrivateKey}
import java.security.spec.{PKCS8EncodedKeySpec, X509EncodedKeySpec}
socat Examples
===============
* 注意
- SYSTEM で : を使う時は必ずエスケープすること
* 相手に接続
# telnet, netcat, socat それぞれの場合
$ socat - TCP:127.0.0.1:8000
@tzhenghao
tzhenghao / .gitignore
Created November 22, 2015 21:20
.gitignore for Code Composer Studio projects
Release/*
.xdchelp
config/*
.launches/*
@hashrock
hashrock / diag.md
Last active February 26, 2024 05:51
作図系ツール・ライブラリまとめ

シーケンス図とかフローチャートをしごとで描画することになった場合、 テキストから生成できたら楽なので、それ系のツールまとめ

GraphViz

http://www.graphviz.org/

  • C製
  • Doxygen, Moinmoinなどと連携可能
  • ブロック図、クラス図、ネットワーク図など