Skip to content

Instantly share code, notes, and snippets.

Avatar

rico goldsky

View GitHub Profile
@goldsky
goldsky / jquery.stoc.js
Created Jan 28, 2012
jQuery Plugin: Table of Contents with Smooth Scrolling
View jquery.stoc.js
/**
* 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 Feb 5, 2012
torben's sticky footer
View body.html
<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 Apr 13, 2012
This snippet loads fancybox automatically to all images inside the #content area. Useful for user's images that are uploaded by TinyMCE.
View autoload.fancybox.js
$(document).ready(function() {
$("#content img").wrap(function() {
return '<a href="'+ this.src +'" />';
}).parent().fancybox();
});
@goldsky
goldsky / utility.class.php
Created Apr 30, 2012
This class has trim utilities to overcome the TinyMCE's bug related to the whitespace characters (&Acirc;|&nbsp;).
View utility.class.php
<?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
MODX's plugin to redirect specified usergroups after logged in using the Login snippet
View login.redirect.usergroups.plugin.php
<?php
if ($modx->event->name !== 'OnWebLogin')
return;
$usergroups = $user->getUserGroupNames();
if(empty($usergroups))
return;
switch (TRUE) {
@goldsky
goldsky / dgrid-controller.php
Created Aug 15, 2012
PHP controller file for dojo's dgrid
View dgrid-controller.php
<?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 Aug 16, 2012
Convert under_score type array's keys to camelCase type array's keys and likewise
View transformKeys.php
<?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 Nov 6, 2012
A javascript function using jQuery's validation and twitter bootstrap's popover
View validate.popover.js
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 Nov 25, 2020
Ajax's connector file using MODX's main index.php
View connector.php
<?php
/**
* Ajax Connector
*
* @package mypackage
*/
$validActions = array(
'web/data/delete',
'web/data/edit'
@goldsky
goldsky / currency.inc.php
Last active Dec 13, 2015
ISO-4217 Currency Codes in a PHP array
View currency.inc.php
<?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);