Skip to content

Instantly share code, notes, and snippets.

View yswallow's full-sized avatar

Sanagi yswallow

View GitHub Profile
@yswallow
yswallow / akbmatome.rb
Created June 8, 2013 14:33
AKB総選挙の64位以上の獲得票数の合計を調べる
# coding: UTF-8
require "open-uri"
require "nokogiri"
url = 'http://akb48matome.com/archives/51881418.html'
page = Nokogiri::HTML(open(url))
File.write "matome.html" , page.to_html
#page = Nokogiri::HTML(open('./matome.html'))
items = page.xpath('//table/tbody/tr')
sum = 0
@yswallow
yswallow / dl_every_voices.rb
Created May 6, 2013 15:35
vcard.ameba.jp の手に入れた音声を全てダウンロードするスクリプト(誰得
require "nokogiri"
require "./collection-post"
require 'open-uri'
ua = "Mozilla/5.0 (Linux; U; Android 4.0.3; ja-jp; URBANO PROGRESSO Build/010.0.3000) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
cookies = { "gameAuthId" => "Your own gameAuthId", "vcardPixelRatio" => "1" }
cookie_str = cookies.map { |cookie| cookie.join('=') }.join(';')
$header = { "Cookie" => cookie_str, "User-Agent" => ua }
def vcard_getio( url )
for i in 1...250
sum = 0
t = i
while sum<500
sum += t
if sum==500
puts i
break
end
t += 1
@yswallow
yswallow / techtech17-2.c
Last active December 16, 2015 18:09
http://www.titech.ac.jp/publications/j/techtech17/06.html のNo.2 (C言語) 人力で解くアルゴリズムを考えさせる問題だと思うけど。
#include <stdio.h>
int main(void)
{
int i,t,sum;
for(i=1;i<250;i++)
{
sum = 0;
for(t=i;sum<500;t++)
@yswallow
yswallow / techtech-19-2.rb
Created April 28, 2013 01:42
東工大のクイズ(http://www.titech.ac.jp/publications/j/techtech19/06.html のNo.2)を力ずくで解く〜Ruby ver.〜
for i in 1..200
puts i if i%7 == 3 && i%5 == 2 && i%3 == 1
end
#=>52,157
@yswallow
yswallow / soinsubunkai.c
Created March 20, 2013 03:21
素因数分解をするプログラム。 掃除してたら出てきたから書きなおしてみた。(昔は割ったあとのfloat==intかどうかで判断してたなんて言えない)
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
unsigned int a,b,amari,i;
if(argc<2)
{
printf("整数を入力してください。\n");
@yswallow
yswallow / yosan_up.rb
Created March 14, 2013 13:57
JR四国のサイトから予讃線・上りの時刻表の画像ファイルをダウンロードするスクリプト
require 'open-uri'
Dir.mkdir("yosan_up") unless FileTest.exist? "yosan_up"
("01".."18").each do |i|
url = "http://www.jr-eki.com/timetable/yosan_up-seto/img/#{i}.gif"
image = open(url).read
File.write("yosan_up/" + i + ".gif",image)
end
@yswallow
yswallow / totsuzen.rb
Created March 13, 2013 06:16
_人人人人人人人人_ > 突然のやる気 <  ̄Y^Y^Y^Y^Y^Y^Y^Y ̄
#coding: UTF-8
module Totsuzen
def totsuzen(str = "突然の死")
str_length = 0
str.each_char do |c|
str_length += (c.bytesize > 1) ? 2 : 1
end
str_length /= 2
result = "_人#{ "人" * str_length }人_\n"
result << "> #{str} <\n"
@yswallow
yswallow / gist:5134507
Created March 11, 2013 14:12
git status から変更された.rbファイル名だけを表示する
$ git status | ruby -ne '/modified:\s+(.+?\.rb)/ =~ $_ ; print $1," " if $1'
=>
a.rb
b.rb
@yswallow
yswallow / twitter_links_only.rb
Created February 23, 2013 08:32
リンクのついてないツイートなんて不要だ。