Skip to content

Instantly share code, notes, and snippets.

View zaru's full-sized avatar
😍
write code

zaru zaru

😍
write code
View GitHub Profile
@zaru
zaru / basicMiddleware.ts
Created March 21, 2024 05:35
Next.js middleware実装方針比較:素朴なパターンと高階関数パターン
import {
type NextFetchEvent,
type NextRequest,
NextResponse,
} from "next/server";
async function heavyTask() {
console.log("start heavyTask.", new Date());
// await fetch("http://0.0.0.0:9999/heavy.php", { cache: "no-store" });
console.log("done heavyTask.", new Date());
@zaru
zaru / Ruby3.2.2-RubyVM::YJIT.runtime_stats
Last active September 29, 2023 00:06
Docker ruby:3.3.0-preview2-slim-bullseye, Rails7.0.6
{
:inline_code_size=>14144068,
:outlined_code_size=>14143076,
:freed_page_count=>0,
:freed_code_size=>0,
:live_page_count=>1727,
:code_gc_count=>0,
:code_region_size=>28291072,
:yjit_alloc_size=>43781717,
:all_stats=>true,
@zaru
zaru / Sample.vue
Created December 16, 2021 14:51
withDefaults error
<script setup lang="ts">
interface ISampleProps {
foo: {
bar: string
}
}
const defaultValue: ISampleProps = {
foo: {
bar: 'bar'
}
@zaru
zaru / readme.md
Last active August 23, 2021 05:36

株式会社ベーシック 開発部

key value
更新 2021-08-23
作者 @zaru
バージョン 2021.8
URL http://basicinc.jp/

概要

@zaru
zaru / find_each.rb
Last active August 22, 2021 12:58
find_each 風味
class Batches
BATCH_SIZE = 2
def initialize
@data = (1..10).to_a
end
def find_each
if block_given?
find_in_batches do |records|
@zaru
zaru / index.html
Created July 27, 2021 15:05
resizable sidebar
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style type="text/css">
* {
@zaru
zaru / dummy_endpoint_200.php
Last active September 28, 2021 01:15
Stimulus example ( switch tabs / custom input / form sync value / editable label / form validator )
<?php
sleep(1);
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style type="text/css">
.todo-done {
class HardWorker
include Sidekiq::Worker
def perform
random = Random.new
init_val = random.rand(1..99999)
apeend_val = random.rand(1..99999)
Hoge.piyo({init_val: init_val, apeend_val: apeend_val})
p "HardWorker perform args: #{init_val} / #{apeend_val} => Hoge.data is #{Hoge.data}"
end
@zaru
zaru / get_menubar_items.swift
Last active February 9, 2024 19:49
$ swiftc -o get_window_title get_window_title.swift && get_window_title 9999
import Foundation
import AppKit
func main() -> Int {
let argv = ProcessInfo.processInfo.arguments
let pid = Int32(argv[1])!
print(pid)
let appRef = AXUIElementCreateApplication(pid)
var menubar: CFTypeRef?
AXUIElementCopyAttributeValue(appRef, kAXMenuBarAttribute as CFString, &menubar)