What is null?

Your friend points you to a room and tells you there's a box there with marbles.

a box with 5 marbles is "5"
a box with no marbles is "empty" or "0"
no box at all is "null"

Approximate string matching cheat sheet

  1. Levenshtein distance : if the pattern is coil, foil differs by one substitution, coils by one insertion, oil by one deletion, and foal by two substitutions.
  2. Damerau–Levenshtein distance : Like Levenshtein but including transpositions among its allowable operations.
  3. Jaro–Winkler distance : designed and best suited for short strings such as person names.
  4. Smith–Waterman algorithm : performs local sequence alignment for determining similar regions between two strings, instead of looking at the total sequence.
  5. Needleman–Wunsch algorithm : divides a large sequence into a series of smaller problems and uses the solutions to the smaller problems to reconstruct a solution to the larger problem.
  6. Soundex : a phonetic algorithm for indexing names by sound, as pronounced in English.
  7. Metaphone : improves on Soundex by using variations and inconsistencies in English spelling and pronunciation.

A note to designers


  • Your job is to make things simpler, not cooler.
  • Restrain the product people from adding unnecessary features.
  • Save time for the engineering team, not make their lives harder.
  • Make sure that form follows function.

Forgive the early adopter

This is a letter to my friends and my colleagues.
I'm truly asking your forgiveness.
Forgive me for switching between messaging apps every few weeks.
Forgive me for forcing you to use my unfinished apps and services.
Forgive me for being mad at you when you buy the "wrong" phone, laptop or TV set.
Forgive the early adopter in me :-)

I really appreciate the fact that you're willing to go through all the beta phases and stick with it.
Your devotion will not be overlooked when our robot overlords take over us and appoint me as one of their liaisons.

Stop Complexity Insanity

Whatever you're doing, stop, breath, and listen to these folks:


  • Isaac Newton - "Nature is pleased with simplicity. And nature is no dummy"
  • Leonardo da Vinci - "Simplicity is the ultimate sophistication"
  • Antoine de Saint ExupĂ©ry - "Perfection is attained, not when there is nothing more to add, but when there is nothing more to take away."
  • 1 Corinthians 14:33 - For God is not a God of confusion but of peace. As in all the churches of the saints.
  • Bruce Lee - "It is not a daily increase, but a daily decrease. Hack away at the inessentials."
  • Oded H. Breiner - "Remove to Improve."

Apprenticeship-based education system


  • Each person will be allowed to choose his "master" and be his apprentice (e.g. a high school student can choose an experienced software developer as a "master").
  • In exchange for education, the master will get cheap labour (e.g. manual QA, or even personal help like cleaning).
  • Down to this point, it is very similar to the apprenticeship model that was common in the later Middle Ages and came to be supervised by craft guilds and town governments.
  • Here's the difference: back then, a master had high motivation to make his apprentice a good craftsman because he would often get him to work for him later on. Today, this model is rare because of the wide volatility in workplaces, and because of big companies.
  • So as an extra incentive, masters should get a cut of their apprentice's wage for a few years after the apprenticeship is over, but only if a certain wage level is achieved.
  • Benefits
    • Cheaper education to be paid by students in the future and only if their education was successful.
    • Higher quality education achieved by one-on-one sessions.
  • Dangers
    • Misuse of students by charlatans.
    • Hard to measure quality of teachers (masters).
  • Solutions to dangers
    • A rating system measured by the amount of money transferred from graduates to masters.
    • The more money that is transferred, the better was the education because the apprentice earns more.

Android wear SDK impressions

Android wear is extremely tied to intents and notifications.

Everything is managed using NotificationCompat API. If an app has standard notifications they will appear in the watch, and all the buttons in the notification will be available in the watch.

Everything in the watch has to be pro-active, besides apps that can register to a closed set of voice intents.

It has a few of interesting tweaks to notifications:
1. You can add a button to a notification that sends voice2text into the app.
2. You can stack multiple notifications.
3. Notifications can have pages for added data.
4. Notifications can have an image background.

why Android's search bar is dumb


Pardon the rant but...
Google's idea of a search bar is pretty darn useless.
A search bar is supposed to be ready for text input the second you touch it.

But no! it is too complicated for all-mighty G to create such a simple thing.
Instead, when you touch that widget up there, it just opens the search app!
Why waste so much space for what is essentially just a fucking icon!?!?!?

I've been waiting on Google for 3 years to fix this, but now I'm putting my foot down!

Google - you don't want to fix this?
I'll fix it myself!

Hello mrQuery
mrQuery is a home button replacement that takes the solution to this problem to the next level.
When you set mrQuery as your launcher it makes your android act like it's on cocaine.

  • Tap the home button, and get the keyboard open right away, start keying a name of an app and it launches immediately.
  • Access your favorite contacts and various system settings from the same box.
  • Every app you launch is added to a small "history" view above the search-bar for even faster access.


Check it out on the play store.

FAIL entrepreneurship

F.A.I.L entrepreneurship:

Fail
Analyse
Iterate
Learn


