Skip to content

Instantly share code, notes, and snippets.

{
"id": "/ctrlpkw",
"groups": [
{
"id": "/ctrlpkw/db",
"apps": [
{
"id": "/ctrlpkw/db/cassandra-seed",
"constraints": [["hostname", "UNIQUE"]],
"ports": [7199, 7000, 7001, 9160, 9042],
@takei-shg
takei-shg / FutureWithOptionT
Created March 5, 2015 15:28
com.twitter.util.Future Chain with OptionT
import scalaz._
import Scalaz._
import scalaz.OptionT._
import com.twitter.util.Future
/**
* Simple example of Future chain, which only shows type level consistency.
* Future chain can be implemented with optionT or simple flatMap chain.
*/
object Main extends App {
@ashrithr
ashrithr / FIleSystemOperations.java
Created February 26, 2015 01:27
HDFS FileSystems API example
package com.cloudwick.mapreduce.FileSystemAPI;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@jpillora
jpillora / INSTALL.md
Last active October 25, 2023 05:03
Headless Transmission on Mac OS X
  1. Go to https://developer.apple.com/downloads/index.action and search for "Command line tools" and choose the one for your Mac OSX

  2. Go to http://brew.sh/ and enter the one-liner into the Terminal, you now have brew installed (a better Mac ports)

  3. Install transmission-daemon with

    brew install transmission
    
  4. Copy the startup config for launchctl with

    ln -sfv /usr/local/opt/transmission/*.plist ~/Library/LaunchAgents
    
@miguno
miguno / CMSHashingBenchmark.scala
Created January 7, 2015 15:57
Benchmark for hashing implementations for CMS[BigInt] in Algebird
package com.twitter.algebird.caliper
import com.google.caliper.{ Param, SimpleBenchmark }
import com.google.common.hash.{ HashFunction, Hashing }
/**
* Benchmarks the hashing algorithms used by Count-Min sketch for CMS[BigInt].
*
* The input values are generated ahead of time to ensure that each trial uses the same input (and that the RNG is not
* influencing the runtime of the trials).
@travisbrown
travisbrown / SimpleHttpServer.java
Last active March 2, 2017 02:49
A very simple Finagle HTTP server example (no error handling, etc.)
import com.twitter.finagle.Http;
import com.twitter.finagle.ListeningServer;
import com.twitter.finagle.Service;
import com.twitter.finagle.http.HttpMuxer;
import com.twitter.util.Await;
import com.twitter.util.Future;
import java.net.InetSocketAddress;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.jboss.netty.buffer.ChannelBuffers.copiedBuffer;
import org.jboss.netty.handler.codec.http.*;
@ezhulenev
ezhulenev / deeptreemap.scala
Created December 4, 2014 22:43
Deep TreeMap conversion
import scala.collection.immutable.TreeMap
trait ToTreeMap[A] {
type Result
def treeMap(x: A): Result
}
trait LowerPriorityToTreeMap {
implicit def plainMap[K, V](implicit ord: Ordering[K]): ToTreeMap[Map[K, V]] =
anonymous
anonymous / mesosphere.sh
Created November 10, 2014 07:56
#! /bin/bash
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
CODENAME=$(lsb_release -cs)
echo "deb http://repos.mesosphere.io/${DISTRO} ${CODENAME} main" | sudo tee /etc/apt/sources.list.d/mesosphere.list
sudo apt-get -y update --fix-missing
sudo apt-get -y install mesosphere
@PatrickCallaghan
PatrickCallaghan / CustomIndex.md
Last active August 29, 2015 14:07
Creating a custom index table from an existing table with Apache Spark

The default is to put this on its own node so you will need to start DSE with dse cassandra -k to create a spark analytics node.

First run the https://github.com/PatrickCallaghan/datastax-userinteractions-demo project to populate the Cassandra cluster (follow instructions in README). Use this project to populate the Cassandra db with hundreds of thousands user interactions. The idea is to have users interacting with multiple apps and we can model this by user in Cassandra.

We have an existing table that has all the data for user interactions with certain applications on the appropriate date. Now, for some other requirements, we need the unique users that visited a certain page within an app on a certain day.

So the first requirement was - show me the user interactions with a certain app

Now, we have a new requirement - show me all the users that interacted with a certain app on a particular day.

@acolyer
acolyer / service-checklist.md
Last active January 30, 2024 17:39
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?