Skip to content

Instantly share code, notes, and snippets.

View mocyuto's full-sized avatar
🏠
Working from home

Yuto Suzuki mocyuto

🏠
Working from home
View GitHub Profile
@mocyuto
mocyuto / syakutori.go
Created October 6, 2021 08:03
しゃくとり法
package main
import "fmt"
func main() {
var length, max int
fmt.Scanf("%d %d", &length, &max)
arr := []int{}
for i := 0; i < length; i++ {
var num int
@mocyuto
mocyuto / buffer2_test.go
Last active September 17, 2021 09:58
buffer test
package main
import (
"bytes"
"io"
"testing"
)
const N int = 2000000
func maxSubArray(nums []int) int {
m := nums[0]
tmpSum := 0
for _, n := range nums {
if tmpSum < 0 {
tmpSum = 0
}
tmpSum += n
if m < tmpSum {
m = tmpSum
@mocyuto
mocyuto / timeout_with_errgroup.go
Created April 9, 2021 01:47
Time out with errgroup
package main
import (
"context"
"fmt"
"log"
"time"
"golang.org/x/sync/errgroup"
)
@mocyuto
mocyuto / createEnv.md
Created June 17, 2018 03:05
iframe 3rd party cookie test

docker構築

dockerを起動した後、以下でnginxサーバを立ち上げる

$ docker run -d -p 80:80 --name webserver nginx
$ docker exec -it webserver /bin/bash

root@docker# apt-get install vim
root@docker# cd /usr/share/nginx/html
## 上記2ファイルを貼る
root@docker# vim index.html 
@mocyuto
mocyuto / snsHandler.go
Last active June 12, 2018 11:48
SNSからS3のイベントを受け取る
package main
import (
"encoding/json"
"log"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
@mocyuto
mocyuto / Input.scala
Last active October 14, 2016 09:50
inputStream to Seq[String]
import java.io.{ BufferedReader, InputStream, InputStreamReader }
object Input{
/**
* inputStreamで取得したものをカラム数だけ取得
* @return (String列, 途中で切ったか)
*/
protected def stream2string(csvStream: InputStream, lineNumberOp: Option[Int]): (Seq[String], Boolean) = {
val reader = new BufferedReader(new InputStreamReader(csvStream))
@mocyuto
mocyuto / temp.scala
Last active October 7, 2016 02:21
Value Class behaves strange
import org.json4s._
import org.json4s.jackson.JsonMethods._
import org.json4s.jackson.Serialization._
Object Temp{
case class Attributes(value: String) extends AnyVal
case class Temp(seq: Seq[Attributes])
def main(args: Array[String]): Unit = {
val a = """ {"seq":["test"]} """
val b = Seq("test")
@mocyuto
mocyuto / akka.conf
Last active September 22, 2016 01:13
akkaの設定をいじったもの
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loglevel = DEBUG
logger-startup-timeout = 25s
actor.deployment {
# deployment id pattern - on the format: /parent/child etc.
/test {
# routing (load-balance) scheme to use
@mocyuto
mocyuto / build.sbt
Created February 5, 2016 10:52
create task
lazy val hello = taskKey[Unit]("say hello to you")
lazy val root = (project in file("."))
.settings(
hello := {println("Hello")}
)