Fail
As soon as you can, you are nothing without failures, they are the fuel for everything: motivation, learning and change. more...

Analyse
Analyse! Analyse! Analyse! set sensors on every possible data and decision point, every user click, tap and interaction. more...


Iterate
Repeat and try again, get into the FAIL loop, do the shortest iterations possible, every time you do a long iteration it's like running with your eyes closed. You have to zoom-out and re-iterate. more...


Learn
From your analysis and failures, commit to learning ahead of time. "If we fail at this, we learn that". more...

Adding a jar to Android Studio

Should be pretty simple right?
Well, the UI doesn't support it right now but it is pretty simple to handle manually, so you'll have to open your build.gradle file that should be in:
/projectName/

And add the following:
dependencies {
    compile files('libs/jarFileName.jar')
}


Example:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/MixpanelAPI.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 16
    }
}

Android layout shadow without 9 patch

Applying shadows to android layouts without using a 9-patch on android 4.3 and below! (4.4 changed toast design)

Using a 9-patch is (sometimes) too much of a pain in the buttocks, when all you want is just a simple shadow, CSS has it, so why doesn't android??? Grrrrr...!

I found a hack.

While working on Mr.Query, I was looking for a built-in android icon because I was too lazy to design a new one.

Then, I stumbled upon:
                android:background="@android:drawable/toast_frame"

                android:background="@android:drawable/dialog_frame"



I tried it on a few different layouts and buttons, and it's not bad!

Here are a few examples:




<TextView
            android:layout_width="fill_parent"
            android:text="I am a simple textview with a shadow"
            android:layout_height="wrap_content"
            android:textSize="18sp"
            android:padding="16dp"
            android:textColor="#fff"
            android:background="@android:drawable/toast_frame"
            />

    <LinearLayout
            android:layout_height="64dp"
            android:layout_width="fill_parent"
            android:gravity="center"
            android:background="@android:drawable/toast_frame"
            android:padding="4dp"
            >
        <Button
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="Button shadow"
                android:background="#33b5e5"
                android:textSize="24sp"
                android:textStyle="bold"
                android:textColor="#fff"
                android:layout_gravity="center|bottom"
                />

    </LinearLayout>

    <LinearLayout
            android:layout_height="64dp"
            android:layout_width="fill_parent"
            android:gravity="center"
            android:background="@android:drawable/toast_frame"
            android:padding="4dp"
            >
        <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="color textView with LinearLayout shadow"
                android:background="#f2eee8"
                android:textSize="18sp"
                android:padding="4dp"
                android:textColor="#111"
                android:layout_gravity="center|bottom"
                />

    </LinearLayout>


Made with hilite

Run Lint on Android Studio

Android Lint is a tool that scans Android project sources for potential bugs.
For example, it can find unused resources.
To run it on Android Studio:
Top menu-> Analyze-> Inspect code

To run it on a specific module, make sure the specific module is selected in the Project tab.

Re-enable smart app banner in ios after clicking x close button

It is pretty simple actually, to re-enable smart app banner in ios after clicking the x (close button), just click "Clear Cookies and Data" in Safari settings under iOS settings.

Sustainable engines of growth


Sustainable engines of growth in startups are ways in which old customers bring new customers

There are 4, according to "The Lean Startup":
  1. Word of mouth.
  2. Side effect of product usage (viral).
  3. Funded advertising, acquiring a customer should be lower than its revenue.
  4. Repeat purchase or use.

REST API simplified

Before I get philosophical, here is the gist:

For the function:
  • getPhoto(String photoName, int userId, int width) 
In the controller:
  • PhotoController.java 
The suggested rest API is:
  • http://hostname.com/api/photo/get?photo_name=flower&user_id=123&width=1024
Or in more general terms:
  • {protocol}://{domain}/api/{controller_or_service_name}/{short_function_name}?param1=value1&param2=value2&paramN=valueN

Philosophy

I've worked with dozens of rest API's and also created a few. Some conventions are very simple and easy,  some are complex.

When creating an API you have three players to think about:

  1. The developer (probably you)
  2. The client developer
  3. The end user


The developer (you)

You are your own client, and so are the developers that will inherit and maintain your code. Creating a self-explanatory API means making it easily expandable.
If you are developing a service layer or a controller layer, I suggest adding their name to the path, right after the host:
  • host.com/photo/
This will make it easy to to find the right controller when maintaining the code. This will also, usually be, either the object that the function returns, the main object that it manipulates, or the name of the main action, in that order of priority.
For the same reason, immediately after, put the short name of the function that handles the parameters:
  • host.com/photo/get 
Then come the query parameters themselves:
  • host.com/api/photo/get?photo_name=flower&user_id=123&width=1024
Non abiding order, optional and nullable.

The client developer

If you only had the client on your mind, using query parameters for everything would be the best choice, their order is non-abiding and they are all optional. But this will require creation of a special function for navigating to the right controller and make it imparseable to the user.

The end user

