Skip to content

Instantly share code, notes, and snippets.

@Papillard
Papillard / comments_create.js
Created February 21, 2014 09:37
jQuery script for remote comment posting
$('#comments').prepend("<%= j render partial: 'comment', locals: {comment: @comment} %>");
$('.counter').html("<%= j pluralize(@challenge.comments_count, 'comment')%> posted");
$('.comment-box:first').animate({backgroundColor: "rgba(45,195,89,0.2)"}, 50);
$('.comment-box:first').delay(1000).animate({backgroundColor: "#FFFF"}, 1000);
require 'open-uri'
require 'nokogiri'
html_file = open("http://www.leboncoin.fr/annonces/offres/ile_de_france/?q=treteau")
html_doc = Nokogiri::HTML(html_file)
html_doc.search('.lbc').each do |element|
puts element.search('.title').inner_text
puts element.search('.category').inner_text
puts element.search('.price').inner_text
class CreatePosts < ActiveRecord::Migration
def up
create_table :posts do |t|
t.string :name
t.datetime :date
t.string :source_url
t.integer :rating
end
end
end
<table>
<tr>
<td>Pays</td>
<td>Classement FIFA</td>
<td>Capitaine</td>
<td>Sélectionneur</td>
</tr>
<tr>
<td>France</td>
@Papillard
Papillard / loto_interface.rb
Created October 13, 2014 10:32
Loto interface for Re-Boot challenge @lewagon
def pick_number()
puts "pick a number please"
gets.chomp.to_i
end
def display_grid(grid)
grid.each_with_index do |num, index|
puts "Numero #{index + 1} => #{num}"
end
end
@Papillard
Papillard / nail.rb
Last active August 29, 2015 14:08
Fort Boyard nail's game @lewagon
def state_of_the_nail(length)
two_digit_length = (length * 100).truncate / 100.0
return "La longueur du clou est de #{two_digit_length} cms"
end
def hit_nail(length, force)
# Give nail length and player force in input, e.g 8, 3
# return new nail's length
return length - force * rand(0..1.0)
@Papillard
Papillard / contact.html
Created October 29, 2014 11:21
Kitty Blog - HTML/CSS example @lewagon
<!DOCTYPE html>
<html>
<head>
<title>KITTY BLOG | Home</title>
<meta charset="utf-8">
<meta name="description" content="KittyBlog, best cat blog in the world">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
@Papillard
Papillard / index.html
Created October 29, 2014 17:11
Fixed Navbar live-code @lewagon
<html>
<head>
<title>MON LAYOUT</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="navbar">
<div class="nav-content">
<h1>MY BLOG</h1>
@Papillard
Papillard / index.html
Created October 30, 2014 10:48
Bootstrap demo @lewagon
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>--- TODO ---</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
@Papillard
Papillard / navbar_white.css
Last active August 29, 2015 14:08
White navbar over-ride for Bootstrap @lewagon
.navbar-white{
background: white;
border-bottom: 1px solid lightgrey;
}
.navbar-white .navbar-nav > li > a,
.navbar-white .navbar-nav > li > a:hover
{
color: black;
line-height: 50px;