Skip to content

Instantly share code, notes, and snippets.

View ponkotuy's full-sized avatar
🗾

ponkotuy ponkotuy

🗾
View GitHub Profile
@ponkotuy
ponkotuy / main.go
Created March 17, 2024 11:35
Golang Genericsサンプル(単方向リスト)
package main
import (
"fmt"
"golang.org/x/exp/constraints"
)
type List[T any] struct {
head *T
@ponkotuy
ponkotuy / ThumbnailGenerator.scala
Created September 22, 2022 03:50
良さげなサムネイル画像作るだけのコード
import sun.awt.image.ToolkitImage
import java.awt.image.{AreaAveragingScaleFilter, BufferedImage, FilteredImageSource, ImageObserver}
import java.awt.{Image, Toolkit, image}
import java.io.{ByteArrayOutputStream, File}
import java.nio.file.{Files, Path}
import javax.imageio.{IIOImage, ImageIO, ImageWriteParam}
case class ThumbnailGenerator(width: Int, height: Int) {
private[this] val filter = AreaAveragingScaleFilter(width, height)
@ponkotuy
ponkotuy / error.sh
Created November 18, 2019 14:09
alpineでadoptopenjdk11を動かしたときのlddのエラー
# ldd /jdk-11.0.5+10/bin/java
/lib64/ld-linux-x86-64.so.2 (0x7f6a45486000)
libz.so.1 => /lib/libz.so.1 (0x7f6a4546c000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f6a45486000)
libjli.so => /jdk-11.0.5+10/bin/../lib/jli/libjli.so (0x7f6a4525b000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f6a45486000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f6a45486000)
Error relocating /jdk-11.0.5+10/bin/../lib/jli/libjli.so: __strdup: symbol not found
Error relocating /jdk-11.0.5+10/bin/../lib/jli/libjli.so: __rawmemchr: symbol not found
@ponkotuy
ponkotuy / point.sql
Created November 17, 2019 12:10
spatial index(geo)とindex(geo) using rtreeの違い
create table point(
id bigint not null auto_increment primary key,
spa geometry not null,
rtr geometry not null,
spatial index(spa),
index(rtr) using rtree
) engine=InnoDB, default charset=utf8mb4;
@ponkotuy
ponkotuy / browser_settings.json
Last active December 1, 2019 16:16
Karabiner-ElementsでMacに人権を導入するcomplex_modifications
{
"title": "Browser settings",
"rules": [
{
"description": "left_control to left_command(Firefox&Chrome)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_control",
@ponkotuy
ponkotuy / ponkotuy.json
Created November 13, 2019 18:48
iTerm2用のProfile
{
"Ansi 6 Color" : {
"Green Component" : 0.73333334922790527,
"Red Component" : 0,
"Blue Component" : 0.73333334922790527
},
"Tags" : [
],
"Ansi 12 Color" : {
@ponkotuy
ponkotuy / ProcStat.scala
Created September 13, 2019 11:50
Scalaで/proc/statのCPU情報を解析するだけの簡単な
package utils
import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Paths}
import scala.collection.JavaConverters._
object ProcStat {
val StatPath = Paths.get("/proc/stat")
def cpuStats: CpuStats = {
@ponkotuy
ponkotuy / EitherTFutureUtils.scala
Created July 11, 2019 09:14
EitherT[Future, A, B]のUtil
import cats.data.EitherT
import cats.implicits._
import scala.collection.immutable.Iterable
import scala.concurrent.{ExecutionContext, Future}
object EitherTFutureUtils {
def eitherT[A, B](a: A): EitherT[Future, B, A] = EitherT(Future.successful(Either.right[B, A](a)))
def futureReduceLeft[A, B](xs: Iterable[EitherT[Future, B, A]])(f: (A, A) => A)(implicit ec: ExecutionContext): EitherT[Future, B, A] = {
@ponkotuy
ponkotuy / binary_search.rb
Created May 10, 2019 10:04
BinarySearchサンプル
class RecordBoundarySearch
KeyValue = Struct.new(:key, :value)
def initialize(table)
@table = table
end
def first
record_boundary(@table.order(id: 'ASC').limit(2))
end
@ponkotuy
ponkotuy / common_cache.rb
Created February 28, 2019 10:01
CacheAPIWrapper
class CommonCache
def initialize(prefix, expire)
@prefix = prefix
@expire = expire
end
def key(id)
"#{@prefix}_#{id}"
end