View mackerel.sh
#/bin/bash -ex
set -ex;
if [ $# -lt 4 ]; then
echo "Usage: $0 api_key service_name [name value ...]"
exit 1;
fi
API_KEY=$1; shift;
View ResponseLTSVLoggingService.java
public static class ResponseLTSVLoggingService<I extends Request, O extends Response>
extends DecoratingService<I, O, I, O> {
public ResponseLTSVLoggingService(Service<? super I, ? extends O> delegate) {
super(delegate);
}
@Override
public O serve(ServiceRequestContext ctx, I req) throws Exception {
ctx.log().addListener(this::logResponse, RequestLogAvailability.COMPLETE);
View line_bot_programming_beginner.md

LINE Botの仕組み

https://gyazo.com/906b2dea05adb6101b7705625c547ef0

  • LINEからのメッセージイベントは、Webhookを通してご自身で用意していただくhttp serverへ届けられます
  • Webhookを受け取るURLには、httpではなく、httpsを設定する必要があります
  • 本チュートリアル内では、開発用のサーバ設定を行います
    • サーバはご自身のPCに立ち上げます
    • 外部(LINEのサーバ)からWebhookを受け取れるようにngrokを利用して、外部リクエストをご自身のPCに立ち上げたhttpサーバへ届くようにします
View DynamicEmbededFieldNameValidatorConfig.java
@Configuration
public class Config extends WebMvcConfigurerAdapter {
@Bean
public LocalValidatorFactoryBean validator() {
LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
TermTranslateMessageInterpolator reTransableMessageInterpolator
= new TermTranslateMessageInterpolator(messageSource());
localValidatorFactoryBean.setMessageInterpolator(reTransableMessageInterpolator);
return localValidatorFactoryBean;
}
View install nginx
# http://openresty.org/ : with lua
groupadd -g 501 nginx
sudo useradd -g nginx -u 501 -s /sbin/nologin -d /var/www nginx
sudo yum install -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
# normal nginx (or --prefix=/usr/local/nginx)
./configure \
--user=nginx \
--group=nginx \
View typelevel_lt.md

!SLIDE

Typelevel FizzBuzz in Scala

@halcat0x15a

!SLIDE

型レベルプログラミング

View Global.scala
import java.lang.reflect.Constructor
import providers.HatenaProvider
import securesocial.core.RuntimeEnvironment
import securesocial.core.providers._
import service.{DemoUser, MyEventListener, InMemoryUserService}
import scala.collection.immutable.ListMap
object Global extends play.api.GlobalSettings {
View either_left_for_complehension.scala
scala> case class InvalidData(i: Int)
defined class InvalidData
scala> def firstProcess(i: Int): Either[InvalidData, Int] = try{ Right(10 / i) } catch { case _: Throwable => Left(InvalidData(i)) }
firstProcess: (i: Int)Either[InvalidData,Int]
scala> def secondProcess(d: InvalidData): Either[InvalidData, Int] = try{ Right(10 + d.i) } catch { case _: Throwable => Left(InvalidData(d.i)) }
secondProcess: (d: InvalidData)Either[InvalidData,Int]
scala> for { a <- firstProcess(2).left; b <- secondProcess(a).right } yield b
View s-99.rb
# -*- coding: utf-8 -*-
##############################
##### Working with lists #####
##############################
def last(ls)
ls[-1]
end
View gist:f94c54678bc02224a8f5
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.