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
threads = [] | |
threads << Thread.new do | |
puts "I'm gonna stop" | |
Thread.stop | |
puts "I started again!" | |
end | |
sleep 3 | |
threads[0].run.join |
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
# horas nocturnas SICA | |
require 'chronic' | |
class Calculadora | |
AM4 = Chronic.parse('4 am') | |
PM9 = Chronic.parse('9 pm') | |
JORNADA = 31500 | |
H12 = 2592000 | |
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
#include <stdio> | |
int check_for_zero(float num1, float num2, float num3, float num4, float num5, float num6) { | |
int zero_present = 0; | |
if(num1 == 0 || num2 == 0 || num3 == 0 || num4 == 0 || num5 == 0 || num6 == 0) { | |
zero_present = 1; | |
} | |
return zero_present; | |
} |
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
discount = case gets.chomp | |
when "i" then " 6" | |
when "s" then "35" | |
when "c" then "20" | |
end | |
print "********************************** | |
** Congratulations! ** | |
** ** | |
** You will get #{discount}% OFF ** |
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
#include <stdio> | |
void user_prompt(){ | |
printf("Please enter \"c\" for College Student, \"s\" for Senior Citizen, or \"i\" for other: "); | |
} | |
char gather_input(){ | |
char input; | |
scanf("%s", &input); | |
return input; |
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
def random_consonant | |
([*"b".."z"] - ["e", "i", "o", "u"]).sample | |
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
> url = "default-ubuntu-1404-i386.load_avg.fifteen" | |
> url2 = "default-ubuntu-1404-i386.vagrantup.com" | |
> match_pattern = /default-ubuntu-1404-i386\.(?=vagrantup)/ | |
> url.match match_pattern | |
#=> nil | |
> url2.match match_pattern | |
#=> #<MatchData "default-ubuntu-1404-i386."> |
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
some_number = 3 | |
case some_number | |
when ->(n) { n == 2 } | |
puts "the number was 2!" | |
when ->(n) { n == 3 } | |
puts "the number was 3!" | |
else | |
puts "the number wasn't 2 or 3..." | |
end | |
#=> the number was 3! |
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
some_number = 3 | |
case some_number | |
when lambda {|n| n == 2 } | |
puts "the number was 2!" | |
when lambda {|n| n == 3 } | |
puts "the number was 3!" | |
else | |
puts "the number wasn't 2 or 3..." | |
end | |
#=> the number was 3! |
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
when naming, you should: | |
Reveal intention | |
avoid disinformation | |
make meaningful distinctions | |
use pronounceable names | |
use searchable names | |
avoid encodings (stick to ascii) | |
classes should probably be nouns | |
methods should probably be verbs or verb phrases | |
don't be cute |