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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'pit' | |
require 'wsse' | |
require 'net/http' | |
Net::HTTP.version_1_2 |
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 'rexml/document' | |
require 'time' | |
require 'pit' | |
require 'wsse' | |
require 'net/http' | |
class HatenaDiary | |
attr_accessor :title, :content, :updated | |
def initialize |
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 'active_support' | |
require 'active_support/core_ext' | |
def my_start_of_month(today, base) | |
today.prev_month.change(:day => base) | |
end | |
my_start_of_month(Date.today, 28) # => 2012年1月21日に実行した場合、 Wed, 28 Dec 2011 が返る |
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
a = [] | |
[1,2,3,4,5].inject(0) { |r,i| s = r + i ; a << s ; s } | |
puts a # => [1,3,6,10,15] |
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
# pass_check.rb | |
# coding: utf-8 | |
def pass_check(password) | |
password =~ /[[:alnum:]!\"#\$%&\'\(\)]/ | |
end | |
# test_pass_check.rb | |
# coding: utf-8 |
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
<!DOCTYPE HTML> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Dynatree Sample</title> | |
<link rel="stylesheet" href="./src/skin/ui.dynatree.css" /> | |
<script type="text/javascript" src="./jquery/jquery.js"></script> | |
<script type="text/javascript" src="./jquery/jquery-ui.custom.js"></script> | |
<script type="text/javascript" src="./jquery/jquery.cookie.js"></script> | |
<script type="text/javascript" src="./dist/jquery.dynatree.min.js"></script> |
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
[~/work/windowlicker]$ svn export http://windowlicker.googlecode.com/svn/trunk | |
A trunk | |
A trunk/LICENSE.txt | |
A trunk/tools | |
A trunk/tools/tools.iml | |
A trunk/tools/apache-ant-1.7.0 | |
A trunk/tools/apache-ant-1.7.0/WHATSNEW | |
A trunk/tools/apache-ant-1.7.0/LICENSE.dom | |
A trunk/tools/apache-ant-1.7.0/NOTICE | |
A trunk/tools/apache-ant-1.7.0/LICENSE |
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 Hello | |
def say_hello | |
puts "hello" | |
end | |
end | |
## Hello.new.say_helloとしたら、下のような出力をしたい | |
## | |
## Method say_hello start | |
## hello |
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
module AddLogging | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def method_added(name) | |
# すでにhookメソッドがあったり、without_hookメソッドがある場合は定義しない | |
return if /hook/.match(name.to_s) || method_defined?("#{name}_without_hook") | |
# 開始と終了時にメッセージを出す |
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
version = "1.9.3-p123" | |
vers = version.tr("-p",".").split(".").delete_if { |i| i.size == 0 }.map { |i| i.to_i } | |
patch_level = vers.pop | |
sum = vers.each_with_index.map { |x, i| x.to_i * 10 ** (5 - i) }.inject { |sum,i| sum + i } | |
sum + patch_level # => 193123 |
OlderNewer