Skip to content

Instantly share code, notes, and snippets.

View Xorlev's full-sized avatar

Michael Rose Xorlev

View GitHub Profile
@Xorlev
Xorlev / MultipleStreamBolt.java
Last active April 7, 2019 15:31
Example of emitting on multiple streams
package storm.examples;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import backtype.storm.tuple.Values;
import java.util.Map;
@Xorlev
Xorlev / gist:9676261f61c5be7a6e44
Created July 28, 2014 17:43
Java 8 - SSL Concurrency Issues
New I/O worker #21 [BLOCKED] CPU time: 1s
java.security.Provider.getService(String, String)
sun.security.jca.ProviderList$ServiceList.tryGet(int)
sun.security.jca.ProviderList$ServiceList.access$200(ProviderList$ServiceList, int)
sun.security.jca.ProviderList$ServiceList$1.hasNext()
javax.crypto.KeyGenerator.nextSpi(KeyGeneratorSpi, boolean)
javax.crypto.KeyGenerator.<init>(String)
javax.crypto.KeyGenerator.getInstance(String)
sun.security.ssl.JsseJce.getKeyGenerator(String)
sun.security.ssl.HandshakeMessage$Finished.getFinished(HandshakeHash, int, SecretKey)
@Xorlev
Xorlev / osx-10.11-setup.md
Created October 26, 2015 17:14 — forked from kevinelliott/osx-10.11-setup.md
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@Xorlev
Xorlev / gzip chain
Created August 30, 2013 02:54
Fast GZIP copy, credit the smart guys at Tumblr. You can use this to replicate data from one machine to another, and without decompressing send the data to the next server in the chain until the terminal link in the chain. pigz is a parallel gzip. With this you can copy data at (almost) gigabit line speed. Great for seeding read slaves.
On the last machine in the chain:
nc -l 1234 | pigz -d | tar xvf -
On each intermediate machine, you use a fifo to copy the data to the next machine as well as decompressing.
mkfifo myfifo
nc $NEXT_SERVER 1234 <myfifo &
nc -l 1234 | tee myfifo | pigz -d | tar xvf -
@Xorlev
Xorlev / MutationUtils.java
Created December 11, 2013 05:20
Utils useful for making ColumnFamilyOutputFormat work with CQL3 tables (CQL3 is all composite types)
package com.fullcontact.hadoop.cassandra;
import com.google.common.collect.Lists;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.CompositeType;
import org.apache.cassandra.db.marshal.UTF8Type;
import org.apache.cassandra.thrift.Column;
import org.apache.cassandra.thrift.ColumnOrSuperColumn;
import org.apache.cassandra.thrift.Mutation;
import org.apache.cassandra.utils.ByteBufferUtil;
@Xorlev
Xorlev / kato.js
Last active December 24, 2015 10:09
Kato.im Fluid.app userscript to update the dock badge with the # of unread messages.
// ==UserScript==
// @name Kato.im Fluid Dock Badge
// @description Displays the unread count of messages, adapted from http://userscripts.org/scripts/review/177616
// @author Michael Rose
// ==/UserScript==
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
@Xorlev
Xorlev / MetricsWeb.java
Created September 2, 2013 21:17
Storm embedded webserver
public class MetricsWeb extends BaseTaskHook {
private static final Logger log = LoggerFactory.getLogger(MetricsWeb.class);
private static Server server = null;
private static CuratorFramework zk = null;
private static ServiceDiscovery<Void> dsc = null;
@Override
public void prepare(Map conf, TopologyContext context) {
if ("production".equals(conf.get("environment"))) {
initWebConsole(9090);
@Xorlev
Xorlev / load_file.rb
Created December 10, 2011 09:10
Naive data loading
# Not the most efficient method...
File.open('track1/albumData1.txt').each do |line|
album, artist, *genres = split_and_filter(line)
genres.map! { |g| Genre.find(g) }
Album.create! :id => album, :artist_id => artist, :genres => genres
end
@Xorlev
Xorlev / models.rb
Created December 10, 2011 09:08
AR Models
require 'active_record'
class Album < ActiveRecord::Base
belongs_to :artist
has_many :tracks
has_and_belongs_to_many :genres
attr_accessible :id, :artist_id, :genres
def to_s
@Xorlev
Xorlev / RateLimitingForwardingSpout.java
Created October 24, 2014 18:27
A rate limited spout wrapper using Archaius dynamic properties to control overall rate limit. Interrogates Storm for total number of spouts to divide rate limit evenly between spout instances.
package com.fullcontact.storm.spout;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.IRichSpout;
import backtype.storm.topology.OutputFieldsDeclarer;
import com.google.common.util.concurrent.RateLimiter;
import com.netflix.config.DynamicDoubleProperty;
import com.netflix.config.DynamicPropertyFactory;
import org.slf4j.Logger;