Skip to content

Instantly share code, notes, and snippets.

View jasonlong's full-sized avatar

Jason Long jasonlong

View GitHub Profile
<% semantic_form_for @post do |form| %>
<% form.inputs do %>
<%= form.input :first_name %>
<%= form.input :last_name %>
<% end %>
<% end %>
<% end %>
<form action="#" method="post" class="formtastic">
<fieldset class="inputs">
<ol>
<li class="string">
<label for="first_name">First Name</label>
<input id="post_first_name" name="post[first_name]" type="text" />
</li>
<li class="string">
<label for="last_name">Last Name</label>
<input id="post_last_name" name="post[last_name]" />
<li class="string error">...
form.formtastic fieldset ol li.error {
/* so that we can absolutely position elements relative to this */
position: relative;
}
form.formtastic fieldset ol li.error img {
/* positioned to the left of the label */
position: absolute;
left: -45px;
top: -10px;
$('form.formtastic fieldset ol li.error').each(function() {
$(this).prepend('<img src="/images/icons/error_marker.png" />');
});
var TT = TT || {};
TT.PAGE_WIDTH = 800;
TT.PAGE_HEIGHT = 500;
TT.PAGE_MIN_WIDTH = 1000;
TT.PAGE_MIN_HEIGHT = 680;
TT.PAGE_MARGIN_LEFT = 32;
TT.PAGE_MARGIN_TOP = 10;
TT.BOOK_WIDTH = 1660;
TT.BOOK_WIDTH_CLOSED = TT.BOOK_WIDTH / 2;
TT.BOOK_HEIGHT = 520;
<!-- So, instead of... -->
<img src="/images/profile.jpg" alt="Sam Adams" width="80" height="100" />
<!-- they use... -->
<img src="/images/spaceout.gif" data-defer-src="/images/profile.jpg" alt="Sam Adams" width="80" height="100" />
<!-- where spaceout.gif is a single, transparent pixel. -->
function loadDeferredImages() {
$$('img[data-defer-src]').each(function(i) {
i.set('src', i.get('data-defer-src'));
});
}
@jasonlong
jasonlong / tablesorter.js
Created June 17, 2011 19:22
Adding a class to <td> elements with jquery.tablesorter.js
$('table.sortable').tablesorter();
$('table.sortable th').bind('click', function() {
// remove sorted class from all table cells and start fresh
$(this).closest('table').find('td.sorted').removeClass('sorted');
// find out which column was clicked and add the sorted class to
// the <td> cells below it
var index = $(this).prevAll().length;
$(this).closest('table').find('tr').each(function(row) {
@jasonlong
jasonlong / massage.md
Created July 6, 2012 13:07
Massage Therapist

Columbus Massage Therapist Recommendation

tl;dr - See https://plus.google.com/117242785508675433416/about?gl=us&hl=en

Recently, someone on Twitter asked for a recommendation for a massage therapist. I ended up emailing the info to that person plus another who happened to see the conversation. Since then, a few more people have asked for the info as well.

Why I Went To a Massage Therapist

I've had lower and upper back pain off and on for over 10 years. I've tried going to chiropractors, orthopedic specialists, and spa-type massage places. Nothing ever works.