Skip to content

Instantly share code, notes, and snippets.

@takezoe
takezoe / DailyScala_PartialFunction.md
Created December 20, 2014 15:21
ScalaのPartialFunction

ScalaのPartialFunction

コレクションのcollectメソッド

コレクションのcollectメソッドについて考えてみる。

case class User(id: Int, name: String, isAdmin: Boolean)

val users: List[User] = List(
@takezoe
takezoe / RowChecksumFunction.java
Created February 25, 2024 17:05
Trino UDF for generating row-level checksum
package io.trino.operator.scalar;
import com.google.common.collect.ImmutableList;
import io.airlift.slice.Slice;
import io.airlift.slice.Slices;
import io.trino.annotation.UsedByGeneratedCode;
import io.trino.metadata.SqlScalarFunction;
import io.trino.spi.block.Block;
import io.trino.spi.block.SqlRow;
import io.trino.spi.function.BoundSignature;
@takezoe
takezoe / jupyter_on_docker.md
Last active April 29, 2023 05:50
Run JupyterLab on Docker

Run JupyterLab on docker

https://hub.docker.com/r/jupyter/scipy-notebook/

$ docker pull jupyter/scipy-notebook

$ docker run -v `pwd`:/home/jovyan/work -p 10000:8888 --name jupyter jupyter/scipy-notebook
...
 To access the server, open this file in a browser:
@takezoe
takezoe / CustomerServiceTest.java
Created June 25, 2017 06:36
Test case which uses @MockBean in Spring Boot application
package com.example.service;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.util.Collections;
import com.example.repository.CustomerRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@takezoe
takezoe / vscode_metals.md
Last active March 12, 2022 00:35
Keyboard shortcuts in VSCode + Metals

VS Code shortcut in VSCode + Metals

Shorcut Description
CTRL + SPACE Code Completion
COMMAND + P Find File
COMMAND + SHIFT + P Command Pallete
COMMAND + T Find Symbol in Workspace
SHIFT + COMMAND + O Find Symbol in Editor
F12 Go to Definition
@takezoe
takezoe / trino_test.rb
Created May 7, 2021 16:38
Test program for trino-client-ruby using tiny-presto which is library to launch Trino/Presto using docker
require 'trino-client'
require 'tiny-presto'
client = Trino::Client.new(server: 'localhost:8080', catalog: 'memory', user: 'test-user', schema: 'default')
cluster = TinyPresto::Cluster.new('trinodb/trino', '355')
container = cluster.run
loop do
begin
# Make sure to all workers are available.
client.run('show schemas')
@takezoe
takezoe / build.yml
Last active January 23, 2021 16:16
GitHub Actions configuration for GitBucket plugins
name: build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11]
trait CyclicA {
val b = bind[CyclicB]
}
trait CyclicB {
val a = bind[CyclicA]
}
val d = Design.newDesign
d.build[CyclicA] { a =>
@takezoe
takezoe / JSONSample.scala
Created December 30, 2011 15:02
Example of scala.util.parsing.json
import scala.util.parsing.json._
val result = JSON.parseFull("""
{"name": "Naoki", "lang": ["Java", "Scala"]}
""")
result match {
case Some(e) => println(e) // => Map(name -> Naoki, lang -> List(Java, Scala))
case None => println("Failed.")
}
@takezoe
takezoe / MyLispParser.scala
Created November 29, 2011 08:13
MyLisp implemented using Scala parser combinator library
package mylisp
import scala.util.parsing.combinator.RegexParsers
import scala.collection.mutable.{Map => MutableMap}
object MyLispParser extends App {
val source = """
(defun sayHello (name) (println "Hello " name "!"))
(defun sum (a b)(if (eq a b) a (sum (+ a 1) b)))
(println (sum 1 1000))