GeoEntity.last
SELECT geo_entities.* FROM geo_entities ORDER BY geo_entities.id DESC LIMIT 1
returns:
County id: 4, eid: nil, pid: nil, ename: nil, etype: 2, created_at: "2011-11-21 06:26:37", updated_at: "2011-11-21 06:26:37"
############################################################################# | |
# Class: Vash (Ruby Volatile Hash) | |
# Hash that returns values only for a short time. This is useful as a cache | |
# where I/O is involved. The primary goal of this object is to reduce I/O | |
# access and due to the nature of I/O being slower then memory, you should also | |
# see a gain in quicker response times. | |
# | |
# For example, if Person.first found the first person from the database & cache | |
# was an instance of Vash then the following would only contact the database for | |
# the first iteration: |
# A small DSL for helping parsing documents using Nokogiri::XML::Reader. The | |
# XML Reader is a good way to move a cursor through a (large) XML document fast, | |
# but is not as cumbersome as writing a full SAX document handler. Read about | |
# it here: http://nokogiri.org/Nokogiri/XML/Reader.html | |
# | |
# Just pass the reader in this parser and specificy the nodes that you are interested | |
# in in a block. You can just parse every node or only look inside certain nodes. | |
# | |
# A small example: | |
# |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Jed Schmidt <http://jed.is> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
# This method finds related articles using Jaccard index (optimized for PostgreSQL). | |
# More info: http://en.wikipedia.org/wiki/Jaccard_index | |
class Article < ActiveRecord::Base | |
def related(limit=10) | |
Article.find_by_sql(%Q{ | |
SELECT | |
a.*, | |
( SELECT array_agg(t.name) FROM taggings tg, tags t |
#!/bin/bash | |
# Idea and interface taken from https://github.com/macmade/host-manager | |
path="/etc/hosts" | |
addusage="Usage: `basename $0` -add host address" | |
remusage="Usage: `basename $0` -remove host" | |
case "$1" in | |
-add) | |
if [ $# -eq 3 ]; then | |
if [[ -n $(grep "^$3.*[^A-Za-z0-9\.]$2$" ${path}) ]]; then |
GeoEntity.last
SELECT geo_entities.* FROM geo_entities ORDER BY geo_entities.id DESC LIMIT 1
returns:
County id: 4, eid: nil, pid: nil, ename: nil, etype: 2, created_at: "2011-11-21 06:26:37", updated_at: "2011-11-21 06:26:37"
#!/usr/bin/env python | |
import gevent.monkey | |
gevent.monkey.patch_all() | |
import boto | |
import config | |
import gevent | |
import gevent.pool | |
import os |
Place me.mailcatcher.plist into ~/Library/LaunchAgents, then run launchctl load ~/Library/LaunchAgents/me.mailcatcher.plist
.
If you use pow, echo 1080 > ~/.pow/mailcatcher
and go to http://mailcatcher.dev, otherwise use http://localhost:1080.
Currently pow doesn't seem to pass websockets through correctly. Looking into this.
// This document distills the magic that happens when you create a file with the ".jst" | |
// and ".ejs" extensions anywhere on your asset path in Ruby on Rails, courtesy of the | |
// Sprockets library (https://github.com/sstephenson/sprockets). | |
// | |
// For the purpose of this example, imagine that you have created a template for | |
// messages in `app/assets/javascripts/backbone/templates/messages/message.jst.ejs` | |
// with the following contents: | |
// | |
// <h1><%= user.full_name %></h1> | |
// <p><%= body %></p> |
CREATE OR REPLACE FUNCTION public.url_slug ( | |
s_texto text | |
) | |
RETURNS varchar AS | |
$body$ | |
DECLARE | |
total integer; | |
BEGIN | |
s_texto := replace(s_texto , 'U$', 'dolares'); | |
s_texto := replace(s_texto , 'R$', 'reais'); |