All posts by mchung

Configuring Nginx to reverse proxy .NET Core on Mac

Moving on from developing .NET using Visual Studio Community Mac, I started working on the necessary configuration for actually running on a Mac host (and by extension, a non-Windows host).

The main task here is to configure Nginx to assist Kestrel (the .NET Core web server). Kestrel currently excels are running the .NET Core application but is not fully-featured enough to do a good job with other things, like security and assets like images, hence the requirement for using two web servers.

The setup for Nginx to run in this reverse-proxy configuration is pretty straightforward.

MAMP configuration

I use MAMP to package up Apache, MySQL, and Nginx for development work, and it helps keep things fairly painless to configure. However, the basic configuration for MAMP does not allow Nginx to reverse proxy a custom address and port, which is what’s needed to direct requests to Kestrel.

Configuration Steps

The solution is to edit the template that MAMP uses to actually generate the nginx.conf file. Here are the steps:

1. In the MAMP menu, select File | Edit Template > Nginx (nginx.conf). This opens up the template file used to actually generate the nginx.conf. You’ll see various predefined macros in red.

2. Add a section to the template file and leave the rest alone – I chose to add a new “server { }” definition inside the “http {” section. and above the first existing “server { }”  definition. This adds a new listener on port 9999 and passes on all queries to Kestrel listening on port 5000.

server {
  #listen over http on port 9999 on localhost
  listen 9999;
  server_name localhost;
  #Kestrel server
  location / {
    proxy_pass http://127.0.0.1:5000/;
  }
}

3. Start (or restart) Nginx through MAMP and all should be well. The actual nginx.conf file generated by MAMP using the above template can be found in /Library/Application Support/appsolute/MAMP PRO/conf/. It may help to double check this config file to make sure your changes are correct and being seen by Nginx.

To run your solution, simply run Kestrel and your .NET Core app through Visual Studio, or by using the dotnet run command line instruction inside your project folder.

Nginx will now proxy all calls to Kestrel. Open up your site on  localhost:9999

There are further optimizations you can add to the nginx.conf file. Foremost is to configure static file requests to be handled by Nginx rather than Kestrel for performance reasons.

 

Visual Studio 2017, .NET Core, MVC and EF on Mac

I’ve started playing with Visual Studio 2017 on the Mac, pulling across a sample MVC Core + Entity Framework Core tutorial project on the Microsoft site. The tutorial can be found here.

I run a Windows in a VirtualBox VM on the Mac, so I have a full Windows 10 + VS 2017 Community install with MSSQL 2016 on it.

On the Mac side, I was trying the latest VS 2017 Community for Mac, along with ASP.NET Core.

I was hoping to suss out how much cross-platform compatibility there was, and how much of a poor cousin VSMac was compared to its Windows counterpart, which is still one of my favourite IDEs.

Installing

Installing VSMac is pretty straightforward and .NET Core is a separate install documented on the Microsoft website.

Moving the project over to the Mac side

I started and finished the project on the Windows VM, running on MS Sql Server. This project opens up fine on VSMac. I had some high expectations it would, and it does. It even builds and runs!

Of course, the lack of database access on the Mac side needed to be addressed, but the web project hosted inside VSMac started up and ran just fine in Safari using localhost and a custom port number just as in the Windows VM and Edge.

Converting to use MySQL instead of SQL Server would be the next challenge.

Adding Pomelo for MySQL Support

I didn’t find too many options for MySQL. There are some hints on the MySQL blog that MySQL Connector works with Core, but I couldn’t actually find a package for the Mac listed in their downloads so I gave up. The one that looked OK is Pomelo.

Pleasantly enough, Pomelo.EntityFrameworkCore.MySql  is one of the packages listed when firing up the Project | Add NuGet Packages… option in VSMac.

Simply add the package to your project at this point and you’re almost ready to go.

Changing the Entity Framework Provider to MySQL

This was also fairly straightforward. In the Startup.cs file, the database context needs to be adjusted to use MySQL.

From:

public void ConfigureServices(IServiceCollection services)
{
  // Add framework services.
  services.AddMvc();

  services.AddDbContext<WebTestContext>(options => options.UseSqlServer(Configuration.GetConnectionString("WebTestContext")));
}

To:

public void ConfigureServices(IServiceCollection services)
{
   // Add framework services.
   services.AddMvc();

  services.AddDbContext<WebTestContext>(options => options.UseMySql(Configuration.GetConnectionString("WebTestContext")));
}

The connection string in the appsettings.json was also changed to the MySQL flavour:

 "ConnectionStrings": {
 "WebTestContext": "server=localhost;port=8889;database=thedbname;uid=myuserid;pwd=thepassword"
 }

Once this was done, running

   dotnet ef update

on the terminal command line in the project directory (where the .csproj file is located) should attach to the configured MySQL instance and create the required tables (in this case, just one) for the sample project.

And voila – things run and the database is created. Quite impressive. You can even add a new movie. But alas, not a second movie…because…

Add Auto Increment to ID field in MySQL

For some reason, the Pomelo provider, or .NET, or something somewhere doesn’t know that EF relies on the ID field on the table being an auto incrementing field. This causes any table inserts beyond the first item to fail with a MySqlException: Duplicate entry ‘0’ for key ‘PRIMARY’error.

The fix is simple enough; either:

  1. Go into phpMyAdmin and change the row property for the ID column to check the A_I (Auto_Increment) box, then save changes; or
  2. Run a SQL command to do the same thing – something along the lines of
ALTER TABLE `Movie` CHANGE `ID` `ID` INT(11) NOT NULL AUTO_INCREMENT;

Notes

  1. Entity Framework Core references must be added manually when using VSMac – you can’t add this through NuGet right now. The .csproj file must be edited manually to create the references. This appears to be a bug / limitation with just VSMac. Since I started the project on VSWin and moved to VSMac, I didn’t have this problem. But I did with a new project started on VSMac. I suspect that moving back and forth between the environments may be quite feasible.
  2. Scaffolding for helping create Insert / Update / Create views does not appear to be present for VSMac while VSWin has an option to create an MVC Controller along with associated views. These would be really handy to help build out your basic CRUD functionality. However, there may be options using Yeoman. More to come.
  3. Razor view tag helpers do not seem to provide syntax highlighting in VSMac.

Next Steps

More research to come, but the next step will be configuring the project so it runs nicely under NGINX or Apache as a Kestrel reverse proxy on the Mac without Visual Studio hosting.

 

Bitten by PHP DateTime mutability

I was finishing off phasing in new content and features of my latest project, the Surrey International Writers’ Conference (www.siwc.ca) website when some reports came in of problems with the published dates of the various writing workshops being held.

Workshops all adhere to a common schedule for each day of the 4-day conference, so I created a custom TimeSlot WordPress post type to centralize timeslots to allow sorting and grouping of workshops together on the master schedule. The data entry page for each workshop has a drop-down list box with friendly names like “Friday 10:00 AM – 11:30 PM”.

The actual format of the workshop date identifier string is “dd-hhmm-hhmm”, where dd is the day (05 = Friday, 06=Saturday, 07=Sunday, etc.) and the hhmm values specified the start and end times for the workshop. Our example workshop TimeSlot ID string as stored in the workshop metadata in WordPress would be “05-1000-1130”.

I had arbitrarily assigned Day 5 to be the Friday of the conference. This allowed the conference in future to potentially start earlier, say on Wednesday (3), or Thursday (4) to accommodate master classes or other pre-conference activities without needing to re-enter new timeslots every year (timeslots do not change year by year).

So when calculating the actual date of the workshop to display to users, I needed to subtract 5 days from the global start date of the conference (expressed as the date of the Friday), then add back the number of days in the workshop date structure. For example, for a Saturday 10:00 AM – 11:30 AM workshop, the ID would be (06-1000-1130).  Taking 5 days away from date of the Friday (October 20, 2017), then adding 6 days gives us October 21, 2017 as the date of the Saturday.

That’s where the problem arose…

Here’s the original code, taking 5 off the conference start date, $siwc_conference_start (DateTime object), then adding the workshop day value that I extracted previously from the string.

// $day = workshop day, 5=Friday, calculated previously

// following line modifies $siwc_conference_start!!!

$thisdate = $siwc_conference_start->sub(new DateInterval('P5D'));  

$thisdate = $thisdate->add(new DateInterval('P' . $day . 'D'));   

return $thisdate;

This caused no end of problems! I was getting seemingly random dates for the Friday – like October 23, October 21, etc.

After much tracing, I isolated it to the fact that the all-important $siwc_conference_start variable, which should have been, and needed to be, constant, was actually changing in value between calls! The only possibility was the sub() method call (and the add(), of course, upon later reflection) affecting the object directly rather than simply returning the result of the calculation.

This outlined an issue I hadn’t been aware of in PHP regarding the mutability of the DateTime class, which $siwc_conference_start was declared as.

The sub() method was actually acting upon the $siwc_conference_start object, subtracting 5 days from the conference, rather than returning an object with the 5 days subtracted from it and leaving the original alone.

The subsequent add() method was adding a different value back to the conference start date. So the conference start date value was bouncing between different values, some actually correct, depending on prior calls. This also explained why I hadn’t caught the bug in my earlier tests – my test data didn’t exercise the function sufficiently (either it had all Friday data, or I didn’t notice the discrepancy).

The  fixed code:

// $day = workshop day, 5=Friday, calculated previously

$thisdate = clone $siwc_conference_start;
$thisdate->sub(new DateInterval('P5D'));
$thisdate->add(new DateInterval('P' . $day . 'D'));

return $thisdate;

This is one fix – using the clone keyword to create a new object containing a shallow copy of the $siwc_conference_start object’s contents. The sub() and add() methods will act on that copy, not affecting the original.

There is also a second fix: declaring $siwc_conference_start as a DateTimeImmutable class introduced in PHP 5.5. This new class is an admission that the original DateTime class implementation was flawed in allowing the original object to be changed. The new implementation in DateTimeImmutable returns a copy of the object as would be expected.

Overall, this highlights a couple of interesting things around object mutability, when it is expected, and when it is not. The original implementation breaks a couple of different programming language expectations…

  1. Caused by my having used other languages’ DateTime types. For example, the .NET DateTime is a value type, therefore would behave as expected in the first implementation.
  2. Caused by expectations that DateTime should be implemented best as a value object rather than reference object. There are few situations where DateTimes are likely to be better off as reference objects (e.g. objects meant to be shared) than value objects. It’s not that the implementation was technically wrong, but the expected usage by programmers did not align well with the initial design decisions for this class.

This is also a lesson for creating a proper test harness for functions like this that are easy to test. I could easily have created a sample set of timeslot IDs and corresponding results, and this would have been identified before going into production.

You’re doing Scrum wrong

I’ve had the opportunity to talk to a few local organizations on Scrum, and also had attended some formal Scrum courses (scrum.org) to sort of align back with the mothership on what Scrum is, or should be.

My conclusion is that there is a lot of confusion around Scrum practices which leads unsurprisingly to the questioning of its benefits and attempts to modify it.

An overarching problem is that Scrum simply isn’t being executed properly.

I have an analogy for this – being Canadian, hockey is where the thought pattern normally flows, but is applicable to any team sport. Hockey, like any sports, has a body of rules and referees execute those rules on the rink, field, or pitch.

Likewise, the rules of hockey do not tell you how to play hockey. They do not tell you how to execute a power play, or that you can pull the goalie for an extra attacker if you’re down a goal, or you should shoot high on a particular goalie because he goes down on the ice too soon, or that you should line up the players this way or that way to counter the lineup on the other side.

The richness of Scrum is in the proper execution by a team; the rules are mainly the guardrails along the side to make sure we’re playing all playing the same sport – hockey, not rugby, or football.

Yet we seem to persist with Scrum leaders that only seem to know how to referee, not coach. We need those coaches that can see the rules as its creators did. Scrum is both incredibly flexible because its rules don’t actually create boundaries as they appear to.

I’ll write further on this, but let me touch upon one concern at a time. Here are a few objections I’ve heard:

  1. Our Lead Developers are swamped having to do the estimation work
  2. Scrum doesn’t handle out-of-band requests like emergency bug fixes
  3. We need longer than 2 weeks (or a month) to release something because our systems are complex and changes are required in many different places
  4. We can’t realistically release an Increment into production every two weeks because our testers find bugs in the test environment and we have to fix them.
  5. We have a continuous improvement or continuous development methodology and we like to deploy during a sprint. We can’t always wait until the end of the sprint.

Here are some potential answers:

  1. A fundamental concept of Scrum is the cross-functional Team. The Team is the one tasked to help create estimates. Having a Lead role runs somewhat counter to this idea. At the very least, it takes some control away from the developer that may actually be doing the work (assuming it’s not the lead developer). And it’s definitely causing the lead developer a lot more work to take on this extra responsibility that could be shared among the team. I would suggest that the estimation work be done by the whole team at the appointed time (a backlog refinement meeting once every sprint.
  2. No, Scrum doesn’t handle bug fixes, obviously, or any emergency situations that can throw an entire Sprint’s progress in jeopardy. Transparency with stakeholders as well as an organized process is what Scrum encourages, so that everybody knows what’s happening. A single point of contact through the Product Owner is very helpful in deciding if a bug is important enough to be fixed immediately, or if it can be put on the backlog for the next Sprint.
  3. Scrum suggests no longer than 4 weeks for a sprint. Four weeks is really based on the fact that organizations work on a month-to-month basis for generating financial or other metrics. These are the metrics that help determine the value of our development efforts and are therefore crucial to be aligned with the outputs of these development efforts.
    A second answer that can be indicate the need for a philosophical shift in the development process is that you may need to look at delivering thin, vertical slices of functionality across all systems rather than dividing the efforts horizontally; i.e. a front-end team plus a back-end team working independently, but having deep dependencies.
    Vertical slices of functionality allow for more agile adaptation to change, as you should only be implementing as much as you need to deliver functionality, rather than building excessive in advance in hopes of utilizing it in future.
  4. Scrum should encompass the entirety of the product development process – “tossing the product over the wall” and having gated tasks beyond the sprint, such as testing, hardening, deployment, security testing, and so on violate the idea of having a product Increment that is ready for production. It also gives a wrong impression of the state of the product – if there are bugs or remaining quality checks to pass, then it is most definitely not done. The fix to this is to create a more stringent definition of Done for the sprint that includes the quality criteria, the testing, and other tasks that were previously outside the sprint.
    This will potentially impact the perception of what is achieved in a sprint, but it is much more truthful and transparent to the entire development process as a whole.
  5. Continuous Deployment is not forbidden by Scrum – the Sprint should be seen as a cadence or rhythm for ensuring the Scrum artifacts occur on a regular basis, rather than enforcing a fixed delivery window of the an all-mighty and encompassing Increment at the end. Each task could simply include in its Definition of Done a “deployed into production” checkbox.
    Continuous deployment is fantastic, and a great way to ensure value is delivered as soon as possible; why not deploy a feature the moment it is ready?

As you can see, it is sometimes the perception of what the rules mean that can be impediments to a great Scrum implementation. One needs to look deeper at the intention of Scrum, rather than the raw rules or literal interpretations of what each Scrum artifact implies.

Job Interview 1: Shiny!

I’ve been interviewing with several large companies for a  role in software development management. I got through to the panel round of interviews with a nationwide retailer to work with their e-commerce presence.

Prior to this, I did a little homework and did what I often to do gauge the maturity level of a company’s website, looking for any obvious issues, the kind of technology used, and evidence of UX/UI consciousness.

I found some glaring issues, such as terrible page load times stretching up to 8 seconds, which is a huge no-no. In addition, page analytics from GTMetrix gave it a failing mark, as did Google’s page speed insights. A product page took a whopping 180+ HTTP requests to load — a number I’ve never seen before (most sites keep it to under a third of this value).

All are red flags that indicate the need for attention – the page will take time to load, causing a penalty on Google, not to mention customers will drop off; and the extra load on servers would potentially cause scalability problems.

The interview was with my future (non-technical) boss and with several of their existing web front-end developer team members that would have been my subordinates. After the normal pleasantries, the developers proceeded to fixate on my thoughts about the latest in front-end technology, rattling off a list of technologies and whether I had used them or not (some I had, some I hadn’t).

I stated that frameworks and technology change and by necessity, there is always a need (and desire by developers) to keep trying new frameworks, but there are some issues with the frameworks that exist today that need to be understood in the context of the larger whole.

These issues have to do a lot with the size of frameworks. It is too easy to pull in an entire framework to do something as small as styling a button (e.g. Bootstrap) and now you’ve impacted your page load speeds by some fraction of a second.

One interviewer was critical about my experience with one of the older UI frameworks that we used in my previous projects. But a framework is just a framework – a simple way to avoid the tedious Javascript programming needed to pop up a dialogue box or a panel or a lightbox – there really isn’t much magic to it. There is nothing that a framework provides that cannot be achieved by a good programmer.

Some frameworks take a complete ground-up redesign from one version to another, rendering prior knowledge completely useless, or even dangerous. Interviewing or hiring on the basis of knowing Angular 3.0 or this or that is silly. You need to figure out if the person you’re hiring can adapt to new technology as it comes out.

I went on further to emphasize that a lot of front-end design is necessitated by having to bow down to Google’s presence, and that several technologies are currently incompatible with good SEO – SPA (single page applications) built on frameworks like Angular are terrible for SEO, and not a good candidate for building out sites that benefit hugely by having their catalogue pages indexable for customers searching for products.

I went on to say that a single page product view is enhanced by bringing in other critical customer-facing information, such as in-stock information through better investment in backend and web service systems and established means such as web service and AJAX calls to bring information to the user; and that the latest UI frameworks, while fun, don’t replace the need to deliver these fundamental features, when the goal is increasing conversions.

The feedback after the meeting: I did not know enough about the latest technologies – thanks for showing up, but we’re passing on you. While somewhat miffed, I was actually relieved, because that was not the kind of organization I would have liked to work with if that was the deciding factor.

Lessons to impart:

1. Do not have your developers push a “shiny is better” mentality onto your hiring decisions. Sure, always keep abreast of the latest technology and see how it can apply to your business, or to the efficiencies on your dev team.

Remember that we’re solving problems, not having fun with one pet framework or another. A good, decoupled architecture will allow usage of different frameworks or technologies to solve problems as needed irrespective of technology – this is Amazon’s approach.

But do not forget to keep pushing the fundamentals – page speed, functionality, SEO-friendliness, user experience. Not one of these elements would have been improved by plugging in the latest JQuery/Angular/ReactJS/Polymer/Web Component framework. What is needed in this case was a roll-up-your-sleeves focus on reducing some of the code bloat on these pages. These frameworks may speed up development (great for programmers, probably product owners and stakeholders), but have the downside of slowing down responsiveness for the client.

Somewhere an architectural decision went wrong with this company’s site and needs to be solved immediately.

2. There is a fundamental problem in current interview processes. I’m sure some good candidates will drop out of a process that relies upon a scorecard of technologies. Fewer but harder questions need to be asked, deep-dives into specific areas such as architecture, or more self-awareness and reflection needs to exist in the minds of the interviewers. An interview cannot necessarily be factored down into a bingo scorecard of technologies. Some testing of ability should be there as a minor formality.

The prospective candidate should talk to the team to assess the environment, the challenges, and exhibit some leadership or analytical skills.

Interviewing well is a skill — not only for the candidate, but for the prospective employer as well.

I would have, for example, been happy to whiteboard a few things, understand the situation, maybe outline a potential plan, just given a few specific details on challenges, or heck, a scenario.

This is where you can start gauging someone’s ability to think and problem solve, and get a glimpse of how they would be to work with.

I always itch to be in a room with a whiteboard and pen and to want to jump up and start drawing stuff.

3. Is it appropriate for staff to interview their future manager? Does a sports team interview their future coach? I don’t think so. I think it is a very big mistake contained in a cosy, touchy-feely, inclusive wrapper.

Will staff be amenable to a new manager who has increased oversight when they have been happy with a lax environment? Is there a particular management style that you require from the manager that the staff do not understand? Can the candidate ask frank questions about existing staff issues and things that he/she will be required to fix? The whole issue is fraught with complications.

Did my comments on adhering to fundamentals and being cautious about adopting new technology not resonate with those that are keen to be using the latest, but show a considerable blind spot with regards to the fundamentals of good UX (as proven by the 3rd party statistics)?

4. If you’re a non-technical boss, how do you interview a technical person?  I raise this question as this was probably the rationale for including the team members.

Naturally, I addressed the working style with the future boss, but I sensed a distinct deferment on the boss’s part to the technical folks to conduct the interview. There was very little “managerial” level talk.

I feel a manager in this situation should try to assess in the candidate the ability to keep up with technology and to keep an open mind on adoption, to act as a bridge and enabler between the various departments (marketing, development, operations), and to get a sense of how he/she will manage his subordinates, a sense of communications ability and political tact.

5. Technology moves on. Knowledge becomes outdated in mere months. Leave a manager to trust the subordinates who are in the trenches to play with new stuff and to recommend stuff that is worthy of consideration, and to know what sort of effort would be involved in doing so. Make sure the manager can create this environment. It’s great if the manager can also be somewhat hands-on, but the developers are ultimately the ones who will have to do the implementation anyway, so they need to be the ones with a large amount of input in this.

Regardless of the outcome, it was a very, very instructive process. I wish them all the best of luck, of course, but, boy, I really wish they had done a better job of the interview. Those nasty page load times indicate that lots of work needs to be done, and quickly.

Canon Flash Notes

The Canon flash system has some interesting quirks (or features) that may trip those coming from other systems, especially Nikon.

The biggest confusion is how the camera P and Av modes handle the flash exposure differently and this is the primary intention of this post.

Flash in Program Mode

The P (Program) mode flash behaviour is set up to be like a point and shoot mode; i.e. fire the flash to illuminate the scene properly no matter what happens and deliver decent, non-blurry results.

It will select a balanced fill-flash mode if the scene is fairly bright (13EV and higher) and it will go into normal flash mode if the scene is dim (10EV and lower), with a blend of both between 10 and 13EV. Naturally, the result of these will be very different – the first method will expose the subject with the background lit fairly well, while the latter will favour the subject exposed properly, but against a darker background — this is the standard direct flash look.

The camera will set a minimum shutter speed of 1/60 up the max sync speed in P mode, hence it should freeze most action fine. If that isn’t sufficient, then you need to use a different mode.

Trouble with Flash in Aperture Priority

That brings us to camera Av (aperture priority) mode shooting. Canon’s default behaviour in Av mode is to be in a fill-flash mode in all lighting situations, which can cause the shutter speed in low light situations to drag out to long durations (up to 30 seconds), rendering people photography in low light conditions useless. The camera is in effect exposing just for the available light with no consideration for the supplemental light from the flash.

This is somewhat troublesome default behaviour, at least for me, as I’m normally shooting people in Av mode and need at least 1/60 or faster to freeze movement. And it can certainly catch people that are not expecting this behaviour, including myself the first few times I used flash.

I can see the merits of both approaches, and illustrates the complexities involved in flash photography and making a design decision. Nikon, on the other hand, forces 1/60 for aperture priority mode, and bundles the options for enable longer shutter speeds to a flash setting: Slow sync or Rear Curtain mode.

Luckily, there are two ways on Canon to bring up the sync speed to that critical 1/60s level or faster and still be in control of depth of field via aperture:

Solution 1: Set Flash sync speed in Av Mode Option

The first solution is to force the camera to only select a shutter speed between 1/60 and the max sync speed (1/200 or 1/250 typically). This option on the 1DxII and 5DS R is under the ‘External Speedlite control’ menu option under the camera settings tab. There is a menu option called “Flash sync. speed in Av mode” where there are three possibilities: “Auto”, “1/250-1/60sec. auto”, and “1/250 sec.(fixed)” [the maximum sync will be 1/200 on the 5D series bodies].

The default setting of “Auto” would be the equivalent of enabling slow sync mode and the long shutter durations. Therefore select either of the two non-Auto options to lock the sync speed to a more hand-holdable or subject movement friendly range.

Solution 2: Manual Exposure

The other solution is to work in manual exposure mode coupled with the flash in an automatic exposure mode (Ext.A, Ext.M, or E-TTL on the 600EX). I personally prefer this way of working.

The camera manual settings will determine the amount of ambient light contribution to the image and action-stopping potential. The flash settings will determine the amount of power output by the flash. Both Ext modes on the 600EX use the sensor on the front of the flash (a.k.a. the external flash sensor in “Ext”) to measure the scene while the E-TTL mode uses the full features of Canon’s E-TTL / E-TTL II system.

For wedding or event work, I will normally work in manual camera + ETTL on the flash for changing situations. I’ll typically dial in a suitable shutter speed, usually 1/125 or faster, and adjust the aperture to set how much ambient light I want, and let the flash do the rest.

For controlled studio situations, then manual camera + manual flash works for full control and consistency from shot to shot.

Tip: Working with Auto ISO

Auto ISO can confound your best efforts to balance ambient and fill, so I find it best just to turn it off when using flash. In fact, for flash, you may as well go full manual mode for exposure and ISO.

This was the case when I was shooting Nikon – Auto ISO would float the ISO all over the place with flash and nothing really seemed to look right unless I turned Auto ISO off on the Nikon. The reason is the camera doesn’t know what it should do – should it meter and set ISO to get a proper exposure for the scene no matter how dim, or should the flash be the primary light source? Note that this behaviour is also different across Nikon cameras – some will drop to the lowest ISO with flash attached, some will go up to the highest. So again, it’s probably good advice to go manual ISO on Nikon unless you know what your camera’s going to do. Picking an intermediate ISO like 400 will give you good results – not noisy, and you get a little more ambient light than going with the camera base ISO (usually 100).

The good news with Canon is that the Canon bodies I use will fix ISO at 400 when a flash is installed and turned on with Auto ISO enabled. This is a handy feature that saves you remembering to disable Auto ISO when using flash, and you can still override ISO manually if you want a specific look. I am happy to push the ISO up to 1600 or more to gain more ambient light.

Bottom Line

Of course, If you truly want pro results, I feel you’re better off shooting manual at least on the camera, and of course getting the flash off-camera!

Solved: Canon 600EX-RT flash not turning on

I’ve had several situation where the low battery warning symbol on my Canon Speedlite 600EX-RT shows when I turn on the flash, even though the batteries are fully charged. The flash refuses to turn on despite trying to Clear settings, removing and installing fresh batteries, etc.  This has annoyingly happened on a few shoots.

I discovered by accident that this was due to my leaving the SCH-E1 clip-on colour filter holder on the front when I was turning on the unit.

I suspect this happens when:

  1. Colour filter is installed on flash
  2. Flash auto shuts-off (or left off a long time)
  3. Attempt to turn on flash with colour filter still installed

Simply removing the SCH-E1 colour filter from the flash and turning the flash on seems to do the trick in all cases. After that, I can turn off the unit with the SCH-E1 installed and turn it back on without any problems.

Since this happened to two units that had been used in the same session with the filter installed and left to auto shut-off, I am suspicious that it may be related to the auto shut-off or else the length of time the units were left in the off state.

Here’s the Canon advisory from a couple of years back that I found describing the issue:

[Canon Canada link] Service Notice: Speedlite 600EX-RT: Caution When Using Colour Filter Holder SCH-E1

 

Solved: iPhone 5s unable to activate touch ID on this iPhone error

About a month ago I encountered the following error on my iPhone 5S:

Unable to activate Touch ID on this iPhone

And sure enough, the Touch ID to log in was not working. When I logged in using my passcode, I went into the Touch ID settings in the Settings app, and saw that Touch ID was disabled. When I enabled it, it briefly popped up the setup screen to enrol fingerprints but then there was a further error window. After dismissing this window, I saw that Touch ID was  disabled again.

The other symptom I noticed on this was that it seemed to occur after I’d charged the phone and it was slightly warm. Once or twice I was able to get Touch ID working again after I powered off the phone and started it up. There was no real consistency in this.

The Investigation

Thinking it may be a potential thermal expansion issue, I opened up the phone. After lifting up the front display glass/LCD assembly, I noticed that the Touch ID / home button flex retainer bracket/clip was slightly misaligned but still in place. The retainer is a tiny metal clip that holds the flex cable from the Touch ID sensor/home button assembly.

I didn’t even think anything of it, since the home button worked, but I started getting a little suspicious. Perhaps the heat of the charging caused some expansion, causing just enough expansion to cause contacts to be broken, and resulting in this intermittent behaviour. And why was the clip slightly out of place? Maybe from dropping the phone, who knows…

I popped the clip in with a satisfying click and fired up the phone, hoping for the best. Sure enough, problem solved. It has been fine for a month now.

How to Fix

It’s an easy fix with the right tools (thanks, iFixit). There are two screws next to the Lightning connector on the bottom of the phone that have to be removed and the front glass assembly will lift off. The main trick is just being careful lifting up the front glass carefully from the bottom.

It’s a tight and frustrating to separate the two parts, and lifting the glass too far (about 2″) may stretch and damage the Touch ID flex.

No other parts need to be removed to fix this, so it’s easy.

Instructions on home button removal on iFixit are here:

https://www.ifixit.com/Guide/iPhone+5s+Home+Button+Replacement/24983

You basically go to step 9, ensure the metal bracket is securely in place, then put it all back together.

 

Single but Coupled

I read with interest Isabelle Tessier’s article entitled I Want To Be Single – But With You  in HuffPost recently.

Essentially, it’s an expression of desire of people who don’t want to lose themselves the moment they get into a relationship, and to approach them with the mindset of still being one’s true self rather than becoming complete only with a partner.

She wants something that is the best of both single and coupled worlds. To have all the comforts of a relationship, but to excise the negative, awkward parts, I think is attainable with the model she’s suggesting.

She doesn’t eschew relationships, and nor do I, just that a special relationship that she describes is one that is absolutely realistic and worth seeking out, despite online criticisms that it is too idealistic.

My  beliefs for long term happiness – core, personality, freedoms:

Strong Core

A joint set of beliefs that are near-immutable, or at least change slowly over time, but should always be compatible. These are things most couples would argue over:

  • Love (expression of affections, mutual support – what kind and how much – always holding hands, or is there just an occasional need to feel connected?)
  • Money attitudes (separate accounts vs. joint, investment and spending strategies)
  • Values (respect, attitude towards societal values, rights, culture, conservatism, liberalism, etc.)
  • Religion (either both are, or one is supportive of the other)

Cores should be as lightweight as possible, but strong. The Core should provide a basis of predicting how one’s partner would behave under different circumstances and should offer few surprises.

Compatible Personality Traits

Beyond core beliefs, we get into the complex land of personalities. I won’t dive into detail into personality types or models like Myers-Briggs or Big 5, but I believe there is benefit in understanding personality types.

Dealing with this in terms of not one type being better than another, but how they interact within a relationship, is the key.

The personality types between two people can be viewed as being on a spectrum between completely identical through complete mirror images, with everything in between.

At one end of the spectrum, identical or extremely similar personality types can make it easier to get along at different levels, but may not provide a longer-term challenge or personal growth potential, so relationships between similar personalities may require external factors to create the stimulation required to last. An alternative is for one of the partners to become the lead; i.e. the more extroverted partner in a pair of extroverts may become more extroverted in order to create that idealized balance.

At the other end, totally incompatible types could cause occasional friction, but could provide ways for the individual couple members to achieve great personal growth if they are open to discussing them.

Compatible non-matching personality traits

Some non-matching personality traits can be viewed as a plus, where both partners

  • Spontaneous / Laid back – One’s laid back and the other isn’t – the “A” type personality could learn to relax a little; the other could learn to get a little more organized
  • Introvert / extrovert – a more extroverted person could pry open the world a little for the introvert
  • Risk-taker / risk-averse – again, opening worlds a little for one, perhaps encouraging taking a pause to consider options for the risk taker
  • Observing / Intuiting – taking the world as it is versus dreaming about how it could be. Not a bad combination either.

This is a lot like “marry your opposite” sort of advice – basically that may be fine of opposite traits can balance, but there may be a limit to how many of these personality traits one may be able to put up with before two people declare themselves out of balance and incompatible.

One partner’s group of traits may come off as more overbearing, superior, or forceful than the other, or unhealthy dependencies or opportunities for strong personalities to butt heads often may arise.

In fact, having a complete opposite in terms of Myers-Briggs types is in one theory the worst and least compatible option for anyone, leading to conflicts where partners know how to inflict maximum pain on each other’s weak spots because there are no shared strengths.

Also, the “opposite” argument does not apply to the Core, which is where you want to “marry your equal”.

It’s not even like the clichéd “you complete me”. I will complete myself, thank you very much. But I’ll definitely appreciate your help.

Incompatible Non-matching personality Traits

While any two well-sorted individuals can work things out, there are some trait matchups that can be tougher.

Thinkers vs. Feelers:  The thinker in a relationship is often a facts-based, less emotionally driven person, and able to take constructive criticism. This can conflict easily with a feeling partner who is more sensitive to conflict and criticism. The Feeler may require more assurances and visible appreciation, and would need to communicate this properly to their partner.

Two thinkers together may have a more harmonious relationship, but then they may have this mutual blind spot with regards to interacting with other Feeling people.

Freedom

This would be the freedom to pursue one’s goals for growth, to do whatever you want, when you want, to be in the company of whomever you want. These are conflated with single person’s freedoms only because they imply a single person has fewer responsibilities than someone in a relationship, which is false, but makes for quick understanding of the point that’s being made about being single, but in a couple.

It’s about being able to do things without being controlled by others, or to feel like you have to follow certain rules. The way to do that is either through singlehood, or by finding the right kind of partner who thinks the same way.

Article, Redux

Here is my man’s take on Tessier’s article with a more personal spin on it:

I want to be single with you.

I want you to go have drinks with your friends without me. I would probably feel like a third wheel anyway, but we are both more interesting to each other when we are not always joined at the hip. I want you to be completely relaxed, not worry about whether or not someone else is having fun, and enjoy every moment. Of course I want you to come home safely and I’ll be there to drive you all home if you need it.

I want you to tell me about the guy who chatted and flirted with you. I know that makes you happy, and it makes you more desirable to me. Just as you would point out an attractive woman to me that I may not have noticed. We feel happy and secure in being able to do that.

I want to spend time together, but apart mentally. We can be in the same room, you on your book, me on my iPad, lost in our own worlds, not needing to say anything, but content that this is OK and we still have an unspoken, unbreakable connection.

When we are at parties together, we circulate among different groups of people, covering more ground to talk about later. Once in a while you’ll glance over and catch my eye and with a glint in your eye or a quick smile, we touch base over this remote connection, “Hey, I love you, just wanted to let you know that”. Or, if we have a chance, I may just touch you gently on your arm in passing. And that’s all we need. I don’t need to hover around you unless there’s a good conversation happening or you need me to come rescue you from a boring one.

Because we’re both introverts, I know your energy level dealing with social situations is not great, and neither is mine, so we know that we can subtly signal each other to leave the party. When we get home, we may quietly retreat to our own physical or mind space, and that’s OK, because that’s how we recharge after these situations.

I want to plan, but not too much. To be in Paris and have a place to stay, but not to have every day planned like a military operation. Only as much structure as needed with freedom to roam – that’s the nature of our relationship.

I want you to have your freedom. To go far away on your own for weeks to go to places or things you love. I struggle sometimes because you’ll be away from me, of course, but I know that you would encourage the same of me and be wholly supportive. I want to be that ideal person, and the more I do it, the closer I become to being him.

I want you to be strong. I will help you become stronger. I want to take away your self-doubts, your insecurities, and all the things that keep you from fulfilling your potential. I need you do the same for me; it is always easier to help someone else than yourself. There will be times you will be strong and I will be weak, and vice-versa.

I want to help you grow in the ways that I am stronger in, just as you are strong in ways that I am not. I will encourage, cajole, nag, and do things I feel will be good for you because I love you and I know you, deep down, want to do them and can do them, except for the fears I am helping you break down.

I want you to have your own job or passions. I do not want you to ever look back with regret on a road not taken, and if I have to give you up so you can pursue your passions, I would be willing to do so. I want to stoke that competitive fire and passion, not extinguish it, because I see in your eyes how excited you are, and how alive you are, when you have a cause you care about.

I want you to challenge me mentally. I want to hear your opinions, and I want them sometimes to be different from mine, just in case mine are wrong, and I want to keep my mind open to all things in the universe.

I want you to be honest with me as I will be with you. Brutal honesty is my only way. I cannot live a lie, and I cannot tell them. Even white lies I struggle with. I would be hard-pressed to be a political surrogate. As David Foster Wallace wrote, “the truth will set you free. But not until it’s finished with you.” Sugar-coating is definitely not my best skill and I know it can hurt.

You get indignant over the words and actions of people, and rightly so. You will be treated badly by others. As a man, I recognize I have blinders on and may not always notice the sexist world we live in, but I am trying, and my eyes are opening. I will always try to see things from your perspective, and I will always unconditionally defend you and back you.

I want to have fun and be silly with you. I know you’ll be aghast at my dance “moves” or jokes, but I am trying to impress you as well as lower my self-censoring and self-deprecating behaviour. I want to make you laugh, because I want you to be happy and because that in turn makes me happy.

I will give you space. You may need time and space to recharge or gather your thoughts just like I do. Even though it may be agonizing silence in the meantime, I acknowledge you may need to do this as a defensive mechanism even though you know I am always here for you. I only ask the same of you. I am never far, just involved in my thoughts and I appreciate your efforts to check in on me.

I don’t need lavish gifts or celebrations of the “Hallmark” holidays. A random thoughtful favourite chocolate bar is what I need, or something small I may have mentioned in passing, which says you were listening to me. Just an occasional reminder that we have a special connection is all I need to thrive. But I want to celebrate the meaningful days of our life – birthdays, Christmas, anniversaries, graduations.

I want to have things we do together. While it is important to grow individually and be “single but together”, we don’t lose sight that there are benefits to sharing and having fun together. Maybe we’ll run and workout together, go on a kayaking expedition, take up a cooking class, or simply cuddle up while binge watching Netflix.

We will find each other.

Javascript or JQuery – which first?

I’ve been asked this quite a number of times recently – should a web developer learn JQuery or Javascript first?  And presumably pick up the other later.

This question would likely apply to other Javascript libraries or frameworks (e.g. Bootstrap).

In other words, does starting with the fun and useful application of Javascript (JQuery) and seeing web pages come to life help to ease one into the drudgery of learning to program?

I have to admit that I’m a programmer first, thus I would fall into the Javascript first camp somewhat by default. My immediate reaction would therefore have been, “Javascript first, duh.” But I wanted to think it over.

My tendency is to learn the hard, foundational stuff first, then move on to the easier stuff later. It’s a bit like learning to do long division on paper, then moving on to use a calculator.

On the flip side, I admit using a ton of JQuery plug-ins way before I learned to use JQuery itself or even got deep into Javascript. This was driven by the desire to find the absolute best image slider for my ASP.NET website without having to do any coding. So I know there will be people that can quite cheerily create a really nice image slider on a webpage using a few lines of HTML without knowing any programming whatsoever, and it’s fantastic that they can do this, and often for free or very little money.

However, if you want to go beyond simple plug-ins on a page, you rapidly run into needing Javascript knowledge:

  • Any really useful functionality will still be written in Javascript; you need to declare variables, use loops and other constructs
  • JQuery IS Javascript, it’s not an either/or, it just is a simplification of what you can do in Javascript. It lets you code less to do the same thing, which is the hallmark of a good framework
  • Some of JQuery’s syntax of passing functions as parameters and nesting of functions within functions or objects can look very intimidating visually (and tough to unravel mentally) compared to starting with Javascript first
  • Knowledge of things like events, event listeners, the DOM, etc. are still required in order for a page to do something useful
  • Understanding how something works at a basic level I feel is crucial so that you know how a framework simplifies it for you (the long division argument above) – for example, knowing that a JQuery function might be implemented as 3-4 lines of Javascript code takes some of the mystery out of JQuery
  • There are many other frameworks based on Javascript, so learning the root Javascript language will help you understand how these frameworks work
  • Debugging is facilitated by knowing the underlying Javascript code – sometimes an error will occur in the JQuery code that you’ll have to figure out why.

So, for budding web designers, I’m firmly in the bottom-up “learn some programming basics first” camp, which can be done conveniently with Javascript, and then learn the simplifications later. I was also supported in this view by hearing responses to my question, “Did you actually know what you were typing, or were you just guessing and fiddling with your JQuery code until you got it to work?”

There can be a dividing line – learn programming basics, then move to DOM events and listeners, manipulating DOM elements, and once you’re comfortable writing a couple of simple interactive pages, dive into JQuery and see how those same things can be simplified substantially. You’ll understand those magic incantations better.

The only real exception is if you are going to strictly use the framework to do some of the fun UI plug-in stuff – if you can figure out how to tweak your HTML to add a JQuery plug-in, go right ahead and good luck!