This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.elijahmanor.com/2011/07/filterbydata-jquery-plugin.html | |
// https://gist.github.com/1048942 | |
(function($) { | |
/* by Elijah Manor with collaboration from Doug Neiner | |
* Filter results by html5 data attributes either at | |
* design or at runtime | |
* | |
* Usages: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript | |
powered JS and SASS powered CSS with YUI compression all via the magic of rack. | |
This stuff will be native in Rails 3.1 and the layout of the files on the | |
filesystem will be different but this guide will get you working with it | |
while we wait for all that to finalize. | |
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist. | |
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem pristine --all --no-extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/3503660/upgrading-with-parameter-on-a-link-to-remote-in-rails-3 | |
// http://railsforum.com/viewtopic.php?id=42215 | |
// http://stackoverflow.com/questions/2508213/rails3-link-to-with-attribute | |
$$('a[data-remote=true]').each(function(a){ | |
a.onclick = function(){ | |
href = a.getAttribute('href'); | |
url = href.split('?')[0]; | |
params = href.split('?')[1]; | |
newParam = encodeURI(eval(a.getAttribute('data-with'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://finishtherace.net/wp/?p=622 | |
# Dropbox as incremental backup. | |
# Justin Schwalbe | |
# http://finishtherace.net/wp/?p=622 | |
password="trickypassword" | |
dropboxdir="~/Dropbox/backups/" #change this as needed, make sure it exists | |
backupfolders="/path/to/folder /path/to/second/folder /and/so/on" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://apidock.com/rails/Enumerable/group_by#508-Array-clustering | |
module Enumerable | |
# clumps adjacent elements together | |
# >> [2,2,2,3,3,4,2,2,1].cluster{|x| x} | |
# => [[2, 2, 2], [3, 3], [4], [2, 2], [1]] | |
def cluster | |
cluster = [] | |
each do |element| | |
if cluster.last && yield(cluster.last.last) == yield(element) | |
cluster.last << element |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://snippets.dzone.com/posts/show/7312 | |
require 'ostruct' | |
class MoreOpenStruct < OpenStruct | |
def _to_hash | |
h = @table | |
#handles nested structures | |
h.each do |k,v| | |
if v.class == MoreOpenStruct | |
h[k] = v._to_hash | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.jroller.com/obie/entry/quickly_generate_random_dates_in | |
class Time | |
def self.random(years_back=5) | |
year = Time.now.year - rand(years_back) - 1 | |
month = rand(12) + 1 | |
day = rand(31) + 1 | |
Time.local(year, month, day) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/ | |
def is_prime(n) | |
("1" * n) !~ /^1?$|^(11+?)\1+$/ | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Cross-browser kerning-pairs & ligatures</title> | |
<style> | |
body { font-family: sans-serif; background: #f4f3f3; color: rgba(40, 30, 0, 1); width: 500px; margin: 80px auto; padding: 0px; } | |
a { color: rgba(15, 10, 0, 0.8); text-decoration: none; border-bottom: 1px solid; padding: 1px; -webkit-transition: background 1s ease; } | |
a:hover { background: rgba(0, 220, 220, 0.2); } | |
p { line-height: 1.5; padding: 0px 1em 0em 0em; } |