Skip to content

Instantly share code, notes, and snippets.

View jec006's full-sized avatar

Josh Caldwell jec006

View GitHub Profile
@jec006
jec006 / postgis.rb
Last active July 20, 2022 12:32
Postgis Formula using Postgres 13
class Postgis < Formula
desc "Adds support for geographic objects to PostgreSQL"
homepage "https://postgis.net/"
url "https://download.osgeo.org/postgis/source/postgis-3.2.1.tar.gz"
sha256 "fbab68dde6ca3934b24ba08c8ab0cff2594f57f93deab41a15c82ae1bb69893e"
license "GPL-2.0-or-later"
revision 5
livecheck do
url "https://download.osgeo.org/postgis/source/"
@jec006
jec006 / examples.js
Last active May 25, 2020 12:27
A wrapper around the base js Object to make iterating and other basic functions easier
let test = usefulHash({test: [1,2,3], dude: 'hi'})
test.forEach(function(k, v) { console.log(`${k}, ${v}`) })
test['zombies'] = true
test.forEach(function(k, v) { console.log(`2: ${k}, ${v}`) })
console.log(test.keys())
console.log(test.values())
@jec006
jec006 / wordpress-nginx.conf
Last active August 29, 2015 14:23
Wordpress Nginx Configuration
server {
listen 80;
server_name optoro optoro.local;
location / {
root /opt/development/optoro-wp-com/wordpress;
index index.php;
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
@jec006
jec006 / jed.cnf
Created January 14, 2014 21:47 — forked from jedprentice/jed.cnf
[mysqld]
# Slow Log
#slow_query_log = 1
#log_queries_not_using_indexes = 1
#long_query_time = 1
# Disable DNS lookups for performance
skip_name_resolve
# MySQL >= 5.5.5 uses InnoDB by default, but set it just in case
@jec006
jec006 / snake-case.js
Created September 3, 2013 20:34
Turns a camelCase or Capital Case word into snake-case.
/**
* Take a camel case word and turn it into snake case
* i.e. layoutBlock to layout-block
*/
String.prototype.toSnakeCase = function() {
return this.replace(/ /g, '-').replace(/([a-z0-9])([A-Z0-9])/g, '$1-$2').toLowerCase();
}
@jec006
jec006 / base.htm
Created May 15, 2013 14:44
Fixes relative base href's in IE
<script type="text/javascript">
//fix relative base paths in IE
var base = document.getElementsByTagName('base')[0];
base.href = base.href;
</script>
@jec006
jec006 / improve_mediaelement.module.php
Created September 26, 2012 14:57
Adding Closed Captioning to MediaElement (media video player module).
/**
* Adds Closed Captioning support to the MediaElement module - http://www.drupal.org/project/mediaelement
*
* Parts of this should be turned into a patch eventually for that module.
*
* The preprocess assumes a field_collection with the media file field and a file field to upload captions
* This can obviously be altered to work with other configurations.
*/
/**
* Implements hook_theme_registry_alter().
<?php
$render = array();
//Good
$render['top'] = array(
'#type' => 'items_list',
'#items' => array(
array('#data' => 'lololol'),
),
<?php
/**
* Implements WidgetInterface::getPreviewForm().
*
* Return a form to collect the date information from the user.
*/
public function getPreviewForm($element, &$form_state) {
$element['#type'] = 'fieldset';
$element['#title'] = empty($this->settings['title']) ? t('Date/Time:') : $this->settings['title'];
$element['#description']= t('Preview nodes published on or after this date.');
@jec006
jec006 / IIBBaseUnitTest.php
Created July 19, 2012 19:04
'Enable' a module during unit tests
<?php
/**
* Fake enables a module for the purpose of a unit test
*
* @param $name
* The module's machine name (i.e. ctools not Chaos Tools)
*/
protected function enableModule($name) {
$modules = module_list();