SAP HANA, xcode, Cocoa and Swift

So as many of you know I work with SAP HANA quite a bit in terms of events, developer evangelism, etc.

Well the other day I decided I would give Swift a try, I wrote about it before. So I thought what better way to drive myself a bit nuts then to try and connect an existing SAP HANA XSODATA service.

The service is one I use in an IoT demo that basically takes the value from a temperature sensor and stores it in a SAP HANA table. The service when called returns a JSON formatted response that I can use in other applications to show active values for different sensors.

  {"results": [
            "type": "sap.devs.demo.iot.IOTType",
            "uri": ""
         "SVALUE": "25.169"

Nothing fancy and outside of the whole demo really unimpressive, but for my purposes it was a perfect way to attempt my hand at something I’d not tried before despite reading about it and being extremely curious.

Therefore up comes my xcode environment on my Mac and following the wizard to create a basic Cocoa application.

Screen Shot 2016-03-24 at 14.45.28

With very basic settings and a project name.

Screen Shot 2016-03-24 at 14.45.45

From there it was a matter of adding a label or a two and a button to my Main Storyboard and then linking the label and button into the View controller.

Screen Shot 2016-03-24 at 14.47.27.png

Now inside my View Controller I added a timer control so I would be able to continuously update the value from the server itself.

timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(self.doUpdate), userInfo: nil, repeats: true)

Then I added my doUpdate function that actually calls the service and retrieves the XSODATA value. Now I really just wanted to show how I was able to read the SAP HANA xsodata and I’m sure you OSX and iOS developers would be able to do this more efficiently but the results I think would be the same.

func doUpdate() {
        let url = NSURL(string: "\(proto)://\(server):\(port)\(path)\(param)")!
        let task = NSURLSession.sharedSession().dataTaskWithURL(url) { (data, response, error) -> Void in
            if let urlContent = data {
                do {

                    let json = try NSJSONSerialization.JSONObjectWithData(urlContent, options: []) as! NSMutableDictionary
                    let lv_value = json["d"]?["results"]! as? NSArray
                    let lv_temp_value = lv_value![0]["SVALUE"]! as! String
                    //print("lv_temp_value: ",lv_temp_value)
                    dispatch_async(dispatch_get_main_queue(), { () -> Void in
                        self.lblTemp.stringValue = "\(lv_temp_value) \(self.temp_unit)"
                } catch {
                    print("error: \(error)")
    override var representedObject: AnyObject? {
        didSet {
        // Update the view, if already loaded.

You’ll notice I also use some parameters for my url creation just because I thought it looked cleaner than the really long url string.

var proto = "http"
    var server = "xx.xx.xx.xx"
    var port = "80xx"
    var path = "/sap/devs/demo/iot/services/iot.xsodata/IOT"
    var param = "?$orderby=ID%20desc&$top=1&$select=SVALUE&$filter=SNAME%20eq%20%27Office1%27&$format=json"
    var temp_unit = "° C"

The parameters refer to the SAP HANA Developer Edition that you can find via the SAP Developers website.

The end result is just a quick little application that I can now expand to duplicate the existing SAP HANA XS application if I wanted to.

Screen Shot 2016-03-24 at 14.58.11

Sometimes a demo is just waiting for you to get over that first initial – what the hell moment! For me it was this.

let lv_value = json["d"]?["results"]! as? NSArray
let lv_temp_value = lv_value![0]["SVALUE"]! as! String

After I managed to get that bit of code and actually access the part of my JSON response I needed the rest was easy. Sometime I’ll share the larger demo now converted to OSX.

Learning to code

I first started with coding back when I was … well I was 8 sitting on the living room floor on a Commodore 64 attached to the TV with a scroll (yes it was a scroll of paper) with a bunch of code in Basic on it. My father had brought it back (and several others) from one of the Navy ships he had been on from the computer folks for me to see. I sat for hours typing in the lines of code.


After hours of typing and hitting “run” the thing would do something extremely simple and I would be frustrated. At this point I began to play with the code and make changes, from that point on coding has been a part of who I.

I’ve seen, heard about and read lots of things lately about how people are starting over in life, careers, etc and learning to code. Whether that is isolated to the circles I travel in or not I thought I would look into a bit more and see exactly how easy it would be for someone to get started and actually learn to code now.

Surprisingly the numbers of resources is rather vast!

Code Combat looks kind of fun and I’ll have to find some time to check it out, learn to code by playing a game sounds like it could be fun – but would it work?

Code Avengers also looks kind of interesting, prompted to do a survey to win a lifetime membership worth $125 (so yep a fee is involved I guess) and they have a bit that will catch your attention right away.

Screen Shot 2014-10-06 at 10.38.52 AM

There area couple of things I have looked into already one of those is Skillcrush. They offer a free 10 day bootcamp that came in via email and was nice and easy to digest and pretty accurate. Nicely presented data and information and I honestly think anyone giving it half a chance would result in a considerable gain in knowledge and chance to head off into the right directions for a digital career but it’s not the end but only a beginning.

One thing that worries me about some of these new sites and “learn today” is the misconception that you’d be skilled coder ready for your first job/contracts within just a few courses. So if you are encouraging someone to start learning or even ready to learn yourself please remember that coding is a skill and a craft and takes years to learn, master and be able to apply appropriately.

With that said though one thing I’ve noticed some of the sites don’t go into or offer is “where” to put your coding, sure some talk about Github and other services but as most focus on “website” technologies none really go into a lot of details there – I guess it’s the separation between operations and development?

There are several options for “getting started” on the actual platform side. You can get a web host (google them), or your own virtual image like one from Digital Ocean (link contains a refferal code of mine), you can also download a package for your computer (WAMP, MAMP, LAMP). The packages actually provide an installable base for web development. The web server, development languages, etc.

These items in themselves however provide their own series of issues – such what happens if I can’t install something on my own laptop (for whatever reason – thinking work laptop and it’s not your in job description) or perhaps you don’t want a monthly cost associated with a host, or maybe that’s a step too far for you at the moment and you are just not sure about how to deal with all of that part?

Well there is another alternative and it’s actually quite cool. It’s a bit more geeky and a bit more technical but also a great learning experience!

I’m referring to the Coder for Raspberry Pi project.

Coder is an experiment for Raspberry Pi, built by a small team of Googlers in New York. It’s a free piece of software that turns a Raspberry Pi into a simple, tiny, personal web server and web-based development environment–just what you need for crafting HTML, CSS, and Javascript while you’re learning to code. It just takes ten minutes to set up and you’re ready to start experimenting with building real web stuff.

They have a simple 3 step process to get started and even without a lot of technical skills you should be able to get up and running within a extremely short period of time!

  1. Download, unzip, and run the Coder Installer. You’ll need a 4GB SD Card.
  2. Insert your new Coder SD card into your Pi, make sure your Pi and your computer are plugged into the network, and power it up.
  3. On your computer, visit http://coder.local/ in Chrome to connect to your new Coder and start playing.

But what is a Raspberry Pi you say? Well that’s it’s a…

The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. It is a capable little computer which can be used in electronics projects, and for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn how computers work, how to manipulate the electronic world around them, and how to program.

And they run on Amazon at very affordable prices and from other locations as well! Model B would be a good one to start with. Add in a power unit, wifi module (or using a cable connection) and a SD memory card and you are looking at maybe a $50 investment maybe a bit more. A small investment if you want to give your kids or yourself a safe environment to begin learning to code in.

Good luck coding!


Game Review: Battle Pirates

For a bit over a year I’ve been playing an online strategy game from a company called Kixeye.

Founded in 2007, KIXEYE (formerly Casual Collective) is an independent game developer that
makes games for gamers by gamers. Responsible for popular titles like Backyard Monsters,
Battle Pirates and Desktop Defender, KIXEYE is the first to deliver proper game play experiences
on social networks. The company is based in San Francisco and backed by Trinity Ventures and
Lightspeed Venture Partners.

The game is called Battle Pirates and is a multiplayer online strategy game and kind of addicting! I started playing the game through Facebook but you can play from their own site as well, it’s a Flash based game but I think really well done.

They officially launched on Facebook back in 2011, and the press release describes the game as such:

Battle Pirates is set in the year 2067 and Earth is covered in water. Due to a terrorist-sparked
world war, only a small amount of Earth’s original landmass remains. With a 95% extinction
level, the only remaining survivors are split into two factions: the Foresaken, impoverished
survivors who rely on engineering hacks, guerilla warfare and piracy, and the oppressive
Draconian Empire, the once elite citizens who’ve now become a giant military complex.

Like most games it has it’s ups and downs and large community following and like most it has it’s fanatics, crazies and die hard fans as well as those who just hate it (but always seem to keep playing).

So the game is such that it runs in 5 worlds broken into sectors of 100 and you can travel throughout those sectors in the world where your base resides, however to move your base you must “relocate” it via a friend. You can relocate within your world or sector or to a completely new world or sector. I’ve moved to several of these worlds and sectors in my time since playing but the only differences you find are of course the players, the game elements are the same.

You can attack other players, or game elements (Draconian or Reaver targets) you can create an alliance or even join an alliance and thus attack players in other alliances or just put around attacking the game elements all the time. Each week they have a “Forsaken Mission” often called the “weekly” and once you start it you have 72 hours to complete Tier 1 through 4 where you get a prize randomly from each tier you complete. Tiers are based on points and targets are different levels paying out different point amounts.

For example here is a video of me attacking a level 65 Outpost with my Barracuda subs, the entire outpost pays out 923K points and each ship pays out 15K. Tier one is 150K, Tier 2 is 500K, Tier 3 is 2.5 million and Tier 4 is 4.5 million points.

Now once a month they give us a “monthly raid” which has bigger targets, more points and you can choose your prizes based on the points you earn; usually you get 4 to 6 days for those raids and everyone starts and stops at the same time.

The last raid was also the newest format:

This format eliminate the ability for you to work together to take out targets but added in different aspects which made the raid more compelling to try. The previous formats were similar to this one:

It’s a strategy game where different hulls have different modifiers and bonuses and different weapons, advanced items and armors can make or break your fleet (up to 5 ships per fleet – up to 14 fleets) so in theory two players all with the same items could end up with two completely different fleets.

The game is free to play but you can also purchase game to make repairs quicker, build faster, etc. For the most part you can do quite well without spending a penny but at the same time you can do really really well with coins. Those who are quick to open their wallets are called “coiners”, those who cheat are called “hackers” and yes several hacks exist but usually you end up banned at some point. The numbers of those whining and complaining is rather large depending on the areas you are looking, reading and active but yet still plenty playing the game. Gamers always get sensitive to change in their games so you take it all as you see it.

Personally I’m a level 67, some nice ships a decent base and do well for myself. If you want to play and want some tips you can find me in the game or through Facebook.


The game does play in real time so when you have an 8 day build or 6 hour repair then you really have that time to wait! Lower levels you can usually get some great stuff build and that very quickly so you work your way up into the bigger and longer times.


Battle Pirates will be performing an extended maintenance period Monday, September 8th at 9pm PDT. Battle Pirates will be unavailable until the maintenance is complete.

Swift, new programming language

Recently Apple announces Swift, a new programming language.

Apple today announced a new programming language called Swift at WWDC, which will replace Objective C as the language developers use for building iOS and OS X apps.

Craig Federighi announced the new language on stage saying, “We’ve used Objective-C for 20 years, and we love it. But we wondered what we could do without the baggage of C.”

Federighi confirmed that Swift code and C can live in the same app together, too, so developers can upgrade their code as they go, rather than replacing it in one go.


Apple has published an eBook on Swift, which can be downloaded for free, here.

I’ve been hunting for more on the language or a way to try it out but the best I’ve gotten is their free download of the eBook. I’ll post more as I find it!

We’ve moved… kind of

I finally got fed up with the VPS I was using and we’ve moved the entire site – it’ll take a few days to relink podcasts, images, etc so hang in there.

SAP TechEd Amsterdam


DJ Adams showing how it’s done…


Season 5

Episode 7

Tom, Rich and Craig wrapping up an interesting Amsterdam trip with everything from 85″ tv’s to meat pudding.



Nope not a mic…

SAP TechEd Vegas: Day 2


They had to call security to Rich’s room…


Season 5

Episode 6

Tom, Rich and Craig wrapping up the week long event in Las Vegas with a few random folks popping in not realizing they were being recorded.