Skip to content

Instantly share code, notes, and snippets.

Erdem Agaoglu agaoglu

View GitHub Profile
View CachesizeApproximation.scala
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,
View Proxy.scala
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(
@agaoglu
agaoglu / backupmongotos3.sh
Created Jun 24, 2014
Backup mongodb directly to S3 (without using local disk). Requires http://s3tools.org/s3cmd.
View backupmongotos3.sh
#!/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
#
@agaoglu
agaoglu / Run.scala
Created Jan 10, 2012
HttpClient concurrency
View Run.scala
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 / JaxWsExceptionCatcher.java
Created Dec 5, 2011
An example exception handler for JAX-WS without code generation
View JaxWsExceptionCatcher.java
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;
View context.xml
<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 / README.md
Created Jun 1, 2011
Resource synchronizer
View README.md

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 / gpuwatch.py
Created Feb 2, 2011
Ganglia metric module for nVidia GPU monitoring
View gpuwatch.py
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 / USAGE.md
Created Oct 7, 2010
Simple CRUD function for couchapps
View USAGE.md

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

View MockHTable.java
/**
* 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.
You can’t perform that action at this time.