Skip to content

Instantly share code, notes, and snippets.

View sorah's full-sized avatar

Sorah Fukumori sorah

View GitHub Profile
@sorah
sorah / a.log
Created December 8, 2014 16:04
2014-12-09 00:47:02 +0900 [error]: forward error: can't modify frozen String
2014-12-09 00:47:02 +0900 [error]: /opt/fluentd/shared/bundle/ruby/2.1.0/gems/fluentd-0.10.38/lib/fluent/plugin/in_forward.rb:185:in `feed_each'
2014-12-09 00:47:02 +0900 [error]: /opt/fluentd/shared/bundle/ruby/2.1.0/gems/fluentd-0.10.38/lib/fluent/plugin/in_forward.rb:185:in `on_read_msgpack'
2014-12-09 00:47:02 +0900 [error]: /opt/fluentd/shared/bundle/ruby/2.1.0/gems/fluentd-0.10.38/lib/fluent/plugin/in_forward.rb:173:in `call'
2014-12-09 00:47:02 +0900 [error]: /opt/fluentd/shared/bundle/ruby/2.1.0/gems/fluentd-0.10.38/lib/fluent/plugin/in_forward.rb:173:in `on_read'
2014-12-09 00:47:02 +0900 [error]: /opt/fluentd/shared/bundle/ruby/2.1.0/gems/cool.io-1.1.1/lib/cool.io/io.rb:108:in `on_readable'
2014-12-09 00:47:02 +0900 [error]: /opt/fluentd/shared/bundle/ruby/2.1.0/gems/cool.io-1.1.1/lib/cool.io/io.rb:170:in `on_readable'
2014-12-09 00:47:02 +0900 [error]: /opt/fluentd/shared/bundle/ruby/2.1.0/gems/cool.io-1.1.1/
@sorah
sorah / r53-ddns.rb
Created November 18, 2014 18:13
r53-ddns (Route 53 DDNS)
#!/bin/bash
new_ip=`curl -s -4 http://ifconfig.me/ip`
zone_id=$1
target_name=$2
batch_json='
{
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
@sorah
sorah / get.rb
Last active August 29, 2015 14:08
require 'net/https'
require 'nokogiri'
require 'uri'
require 'time'
require 'base64'
require 'openssl'
abort "Usage #{$0} zoneid" unless ARGV[0]
token = ENV['AWS_ACCESS_KEY_ID']
@sorah
sorah / a.sh
Created October 17, 2014 05:20
Homebrew relink if necessary
#!/bin/bash
for keg in /usr/local/Library/LinkedKegs/*; do
kegname="$(basename $keg)"
dir="$(find $keg/ -maxdepth 1 -type d | grep '\/\(sbin\|bin\|etc\|var\|lib\|include\|libexec\|share\)$' | head -n1)"
[ -z "${dir}" ] && continue
testee="$(find $dir -type f | head -n1 | sed -e "s|${keg}||")"
[ -f /usr/local/$testee ] || (echo $keg && brew unlink $kegname; brew link --force $kegname)
done
@sorah
sorah / ip.sh
Created October 16, 2014 04:46
Shell script assigns given private IPv4 addresses (e.g. secondary private IP) to a EC2 instance
if_macs="$(ip -o link show up | grep -v lo: | grep link/ether | sed -re 's|^[0-9]+: (.+?): .+link/ether ([0-9a-f:]+?).*$|\1,\2|')"
for if_mac in $if_macs; do
ifname="$(echo "$if_mac" | cut -d, -f 1)"
mac="$(echo "$if_mac" | cut -d, -f 2)"
ifmeta="http://169.254.169.254/latest/meta-data/network/interfaces/macs/${mac}"
cidr="$(curl -s ${ifmeta}/subnet-ipv4-cidr-block)"
netlen="$(echo "$cidr" | cut -d/ -f 2)"
@sorah
sorah / a.rb
Last active August 19, 2022 04:23
n=1
a=["", ""]
$_.chomp.chars {|c| n.abs == 1 && (n*=c.to_i+1) || (s=n<=>0) && a[1<=>s] << c && (n-=s) && n!=s || (n*=-1) && n>0 && (p(a[1].to_f/a[0].to_f); a=["",""])}
# https://pbs.twimg.com/media/BvujU0bCIAMxa1O.jpg
@sorah
sorah / a.md
Last active August 29, 2015 14:03
2014 Summer Anime JP 夏アニメ
# STR-DN2030 TCP Control Protocol (analyze)
sock = TCPSocket.open('x.x.x.x', 33335)
###
get_vol_status = "\x02\x04\xa0\x92\x00\x03\x00"
vol_up = "\x02\x03\xA0U\x00\x00"
vol_down = "\x02\x03\xA0V\x00\x00"
set_vol = "\x02\x06\xa0\x52\x00\x03".b + [26].pack('s>') + "\x00".b
require 'socket'
require 'securerandom'
session = SecureRandom.uuid
TCPSocket.open('Apple-TV.local', 7000) do |io|
payload = <<-EOF
Content-Location: ...
Start-Position: 0
EOF
[560717.513222] EXT4-fs (sdc1): mounted filesystem with ordered data mode. Opts: (null)
[562910.917018] BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
[562910.917169] IP: [<ffffffff811eddf2>] ext4_ext_remove_space+0x821/0xb7a
[562910.917292] PGD 2679067 PUD 26d7067 PMD 0
[562910.917375] Oops: 0000 [#1] SMP
[562910.917439] CPU 0
[562910.917474] Modules linked in: ata_generic pata_acpi radeon ttm drm_kms_helper drm i2c_algo_bit tg3 pata_atiixp shpchp pt3_drv(O) sp5100_tco i2c_piix4 i2c_core pcspkr amd64_edac_mod edac_core edac_mce_amd k10temp
[562910.917884]
[562910.917914] Pid: 1939, comm: rm Tainted: G W O 3.4.9-gentoo #8 HP ProLiant MicroServer
[562910.918067] RIP: 0010:[<ffffffff811eddf2>] [<ffffffff811eddf2>] ext4_ext_remove_space+0x821/0xb7a