Posts on this site are never sponsored.

Regular expression to extract cookie value from Apache access logs

I was recently troubleshooting a problem where I needed to extract cookie values and IP addresses from Apache access logs. In short, cookies were being shared across sessions instead of being unique to each session. The Apache log entries looked something like this: - [29/Oct/2015:23:59:46 -0400] "GET /user/profile HTTP/1.1" 503 17839 "" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36" "SESSID=59n42qa556o2k08ekmbmlhgdg1; othercookie=(direct)" -

Using this command, I could extract the cookie values for SESSID and save them to a file:

grep -ir 'GET \/user\/profile HTTP\/1.1" 503' /web/logs/access_log | sed -r 's/.*SESSID\=(.*)[;|"].*/\1/' > 503_cookies.txt

The sed regular expression wasn’t stopping the match at the semi-colon or quote, however. Instead of using (.*) in the capture for any character, I had to use [^;"] for “not semi-colon or quote” even though the match on the same characters happens outside of the parentheses:

grep -ir 'GET \/user\/profile HTTP\/1.1" 503' /web/logs/access_log | sed -r 's/.*SESSID\=([^;"]*)[;|"].*/\1/' > 503_cookies.txt

Further work was needed to grab the IP addresses for the matches and save them to another file. Here I didn’t need a regular expression, as I could just grab the first column with awk:

grep -ir 'GET \/user\/profile HTTP\/1.1" 503' /web/logs/access_log | awk '{print $1}' > 503_ips.txt

Then I could use the paste command to put the relevant IP address + cookie value entries on the same lines in the report and collapse all duplicate entries:

paste 503_ips.txt 503_cookies.txt | sort | uniq

Each line then looked something like this: 59n42qa556o2k08ekmbmlhgdg1

Mugo Web office in New Westminster

In early 2015, my company decided to trade in our downtown Vancouver office for a new Mugo HQ in downtown New Westminster (30 minutes outside of Vancouver)! Although the main motivation behind the move was to have a more central location relative to Mugonites’ homes, we’ve been very pleased with the surrounding area and amenities.

When we were first surveying available office locations in downtown New Westminster, we met up with David Sarraf, who walked us up and down Columbia Street, speaking glowingly about the city’s revitalization and showing us the many buildings that he owns and has refurbished. When he showed us one of his offices with sweeping river views, we were sold.

Mugo's New Westminster office view

We soon met our office neighbours Techno Monkey Media, who gave us a warm welcome to the building, introduced us to a few others in the business community, and helped us with some unexpected internet connectivity issues.

We then got acquainted with the Downtown New Westminster Business Improvement Association, which is a close-knit business community. We’ve learned a lot about the many new businesses that have come to New Westminster recently, and have been kept up-to-date on the various challenges, successes, and developments in the downtown area.

And finally, we got introduced to some of the people from City Hall, who are a responsive and hard-working bunch. Whether the topic is the recently opened New Westminster Pier Park, hosting an event at the Anvil Centre, or the upcoming city-owned fibre optic network BridgeNet, people like Blair Fryer are hard at work improving the city and eager to talk collaboratively with businesses and residents about various initiatives. Blair also has all the good tips about stores and restaurants at River Market and where to get the best turkey sandwich.

To top it all off, after almost 7 years of remote work, we finally met some of the doctors from one of our first clients: Royal Columbian Hospital in New Westminster. We’ve worked with them on a number of web projects, including the recent emergency department shift evaluation system.

We’ve had a great year in New Westminster and look forward to many more!

Baby passport photos in New Westminster

There are plenty of places that take passport photos in New Westminster, but finding somewhere to take baby / newborn (that is, less than 6 months old) passport photos is tricky. I visited London Drugs and BCAA in Uptown New Westminster, but neither of them would do it. London Drugs said that the baby needs to be able to hold their own head up. I didn’t try Shoppers Drug Mart, but my guess is that they won’t do it either. I was referred to Walmart, but beware that the one at Royal City Centre does not do passport photos at all.

I had success at the Walmart at Queensborough Landing (Boyd Street). At $25 + tax, it definitely wasn’t cheap. However, the photographer knew what she was doing and was able to get the baby’s attention for the photo even when the baby was crying. Walmart guarantees that the picture will be valid, in that if the passport office rejects the pictures, Walmart will retake them for free.

Before you go, make sure the baby is wearing dark clothing — white clothes on a white background is not allowed. If the baby is wearing a sleeper, make sure it’s one with buttons, because you have to prop the baby up with your hands underneath their clothes without your hands appearing in the picture. And lastly, be prepared to wait at the store in case there are other photo appointments ahead of you. Walmart won’t take appointments for passport photos, since they should technically be very quick once it’s your turn.

Uber for Business review: simple small business transportation

Uber, Lyft, Gett, and other ridesharing services can be more attractive than taxis for many reasons: they often cost less, are more convenient to hail a ride, and do not require physically exchanging any money or a credit card.

Uber for Business enables employees to charge normal Uber rides to a single business credit card. This makes it simple for employees because they just need to use Uber as per normal. Administrators get the advantage of consolidated expense reporting, and the only required setup is that the employee is added to the Uber business account. No additional credit cards are required.

For an employee, Uber for Business works just like normal Uber. Using the Uber app, you enter a pick-up location and destination, pick a type of ride (from among all of the usual uberX, uberPOOL, uberXL, and other options) and request a fare estimate:

Uber: fare estimate

Before officially requesting the ride, you can select a payment profile for the company, or for yourself:

Uber for Business: selecting a payment profile

Then, you can optionally enter some expense notes to describe the trip:

Uber for Business: expense notes

Then, you just wait for the car to arrive!

Uber: ride arriving

En route, the app shows you a map of where you are and an estimated time of arrival.

Uber: map of route

When you’ve arrived at your destination, you can just step out of the car and the ride is automatically charged to the card on file. Since Uber does not offer a tip option in the app, if you want you can tip the driver with cash, although that is not required.

For administrators, there is a web interface where you can do the following:

  • Generate a list of trips taken by all company users, and export that list to CSV
  • Download monthly PDF statements
  • Add and remove employees by e-mail address
  • Add and remove credit cards
  • Manage settings to limit pick-up locations, and days and times during which employees are allowed to take rides. Or, just allow trips to be taken at any time of day from anywhere.
  • Forward ride e-mail receipts to specific administrators

Uber for Business: employee trips report

For me, the account setup process was intuitive and straightforward. Once everybody’s accounts were set up, the booking and reporting worked exactly as advertised!

Flintan IKEA office chair review: simply comfortable

As someone who works on a computer all day, my favourite office chair is the Flintan from IKEA.

Flintan IKEA office chair

I’ve tried many chairs over the years — IKEA and non IKEA — and have found them to be either too much in the “executive” style without proper lower back support, or too rigid for when I want to lean back.

The Flintan has the right back support and a nice tilt action. I prefer the Flintan to the more expensive IKEA Markus (which makes it on a lot of “best chair” lists).

With the “Nominell” arm rests, the Flintan is $99 CAD.

There aren’t many options to adjust the Flintan. The arm rests are fixed, but you can change the height of the chair and lock or unlock the tilt action. The tilt action is unique (compared to many other chairs I’ve tried) in that it is easy to lean back in it, but its resistance adjusts based on how much you lean back. Therefore, it does not take any additional effort to keep the recline position at the exact angle that you’d like. It is sturdy but forgiving. With the Markus, I don’t like the fixed recline positions and I find the resistance when leaning back to be a bit too much.