Skip to content

Instantly share code, notes, and snippets.

View DaveRandom's full-sized avatar

Chris Wright DaveRandom

View GitHub Profile
@DaveRandom
DaveRandom / file.php
Last active December 12, 2015 03:38
Simple file upload manager lib
<?php
namespace Upload;
class File implements IFile {
/**
* The meta data about the file (from the $_FILES array)
*
* @var array $uploadMeta
@DaveRandom
DaveRandom / Cell.php
Last active December 15, 2015 03:29
Small library for manipulating Excel spreadsheets using COM on a Windows machine with Microsoft Office is installed
<?php
/**
* Class for objects representing a single cell in an Excel worksheet
*
* PHP version 5.3/Windows, requires Microsoft Office Excel to be installed on the host system
*
* @package ExcelCOM
* @author Chris Wright <info@daverandom.com>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0.0
@DaveRandom
DaveRandom / gist:5201273
Created March 20, 2013 00:02
Bit-shift PHP strings.
<?php
function str_left_shift($str, $count) {
$bytes = floor($count / 8);
if ($bytes) {
$str = substr($str, $bytes)
. str_repeat("\x00", $bytes);
$count = $count % 8;
[**Please, don't use `mysql_*` functions in new code**](http://stackoverflow.com/q/12859942). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [**red box**](http://php.net/mysql-connect)? Learn about [*prepared statements*](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://php.net/mysqlinfo.api.choosing) will help you decide which. If you choose PDO, [here is a good tutorial](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers).

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or [MySQLi](http://php.net/mysq

[**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](http://j.mp/XqV7Lp). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ).

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.

@DaveRandom
DaveRandom / RegExp.bas
Created May 15, 2013 08:41
VB classic regular expressions that suck (a bit) less
Attribute VB_Name = "RegExp"
Option Compare Database
Option Explicit
Public Enum REGEXP_PARSEERROR
REGEXP_PARSEERROR_INVALIDWRAPPER = 1
REGEXP_PARSEERROR_UNBALANCEDESCAPES = 2
REGEXP_PARSEERROR_UNKNOWNMODIFIER = 3
REGEXP_PARSEERROR_SYNTAXERROR = 4
REGEXP_PARSEERROR_UNEXPECTEDQUANTIFIER = 5
@DaveRandom
DaveRandom / ImageRandomizer.js
Created July 1, 2013 09:20
Prototype for object which randomly displays a list of images with fading transitions
/*jslint browser: true, plusplus: true, regexp: true, white: true */
/**
* Prototype for object which randomly displays a list of images with fading transitions
*
* @package ImageRandomizer <https://gist.github.com/DaveRandom/5899497>
* @author Chris Wright <https://github.com/DaveRandom>
* @copyright Copyright (c) Chris Wright <https://github.com/DaveRandom>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0.127
@DaveRandom
DaveRandom / Module.vbs
Created July 5, 2013 15:38
Module for repositioning windows in Access using Window API calls
Option Compare Database
Option Explicit
Private Type Point
x As Long
y As Long
End Type
Private Type Position
left As Long
@DaveRandom
DaveRandom / build_url.php
Last active December 20, 2015 05:28
PHP build_url()
<?php
function build_url($parts)
{
$result = '';
if (isset($parts['scheme'])) {
$result .= $parts['scheme'] . ':';
}
@DaveRandom
DaveRandom / ContentType.php
Last active December 20, 2015 06:59
PHP Content-Type negotiation
<?php
/**
* Represents a MIME content type
*
* @author Chris Wright <github@daverandom.com>
*/
class ContentType
{
/**