Skip to content

Instantly share code, notes, and snippets.

Rousseau Alexandre madeindjs

Block or report user

Report or block madeindjs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View number_to_french.rb
# on inclue la librairie de test de Ruby pour faires quelques petits test unitaires
require 'test/unit'
# On va gérer toute la conversion dans une classe qui va avoir une méthode `translate` qui s'occupera de tout traduire.
# La classe va nous permettre de mieux organizer le code en plusieurs méthodes plus petites et donc plus lisibles
class Converter
# On va commencer par définir des constantes (aka des variables qui ne changerons jamais)
# En Ruby, les constantes sont des variables nomées en majuscule
# La syntaxe avec le `%w[]` permet simplement de définir des tableaux en mode un peu plus sexy.
@madeindjs
madeindjs / number_to_english_2.rb
Created May 12, 2019
Juste quelques améliorations au niveau des nommages
View number_to_english_2.rb
# Il vaut mieux définir des constantes (aka des variables qui ne changerons jamais)
# en dehors de la méthode. Les constantes sont juste nomées en majuscule
#
# La syntaxe avec le `%w[]` permet simplement de définir des tableaux en mode un peu plus sexy
NUMBER_TRANSLATIONS = %w[one two three four five six seven eight nine].freeze
DOZEN_TRANSLATIONS = %w[ten twenty thirty forty fifty sixty seventy eighty ninety].freeze
TEENAGERS = %w[eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen].freeze
# Convert a number to a beautiful string
# @param [Integer] as a number
View api_consumer.html
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>TODO front-end</title>
</head>
<body>
<div id="app">
@madeindjs
madeindjs / json.swift
Created Apr 12, 2019
Fetch & Parse JSOn from raspberry-cook.fr
View json.swift
import Foundation
let decoder = JSONDecoder()
let uri : String = "http://raspberry-cook.fr/recipes/buddha-bowl-au-thon-cuit.json"
let feedUrl = URL(string: uri)!
struct Recipe : Codable {
var id : Int
var name : String
@madeindjs
madeindjs / wifi_scanner.rb
Last active Mar 28, 2019
Scan a Wifi and log each new device connected on it
View wifi_scanner.rb
require 'hooray'
require 'logger'
LOG_FILE = './wifi.log'.freeze
INTERVAL_TIME = 30
DEFAULT_NODE_NAME = 'UNKNOW'.freeze
class Scanner
attr_reader :logger
@madeindjs
madeindjs / oop.rb
Last active Jan 8, 2019
A simple of OOP in ruby
View oop.rb
# A class who provide access to database
class Record
attr_accessor :title
# Create and return the record
def self.create(title)
record = Record.new
record.title = title
record.save
record
end
@madeindjs
madeindjs / template_benchmark.rb
Created Nov 10, 2018
Benchmarking of existing templating libs
View template_benchmark.rb
require 'erb'
require 'haml'
require 'slim'
require 'benchmark'
class Context
attr_reader :title, :content
def initialize(title, content)
@title = title
View backup_server.sh
#!/bin/bash
green='\e[0;32m'
darkred='\e[1;31m'
lightblue='\e[1;34m'
defaut='\033[0m'
today=$(date +%Y-%m-%d)
foldername_save="pi3"
folder_save="${HOME}/backup/${foldername_save}"
sqldump_filename="_dump_${today}.sql"
@madeindjs
madeindjs / prepare-commit-msg.sh
Last active Nov 8, 2017 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
View prepare-commit-msg.sh
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@madeindjs
madeindjs / redmine_colors_ticket.js
Last active Feb 22, 2018
Color tickets assigned to me
View redmine_colors_ticket.js
// ==UserScript==
// @name Color Redmine Flow
// @version 1
// @grant none
// ==/UserScript==
var nameToSearch = /Rousseau/;
var unavailableColor = "GhostWhite";
var activeColor = "Gold";
var testColor = "Khaki";
You can’t perform that action at this time.