This file contains 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 getMiddleRange(min,max,limit,type) | |
{ | |
--limit; | |
var new_num | |
var data = ''; | |
for(var x=0; x<=limit; x++) | |
{ | |
var new_num = Math.ceil((max - min) / limit); | |
new_num = min + (new_num * x); | |
if(x==0){new_num = min;} |
This file contains 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 | |
// from http://www.if-not-true-then-false.com/2010/php-class-for-coloring-php-command-line-cli-scripts-output-php-output-colorizing-using-bash-shell-colors/ | |
class Colors { | |
private $foreground_colors = array(); | |
private $background_colors = array(); | |
public function __construct() { | |
// Set up shell colors | |
$this->foreground_colors['black'] = '0;30'; | |
$this->foreground_colors['dark_gray'] = '1;30'; |
This file contains 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
#!/bin/bash | |
spinner() | |
{ | |
local pid=$1 | |
local delay=0.4 | |
local spinstr='|/-\' | |
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do | |
local temp=${spinstr#?} | |
printf " [%c] " "$spinstr" | |
local spinstr=$temp${spinstr%"$temp"} |
This file contains 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 | |
function addOrdinalNumberSuffix($num) { | |
if (!in_array(($num % 100),array(11,12,13))){ | |
switch ($num % 10) { | |
// Handle 1st, 2nd, 3rd | |
case 1: return $num.'st'; | |
case 2: return $num.'nd'; | |
case 3: return $num.'rd'; | |
} | |
} |
This file contains 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 | |
function spreadAmount($amount,$qty) | |
{ | |
if($amount % $qty === 0) | |
{ | |
$start = $amount / $qty; | |
$last = $start; | |
} | |
else | |
{ |
This file contains 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 | |
function ordinal($cdnl){ | |
$test_c = abs($cdnl) % 10; | |
$ext = ((abs($cdnl) %100 < 21 && abs($cdnl) %100 > 4) ? 'th' | |
: (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1) | |
? 'th' : 'st' : 'nd' : 'rd' : 'th')); | |
return $cdnl.$ext; | |
} | |
for($i=1;$i<100;$i++){ | |
echo ordinal($i); |
This file contains 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
// HTML: | |
// <h1 id="anchor">Lorem Ipsum</h1> | |
// <p><a href="#anchor" class="topLink">Back to Top</a></p> | |
$(document).ready(function() { | |
$("a.topLink").click(function() { | |
$("html, body").animate({ | |
scrollTop: $($(this).attr("href")).offset().top + "px" |
This file contains 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
var loading = false; | |
$(window).scroll(function(){ | |
if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){ | |
if(loading == false){ | |
loading = true; | |
$('#loadingbar').css("display","block"); | |
$.get("load.php?start="+$('#loaded_max').val(), function(loaded){ | |
$('body').append(loaded); | |
$('#loaded_max').val(parseInt($('#loaded_max').val())+50); | |
$('#loadingbar').css("display","none"); |
This file contains 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 | |
// Global Variables | |
$image_dir = "$_SERVER[DOCUMENT_ROOT]/examples/imgs"; // directory on server | |
$image_relative_path = '/examples/imgs'; // path to images relative to script | |
$file_types = array('jpg','jpeg','gif','png'); | |
$image_time = '4000'; // seconds each image will display (4000 = 4 seconds) | |
if($handle = opendir($image_dir)) { | |
while (false !== ($file = readdir($handle))) { | |
if ($file != "." && $file != "..") { |
This file contains 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
DROP TABLE IF EXISTS `onix_code_list`; | |
CREATE TABLE `onix_code_list` ( | |
`list_id` int(11) unsigned NOT NULL, | |
`values` varchar(20) DEFAULT NULL, | |
`name` varchar(100) DEFAULT '', | |
`notes` text, | |
`revision` int(11) unsigned DEFAULT NULL, | |
KEY `list_id` (`list_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
OlderNewer