I hereby claim:
- I am suryart on github.
- I am srt (https://keybase.io/srt) on keybase.
- I have a public key whose fingerprint is 0BEA 34ED DE36 3D58 3601 FC41 BED2 86EA 420A F92C
To claim this, I am signing this object:
1.upto(STDIN.gets.to_i) do |num| | |
break if num > 10**7 # num should be less than 10^7 | |
output = nil | |
output = output.to_s + 'Fizz' if num % 3 == 0 | |
output = output.to_s + 'Buzz' if num % 5 == 0 | |
puts output || num | |
end |
#!/usr/bin/ruby | |
require 'benchmark' | |
str2 = "My another testing well string" | |
n = 500 | |
Benchmark.bm(40) do |x| | |
x.report("str2[/(.*)\s/,1] "){ n.times { str2[/(.*)\s/,1] } } | |
x.report("str2[0...str2.rindex(' ')] "){ n.times { str2[0...str2.rindex(' ')] } } | |
x.report("str2.split(' ')[0...-1].join(' ') "){ n.times { str2.split(' ')[0...-1].join(' ') } } | |
x.report("str2[/.*(?=\s)/] "){ n.times { str2[/.*(?=\s)/] } } | |
end |
// layout file | |
<body> | |
<div class="container"> | |
<%= flash_messages %> | |
<%= yield %> | |
</div><!-- /container --> | |
</body> |
arr = [1, 2, 4, 10, 90, 302, 312, 500] | |
(2..arr.count).each do |len| | |
arr.combination(len).each do |comb| | |
sum = comb.inject(:+) | |
if arr.include? sum | |
puts (comb << sum).inspect | |
end | |
end | |
end |
require 'benchmark' | |
string = 'dskjkd' | |
n = 500000 | |
Benchmark.bm(40) do |x| | |
x.report("string.size "){ n.times { string.size } } | |
x.report("string.length "){ n.times { string.length } } | |
end | |
require 'benchmark' | |
def my_method | |
string = 'dskjkd' | |
chars = string.split('') | |
counts = chars.count | |
(2..chars.count).each do |len| | |
chars.combination(len).each do |comb| | |
string = comb.inject(:<<) | |
counts += 1 if string.reverse == string |
module InstanceModule | |
def track | |
"Tracking todo: #{self.name}" | |
end | |
end | |
module ClassModule | |
def class_name | |
"Tracking class: #{self.name}" |
def is_prime?(num) | |
return false if num <= 1 | |
2.upto(Math.sqrt(num).to_i) do |x| | |
return false if num%x == 0 | |
end | |
true | |
end |
I hereby claim:
To claim this, I am signing this object:
// Just empty macbook.local.err file then restart the server | |
rm /usr/local/var/mysql/macbook.local.err | |
mysql.server start |