If you were only to think about the end user, you would probably use very few query parameters (e.g. id=123) and mostly path sections (e.g. photo/id/123). Path sections are cleaner looking and use one simple delimiter character ("/"), so users have an easier time navigating your API. But this is where user simplicity ends, and developers' complexity begins:
  1. Using a path for dynamic data like a user's id could cause some trouble:
    • if the function can handle a null value
    • if it includes special characters.
  2. The order of the parameters is static and the client developer can't just throw them on using a query parameter map.
  3. Arrays and JSON objects can't fit in a path.


To sum it up:


  • http://hostname.com/api/photo/get?photo_name=flower&user_id=123&width=1024

Or in more general terms:
  • {protocol}://{domain}/api/{controller_or_service_name}/{short_function_name}?param1=value1&param2=value2&paramN=valueN


And here are a couple additional examples:
  • Function: deAssociateUserAndPhoto(String userId, String photoId)
    API: http://hostname.com/api/user/deassociate ?photo=456 user=123
  • Function: MapService.getDistance(Point a, Point b)
    API: http://hostname.com/api/map/distance?point_a=42.365,31.987&point_b=36.743,28.234

The real difference between static and dynamic programming languages

The real difference between static and dynamic programming languages from an entrepreneur's point of view.

The debates are endless and tiring, you can get a taste at stackoverflow.

But when push comes to shove, and you really want to know what is the actual real-life difference between statically typed (aka Java) and dynamically typed (aka python) programming languages...

It all comes down to this simple explanation:

  • Dynamically typed = Easy Get up
  • Statically typed = Easy Maintenance

When using dynamically typed languages, you are much faster in constructing a new project, and you need less lines of code than a statically typed language to do most things. Later on, when you'd want to poke around and change stuff, it would probably be harder.

When using statically typed languages, it's easier to maintain, change and refactor the code, but you have to do more work to get things going.

For example, defining and sorting a list:

Java (static):
List<integer> a = new ArrayList<integer>();
a.add(5);
a.add(2);
a.add(3);
a.add(1);
a.add(4);
Collections.sort(a);

python (dynamic):
sorted([5, 2, 3, 1, 4])

As you can see, Java (static) is longer to type and you have to know about many keywords, pyhton (dynamic) is much shorter and self explanatory...
But if one day, you would want to change some of the objects in the list, and accidentally put a "text" object instead of a "number":
python would just handle it and treat all of the objects in the list as text objects. You would only find out about your mistake when the program runs and a human actually looks at the output and realizes something is misplaced.
Where in Java, the program will not even run, so you would know immediately where and what to fix.

You can say that python is "smarter" because it adapts to the data, and you would have a point... but when you have thousands of lines of code, and many programmers, you want zero flexibility and you want to be notified of any inconsistency.

So to sum it up:
If you want speed at the beginning, use a dynamic language.
If you want easier long-term maintenance, use a static language.

What do you think? comments/corrections are welcome...

The Art and Science of Fundraising (Excerpt)

The Art and Science of Fundraising - excerpt
According to Scott Weiss from Allegis Capital.
  1. I hear and I forget, I see and I remember, I do and I understand.
  2. Get multiple term-sheets (offers).
  3. Leave a positive impression on everyone you meet.
  4. Valuation by perfection, be pedantic on every investor touchpoint.
    1. Team
      1. CEO
        1. Authenticity - don't be phony, sweat, show your weakness, be yourself, know what you don't know, don't be defensive.
        2. Coachability - solicit feedback, surround yourself with mentors, you are a share holder before ceo.
      2. Chemistry, don't interrupt each other, everyone talks about what they know best.
      3. Match up your team to the investor team: Tech specialist -> geek, Numbers guy -> marketing, 2 to 1, 3 to 2.
    2. Market opportunity
      1. Tell a story in your slides, keep it short,
      2. You know all the questions, 20-30, prepare for each one of them. Know which team member is going to answer them. The ceo is like a point guard, dish out to the member who knows the answer.
    3. Competitive advantage
    4. Traction
  5. Practice, practice, practice, start with tier 3 investors and move up.
  6. Cast a wide net, meet many VC's and angels in a short time. Makes the deal hot.
  7. Talk with other CEO's before choosing a term sheet.
  8. Have a user advisory board, if an investor ever needs to call a user. give them stock. get their cellphone.
  9. Know the time to close, due-diligence period.
  10. Small odd-number board, majority of founders and independents (non-vc's), could be experts.





The Art and Science of Fundraising from Allegis Capital on Vimeo.

Setting up google analytics EasyTracker for Android


  • Add libGoogleAnalytics.jar to your project's /libs directory.
  • Add EasyTracker.jar to your project's /libs directory.
  • Add the following permissions to your project's AndroidManifest.xml file:
  • Get UA code from your analytics admin section
  • Add your UA code to your values/strings.xml like so: UA-xxxxxxxx-x .
  • Change the activities you want to track-
    • from: Activity / ListActivity
    • to: TrackedActivity / TrackedListActivity
you're done!

Skynet attacks stock market

I never thought Skynet will attack the stock market first...

Watch this terrifying GIF and see how robots have taken over the Stock markets.

Wait until 2012...