Ted Piotrowski

Code to live. Live to spend time outdoors.

Page 2


Using a Raspberry PI as an AirPrint server

I’ve had my Brother HL2170W laser printer since January 2010, before AirPrint printers were really a thing. It’s been a solid printer and still has 90% of its second cartridge left. I’ve had an iPhone since around 2010 as well and I was under the mistaken impression that the two devices could never talk to each other. True, the devices are not directly compatible, but it is possible to use a Raspberry Pi as a mediator to have the two work together. Here’s a quick run down of how works in under four minutes:

View →


Running NodeJS, NPM and Git on Windows 10 without Administrator privileges

  1. Download NodeJS zip (http://nodejs.org/dist/latest/), likely the *-win-x64.zip version and unzip inside ~/AppData/Local/Programs/node1
  2. Download git for windows (https://git-for-windows.github.io/)
  3. Run installer
    1. Uncheck all components except Use TrueType font
    2. select Use Git from Git Bash only
    3. You can leave default line ending conversion
    4. Use Windows’ default console window
    5. Check file system caching and Credential Manager
  4. Run git bash shell
  5. vi .bash_profile or use notepad.exe to create it in your user directory

    PATH=$PATH:~/AppData/Local/Programs/node
    PATH=$PATH:/c/Windows/System32/
    
  6. Restart git bash shell or run source .bash_profile

  7. Clone your github repo over HTTPS (no SSH keys required). Credential manager can store your password.

  8. Cd into project and npm install2

  9. Go forth and profit

 Bonus: Visual Studio Code

Visual Studio Code is my favorite editor and it’s free.

  1. ...

Continue reading →


Browsing on a Chromebook using a SOCKS proxy

How to watch HBOGO abroad on your Chromebook?

  1. Turn on developer mode on your Chromebook
  2. Press Ctrl+Alt+T to open a shell window and type shell at the prompt
  3. Start a SOCKS proxy server on your laptop that forwards traffic through a server in the USA you can access via SSH
    ssh -D 20001 user@serverintheusa
  4. Configure your Chromebook connection to use the local proxy.

Screenshot 2016-07-05 at 5.42.52 PM.png

4a. Click on your active Wifi connection to bring up the proxy configuration. Fill in the appropriate SOCKS host and port.

Screenshot 2016-07-05 at 5.42.30 PM.png

4b. You should now be able to access HBOGO

Screenshot 2016-07-05 at 5.43.56 PM.png

What is a proxy?

A proxy acts as a middle-man for your internet traffic. If you want to read cnn.com, instead of issuing a request for that page directly from your browser, you would first issue this request to a proxy server. The proxy would then request the contents of cnn.com and once it received the response, it would return the requested data back...

Continue reading →


Ford Focus heat shield fix

I recently noticed some tin-can rattling coming from the underside of my mom’s car. Google'ing pointed me towards the rear heat shield coming loose. I used some aluminum flashing and oversized washers to fasten it back in place.

Tools:

  1. Scissors
  2. 10mm socket wrench
  3. WD-40
  4. Framing nail + hammer

Parts:

  1. 10-24 nylon lock nuts
  2. 3/16" x 1 ¼" washers
  3. aluminum flashing

View →


Debugging load cells and HX711

I’m working on a system to determine how long it takes to air dry laundry. As the fabric dries, it becomes lighter. The idea is to measure the weight of drying laundry and when it stops decreasing you know it is dry.

Enter: the load cell. Load cells convert force measurements (such as weight) into electrical signals. They’re found in most digital kitchen scales. If we can hang a piece of laundry from the load cell and feed the reading to a computer, we’ll be able to get the data we’re after.

Load Cell Cantilever.jpg

Image from http://2.bp.blogspot.com/

I decided to use a strain gauge load cell because it can measure hanging force easily, and it’s cheap and plentiful on Amazon.com. Grab a volt meter and a variable power supply and lets demonstrate how a load cell works.

Screenshot 2016-06-13 at 1.33.37 PM.png

Reading a load cell

A load cell comes with four wires. Red and black wires for voltage in and ground (5-10V). Two additional wires...

Continue reading →


Move over Macbook Air

fg (1).png

Image from asus.com

I bought an ASUS Chromebook Flip recently and it’s been a treat. The 4GB model sells for $279, but you can always find an “opened box” model on Amazon Warehouse deals for around $220. I guess some people are not thrilled with the Chromebook (browserallthethings) approach and send them back barely used. Their loss, your gain.

I’ve been looking at tablets for sometime, but could not find the winning tablet/keyboard combo. The desire is to be able to read articles/docs + watch movies comfortably, but be able to shoot off a lengthy email and write some code as well. The Chromebook Flip has a 360 degree hinge allowing it to act as a tablet and a traditional laptop as well. Win. It’s also light (less than a kg) and super thin (1.5cm).

The Flip is one of the few Chromebooks that runs on ARM making it very power efficient. No more sprints for the charger because battery...

Continue reading →


First 3D printing project

3D printing is the process of creating models by stacking layers of thermoplastic on top of each other. It’s similar to icing a cake. There are some rules to follow. Each additional vertical layer can only overhang the previous layer at a 45 degree angle. This means you can 3D print a capital letter Y because the branches go up at a gradual 45 degree angle. A capital letter T would collapse, however, because the crossbar is an abrupt 90 degree angle.

It’s good to start learning 3D printing by trying to recreate an existing part. I used a part from a broken pair of headphones. The part is responsible for holding the headphone headband together. I chose this part because it has a simple geometric design and because I had the broken part available for measurement.

Printed replacement along with broken piece

You create your 3D model in a free program called SketchUp. I learned the necessary SketchUp skills in a one hour class at...

Continue reading →


How laundry dries

One thing that bothered me while living in Australia was drying laundry. Many rental properties do not contain a clothes dryer and people tend to avoid using dryers when they are available. I like dry laundry. Even on intensely sunny days in Australia, drying clothes on a line never seemed to eliminate all the moisture content. People claim sun dried laundry has a fresh smell. To me, it smelled like faint dampness.

I recently took a stab at quantifying the effect. The experiment consisted of hanging wet laundry outside and measuring its weight over time. As a shirt dries it loses water content and its weight decreases. Here is the data:

Time elapsed Merino shirt Cotton shirt
0 minutes 220g 280g
15 minutes 185g 251g
30 minutes 156g 220g
45 minutes 145g 193g
60 minutes 141g 172g
75 minutes 141g 167g
90 minutes 140g 164g
105 minutes 141g 165g
After dryer 130g 1
...

Continue reading →


NSA puzzle

My dad recently presented me with a puzzle. The puzzle consists of nine square tiles. Each tile edge has the top or bottom half of an Air Force, Army, Marines, or Navy emblem. The challenge is to arrange the tiles in a 3x3 grid where all emblems between touching tiles align correctly.

unsolved.jpg

 Number of possibilities

To create a 3x3 grid, we start by choosing a tile for the upper-left hand corner. We have 9 tiles to choose from. Each one of those tiles can also be rotated in one of 4 ways (0, 90, 180 and 270 degrees). Therefore we have 9 * 4 = 36 options for the first tile. Next we choose the upper-middle tile. With the upper-left tile selected, we only have 8 tiles to choose from. Once again, this tile can be rotated one of 4 ways. Therefore we have 8 * 4 = 32 options for the second tile. Proceeding like this we have 7 * 4 = 28 options for the upper-right tile, 6 * 4 = 24 options for the...

Continue reading →


Unit tests are for developers. Integration tests are for users.

I was recently tasked with teaching a fellow developer about unit testing. Tim had no testing experience prior to joining the company. Tim had learned to write Webdriver tests over the past year, but now wanted to learn about unit testing.

The first point I covered is that unit testing is good for combinatorial tests. If you want to test a lot of different inputs, you’ll likely want to do it by writing unit tests because they are fast.

The second point I made is that the easiest methods to test are methods that map inputs directory to outputs. Sum(a, b) is a good example. The sum method’s return value is always dependent on its arguments, a and b.

Next I created an example where a module called out to another module in one of its methods. I showed how to mock the external module and proceeded to test that given an input the module under test called out to the mocked module.

Tim did...

Continue reading →