Wednesday, 11 October 2023

Can we just autofill city and state? Please!

Coming from a country that is not the US where zip/postal codes are hyper specific, it always drives me nuts when you are filling in a form in the US that is like:

City

State

Zip

It's patently obvious and massively infuriating that anyone from a country such as the UK that this could be trivially autopopulated if you asked for the zip first. In the UK you usually are asked to enter the postcode and then the first line is the only one you have to complete.

As with many things in the US, why is this so hard?

Like literally, mash in the 10011 -> New York City, New York. Done. It would also improve the quality of the data that the forms collect.

So in an idle 10 minutes I decided to have a go at fixing the problem with ChatGpt.



Looks pretty sensible to me. Does it work? Sure does.

One small snag is that there are zip codes that cross state lines. That's a minor annoyance and one of the justifications used to excuse this lack of functionality in form filling websites. OK so I tested it with a zip that is ambiguous:

[nix-shell:~]$ node ~/state/state.js
State: Arizona
City: Teec Nos Pos

This seems reasonable. If you are one of the poor suckers who lives in an ambiguous zip then I am sorry, that is the price you have to pay. At the moment everyone is paying the price to fill in City and State!



Ok so let's ship it.


// Define a function to resolve ZIP code to state and city
function resolveZipCode(zipCode, callback) {
  // Define the API endpoint for Zippopotam
  const apiUrl = `https://api.zippopotam.us/us/${zipCode}`;

  // Make an HTTP request to the API
  fetch(apiUrl)
    .then(response => {
      if (response.status === 200) {
        return response.json();
      } else {
        throw new Error('ZIP code not found');
      }
    })
    .then(data => {
      const state = data.places[0].state;
      const city = data.places[0]['place name'];
      callback(null, { state, city });
    })
    .catch(error => {
      callback(error, null);
    });
}

// Example usage
const zipCode = '86514'; // Replace with the ZIP code you want to resolve
resolveZipCode(zipCode, (error, result) => {
  if (error) {
    console.error('Error:', error);
  } else {
    console.log('State:', result.state);
    console.log('City:', result.city);
  }
});



Wednesday, 13 September 2023

deauthenticated due to inactivity (timer DEAUTH/REMOVE)

I have an r6260 running dd-wrt which my pixel 7 was having trouble connecting to. It would connect-ish and then say there was no internet and disconnect.
It would do this more aggressively on the 5g channel than the 2.4g channel, both didn't really work well though.

Reading the syslogs in dd-wrt in the status tab logs it would show:


deauthenticated due to inactivity (timer DEAUTH/REMOVE)
 
A miniscule bit of a Googling led me to this post which recommended a dissoc setting that allegedly was aggressively disconnecting the client after inactivity. Switching that didn't do anything seemingly.
Another post that I saw for IOT devices recommended simplify the wireless security settings. So I went into the wireless settings tab and changed my 5g network to only support WPA2-Personal (removing WPA3-Personal) and only supporting CCMP-128 algorithms.

Save settings, reboot and voila the connection is stable. Seems like a bug in android not being very stable in mixed WPA2/WPA3 networks? Other devices like my macbook work just fine.

Friday, 12 July 2019

Reading For Team Leads

Radical Candor: awesome way of thinking about what you do with your day and how you work with your people.
What Got You Here Won't Get You There: gives you a good perspective on the role
One Minute Manager: classic but not very useful.

Sunday, 9 June 2019

Strava GPX Format for Watts and Power

Strava documentation here is vague. The tags you need to set to extend the Garmin GPX format to allow Cadence and Power look like this:

      <Cadence>0</Cadence>
      <Extensions>
       <TPX xmlns="http://www.garmin.com/xmlschemas/ActivityExtension/v2">
        <Speed>2.5</Speed>
        <Watts>0</Watts>
       </TPX>

      ...

So to add the Watts to a Trackpoint you need to use the TPX tag and set the namespace to an extension and put the Watts in there.
 

Monday, 11 September 2017

Playing with Google Cloud Services

Late last night I wanted to build a simple but humorous website (the details of which shall remain veiled from you). The website simply needed to serve up a random image, i, (from a collection of N) and then serve a title that I had associated with said i. That is, show an image and a caption.

