Skip to content

Instantly share code, notes, and snippets.

View takahashilabo's full-sized avatar

Keiichi Takahashi takahashilabo

View GitHub Profile
@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 / 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//'
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 / 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!');
@takahashilabo
takahashilabo / gist:fa1881cf524376b2038e181320865a28
Last active May 19, 2022 10:54
Simple janken program on Strategy Pattern
import random
class Hand:
hand = ['GUU', 'CHO', 'PA']
@classmethod
def getHand(cls, i):
return cls.hand[i]
class Strategy:
def nextHand(self):
@takahashilabo
takahashilabo / gist:28125871c0ef45832debf595bbf350f7
Last active May 19, 2022 11:06
Mario and Kuribo on Template Method Pattern
class Chara:
def __init__(self):
self.__cs = []
def add(self, c):
self.__cs.append(c)
def draw(self) :
pass
@takahashilabo
takahashilabo / gist:93c5886a6eead21939596756c1ffa99e
Created May 19, 2022 11:08
Mario and Kuribo on Factroy Method Pattern
class Chara:
def __init__(self):
self.__cs = []
def add(self, c):
self.__cs.append(c)
def draw(self) :
pass
class Entry:
def add():
pass
def getName():
pass
class File_(Entry):
def __init__(self, name):
self.__name = name
def add(self):
#!/bin/bash
page=10 #Kindleのページ数をいれる
wid=7374 #brew install smokris/getwindowid/getwindowid でインストールして「getwindowid Kindle --list」を実行した書籍のウィンドウIDを取得していれる
osascript -e 'tell application "Kindle" to activate'
while (( page-- > 0)); do
/usr/sbin/screencapture -l$wid -x -r o/c_`ls o/*png | wc -w | sed 's/^[[:blank:]]*//'`.png
osascript -e 'tell application "System Events" to keystroke (ASCII character 29)'
@takahashilabo
takahashilabo / gist:02342d1a1e83e9f830d24df96aa7f123
Last active January 27, 2023 01:47
Google ClassroomのClassroomフォルダから最新提出ファイルのみ取り出すスクリプト(ChatGPTの生成コードを改変しただけ)
//使い方:
// 1. Google Driveのトップにスクリプトを新規作成し以下のコピペする。
// 2. 抽出したいClassroomの課題フォルダのFOLDER_IDを取得して以下にコピペする
// 3. あとは1で作成したスクリプトを実行する(コード上の実行ボタンを押すだけ)。
// 4. Google DriveのトップにLatest Submissionsというフォルダができるのでその中に提出された最新ファイルだけがコピーされる。
function extractLatestSubmissions() {
// Define the folder containing the submissions
var folder = DriveApp.getFolderById("FOLDER_ID");
// Get all the files in the folder