Moazzam's Ramblings

12Jul/150

My misadventures with paint brushes and pig hair

When I started painting about a year ago, I knew that I was not allowed to use any brush made of human hair (Islam forbids it to the best of my knowledge). Human hair was very common for soft brushes a few years ago so I took extra pre-cautions and made sure I didn't buy anything that contained human hair.

Until recently, what I did not know was that brushes made of pig hair are just as common and sought after by professional artists. Whenever an artist referred to a "hog bristle brush" I thought hedgehog hair was used in making that brush (don't ask me why). You can imagine how disturbed I was when I realized hog bristle actually made of pig hair. "Hog" actually referred to pig.

Anything that says "bristle brush", "natural bristle brush", "hog bristle brush", "china bristle", "chungking", etc is made from pig hair

After having learned this, I began to wonder what else is made of pig hair. My investigation surprised me even more. All cheap brushes that claim to be made of "natural bristles" are made from pig hair. Same goes for "bristle" brush. Even more shocking to me was that food brushes are also made of (you guessed it) pig hair. We don't use brushes to glaze anything in my home but I wonder if there are other Muslims who do (and if they know what their brush is made out of).

We all know eating pork is haram. However, after going through some Islamic sites, I found out that using brushes made of pig hair is actually allowed but it is disliked. There is, however, a minority of scholars who consider it to be haram (I leave it up to you - the reader - to do your own research and come to a conclusion on the matter).

Even if using brushes made of pig hair is allowed for external purposes (painting, combing hair, etc) I would not want to use a food brush made made of "natural bristles" to glaze my food. I have learned how to identify if a brush is made of natural bristles so I can avoid them (maybe I will make another post with details) but for the masses that don't - be careful :). Use synthetic brushes as much as you can.

Hog bristle food brush
(Natural bristle food brush)

Filed under: Painting No Comments
12Jul/150

Synthetic alternative to hog bristle brushes

I will add more brushes as I come across them but here is a line of brushes I have fallen in love with :

http://www.dickblick.com/products/princeton-catalyst-polytip-bristle-brushes/

I bought a few of these brushes and had a chance to try the fan brush. It has become my favorite. Their fan brush is almost as stiff as a hog bristle brush and retains its shape well. I, mostly, paint sceneries with a lot of grass and this brush covered a lot of area in a very short time.

One thing to keep in mind when using their fan brush (like all synthetic fan brushes) is to make sure the paint is not very thick. The brush bristles tend to clump up (more than natural bristle brushes) when there is not enough water in the paint.

The next line of brushes I am going to try (specifically fan and round brushes) are these: http://www.dickblick.com/products/princeton-series-6300-best-synthetic-bristle-brushes/#items. The Princeton 6300 series of brushes is supposed to be as stiff as the natural hog bristle brushes.

12Jul/150

A big $1.00 peel off palette for acrylic paints

I took up painting as a hobby about a year ago which is when my search for the perfect palette began. After having searched for an easy to clean but inexpensive palette, I came across this at my local Walmart:

null

http://www.walmart.com/ip/Polypropylene-10-Double-Wall-Dinner-Plate-Set-of-6/44198302

I got 2 of these plates and have been using them. They require no effort to clean (like you would expect from a peel off palette).

I have come across artists who use use-and-throw plastic plates as palettes. However, I find these plates are better as they are more durable.

Filed under: Painting No Comments
5Jul/150

Some very cool features in PHP7

I played around with PHP7 over the weekend and I have to admit it has some very cool things I have wanted PHP to have for a while, and then some. Here are some of them (in no particular order):

  • Performance

    PHP7 will increase the performance of PHP scripts by 50-60%. Nuff said.

  • Anonymous Classes

    I have always been able to do this in Java where I can just define a required object and pass it along.
    Now, you can do the same in PHP (I know that it is a double-edged sword and can leave your code un-organized
    if not used wisely). Here is an example:

    <?php
    // Let's say we want to log db inserts for whatever reason
     
    $db->addInsertListener(new Class implements DbInsertObserver {
    	public function log($sql)
    	{
    		// log here 
    	}
    });

    This can be pretty useful if all you are troubleshooting a production-only issue. Ideally, your testing
    environment will be exactly like your production environment. And, you are able to re-produce every production
    bug in QA but real world is rarely meets ideal standards. We, now, have anonymous classes to help.

  • Scalar type-hinting and Return type hinting

    Ever since PHP introduced type-hinting, I have been using it everywhere I can. It helps with static analysis of code
    and helps prevent bugs (although I love the freedom that comes with PHP not being a statically typed language).

    Note: like previous versions of PHP, PHP7 will not force its user (the PHP developer) to type-hint anything. So, old scripts
    will still work.

    <?php
    // The : int is how you declare the type that will be returned
    function doSomething(int $num) : int
    {
    	return $num + 10; 
    }
  • Removal of date.timezone warning

    Every time you use a date method, PHP would throw a warning if you didn't have a default timezone set in php.ini
    or in your code (using date_timezone_default_set()). PHP would default to UTC and throw the warning. This warning
    has been removed in PHP7. Good riddance.

  • Null Coalesce Operator

    Also called the isset ternary operator, gives you a more convenient way of ... doing this:

    // Before PHP7
    $someVar = isset($someArray['some_key']) ? $someArray['some_key'] : 'default value';
     
    // In PHP7
    $someVar = $someArray['some_key'] ?? 'default value';

There are more cool and useful features I have not mentioned here. You can read about them here: https://wiki.php.net/rfc

Tagged as: No Comments
29Jun/150

PHPSpec: Mocking methods of the object being tested

PHPSpec is very opinionated and won't let you mock anything of an object being tested. It helps you write better code. This, however, causes issues when you are writing specs for legacy code which (usually) was not well designed.

There is a way you can get around this limitation - a child class. Let's say the class you want to test is called "Car" and it has a method called "getNumberOfDoors" that you need to mock. Just write a child class and mock the method in it. Here is the code:

 
// Car.php
class Car
{
    // We want to test this method
    public function isSportsCar()
    {
        return $this->getNumberOfDoors() <= 3;
    }
 
    // It would make life much easier if we can mock this method
    // to test isSportsCar() method above
    public function getNumberOfDoors()
    {
        return 4;
    }
}
 
// CarSpec.php
 
// ..namespace and use statements here .. 
 
class CarSpec extends ObjectBehavior
{
    public function let()
    {
        $this->beADoubleOf('CarSpy');
    }
 
    public function it_can_identify_car_type()
    {
        // And viola! we can test to our heart's content for all possible
        // edge cases
 
        $this->setNumberOfDoors(2);
        $this->getNumberOfDoors()->shouldReturn(true);
    }
}
 
// The child class which we can use to manipulate the actual class
// we want to test
class CarSpy extends Car
{
    protected $numDoors;
 
    public function getNumberOfDoors()
    {
       return $this->numDoors;
    }
 
    public function setNumberOfDoors($val)
    {
        $this->numDoors = $val;
    }
}
28May/145

Ergodox: Make LEDs indicate the layer you are on

This article assumes that you are working with the source code downloaded from MassDrop.

Open the file lib /key-functions/public/basic.c and add the following line below after all the #define statements.

extern uint8_t keyboard_leds;

Then go to the push function of the layer you want the LEDs to light up on. Let's assume we want to turn on NumLock LED when layer 2 is active. In kbfun_layer_push_2 function, we add the following line:

keyboard_leds = 0x01;

So the function will look like this:

/*
 * [name]
 *   Layer push #2
 *
 * [description]
 *   Push a layer element containing the layer value specified in the keymap to
 *   the top of the stack, and record the id of that layer element
 */
void kbfun_layer_push_2(void) {
	keyboard_leds = keyboard_leds | 0x01;
	layer_push(2);
}
 
/*
 * [name]
 *   Layer pop #2
 *
 * [description]
 *   Pop the layer element created by the corresponding "layer push" function
 *   out of the layer stack (no matter where it is in the stack, without
 *   touching any other elements)
 */
void kbfun_layer_pop_2(void) {
	keyboard_leds = keyboard_leds &amp; ~(uint8_t)0x01;
	layer_pop(2);
}

You will notice that there is a keyboard_leds = keyboard_leds & 0x01 in the pop function for layer 2. This will turn the LED off when we exit the layer. For CapsLock LED set keyboard_leds to 0x02 and set it to 0x04 for scroll lock.

What if you want to turn on multiple LEDs when you are on a specific layer? If you want the NumLock and Scroll Lock LED to turn on when you are on layer 2, you would write the following:

keyboard_leds = keyboard_leds | 0x01 | 0x02; 
 
//To turn them off
keyboard_leds = keyboard_leds & ~(uint8_t)0x01 & ~(uint8_t)0x02;
Tagged as: 5 Comments
26May/140

Ergodox – The customizable ergonomic split keyboard

A few months ago, I got a mechanical keyboard called Ergodox. It is an open source keyboard (which means its schematics are posted online for anyone who wants to build it.) that you need to build yourself. You cannot buy it pre-built. Although, recently people have been putting up Ergodox with Cherry MX blue switches.

It has 2 halves (like every other split keyboard) that are separated by a wire. And, you can put the two pieces as far or as close as you want. I usually have a 6-7 inch separation between them.

Why did I get it?

I hated the placement of the apple command key on regular keyboard and wanted it to be in a more convenient place so I set out to search for keyboards that have it placed more to the middle. Das seemed like a great choice for this as their alt key is located below the letter C (not below X where it usually is) but I still wasn't satisfied. So, after some research I found out about Ergodox.

I did quite a bit of research (read reviews, visited geekhack, etc) and decide to take a leap of faith and just get one for myself. Massdrop was doing a group buy and it was going for cheap so I joined the group buy and received it in about 2 months.

Ergodox's design is heavily influenced by Kinesis Advantage which is an amazing keyboard in its own right. I love that they (both Ergodox and Kinesis Advantage) have a thumb cluster (a set of keys intended for use by the thumb).

It uses Teensy to register key presses and you can make any key register anything you want. You can choose to have a qwerty, colemak, dvorak or a custom layout. For alphabets, I use qwerty layout but for other things I have it customized to help me program. You can find a link to my layout at the bottom of this post.

The Good

You can customize pretty much anything you want. You can have one layout or multiple layouts. Very few keyboards let you do that and those that do, have a limited selection of layouts you can use. With Ergodox, you can make your own layout, if you wanted.

If you know a little C you can even customize the LEDs. Usually the LEDs are used to indicate if caps lock or num lock is on (I don't think anyone uses or cares about scroll lock). I have never needed to use caps lock or num lock so I programmed my Ergodox to tell me which layer I am on (I use one layout for regular use and another for gaming and I have another layer for multimedia keys like volume control, etc).

The thing I love a lot about Ergodox is the thumb cluster. I have found it to be very useful. It has reduced my hand travel by quite a bit and this has, in turn, reduced the typing mistakes I make.

It is truly a split keyboard. You can have the two halves of Ergodox as far or close as you want. You can also detach the wire separating them for easy storage.

The Bad

There is a big learning curve initially - just like if you moved to Kinesis Advantage from a regular keyboard. So, you will have to be patient with it for the first month. I got fairly comfortable with it in a week but it took me about a month or two to treat it like an extension of my hand.

You have to wait about 2 months to get it after you order it (if you want it for a cheaper price). Or, spend over 500 dollars.

You cannot order it whenever you want if you want to get it for an affordable price. Massdrop, which is pretty much the only distributor that sells Ergodox for an affordable price, does a group buy every 2-3 months. So, if you miss the drop you have to wait 2-3 months to get it.

Ergodox cannot wake up your Mac from sleep. If your computer is in hybernation or sleep then hitting a key on the keyboard will wake it up. This is not the case with Ergodox. So, you will need to use your mouse to wake your computer up.

Although, if you connect your Ergodox to your computer through a USB hub then it will be able to wake the computer up (but not when Ergodox is connected to the computer directly).

Conclusion

I have been using Ergodox for over 3 months now and I don't want to use any other keyboard. I love it so much that I take it to work and back home since I have just one. Although, will be getting another one for work because I don't want to carry it everyday.

I have been tweaking it ever since I got it. Moulding it to my needs - making my life easier as I keep using it. I have had a complaint with all the keyboards I have ever used including Kinesis freestyle 2 and Kinesis Advantage. For the most part, you can't do anything about it but with Ergodox you can and there is a huge community of people at geekhack to help you.

It is, however, not for everyone. My friend tried it and said he preferred the staggered layout of a regular keyboard vs the matrix layout of Ergodox. I have found matrix layer to be better for me when typing. So, it is all subjective.

The keycaps that Massdrop sells for Ergodox make it hard to use the top row in the thumb cluster. However, Signature plastics sells DCS R5 keycaps on their website that make using those keys so much easier. Kinesis Advantage does the same thing.

If you can afford it, I suggest you try Ergodox out and if you don't like it you can sell it on Ebay for nearly its cost price and maybe even more than it.

Ergodox's website: http://ergodox.org
Massdrop: http://massdrop.com
My layout (which keeps changing): https://www.massdrop.com/ext/ergodox/?referer=79XXDG&hash=c7c8e22d2b149739fe6c43a1c8d33286

Filed under: Uncategorized No Comments
22Feb/140

My mechanical keyboard

In my last post, I talked about mechanical keyboards and how great they are to type on. I figured I would show you guys what my keyboard looked like. I have a Corsair K60 with custom key caps (well some of them are custom). Corsair did a great job with the keyboard and the only thing I didn't like about this keyboard is that the right shift wasn't smooth to press if I were to press it on the edge. I, accidentally, solved this problem by changing the keycaps. So here is what my keyboard looks like:

Filed under: Uncategorized No Comments
22Feb/140

Mechanical keyboards

Between work and personal projects, programmers tend to type 8 or more hours a day and it helps to have a keyboard you can type on comfortably. Something that wont kill your fingers or your hands over time. Mechanical keyboards fill this need. They have taken the gaming world by a storm and a lot of the hard core programmers I know don't like using anything else. Now that more and more companies have started to offer mechanical keyboards as part of their lineup, it is really easy to get your hands on one.

For those who don't know what mechanical keyboards are, you can read about them here: http://en.wikipedia.org/wiki/Keyboard_technology. I got interested in them because my Dell keyboard (the one that comes free when you buy a PC) was starting to feel like I had to fight it to type anything. This made me start looking for an alternative. The first mechanical keyboard I tried was a DAS keyboard and now I don't ever want to use a rubber dome keyboard ever again (except Kinesis freestyle 2).

Mechanical keyboards are a treat to type on and come in many shapes and sizes. If your fingers hurt when you type on a regular keyboard I highly recommend that you get a mechanical one. You don't have to press the keys all the way to the bottom for the computer to know you pressed a key. This means your fingers face less resistance when typing. You will, however, have to practice not bottoming-out the keys (pressing the keys all the way to the bottom).

If this has made interested in mechanical keyboards and you want to get one. Here are some I recommend looking into:

  • Filco Ninja or Majestouch 2 keyboards. Filco is, hands down, the best keyboard maker. Their keyboards are not backlit and don't have macro support but their build quality is the best. Amazon is the only reseller that sells these in USA.
  • Ducky Shine. Ducky is more of the higher end mechanical keyboards and they have the best backlit keyboards.
  • DAS keyboard. DAS has been making keyboards for quite some time now and I love their design. Their keyboards, like Filco, are also not backlit
  • Ergodox. This is an open source keyboard you will have to make yourself but it is very ergonomic and you get the satisfaction of having made your own keyboard.
  • Fully mechanical keyboards by Corsair. Corsair has some very original designs for their keyboards. Their keyboards have no bezel making it really easy to clean them. Starting from K70, they are backlit.
  • Filed under: Uncategorized No Comments
3Feb/142

Corsair k60 OSX issues

I got a Corsair K60 a few months ago and fell in love with it. It is a mechanical keyboard (my first mechanical keyboard) with Cherry MX red switches. There is, however, one problem with it. The caps lock LED is always on and the LEDs for num lock and scroll lock are always off.

This affects all models of Corsair keyboards as far as I know. Why they don't just add support for Macs? I don't know. It can't hurt. It is just another HID device.

The keyboard will toggle caps lock when you press it but it won't change the state of the LED. So, like any sensible person I set out to fix the damn LEDs. And, let me tell you it was not an easy task (considering I have not programmed a single line in objective C before this or written any hardware drivers in any language).

After spending the whole weekend on it, I was able to write a program that will listen for key strokes from k60. Now, I have to figure out how to toggle the LED when caps lock is pressed and I will be able to have a normal functioning keyboard.