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
require 'cgi' | |
google_url = "http://chart.apis.google.com/chart?cht=tx&chl=" | |
$<.each{|l| | |
l.chomp! | |
l.scan(/(\[tex:(.*?)\]){1,}/).each do |e| | |
math = e[1] | |
url_math = CGI.escape(math) | |
l.sub!(/#{Regexp.quote(e[0])}/,"<img src=\"#{google_url}#{url_math}\">") | |
end | |
puts l |
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
#include <unordered_map> | |
#include <map> | |
#include <iostream> | |
using namespace std; | |
struct myeq : std::binary_function<pair<int , int> , pair<int , int> , bool>{ | |
bool operator() (const pair<int , int> & x , const pair<int , int> & y) const{ | |
//keyの一致って普通これですよね | |
return x.first == y.first && x.second == y.second; |
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
#include <unordered_map> | |
#include <map> | |
#include <iostream> | |
using namespace std; | |
struct myeq : std::binary_function<pair<int , int> , pair<int , int> , bool>{ | |
bool operator() (const pair<int , int> & x , const pair<int , int> & y) const{ | |
//keyの一致って普通これですよね | |
return x.first == y.first && x.second == y.second; |
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
class Object | |
def to_i_or_nil | |
if self.nil? | |
return nil | |
else | |
return self.to_i | |
end | |
end | |
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
# -*- coding: utf-8 -*- | |
$KCODE='u' | |
t_a = "釣りゲームはGree".split(//) | |
s = t_a.size | |
c = "" | |
ARGV[0].to_i.times do |i| | |
c += t_a[0..rand(s).to_i].join("") | |
end | |
c += "、無料です" | |
puts c |
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
require 'rubygems' | |
require 'mechanize' | |
require 'hpricot' | |
require 'open-uri' | |
agent = Mechanize.new | |
agent.user_agent_alias = 'Windows IE 7' | |
page = agent.get("https://twitter.com/login") | |
f = page.forms[0] | |
f["session[username_or_email]"] = "username" |
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 fact(x) | |
x > 1 ? x * fact(x-1) : 1 | |
end | |
def f(x) | |
return fact(x).to_s.reverse.scan(/^0+/).to_s.size | |
end | |
if $0 == __FILE__ | |
p f(ARGV[0].to_i) |
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
#include <iostream> | |
using namespace std; | |
class TEST1{ | |
typedef int id; | |
public: | |
A(){}; | |
void set(id n){ | |
x = n; | |
}; |
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
describe Hoge do | |
before do | |
@h = Hoge.new | |
end | |
describe Hoge, "メソッドAについて" do | |
it "0には1を返す" do | |
@h.method_a(0).should == 1 | |
end | |
end | |
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
describe Hoge do | |
before do | |
@h = Hoge.new | |
end | |
describe Hoge, "メソッドAについて" do | |
it "0には1を返す" do | |
@h.method_a(0).should == 1 | |
end | |
end | |
end |