Skip to content

Instantly share code, notes, and snippets.

View czj's full-sized avatar

Clément Joubert czj

View GitHub Profile
set -x BROWSER "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
set -x EDITOR "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -w"
set -x RUBY_CONFIGURE_OPTS "--with-jemalloc"
status --is-interactive; and source (rbenv init -|psub)
alias atom="/Applications/Atom.app/Contents/Resources/app/atom.sh"
alias buuc="brew update; and brew upgrade --cleanup"
alias ddb="make download_db"
alias df='df -h'
@czj
czj / crontab.sh
Last active January 15, 2017 18:22
Running Rails 5.0.1 rake tasks without depreciation messages in cron
# This triple redirection allows filtering STDERR by removing depreciation messages
# The second grep allows removing empty lines (which might trigger an email on some server)
cd /home/appname/www/current && (RAILS_ENV=production bundle exec rake myapp:mytask 3>&1 1>&2 2>&3 | grep -v 'is deprecated' ) 3>&1 1>&2 2>&3 | grep -v ''
# You can also log STDOUT to a log file
cd /home/appname/www/current && ((RAILS_ENV=production bundle exec rake myapp:mytask 3>&1 1>&2 2>&3 | grep -v 'is deprecated' ) 3>&1 1>&2 2>&3 | grep -v '') >> /home/appname/www/shared/log/taskoutput.log
@czj
czj / ua.txt
Created March 9, 2017 15:19
Facebook browser's weird iOS User Agent
Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13F69 [FBAN/FBIOS;FBAV/60.0.0.37.141;FBBV/34183777;FBRV/34183777;FBDV/iPhone8,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/9.3.2;FBSS/2;FBCR/Telekom.de;FBID/phone;FBLC/de_DE;FBOP/5]
@czj
czj / french_popular_words.js
Last active March 23, 2017 12:20
~ 2000 most popular french language words (noums, adjectives, verbs)
@czj
czj / Compte-rendus.md
Last active April 3, 2017 08:51
Rénovation de notre quartier : comptes rendus du travail de janvier à mars
@czj
czj / ydl.sh
Last active September 11, 2018 16:20
Download any YouTube video, channel or playlist using youtube-dl
#!/usr/bin/env bash
# Download a file from a given url
if [ -z "$1" ]; then
echo "Download a video."
echo "Usage: ydl \"url\""
else
youtube-dl --get-filename -o '%(title)s.%(ext)s' --restrict-filenames --yes-playlist --no-mark-watched --all-formats -f 'best[ext=mp4]/best' "$1"
fi
@czj
czj / fix.fish
Created June 18, 2017 16:04
Fix for rbenv integration for fish shell
# 2017-06-06 : FIX RBENV / FISH
if not command -s rbenv > /dev/null
echo "rbenv: command not found. See https://github.com/rbenv/rbenv"
exit 1
end
set -l rbenv_root ''
if test -z "$RBENV_ROOT"
set rbenv_root "$HOME/.rbenv"
#!/usr/bin/env ruby
if `brew --version`.include? 'Homebrew'
puts "Homebrew already installed."
else
puts "Installing Homebrew ..."
`/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
end
`brew upgrade`
@czj
czj / simple_form.rb
Last active February 19, 2018 14:29
Bootstrap 4.0 compatible SimpleForm initializer
# frozen_string_literal: true
# Bootstrap 4 specific
# https://github.com/plataformatec/simple_form/pull/1476
SimpleForm::Inputs::Base.prepend(Module.new {
def merge_wrapper_options(options, wrapper_options)
if wrapper_options&.key?(:error_class)
wrapper_options = wrapper_options.dup
error_class = wrapper_options.delete(:error_class)
wrapper_options[:class] = "#{wrapper_options[:class]} #{error_class}" if has_errors?
@czj
czj / fake_name_generator.rb
Created June 9, 2018 19:44
Fake name generator (french/France)
#!/usr/bin/env ruby
require "json"
1000.times do
json = `curl --silent --insecure "https://api.namefake.com/french-france/random/"`
data = JSON.parse(json)
puts data["name"]
end