Skip to content

Instantly share code, notes, and snippets.

@twalker
twalker / enterclick
Created July 19, 2009 21:15
An Element extension for clicking a button when the enter key is pressed.
/* onEnterClick v1.0
* (c) 2009 Tim Walker
* onEnterClick is freely distributable under the terms of an MIT-style license.
*
* EnterClick listens on a containing element for the enter/return key being pressed.
* When the enter key is pressed within a child input element that will submit the form,
* it will prevent the default form submittal and fire the click event of a designated button.
* Depends on Prototype.js (v1.6.+) and extends Element.
*
* Usage:
@twalker
twalker / jQuery.revealMore
Created June 16, 2010 02:15
A tiny jQuery plugin to reveal a target element from a triggering link.
/*
* revealMore
*
* A tiny jQuery plugin to reveal a target element from a triggering link.
*
* Usage:
* <a class="more_trigger" href="#more1">more...</a>
* <div id="more1">More Info</div>
*
* <script type="text/javascript">
@twalker
twalker / pattern : dynamic sub-module
Created October 31, 2010 19:32
sub-module that loads itself dynamically to its parent
// sub-module that loads itself dynamically to its parent
// see: http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth
var UTIL = (function (parent, $) {
var self = parent.ajax = parent.ajax || {};
self.get = function (url, params, callback) {
return $.getJSON(url, params, callback);
};
// etc...
@twalker
twalker / UTIL.console.js
Created November 11, 2010 20:26
A condom for basic console logging.
/**
* @name UTIL.console
* UTIL.console acts as a proxy to native console, using window.status for ie6/7.
* For when you forget some console calls in your source and don't want the output
* shown in staging/production environments. We have enough stuff to remember, eh.
* Logging defaults to only being enabled on localhost (or other logic).
*
* @example
* UTIL.console.log("Hello", "World"); // outputs "Hello World"
* UTIL.console.disable();
@twalker
twalker / .emacs
Created February 27, 2011 01:56
a minimal emacs setup
(custom-set-variables
;; custom-set-variables added by Custom.
'(cua-mode t nil (cua-base))
'(show-paren-mode t))
(custom-set-faces
;; custom-set-faces added by Custom.
)
;; http://www.emacswiki.org/emacs/EmacsCrashCode
(setq-default indent-tabs-mode t)
(setq-default tab-width 2)
@twalker
twalker / git_prompt
Created March 3, 2011 02:03
add git branch to bash prompt
# git prompt ( put in .profile or .bashrc)
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '
export GIT_PS1_SHOWDIRTYSTATE=1
@twalker
twalker / aptana.desktop
Created October 16, 2011 02:58
aptana3 unity desktop launcher
[Desktop Entry]
Name=Aptana Studio 3
Comment=Integrated development environment (IDE) for building Ajax web applications.
Exec=/home/twalker/bin/AptanaStudio3/AptanaStudio3 -applciation
Icon=/home/twalker/bin/AptanaStudio3/icon.xpm
Terminal=false
Type=Application
StartupNotify=true
Categories=Development;RevisionControl;
X-GNOME-FullName=Aptana Studio 3
@twalker
twalker / remove_bom
Created May 4, 2012 17:10
Remove BOM from js files
# Removing BOM from all js files in current directory:
sed -i '1 s/^\xef\xbb\xbf//' *.js
@twalker
twalker / bbv.sublime-snippet
Last active October 8, 2015 15:08
sublime snippet for backbone view module with mustache
<snippet>
<content><![CDATA[
/**
* ${1:name} view
*/
define(function(require){
var Backbone = require('backbone'),
Mustache = require('mustache'),
mainTemplate = require('text!views/${1:name}/${1:name}.mustache');
@twalker
twalker / git_prompt_with_smiley
Created September 14, 2012 03:10
git integrated bash prompt with smiley
# git
# pulled together with posts and gists starting at: https://bbs.archlinux.org/viewtopic.php?id=50885&p=11
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"