Category: Coding

  • Testing concurrent code in Golang

    I wrote a package which tracks certain hashtags on twitter and part of the package is adding and removing hashtag from list of hashtags. Plan is that this can be done from different goroutines hence tracking/untracking is done by putting hashtag in channels. It looks like this: var ( trackChan = make(chan string) untrackChan =…

  • Post embed codes of 8 popular social networks

    Here are embed codes for post of 8 popular social networks – from Facebook, YouTube, Twitter, Instagram, Reddit, Google+, Tumblr and Pinterest. I also wanted to include LinkedIn, but it doesn’t have such thing. Some observations: Facebook and YouTube have the simplest, one line of code (iframe), Instagram has the longest one. Pinterest has its…

  • Channels in Go

    Do not communicate by sharing memory; instead, share memory by communicating. Channels are for orchestration, mutexes are for serialization. Go Proverbs – Rob Pike Yesterday I wrote my first project ((It’s URL shorterer, a project which I write in every new programming language I learn.)) in Go which does not use traditional locks when dealing…

  • Table-driven tests are a good stuff

    In Go there is a great emphasize on writing a table-driven tests. Main goal of these tests is to reduce copy-pasting test skeleton from test to test where only input and expected output are changed. You first define an array of test cases where each test case contains input and expected output. Then you iterate…

  • Spread operator for faster JavaScript debugging

    Spread operator in JavaScript version ES2015 lets you explode array elements into arguments. That can be very useful when creating a new array consisting of all elements from another array ((so that you don’t mutate the latter)) or when calling a function with arguments that are in array ((equivalent to calling a function with .apply…