Skip to content

Instantly share code, notes, and snippets.

View ryun's full-sized avatar
😉

Ryun Shofner ryun

😉
View GitHub Profile
@ryun
ryun / app.js
Created November 6, 2011 07:47
Titanium Mobile js module: Horizontal and Vertical Scrolling Tables
// Require the table modules
var scrollableTableView = require('scrollableTableView').scrollableTableView;
var scrollableTable = require('scrollableTable').scrollableTable;
// Container View (so we can fit multiple table on one page)
var tblView = new scrollableTableView();
// Create Some tables
var tbl = new scrollableTable();
var tbl2 = new scrollableTable();
@ryun
ryun / example.cache_lib.php
Created April 18, 2012 00:38
This demonstrates howto cache a static methods output. I use this "lazy method" for example: when I don't want to make multiple calls to the database
<?php
Class Example_Lib {
/**
* Internal cache helper
* Caches internal method results in memory
*
* @param string $func function to call
* @param array $args arguments for the callback function
@ryun
ryun / Hitcount_Lib.php
Created May 26, 2012 18:30
Hitcounter for pretty much anything
<?php
class Hcount {
private static $CI;
private static $CFG = array();
private static $DEFAULTS = array(
'timeout' => 2419200, // 4 * 7 * 24 * 3600 (1 month)
//Hits counter table
'tbl_hit_count' => array(
@ryun
ryun / plugin.php
Created May 29, 2012 15:36
Drop-in replacment for navigation plugin (uses span for current page)
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Navigation Plugin
*
* @author PyroCMS Dev Team
* @package PyroCMS\Core\Modules\Navigation\Plugins
*/
class Plugin_Navigation extends Plugin
{
/**
@ryun
ryun / form.css
Created May 30, 2012 20:32
Default form styles
/**
* Forms
*/
form
{
margin: 0;
}
form p, label {display:block;}
form ul
{
@ryun
ryun / slugify.php
Created June 29, 2012 16:51
Slugify helper function
function to_slug($str, $replace=array(), $delimiter='_', $maxLength=200)
{
if(!empty($replace))
{
$str = str_replace((array)$replace, ' ', $str);
}
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = preg_replace("%[^-/+|\w ]%", '', $clean);
$clean = strtolower(trim(substr($clean, 0, $maxLength), $delimiter));
@ryun
ryun / Plugin.example
Created November 17, 2012 04:09
Slugify jQuery plugin
<input type="text" name="title" value="" id="title">
<input type="text" name="slug" value="" id="slug">
<script>$(function(){ $("#title").c_slugify({slug: "#slug", type: "_"}) });</script>
@ryun
ryun / Example plugin tags layout
Created November 24, 2012 07:10
Global helper plugin tag
{{ pyroforms:get id="1" display="custom" }}
<h3>{{ form_name }}</h3>
{{ if global:is_get }}
<p>{{ form_info }}</p>
{{ endif }}
{{ header }}
<fieldset>
<legend>User:</legend>
{{ form_fields:name }}
@ryun
ryun / ajaxCache.example.js
Last active December 10, 2015 00:19 — forked from anonymous/Usage.js
Ajax auto-cache
var aCache = new ajaxCache({pk: "folder_id", prefix: "folder");
$('#folder_sel').change(function() {
var folder_id = $(this).val();
aCache.post(href_val, {'folder_id': folder_id}, function(data) {
//code
});
})
@ryun
ryun / jquery.precode_linenumbers.js
Created February 18, 2013 04:59
This little plugin takes a code block: "<pre><code></code></pre>" And turns it into a nice little scroll-able div with line numbers for the code.
(function($){
$.fn.linenumbers = function() {
return this.each(function() {
var $block = $(this);
if ( $block.parent().is("pre") )
{
$block.unwrap();