Skip to content

Instantly share code, notes, and snippets.

@yoggy
yoggy / time_parse_test.txt
Created May 16, 2018 11:40
RubyのTime.parseはタイムゾーンが付いていない文字列をローカルタイムゾーンの時刻として解釈する。
$ irb -r time
irb(main):001:0> Time.parse("2018-1-1 0:0:0.0")
=> 2018-01-01 00:00:00 +0900
irb(main):002:0> Time.parse("2018-1-1 0:0:0.0 UTC")
=> 2018-01-01 00:00:00 UTC
irb(main):003:0> Time.parse("2018-1-1 0:0:0.0 UTC").localtime
=> 2018-01-01 09:00:00 +0900

Raspberry Piにroot-roを適用する手順メモ (2018/3/26)

今回使用したイメージはRaspian Lite 2018-03-13版。 まずEtcherを使ってイメージをmicroSDへ書き込む。

イメージ書き込み後、PCからmicroSDにあるconfig.txtを編集する。

※以下の行を末尾に追加する

dtoverlay=pi3-miniuart-bt

//
// mh-z14-calibration-test.pde
//
// see also... https://www.openhacks.com/uploadsproductos/mh-z14_co2.pdf
//
import processing.serial.*;
byte [] buf = new byte[9];
Serial s = new Serial(this, "COM9", 9600);
@yoggy
yoggy / overriding-backticks-test.rb
Last active November 29, 2017 05:42
Rubyではバッククォートをオーバーライドできてしまうという個人的な驚き
#!/usr/bin/ruby
def `(str)
'Wed Nov 29 12:34:56 JST 2017'
end
puts `date`
@yoggy
yoggy / imgsplit.py
Last active November 28, 2017 09:09
OpenCVを使った画像の分割ツール。縦スクロール用
import numpy as np
import cv2
import sys
import os
if (len(sys.argv)!=4):
print("usage : {0} step_h overlap_h filename".format(sys.argv[0]))
sys.exit()
step_h = int(sys.argv[1])
@yoggy
yoggy / Androidでスクリーンショット撮影例.bat
Created November 21, 2017 06:58
Androidでスクリーンショット撮影例.bat
rem
rem Androidでスクリーンショット撮影例.bat
rem adbとImageMagickを使用
rem
rem license:
rem Copyright (c) 2017 yoggy <yoggy0@gmail.com>
rem Released under the MIT license
rem http://opensource.org/licenses/mit-license.php;
rem
@yoggy
yoggy / 何かと便利なBusPirateの使い方メモ.md
Last active July 17, 2024 11:44
何かと便利なBusPirateの使い方メモ
$ ps ax | grep -i wayland
822 tty1 Ssl+ 0:00 /usr/lib/gdm3/gdm-wayland-session env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu
921 tty1 Sl+ 0:01 /usr/bin/Xwayland :0 -rootless -noreset -listen 4 -listen 5 -displayfd 6
8302 pts/0 S+ 0:00 grep --color=auto -i wayland
$ apt-file search Xwayland
xwayland: /usr/bin/Xwayland
$ apt-cache depends xwayland
xwayland
$ cat a.txt
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccccccccccccccccccccccccccccccc
あああああああああああああああああああああああああああああああ
いいいいいいいいいいいいいいいいいいいい
うううううううううううううう
123123123123123123123123123123123123
$ cat a.txt | ruby -ple 'l="";n=0;$_.each_char{|c|l+=c;n+=(c.ord<128?1:2);if(n>40) then n=0;l+="\n" end};$_=l'
//
// file2string.cpp
//
// see also... https://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring
//
#include <fstream>
#include <sstream>
#include <iostream>
int main(int argc, char *argv[])