Skip to content

Instantly share code, notes, and snippets.

View splittingred's full-sized avatar
💭
🚀

Shaun McCormick splittingred

💭
🚀
View GitHub Profile
@splittingred
splittingred / .htaccess
Created April 9, 2012 21:48
Example of how to use new REST server class in MODX 2.3+
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ rest/index.php?_rest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ rest/index.php [QSA,NC,L]
</IfModule>
@splittingred
splittingred / prehook.profile.php
Created August 26, 2011 17:48
PreHook for FormIt to load User data into form
<?php
if (!$modx->user->hasSessionContext($modx->context->get('key')) return '';
$userArray = $modx->user->toArray();
$profile = $modx->user->getOne('Profile');
if ($profile) {
$userArray = array_merge($profile->toArray(),$userArray);
$extended = $profile->get('extended');
if (!empty($extended) && is_array($extended)) {
@splittingred
splittingred / gist:4689218
Last active April 30, 2019 09:39
Example of modRest, a REST Client, in MODX 2.3.
$config = array(
'baseUrl' => rtrim('http://mywebsite.com/rest/api/','/'),
'format' => 'json', // json or xml, the format to request
'suppressSuffix' => false, // if false, will append .json or .xml to the URI requested
'username' => 'myuser', // if set, will use cURL auth to authenticate user
'password' => 'mypass',
'curlOptions' => array(
'timeout' => 30, // cURL timeout
'otherCurlOption' => 1,
@splittingred
splittingred / gist:606c6b6b07c8e536dcd7
Last active February 28, 2018 19:37
Things Nick Hates
Things Nick Hates
0) Ann Kitchen
1) non-shallow tests
2) `if !`
3) ants
4) rock stars
5) sunlight off porch windows when drinking coffee
6) people who feed the meter
7) using floats for money
@splittingred
splittingred / Jobs.proto
Created July 25, 2017 15:30
gruf-bp-proto
syntax = "proto3";
package demo;
service Jobs {
rpc GetJob(GetJobReq) returns (GetJobResp) { }
}
message GetJobReq {
uint64 id = 1;
@splittingred
splittingred / transport.menu.php
Created April 20, 2012 18:45 — forked from BobRay/transport.menu.php
MODX menu transport file (for MODX 2.3)
/* will route to the first found of the following:
[namespace-path]controllers/[manager-theme]/index.class.php
[namespace-path]controllers/default/index.class.php
[namespace-path]controllers/index.class.php
*/
$menu= $modx->newObject('modMenu');
$menu->fromArray(array(
'text' => 'mycomponent',
'parent' => 'components',
'description' => 'mycomponent.menu_desc',
@splittingred
splittingred / activeuser.chunk.tpl
Created September 22, 2011 13:26
A MODX Snippet to show active, logged in users
<li>[[+username]]</li>
@splittingred
splittingred / install.sh
Created September 22, 2011 21:35
Bash script to install a new MODX Revolution 2.2+ install via CLI
Examples of above script:
# into a standard directory, where config.xml resides in the current working directory
sh install.sh /home/modx/public_html/
# with a custom config.xml file
sh install.sh /home/modx/public_html/ /opt/local/modx/config.xml
@splittingred
splittingred / response.xml
Created February 1, 2016 15:35
enom-response.xml
<?xml version="1.0" encoding="utf-8"?>
<interface-response>
<CertGetApproverEMail>
<Success>False</Success>
</CertGetApproverEMail>
<Command>CERTGETAPPROVEREMAIL</Command>
<APIType>API</APIType>
<Language>eng</Language>
<ErrCount>1</ErrCount>
<errors>
@splittingred
splittingred / normalized_word_frequency.rb
Last active December 14, 2015 05:29
Finds a normalized ranking of word frequency given an article of text
##
# Finds a normalized ranking of word frequency given an article of text
#
class Hash
##
# Normalize the array to values between 0 and 1
#
# @param [Boolean] weight_lower_value Set to true to give more weight to lower values
#
def normalize(weight_lower_value = false)