# Stephen Smith's Blog

Musings on Machine Learning…

# Introduction

I received a Seeed Studio Wio Terminal, an interesting device that contains an Arduino style microcontroller, but packaged with a 320×240 2.4” color screen, buttons, bluetooth, WiFi, microphone, buzzer, microSD card slot, light sensor and infrared emitter. The packaging means you can work with it, without any soldering or breadboarding. It also has two Grove ports and Raspberry Pi compatible 40-pin GPIO pins.

It is built around a ATSAMD51 microcontroller containing a 32-bit ARM Cortex-M4 processor with a Floating Point Unit (FPU), running at 120 MHz. For memory there is 192KB RAM and 4MB flash.

To program the Wio Terminal, the current options are:

1. Arduino – Use the Arduino IDE and supplied libraries for the integrated devices.
2. MicroPython – There is a special MicroPython build for device support.
3. Codecraft’s TinkerGen cloud development which includes TinyML support.

In this article we’ll look at the Arduino support and a simple fractal program to see what is involved. Below is a picture of the Wio Terminal with our fractal Koch snowflake. The screen is better than shown, as there was some interference between my phone’s shutterspeed and the screen refresh rate.

# Koch Snowflakes

Koch snowflakes are simple fractals that are a good way to give an idea of how fractals can build complexity out of simplicity. Basically you start with a base shape, in this case a triangle, then you replace each line segment with a new shape, in this case the two lines with a “v” in the middle. Then you do this recursively to get more and more complicated shapes. Below is the progression from level 0, the base shape to level 1, with the base shape lines replaced by the fractal generator and then so on as the level increases.

This is a fractal because in the limit as the level goes to infinity, the shape has a fractal dimension, in that it is somewhere between 1 dimensional and 2 dimensional in a defined mathematical sense.

# Turtle Graphics

To me the easiest way to draw fractals is with a turtle graphics library. This is a simple drawing library where you tell a turtle to either turn or move forwards. As he moves he leaves a trail. Hence the base shape for the Koch snowflake is forward 1, turn 60, forward 1, turn -120, forward 1, turn 60 forward 1. This is then really easy to apply recursively to draw fractals.

# Programming the Wio Terminal

Drawing Koch snowflakes on the Wio Terminal turned out to be quite easy. The TFT graphics library Seeed Studio provides is quite good and makes programming easy with routines for lines, colors, text, basic shapes, all the way up to higher level objects like histograms. 320×240 may not seem like much resolution by today’s 4k standards, but remember this is about the same as CGA graphics on the original IBM PCs. Besides initialization, the only routine we used is drawLine. The Wio Terminal came with a USB-C to USB cable to connect the device to a regular computer. You program in the Arduino IDE on your PC and download the result to the WIo Terminal to run.

Below is the complete source code to draw the Koch snowflake.

#include”TFT_eSPI.h”

TFT_eSPI tft;
float turtleX;
float turtleY;

void setup() {
int level = 3;
int size = 200;
tft.begin();
tft.fillScreen(TFT_WHITE);

turtleX = 320/10;
turtleY = 240/2;

turn( 60 );
KockSnowflakeSide( level , size);
turn( -120 );
KockSnowflakeSide( level, size);
turn( -120 );
KockSnowflakeSide( level, size);
turn( 180 );
}

void KockSnowflakeSide(int level, int size)
{
if (level == 0)
{
forward( size );
}
else
{
KockSnowflakeSide( level – 1, size / 3 );
turn( 60 );
KockSnowflakeSide( level-1, size / 3);
turn( -120 );
KockSnowflakeSide( level-1, size / 3);
turn(60);
KockSnowflakeSide( level-1, size / 3);
}
}

void forward(float amount) {

tft.drawLine(turtleX, turtleY, newX, newY, TFT_BLACK);
turtleX = newX;
turtleY = newY;
}

void turn(float degrees) {
}

void loop() {
}

I spent most of my professional career as a C programmer, and I really like the Arduino environment. I think learning to program in C is a great skill for any programmer or prospective programmer. It is a great starting point to getting into more technical areas like programming microcontrollers using the GNU GCC tools and all the various low level SDKs you are likely to encounter.

# Summary

The Wio Terminal is a great way to get into learning about microcontrollers without needing to know soldering or electronics. The Grove system lets you connect all sorts of sensors to the Wio Terminal using standard cables. The screen is good enough to display things like weather station data and the buttons can be used to build simple UIs.

Programming the Wio using the Arduino IDE works well. The provided board and device support are great, making programming the device easy. C programming has its pitfalls and a novice programmer might want to start with MicroPython first, but learning C is worthwhile. The processor is powerful enough for most applications and having an FPU is a nice bonus.

Overall the Wio Terminal is an interesting entry in the microcontroller world, trying to remove the intimidation and difficulty of learning electronics, but still allowing you to learn programming and construct many of the same DIY projects. Seeed Studio’s website contains many tutorials and suggestions for projects. This would be great in a classroom setting, since you don’t need to police youngsters risking burning themselves with improper care while soldering. The price runs at around \$37 which makes it accessible to most people and price competitive against Arduino starter kits.

Written by smist08

August 30, 2021 at 11:43 am

# Introduction

Last year we packed up the r-pod travel trailer and headed down to Bellingham, WA for some mountain biking and LinuxFest Northwest 2019. It was a really fun and informative show that I blogged about here. I greatly enjoyed the show and hoped to return the next year participating by giving a presentation. I applied last fall and was accepted. This looked like it was going to really work out since the show corresponded with the release of my second computer book: Programming with 64-Bit ARM Assembly Language from Apress.

# Enter Covid-19

Things were looking good until in February things started to lock down and get cancelled due to the Covid-19 outbreak. Eventually LinuxFest NorthWest in Bellingham was added to the list of cancelled events. Even if the organizers hadn’t cancelled, the border between Canada and the USA was closed to all non-essential travel. I suspect I would have had a hard time convincing the border guards that my presentation at LinuxFest was essential.

The organizers of LinuxFest Northwest weren’t happy abandoning the show all together so they asked all the presenters if they would record their presentations and upload them to be posted on the LinuxFest YouTube channel. Further they set up a questions and answer section on the LinuxFest discussion forums.

It looks like quite a few presenters participated and you can find all the sessions here. The Q&A forums are all here. More specifically my presentation is here.

# Summary

I’m disappointed that LinuxFest Northwest didn’t happen live this year. I was looking forward to it. But at least we had the virtual event. I invite you to browse and watch a few of the sessions. Hopefully, we will gather in person next year.

Written by smist08

May 22, 2020 at 1:09 pm

# Introduction

Last time, we started to explore Arduino programming. I noted that the Arduino IDE and language is largely based on Processing. In this article we’ll look at the Processing language and environment. Processing was designed to be a simple language to allow people in the Graphical Arts world to learn programming. Hence the language is oriented around drawing and animation.

There are quite a few education oriented programming systems such as Scratch which I talked about here. Processing is nice because it is really a subset of Java, so as you learn and become proficient at Processing, you are also learning a lot of Java. The drawing library in Processing is popular and has been ported to many other languages such as Python. The drawing library draws from PostScript and OpenGL and is quite powerful, in spite of its simplicity. Khan Academy uses a JavaScript version of Processing, namely ProcessingJS to teach programming for kids.

The Processing IDE and the subset of Java it uses are intended to be simple. The goal is to eliminate as much overhead as possible so you just write your program as sketches where you iteratively develop the end result. The feeling was that program design and object oriented design add too much of a barrier for non-technical people to learn programming. For artists, it is much more natural to learn by experimenting and playing rather than trying to design something before starting to program.

# Drawing a Koch Snowflake

We drew a simple Koch Snowflake fractal back in my article introducing writing iOS Apps in Swift. The complete Processing code for this is at the end of the article. Notice how much simpler it is to do this in Processing than in Swift. This is part of why Processing is such a good language to learn programming with.

You enter the code into the Processing IDE:

And then hit the green play button to run the program and the following window pops up:

Feel free to play with the program (called a sketch) to do things like change the size, level or anything else.

Every Processing sketch has two routines:

1. setup: run once when the program starts before anything else.
2. draw: run repeatedly at the configured frame rate.

In our sketch below, the routine that does the actual drawing is the line() function. The first line in setup() is size() which configures the size of the drawing window.

All in all this is a fairly simple program to create something as complex as this fractal. This is why Processing and the Processing graphics library is so popular.

# Gallery

Processing is an open source language and environment, but further the folks at Processing.org encourage the sharing of work. It is interesting to browse the work that other artists have done. Here are a couple of links:

Exhibition: a curated exhibition of projects.

OpenProcessing: Gallery of submitted projects.

Hour of Code: Gallery of submitted projects.

Gallery: Place to share and discuss projects.

# Summary

If you are interested in learning how to code and you have an artistic temperament then Processing is a good place to start. If you’re interested in learning Java, then Processing is a good way to go. If you are a programmer and interested in learning graphics or animation then Processing is a really good place as well.

Processing source code for the Koch Snowflake fractal:

```float turtleX;
float turtleY;

void setup() {
size(600, 600);
turtleX = width/5;
turtleY = height/3;
}

void draw()
{
int level = 3;
int size = 400;

turn( 60 );
KockSnowflakeSide( level , size);
turn( -120 );
KockSnowflakeSide( level, size);
turn( -120 );
KockSnowflakeSide( level, size);
turn( 180 );
}

void KockSnowflakeSide(int level, int size)
{
if (level == 0)
{
forward( size );
}
else
{
KockSnowflakeSide( level - 1, size / 3 );
turn( 60 );
KockSnowflakeSide( level-1, size / 3);
turn( -120 );
KockSnowflakeSide( level-1, size / 3);
turn(60);
KockSnowflakeSide( level-1, size / 3);
}
}

void forward(float amount) {

line(turtleX, turtleY, newX, newY);
fill(0);

turtleX = newX;
turtleY = newY;
}

void turn(float degrees) {
}

```

Written by smist08

April 11, 2020 at 4:49 pm

## 10 Questions for Sage Uncle Steve

This is a guest blog posting by my wife, Cathalynn Labonté-Smith, though I’m the one answering the questions.

***

It may seem odd to readers to interview the man I’ve looked across the dinner table at for 29 plus years in his own blog, but we’ve had a recent addition to our household, Ian. Steve’s nephew is an enthusiastic young man who is in a programmer’s boot camp (see Steve’s Blog entry The Times They Are a Changin) and as an educator this has brought to my mind new questions for my darling husband beyond, “How was your day?” and “Will you be able to fit in a vacation around your business travel this year?” Also, he didn’t like my alternate idea of a Valentine to Computing.

We got out of the habit of talking about the details of Steve’s work since the time I worked as a technical writer in the field of wireless technology nearly a decade ago. For couples out there who both work in the same or related fields, you will know what I mean when I say it’s just best to unwind and avoid topics to do with work in the off hours.

When I left tech writing and became a teacher, occasionally I’d walk into a business class that was learning Accpac for Windows or Simply Accounting. Trained as an English teacher I’d do what all on-call teachers do when outside their subject area: stick to the lesson plan, get help from the brightest students in the class and muddle through as best I could. So it was fun to share those experiences with Steve and I actually learned a bit about the Sage products.

It’s been many years since I’ve been in the classroom, but having taught career preparation I want to know the following from Steve for programmers coming on stream. I know that Steve’s blog audience is unlikely to be junior programmers but I thought this might get his more senior executive readers thinking about what legacy they can pass along to new programmers.

Whoa, I can hear you say, what makes you think they can hear us with their ears jammed with ear buds and if they could we don’t speak their lingo? I’m not saying they’re going to sit through a PowerPoint of your ruminations and really the best example is modelling, after all, and as a teacher I found that it was an equal exchange. You can learn as much from your novice employees as they can learn from you–just about different things.

When I met Steve he was a Teacher’s Assistant in the Math Department at the University of British Columbia working on his Master’s Degree. His Math 100 class was just him, the blackboard, a huge lecture hall packed full of nervous first-years and a piece of chalk. I was never his student, no; I was on the other side of campus in Creative Writing workshops in poetry, fiction and children’s writing.

