Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
hyuki0000 / solve.rb
Last active August 29, 2015 14:11
サルベジオン問題の参考プログラムです。
#! /usr/bin/ruby
require 'open-uri'
SLEEP_SEC = 1
API_URL = "http://salvageon.textfile.org/"
def puts_output(db, index)
output = URI("#{API_URL}?db=#{db}&index=#{index}").read
@hyuki0000
hyuki0000 / git-config-https-to-git.rb
Last active August 29, 2015 14:10
Change remote.origin.url from "https://..." to "git@...".
#!/usr/bin/env ruby
url = `git config remote.origin.url`
puts "BEFORE: #{url}"
# https://[email protected]/YOURNAME/myrepo.git
if url.match(/https:\/\/([^\/@]+@)?([^\/]+)\/([^\/]+)\/(.+)\.git/)
optional_login_name, domain, name, repo = $1, $2, $3, $4
cmd = "git remote set-url origin git@#{domain}:#{name}/#{repo}.git"
puts cmd
@hyuki0000
hyuki0000 / README
Last active August 29, 2015 14:06
AutoGetter - Twitterで自分のツイートから自分へのリプライをまとめるRubyスクリプト(連ツイまとめ作成用)
## AutoGetter - Twitterで自分のツイートから自分へのリプライをまとめるRubyスクリプト(連ツイまとめ作成用)
https://gist.github.com/hyuki0000/85989bcf78d1476d74d3
1. config.yamlを自分用に作成する。
2. ruby autogetter.rb を実行する。
3. 自分へのリプライ(リプライ連鎖)ごとに 1.html, 2.html, 3.html, ... とファイルにまとめる(既存ファイル上書き)。
4. HTMLが直接書けるサイトに貼り付ける。
@hyuki0000
hyuki0000 / README
Last active August 29, 2015 14:06
テキストに書かれている内容をランダムにツイートするbot用のPerlスクリプト
1. Edit tweet.yaml.
2. Prepare tweet.txt (one line for one tweet).
3. Run tweet.pl.
@hyuki0000
hyuki0000 / figren.rb
Created June 7, 2014 05:38
31foo.eps → 10foo.eps のようにファイル名変換するシェルスクリプトを生成するRubyスクリプト
# 31foo.eps → 10foo.eps
# 35baa.eps → 30baa.eps
# のようにファイル名変換するシェルスクリプトを生成するRubyスクリプト
MAP = {
'31' => '10',
'32' => '10',
'33' => '20',
'34' => '20',
'35' => '30',
@hyuki0000
hyuki0000 / answer.txt
Last active August 29, 2015 14:01
チケットゴブル問題の参照ファイルです。
62 Afghanistan Angola Antarctica Austria Azerbaijan Barbados Belarus Botswana Burundi Canada China Cyprus Denmark Ecuador Eritrea Ethiopia Finland Georgia Germany Ghana Greece Guadeloupe Jordan Kiribati Liberia Libya Liechtenstein Macao Malawi Malaysia Martinique Mongolia Montenegro Montserrat Myanmar Namibia Narnia Niger Nigeria Oman Palau Poland Portugal Romania Rwanda Samoa Senegal Serbia Seychelles Slovakia Slovenia Somalia Sudan Sweden Switzerland Tajikistan Tokelau Turkey Uganda Ukraine Zambia Zimbabwe
@hyuki0000
hyuki0000 / local_solve.rb
Created April 28, 2014 06:15
スペーストーキー問題の参照ファイルです。
#! /usr/bin/ruby
class String
ALPHABET_LEN = 26
def encode
s = self
out = ''
while m = s.slice(/(.)\1*/)
c = m[0]
@hyuki0000
hyuki0000 / lsnote.rb
Created April 18, 2014 01:01
lsnote.rb
#! /usr/bin/ruby
# lsnote.rb
# カレントディレクトリ中の
# book-001.txt, book-002.txt, book-004.txt, book-005.txt
# teaching-003.txt, teaching-004.txt, teaching-005.txt, teaching-006.txt, teaching-009.txt
# writing-001.txt, writing-002.txt, writing-003.txt, writing-008.txt, writing-009.txt
# のようなファイルから、コーナー(book,teaching,writing)ごとに番号の最も大きなものを見つけ、
# タイムスタンプ順に表示する。
#!/usr/bin/ruby
def analyze(encrypted_hex)
guess = {
'CB' => ' ', # 'A',
'9C' => 'e', # 'B',
'BA' => 't', # 'C',
'DA' => 'o', # 'D',
'0D' => 's', # 'E',
'24' => 'n', # 'F',
@hyuki0000
hyuki0000 / hyuki-help.txt
Created February 28, 2014 00:57
Tiny Vim helpfile.
*hyuki-help.txt*
ジャンプ <CTRL-]>
戻ってくる <CTRL-O>
|help-writing| ヘルプファイルの書き方
|hyuki-latex| LaTeX用メモ
vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: