Skip to content

Instantly share code, notes, and snippets.

@davidderus
davidderus / application_policy.rb
Last active October 26, 2016 11:47
Non-Standard ApplicationPolicy for Pundit
# Handling Application rights thanks to roles
#
# A direct adaptation of http://through-voidness.blogspot.fr/2013/10/advanced-rails-4-authorization-with.html
# but much more performance-wise
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
raise Pundit::NotAuthorizedError, 'Must be signed in.' unless user
@user = user

Keybase proof

I hereby claim:

  • I am davidderus on github.
  • I am davidderus (https://keybase.io/davidderus) on keybase.
  • I have a public key ASAxJBJuCOjK7LuL3cC_5dpQ2-my4iYn7VLxyyyrcEoVhwo

To claim this, I am signing this object:

@davidderus
davidderus / dtdns-updater.sh
Last active July 21, 2016 15:52
Updates a DtDNS Hostname with the current device public IP
#!/bin/bash
# Updates a DtDNS Hostname with the current device public IP.
# You may run this script via an hourly CRON (DtDNS propagation is around 15min so a shorter rerun time is useless).
#
# Author: David Dérus
# Version: 1.1.3
# Config
HOSTNAME='MYHOSTNAME'
@davidderus
davidderus / .dockerignore
Last active March 3, 2024 10:15
Docker + Rails + Puma + Postgres + Nginx
.git
.gitignore
/doc
.yardoc
coverage
jsdoc
/tmp
/log
Dockerfile
Dockerfile.prod
@davidderus
davidderus / dns.zsh
Last active November 23, 2021 21:08
DNS Response Time Checker
#!/bin/zsh -
#===============================================================================
#
# FILE: dns-tests.zsh
#
# USAGE: ./dns-tests.sh google.fr
#
# DESCRIPTION: DNS Response Time Checker
#