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
# sample 1: | |
a = 5 | |
a ||= 3 | |
a | |
#result: | |
5 | |
# same as: |
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
GET | |
POST | |
PUT | |
UPDATE | |
DELETE | |
Recursos: | |
productos, | |
compras, |
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 foo(a, *b, **c) | |
[a, b, c] | |
end | |
puts foo(10, 123, 12, 4, 6, clave: 'hola', nueva: 'asdfads').inspect |
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 example is going to show you how to use different versions of rails with a specific version of ruby | |
# 1. Select your ruby version | |
rvm use 2.5.1 | |
# 2. Create a gemset for your specific version of rails. The basic approach is to use one gemset per project. | |
rvm gemset create my_project_in_rails_4 | |
# 3. Check that your gemset was created with: | |
rvm gemset list | |
# 4. Select your gemset with: | |
rvm gemset use my_project_in_rails_4 | |
# 5. Install your specific vesrion of rails. In this case 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
version: '2' | |
services: | |
node: | |
build: | |
context: . | |
dockerfile: node.dockerfile | |
ports: | |
- "3000:3000" |
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 stars(n) | |
n.times {print"*"} | |
end | |
stars(5) | |
puts "\n" | |
stars(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
def string_rev_4(word) | |
if word.length < 4 | |
word.reverse | |
else | |
word | |
end | |
end | |
puts string_rev_4('hello') | |
puts string_rev_4('yo') |
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 "Hey, user are you in a good mood? " | |
until gets.chomp == 'y' | |
puts "Well, You're fabulous. Are you in a good mood now?" | |
end | |
puts "I knew I could cheer you up" | |
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 "Hey, user are you in a good mood? " | |
user_mood = gets.chomp | |
until user_mood == 'y' | |
puts "Well, You're fabulous. Are you in a good mood now?" | |
user_mood = gets.chomp | |
end | |
puts "I knew I could cheer you up" |
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
# How to delete many branches at the same time | |
# This will delete all branches already merged that start with release follow by anything | |
git branch -d `git branch | grep -E 'release*'` |
NewerOlder