Skip to content

Instantly share code, notes, and snippets.

View polamjag's full-sized avatar
:shipit:
 

Satoru Abe polamjag

:shipit:
 
View GitHub Profile
@polamjag
polamjag / mackerel_rtx.lua
Created December 9, 2023 06:13 — forked from dolpen/mackerel_rtx.lua
文字コードはSJIS、改行コードはCRLFでの動作を確認しました
--[[
# ルーターメトリック収集スクリプト
## 概要
定期的にルーターのリソースを監視して、プロキシ経由で Mackerel に下記メトリック情報を送信します
* CPU 使用率(整数)
* メモリ使用率(整数)
* 筐体内温度(整数)
require 'json'
require 'base64'
require 'open-uri'
RELEASE_TO_TOTAL_CACHE = {}
RELEASE_TO_LABEL_CACHE = {}
def get_total_track_count_from_release_url(release_url)
return RELEASE_TO_TOTAL_CACHE[release_url] if RELEASE_TO_TOTAL_CACHE.has_key?(release_url)
@polamjag
polamjag / user.css
Last active August 3, 2016 06:35
法令データ提供システムの法律ページ用 User CSS
@-moz-document url-prefix("http://law.e-gov.go.jp/htmldata/") {
body {
font-size: 13px;
}
p b a, a b {
display: block;
border-bottom: 3px solid #c6c6c6;
padding-bottom: .2em;
font-size: 1.3em;
@polamjag
polamjag / multicast_qc.rb
Created January 8, 2016 22:11
Send STDIN to Quartz Composer via UDP Multicast in Ruby only with standard components
require 'socket'
while str = STDIN.gets
UDPSocket.new.send(
([str.encode('UTF-16LE').chars.map{|i| i.unpack("H*").first.reverse.rjust(8, "0")}.flatten.join].pack('h*')),
0,
"225.0.0.0", 50000 # hostname (UDP Multicast), port
)
STDERR.puts "sent: #{str}"
end
@polamjag
polamjag / slack-incoming-webhook.rb
Last active November 27, 2015 20:24
Slack Incoming Webhook in Ruby
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
# param `data` will be like this (only `text` is mandatory)
# {
# channel: '#general',
# username: 'somebot',
@polamjag
polamjag / shairplay.service
Created November 18, 2015 09:38
~/.config/systemd/user/shairplay.service
[Unit]
Description=Shairplay daemon
Requires=pulseaudio.service
Wants=avahi-daemon.service
After=avahi-daemon.service
[Service]
Type=simple
ExecStart=/usr/bin/shairplay -a %H
Restart=always
@polamjag
polamjag / keybase_proof.md
Created September 11, 2015 06:27
keybase.io proof

Keybase proof

I hereby claim:

  • I am polamjag on github.
  • I am polamjag (https://keybase.io/polamjag) on keybase.
  • I have a public key whose fingerprint is 66A7 A979 6EAD 5905 70DC 0EEC 50A1 9475 7943 AF8E

To claim this, I am signing this object:

@polamjag
polamjag / google_play_music.txt
Created September 5, 2015 16:44
Google Play Music cuts off metadata
% ffmpeg -i /Users/satoru/Downloads/Skrillex,\ Kill\ The\ Noise\ -\ Recess\ \(Original\ Mix\).mp3
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFWZjmcBEACngn9nI83StlhLcft0aTy3ZcKyRHaicIEwpsMdLsVyqGKy+JBl
aauZpP78hvxrAFDG8u8rQw41q9qr/kR5dah1cZTN+6SbYOpeiueThWWUi7ufN53M
cj05IcnSNTmI3dB40L9HVa/Nkd9SdHRXnWcKeAGVGF/+XHRRjDTuVGVi7szZTCDm
mMTn91iS8Ip59GO3Ybh0Rw0MfOUWFqximz8rX86zdAZIFTmFPnscM8oQ/x/mQMHF
SfZmpQZbwQAUzT8RoV33CNO1xyDIXnPQF7vmfx5efrG05R+DBYYAsFRblllXpc+p
+hX/AIdQBsnwvXNgulfQsZtO+MoeP/bXYaK6HCKJSrlf8DijUkBKkRCuQ1W/MeX2
1DCzpX+/W32Xe1uO1zKHiP6/Hn/5QV7eQXy94QIZ8ZaAm37QHz1OrezgXJ2zBBND
fYj1bryHJlVtjVRNftHekMFGjkGds5V8xGipLsNMXh7O7D+7Szbq6w4Z1o8QpsU9
@polamjag
polamjag / deep_except.rb
Created May 7, 2015 12:00
super dirty deep_except in Ruby
# deep_except
class Hash
def deep_except!(*keys)
keys.each { |key| delete(key) }
self.each { |k, v|
v.except!(*keys) if v.is_a? Hash
}
self
end