Skip to content

Instantly share code, notes, and snippets.

View michaelbaudino's full-sized avatar

Michael Baudino michaelbaudino

View GitHub Profile
@michaelbaudino
michaelbaudino / git-in-prompt.sh
Last active August 30, 2021 08:57
Bash prompt with GIT branch and status display
### Michael Baudino <michael.baudino@alpine-lab.com>
### License: WTFPL
###
### To use this fancy prompt:
### 1. copy this file as ~/.git-in-prompt.sh
### 2. add the following line to your ~/.bashrc file:
### [[ -s "$HOME/.git-in-prompt.sh" ]] && source "$HOME/.git-in-prompt.sh"
### 3. enjoy :-)
###
@michaelbaudino
michaelbaudino / bc-in-shell.sh
Last active December 6, 2016 02:06
Bash (and probably other POSIX shells) functions and aliases to use bc directly from the prompt
### Functions to use bc from prompt
### paste this in your ~/.bashrc or ~/.bash_profile
### based on http://brettterpstra.com/2011/02/02/quick-calculations-in-bash/
# Basic functions displaying result of operations
function calc() { # Default precision used is 2
equat=$(echo ${@//[^-0-9\.\+\/\*\(\)]/ } | sed 's/[ \t]*//g')
echo -e "scale=2\n$equat\nquit\n" | bc -lq
}
function calc3() { # Default precision 3
@michaelbaudino
michaelbaudino / browser.js.coffee
Last active December 16, 2015 12:38
Implémentation Paymill (code du slide #27 de mon talk à Lyon.rb le 10/04/2013 : http://michaelbaudino.github.io/presentation-paiements).
# Initialize Paymill public API key
window.PAYMILL_PUBLIC_KEY = '8a8394c13bb2c160013bb7f6af8a1c85'
# Retrieve Paymill javascript snippet (the "bridge")
$.getScript('https://bridge.paymill.com')
# This should be called when the user validates the HTML form
paymill.createToken
number: $('#card-number').val() # required, without spaces and hyphens
exp_month: $('#card-expiry-month').val() # required
@michaelbaudino
michaelbaudino / foundation_and_overrides.css.sass
Created May 5, 2013 09:26
Zurb Foundation 4 overrides (customization) file, converted to sass syntax (originally generated by `rails g foundation:install` in scss syntax)
////
//// Foundation Variables
////
//// The default font-size is set to 100% of the browser style sheet (usually 16px)
//// for compatibility with brower-based text zoom or user-set defaults.
$base-font-size: 100% !default
//// $base-line-height is 24px while $base-font-size is 16px
// $base-line-height: 150%
@michaelbaudino
michaelbaudino / validates_timeliness.fr.yml
Last active December 18, 2015 05:59
French locale file for validates_timeliness gem (https://github.com/adzap/validates_timeliness)
fr:
errors:
messages:
invalid_date: "n'est pas un objet Date valide"
invalid_time: "n'est pas un objet Time valide"
invalid_datetime: "n'est pas un objet DateTime valide"
is_at: "doit être %{restriction}"
before: "doit être avant %{restriction}"
on_or_before: "doit être le ou avant le %{restriction}"
after: "doit être après %{restriction}"
@michaelbaudino
michaelbaudino / programme-lyonrb-2013-2014.md
Last active December 19, 2015 09:49
Programme proposé pour Lyon.rb pour l'exercice 2013-2014

Programme pour Lyon.rb (WIP)

Intro

Ce document présente ce que propose la liste composée de Camille Appert et Michael Baudino pour Lyon.rb pour l'année 2013-2014.

Meetups

Communication

@michaelbaudino
michaelbaudino / Bones (WP theme) in Sass syntax
Last active December 19, 2015 11:49
Bones Wordpress theme Scss files converted to Sass. If, like us, you want to use Bones (http://themble.com/bones) but prefer Sass syntax over Scss one, feel free to use these translated files.
This file is just to have a nicely named Gist. Do not care about it.
@michaelbaudino
michaelbaudino / rails_version_comparison.rb
Last active August 29, 2015 13:56
Rails version matching
def rails_version_matches?(requirement)
Gem::Requirement.new(requirement).satisfied_by? Gem::Version.new(::Rails::VERSION::STRING)
end
def rails_version_matches_any?(*requirements)
requirements.map{ |r| rails_version_matches?(r) }.reduce(:|)
end
def rails_version_matches_all?(*requirements)
requirements.map{ |r| rails_version_matches?(r) }.reduce(:&)
@michaelbaudino
michaelbaudino / keybase.md
Created September 23, 2014 07:23
Keybase.io

Keybase proof

I hereby claim:

  • I am michaelbaudino on github.
  • I am michaelbaudino (https://keybase.io/michaelbaudino) on keybase.
  • I have a public key whose fingerprint is 8AD2 5BE0 7CC5 861E E6DF 222C B447 ACD3 845B D9F5

To claim this, I am signing this object:

@michaelbaudino
michaelbaudino / start-docker-sync-and-wait.sh
Last active December 11, 2018 20:16
Docker Sync start script (only returns once initial sync is complete for all endpoints)
#!/bin/bash
DOCKER_SYNC_LOGFILE="/tmp/docker-sync.log"
DOCKER_SYNC_SCREEN_NAME="docker-sync"
function start_docker_sync_screen_session {
# We start `docker-sync start` twice because it often updates some images on first run and when it does,
# it exits successfully but asking for a `docker-sync clean` and then another `docker-sync start` run ¯\_(ツ)_/¯
local cmd="docker-sync clean && docker-sync start && docker-sync clean && docker-sync start"
screen -d -m -S ${DOCKER_SYNC_SCREEN_NAME} script -F ${DOCKER_SYNC_LOGFILE} bash -c "${cmd}"