After his degree, he worked at various software companies in many different fields as a contractor, consultant or employee before finding his long-time home at Sage. Aside from having over twenty years at Sage now in his current role as Chief Architect, I’m curious as what Uncle Steve would say to Ian if he were around longer than it takes for him to gulp down his dinner and head upstairs for more studying?

1. Steve, what kind of guidance can you offer for formal programs a would-be programmer should choose for the best future employment and advancement? Can you compare it to your formal programming education?

A. I learned to program originally in Grade 11. Nowadays people have lots of opportunity to learn how to program at a young age. There are quite a few exceptional online programs where you can learn program, for example, Khan Academy. Khan Academy teaches you to program in JavaScript while creating fun drawings and animations. Programming like most skills requires practice to master. In the book Outliers, Malcolm Gladwell maintains that it takes 10,000 hours of practice to really master something, so starting early really helps.

My undergraduate and master’s degrees are in Mathematics and not Computer Science. However’ I took a few CS courses along the way (in things like Numerical Analysis and Operations Research), so strictly speaking I don’t have a formal CS background.

I was in the Co-op program at the University of Victoria so when I did graduate I had four work terms of job experience. Plus, I was always working on some sort of programming project on my trusty Apple II Plus computer (usually involving Fractals).

It doesn’t really matter so much which programming languages you learn, just learn a variety. After all, things are changing so fast these days that you need to expect to keep learning these as you progress through your career.

To summarize, you need something that will give you lots of practice programming, a few formal courses to give you credibility and you need to be a voracious reader.

2. In your undergraduate degree, you went through a co-op program. Is this something that you recommend and why? For example, does it make a programmer more desirable as a future employee?

A. Yes, absolutely. I think intern type programs are terrific ways to get job experience and references ready for that first real job. I did four co-op work terms and learned an awful lot about how various companies operate and what is involved. It is a great chance to get some experience with a variety of companies, perhaps a large one, a small one and a government one. I certainly give credit for co-op work terms when I’m hiring.

3. What kind of summer, part-time or volunteer work might add to and develop their skills?

A. I would look for something where you are giving back to the community, such as donating your time to a charity and if you have the chance to travel when you do this then even better. Again do something that interests you and you are passionate about.

4. What kind of advice can you give new programmers about how to pick their first employer?

A. Chances are you are going to have several jobs throughout your career. More than likely the pay will be similar, so go for something interesting. Do some research on the companies you are applying to and look beyond the initial job you will have there. Also, consider travelling to a new location for your first job to get a bit more experience of the world as well.

5. Just like some doctors are better at staying current on the latest treatments and research, how do programmers stay current when there seems to be so many new technologies and programming languages to learn. How do you manage to filter through all of it to get what will last and have future value? Or is it even critical that programmers do stay current or is there enough maintenance work to go around forever?

A.  I think the number one rule is to not rely on your employer for this. This is really your own professional responsibility. Employers will train you for what you need immediately but usually not for much else and not for things that they aren’t interested in.

One of the great things about the profession today is that most of the programming tools that are important are either open source or have free versions available (like Visual Studio Express). So you can dabble with all sorts of things in your spare time. All you really need is a computer and an Internet connection. I really believe in learning by doing. So pick something new and interesting and do a small project in it to see if you want to go deeper.

6. What are some common pitfalls new programmers could avoid in their early careers?

A. I think the most common pitfalls are either being too loyal to a company or giving up on a company too easily.

Often people in their career have very high and probably unrealistic expectations on how well a company is run. Often this gives rise to a lot of changing jobs after quick stints. This can be a mistake if you don’t get ahead and develop a resume with lots of short stays.

The reverse is the other common mistake—being in a job that doesn’t work, but trying to stick it out too long rather than cutting the cord. Leaving is often a hard decision to make, but is often easier earlier in your career. Finding the right compromise between these two extremes can be very difficult.

7. What is the most valuable lesson or lessons that you’ve learned throughout your career that you could share with a new programmer?

A. That things are often darkest before the dawn. On any project at some point things are going to look bad, problems look unsolvable, bugs are piling up and deadlines are being missed. The lesson here is not to take the whole world’s problems on your shoulders, but to just work through the problems one by one. Often these are difficult problems that take much more time than you would have thought, but sticking to this eventually yields the light at the end of the tunnel.

Another take on this is to remain optimistic in the face of adversity. Or follow the Hitchhiker’s Guide to the Galaxy’s main advice: Don’t Panic! (Their other advice of always carry a towel, I’m not so sure about).

8. Who were your early role models?

A. Bill Gates and Steve Wozniak for what they did to start their companies. Steve Jobs for what he did when he returned to Apple.

9. Is there anything you would have done differently in your early career knowing what you know now?

A. There are always so many shoulda coulda wouldas. Now I know which companies back then paid the big bucks in stock options, but it’s hard to predict when looking forwards. I sometimes wonder if I should have moved from Vancouver, but then you get a beautiful day like today and just say “Nah”.

10. Is there a question that I didn’t ask that you wished I did?

A. No, this blog is already getting quite long J.

Point taken, Steve, this is a good place to wrap it up. Oh and, Happy Valentine’s Day, to you and to all your readers.

Written by smist08

February 15, 2014 at 4:34 pm

## Introducing Sage City Online

with one comment

Introduction

Last year at Sage Summit in Nashville we tried an experiment in social networking that we called Sage City. I mentioned this in my blog on Sage Summit 2012 here. Sage City in Nashville was a huge success and we will be building on that for an even better Sage City event at this year’s Sage Summit conference in Washington, DC.

Last week we opened the online version of Sage City. The intent is to build a social networking super-site for all Sage customers, partners and employees.

History

There has always been a lot of social networking around Sage and its products. Typically each product group or division operated its own set of forums and blogs. This is then hard for customers who use several products like say Sage CRM and Sage ERP. They need to join several disparate communities, which are all quite different.

There are all sort of groups on the main social networking sites like Facebook or LinkedIn. Many of these groups are highly successful with thousands of members. For instance the Sage Partners, Employees & Alumni Networking Group on LinkedIn has over 8200 members and has lots of interesting activity.

The external groups are doing great and will continue to do so. But something needed to be done about all the internal groups. Many were running different software platforms, used different sign-on ids, looked quite different, and had different policies and so on.

Unify the Sage Social Sites

