This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(id) | |
s = id.to_s | |
s.sub!(/^(\d\d\d\d)$/, '\1年') | |
s | |
end | |
id = '2016' | |
foo(id) | |
puts id #=> 2016年 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
COLOR_PRIMARY = '#ab5637' | |
TWITTER = '@hyuki' | |
TWITTER_URL = 'http://twitter.com/hyuki' | |
URL = 'http://note6.hyuki.net/' | |
TITLE = '数学ガールの秘密ノート/ベクトルの真実' | |
BACKGROUND_IMAGE = 'http://static.tumblr.com/91187c5df2205978c2937c64fa62d5bc/qcurvlw/K4pnwia5u/tumblr_static_ebhmjmagw5k48cw8oogkow8o4_2048_v2.png' | |
SHORTCUT_ICON = 'http://33.media.tumblr.com/avatar_f70f97f2c814_128.png' | |
SHORTCUT_ICON_PRECOMPOSED = 'http://33.media.tumblr.com/avatar_f70f97f2c814_128.png' | |
BOOK_COLLECTION_TITLE = '数学ガールの秘密ノート' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
Dir.glob("source/*.md").each do |md| | |
open("#{md}.txt", "w") do |wf| | |
open(md) do |rf| | |
rf.readlines.each do |line| | |
if line.match(%r(http://img\.textfile\.org/)) | |
line.gsub!(%r(http://img\.textfile\.org/), "https://img.textfile.org/") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'twitter' | |
CLIENT = Twitter::REST::Client.new do |config| | |
config.consumer_key = "XXXXXXXXXXXXXXXXXXXXXXXXX" | |
config.consumer_secret = "ssssssssssssssssssssssssssssssssssssssssssssssssss" | |
config.access_token = "0000000-tttttttttttttttttttttttttttttttttttttttttt" | |
config.access_token_secret = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[a5paper,10pt]{jsbook} | |
\usepackage[dvipdfmx]{color} | |
\usepackage[dvipdfmx]{graphicx} | |
\usepackage{amsmath} | |
\usepackage{amssymb} | |
\usepackage{amscd} | |
\usepackage{euler} | |
\usepackage{okumacro} | |
\usepackage{colortbl} | |
\usepackage{otf} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
require "fileutils" | |
if ARGV.length != 2 | |
puts <<-"EOD" | |
Which figure files are not used during LaTeXing? | |
Usage: ruby not-used-fig.rb LOGDIR FIGDIR | |
Example: ruby not-used-fig.rb . fig | |
LOGDIR contains *.log files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
# Based on http://blog.teapla.net/2015/05/5444 | |
TOUCH_FILE = ENV["HOME"] + "/.imeoff" | |
INTERVAL_SEC = 10 | |
if not File.exists?(TOUCH_FILE) or Time.now - File.ctime(TOUCH_FILE) > INTERVAL_SEC | |
system("osascript -e 'tell application \"System Events\" to key code 102'") | |
system("touch #{TOUCH_FILE}") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.length != 1 | |
puts "Usage: ruby note-prevs.rb https://note.mu/USERNAME/n/NOTEID" | |
puts "Example: ruby note-prevs.rb https://note.mu/hyuki/n/n220bad7464fb" | |
puts "This program visits given user's pages via prev-link and puts their titles and urls." | |
abort | |
end | |
# cf. https://note.mu/wadako/n/n01733b19bc9c |