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
require 'rubygems' | |
require 'sinatra' | |
require 'redis' | |
# To use, simply start your Redis server and boot this | |
# example app with: | |
# ruby example_note_keeping_app.rb | |
# | |
# Point your browser to http://localhost:4567 and enjoy! | |
# |
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
import re | |
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone | |
from metaphone import dm as double_metaphone | |
# get the Redis connection | |
from jellybean.core import redis | |
import models | |
# Words which should not be indexed |
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
# rubygems DNS is temporarily down, put this into your /etc/hosts to install gems, | |
# but don't forget to remove the entries once their DNS is back up again | |
72.4.120.124 rubygems.org | |
207.171.181.231 production.s3.rubygems.org | |
216.137.45.24 production.cf.rubygems.org |
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
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001 | |
From: Ilya Grigorik <ilya@igvita.com> | |
Date: Thu, 10 Jun 2010 00:46:48 -0400 | |
Subject: [PATCH] async rails3 | |
--- | |
Gemfile | 6 ++++++ | |
app/controllers/widgets_controller.rb | 6 ++++++ | |
app/models/widget.rb | 2 ++ | |
config.ru | 1 + |
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; } |
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
# 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://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://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://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" |