The first goal of Sage City was to unify all these different Sage social communities into one place. Basically a Sage customer now only needs to sign up for Sage City and then they can join discussions on many Sage products as well as reference all sorts of other on-line resources. Now all the Sage forums are using the same software, they all work the same way and they will all be updated and maintained together providing a unified experience. Below is just the start of quite long list of support communities available on Sage City:

Notice that we now have both unified customer communities as well as unified partner communities.

You might ask: What about all the great content in all the previous discussion forums and blogs? The Sage City team did a great job of bringing all this content over to the new site. This isn’t an empty site waiting to be filled, there are already hundreds of blog postings and thousands of discussion forum threads imported from the older sites. This provides a great resource of information that has already been captured.

If you attended Sage Summit last year, you know that Sage City wasn’t organized around products, it was organized around business interests. Now that we’ve brought together all the different product social sites into one place, this now gives us a great opportunity to build on this new greater expanded community.

Across all the different Sage business products there is a lot of commonality in professional function. For instance there are many Accountants using Sage ERP products. Sage City offers social sites for all of these. In the screen shot below is the start of the list of the various business communities that are available on Sage City:

The key to their success is that these communities are large enough to be vibrant and self-sustaining. By bringing together the larger Sage community we can achieve this.

Most business issues and problems don’t have anything to do with ERP or CRM software and these new forums offer a great opportunity to discuss these with knowledgeable peers in a community of like minded people.

A True Social Site

Besides unifying all our various discussion forums and blogs, the new Sage City site also offers many of the expected social features that you would expect on any modern Social Media site. You can have friends, follow people, like things, join groups, send messages, mark favorites, subscribe to RSS feeds, and post comments and replies.

The site is integrated with Twitter feeds and with Sage’s product idea site.

There are discussion forums, blogs and videos. There are feeds showing all the activities going on either on the whole site or just in a specific group.

A Platform to Build On

Last week was the initial launch, but we have a large enthusiastic team that continues to work on Sage City, so you can expect to see regular updates and enhancements to make this a continually growing and more and more vibrant site.

The first goal is to attract as many people as possible to the site. The strength and value of a community is built on the enthusiasm of the individual participants. A strong community is a powerful thing. Hopefully by bringing together all the customers, partners and employees from separate Sage product camps we can build a much more valuable community than we could acting separately.

Summary

Sage City is now live. Sage City is so new the Google Spiders haven’t even cataloged its contents yet. But I think Sage City is a great improvement over Sage’s separate product social site. There are already lots of active users and discussions. I’ll be contributing regularly and I hope to see you there as well.

Written by smist08

June 22, 2013 at 8:05 pm

## My First Experience Writing an iPad App

Introduction

To get a feel for iOS programming I thought I would create a simple iOS application to display a Koch snowflake. There would be a simple edit box where you enter the fractal level and then it will draw the snowflake. I thought this would be a good example to get a feel for the XCode development environment, simple user interaction with controls and a flavor for some graphics programming.

Two jobs before I started with Computer Associates to work on CA-Accpac/2000, I worked for a company that created stock market software. They were working on a new workstation version for the NeXT computer. So with that company (over 20 years ago), I gathered good experience in this environment. We programmed in Objective-C and used the innovative NeXTStep development environment which had many neat features like using DisplayPostScript for rending on-screen graphics.

Now so many years later, here I am programming iOS and relearning Objective C. Although Apple has had many battles with Adobe over the years resulting in display postscript never being mentioned, I still see it there in how you do things. Since I’m newly relearning all this stuff and there have been many changes in the past 25 years, don’t take everything I say as the best way to do things, they are the way I first figured out how to do things for this simple project. Especially if you can do something visually in XCode versus writing code, I probably wrote code because that’s what I’m most comfortable with.

XCode

XCode is Apple’s IDE for doing both native Mac OS and IOs development. XCode is a very rich development environment with many built in tools for things like unit testing, debugging, screen designing and such. It has built in support for the Git source code control system, which is used by default for all projects. There is much built in documentation and help, as well as emulators to test and debug your iPad and iPhone applications. The main requirement of XCode is that it runs on MacOS. Hence I have to run it on my trusty MacBook Air.

XCode has a great many productivity helpers like auto-complete and many way to graphically create your programs rather than coding them. The thing that gave me the most trouble was the graphical part, I’m fine with writing code, but graphically connecting things wasn’t as intuitive to me as I would have expected.

Koch Snowflakes

Koch snowflakes are simple fractals that are a good way to give an idea of how fractals can build complexity out of simplicity. Basically you start with a base shape, in this case a triangle, then you replace each line segment with a new shape, in this case the two lines with a “v” in the middle. Then you do this recursively to get more and more complicated shapes. Below is the progression from level 0, the base shape to level 1, with the base shape lines replaced by the fractal generator and then so on as the level increases.

This is a fractal because in the limit as the level goes to infinity, the shape has a fractal dimension, in that it is somewhere between 1 dimensional and 2 dimensional in a defined mathematical sense.

Turtle Graphics

To me the easiest way to draw fractals is with a turtle graphics library. This is a simple drawing library where you tell a turtle to either turn or move forwards. As he moves he leaves a trail. Hence the base shape for the Koch snowflake is forward 1, turn 60, forward 1, turn -120, forward 1, turn 60 forward 1. This is then really easy to apply recursively to draw fractals.

Objective C

Objective-C was one of the first object oriented extensions to C. It was implemented as a pre-processor that generated C code which was then compiled using regular C development tools. This greatly simplified implementation, but the syntax reflects that it was designed to be easily processed by a preprocessor. It’s certainly evolved since its early days, but is perhaps considered a bit clunky as a result. Objective-C has all the object oriented features like inheritance and classes, but lacks a lot of the complexity of C++. The object oriented features are more similar to Java, but unlike Java, Objective-C still has all of C under it, meaning all the pointers and pointer related features that Java removed; hence you can easily crash your iOS app if you make pointer mistakes like in a C program.

Both Java and C++ overloaded the pointer syntax to call methods and such making them behave like function pointers in a structure. Objective C tried for a syntax to reflect message passing using their square bracket syntax of [object method] to send a message to an object. See the source code listings below for some examples. Recently Objective C has adopted the pointer type syntax as an option but considers it good coding practice to only use this for accessing class properties.

