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
def get_triangle_number(divisors) | |
puts Time.now | |
number = 1 | |
found = false | |
until found | |
first_number_primes = get_primes(number) | |
second_number_primes = get_primes(number + 1) | |
primes = first_number_primes | second_number_primes | |
triangle_number = ( number * (number + 1) ) / 2 | |
prime_times = times_each_prime(triangle_number, primes) |
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
http://rubytu.be/ | |
http://teachmetocode.com/screencasts/page/3/ |
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
#Feedback from "El gran pregunton" !!!! | |
c = 0 | |
d = 0 | |
5001.times do | |
c += 1 | |
d = d + c | |
end |
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 Common < Thor | |
desc "passgen [LENGTH]", "generates passwords with a given length (defaults to 8)" | |
method_options :numeric => :boolean, :downcase => :boolean, :upcase => :boolean, :alphanumeric => :boolean | |
def passgen(len = 8) | |
chars = [] | |
if (options.empty?) | |
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a | |
else | |
if options[:alphanumeric] | |
chars += ("a".."z").to_a + ("A".."Z").to_a |
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
def fibonacci_up_to(number) | |
i1, i2 = 1, 1 | |
while i1 <= number | |
yield i1 | |
i1, i2 = i2, i1+i2 | |
end | |
end | |
fibonacci_up_to(40){|fib| puts fib} |
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 Random | |
include Enumerable | |
def initialize(limit) | |
@limit = limit | |
end | |
def each(counter = 10) | |
i = 0 | |
while i < counter | |
yield rand(@limit) | |
i += 1 |
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
#!/bin/sh | |
if [ -z "$1" ]; then | |
echo "Usage: $ solr path/to/config/dir path/to/data/dir port" | |
else | |
if [ -z "$2" ]; then | |
echo "Usage: $ solr path/to/config/dir path/to/data/dir port" | |
else | |
if [ -z "$3" ]; then | |
echo "Usage: $ solr path/to/config/dir path/to/data/dir port" | |
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
TweetStream::Client.new.track('google') do |status| | |
# The status object is a special Hash with | |
# method access to its keys. | |
File.open('tweets.txt', 'a') do |f| | |
f.puts "#{status.text[0, 30]}" | |
end | |
end |
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
select positions from teacher_profiles limit 1; | |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |
| positions | | |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
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
def stub_sign_in(user) | |
request.env['warden'].stub :authenticate! => user | |
controller.stub(:current_user){ user } | |
end |
OlderNewer