Bits

Comparing Performance of Ruby and Golang With a Benchmark

2 minute read Published:

I recently solved a coding challenge using Ruby. I’ve been curious for some time about coding using Golang, and so I decided to port it over, and see what the performance difference was. I made a small adaption for a better comparison. I’m now using a grid that has 100_000_000 squares on it. This is definitely a bit of work. The code package main import ( "encoding/json" "fmt" "io/ioutil" "os" ) var grid [][]int var gridDim [2]int var a = make(map[[2]int]bool) func main() { jsonFile, err := ioutil.

Proving the Monty Hall Problem

3 minute read Published:

Doors When I first heard of the Monty Hall problem, I read about it in Sam Harris’ The Moral Landscape, and it took me a few minutes to really wrap my brain around it. Talking about it with a few people since, I struggle to convince them that this really works this way. I think part of it is that I still don’t quite believe it.

Find Adjascent Squares for a Coding Challenge

3 minute read Published:

Random grid of numbers. I spotted a challenge that was something like this online, and I adapted it. There was something that I wanted to understand a little bit better. The interesting thing here is about the data structures used, to increase efficiency. Find Contiguous Squares Imagine you have a grid of n width and height, and it’s populated with random numbers. It could be represented something like this:

Big O Notation Put Simply

2 minute read Published:

“Big O” notation is called this because it’s written something like O(n), and serves as a measure of efficiency of a particular algorithm. It’s a way of explaining how much a particular piece of code will suffer when put under load. The the meaning of the “O” appears to be purely historical. So don’t get caught up on that. I’ll do a few examples in ruby to show how this works.

Use Terraform to Set Up Github Pages With Route 53

1 minute read Published:

Terraform can quickly build the DNS records for your github pages site. It's declarative, and easy to keep up to date, and replicate.
This will result in a certificate error if you don't take further steps. It’s nice to be able to spin up everything you need for github pages all in one go. If you’re using amazon for AWS, here’s a basic terraform configuration that should do everything you want in terms of DNS. This assumes you want to point everything at the apex domain rather than the www. After doing this you’ll still need to specify the CNAME file on your target project, and set the name servers on the domain.

Variable Naming Cases

1 minute read Published:

There are a number of ways to make variables readable, and also to distinguish what variable types you might be working with. These things change from language to language, but it’s nice to have a common set of vocabulary to refer to them. I find that I’m sometimes forgetful of how to actually refer to any given case, so here’s a quick reference. Case Example Snake Cases snake_case Camel Case camelCase Pascal Case Pascal Case Kebab Case kebab-case I’ve found that I often want to be able to switch from one to another, and that there’s always a solution already in existence, the most helpful thing is knowing what to call it for the sake of googling.

Github Pages With Apex Domain

2 minute read Published:

www and apex domains pointing to a github pages site. This is the basic setup.
Saving time and money with GitHub Pages I know that GitHub Pages are nothing new, but I only recently realized how versatile they are. You can host any static content you want there for free, and I’ve recently started using it for my blogs. Major benefits of using GitHub Pages as I see it: Free hosting for simple pages Deployment is as easy as a git push SSL certs are a one time checkbox It handles redirecting to the www subdomain, or to the apex domain without no real configuration My default configuration You just have to set up the DNS.

Serving Localhost to the Web with Reverse Ssh Tunnels

2 minute read Published:

So, you have a webpage on your computer you want to show to a remote person?
Note: If you don’t have a server already, check my last tip. This topic is always a little tricky, so, here’s the basic thing to know, as this is the most frequent use case. Suppose you have a development rails server running on your local computer. You can access this server via curl http://localhost:3000. Which is to say, it’s running on your localhost, on port 3000. You want your client to see it, to give you feedback, but they’re nowhere near you, and you just want a quick way to show it to them.

Exporting A Zone File From Mediatemple

1 minute read Published:

How to get DNS info out of MediaTemple
I was in the process of moving my DNS from MediaTemple to Route53 and was having trouble making sure I’d moved all of the entries. I decided I’d just export a zone file to do a comparison in a text editor. Surprise! You can’t. Instead, here’s a quick bit of jQuery, which is already available in the MediaTemple control panel. Just navigate to the zone file editor, open your console, and use this:

Reducing The Size Of Alpine Docker Images

1 minute read Published:

Why the heck is my alpine docker image so huge? That’s a tough question to answer, especially when you have no idea what’s taking up all of the space. This is a dirty little one-liner that yields a sorted list of all of the packages on your alpine image by size. It does this by Getting the complete list from apk info Iterating over the results to ask apk for its size Removing the blank lines Combining the size lines and the name lines Sorting by size