Skip to content

Instantly share code, notes, and snippets.

View jtarleton's full-sized avatar

James Tarleton jtarleton

View GitHub Profile
<!doctype html>
<head>
<script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.9.1.min.js"></script>
<script src="modal.js"></script>
<style type="text/css">
#mask{
position:absolute; /* important */
top:0px; /* start from top */
left:0px; /* start from left */
height:100%; /* cover the whole page */
@jtarleton
jtarleton / gitconfig
Created July 1, 2013 21:01
Good git config commands
git config --global core.editor vim
git config --global color.ui true
git config --global color.diff.meta "blue black bold"
@jtarleton
jtarleton / gist:6063129
Created July 23, 2013 15:09
Finds the intersection of two arrays in a simple fashion.
/**
* finds the intersection of
* two arrays in a simple fashion.
*
* PARAMS
* @param a - first array, must already be sorted
* @param b - second array, must already be sorted
*
* NOTES
*
@jtarleton
jtarleton / slavestatus.php
Created September 17, 2013 21:54
Simple batch job to write MySQL's slave status to a file
<?php
abstract class Base
{
//An array of DB config values
protected static $config;
//Path to configuration
protected static $iniPath = 'C:\Users\winuser\Desktop\dbconfig.ini';
}
@jtarleton
jtarleton / drupalstuff.php
Last active August 29, 2015 14:06
A set of generic data structures for extending the Drupal 7 Database class
<?php
/**
* A set of generic data structures for extending the Drupal 7 Database class.
*
* For non-Drupal projects, you could also use this with PDO.
*
* Just re-write the BaseObject, BaseEntity, BaseCollection classes.
*
*
* Defining your own data types in PHP is as easy as:
@jtarleton
jtarleton / drupalhashing.php
Created September 4, 2014 20:17
Drupal-style password hashing routine
<?php
/**
* A general purpose password hashing routine (from Drupal)
*
* Requires two standard drupal "include" files (available for download at https://www.drupal.org/):
* 1. drupal_bootstrap.inc
* 2. drupal_password.inc
*
* You might also want to use it to manually "reset" a password in a Drupal site's "user" MySQL table
*
@jtarleton
jtarleton / gist:52941b676eb4ada9b290
Last active August 29, 2015 14:10
Drupal Form Builder class using ArrayAccess and Builder pattern
<?php
class DrupalFormBuilder implements ArrayAccess
{
private $data = array();
public function __construct(array $fieldsets = array('fs1'=>'fs1')) {
foreach($fieldsets as $key=>$fieldset){
$this->addFieldset($fieldset);
@jtarleton
jtarleton / JtXmlParser.class.php
Last active August 29, 2015 14:11
XML Parsing in PHP Tutorial
class JtXmlParser
{
const XML_PATH ='datasource.xml';
const START_NODE = 'ROW'; // the element identifying a new record
public $file,
$rows = array(),
$record = array(),
$fdata = '',
@jtarleton
jtarleton / JtCaptcha.class.php
Last active August 29, 2015 14:11
Simple Captcha Image
<?php
/*
* Based on SIMPLE CAPTCHA IMAGE SCRIPT by Constantin Boiangiu
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@jtarleton
jtarleton / gdtest.php
Last active August 29, 2015 14:14
Checking for GD Support in PHP
<?php
/* Displays details of GD support on your server */
echo '<div style="margin: 10px;">';
echo '<p style="color: #444444; font-size: 130%;">GD is ';
if (function_exists("gd_info")) {