Skip to content

Instantly share code, notes, and snippets.

View krciga22's full-sized avatar

Andrew Forster krciga22

View GitHub Profile
@krciga22
krciga22 / rand-key-size
Created May 18, 2015 02:29
Generate a random key of N size
<?PHP
// Generate a random key of N size
$keySize = 256;
$key = bin2hex(openssl_random_pseudo_bytes($keySize/2));
echo 'Generating Key of size: '.$keySize;
echo '<br />Key: '.$key;
echo '<br />Length: '.strlen($key);
die();
function BasicTabMenu(aMenuContainerId, aStartTabId){
var _this = this;
var _menuContainerId;
var _currentTabLink;
var _currentTab;
function init(aMenuContainerId, aStartTabId){
_menuContainerId = aMenuContainerId;
@krciga22
krciga22 / CSS Horizontal Drop Down Menu.css
Created May 1, 2014 22:24
CSS Horizontal Drop Down Menu (Basic)
/* menu structure (horizontal dropdown of three levels */
ul{margin:0;padding:0;}
li{list-style-type:none;}
ul.menu{z-index:100;}
ul.menu li{position:relative;display:inline-block;}
ul.menu li:hover > ul.sub-menu{display:block;}
ul.sub-menu{display:none;position:absolute;}
ul.sub-menu li{display:block;}
li a{display:block;}
@krciga22
krciga22 / cache.php
Last active August 29, 2015 14:00 — forked from johndyer/cache.php
<?php
class PHPCache {
protected $path = null;
protected $durationInSeconds = null;
protected $filenamePrefix = null;
protected $disableCacheForAdmin = false;
function __construct ( $path, $filenamePrefix='phpcache-', $durationInSeconds = 60) {
$this->path = $path;
$this->filenamePrefix = $filenamePrefix;
@krciga22
krciga22 / BETA-Testing-Cookie.php
Created April 29, 2014 14:21
BETA Testing Cookie
@krciga22
krciga22 / ANF_StatefulMenu
Created March 3, 2013 18:43
Use this JavaScript class to quickly add css state to an html menu with a tag links. Once initiated, the class will look at all a tags within the main menu element specified and will append the class name 'selected' to the a tag representing the current page. *Please note this is not for ajax based menus.
/**
* Use this class to quickly add css state to an html menu with a tag links.
* Once initiated, the class will look at all a tags within the main menu element
* specified and will append *the class name 'selected' to the a tag representing
* the current page. Please note this is not for ajax based menus.
* @class ANF_StatefulMenu
* @author ANF.
* @example
// menu initiation script (requires jQuery to be loaded so place in your html code near the closing body tag)
@krciga22
krciga22 / gist:4525755
Created January 13, 2013 19:19
Truncate String PHP Snippet: truncate a string in PHP either by setting a maximum length or maximum number of words. Also includes the ability to append a suffix if the string is truncated.
<?PHP
function truncate($text, $suffix="...",$maxLength=false,$maxWords=false){
$text = trim($text);
$text = preg_replace("/[\s]+/", " ", $text); // convert all consecuritve spaces to single spaces
if($maxLength!==false){
if(strlen($text)>$maxLength){
$text = substr($text, 0, $maxLength).$suffix;
}
}
if($maxWords!==false){