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 gibberish($numParagraphs = 1, $wordsPerParagragh = 10, $maxWordLength = 20) | |
{ | |
mt_srand(microtime() * 1000000); | |
$bank = array_merge(range('a', 'z'), range('A', 'Z')); | |
$paragraphs = array(); | |
for ($i = 0; $i < $numParagraphs; $i++) | |
{ | |
$words = array(); |
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 simple_xml_encoder($data, $rootNode = 'response', $node = 'string') { | |
function traverse($data, $node) { | |
$xml = ''; | |
if (is_array($data) || is_object($data)) { | |
foreach ($data as $key => $value) { | |
if (is_numeric($key)) { | |
$key = $node; | |
} | |
if (empty($value)) { |
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 | |
//include.php | |
function add($x, $y) { | |
return $x + $y; | |
} | |
return add(5,10); | |
?> |
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
//TODO: http://stackoverflow.com/questions/7042611/override-console-log-for-production | |
; | |
(function (window) { | |
if (window.log) { | |
return; | |
} | |
window.log = function() { | |
log.history = log.history || []; // store logs to an array for reference | |
log.history.push(arguments); |
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
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
namespace ParseUtility | |
{ | |
public static class ParseUtility | |
{ | |
//-- Parsing |
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
public static class StringCoalesceExtension | |
{ | |
public enum CoalesceProperty | |
{ | |
OnNull = 1, | |
OnNullOrEmpty = 2, | |
OnNullOrWhiteSpace = 4 | |
} | |
public static string Coalesce(this string originalString, params string[] strings) |
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 | |
class Bytes | |
{ | |
private $sizeInBytes; | |
private static $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); | |
public function __construct($sizeInBytes) | |
{ | |
$this->sizeInBytes = floatval($sizeInBytes); |
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
-- Based on https://www.ibm.com/developerworks/community/blogs/SQLTips4DB2LUW/entry/aggregating_strings42?lang=en | |
SELECT | |
dept, | |
SUBSTR(XMLCAST(XMLGROUP(',' || name AS a | |
ORDER BY name) | |
AS VARCHAR(60)), 2) AS Names, | |
avg(salary) as avgsal | |
FROM emp | |
GROUP BY dept; |
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 | |
/** | |
* Smart Tidy/Gzip Output Buffer | |
* Compress HTML output to a single line, then attempt gzip compression. | |
* @param string $buffer | |
* @param int $mode | |
* @return string|false | |
*/ | |
function ob_minify($buffer, $mode) { |
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 | |
/* Directories that contain classes */ | |
$classesDir = array ( | |
ROOT_DIR.'classes/', | |
ROOT_DIR.'firephp/', | |
ROOT_DIR.'includes/' | |
); | |
function __autoload($class_name) { | |
global $classesDir; |
OlderNewer