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
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.

Golang: Get the function caller’s name

Problem

Consider this code:

In the function foo, we want to get the name of the function (and preferably file name and number ) that called it.

Solution

We can get this information by traversing the stack trace (which Go’s “runtime” package has handy functions for:

Golang: Connect to Postgres and selecting data from a table

You will need to get the Postgres driver first. In the terminal type:

Connecting to Postgres

Selecting data from a table

After connecting to the database, you can do the following:

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

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:

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

Golang: Make HTTP requests

A simple GET request can be made like this:

POST request:

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

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:

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

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

Go: Declaring and using objects

Go (or Golang) doesn’t have the concept of classes. The class equivalent in Go loos like this:

The above declaration can now be used as an object like so: