Skip to content

Instantly share code, notes, and snippets.

View rikas's full-sized avatar
🏠
Working from home

Ricardo Otero rikas

🏠
Working from home
View GitHub Profile
@rikas
rikas / car.rb
Created October 24, 2018 09:47
OOP Basics Lecture
# car.rb
# filename - lower_snake_case
# class name - UpperCamelCase
# sports_car.rb => SportsCar
class Car
attr_reader :brand
# attr_writer :color
paris = {
"country" => "France",
"population" => 2211000
}
students = {
2882 => {
'name' => 'Ricardo',
'age' => 27
}
def beautify_name(first_name, last_name)
full_name = "#{first_name.capitalize} #{last_name.upcase}"
yield(full_name)
end
message = beautify_name("john", "lennon") do |name|
"Greetings #{name}, you look quite fine today!"
end
message = beautify_name("john", "lennon") do |name|
# Everything's ok
200 - OK
# Redirects or cache
301 - Permanent redirect
302 - Temp redirect
304 - Not modified
# Client error (you screw up)
401 - Unauthorized
@rikas
rikas / chef.rb
Created April 26, 2018 10:33
Inheritance & Self
# chef.rb
class Chef
attr_reader :name, :restaurant
def initialize(name, restaurant)
@name = name # String
@restaurant = restaurant # Restaurant
end
end
@rikas
rikas / car.rb
Created April 25, 2018 09:49
Classes & instances
# car.rb
# filename - lower_snake_case
# class name - UpperCamelCase
class Car
attr_reader :brand
# attr_reader :brand
# attr_writer :color
# same as attr_writer + attr_reader
attr_accessor :color
@rikas
rikas / resque
Last active January 26, 2017 05:02
File to use in /etc/init.d/resque to run resque workers
#!/bin/bash
### BEGIN INIT INFO
#
# Provides : resque-env
# Required-Start :
# Required-Stop :
# Default-Start : 2 3 4 5
# Default-Stop : 0 1 6
# Short-Description : Resque worker via init.d (assumes you have Ruby, and a plugin to allow wildcards in queue names)
# Description : see Short-Description, brah
@rikas
rikas / monitrc
Last active December 21, 2015 00:29 — forked from franck/monitrc
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file and a complete list of statements and
## options, please have a look in the Monit manual.
#!/bin/bash
### BEGIN INIT INFO
# Provides: sidekiq beta
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: sidekiq
#!/usr/bin/env ruby
##
# This file must be renamed to pre-commit without extension and
# added to your .git/hooks directory
# After that, run `chmod 755 pre-commit` to make it executable
$user = ENV['USER']