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
| View: | |
| <a target="_blank" href="<%= model.cuhacker_url %>">Cu-hackerで確認</a> | |
| Model: | |
| def cuhacker_url | |
| url = 'https://cu-hacker.com/calendar?' | |
| stime = Time.parse(self.meeting_date.to_s + ' ' + self.start_time.to_s) - (9*60*60) | |
| stimeutc = stime.strftime("%Y%m%dT%H%M%SZ") | |
| etime = Time.parse(self.meeting_date.to_s + ' ' + self.end_time.to_s) - (9*60*60) | |
| etimeutc = etime.gmtime.strftime("%Y%m%dT%H%M%SZ") |
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
| #coding: utf-8 | |
| line = 0 | |
| count = 0 | |
| days = 0 | |
| products = Array.new | |
| campaign_prices = Array.new | |
| s = gets.chomp.split(" ") | |
| count = s[0].to_i | |
| days = s[1].to_i |
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
| x = (1..12) | |
| y = (1..12) | |
| print ' ' | |
| x.each {|i| print "%-5d" % i } | |
| print "\n " | |
| x.each {|i| print '---- '} | |
| print "\n" | |
| y.each do |j| |
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
| #coding: utf-8 | |
| members = ('0001'..'0528').to_a | |
| members.delete_if{|m| /[49]/ =~ m } | |
| p members.count.to_s + '人' |
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
| import scala.testing.Benchmark | |
| import scala.util.Random | |
| object Main extends Benchmark { | |
| def kouyaku(num:Int) { | |
| var i:Int = 0 | |
| val listBuffer = new collection.mutable.ListBuffer[Int] | |
| while(i <= num){ | |
| val maxnum = 10000 | |
| val a = Random.nextInt(maxnum) | |
| val b = Random.nextInt(maxnum) |
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
| #coding: utf-8 | |
| cipher_text = "qdq-gi.q-a ziatmxxitmdqibtqi-ustbi ri.qmoqrcxi.qbubu zir -ibtqi-qp-qaai ripmymsqkir -ibtqi-qy dmxi ri.cnxuoi rruoumxakir -ibtqiqzmobyqzbkii-q.qmxi -imyqzpyqzbi rixmeaki -puzmzoqai -i-qscxmbu zaimzpir -i btq-iymbbq-a;iz -iatmxximzgi.q-a zinqiuzimzgiemgipuao-uyuzmbqpimsmuzabir -ia. za -uzsiacotiimi.qbubu zj" | |
| @alphabet = "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z: :.:,:-".split(":") #復号用文字列 | |
| def decode(cipher, keyword) | |
| @alphabet.each do |letter| | |
| deciphered_text = '' | |
| cipher_position = @alphabet.index(cipher[0].chr) #暗号文字列の1文字目が、復号用文字列の何文字目にあるか | |
| clear_position = @alphabet.index(letter) #復号文字が、復号用文字列の何文字目にあるか |
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
| #coding: utf-8 | |
| require 'timeout' | |
| def prime_list(n) | |
| return [] if n < 2 | |
| return [2] if n == 2 | |
| limit = (n ** 0.5).to_i | |
| arr = (1 .. n).step(2).to_a | |
| arr[0] = 2 | |
| len = arr.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
| #coding: utf-8 | |
| require 'open-uri' | |
| require 'nokogiri' | |
| hatena_url = 'http://b.hatena.ne.jp/hotentry.rss' | |
| yahoo_url = 'http://jlp.yahooapis.jp/MAService/V1/parse' | |
| appid = '*****' | |
| doc = Nokogiri.HTML(open(hatena_url)) | |
| str = "" | |
| doc.css('item').each do |item| | |
| count = item.css('bookmarkcount').first.content.to_i |
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
| #coding: utf-8 | |
| class Card | |
| attr_accessor :suit, :num | |
| def initialize(suit, num) | |
| @suit = suit | |
| @num = num | |
| end | |
| def to_s | |
| @num.to_s + "[" + @suit + "]" | |
| 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
| #coding: utf-8 | |
| require 'open-uri' | |
| require 'zip/zip' | |
| require 'csv' | |
| CSVFILE = 'zenkoku.csv' | |
| url = 'http://jusyo.jp/downloads/new/csv/csv_zenkoku.zip' | |
| filename = url.split(/\//).last | |
| open(url) do |source| | |
| open(filename, "w+b") do |o| | |
| o.print source.read |
NewerOlder