Skip to content

Instantly share code, notes, and snippets.

View magnetikonline's full-sized avatar
💡
I have an idea!

Peter Mescalchin magnetikonline

💡
I have an idea!
View GitHub Profile
@magnetikonline
magnetikonline / gist:8746669
Created February 1, 2014 01:34
Webalizer IgnoreAgent/SearchEngine rule sets conf - 2014-01
IgnoreAgent +http://www.baidu.com/search/spider.html)
IgnoreAgent ; 360Spider
IgnoreAgent ; Claritybot)
IgnoreAgent ; Google Web Preview)
IgnoreAgent ; Googlebot
IgnoreAgent www.webwombat.com.au
IgnoreAgent Aboundex/*
IgnoreAgent Apache-HttpAsyncClient/*
IgnoreAgent Apache-HttpClient/*
IgnoreAgent AppEngine-Google*
@magnetikonline
magnetikonline / README.md
Last active August 29, 2015 13:56
Create favicon.ico from PNG source using ImageMagick.

Create favicon.ico from PNG source using ImageMagick

Using a source PNG image with dimensions of 144x144, which will be our apple-touch-icon used for Apple iOS and tablet devices.

$ convert -resize 32x32 -colors 256 favicon.png favicon.ico

Markup for HTML page <head> area:

@magnetikonline
magnetikonline / gist:9497941
Last active August 29, 2015 13:57
Webalizer IgnoreAgent/SearchEngine rule sets conf - 2014-03
IgnoreAgent +http://www.baidu.com/search/spider.html)
IgnoreAgent ; 360Spider
IgnoreAgent ; Claritybot)
IgnoreAgent ; Google Web Preview)
IgnoreAgent ; Googlebot
IgnoreAgent Aboundex/*
IgnoreAgent Apache-HttpAsyncClient/*
IgnoreAgent Apache-HttpClient/*
IgnoreAgent AppEngine-Google*
IgnoreAgent Baiduspider*
@magnetikonline
magnetikonline / README.md
Last active August 29, 2015 13:57
Update WordPress database dump URL paths.

Update WordPress URL paths

PHP script that takes a mysqldump file and brute force replaces URLs into an output dump file.

Ensure to dump the source SQL database using the --skip-extended-insert switch to ensure INSERT INTO() statements don't end up on singular and very long lines, which won't help the script crunch all the replacements.

E.g.

$ mysqldump \
	-hlocalhost -uUSERNAME -p \
@magnetikonline
magnetikonline / test.php
Created March 28, 2014 03:33
Enabling PHP PCRE case insensitive searching for specific sections of your regular expression.
<?php
$testExpression = '/(?i)te(?-i)st/';
testPCRESectionOnly($testExpression,'test');
testPCRESectionOnly($testExpression,'TEst');
testPCRESectionOnly($testExpression,'teST');
testPCRESectionOnly($testExpression,'TEST');
/*
Should return:
@magnetikonline
magnetikonline / generate.php
Last active August 29, 2015 13:59
PHP generate random string with characters [0-9a-f].
<?php
function generateRandString() {
$randString = '';
while (strlen($randString) < 32) {
// generate a character between 0-9 a-f
$character = mt_rand(0,15);
if ($character > 9) $character += 39;
$randString .= chr($character + 48);
}
@magnetikonline
magnetikonline / emailcheck.php
Last active August 29, 2015 13:59
Very liberal PHP is valid email check.
<?php
function isValidEmailAddress($email) {
return (
(preg_match('/^[^\r\n\t]+@[^\r\n\t ]+\.(?i)[a-z]{2,10}$/',$email)) &&
(count($partList = explode('@',$email)) == 2) &&
(!preg_match('/\.{2}/',$partList[1]))
);
}
@magnetikonline
magnetikonline / nginx.conf
Last active August 29, 2015 14:00
SilverStripe improved Nginx configuration built upon http://doc.silverstripe.org/framework/en/installation/nginx.
location / {
try_files $uri /framework/main.php?url=$uri&$query_string;
}
error_page 404 /assets/error-404.html;
error_page 500 /assets/error-500.html;
location ^~ /assets/ {
sendfile on;
try_files $uri =404;
@magnetikonline
magnetikonline / README.md
Last active August 29, 2015 14:03
Install Windows 7 ISO to USB key.

Install Windows 7 ISO to USB key

Plug in USB key and get device name:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             110G   34G   71G  33% /
udev                  7.9G  4.0K  7.9G   1% /dev
tmpfs 1.6G 1.5M 1.6G 1% /run
@magnetikonline
magnetikonline / README.md
Last active August 29, 2015 14:05
PHP array addition examples.

PHP array addition

Example script

<?php
$first = [
	'one' => 'first',
	'two' => 'first',
	'three' => 'first'
];