Skip to content

Instantly share code, notes, and snippets.

@vdite
vdite / Redirectmatch with regEx
Created June 12, 2013 11:26
Redirectmatch some URL Parts
Redirectmatch 301 ^/song((s)|(writer))(\/){0,1}(\.htm){0,1}(l){0,1}$ http://tld/songs.html
@vdite
vdite / traffic analyser
Created June 18, 2013 13:52
ethernet packet analyser monitor network activity
tcpdump -i [interface, en0 is ethernet, en1 is wireless]
@vdite
vdite / Javascript console debugging
Created June 18, 2013 19:59
Javascript console debugging - don't use just console.log(); - it fails on IE Make sure, console is defined
if(console!="undefined"){console.log('myLog');}
@vdite
vdite / Get all POST Variables from the array
Created June 19, 2013 19:48
PHP: howto automatically create variables with the same name as key in POST array
// One more cautios way of extracting all input fields at once is:
extract( $_POST, EXTR_OVERWRITE, "form_" );
// This way all your input variables will be called $form_foo and $form_bar at least.
// Avoid doing that in the global scope - not because global is evil, but because nobody ever cleans up there.
// http://goo.gl/3Q5RV
// Thanks to Sergej Müller @wpSEO
// you know this how you are doing:
$username=$_POST["username"];
$age=$_POST["age"];
@vdite
vdite / redirect old site to new domain
Created June 27, 2013 21:09
Redirect an old domain and all the old sites to a new domain
#this redirects all your old stuff to the main site of the new domain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old-domain.com [NC]
RewriteRule ^(.*)$ http://new-domain.com/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.old-domain.com [NC]
RewriteRule ^(.*)$ http://new-domain.com/ [L,R=301]
#this redirects all your old stuff to the new domain, leaving all deep urls like before
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old-domain.com [NC]
@vdite
vdite / jQuery: Collapse iframe if empty
Created June 28, 2013 09:55
Collapse iframe if empty with jQuery
// if you are using no caching headers in your iframe sources, so you 'll always get an "filled" iframe. This does kick your layout sometimes.
// this is how to coollapse such iframes:
if($("#iframeid").contents().find("p").length) {
$('#iframeid').css('display', 'none');
}
// this is how to kill all caches in the iframe source
// <head>
// <meta http-Equiv="Cache-Control" Content="no-cache">
@vdite
vdite / Completely Remove RSS Feeds in WordPress
Created June 28, 2013 20:04
Completely Remove RSS Feeds in WordPress
<?php
// add this to yout functions.php file
// you may just want to kill all your RSS Feeds, wordpress does provide
remove_action('do_feed', 'disable_all_feeds', 1);
remove_action('do_feed_rdf', 'disable_all_feeds', 1);
remove_action('do_feed_rss', 'disable_all_feeds', 1);
remove_action('do_feed_rss2', 'disable_all_feeds', 1);
remove_action('do_feed_atom', 'disable_all_feeds', 1);
@vdite
vdite / debug php in the browser console
Created July 7, 2013 11:43
best way to debug php in the browser console
<?php
/**
* Send debug code to the Javascript console
*/
function debug_to_console($data) {
if(is_array($data) || is_object($data))
{
echo("<script>
if(console.debug!="undefined"){
console.log('PHP: ".json_encode($data)."');
@vdite
vdite / gist:6391520
Created August 30, 2013 16:13
replaces given string in a bunch of files inside an folder with php
<?php
foreach(glob('./*.html') as $filePath) {
$file_contents = file_get_contents($filePath);
$file_content_replace = preg_replace('windows','linux',$file_contents);
file_put_contents($filePath,$file_content_replace);
}
?>
@vdite
vdite / new_gist_file
Created September 9, 2013 10:06
manual loading Google Webfont
@font-face {
font-family: 'Fjalla One';
font-style: normal;
font-weight: 400;
src: local('Fjalla One'), local('FjallaOne-Regular'), url(http://themes.googleusercontent.com/static/fonts/fjallaone/
v1/rxxXUYj4oZ6Q5oDJFtEd6r3hpw3pgy2gAi-Ip7WPMi0.woff) format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;