Monday, October 12, 2015

What I've learnt today

Here is a list of things I have learnt today. Things to remember for myself and to reflect on.
  1. AppCode has a simple, yet very useful CocoaPods integration. Easily create a podfile and fill in your dependencies. AppCode will provide you with a button to install your dependencies. Bonus: if you remove a dependency from your podfile, AppCode will give the uninstall button. Keeps your project directory neat and tidy. You can do this on the command line too, but it fits perfectly into the IDE.
  2. Swift playground in XCode 7.0.1 on El Capitan 10.11 sucks! I had so many crashes in the playground, that I had to restart XCode several times to get it back working.
  3. Swift and Objective-C seem to have a "Love and Hate" relationship? Why, you might ask? I tried to use some library that was written in Objective-C with my Swift project. It took a good amount of work to navigate around those little compile errors and find alternative ways to use the library anyways. But it was painful and not fun at all. What I did? I created a custom XML deserializer for Alamofire with Ono.

Tuesday, September 1, 2015

1st Electron-Shell User Group Meetup

I went to the 1st Bay Area Electron-Shell User Group Meetup last Tuesday, 8/25/2016. The meetup was hosted by (WagonHQ) in San Francisco’s Mission district. It started at 6pm and was scheduled to last until 9pm. The nice folks at WagonHQ provided some food and drinks for all attendees.
The Agenda for this meetup is available (here).
There was a good crowd of interested engineers (between 40 and 60 people). Some of them were already using electron-shell in one or the other project.

The Talks

There were 4 tech talks for this event:
  • The History of Electron (Kevin Sawicki - Engineer at GitHub)
  • Integrating with Native Code (Paul Betts - Engineer at Slack)
  • Electron, React, and Haskell. Oh my! (Mike Craig - CTO at Wagon)
  • Making a web app feel native (Ben Gotow - Engineer at Nylas)
The talks covered different parts of app development and the specialities of building a cross platform desktop app with web technolgy. A lot of questions around styling, using node modules, write your own node modules, call C# APIs to integrate with Windows, call Objective-C to integrate better with OSX and app packaging (I might have missed something).
I’m looking forward to attend the next meetup. I think that some attendees might have tried electron-shell for their own projects and have some eperiences to share.

Tuesday, June 9, 2015

Simple date math in bash script

To catch up with my blog, I needed to extract data from a twitter feed. Usually I update the blog on a weekly basis. Since I didn’t find the time recently, I fell behind.
I was looking for a quick solution to download all the feed data at once. A bash script should be good enough.
The script that I use to extract the data from the twitter feed, expects a date argument in the form mm/dd/yyyy. The script will extract all data for the range [date - 7days, date]

Create the series of dates

I need to create a series of dates for several weeks. Given a start date, I’m going to produce new dates with a 7 day interval. The starting date is included in the series. Here is what I ended up with:
#!/usr/bin/env bash

set -e

# startdate in the form mm/dd/yyyy

for ((i=0;i<${weeks};i++)); do
    newDate=`date -j -v+${offsetDays}d -f "%m/%d/%Y" ${startDate} "+%m/%d/%Y"`

    startDateFilename=`echo ${newDate} | sed "s/\//-/g"`

    echo ${startDateFilename}
    # download the twitter data and redirect all output to that file
    exec &> weeklyTwitterData-${startDateFilename}.txt
    # call the script to extract the data from twitter stream
    coffee src/ -n ${startDate}

Since I didn’t want to do all the calendar math myself, I rely on the magic of the date utility. The line defining newDate is where the magic happens. Parsing a date ${startDate} in a given format %m/%d/%Y, adding $offsetDays to the parsed date and print out the new date in the format %m/%d/%Y.
That’s it.