sleek html5 video player. eagerly looking forward to firefox and ie flash fallback support.
The
Palm
Civet
rendering rails partials with ajax w/o a framework
ever wanted to quickly create a link in rails that, when clicked, dynamically renders a partial in a targeted element? accepting bonus points for being framework agnostic? throw this puppy in your application helper =>
def remote_partial_link(*args)
name = args.first
partial = args.second
target_id = args.third
html_options = args.fourth
locals = args.fifth
if html_options
html_options = html_options.stringify_keys
tag_options = tag_options(html_options)
else
tag_options = nil
end
if locals
p = render_to_string :partial => partial, :locals => locals
else
p = render_to_string :partial => partial
end
p = escape_javascript(p).gsub("\"","'")
"<a onclick=\"document.getElementById('#{target_id}').innerHTML = '#{p}'\" "+
"#{tag_options}>#{name}</a>"
end
basically, its a bastardized version of rails built-in link_to helper. with it, in your views you can write =>
<%= remote_partial_link("Add Link", "lists/link", "link-#{i}",
{ :class => "ajax" }, { :i => i }) %>
the only limitation is that these are generated on the page’s load, so it can’t account for any remote calls that happens after that. but that also makes this solution good for performance, since the script is baked inline to the element and ready to fire. the only other piece of set-up is making the render_to_string method accessible in your helpers from your application controller =>
helper_method :render_to_string
fluid for web development
i have been using fluid, the mac osx application for wrapping sites as their own webkit applications for a while, but only for beasts like gmail and google reader. then i realized, fluid makes a great sidekick for my new emacs driven development environment:
* it saves the previous session’s tabs, so you can preserve and separate your development from daily browsing.
* you can give it a global hotkey to pull it up quickly.
* you get to use webkit’s ever-improving, top-notch webkit inspector.
setting it up is super easy. for example, if you’re working in rails, create a new fluid app at the address 0.0.0.0:3000, call it whatever you want, give it a fancy icon and you’re ready to apple+tab between the guts and face of your project.
more rails development means more time in the script/console and irb, but it can quickly become a headache with doing ugly things like returning activerecord objects. for that, hirb’s table view is a lifesaver. check out this example output =>
irb>> Tag.last
+-----+-------------------------+---------------+-----------+-----------+-------+
| id | created_at | name | namespace | predicate | value |
+-----+-------------------------+---------------+-----------+-----------+-------+
| 907 | 2009-03-06 21:10:41 UTC | gem:tags=yaml | gem | tags | yaml |
+-----+-------------------------+---------------+-----------+-----------+-------+
1 row in set
=>true
if you want to get more snazzy, you can define your own views for a more custom output. git it at hirb’s github page.
to enable hirb by default in your rails application, append this to the end of your config/environment.rb file =>
if $0 == 'irb'
require 'hirb'
Hirb.enable
end
want to use javascript to create images and graphs with html5’s sexy <canvas> element? cool, but internet explorer doesn’t support it? slap this canvas to vml converting library in your head. done.
mmm, a tiny (1.8 kb tiny) ajax javascript framework. a perfect replacement for jquery if all you need is a set of shortcuts for form serializing, get-ing, and post-ing.
sync coda, espresso, textmate across multiple computers with dropbox
if you don’t use dropbox, the multi-platformed, cloud-backed-up, version-tracking storage-and-sharing application, you are most likely a) uninformed or b) an idiot. it’s one of those ‘how did i live without it’ kinds of things.
recently i started unlocking a new batch of syncing/redundancy potential through the process of creating symbolic links, which are aliases that jump to a different directory on your system. with these, you can dropbox-ize folders that would normally reside in your ~/Library directory. for example, crack open a terminal window =>
mv ~/Library/Application\ Support/Textmate ~/Dropbox
ln -s ~/Dropbox/Textmate ~/Library/Application\ Support/Textmate
this would move your textmate bundles and preferences to your dropbox, but to your mac, it would seem to be in the same location. to use the same textmate folder on a different mac, back-up your ~/Library/Application\ Support/Textmate folder and run the 2nd command on that machine. the same process should work for coda or espresso.
for more info on what else you can do with dropbox, check out dropbox’s wiki page.
regular expressions (aka regex) are very handy for defining patterns to look for when searching through text. without instruction on the matter though, they can look as cryptic as hieroglyphics. take john gruber’s liberal, accurate regex pattern for matching urls =>
\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))
alan storm does a nice job dissecting the regex to show how it works and suggests some areas for improvement.
with both articles in the latest edition of a list apart concerning web typogrpahy and the recent release of much-hyped typekit, the smell of new type freedom is in the air.
unfortunately, @font-face support is still fragmented by different syntax and file formats across the browsers. tim brown has an excellent post on how to properly hit all your bases, but doing such requires 4 different font formats. conveniently, he links to font squirrel’s @font-face kit generator, a handy tool for transcribing a .ttf or .otf font into .eot, .svg, and .woff versions.
as a heavy jquery w/ plugins user, i usually end up with quite a few javascript include lines in the header. in an attempt to cut down on the load time, i’m giving sprockets a whirl. sprockets is a javascript organization and compressor library written in ruby.
what turned me onto trying sprockets was the success i have had with less, the dynamic css library, which allows me easy management over grids, fonts, colors, and general sets of attributes from one css file.
the one thing i was bummed to not see in the documentation was the ability to run a rake script that would watch for file changes and keep the master js file constantly updated, like you can with less.
luckily ‘the google’ revealed this gist, which is a simple rake file for just that. given a directory structure of js/src (for your source files) and js/dist (for your build files), save this file as a rakefile.rb in js/ and simple run in the command line =>
rake watch
compiling and sharing code, ideas, and tools for making better websites and applications.
by justin talbott {email me}