Bulk Deleting Folders based on existing git repos

sdfsdfsdfsdf By evan on Feb 08, 2016

I have a system set up where testers can ‘check out’ a feature branch to test. It sets up a full web environment (at var/www/test/branch_name), for an arbitrary feature and customer. It works great, but a problem quickly arose where we had to manually delete stale test environments.

Since repeating something twice means automating it…

There’s a way to delete all folders except a and b.

shopt -s extglob
rm -rf !(folderA|folderB)

shopt lets you use !(a|b) to not rm a or b.

Then we need to get a list of folders to not delete; this command will get every branch, that starts with “test/”, remove the prepended , replace newlines with |, and remove the last |.

git branch | grep 'test/' | sed 's/\ \ //g' | tr '\n' '|' | sed s'/.$//'

to use that in a shell script,

DIR_KEEP=`git branch | grep 'test/' | sed 's/\ \ //g' | tr '\n' '|' | sed s'/.$//'`
shopt -s extglob
rm -rf !($DIR_KEEP)

In this case, it expands to

rm -rf !(test/FEAT-1|test/FEAT-2|test/FEAT-3|test/FEAT-4)

Success! Throw that on an hourly cron job and it will cull the test directories as the feature branches are merged and deleted.

Tor Rate Limiting

sdfsdfsdfsdf By evan on Jan 31, 2016

If you know much about Tor, you know that all connections come from localhost. Even though it’s old news (I first heard about this a year ago) it has come up in the news recently.

It reminded me of a proof of concept I wrote for rate limiting hidden services, or alternatively, any service where you can’t distinguish users. Basically, you have them prove they did some amount of work (and therefore spent a certain amount of time between requests)

Factoring a semiprime, for example. It’s slow, which is why it is the basis of RSA encryption. More on that in the near future 😉

Full source at github

Update (Feb 15): There’s now another version of this concept available, which operates more similarly to bitcoin.


sdfsdfsdfsdf By evan on Mar 24, 2015


Built a exif detector. Kind of like a metal detector for geotagged images. Those that have data are circled in green. Those that don’t are circled in red.

Consider it a proof of concept. The lat/lng and a google maps link are logged to the console.

Bootstrap does not fit wordpress eh?

sdfsdfsdfsdf By evan on Dec 19, 2014

Then you’re doing it wrong.

The only thing that’s kind of screwy is the main nav. Apart from that, it’s no worse than any other front end framework, and better in a lot of ways.

Of course, I could be biased. I need to rewrite that theme to take advantage of LESS.

Dyslexia Chrome Plugin

sdfsdfsdfsdf By evan on Aug 25, 2014

Screen Shot 2014-08-25 at 6.52.30 PMNoticed a friend joking back and forth earlier about the ALS ice bucket challenge with of his with dyslexia. As soon as I heard that, I remembered having done a site a few years back  and asked him if the opendyslexia (more…)

Kijiji Unsold Plugin

sdfsdfsdfsdf By evan on Aug 04, 2014

kijiji_logo1I’ve been getting pretty frustrated with kijiji recently. One thing that keeps coming up is people writing “sold” in the title rather than actually deleting the ad. Why? I have no idea. Perhaps they think people (more…)

WordPress Chart Plugin

sdfsdfsdfsdf By evan on May 07, 2014

Screen-Shot-2014-05-07-at-11.50.17-AMI hadn’t been able to find a decent plugin to create charts in WordPress, so I wrote my own.

It uses HandsOnTable for the backend, to provide an excel-like editor, and Charts.js for the front end.

Long story short, (more…)

Watermarking an image

sdfsdfsdfsdf By evan on Feb 15, 2014

Note: This is a post from my old website, I came across it today and it’s still relevant.

Let’s suppose you have a ton of images that you want to protect from being copied.

The obvious solution is (more…)

Interlaced PNG’s

sdfsdfsdfsdf By evan on Jan 12, 2014

images (1)Browsing the internet the other day, I came across the “Interlaced PNG” format. This was apparently designed about 15 years ago when internet connections were much slower. As connection speeds get faster, there’s been a trend (more…)