• Hello Python: Syntax Cheat Sheet

    A cheat sheet for the basic syntax and constructs of Python 3. It includes basic IO, conditionals, collections, functions, classes, modules and packages.

  • Hello Haskell, language introduction and cheat sheet

    Haskell is a statically typed pure functional programming language. This is more of a cheat sheet for basic haskell syntax and constructs. I will not describe in any details what is pure functional programming or what is static typing. Scala, Kotlin and now Java are a mixed paradigm programming languages, which are mixture of OOP with Functional programming. If you have used Scala or a modern version of Java or Kotlin, you should find familiar constructs. The only thing you will not find , is classes , objects or any other OOP constructs. You will find something called Type Classes that has nothing to do with classes in OOP, you can think of it as type categories or the closest OOP thing to it is interfaces.

  • Managing Cross Concerns using Proxy Pattern

    Cross concerns such as logging, instrumentation and authorization are like bad contractors. One needs them, but they tend to leave a mess. A cross concern violates the single responsibility principles which states that a class or a module should have one and only one reason to change. Violating this principle results in code that is difficult to understand with intertwined rules. The core business of the application gets buried under tons of unrelated code, which extends to tests as well. A test case will either test multiple unrelated concerns or duplicated for each concern.

  • Vim Plugins

    While you can manually install, remove and update Vim Plugins, it is a tedious process. There are two well known plugin managers for Vim, Github: Vundle and Github: Vim-Plug. After short reading one both, it seems to me that Vundle is no longer maintained in one hand and Vim-Plug has more appealing features on the other. So, I will for now try Vim-Plug.

  • Vim Configuration

    Configure Vim to have your own keyboard mapping, custom commands or change vim settings. We will look on how to do that and a couple of useful configurations that worked for me. Vim configurations live in ~/.vimrc. A shortcut to edit a file is :e $MYVIMRC. Finally, comments start with a single quotation mark ".

  • Vim Cheat Sheet

    I used Vim every now and then when I needed to do a quick file editing in the terminal. I was reluctant to take the learning curve until very recently. My IDE of choice is struggling with a relatively large codebase. I found many of my colleagues flying through source code using Vim. This changed my position on the learning curve. Now, I the potential IDE legginess justifies the learning time. Besides, Vim is cool.

  • My First Drawing Lesson: It's All About the Lines!

    My dad has been trying to convince me to do something non-technical for a while, to find a hobby where I don’t write code. I didn’t think I have ever had it in me. I tried music before, and I sold my brand-new guitar in less than a month. I have doodled a lot, but my drawing—well, it is an insult to call them art. You might understand why I never got into it. I always believed that I am channeling my creativity through code.

  • Github Pages, Markdown and Jekyll tips and tricks

    This page will include some tricks I have learned with Jekyll, Markdown and Github Pages.

  • How to setup github pages with an https custom domain?

    Github pages is one of the simplest ways to blog, or to have a simple static site. However, routing your own domain to Github pages can be tricky. It is mostly a matter of correct configurations and patience. You need first to configure your domain or sub-domain to point to Github and then configure Github to recognize the routing. Finally, setting up HTTPS, which should work by just checking a single checkbox, but when it doesn’t, it is tough to know what to do next.

  • Type Classes

    Type classes have been a blocker between me and getting a further understanding of the beauty of Functional Programming in Scala. Materials covering the matter tend to be mixed with a complex business problem or more likely some parser or JSON converter. I tried to strip all that away and create a step by step tutorial on how type classes work. I start with a TL;DR for both the inpatient and my future self. I would encourage you to go through the following sections where I go over the motivation for having type classes and how we tidy our way into a cleaner implementation. I left the theory and housekeeping until the end. You can go through the resources for more complex examples on the topic.

  • Unidirectional Channels

    In the unbuffered channels post final example countUp(counts chan int) will always send values to the channel while printOutput(counts chan int) will always receive values from the channel. We can make that explicit in the type of the channel. The countUp argument will be counts chan <- int to signal a channel that only receives values. and the printOut argument will be counts <- chan int to signal a channel that only produces value. Feel free to check the final implementation on Go Playground.

  • Unbuffered Channels

    Channels are Go’s mechanism for communication between goroutines(think lightweight parallel threads). One can send a message from one goroutine to the other.

  • Goroutines

    We can think of a goroutine, as a lightweight thread. When a new program starts by calling main it starts in a goroutine, conveniently called the main goroutine. We can invoke a function in a new goroutine by prefixing the function call by the keyword go.

  • Ruby Conditionals: if, else, elseif and unless

    There is the if statement similar to any other language you came from

  • Interfaces

    There is no inheritance in Go, but there are interfaces! Interfaces has methods and any type having the same methods satisfies that interface. In that sense, that type is an instance of that interface. So, in Go, you will not find extends or with. It just happens. In my personal opinion, you lose a bit of type self-documentation. Thus, there is no override either. So, unless I discover something interesting, you might rename a method and no longer satisfy an interface that the type used to.

  • Functions

    Functions in Go are first class citizens. Function may return one or more arguments. They may take a function as an argument. We cover these topics here. We take a look at variadic functions in Go, which are functions that take zero or more arguments. A deferred function is a function that is executed at the end of the execution of its enclosing function.

  • Pimp My Library Pattern

    Pimp my Library is a term coined by Martin Odersky explaining how Scala gives you the option of enriching types that you might not own. It comes to mined when you think about how methods can only have receivers in the same package. It turns out it is possible to create methods for receivers you don’t own and hence extend existing types or other libraries. There are other advantages of this of course. Let’s have a look at enriching int. We will just add a method Increment to int. This is redundant of course to +1 or ++ but it is a simple example in one hand, and it is immutable on the other.

  • Methods

    Let’s create a simple type, account which has one field money, we will create a one method add which will add some money to the account.

  • Error Handling and Recovery

    Go Functions may have multiple return values, by convention the last result is an error indicator or an error. An error indicator is a boolean that will evaluate to true if there is no errors.

  • Collections

    Go collections is very easy to learn. We have arrays and its close cousin slices. Then there are maps and that’s it. You can form a set using map keys as values. We will see how to create each of these types. How can we iterate through each of those types. We will see how to add an element to an existing collection.

  • Commandline Arguments and Flags

    Go has a different way compared to languages such as Java, Scala and C in handling commandline arguments and flags. There are built in utility to generate commandline help message and assign default values to flags. One can create flags that maps to more complex data types.

  • Type, Struct, Type Embedding and Constants

    type is not a type alias, which is different than Scala for an example. The new type is not compatible, assignable or comparable to the original type. In my mind this is better than type aliasing because type aliasing, if overused, is in many cases redundant and confusing. type timeInSeconds int and type timeInMilliSeconds int are not compatible. You need to cast from one to the other (or just for correctness to int and then to the other) to convert.