Misadventures with varnish

I like experimenting. It keeps life interesting. You discover something new and get excited. It advances the world, ushers in a new era of new found knowledge expanding the horizon of human understanding.

It does not come without a cost though. Sometimes the cost is too much to bear. You start questioning your life decisions while drowning in a sea of your tears. Lots of tears I might add.

Part of experimenting is failing. Oftentimes miserably. I wanted to try out the Conservar Isolating Varnish. I had read about how it is great for isolating the paint film from the final varnish. So, if your painting got dirty or damaged and needed to be restored, you could easily remove the final layer of varnish without dissolving/damaging your painting. What could go wrong?

Little did I know it had really powerful solvents and made the mistake of applying a thick layer with a fat brush. Which would have probably been fine had I not accidentally brushed over already varnished areas again.

The varnish dissolved the top layer of my painting and brushing over it accidentally caused the layers beneath to show up. I guess the fact that my varnish brush was turning blue should have alerted me to stop and asses what I was doing. Lesson learned.

Now I understand why artists stress so much about not brushing over already varnished areas even if some spots were left dry. You can go over those spots when you apply the second layer of varnish.

I am a bit sad that my painting got damaged and I will need to retouch it. But (because I didn’t learn my lesson) I am also excited about painting thin layers (glazing) over the isolating varnish and seeing what kind of affect it will have. Maybe the painting will be as luminous as the old master paintings!

I don’t recommend you try this at home. Painting over a reversible varnish layer means your top paint layer will become removable and will get off the painting when you try to restore the painting . Oh, did I mention it makes it really hard to restore a painting?

My plan is to paint over the isolating varnish. Use more isolating varnish over that paint film then go over the whole thing with regalrez varnish. This should keep all the layers of my painting safe if it needs to be restored later on. Regalrez will come off with Gamsol (or any other odorless mineral spirit). Conservar varnish, I will need more powerful solvents which should (theoretically anyway) keep the paint film intact.

I plan to keep this one in my private collection so I feel safe experimenting with it but I’m making dua as I try to think through my blood soaked tears that this painting will turn out even more amazing than before.

I will post pictures of the painting before and after varnish . See if you can figure out where the paint film dissolved into the varnish .


Missing package errors after upgrading Go

Very recently, I upgraded Go from 1.11 to 1.12 and all hell broke lose. I kept getting errors of missing packages in , etc .

The solution was to re-install Go. This can be done easily on OSX with

brew remove go --ignore-dependencies

My experience with PHP/Zend certification

This post has been sitting in my drafts since 2013. I figured it was time to finish and publish it.

I passed PHP Certification exam. It felt nice. I had read about how people failed more than once so it was cool that I passed it on my first try.

Registering for the test

I’m sure there’s more than one way to do it but I went to Zend’s website and bought an exam voucher, which was $195. They have various packages where they offer to give you a crash course or study material and such but I decided to study on my own.

When you buy the voucher Zend will send you an email with the voucher code. You will, then, have to register with Pearson Vue on for the test. Provide them the voucher code Zend gave you. Then, you can pick a date when you want to take the test, and take it.

After buying the voucher you have a year to use it before it expires. You can set an exam date that’s more than year away as long as you register for the test within the year on buying the voucher. My voucher was going to expire in November 2011 so I registered for the test one day before the expiration date and set the exam date to Jan 2012.

Preparing for the exam

The exam isn’t super hard but it’s not something you can pass without preparing for it. And, it looked like the people designing the questions put effort into it.

  • Download the Zend Certification Study Guide from their website and read it
  • Go to and read up on all functions related to strings, arrays, streams, the standard PHP library
  • I would recommend taking mock exams if you can get them. It will give you an idea about what type of questions to expect

Does getting the certification do anything for your career?

A lot of times, recruiters confuse Zend certification with , being certified for the Zend framework. Surprisingly, more than PHP certification, people have asked if I was certified for Zend framework.

The certification definitely helps give recruiters some confidence in hiring you over another developer but I wouldn’t say it catapulted my career to new heights. When I did the certification, I got a free perpetual license for Zend Studio which was nice. I, however, decided to ditch the free license and pay for PHPStorm.

Should you take the test?

I would say, yes. I studied for it for a little over a month and discovered gems of knowledge I probably wouldn’t have found otherwise. Taking the test and passing was a great experience for me.

So, if you can spare a few hundred dollars and put in some studying, I say go for it.

