Skip to content

Instantly share code, notes, and snippets.

View stan's full-sized avatar
💭
¯\_(ツ)_/¯

stan

💭
¯\_(ツ)_/¯
View GitHub Profile
@stan
stan / jquery.filterbydata.js
Created July 20, 2011 01:19 — forked from elijahmanor/jquery.filterbydata.js
filterByData jQuery Plugin
// 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:
@stan
stan / 0_instructions.txt
Created May 19, 2011 02:25 — forked from sgruhier/0_instructions.txt
Sprocket 2 in Rails 3.0.x ala Rails 3.1
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
@stan
stan / gist:958845
Created May 6, 2011 12:14
gem pristine --all --no-extensions
gem pristine --all --no-extensions
@stan
stan / gist:777387
Created January 13, 2011 04:25 — forked from vrinek/gist:451508
// 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')));
@stan
stan / gist:717551
Created November 27, 2010 03:59
Dropbox as incremental backup
# 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"
# 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
# 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
# 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
# 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
<!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; }