Adding Open Command Window Here in Windows 10

In Windows 7, you could be in a File Explorer window and hold Shift + Right click to bring up the “Open Command Window Here” in the context menu. It’s very hand when I want to just be in the correct directory to do stuff without having to go through all the paths to get there.

This feature is disabled in Windows 10 and you have “Open PowerShell window here” instead. I don’t (but should someday) use Power Shell. For now, I just want my good old command window.

There are instruction online to do a bunch of permission change via RegEdit and changing the flag of the cmd folder registry. It was pretty involved and in the end I couldn’t really get it to work. I then stumbled upon somebody’s comment on an easier way.

Basically, just save this script as a .Reg file and then run it. It’ll automatically add the registry key that allows the right click context that we need. You might want to close all the File Explorer windows to get it to work.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\normal_cmd]
@="@shell32.dll,-8506"
"Icon"="cmd.exe,0"

[HKEY_CLASSES_ROOT\Directory\Background\shell\normal_cmd\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Directory\shell\normal_cmd]
@="@shell32.dll,-8506"
"Icon"="cmd.exe,0"

[HKEY_CLASSES_ROOT\Directory\shell\normal_cmd\command]
@="cmd.exe /s /k pushd \"%V\""

Now when you Shift + Right click in a File Explorer, you’ll have “Open Command Window Here” back.

How to embed icon data in Python 3.x for TkInter

Sometimes when you want to use TKinter or other GUI dialog but you don’t want to use the generic default icon. You also might not want to have the *.ico or *.png file included in the same folder as your script. Wouldn’t it be nice to just have the icon data embedded in your code?

It’s actually not too difficult to do in Python. I’m working with Python 3.x here so you might have to adjust the code for Python 2.x. We’ll use Tkinter dialog as an example here. Let’s try putting this example books.icon or any icon you would like to use in code. If you need icons to play with, you can get a great set of open-sourced icons from here:
https://sourceforge.net/projects/openiconlibrary/

The icon I’m using is from the icon pack and once you extract the archive, it’s in ../ico/16×16/others/books.ico. You can also just download the icon file here: books.ico

books.ico

The trick is to converting the icon file data into string representation of hex data that we can store in the program. This is actually surprisingly easy to do using repr() function to generate string of the object. In this case, we are converting the icon image data into string hex values. The following code will print out the data for the icon file in the almost correct format for you to use. Make sure the icon file is in the same location as your script when running this code.

with open("books.ico", "rb") as image:
     a = image.read()
print(repr(a))

I said almost a correct format because you’ll end up with a really long string hex data dump and it’s in a single line. This could be used as-is but you’ll end up with a really long line in your python file that you’ll have to scroll right very far to see the entire thing. I’m truncating here so we don’t fill up the whole page.

b'\x00\x00\x01\x00\x01\x00\x10\x10\x00\x00\x00\x00\x00\x00h\x04\x00\x00\x16\x00\x00\x00(\x00\x00\x00\x10\x00\x00\x00 \x00\x00\x00\x01\x00 
... 
f00\x00\xf0\x03\x00\x00\xfe\x1f\x00\x00\xff\xff\x00\x00'

For the sake of readability in our code, we’ll format it into a nicer format by breaking every 16th hex values into its own line. Here’s the previous code updated with a formatting code below:

with open("books.ico", "rb") as image:
    a = image.read()
data = (repr(a))

data = data[2:]  #trim out the b'
data = data[:-1]  #trim out the last '

dataList = data.split('\\x')  #split by hex unit
dataList = dataList[1:] #remove the blank  value at the beginning

totalLen = len(dataList)

i = 0
hexline = ''
lenCount = 0
groupCount = 0
for hex in dataList:
    if(lenCount == totalLen-1):
        hexline += '\\x' + hex
        print('b\'' + hexline + '\'')
    if(i == 16):  #change number of grouping here       
        print('b\'' + hexline + '\'')
        i=0
        hexline = ''
        groupCount += 1

    hexline += '\\x' + hex
    i+=1         
    lenCount += 1

