Skip to content

Instantly share code, notes, and snippets.

Avatar

結城浩 / Hiroshi Yuki hyuki

View GitHub Profile
@hyuki
hyuki / suika-sample.rb
Created Sep 26, 2020
suika-sample.rb
View suika-sample.rb
require 'suika'
text = <<"EOD"
文書処理のためにさくっと動く形態素解析がほしくなって検索したら
Suikaというものがありました。
Ruby 2.4.0では動かなかったけど、
Ruby 2.5.1にしたら動きました。'
EOD
tagger = Suika::Tagger.new
@hyuki
hyuki / fitbit.rb
Created Sep 1, 2020
fitbit.rb - 運動するときの記録表示とBGM再生のためのスクリプト
View fitbit.rb
#!/usr/bin/env ruby
utada = {
:url => 'https://www.youtube.com/watch?v=jmKRgqWGrWc',
:time => '2:45',
:title => 'Utada Hikaru「Beautiful World」 Directed by Tsurumaki Kazuya'
}
MUSIC = utada
puts <<"EOD"
@hyuki
hyuki / paper-fig.rb
Created Aug 8, 2020
paper-fig.rb - 指定ディレクトリ中の "Paper.*.png" を "paper-*.png"に置き換えてLaTeXのソースを表示するRubyスクリプト
View paper-fig.rb
#! /usr/bin/env ruby
APPNAME = 'paper-fig'
if ARGV.size != 1
puts "#{APPNAME} DIRNAME"
puts "DIRNAMEのディレクトリからPaper.*.pngのファイルを探してリネームしてLaTeXソースを表示する"
abort
end
@hyuki
hyuki / wasabi
Last active Jul 10, 2020
wasabi - Simple file backup script for Wasabi.com.
View wasabi
#! /usr/bin/env ruby
# Wasabi.com
# $ grep ~/.bash_profile WASABI_
# export WASABI_ACCESS_KEY_ID=1234ABCD1234ABCD1234
# export WASABI_SECRET_ACCESS_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
# export WASABI_REGION=us-east-1
# export WASABI_BUCKET=bucketname
require 'aws-sdk-s3'
@hyuki
hyuki / color_graph.rb
Created Jul 10, 2020
color_graph.rb - coloring bipartite graphs.
View color_graph.rb
#!/usr/bin/env ruby
# See 「数学ガールの秘密ノート」第296回 https://link.hyuki.net/girlnote296
# by Hiroshi Yuki.
class Graph
def info(depth, s)
puts ' ' * depth + s
end
@hyuki
hyuki / promise.html
Created Jul 4, 2020
promise.html - A JavaScript Promise Example.
View promise.html
<script>
/* cf. https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise */
'use strict';
var promiseCount = 0;
function runPromise() {
let id = promiseCount++;
console.log("runPromise: START: " + id);
@hyuki
hyuki / EsaBacklogCommand.js
Last active May 23, 2020
EsaBacklogCommand.js
View EsaBacklogCommand.js
/*
* EsaBacklogCommand.js
*
* When you see:
* https://esa-pages.io/...
* Then show the following line:
* esa-backlog "https://esa-pages.io/..." | pbcopy
*/
function start() {
@hyuki
hyuki / esa-backlog.rb
Created May 23, 2020
esa-backlog - 「結城浩の作業ログ」を振り返ってみて「あ、これ、あとでまた見たいな」というときに現在の作業ログからリンクを貼るためのツール。
View esa-backlog.rb
#! /usr/bin/env ruby
require 'cgi'
require 'logger'
require 'mechanize'
if ARGV.length != 1
abort("Usage: esa-backlog https://esa-pages.io/.*.html#文字列")
end
@hyuki
hyuki / mathquiz.rb
Created May 14, 2020
mathquiz.rb - 約数の個数が連続して等しくなる数を探す
View mathquiz.rb
require 'mathn'
def w(k)
a = []
k.prime_division.each do |pn|
a << "#{pn[0]}^#{pn[1]}"
end
if a.size > 0
a.join(' * ')
else
@hyuki
hyuki / TwitterMarkdownCommand.js
Created May 13, 2020
TwitterMarkdownCommand.js - Convert URL to Command.
View TwitterMarkdownCommand.js
/*
* TwitterMarkdownCommand.js
*
* When you see:
* https://twitter.com/hyuki/status/1079981317184315392
* Then show the following line:
* twitter-markdown https://twitter.com/hyuki/status/1079981317184315392 | pbcopy
*/
function start() {
You can’t perform that action at this time.