Skip to content

Instantly share code, notes, and snippets.

View adamesque's full-sized avatar

Adam Luikart adamesque

View GitHub Profile
(function () {
var selector = window.prompt("Enter a selector to highlight", "a, .gl, a span"),
els = document.querySelectorAll(selector),
el;
for each (el in els) {
if (el.style) el.style.backgroundColor = "rgba(255,0,0,0.5)";
}
}());
var placeholders = function () {
var body = $(document.body),
inputs = $("label.ui_placeholder").map(function () {
var label = $(this),
input = $("#" + label.attr("for"));
if (input.val()) {
label.hide();
}
@adamesque
adamesque / raphael.html
Created November 3, 2010 20:23
Modified raphael.js to allow fill image rotation
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="raphael.js"></script>
<style>
div {
/* border: 1px solid #ccc;*/
}
</style>
</head>
@adamesque
adamesque / Rakefile
Created January 14, 2011 20:01
Custom nanoc Rakefile
require 'nanoc3/tasks'
require 'rubygems'
def rebuild_site(relative)
begin
puts ">>> Change Detected to: #{relative} >> Update Complete "
sh 'nanoc co'
rescue StandardError => e
puts e
end
@adamesque
adamesque / preloader.js
Created February 16, 2011 23:38
Uses jQuery's new Deferred object to help with image loading
/**
* Helper function for passing arrays of promises to $.when
*/
jQuery.whenArray = function ( array ) {
return jQuery.when.apply( this, array );
};
/**
* Accepts a single image src or an array of image srcs.
@adamesque
adamesque / gist:940823
Created April 25, 2011 17:00
Calculate elapsed time (to be added to a "When did you mean to turn this off" Harvest overnight timer UI)
(new Date("Apr 22 2011 17:00") - new Date("Apr 22 2011 16:01")) / (1000 * 60 * 60)
@adamesque
adamesque / config.ru
Created June 1, 2011 19:09
Password-protected Middleman via Rack/Heroku
require 'rubygems'
require 'middleman'
middleman_app = Middleman::Server.new
protected_middleman = Rack::Auth::Basic.new(middleman_app) do |username, password|
[username, password] == ['theuser', 'thepassword']
end
run protected_middleman
@adamesque
adamesque / config.ru
Created June 2, 2011 21:05
Feature-incomplete Middleman/Rack::Rewrite demo
require 'rubygems'
require 'rack-rewrite'
require 'middleman'
use Rack::Rewrite do
rewrite %r{^/([^\./]+)/?$}, '/$1.html'
end
run Middleman::Server
@adamesque
adamesque / .bash_profile
Created July 19, 2011 19:25
My .bash_profile
if [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then
source /usr/local/etc/bash_completion.d/git-completion.bash
fi
alias ls="ls -F"
alias l="ls -G"
alias la="ls -a"
alias ll="ls -al"
alias ps="ps -ajx"
alias cdd="cd"
@adamesque
adamesque / hyphenated-completion.vim
Created August 8, 2011 16:00
Tell vim to treat '-' as a keyword char for tab completion in HTML & CSS files.
if has("autocmd")
" Treat '-' as a keyword char in HTML & CSS
autocmd InsertEnter *.{html,haml,css,scss,sass,slim} setlocal iskeyword+=-
autocmd InsertLeave *.{html,haml,css,scss,sass,slim} setlocal iskeyword-=-
endif