Tuesday, May 06, 2014

dupfinder

My family and I own about seven devices that takes photos. Most of these devices are phones. Funny enough, we only have one camera. With some many photos floating about, managing them is a headache.

The first step in managing these many photos is to weed out the duplicates. One sure way of generating duplicates on our computer is not to take care when transferring them from the phone to the computer. The following is the typical situation.


  • plug the phone to the computer.
  • transfer the pictures to the computer.
  • I don't delete the photos from my phone as I want to see them as I carry my phone about.
  • A few days later, I would repeat the download cycle again, except that I would copy all the photos to different directory. I can't remember where I put the photos a few days ago and I am too scared that I might delete photos.
To overcome this problem, I need a python script.

The algorithm is simple. In 3 simple steps,
  1. For each file generate a md5 digest of it.
  2. group all the files that have the md5 digest together.
  3. copy a file from each group to a new directory
The underlying assumption is that collisions are not possible, but as we all know (http://en.wikipedia.org/wiki/MD5#Collision_vulnerabilities) md5 are not collision free.

The script seems to be relatively fast. It through its way through 2500 photos in about 10mins. This is on an Mac Mini with an 2.7Ghz i7 processor. 

The first version is not fancy and not loaded up with options. There are a number of options i would like to add, including a paranoid and a statistical mode

If you are interested, the source code is available at my Github (https://github.com/tyc/dupfinder) 

Sunday, January 19, 2014

idea for side project #1

Problem

Not knowing how often the lights are being turned on when it is not being used.

Solution

To solve this problem, data must be collected to understand usage pattern of the environment. From this problem, when the light switch is turned on and off, the system will take a note of the date and time of each event. Ideally, each light source would have an accompanying sensor.

Over a course of about two months, enough data would be collected to the system to start doing some preventive measurement.

However, the first measurements it would provide is how much energy is being used by the lights. This should correlate to your power bill.

Secondly, due to the pattern that it has analysed, if anything falls outside the usage pattern, a notification could be sent out. Potentially, saving money.

The sensor could be coupled to a PIR. The analysis could draw patterns on the presence of movements and the active status of the light.

In a typical family house with children, lights will be left on when they exited the room. This system will help reduce the amount of the light is switched on and no one is  in the room

Saturday, December 28, 2013

Keep your App signing keys safe.

Today I tried to publish version 3 of Dream Noise but struck against a problem that I was not aware previously.

During the preparation of the apk for uploading to Google Play, I forgot the password for the signing. "OK, no big deal. I will just delete the old keystore and create a new one," I thought. Well, that went well until I upload the apk onto Google Play. As the version 3 of the Dream Noise was signed with a different key, Google detected that the difference and reject the submission.

I can see that this is the correct thing for Google to do. The signing of apk ensures that it can only be updated by the same people.

So the lesson learn for me is to keep a note of the password that I have used to create the keystore.

To recovery of this problem is to unpublish Dream Noise from Google Play, wait for it to be removed. Upload a new application on to it. That is the plan. Let see if it will work out like that.


This is a link on StackOverflow that addresses this problem. Take heed.

http://stackoverflow.com/questions/4843212/the-apk-must-be-signed-with-the-same-certificates-as-the-previous-version

Monday, December 16, 2013

Dream Noise is on Google Play

Dream Noise is now published on Google Play. Initially, I wanted to do the right testing phase and run the Alpha / Beta test programs through the Google eco system. After speaking to a couple of friends, it turns out that the simplicity of the app allows it to be published straight away.

If you are interested to find out what it is, just to the Google Play link, (https://play.google.com/store/apps/details?id=com.dreamnoise.application) to download and play.

I have also posted the link to Facebook, Google Plus and Twitter. I am now actually sure how to track where the most clicks are coming from. The Google Developer console does have a statistical information, but it is only for downloads. Visits does not count to the Google Play item does get counted.

So far, it has gone through one iteration. It was mostly to change the background colour from a white colour to something darker. The reasoning is when the user is trying to fall asleep, it would be rather silly to have it a bright light emitting from the phone. So I changed it to a dark blue colour.


Saturday, November 30, 2013

zipalign

Before an application is uploaded into Google, it must be aligned to the 32bit boundary. The alignment will be checked by the Google during the upload process. If it fails, a pop up message will say that the .apk is not aligned and reject the upload.

The zipalign tool is located to /tools. You can call it directly or add it to your PATH environment variable.

To execute it, use the following

zipalign -v 4 < outfile.apk>

The outfile is now ready for upload into Google.


Saturday, November 16, 2013

Simple usage of MediaPlayer on Android

In the side project, I wanted to play a sound that I have embedded as part of the resources. After a short research, Android provides MediaPlayer to help you play sounds and videos. I am only going to use it playback some sounds.

Before I started, I browse over to the MediaPlayer docs on Google. The most important is the state diagram that it is displaying. From here, it is required for states of your implementation of the player to follow.

To start with, you will need to create your instance of MediaPlayer.

try {
    mp = MediaPlayer.create(getApplicationContext(), R.raw.whitenoise_30s);
} catch (IllegalStateException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
mp.setLooping(true);
mp.start(); 

When create() is called, the MediaPlayer enters into Prepared state. This means that we can immediately call the start()  and the MediaPlayer transitioned into the Started state. The audio will start to play on  the speaker.

To stop the playing, stop() can be called. When stop() is called, the MediaPlayer transitioned into Stopped. The audio will stop to play and be silent on the speaker.

To playback, instead of calling create() again, it is better to call prepare(). From the state diagram, the MediaPlayer will transition from Stopped to Prepared. A boolean could be used to track if the MediaPlayer has been created or not. This is to indicate whether create() or prepare() should be called. 

Saturday, November 02, 2013

Setting up the menu on an Android App.



As I am developing the Android App, I need to add a simple menu for popping up a dialog box to show the version of the application. As far as I know, the only menu that can be popped up is the Menu button. On a phone, this soft button is usually located on the bottom left hand corner.

I wanted to have a single menu item in the list. It is simple "About"

Firstly, I create a menu.xml and placed it in under /res/menu.

xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
   
    <item android:id="@+id/menu_about"
          android:title="About" />

</menu>

Secondly, I added the code that adds this menu. This code resides in onCreateOptionMenu() which is in MainActivity.java.


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu items for use in the action bar
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main_activity_actions, menu);
        getMenuInflater().inflate(R.menu.menu, menu);
        super.onCreateOptionsMenu(menu);
        return true;
    }

In the snippet of code, I have also shown the code for the action bar. However, the line of the that creates the option menu the call to getMenuInflater(). Be sure that the ID of the xml file is referenced correctly.

When the menu button is clicked, a menu will pop up with only the "About" option displaying.

Thirdly, I created code to handle the event when the "About" option is selected. This is handled in the onOptionsItemSelected() method. So I have the following implementation.

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle presses on the action bar items
        switch (item.getItemId()) {
            case R.id.action_search:
        Toast.makeText(getApplication(), "search is selected",
Toast.LENGTH_SHORT).show();
        
            openSearch();
                return true;
            case R.id.action_settings:
            
        Toast.makeText(getApplication(), "settings is selected",
Toast.LENGTH_SHORT).show();
        
                openSettings();
                return true;
                
            case R.id.menu_about:
                // Single menu item is selected do something
                // Ex: launching new activity/screen or show alert message
                //Toast.makeText(AndroidMenusActivity.this, "Bookmark is Selected", Toast.LENGTH_SHORT).show();
                
            String message = getString(R.string.app_name) + "\n" + getString(R.string.app_version);
            
    // pop up a very simple About dialog box.
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
    .setMessage(message)
    .setPositiveButton("OK", null)
        .show();
                return true;

            default:
                return super.onOptionsItemSelected(item);
        }
    }

This implementation also includes actions for when items from the action bar is also selected.

So when the "About" is selected, a simple dialog box will pop up.

This code also abstract the strings to strings.xml so that it be changed easily. A snippet is shown below.


    <string name="app_name">BackgroundNoise</string>
    <string name="app_version">version 0.01</string>


Friday, April 19, 2013

Started a T-Shirt shop

I have always been fascinated by a business like a market stall on a weekend. Since shifting to Germany, the chance of that happening is small.

So I started to look around the internet to see what is happening. I came across the concept of drop shipping. Drop shipping is a concept where you are selling the physical product, but the inventory is held by your supplier. The supplier also ships the product directly to the customer. Do a check via Google on what drop shipping. Plenty of information will pop up. T-Shirt is a possible avenue.

The T-Shirt bug started when I came across Tee Spring after hearing it on Mixergy. The thing about Tee Spring is that it uses the crowd funding model. You design a T-Shirt by putting some text and some graphic on a T-Shirt. Next you specify how many T-Shirt is your minimum quantity, and set your selling price. You will also need to specify the number of days it is on sale for. Once all these are set, it is time to launch it onto the market. The idea is to get the minimum of number of folks to sign up. When the time has expired and if the minimum number of folks have signed up, a production run of the T-Shirt is executed and delivered out. Some folks have had great success with this platform, unfortunately, I didn't

The next platform I tried was a spreadshirt. It is a more traditional model. You basically create a shop, upload or create some T-shirts, and start the marketing campaign. You can see what my efforts are at http://smartarsecomments.spreadshirt.co.uk/.

The one thing that I did which I should have taken sometime is the name of the shop. I called it "smart arse comments". In some ways, it portrays a red neck attitude for the shop, not something that I feel happy about. It also limits to what I can sell in the shop. The name of the shop should represent the type of T-Shirt it is selling. In the long term, I definitely don't want to see T-Shirts with smart arse comments on it.

Well, I have created 8 T-Shirts on it, any haven't managed to sell any yet. Today is the 8th since I started the shop. The next thing I need to do is to create more T-Shirts, and the start the marketing campaign. I hope that the type of T-Shirts that I have for sale is of interest to the general public.





Friday, January 04, 2013

Hacker News in various flavours


Hacker News is a news aggregator for news tidbits in the tech work about the hacker community.  In this context, hacker means someone who takes something and modifies it to be used in a different manner. The modifies aspect is the hacking activities.

So without further ado, the following is how some folks from the HN community likes to show the news items. 

Websites
Browser extension
Twitter

Friday, December 28, 2012

Initial foray into Android development

I took a deep breath and jumped in. You know what, the water is fine.

I finally made the small jump into Android development. Although, I am just hacking about, I am determine to build something useful. Firstly, useful for me as the first customer, and the useful for anyone else.

The stimulus for getting started in the Android development is the release of the SDK from Google that is easy to install and to get started upon. The one thing that really threw me off to get started on development on the Android platform getting the development environment working correctly.

I have always had a low budget x86 PC as my home computer, and this is what I was going to use as my development machine at home. To get the Android development working nicely on this was a nightmare. I recently bit the bullet and got a Mac Mini with a Intel I7 core. Even with this modest setup, it proved to be the silver bullet for me to get started. The nicely packaged SDK also help enormously.

I downloaded the SDK for Mac from Google. The download from Google installed a properly configured Eclipse and SDK in their correct location. I can simply start Eclipse and start following the Android developer's training. 

To round up the overall development, I signed up for a Github account. I also had to install Git, but that was pretty painless after following the instructions here. I have resisted installing any Git GUI client as I really like the command line interface.




Monday, September 03, 2012

Creating a landing page

If you listen to the many startup podcasts, the one thing that is consistently common among the advice from them when validating an idea is to create a landing page.

What is a landing page? Well, a landing page is a website that gives the visitor quick spiel of your idea and a spot for them to signup to it. The idea is to measure how much interest there are out there to you idea. There are no real measure for this except for the number of signups.

A measure of visitors the landing page is not a good measure as they are only considered as a casual visitors, and does not necessary show real interest in the product.

My landing page at launch.48translate.com was based upon the services of launchrock.com. It uses one of the standard template. I just updated the description and the background to give it a different flavour. Looking at it, it is unmistakeably a page from launchrock.com.

My landing page is my attempt to capture an email address which is a sign of the interest.

I could have gone with a different implementation by using something like weebly.com and embedding a widget from someone like mailchimp.com. Both solutions are free to get started on, but the weebly implementation requires two services, where as launchrock.com only requires the one services.

Some things to lookout for. 

  1. When you first starting a landing page, make sure that your naked address and your www address also redirected to it. 
  2. Get someone to review your text that you put up on the landing page. Make sure that it is correct. Nothing more embarrassing that publishing some action that you cannot support.
  3. Have something on your landing page that could encourage visitors to signup.




Tuesday, July 10, 2012

csv.DictReader in python

I am playing around getting python to parse simple CSV files. In the past, it would get quite difficult no matter which language I choose to do it. PERL does some useful parsing of it, but python is dead simple. It becomes even simpler when usign the csv.DictReader. The following snippet of code illustrates the point.


#!/usr/bin/python
from optparse import OptionParser
import csv


parser = OptionParser()
parser.add_option("-f", "--filename", dest="filename", help="the filename of the csv file")


(options, args)=parser.parse_args()


if options.filename != None:
        csv_filename = str(options.filename)
else:
        csv_filename = "foobar.csv"
print "csv file is " + csv_filename


inputfile = open(csv_filename, "rb")
csvReader = csv.DictReader(inputfile, fieldnames=['create_ts','title','url','id','hn_discussion'], delimiter=',', quotechar='"')


for row in csvReader:
        print row['id'] + " " + row['url']


inputfile.close()

The first part just parses for an input from the console for a filename of the csv file.

The second part is the interesting part where it parses the file as per the given fieldnames. The fieldnames were given during the call of the csv.DictReader.

By the way, this snippet of code is more prototype rather than production. Much error checking is missing and exception handling is missing, so beware.


Tuesday, June 26, 2012

What platform for Mobile apps?

This is just a list of development platforms that I can use for mobile apps.


Google Android SDK - Only for Android, however supported by Google.


Haxe.org - Multi-target. Also needs the Google Android SDK as it generates C++ code. Haxe is a multi target language, similar to Java.



Monday, June 25, 2012

Googlecl, what the f*ck is it?

I was going crazy trying to workout a way to upload data into the my blogger account. Sure, I could just write a post via the post option within blogger, but I want to do this in an automatic manner.


My first was to sent an email via the command line to blogger. The problem is that while it sort of work, I came across the problem that the post is uploaded and marked as a draft version. So I still need to login and publish it. Another problem is that my posts have pictures in them. I am unable to embedded a picture in the email that I am sending via the command line.


The second attempt is to access the Blogger API directly. However, during my research in the Blogger API, I came across googlecl. 


googlecl is Google's answer to accessing data to their services. Their services includes Blogger, Picasa, Docs and many more.


googlecl is also able to upload a file. So if that file is a html file, it would be rendered quite nicely by blogger.


The commandline is


google blogger post --src [filename.html] --title "a title" --tags "awesome"


The article has some hints if googlecl docs are too confusing.

Monday, May 07, 2012

Creating a news aggregator, showhn.blogspot.com

I have been a frequent leader of the tech news aggregator site at Hacker News. It is basically a collection of links and discussions of tech startup news, or just tech news in general that would appeal to the startup hacker.


When someone wants to show case their weekend projects, they usually post a "Show HN" posts on hacker news. As a way of increasing their presence, I have filtered all the Hacker News post for the "Show HN",  screen grab the webpage, voila, showhn.blogspot.com is born.


I have automate the collecting of data via an Google Spreadsheet App script. It uses the hnsearch api to grab the data.


The hnsearch api works directly with the Hacker News database. There are a couple of other hacker news API that performs a HTML scrapes on the Hacker News website and store it in their internal database. An API is available to access the scraped data.


The screen capture is performed using a Chrome screen capture plugin, specifically the Google Chrome Screen capture. 


At the moment, I am treating this as a learning tool. I am especially on getting a handle on how data can be obtained from the websites, and how that data can be manipulate. So far it has been quite a enlightening experience.

Thursday, April 12, 2012

This is getting annoying...validation of an idea.

I got a email from Nev (of AppSumo fame) about how many people are having good success in validating their ideas. So the AppSumo guys thought it would be a good idea to run a competition to see who had best validations, and the winner gets a trip to Austin, Texas.

Well, I accepted the challenge and posted up a validation idea. Check it out here, http://totalcostofcar.weebly.com/ for the launching site.

So I posted up my validation response and ticked the box to receive any follow up messages. This was getting good until some crazy spammers started to post comments, eh spams, up. It was getting annoying.
 
As for my idea, I am going to run this as a slow ramp up. Firstly, I don't have the time to launch into full time, and secondly, I have many things to learn, and thirdly, it started to look like a small idea the start, but it is actually quite a complex application.

I am using weebly.com to create the launch page, however I came across launchrock.com which could have been a better choice as it has better mailing list integration. 

For mailing list management, I stuck with mailchimp.com as I didn't know anything else and I have heard that it was one of the better ones around.

The launch page has been up for about 1 week, and I haven't done and marketing for it. I have four subscribers, so lets see. I need to understand how mailchimp.com works to use it more effectively. 


Tuesday, March 27, 2012

unity, cmock and ceedling

This could be the first post about how I am using a unit testing framework that uses the mock concept.


Some background, I was researching some information on the best way to deploy a unit testing framework for embedded work. I started by posting a question on the programmers.stackexchange.com. The answers led me to investigate the solutions provided by Atomic Embedded, namely unity, cmock and ceedling.


Each of the tool by itself will provide some value of unit testing for you, but for embedded work and to help manage all the infrastructure, all the three tools need to be present.


unity is a bunch of macros that performs the tests that determines if the results are correct. 

cmock provides an intelligent parser and framework that mocks the underlying code. So for all the functions that you use, cmock would be your friend.


ceedling is like the glue that holds unity and cmock together. It is a bunch of ruby scripts the parses your code that is being tested and generates the calls to cmock, generates the test runners and builds the unit test executables.


The Atomic Embedded folks also have CException but I haven't investigate this option.

Tuesday, March 06, 2012

As I was researching Java scripting, I came across an interesting new language. It is called HAXE. For me, the interesting part is the cross platform nature. 


Having a quick look at it, it looks like that HAXE has quite an establish community of developers. There have been quite a few sites, applications and webapps using HAXE as their language of choice. 


Be cross platform, it means that I could be developing a Android application, but it can also be deployed for iOS or a Windows phone.


A framework is also available to create rich and engaging sites. The framework is NME.


I am not too sure what toolchain is required, but with NME as a framework, deployment of it to an Android device looks to be quite easy.



Saturday, March 03, 2012

Choosing a host

On my journey to be the webapp guru :-), I started to search on the net for online tutorials and came across www.html.net. 


On the html.net, it gives some information for all the basic foundations of the building a webapp. I mean, the stack could include Ruby or Python or other. html.net concentrated a php for the server side functionality and javascript for client side functionality. That seems quite reasonable.


I quickly read through the html tutorial and the tutorials about CSS. It is now time to tackle php. I went with their recommendation on using 000webhost.com


The signup process was pretty easy and allow me to quickly get up and going quickly.


From my learning perspective, it said that it gives me full php functionality with MySQL. Technically, it gives me php version 5.2.17 and I can get access to a MySQL installation.


Well, let continue and see how far this gets me.


disclaimer: the link to 000webhost.com is an affiliate link..

Wednesday, February 29, 2012

Hacker News articles and webapp

I just read a couple of post that has quipped my interest in getting starting in webapplications. I found the posts here, where someone was learning Java Script. His results were impressive.

The other posts that I found were through a search on "profitable weekend project" on Hacker News and it brought up quite a few projects.

Some of the projects were quite simple to implement, include www.whatportis.com. It just allows the user to enter a port number and it tells you what it is used for. The other interesting thing is that a simple site like this is a great server for on-line adverts. 

So my motivation for learning Java scripting is to give me the tools to build these simple webapp. Perhaps getting more complicated as my skill set grows.