Skip to content

Instantly share code, notes, and snippets.

Claudel Sylvain rivsc

Block or report user

Report or block rivsc

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
rivsc / calcul_cle_rib.js
Created Oct 25, 2019
Calcul clé rib javascript
View calcul_cle_rib.js
// Fonction de calcul de la clé RIB en javascript
function cle_rib(code_banque, code_guichet, numero_compte){
var mapping = ["", "AJ", "BKS", "CLT", "DMU", "ENV", "FOW", "GPX", "HQY", "IRZ"];
var cherche_lettre = new RegExp(/[A-Z]/g);
var res = numero_compte.match(cherche_lettre);
if(res.length > 0){
mapping.forEach(function(str, i){
numero_compte = numero_compte.replace(new RegExp(ch,"g"), i);
rivsc / calcul_cle_rib.rb
Last active Oct 25, 2019
Méthode de calcul de la clé RIB (relevé d'identité bancaire)
View calcul_cle_rib.rb
# Methode de calcul de la clé RIB (relevé d'identité bancaire)
# le calcul vient de wikipedia fr
def cle_rib(code_banque, code_guichet, numero_compte)
mapping = ["", "AJ", "BKS", "CLT", "DMU", "ENV", "FOW", "GPX", "HQY", "IRZ"]
numero_compte.scan(/[A-Z]/).each do |ch|
mapping.each_with_index do |str, i|
if str.include?(ch)
numero_compte = numero_compte.gsub(ch, i.to_s)
rivsc / hash
Created Jun 14, 2017
Hash syntaxe
View hash
# Clé integer
2.3.3 :054 > { 4 => 'truc' }
=> {4=>"truc"}
2.3.3 :055 > { 4: 'truc' }
SyntaxError: (irb):55: syntax error
# Clé string
2.3.3 :061 > { 'cle': 'truc' }['cle']
rivsc / photoflash.rb
Last active Sep 13, 2018
Raspberrypi with custom flash light
View photoflash.rb
#!/usr/bin/env ruby
# @rivsc /
require 'rpi_gpio'
PIN_NUM = 12
RPi::GPIO.set_numbering :board
RPi::GPIO.setup PIN_NUM, :as => :output
View gist:d25aa3bec65ec9166cb7543f56182a1f
require 'Benchmark'
def inject_method(arr)
arr.inject( { |a, e| a[e] += 1 ; a }
def each_wo_method(arr)
arr.each_with_object( { |e, a| a[e] += 1 }
View gist:71481becaeb7ff2a5b95
class Test < ActiveRecord::Base
belongs_to :bidule
has_many :truc
rivsc / prawn_rollback_test.rb
Created Nov 14, 2011
Prawn #rollback method is broken
View prawn_rollback_test.rb
require 'rubygems'
require 'prawn'
Prawn::Document.generate("make_a_broken.pdf") do |pdf|
pdf.font_size 12
pdf.move_down 20
pdf.font "Helvetica"
# We use the rollback method so the text in this block should not be displayed
pdf.transaction do
You can’t perform that action at this time.