First CoderDojo Experience as a Mentor

CoderDojo Kenmore 2014

Last weekend, I was a first-time volunteer at a CoderDojo event here in Brisbane. CoderDojo is a movement to encourage young people to think of a computer as a creative toy/tool rather than just as a game machine.

This was the first session of six and introduced MIT Scratch programming to primary school children.

As usual, the course was oversubscribed, and attendance turned out to be pretty good. The room was half full about 15 minutes to start time, but everyone showed up on time. The room at Kenmore Library was very big, and the plan was to arrange the tables into two class rooms, 1/3 for people who already know scratch, and 2/3 for people who haven’t done it before. However, our estimate was wrong. We did a show of hands – about 2/3 of the attendees already had prior Scratch exposure. We lost a good 10 minutes moving kids around, shifting tables etc.
Continue reading

Exam 71-532 Microsoft Azure Solutions – Study Guide

Windows Azure Certification

Here is a somewhat uncomplete list of resources for the Azure 71-532 exam. I’m planning to sit for this. If you have any resources to share, add them in the comments please.

Create and manage virtual machines

Configure VM Networking

  • Configure reserved-ip addresses
    Get-AzureStaticVNetIP -vm ( Get-AzureVM -Name "thegu" -ServiceName "thegu-teyc" )
    Set-AzureStaticVNetIP -vm {{VM}} -IPAddress {{IP}}
    Set-AzureStaticVNetIP -vm ( Get-AzureVM -Name "thegu" -ServiceName "thegu-teyc" ) - IPAddress 192.168.0.10 | Update-AzureVM
    Test-AzureStaticVNetIP -VNetName "lab1" -IPAddress "192.168.0.10"
    
  • ACL can be used to restrict access to particular IP ranges. The CIDR format e.g. /24 means the first 24 bits are fixed, i.e 74.207.253. The last 8 bits can vary from 0-255.
  • DNS
  • Load Balance Endpoints. Delete the existing endpoint, and add new ones, but put them into a new load balanced set. Note at present, you cannot configure multiple endpoint on the same private port.
  • HTTP and TCP Health probes
  • Public IPs
  • Firewall Rules
  • Direct Server Return – Load Balancer configuration that takes load off the load balancer by permitting server to respond directly. Use cases are UDP and RTSP.
  • Keep-Alive

Continue reading

Stackoverflow-Style Permalinks that includes Post Id with WordPress

I like how Stackoverflow implements permalinks. For instance, take a look at this URL:

http://stackoverflow.com/questions/26497051/python-how-to-append-file-content-into-format-string

The URL includes both the post_id as well as the slug. This way, if the slug was changed, the system still retains a post id and can find the correct article.

On WordPress, this is implemented as a custom permalink. I think it ought to be standard.stackoverflow-style-permalinks on WordPress using Custom Permalink setting

For example, this post can be referenced as
http://cognoware.com/132/stackoverflow-style-permalinks-with-wordpress/
However, if the slug was different in the past, say it was xyz, the links will not rot.
http://cognoware.com/132/xyz/

Older programmers

There has been a spate of articles and blog posts around programmers with over 10 years experience.

Robert Martin at CleanCoder suggests that seasoned programmers deployed correctly can have a tremendous positive effect on the junior programmers around them. However, the question remains – why is the distribution skewed towards younger programmers.

The question is – where are the older programmer’s now?

Michael writes

But it gets harder and harder to be taken seriously the older you get. Which is funny because as the value of what you have to say goes up — people’s willingness to listen to it goes down.

And the pay goes down over time (I’m now making the same salary I was making 20 years ago — and that’s not adjusted for inflation). Frankly, I’m just happy to not be homeless.

Programmers are expected to act their age. There is a persistent perception out in the market place that an older programmers ought to be doing something more senior. Given the low barriers of entry, programming is a younger person’s game.

In particular, location may be a very big factor. Dave writes

I’m not a developer, but a manager. I have a number of older developer friends who are having a hard time getting any interviews. It seems like the companies where we live (Ontario, Canada), just toss any resumes over 40.

