Skip to content

Instantly share code, notes, and snippets.

Avatar

Fuminori Sakamoto goldeneggg

View GitHub Profile
@goldeneggg
goldeneggg / merge_vs_mergex.rb
Last active May 19, 2021
Compare performance `Hash#merge` and `Hash#merge!` for Ruby 2.6
View merge_vs_mergex.rb
require 'benchmark/ips'
require 'benchmark/memory'
class Hoge
class << self
DEFAULT_TIME = 5
DEFAULT_WARMUP = 2
def ips(title:,
time: DEFAULT_TIME,
View benchstat-vs-latest-remove-interface
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)
View hoge.go2
package main
import "fmt"
func Print(type T)(s []T) {
for _, v := range s {
fmt.Println(v)
}
}
@goldeneggg
goldeneggg / ci.yml
Last active Mar 22, 2021
Rails 6 API Development and GitHub Actions CI with Docker (.github/workflows/ci.yml)
View 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
Rails 6 API Development and GitHub Actions CI with Docker (docker-compose.yml)
View 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 Jan 30, 2021
Rails 6 API Development and GitHub Actions CI with Docker (Dockerfile)
View 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 \
@goldeneggg
goldeneggg / bench_uniq_reject.rb
Last active Jun 28, 2020
[ruby] 一覧から重複削除してnilを除去、の実装方法別パフォーマンス比較
View bench_uniq_reject.rb
require 'benchmark/ips'
require 'benchmark/memory'
require 'set'
CLASSES = [
Class.new {
@arr = ['1', '2', '33', '444', nil, '5555', nil, '444', '66666', 'abcde', '777777', nil, 'XXXX', '33', 'zzzzzzzzzz']
def self.label
@goldeneggg
goldeneggg / app.js
Last active Dec 7, 2018
AWS Lambdaの言語サポート状況を取得する為のLambda Function
View app.js
const axios = require('axios');
const cheerio = require('cheerio');
const url = 'https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/lambda-runtimes.html';
let $;
let response;
/**
@goldeneggg
goldeneggg / kh2md.rb
Last active May 22, 2018
Kindle highlights to markdown for amazon.co.jp
View kh2md.rb
# Note:
# tagged version of kindle-highlights gem is not supported "root_url" option.
# So should use "master" branch version.
require "kindle_highlights"
puts "START kindle highlights output to markdown"
kindle = KindleHighlights::Client.new(email_address: ENV['KINDLE_EMAIL'], password: ENV['KINDLE_PASSWD'], root_url: 'https://read.amazon.co.jp')
kindle.books.each_with_index do |book, i|
puts "========== TITLE: #{book.title}"