This should now give us the format we can just cut and paste from the output window into our code for the Icon data. For every 16th hex value, a new line is created with b’ at the beginning of the line to represent byte code representation using string. Again I truncated the data to save space.

b'\x00\x00\x01\x00\x01\x00\x10\x10\x00\x00\x00\x00\x00\x00h\x04\x00'
b'\x16\x00\x00\x00(\x00\x00\x00\x10\x00\x00\x00 \x00\x00\x00\x01\x00 '
...
b'\x00\x00\xc0\x01\x00\x00\x80\x01\x00\x00\x00\x07\x00\x00\x00\x07'
b'\x00\x00\x01\x00\x00\xc0\x01\x00\x00\xc0\x01\x00\x00\xc0\x01\x00'

Now we’ll do an example of a TKInter window with the embedded icon data. Use the full icon data from the output generated by the code. The data shown in the code below is truncated in this code example.

import tkinter
import tempfile

ICON = (b'\x00\x00\x01\x00\x01\x00\x10\x10\x00\x00\x00\x00\x00\x00h\x04\x00'
b'\x16\x00\x00\x00(\x00\x00\x00\x10\x00\x00\x00 \x00\x00\x00\x01\x00 '
...
b'\x00\x00\xc0\x01\x00\x00\x80\x01\x00\x00\x00\x07\x00\x00\x00\x07'
b'\x00\x00\x01\x00\x00\xc0\x01\x00\x00\xc0\x01\x00\x00\xc0\x01\x00')

_, ICON_PATH = tempfile.mkstemp()
with open(ICON_PATH, 'wb') as icon_file:
    icon_file.write(ICON)

root = tk.Tk()
root.iconbitmap(default=ICON_PATH)

tk.mainloop()

If you cut and paste the data value into the ICON correctly, you should see a blank tk window with the icon that had the generated the data.

Here are the complete codes for the data generator and the tk example. You need to rename the file extension to .py. This server doesn’t allow .py extension to be viewed.

IconData.txt
Tkinter_IconData_example.txt

Pyinstaller Trouble with PyQt5 and Matplotlib on Python 3.7

Pyinstaller is a fantastic python to exe packager. When I tried making a stand alone exe with a python script (PyQt5Test.py) using a quick PyQt5 example, it creates a working exe file right off the bat using this simple command:

pyinstaller PyQt5Test.py --onefile

Here’s PyQt5Test.py:

import sys
from PyQt5.QtWidgets import QWidget, QMessageBox, QApplication