There is also a running joke that at a large company they keep a stable of their older programmers around so that every year they can cull a few to increase company profits.

Of course there are survivor tales, such as this one:

Well… I’m 69. I started in 1968 with Fortran at engineering college. Don’t ask for my CV or my github because I’m very happy as a consultant in ThoughtWorks Brazil doing a lot of things especially those most directly related with innovation and agile development

However, the days of older software assembly-worker will one day be gone. When the last of those jobs go, it will be like what happened to manufacturing. The managerial work will be gone too. However, it does not mean the end of software. It just means the stacks get higher, and increasing specialization – be it SAP or Salesforce. Or you may need to go into consulting.

On Docker

Docker is a name for several technologies:

  • a toolchain that creates dockerized images,
  • an engine that runs images as containers and stops them,
  • and Docker Hub – a SAAS that manages application stacks.

What is a dockerized image? A dockerized image is similar in concept to Portable Apps – isolated software packages that bundles its own dependencies. It is a packaging format that includes a specification of the linux kernel, application files, and open ports. While conceptually this sounds like a virtual machine, in practice, a docker is implemented as a LXC process container. In fact, shutting down a docker conatiner is more akin to killing a process. The entire filesystem of the dockerized image is deleted.

Conceptually, this is how every maps

Technology Build Image Execution Persistence
Portable Apps not specified – e.g. Makefile Standard Directory + Executables Process not specified – any where on the user’s file system
Docker Dockerfile Docker Image Docker Containers (LXC processes) Data Volumes, or Data Volume Containers
Virtual Machines not specified Primary Configuration file .vmx and Disks .vmd Guest OS Disks .vmd
AWS EC2 Snapshots AMI EC2 instances RDS, S3

This concept is not entirely new. EC2 architecture requires persistent data to be written to a persistent data store/service. You have two options: you can mount local directories onto Docker images so that MySQL writes the database files into the host directories. Alternately, you can create a data volume container.

The main attraction of docker is this: modern applications tend to span multiple services. For example, besides the database server, there might be a mail server, a caching server, logging servers. The cost of mocking these services for development and testing can increase, and it gets brittle very quickly. Running up lightweight docker images is the cheaper and faster way creating all the services a developer needs. Some benchmarks show docker being much more performant than virtual machines.

Furthermore, a docker image is also a convenient deployment unit for production. Higher level tools allow docker images to be composed into applications. Others layer monitoring and auto scaling.

A shout out to the ImagePaste WordPress Plugin

The ImagePaste plugin is a great timesaver if you are blogging screenshots.  It copies images from your clipboard and uploads it to the server automatically.

I usually use the Windows Snipping Tool to capture my screenshots

In the past, I’d have to save this to a file and then upload to the server. Now, with ImagePaste, it’s a matter of CTRL+V into the mce text area.

NB:

  1. The presence of JetPack interferes with ImagePaste.
  2. You need to be in Visual Mode for ImagePaste to work.

How to create a JavaFX control from scratch

Thanks to Richard Bair

  1. Extend Control class,
  2. Set the Stylesheet,
  3. Provide no arg-constructor
    public class MoneyField extends Control {
        /**
         * Creates a new MoneyField. The style class is set to "money-field".
         */
        public MoneyField() {
            getStyleClass().setAll("money-field");
        }
     
        @Override protected String getUserAgentStylesheet() {
            return getClass().getResource("MoneyField.css").toExternalForm();
        }
    }
    
  4. Create .css file in the same package
  5. Define .money-field class (see how constructor sets style to “money-field”)
  6. Define -fx-skin: “fully-qualified-name-of-ControlSkin”;
  7. Create Skin class
    public class MoneyFieldSkin implements Skin<moneyfield> {
    }
    

  8. In constructor, create the controls required for the shadow-DOM
    public class MoneyFieldSkin implements Skin<moneyfield> {
        /**
         * Create a new MoneyFieldSkin.
         * @param control The MoneyField
         */
        public MoneyFieldSkin(final MoneyField control) {
            this.control = control;
     
            // Create the TextField that we are going to use to represent this MoneyFieldSkin.
            // The textField restricts input so that only valid digits that contribute to the
            // Money can be input.
            textField = new TextField() { // ...
            };
     
            // ... and a lot more stuff!
        }
    }
    