Here are some sample questions similar to what you might see in the PHP certification exam:

Which of the following cannot be used to set a cookie

  • setcookie
  • $_COOKIE
  • setrawcookie
  • header

What is the output of the following code


try {
    class MyCustomException extends Exception {}
    try {
        throw new MyCustomException();
    } catch (Exception $e) {
        print '1:';
        throw $e;
    } catch (MyCustomException $e1) {
        print '2:';
        throw $e1;
} catch (Exception $e) {
print get_class($e);

Which of the following can be used to traverse the file system:

  • ArrayObject
  • RecursiveDirectoryIterator
  • SplTmpFileInfo
  • TraversingIterator

How often will func() run?

function func(&x=0, &y=1)
if ($x > $y) {
$r = $x + $y;
$x = $y;
$y = $r;



Oaths in Islam – Part 2

Since I posted an article on “Oaths in Islam”, I have gotten quite a few questions from readers (most of which I have not published) asking me to clarify if an oath they took is valid or something else related to oaths they took. I figured I would write another article providing examples to help such people out.

First I’d like to state that I am not a scholar, or even a formal student of sacred knowledge. I just happen to like learning and get my knowledge from reading various books, articles and listening to lectures. I had written the original article as a reminder for me after having read articles about oaths on (now and other sources. Here is the original article, I am talking about: if you are curious.

My friend/whoever took an oath that they will do something bad to themselves if I don’t do what they want.

If your friend, or anyone else takes an oath to not eat (or harm themselves) until you do something, that is between them. You are not responsible for their oaths. If they break those oaths, they will have to pay kaffarah for it. It doesn’t affect you. No one can force you to do something by taking an oath. Allah will not hold you accountable for an oath someone else took.

I swore that I will not let my son/daughter do something (like play soccer), but I want to let them play it. What should I do?

Firstly, try not to take oaths you can’t keep. Secondly, if you break your oath, you will have to pay the kaffarah. If you don’t break that oath, then you son/daughter will not get to play soccer (or whatever you forbade them from) .


Go – Finding and removing duplicate files on a Mac

My laptop’s hard drive is plagued with the same family pics stored in different folders. So, I wrote a simple app in Go to take care of this for me. The app does this by comparing MD5 hashes of files.


Assuming you saved the code in a file called main.go, here is how you can use it to find duplicate files:

go run main.go -dir /some/dir -dir=/another/dir 

This will print duplicate files to the terminal. I added the flag `-dupe_action=sym` flag in the app which will sym-link all duplicates to one file.

go run main.go -dir /some/dir -dir=/another/dir -dupe_action=sym
package main

import (

// This type is here so we can accept a list of directories
type arrayFlags []string

func (r *arrayFlags) String() string {
	return "something"

func (r *arrayFlags) Set(value string) error {
	*r = append(*r, value)
	return nil

// getFilesInDirectories gets all the files in directories recursively
func getFilesInDirectories(dir []string) []string {
	var ret []string

	for _, item := range dir {
		// This could have been done with pure Go, but I was lazy             
		c := exec.Command(`find`, item, `-type`, `f`, `-iname`, `*.jpg`)
		outBytes, _ := c.Output()

		files := strings.Split(string(outBytes), "\n")
		for _, fileItem := range files {
			ret = append(ret, fileItem)

	return ret

// getFileMd5 returns the md5 hash of a file
func getFileMd5(path string) (string, error) {
	file, err := os.Open(path)
	if err != nil {
		return ``, err

	defer file.Close()

	hash := md5.New()
	if _, err := io.Copy(hash, file); err != nil {
		return ``, err

	hashInBytes := hash.Sum(nil)[:16]
	ret := hex.EncodeToString(hashInBytes)

	return ret, nil

func main() {
	var dupeAction string
	var lookInDirectories arrayFlags

	flag.StringVar(&dupeAction, "action", ``, `Action to take with duplicate files. Value: sym`)
	flag.Var(&lookInDirectories, `dir`, `Directory to look in`)


	// Get all relevant files
	output := getFilesInDirectories(lookInDirectories)

	fileMap := make(map[string][]string)
	for _, file := range output {
		hash, err := getFileMd5(file)
		if err != nil {
			fmt.Println("MD5_ERROR", file, err)
		fileMap[hash] = append(fileMap[hash], file)

	// Print dupes
	for _, item := range fileMap {
		// Do nothing if the file has no duplicates
		if len(item) <= 1 {

		firstFile := item[0]
		for i := 1; i < len(item); i++ {
			file := item[i]

			// Sym link dupes if flag was set
			if dupeAction == `sym` {
				err := os.Remove(file)
				if err != nil {
					fmt.Println(`Failed to delete `, file, err)
				exec.Command(`ln`, `-s`, firstFile, file).Run()


3D Printing

The future is here – with 3D printing. If anyone has seen Star Trek, they will know about the synthesizer used in the show to make (synthesize) anything from coffee to costumes to anything else. This is how I felt when I first got my 3D printer and started making (printing) things with it.

You can pretty much design and print anything. It is, however, not as fast as the ones on the show (or the movies). They take a while to print somethhing but they are precise and will make almost anything you want/need. I have printed a holder for dry-erase markers and cleaning spray (which turned out to be better than anything I have ever bought for it), green latern rings for the kids, toy cars and many other things. It is also not as expensive as I thought it would be. To be fair, there are printers out there that cost upwards of $10,000 but they are not meant for a hobby-ist.

I got my printer for (I am not kidding) $250 on a sale. It’s regular price is $300 (Monoprice maker select v2).The plastic it uses to print stuff cost me $14.00 and will print things that cost a lot more than that.I printed a car phone ring holder. Each ring holder in the store costs $20. I printed it for less than a dollar.

I will try and post pictures of things I have printed in another post and my experiences with my printer and 3D printing in general.

Go Uncategorized

Gogland build expired (renamed to Goland)

This confused me for a few minutes so I am writing this for those who have the same issue. Jetbrains renamed Gogland Goland. They also expired Gogland build. So you have to go to their site and download Goland and use that. Remove Gogland completely from your computer


Why Golang/Go is so awesome

I have been working with Go for quite some time now and know more about it. My initial thoughts about it were accurate, I think with some variations. Go really can do almost everything.

It can be run like any interpreted language for development and compiled for production

This is something I love about Go a lot. You can run any Go code by just typing:

go run someFile.go

And, you can compile your whole app into a binary, copy that binary to a production server and just run it. No dependencies needed. If you have assets that your app reads (like images, etc) , they can be compiled into the binary as well! This gives a whole new meaning to portability (at least for me).

It supports parallelism and concurrency

With Go routines, you can run multiple things at the same time (assuming you have a multi-core CPU). Go takes care of splitting your routines into multiple-threads and all the house-keeping chores that come along with it. It is, by far, the best multi-threaded language I have come across.

Many developers think Node supports parallelism but it doesn’t. Node is a great language for its asynchronous model but it executes only 1 thread at a time. Most scripting languages that I know of (Ruby, Python, etc) have this issue. They have a global interpreter lock, which makes sure only one thread executes at a time. So, they are concurrent but do not support parallelism (running multiple things at the same time).

Since, web servers spawns multiple processes for processing multiple HTTP requests, you don’t generally notice the bottleneck.

It has a unit testing framework in its standard library

It’s the first language, I’ve seen doing this. No need to install external libraries. The testing framework (in a package called “testing”) is very performant. It also lets you run benchmark tests and example code for generating documentation.

It has support for GUIs apps

There are a bunch of libraries in Go that will let you write native applications for Windows, Mac, etc. Go has bindings for GTK, QML, etc. Some Go libraries will even let you write hybrid apps (for desktop applications – will talk about mobile later).The content in these native UIs can be done using HTML/CSS. I tried this for a proof-of-concept app that generates configuration for a proprietary ETL tool at my work and it is so easy to do! The library I used was :

It has support for writing web services and web applications

Go, with it’s standard library has a templating engine built-in. And, it is very performant. No need to worry about which library to use for templating, etc. You can, with a few lines of code, create a web service!

There are quite a few features that make Go a great language to work with. I hope it proliferates the IT market so much that more companies ask for Go as a main requirement for jobs (and not just a nice-to-have).


How are paints made for various painting mediums?

Paints are made by adding pigment (color) to something that will help it stick to the surface of a canvas (or anything else it can be painted on).

Color, also referred to as pigment, is a powder with a specific color. For artist grade and premium grade paints this is ground up metal in most cases. Cobalt blue is made with Cobalt powder mixed into a medium.

For Student grade paints, the pigment is usually obtained by using a colored die and mixing it with chalk (the one you write on a black board with) or marble dust. This helps manufacturers reduce the cost of the paint.

Oil Paints
Oil paints are generally made by grinding the pigment powder with linseed oil. The grinding can be done by manually (with grinding stone, etc) or using a machine that can do it much faster.

Linseed oil has forms the most flexible film when it dries compared to other drying oils. The disadvantage of linseed oil is that it tends to yellow more than other oils over time. The other oil used for making oil paints is walnut oil, which doesn’t yellow as much but is forms a less flexible film than linseed oil does. It is, sometimes, mixed with linseed oil so the resultant paint will have a strong film and yellow less.

Cheaper oil paints tend to have less pigment and oil and more filler (marble dust, chalk or any other filler). Artists grade paints have less filler but they do contain some. Premium grade paints have no filler. They may, however, have stabilizers for certain pigments.

Acrylic paints
Acrylic paints are made by mixing pigment into acrylic emulsions (plastic). Like oil paints, artist grade acrylic paints have more pigment and than student grade paints.

Watercolor paints
The medium for watercolor paints is not water. It is gum arabic. Pigment added to gum arabic to make watercolors. Gum arabic is soluble in water which is why water can be used with watercolors as medium (to move the paint around, etc)

Egg Tempera
This is not as popular as the other 3 mediums but this has been around for a while. Egg tempera paints are made by mixing pigment into the egg yolk (not the egg white).

Encaustic paints
Encaustic paints are wax sticks that heated and the wax is used for painting while it is hot. When the wax dries it cannot be manipulated. Encausing paints are made by adding pigment to heated beeswax


Golang: Restart web server on file change

A great feature of scripting languages like PHP, Python and Ruby is that you don’t need to re-compile the app or restart a web server every time you change something. With Go, you need to restart the web server for your changes to take affect. This can be a pretty daunting task.

We can, however, have this feature in Go as well (with some extra code). We just need to write a file watcher that will restart the web server on any file changes. Below is working code (from a project I am building) that does exactly this. You can modify it to suit your needs or just put it in your project as is.

package main

// This file is: web/main_dev.go
// It will recursively monitor any path we are interested in and re-start the web server
// on any file changes
// web/main.go is where my web server code resides. You should change the code
// to your run the command you use for your web server in main() 

import (

// We will store all MD5 hashes of files we are interested in, in this variable
var fileHashes map[string]string

// Command to start the web server
var cmd *exec.Cmd

// Path we want to monitor for file changes
var pathToMonitor string

// fileMd5 calculates the md5 hash of a file
// Source obtained from
func fileMd5(filePath string) (string, error) {
    //Initialize variable returnMD5String now in case an error has to be returned
    var returnMD5String string

    //Open the passed argument and check for any error
    file, err := os.Open(filePath)
    if err != nil {
        return returnMD5String, err

    //Tell the program to call the following function when the current function returns
    defer file.Close()

    //Open a new hash interface to write to
    hash := md5.New()

    //Copy the file in the hash interface and check for any error
    if _, err := io.Copy(hash, file); err != nil {
        return returnMD5String, err

    //Get the 16 bytes hash
    hashInBytes := hash.Sum(nil)[:16]

    //Convert the bytes to a string
    returnMD5String = hex.EncodeToString(hashInBytes)

    return returnMD5String, nil


// fileWatcher monitors files and restarts the web server if any file changes
func fileWatcher() {
    for {
        filepath.Walk(pathToMonitor, func(path string, f os.FileInfo, err error) error {
            fileHash, err := fileMd5(path)
            if err != nil {
                //panic(`Could not calculate hash for ` + path)

            if _, ok := fileHashes[path]; !ok {
                fileHashes[path], _ = fileMd5(path)

            } else if fileHashes[path] != fileHash {
                fileHashes[path] = fileHash

                fmt.Println(`file changed`, path, ` . Restarting web server`)

            return nil


func main() {
    pathToMonitor = "./"

    // First we get MD5 hashes of all the files we want to monitor
    fileHashes = make(map[string]string)
    filepath.Walk(pathToMonitor, func(path string, f os.FileInfo, err error) error {
        fileHashes[path], _ = fileMd5(path)

        return nil

    // Start a file watcher go rountine that will monitor the files for
    // any changes
    go fileWatcher()

    // Run the web server
    fmt.Println(`Started server`)
    cmd = exec.Command(`go`, `run`, `web/main.go`)

    // Create a channel and wait on it. This is here so the main thread
    // exit
    doneChannel := make(chan bool)
    _ = <- doneChannel