class Example(QWidget):    
    def __init__(self):
        super().__init__()        
        self.initUI()        
        
    def initUI(self):               
        
        self.setGeometry(300, 300, 250, 150)        
        self.setWindowTitle('Message box')    
        self.show()       
        
    def closeEvent(self, event):
        
        reply = QMessageBox.question(self, 'Message',
            "Are you sure to quit?", QMessageBox.Yes | 
            QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()        
                
if __name__ == '__main__':
    
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

Running the executable file from the dist folder in works perfectly just as the same way as you just run the script in the interpreter

I left the console option in the background so that if there’s an error I could see it when the program runs. However, you could get rid of the console by adding “–noconsole” option to pyinstaller.

pyinstaller PyQt5Test.py --onefile --noconsole

Now that works so well, I want to see whether I could make a standalone file with a script that has PyQt5 and Matplotlib. Here’s the code I use to test this:

import sys
import PyQt5
from PyQt5.QtWidgets import QApplication, QMainWindow, QMenu, QVBoxLayout, \
   QSizePolicy, QMessageBox, QWidget, QPushButton, QListWidget, QDesktopWidget
from PyQt5.QtGui import QIcon
from PyQt5 import QtCore
import PIL
import tkinter
from tkinter import filedialog


from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
import matplotlib.pyplot as plt

import random

class App(QMainWindow):

    def __init__(self):
        super().__init__()
        self.left = 10
        self.top = 10
        self.title = 'PyQt5 matplotlib example'
        self.setFixedSize(640, 700)
        self.initUI()

    def location_on_the_screen(self):
        ag = QDesktopWidget().availableGeometry()
        sg = QDesktopWidget().screenGeometry()

        widget = self.geometry()
        #x = ag.width() - widget.width()
        #y = 2 * ag.height() - sg.height() - widget.height()
        x = sg.width() - widget.width()
        y = 2 * ag.height() - sg.height() - widget.height()
        self.move(x, y)

    def initUI(self):
        self.setWindowTitle(self.title)
        #self.setGeometry(self.left, self.top, self.width, self.height)
        self.location_on_the_screen()

        m = PlotCanvas(self, width=5, height=4)
        m.move(0,0)

        button = QPushButton('PyQt5 button', self)
        button.setToolTip('This s an example button')
        button.move(500,0)
        button.resize(140,100)

        button2 = QPushButton('Plot', self)
        button2.setToolTip('Plot Data')
        button2.move(500,102)
        button2.resize(140,100)

        listBox = QListWidget(self)
        listBox.setGeometry(QtCore.QRect(120,10,281,192))
        listBox.move(500,400)

        self.show()


class PlotCanvas(FigureCanvas):

    def __init__(self, parent=None, width=5, height=4, dpi=100):
        fig = Figure(figsize=(width, height), dpi=dpi)
        self.axes = fig.add_subplot(111)

        FigureCanvas.__init__(self, fig)
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self,
                QSizePolicy.Expanding,
                QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)
        self.plot()


    def plot(self):
        data = [random.random() for i in range(25)]
        ax = self.figure.add_subplot(111)
        ax.plot(data, 'r-')
        ax.set_title('PyQt Matplotlib Example')
        self.draw()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = App()
    sys.exit(app.exec_())

When creating an exe for this script using Pyinstaller I see a lot of warnings but no errors. I even got an exe. However, when I ran the exe I got an error:
ModuleNotFoundError: No module named ‘numpy.core._dtype_ctypes’

I did have Numpy correctly installed using pip and I have version 1.16.0 and it’s supposedly the most up-to-date version.

After Googling the error, I found that the problem was indeed Numpy itself and the issue is fixed if I have version 1.16.1. However, doing pip install numpy doesn’t work since it insists that 1.16.0 was the up-to-date version.

Therefore, I have to force the install of 1.16.1 Numpy

pip install numpy==1.16.1

This forces the new version of Numpy to be installed. I tried to create the exe file again using Pyinstaller. Again, the exe creation went just fine as before. I wasn’t sure whether this would work or not, but to my surprise when running the exe file I have a working program!

I was quite pleased with the result. Now I could move forward with using Pyinstaller to make a standalone program.

Installing Python 3.7 on Raspberry Pi

As of Jan 2019, Raspberry Pi comes with Python 3 but it’s an older version of Python 3 (<3.6). The latest Python version is 3.7.2 at the time of this post. If we want to use the latest version on Raspberry Pi, we need to compile it from the source. Please make sure to note the use of ‘sudo’ in the command lines because at certain lines you don’t want to have sudo because it’ll change the location of the configuration and installation and you might not end up with a working Python 3.7.2

First make sure you update your Raspbian to the latest update. If any prompt comes up just answer ‘yes’. There might be some information page that you have to scroll through by holding down the space key to the end. After that press q to continue with the installation.

$ sudo apt-get update
$ sudo apt-get -y dist-upgrade

Your Raspberry Pi might require a reboot. If you end up with a black screen and no response at some point then you can unplug and plug in the power to re-start your Pi.

Now you are ready to upgrade to Python 3.7.2. One thing to note is that your GPIO libraries that’s specific to the hardware might not work. You can always still access your original system Python 3 using /usr/bin/python 3 to bring up the original system Python3

