Skip to content

Instantly share code, notes, and snippets.

View thibaultcha's full-sized avatar

Thibault Charbonnier thibaultcha

View GitHub Profile
@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 / 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 / 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 / brew-legacy.sh
Last active November 19, 2023 18:34
Ever wondered which of your homebrew formulas are unused legacy dependencies? Run this!
#!/bin/bash
GREEN="\033[1;32m";
RESET="\033[m";
echo "Searching for standalone formulae...";
dependencies=();
for formula in $(brew list); do
deps=(`brew uses $formula --installed | tr '\n' ' '`);
# Add the formula if it's being used by another, installed one
if [ ${#deps[@]} -lt 1 ]; then
@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
@thibaultcha
thibaultcha / npmls.markdown
Last active August 29, 2015 14:06
List npm dependencies without all the shit
@thibaultcha
thibaultcha / about.md
Last active January 23, 2022 19:08
Irssi setup

Irssi setup in 3 minutes

  1. Install irssi:
  1. Install the script manager (usefull to manage other scripts):

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 / 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
}
@thibaultcha
thibaultcha / metamethods.txt
Created November 30, 2015 19:54
Lua metamethods table
Sean Conner
http://lua-users.org/lists/lua-l/2015-04/msg00033.html
5.1 5.2 5.3 function
__add * * * a + b
__sub * * * a - b
__mul * * * a * b
__div * * * a / b
__mod * * * a % b
__pow * * * a ^ b