Skip to content

Instantly share code, notes, and snippets.

@Papillard
Papillard / array_basics.rb
Last active July 12, 2017 09:07
CRUD operations and basics methods on Array
# Define an array
fruits = [] # empty array
beatles = ["john", "paul", "ringo", "georges"]
# 0 1 2 3
# Get the size of the array
puts beatles.size
# or
# puts beatles.length
# puts beatles.count
@Papillard
Papillard / app.js
Created May 18, 2017 09:34
GET repos with AJAX
$(document).ready(function(){
$("#submit").on("click", function(){
// get the username from input
// make a GET request to the API
// inject the response in the page
var userName = $("#username").val();
@Papillard
Papillard / app.js
Created May 18, 2017 09:33
POST gist with AJAX
$(document).ready(function(){
$("#submit").on("click", function(){
var content = $("#content").val();
var gistData = {
"description": "Stupid gist",
"public": true,
"files": {
@Papillard
Papillard / app.js
Created April 13, 2017 09:03
Playing with AJAX and Github
$(document).ready(function(){
var baseUrl = "https://api.github.com";
$("#fetch").on("click", function(){
// get the value from username input
// make a GET request to api.github.com/users/username/repos
// inject response in the list #repos
var userName = $("#username").val();
@Papillard
Papillard / example.rb
Created April 13, 2017 08:28
a description
puts "hello"
@Papillard
Papillard / cheatsheet.md
Created April 5, 2017 08:31
Bootstrap 4 cheatsheet

Utilities class

  • img-rounded replaced by rounded-circle
  • hidden replaced by invisible (add display: none; on .invisible in the CSS if you need)
  • hidden-xs is replaced by hidden-xs-down
  • hidden-sm hidden-md hidden-lg is equivalent to hidden-sm-up

Grid

  • col-xs-6 is now col-6
  • col-md-offset-2 becomes offset-md-2
@Papillard
Papillard / smorrebrod.rb
Last active November 16, 2016 16:33
Smorrebrod restaurant scraper
require "open-uri"
require "nokogiri"
url = "http://www.visitdenmark.com/copenhagen/gastronomy/smorrebrod-restaurants-copenhagen"
html_file = open(url)
doc = Nokogiri::HTML(html_file)
doc.search(".gdkProduct").each do |smorrebrod|
p smorrebrod.search(".ProductImage")[0].attr("src")
@Papillard
Papillard / timeout_pub_scraper.rb
Created August 17, 2016 16:12
TimeOut best pubs scraper
require "open-uri"
require "nokogiri"
url = "http://www.timeout.com/london/bars-and-pubs/the-100-best-bars-and-pubs-in-london"
html_file = open(url)
doc = Nokogiri::HTML(html_file)
doc.search(".feature-item").each do |bar|
p bar.search("img")[0].attr("src")
p bar.search("h3 a")[0].text
@Papillard
Papillard / cheatsheet.js
Created August 9, 2016 07:38
Cheatsheet going through all Javascript programming basics (that you already know in ruby!)
// 1 ------------ Basics ------------
// console.log
console.log("hello london!");
// variable / typeof
var name = "Seb Saunier";
var lastName = "Paillard";
var age = 17;
var weight= 72.6;
@Papillard
Papillard / active_record_cheatsheet.rb
Created August 1, 2016 10:19
Active Record most useful methods
# For exhaustive documentation => http://guides.rubyonrails.org/active_record_basics.html
# Create a restaurant
fox = Restaurant.new(name: "the fox")
fox.save
# Update a restaurant
fox.address = "Bristol"
fox.save