When you create a new project in XCode you get a complete working program and then only have to fill in your own code for your functionality. I edited the iPad storyboard to have a single page consisting of a label and text field for the fractal level and then a view to draw the image on. I created a couple of classes, one for turtle graphics, another to draw the fractal and then one to act as the interface to the UI form. All in all, not a lot of code and it seems to run fairly well. I placed the source code listings at the end so as not to clutter up this article. Beware that WordPress often changes characters for typographic reason, things like regular double quotes to 66 or 99 type quotes, this tends to introduce syntax errors if you cut and paste the code, so beware.

Storyboards are a relatively new feature to XCode, they allow you to define many screens within a single file and to connect them all together, so a button on one screen can trigger a transition to another screen, all setup graphically with no code. This is a great tool for quickly prototyping applications, but since for this app, I only have one screen it isn’t really used.

To connect the controls in the storyboard to the code, you create matching variables in the generated interface file and then drag an arrow from a small o in the margin to the matching control in the storyboard file (a process I find a bit cumbersome). Then you can ask for notifications and set properties for the various controls. You can see a couple of examples in the interface file below.

With any object oriented framework like Cocoa Touch there is quite a steep learning curve. Not only do you need to find the properties and methods to call to do things for you, but you also need to learn when you have to extend one of the system base classes. In the case of drawing the fractal, it’s a matter of putting a view control on the page, but then you need to extend the default class to override its drawRect method that is called whenever the view need redrawing. This is similar to handling a WM_PAINT message in Windows. Again you can have a look at the code down below.

Below are a couple of screen grabs of running this iPad app in the iPad emulator on my MacBook Air:

Summary

Sadly you can’t just post and distribute iPad apps, but have to go through the Apple iTunes store. I’m not going to bother posting this app, so you can’t play with it. I do like being able to post source and app to let people just run it, but Apple doesn’t allow this.

Creating this app was fun. XCode is quite a good development environment and they make it easy to write code quickly. iOS is a very full featured operating system with many built in services and a great deal of power. This are tons of books and internet articles on iOS development along with all the Apple documentations. Now to dig in a bit deeper to what you can do.

Source Code Listings

```//
//  csFractal.m

//  Fractal1
//
//  Created by Stephen Smith on 2013-03-05.
//

#import "csFractal.h"
#import "csTurtleGraphics.h"

@implementation csFractal
{
csTurtleGraphics *tg;
CGContextRef context;
}

- (id)initWithContext: (CGContextRef) inContext
{
self = [super init];
if (self)
{
context = inContext;
tg = [[csTurtleGraphics alloc] initWithContext:context];
}
return self;
}

- (void) KockSnowflake:(int)level
{
[tg turn: 60];
[self KockSnowflakeSide: level size: 500];
[tg turn: -120];
[self KockSnowflakeSide: level size: 500];
[tg turn: -120];
[self KockSnowflakeSide: level size: 500];
}

- (void) KockSnowflakeSide: (int)level size:(double) size
{
if (level == 0)
{
[tg move: size];
}
else
{
[self KockSnowflakeSide: level-1 size: size/3];
[tg turn: 60];
[self KockSnowflakeSide: level-1 size: size/3];
[tg turn: -120];
[self KockSnowflakeSide: level-1 size: size/3];
[tg turn:60];
[self KockSnowflakeSide: level-1 size: size/3];
}
}

@end

//
//  csTurtleGraphics.m
//  Fractal1
//
//  Created by Stephen Smith on 2013-02-23.
//

#import "csTurtleGraphics.h"

const double pi = 3.14159;

@implementation csTurtleGraphics
{
double x, y;
double angle;
CGContextRef    context;
}

- (id)initWithContext: (CGContextRef) inContext
{
self = [super init];
if (self)
{
context = inContext;
x = 50.0;
y = 150.0;
CGContextMoveToPoint(context, x, y);

angle = 0.0;
}
return self;
}

- (void)move:(int) dist
{
x = x + dist * cos( angle * pi/ 180.0);
y = y + dist * sin( angle * pi/ 180.0);

}

- (void) turn: (int) angleIncrement
{
angle = angle +angleIncrement;
}
@end

//
//  csViewController.m
//  Fractal1
//
//  Created by Stephen Smith on 2013-02-10.
//

#import "csViewController.h"

@implementation csViewController

@synthesize textField;
@synthesize fracView;

{
textField.text = @"2";
[fracView setLevel: 2];

selector:@selector(textChangeNot:)
object:textField];

}

- (void) textChangeNot: (id) object
{
[fracView setLevel: textField.text.intValue];
[fracView setNeedsDisplay];
}

{
// Dispose of any resources that can be recreated.
}

@end

//
//  csFractalView.m
//  Fractal1
//
//  Created by Stephen Smith on 2013-02-17.
//

#import "csFractalView.h"
#import "csFractal.h"

@implementation csFractalView
{
csFractal *frac;
int level;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
level = 1;
}
return self;
}

- (void) setLevel: (int)lev
{
level = lev;
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code

UIColor* currentColor = [UIColor blackColor];
CGContextRef    context = UIGraphicsGetCurrentContext();

//Set the width of the "pen" that will be used for drawing
CGContextSetLineWidth(context,1);
//Set the color of the pen to be used
CGContextSetStrokeColorWithColor(context, currentColor.CGColor);

frac = [[csFractal alloc] initWithContext: context];
[frac KockSnowflake: level];

//Apply our stroke settings to the line.
CGContextStrokePath(context);
}

@end```

Written by smist08

March 16, 2013 at 4:59 pm

Posted in Learning, Mobility

## Some Experiences from Blogging

Introduction

I’ve been writing this blog for nearly four years now. I’ve written 175 articles and there have been 940 comments (many of these responses by myself). This is a bit of a self-indulgent article on my experiences blogging. Partly because I think blogging is a great communications mechanism and partly because I need a topic this week. I’ve managed to get my readership up to a bit over ten thousand views per month now, which given the specialized topics I blog on, I tend to think is pretty good. I get a quite varied readership with all parts of the globe being represented.

Format

