Skip to content

Instantly share code, notes, and snippets.

View jimjeffers's full-sized avatar

Jim Jeffers jimjeffers

View GitHub Profile
@jimjeffers
jimjeffers / jquery.plugin.databinder.coffee
Created December 5, 2010 16:12
A simple data binder plugin for jQuery.
# DataBinder is an object attached to the window. You can pass a JSON object
# and HTML node to the bind method to bind the JSON object data to the
# attributes mapped in the HTML node's data-bindings attribute. Providing
# an attribute data-template will cause the function to run recursively on child
# nodes. To prevent child nodes from being overwritten you can also set a
# data-preserve attribute on a given node. This will re-append a given elements
# children after updating it's content.
#
# Here's an example of a template in HTML:
# --------------------------------------------------------------------------------
# Pre-reqs
sudo apt-get -y install libc6-dev libssl-dev libmysql++-dev libsqlite3-dev make build-essential libssl-dev libreadline5-dev zlib1g-dev
# Install ruby 1.9.2 -p290
sudo mkdir /usr/local/src
cd /usr/local/src
sudo curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
sudo tar xzvf ruby-1.9.2-p290.tar.gz
cd ruby-1.9.2-p290
sudo ./configure --prefix=/usr/local
@jimjeffers
jimjeffers / jquery.plugin.calendar_input.coffee
Created March 29, 2010 06:13
A simple calendar input that only has essential functionality.
jQuery.fn.calendarInput: (options) ->
defaults: {
active_class: "active"
calendar_id: "calendar_table"
calendar_class: "calendar_object"
calendar_container_id: "calendar_container"
controls_class: "calendar_controls"
custom_class: false
default_class: "calendar_input"
dont_allow_dates_from_the_past: true
jQuery.fn.formtasticCustomSelect: (options) ->
defaults: {
activeClass: "active"
containerClass: "custom_select_container"
customClass: false
defaultClass: "custom_select"
dropdownClass: "custom_select_dropdown"
inactiveClass: "inactive"
indicatorClass: "custom_select_indicator"
linkClass: "custom_select_link"
jQuery.fn.formtasticCustomRadios: (options) ->
defaults: {
activeClass: "checked"
inactiveClass: "unchecked"
customClass: false
defaultClass: "custom_radio"
rowClass: false
spanClass: "radio_button_element"
}
settings: jQuery.extend(defaults,options)
/* How to fake Photoshops 'innershadow' layer effect with CSS3 modules and rgba. */
h1 {
background: rgba(255,255,255,.25);
border-radius:5px;
-o-border-radius:5px;
-icab-border-radius:5px;
-khtml-border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
/* The two rules below would accomplish the same thing. */
div#primary_content p {
font-size: 0.875em;
}
p {
font-size: 0.875em;
}
# Joins multiple assets into a single file.
# Just like asset caching in Ruby on Rails
# Except we also minify with the yui-compressor!
require "rubygems"
require "yui/compressor" # sudo gem install -r yui-compressor
# Specify paths for your assets.
paths = {
:js => "javascripts/",
:css => "stylesheets/"
@jimjeffers
jimjeffers / hover_example.html
Created November 4, 2009 08:36
Basic CSS Hover Example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>This is a page SUCKA!</title>
<style type="text/css" media="screen">
ul#primary_navigation {
display: block;
overflow: auto;
@jimjeffers
jimjeffers / NoHassleDropDown.js
Created February 27, 2009 16:23
Give any element a class of '.sub_navigation' and bam you have a hover show/hide with timeouts for better usability. Requires jQuery.
// Handle any drop down navigation systems.
$(document).ready(function(){
$('.sub_navigation').each(function() {
var menu = $(this);
menu.hide();
var parent = $(menu.parent().get(0));
var timeout = false;
parent.hover(function(){
if(!timeout && !menu.is(':visible')) {
timeout = setTimeout(function(){