Categories
Uncategorized

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 .



Categories
Uncategorized

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 golang.org/x/tools , etc .

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

brew remove go --ignore-dependencies
Categories
Uncategorized

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 http://pearsonvue.com/ 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 php.net 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

<?php

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) {
return;
}
$r = $x + $y;
$x = $y;
$y = $r;
}

func()

Categories
Uncategorized

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.

Categories
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

Categories
Uncategorized

Earn more by learning Go!

According to this article a friend forwarded to me, software developers who learn Go, Python or Scala (along with tech like Apache Spark) have found it easier to find jobs with better salaries. Learning Scala caused the highest boost and in the second place was Go.

Learning python is a bit subjective in terms of getting a raise. It depends on what you are doing and which field you are in. So the increase in income with Python isn’t as consistent as it is with the other 2 languages.

Here is the article in detail: http://www.infoworld.com/article/3071623/salary/want-to-boost-your-salary-learn-scala-golang-or-python.html

Categories
Uncategorized

Golang: Testing HTTP requests

Unit testing HTTP calls to external services is pretty easy in Go. Let’s say we have some code that makes HTTP requests like so:

package something

import (
    "net/http"
)

func SomeFunc(url) string {
    rs, _ := http.Get(url)
    defer rs.Body.Close()
    body, _ := ioutil.ReadAll(rs)

    return string(body)   
}

We can test if the request is made and we get the response we want by mocking the external service. Below is the code:

package something

import (
    "net/http/httptest"
)

/**
This code uses Ginkgo and Gomega for unit tests but this can be easily adopted to any other framework or vanilla Go tests
**/
var _ = Describe("It makes HTTP requests", func () {
    Context("In some context", func () {
        It("makes an HTTP response which returns something", func() {
            server := httptest.NewServer(http.HandlerFunc(func(rs http.ResponseWriter, rq *http.Request) {
                if rq.RequestURI == `/` {
                    content := "Hello"
                    if err != nil {
                        fmt.Println("FL", err)
                    }
                    rs.Write(content)
                }
            }))
            defer server.Close()

            // If we were testing for the response, we do assert it.  
            Expect(someFunc(server.URL)).To(Equal("Hello")
        }
    })
})
Categories
Uncategorized

Golang: Make HTTP requests

A simple GET request can be made like this:

package main

import (
    "net/http"
    "ioutil"
)

func main() {
    // Make a get request
    rs, err := http.Get("https://google.com")
    // Process response
    if err != nil {
        panic(err) // More idiomatic way would be to print the error and die unless it's a serious error
    }
    defer rs.Body.Close()

    bodyBytes, err := ioutil.ReadAll(rs.Body)
    if err != nil {
        panic(err)
    }

    bodyString := string(bodyBytes)
}

POST request:

import (
    "bytes"
)
func main() {
    body := []byte("key1=val1&key2=val2")
    rs, err := http.Post("http://someurl.com", "body/type", bytes.NewBuffer(body))
    // Code to process response (written in Get request snippet) goes here

    // Simulating a form post is done like this:
    rs, err := http.PostForm("http://example.com/form",
                            url.Values{"key": {"Value"}, "id": {"123"}})
    // Code to process response (written in Get request snippet) goes here
}

If more control is needed, like specifying headers, cookies, etc:

// ...
client := &http.Client{}
req, err := http.NewRequest("GET", "http://example.com", nil)
req.Header.Add("If-None-Match", `some value`)
resp, err := client.Do(req)
// Code to process response
Categories
Uncategorized

Golang: Polymorphism

Polymorphism is a bit different in Go. It supports polymorphism only through interfaces (and not through inheritance). To help you understand better, here is an example:

import "fmt"

type Car interface {
    func Drive()
}

type Lamborgini struct {
    // Implement the Car interface
    func Drive() {
        fmt.Println("Driving")
    }
}

func driveACar(car Car) {
    car.Drive()
}

// This will work 
lambo := new(Lamborgini)
lambo.Drive() // Will work 
driveACar(lambo)  // Will print "Driving"

However, Polymorphism doesn’t work when driveACar(lammborgini) would not work if Car was a struct and not an interface. Here is an example:

import "fmt"

type Car struct {
    func Drive() {
        fmt.Println("Driving")
    }
}

type Lamborgini struct {
    Car
}

func driveACar(car Car) {
    car.Drive()
}

lambo := new(Lamborgini)
lambo.Drive() // Will call car's Drive method and will work
driveACar(lambo)  // Will throw an error
Categories
Uncategorized

Don’t waste time

A friend of mine sent me an interesting quote by Imam Ghazali which puts things in perspective.

Your time should not be without any structure, such that you occupy yourself arbitrarily with whatever comes along.
Rather, you must take account of yourself and order your worship during the day and the night, assigning to each period of time an activity that must not be neglected nor replaced by another activity.
By this ordering of time, the blessing in time will show itself. A person who leaves himself without a plan as animals do, not knowing what he is to do at any given moment, will spend most of his time fruitlessly.
Your time is your life, and your life is your capital: by it you make your trade, and by it you will reach the eternal bounties in the proximity of Allah.
Every single breath of yours is a priceless jewel, because it is irreplaceable; once it is gone, there is no return for it.
So do not be like fools who rejoice each day as their wealth increases while their lives decrease. What good is there in wealth that increases while one’s lifespan decreases?
Do not rejoice except in an increase of knowledge or an increase of good works.
Truly they are your two friends who will accompany you in your grave, when your spouse, your wealth, your children, and your friends will remain behind.
— Imam al-Ghazali