Sunday, 12 April 2015

Git micro commits vs issue commits

Probably many of you have used Git, or SVN or both. If you didn't use them then give Git a try and forget SVN, it will make your life easier. You can find the most popular git cloud repositories at GitHub and BitBucket. I'm not gonna waste your time with what is Git or SVN, you can read yourself and figure it out. 

Now why I choose to compare micro commits vs large commits? Well, until recently I used a piece of software built on SVN. When it launched, probably was a very hot tool to use, but as time passes other tools come around and this one doesn't satisfy your needs at full. Using SVN for a few years now I couldn't branch. The tool had the option to branch but it was a nightmare to use it so instead of ruining the whole repository I choose not to use it. So basically I was forced to commit and push only after my code was done, tested and fully functional. Imagine working a week, or even more, adding more and more stuff to your solution and push everything into one massive chunk of code. For me it was a nightmare as if any of the code me or my team were pushing might need removal you have to remove the entire push. This is the story for mega commits.

Recently I decided to use git for my final year project. Some reasons behind this decisions involved a good branching system, more grained control over your code and your work and very easy rollback in case of mistakes. Usage of a new system came with the specific learning curve and after I got used with using it I forgot about the old SVN system. What is interesting is that when you learn a similar technology you tend to use your old habits with it and not be aware of some of the advantages. This happened to me as even having all the advantages of git I kept commiting and pushing after all the work has been done. While working on my Android project I had a git issue that involved adding activities, classes, creating data models and changing other existing ones so I started to commit after each change. For example when I added a class, an activity or an xml file I commited. Then I realized that this is a more efficient way to commit my work as I could see better commit messages and cherry pick commits. Also my commit messages are more specific and my final one will close the GitHub issue I was working on.

This is one day of work:
SourceTree commit messages log
SourceTree commit messages log
The tool I use to manage my repositories is called SourceTree and is free.

Wednesday, 9 July 2014

Google Glass Development - setup tools, environment and turn on debugging on Glass

Hi there!

Recently I acquired a Google Glass and I thought to make my final year project based on this device. I know this is new technology and the hardware is still a prototype but I think I can learn new interesting things. So lets get started by installing the development tools. First I downloaded and installed Android Studio from Google. Here is the link I used Android Studio. I'm using Windows so you have to select your OS if is not already detected by Google and you are presented with a download link for your OS. You can also develop your project(s) by using Eclipse and the ADT plugin.

After I installed Android Studio I put my glass in development mode. This is not very hard to do, you just need a bit of practice on how to navigate with the touch pad. Just a short description on how to navigate the touch pad:
- swipe backward to get to next menu item or to the settings menu if you are on the home screen;
- swipe forward to access previous items or cards;
- touch the pad to access the menu item highlighted, to see a picture or to play a video. Tapping means that you want to execute the menu option in focus.

Now lets get back on how to put your Google Glass in debug mode. First step is to turn on your Google Glass by pressing the little round button inside the frame of the Glass. After your device is ON then on the Home screen (the screen with clock and "ok glass" command) swipe back with the touch pad (swipe from front to the back of your head) until you will see the menu "Settings" and you can see the icons with the battery and the cloud. At this point tap on your touch pad to access this menu, then swipe forward using the touch pad until you see the "Device info" menu screen. At this point tap on your touch pad to access this menu and swipe forward until you see the "Turn on debug" menu. When you see this menu option tap on the side and the Glass it will inform you that you have activated debug mode and your menu will change to "Turn off debugging". At this moment you are ready to start developing.

To turn off debugging on your Google Glass just follow previous steps and tap the glass when you see "Turn off debugging" menu option.

Next option after this menu item should be "Factory Reset" so please be careful what you tap or you might erase all your data on your Glass. To avoid this turn on backup and Google will backup what's on it.

Once all your installation is done and your device is ON debug mode you can start developing that cool stuff you dreamed off or you are paid to do it. Either one of these, enjoy it :).

I will come back with more information regarding my project on Glass and code samples.

Tuesday, 12 November 2013

Fix blurry Chrome on Windows 8.1

Recently my computer decided to upgrade to Windows 8.1. Microsoft decided that I should follow technological trend and not stay behind so after restart, surprise! My computer now has a cutting edge operating system and should make my days easier, and the entire world will be happy.

Curious to see what new Windows 8.1 has extra I decided to start Chrome, but then I noticed that my Chrome is blurry. I thought that my video card went crazy so I checked settings, but everything was fine. Then I applied classical Windows fix: restart my computer, but same problem. Now if that didn't fix it, nothing can be done related to Windows (from my experience a computer restart will solve 90% of my problems regarding Windows). Now I am a bit worried that I might have a virus, so I start a virus check, download anti-malware and anti-virus software but nothing, Chrome is still blurry. If there is no virus and Windows is healthy probably Chrome has a problem so I switched to Firefox. Foxy is happy, no blurry edges, nothing.

Today I got some time and by curiosity I found the solution: I deactivated Chrome's display scaling on high DPI settings and everything works fine now. That came in mind after realizing that Chrome is blurry only on my 1080p screen and not on other computers running Windows 8.1 that I have access to.

For easy of understanding I also attached a picture:

Image how to fix Chrome blurry on Windows 8.1

To deactivate scaling on high DPI go to Chrome icon on Desktop -> right click -> select Compatibility -> tick Disable display ... -> click Apply -> click OK -> restart Chrome -> be happy!

That's it.
See you next time!

Friday, 7 June 2013

How To: Get the rendered HTML of a webpage with Python

Hello again!

This time I'm gonna show you how to get the rendered HTML of a webpage using Python. For this task we need only ten lines of code and to import urllib2, the library that it will help us. The rendered HTML of a webpage is the HTML that our web-browser receives from the server and renders on the screen. In simple words, this is what we see on the screen and not the code used to generate the webpage.
This HTML code I use to find specific tags into the code.

Here is the code:

def get_page_code(link):
    import urllib2                 # import the necessary library
    html = ""                      # initiate an empty string as the variable that holds the html code
    req = urllib2.Request(link)    # initiate a request
    try:
        response = urllib2.urlopen(req) # store the response in a file
        html = response.read()     # read the content of the file
        response.close()           # close the file
    except ValueError:
        return html                # if there is an error return the empty string
    return html                    # return the generated html


Keep in mind that you will get a long string as output.

Tuesday, 4 June 2013

Set union of two lists in Python

Hi there!

This is my first blog post so please be patient with me. Today I started a small course about Computer Science and as programming language is using Python. For me this the first time when I use Python and I am impressed by the syntax and other features. I am coming from Java and c# but I hope I will do fine with Python to.

One of my tasks for today it was to define a function in Python that takes as input two lists a and b, it does set union on them and the result is the list a modified with the new values. I find it very easy to do, I didn't had to use any indexes or something like that, just 3 lines of code and problem solved.

Here is the code:

def union(a, b):
    for el in b:             #iterate over list b
        if el not in a:      #if element of b is not in a
            a.append(el)     #append the element to a

Now a test in console it should look like:
a = [1, 2, 4]
b = [2, 3, 6]
union(a, b)
print a
>>> [1, 2, 3, 4, 6]
print b
>>> [2, 3, 6]

That's it.