Skip to content

Instantly share code, notes, and snippets.

View jtarleton's full-sized avatar

James Tarleton jtarleton

View GitHub Profile
@jtarleton
jtarleton / Helpers.class.php
Last active August 29, 2015 14:15 — forked from anonymous/Helpers.class.php
Sort an associative array of objects by any number of properties in any order, maintaining key association.
<?php
class HelperLibrary
{
/**
* Sort an associative array of objects by any number of properties in any order, maintaining key association.
*
* Example usage, for an array of users:
*
* $users = array();
*
@jtarleton
jtarleton / HelperLib.class.php
Created February 18, 2015 15:28
Helper function for array slicing
<?php
class HelperLibrary {
// Utility to slice an associative array
public static function assoc_array_slice($array, $offset, $count) {
$result = array();
$keys = array_keys($array);
$end = min($offset + $count, count($array));
@jtarleton
jtarleton / js-sort.html
Created April 16, 2015 16:44
Sorting an Array Objects in Javascript
<!DOCTYPE html>
<head>
<title>Javascript Object Sorting Exercise</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style type="text/css">
.yella {
background-color: yellow;
}
.arrow-up {
@jtarleton
jtarleton / JtAwesomeHelpers.class.php
Created September 23, 2016 14:27
Helper functions
<?php
class JtAwesomeHelpers
{
public static function SimpleMailer($subject = 'DW Operation Complete', $body='', $htmlbody = '', $to = '[email protected]') {
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n" .
'From: Your Mailer <[email protected]>' . "\r\n" .
@jtarleton
jtarleton / PatIndex.sql
Created June 27, 2018 13:49
PatIndex MySQL stored procedure
CREATE DEFINER=`root`@`localhost` FUNCTION `PatIndex`(pattern VARCHAR(255), tblString VARCHAR(255)) RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE i INTEGER;
SET i = 1;
myloop: WHILE (i <= LENGTH(tblString)) DO
IF SUBSTRING(tblString, i, 1) REGEXP pattern THEN
@jtarleton
jtarleton / Vagrantfile
Created July 11, 2018 14:13
Vagrant File for Local Dev Environment: Three Web Servers, One DB Server
Vagrant.configure("2") do |config|
#config.vm.synced_folder "C:\\Users\\jtarleton\\vagrant", "/var/winroot"
#config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "192.168.33.10"
#config.vm.provision :shell, path: "bootstrap.sh"
config.vm.define "weblocal" do |weblocal|
weblocal.vm.box = "ubuntu/precise64"
weblocal.vm.synced_folder "C:\\vagrantvm\\adid", "/var/www/adid"
weblocal.vm.synced_folder "C:\\Users\\jtarleton\\vagrant_www", "/var/winroot"
weblocal.vm.synced_folder "C:\\Users\\jtarleton\\vagrant_web\\home\\jtarleton\\tmp", "/home/jtarleton/tmp"
weblocal.vm.network "private_network", ip:"192.168.33.10"
@jtarleton
jtarleton / block.html.twig
Created January 23, 2019 19:06
Drupal 8 Core Block Template
{#
/**
* @file
* Default theme implementation to display a block.
*
* Available variables:
* - plugin_id: The ID of the block implementation.
* - label: The configured label of the block if visible.
* - configuration: A list of the block's configuration values.
* - label: The configured label for the block.
@jtarleton
jtarleton / node.html.twig
Created January 23, 2019 19:21
Drupal 8 Node Core Template
{#
/**
* @file
* Default theme implementation to display a node.
*
* Available variables:
* - node: The node entity with limited access to object properties and methods.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - node.getCreatedTime() will return the node creation timestamp.
@jtarleton
jtarleton / html.html.twig
Created January 26, 2019 01:12
Sample Drupal 8 Outer Html Template
{#
/**
* @file
* A subtheme implementation for the basic structure of a single Drupal page.
*
* Variables:
* - logged_in: A flag indicating if user is logged in.
* - root_path: The root path of the current page (e.g., node, admin, user).
* - node_type: The content type for the current node, if the page is a node.
* - head_title: List of text elements that make up the head_title variable.
@jtarleton
jtarleton / page.html.twig
Last active January 28, 2019 13:57
Drupal 8 Example Page (Inner HTML) template
{#
/**
* @file
* Example subtheme implementation to display a single page.
*
* The doctype, html, head and body tags are not in this template. Instead they
* can be found in the html.html.twig template in this directory.
*
* Available variables: