-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.xml
More file actions
265 lines (265 loc) · 44.5 KB
/
index.xml
File metadata and controls
265 lines (265 loc) · 44.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Blog</title>
<link>https://www.usman.me.uk/</link>
<description>Recent content on Blog</description>
<generator>Hugo</generator>
<language>en-gb</language>
<copyright>Usman Mahmood</copyright>
<lastBuildDate>Mon, 19 Jan 2026 23:34:59 +0000</lastBuildDate>
<atom:link href="https://www.usman.me.uk/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>LLM: Understanding Tokens</title>
<link>https://www.usman.me.uk/posts/llm-tokens/</link>
<pubDate>Mon, 19 Jan 2026 23:34:59 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/llm-tokens/</guid>
<description><h2 id="overview">Overview</h2>
<ul>
<li>Understand why tokens are the currency of LLMs</li>
<li>Learn how tokenisers split words into tokens</li>
<li>Why tokens are different across LLM providers</li>
<li>How the costs of tokens are calculated</li>
<li>Understand token limits</li>
</ul>
<h2 id="introduction">Introduction</h2>
<p>In this post, we look deeper into tokens, and how they relate to Large Language Models (LLMs). If you have read any API documentation or any other technical content relating to LLMs, you will have come across the term tokens. Tokens are fundamental to LLMs, and understanding them is vital when learning how LLMs work under the hood.</p></description>
</item>
<item>
<title>LLM: Understanding Log Probabilities</title>
<link>https://www.usman.me.uk/posts/llm-logprob/</link>
<pubDate>Mon, 12 Jan 2026 23:34:59 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/llm-logprob/</guid>
<description><h2 id="overview">Overview</h2>
<ul>
<li>Learn what token log probabilities are.</li>
<li>Understand and use the <em>logprobs</em> parameter.</li>
<li>Learn the practical use cases for log probabilities.</li>
</ul>
<h2 id="introduction">Introduction</h2>
<p>In this blog post, we will discuss what LLM log probabilities are, also known as <em>logprobs</em>. We will use the OpenAI API to retrieve the log probabilities of individual tokens output in response to user prompts. We will write some code to understand what we can do when we have this extra information returned from the API. And finally, see some practical use cases of log probabilities.</p></description>
</item>
<item>
<title>LLM: Understanding The Temperature Parameter</title>
<link>https://www.usman.me.uk/posts/llm-temperature/</link>
<pubDate>Fri, 02 Jan 2026 23:51:24 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/llm-temperature/</guid>
<description><h2 id="overview">Overview</h2>
<ul>
<li>How tokens are the fundamental unit of LLMs.</li>
<li>Understand the token vocabulary and role it plays in LLMs.</li>
<li>Learn what the LLM temperature parameter is and how it works.</li>
<li>Understand why LLMs are non-deterministic.</li>
<li>The use cases where developers may adjust the temperature parameter.</li>
</ul>
<h2 id="introduction">Introduction</h2>
<p>During inference, a user can pass in various parameters into an LLM to guide its behaviour and the output it returns. One of those parameters is the temperature parameter, when this parameter is set to a low or high value it controls the randomness of the LLMs output. In this post we will dive deeper into the temperature parameter and explain what it is, its purpose, and have a look at what happens when you set the temperature to different values during LLM inference.</p></description>
</item>
<item>
<title>How Kubernetes Creates a Pod</title>
<link>https://www.usman.me.uk/posts/k8s-pod-creation/</link>
<pubDate>Mon, 01 Dec 2025 15:51:50 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/k8s-pod-creation/</guid>
<description><h2 id="overview">Overview</h2>
<ul>
<li>Learn the process Kubernetes goes through to create a Pod when you apply a manifest.</li>
</ul>
<h2 id="introduction">Introduction</h2>
<p>In this blog post, we will discuss the process that Kubernetes goes through to create a Pod. Kubernetes is made up of a number of components, and we will see how these various components coordinate with each other to deploy various manifests. A Pod is a group of containers and is the smallest unit that Kubernetes administers. Kubernetes manages Pods, not containers. Pods live on nodes, nodes live on machines.</p></description>
</item>
<item>
<title>Using Go's errgroup Package To Implement The Scatter Gather Pattern</title>
<link>https://www.usman.me.uk/posts/errgroup/</link>
<pubDate>Thu, 13 Nov 2025 13:45:31 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/errgroup/</guid>
<description><h2 id="overview">Overview</h2>
<ul>
<li>Package <em>errgroup</em> is a third party library available at <a href="https://pkg.go.dev/golang.org/x/sync/errgroup" target="_blank">golang.org/x/sync/errgroup</a>.</li>
<li>See example usage of package <em>errgroup</em> to manage a group of goroutines that are working on tasks.</li>
<li>Use <em>errgroup</em> to implement a design pattern called the Scatter Gather Pattern.</li>
</ul>
<h2 id="introduction">Introduction</h2>
<p>In this post, we will talk about Go&rsquo;s <em>errgroup</em> package and use it to implement the Scatter Gather Pattern.</p>
<p>The package <em>errgroup</em> allows groups of goroutines working on subtasks of a common task to synchronize, propagate errors, and cancel context. This package is helpful because it takes care of the handling of tasks, managing, and returning errors. Without it, you may end up writing a lot of convoluted error handling code that makes your code harder to read and maintain.</p></description>
</item>
<item>
<title>Finding Performance Issues In Python Using Line Profiler</title>
<link>https://www.usman.me.uk/posts/line_profiler/</link>
<pubDate>Tue, 23 Sep 2025 15:17:50 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/line_profiler/</guid>
<description><h2 id="overview">Overview</h2>
<ul>
<li>Line profiler is a 3rd party library available on <a href="https://github.com/pyutils/line_profiler" target="_blank">GitHub</a>.</li>
<li>Line profiler package helps in identifying the cause of CPU-bound problems in Python code.</li>
<li>Gives you a data driven approach on where to allocate your time in order to fix performance issues.</li>
<li>Understand the output of line_profiler by working through a simple code example.</li>
</ul>
<h2 id="introduction">Introduction</h2>
<p>Python has established itself as a top tier programming language. As of late 2025 according to the <a href="https://www.tiobe.com/tiobe-index/" target="_blank">TIOBE</a> index, the top 3 languages as a measure of programming language popularity, are consistently Python, C, and C++, often with Python in the lead. This popularity and increase in use of Python has been driven by fields such as machine learning, artificial intelligence and data engineering. As these fields continue to grow and so does their use of Python, the performance of code matters more than ever.</p></description>
</item>
<item>
<title>Merkle Trees and Data Verification</title>
<link>https://www.usman.me.uk/posts/merkle-tree-verify/</link>
<pubDate>Tue, 23 Jun 2020 19:01:24 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/merkle-tree-verify/</guid>
<description><p>A Merkle tree is a binary tree where the nodes stores hashes of data, rather than the data itself. The leaf nodes store hashes of the data and the parent nodes are the results of concatenating the left and right children and then applying a hash function on the result.</p>
<p>To read more about Merkle trees go <a href="https://en.wikipedia.org/wiki/Merkle_tree" target="_blank">here</a>.</p>
<p>In this post, I will talk about how data verification is performed in Merkle trees.</p></description>
</item>
<item>
<title>Server-Sent Events (SSE) With Go</title>
<link>https://www.usman.me.uk/posts/sse-go/</link>
<pubDate>Fri, 08 May 2020 13:13:23 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/sse-go/</guid>
<description><p>Server-Sent Events (SSE) technology is best explained by this article on <a href="https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events" target="_blank">MDN</a>:</p>
<blockquote>
<p>The EventSource interface is used to receive Server-Sent Events. It connects to a server over HTTP and receives events in text/event-stream format without closing the connection.</p>
</blockquote>
<p>The connection is persistent and communication is one-way, from the server to the client, the client cannot push data to the server. This is unlike WebSockets where communication is bi-directional.</p>
<p>Some unique characteristics of SSE compared to WebSockets or long polling are:</p></description>
</item>
<item>
<title>Secure Tunnels with WireGuard</title>
<link>https://www.usman.me.uk/posts/wireguard/</link>
<pubDate>Mon, 23 Mar 2020 22:11:03 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/wireguard/</guid>
<description><p>Wireguard is a secure networking tunnel, it can be used for VPNs, connecting data centers together over the Internet, or any place where you need to connect two or more networks together in a secure way.</p>
<p>Wireguard is open source and it is designed to be much simpler to configure than other tools such as OpenVPN or IPSec.</p>
<p>Below, we are going to connect two computers together:</p>
<pre tabindex="0"><code>Machine A IP address 192.168.0.40
Machine B IP address 192.168.0.41
</code></pre><p>First, we need to install WireGuard on each machine:</p></description>
</item>
<item>
<title>Configuring Remote Connections with PostgreSQL</title>
<link>https://www.usman.me.uk/posts/conn-postgres/</link>
<pubDate>Thu, 13 Feb 2020 19:15:15 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/conn-postgres/</guid>
<description><p>If you need to access your PostgreSQL database from another machine, you need to edit the configuration, to make the database listen to incoming connections from other hosts. Below are the steps on how to do this.</p>
<p><strong>Note</strong>: Do not do this on your production database environment, It will open up a potential security flaw. This should be fine to do on your staging environment for testing purposes.</p>
<p>On the machine running PostgreSQL, locate configuration file <em>postgres.conf:</em></p></description>
</item>
<item>
<title>Compiling OpenVPN on the Raspberry Pi 3</title>
<link>https://www.usman.me.uk/posts/compile-openvpn/</link>
<pubDate>Sun, 15 Dec 2019 14:41:12 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/compile-openvpn/</guid>
<description><p>Recently I needed to upgrade the version of OpenVPN on my Raspberry Pi 3 Model B. Below are the steps needed to do this, here we upgrade to OpenVPN version 2.4.8.</p>
<pre tabindex="0"><code>$ cd /tmp
$ wget https://swupdate.openvpn.org/community/releases/openvpn-2.4.8.tar.gz
$ tar xf openvpn-2.4.8.tar.gz
$ cd openvpn-2.4.8/
$ sudo apt-get install libssl-dev
$ sudo apt-get install liblzo2-dev
$ sudo apt-get install libpam0g-dev
$ ./configure --prefix=/usr
$ sudo make
$ sudo make install
</code></pre><p>Verify that the new version installed:</p></description>
</item>
<item>
<title>Styling Markers on Mapbox Static Maps</title>
<link>https://www.usman.me.uk/posts/styling-markers-mapbox/</link>
<pubDate>Sat, 05 Oct 2019 16:12:46 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/styling-markers-mapbox/</guid>
<description><p>Recently I was using the python map-box api to generate static maps. I needed to
style the markers which pin pointed locations on the map. I found it difficult to
find the necessary documentation on how to do this. In the end it simply involved
adding the following fields:</p>
<ul>
<li>maker-colour (hex value).</li>
<li>marker-symbol (<a href="https://labs.mapbox.com/maki-icons/" target="_blank">Maki icon name</a>. an integer, or a lowercase letter).</li>
<li>marker-size (small, large).</li>
</ul>
<p>To the JSON like so:</p></description>
</item>
<item>
<title>Ignoring Directories When Backing up with Borg</title>
<link>https://www.usman.me.uk/posts/borg-ignore/</link>
<pubDate>Fri, 14 Sep 2018 20:36:32 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/borg-ignore/</guid>
<description><p>Borg backup has a <code>--exclude-if-present</code> flag, which allows you to ignore a directory from being backed up, If it contains a certain &rsquo;tag&rsquo; file.</p>
<p>So given the following directory structure, which we want to back up:</p>
<pre tabindex="0"><code>+ MyFiles
	+ dirA
		- file_one.pdf
		- file_two.pdf
	+ dirB
		- spreadsheet.xsl
		- image.png
</code></pre><p>If we want to ignore <code>dirB</code> from being backed up by borg, we have to create a tag file in that directory:</p></description>
</item>
<item>
<title>Tar Archiving Using Relative Paths</title>
<link>https://www.usman.me.uk/posts/tar_relative_path/</link>
<pubDate>Sat, 10 Mar 2018 15:40:39 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/tar_relative_path/</guid>
<description><p>If you want to archive a directory (using the tar command), but not include the absolute path to the directory. You can use the <strong>-C</strong> option to the tar command, which essentially cd&rsquo;s into the directory and then archives it. Here is an example:</p>
<pre tabindex="0"><code>$ tar czf /tmp/my_backup.tar.gz -C ~/home/coorp/my_files
</code></pre><p>When un-archived, the directory structure will be:</p>
<ul>
<li><em>/some_path/my_files</em></li>
</ul>
<p>And not:</p>
<ul>
<li><em>/some_path/home/coorp/my_files</em>.</li>
</ul>
<p>Fin.</p></description>
</item>
<item>
<title>Make 'echo %PATH' More Readable</title>
<link>https://www.usman.me.uk/posts/print-path-env-var/</link>
<pubDate>Sat, 18 Nov 2017 14:34:22 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/print-path-env-var/</guid>
<description><p>When you want to check the contents of your <em>$PATH</em> variable. To see which directories are in your session, you run the command:</p>
<pre tabindex="0"><code>$ echo $PATH
</code></pre><p>Output:</p>
<pre tabindex="0"><code>/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/local/sbin:/opt:/usr/local/go/bin:/usr/local/texlive/2015basic/bin/x86_64-darwin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/sbin:/opt:/usr/local/go/bin:/usr/local/texlive/2015basic/bin/x86_64-darwin
</code></pre><p>This is all well and good, but the output of the command can be hard to read if you have many directories in your path. What you want is a command that outputs the <em>$PATH</em> variable in an easier to read format. Luckily, this can accomplished with a little bit of bash code:</p></description>
</item>
<item>
<title>Piping Commands into Go Binaries</title>
<link>https://www.usman.me.uk/posts/pipe-cmds-go/</link>
<pubDate>Sun, 27 Aug 2017 18:31:37 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/pipe-cmds-go/</guid>
<description><p>In this post we will see how we can pipe commands into our Go applications. We will write a basic command line program which demonstrates the functionality. Before we get started, it&rsquo;s worth going over the basics of piping commands.</p>
<p>The modular nature of the UNIX operating system. Allows the user to use basic commands to build up new commands. By allowing the output of one command to be used as the input for the next command. The general form of the pipe command is:</p></description>
</item>
<item>
<title>Sync.Pool is Drained During Garbage Collection</title>
<link>https://www.usman.me.uk/posts/sync-pool-gc/</link>
<pubDate>Tue, 23 May 2017 21:31:37 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/sync-pool-gc/</guid>
<description><p>The Go sync.Pool type stores temporary objects, and provides get and put methods. Allowing you to cache allocated but unused items for later reuse. And relieving pressure on the garbage collector.</p>
<p>The purpose of the sync.Pool type is to reuse memory between garbage collections. Which is why sync.Pool is drained during garbage collection (GC).</p>
<p>Here is an example of how to use the sync pool:</p>
<pre tabindex="0"><code>package main

