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
| -module(recursion). | |
| -export([bump/1, average/1, even_only/1]). | |
| bump([]) -> | |
| []; | |
| bump([H|T]) -> | |
| [H + 1 | bump(T)]. | |
| average(L) -> | |
| sum(L) / length(L). |
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 "rubygems" | |
| require "nkf" | |
| require "kconv" | |
| require "net/smtp" | |
| # Hog - Japanese ISO2022JP Mail Sender | |
| # ==== Description | |
| # sending Japanase Mail with ISO-2022-JP encoding. | |
| # See the bottom of this source for a sample usage. | |
| class Hog |
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
| int* ConvolveIn(int x[], int h[]){ | |
| int ix, ih; | |
| //x[]とh[]の配列の大きさを求める | |
| ix = sizeof(x)/sizeof(int); | |
| ih = sizeof(h)/sizeof(int); | |
| iy = ix + ih; | |
| //output | |
| int y[iy]; | |
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
| module DataMapper | |
| module Timestamps | |
| def self.included(model) | |
| model.before :save, :set_timestamps_on_save | |
| model.before :save!, :set_timestamps_on_save | |
| model.extend ClassMethods | |
| end | |
| end | |
| 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
| migration 1, :create_people_table do | |
| up do | |
| puts "up" | |
| create_table :people do | |
| column :id, Integer, :serial => true | |
| column :name, String, :size => 50 | |
| column :age, Integer | |
| end | |
| end | |
| down do |
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 "lru_cache" | |
| describe Array do | |
| it "指定された値を末尾に移動させる" do | |
| arr = [:a, :b, :c] | |
| arr.move_to_last(:a) | |
| arr.last.should eql :a | |
| end | |
| 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
| class Array | |
| def move_to_last(val) | |
| self.delete(val) | |
| self.push(val) | |
| end | |
| end | |
| class LRUCache | |
| attr_reader :cache_size |
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
| # via http://ujihisa.blogspot.com/2010/02/redirecting-stdout.html | |
| def capture_io | |
| require 'stringio' | |
| orig_stdout, orig_stderr = $stdout, $stderr | |
| captured_stdout, captured_stderr = StringIO.new, StringIO.new | |
| $stdout, $stderr = captured_stdout, captured_stderr | |
| yield |
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
| javascript:(function(){var e=function(c){return String.fromCharCode(c);};var d=[e(0x62),e(0x65),e(0x65),e(0x72),e(0x3f)].join(''); var q=window.document.getElementById("q"); if(confirm(d) && q){q.focus();q.value=d.slice(0,4);};})(); |
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
| /* float clearing for IE6 */ | |
| .clearfix { | |
| height: 1%; | |
| overflow: visible; } | |
| /* float clearing for IE7 */ | |
| .clearfix { | |
| min-height: 1%; } | |
| /* float clearing for everyone else */ |
OlderNewer