Skip to content

Instantly share code, notes, and snippets.

View luizfonseca's full-sized avatar
💻
cargo run

Luiz Fonseca luizfonseca

💻
cargo run
View GitHub Profile
@luizfonseca
luizfonseca / controller.rb
Created July 14, 2017 16:58
Todo List using MVC
# this file serves as a router for any questions related to tasks
class Controller
# Called on `Controller.new`
def initialize(repository, view)
# STATE
# We receive an instance of Repository Class
@repository = repository
# Receive a instance of View, so we can display things
@luizfonseca
luizfonseca / interface.rb
Created July 11, 2017 16:10
[Reboot] Instacart
# 1) print "Welcome to the Instacart"
# 2) Define the items on the store (Hashes)
# 3) Initialize an empty cart
# 3) Print the items
# 4) Ask the user for one item until he types "quit"
# 5) If the item is not on store, do something
# 8) if user types "quit", then Display the order (BILL)
# 9) Checkout.
# Our items on store
@luizfonseca
luizfonseca / interface.rb
Last active July 11, 2017 16:08
[Reboot] Horse races
# 1) print "Welcome to the Horse Race of Le Wagon"
# 2) Create a List of horses? DONE
# 3) Show the list of horses
# 4) Ask the user: "On which horse do you want to bet on?"
# 5) Ask the user: "How much do you want to bet?"
# 6) Place the bet
# 7) Run the race METHOD
# 8) Display the result of the race: "Winner/Loser"
# 9) Display the result of the bet
# 10) Want to bet again?
@luizfonseca
luizfonseca / README.md
Last active July 11, 2017 16:05
[Reboot] Calculator

Pseudo code steps

1 - print "Welcome to the calculator"?

2 - Get first number from the user

3 - Get second number from the user

4 - Ask which operation the user wants to perform

5 - Show the results

@luizfonseca
luizfonseca / livecode.rb
Created July 11, 2017 15:59
Le Wagon, March 10 2017
require "date"
# REGEX TIME!
# Write a #french_ssn_info method extracting infos
# from French SSN (Social Security Number) using
# regexp.
# "1 84 12 76 451 089 46"
# Gender (1 == man, 2 == woman)
# Year of birth (84)
@luizfonseca
luizfonseca / chef.rb
Last active January 19, 2017 16:55
OOP Advanced => Inheritance, Class Methods and Self
# Our Chef class that receives a Restaurant as a parameter
class Chef
attr_reader :name
def initialize(name, restaurant)
@name = name
@restaurant = restaurant # Can be any Restaurant
end
end
###########Bibliotecas########
#se nao tiver instalada, e necessario usar o comando
#install.packages("nome_da_biblioteca")
library(tm)
library(wordcloud)
library(RColorBrewer)
######################################
#seta o folder de trabalho. é preciso passar o caminho completo até a pasta onde estao os dados
setwd("/home/caminho/para/psta_local/dos_dados")
@luizfonseca
luizfonseca / form.html
Last active August 29, 2015 14:26
Mailchimp VisãoRio500
<form action="//desafioagorario.us9.list-manage.com/subscribe/post?u=5f55ed935ec2264bdcd24a578&amp;id=25a5430095" method="post" target="_blank">
<label for="mce-EMAIL">Email: </label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
<input type="hidden" name="b_5f55ed935ec2264bdcd24a578_25a5430095" tabindex="-1" value="">
<input type="submit" value="Cadastrar" name="subscribe" id="mc-embedded-subscribe" class="button">
</form>
@luizfonseca
luizfonseca / get_category_zone.sql
Last active August 29, 2015 14:23
Sum of Pins that intersect with the current district on the given category id
DROP FUNCTION IF EXISTS get_category_zone(integer, text);
CREATE OR REPLACE FUNCTION get_category_zone(cat_id integer, zone_id text) RETURNS numeric AS $$
SELECT SUM(zone_list.count) FROM (
SELECT
d.id,
d.zone,
(
SELECT COUNT(*)
FROM pins p0
DROP FUNCTION IF EXISTS get_category_zone(integer, text);
CREATE OR REPLACE FUNCTION get_category_zone(cat_id integer, zone_id text) RETURNS numeric AS $$
SELECT
SUM(zone_list.count)
FROM (
SELECT
d.id,
d.zone,
(
SELECT COUNT(*)