Skip to content

Instantly share code, notes, and snippets.

View takahashilabo's full-sized avatar

Keiichi Takahashi takahashilabo

View GitHub Profile
@takahashilabo
takahashilabo / gist:f1de55e37ee88083cd3e50f9a39b8ff8
Created April 23, 2021 10:10
Box Step by Sphero Mini using Spherov2.js
//see https://www.youtube.com/watch?v=SjjnBMIci2s
//spherov2.js at https://github.com/igbopie/spherov2.js
const { Scanner, Utils } = require('spherov2.js');
const makeItBlink = async () => {
const spheros = await Scanner.findAllSpheroMini();
if (!spheros || spheros.length == 0) return console.log('sphero mini not available!');
require 'bcrypt'
#signup
signup_password = BCrypt::Password.create("my password")
p signup_password
p signup_password.class
to_db = signup_password.to_s
p to_db
p to_db.class
@takahashilabo
takahashilabo / keiho.sh
Created July 3, 2018 02:51
気象庁のページをスクレイピングして福岡地方の暴風警報を取得する
curl "http://www.jma.go.jp/jp/warn/346_table.html" | xmllint --html --xpath '//table[@id="WarnTableTable"]' - | sed -e 's/<tr>//g' | sed -e 's/<td.[^>]*>//g' | sed -e 's/<\/td>/,/g' | sed -e 's/<\/tr>/\'$'\n/g' | sed -e 's/<a.[^>]*>//g' | sed -e 's/<\/a>//g' | sed -e '1,2d' | sed -e '$d' | sed -e '$d' | sed -e 's/福岡地方,福<br>岡<br>地<br>方<br>,//g' | sed -e 's/京<br>築<br>,//g' | sed -e 's/北九州地方,北<br>九<br>州<br>・<br>遠<br>賀<br>地<br>区<br>,//g'| sed -e 's/筑豊地方,筑<br>豊<br>地<br>方<br>,//g'| sed -e 's/筑後地方,筑<br>後<br>北<br>部<br>,//g'| sed -e 's/筑<br>後<br>南<br>部<br>,//g' | sed -e 's/<tr.*th>//g' | sed -e 's/^M//'
@takahashilabo
takahashilabo / keiho.rb
Last active July 3, 2018 02:51
気象庁のページをスクレイピングして福岡地方の暴風警報を取得する
#気象警報・注意報 : 福岡県 取得
s = `curl "http://www.jma.go.jp/jp/warn/346_table.html"`
File.open("dummy.html", "w") do |f|
f.puts(s)
end
s = `xmllint --html --xpath '//table[@id="WarnTableTable"]' dummy.html`
s2 = s.gsub('<tr>', '')
@takahashilabo
takahashilabo / consecutive_line_counter2.rb
Created June 17, 2017 22:42
This code counts consecutive lines in standard input
data = []
while s = gets
data << s.chomp
end
tmp = {}
data.each do |item|
if tmp.has_key?(item) then
tmp[item] << item
else
@takahashilabo
takahashilabo / consecutive_line_counter.rb
Created June 17, 2017 04:39
This code counts consecutive lines in standard input
cnt = 1
prev_s = ""
while s = gets do
s.chomp!
if prev_s == "" then
prev_s = s
next
end
@takahashilabo
takahashilabo / drawArrow.pde
Last active December 27, 2017 13:23
draw an arrow method for Processing
void setup() {
size(400, 400);
stroke(255);
noLoop();
}
void draw() {
background(255);
stroke(255, 0, 0);
fill(255, 0, 0);
@takahashilabo
takahashilabo / outlietext.pde
Created April 30, 2016 02:30
drawOutlineText method for Processing
void setup() {
size(800,400);
}
void draw() {
background(0, 255, 255);
float y = 0;
for (int i = 1; i <= 5; i++) {
y += 24 * (i - 1);
drawOutlineText("Hello, Processing World!", 0, y, 24 * i, color(255), color(0));
/*
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
@takahashilabo
takahashilabo / findNoTextPdf.sh
Last active August 29, 2015 14:02
This shell script file for finding the pdf files which probably include no OCRed text.
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: findNoTextPdf.sh path"
exit 1
fi
find $1 -type f -name "*.pdf" | while read myfile
do
pdftotext -l 1 "$myfile" tmp
status=`hexdump -ve '1/1 "%.2x"' tmp | head -c 2`