Why Matchbox, and how it connects people through music

There’s no doubt that music defines us. It influences our moods, for example, making us happy by releasing a chemical named dopamine. It can affect what we wear, what we eat, and perhaps even who we enjoy being together with. It affects our thought process too (it’s well known that ambient noise can improve productivity).

In a study conducted amongst couples who were eighteen years old, it’s been found to predict personality traits. According to the same study, it’s what we’re most likely to discuss about when we meet somebody new, within the first few weeks. Psychologically, men and women who listen to similar music tend to be better communicators, and have longer lasting relationships.

It’s probably one of the most important things in our lives. If I were to place music on Maslow’s hierarchy of needs, I’d place it at the physiological stage. It’s a fundamental part of our society. Even the Hollywood movie directors (e.g. the scene from Interstellar) would agree.

Why not extend this to the social discovery apps we use today? None of them base their core on this. One of the most popular apps for social discovery, Tinder, uses Facebook page likes and interests, to match people together.

This is why Matchbox was created. It bridges the gap between “truly anonymous“, and “hey there“. The app shows you the top ten artists that are common between you and the person you’re looking at, giving you a fair knowledge of what that person would be like:

Matchbox showing the top 10 artists
Matchbox showing the top 10 artists

You’re more likely to be at ease knowing that the opposite person is a little similar to you. Matchbox was crafted with the sole intention that music is the key that connects us, and binds us together. It has evolved for over 9 months, before being made available to the world.

As it stands right now, Matchbox has a hundred active users, and is growing slowly.

Go ahead and test drive the app, and see for yourself how Matchbox re-defines the social discovery platform.

Download on the App StoreGet it on Google Play

Compile LESS on the fly for your exploded WAR in IntelliJ

At CleverTap, we’ve recently started using LESS for dynamic CSS. While it has it’s upsides, the biggest downside was that most of our developers couldn’t use the hot deploy feature for their local deployments.

After an hour or so, we came up with a neat solution.

 

There are two parts to this:

  1. Just before deploying the app into the web container, compile all the LESS files within the exploded artifact output directory
  2. Have the File Watcher plugin re-compile a modified LESS file within the IDE, and copy it over to the artifact output directory

Both parts above utilize a bash script (since everybody uses a Mac for development, it’s cool).

Prerequisites:

  1. The LESS compiler – can be installed using npm (npm install -g less). If you don’t have the Node Package Manager, just search on how to install it (most likely you’d use Homebrew)
  2. Install the File Watcher plugin in IntelliJ
    1. Go to Preferences in IDEA, then to Plugins
    2. Hit the “Install JetBrains plugin…” button, and search for “file watchers”.
    3. Install the plugin and restart the IDE
  3. A run configuration that is configured to deploy an exploded WAR (can be either Tomcat/Jetty/anything)
  4. Knowing where your exploded artifact resides (in my case, it is /Users/jude/developer/WizRocket/out/artifacts/Dashboard_war_exploded). If you don’t know how to get this, follow these steps:
    1. Go to File -> Project Structure
    2. Click on Artifacts (in the left menu)
    3. Select your exploded WAR artifact
    4. On the right, you’ll see the output directory

Part 1: Compile the LESS into CSS just before deployment

Copy the following script and save it as /Users/username/bin/lessc-idea:

Note: You will need to update the variable exploded_artifact_path in the script above.

Make it executable:

$ chmod +x /Users/username/bin/lessc-idea

Now, open up your run configuration, and scroll all the way to the bottom (where it says Make, followed by Build artifact …). Hit the “+” button, and select “Run External Tool”.

Hit the “+” button to add a new External Tool, and configure it as follows:

External Tool configuration for compiling LESS files before deployment

Ensure that the build order in your run configuration is as follows:

Build order for LESS compilation

Once this is done, your LESS files should be automatically generated when you deploy your web app. Go ahead and give it a shot.

 

Part 2: Configure the File Watcher plugin to re-compile LESS files edited:

