Tuesday, September 15, 2015

iOS - CocoaPod


CocoaPod
This is a short tutorial about how to use CocoaPod.
CocoaPod is a dependency manager, you can compare it with Gradle for Android projects (or Maven). CocoaPod makes it easy for you to manage libraries in your Xcode projects, because CocoaPod has a database servers with a lot of popular libraries. An advantage is you don’t have to clone a library from github and than include it to your project. This is all automated for you, but before it does all the work for you, you have to to configure a file to make it work for you.

First you need to install CocoaPod on your Mac, I provide you with the following link on how to do that:

To manage your project with CocoaPod, you have to create a Podfile, you can do this by issuing the following command in your project directory:
# pod init

This will create a ‘Podfile’ which will be used by CocoaPod to read what dependencies to manage.
If you want to use FMDB library, this is a wrapper library for managing SQLite db, you add the following line between “target ‘projectname’ do” and “end”:
pod ‘FMDB'

Save file and close your editor, than execute the following command:
# pod install

You’ll see the following output of the command:
Analyzing dependencies
Downloading dependencies
Installing FMDB (2.5)
Generating Pods project
Integrating client project

After that you have to do one more thing! Close your project in Xcode and open the project with the file name projectname.xcworkspace and NOT projectname.xcodeproj anymore.

Well that’s about it. This is the basic to quickly get you started. For more fancy stuff, Google is your friend. 

Friday, August 28, 2015

What I think about AppleWatch


I’m lucky to have an AppleWatch at work to develop apps for it. But before I started to develop an app, I was playing with the  watch to get to know the watch better and its functionality. To be honest I wasn’t really impressed, it didn’t gave me the ‘amazing wow’ feeling. To me, the watch felt so limited, maybe because my expectation was huge.

Friend button
First, I can’t do nothing with the side “friend” button (beneath the crown wheel). The button is there and every time I press on it, I get the message that I can add friends. That’s it, I tried to hard press on it, swipe up, swipe down, just nothing. None of my friends have an AppleWatch and not all of my friends have an iPhone. So this button is useless to me and it’s just there doing nothing.

Home screen
The home screen has a watch interface and you can change the face of the home screen by hard pressing on it. This way you can change the faces and customise its color and so on. So the home screen shows time, date, meeting reminders and so on and also shortcuts to agenda, alarm etc., like a normal watch should be.

Glances
You also have Glances, these are static screens to quickly launch the corresponding app. To show Glances you have to swipe up from the home screen. This gives you access to multiple Glances, by swiping left or right you can switch to other Glances. A Glance just shows you a short current status with no interaction, so it’s a read-only view. By pressing on it, the corresponding app will be launched. So if you want to quickly start an app from your home screen, you just swipe up and than swipe left or right to the desired Glance and than press on it. This is fine if you have just three or four Glances, but if you have a dozen or more, this will be clumsy, because you might have to swipe like 6 or 7 times before you find the right Glance and than press on it to launch the app. So Glances are ok if it’s limited to just 4 Glances.


To start an app without Glances, you press on the Digital Crown, this brings you to a bunch of balls (depending on how much apps you have) each representing an app. You can zoom in and out with the crown to find the app you want to launch. Well, it’s funny how it is designed and it’s unique comparing to other smartwatches, but after playing with it some time, the fun is gone. Some apps are not necessary, like the Map app, the screen is too small to show the map in a comfortable way. The same applies for the camera app, you need the iPhone anyway (it won’t work without the iPhone camera activated). Calling a phone is not a thing I’d do when I’m in public, I rather use handsfree. So it’s clearly obvious some things are not handy to use them on an AppleWatch.

If you want to see notifications from the home screen, you just have to swipe down and you get a list of received notifications that are not dismissed yet.

Another feature of AppleWatch is to use Siri. The thing is, I don’t feel comfortable to use Siri in a public environment. For example in a subway, in a library, or in a supermarket. I rather use Siri when I’m in a car or at home. So I’ll use Siri only in certain places (if I use it at all).

To me, a watch is to just have a quick view or a glance , that’s it. Because it’s a small device, you can’t expect to do a lot of things with your fingers and you can’t see a lot of details on a small screen. A watch should only show you a short information message. So I’m glad Apple payed attention on that. When your iPhone is in your pocket and your AppleWatch on your wrist, all the notifications are sent to your AppleWatch (depending on the settings). Messages like Twitter, WhatsApp, SMS, Email, Facebook posts and so on are perfect to read out from AppleWatch. Also controlling functions, like controlling your music, turn off/on lights of your house while you’re sitting on the couch, remote controlling the TV and so on can be perfectly done from AppleWatch.

So the AppleWatch is a nice thing to have and has nice stuff, but it’s not perfect. Some apps are too complex and overwhelming and thus not necessary to have it on AppleWatch (Map, Camera…). The user interface is not perfect too, it can be better. Also it’s too bad to charge battery every day.

If I would choose between a Pebble or an AppleWatch, I definitely would choose Pebble. 

Tuesday, June 23, 2015

A quick Git tutorial part4

 

gitignore
A common problem when adding .gitignore file is some undesired files are already tracked by Git.
To solve this problem, you need to do the following:
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
 
Solution is found here: http://stackoverflow.com/a/1139797
 
 

Monday, February 2, 2015

A quick Git tutorial part 4

Git notes
Normally, when you commit something, you add a short description to tell what's the commit about.
Such description should be short, with just one line.
But sometimes you'd like to give more information about the commit, something like a note.
Well, Git has a solution for that too. We can add a note like this:
$git notes add HEAD
This will bring you to a default editor to write your note.

Another easier approach is:
$git notes add HEAD -m "This is my note"
This way you can add a note right away.
The above way is comparable with a description for a commit "git commit -m 'this is my comment'".

This feature is added since version 1.6.6!
The note is not added in Sha calculation, so you don't need to amend a commit.


git show-branch
This one is very handy, if you want to compare commit revisions between two branches. Say you were working on a branch and you don't remember whether a feature has already included in the master branch. You can off course switch to the master branch and do a log, but that's not necessary now :) Just do the following in your working branch:
git show-branch master workingbranch
And you get a nice output about the difference between two branches.
Cool right?


For more information, read this link: http://git-scm.com/blog/2010/08/25/notes.html

Wednesday, September 3, 2014

Java - ByteBuffer



There are 2 states in a ByteBuffer object, read-mode and write-mode. There are 3 importantsvalues in a ByteBuffer:
position, limit and capacity.

Capacity: this gives us the maximum bytes a buffer can have, it's a buffer size.

Position: in write-mode it's the index of the next byte to write. If 4 bytes has been written into a ByteBuffer object, than the position is 4, which is the 5th element of a ByteBuffer's array. In read-mode it's the index of the next byte to read, the logic is the same as in write-mode.

Limit: is the space left to write or the amount of bytes yet to read, depending on the state.

Initial state of ByteBuffer is write-mode, why? Well, if you create a new buffer, the buffer is normally empty,
because you haven't filled it yet, so there's nothing to read also. So the first thing to do is to fill the buffer with data, that's why the first state of a ByteBuffer object is write-mode.

Write data to ByteBuffer:
byte[] data = new byte[48];
byteBuffer.put(data, 0, numBytes);

Remaining data means in this state (write-mode), how many bytes available in the buffer to write.
byteBuffer.remaining();

Switch from write-mode to read-mode
byteBuffer.flip();

Remaining data means in this state (=read-mode), how many bytes available left in the buffer to read.
byteBuffer.remaining();

Read data into the buffer:
byteBuffer.get(buffer);

This method means clear all the bytes, reset its states and switch to write-mode.
byteBuffer.clear();

This method means move the remaining bytes to the beginning of the buffer, update its states and switch to write-mode.
byteBuffer.compact();

This method resets its states after reading, so you can read again from the beginning.
byteBuffer.rewind();

mark its current states
byteBuffer.mark();
do some reading...
change it to its pervious states
byteBuffer.reset();

Source:
http://www.ibm.com/developerworks/java/tutorials/j-nio/j-nio.html
http://www.tech-recipes.com/rx/1438/java-working-with-buffers/
http://tutorials.jenkov.com/java-nio/buffers.html

Monday, August 25, 2014

Android - Developer options on Samsung S3

How to enable development on a Samsung S3?

It wasn't easy to enable developer options for the Samsung S3 (apparently also S4) as this feature is hidden. To make it unhidden you have to do the following steps:
  • Go to Settings -> More -> About Device
  • Scroll down to Build Number
  • Tap on it multiple times, it than shows a Toast how many times left to tap.
  • Finally you get a message that you've become a developer.
  • Now go to Developer options in Settings -> More.
Good luck :)

NSNotification example