Skip to content

Instantly share code, notes, and snippets.

View hungryblank's full-sized avatar

Paolo Negri hungryblank

  • Contentful
  • Berlin, Germany
View GitHub Profile
@hungryblank
hungryblank / Invalidation.js
Last active August 29, 2015 14:25
Invalidate CloudFront cache for static websites hosted on S3
'use strict';
var crypto = require('crypto');
var path = require('path');
var Promise = require('bluebird');
var Invalidation = function (config, s3EventRecord) {
this.record = s3EventRecord;
this.config = config;
@hungryblank
hungryblank / aws_sdb_bare_demo.rb
Created May 14, 2009 20:37
Short code tutorial for the aws_sdb_bare gem
#http://github.com/hungryblank/aws_sdb_bare
#
#remember to install the gems!!
#sudo gem install hungryblank-aws_sdb_bare -s http://gems.github.com
#sudo gem install open-uri
#
#The first thing you probably want to do on SimpleDb is creating a domain.
#The domain is a container for SimpleDB records.
#let's require the gems we need
require 'rubygems'
require 'aws_sdb_bare'
require 'nokogiri'
require 'net/http'
require 'uuid'
include AwsSdb
include AwsSdb::Request
module HttpHandler
require 'nokogiri'
class Page
attr_accessor :html
include EM::Deferrable
def initialize(url_as_a_hash)
client = EM::Protocols::HttpClient.request(url_as_a_hash)
@html = nil
LIBDIR = `erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell`
VERSION = 0.0.1
CC = erlc
ERL = erl
EBIN = ebin
CFLAGS = -I include -pa $(EBIN)
COMPILE = $(CC) $(CFLAGS) -o $(EBIN)
EBIN_DIRS = $(wildcard deps/*/ebin)
syntax on
"Rainer paste
set ffs=unix " only support unix (could also be dos,mac)
syntax on " syntax highlighting on
set ruler " Always show current positions along the bottom
set noerrorbells " don't make noise
set showmatch " show matching brackets
set mat=5 " how many tenths of a second to blink matching brackets for
set so=3 " Keep 3 lines (top/bottom) for scope
#backup from google cache, still useful for svn repos with funny structure that git svn can't understand automatically
First, clone the SVN repo with:
git-svn clone svn+ssh://your-server/home/svn/project-name/trunk -r NNNN project-name.git
where NNNN is some relatively recent revision, unless you like waiting forever for git-svn to sync. Make sure that the revision number you pick is actually on trunk -- don't just choose an arbitrary number in the past. Don't bother trying to pull branches with the -b argument at this point -- if that worked, we wouldn't be doing this.
Then, cd into project-name.git and:
# A ping pong ball, which pings and pongs properly
class Ball
SOUNDS = %w(ping pong)
def initialize
@hit_count = 0
end
def hit
code stats retrieved from the sadly now dismissed getcaliper.com
================================================================
1 LOC /1.1 LOTC
Flay 1 duplication /204.9 LOC
flog method: 10.1
Saikuro method 2.2
Reek 1 smell/9.6 LOC
Roodi 1 issue/89 LOC
require 'rubygems'
#require 'spec/rake/spectask'
require 'rake/gempackagetask'
#Spec::Rake::SpecTask.new
gem_spec = eval(IO.read(File.join(File.dirname(__FILE__), "aws-sdb.gemspec")))
desc "Open an irb session preloaded with this library"
task :console do