This file contains hidden or 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 'open-uri' | |
begin | |
f = open("http://unknown_link") | |
rescue | |
p "Link die" | |
end |
This file contains hidden or 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
// Read felica id | |
// http://blog.livedoor.jp/amelabo/archives/862065.html | |
#include <stdio.h> | |
#include "felicalib.h" | |
static void hexdump(uint8 *addr, int n); |
This file contains hidden or 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
[railsserver@anhnt models]$ console | |
Loading development environment (Rails 2.3.1) | |
>> User.table_name | |
=> "tblusers" | |
>> |
This file contains hidden or 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 uploaded_file(tmp_filename, content_type, filename) | |
t = Tempfile.new(filename) | |
t.binmode | |
path = RAILS_ROOT + "/test/fixtures/files/" + tmp_filename | |
FileUtils.copy_file(path, t.path) | |
(class << t; self; end).class_eval do | |
alias local_path path | |
define_method(:original_filename) { filename } | |
define_method(:content_type) { content_type } | |
end |
This file contains hidden or 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
# comment | |
def days | |
ActiveSupport::Duration.new(self * 24.hours, [[:days, self]]) | |
end |