$ /usr/bin/python3

Before downloading and compiling the new Python 3, install all the required packages to do this:

$ sudo apt-get install libffi-dev libbz2-dev liblzma-dev libsqlite3-dev libncurses5-dev libgdbm-dev zlib1g-dev libreadline-dev libssl-dev tk-dev build-essential libncursesw5-dev libc6-dev openssl git

You might have to force install libssl-dev 1.0.2 in order to get pip to work with Python 3.7.2 since apparently you have to have OpenSSL 1.0.2 or 1.1 compatible libssl.

You can check your version of libssl-dev using this command:

$ sudo apt-cache policy libssl-dev


I found a post discussing how he solved this issue by running this install first before compiling Python 3.7.2

$ sudo apt install -t jessie-backports libssl-dev

Download Python 3.7.2 and extract it.

$ wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
$ tar xf Python-3.7.2.tar.xz
$ cd Python-3.7.2

Now configure the directory. It’s important to have the –with-ssl option or openssl wouldn’t be included. This will take a couple of minutes:

$ ./configure --prefix=$HOME/.local --with-ssl --enable-optimizations

Build and install Python 3.7.2. This step takes a long time. On my Raspberry Pi B (not B+) it takes about 30 minutes. DO NOT USE SUDO! Make sure to have the -l 4 option there to keep the error build limit or you’ll encounter problems.

$ make -j -l 4
$ make install

After the installation is done, update ~/.bashrc so that when you type Python3 as a command it will choose Python 3.7.2 over the pre-installed Python 3.4.

$ nano ~/.bashrc

Add the following line at the end of the file. Save and the exit nano.

export PATH=$HOME/.local/bin/:$PATH

You can now close this terminal and open a new one. Launch python3 using the following command and check what version you have. Use exit() to quit Python.

$ python3

You can also check what version of pip3 you have by typing in the command:

$ pip3 --version

Remember to have the 3 at the end of these commands otherwise you’ll launch the default Python 2.7.

If there you have limited space on your Raspberry Pi, you might want to remove all the compile tools and the source code to free up space. Use the following commands. Make sure you are not in the Python-3.7.2 directory where we were doing the compiling.

$ cd $home
$ sudo rm -r Python-3.7.2
$ sudo rm Python-3.7.2.tar.xz
$ sudo apt-get --purge remove libffi-dev libbz2-dev liblzma-dev libsqlite3-dev libncurses5-dev libgdbm-dev zlib1g-dev libreadline-dev libssl-dev tk-dev build-essential libncursesw5-dev libc6-dev openssl git -y
$ sudo apt-get autoremove -y
$ sudo apt-get clean

I want to give credit to the following pages for the original content on how to install Python 3.7.x on Raspbian:

https://gist.github.com/SeppPenner/6a5a30ebc8f79936fa136c524417761d
https://www.scivision.co/compile-install-python-beta-raspberry-pi/
https://medium.com/@dblume/getting-pip-working-for-python-3-7-on-rasbian-f414d9d526d0

Enjoy Python 3.7.2 on Raspberry Pi!

Fixing Ugly Looking Texts on Chrome Web Browser

I have noticed in the recent weeks how pixelated all the texts in my Chrome Browser look. Take a look at Monoprice web page and see how all the texts are pixelated. Compare it to the same page rendered on *gasp* Internet Explorer (not Edge Explorer).

Texts are all pixelated on Google Chrome on this page
Texts are nice and smooth on IE

So why does it do this? I don’t know so I started looking for answers online. I went to several tech forums and posts and many suggested tweaking the settings on Chrome like font anti-aliasing. Noting worked for me until I stumbled upon a comment posted in one of those forums. I can’t remember where I found it now or I would give the author the credit he/she deserves.

To fix the problem I have, I go to:

chrome://flags

