Feb 21 2012

Move Along, Nothing To See Here

Category: megiordano scalzo @ 2:20 pm

Ok, blog is too 2005 and I’m to busy to follow a so vintage wave.
Anyway, I still think write and share carry a lot of value, so I’ll write something on http://giordanoscalzo.tumblr.com.

See You on the Other Side


May 09 2011

UiWebView with transparent background

Category: megiordano scalzo @ 11:50 am

Just a little tip to improve an iPhone UX.
If you need to set a transparent background to a UIWebView, setting a clearColor as backgroundColor isn’t enough: you should set it as non opaque too:

    self.myWebView.backgroundColor = [UIColor clearColor];
    [self.myWebView setOpaque:NO];

Very easy when you know it!


Apr 18 2011

iPhone Unit Test tips: Read a file in your test

Category: bdd,objective-cgiordano scalzo @ 12:44 pm

Very often I need to unit test something read from a file, but it seems very difficult to accomplish this simple task in iOS, so usually I give up.
But today I felt was a good day to find a solution ;-)
In my code I want to read a JSon data from a file, so I wrote a simple test:

describe(@"Conference", ^{
    it(@"loads given a filename", ^{
        Conference *conference = [[Conference alloc]initWithFile:@"talks_with_three_tracks"];
        [[theValue([conference hasData]) should] beTrue];
    });
});

with a simple init method:

-(id)initWithFile:(NSString *)filename{
    if ((self = [super init])) {
        NSString* path = [[NSBundle mainBundle] pathForResource:filename ofType:@"json"];
        NSError *error;
        NSString* talksString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
        talks = [talksString JSONValue];
    }
    return self;
}

-(BOOL)hasData{
    return talks!=nil;
}

Unfortunately it doesn’t work :-( , because path is nil;
But here it isthe solution:
instead of using [NSBundle mainBundle], we should use the bundle associated with our class:

        NSString *path = [[NSBundle bundleForClass:[Conference class]] pathForResource:filename ofType:@"json"];

Simple and neat: thank you StackOverflow ;-)

Technorati Tags: , ,

Tags: , ,


Jan 05 2011

Learn a bit of Ruby every day: block local variable

Category: ruby,tutorialgiordano scalzo @ 5:52 pm

In Ruby 1.8.7 it wasn’t possible define a local variable to a block, so the following code produces an exception:

class Shape
  def initialize(args)
    @sides = args[:sides]
  end
  def draw
    puts "Drawing #{@sides} sides"
  end
end

square = Shape.new(sides: 4)
sum = 0
(1..3).each do |value|
  square = value * value
  sum	+= square
end
puts sum
square.draw

Ruby 1.9.2 it’s possible add a local variable to a block:

class Shape
  def initialize(args)
    @sides = args[:sides]
  end
  def draw
    puts "Drawing #{@sides} sides"
  end
end

square = Shape.new(sides: 4)
sum = 0
(1..3).each do |value; square|
  square = value * value
  sum	+= square
end
puts sum
square.draw

Now it works as expected


Jan 02 2011

Learn a bit of Ruby every day: Dir.exist?

Category: ruby,tutorialgiordano scalzo @ 10:38 pm

Introduced in 1.9, it’s a cool method to know if a directory exists:

Dir.exist?("/tmp") # => true
Dir.exist?("/temp") # => false

A more correct alias is Dir.exist?.


Jan 01 2011

Learn a bit of Ruby every day: Enumeration.reduce

Category: me,rubygiordano scalzo @ 11:30 pm

Ilya Grigorik is an awesome programmer who recently launched the geek equivalent of Farmville: VimGolf, the idea that every geek had, but nobody created.

From today he starts to tweet a piece of Ruby every day, mainly 1.9.2.

The first tweet is about Enumeration.reduce, an alternative, and more speaking, name for Enumeration.inject:
ruby-1.9.2-p136 > (1..3).reduce(:+)
=> 6

The strange argument is the symbol for plus, the operation to do to each element.
A more verbose, and less magic, version is:
ruby-1.9.2-p136 > (1..3).reduce {|sum, e| sum+e}
=> 6


Jul 09 2010

Simplified Ad Hoc Distribution in Xcode 3.2

Category: objective-cgiordano scalzo @ 11:41 am

Currently, Ad Hoc distribution is the only way to share an application to try itin to several devices or users (to maximum of 100 devices).
Despite the Apple’s reputation to create simple and effective things, the Ad Hoc Distribution is one of awkward and cumbersome process I’ve ever seen: I admit every time I need to change a certificate to add or remove certain devices or I’ve to check another application, I hold my breath and start cold sweat until the end of process… but, in Xcode 3.2 they simplified it a little bit.

In Build menu you can find a new entry, Build and Archive, that creates your application and archive it, allowing to share and signing it in a more confortable way:

All archived applications are in a new window of the Organizer:

When you “share” an application an ipa file is created and you can share it with your betatesters:

Just a little thing, but it’s useful to manage all versions.

More information can be found in this interesting post by Jeff LaMarche: if are serious about iPhone development you must subscribe his blog (and buy his book too ;-) )

Technorati Tags: , ,

Tags: , ,


May 10 2010

“Better Software Developers” slides from Better Software 2010

Category: agile,me,presentationgiordano scalzo @ 3:15 pm

Here are the slides from my presentation I gave at Better Software 2010: a humble attempt to spread the Software Craftsmanship philosophy among developers and managers.

Technorati Tags: , ,

Tags: , ,


Apr 02 2010

“Agile iPhone Development” at Xpug Milano

Category: me,objective-c,presentationgiordano scalzo @ 9:29 am

Spring is almost arriving and it’s time for another Xpug Milano meeting in coding dojo format.

This month we practiced with ObjectiveC; I gave an introductory presentation about the language, the ide and the framework, then we faced up to a nice Kata I proposed, inspired by some work of Brett Schuchert: the KataRpnCalculator.

I admit I’m amazingly surprised by how quick the Xpuggers learned the basic of the language and how good is the code they produced: awesome!
It’s the proof that it’s always a people problem not a technologic problem, and people with the right attitude can produce very good code, even though they don’t know very well the language.


Mar 17 2010

AgileCamp 2010: richness of difference

Category: agile,bdd,me,objective-c,presentationgiordano scalzo @ 2:59 pm

Some weeks ago, I has been lucky enough to attend to AgileCamp 2010, an awesome Barcamp organized by Sketchin, a Swiss UX and Web agency.
With my good fellows XpUg-gers Gabriele, Andrea and Indrit, we reached a lot of old and new friends, all of them caring about quality and “Things Got Right”.
I came back really enriched, mainly because I met people with experiences and point of view different than mine.

It has been my first Barcamp, so I though it was necessary to present something, and I decided to assemble a little introduction to Tdd coding for Iphone.

Here there is the video of my presentation:

AgileCamp – iPhone agile DEV (di Giordano Scalzo) from Sketchin on Vimeo.

Technorati Tags: , ,

Tags: , ,


Next Page »