Skip to content

Instantly share code, notes, and snippets.

@intval
intval / gist:1947590
Created March 1, 2012 05:41
3 sorting algorithm imlementations
<?php
class sortings
{
public static function bubbleSort(array $integers)
{
for($runTo = sizeof($integers)-1; $runTo >0; $runTo-- )
{
for($i = 0; $i < $runTo; $i++)
{
@intval
intval / gist:2181946
Created March 24, 2012 12:21
random math question generator
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MathWeb
{
public partial class WebForm1 : System.Web.UI.Page
@intval
intval / restorePMAdump.php
Created August 10, 2012 08:10
Restore phpMyAdmin dump
<?PHP
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
header('Content-Type: text/html; charset=utf-8');
@intval
intval / gist:3798792
Created September 28, 2012 09:09
Handle fatal errors php
<?php
function the_last_function()
{
static $haltCodes = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR);
$error = error_get_last();
if ($error && in_array($error['type'], $haltCodes))
{
class RamCache
{
private static $data = array();
public static function set($key, $value)
{
self::$data[$key] = $value;
}
public static function get($key)
@intval
intval / websockets_encode_decode.php
Created May 20, 2013 18:30
websockets encoding and decoding functions
<?php
function hybi10Encode($payload, $type = 'text', $masked = true)
{
$frameHead = array();
$frame = '';
$payloadLength = strlen($payload);
switch($type)
{
// divides array into equal arrays, each of size n
function by(n, arr)
{
function byby(n, arr, accum)
{
if(arr.length < 1) return accum;
var head = [arr.slice(0,n)];
var tail = arr.slice(n);
return byby(n, tail, accum.concat(head));
}
@intval
intval / gist:2e8d6baf632ce5bc82e8
Created November 1, 2014 14:51
Linked List php example - unimplemented
<?php
class Node
{
/** @var int $value - The value of the item */
public $value;
/** @var Node $next - Reference to the next item in list */
public $next;
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP errors
*
*/
RunPHPLoc();
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsaUsH2NsgRDNgT5BrodagWWI1L6KUm6vap/3OPWdNKj67QzncVDsMyXLosutzldVp1GzINudY3lXPrcDErGi7kQPcwL6CcKidg2wC5/SnUU+uuhOv3jjSR6tNvegI6jpQ1HYMOGSDV6qo6wlVfcTur9dHM8ZejqMXnTJJ7MbwK1MA2CbTOx0vy/o1lax7dvicPFuioVy5J6vzDbVSW10hhhFn6RSU0bIS7c5K6PxE/uauAs2ZVc8lsiqZf7p0Mq9U6FtEdQmCOhFB8MstUe9soYLDN7rWk7TdKL1Kz/GrggCo/B2jwczPfFNrH2TUlzqP6WjItW3Db7dIhsx7Jc8R raskin@TPG_DEV_001