Skip to content

Instantly share code, notes, and snippets.

View supercaracal's full-sized avatar
🏠
Working from home

Taishi Kasuga supercaracal

🏠
Working from home
  • Saitama, Japan
  • 08:11 (UTC +09:00)
View GitHub Profile
@supercaracal
supercaracal / redis_migration.rb
Last active June 10, 2023 22:20
A naive example for Redis migration from a standalone server to a cluster
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'redis-cluster-client'
end
src = RedisClient.config(url: ENV.fetch('REDIS_URL')).new_client
@supercaracal
supercaracal / override.go
Created May 13, 2023 10:43
How to call child methods from parent methods
package main
import "fmt"
type parent struct {
b func() string
}
func (p *parent) a() string {
if p.b == nil {
@supercaracal
supercaracal / ldd3_index.md
Last active June 19, 2023 01:03
An index of Linux Device Driver 3rd edition for my poor memory
@supercaracal
supercaracal / ruby-memory-alloc.md
Last active September 25, 2022 13:18
Memory allocation comparison in Ruby

Array vs StringArray

This use case is under conditions that the array size is huge and the kind of elements are limited.

irb(main):001:0> require 'objspace'
=> true

irb(main):002:0> ObjectSpace.memsize_of(Array.new(16384))
=> 131112
@supercaracal
supercaracal / more-darker.js
Last active February 5, 2022 00:09
Cover document objects with a dark layer for saving nocturnal animal's eyes.
var div = document.createElement('div'); div.setAttribute('style', 'display: block; position: fixed; z-index: 2147483647; background-color: #333333; top: 0px; left: 0px; height: 100%; width: 100%; opacity: 0.7;'); document.body.appendChild(div);
@supercaracal
supercaracal / compose.redis-cluster.yaml
Last active December 31, 2023 16:16
Redis Cluster Docker Compose example
---
services:
node1: &node
image: "redis:6.2.6"
command: >
redis-server
--maxmemory 64mb
--maxmemory-policy allkeys-lru
--appendonly yes
--cluster-enabled yes
@supercaracal
supercaracal / do-a-barrel-roll.js
Last active February 5, 2022 00:10
Do a barrel roll
(function(){var deg=0;var set=function(val){document.body.style.webkitTransform=val;document.body.style.MozTransform=val;document.body.style.msTransform=val;document.body.style.OTransform=val;document.body.style.transform=val;};var pid=window.setInterval(function(){deg+=6;if(deg>359){window.clearInterval(pid);set(null);}set('rotate('+deg+'deg)');},16);}());void 0;