Skip to content

Instantly share code, notes, and snippets.

@aviflax
aviflax / apache_client_3.groovy
Created January 20, 2011 19:36
Benchmarking HTTP client performance using Apache HttpClient 3.1 and 4.0 with and without Restlet 1.1 and 2.0. The server is a constant value (always warmed up) and I tried to make the scripts as identical as possible.
#!/usr/bin/env groovy -cp restlet-1.1.10/httpclient/*
/*** SETTINGS ***/
requestsToSend = args.length >= 1 ? args[0] as Integer : 10000
concurrency = args.length >= 2 ? args[1] as Integer : 10
port = args.length >= 3 ? args[2] as Integer : 3000
@GregMefford
GregMefford / setup-statsd-centos.sh
Last active April 10, 2022 15:31 — forked from collegeman/setup-statsd.sh
Install Graphite and StatsD on CentOS (updated for 6.4 x86_64)
# First do a fresh install of CentOS 5.7 i386, server configuration (no GUI)
# This should be performed as root since it's going to be installing a bunch of stuff
# --- Update things to make sure we have the latest patches ---
# Add EPEL so we can get reasonably recent packages
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# --- Install all the packages --- #
yum -y install python-whisper python-carbon graphite-web python-memcached python-ldap httpd memcached
@criminy
criminy / PageI.java
Created October 5, 2011 01:01
Initial MyBatis support for Spring-Data (specifically a sample repository and Pagination).
import java.util.Collection;
import java.util.List;
import java.util.ListIterator;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
/**
* Extension class between spring data commons and java.util.List that is
* required to get MyBatis to use it as a return value.
@chalmerj
chalmerj / gist:1492384
Created December 18, 2011 04:39
Init script for Graphite carbon-cache
#! /bin/sh
### BEGIN INIT INFO
# Provides: carbon-cache
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: carbon-cache init script
# Description: An init script for Graphite's carbon-cache daemon.
### END INIT INFO
@acdha
acdha / carbon-cache.conf
Last active March 20, 2022 02:02
Upstart config for Graphite's carbon-cache daemon
#!/etc/init/carbon-cache.conf
description "Carbon server"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
umask 022
expect fork
respawn
@jabbrwcky
jabbrwcky / InsecureHttpClient.java
Created February 6, 2012 13:15
A sample how to configure Apache HTTPClient (4.+) to accept SSL connections *without* certificate and hostname validation
package net.hausherr.sample;
import org.apache.http.client.CookieStore;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
@omnicolor
omnicolor / RB-precommit.php
Last active July 26, 2023 14:42
SVN pre-commit intergration with Review Board
#!/usr/local/bin/php
<?php
/**
* Pre-commit Subversion script.
*
* Forces the commit message to have a line like
* review: 42
* and checks that the review has received a Ship It! from
* a peer.
* @author Omni Adams <[email protected]>
@fehmicansaglam
fehmicansaglam / Application.java
Created February 9, 2012 18:50
Accept range header and write a partial content to the response with Play! Framework.
public static void downloadFile(final Long fileId) throws IOException {
response.setHeader("Accept-Ranges", "bytes");
notFoundIfNull(fileId);
File underlyingFile = ... //load file
String fileName = ...//name of the file
Header rangeHeader = request.headers.get("range");
if (rangeHeader != null) {
throw new PartialContent(underlyingFile, fileName);
@rednaxelafx
rednaxelafx / HelloWorld.java
Created March 20, 2012 16:46
pmap of a "HelloWorld" Java program on OpenJDK6b20 on 32-bit XUbuntu 10.10
public class HelloWorld {
public static void main(String[] args) throws Exception {
System.out.println("Hello World!");
System.in.read();
}
}
@rednaxelafx
rednaxelafx / annotated_maps
Created March 20, 2012 18:56
another memory layout example. JDK6u25 on AMD64 Ubuntu 10.10
List of threads:
4210 Thread-4
4208 WatcherThread
4209 Timer-0
4207 Low Memory Detector
4206 C2 CompilerThread1
4205 C2 CompilerThread0
4204 Signal Dispatcher
4203 Finalizer