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 primos(limite): | |
primos = [] | |
for elemento in range(2,limite): | |
encontrado = False | |
for primo in primos: | |
if elemento % primo == 0 and elemento is not primo: | |
encontrado = True | |
break | |
if not encontrado: | |
primos.append(elemento) |
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
Basic commands: | |
html:5 | |
Creates a HTML5 template |
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
This zen: | |
html:5>h1+(fieldset>(p>label+input)*2)+(fieldset>(label+(p>input)*4)+(p>label+input)*2)+(fieldset>(p>label+input)*4+(label+select>option*2)) | |
Generates this: | |
<!DOCTYPE HTML> | |
<html lang="en-US"> |
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
public class Operaciones { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
char operacion = args[0].charAt(0); | |
int valor = Integer.parseInt(args[1]); | |
suma(valor, operacion); | |
} |
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
print 'Enter your name: ' #Fer | |
name = gets() | |
puts "Hello #{name}" #prints "Hello Fer" | |
puts 'Hello #{name}' #prints "Hello {name}" |
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 RubyMeeting | |
attr_accessor :name, :number, :date | |
def initialize( aName, aNumber, aDate = Time.now ) | |
@name = aName | |
@number = aNumber | |
@date = aDate | |
end | |
def attendance |
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
puts %Q/This is the same as a double-quoted string./ | |
puts %Q/This is also the same as a double-quoted string./ | |
puts %q/And this is the same as a single-quoted string/ | |
puts %Q*This is the same as a double-quoted string* | |
puts %Q!This is also the same as a double-quoted string! | |
puts %q(And this is the same as a single-quoted string) | |
puts %Q?This is the same as a double-quoted string? | |
puts %Q/This is also the same as a double-quoted string./ | |
puts %q/And this is the same as a single-quoted string/ | |
puts %Q#This is the same as a double-quoted string# |
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
puts(`ls`) | |
puts(%x/clear/) | |
puts(%x{su -}) |
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
s = "Hello " << "rubyCUCEI" | |
puts s # Hello rubyCUCEI | |
s = "Hello " + "rubyCUCEI" | |
puts s # Hello rubyCUCEI | |
s = "Hello " "rubyCUCEI" | |
puts s # Hello rubyCUCEI |
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
#s = "Hello " + 64 #Error: can't convert Fixnum into String | |
s = "Hello " << 64 | |
puts s # Hello @ | |
s = "Hello " << 64.to_s | |
puts s # Hello 64 |
OlderNewer