Skip to content

Instantly share code, notes, and snippets.

View johanbove's full-sized avatar
💭
Semper meliorem facio

Johan Bové johanbove

💭
Semper meliorem facio
View GitHub Profile
@johanbove
johanbove / contributing.markdown
Created July 14, 2015 13:38
How to contribute to Git projects

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D
@johanbove
johanbove / dateformat_wtf.js
Created July 15, 2015 13:23
Formatting a data to dd.mm.yy with JavaScript
var today = new Date(),
formatted = ("0" + today.getDate()).slice(-2) + "." + ("0" + (parseInt(today.getMonth(), 10) + 1)).slice(-2) + "." + (today.getYear().toString()).slice(-2);
console.log("Today is", formatted);
@johanbove
johanbove / post.sh
Last active August 29, 2015 14:25 — forked from metaskills/gist:6414713
Jekyll tasks/post to help create a new post.
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Usage: provide a title argument."
exit -1
else
title="$@"
fi
d=$(date +"%Y-%m-%d")
@johanbove
johanbove / acceptlanguage_htaccess
Last active September 4, 2015 07:53
htaccess accept-language redirect
<IfModule mod_rewrite.c>
RewriteEngine On
# All others go to the English version
RewriteCond %{HTTP:Accept-Language} !^de [NC]
RewriteCond %{REQUEST_URI} !\.(ico|jpg|gif|png|css|js|txt|svg|pdf)$
RewriteCond %{REQUEST_URI} !^/de/?.* [NC]
RewriteCond %{REQUEST_URI} !^/en/?.* [NC]
RewriteRule ^(.*)$ /en/$1 [R=301,L]
@johanbove
johanbove / dateAxis.html
Created August 17, 2015 07:37
Merge conflict jqplot dateAxis.html
<html>
<head>
<title>Date Axis</title>
<!-- JQuery dependence -->
<script src="../../../dist/core/jquery.min.js"></script>
<script src="../../../dist/core/jquery.jqplot.min.js"></script>
<!-- Axes -->
<script src="../../../dist/plugins/axis/jqplot.dateAxisRenderer.min.js"></script>
@johanbove
johanbove / jsleadingzeroes.js
Created August 21, 2015 11:38
JavaScript leading zeroes to date
// @see http://stackoverflow.com/a/3605248
var MyDate = new Date();
var MyDateString;
MyDate.setDate(MyDate.getDate() + 20);
MyDateString = ('0' + MyDate.getDate()).slice(-2) + '/'
+ ('0' + (MyDate.getMonth()+1)).slice(-2) + '/'
+ MyDate.getFullYear();
@johanbove
johanbove / sometimeago.js
Created August 25, 2015 13:13
Two hours ago in JavaScript
var twohoursago = new Date(new Date().setHours(new Date().getHours() - 2));
@johanbove
johanbove / .htaccess
Last active September 5, 2015 17:17
Poor man's mod_deflate if your web host does not support mod_deflate but allows PHP
# Cache-Control header 604800 = 1 week in seconds
<FilesMatch "\.(jpg)">
Header set Cache-Control "max-age=604800, must-revalidate"
</FilesMatch>
<FilesMatch "\.(css)">
Header set Content-Type "text/css"
ForceType application/x-httpd-php
php_value auto_prepend_file "../gzip.php"
</FilesMatch>
@johanbove
johanbove / analyseBreakinAttempts.sh
Last active September 19, 2015 15:31 — forked from pklaus/analyseBreakinAttempts.sh
A script that analyses the log files /var/log/auth.log* for illegal break-in attempts and writes all output to $logdir – Check http://blog.philippklaus.de/2010/02/analyse-illegal-ssh-login-attempts/
#!/bin/bash
# This script analyses the log files /var/log/auth.log* for
# illegal break-in attempts and writes all output to $logdir.
# <http://blog.philippklaus.de/2010/02/analyse-illegal-ssh-login-attempts/#comment-12211>
# inspired by <http://goo.gl/QMOhiU>
# and <http://filipivianna.blogspot.com/2009/10/checking-authlog-for-ssh-brute-force.html>
logbasedir=~/logs
@johanbove
johanbove / .htaccess
Last active September 22, 2015 14:15
Rewrite URLS for missing files and permanent links to files
# Forward a "broken" file link
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^files/(.*)-Project-Sustainica_brochure.pdf$ /en/brochure.pdf [L]
# Forward permalinks to files to their changing physical targets
RewriteRule ^en/brochure.pdf /files/20150914-Project-Sustainica_brochure.pdf [L]