This weeks update : Bye Bye MongoDB

So it is exciting times! I have made some progress with TRTLExchange, however, due to things outside of my control it been slower than expected.  So I have turned my spare time to Burf.co, my new search engine project and while there is no website for it yet (will be by the weekend), the actual search technology(code) has come along leaps and bounds.  Overnight it managed to index over 500,000 pages which for a single server, was pretty cool.  It did get up to 1.3 million pages but MongoDB has erm, shit the bed(many many times).  This could be a hardware limit (Harddrive speed) or some performance thing I need to do however it gets to the point where I can’t even insert more records without timeouts.  This concerns me quite a bit as I have a HP Blade Server on way to somewhat up the crawling rate by a factor of 8.  I am going to try and give it one last go today however its taken 12 hours to delete the data from the DB (I did remove instead of drop 🙁 ).  It has been a very interesting learning curve on learning MongoDB.  I think unless some magic happens I am going to try out Postgres next.

On the Swift front I did start building the frontend for Burf, first I was going to do this in VueJS, however, I have now found that Swift’s server-side framework Perfect supports templating via Mustache.  I think I will make faster progress writing it all in Swift than switching back and forth.   I still want to continue learning VueJS on the side (used for the TRTLExchange) as Javascript is such a good thing to know nowadays.

Writing this blog post has also just raised the point that I was trying to learn Kotlin about a month ago (facepalm).  Damn!

 

Experimenting with MongoKitten

As mentioned in my previous post, I have started looking at Server Side Swift with the aim to build a search engine (Burf.co).  To store my crawled data I decided to try and use MongoDB as it supports full-text search out of the box.  The original Burf.com used Equinox (made by Compsoft) and then later used Microsoft Indexing Service.  This time round I wanted to be a little more scalable.  Now there are probably better DB solutions for what I plan to do, but MongoDB seemed really simple to get up and running with.  Later on, I should be able to switch out the database layer if needed.

MongoKitten

Now that I had decided to use Swift, and MongoDB, I needed to find a framework that connects them, my friend (who knows his stuff) recommended MongoKitten!  I got up and running with it fairly quickly even though I don’t know MongoDB too well. Life was good, however, there were a few things I did struggle with:

Contains

So, search a field for a partial string requires you to use Regex (it seems).  

Mongo:

db.users.findOne({“username” : {$regex : “.*eBay.*”}});

MongoKitten:

let query: Query = [

           “url”: RegularExpression(pattern: “.\(eBay).”)

       ]

let matchingEntities: CollectionSlice<Document> = try pages.find(query)

Sorting results on $meta textScore

MongoDB allows you to setup full text searching across your data, it can be across an entire record, or just certain fields (name, address etc).  When you perform a full-text search, MongoDB returns the relevant records with an accuracy score ($meta.textScore).  MongoDB lets you change how it creates these scores by allowing you to adjust the weights each field receives e.g name is more important than address.

Mongo:

db.pages.find( {$text: {$search: “ebay”}},{score: {$meta: “textScore” }}).sort({score: {$meta:”textScore”}})

MongoKitten:

let query: Query = [

           “$text”: [“$search”: str ],

           “lang” : [“$eq”: “en”],

       ]        

let projection: Projection = [

            “_id”: .excluded,

           “url”: “url”,

           “title”: “title”,

           “score”: [“$meta” : “textScore”]

       ]    

let sort: Sort = [

           “score”: .custom([

               “$meta”: “textScore”

               ])

       ]      

let matchingEntities: CollectionSlice<Document> = try pages.find(query, sortedBy: sort, projecting: projection, readConcern:nil,  collation:nil, skipping: 0, limitedTo: Settings.searchResultLimit )

Getting Help

I found the best way to get help was to contact the creator(Joannis) of MongoKitten via Slack, he is pretty busy but super helpful!

This weeks update : Server side Swift and updates to the site!

So, in terms of coding, the last week has been rather busy, actually in terms of progress, it’s looking good on all front (except Hack24)!

