Skip to content

Instantly share code, notes, and snippets.

View goldsky's full-sized avatar

rico goldsky

View GitHub Profile
@goldsky
goldsky / jquery.stoc.js
Created January 28, 2012 12:16
jQuery Plugin: Table of Contents with Smooth Scrolling
/**
* jQuery Plugin: Table of Contents with Smooth Scrolling
* @link http://www.1stwebdesigner.com/css/jquery-plugin-smooth-scrolling/
* @author Rochester Oliveira
*/
(function($){
$.fn.stoc = function(options) {
//Our default options
var defaults = {
@goldsky
goldsky / body.html
Created February 5, 2012 09:21
torben's sticky footer
<body lang="en" class="sticky-frame">
<header id="header" class="sticky-row">
<div class="center">
<h1>Some Header</h1>
</div>
</header>
<div id="wrap" class="sticky-row sticky-expand">
<div id="content-wrapper">
<article id="content">
<p>Some content</p>
@goldsky
goldsky / autoload.fancybox.js
Created April 13, 2012 04:45
This snippet loads fancybox automatically to all images inside the #content area. Useful for user's images that are uploaded by TinyMCE.
$(document).ready(function() {
$("#content img").wrap(function() {
return '<a href="'+ this.src +'" />';
}).parent().fancybox();
});
@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() {}
@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 / 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 / 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 / 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 / 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 / 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);