Skip to content

Instantly share code, notes, and snippets.

View SaschaMoellering's full-sized avatar

Sascha Möllering SaschaMoellering

  • http://autoscaling.io
  • Berlin
View GitHub Profile
require 'net/http'
link = URI.parse('http://169.254.169.254/latest/meta-data/instance-id')
request = Net::HTTP::Get.new(link.path)
begin
response = Net::HTTP.start(link.host, link.port) { |http|
http.read_timeout = 5 #Default is 60 seconds
http.request(request)
}
require 'net/http'
link = URI.parse('http://169.254.169.254/latest/meta-data/instance-id')
request = Net::HTTP::Get.new(link.path)
begin
response = Net::HTTP.start(link.host, link.port) { |http|
http.read_timeout = 5 #Default is 60 seconds
http.request(request)
}
include_recipe "graphite"
begin
r = resources(:template => "#{node['graphite']['base_dir']}/conf/storage-schemas.conf")
r.cookbook "my-cookbook"
rescue Chef::Exceptions::ResourceNotFound
Chef::Log.warn "could not find template to override!"
end
@SaschaMoellering
SaschaMoellering / verx.erb
Created December 9, 2013 10:21
Chef-template for Vert.x-Jmxtrans configuration
{
"servers" : [ {
"alias" : "<%= @node[:hostname] %>",
"host" : "<%= @node[:hostname] %>",
"port" : "<%= @jmx_port %>",
"username" : "<%= @jmx_user %>",
"password" : "<%= @jmx_password %>",
"queries" : [
{
"obj" : "java.lang:type=Memory",
public class SharedData
extends java.lang.Object
Sometimes it is desirable to share immutable data between different event loops, for example to implement a cache of data.
This class allows instances of shared data structures to be looked up and used from different event loops.
The data structures themselves will only allow certain data types to be stored into them. This shields you from worrying about any thread safety issues might occur if mutable objects were shared between event loops.
The following types can be stored in a shareddata data structure:
String
@SaschaMoellering
SaschaMoellering / logfile
Created November 23, 2013 22:43
The problem is: the vertx-zip file is not correctly installed. vagrant@debian-squeeze:~$ ls -la /usr/local/vertx-2.0.2 total 8 drwxr-sr-x 2 root staff 4096 Nov 23 22:38 . drwxrwsr-x 11 root staff 4096 Nov 23 22:38 .. vagrant@debian-squeeze:~$
default[:vertx][:version] = '2.0.2'
default[:vertx][:home] = '/srv/vertx'
default[:vertx][:url] = 'http://dl.bintray.com/vertx/downloads/'
@SaschaMoellering
SaschaMoellering / XMLjson
Created November 20, 2012 16:30
XMl -> JSON
XML -> NSDictionary
NSError *error = nil;
NSString *contents = [NSString stringWithContentsOfURL:[NSURL URLWithString:searchIncentivesURL]
encoding:NSUTF8StringEncoding
error:&error];
NSData* xmlData = [contents dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLData:xmlData error:error];