First off, there have been some updates to the website to finally include a basic list of historic Robotics projects.  I had planned to do that last year!  I have also updated the design and content a little, which frankly no one will notice!

Next, I started yet another new project, Burf Search Engine (The Return).  It had been on the cards for a while, however, I have now started coding it.  First in NodeJS, then in Server Side Swift using the Perfect framework.  It went swimmingly well (thanks to Ad) until I had to deploy it to Ubuntu.  There, you start to learn the differences between Apple frameworks and the open source versions of the same framework. Randomly I am expecting the Apple framework to have less //todo and //to implement comments 🙂

The Crypto project didn’t process as far as I hoped this week purely due to my friend (and other coder) being ill, however, momentium has now picked back up.  As your also probably aware Cryptocurrencies took a massive dive this week!

No update on Hack24, it will resume after phase 1 of the Crypto project has been completed and the search engine crawler for Burf.co is live 🙂

On the side note, really enjoying Altered Carbon on Netflix’s and Thanks to Ford for sending me this epic LEGO set 75885 (Ford Fiesta M-Sport WRC) to review at the weekend.

 

 

iOSDevUK 2017

iOSDevUK is a conference for iOS developers that takes place at the Aberystwyth university campus in Wales (You get to be a student again).  It is a 4 day event which features talks on the latest iOS frameworks, best practices and ends with a 10 hour hackathon.  Sadly Andrew (iOS developer from Priority) and I could not attend the Hackathon.

The event was less hands on than previous developer events like iOSConf which was a shame but we still got to learn about some of the latest iOS 11 frameworks like:

ARKit

This is Apple’s augmented reality framework which looks really impressive.  We have been waiting for Apple to do something in the AR space since they brought Metaio in 2015.  With the new iPhones having 2 back facing cameras to allow the device to detect depth, the mapping of virtual objects to real life objects has become very accurate.  In the workshop we saw how to place space invaders ships in the real world.

CoreML

CoreML is Apple’s machine learning framework which allows you to take your algorithms from other platforms and use them on your iOS device.  You can’t actually generate your model on the device but you can import it from many different tools (Caffe, SciKit, Kera) and it will run on the device hardware accelerated. The main aim of this talk was to clarify what CoreML’s abilities were as there was a lot of confusion when Apple announced it

FileProviders

So with iOS 11, you’re going to get a file system, like you do in Windows etc.  This workshop showed how you could make your own cloud service like Dropbox and integrate it into iOS11.  This was one of the only talks in ObjectiveC rather than Swift.

ServerSide Swift

This talk went over 3 apps that the company had made using ServerSide Swift which included a SlackBot, a CI tool and an Alexa tool, however the presenter did say that server side swift was far from production ready which was a little bit of a let down.  They suggested the best way to get started with it was to use Docker.

There were a few talks on Design patterns and where to use which ones like VIPER, MVVM, MVP etc.  VIPER seems to becoming popular if your iOS app is very big.  

There were a few talks on the whole pipeline of testing and releasing builds using Unittest, UI test, Jenkin’s, Fastlane and GitHub issues however it was only a overview and not actually how to go about setting it up

 

 

 

WWDC 2017

This years WWDC saw lots of new hardware being released but not too much cool new features mentioned. This definitely felt the year that Apple played catch up to Amazon, Google and Samsung.

Safety

2 Features that stood out to me, Emergency SOS and Do Not Disturb While Driving. The first allows you to setup an “Auto Call” to the emergency services if the Sleep/Wake button is pressed five times.  The 2nd feature will block all notifications, texts and phone calls if the phone detects your driving.  Of course you can turn it off if your friend is driving!  I think features like this really should get more attention because they can save lives!

Business Chat

This was not mentioned on the main WWDC keynote but thanks to Sean Antony from Digital Products, it was brought to my attention.  This is actually a big deal.  The idea is that you can just message a business like you would a friend instead of phoning them up, being on hold, listening to terrible music etc.  You can even purchase goods directly in the chat.

HomePod

