If you ever wanted to improve your understanding of a computer system or write a compiler then this post may convince you to take the course or read the book. TLDR Cons Hack platform is an educational platform, so learnings aren’t directly applicable in “real world” (see Pros tho) provided software is somewhat rough at times with unclear and hard to debug errors Jack OS is not what many people may…
In Trusting Trust paper, Ken Thompson touched several ideas that made me think. STAGE I … to write a source program that, when compiled and executed, will produce as output an exact copy of its source. If you have never done this, I urge you to try it on your own. The discovery of how to do it is a revelation that far surpasses any benefit obtained by being told how to do it.
Motivation Understanding what is glob and how glob matching operates will help you adopt this useful mini-language in your domain whether you’re a user, programmer, or an architect. What is glob? Long ago, in UNIX V6, there was a program /etc/glob that would expand wildcard patterns. Soon afterward this became a shell built-in. — glob(7) — Linux manual page Glob, short for global, is…
Do you want to improve your technical writing? Google Developers were kind enough to publish Technical Writing One so there are no more excuses to not get better at it. The course takes ~2 hours to finish and it’ll immediately improve your writing. The course is so polished that the table of contents serves as “fast and hard rules” index which I decided to turn into a blog post…
.sli {color: brown} .slo {color: blue} .sla {color: green} .eb {color: purple} .eb, .sli, .slo, .sla, .eb { font-weight: 800; font-style: normal; } Just finished the SRE course and thought I need to capture my thoughts both directly and indirectly related to the course. This is a work-in-progress. 100% Reliability In an perfect world everything is 100% reliable. Too bad we don’t have one.…
Notes on ambiguity and its effects in spoken and programming languages. This post touches on: syntactic ambiguity (and disambiguation) in spoken language(SL) syntactic ambiguity (and disambiguation) in programming languages(PL) deliberate ambiguity and its effects PS: i’m not a linguist and all my findings are empirical so feel free to point out my mistakes… Ambiguity Let’s define…
Leveraging Chrome DevTools for HTTP middleware observability and building a HTTP reverse|forward proxy with Go. TLDR cdp-proxy project is 2 things: a reverse|forward proxy with cdp-proxy executable an http.Handler middleware to plug your Go project to Chrome DevTools cdp-proxy is short for Chrome DevTools protocol. cdp-proxy: a reverse|forward proxy cdp-proxy executable is just like any other mitm…
Cost-effective way to have your app conform with 12 factor methodology with Go’s stock flag package. Summary Previously, before “cloud” was a thing, it was common to have configuration part of the source code, ie Rails’ config/database.yaml. These days, with immutable infrastucture, separation of configuration and code is preferred; quoting 12 factor: III. Config Store…
TLDR Cloud Run is a great platform to host your static site. The article describes the process of setting up one with focus on best practices and simplicity. Hosting gmarik.info My blogging setup had changed couple of times now: Blogging with jekyll, rack and heroku for free! Hosting static site with App Engine, Cloud Build and Hugo The last platform was fast and worked well except few things:
I’ve been working with Datadog’s Application Perfomance Monitoring recently and discovered that the APM agent produces both traces and metrics, which isn’t obvious from looking at the docs. When the APM is configured, ie for ruby: require 'ddtrace' Datadog.configure do |c| # This will activate auto-instrumentation for Rails c.use :rails end Then the agent starts collecting…
…well, one of! Javascript has a bad wat reputation. Despite the difficult history and being an ugly-duck of programming languages there are some ideas that Javascript today does better than other languages in my opinion. Brendan Eich wrote javascript in 10 days, in May 1995 https://en.wikipedia.org/wiki/JavaScript Personal context In past I’ve never fully commited to writing Javascript.…
Minimal SwiftUI example If you’re eager to get your feet wet with SwiftUI the minimal sample may look like this: import SwiftUI struct App: View { var body = Text('Hello World') } But hold your horses Unless you’re Swift developer you’re unlikely to have all the required software. So the challenge now is how to get minimal number of required components to be able to try SwiftUI.…
A Day: Perfect model vs Imperfect Reality Expectation: 1 Day = 24 Hours = 86,400.000s Reality: 1 Day ~ 24 Hours ~ 86,400.002s (SI, mean) 1 Day is not exactly 24 hours Time And Date 1 Day (measured with Solar Time) is the time it takes the Earth to rotate around its own axis so the Sun appears in the “same position” in the sky. It takes mean 1s/0.
So once in a while I try new platform to host my blog. So far i’ve tried Heroku+Jekyll, VPS+Nginx, Netlify+Hugo. Every option has its Cons and Pros but this post is about: App Engine + Cloud Build + Hugo. Requirements https support git push style deploys support for various static site compilers cheap fast Note: if you’re looking for the simplest setup it’s the Netlify, IMO. App…
At Rover.io we’re migrating existing rails/node monoliths into microservice based architecture. Recently we launched another Go powered, mongodb backed service which tracks device events. This post is documents steps taken while debugging performance issues and using tests to detect and prevent performance degradation. Why Mongo Our service is backed by mongodb for few reasons: enable…
I’ve published my first word game wordfight inspired by venerable Letterpress. It’s a game where players make up words from the letters on the board. Whoever takes the most letters wins once all the letters are taken. The idea has been in my “todo” for few reasons: algorithmic problem at heart build a UI with reactjs build a bot opponent and AI real-time multi-player app…
or how I almost had to invert a binary tree to use it. Good Google announced ‘Always Free’ products during its Google Cloud Next‘17 Plus, we’re introduced new Always Free products – non-expiring usage limits that you can use to test and develop applications at no cost. Visit the Google Cloud Platform Free Tier page for details. (see FAQ for more) It’s a great incentive to…
Code review is one of most important tools when it comes to social software development. But there’s an aspect that may ruin the whole experience as code-review becomes point of inter-personal tensions due to various reasons. By carefully constructing the language you can make a difference for everyone involved. Here are my notes from personal experience. As a reviewer Address the code, not…
In this post we’ll ponder the Go peculiarities when working with for range loops and closures. Problem On of the Go gotchas when coming from other languages is how for range loop operates with closures. Here’s a simple example: package main import 'os' func main() { for _, arg := range os.Args { defer func() { println(arg) }() } } Running the example: $ go run for.go hello world one…
This post describes building simple composable execution pipelines with Ruby, it’s a useful technique that enables writing reusable, chainable and testable components. Execution pipeline Execution pipeline (also known as Chain of responsibility pattern) focuses on performing set of actions; IE an “order creation pipeline”: creates an order creates order details decreases…
Problem Imagine we have a one-off task of copying subset of files residing in an s3 bucket to another bucket. We’re going to use aws s3 ls s3://a_bucket/path/ command to get the list of files and then only copy the ones that match a pattern. Let’s assume the resulting file-list looks something like this: $ cat in.txt 2013-03-29 14:35:03 10314739 20130314T011325_WCBK_SCHEDULE.XML…
Pipelines is a powerful concept that is language independent and is “a must” for any developer to master. This post discusses concept of pipelines and how it can affect application speed; it also assumes some Go and basics of concurrency knowledge. A naive prime calculation algorithm is chosen deliberately for the sake of demonstration in this post and, instead of improving the…
This post raises more questions than answers (for me). While I’m learning more about what Go’s nil is I’ll be making assumptions based on how the languages behaves. I’ll try to collect the answers from the Go’s source code, but in the mean time: just plain assumptions, feel free correct. Nil is a typed value Type information is inherent part of a nil value in Go. Lack…
After moving to Canada, part of initial culture shock was the fact how expensive cell phone services are. That motivated me to started thinking how to migrate off cell-provided services. Another reason for migration was the fact that service providers have surprisingly poor service quality: @Fidomobile been trying to give you my money but you're resisting too hard. Yet my number stopped working.…
This is Part 2 of the 2-post series. See Part 1 if you haven’t yet. Hacked together sensor reporting since #Intel provides free analytics platform. Blog post soon. #Golang #IoT pic.twitter.com/WllvBPLr8j — gmarik (@gmarik) February 19, 2016 In this post we’ll go through the process of configuring and running sensor-reporter and submitting the sensor metrics to the EnableIoT…
In Nov 2015 I participated in Intel Roadshow where people hacked on Intel Edison powered projects. Got a temperature sensor running hooked to http server and LCD #edison #IntelMakerON #fun pic.twitter.com/IJCC0olW8c — gmarik (@gmarik) November 21, 2015 After the hackathon, I couldn’t come up with a good idea what to do with the device, so I decided to go with the obvious one: reporting…
Problem One of projects I’m working on is responsible for coordinating/running multiple processes. It’s a simple real-time web app that allows starting, stopping, pausing and terminating processes. Since I’m developing and testing on OSX and the service is running on Linux I came across a surprising behaviour how those platforms handle particular signals. Description Common…
Problem I’ve been working on a Go CLI app to push sensor data to Cloud™ and hit the problem. In order to read the sensor data I had a very simple piece of code: package main //analog_read.go import ( 'flag' 'fmt' 'os' 'github.com/hybridgroup/gobot/platforms/intel-iot/edison' ) var ( pin = flag.String('pin', '', 'Sensor's pin-ID to read analog value from. Required.') ) func main() {…
Problem Imagine we’re tasked to implement a search with auto-completion support. Because it’s an auto-completion, every time the search phrase is changed, there’s a chance to have more than one outstanding request going at a time. How do we keep resource usage to a minimum and avoid unnecessary requests? Possible Solutions keep at most one(the latest) request going at a time…
Problem After I started learning about [FP] couple years ago my code started resemble pseudo-purely-functional one: # Version A # builds a reverse item-to-category map def items_to_categories_map reducer = -> (acc, (cat, items)) do items.reduce(acc) { |acc, item| acc.merge(item => cat) } end CAT_TO_ITEM_MAP.reduce({}, &reducer) end CAT_TO_ITEM_MAP = { 'numbers' => %w[0 1 2 3], 'letters' => %w[a b…
Here are few things that help improve my Bash code when a script grows more than just couple lines but not enough to be rewritten with Go. Tip 1: fail early Probably is well known but still worth mentioning: -e Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command, exits with a non-zero status. See man bash's “SHELL BUILTIN…
Or using Ansible as an acceptance test tool. Problem My blog has received major overhaul couple days ago: migrated to Hugo from Jekyll migrated to DigitalOcean from Heroku adopted Ansible for provisioning and setup migrated to www.gmarik.info from gmarik.info new blog permalink format /blog/:year/:slug(as month/day do not matter much in url) Preserving site permalinks was my major migration…
In my spare time i’ve been working on a project that involves IPC with Rack applications from a Go app. It was quite easy to extract IPC code into a standalone module and it’s going opensource today. The project is called Gorack and it’s a: Go frontend webserver for Ruby’s Rack applications Feel free to checkout Gorack readme and try it out. Let me know what you think.
I’ve been looking for a good explanation to the concurrency slogan: Do not communicate by sharing memory; instead, share memory by communicating Having found none that satisfy my requirements: initial problem with an example provide Shared Memory solution provide Share by Communicating solution this post is my take on explaining the subject. After reading it one should be able to get an idea…
Vundle is my most popular OSS project. Yet I stopped contributing to it a while ago. Here I’ll try cover my reasons and also to initiate discussion about Vundle’s future. History Vundle was written to serve my personal needs as an experiment. It took me a day(while I was sick) to get initial version out and I spent significant time after polishing it towards v1.0 which hasn’t…
Problem client authentication in Service Oriented Architecture (SOA) Solution Encrypted communication is a must these days, it(TLS) also could be used for client auth. TLS Transport Layer Security and its predecessor, Secure Sockets Layer (SSL), are cryptographic protocols which are designed to provide communication security over the Internet. Authentication Authentication (from Greek: αὐθεντικός;…
As far as I know there are 3 ways: Organizer iTunes iTunes Backup Assuming that you can deploy the app to the device. Organizer Organizer lets you quickly download app data from a device. Press download to get data saved. This approach doesn’t work if an app is installed from AppStore even if you’re the developer. iTunes iTunes mediates access to the Documents/ folder in App Sandbox.…
Just pushed first useful(in my opinion) Objective-C component. It’s called MHAboutView and is a generic ‘about view’ for iOS apps. Problem Enable users to give feedback to app publisher. It’s very important for a developer to stay in touch with customers: bug reports answering questions feature requests are beneficial for both parties. MHAboutView Most iOS apps provide no…
It’s hard to work on a side project and get it done. Esp when it’s something new, complicated, takes a lot of time, and you don’t get paid for it. But it’s achievable! “So, why do it when you don’t get paid?” – one may ask. just for fun. Well, it’s not always about fun though, it’s about learning too. And learning is never easy, esp.…
Or adding a “tree” to your app. Problem It’s often necessary to store hierarchical data in DB. We’ll review available models and their strengths and weaknesses. Since knowing theory is good but not enough, pluggable solutions are considered for Ruby On Rails framework. Theory There are several ways to model recursive/hierarchical data with relational DB: Adjacency List…
Process In computing, a process is an instance of a computer program that is being executed. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently. Parent Process In the operating system Unix, every process(except the very first one) is created when a process creates a new process. Those 2 processes establish a…
pt-online-schema-change is a CLI script and part of Percona-toolkit by Percona. It’s one of the most efficient tools for performing large MySQL table migrations, minimizing DB downtime. Here’s a rough outline of the performed operations: create empty a_table_new duplicating a_table's stucture alter empty a_table_new as specified(performs structure migration) add data-copy-trigger to…
Along with widely used mysqldump there are often times when Raw backups need to be performed. These are my notes on this subject. Raw Backup vs Logical Backup Below backup comparison is an excerpt from High Performance Mysql 2nd ed BTW they released 3rd edition of High Performance Mysql in March 2012. Logical Backup Pros: Consists of normal text files; which means they’re…
What are the responsibilities of a Presenter? The presenter acts upon the model and the view. It retrieves data from repositories (the model), and formats it for display in the view or briefly transform data from one to another form(representation) I like to think of Presenter as just a transformation function withing a context(an MVC). Thinking with mapping Map is a very simple but powerful…
Happy Holidays everyone! This post has been sitting in my drafts for a while now, so today I finally managed to complete it. Antipatterns There are best-practices for all kinds of programming languages but I haven’t seen vim-script’s one. This post doern’t try to cover actual best practices but rather just “issues” often found when scripting Vim. 1. Copy-pasting There…
Gotta stop googling everytime this happens. Mysql Load mysql dump $ mysqld_safe & # start mysql server $ mysql -u root app_development < dump.sql # load dump ERROR 2006 (HY000) at line 151988: MySQL server has gone away oops looks like we got an error Customize Mysql configuration $ mysqladmin -u root shutdown # shutdown server for configuration change $ mkdir -p /usr/local/mysql/etc # create…
I have two Xcodes versions installed 3.2.4 and 4.2. And the former one was the default one. This wasn’t a big deal unless I tried to open a project in Finder which caused Xcode 3.2.4 to pop up. Defaultig to Xcode 4 is a bit tricky: CTRL-click on a project so context menu pops up, select Open with File selection dialog pops up. Press Shift-CMD-G - Goto Filder dialog pops up.
Designing good UX is hard. Especially for developers without design background. Messing with UI was one of my most time consuming activities with little outcome. Ready-to-use-templates were probably the only solution which didn’t make developer stuck with UI. And there are lots of sites you can get one from. Those templates aren’t very reusable though(unless all of your project look…
I’m learning (new to me) platform from Apple. Here are my impressions so far. Objective-C (the ugly) After programming Ruby for a while, Objective-C looks kinda ugly, ie: + (MyGizmoClass*)sharedManager { if (sharedGizmoManager == nil) { sharedGizmoManager = [[super allocWithZone:NULL] init]; } return sharedGizmoManager; } When you look at this code the very first time you’ll probably…