Skip to content

Instantly share code, notes, and snippets.

View kaorukobo's full-sized avatar

Kaoru Shirai kaorukobo

  • Hiroshima, Japan
View GitHub Profile
@kaorukobo
kaorukobo / implement-capture-haml-in-haml6.md
Last active April 30, 2024 09:05
A shim for capture_haml method dropped in Haml 6+

The capture_haml method has been removed as of HAML 6.0.0:

https://github.com/haml/haml/blob/main/CHANGELOG.md#600 Most Haml helpers are removed. For helpers generating general HTML tags, also consider using what your framework provides, e.g. Rails content_tag. Same applies to capture_haml, e.g. Rails capture.

This change is breaking for the code that works outside of Rails. So I have implemented capture_haml for Haml 6

Note that this does not work with block capturing support so you need to set the option {disable_capture: true}.

require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main" # commit: 608c1bf
gem "sqlite3"
end
#!/usr/bin/env ruby
def setcwd_to_tmpdir
require "tmpdir"
tmpdir = Dir.mktmpdir
Dir.chdir(tmpdir)
end
def load_gems
#!/usr/bin/env ruby
def setcwd_to_tmpdir
require "tmpdir"
tmpdir = Dir.mktmpdir
Dir.chdir(tmpdir)
end
def load_gems
@kaorukobo
kaorukobo / README.md
Last active July 6, 2023 05:04
2023.06 Figma Japanese Text Disappear Bug

Non-English text disappears in prototype mode (case with component & overlay features)

Reported on Jul 4, 2023 to Figma Support Contact

Update (Jul 6) They fixed it🎉

According to the follow-up from Figma support, now the engineers have published a fix for this problem. I have confirmed that this problem is not reproducible anymore. I appreciate their expeditious action. 🎉🙏

Update (Jul 5) Hint from support

@kaorukobo
kaorukobo / ajax-under-cors-example.js
Last active December 2, 2021 02:51
Example of doing Ajax request with credential under CORS (Node.js + Express)
// npm i express cookie-parser
//
// node ajax-under-cors-example.js
//
// open http://localhost:12300/
// => Step 3 will work.
//
// open http://AnotherHostNameOfYourMachine:12300/
// => Step 3 will fail due to SameSite issue of Cookie.
//
@startuml
' License: CC0
title リンパ球減少の原因へのウイルス及び二酸化塩素の関与の可能性\n(Determination of the Effectiveness of Chlorine Dioxide in the Treatment of COVID 19, \nISSN1747-0862 Molecular and Genetic Medicine を元にライター作成)\n
skinparam defaultFontSize 18
skinparam monochrome true
storage "**二酸化塩素**" as clo2
storage "**SARS-CoV-2**" as ncov
card "ほとんどの患者に見られる\n**リンパ球減少**" as lymphopenia
@kaorukobo
kaorukobo / lissajous-figure-with-ruby2d.rb
Last active April 3, 2021 06:16
「R2Dを使って、リサージュ図形をアニメーションしてみました https://maehrm.hatenablog.com/entry/20140208/p1 」のR2Dがdeprecatedなので、 Ruby2D gem 向けに書き換えたもの。
# -*- coding: utf-8 -*-
# Originally written by maehrm (id:rahaema) - https://maehrm.hatenablog.com/entry/20140208/p1
require "ruby2d"
include Math
w = Window
class Numeric
def to_rad
self*PI/180
@kaorukobo
kaorukobo / how-to-solve-wordpress-invalid-default-value.sql
Created March 12, 2020 03:13
How to solve the `invalid default value for 'post_date'` error on WordPress DB with MySQL when modifying the schema of wp_posts table
SET SQL_MODE = '';
ALTER TABLE `wp_posts` CHANGE `post_date` `post_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_date_gmt` `post_date_gmt` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_modified` `post_modified` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';
ALTER TABLE `wp_posts` CHANGE `post_modified_gmt` `post_modified_gmt` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00';