Go to Preferences, and navigate to File Watchers under Tools (left menu). Hit the “+” button and select “Less”.

Configure your new watcher as shown in the screenshot below:

File Watcher configuration for LESS files

Before your hit the OK button, a few things to do:

  1. Clear any output filters added automatically: Press the Output Filters… button, and remove anything inside there.
  2. Select your scope: Select the CSS/LESS directory within your web module (ensure you click on Include Recursively after you’ve selected the directory)

You’re all set. Hit OK, then Apply, and OK.

Test drive your new setup. The moment you change a LESS file, it’ll get re-compiled into the corresponding CSS file within the corresponding directory in the artifact output, and you’ll be able to see the changes immediately.

Sending notifications via Apple’s new HTTP/2 API (using Jetty 9.3.6)

HTTP/2 is still very much new to Java, and as such, there are just two libraries who support it – Jetty (from 9.3), and Netty (in alpha). If you’re going the Jetty way (as I have), you’ll need to add their ALPN library to your boot classpath.

Note: Jetty 9.3.x requires the use of Java 8.

A full library for this is available here, on GitHub.

Here’s a quick example:

openFrameworks and AppCode

Developing an openFrameworks app with AppCode is pretty easy. However, if you just open and run the project created by the project generator, you might see the following errors:

Building a stock openFrameworks app results in these errors
Building a stock openFrameworks app results in these errors

Why doesn’t it just work?

This is because openFrameworks doesn’t support 64 bit builds yet on the Mac, due to a dependency on the deprecated QT framework. More on that here.

What’s the quick fix?

Set your project’s architecture to i386 (32 bit) in it’s build settings:

Ensure that you set both, your project's architecture, as well as openFrameworks' architecture to i386
Ensure that you set both, your project’s architecture, as well as openFrameworks’ architecture to i386

Once you’ve done this, your run configurations should shortly say 32 bit Intel instead of 64 bit Intel:

Run configurations now say 32 bit. Yay!
Run configurations now say 32 bit. Yay!

Kudos! Run your project now, and it will work right out of the box!

OpenWRT won’t bring my WiFi interface up, unless the other is up

I recently bought a D-Link DIR 505 router. So far, I’ve got a DLNA server running on it, along with Transmission, a bit torrent client. Life is awesome so far.

I set it up to repeat another WiFi router in my house, the one connected to the internet – using a bridge. It works really well right now.

However, when that WiFi network is down, even the second WiFi network created by my new router won’t come up. I don’t know why as of yet, but I have a dirty hack – if within 10 seconds after boot the router cannot ping my other WiFi router, I will disable that interface and restart the WiFi. This brings the network created by the D-Link up, and I can continue to stream stuff off my hard drive from it.

I created an executable shell script, and placed it in /usr/bin. Then I added a link in rc.local, which is executed after the system is up:

# /usr/bin/wifi_failsafe.sh

logger "Waiting for 10 seconds for network to settle down"
sleep 10

if uci get wireless.@wifi-iface[0].disabled | grep 1; then
    logger "Primary interface is disabled"
else
    logger "Primary interface hasn't been disabled"
    logger "Checking for connectivity"
    if ping -c 1 192.168.2.1; then
        logger "Connectivity has been established"
    else
        logger "Connectivity lost. Disabling primary WiFi interface"
        uci set wireless.@wifi-iface[0].disabled=1
        uci commit wireless
        wifi
    fi
fi

Discover – my second iOS app

iTunes Genius is a great feature. However, it lacks music discovery outside your own music library. Sure, you can always do a Google search for similar tunes, but let’s face it – who has time to do this anymore?

There weren’t any great music discovery apps on the App Store either. All of them either looked ugly, or had to be opened by the user. The content wasn’t available readily.

Then I thought of Discover. I wrote this app keeping in mind that the app would never have to be opened by the user, to see any content. Instead, why not present it in the Today screen itself? This way, the widget can refresh it’s content quickly and present it, in a beautiful manner.

Unobtrusive. Simply genius, isn’t it?

