Skip to content

Instantly share code, notes, and snippets.

View aghouseh's full-sized avatar

Andrew Householder aghouseh

View GitHub Profile
@aghouseh
aghouseh / file_relink
Created October 10, 2012 02:06
Concrete5 Relink Files - If you accidentally and block-headedly deleted your /files/ folder, but have source images available elsewhere, use this to restore them. Crawls a given directory and matches against Concrete5 filenames to relink missing images.
@aghouseh
aghouseh / states and counties
Created October 21, 2012 07:10
PHP nested array of states and counties
$counties = array(
"Alabama" => array(
"Autauga County",
"Baldwin County",
"Barbour County",
"Bibb County",
"Blount County",
"Bullock County",
"Butler County",
"Calhoun County",
@aghouseh
aghouseh / get_parameters.js
Last active December 16, 2015 19:30
string prototype to get all query values from a URL string or alternatively search for a specific value. pieced together from various things i found on the googles.
String.prototype.getParameters = function(key){
var urlParams,
match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, ' ')); },
query = this;
// this is hasty and fragile currently
if (query.indexOf('?') !== -1) {
<?php
$scriptStart = microtime(true);
$iterations = 5000;
$longString = str_repeat('0123456789', 102 * 5); // 10 * 102 * 5 = 5k
if (is_file(dirname(__FILE__) . '/config/site.php')) {
include(dirname(__FILE__) . '/config/site.php');
if (defined('DB_SERVER')) {
@aghouseh
aghouseh / jquery.form-clear.js
Created June 24, 2013 21:49
simple jQuery function to clear a form's elements. differs from a reset in that it will zero values even if they were initially checked / selected on page render.
$.fn.clear = function() {
if (this[0].tagName.toUpperCase() !== 'FORM') { return this; }
return this.find(':input').each(function() {
if (this.type === 'radio' || this.type === 'checkbox') {
this.checked = false;
} else {
$(this).val('');
}
});
}
@aghouseh
aghouseh / image.php
Last active December 21, 2015 09:49
concrete5 image helper extension to allow for custom rendering of img tags. the intention is to provide a way to globally update img tag rendering in the future, pending a w3c approved responsive image solution
<?php defined('C5_EXECUTE') or die(_('Access Denied.'));
class ImageHelper extends Concrete5_Helper_Image {
/**
* Runs getThumbnail on the path, and then prints it out as an XHTML image
*/
public function outputThumbnail($obj, $maxWidth, $maxHeight, $alt = null, $return = false, $crop = false) {
$thumb = $this->getThumbnail($obj, $maxWidth, $maxHeight, $crop);
if ($return) {
@aghouseh
aghouseh / fn_to_hyper.json
Created December 10, 2022 04:39
Fn to Hyper - complex modification for Karabiner-Elements
{
"title": "Fn Key → Hyper Key (⌃⌥⇧⌘)",
"rules": [
{
"description": "Fn Key → Hyper Key (⌃⌥⇧⌘)",
"manipulators": [
{
"from": {
"key_code": "fn",
"modifiers": {