RSSAmplifier

Blog

JoelPM

joelpm.comRSS feed ↗11 posts

Latest posts

Curl with Cookies and Headers

Every now and then I find myself needing to make an http request with specific cookies and headers to help debug an issue. And every time I resort to the curl manpage and try a few times until I get the right incantation. So, to save myself time in the future, here is an example: curl -v --cookie "cookieName=cookieValue" --header "Accept-Language: en" --header "X-Forwarded-For: 123.123.123.123"…

EC2 Storms

Below is a graph of latency for requests coming into three load balancers (the dashed line is the latency for requests to the domain that fronts the three LBs, which does DNS round-robin to the three load balancers). As you can see, requests to two of the three load balancers are extremely slow (the orange and blue lines), while requests to the third load balancer (the green line) are consistently…

Maven and YUICompressor

Here's how I use YUICompressor to minify/obfuscate our Javascript during Maven's compile phase. First, add YUICompressor to your pom as dependency: Once YUICompressor is listed as a dependency we can use the ant-run plugin to invoke it during the build: What we're doing above is hooking the ant-run plugin to the compile phase, creating an ant property that contains the path to yuicompressor.jar,…

Compiling HAProxy on OS X

If you want to use PCRE when building HAProxy on your mac (recommended by the docs) and you've installed PCRE using MacPorts ( sudo port install pcre ), you may need to tweak Makefile.osx to help it find the headers, otherwise you'll see a whole slew of errors starting with this: In file included from include/types/proxy.h:34, from include/common/cfgparse.h:29In file included from…

Thrift: Bidirectional Async RPC

Source on GitHub: http://github.com/JoelPM/BidiThrift A reader posted to the thrift-user mailing list wondering if it was possible for a Thrift RPC server to send messages to the client. The responses indicated that this could be accomplished by polling the server for updates or hosting another Thrift server in the client that could receive RPCs from the server (requires opening another port on…

Thrift: Writing Thrift Objects to Disk with Java

If you're using files to pass data around between different components of a system it may make sense to use Thrift. Doing so means you get smaller file sizes (assuming you do binary serialization) but still have files that can be easily read in many programming languages. In Java, writing Thrift objects to disk is straightforward. Here's a utility class that I use for doing so: import…

Thrift: Reading Thrift Objects from Disk with Java

Reading Thrift objects is as easy as writing them to disk . Here's the utility class I use for reading one or more Thrift objects (of the same type) serialized to disk: import java.io.BufferedInputStream ; import java.io.File ; import java.io.FileInputStream ; import java.io.FileNotFoundException ; import java.io.IOException ; import com.facebook.thrift.TBase ; import…

Invoking the Thrift Compiler from Maven

Thrift and Protocol Buffers require you to invoke a custom compiler during the build process to generate source code from the message definitions in your .thrift or .proto files. You can accomplish this with Maven by using the antrun plugin. Here's the relevant section from pom.xml: <profiles> <profile> <id> profile-buildthrift </id> <activation> <file> <exists> /usr/local/bin/thrift </exists>…

Rest In a Jar: Maven, Spring, Jetty, and Jersey

Here's a quick example of how to use Maven, Spring, embedded Jetty, and Jersey to build an application that provides a RESTful interface (in a single Jar file). There are four main parts to this project: First, create and configure the project using Maven. Second, create the resources. Third, create/configure the Jetty server. Finally, tie it all together with Spring. First, create your project…

Add new files to SVN

I frequently find myself needing to add a bunch of new files to svn. Here's how to do it for Java files: svn status | grep ^?.*\.java$ | awk '{print $2}' | xargs svn add And here's how it works: svn status | Gets the status from Subversion and pipes it to: grep ^?.*\.java$ | Which matches all lines starting with a question mark (meaning they aren't in the svn repo) and ending in .java and pipes…

From the Archives: Monitors

This is another entry from the Mephisto era that still seems to get a lot of traffic, so I'm bringing it back in the hopes that it will help someone trying to decide what the right monitor strategy is for their needs. For the record, I still favor a single 30" over dual 24". My first internship was with a company called Tellabs that made telecom products - large, powerful boxes that did telephone…