How can this be made any better? Provide buttons which directly search the iTunes Store or YouTube for the song recommended. This way, it’s easy for the user to try out new songs, with zero effort. Eureka! The effort of typing on the device is now gone!

I’ve submitted the app on the App Store for review, and I hope it will be accepted and published soon. Here’s a sneak peak of it:

Highlights of Discover
Highlights of Discover

Discover took a total of one month to complete. Although it was a simple app, I couldn’t give it much time day to day.

I love what it’s turned into. There’s so much that I’ve learned about iOS – auto layout, GCD, and the language itself.

Download your Coursera lectures using JS, bash and wget

So, in light of recent events, I was unable to follow up on my Coursera Algorithms course.

Trying to find a way to download all the lectures at once, I couldn’t find a way that worked for me – I found two, but they simply didn’t work. With the help of some JavaScript that I got from one of these sources, I cooked up the following steps to easily download all the lectures at once:

Step 1: Extract the lecture names, and their IDs from the Coursera page
Navigate to your lecture page(for me, it was https://class.coursera.org/algs4partII-003/lecture).
Execute the following JavaScript in the Console(in Chrome, use the Inspect Element option):

function findLectures () {
  var link_elems = document.querySelectorAll('.lecture-link');
  var lectures = "";
  Array.prototype.slice.call(link_elems).forEach(function (elem, i) {
    var lecture = i + "|" + elem.getAttribute('data-lecture-id') + "|" + elem.innerText.trim();
    lectures += lecture + "\n";
  });
  return lectures;
}

Then call the method findLectures(). This will print each lecture in the following format: Lecture position in page|Lecture ID|Lecture name.
Example output:

0|43|Course Introduction (9:22)
1|1|Introduction to Graphs (9:32)
2|2|Graph API (14:47)

Save this to a file named lectures.txt(exclude any quotes that get pasted)

Step 2: Export Coursera’s cookies
Use the Chrome plugin cookie.txt export to export all the cookies that Coursera has saved. Save the result to a file named cookies.txt

Step 3: Download them!
Run the following in the terminal:

export COUNT=1; while read line; do lecture_name=`echo $line | awk -F '|' {'print $3'}` lecture_id=`echo $line | awk -F '|' {'print $2'}`; echo "Downloading lecture $COUNT; ID=$lecture_id; Name=$lecture_name..."; ((COUNT++)); wget --load-cookies cookies.txt https://class.coursera.org/algs4partII-003/lecture/download.mp4?lecture_id=$lecture_id -O "$COUNT - $lecture_name"; done < lectures.txt

Make sure you replace the link to where your lectures are listed. The above link has “https://class.coursera.org/algs4partII-003/lecture/” in it.

This will download all the lectures in the current working directory. It does not maintain any relationship with the week that the lecture was released in. It downloads them in the order that they are listed on the Coursera lecture page.

“The Library” is here

“The Library” is a collection of several popular encyclopedias. It is your one stop for popular game guides and TV show trivia. You can search, and bookmark articles from various encyclopedias.
What’s more? Each time the app is launched, it displays a random featured article from the encyclopedia you last viewed! Explore more about your favourite game/TV show each day.

Popular encyclopedias include:
– Doctor Who
– Assassin’s Creed
– Lord of the Rings
– Mass Effect
– and 42 more!

With this app, you can:
– Read more about your favourite character
– Read about movie plots, and further details
– Game level guides and walk-throughs
– and much more!

Get it on Google Play

CardBox – Personalize a card for every occasion

We[the CardBox developers], have recently launched a brand new app, CardBox, which allows you to create and instantly share greeting cards for almost any occasion!
CardBox allows you to create cards for the following occasions currently:

  • Birthdays
  • Anniversaries
  • Christmas
  • New Year’s day
  • Valentine’s day
  • Women’s day
  • Mother’s day
  • Father’s day
  • Parents’ day
  • Grandparents’ day
  • Halloween
  • Children’s day
  • Thanksgiving

Here’s a review from one of our fans:

Creating personalized cards has never been this easy! Be it Christmas or New Year's or birthdays and anniversary wishes, CardBox allows you to custom make your own cute little e-card to send to the world. The app contains a bunch of ready-made cards to use for popular events. You can personalize these by adding in your own text and images. If you are more inclined towards the do-it-yourself cards, you can make your own from scratch as well, with the option to use your own photos, and the tons of font and color options available. One of the features that I appreciate most about CardBox is that it auto-syncs with your Facebook friends' information and sends you reminders of their life events such as birthdays and anniversaries. On the whole, this is a great little app to have just to wish someone on their special day in a very different way.

– Rashmi Anand

Like CardBox on Facebook

Get it on Google Play
Coming soon to iOS.

How to get a File object of an Android raw resource using reflection

Context:

You have a URI to a resource which is placed in the raw directory inside the Android resources directory, res. Say you want to take that raw resource(let’s say it’s an image) and add it to an attachment using FIleBody to a MultiPartEntity. Both these classes are available in the Apache HTTP Components library. FileBody will only allow you to give it a File object in it’s constructor. Certainly, you are stuck as you have the URI to an Android raw resource, and CANNOT create a File object out of it.

 

So what’s the solution? Reflection.

    private File getFileFromRawResource(Uri rUri) {
        String uri = rUri.toString();
        String fn;
        // I've only tested this with raw resources
        if (uri.contains("/raw/")) {
            // Try to get the resource name
            String[] parts = uri.split("/");
            fn = parts[parts.length - 1];
        } else {
            return null;
        }
        // Notice that I've hard-coded the file extension to .jpg
        // I was working with getting a File object of a JPEG image from my raw resources
        String dest = Environment.getExternalStorageDirectory() + "/image.jpg";
        try {
            // Use reflection to get resource ID of the raw resource
            // as we need to get an InputStream to it
            // getResources(),openRawResource() takes only a resource ID
            R.raw r = new R.raw();
            Field frame = R.raw.class.getDeclaredField(fn);
            frame.setAccessible(true);
            int id = (Integer) frame.get(r);
            // Get the InputStream
            InputStream inputStream = getResources().openRawResource(id);
            FileOutputStream fileOutputStream = new FileOutputStream(dest);
            // IOUtils is a class from Apache Commons IO
            // It writes an InputStream to an OutputStream
            IOUtils.copy(inputStream, fileOutputStream);
            fileOutputStream.close();
            return new File(dest);
        } catch (NoSuchFieldException e) {
            Log.e("MyApp", "NoSuchFieldException in getFileFromRawResource()");
        } catch (IllegalAccessException e) {
            Log.e("MyApp", "IllegalAccessException in getFileFromRawResource()");
        } catch (FileNotFoundException e) {
            Log.e("MyApp", "FileNotFoundException in getFileFromRawResource()");
        } catch (IOException e) {
            Log.e("MyApp", "IOException in getFileFromRawResource()");
        }
        return null;
    }    

The code is pretty much self-explanatory. Drop a comment if you have any questions/doubts.

Calculate the REAL scale factor and the angle of rotation from an Android Matrix

After performing transformations such as rotation of a bitmap about an arbitrary point, the scale is lost. Of course, this makes sense because the bitmap is rotated inside the same bounds.

To get the real scale now, along with the most reliable degree of rotation, I had to follow this method. Hope it saves the rest of you a night or two.

float[] v = new float[9];
matrix.getValues(v);
// translation is simple
float tx = v[Matrix.MTRANS_X];
float ty = v[Matrix.MTRANS_Y];

// calculate real scale
float scalex = values[Matrix.MSCALE_X];
float skewy = values[Matrix.MSKEW_Y];
float rScale = (float) Math.sqrt(scalex * scalex + skewy * skewy);

// calculate the degree of rotation
float rAngle = Math.round(Math.atan2(v[Matrix.MSKEW_X], v[Matrix.MSCALE_X]) * (180 / Math.PI));