Redirecting varnish to new backend on the fly

varnishCache1) Change VCL backend config

Go to your vcl file (in my case /etc/varnish/default.vcl). Edit the backend param to point to another server. Also increase the timeouts since it will take longer than accessing localhost.

backend default {
 .host = "";
 .port = "80";
 .connect_timeout = 120s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 60s;

2) Validate VCL script on the fly

sudo varnishd -C -f /etc/varnish/default.vcl

This will notify if any syntax issues exist.


3) Reload the VCL Script without restarting varnish

I utilized:

$varnishadm -T localhost:6082
vcl.load reload01 /etc/varnish/default.vcl 
vcl.use reload01


VBA: Read localstorage variable from Internet Explorer Object using temporary textfield

Here is a toy solution to access localstorage variables if they are not accessible directly.

Imagine we have test HTML webpage with HTML:

// Put the object into storage
localStorage.setItem('testObject', 'testString');

// Retrieve the object from storage
var retrievedObject = localStorage.getItem('testObject');


Bash script to monitor server HTTP output length and e-mail an alert

Below is an example of a script that uses CURL to monitor the length of various HTTP server outputs and output a response if this is different than 103 characters.
This is my first bash script, so I had some reading/experimenting to do and it is quite rough.

Optimized Character Escaper for Java

I wanted to write my own character escaper for requests going to Apache Lucent.
After writing my own, I also received feedback from programmers-stackexchange which resulted in the fastest implementation, also posted here. (Thanks to MrSmit42)

Below is my application that tests 6 different slightly different implementations over 30,000,000 executions each and outputs the time in MS.

The results in MS (on my computer) were the following:

Method 1 (Boolean Array)->    7574
Method 0 (Switch Stmt)->    9778
Method 4 (Switch Stmt Ugly – BreakPoints after evert case)->    12451
Method 6 (HashSet)->    17273
Method 5 (EnumMap)->    39516
Method 3 (Pattern/Regex)->    98229

This proves that for production systems that have many requests, jumping directly on the RegEx bandwagon for even trivial problems is not always the solution.
Even a 0,5 MS reduction per request leads to 50MS saved over 100 requests (per second) and 500MS over 1000 requests.

[polldaddy poll=7418939]


Greesemonkey Script for filtering Stackoverflow Bounty Page

I’m a big fan of stackoverflow and many times surf the featured page that has many questions that have an additional bounty attached.
One of the things though that I want to do is quickly find the questions with zero answers that have not received attention due to one reason or another (e.g. very difficult).

For the specific URL: , Below a greesemonkey script just for that!


SO:Removing duplicate rows from data pulled from db in java

I’ve become an active member of stack overflow, both answering and making questions.
It’s amazing, there’s a whole community there that I hadn’t noticed before.
As I have not had time to post new items, I will be borrowing my answers to stackoverflow questions and re posting them here.

User Question:

So here’s my question. I have a giant text file of data and I need to input all of this data into a mySQL database fast through obviously using a java program. My only problem is that, the data is identified by a certain ID. Some of these ID’s have duplicates and contain all the same info as eachother. I would like to remove all of these for sorting purposes and clarity sake.

What would be the best way to go about this? If anyone could help I’d appreciate it




While reading the data have a hashmap or hashset. check if the id exists in the hasmap/hashset and if so continue. otherwise enter in set/map and insert.

An aside: The difference between hashmap and hashset is hashset only takes values while hashmap takes key values. However, Hashset itself uses a hashmap within memory and just inserts a dummy object for values. See: Differences between HashMap and Hashtable?


How to search all columns of all tables in a microsoft sql database for a keyword (including any data type)


I’ve been working on a very large unknown database (over 45 tables) where the reverse engineered schema diagram was quite chaotic. Having the task to find several needles in the haystack I searched the internet and found the very useful script at:  (pasted below).

However, one limitation I noticed was that the script only searched (‘char’, ‘varchar’, ‘nchar’, ‘nvarchar’).


Encrypt in VB.NET and Decrypt in PHP 4 Using Phpseclib0.3.0

Originally I had found code from: Encrypt in VB.NET and Decrypt in PHP and Vice Versa .

Everything worked well, until I realized that the specific webserver I was writing code for ran PHP 4…No mcrypt_decrypt.

Hence I discovered PHPSecLib has the Rijndael algorithm implemented as PHP code.
Following please find code to check if mcrypt exists and react differently (where $line is the encrypted text):

$dec = decryptRJ256($ky, $iv, $line);
$dec = decryptRJ256_PHPSECLIB($ky, $iv, $line);


Add new JSON document using plain text string with LightCouch


Small post outlining a small modification to the 0.4 lightcouch source to allow direct plain text json insertion. A colleague and I had a JSON string which we wanted to insert into lightcouch without having to create a JSON object – only to have .toString() be called during the final POST request.


Limiting TOP command to a specific process name and keeping interactivity


In this post we analyze the following command which allows you to run “top interactively without having to look up the pids” your interested in.

top -p `pgrep process-name | tr "\\n" "," | sed 's/,$//'`


The command is split into multiple sub commands.

  • top: displays running processes. With -p option  means monitor specific process IDs.
  • pgrep: Looks through the currently running processes and lists the process IDs which matches the selection criteria (proccess-name).
  • pipe (|): The pipe operator. It is used to direct the stdout of the first command to the stdin of the second command.
  • tr (translate): Is used for replacing or removing specific characters in its input data set. Above: linefeed(\n) is replaced with comma(,) .
  • sed: sed is used to remove the last comma(,) for the list. Sed is a stream editor which are used to perform basic text transformations on an input stream (a file or input from a pipeline). sed‘s ability to filter text in a pipeline particularly distinguishes it from other types of editors.