Skip to content

Instantly share code, notes, and snippets.

View thecocktail's full-sized avatar

The Cocktail thecocktail

View GitHub Profile
#!/usr/bin/ruby
# seen on ap 11:22:33:44:55:66 with rssi 24 at Tue Mar 26 11:50:31.836 UTC 2013
require 'rubygems'
require 'sinatra'
require 'json'
if ARGV.size < 2
# The sinatra gem parses the -o and -p options for us.
puts "usage: sample_push_api_server.rb [-o <addr>] [-p <port>] <secret> <validator>"
@thecocktail
thecocktail / default.vcl.pl
Created December 5, 2011 12:12 — forked from bmarini/default.vcl.pl
A good varnish config for a Rails app
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)
@thecocktail
thecocktail / gist:9281
Created September 7, 2008 16:04
Rake task to validates massively html files
# # Massive html validation task
#
# This rake task comes from the nanoc validation task (http://gist.github.com/8961)
# Copy this Rakefile to the root of your htmls or add the task to your existing Rakefile
# and run:
#
# rake validate
#
# and that's all :)
@thecocktail
thecocktail / validate.rake
Created September 5, 2008 12:27
Nanoc rake task to make a w3c validation of your output html/css
# #Nanoc validation task
#
# To use this validation task you need the w3c_validators gem
# gem install w3c_validators
# and run rake validate on your project root
#
require 'yaml'
require 'w3c_validators'
include W3CValidators
@thecocktail
thecocktail / page_helper.rb
Created September 4, 2008 21:58
Nanoc plugin to solve usual problems working with nanoc projects
# This function helps to build a relative path from the page to the output root.
#
# Usage: <img src="<%= page_depth @page.path %>images/hardon.png" alt="wadus" />
def page_depth path
depth = ""
(path.split("/").size-1).times do
depth = depth + "../"
end
depth
end
@thecocktail
thecocktail / sips_flatten.rb
Created September 4, 2008 18:40
Nanoc plugin that flattens fireworks pngs
# Sips Flatten Filter for nanoc 2.1.1
#
# Uses the 'sips' command line tool in Mac OS X to flatten Fireworks images
# Quick hack, use at your own risk. Don't blame us if it destroys your carefully
# crafted images
module Nanoc::BinaryFilters
class SipsFlattenFilter < Nanoc::BinaryFilter