Skip to content

Instantly share code, notes, and snippets.

@robinflyhigh
robinflyhigh / Display Object on Browser
Last active September 29, 2015 05:47
Display Object on Browser
<?php
/*
Display Object on browser for easy reading...
*/
function print_object($obj)
{
echo "<pre>";
print_r($obj);
echo "<pre>";
@robinflyhigh
robinflyhigh / Split Long Sentence into Lines
Last active September 29, 2015 05:47
Split Long Sentence into Lines
<?php
/* Split Long Sentence into Lines/*
function getLines($content)
{
$pos = strpos($content, '.');
if($pos === false)
return $content;
else
return substr($content, 0, $pos+1);
}
@robinflyhigh
robinflyhigh / Non WWW to WWW using .htaccess
Last active September 29, 2015 06:18
Non WWW to WWW using .htaccess
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
@robinflyhigh
robinflyhigh / Set Expire Headers using .htaccess
Last active September 29, 2015 07:58
Set Expire Headers using .htaccess
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# cache.appcache needs re-requests
# in FF 3.6 (thx Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
@robinflyhigh
robinflyhigh / Enable PHP Error Reporting via .htaccess
Last active September 29, 2015 08:28
Enable PHP Error Reporting via .htaccess
php_flag display_errors on
@robinflyhigh
robinflyhigh / 301 Redirection using .htaccess
Last active September 29, 2015 12:17
301 Redirection using .htaccess
RewriteRule old.html$ new.html [R=301,L]
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
@robinflyhigh
robinflyhigh / Redirect Request to a Folder using .htaccess
Last active December 18, 2015 00:59
Redirect Request to a Folder using .htaccess
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/domain.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domain.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ domain.com/ [L]
@robinflyhigh
robinflyhigh / Load Script
Last active December 18, 2015 02:59
Load Script
<script>
function loadScript(url)
{
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.async = true;
head.appendChild(script);
}
@robinflyhigh
robinflyhigh / Get Random Color
Last active December 18, 2015 02:59
Get Random Color
<script>
function getRandomColor() {
return (
pad(getRandomInt(0, 255).toString(16), 2) +
pad(getRandomInt(0, 255).toString(16), 2) +
pad(getRandomInt(0, 255).toString(16), 2)
);
}
</script>