This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A Multi-Fallback Script Loader for jQuery | |
By Jared S. Abbott */ | |
if(typeof($) != 'function' || 'undefined'==typeof jQuery){document.write(unescape("%3Cscript src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));} | |
else if(typeof($) != 'function' || 'undefined'==typeof jQuery){document.write(unescape("%3Cscript src='http://ajax.microsoft.com/ajax/jquery/jquery-1.7.1.min.js' type='text/javascript'%3E%3C/script%3E"));} | |
else if(typeof($) != 'function' || 'undefined'==typeof jQuery){document.write(unescape("%3Cscript src='js/libs/jquery-1.7.1.min.js' type='text/javascript'%3E%3C/script%3E"));} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Want to be able to display the source code of any webpage, with line numbering? Here is a simple code snippet to do it. Just modify the url on line 2 or make a function. | |
$lines = file('http://google.com/'); | |
foreach ($lines as $line_num => $line) { | |
// loop thru each line and prepend line numbers | |
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// If you need to get the whois information for a specific domain, why not using PHP to do it? The following function take a domain name as a parameter, and then display the whois info related to the domain. | |
function whois_query($domain) { | |
// fix the domain name: | |
$domain = strtolower(trim($domain)); | |
$domain = preg_replace('/^http:\/\//i', '', $domain); | |
$domain = preg_replace('/^www\./i', '', $domain); | |
$domain = explode('/', $domain); | |
$domain = trim($domain[0]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// In order to optimize your scripts, you may definitely want to know how many amount of RAM they use on your server. This snippet will check memory and then print initial, final and peak usages. | |
echo "Initial: ".memory_get_usage()." bytes \n"; | |
/* prints | |
Initial: 361400 bytes | |
*/ | |
// let's use up some memory | |
for ($i = 0; $i < 100000; $i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Point the script to an image and get its dominant color. | |
$i = imagecreatefromjpeg("image.jpg"); | |
for ($x=0;$x<imagesx($i);$x++) { | |
for ($y=0;$y<imagesy($i);$y++) { | |
$rgb = imagecolorat($i,$x,$y); | |
$r = ($rgb >> 16) & 0xFF; | |
$g = ($rgb >> & 0xFF; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function crush($_file) { | |
$_file = preg_replace(array("/((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/","!/\*[^*]*\*+([^/][^*]*\*+)*/!"), "", $_file); /* remove comments */ | |
$_file = str_replace(array('\r\n','\r','\t','\n',' ',' ',' '), '', $_file); /* remove tabs, spaces, newlines, etc. */ | |
/* remove spaces before/after certain characters */ | |
$_file = preg_replace(array('(( )+\))','(\)( )+)'), ')', $_file); $_file = preg_replace(array('(( )+\()','(\(( )+)'), '(', $_file); | |
$_file = preg_replace(array('(( )+\})','(\}( )+)'), '}', $_file); $_file = preg_replace(array('(( )+\{)','(\{( )+)'), '{', $_file); | |
$_file = preg_replace(array('(( )+\:)','(\:( )+)'), ':', $_file); $_file = preg_replace(array('(( )+\;)','(\;( )+)'), ';', $_file); | |
$_file = preg_replace(array('(( )+\,)','(\,( )+)'), ',', $_file); return $_file; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class document { | |
public static function getElementsByClassName($name) { | |
global $xpath; | |
$nodes = array(); | |
$elements = $xpath->query(sprintf("//div[contains(@class, '%s')]", $name)); | |
foreach ($elements as $e) { | |
array_push($nodes, $e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Thiemo Mättig <http://maettig.com/> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function file_force_dl($_path) { | |
$mime = 'application/force-download'; | |
header('Pragma: public'); // required | |
header('Expires: 0'); // no cache | |
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); | |
header('Cache-Control: private',false); | |
header('Content-Type: '.$mime); | |
header('Content-Disposition: attachment; filename="'.basename($_path).'"'); | |
header('Content-Transfer-Encoding: binary'); | |
header('Connection: close'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
.countDown { | |
font-family:"Helvetica Neue",Helvetica,Calibri,"Liberation Sans",Arial,sans-serif; | |
font-weight:300; | |
letter-spacing:0.5px; | |
text-align:center; | |
} | |
</style> | |
<script type="text/javascript"> | |
currentDate = new Date(); |
OlderNewer