Category: 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 }…

  • 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()…

  • 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…

  • Go: Declaring and using objects

    Go (or Golang) doesn’t have the concept of classes. The class equivalent in Go loos like this: // Make a Car class equivalent type Car struct { // object properties go here doors int } // Get the number of doors func (car *Car) Doors() int { return car.doors } // Set the number of…

  • First impressions of Go

    I have been in search for a language I can use for web programming, writing computationally intensive and general scripting among other things. The language that came close to fitting all of these things was Racket, a dialect of Chicken Lisp. It can even do geometry drawings. However, there were issues with it so I…

  • Programming Macros for Ergodox

    The default configuration tool on Input Club or Massdrop don’t allow for macro programming. So you will have to get your hands dirty and mess with the firmware code a little. It’s not hard. Run the following commands on your terminal to clone Ben Blazak’s firmware code from github and create a custom layout for…

  • What should I learn?

    This is a question I get asked a lot. Mostly by those who are just starting off their career as programmers/developers, but often times also by veterans of IT field. Recently, I found myself asking that question when I came to the realization that PHP, as a language was not as much in demand as…

  • Macports Ruby: Symbol not found: _SSLv2_client_method error

    This error usually shows up when you try to run the following command: sudo gem install For those that don’t know what I am talking about, this is the error message: ERROR: Loading command: install (LoadError) dlopen(/opt/local/lib/ruby2.2/2.2.0/x86_64-darwin15/openssl.bundle, 9): Symbol not found: _SSLv2_client_method Referenced from: /opt/local/lib/ruby2.2/2.2.0/x86_64-darwin15/openssl.bundle Expected in: /opt/local/lib/libssl.1.0.0.dylib in /opt/local/lib/ruby2.2/2.2.0/x86_64-darwin15/openssl.bundle – /opt/local/lib/ruby2.2/2.2.0/x86_64-darwin15/openssl.bundle The only way…

  • Setting, removing and reading cookies in Javascript

    Copy/paste these methods and use them /** * Create a cookie * * @param string name * @param mixed value * @param int days */ function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = “; expires=”+date.toGMTString(); } else var expires = “”; document.cookie = name+”=”+value+expires+”; path=/”; } /** *…

  • Sunlit Garden

    I have been painting landscapes mostly so I wanted to try something different this time. Another reason I wanted to do this painting is to experiment with sunlight (and little details like the gate) change how the viewer feels when he/she looks at the painting. Thankfully, my experiment was successful. Here is the painting: I…