Skip to content

Instantly share code, notes, and snippets.

View ksafranski's full-sized avatar

Kent Safranski ksafranski

View GitHub Profile
@ksafranski
ksafranski / getScript-w-cache.js
Created June 14, 2012 13:02
Replacement for the jQuery $.getScript function with caching
$.getScript = function(url, callback, cache){
$.ajax({
url: url,
dataType: 'script',
success: callback,
cache: cache
});
};
@ksafranski
ksafranski / JSON_PHP_Encapsulation.php
Created June 16, 2012 02:50
Encapsulate JSON in PHP
/*
* This script allows saving & retrieval of JSON data in .php files by
* encapsulating in a <?php/*| ... |*/?> closure, preventing them from
* being accessed via URL.
*/
//////////////////////////////////////////////////////////////////////
// Get JSON
/////////////////////////////////////////////////////////////////////
@ksafranski
ksafranski / CSS-Self-Clear.css
Created June 21, 2012 13:05
Easy self-clear for floats
/* clearing floats normal browsers */
.group:after {
content: "";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
/* clearing floats IE6 */
@ksafranski
ksafranski / Common-Currency.json
Last active April 22, 2024 15:16
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@ksafranski
ksafranski / US-States.json
Created June 22, 2012 17:14
US States in JSON
{
"AL": {
"count": "0",
"name": "Alabama",
"abbr": "AL"
},
"AK": {
"count": "1",
"name": "Alaska",
"abbr": "AK"
@ksafranski
ksafranski / GetIPAddress.php
Created June 29, 2012 21:25
Reliable method for getting visitor IP Address
function getIP(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
$ip=$_SERVER['HTTP_CLIENT_IP'];
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{ $ip=$_SERVER['REMOTE_ADDR']; }
return $ip;
}
@ksafranski
ksafranski / jquery.rotator.js
Created July 17, 2012 15:53
Simple jQuery Rotator with all the goodies
/*
*
* Another fine bit of code by Kent Safranski < http://www.fluidbyte.net >
*
* HTML:
* <ul id="banner">
* <li>Stuff</li>
* ...
* </ul>
*
@ksafranski
ksafranski / jquery.autocomplete.js
Created August 9, 2012 21:04
Simple jQuery Autocomplete plugin
/*
*
* Simple Autocomplete Plugin
* @author - Kent Safranski - http://www.fluidbyte.net
*
* HTML:
* --------------------------------------------------------------------
* <input class="autocomplete" data-src="path/to/processor.php" />
*
* CSS:
@ksafranski
ksafranski / DumGrid.css
Created August 14, 2012 20:27
DumGrid For Responsive Inline-Block Grid Layout
/*
*
* Inline-Block CSS Responsive Grid System
*
* <!-- 2 Column with 10% Gutter -->
* <div class="grid column-45 gutter-10"></div>
* <div class="grid column-45"></div>
*
* <!-- 3 Column with 5% Gutter -->
* <div class="grid column-30 gutter-5"></div>
@ksafranski
ksafranski / include.js
Created October 9, 2012 15:36
Simple JavaScript Include Function
/*
* Simple JS Include Function
* Format: include({array_files},{callback});
* Example: include(['script1.js','script2.js'],function(){ alert('Loaded!'); });
*/
function include(array, callback) {
var loader = function (src, handler) {
var script = document.createElement("script");
script.src = src;