Skip to content

Instantly share code, notes, and snippets.

@agaoglu
agaoglu / MockHTable.java
Created October 6, 2010 11:34
MockHTable
/**
* This file is licensed to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@agaoglu
agaoglu / USAGE.md
Created October 7, 2010 15:29
Simple CRUD function for couchapps

CRUD requires jquery.deepjson.js to work so it should be included

<script type="text/javascript" src="js/jquery.deepjson.js"></script>

Then you can assign whatever's in crud.json to a variable or you can put crud.json into your evently directory and let couchapp push it to your application.

Simplest way to use it is

@agaoglu
agaoglu / gpuwatch.py
Created February 2, 2011 21:48
Ganglia metric module for nVidia GPU monitoring
import os
descriptors = list()
def getString():
test_file = "nvidia-smi -q --gpu=0 | tail -23"
try:
p = os.popen(test_file, 'r')
return p.read()
@agaoglu
agaoglu / README.md
Created June 1, 2011 16:37
Resource synchronizer

An example process synchronizer using ZooKeeper.

Coordinates timesharing of the resources among the same type of processes. Basic usage is like that:

ResourceSynchronizer rs = new ResourceSynchronizer(
    new ZooKeeper(zkconnectionstring, timeout, null), 
    "/pool", new String[]{"res0", "res1"});

prepareData();

String myResource = rs.request();

@agaoglu
agaoglu / context.xml
Created October 5, 2011 17:39
ODE on postgre
<Context path="/ode" docBase="ode" debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/odedb"
auth="Container"
type="javax.sql.DataSource"
username="sa"
password=""
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/ode"
validationQuery="select 1"
maxActive="10"
@agaoglu
agaoglu / JaxWsExceptionCatcher.java
Created December 5, 2011 17:27
An example exception handler for JAX-WS without code generation
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.Node;
@agaoglu
agaoglu / Run.scala
Created January 10, 2012 18:04
HttpClient concurrency
object Run extends App {
LoggerFactory.getLogger(getClass) // initialize SLF4J early
val sprayClient = actorOf(new HttpClient())
Supervisor(
SupervisorConfig(
OneForOneStrategy(List(classOf[Exception]), 3, 100),
List(
Supervise(sprayClient, Permanent)
@agaoglu
agaoglu / backupmongotos3.sh
Created June 24, 2014 13:28
Backup mongodb directly to S3 (without using local disk). Requires http://s3tools.org/s3cmd.
#!/bin/bash
#########
# Copyright 2014 Erdem Agaoglu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
import akka.actor.{Actor, ActorRef}
import akka.io.IO
import spray.can.Http
import spray.can.client.ClientConnectionSettings
import spray.http.Uri
import spray.http.HttpHeaders
import spray.http.HttpRequest
import spray.http.HttpResponse
class Proxy(
import com.twitter.scalding._
class CachesizeApproximation(args : Args) extends Job(args) {
val MINUTE = Duration.MIN_IN_MS
val HOUR = Duration.HOUR_IN_MS
// (1) These are different test configurations
val inactive = List(
10*MINUTE,