A warning that this is a settings page that Google doesn’t really want you to mess with unless you know what you are doing. So you probably don’t want to randomly set things. We are just going to just change the option “LCD text antialiasing”. You could search for it on the page by using Ctrl+F or Command + F on Mac.

On my Chrome, it’s set to “Enabled” so I’m just going to set it to “Disabled”. On a different computer, I see it as “Disabled” so I set it to “Enabled”. Basically just toggle the state of that option from whatever you have now to get rid of the text aliasing issue. You could also try setting it to “Default”. If that doesn’t work, you can come back to this page again and set to a different state that works for you.

Chrome will re-launch. If you have nice looking and pixelation free texts again, you are all set!

Installing a new Ubuntu 18.04 LT on WSL

I just tried enabling WSL on a new Windows 10 computer today using the instructions I wrote in the post last year and found out that when you launch bash you no longer get to install Ubuntu automatically.

Now you need to download the install from Windows Store which I despise and it doesn’t even let me click the link. Luckily there’s a way around getting the install from Windows Store. You can download the install file directly from the providers of the distros. Click on the link of the distro you prefer. In my case, I picked Ubuntu 18.04.

Once you download the file, just launch it to get the setup going. There’s not much of an indication message during the install so wait a while and click Enter and it would ask for you UNIX username and password. After that the installation is done.

I believe there’s a way to install more than one distro but I’m not going to get into that in this post.

After you have Ubuntu installed, you can follow the previous post to get X-11 server for display output and Anaconda working on WSL.

Enjoy!

Upgrading Windows Subsystem Linux (WSL)

I posted about how to enable WSL on Windows 10 a while back.  At the time, the included Ubuntu Linux version would have been Ubuntu 14.04.5 LTS.  It’s been a while and WSL has matured to get to newer version.   Why upgrade to a newer version of Ubuntu?  So we can take advantage of new features offered such as using SciPy and other modules in Python. Other Linux distributions are now also supported in WSL but I’m not going to cover them in this post.

So let’s upgrade our Ubuntu to the latest version and then I’ll cover installing Xming Server so we can use graphical output needed for Matplotlib.  Yes, although not officially, we can now have graphical output in WSL through a 3rd party program which is a good start.

First, check to see what version of Ubuntu we have.  Enter the following command in WSL bash:
$ lsb_release -a
This should return the information on the Ubuntu version we have

Just for fun, we can also check what version of Windows we have using the following command:
$ cmd.exe /c "systeminfo" | grep "^OS Version"

Right here alone makes it worth while using WSL. Can’t do grep in command prompt but here we can.

Once we confirmed that we have the older version, let’s update to the latest version by typing in the following commands:
$ sudo -S apt-mark hold procps strace
$ sudo -S env RELEASE_UPGRADER_NO_SCREEN=1 do-release-upgrade

This will go through a bunch of fetching and about a couple of minutes in it’ll prompt you to continue with the installation since this will take a couple of hours. After all we are replacing the entire Ubuntu version here. Type in Y to continue and now let it run for a while. There might be several more prompts later so don’t go away and expect it to be done when you get back.

At the end, you’ll need to reboot WSL. With the newer version of WSL, closing the bash window won’t stop all the services. You can manually stop and restart WSL using command prompt (with Administrative Rights). Close the Bash window and then Run command prompt as Administrator and then type in the following commands:

net stop LxssManager
net start LxssManager

Relaunch WSL and check your Ubuntu version again.  At the time of this post, I have 16.04.5 LTS (xenial) using this method.  I guess that it doesn’t jump right from 14.04 to 18.08 in one upgrade. I do know that 18.08 version is available so we need to do more to update to the latest version.  We’ll do the following commands to bring 16.04 up-to-date:

$ sudo apt update -y # makes apt system up-to-date
$ sudo apt upgrade -y # upgrades/makes up-to-date current Ubuntu 16.04 packages

Now we do another update to make sure everything is good and then do another release upgrade.

$ sudo apt update && sudo apt -y upgrade

