Effective Objective-c 2.0, by Matt Galloway

Over the next weeks, I will be making a small comment about the new book of Mr. Matt Galloway. This comments will be about each chapter’s item, so we are talking about 52 small posts. I prefer to do so, instead of dissecting 7 chapters. So godspeed!

The goal here is not to, in no way, transcript the book, but to be a guide for me, to study and retain what the book is trying to transmit.

Advertisements
Tagged , , , , , ,

RPNSURLConnection+Swizzled

Created a few days ago a category that allows you to know what calls are you making (the url more precisely). This is extremely helpful because you don’t have to keep track of every place where you use NSURLConnection.

It will also output the stack trace, which can as well be very useful to understand from where the call is coming. You can find it here. Since it uses method swizzling, I don’t recommend the use of it on production (aka release).

Blocks as Closures

Closures can be something difficult to grasp but they have some interesting use-cases from simple to harder ones. For instance:

def power_to
  foo = 1
  Proc.new { foo += foo }
end

proc_obj = power_to
puts proc_obj.call
puts proc_obj.call
puts proc_obj.call

This will print:

$ 2
$ 4
$ 8

The method power_to returns a Proc object which has the state of foo local variable. Though, the variable remains accessible to the block even if that variable is out of scope when the block is called again.

That’s closures and it’s the basis of lexical scoping which you can find in other programming languages such as JavaScript.

Tagged , , ,

Xcode Hidden features

A nice thread @ stackoverflow about hidden features in Xcode

Tagged , ,

How debug Node.js applications using Eclipse

eclipse-node

In this post I’ll help understand how can debugging a Node.js application from scrach.

Requirements

You need installed in you computer the following tolls:

  • Java
  • Eclipse
  • Node.js (make sure that you have access a node command in your command line tool)

Create a Simple Node.JS application

First, we’ll install express.

npm install -g express

Note: The -g flag means that you are installing express globally on your system.

So, now we are available for create a node.js application using express.

express -c stylus express-app-sample

Note: The -c states that we want to use stylus for css.

The next step, is install the app dependencies. So, we need enter express-app-sample folder and install. We can do that with the following commands:

cd express-app-sample
npm install

And now we’re available for running our app. What we need to do is the following command.

node app.js

You should see Express server listening on port 3000 and if you open http://localhost:3000 you’ll see the default Express page.

Debugging Node.js application using Eclipse

Install Eclipse debugger plugin for V8

With Eclipse debugger plugin for V8 we can easy used for debugging node applications. This is the steps to install the plugin on Eclipse:

  1. Select the menu item Help > Install New Software…
  2. Click on Add… button.
  3. In the textbox labeled Name: enter Google Chrome Developer Tools. In the textbox labeled Location: enter http://chromedevtools.googlecode.com/svn/update/dev/. Click OK.
  4. Select Google Chrome Developer Toolshttp://chromedevtools.googlecode.com/svn/update/dev/ from the combo box Work with.
  5. Click the checkbox next to Google Chrome Developer Tools in the table. And Click the button labeled Next >.
  6. Accept the terms of the license agreement and click the button labeled Finish.
  7. Eclipse will restart with the V8 Eclipse Debugging Plugin installed.

Debug node.js application

  1. Using node.js command line, we’ll launch our app on debug mode, using the following command:
    node --debug=5858 app.js
    
  2. In the Menu, choose Window > Open Perspective > Other, then select Debug from the list and click OK, to ensure we are viewing the debug perspective.
  3. Click the drop box button next to the green bug one and select “Debug Configurations …” option.
    debug-configurations
  4. Start the debugging by clicking “Debug” button. If everything goes well, we’ll get something like this:
    node.js-debug
  5. So, we just need to put breakpoints on the project that appears when we start debugging, in the Project Explorer, to debug.

NOTE: You can find out more about debugging node.js applications using Eclipse in this link.

Tagged , , ,

iOS 7

iOS 7

Tagged

TestFlight + Xcode + Archive Post-Script = win

Imagem

For some time now I wondered how I could do automatic uploads to Test Flight. As you might have guessed, they allow to make builds uploads by using their API, which is quite straightforward. So, I read somewhere that some people already had created scripts to do this automatically for you. A big bonus here, is that Xcode, allows you to run scripts after an archive has been made:

Imagem

This can easily be found when editing your schemas. After that just add this. And the blog post talking about it. I have tried the first  suggestion, but the 2nd one was the most complete. Besides allowing you to select some stuff (distribution lists, Provisioning profile, etc) it also shows you what’s going on the console. So have fun!

Tagged , , , , , , , ,

HTTP Proxys

These days I have been working with Proxys, Load Balancers, HTTP and all kind of related stuff. I was wondering how can I setup a anonymous proxy (a humble one, of course) so I could play a little bit with it.
I found some cool comparison that shows different types of proxys and which HTTP headers they set in each request:

Transparent Proxy

REMOTE_ADDR: Proxy IP address
HTTP_VIA: Proxy IP address/hostname and details – e.g. 1.1 proxy1.mydomain.net:3128 (squid/2.7.STABLE9)
HTTP_X_FORWARDED_FOR: Your real IP address

Anonymous Proxy

REMOTE_ADDR: Proxy IP address
HTTP_VIA: Proxy IP address/hostname and details – e.g. 1.1 proxy1.mydomain.net:3128 (squid/2.7.STABLE9)
HTTP_X_FORWARDED_FOR: blank

Elite Proxy

REMOTE_ADDR: Proxy IP address
HTTP_VIA: blank
HTTP_X_FORWARDED_FOR: blank

Tagged , , , , , ,

Solarized on the Terminal

Looking good, although I also added the following:

  • Changed the font to Inconsolata 15p.
  • Window Size => 130 columns 30 rows

Imagem

Tagged , , ,

Solarized Theme

Was actually looking for a new theme for my Terminal, when I found this. In the end I just putted on Xcode, and I might add it looks really nice.

Imagem

Tagged , , ,