Skip to content

Instantly share code, notes, and snippets.

@nfo
nfo / gist:456198
Created June 28, 2010 18:41
Facebooker: replace session_key by access_token
# Monkey patch Facebooker to set an access token instead of a session key,
# and use the access token on EVERY requests.
Facebooker::Session.class_eval do
def post_without_logging_with_access_token(method, params = {}, use_session_key = true, &proc)
params[:access_token] ||= (params.delete(:session_key) || @session_key)
post_without_logging_without_access_token(method, params, false, &proc)
end
alias_method_chain :post_without_logging, :access_token
end
@nfo
nfo / riak_curb_logger.rb
Created November 4, 2010 19:11
Prints all the sent HTTP queries, with the headers and data.
Riak::Client::CurbBackend.class_eval do
private
def perform_with_logs(method, uri, headers, expect, data=nil)
puts "\e[31m#{method.upcase} #{uri}\e[0m"
puts "\t\e[33m#{headers}\e[0m"
# puts "\t\e[36m#{expect}\e[0m"
puts "\t\e[34m#{data}\e[0m" if data
# puts "\t\e[37m#{caller.last}\e[0m"
puts
perform_without_logs(method, uri, headers, expect, data)
@nfo
nfo / screenme.rb
Created December 1, 2010 11:27
Sends a screenshot via HTTP (faster than logging to LogMeIn for simple checks)
require 'rubygems'
require 'sinatra'
get '/' do
Dir.mktmpdir('screenme') do |dir|
file = File.join(dir, Time.now.strftime('%Y%m%d%H%M%S') + '.png')
%x(/usr/sbin/screencapture -x #{file})
send_file file
end
end
@nfo
nfo / gist:1244830
Created September 27, 2011 11:09
Compiling jenkins_campfire_plugin ... really ?
[user@server yum.repos.d]# yum install maven2
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: centos.crazyfrogs.org
* epel: mirror.bytemark.co.uk
* extras: centos.crazyfrogs.org
* jpackage-generic: jpackage.netmindz.net
* jpackage-generic-updates: jpackage.netmindz.net
* rpmforge: apt.sw.be
* rpmforge-extras: apt.sw.be
@nfo
nfo / README.md
Created September 10, 2012 15:54
A microgem to query the Amazon Web Services (S3/EC2/etc) usage reports.
@nfo
nfo / README.md
Last active January 16, 2017 22:54
Kafka Streams - Handling records with same ID with updated metrics.
@nfo
nfo / README.md
Created January 16, 2017 18:41
Kafka Streams - A serde for timed windows (start + end)
@nfo
nfo / InValueTimestampExtractor.java
Created January 16, 2017 22:13
Kafka Streams - Custom timestamp extractor, from a `long` field named "timestamp"
/**
* Handle records with a timestamp in their Avro value.
* Expects a LONG field named "timestamp".
* Any problem makes this extractor return the record's internal timestamp.
*/
public class InValueTimestampExtractor implements TimestampExtractor {
@Override
public long extract(ConsumerRecord<Object, Object> record) {
if (record != null && record.value() != null) {