If more packages are found and need to be upgraded then you need to do it or it won’t let you upgrade to the next release. While I was doing this, there were 2 packages that could be upgraded but didn’t because they were kept back for some reasons. You can install them manually using:

$ sudo apt-get install

In my case, I hade procps and sudo packages that need to be install. I think it’s maybe because I made some modification to them in the previous version and I did ask the installer to keep my local configurations from before. Maybe it would been better to just install fresh config when I did the upgrade. Once the installs are done, try running the update again to see if there’s anything left to upgrade.

Once you have nothing to update/upgrade, it’s time to get to the next version 18.04.

$ sudo do-release-upgrade

Again this will take a while. We’ll have to do the same process as before and then check the version again. Once we have 18.04, we are done! (for now until the next release).

Installing Xming X11 Server:
Head over to Source Forge and install Xming to allow graphical output for WSL.
After the installation is done, modify the system configuration file using the following command:
$ sudo nano ~/.bashrc
Add at the bottom of the file the following lines

export DISPLAY=localhost:0.0 
Block external IP access so that we know our X-server is secured

Windows firewall might pop up here. Choose to only allow local traffic and block it from going outside since the X-server runs locally and there’s no need to have it be exposed to the outside world for security precautions. Set the scope to just your local IP 127.0.0.1

Launch X-server and have it run in the background.  You should see a little icon for Xming in the running program icon box.  Try installing some X-11 programs using the following command:

$ sudo apt-get install x11-apps

Now run a sample program like Xcalc:

$ xcalc

You should see a calculator program showing up on your desktop. You can move it around just as you do as a normal windows program!

If you have an error with “no display output”, check that the firewall is correctly enabled for the local host connection. You can also make sure that the display is correctly set up by sending this command:

$ export DISPLAY=localhost:0.0

Installing Anaconda:
Now that we have the graphical output, we are ready to use Matplotlib, but trying to manually install all the dependencies is quite annoying to deal with. Therefore, we’ll install a python package like Anaconda so that we get everything we need for python using the “conda” command. Since this is 2019, let’s use Python 3.x. I think it’s about time to move on to the new version since I have been stuck using 2.x for the last decade.

First, install Anaconda with wget. Let it sift through all the servers until it finds what it needs. Might take a while so sit back and relax.

$ sudo wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

After the it found the package it needs, execute the installation:

$ bash Miniconda3*.sh

Just watch the installation process and at some point you’ll have to supply a Y to proceed with the installation.

Now run the following lines to update Qt 5 and get the latest configuration of Anaconda to prevent errors with Qt5.6 WebKitEngine error that people get if they want to launch Spyder IDE.

sudo apt-get install python-pyqt5.qtwebkit

After this is done, you should be able to launch Spyder IDE with Spyder command, but let’s wait until we install all the great packages to use in Anaconda first. Get all the packages we need for data science:

$ conda install numpy pandas scipy matplotlib seaborn scikit-learn

After the installation is done, now you can launch Spyder IDE:

$ spyder

If you run into problems with the ModuleNotFoundError: No module named ‘PyQt5.QtWebKitWidgets’, run this command (*Warning: this will break MatPlotlib! There’s no solution at the moment because the newest Matplotlib uses the new Qt 5.9 but this causes problem with Spyder):

conda update qt pyqt -c conda-forge

After the installation is done, it should fix the problem. Try launching Spyder IDE again and you should now have the program on your desktop.


One thing to note is that sometimes after you exit Spyder IDE, the program might still be there and you can no longer launch it again. To kill it, just exit X-server by Right clicking the X-server icon in the Icon Tray and click Exit. It will give you a warning about terminating all the program running on X-server. This will terminate Spyder display running on X-server. Close out the bash window and use command prompt to stop and re-start the service so that we don’t have any more programs running in the background.


Start X-server first and then the bash window again. You can also check to make sure that there’s no more file associated with Spyder:

$ cd ~/.spyder
or

