Skip to content

Instantly share code, notes, and snippets.

View bantya's full-sized avatar
🎯
Focussing

Rahul Thakare bantya

🎯
Focussing
  • http://127.0.0.1:4200
  • http://127.0.0.1:8080
  • 06:26 (UTC -12:00)
  • X @rkkth
View GitHub Profile
@schacon
schacon / gist:1
Created July 15, 2008 18:17
the meaning of gist
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.
@romansklenar
romansklenar / Inflector.php
Created December 11, 2009 21:42
Ruby on Rails Inflector port to PHP
<?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)
@banksean
banksean / perlin-noise-classical.js
Created February 15, 2010 10:00
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// 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.
*/
@dahnielson
dahnielson / UUID.php
Last active May 31, 2024 23:54
Pure PHP UUID generator
<?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.
@donatj
donatj / lorem.php
Created September 22, 2010 19:55
PHP Flavored Lorem Ipsum Generator
<?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 = '';
/**
* 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
@johndyer
johndyer / cache.php
Created February 9, 2011 03:06
Simple PHP Object Caching
<?php
// Super simple caching class
class PhpCache {
protected $path = null;
protected $duration = null;
function __construct ( $path, $duration = 60) {
$this->path = $path;
$this->duration = $duration;
}
@adaburrows
adaburrows / functional_fibonacci.php
Created April 25, 2011 04:02
Functional Programming in PHP
<?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 {
@danielgwood
danielgwood / Date.php
Created April 25, 2011 20:15
Some utility functions for working with dates in PHP
<?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.
@adaburrows
adaburrows / compose_functions.php
Created April 26, 2011 06:24
Composing functions in PHP
<?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) {