Skip to content

Instantly share code, notes, and snippets.

View thibaultcha's full-sized avatar
🕉️

Thibault Charbonnier thibaultcha

🕉️
View GitHub Profile
@thibaultcha
thibaultcha / grid.less
Last active December 30, 2015 02:19
Responsive grid layout system with a LESS script. This is a clone of http://zurb.com/playground/css-grid-builder Demo available here http://jsfiddle.net/thibaultCha/kKBZT/ Customize @nbcols, @Colwidth and @gutterwidth
* {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
}
.container {
position: relative;
width: 590px;
margin: 0 auto;
@thibaultcha
thibaultcha / emojify.js
Created September 23, 2013 08:41
Converts strings as ':heart:' to <span> elements with the equivalent emoji image in background. See http://www.emoji-cheat-sheet.com/
function emojify (domElement, ressource, size) {
var element = document.getElementById(domElement)
var matching = element.innerHTML.match(/:[a-z0-9+_-]+:/g)
for (var i = matching.length - 1; i >= 0; i--) {
element.innerHTML = element.innerHTML.replace(matching[i], '<span style="display:inline-block;background-image:url('+ressource+matching[i].slice(1, matching[i].length - 1)+'.png);background-size:'+size+'px;height:'+size+'px;width:'+size+'px;vertical-align:-10%;"></span>')
}
}
@thibaultcha
thibaultcha / Coffee.sh
Last active December 19, 2015 18:28
Bash function to prevent your Mac from sleeping for X hours. Put it in your .bash_profile and call it maybe.
function coffee() {
hours=${1}
time=$(( $hours*3600 ))
echo "Will prevent sleeping for $hours hours."
$(caffeinate -u -t "$time")
}
@thibaultcha
thibaultcha / fortunecow.sh
Created April 8, 2015 02:25
Prints a random fortune in a random cow template
# Add this to your .profile
# $ fortunecow
function fortunecow() {
files=`cowsay -l | cut -d \: -f 2 | xargs echo`
arr=("${(s/ /)files}")
file=$arr[$RANDOM%$#arr+1]
fortune | cowsay -f $file
}

Keybase proof

I hereby claim:

  • I am thibaultcha on github.
  • I am thibaultcha (https://keybase.io/thibaultcha) on keybase.
  • I have a public key whose fingerprint is C646 C91F 25DF 3CEA 6E44 F93C E1D4 1D2D DFA3 B99D

To claim this, I am signing this object:

@thibaultcha
thibaultcha / npmls.markdown
Last active August 29, 2015 14:06
List npm dependencies without all the shit
@thibaultcha
thibaultcha / pre-commit
Created May 9, 2014 04:30
Used to detect a forbidden pattern that you don't want to commit
FILES_PATTERN='\.(js|coffee)(\..+)?$'
FORBIDDEN='console.log'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && echo "COMMIT REJECTED. Found $FORBIDDEN references. Please remove them before commiting" && exit 1