Skip to content

Instantly share code, notes, and snippets.

View dcneiner's full-sized avatar

Doug Neiner dcneiner

View GitHub Profile
// Adapted from code provided by 37Signals on their Signal vs. Noise blog.
// Added support for Twitter date parsing.
// Call DateHelper.time_ago_in_words_with_parsing(twitter_date_as_string) to use.
var DateHelper = {
date_parse_from_twitter: function(str){
parts = str.match(/^([a-z]{3}) ([a-z]{3}) (\d{2}) (\d{2}):(\d{2}):(\d{2}) \+(\d{4}) (\d{4})$/i);
if(!parts) return false;
var date_str = parts[1] + ", " + parts[3] + " " + parts[2] + " " + parts[8] + " " + parts[4] + ":" + parts[5] + ":" + parts[6] + " GMT";
/*
* jQuery fasterTrim Plugin
* version: 1.0.1
* @requires jQuery v1.0.x or later
*
* licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* @version $Id: jquery.fastertrim.js 2 2010-03-04 12:00:00Z $
* @author Travis Hardiman https://forum.jquery.com/user/travis.hardiman http://travis.servebeer.com
/*
* jQuery UI CSS Framework
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
* To view and modify this theme, visit http://jqueryui.com/themeroller/
*/
/* Component containers
----------------------------------*/
(function($){
$.widget('pixel.countdown', {
options: {
milestones: [
{ label: "one_minute", minute: 1 },
{ label: "five_minutes", minute: 5, second: 30 }
],
interval: 1, // Interval in seconds to refresh the widget
formatter: function(min, sec){
// How I normally did it:
(function ($) {
var global = {
// ...
};
window.global = global;
// Valid
var myFunction = function () { };
var myFunction = function (first, second, third) { };
function myFunction() { }
function myFunction(first, second, third) { }
d = 1 + 2 / (3 * 5);
if (test === true) {
// Private Scope
(function ($) {
var variable = "Hello";
}(jQuery));
alert(typeof variable); // undefined
// Private Scope, Public Variable
var variable = (function ($){
var first = "Hel", second = "lo";
a:after {
...
content: attr(title); /* Default to title */
...
};
html.js a:after {
...
// Original code from David Walsh
jQuery(document).ready(function() {
/* fetch elements */
jQuery('form.follow-form').each(function() {
/* stop form event */
jQuery(this).bind('submit',function(e) {
/* stop event */
e.preventDefault();
/* "on request" */
jQuery(this).find('i').addClass('active');
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {