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
# You should have the same amount of `{` as `}` | |
# 2 | |
%Q{{hi}} | |
# => "{hi}" | |
# 4 | |
%Q{{{{42}}}} | |
# => "{{{42}}}" | |
# `{`: 2; `}`: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
puts `ruby -e 'class Fixnum; def to_s; "WHAT"; end; end; puts 42.to_s; puts "#{3 * 4}";'` | |
# WHAT | |
# 12 | |
# this one works only in the pry | |
# .ruby -e 'class Fixnum; def to_s; "WHAT"; end; end; puts 42.to_s; puts "#{3 * 4}";' | |
# WHAT | |
# 12 | |
system(%q{ruby -e 'class Fixnum; def to_s; "WHAT"; end; end; puts 42.to_s; puts "#{3 * 4}";'}) |
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
module A | |
# evil module: | |
module A | |
module B | |
def foo | |
:evil_foo | |
end | |
end | |
end | |
# good module: |
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 RStruct | |
def initialize | |
# `@name` => just to show that code works | |
# you don't have to put it into `initialize` | |
@name = 'example' | |
@my_object_id = self.object_id | |
end | |
attr_reader :name, :my_object_id | |
def save_to_Redis | |
# some code |
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 correct? input | |
if 24 == input | |
puts "great job! you did it!" | |
true | |
else | |
puts "please try again" | |
false | |
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
# 1 | |
# you have to use parens => `()` | |
# otherwise Ruby will threat it as `stuff if condition` | |
puts (if 1 | |
then 2 | |
else 3 | |
end) | |
# 2 | |
puts 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
I wanted to try this. | |
So I added new line. |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>HTML5 Video</title> | |
</head> | |
<body> | |
<!-- Write your video tag here: --> | |
<video controls="controls" src="">Your browser does not support the HTML5 video tag.</video> | |
</body> | |
</html> |
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
#lang datalog | |
ancestor(A, B) :- parent(A, B). | |
ancestor(A, B) :- | |
parent(A, C), D = C, ancestor(D, B). | |
parent(john, douglas). | |
parent(bob, john). | |
ancestor(A, B)? |
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
bezwgledna(float a) if (a<0) return (a-(2*a)); else return a; | |
if ( bezwgledna(liczba_float1 - liczba_float2) < 0.0001 |
OlderNewer