Skip to content

Instantly share code, notes, and snippets.

@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
@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: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:
<
%3C
&lt
&lt;
&LT
&LT;
&#60
&#060
&#0060
&#00060
# 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
#!/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
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
@paultyng
paultyng / redis_queue.rb
Created July 9, 2014 02:20
RedisQueue mock for SQS
require 'redis'
RedisMessage = Struct.new(:body)
class RedisQueue
def initialize(redis)
@redis = redis
end
def poll(&block)
  1. General Background and Overview
@paultyng
paultyng / bling.js
Last active August 29, 2015 14:23 — forked from paulirish/bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn)
}
NodeList.prototype.__proto__ = Array.prototype