-
名前
- 内藤 建 (Takeru Naito)
-
twitter
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 String | |
def strimwidth(width) | |
self.split(//)[0...width].join | |
end | |
end | |
#see also http://www.ruby-lang.org/ja/man/html/Array.html#self.5bstart.2e.2eend.5d |
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
(use srfi-1) | |
(map (lambda (x) | |
(cond | |
[(= (modulo x 15) 0) 'FizzBuzz] | |
[(= (modulo x 5) 0) 'Fizz] | |
[(= (modulo x 3) 0) 'Buzz] | |
[else x])) | |
(iota 100 1)) | |
;=> (1 2 Buzz 4 Fizz Buzz 7 8 Buzz Fizz 11 Buzz 13 14 FizzBuzz 16 17 Buzz 19 Fizz Buzz 22 23 Buzz Fizz 26 Buzz 28 29 FizzBuzz 31 32 Buzz 34 Fizz Buzz 37 38 Buzz Fizz 41 Buzz 43 44 FizzBuzz 46 47 Buzz 49 Fizz Buzz 52 53 Buzz Fizz 56 Buzz 58 59 FizzBuzz 61 62 Buzz 64 Fizz Buzz 67 68 Buzz Fizz 71 Buzz 73 74 FizzBuzz 76 77 Buzz 79 Fizz Buzz 82 83 Buzz Fizz 86 Buzz 88 89 FizzBuzz 91 92 Buzz 94 Fizz Buzz 97 98 Buzz Fizz) |
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 | |
for n in 1..30 | |
if 0 == n % 15 | |
p "fizzbuzz" | |
elsif 0 == n % 5 | |
p "buzz" | |
elsif 0 == n % 3 | |
p "fizz" | |
else |
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
p((1..100).map{|i|(("%s%s"%[(i%3==0?"Fizz":""),(i%5==0?"Buzz":"")]).match(/.+/)||[i])[0]}) |
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
%w[abc abc foo def foo ghi].inject(Hash.new(0)){|s, v|s[v] += 1;s}.tap{|h| p h.select{|k,v| v == h.values.max}} | |
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
--- anything-config.el.orig 2009-10-09 07:14:33.000000000 +0900 | |
+++ anything-config.el 2009-10-09 07:17:32.000000000 +0900 | |
@@ -1611,10 +1611,11 @@ | |
;; W3m bookmark | |
-(eval-when-compile (require 'w3m-bookmark nil t)) | |
-(unless (and (require 'w3m nil t) | |
- (require 'w3m-bookmark nil t)) | |
- (defvar w3m-bookmark-file "~/.w3m/bookmark.html")) |
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 | |
# -*- mode: ruby; coding: utf-8-unix; indent-tabs-mode: nil -*- | |
# | |
# Author:: Takeru Naito (mailto:[email protected]) | |
# Copyright:: Copyright (c) 2009 Takeru Naito | |
# License:: Distributes under the same terms as Ruby | |
# | |
# | |
require 'logger' |
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
#!/opt/local/bin/ruby1.9 | |
# -*- coding: utf-8 -*- | |
# based upon | |
# http://d.hatena.ne.jp/omochist/20060906/1157532315 | |
require 'action_mailer' | |
require 'logger' | |
logger = Logger.new(STDERR) |
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
dummy |
OlderNewer