Skip to content

Instantly share code, notes, and snippets.

@arosh
arosh / delete.rb
Created June 24, 2011 13:44
NicoCache_nl cached files deleter
#!/usr/bin/ruby -Ku
def fileDel(f_name)
puts f_name
File::delete(f_name)
end
Dir::glob("*.{swf,mp4,flv}").each do |file|
diff = (Time.now - File::mtime(file)).div(24 * 60 * 60)
if diff > 90
@arosh
arosh / mkcase.rb
Created June 24, 2011 15:02
SuperCon2011 Test Case Maker
#!/usr/bin/ruby -Ku
m = 200
n = 200
k = 200
puts "#{m}, #{n}, #{k}"
(n + 1).times do
m.times do
print "#{(rand * 21).to_i}, "
end
@arosh
arosh / TECHNO-algo.txt
Created July 1, 2011 08:57
Supercon2011 TECHNO
いろいろなアルゴリズムを適用できるようになりそうなので、まずは問題で与えられているデータを
交差点 -> 頂点、道路 -> 辺
とした無向グラフと考えることにした。
データがグラフならば、最短路を求めるのにはダイクストラ法などのアルゴリズムを利用することができる。
今回の予選課題は、ダイクストラ法を元にした方法で解くことにした。
まずはプライオリティキューを実装した。
このキューは、
@arosh
arosh / gist:1059866
Created July 2, 2011 08:38
Project Euler Problem 1 by LISP
(define inputMax 999)
(define (isMultiOf5 n) (if (= (modulo n 5) 0) #t #f))
(define (isMultiOf3 n) (if (= (modulo n 3) 0) #t #f))
(define (isMulti n) (if (isMultiOf3 n) #t (isMultiOf5 n)))
(define (solve n) (if (= n 0) 0 (+ (if (isMulti n) n 0) (solve (- n 1)))))
(display (solve inputMax))
@arosh
arosh / aoj_solved_list.rb
Created July 29, 2011 11:29
AOJ solved_list
#!/usr/bin/ruby -Ku
require 'rexml/document'
require 'open-uri'
def getXMLDocument(user_id)
uri = "http://judge.u-aizu.ac.jp/onlinejudge/webservice/user?id=#{user_id}"
xml_source = open(uri).read
sleep(1)
return REXML::Document.new(xml_source)
@arosh
arosh / tetris.cpp
Created August 8, 2011 03:04
tetris
#include "DxLib.h"
#include <ctime>
static const int FRAME_RATE = 10;
static const int DOWN_RATE = 5;
static const int BROCK_LENGTH = 24;
static const int BOARD_WIDTH = 10;
static const int BOARD_HEIGHT = 20;
int BROCK_COLOR[8];
@arosh
arosh / gist:1305914
Created October 22, 2011 11:59
Renamer
#!/usr/bin/env ruby
files = Dir.glob("*.abc") # 拡張子で指定する
files.each do |f|
if f =~ /regex/ # 正規表現でガリガリ
puts "#{f} -> hogehoge - #{$1}.abc" # キャプチャーしたのも、てけとーに
#File.rename(f, "hogehoge - #{$1}.abc")
end
end
@arosh
arosh / gist:1549470
Created January 2, 2012 05:30
diffall
#!/usr/bin/env ruby
ARGV.each do |arg|
puts "*** diff #{arg} ‾/#{arg} ***"
puts `diff #{arg} ‾/#{arg}`
end
@arosh
arosh / chisquare.ipynb
Last active September 29, 2015 07:29
NumpyとScipyでカイ二乗検定
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arosh
arosh / gist:1965879
Created March 3, 2012 12:35
toPascalCase
class String
def to_pascal_case
self.split("-").map {|s| s.capitalize }.join
end
end