import (
	&#34;bytes&#34;
	&#34;fmt&#34;
	&#34;sync&#34;
)

var bufPool = sync.Pool{
	New: func() interface{} {
		return new(bytes.Buffer)
	},
}

func main() {
	b := bufPool.Get().(*bytes.Buffer)
	b.WriteString(&#34;What is past is prologue.&#34;)
	bufPool.Put(b)
	b = bufPool.Get().(*bytes.Buffer)
	fmt.Println(b.String())
}
</code></pre><p>Output:</p></description>
</item>
<item>
<title>Access Raspberry Pi Externally using ngrok</title>
<link>https://www.usman.me.uk/posts/external-access-pi-ngrok/</link>
<pubDate>Sun, 26 Feb 2017 00:15:59 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/external-access-pi-ngrok/</guid>
<description><p>In this blog post we will set up our Raspberry Pi so it will accessed using SSH from outside our home network. Below is a diagram of the architecture:</p>
<p>[ Home Network : Raspberry Pi ] &lt;&ndash; [ ngrok ] &ndash;&gt; [ External Network ]</p>
<p>From our home network we will create a secure tunnel, through ngrok. Which we will then connect to from our external network. This will allow us to SSH into our Raspberry Pi, and manage it.</p></description>
</item>
<item>
<title>Raspberry Pi Slow SSH Fix</title>
<link>https://www.usman.me.uk/posts/pi-slow-ssh-fix/</link>
<pubDate>Mon, 20 Feb 2017 21:42:26 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/pi-slow-ssh-fix/</guid>
<description><p>If you SSH into your Raspberry Pi and have noticed a lag when typing characters into the terminal. Then the following fix may get rid of the lag (it worked for me!).</p>
<p>Log into your Raspberry Pi and type:</p>
<pre tabindex="0"><code>$ sudo nano /etc/ssh/sshd_config
</code></pre><p>At the bottom of the config file add:</p>
<pre tabindex="0"><code>UseDns no
</code></pre><p>Save the file, then restart sshd:</p>
<pre tabindex="0"><code>$ service ssh restart
</code></pre><p>Or better, reboot your Raspberry Pi:</p>
<pre tabindex="0"><code>$ sudo reboot
</code></pre><p>SSH&rsquo;ing into your Raspberry Pi should no longer be slow after these steps. 🤞</p></description>
</item>
<item>
<title>Runtime and User Level Panics in Go</title>
<link>https://www.usman.me.uk/posts/runtime-user-panics/</link>
<pubDate>Thu, 08 Dec 2016 17:12:39 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/runtime-user-panics/</guid>
<description><p>How can our application code detect the difference between a runtime panic and a user level panic? Before answering this question. Let&rsquo;s take a look at the difference between a runtime panic, and user level panic.</p>
<p>A runtime panic is one thrown by the Go runtime, there are many things that can trigger a runtime panic. An example of the the most common runtime panic would be attempting to index an array out of bounds. The Go runtime would detect the illegal access and call the built-in panic function.</p></description>
</item>
<item>
<title>Creating Empty Git Commits</title>
<link>https://www.usman.me.uk/posts/git-empty-commit/</link>
<pubDate>Tue, 29 Nov 2016 00:43:13 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/git-empty-commit/</guid>
<description><p>You may not know it, but Git allows you to create an empty commit in to your repo. It doesn&rsquo;t like it, but you can do it any way.</p>
<p>An empty commit is one where you don&rsquo;t actually commit any code changes i.e. if you <em>git status</em> your repo, you get the message:</p>
<pre tabindex="0"><code>On branch master
nothing to commit, working tree clean
</code></pre><p>Why would you want to create an empty commit? You may want to communicate changes, which have nothing to do with code. But you have updated something that you want the rest of the team to know about. And you feel that communicating this via the git log make sense.</p></description>
</item>
<item>
<title>Changing the Date of Git Commits</title>
<link>https://www.usman.me.uk/posts/git-commit-change-date/</link>
<pubDate>Tue, 15 Nov 2016 19:29:07 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/git-commit-change-date/</guid>
<description><p>Have you ever looked at peoples Github contribution timelines and seen a word or some ASCII art. This is done by creating a repo, then manipulating the dates of commits, to create the desired design.</p>
<p>This blog post is not about creating funky pieces of art in your Github commit history timeline. But instead, shows you how to change the date of a commit using Git.</p>
<p>When you make a git commit you can actually set the date of the commit to anything you want. Lets get started.</p></description>
</item>
<item>
<title>Using Subtests and Sub-benchmarks in Go</title>
<link>https://www.usman.me.uk/posts/using-sub-tests-benchmarks/</link>
<pubDate>Sat, 22 Oct 2016 21:45:22 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/using-sub-tests-benchmarks/</guid>
<description><p>In this post we will walk through an example of how to use the new subtests and sub-benchmarks functionality introduced in Go 1.7.</p>
<h4 id="subtests">Subtests</h4>
<p>One of the nifty features in Go is the ability to write table driven tests. For example, if we wanted to test the function:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">Double</span>(<span style="color:#a6e22e">n</span> <span style="color:#66d9ef">int</span>) <span style="color:#66d9ef">int</span> {
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> <span style="color:#a6e22e">n</span> <span style="color:#f92672">*</span> <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Then we could write a table driven test as follows:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">TestDouble</span>(<span style="color:#a6e22e">t</span> <span style="color:#f92672">*</span><span style="color:#a6e22e">testing</span>.<span style="color:#a6e22e">T</span>) {
</span></span><span style="display:flex;"><span>	<span style="color:#a6e22e">testCases</span> <span style="color:#f92672">:=</span> []<span style="color:#66d9ef">struct</span> {
</span></span><span style="display:flex;"><span>		<span style="color:#a6e22e">n</span> <span style="color:#66d9ef">int</span>
</span></span><span style="display:flex;"><span>		<span style="color:#a6e22e">want</span> <span style="color:#66d9ef">int</span>
</span></span><span style="display:flex;"><span>	}{
</span></span><span style="display:flex;"><span>		{<span style="color:#ae81ff">2</span>, <span style="color:#ae81ff">4</span>},
</span></span><span style="display:flex;"><span>		{<span style="color:#ae81ff">4</span>, <span style="color:#ae81ff">10</span>},
</span></span><span style="display:flex;"><span>		{<span style="color:#ae81ff">3</span>, <span style="color:#ae81ff">6</span>},
</span></span><span style="display:flex;"><span>	}
</span></span><span style="display:flex;"><span>	<span style="color:#66d9ef">for</span> <span style="color:#a6e22e">_</span>, <span style="color:#a6e22e">tc</span> <span style="color:#f92672">:=</span> <span style="color:#66d9ef">range</span> <span style="color:#a6e22e">testCases</span> {
</span></span><span style="display:flex;"><span>		<span style="color:#a6e22e">got</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">Double</span>(<span style="color:#a6e22e">tc</span>.<span style="color:#a6e22e">n</span>)
</span></span><span style="display:flex;"><span>		<span style="color:#66d9ef">if</span> <span style="color:#a6e22e">got</span> <span style="color:#f92672">!=</span> <span style="color:#a6e22e">tc</span>.<span style="color:#a6e22e">want</span> {
</span></span><span style="display:flex;"><span>			<span style="color:#a6e22e">t</span>.<span style="color:#a6e22e">Errorf</span>(<span style="color:#e6db74">&#34;fail got %v want %v&#34;</span>, <span style="color:#a6e22e">got</span>, <span style="color:#a6e22e">tc</span>.<span style="color:#a6e22e">want</span>)
</span></span><span style="display:flex;"><span>		}
</span></span><span style="display:flex;"><span>	}
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Note:</strong> The test case {4, 10} is present to make the test fail, 4 * 2 != 10 😃.</p></description>
</item>
<item>
<title>SVG Sprites</title>
<link>https://www.usman.me.uk/posts/svg-sprites/</link>
<pubDate>Tue, 16 Aug 2016 19:54:44 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/svg-sprites/</guid>
<description><p>Within an single SVG file we can define many sprites. This consists of merging all your SVG sprites into a single .svg image file. Every sprite is wrapped in a &lsquo;symbol&rsquo; tag, like this:</p>
<pre tabindex="0"><code>&lt;svg class=&#34;character&#34; width=&#34;100pt&#34; height=&#34;100pt&#34; version=&#34;1.1&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
 &lt;symbol id=&#34;circle-red&#34; viewBox=&#34;0 0 100 100&#34;&gt;
 &lt;circle cx=&#34;50&#34; cy=&#34;50&#34; r=&#34;40&#34; stroke=&#34;black&#34; stroke-width=&#34;3&#34; fill=&#34;red&#34; /&gt;
 &lt;/symbol&gt;
 &lt;symbol id=&#34;circle-black&#34; viewBox=&#34;0 0 100 100&#34;&gt;
 &lt;circle cx=&#34;50&#34; cy=&#34;50&#34; r=&#34;40&#34; stroke=&#34;black&#34; stroke-width=&#34;3&#34; /&gt;
 &lt;/symbol&gt;
&lt;/svg&gt;
</code></pre><p>We can then use HTML or CSS to pick out each part of the image:</p></description>
</item>
<item>
<title>Updating Third Party Packages in Go</title>
<link>https://www.usman.me.uk/posts/update_packages/</link>
<pubDate>Sat, 11 Jun 2016 14:43:49 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/update_packages/</guid>
<description><p>Just a short post on how to update packages using <em>go get</em>.</p>
<p>To update all third party packages in your <em>GOPATH</em> use the following command:</p>
<blockquote>
<p>go get -u all</p>
</blockquote>
<p>To update a specific package, just provide the full package name to <em>go get</em>:</p>
<blockquote>
<p>go get -u github.com/gorilla/mux</p>
</blockquote>
<p>What about vendor-ed packages? These are updated in exactly the same way as above:</p>
<blockquote>
<p>go get -u my-project/vendor/megacorp/foo</p>
</blockquote>
<p>If you want more information about your <em>GOPATH</em>, run the command:</p></description>
</item>
<item>
<title>sort.Sort & sort.Stable</title>
<link>https://www.usman.me.uk/posts/sort-stable/</link>
<pubDate>Sun, 13 Mar 2016 19:34:13 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/sort-stable/</guid>
<description><p>Go 1.6 made improvements to the Sort function in the sort package. It was improved to make fewer calls to the Less and Swap methods. Here are some benchmarks showing the performance of sort.Sort in Go 1.5 vs 1.6:</p>
<pre tabindex="0"><code>Sort []int with Go 1.5
BenchmarkSort_1-4 20000000 67.2 ns/op
BenchmarkSort_10-4 10000000 227 ns/op
BenchmarkSort_100-4 500000 3863 ns/op
BenchmarkSort_1000-4 30000 52189 ns/op

Sort []int with Go 1.6
BenchmarkSort_1-4 20000000 64.7 ns/op
BenchmarkSort_10-4 10000000 137 ns/op
BenchmarkSort_100-4 500000 2849 ns/op
BenchmarkSort_1000-4 30000 46949 ns/op
</code></pre><p><em>source: <a href="https://talks.golang.org/2016/state-of-go.slide#24" target="_blank">state of go</a></em></p></description>
</item>
<item>
<title>The Defer Statement</title>
<link>https://www.usman.me.uk/posts/defer-statement/</link>
<pubDate>Mon, 14 Dec 2015 20:55:08 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/defer-statement/</guid>
<description><p>The Go programming language has a defer statement that allows for a function call to be run just before the currently running function returns. Here is how the defer statement is explained in the language specification:</p>
<p><em>&ldquo;A &ldquo;defer&rdquo; statement invokes a function whose execution is deferred to the moment the surrounding function returns, either because the surrounding function executed a return statement, reached the end of its function body, or because the corresponding goroutine is panicking.&rdquo;</em></p></description>
</item>
<item>
<title>Go Channel Axioms</title>
<link>https://www.usman.me.uk/posts/channel-axioms/</link>
<pubDate>Mon, 14 Dec 2015 01:40:39 +0000</pubDate>
<guid>https://www.usman.me.uk/posts/channel-axioms/</guid>
<description><p>A while ago I was watching a tech talk by Blake Caldwell on <a href="https://www.youtube.com/watch?v=PyBJQA4clfc" target="_blank">Building Resilient Services with Go</a>. In his presentation he had a slide which listed go channel axioms. I have listed his channel axioms here and provided some short code snippets to hopefully clarify them.</p>
<h3 id="a-send-to-a-nil-channel-blocks-forever">A send to a nil channel blocks forever</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#66d9ef">var</span> <span style="color:#a6e22e">ch</span> <span style="color:#66d9ef">chan</span> <span style="color:#66d9ef">bool</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">ch</span> <span style="color:#f92672">&lt;-</span> <span style="color:#66d9ef">true</span> <span style="color:#75715e">// will always block</span>
</span></span></code></pre></div><p>We declare a channel &lsquo;ch&rsquo; but do not initialize it (with make), so it is a nil channel. We then attempt to <strong>send</strong> a value down the channel, this causes a blocking operation.</p></description>
</item>
<item>
<title>dotGo 2015</title>
<link>https://www.usman.me.uk/posts/dotgo-eu-2015/</link>
<pubDate>Thu, 12 Nov 2015 13:15:12 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/dotgo-eu-2015/</guid>
<description><p><img src="https://i.imgur.com/uiLTeK2.png" alt="Dot conf. logo"></p>
<p>On Monday the 9th of November I was in Paris attending dotGo, the European Go conference. This blog post is a summary of my time there.</p>
<h3 id="pre-conference">Pre-Conference</h3>
<p>The day before the conference, the Paris tech talks group organized a pre-conference meetup/party. There were a large number of delegates who turned up and the meet up consisted of about six or seven talks. The talks were about how individuals at there respective companies were using Go. All the projects demoed and talked about were network related i.e. using Go to write a load balancer which solved a particular problem. After the talks, there was a chance to socialize and eat pizza with other gophers :).</p></description>
</item>
<item>
<title>tmux Cross Platform Config.</title>
<link>https://www.usman.me.uk/posts/tmux-cross-platform/</link>
<pubDate>Tue, 20 Oct 2015 17:15:08 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/tmux-cross-platform/</guid>
<description><p>If like me you use tmux on both Linux and OS X, then managing your tmux configuration can be a pain. The problem is there is configuration that is specific to either OS, such as copy and paste behavior. This blog post will show you how to manage your tmux configuration across platforms in a better way.</p>
<p>The first thing you want to do is create a dot file for each platform, so for Linux create <em>.tmux-linux.conf</em> and for OS X create <em>.tmux-osx.conf</em>. Create and place these files in the same location as your <em>.tmux.conf</em> file (most likely your home directory).</p></description>
</item>
<item>
<title>Things to do before committing Go code</title>
<link>https://www.usman.me.uk/posts/go-todo/</link>
<pubDate>Wed, 02 Sep 2015 18:22:06 +0700</pubDate>
<guid>https://www.usman.me.uk/posts/go-todo/</guid>
<description><p>This blog post will list some of the basic things you should really do before committing Go code into your repository.</p>
<p><strong>1)</strong> Run gofmt/goimports</p>
<p><em>gofmt</em> is probably the most popular Go tool amongst gophers. The job of <em>gofmt</em> is to
format Go packages, your code will be formatted to be consistent across your code base. For example if we have the following <em>if</em> statement:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#a6e22e">x</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">42</span> { <span style="color:#a6e22e">fmt</span>.<span style="color:#a6e22e">Println</span>(<span style="color:#e6db74">&#34;The answer to everything&#34;</span>) }
</span></span></code></pre></div><p>Then running <em>gofmt</em> on this will format the code to:</p></description>
</item>
<item>
<title>Golang UK Conference 2015</title>
<link>https://www.usman.me.uk/posts/golang-uk-conf-2015/</link>
<pubDate>Tue, 25 Aug 2015 22:09:24 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/golang-uk-conf-2015/</guid>
<description><p><img src="https://i.imgur.com/LJfFYSS.png" alt="British Gopher"></p>
<p>On Friday the 21st of August I attended the <a href="http://www.golanguk.com/" target="_blank">Golang UK conference 2015</a> held at
the amazing Brewery in London. This post is a short write up of my time at the
conference.</p>
<p>This was my first ever conference so apart from the talks, I did not know what
else to expect. Overall though, I found the conference was excellent and I met
a wide range of interesting people.</p></description>
</item>
<item>
<title>Gofmt and Rewrite Rules</title>
<link>https://www.usman.me.uk/posts/gofmt-rewrite-rules/</link>
<pubDate>Tue, 04 Aug 2015 23:26:39 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/gofmt-rewrite-rules/</guid>
<description><p>One thing I absolutely love about Go is its tooling support. Whenever I use the
numerous tools I always discover something new. In this short post I will be
showing off gofmt&rsquo;s -r flag, this flag allows you to apply a rewrite rule to your
source before formatting.</p>
<p>A rewrite rule is a string in the following format:</p>
<pre tabindex="0"><code>pattern -&gt; replacement
</code></pre><p>Both pattern and replacement must be valid Go expressions (more on this later), lets
apply a simple rewrite to the following code:</p></description>
</item>
<item>
<title>Go and String Concatenation</title>
<link>https://www.usman.me.uk/posts/go-string-concat/</link>
<pubDate>Sun, 26 Jul 2015 18:45:28 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/go-string-concat/</guid>
<description><p>When writing Go code you should try to stay away from concatenating strings using the &lsquo;+&rsquo; and &lsquo;+=&rsquo;&rsquo; operators.</p>
<p>Strings in Go, like many other languages (Java, C#, etc&hellip;) are immutable, this means after a string has been created it is impossible to change. Here is what the <a href="https://golang.org/ref/spec#String_types" target="_blank">Go Programming Language Specification</a> has to say about the string type:</p>
<p><em>&ldquo;A string type represents the set of string values. A string value is a (possibly empty) sequence of bytes. Strings are immutable: once created, it is impossible to change the contents of a string. The predeclared string type is string.&rdquo;</em></p></description>
</item>
<item>
<title>Calling C from Go</title>
<link>https://www.usman.me.uk/posts/calling-c-from-go/</link>
<pubDate>Sat, 25 Jul 2015 20:18:15 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/calling-c-from-go/</guid>
<description><p>This post will show you the basics of how to call C code from a Go package.</p>
<p>Lets get started with an example:</p>
<p>Create a header file &ldquo;add.h&rdquo; with a function prototype:</p>
<pre><code>#ifndef _ADD_H_
#define _ADD_H_
int add(int, int);
#endif
</code></pre>
<p>Create the source file &ldquo;add.c&rdquo; containing the definition for add:</p>
<pre><code>#include &quot;add.h&quot;

int add(int a, int b)
{
 return a + b;
}
</code></pre>
<p>Create a Go package &ldquo;main.go&rdquo;:</p></description>
</item>
<item>
<title>First Post</title>
<link>https://www.usman.me.uk/posts/first/</link>
<pubDate>Sat, 25 Jul 2015 17:15:08 +0100</pubDate>
<guid>https://www.usman.me.uk/posts/first/</guid>
<description><p>This is my blog. There are many like it, but this one is mine.</p></description>
</item>
</channel>
</rss>