Skip to content

Instantly share code, notes, and snippets.

View chucktrukk's full-sized avatar

Charlie Madison chucktrukk

View GitHub Profile
@chucktrukk
chucktrukk / modx-share-cookie.php
Created April 18, 2012 18:02
Share modx cookie. Dont really work
@chucktrukk
chucktrukk / 404-301-redirects.php
Created December 14, 2011 16:05
MODx evolution 404 snippet for 301 redirects
<?php
$redirects = array(
'www.domain.com/old-url-1' => 'www.domain.com/new-url-1',
'www.domain.com/old-url-2' => 'www.domain.com/new-url-2',
);
$host = $_SERVER['HTTP_HOST'];
$url_parts = explode('?', $_SERVER['REQUEST_URI']);
@chucktrukk
chucktrukk / twig-render-function.php
Created December 8, 2011 22:30
quick method to send class to twig
<?php
class AnyClassUsa {
public function render($template)
{
$twig = $this->twig;
foreach(get_object_vars($this) as $property => $value) {
$params[$property] = $value;
@chucktrukk
chucktrukk / toggle_api.php
Created December 7, 2011 16:19
toggle api example
<?php
/*
curl -v -u API_TOKEN_HERE:api_token -X GET https://www.toggl.com/api/v6/me.json
curl -v -u API_TOKEN_HERE:api_token -X GET https://www.toggl.com/api/v6/time_entries.json
curl -v -u API_TOKEN_HERE:api_token -X GET "https://www.toggl.com/api/v6/time_entries.json?start_date=2010-02-05T15%3A42%3A46%2B02%3A00&end_date=2010-02-12T15%3A42%3A46%2B02%3A00"
*/
$from_date = isset($_GET['from_date']) ? $_GET['from_date'] : date('m-d-Y');
$to_date = isset($_GET['to_date']) ? $_GET['to_date'] : date('m-d-Y');
<?php
/**
* RPX Helper Class for JanRain Engage
* @author Andres Cordero
* @license MIT
* See http://www.opensource.org/licenses/mit-license.html
* if LICENSE file not present
* Make sure cURL is installed and allowed to initiate HTTPS connections
*/
@chucktrukk
chucktrukk / revosnippet.class.php
Created September 26, 2011 20:00
Revo Snippet
<?php
if( !defined('VENDOR_PATH')) {
define('VENDOR_PATH', MODX_BASE_PATH.'/vendors');
}
class RevoSnippet
{
public function __construct()
{
var toggleFullScreen = false;
jQuery(document).ready(function($) {
$('#toggleButton').click(function() {
toggleFullScreen = true;
flowplayer.pause();
toggleFullScreen = false;
Array
(
[0] => __construct
[1] => listGroups
[2] => getTemplateVarCollection
[3] => refreshURIs
[4] => process
[5] => getContent
[6] => setContent
[7] => getCacheKey
<?php
function variable_name( &$var, $scope=false, $prefix='UNIQUE', $suffix='VARIABLE' ){
if($scope) {
$vals = $scope;
} else {
$vals = $GLOBALS;
}
$old = $var;
$var = $new = $prefix.rand().$suffix;
@chucktrukk
chucktrukk / gist:1100267
Created July 22, 2011 19:48
revo updates

Allow multiple templates to have the same name

  1. Remove index on template name via: ALTER TABLE modx3_site_templates DROP INDEX templatename
  2. comment out 25-30 in /core/model/modx/processors/element/template/create.php
  3. comment out 40-46 in /core/model/modx/processors/element/template/update.php