In simple terms this is Apple’s answer to Google Home and Amazon’s Echo however it’s being marketed as a smart speaker rather than a smart assistant.  It designed to deliver amazing audio quality and uses spatial awareness to sense its location in a room and automatically adjust the audio, however it costs over twice as much as an Amazon Echo or Google Home Device and requires a Apple Music subscription (sorry Spotify fans).  That being said, Apple fans will buy it, and don’t be surprised if high numbers are sold.

Hardware updates

New Macbook, iMac and iPad pros all got announced, the one that caught my eye was the new iMac pro, the most powerful machine they have every made, starting at $5000, it should be!  I am an Apple fan however you can buy a lot for $5000.  The new iPad pros’ support brighter screens , the 9.7” one has put on some weight and is now 10.5” and both offers screen refresh rates of up to 120Hz for better responsiveness smoother motion

MacOS High Sierra

Apple’s new operating system is called High Sierra, I am not sure much effort went into the name (previous version is Sierra).  It will finally allows Mac users to experience Virtual Reality (assuming you will need a new Mac) and supports a new file system called Apple File System.  Safari will now block autoplaying videos and keep advertisers from tracking Mac users.

Apple TV / Apple Watch

Very minor updates here, Apple TV can act as a HomeKit Speaker and is getting Amazon Prime (Whoop Whoop), Apple Watch got some new fitness stuff, Core Bluetooth support, Toy Story clock faces and a watch face that uses Siri to offer up dynamic suggestions that change based on user preference and time of day.

iOS 11 “The Biggest iPad release ever”

This is what we are truly here for!  So iOS 11 for iPad looks to really improve the multitasking ability on a iPad, it allows you to drag and drop things and give you a Mac like dock at the bottom of the screen to.  The demo they gave did get me wanting a new iPad.  They have also introduced a new Files app which is just their iPad version of Finder / Windows Explorer.

Other new features, Apple Pay now supports person-to-person payments via iMessage, a new framework called ARKit which will make making Augmented Reality apps a lot easier and a new machine learning framework called MLKit which will allow you to take your complex algorithms from other systems and use them on your phone GPU.  This will pave the way to more intelligent apps.

Siri is also getting smarter via deep learning and will soon suggest content to its users based on their Safari searches 🙂  iOS 11 also knows when you use an app and so now has a setting to offload unused apps, this is a great feature to save space on your device.

Swift Playgrounds

This is a iPad app that allows you to learn to code in Swift.  Since its been on the AppStore (just under a year), over 1 million people are using it to learn Swift.  Version 1.5 has a host of new features including a framework to talk to robots, drones and robotics kits like the LEGO Mindstorms kit, the Parrot Drone or Dash Robot.  

 

iOSConf 2017

iOSCon 2017

iOSCon is a 2 conference in London for people interested in iOS development and the Swift programming language.  I got the chance to attend with a few people from Digital Products who work on our apps like MyO2, O2 Drive and Priority.   I was rather looking forward to going as I have had my feet out of the iOS development circle for a while.  Working in the Lab requires you to jump around from technology to technology, each project could be written in a completely different programming language, tool or involve no coding at tall.

The conference covered things like:

  • New design patterns / ways to architect your app (VIPER, VIP and Clean to Flux, Redux and Reactive, POP)
  • Better ways to do API calls(Protocol Buffers and GraphQL) ,
  • How to get started in functional reactive programming,
  • Better ways to do Test Driven Development (some people call it Test Driven Design) by using Swift Playgrounds.
  • A few talks on accessibility and how to debug it.

What was interesting about this conference compared to others was the focus on behind the scenes stuff.  Previous conferences I had attended featured a lot of talks on UI, user experience, building custom controls etc.  This conference focused on making your code more stable, structured and easier to test.

You can find most of the talks here for free: https://skillsmatter.com/conferences/8180-ioscon-2017-the-conference-for-ios-and-swift-developers?tc=260f81#skillscasts

Here are 2 talks I really enjoyed:

It’s about time by Daniel Steinberg

