Skip to content

Instantly share code, notes, and snippets.

View olim7t's full-sized avatar

Olivier Michallat olim7t

  • DataStax
  • San Jose, CA
View GitHub Profile
@olim7t
olim7t / graphite.sh
Last active December 12, 2015 09:39
Install Graphite 0.9.10 on a Mac
# Install graphite 0.9.10 on a Mac (Python 2.6 preinstalled)
# Gathered from my notes, might not be 100% accurate
brew install py2cairo
sudo pip install Django==1.3
sudo pip install django-tagging
sudo pip install carbon
sudo pip install whisper
sudo pip install graphite-web
sudo pip install tagging # not sure if really useful
@olim7t
olim7t / DriverDemo.java
Created November 13, 2015 11:45
Standalone program that can be used as a template to reproduce Java driver issues
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import com.datastax.driver.mapping.annotations.UDT;
public class DriverDemo {
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Iterator;
import java.util.NoSuchElementException;
/** Streams the lines of a {@link BufferedReader} while applying some parsing method. */
abstract class LineParsingIterator<T> implements Iterator<T> {
private final BufferedReader input;
private T buffered; // parsed but not yet returned to the client
/* Finds the version history of a POM in a Subversion repository */
import scala.sys.process.Process
object Conf {
val url = "put the url of your POM here"
val svn = "svn --username xxx"
}
case class Revision(number: Int, date: String, version: String) {
@olim7t
olim7t / gist:1061569
Created July 2, 2011 19:38
Game of Life
/**
* Clear-headed attempt at a functional-style, "Scala-way" implementation.
*
* Seems to work on trivial cases. Too lazy to write unit tests now (note to self: write them later and then pretend I did TDD).
*/
class GameOfLife(val width: Int, val height: Int, val liveCells: Set[(Int, Int)]) {
def nextIteration: GameOfLife = {
val newCells = for {
(cell, liveNeighborCount) <- liveNeighborCounts
@olim7t
olim7t / gist:957409
Created May 5, 2011 16:52
ToArrayTest.java
package test;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* Illustrates a case when Collection.size() cannot reliably indicate how many elements were dumped by
* Collection.toArray().
*
* Assuming that the array is reused and was previously filled with unrelated values, the fact that toArray()
* writes null after the last element is the only way to find out how many elements were actually dumped.
@olim7t
olim7t / Tocttou.java
Created March 25, 2011 22:53
Example code for my blog post "The TOCTTOU attack", available at http://out-println.appspot.com/posts/tocttou.
import java.util.Date;
/**
* Example code for my blog post "The TOCTTOU attack", available at http://out-println.appspot.com/posts/tocttou.
*/
public class Tocttou {
public static final class Interval {
private final Date min;
@olim7t
olim7t / Breaks.java
Created December 16, 2010 19:47
Utility class to simulate dependencies between breakpoints in the Eclipse debugger.
/*
* Copyright (c) 2010, Olivier Michallat
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
import java.util.Calendar._
import java.util.GregorianCalendar
import java.util.GregorianCalendar._
import java.util.TimeZone
// A calendar in Paris' time zone (GMT+1)
val cfr = new GregorianCalendar
cfr.setTimeZone(TimeZone.getTimeZone("Europe/Paris"))
// A calendar at GMT+0
/* Basic j.u.l config for simple projects */
import java.util.logging.Level;
import java.util.logging.Logger;
public class Jul{
static {
Logger.getLogger("").setLevel(Level.SEVERE);
final Logger myLogger = Logger.getLogger("com.mycompany");
myLogger.setLevel(Level.FINEST);