Skip to content

Instantly share code, notes, and snippets.

@muyesh
muyesh / maximize.sh
Last active September 24, 2019 06:05
Ultra Wide Snap Window Tool
#!/bin/bash
# define
LEFT_WINDOW_WIDTH=1920
DEBUG_FLG=0
LOG_FILE="/tmp/maximize.log"
# debug statement
if [ -z "$1" ]
@muyesh
muyesh / bc_b128.rb
Created October 7, 2018 23:20
Bitcoin Core Base128 Serializer by Ruby
#!/usr/bin/env ruby
# Bitcoin Core Base128 Serializer
# https://github.com/bitcoin/bitcoin/blob/v0.16.3/src/serialize.h#L317
def b128_encode( n )
puts (n).to_s(2)
tmp = []
while true do
tmp.push( ((n & 0x7F) | (tmp.length>0 ? 0x80 : 0x00) ).chr )
@muyesh
muyesh / simple_uleb128.rb
Created October 7, 2018 22:59
Simple ULEB128 by Ruby
#!/usr/bin/env ruby
# Unsigned LEB128 Converter
# https://en.wikipedia.org/wiki/LEB128
def leb128_encode( n )
tmp = []
while true do
tmp.push( ((n & 0x7F) | 0x80 ).chr )
if n <= 0x7F
@muyesh
muyesh / bc_amount_compression.rb
Last active October 15, 2018 01:07
Amount Compression for Ruby
#!/usr/bin/env ruby
# Bitcoin Core Amount compression
# https://github.com/bitcoin/bitcoin/blob/v0.16.3/src/compressor.cpp#L133
def compress_amount(n)
if n == 0
return 0
end
e = 0
@muyesh
muyesh / leb128.rb
Created October 1, 2018 22:20
Unsigned LEB128 Converter
#!/usr/bin/env ruby
# Unsigned LEB128 Converter
# https://en.wikipedia.org/wiki/LEB128
def encode( num, with_hex=false)
bs_n = num.to_s(2)
len = bs_n.length
# 0 padding for 7-bit
padding_len = (len / 7 + ( len % 7 > 0 ? 1 : 0 )) * 7
@muyesh
muyesh / radiko.sh
Last active October 26, 2017 07:59 — forked from soramugi/radiko.sh
radikoをlinuxで聞いたり録音したりするやつ
#!/bin/bash
# https://mtunn.wordpress.com/odroid-u2★セットアップ/radikoの録音・再生(archlinux)/
pid=$$
wkdir='/var/tmp'
playerurl=http://radiko.jp/apps/js/flash/myplayer-release.swf
playerfile="${wkdir}/player.swf"
keyfile="${wkdir}/authkey.png"
auth1_fms="${wkdir}/auth1_fms_${pid}"
auth2_fms="${wkdir}/auth2_fms_${pid}"
@muyesh
muyesh / samba_backup.sh
Last active November 5, 2018 10:43
samba_backup script for Ubuntu 14.04
#!/bin/sh
#
# Copyright (C) Matthieu Patou <mat@matws.net> 2010-2011
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@muyesh
muyesh / S3Buckup.py
Created June 5, 2011 13:02
ディレクトリを任意のS3へバックアップするスクリプト
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tarfile,gzip,os
from time import time,strftime
from boto.s3.connection import S3Connection
from boto.s3.key import Key
class S3Backup:
bucket=None
@muyesh
muyesh / conv4kindle.sh
Created May 10, 2011 16:43
ImageMagicを利用してPPTとかのPDFをKindle3用の画像アーカイブzipにするスクリプト
#!/bin/bash
pdf=$(echo $1|sed 's/.pdf//g')
# 変換
convert -density 150 -geometry 800x600 +antialias \
-rotate 90 -type GrayScale ${pdf}.pdf pdfpage_%02d.jpg
# 圧縮
zip ${pdf}.zip pdfpage_*.jpg