This was a rather hard hitting talk about striking the right balance between work and home life.  He focuses on things like, either work or relax, don’t try to mix them, don’t go home and think of work. He tries to get you to focus on why you’re doing something, not the what your doing.  He also covered planning your day better and how interruptions cost you.  Every time someone bothers you for a minute, it takes 23 minutes to recover, even if it’s you who caused the interruption.

If you’re interested in watching the talk, check the link below, warning it may make you rethink things a bit.

https://skillsmatter.com/skillscasts/9447-keynote-it-s-about-time#video

The second talk I really enjoyed was

Natural Swift: write Swift the way it was meant to be written by Paul Hudson

The talk focuses on 3 topics which together can really help you improve your code.  The first is POP (Protocol oriented Programming), the second is Functional Programming which focused on the map, flatmap, filter and reduce commands.  These really impressed me because they can do in 1 line of code, what I would usually do in 5.  The last topic he covered was value types,  ObjectiveC is very different to Swift and you need to know what is a value type and what’s a reference type.

Sadly this talk was not filmed by Skillscast however you can download it for free from https://gumroad.com/l/natural-swift

Xcode 6.4 crashing after installing Xcode 7.01 when viewing a storyboard

I don’t usually blog about crashes etc but this one wasted me a few hours.  I was working on a iOS 8.4 project in Xcode 6.4.  Each time I edited the storyboard, Xcode would instantly crash.  However my colleague’s machine did not?  The only difference we could see (even after reinstalling Xcode) was I had also had Xcode 7.1 installed.  Usually this would be fine however something changed with the libraries it uses (PepperUICore).  It was only when I found this post, I saw the fix

https://forums.developer.apple.com/thread/21927

The fix, which worked for me was to run the following commands to make some symbolic links

sudo ln -s “/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 8.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PepperUICore.framework” “/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 9.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks”

sudo ln -s “/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 8.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SockPuppetGizmo.framework” “/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 9.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks”

 

 

New version of Hack24 submitted!

I May of just solved a programming issue that’s been bugging me for many months. The only way I thought I could get round it was a complete rewrite of the 3D engine for Hack24. However it seems you can get around the massive performance with Hack24 by having multiple threads. Yes seems obvious however this is OpenGL world and that is completely different, the items have to created in the main context!

The fix worked, so a new version of Hack24 has been submitted (with other bug fixes!)

Xamarin : Results so far

So, I been playing with Xamarin on and off (damn meetings) and I am slowly getting to grips with it.  I am not a C# developer so while learning Xamarin, I am also learning C#!

I have to be honest, some things I have found a real struggle.  The Android part of my project just died, would not build for toffee, after many hours of search for info, even talking to Xamarin (work call), it turned out to be a corrupt package in a hidden directory.  To be fair, with every new tool, language you are going to learn these issues.

The other random issue which I have not solved is using OpenTk and OpenGL to render a cube on the screen.  This is completely shared code (WOOHOO) however iOS works, Android does not.  One thing I picked up from when speaking to Xamarin is that if any platform is going to break, its Android due to Google pushing updates.  I can respect that!  Android Studio 0.9 -> 1.0 broke every project for me.

The Show must go on!

I can see some real benefits from Xamarin, if I was a C# developer I would be in heaven!  I really want to see whats possible with Xamarin Forms, the holy grail of mobile development (Be warned its not!, its a good technology for a certain job, not all jobs).

In all honestly I don’t have much interest in Xamarin Native which is where you write C# code that directly binds to native Apple/Android Api’s.  I would prefer just to do it in Xcode / Android Studio.

Focus!

I think my personal focus for Xamarin is looking at cross-platform game development using MonoGame or OpenTK.OpenGL.  I either need to learn XNA for MonoGame 3D stuff or see how different the OpenGl is on OpenTK.  This however brings me to the question, why am I not using Unity3D?

My work focus is Xamarin Forms and working out how far you can go with them.  I have been told things like custom pins on a map is a no go on Forms.

I will keep you posted on what I discover!