Continue reading

On Ubuntu’s new smartphone OS

BBC reports:

The Ubuntu operating system has been adapted to run on smartphones.

The Linux-based software will allow users to run desktop apps on their handsets, allowing them to double for PCs when docked to monitors.

Here are the reasons why I think Mark Shuttleworth is doing this:

Today, Linux is everywhere in the sense that beneath Android – runs Linux. Unfortunately, Ubuntu doesn’t figure in the equation. Tablets, phones are all locked down devices and enthusiast/hobbyist open source doesn’t figure unless drivers are available. To maintain relevance, Ubuntu needs to exist in the mobile space.

Today’s announcement is an early one, and is making the same value proposition as Android did early on, before Google’s acquisition. i.e. an open source system that any phone vendor can use to build their smartphone platforms on.

The Problems

Ubuntu has a remarkably polished desktop product for years but it has remained a fringe product and the PC market has simply stopped growing. Jobs has carefully taken Apple around MS’s hegemony on the desktop by tackling music players first, then a pincer movement through Windows Mobile dominance by producing a very expensive smartphone.

Shuttleworth faces not one but several well established and cashed up competitors – Apple, Google/Samsung, Amazon. I haven’t even mentioned Microsoft, or the Chinese Korean and Taiwanese versions of a smartphone OS. Each of them have an arsenal of patents and services that gives them degrees of freedom to move around the space. Google for example commands the email/contacts/calendar integration, YouTube, Maps and Navigation. Google’s approach is to deny competitors full functionality of these services to cripple their smartphone offerings. e.g. turn by turn in the case of iOS, YouTube search APIs in the case of Windows Phones. Apple and Amazon have offered cloud locker services for those who purchased music and books from their online stores. Microsoft has some cards left in enterprise management and server integration.

Next steps

I believe this is just an initial salvo. Promising compatibility with Android kernel level drivers is a good start. Right now there isn’t enough value proposition for Ubuntu phone in terms of apps or services. Integrating a phone and desktop are novel but it is far from a sure bet. A reference phone design might be good bet if they think it will persuade some of the smaller Chinese manufacturers to jump onboard. However, this will not please Dell. It might make a MIUI-like play, and remain a niche phone OS for several years until the opportunity is right.

What Ubuntu really needs to do now as an organisation is to make a sideways bet into iOS and Android. It needs to kick start development of its own mail app, or acquire a navigation maker like Waze, and get these loaded onto the popular phones today. There is still some geek-cred left in Ubuntu for people to load these apps on, and who knows, they might catch on in the enterprise space.

T-SQL when SQL Server Management Studio is not available

C:\Program Files\Microsoft SQL Server\100\Tools>sqlcmd -S .\SQLEXPRESS

1> — Fetches the logical names from a backup file
2> RESTORE FILELISTONLY FROM DISK=’C:\VMS\2mtsam_com.bak’
3> GO

1> — Restore the back up file
2> RESTORE DATABASE SAMDB FROM DISK=’C:\VMs\2MTSAM_COM.BAK’
3> WITH
4> MOVE ‘SAMDB’ TO ‘C:\VMs\SAMDB.mdf’,
5> MOVE ‘SAMDB_LOG’ TO ‘C:\VMs\SAMDB.ldf’
6> GO

C:\Program Files\Microsoft SQL Server\100\Tools>sqlcmd -S .\SQLEXPRESS
1> create login SamDbUser with password=’SamDbUser’
2> go
1> use samdb
2> go
Changed database context to ‘SamDb’.
1> create user SamDbUser FROM LOGIN SamDbUser
2> GO
1> sp_addrolemember ‘db_owner’, ‘SamDbUser’
2> GO

with thanks to StackOverflow

Reference:
Create User TSQL
TSQL Map User To Database