Reducing Maven Package times due to resource copying

I once worked on a web application with a 250+MB code base. This consisted of 200,000 images. For every development cycle, you had to compile and deploy the code on the server which was painful to say the least. The size wasn’t the problem as much as the number of resources. The code took less than 20 seconds to compile.

We figured that compilations overwriting class files were OK but having to edit any resource just took too long. In such cases, you can use maven’s process-resources plugin to ask maven to only copy the new resources to your target directory.

This is significantly faster. Package times went down from 6 minutes to 18 seconds. Of course, a SSD would have helped but looking at the difference, it’s well worth the effort :)

mvn process-resources

Go try it out!

Maven Compilation in Ram Drive

If you’re working on huge maven projects and have a slow disk, compilation, packaging and install times can sore quite high. If getting faster hard disks isn’t possible, why not try moving the compilation to a ram drive?

A code base which used to take 22 minutes to compile went down to 3 minutes. This just goes to show the effect that disk IO bottlenecks can have on your system.

Continue reading Maven Compilation in Ram Drive

Forced HTTPs on your website with CloudFlare

I’m a supporter of the HTTPS everywhere movement by the EFF. They advocate users use (all) websites with HTTPS for extra security. This means everyone should probably fork out a few dollars to get their own certificates. Unless you’re buying a domain at NameCheap (in which case they tend to throw in a SSL certificate for the first year), you’d have to shell out $8-$12 to get one.

Side note, I recommend every user have HTTPS everywhere installed on every browser.

Though it’s not perfect, you can get a SSL for your website for free.

Continue reading Forced HTTPs on your website with CloudFlare

Signs of a troubled startup

India has been developing the startup culture quite seriously over the past half a decade. In this time I’ve seen dozens of ventures pop up and quite a few of them fizzle out. If you’ve gone through a startup bootcamp or an equivalent program, you’ve probably heard the stats. Failure rate of startups is pretty high. I admit, I am concerned. Not about the high failure rate. It’s about why quite a few Indian startups are failing these days.

I am concerned because they seem to not be getting their basics right. Most startup schools and accelerators tell you things that usually go wrong. Repeatedly. Yet there are other things they don’t tell you. Things they’d think are common sense.

Sometimes it is hard to spot these from the outside but if you do see these signs, you better have taken your ERT training seriously because the building is on fire and you better be prepared to evacuate people.

Continue reading Signs of a troubled startup

Net Neutrality: Why should I care?

Yes, that’s one of the most often asked questions right after “What is that?”. I don’t often provide this explanation to techies because doing that is as simple as giving them a few lines of explanation and pointing them to a good website with information. The real challenge, if you ask me, is explaining this problem to the everyday Joe out there. Especially since, in a place like India you’re likely to hear “we have bigger problems than <insert issue here>“. This to me sounds like a blanket excuse for not wanting to deal with an issue at hand and here’s how I tend to answer such queries.

Continue reading Net Neutrality: Why should I care?

Mac: Camera not available

My Macbook Pro sometimes doesn’t detect it’s web camera when I’m trying to join a video call and it’s painful to have to reboot the machine to fix it. A simpler way (especially if you have root access to your machine) is to kill VDCAssistant from the command line.

sudo killall VDCAssistant

Once you’re done, restart the application that was attempting to use your web camera :)

Removing uTorrent ads

When BitTorrent bought over μTorrent, they promised users that all adverts would be optional. They have, however, made it harder and harder to hide the adverts including now a set of hidden options. Thankfully users have found how to access those hidden options.

Turn off ALL Ads/Featured Content/Bundle Crap in μtorrent/Bittorrent:

Options > Preferences > Advanced

Turn ALL settings to false:

  • bt.enable_pulse
  • distributed_share.enable
  • gui.show_notorrents_node
  • offers.left_rail_offer_enabled
  • gui.show_plus_upsell
  • offers.content_offer_autoexec
  • offers.sponsored_torrent_offer_enabled
  • offers.featured_content_badge_enabled
  • offers.featured_content_notifications_enabled
  • offers.featured_content_rss_enabled

Options > Preferences > Hold Shift+F2 while clicking Advanced (Hidden fields)

Turn ALL settings to false:

  • gui.show_gate_notify
  • gui.show_plus_av_upsell
  • gui.show_plus_conv_upsell
  • gui.show_plus_upsell_nodes

Source: Forum post from Beasley

Mass downloading Google Drive Files

Has anyone ever shared with you hundreds of Google Drive files instead of sharing the directory? It happened to me today and I noticed Gmail clips the HTML part of the message at 102 KB. Usually Gmail provides a way to download all attachments (Google Drive or otherwise) or the ability to save them on your Google Drive from where you can mass download them. If the email is clipped, you can only save a subset of these files into your Google Drive so no mass downloads. Bummer.

It’s simple enough to fix with some Scala magic. First you should save the email source as email.html. This file can then be read line by line to find any google docs links along with the file name. In my case the files were named “File – 1.JPG”. Next update the file saving location (for me it was “dl/File 1.jpg” for which I created the folder dl). Assuming your regular expressions are correct, you’re good to go!

import java.io.File
import java.net.URL

import scala.io.Source
import scala.sys.process._

object Launcher extends App {
  def processLine(line: String) = """https\://docs.google.com/file/d/(\w*)/edit\?usp\=drive_web.*?File - (\d*)\.JPG""".r
    .findAllMatchIn(line).map(_.subgroups)
    .map(list => (s"https://drive.google.com/uc?export=download&id=${list(0)}", s"dl/File ${list(1)}.jpg"))

  def download(url: String, fileName: String) = new URL(url) #> new File(fileName) !!

  val downloadFromTuple = (download _).tupled

  Source.fromFile("email.html").getLines().map(processLine).filterNot(_.isEmpty).foreach(_.foreach(downloadFromTuple))
}

Yes, this is a quick hack and can be improved for readability (such as extracting the regular expression, download link and file read and save locations) but for a quick hack that seems unnecessary.