Skip to content

Instantly share code, notes, and snippets.

Shizhuo Muye muyesh

Block or report user

Report or block muyesh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@muyesh
muyesh / bc_b128.rb
Created Oct 7, 2018
Bitcoin Core Base128 Serializer by Ruby
View bc_b128.rb
#!/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 Oct 7, 2018
Simple ULEB128 by Ruby
View simple_uleb128.rb
#!/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 Oct 15, 2018
Amount Compression for Ruby
View bc_amount_compression.rb
#!/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 Oct 1, 2018
Unsigned LEB128 Converter
View leb128.rb
#!/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 Oct 26, 2017 — forked from soramugi/radiko.sh
radikoをlinuxで聞いたり録音したりするやつ
View radiko.sh
#!/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 Nov 5, 2018
samba_backup script for Ubuntu 14.04
View samba_backup.sh
#!/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 Jun 5, 2011
ディレクトリを任意のS3へバックアップするスクリプト
View S3Buckup.py
#!/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
ImageMagicを利用してPPTとかのPDFをKindle3用の画像アーカイブzipにするスクリプト
View conv4kindle.sh
#!/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
You can’t perform that action at this time.