Skip to content

Instantly share code, notes, and snippets.

View volpeo's full-sized avatar
🦊
Freelancing

Sylvain Peigney volpeo

🦊
Freelancing
View GitHub Profile

Byebug syntax highlighting. Works for v10.0.0 and higher.

@volpeo
volpeo / jato.js
Created November 8, 2019 23:49
Jato.js
data = request_result
// target the array of projects
projects = request_result.data.projects.group
// target the array of repos
repos = data.data.repo.edges
// get the strings we need to filter on as source
source = repos.map(function(repo) { return repo.node.relativePath })
FR0010592105
FR0010718312
FR0010105411
FR0010358986
LU0998992639
LU1881735861
LU0276015889
LU1319654866
LU1914343311
LU1914341026
const writeData = (data, contentElt) => {
contentElt.innerHTML = `
<p>Name is ${data.person.name.fullName}</p>
<p>Company is ${data.company.name}</p>
`
};
const getInfoFromClearbit = (e) => {
const contentElt = document.getElementById('content');
e.preventDefault();
POSSIBLE_OPERATORS = %w(* / + - %)
def process_calculation(first_number, second_number, operator)
return nil unless POSSIBLE_OPERATORS.include? operator
# case operator
# when "+"
# first_number.+(second_number)
# when "-"
# first_number.-(second_number)
# when "*"
$products = [
{
name: "kiwi",
price: 5,
stock: 20
},
{
name: "banane",
price: 3,
stock: 3
def process_calculation(first_number, second_number, operator)
first_number.send(operator, second_number)
end
require "date"
def count_days_to_christmas(date = Date.today)
#today = Date.new(2018, 12, 26)
christmas = Date.new(date.year, 12, 25)
if date > christmas
christmas = Date.new(date.year+1, 12, 25)
end
(christmas - date).to_i
end
# def compute(a, b, operator)
# case operator
# when "+" then a + b
# when "-" then a - b
# when "*" then a * b
# when "/" then a / b
# when "%" then a % b
# else "Not implemented"
# end
# end
@volpeo
volpeo / some_controller.rb
Created September 14, 2016 10:20
Redirect from a satellite static website to application
# create cookie at sign in
cookies[:redirect] = {
:value => 'yes',
:expires => 1.year.from_now,
:domain => '.mydomain.com'
}
# delete cookie at sign out
cookies.delete :redirect, domain: '.mydomain.com'