Skip to content

Instantly share code, notes, and snippets.

View toshimaru's full-sized avatar

Toshimaru toshimaru

View GitHub Profile

Class Diagram

classDiagram
    Animal <|-- Duck
    Animal <|-- Fish
    Animal <|-- Zebra
    Animal : +int age
    Animal : +String gender
    Animal: +isMammal()
@toshimaru
toshimaru / unicorn6.1-memory-usage.md
Last active January 23, 2022 16:00
unicorn 6.1 reduces memory usage.

Environment

  • Ruby 3.1 (ruby:3.1 docker image)
  • unicorn 6.1
  • Rails 6.1

Workload

  • Run unicorn with 4 worker processes
  • Request 100 times to unicorn app

github.ref vs github.head_ref in GitHub Actions

Trigger event pull_request pull_request_target push
github.ref refs/pull/53/merge refs/heads/main refs/heads/test/pull_request_target
github.head_ref test/pull_request_target test/pull_request_target -
  • main: default branch
  • test/pull_request_target: topic branch name
  • 53: pull request number
@toshimaru
toshimaru / check-server-process-using-jemalloc.rb
Last active January 29, 2025 21:00
Enable jemalloc for alpine.
# Check server process is using jemalloc
# ref. [Japanese] https://tech.studyplus.co.jp/entry/2019/09/09/094140
class AppController < ActionController::Base
def show
r = `strings /proc/#{Process.pid}/maps | grep jemalloc`
render plain: "<h1>#{ENV['LD_PRELOAD'].presence || 'empty'}</h1><pre>#{r}</pre>"
end
end
  • level-1
    • level-3
    • level-2
    • level-2
      • level-3

* level-3
  • level-2
def a
doc = <<-EOS
def hello
puts "Hello World!"
end
EOS
end
require 'benchmark/ips'
Benchmark.ips do |x|
ary = []
x.report(:a) {
10_000.times do |num|
ary << "#{num} #{num * 2} #{num * 3}"
end
}
@toshimaru
toshimaru / webpacker.md
Created December 9, 2016 20:47
Try webpacker

Try webpacker

Try rails/webpacker

Installation

gem 'webpacker', github: "rails/webpacker"
@toshimaru
toshimaru / terraform-ssh-remote-exec.tf
Last active August 19, 2023 08:09
How to connect to server via SSH and use remote-exec provisioner.
resource "digitalocean_droplet" "web" {
image = "ubuntu-16-04-x64"
name = "web-1"
region = "sgp1"
size = "512mb"
ssh_keys = [12345]
connection {
type = "ssh"
user = "root"
@toshimaru
toshimaru / install-mysql5.7-circleci.sh
Last active May 3, 2018 08:32 — forked from kimh/install-mysql5.7-circleci.sh
Install MySQL 5.7 non-interactively in CircleCI
#!/bin/bash
set -x
set -e
export DEBIAN_FRONTEND=noninteractive
curl -LO https://dev.mysql.com/get/mysql-apt-config_0.7.3-1_all.deb
echo mysql-apt-config mysql-apt-config/select-product select Apply | sudo debconf-set-selections
echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections
echo mysql-apt-config mysql-apt-config/select-connector-python select none | sudo debconf-set-selections