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
This is gist. | |
There are many like it, but this one is mine. | |
It is my life. | |
I must master it as I must master my life. | |
Without me gist is useless. | |
Without gist, I am useless. |
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 | |
/** | |
* The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, and class names to foreign keys. | |
* This solution is partitionaly based on Ruby on Rails ActiveSupport::Inflector (c) David Heinemeier Hansson. (http://rubyonrails.org), MIT license | |
* @see http://api.rubyonrails.org/classes/Inflector.html | |
* | |
* @author Roman Sklenář | |
* @copyright Copyright (c) 2009 Roman Sklenář (http://romansklenar.cz) |
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
// Ported from Stefan Gustavson's java implementation | |
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf | |
// Read Stefan's excellent paper for details on how this code works. | |
// | |
// Sean McCullough banksean@gmail.com | |
/** | |
* You can pass in a random number generator object if you like. | |
* It is assumed to have a random() method. | |
*/ |
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 | |
/** | |
* UUID class | |
* | |
* The following class generates VALID RFC 4122 COMPLIANT | |
* Universally Unique IDentifiers (UUID) version 3, 4 and 5. | |
* | |
* UUIDs generated validates using OSSP UUID Tool, and output | |
* for named-based UUIDs are exactly the same. This is a pure | |
* PHP implementation. |
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('words_example.php'); //Our Datasetm $data | |
$patSize = 5; | |
foreach( $data as $word ) { | |
for( $i = 0; $i <= strlen( $word ) - 2; $i++ ) { | |
$j = 0; | |
$str = ''; |
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
/** | |
* Method for taking a string formatted as a css selector and breaking it down into id/classes/attributes/in-line styles | |
* to use in the creatin of an element. I.E. "#id.class.class2[attribute=value]{ border: 1px solid blue; }" | |
* | |
* @ignore this is the original regex i wrote, which was awesome, but broke on some edge cases ... | |
* "!(\#(.+?)(\.|\[|\{)){1,}!" => ' id="$2" $3', //ID | |
* "!(\.(.*?)(\[|\{)){1,}!" => ' class="$2" $3', //CLASS | |
* "!\[(.*?)=([^\[]*)\]!" => ' $1="$2" ', //ATTRS | |
* "!\{(.*)\}!" => ' style="$1" ', //INLINE STYLE | |
* "!\.([a-zA-Z_]+[\w\-]*)!" => ' $1', //SPECIFIC CLASSES |
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 | |
// Super simple caching class | |
class PhpCache { | |
protected $path = null; | |
protected $duration = null; | |
function __construct ( $path, $duration = 60) { | |
$this->path = $path; | |
$this->duration = $duration; | |
} |
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 | |
/** | |
* Fibonacci: | |
*============================================================================ | |
* Class for computing fibonacci numbers using functional programming in PHP | |
* Uses the formula at: http://jburrows.wordpress.com/2009/12/30/fibonacci/ | |
*/ | |
class fibonacci { |
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 Date | |
{ | |
/** | |
* Returns time difference between two timestamps, in human readable format. | |
* | |
* @param int $time1 A timestamp. | |
* @param int $time2 A timestamp, defaults to the current time. | |
* @param string $output Formatting string specifying which parts of the date to return in the 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 | |
/** | |
* Just trying out more functional programming in PHP | |
* This gist provides some basic utility functions for: | |
* + Working with functions | |
* + Working with arrays | |
*/ | |
// This function allows creating a new function from two functions passed into it | |
function compose(&$f, &$g) { |
OlderNewer