Skip to content

Instantly share code, notes, and snippets.

View rintaun's full-sized avatar

Matthew Lanigan rintaun

View GitHub Profile
<?php
$a = true;
$b = false;
var_dump(${ 1 ? 'a' : 'b' });
${"your mom is your mom http://www.google.com/"} = 'a';
_=$=+!![];$__=((_$={})+'')[_+$+_+$+_];__$=((![])+'')[$];_$_=((_$={})+'')
[_+$+_+$+_+$];____=[][$__+((_$={})+'')[$]+(($)/(![])+'')[$]+$__+__$+_$_];$__$=(!![]+"")
[$+$+$]+([][(![]+"")[$+$+$]+(+[]+{})[$+$]+(!![]+"")[$]+(!![]+"")[+[]]]+"")[($+$)+""+
($+$+$)]+(![]+"")[$]+(![]+"")[$+$];$_$_=____()[$-$][$__$]("\"\\"+($)+($+$+$+$+$+$+$)+
($+$)+"\"");_$=(![]+'')[$-$]+([][[]]+[])[$+$+$+$+$]+$_$_+$_$_;$_=(_+{})[$+$+$]+(!![]+'')
[_+$]+$_$_+$_$_;_--,$$=$+$;____()[$-$][$__$]((![]+"")[+[]]+(+[]+{})[$+$]+(!![]+"")[$]+
"(;++_;)$$$=!(_%("+($$+$$+$)+")),____()[+[]][__$+((![])+'')["+($+$)+"]+((!![])+'')["+
($+$+$)+"]+((!![])+'')[+!![]]+_$_](!(_%("+($$+$)+"))?$$$?_$+$_:_$:$$$?$_:_);");
@rintaun
rintaun / Date
Created December 20, 2011 14:54 — forked from anonymous/Date
Date code
<?php
//This is for PRACTICE only!
$d=date('D', strtotime('-1 day'));
if ($d=="Tue")
echo "Have a nice Tuesday!";
elseif ($d=="Mon")
echo "Have a nice Monday!";
else

MySQL / PostgreSQL comparison

MySQL

Pros

  • Somewhat lighter-weight (i.e. does not use as much memory necessarily)
  • Widespread support by many apps
  • Table partioning simple and built-in
<?php
class Model {
/**
* Load a row from the database
*
* Pulls data from the database for a given model into the object. Note
* that this clears any state (modifications/etc.) that have been set
* on the object first, for any Model-controlled columns.
@rintaun
rintaun / pagerank.php
Created April 24, 2012 14:12 — forked from anonymous/pagerank.php
Hashing algoriths for Page Rank
<?php
// Function d checks
function d($a, $b) {
//$c = intval(8E7, 16);//80000000
$c = 2147483648;
$a = $a & 0xffffffff;
if ($c & $a) {
$a >>= 1;
$a &= ~$c;
$a = $a | 1073741824;
@rintaun
rintaun / closurize.php
Created May 23, 2012 03:50
closurize(): Converts any valid PHP callable into a Closure. Requires PHP 5.4.0+.
<?php
/**
* Converts any valid PHP callable into a Closure. Requires PHP 5.4.0+.
*
* The ramifications of this are many, but basically it means that any function
* or method can be converted into a Closure, bound to another scope, and
* executed easily. Works properly even with private methods.
*
* - On success, returns a Closure corresponding to the provided callable.
* - If the parameter is not callable, issues an E_USER_WARNING and returns a
<?php
use Ribcage\Rib;
/**
* public function render($filename, $renderer = null);
*
* @param $filename Filename relative to the "views" folder in the
* root directory.
* @param $renderer (Optional) Name of the renderer class to use;
* determined by file extension by default.
<?php
namespace Haml;
class Haml
{
public static function getTree($data)
{
$root = $last_node = new Node('', -1);
$re = '/^[\r\n]*([ \t]*)([^ \t]?(?:(?=.*?{[^}]*)\s*[^}]*}.*?|' .
'(?:(?=.*?\s*\|\s*)(?:.*?\s*\|\s*)*|.*?)))(\s*?)[\r\n]*$/m';
+---------------+
| organizations |
+---------------+
+------>| id(PK) |<---------+
| +---------------+ |
| |
| +--------+ +----------+ |
| | groups | | profiles | |
| +--------+ +----------+ |
+---| org_id | | org_id |---+