Skip to content

Instantly share code, notes, and snippets.

View goldeneggg's full-sized avatar

Fuminori Sakamoto goldeneggg

  • 合同会社Practa / Practa LLC (Founder)
  • Japan
  • X @practainc
View GitHub Profile
@goldeneggg
goldeneggg / main.go
Last active September 6, 2023 04:41
TELNET or TELNETS(TELNET over SSL) to koukoku.shadan.open.ad.jp in Go
package main
import (
"bufio"
"bytes"
"crypto/tls"
"fmt"
"io"
"log"
"net"
@goldeneggg
goldeneggg / benchmark-hash-struct-openstruct.rb
Last active November 28, 2022 01:02
Benchmark Comparison - Hash vs Struct vs OpenStruct in Ruby 2.7.6
require 'benchmark/ips'
require 'benchmark/memory'
module Benchmarker
class Target
attr_reader :title, :code_block
def initialize(title:, code_block:)
@title = title
@code_block = code_block
@goldeneggg
goldeneggg / benchstat-vs-latest
Last active August 17, 2021 03:00
benchstat Go 1.17 vs 1.16 on GitHub Actions using https://github.com/goldeneggg/structil (1.17 is very faster)
name old time/op new time/op delta
pkg:github.com/goldeneggg/structil goos:linux goarch:amd64
NewGetter_Val 690ns ± 6% 568ns ± 0% -17.66% (p=0.008 n=5+5)
NewGetter_Val-2 737ns ± 2% 584ns ± 4% -20.82% (p=0.016 n=5+4)
NewGetter_Ptr 556ns ± 3% 391ns ± 1% -29.62% (p=0.008 n=5+5)
NewGetter_Ptr-2 616ns ±11% 443ns ± 4% -28.15% (p=0.008 n=5+5)
GetterGetType_String 24.4ns ± 3% 13.6ns ± 0% -44.15% (p=0.008 n=5+5)
GetterGetType_String-2 24.2ns ± 2% 13.7ns ± 0% -43.53% (p=0.008 n=5+5)
GetterGetValue_String 24.4ns ± 6% 13.9ns ± 0% -43.12% (p=0.008 n=5+5)
GetterGetValue_String-2 24.5ns ± 3% 13.9ns ± 0% -43.23% (p=0.016 n=5+4)
@goldeneggg
goldeneggg / merge_vs_mergex.rb
Last active May 19, 2021 01:26
Compare performance `Hash#merge` and `Hash#merge!` for Ruby 2.6
require 'benchmark/ips'
require 'benchmark/memory'
class Hoge
class << self
DEFAULT_TIME = 5
DEFAULT_WARMUP = 2
def ips(title:,
time: DEFAULT_TIME,
name old time/op new time/op delta
pkg:github.com/goldeneggg/structil goos:linux goarch:amd64
NewFinder_Val 831ns ± 2% 971ns ± 4% +16.84% (p=0.008 n=5+5)
NewFinder_Val-2 831ns ± 5% 931ns ± 9% +11.98% (p=0.008 n=5+5)
NewFinder_Ptr 738ns ± 3% 779ns ± 1% +5.53% (p=0.008 n=5+5)
NewFinder_Ptr-2 778ns ± 6% 813ns ±12% ~ (p=0.421 n=5+5)
ToMap_1FindOnly 437ns ± 3% 405ns ± 3% -7.41% (p=0.008 n=5+5)
ToMap_1FindOnly-2 430ns ± 4% 426ns ± 6% ~ (p=0.587 n=5+5)
ToMap_2FindOnly 541ns ± 2% 574ns ± 4% +6.10% (p=0.008 n=5+5)
ToMap_2FindOnly-2 559ns ± 4% 580ns ± 2% ~ (p=0.103 n=5+5)
package main
import "fmt"
func Print(type T)(s []T) {
for _, v := range s {
fmt.Println(v)
}
}
@goldeneggg
goldeneggg / ci.yml
Last active September 4, 2023 19:49
Rails 6 API Development and GitHub Actions CI with Docker (.github/workflows/ci.yml)
on:
push:
branches:
- master
paths-ignore:
- '**/*.md'
- 'LICENSE'
pull_request:
paths-ignore:
- '**/*.md'
@goldeneggg
goldeneggg / docker-compose.yml
Last active May 27, 2020 05:04
Rails 6 API Development and GitHub Actions CI with Docker (docker-compose.yml)
version: "3.7"
services:
db:
image: mysql:8.0.20
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD
- MYSQL_ALLOW_EMPTY_PASSWORD
volumes:
@goldeneggg
goldeneggg / Dockerfile
Last active January 30, 2021 13:17
Rails 6 API Development and GitHub Actions CI with Docker (Dockerfile)
ARG ARG_RUBY_VERSION
FROM ruby:${ARG_RUBY_VERSION}-alpine3.11
# hadolint ignore=DL3008,DL3018
RUN apk update && \
apk add --update --no-cache \
build-base \
bash \
curl \