Being an engineer, I knew I simply must over-engineer this simple challenge. I also wanted to use it as an opportunity to learn a little about the Google Cloud Services products (Google's answer to Amazon Web Services).

I spent some time perusing the vast litany of products that Google Cloud Services provides; from storage, to compute, to SQL to container hosting to VM hosting; it's all there. I didn't see anything missing (yet).

My initial design looked something like the following (artwork courtesy of yours truly).
My Website 1.0
The general idea was that I would have some sort of Google Cloud Function that would house the business logic of my project. It would simply get a random number in a given range and then request an image with that number from Google Cloud Storage and return its url. I would house the captions in a database (in this initial design I chose Spanner since that seemed hip and cool and in the news but then I realised it was expensive so opted for postgres later). This initial design was missing where the html would actually be served from as we will find out later.

Google Cloud Storage was the most impressive thing so far. It was really easy to setup and get used to; it was easy to understand and striaghtforward to use.

I realised fairly quickly that Google Cloud Function was not appropriate for what I was doing. What I should be using was Google App Engine (known as GAE). This thing was built literally for hosting websites (mine was not static). I followed the initial hello world tutorial and realised it only needed a tiny bit of tweaking for me to use it for my website.
After about 2 hours I was serving some simple HTML from GAE (using a Go application) that would simply generate a random number in a given range and then serve the image with that name from my GCS. Simple.

Now I wanted to serve the captions for these images. Initially you could see that I wanted to put them in a database (Postgres because I don't like MySql). Postgres is still in beta on Google Cloud Services. Getting Postgres in a usable state was tremendously hard. I was able to create the tables through an interactive prompt launched from the GAE website but it was very difficult to get my GAE connected to the same instance - I spent 1 hour jerking around with certificates and keys to only get hangs. I could at some point connect interactively with psql from my GAE prompt but not reliably - not sure what was going on. There are tutorials on GAE for connecting to postgres from Java and Python (which seems to need a proxy!?) but nothing for Go (yet). So I was kinda stuck up a creek without a paddle.

So I just mashed the captions into the code and put out version 0.1.

The end design looking something like this:

The diagram is actually pretty inaccurate since the go code doesn't actually talk to GCS but it just generates the URL and the browser downloads it.

The whole process was pretty cool all in all. I was able to get up and running without spending a penny (1 year of $300 for free when you sign up woo) and jump around the different products easily. The integration between the Postgres/GAE stuff was terrible. It was really hard to work out how to get the auth setup. I also didn't take enough time to setup the interactive tools locally - my internet was spotty - and using the web based tmux console was very painful and slow. But it was fun to bash something out from my browser that hit GCS and used Go without having to download a megalith of tools that I would never look at again.

ICV?

Saturday, 25 March 2017

Chat Apps

This xkcd really struck a chord with me. Current chat apps on my phone are:

  • Slack
  • Allo
  • Hangout
  • Whatsapp
  • Facebook Messenger
  • SMS
Spoilt for choice...

Sunday, 15 January 2017

Magic List of Things to Consider if you're going Cycling?


  • Bike
  • Lock
  • Jersey
  • Shorts
  • Sunglasses
  • Helmet
  • Garmin
  • Garmin Cable
  • Water bottle
  • Inner tube
  • Puncture repair kit
  • pump
  • shoes
  • Multi tool
  • Spanner

Saturday, 29 October 2016

Why I am excited about the new macbook

I am not normally a super mac fanboy; it's true that I am typing this on a Macbook pro now but I did't buy it myself - it was provided for me. But I still love it and definitely would buy it as my next laptop.

Apple just released their latest line in the Macbook Pro series and I think it's really cool. Whenever you mention it your nearest (most likely, vim using) colleague will poo-poo it and complain that it has lost the escape key. However, in its place is something much more exciting. I really like the idea of the customizable screen at the top.

In the past most keyboards were fairly standard. There was the 99% of keyboards that were your standard qwerty (maybe with a few extra buttons for power or volume or media control) as well as was the gamer keyboards that used to have loads of custom buttons everywhere but no one ever took the time to properly hook those up to all their apps and doing so was tedious and error prone. Now applications will be able to provide great hardware shortcuts for all those common tasks using the screen at the top of the keyboard. It has been made accessible for the everyman.

Have you ever watched someone at an airline check in desk? Or watched someone use a trading terminal? They don't really look at the keyboard, they mash out keystrokes and shortcuts like it's an extension of their body. They don't interact with the computer as much as work with the computer. They work together to get the job done. This is how I see the button bar will be great for the Macbook. It will become second nature to zip through Photoshop or Chrome using that button bar along the top. You won't need to remember every changing or inconsistent keyboard combinations (RIP the backspace key in Chrome) but instead you'll naturally reach for the virtual key in the Macbook screen. You will work better with your Macbook and get every day tasks done that much faster. Maybe you'll have all your favourite internet shortcuts up there within a fingers reach, or maybe you'll be able to whizz through your photo albums after vacation without lifting your fingers for the mouse or keyboard. I know from my job that these special keys become second nature after a few goes of using them as they simply make everything faster and more natural.

I'm sure there will be some interesting apps that come out around everyday tasks that will become that little bit less mundane or tedious.

Having said all that, are we still in an age where the Caps lock key is still a thing? Really?

Do you collaborate or cooperate?

Some thought provoking reading on whether your organisation is working together in a collaborative mode or a cooperative mode. Never really thought about it like that before.

Tuesday, 16 August 2016

Why would you not differentiate member variables?

Another post from the llvm mailing list, this time on the topic of member variable naming conventions.

I remember hacking away on some llvm code and having a terrible time with this. It can also lead into dangerous ambiguities when you use local variables that actually hide member variables. The whole naming convention they use is insane. I wonder if they use any static analysis tools?

Thursday, 11 August 2016

Holacracy

Someone pointed me to this article on Holacracy which is an interesting approach to organisation. You effectively form 'circles' of people who are focused on an area and it is composed of diverse sets of people. You are on multiple circles at once and move around. Seems like an interesting idea but a little anarchic.

Tuesday, 9 August 2016

Internals of Firefox Threading

Interesting post on the internals of firefox's new multithreading 

Mega repo or microrepos? Llvm-dev take

There is an interesting discussion going on at the llvm-dev mailing list as to whether to split their massive svn repo into multiple smaller repositories with git.

http://lists.llvm.org/pipermail/llvm-dev/2016-July/103097.html

I have come across the problem so many time and the issue ultimately boils down to workflow: tools really don't support this. I want to build the modules individually and then sometimes for integration all together. If there is a dependency between repositories I sometimes need to express it.

Surely there is a better way.

Wednesday, 22 June 2016

Short Term Apartment Hunting in NY

I recently found myself searching for short term apartments in New York City. This was surprisingly difficult so I thought I would list some of the resources I found that met my constraints.

I wanted a furnished place for a maximum six months. I have no credit history (my first time here), no guarantor (I have no family here and wanted to avoid relying on friends). Finally, I wanted to be somewhere between the East Village and 60th Street in Manhattan or Williamsburg.

Without further ado, here are the websites that showed most promise:

  • https://www.homeaway.com/ - like Airbnb but longer term and thus slightly cheaper.
  • https://www.roomorama.com/ - same as above.
  • http://streeteasy.com/ - dedicated to NYC but very hit and miss. Involves contacting realtors through the 'Contact' button which invariably leads to tedious email chains trying to arrange viewings etc. There are some 'No Fee' listings that are from directly from building management companies but these are few and far between.  
If you are really scraping the barrel, there is zillow and airbnb but both of these seemed either to have poor filtering (couldn't find furnished stuff on zillow) or expensive.
None of the usual longer term websites like zillow and streeteasy allow you to filter down to short term listings only with much reliability which makes life hard. Most email exchanges were 'Is this available for a six month lease?' to which you get 'No' or 'Yes, starting 2 months from now'. I needed to move in within a month.

Finally there is also http://www.nycityapartment.com/ which seemed to have promising stuff and specialised on short term leases. Good if you are really at your last tether. The prices were good and the realtor was nice but the places I looked at weren't particularly appealing - perhaps you could make them your home with a little TLC.

Monday, 16 May 2016

DIY Refit Hansgrohe Plug

One of the worst errors any proud Hansgrohe owner (a 'groher) can make is to attempt to dismantle their sink plug.
http://www.bathroomspareparts.co.uk/ekmps/shops/ebaths2/images/hansgrohe-pop-up-plug-for-basin-bidet-96026000-15890-p.jpg
Fig 1.0 'grohe mechanism







Per fig 1.0, the plug mechanism is fairly involved. The bottom-most ring (low-ring) seen in fig 1.0 is to be inserted on a protruding 'prong' that is attached to a long arm for raising and lowering the plug to block the plug hole.

If the low-ring is disconnected from the prong then you're in trouble as you have to reconnect it to get a functioning sink plug.
If you have managed to drop any components for this process down the sink (by attempting to unscrew the silver top of the plug, for example), then you will need to buy something like a PUP pickup claw.

Once you have retrieved all the components that are part of the mechanism, you can begin to reassemble using our custom procedure below.

Components

Fig 2.0 Components laid out
Figure 2.0 shows the salient components for this procedure. From left to right: low-ring spike, mid-section and top-lid. Along the bottom sits a common kitchen straw which we'll use later to assemble the plug.

Step 1

If you have small hands you should be able to reattach the low-ring to the spike protruding from the sink inside the plug-hole. To do this, you need to disassemble everything as shown in Fig 2.0. Attaching the low-ring can be a risky operation so you might want to loop a small piece of thread through the low-ring so that you can hold onto it and attempt to reattach it without fear of losing it into the sink and having to retrieve it (as explained earlier).

Step 2

Now you want to reattach the mid-section to the low-ring spike without dropping the low-ring spike down the sink and ruining your hard work. However, you can't really hold onto the low-ring spike while it is attached to the prong as then you haven't got space to put the mid-section on. This is where the drinking straw comes in.
Fig 3.0 Straw usage



Place the drinking straw on top of the low-ring spike (hopefully your drinking straw is the same diameter as mine which was helpfully the right width to fit on top of the spike).

Step 3 

Using the straw you can maintain the position of the spike while lowering the mid-section down the straw. Fig 3.0 attempts to demonstrate this.
Slide the mid-section all the way down to the bottom of the straw and onto the spike. You should then be able to remove the straw and the width of the mid-section will hold the construction in place.

Step 4

Attach the top-section to the mid-section by placing it on top. Simply rotate the top-section to tighten the whole construction.

And there you have it. Now sit back and admire the rare earthly delight that is a fully-functioning 'grohe!



Saturday, 3 May 2014

Skype Humming on Ubuntu

When you log into skype sometimes it hums after it plays sounds on Ubuntu Linux, most likely because it was written by Microsoft.

Anyway, this can often be solved by running skype as:

PULSE_LATENCY_MSEC=60 skype %U


which does something magic to PulseAudio.

Saturday, 14 September 2013

Getting Started with Bloomberg Standard Library

A quick guide to getting started with the Bloomberg standard library from their github repo:

Let's say for now I'm installing to ~/bsl on my linux machine with GNUMake:

Linux 3.11.0+ x86_64 x86_64 x86_64 GNU/Linux

For other flavours, see the official wiki.
  • cd ~/
  • git clone https://github.com/bloomberg/bsl.wiki.git
  • cd bsl
  • python tools/bsl_gyp.py
  • cd build
  • make all
  • ...have a coffee..
 Done!

Now you want to write your first program using bsl. Simple:

  • cd ~/test
  • Write a test program:
#include <bsl_vector.h>

int main()
{
    // A simple program illustrating bsl
    bsl::vector<int> v;
    v.push_back(4);
    return 0;
}
  • compile: gcc main.cpp -I~/bsl/build/include -L~/bsl/build/Release/lib -lbsl -lstdc++

Monday, 26 August 2013

Breaking Change to Realtek r8168 drivers

If you have ever installed the linux kernel manually you might have encountered an issue with the r8168 drivers for your ethernet port. Specifically my
3:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168 PCI Express Gigabit Ethernet controller (rev 06)

I found that I have to download and install them directly from realtek since - perhaps - my .config wasn't correct. I downloaded version r8168-8.036.00.

Nevertheless, when I tried to install the drivers for 3.11.0-rc7 I found that they didn't compile:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
r8168-8.036.00/src/r8168_n.c: In function ‘rtl8168_rx_vlan_skb’:
r8168-8.036.00/src/r8168_n.c:2237:9: error: too few arguments to function ‘__vlan_hwaccel_put_tag’
In file included from r8168-8.036.00/src/r8168_n.c:46:0:
include/linux/if_vlan.h:236:31: note: declared here
r8168-8.036.00/src/r8168_n.c: In function ‘rtl8168_hw_set_features’:
8168-8.036.00/src/r8168_n.c:2298:25: error: ‘NETIF_F_HW_VLAN_RX’ undeclared (first use in this function)
r8168-8.036.00/src/r8168_n.c:2298:25: note: each undeclared identifier is reported only once for each function it appears in
r8168-8.036.00/src/r8168_n.c: In function ‘rtl8168_init_one’:
r8168-8.036.00/src/r8168_n.c:16198:26: error: ‘NETIF_F_HW_VLAN_TX’ undeclared (first use in this function)
r8168-8.036.00/src/r8168_n.c:16198:47: error: ‘NETIF_F_HW_VLAN_RX’ undeclared (first use in this function)
make[3]: *** [r8168-8.036.00/src/r8168_n.o] Error 1

So it appears there are 2 issues.

  1. The first is that the number of arugments for __vlan_hwaccel_put_tag is wrong. This appears to be a breaking change to if_vlan.h in the kernel introduced here. So AFAIK the quick fix is just to add an extra parameter indicating the protocol. Here, I think you put  htons(ETH_P_8021Q) but someone much wiser can correct me there. That's what I put and it seemed to work for me.
  2. The second issue is that a #define has been renamed. The NETIF_F_HW_VLAN_{R,T}X defines have been changed to NETIF_F_HW_VLAN_CTAG_{R,T}X in this change.
The patch can be found here.

This isn't the most scalable of fixes since it's not backwards compatible so I guess the vendor will have to apply to kung-foo using the KERNEL_VERSION macro. I didn't bother to look at exactly which kernel version this was broken in.

HTH.

Can we just autofill city and state? Please!

Coming from a country that is not the US where zip/postal codes are hyper specific, it always drives me nuts when you are filling in a form ...