Skip to content

Instantly share code, notes, and snippets.

@thomaspuppe
thomaspuppe / url-parser.js
Created October 24, 2013 12:51
Native JS URL Zerpflückung
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@thomaspuppe
thomaspuppe / gist:5378650
Last active February 3, 2016 12:38
git Commands

##Fetch the status from origin and ignore all local changes

git fetch --all
git reset --hard origin/master

##Change the last commit Message

git commit --amend -m "New commit message"
@thomaspuppe
thomaspuppe / gist:4593700
Last active December 11, 2015 11:28
Extract Month and Year from a datetime/timestamp coloumn
### With timestamp/integer coloumn (1354711936)
SELECT
FROM_UNIXTIME(crdate, '%Y') AS year,
FROM_UNIXTIME(crdate, '%M') AS month,
COUNT(uid) AS number
FROM `tx_campeforms_domain_model_contact`
WHERE interest LIKE "%Techniker%"
AND email NOT LIKE "%test.de%"
AND email NOT LIKE "%ondigo.de%"
@thomaspuppe
thomaspuppe / Bugs
Last active December 11, 2015 06:08
Dumme Fehler. Bitte nur einmal machen.
Cache! In allen Ebenen, samt Inhalt und Header.
=================================================
MySQL Tabellen anlegen: TYPE=InnoDB => ENGINE=InnoDB
=================================================
SITUATION: Formular. Eine Zeile soll via JS ausgeblendet werden, wenn das Feld nicht benötigt wird. Suche per parents('.selector').
FEHLER: Nachdem sich die HTML-Struktur änderte, gab es weiter oben im DOM weitere '.selector' , sodass plötzlich praktisch die ganze Seite ausgeblendet wurde.
@thomaspuppe
thomaspuppe / .htaccess
Created January 4, 2013 16:45
Redirect of a certain path in .htaccess
# Redirect auf Sitemap (extern, Weiterleitung)
RewriteRule sitemap.xml$ /index.php?eID=dd_googlesitemap [L,Redirect=permanent]
# Redirect auf Sitemap (intern, Auslieferung)
RewriteRule ^sitemap\.xml$ index.php?eID=dd_googlesitemap [L]
@thomaspuppe
thomaspuppe / php.ini
Created December 19, 2012 11:40
Error Logging bei Mittwald-Projekten
# /etc/php/php.ini
log_errors = On
error_log = /tmp/php-error.log
@thomaspuppe
thomaspuppe / .htaccess
Created November 6, 2012 11:25
.htaccess Redirect for folders, preserving subfolders
### Redirect for folders, preserving subfolders
RedirectMatch 301 ^/en/orchester/mitglieder/musiker/(.*) /en/orchestra/musician/$1
RedirectMatch 301 ^/orchester/mitglieder/musiker/(.*) /orchester/musiker/$1
@thomaspuppe
thomaspuppe / gist:4000626
Created November 2, 2012 11:49
Track Navigation Timing data from the Browser in Google Analytics
var NAMESPACE = NAMESPACE || {};
NAMESPACE.gaSpeedTrackingJsLoadStart = (new Date()).getTime();
/* All JS ... */
/* Encapsulate "use strict" to this part of the code, while others can still be unstrict. */
(function () {
"use strict";
/* Track JS Parsing time (start was set at the Beginning of the JS) */
@thomaspuppe
thomaspuppe / gist:3163220
Created July 23, 2012 11:48 — forked from madrobby/gist:3161015
detect retina support
function isRetina(){
return (('devicePixelRatio' in window && devicePixelRatio > 1) ||
('matchMedia' in window && matchMedia("(-moz-device-pixel-ratio:1.0)").matches))
}