$ cd ~/.spyder-py3

If this does exist, the remove the lock by using this command:

$ rm -f spyder.lock

Now you should be able to start Spyder again. Let’s try running MatPlotLib to make sure that this works. Let’s use this example code


import matplotlib.pyplot as plt
import numpy as np


def f(t):
    'A damped exponential'
    s1 = np.cos(2 * np.pi * t)
    e1 = np.exp(-t)
    return s1 * e1


t1 = np.arange(0.0, 5.0, .2)

l = plt.plot(t1, f(t1), 'ro')
plt.setp(l, markersize=30)
plt.setp(l, markerfacecolor='C0')

plt.show()

Unfortunately, looks like our MatPlotlib is now broken because the update Qt command we ran. We can reinstall MatPlotlib, but then it breaks the Qt again because of the update from Qt 5.6 to Qt 5.9. At the moment I don’t have a solution to this. Maybe Spyder will get updated to fix this issue with the new Qt problem. In the mean time, you can re-install Matplotlib and should be able to execute the code to generate a plot via X-11 output.

That’s it for now. Enjoy coding!

Waterproofing Wax Recipe for Canvas and Leather


I recently bought a new camera bag and it’s a canvas kind.  It came with a tin of
refinishing wax for water proofing the canvas.  I wasn’t sure how to correctly apply the wax because the instruction was vague: “Rub a small amount on area to be finished.  Move warm hair dryer over area while rubbing with cloth to blend compound thoroughly into fabric”.  As an engineer, a “small amount” doesn’t tell me the actual amount required.  So I checked YouTube to see whether there’s an instruction video on how to apply refinishing wax on canvas.  I instead came across a video on how to make your own refinishing wax to apply to a canvas bag.  The video might not stay up forever, but here’s the Link.

In any case, the video said that the formula for the wax compound is 2 part bees wax, 1 part boiled linseed oil, and 1 part turpentine.

He also said that you could use either bees wax or paraffin wax.  He chose bees wax and it was a 1/2 lb. stick that he cut up and melted to mix with the other liquid.  One of the comments was saying how the guy in the video was melting a 1/2 pound stick of bees wax and claimed that it was 8 ounces of fluid so he added 4 ounces of boiled linseed oil and then 4 ounces of turpentine to make his final compound.  This was interesting because 1 lb. weight is equal to 16 ounces weight and if it’s water then 16 ounces weight is the same as 16 fluid ounces since water density is 1.00.  However, can the same thing be true for bees wax?

Oddly enough, a pound (weight) of bees wax is around 15.96 fluid oz. according to this handy online weight to volume converter for various liquid:

https://www.aqua-calc.com/calculate/weight-to-volume

So his measurement of 1/2 lb. of bees wax is around 8 fluid oz. So 8 oz. (1 cup) bees wax: 4 oz (1/2 cup). linseed oil: 4 oz. turpentine (1/2 cup) formula is correct. Basically, 2 parts bees wax to 1 part boiled linseed oil to 1 part turpentine as he stated.

However, paraffin wax is different. 1 weight lb. of paraffin wax is 17 fluid. oz. according to the converter. Therefore, he would need to use a little bit less than a 0.5 lb of paraffin wax to use the same liquid amount of linseed oil and turpentine.

Doing some more searches, I found another source to confirm the bees wax weight to liquid conversion. It also offers another way to figure out the weight to liquid conversion using a water displacement method.

According to Super Formulas Arts & Crafts How to make more than 360 useful products that contain honey and beeswax by Elaine C. White., there’s a section entitled Measuring Beeswax. Here’s the excerpt:

Measuring Beeswax
Usually there is a great difference between the liquid volume of an ingredient and its dry weight. This is not true of beeswax.

Example: 1 ounce weight of solid beeswax is equal to 1 ounce liquid measurement of melted wax. The following chart can be used to measure beeswax as a solid or as a liquid.

