Skip to content

Instantly share code, notes, and snippets.

View vijaykramesh's full-sized avatar

Vijay Ramesh vijaykramesh

  • Demandbase
  • San Francisco
View GitHub Profile
@vijaykramesh
vijaykramesh / newrelic_transaction_naming.java
Last active August 29, 2015 14:02
NewRelic transaction naming for Dropwizard
public class TimedResourceMethodDispatchProvider implements ResourceMethodDispatchProvider {
final ResourceMethodDispatchProvider provider;
public TimedResourceMethodDispatchProvider(ResourceMethodDispatchProvider provider) {
this.provider = provider;
}
@Override
public RequestDispatcher create(AbstractResourceMethod abstractResourceMethod) {
RequestDispatcher dispatcher = provider.create(abstractResourceMethod);
@vijaykramesh
vijaykramesh / partitioner.js
Last active December 30, 2015 04:09
partition an id of some sort into the unit interval, using md5 hexdigest
var crypto = require('crypto');
var salt = "some_salt";
function place_in_interval(id) {
var m = crypto.createHash('md5');
m.update(salt + ":" + id)
var key = m.digest('hex');
return parseInt(key,16) / Math.pow(16,key.length);
}
@vijaykramesh
vijaykramesh / glacier_account_id.rb
Created November 14, 2013 22:06
example plugin with aws-sdk-core
require 'aws-sdk-core'
class GlacierAccountId < Seahorse::Client::Plugin
option :account_id, '-'
# :validate, :build, :sign, :send - where in the stack you want the middleware to apply
handle_request(step: :validate, priority: 99) do |context|
context.params[:account_id] ||= context.config.account_id
end
end