Skip to content

Instantly share code, notes, and snippets.

View Shinichi-Ohki's full-sized avatar

Shinichi Ohki Shinichi-Ohki

  • Switch Science / 144Lab
  • Japan
View GitHub Profile
@Shinichi-Ohki
Shinichi-Ohki / bwc.rb
Last active January 11, 2019 03:53
bmp to header file. (.bmp to .h)
require 'mini_magick'
shiftbit = 2
filename = ARGV[0]
bname = File.basename(filename, '.*')
img = MiniMagick::Image.open(filename)
img_width = img.width
img_height = img.height
pixels = img.get_pixels
@Shinichi-Ohki
Shinichi-Ohki / nem-sn-json.py
Last active March 11, 2018 09:06
NemのSupernodeの一覧を取得するPythonスクリプト
import json
import sys
import datetime
import math
import requests
import bs4
"""
https://supernodes.nem.io/をスクレイピングしてSupernodeの一覧を格納した辞書オブジェクトとjsonオブジェクトを作ります。
引数で取得件数を決められます。省略すると全部取ります。
@Shinichi-Ohki
Shinichi-Ohki / Nekonium-QR-code-Printer.md
Last active January 3, 2018 23:02
Nekonium QRコードをプリンタシールドから出力します。

用意する物

  • Raspberry Pi 3(他のでも動くと思う)
  • AS-289R2 プリンタシールド
  • 配線用ジャンパケーブル少々
  • Python3パッケージ
    • qrcode (QRコード生成)
    • serial (シリアル通信)
    • WiringPi (GPIO制御など)
  • imagemagick
@Shinichi-Ohki
Shinichi-Ohki / pdfr.bat
Created December 4, 2017 02:46
PDF書類を右90°回転させるだけのバッチファイル。要pdftk。SendToディレクトリにショートカットを入れておくといいです。
echo off
pdftk %1 cat 1-endeast output %1.pdf
@Shinichi-Ohki
Shinichi-Ohki / Twitterのアイコンを10%の角丸にする
Last active July 30, 2017 05:02
Twitterのアイコンを10%の角丸にするCSSです。Stylishでどうぞ。書き込み欄の角丸も取ります。
/* Twitter */
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("twitter.com") {
.edge-design .avatar {
border-radius: 10% !important;
}
.DashboardProfileCard-avatarImage {
@Shinichi-Ohki
Shinichi-Ohki / Hide Unwanted Results Data.csv
Created November 30, 2016 09:44
DeNAパレット URLリスト for Hide Unwanted Results of Google Search
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2 in line 1.
Hide Unwanted Results Data v1.0
1,welq.jp
1,cafy.jp
1,mery.jp
1,iemo.jp
1,find-travel.jp
1,jooy.jp
1,cuta.jp
1,puul.jp
1,upin.jp
@Shinichi-Ohki
Shinichi-Ohki / readme.md
Last active October 14, 2015 16:00
7種類から重複ありで4つ選ぶ組み合わせを出力するスクリプト

7種類から重複ありで4つ選ぶ組み合わせを出力するスクリプト

7つある要素から重複あり(同じ要素が何度でも使える)で4つ選ぶ組み合わせを出力します。 組み合わせなので、例えば(2,3,4,4)と(4,3,4,2)は同じとみなして1つと数えます。 詳細は「重複組合せ」で検索してみてください。

Rubyで書こうかと思っていたらPythonだとそのまんまのメソッドを持つモジュールがあったので日和りました。
と思ったらRubyでもrepeated_combinationメソッドありました。検索力が低かっただけでした。Rubyのも足しました。
Pythonのが行数が多いのは作者のPython力が低いからです。

@Shinichi-Ohki
Shinichi-Ohki / halfcut.rb
Created May 30, 2015 13:30
一つの画像を縦に半分に切って二つにする
#!/usr/bin/env ruby
require 'RMagick'
include Magick
fext = File.extname(ARGV[0])
fname = File.basename(ARGV[0],fext)
img = Magick::ImageList.new(ARGV[0])
imgsize_x = img.columns
@Shinichi-Ohki
Shinichi-Ohki / gist:682334a6a0422e1feba8
Created March 31, 2015 04:10
Eagleのライブラリを再帰的に探して、登録されている部品名を出力するRubyスクリプト
#!/usr/bin/env ruby
require 'rexml/document'
def libdevicelist(partslibrary)
devicelist = []
partslibrary.elements.each('eagle/drawing/library/devicesets/deviceset') do |element|
devicelist << element.attributes["name"]
end
return devicelist
@Shinichi-Ohki
Shinichi-Ohki / gist:8662707
Created January 28, 2014 05:29
B列に入ってる曜日が月〜金でC列になにか記入されているセルを数える式と、土日祝で(略)を出力するRubyスクリプト
# coding: utf-8
1.upto(31){|num|
if num==1
print("=")
else
print("+")
end
print("and(or($B$%d=\"月\",$B$%d=\"火\",$B$%d=\"水\",$B$%d=\"木\",$B$%d=\"金\"),C$%d<>\"\")"%[num+1,num+1,num+1,num+1,num+1,num+1])
# )