Skip to content

Instantly share code, notes, and snippets.

View floriandejonckheere's full-sized avatar

Florian Dejonckheere floriandejonckheere

View GitHub Profile
@floriandejonckheere
floriandejonckheere / renew-certs.cron
Created October 5, 2016 14:42
Renew Let's Encrypt certificates using acme-tiny
# crontab entry
0 0 1 * * /etc/ssl/acme/renew_certs.sh 2>&1 | tee -a /var/log/acme.log
@floriandejonckheere
floriandejonckheere / view.html.erb
Created August 13, 2016 09:59
Call byebug in a view using the controller's context
<% controller.send :byebug %>
@floriandejonckheere
floriandejonckheere / doorkeeper.rb
Created August 13, 2016 09:36
Allow Devise redirection to Doorkeeper authorization
# config/initializers/doorkeeper.rb
Doorkeeper.configure do
resource_owner_authenticator do
# fail "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"
# Put your resource owner authentication logic here.
if signed_in?
current_user
else
# redirect to /oauth/authorize?... after signin
session[:user_return_to] = request.fullpath
@floriandejonckheere
floriandejonckheere / tictoc.js
Last active July 7, 2016 07:14
Measure JavaScript execution
function tic(n){t[n]=(new Date).getTime()}function toc(n){console.log(n+': '+((new Date).getTime()-t[n])+'ms')}t=[]
@floriandejonckheere
floriandejonckheere / grape_token_auth.rb
Last active May 30, 2016 11:26
Grape token auth documented initializer
GrapeTokenAuth.setup! do |config|
## The time span that GTA tokens are valid for
# config.token_lifespan = 2.weeks
## The timeframe in which a subsequent requests
## are considered "batch" requests
# config.batch_request_buffer_throttle = 5.seconds
## Whether new auth headers / tokens are created on each request
# config.change_headers_on_each_request = true
@floriandejonckheere
floriandejonckheere / backup.sh
Last active May 27, 2016 08:50
Simple backup script
#!/bin/bash
# don't do anything
DRYRUN=0
# add trailing slash
BACKUPDIR="/backup/files/"
# generate final bzipped tarball, uses pbzip2
TARBALL=/backup/backup.tar.bz2
@floriandejonckheere
floriandejonckheere / pre-push
Last active June 28, 2022 13:42
RDoc git hook to GitHub Pages
#!/usr/bin/sh
git checkout gh-pages
git merge master
rake rdoc
git add -f html
git commit -m "Generate RDoc for commit $(git rev-parse master)"
git push --no-verify
git checkout master
@floriandejonckheere
floriandejonckheere / scenebuilder.desktop
Created February 8, 2016 09:04
JavaFX Scene Builder
[Desktop Entry]
Type=Application
Name=JavaFX Scene Builder
Comment=Visual layout tool that lets users quickly design Java application user interfaces
Icon=java
TryExec=scenebuilder
Exec=scenebuilder
Terminal=false
@floriandejonckheere
floriandejonckheere / parse.rb
Created February 3, 2016 13:22
Parse ddrescue's mapfile and list bad regions and their sizes
#!/usr/bin/env ruby
#
# parse_ddrescue_log - show bad sectors and their sizes
#
require 'filesize'
unless ARGV.count == 1
puts "Usage: #{__FILE__} MAPFILE"
exit 1
@floriandejonckheere
floriandejonckheere / gist:df20cae37c2bb0befa6f
Created January 12, 2016 14:47
MATE volume change increment
dconf key: /org/mate/settings-daemon/plugins/media-keys/volume-step