Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Please read http://otobrglez.opalab.com for more information about this code.
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end
# 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
<
%3C
&lt
&lt;
&LT
&LT;
&#60
&#060
&#0060
&#00060
@paultyng
paultyng / gist:3236880
Created August 2, 2012 13:03
SES Setup for IIS Relay

Instructions taken from Amazon's docs and modified as necessary.

1. Install stunnel:

  • Download from stunnel's download page
  • Run installer w/ default options, create self signed cert by answering questions
  • Open the c:\program files (x86)\stunnel\stunnel.conf file in notepad
  • Clear all the server configs (under Example SSL server mode services section, won't have a client = yes line)
  • Create a new client config:
@paultyng
paultyng / VendorHoursGrammar.cs
Created July 16, 2012 18:39
Vendor Hours Grammar (Irony)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Irony.Parsing;
namespace IronyHours
{
public class HoursGrammar : Grammar
{
@paultyng
paultyng / gist:2830129
Created May 29, 2012 19:18 — forked from kylefritz/gist:2563866
Delete branches that have been merged into HEAD
#all local branches that are merged into HEAD
git branch -d `git branch --merged | grep -v '^*' | tr -d '\n'`
#Delete all remote branches that are merged into HEAD
#jump back to master
git co master
#get rid of all local branches not on origin