I use WordPress. I didn’t do a lot of research to pick it, I just noticed several blogs that I liked used it and gave it a try. I found it really easy to get going and have basically stuck with it since. It’s important to keep your blog URL the same so people can continue to find you. I never paid for a personalized URL, so if I ever did want to switch away from WordPress it would be hard, since I would need to change the URL of my blog. I’ve only ever used the free version/functionality and never paid for anything, though WordPress makes some money off me by having a few adds on my blog now and then.

I write my articles in MS Word. Then I copy/paste them into WordPress. WordPress preserves most of the formatting so I don’t need to reformat things usually. Sometimes it messes up, but I tend to keep the formatting simple so I don’t confuse it. The pictures don’t copy across, so I need to insert them separately when done.

I don’t really like the contents/indexing of blog articles that WordPress provides, so I use the custom page feature to keep some tables of contents and directories of articles more in a way that I prefer.

When you start a blog and post it on a site like WordPress, even if you don’t do anything, you will still get a few views, even if it’s only a dozen a week. So how do you get readers? How do you keep them coming back? There are a lot of articles and blogs on how to promote blog readership, but these are a few things that I find work.

3. Posting notifications on relevant Facebook pages generates a few views, but at least for me, the audience is wrong and I don’t get many views this way.
4. Reddit. Since Digg died, Reddit is supposedly the main referral site for articles. However most blogs are just rejected by the various topic editors and it’s very hard to keep good referrals here. I’ve only managed to do it once, but it did payoff with a record day. But generally I find Reddit too much work.
5. Write regularly. If you write regularly then people will subscribe to your blog to be notified either by e-mail or RSS every time you post. Subscribing readers are the best kind of readers. Plus Google (see #1) favors sites that keep posting original content. It doesn’t take long for all that content to add up to a pretty sizeable set of reference material.
6. Build a twitter following. Tweeting is a great way to promote your blog. I found Twitter worked better a few years ago. My theory is that so many people tweet now, that your posts tend to get lost in the general sea of tweets. Google is putting a bit more weight into social media references, so it can’t hurt.
7. There are sites that claim if you pay them, they will find you all sorts of readers and send your viewership skyrocketing. I don’t really believe this and have never paid for such a service. I’ve also never paid for things like Facebook or Twitter to promote my posts.
8. Have relevant keywords. But don’t go overboard. There has been so much abuse of HTML keywords, that most search engines just ignore them and go for the content. A few good keywords is good, but if you add every word in the dictionary it just makes your page slow to load and the search engines will ignore them. The search engines are much better at deriving these from your content these days.

Generally unless you are a celebrity (or blogging about celebrities), your number of viewers won’t be in the millions (or even hundreds of thousands). But getting a readership in the thousands or tens of thousands isn’t that hard. It just takes consistency, good content and a bit of perseverance. Also remember that if you are blogging on a technical topic, your whole total audience may not be that big, due to the high levels of specialization we see these days.

Geographic

WordPress now will categorize your readership by country. This is based on your IP address which isn’t perfect. At our Sage Richmond office, our internet is routed through Irvine, CA. So if anyone in the office (in Canada) reads my blog then it counts as US (since this is how the IP address is assigned).

My readership tends to follow proportionately where Sage 300 is successful. But there are a few anomalies. Strangely I get quite a few views from Brazil, even though we’ve never really sold Sage 300 there.

Stats

Blogging software like WordPress is great for providing you all sorts of statistics. Like tracking your viewers over the years, telling you which countries follow your blog the most, telling you who is referring people to your blog. I find keeping an eye on these statistics is very addictive. Plus it’s a great feedback mechanism where you can experiment and then get some real data on what the affect is.

Feedback

Blogs are a great way to get feedback. People are quite willing to share their thoughts with you. Generally it’s a good idea to prescreen comments to eliminate spam and other unsavory remarks. It’s amazing how many online scams try to propagate by posting comments on blogs.

Versus Tech Support

I do try to answer most of the questions posted to my blog. But remember it isn’t tech support. When you open a tech support ticket, it is tracked and they will keep working on it till it’s solved. For my blog I might not have any idea and not answer, or I might be busy and it falls through the cracks. Or it requires more back and forth than can be achieved via blog comments. Also remember that blog comments aren’t a replacement for on-line forums, these are much better at gaining answers from a community of people. One of the goals of my blog is to reduce tech support, but blogging on topics that give people trouble or by blogging on ways to troubleshoot problems. But in the end if you really do need an answer and you need things to be followed up and escalated then please do call tech support.

Summary

I find blogging a very rewarding activity. One saying that I take to heart is that you don’t really understand a topic until you can teach it to someone else. I find I learn a lot researching for blog posts and that it can really crystalize my thinking when going through the process of writing an article.

Plus it is enjoyable to attend conferences and have people come up to me and say that they regularly do read my blog.

Written by smist08

November 10, 2012 at 2:48 am

## Our First Hackathon

Introduction

Hackathons are becoming a fairly common method to stimulate innovation at companies, software or otherwise. We recently held our first Hackathon here with the Sage 300 ERP development team. We are adding Hackathons to our Sage Innovation Process as an idea generator and a concept tester.

Probably the most famous recent Hackathons are those held at Facebook which resulted in the Like button, Facebook Chat and the Timeline feature. If you Google Facebook Hackatons on YouTube, you can find all sorts of videos showing these. In fact Hackathons are being conducted in industries outside of software development in things like government and food production.

The key goal of Hackathons is to stimulate the creative juices in the organization. To get ideas flowing, to provide a platform to quickly develop them, to show them off and then possibly productize them. In some sense you would like to have everyone creative and innovative all the time, but the pressures of day to day tasks usually damper such things.

Hackathons also give programmers a chance to do projects they’ve always wanted to do and felt were important, but couldn’t convince Product Management to prioritize high enough to get done.

Logistics

We decided to have a two day Hackathon. We had a kick-off meeting just before lunch on Wednesday and then the teams had two days to hack. We then had a results presentation just after lunch on Friday. Some people formed small teams, others worked solo. Basically the two days were up to them. We then provided snacks and lunch on Thursday.

Facebook runs their Hackathons for 24 hours and people don’t sleep. We thought that too extreme. Although some people worked quite long hours getting their hacks to work, no one missed a night’s sleep. Our feeling is that sleep deprivation doesn’t help and is in fact quite destructive. Often a good night’s sleep is what you need to solve difficult problems.

Idea Generation

When we were initially planning the Hackathon, we were worried that people wouldn’t participate because they would have trouble coming up with ideas of what to do. So to try to alleviate this, we came up with a list of suggestions for people.

What we found instead was that this wasn’t a problem at all. We had really good participation and none of our original ideas were used. All teams either had a brain storming session to start with, or had their own ideas that they had been thinking about and just needed an opportunity to explore them.

One key is to give plenty of warning of an upcoming Hackathon, so people can have plenty of time to come up with ideas, and to network with their peers to develop teams.

Results

The results of the Hackathon greatly exceeded our expectations. All the teams, except for one that had to deal with an emergency issue, were able to demonstrate useful and exciting results.

The projects were very diverse including:

• testing out a new automated test tool
• evaluating running static code analysis tools on our code
• developing a new customer information connected service
• created a better tool to create knowledge base articles
• created a direct to customer advertising feature
• added a key CRM integration feature
•  fixing some long standing annoyances that never made the priority list.

Below is a picture of the winning team, that hacked in a number of useful social media integrations to the Sage 300 ERP product, including a rating system for things like customers (similar to Amazon ratings), integrations to Skype, Google Maps and a number of other things.

Write Up

We insisted that each group write up their results. We wanted to document all learning’s. We want to know things tried that didn’t work out as well as successes. We did this via a page on our internal development Wiki. This is a very important part of Hackathons since you want to build on everything accomplished.

Learning’s

Our summary presentations went a bit long because everyone was so excited to show so much; however, we decided that next time we will limit each presentation to 5 minutes, since the whole presentation went quite long.

The idea of giving awards turned out to be quite controversial. We had a best project award and a better luck next time award. Everyone felt we should get rid of the better luck next time award. Some people like the idea of having a “winner”, others felt that it corrupted the hackathon process by motivating people to produce visual fluff over perhaps more technical work.

The idea of the “better luck necessary” award was to celebrate failure, since we want to motivate people to take risks and not be too conservative. However people seemed to think this wasn’t a great idea since a couple of “failures” were actually considered successes since they provided proof that a couple of popular technologies weren’t really ready for prime time.

The two day time frame seemed to work quite well for our staff. No one wanted to switch to the 24 hour no sleep method. Then the consensus was that we should try to repeat the Hackathon every 2 to 3 months. It makes no sense to only do a Hackathon once, you really need to keep doing them regularly to exercise your innovation muscles or they will just atrophy again.

Summary

Hackathons are a great way to stimulate innovation in an organization. Not only do you generate a lot of ideas, but you often pick off some low hanging fruit. Or you have a POC (proof of concept) to prove out an idea to productize. Hackathons have been used successfully at many companies in many industries and our own experience was very positive.

Written by smist08

October 20, 2012 at 10:44 am

## SData Training Videos

Introduction

A couple of weeks ago I blogged on Learning over the Web, in this blog I mentioned that I really like the Khan Academy and their video method of training. I’ve now started experimenting with making Khan Academy style videos. I’ve now done three, so far, as an introduction to SData. I plan to make more of these going forwards. Once I have a larger set of videos on SData, I may try branching out to other topics. Below is a picture of Sal Khan working on such videos:

New Video Page

I’ve added a Video page to my blog which will provide links to all the videos I produce. To start with there are three videos, which aren’t very many. However I hope to make a new one every week or so and then if I can keep that up, after a year there will be fifty or so videos. The first three videos are:

The best way to learn something is by doing. So I recommend playing with SData and experimenting with the various items described in the video. To this end you can play with a locally installed version of Sage 300 ERP (or another Sage product) or you can access our demo server at http://sage300erpdemo.na.sage.com. The user id and password are ADMIN/ADMIN, make sure you enter them in upper case if prompted from the Browser or other client software. If you type the URL: http://sage300erpdemo.na.sage.com/SDataServlet/sdata/sageERP/accpac/SAMINC/arCustomersFinder into the Chrome browser and enter ADMIN/ADMIN for the userid/password then you should get back a large amount of XML containing the first 10 customer records in the SAMINC database. For information on how to perform other querying, see the third video.

If you want to try these with a different Sage product, then you might need to run Fiddler to see the exact form of their SData URLs. Once you have this, you can be up and running. Fiddler is a very useful tool for spying on HTTP requests made from your computer. You can spy on any program or website to see what it is doing.

For more background information on SData, see the SData Website or some of my previous blog posts: SData in Sage ERP Accpac 6, More on SData and Sage ERP Accpac 6, Stateful SData, On the Sage GCRM Contract, Fun with SData, A Roadmap for SData Integration to Sage Products or Defining SData Feeds for Sage 300 ERP. Jarett Smith has also started a blog on SData which is well worth checking out.

Production

I find creating videos more time consuming than writing, mostly because it’s harder to jump around in videos and harder to edit them. I’m hoping I can get better at creating videos with more practice and time. Partly getting used to the process and learning by doing. I hope that as I keep doing these, they will get better. It certainly takes some practice to use the writing tablet for drawing (hopefully my handwriting will improve) and at the same time I need to watch myself to not say “Um” so much. So I consider these first three videos the first three steps on a longer journey.

For producing the videos I pretty much copied what they use at Khan Academy. It’s neat that you can create videos these days with very little equipment or post production software. I used entirely either open source or free software and a very inexpensive writing tablet. The items I used:

• YouTube to post the videos to. Seemed the easiest and the URLs are easy to circulate.
• SmoothDraw 3 for drawing. I start with a black rectangle 854×480 pixels (which is a preferred YouTube resolution that fits well on my monitor).
• BB FlashBack Express for screen recording.
• Wacom Bamboo Connect pen input tablet. Cost around \$80CAD.
• A Blue Snowball Microphone. This works a lot better than the microphone built into my laptop and we already have a few of these around the office. Original cost was about \$65CAD.
• Windows Live Movie Maker for video editing. Not a very good solution, but it has done what I need. Suspect I might need to buy Camtasia eventually.

It took me a bit of trial and error to get things to work right. I tried a couple of free screen recording utilities like Camstudio, which didn’t work for me. They either crashed or didn’t produce good results. Then in editing, for MovieMaker you need to change the project from 4×3 to 16×9 or it produces something that doesn’t work right on YouTube.

I’m still undecided on whether I want to add vlogging to my blogging. This requires a camera, but web cams are cheap and for that matter both my phone and camera both take really good videos, certainly good enough for YouTube. When I’ve tried this in the past, I haven’t been happy with the results and found that much more video editing is required. But then again hopefully with some practice, I can get better over time.

Summary

I hope you find my new Video page useful. Hopefully over the coming month I’ll add quite a few videos and start to branch out to other topics.

Written by smist08

April 28, 2012 at 5:19 pm

Posted in Learning, SData

## Learning over the Web

with one comment

Now a days, when people need to know something, they turn to Google. When people need to learn something new, like say a new programming language or application, they turn to the Web for on-line training. But what is the best way to learn things from the Internet? Which tools work well? Which tools end up wasting a lot of time? As a blog writer and Software Architect, I spend some time wondering on the best ways to disseminate information. I’ve tried a lot of the items discussed in this posting both as a teacher and as a student. As usual these represent my own personal biases and opinions.

I think there is a lot to be said for attending real physical classroom or attending conferences. Besides the sessions there is all the networking and sharing of experiences with other attendees. Sage Summit is a great one for learning and networking here in North America. But travel is expensive and time consuming. Often attending classes is too much time commitment. So it’s nice that if you can’t turn to these there are still some good alternatives.

PowerPoint is Evil

The heading refers to a well-known Wired article: PowerPoint is Evil. Many consider PowerPoint to be the worst thing that has ever happened to education. Here is the Gettysburg Address in PowerPoint form  to emphasize what is lost in a PPT presentation.  If you are looking to learn a new topic and you Google, chances are you will find many PPT presentations on the topic. Chances are if you download and read these, you will learn very little and become frustrated. I know I’ve annoyed people by sending them PPTs from old conferences in answer to various questions. Many Universities and Colleges make a big deal on how they publish all their class PPTs on the Web. To me these aren’t very useful, and make me wonder at the value of these institutions. Never mind the horror of death by PowerPoint in a meeting or at a conference.

Khan Academy is a website that is completely free to use and offers course material from all over elementary school, high school and college. There are over 3000 videos and over 300 math exercise that you can use. All the videos are made by the founder Salman Khan, and are interesting because of their simplicity. Basically you get a virtual blackboard that Salman draws on as he explains a topic. Most of the videos are under ten minutes long and using this site is quite addictive. Although I haven’t done it yet, I feel that producing Khan Academy type videos could be a very efficient way of producing quite effective training material. There are other specialized on-line training sites like Code Academy, but I tend to like Khan the best.

Videos

There are some excellent videos of training sessions and lectures on the Internet. InfoQ is always posting quite good lectures. The main problem I have with them is that they are hard to skim through. Often to get the benefit you have to watch a full hour long video. I tend to prefer written material since I can skim through it and process it quite a bit quicker. You also have to watch the quality of the video, some are quite un-watchable. In a way videos are great to watch lectures you missed, perhaps at a conference you couldn’t attend. On the other hand I find it really hard to find that un-interrupted hour in a day to watch a complete video lecture.

I’ve only created a couple of videos, I found it very time consuming, mostly because in the editing process you spend so much time watching and repeating parts. Perhaps I need more practice, but I find it can take a full day to create a decent 20 minute video. I wonder if to practice, I should start doing some of my blogs as vlogs?

Webinars

I’ve attended some really excellent webinars. I especially like them if they are interactive. If there are a small number of attendees then you can ask questions as you go along. If attendees can’t ask questions I find it isn’t nearly as engaging, if there is a large audience, often a helper can find some good questions off the chat window to interject a little interactivity. Generally a good technology to provide a near classroom experience when you can’t physically meet.  With newer Telepresence technologies, I expect webinars to get better and better and to fulfill the vision of virtual classrooms.

Often when people give webinars, they record them and then post them for people that missed the live webinar. Then you get into all the issues I mentioned in the videos section. I often find recorded webinars quite boring in comparison to the live event.

E-Books

Often you can find a number of free e-books on any given topic. For that matter you could buy a real physical book or buy an e-book version. For much learning, I still enjoy quietly reading a book, whether a physical book or an e-book on my iPad. There are always promises of more interactive books, but I still like the old fashioned passive variety. Being able to mark up and search e-books is definitely nice. I even wonder if I should one day create a book version of all my blog posts?

I like it that companies post all their instruction manuals as PDFs on the web. So once I’ve lost the manual for my phone and need to change the answering machine, I can find the manual much easier on the web than finding the printed one in my house.

Blogs

I find blogs a good way to disseminate small amounts of information. However I don’t think a blog is a good vehicle for producing a training course. Cumulatively there are a lot of blogs out there and a lot of good information is available in blogs first before it appears in other media. I know I try to push out information in my blog before other departments have a change to process and publish it. So generally I find blogs best for information at the very bleeding edge, often in quite a raw form. I’m not sure if I would get many viewers, if say I ran a ten part series on say learning SData.

Wikis

Around the office we have a joke that Wikipedia knows everything and this is pretty much true. If you need quick info on a topic, then Wikipedia or other Wiki’s can be a great source. We do all our technical documentation in Wiki format now, so we can quickly push it from our internal to external Wiki very easily. We find this is a great way to provide technical documentation without any extra overhead. Many companies have Wikis of this nature. These aren’t always the best places to learn from, but they are great for looking things up.

Reference Material

A lot of companies publish all their reference material to the Internet. Often this is in Wiki format as mentioned above. However there are many other tools for generating this. For instance for our Java APIs we insist that all source code has complete JavaDoc, and then we generate this JavaDoc and reference it form the Wiki to provide API reference documentation.

Summary

I tend to think the best way to learn, is by doing. The best way to learn is from making mistakes and you need to be doing, to make those mistakes. You can’t learn all the pitfalls of something just by reading or watching. But how do you get started? The web now offers a wonderful variety of resources that are mostly free to get started and to get learning.

Written by smist08

March 31, 2012 at 5:13 pm