Skip to content

Instantly share code, notes, and snippets.

View nahakiole's full-sized avatar

Robin Glauser nahakiole

View GitHub Profile
@nahakiole
nahakiole / Force Domain redirection
Last active August 29, 2015 14:04
Force a domain redirection with .htaccess file.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !(robinglauser.ch)$ [NC]
RewriteRule ^(.*)$ http://www.robinglauser.ch/$1 [L,R=301]
@nahakiole
nahakiole / useragent.php
Last active April 2, 2018 07:43
Check user agent for curl or wget
<?php
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/(curl|wget)/i", $_SERVER['HTTP_USER_AGENT'])) {
/*
Request is made with curl or wget (Or with modified user agent header)
*/
}
//Regular request
@nahakiole
nahakiole / minimal.php
Created August 6, 2014 06:55
Contrexx Minimal Mode Template File
<?php
require_once dirname(__FILE__) . '/core/Core/init.php';
/**
* If you activate debugging here, it will be activated for all normal usage
* (front- and backend).
*/
//\DBG::activate(DBG_PHP);
bootbox.dialog({
title: "That html",
message: '<img src="images/bootstrap_logo.png" width="100px"/><br/> You can also use <b>html</b>'
});
bootbox.dialog({
title: "This is a form in a modal.",
message: '<div class="row"> ' +
'<div class="col-md-12"> ' +
'<form class="form-horizontal"> ' +
'<div class="form-group"> ' +
'<label class="col-md-4 control-label" for="name">Name</label> ' +
'<div class="col-md-4"> ' +
'<input id="name" name="name" type="text" placeholder="Your name" class="form-control input-md"> ' +
'<span class="help-block">Here goes your name</span> </div> ' +
@nahakiole
nahakiole / for.sh
Created September 15, 2014 11:49
Create Dummy Images
for i in {101..300}; do cp Image.jpg Image$i.jpg; done
@nahakiole
nahakiole / fullpatch.sh
Last active August 29, 2015 14:06
Create a patch with the full files from a revision
function createSVNPatch {
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit
fi
svn log -v -r$1 | awk '/\//{print $2}' | sed ""s/$(svn info | grep "Relative" | grep --only-matching -E "/.*" | cut -c 1- | sed -e 's/\//\\\//g')//g"" | cut -c 2- | while read x ; do mkdir -p /tmp/$1/$(echo $x | rev | cut -d'/' -f2- | rev); svn cat -r32804 $x > /tmp/$1/$x ; done && cd /tmp/$1 && zip ~/$1.zip * && cd -
}
@nahakiole
nahakiole / vhost.conf
Last active August 29, 2015 14:07
Dynamic Virtual Host Configuration
<VirtualHost *>
UseCanonicalName Off
ServerAlias *
VirtualDocumentRoot /home/robin/Web/%0
VirtualScriptAlias /home/robin/Web/%0
<Directory /home/robin/Web/>
Options Indexes FollowSymLinks
AllowOverride All
@nahakiole
nahakiole / maths.sh
Created October 2, 2014 15:55
Add all numbers from a file seperated by line break
cat file | grep -Eo "[0-9]+" | tr '\n' '+' | rev | cut -c 2- | rev | bc
@nahakiole
nahakiole / unzipper.desktop
Created October 12, 2014 16:02
A 1 click un-zipper for archives which uses file-roller.
[Desktop Entry]
Name=Unzipper
Type=Application
Exec=file-roller -h %U
Terminal=false
Icon=file-roller
MimeType=application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-alz;application/x-ar;application/x-arj;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/x-deb;application/x-ear;application/x-ms-dos-executable;application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-java-archive;application/x-lha;application/x-lhz;application/x-lrzip;application/x-lrzip-compressed-tar;application/x-lzip;application/x-lzip-compressed-tar;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lzop-compressed-tar;application/x-ms-wim;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-rzip;applica