Skip to content

Instantly share code, notes, and snippets.

View barangerbenjamin's full-sized avatar

Baranger Benjamin barangerbenjamin

View GitHub Profile
class PostsView
def display(posts)
posts.each do |post|
# We display the id so the user can tell us which post they want to update/delete/upvote
puts "#{post.id}. #{post.title} - #{post.url} | #{post.votes}"
end
end
def ask_for(question)
puts question
require_relative "../views/posts_view"
class PostsController
def initialize
@view = PostsView.new
end
def index
# Ask the model to retrieve all the records
posts = Post.all
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import requests
# url = 'https://api.github.com/users/ssaunier'
# response = requests.get(url).json()
# print(response['name'])
# ------------------------------------------------
import requests
import csv
from bs4 import BeautifulSoup
url = "https://www.imdb.com/list/ls055386972/"
response = requests.get(url)
soup = BeautifulSoup(response.content, "html.parser")
items = soup.find_all("div", class_="lister-item-content")
movies = []
const form = document.getElementById('new-car'); // Retrieve the form and store it in a variable
form.addEventListener('submit', (event) => { // Listen for a form submit
event.preventDefault(); // prevent the page to reload
const car = { // create a car object that we can feed later to the API
brand: document.getElementById('brand').value, // retrieve the brand from the form input
model: document.getElementById('model').value, // retrieve the model from the form input
plate: document.getElementById('plate').value, // retrieve the plate from the form input
owner: document.getElementById('owner').value // retrieve the owner from the form input
}
const url = "https://wagon-garage-api.herokuapp.com/batch-476/cars"; // define the API url
class Connect4():
def __init__(self): # Constructor
self.current_player = "1" # Who's playing now
self.next_player = "2" # Who's the next player
self.ongoing = True # Is the game finished?
self.grid = [
['0', '0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0', '0'],
print("> Welcome to your Christmas gift list") # Print welcome in the console
gifts = {} # Define an empty list to hold the gifts
running = True # Define a variable to control the loop
while running: # Loop while running is set to a True value
action = input("> Which action [list|add|delete|mark|quit]?\n> ") # Print the menu to the user
if action == "list": # If the user says list
if gifts: # If the gifts dict is not empty
for index, (item, marked) in enumerate(gifts.items()): # Iterate over the iterable of the key/value pairs in the gifts dict
if marked: # If the value of marked is True for the item