Skip to content

Instantly share code, notes, and snippets.

View clemlatz's full-sized avatar

Clément Latzarus clemlatz

View GitHub Profile
@clemlatz
clemlatz / install.sh
Last active February 16, 2016 14:39
Installing capybara-webkit on Debian wheezy
# Add capybara-webkit to Gemfile in :test group
# https://github.com/thoughtbot/capybara-webkit#usage
bundle install
# If bundle install fails, manual install
sudo apt-get update
sudo apt-get upgrade
# Install liborc (version required by Qt)
# http://forums.debian.net/viewtopic.php?f=6&t=117769
@clemlatz
clemlatz / README.md
Last active December 6, 2017 13:59
puma daemon management

Puma daemon management

Install

  1. Save puma.rb file locally (eg. to ~/bin/puma.rb)
  2. Create alias alias p='~/bin/puma.rb in bash.rc

Usage

Start server

@clemlatz
clemlatz / pre-commit-eslint
Last active January 11, 2018 11:20 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/bin/bash
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [ "$STAGED_FILES" = "" ]; then
exit 0
fi
PASS=true
@clemlatz
clemlatz / convert-eps-to-jpg.sh
Created January 15, 2018 10:54
Convert EPS files to JPEG
# Remove single quote and space in file names
for f in *\'*; do mv "$f" "${f//\'/_}"; done
for f in *\ *; do mv "$f" "${f//\ /_}"; done
# Convert to PDF
echo *.eps | xargs -n1 pstopdf
# Move files to pdf folder
cd ../pdf/
mv $(echo ../eps/*.pdf) .
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
function parse_git_stash {
[[ $(git stash list 2> /dev/null | tail -n1) != "" ]] && echo "^"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)$(parse_git_stash)/"
}
PS1='\[\e[0;33m\]${HOSTNAME}\[\e[m\] \W \[\e[0;36m\]$(parse_git_branch)\[\e[m\] $ '
@clemlatz
clemlatz / redux-basics.js
Created February 6, 2018 12:31
Redux basics
const redux = require('redux');
const createStore = redux.createStore;
const initialState = {
counter: 0,
};
// Reducer
@clemlatz
clemlatz / keybindings.json
Last active May 15, 2018 10:18
VSCode config
[
{
"key": "cmd+0",
"command": "workbench.action.openLastEditorInGroup"
},
{
"key": "cmd+1",
"command": "workbench.action.openEditorAtIndex1"
},
{
@clemlatz
clemlatz / guest-sort.js
Last active September 28, 2018 07:48
Sort guests
(function() {
const getLastName = guest => {
const title = guest.querySelector('.title-nom-prenom');
const names = title.textContent.split(' ');
return names[names.length - 1];
}
const isotope = document.querySelector('#isotope-list-invites');
const guests = Array.prototype.slice.call(isotope.querySelectorAll('a'));
guests.sort((a, b) => {
const aLastName = getLastName(a);
@clemlatz
clemlatz / setup.sh
Last active August 9, 2019 00:00
Set up nginx + letsencrypt ssl on Mac OSX El Capitan
# Install nginx with brew
brew install nginx
# Install PIP
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
# Get letsencrypt
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt