quarta-feira, 14 de janeiro de 2015

[QuickTips] Git Ignore....

This is going to be a blazing fast tip. We all have had problems with .gitignore files not being properly setup or not being the way we wanted them to be.

Along with that comes the fact that we maintain lots of notes about each technology we use to determine how the file should be filled.

But then there is those kind-hearted souls who decided to give us a boost

First I wanted to reference the github repository named gitignore containing templates like Objective-C.gitignore and VisualStudio.gitignore and many more.

Last but not least is the site that remembers Google, just a search field and a click of distance to access lots of .gitignore templates: gitignore.io.

That's it for now, enjoy a new world without the troubles of those lovely files.

sexta-feira, 14 de novembro de 2014

[Quicktips] Tools for web dev - curl e hurl.it

Often developers ask others about tools to solve or help solving problems of all kinds and sizes.

When it comes to restful API's we have one (amongst others) annoying problem: testing the endpoints.

So how do you do this? Not all API's have tools made by their teams to test them.  The same is true for your own one.

And here goes a tip, two tools to help you, the first one your computer probably has one, the second one is a web tool.


It's a terminal tool  for transferring data with URL syntax in different protocols with a myriad of options, open your terminal and type curl -h to see the magic.

Why is it here? Why is it good?

  • Easy to use
  • Json friendly
  • Command line tool!
Why not?
  • May become cumbersome to type
  • Not any user friendly


A free HTTP request tool, similar to curl but works in the browser.

Why is it good?
  • User friendly
  • Free
  • Works in the browser
 Why not?
  • Web only
  • HTTP only
Check it here

segunda-feira, 29 de setembro de 2014

[iOS Quicktips] Transparency error on iTunes

Apple normaly gets things right about improving their hardware and software, but in regards of devs support some times things don't go quite well.

One of this samples is the last iTunes Connect update (Xcode 6 / iOS 8  in 2014) which changed something on how they expect your images to be uploaded and made a bunch of us quite sad.

If you have the same problema as me you were receiving this message: "Images can't contain alpha channels or transparencies."

By the time this problem came to me the design team have already tried almost everything they could think of, and I went to a simple path of looking in the net one last time.

So I got to this  stackoverflow post, and Smikey anwser solved my problem.

He simply suggests that we re-export the asset using Preview with Alpha option unchecked. By the way we were using a .png image.
Thats it problem solved.

Hope this help you ;)

sábado, 2 de agosto de 2014

[Quicktips] iOS - Follow Keyboard Animation Behaviour

On getting back to iOS programming I restarted to check into interesting subjects, like the right way of creating view controllers, behaviours and more.

One thing I had to create these last days was some code for a text field to follow the keyboard open/close animation. Then it come to me that we were going to use that behaviour was needed in more places and that it didn't belong to the view controller neither to the view using it.

So in order to achieve that I decided to create a behaviour class which features are:
  • To receive a target view
  • Register under keyboard events
  • Animate the target view to follow the keyboard open/close animation
  • Keep target view before (on top) of keyboard, meaning that target will be hidden when keyboard is closed
This set of features don't break the single responsibility principle since it is responsible only for controlling the animation behaviour of a view following the iOS keyboard.

To achieve our desire the class must subscribe to keyboard notifications and follow keyboard info dictionary in order to animate the same way the keyboard does.

In 1. we retrieve the type of animation, the duration and the final position of the keyboard. The problem with the animation type is that Apple uses a internal value which only works directly with the old animation style.
To use it with animationWithDuration methods we would have to shift the value, this isn't easy to understand and read later so is preferable to keep the old style in this case.

In 2. we use the animation calls on UIView to prepare animation with keyboard info.

In 3. we animate using the keyboard final position, in my case I'm positioning the view right above keyboard, and when dismissed the view will be hidden outside of the screen in the bottom. Also we have to commitAnimations so evertyhing will work properly.

That is all we need to create a behaviour that works with any view.

The class and the demo are available on github.

segunda-feira, 14 de abril de 2014

A few things I've learned with Ruby and Rails

The past 3 months have been a heavy storm with hail rain and everything, still there is always a bright side on life events.

During my last job at Code Miner I had the pleasure to work with:
  • Ruby on Rails (and the huge amount of things that come along with it)
  • Good professionals
This short time lead me to decide to share my small knowledge with the others that may struggle, like I did at some points. 

So first things first: Ruby on Rails. This pack made it appearance several times in all those years and deserves a cool place in things you would like to learn or at least should learn.

The Ruby and the Rails community, along with my teammates, taught me lots of new skills and improved old ones, so let's get to the sweeties.

1 - Debug, debug... and.... did I said debug?

The most important thing to learn when programming in any language is how to debug your code. Ruby has this quite good Gem to help you: pry

All you have to do to use it is requiring: require 'pry' then you add binding.pry anywhere on your code and ta-da! when you run your app it will stop at that command and from this time on there is access to code variables, next steps and a few more useful things (take a look at github)

2 - My precious! My gems, gollum gollum

You probably already heard that cliche line: Don't reinvent the wheel.

Ruby has those precious libraries of working software called Gems. 
Need something to debug your code? Bam: Pry gem. 
Need something to parse xml? Boom: Nokogiri gem.
Need some background processing? Pow: Sidekiq gem.
Need your sidekiq jobs to be scheduled? Bang: Sidetiq gem.

There is a huge sort of gems sitting there just waiting to help in solving pesky problems so you can focus on creating an awesome app. Oh and there is a lot of them dedicated directly to Rails like the famous ActiveAdmin.

Ruby Toolbox and Ruby Gems may help you finding the ones you need.

3 - Did you saw that bug?

Sadly Test Driven Development (TDD) isn't used as much as it should be and  I can understand that. 

Most of  the non TDD teams have lots of excuses but almost none of them spent or want to spend enough time using it, otherwise they would see how beautiful and useful it is.

TDD has proven worthy to me after much struggling still with objective-c in iOS world, which community is not so visibly into it. 

Here is 4 reasons why I love it:

1. Bugs reduction and faster bug finding:

The first happens because you're thinking ahead, you need a way to check your code output even before it exists. The later happens because when changes are made you know what is the desired output.

2. Improves code readability and quality

It's hard to believe, but you tend to be more careful with what you're writing since you and others will be getting back to the tests a thousand of times. 

Since you're being more careful with the code it's architecture will receive a boost, be prepared to read tons of articles/book on the subject.

3.  Changes the way you see refactoring

You start to hate when its difficult to test your code, and that will be more often than you think. Refactoring begins to be more clear and this feeling fades away  before you know.

Besides with a good testing suite refactoring  will be easier and delightful.

4. Working in teams is nicer

Hey have you never hated that hard to use friend's code? Now if you have tests you probably will just have to run them a few times and there you go. 

4. Everyone loves free candies, but do you give them too?

This one is short, we all love to use open source projects (yep Gems for example), but most of us don't have the guts to contribute.

Hey no one will shove you off if you're really helping, just give it a try. Oh and those beautiful projects of yours, release them properly as Open Source too, who knows, maybe you get some katas for that attitude.

I didn't learned this here with Ruby, but this feeling is stronger amongst its community.

This absolutely isn't all the things I wanted to share, there is more, but I think this is enough to my purpose, to give you a glimpse of the good things from the many which will improve yourself as a programmer when you enter, even for a moment, in the Ruby and Rails world.

By the way, I can't address how fulfilling is working with a great team, so if you have the chance of doing this please just go for it.