Skip to content

Instantly share code, notes, and snippets.

View ajaegers's full-sized avatar

Arnaud JAEGERS ajaegers

View GitHub Profile
@ajaegers
ajaegers / git-up.sh
Last active August 28, 2018 13:58
Simple way to get all your local Git branches up to date
#!/bin/bash
# Simple way to get all your local branches up to date
# Ps: Add this to your .bash_profile or other file as a global helper
function _gitup(){
branches=`git branch`;
current_branch=null;
git_status=`git status -s`;
has_stashed=false;
@ajaegers
ajaegers / MyHelpers.gs
Created March 1, 2017 21:19
My usefull Google Sheets macros
/**
* A special function that runs when the spreadsheet is open, used to add a
* custom menu to the spreadsheet.
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [
{name: "Unquote.li / Generate mysql insert on update from selection", functionName: "unquoteGenMySqlInsert_"}
];
spreadsheet.addMenu('MyHelpers', menuItems);
@ajaegers
ajaegers / vanilla.js
Created December 9, 2016 15:16
Javascript Vanilla functions
function hasClass(el, className) {
return el.classList ? el.classList.contains(className) : new RegExp('\\b' + className + '\\b').test(el.className);
}
function addClass(el, className) {
if (el.classList) el.classList.add(className);
else if (!hasClass(el, className)) el.className += ' ' + className;
}
function removeClass(el, className) {
@ajaegers
ajaegers / app.js
Created December 9, 2016 15:14
Javascript template / Basic module pattern
/**
* Global module
* @source https://addyosmani.com/resources/essentialjsdesignpatterns/book/
*/
var App = (function () {
// Module object
var module = {},
privateVariable = "Hello World";
@ajaegers
ajaegers / certbot-renew
Last active December 2, 2021 23:11
Simple Certbot (Let's Encrypt) script for auto-renewal certificates
# Put this file in folder /etc/cron.d/
MAILTO="debug@example.com"
0 1 * * * root /usr/local/sbin/certbot-renew.sh
@ajaegers
ajaegers / regex-tld-domain.js
Created February 1, 2016 15:10
Regex to match a TLD domain
/**
* Simple regex to match domain even with new tlds and xn-- (internationnal domain names)
* @link tld list from http://data.iana.org/TLD/tlds-alpha-by-domain.txt sorted by extension length
*/
var re = /(([a-z0-9-_\.]*)\.([a-z0-9-_]+)\.(XN--VERMGENSBERATUNG-PWB|XN--VERMGENSBERATER-CTB|XN--CLCHC0EA0B2G2A9GCD|TRAVELERSINSURANCE|XN--MGBERP4A5D4AR|XN--XKC2DL3A5EE0H|XN--XKC2AL3HYE2A|XN--KCRX77D1X4A|XN--MGBC0A9AZCG|SANDVIKCOROMANT|XN--I1B6B1A6A2E|XN--NQV7FS00EMA|XN--MGBA3A4F16A|XN--LGBBAT1AD8J|XN--MGBX4CD0AB|XN--MGBA3A3EJT|XN--FIQ228C5HS|XN--MGBBH1A71E|XN--B4W605FERD|XN--MGBAAM7A8H|XN--MGBAYH7GPA|XN--MGBB9FBPOB|XN--JLQ61U9W7B|CANCERRESEARCH|WEATHERCHANNEL|XN--6QQ986B3XL|XN--YGBI2AMMX|INTERNATIONAL|XN--FZC2C9E2C|LIFEINSURANCE|SPREADBETTING|XN--YFRO4I67O|XN--ECKVDTC9D|XN--FPCRJ9C3D|XN--MGBT3DHD|XN--QCKA1PMC|XN--3E0B707E|XN--MK1BU44C|XN--80ASEHDB|VERSICHERUNG|XN--NGBC5AZD|XN--NGBE9E0A|CONSTRUCTION|XN--OGBPF8FL|PAMPEREDCHEF|SCHOLARSHIPS|XN--MGB9AWBF|XN--MGBAB2BD|XN--MGBPL2FH|XN--80ADXHKS|XN--42C2D9A|XN--G2XX48C|XN
@ajaegers
ajaegers / style-animation-rainbow.css
Created December 10, 2015 10:35
Css animation rainbow effect based on rotating hue colors
/**
* Found in http://mapbox.com footer (hover robot)
*/
.element:hover {
-webkit-animation: rainbow 4s steps(36) infinite;
}
@-webkit-keyframes rainbow {
from { -webkit-filter:hue-rotate(10deg); }
to { -webkit-filter:hue-rotate(360deg); }
@ajaegers
ajaegers / command.sh
Created November 26, 2015 15:10
Bash create file and insert multiline content
#!/bin/bash
cat <<EOF > result.txt
Content 1
Content 2
Content 3
Content 4
EOF
@ajaegers
ajaegers / .htaccess
Created October 11, 2015 14:50
Htaccess alias subdomain redirection in document root subfolder
# SECTION BEGIN SubDomainOnFolder
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(blog|preprod)\.
RewriteCond %{REQUEST_URI} !^/(blog|preprod)/
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^(.*)$ %1/$1 [L]
# SECTION END SubDomainOnFolder
@ajaegers
ajaegers / form-input-file.html
Created August 25, 2015 13:00
Html input file for mobile devices via capture attribute
<!-- as seen on http://openweb.eu.org/articles/html-media-capture -->
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" accept="image/*" capture />
<input type="file" name="video" accept="video/*" capture />
<input type="submit" value="Upload" />
</form>