Skip to content

Instantly share code, notes, and snippets.

/* You can use any element aside from the example below.
How it works is that you simply create .hover, .active styles
for whatever element you use this on. Works very well. Uses
the underscore hack to targe ie6.
*/
input, button {
_azimuth: expression(
this.onmousedown = this.onmousedown || new Function("this.className += ' active'"),
this.onmouseup = this.onmouseup || new Function("this.className = this.className.replace('active','')"),
<small><ul>
<% @curators.each do |member| %>
<li><%= member.person.name %></li>
<% end %>
</ul></small>
@atinypixel
atinypixel / grow_text_area.js
Created January 17, 2009 06:29
Automatically grow your textarea inputs
// USAGE EXAMPLE (in HTML)
// <script type="text/javascript">
// new ResizingTextArea("dom_id_for_textarea_here");
// </script>
var ResizingTextArea = Class.create();
ResizingTextArea.prototype = {
defaultRows: 2,
@atinypixel
atinypixel / gist:52561
Created January 25, 2009 22:00 — forked from dhh/gist:45076
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
#
# Inspired by
# http://dev.rubyonrails.org/svn/rails/plugins/account_location/lib/account_location.rb
#
module SubdomainAccounts
def self.included( controller )
controller.helper_method(:account_domain, :account_subdomain, :account_url, :current_account, :default_account_subdomain, :default_account_url)
end
protected
@atinypixel
atinypixel / reset.sass
Created February 3, 2009 06:49
Eric Meyer's Reset CSS (using sass)
/*
Reset
By Eric Meyers
PURPOSE:
Resets everything to zero for better browser compatibility
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, p, blockquote, pre, a,
abbr, acronym, address, big, cite, code, small, strike, strong, sub, sup, tt, var,
require 'csv'
CSV.open('sample_users.csv', 'r').each do |row|
User.create(:username => row[0], :email => row[1])
end
# Simple example
# Regex is between these -&gt; \\ and my replacement string is in single quotes
def change_p_tags_to_divs(content)
content.gsub(\<.*?(p)>\, 'div')
end
# Complex example
# This (real) example puts `@tags` in a hyperlink, finds a path (if any) and then spits out the result.
# Rails modules for user controllers and models.
module Tiny
module Controller
module Accounts
def self.included(controller)
controller.helper_method(
:current_account,
:account_domain,
:account_subdomain,
# To parse a tweet from twitter to get teh '@' , '#' and the text seperated
parsed_text = tweet.text.gsub(/ ?(@\w+)| ?(#\w+)/) { |a| ((a.include?('#')) ? tags : replies) << a.strip.gsub(/#|@/,''); '' }