Skip to content

Instantly share code, notes, and snippets.

View zaru's full-sized avatar
😍
write code

zaru zaru

😍
write code
View GitHub Profile
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)
@zaru
zaru / request.rb
Created March 23, 2020 09:39
AWS SNS publish api curl request
require 'json'
require 'aws-sigv4'
require 'active_support/core_ext'
params = {
'Action' => 'Publish',
'TargetArn' => 'arn:aws:sns:ap-northeast-1:000000000000:example-topic',
'Message' => 'message',
'Version' => '2010-03-31'
}.to_query
@zaru
zaru / app.rb
Created March 2, 2020 14:14
rack middleware simple demo
require 'sinatra/base'
class MyApp < Sinatra::Base
get '/' do
'top page'
end
end
require 'random_bell'
require 'csv'
require 'securerandom'
bell = RandomBell.new
CSV.open("./files/data_sum_#{ARGV[0]}.csv",'w') do |csv|
head = Date.new(2019, 1)
tail = Date.new(2020, 12)
(head..tail).each do |date|
@zaru
zaru / fetch.sh
Last active February 15, 2020 10:01
サポーターズ学生フィードバック集計スクリプト
for i in {1..12}; do
curl --anyauth --user user:password \
-H 'content-type: application/json' \
https://viewer.kintoneapp.com/public/api/records/xxxxxx/$i > ./files/$i.json
done
@zaru
zaru / main.ts
Last active January 5, 2020 02:08
micro:bit ボタン早押しゲーム
let inGame = false
let pushedFlag = 0
let score = 0
let plot = 0
let showScoreLED: Function
input.onButtonPressed(Button.A, function () {
if (!inGame) {
gameStart()
} else if (inGame && pushedFlag == 0) {
@zaru
zaru / main.go
Created December 23, 2019 09:07
Go sleep
package main
import (
"log"
"time"
)
func main() {
log.Print("Start")
time.Sleep(11 * time.Second)
@zaru
zaru / index.html
Last active November 16, 2019 15:48
すべてが zaru になるサンプルコード
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.js"></script>
<style type="text/css">
#image {
@zaru
zaru / 0.99px.html
Created April 10, 2019 15:06
ローカル HTTP でアクセスすると div の高さが 0.99 px になる謎(5K ディスプレイが原因説)
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div style="height: 1px;"></div>
</body>
</html>