Skip to content

Instantly share code, notes, and snippets.

View goldsky's full-sized avatar

rico goldsky

View GitHub Profile
@goldsky
goldsky / tv-counter.php
Created December 24, 2013 08:47
Count how many resources which have specified TV that has specified value
<?php
$name = $modx->getOption('name', $scriptProperties);
$value = $modx->getOption('value', $scriptProperties);
if (empty($tvName) || empty($value)) {
return;
}
$tvObj = $modx->getObject('modTemplateVar', array(
'name' => $name
));
@goldsky
goldsky / sticky-footer-2.css
Last active September 14, 2018 11:46
Sticky footer using CSS's display: table, inspired by: http://pixelsvsbytes.com/blog/2012/02/this-css-layout-grid-is-no-holy-grail/
@goldsky
goldsky / sticky-footer.css
Last active October 27, 2021 02:50
Sticky footer using CSS's display: table, inspired by: http://pixelsvsbytes.com/blog/2012/02/this-css-layout-grid-is-no-holy-grail/
@goldsky
goldsky / currency.inc.php
Last active December 13, 2015 19:58
ISO-4217 Currency Codes in a PHP array
<?php
header('Content-Type: text/html; charset=utf-8');
/**
* Download the currecy data from the link below, and place it along side this file
* @link http://www.currency-iso.org/en/home/tables/table-a1.html Current currency & funds code list
*/
$xml = file_get_contents( dirname(__FILE__) . '/dl_iso_table_a1.xml');
$currencyArray = json_decode(json_encode((array) simplexml_load_string($xml)), 1);
@goldsky
goldsky / connector.php
Last active November 25, 2020 20:30
Ajax's connector file using MODX's main index.php
<?php
/**
* Ajax Connector
*
* @package mypackage
*/
$validActions = array(
'web/data/delete',
'web/data/edit'
@goldsky
goldsky / validate.popover.js
Created November 6, 2012 04:40
A javascript function using jQuery's validation and twitter bootstrap's popover
function validateForm(formId, erPlacement, validRules) {
erPlacement = erPlacement || 'bottom';
validRules = validRules || {};
/* Validation message with the twitter's popover */
/* http://d.hatena.ne.jp/hipsrinoky/20120329/1333035926 */
var eClass = 'error'; // for bootstrap
var sClass = 'success'; // for bootstrap
var wClass = 'warning'; // for bootstrap (not in used)
$(formId).validate({
@goldsky
goldsky / transformKeys.php
Created August 16, 2012 18:36
Convert under_score type array's keys to camelCase type array's keys and likewise
<?php
/**
* Convert under_score type array's keys to camelCase type array's keys
* @param array $array array to convert
* @param array $arrayHolder parent array holder for recursive array
* @return array camelCase array
*/
public function camelCaseKeys($array, $arrayHolder = array()) {
$camelCaseArray = !empty($arrayHolder) ? $arrayHolder : array();
@goldsky
goldsky / dgrid-controller.php
Created August 15, 2012 10:53
PHP controller file for dojo's dgrid
<?php
$out = '';
switch ($_REQUEST['act']) {
// ... more cases above
case 'get-data':
$params = array();
//$headers = apache_request_headers();
//$range = @explode('-', ltrim($headers['Range'], 'items='));
@goldsky
goldsky / login.redirect.usergroups.plugin.php
Created May 21, 2012 10:19
MODX's plugin to redirect specified usergroups after logged in using the Login snippet
<?php
if ($modx->event->name !== 'OnWebLogin')
return;
$usergroups = $user->getUserGroupNames();
if(empty($usergroups))
return;
switch (TRUE) {
@goldsky
goldsky / utility.class.php
Created April 30, 2012 10:55
This class has trim utilities to overcome the TinyMCE's bug related to the whitespace characters (&Acirc;|&nbsp;).
<?php
/**
* @license The included classes have their own licenses
* @copyright (c) 2012 by goldsky <goldsky@fastmail.fm>
*/
class Utility {
public function __construct() {}