Technical Notebook

Thoughts on iOS, Android, GoLang and more.

Golang Blogging softwareWed Oct 23 14:57:03

By Simon

My all new Blog

I recently switched my hosting provider and I upgraded to an cheap dedicated server by ovh So I started migrating all my data and I decided to speed up my software stack a little bit by replacing apache with nginx. I was never quite satisfied with the speed of my old website, but - so I thought - with this new dedicated server everything should be faster.

When I finally had everything ready I notice that the loading time for the webpage is over 500ms just to load the HTML. Old graph

I decided this can’t be and since I always wanted to get started with Go I decided to use a nice webframework named revel and build my own blogging software.

This is the result

Of course most javascript and css resources are now cdn hosted, but the rendering and delivery of the html page happens in under 50ms New graph

I also optimized it a little bit more for mobile devices, the resulting website scores much better on Google’s PageSpeed Insights The blog code is just a few hundred lines of go code + lots of template code.

If you’re interested you can have a look at the code on github

Thanks to alle the people who wrote the components this software builds on:

And of course for inspiration

View all 18 Comments

SGShareKit: Designing a modern iOS sharing UIMon Oct 21 04:18:29

By Simon

Recently I faced the challenge to support sharing with various social services in an iOS 5+ App. This meant I wouldn’t be able to use the built in UIActivity* classes.

Personally I don’t like the look of the recently introduced UIActivityViewController. Instead I decided to build a simpler to use and customize API which can accomplish similar results and works on iOS 5: SGShareKit

SGShareKit Demo

The design is based on Levey’s LeveyPopListView but I added rotation support and provided the actual sharing implementations.

The central class is the SGShareView which is designed to work like an UIAlertView.

For each view instance a new UIWindow is created, which is displayed above all other Windows of your application. This is accomplished by setting the window level to UIWindowLevelAlert:

- (void)show {
  self.myWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.myWindow.windowLevel = UIWindowLevelAlert;
  self.myWindow.backgroundColor = [UIColor colorWithWhite:0 alpha:0.24];
self.myWindow.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

  UIViewController *vC = [SGShareViewController new];
  vC.view = self;
  vC.wantsFullScreenLayout = YES;
  self.myWindow.rootViewController = vC;
  [self.myWindow makeKeyAndVisible];

The API itself is inspired by UIActivityViewController, but works on iOS 5+

It’s easy to use this, you just have to init ActivityView with the objects you want to share and call - (void)show; on the activity view. This is very similar to an UIAlertView:

#import "SGActivityView.h"
// ...
NSString *text = @"Hello world";
NSURL *url = [NSURL URLWithString:@""];
NSURL *mail = [NSURL URLWithString:@""];
SGActivityView *activity = [[SGActivityView alloc] initWithActivityItems:@[text, url, mail]
[activity show];

Comment on this article

Foxbrowser, attempting to create Firefox for iPadMon Oct 21 04:22:00

By Simon

Recently Google released Chrome for iPad and iPhone, my first thought when I watched the announcement on Google IO was: ‘Why isn’t there at least Firefox for iPad?’. After all it’s not that hard to develop the UI components like tabs and the other stuff that’s needed for a modern tablet browser (I actually designed a tab component: SGTabs).

So I decided that I should spend some hours and try to build a reasonable complex prototype by forking Firefox Home for iPhone. I choosed the codename ‘Foxbrowser’ to indicate the long term goal of the project. I needed a few components to support all necessary features

  • A tab component
  • An address bar for real-time search in your bookmarks, tabs and history.
  • Browser controls (Back, Forward, Cancel/Reload)
  • A screen for new tabs with your most frequently visited websites
  • A screen for your open tabs on other devices
  • A bookmarks browser
  • A web view controller with custom context menus and HTTP Auth
  • Settings View
  • Login View

To speed up the development, I forked the Firefox Home App and were able to reuse many components that were not UI specific.

Code is available on Github:

Foxbrowser - Simon Grätzer Foxbrowser Logo

Screenshot 1 Screenshot 2

View all 2 Comments

FizzBuzz using Scala StreamWed Oct 23 15:00:16

By Simon

While I’m trying to wrap my head around the Stream class in scala, I’ve written this piece of code to implement FizzBuzz in an unusual way. (Sorry the first line is a bit long)

I think it’s an good example how the Stream class works and simpler to understand than the countless fibunacci examples

var fb:Stream[(Int, String)] = (1, "")#::(2, "")#::(3, "Fizz")#::(4, "")#::(5, "Buzz")#::(6,"Fizz")#::(7,"")#::(8,"")#::(9,"Fizz")#::(10,"Buzz")#::(11,"")#::(12,"Fizz")#::(13,"")#::(14,"")#::(15,"Fizzbuzz"){ case (x, y) => (15+x, y)};

fb take 100 foreach {case (a,"") => println (a); case (a, b) => println (b)}

So you may ask: ‘What the hell happens there?’.

It’s actually quite simple. The Stream object fb is basically an infinite List of tupel object’s. As soon as you’re trying to evaluate the element at index 15 you invoke map on the same list. Map is lazy and isn’t evaluated until a value is actually requested. Basically while you’re walking through the list from index 0 to infinity, you add 15 to the current element and attach the result at the end. So for the element (1, “”) map calculates (16, “”) at (15, “FizzBuzz”) => (30, “FizzBuzz”)

Comment on this article

Android Actionbarsherlock mit Tabs und ViewPagerMon Oct 21 04:06:51

By Simon

Ich habe zuletzt an einem Android Projekt gearbeitet, in dem Tabs zum Einsatz kommen sollten. Um ein modernes Design auch auf älteren Android Versionen zu erreichen, ionbarsherlock eingesetzt in Kombination mit dem ViewPager Beispiel aus dem Android Support Package. Das Ergebnis ähnelt ein wenig dem was Google in der Play Android App benutzt

Comment on this article

Next »