Melted beeswax or liquid measure= Solid wax or Dry Weight
1 Tablespoon melted beeswax or liquid measure=1/2 ounce solid wax or dry weight
2 Tablespoons or 1 ounce= 1 ounce
1/4 cup or 4 tablespoons = 2 ounces
1/2 cup or 8 tablespoons= 4 ounces or 1/4 pound
1 cup or 16 tablespoons = 8 ounces or 1/2 pound
2 cups or 16 ounces= 1 pound or 16 ounces

The liquid displacement formula
Solid beeswax can be measured by displacing liquid. For example, to measure 1 Tablespoon beeswax use the following method:

Since 4 tablespoons of liquid equal 1/4 cup, add 3 tablespoons of water to a clear measuring cup. Add lumps of solid wax until the water reaches the 1/4 cup line. Pour off the water. The remaining wax equals 1 tablespoon. Set the wax aside to dry before using it in any formula.

Atollic TrueStudio for STM32 is now released!

My last post stated that Atollic got acquired by ST Microelectronics. The new TruStudio would be free courtesy of STM. I just got the message from my contact that gave the link to the download for the latest version of TrueStudio. It’s not up on their website yet so this is an early present for everyone looking forward to this.  Enjoy!

Windows version:
http://download.atollic.com/TrueSTUDIO/installers/Atollic_TrueSTUDIO_for_STM32_windows_x86_v9.0.0_20180117-1023.exe
Linux version:
 http://download.atollic.com/TrueSTUDIO/installers/Atollic_TrueSTUDIO_for_STM32_linux_x86_64_v9.0.0_20180117-1023.tar.gz

Great news for STM32 firmware engineer

I’m about to start a new project using STM32F4x ARM Cortex M4 from ST Micro. I was planning to maybe get Keil uVision 5 since most of my training had been done using Keil. I have explored other options like a bunch of GNU tool chains and such but found them to be really annoying to put together and many times don’t work real well especially with ST ARM devices. I came across Atollic TrueStudio Lite a while back and I really like it. All my codes that were written in Keil uVision 5 compiled with no issues using TrueStudio. I first started looking at Keil uVision 5 pricing and it’s $5k for a node lock perpetual license or $9k fro a perpetual floating license. Maybe I could convince work to buy the license, but after spending 17K on Altium Designer license and subscription I don’t know whether I could get Keil license too. Fortunately, I went to Atollic website again to see how much a TrueStudio Pro would cost. I found this news announcement:



http://blog.atollic.com/early-holiday-gift-from-stmicroelectronics

Basically, it said that ST Micro just acquired Atollic and they’ll make TrueStudio Pro FREE!!! Wow!  I can’t wait to try the Pro version since the Lite version was pretty good (except for the annoying long loading splash screen at the beginning).  Some people might say the TrueStudio is still technically a GNU compiler and Keil would be a better tool.  Nevertheless, I don’t think you can beat a free professional tool.  Even TI made their Code Composer Studio free a while back which actually annoyed me because I did pay for the license just a couple months before they made it free.  I did consider using MSP432 since it’s also an ARM device, but you don’t have the freedom to clock it to 400 MHz like you can with ST ARM devices.  The STM32 Cube tool was decent but it’s annoying without having a decent IDE to use it with. As I mentioned before, I tried to roll my own GNU tools, but the success of compiling the codes from STM32 Cube was questionable without a lot of manually fixing a lot of things.  It works well with Keil and TrueStudio right out of the box though. Now I can see an even better integration between ST software and TrueStudio going forward.  Maybe they’ll bundle STM32 Cube already inside TrueStudio and it’ll be a one-click code generation.  That would be incredible.

Free good professional software is the name of the game these days.  That’s really the reason why I picked Atmel products over Microchip 10 years ago.  Atmel has Atmel Studio which was a quality C GNU compiler tool for free while Microchip charged you a lot of money to use their C compiler.

In any case, looks like I have a perfect solution for my ARM Cortex M4 project.