Generalizing the shuffle to arbitrary numbers of blocks. The post Rotation revisited: Shuffling more than three blocks, and other small notes appeared first on The Old New Thing.
#code
140 posts
8 Jun
5 Jun
Rotation revisited: Avoiding having to calculate the gcd when doing cycle decomposition
Raymond ChenMath is hard. Let's go counting! The post Rotation revisited: Avoiding having to calculate the gcd when doing cycle decomposition appeared first on The Old New Thing.
4 Jun
Rotating in the minimum number of steps by performing cycle decomposition. The post Rotation revisited: Cycle decomposition in clang’s libcxx appeared first on The Old New Thing.
3 Jun
We've seen this before. The post Rotation revisited: A shocking discovery about gcc’s unidirectional rotation algorithm appeared first on The Old New Thing.
2 Jun
Moving in a straight line, in a different way. The post Rotation revisited: Another unidirectional algorithm appeared first on The Old New Thing.
29 May
Sharing the result of a single Windows Runtime IAsyncOperation among multiple coroutines, part 3
Raymond ChenA variation where we try only once. The post Sharing the result of a single Windows Runtime IAsyncOperation among multiple coroutines, part 3 appeared first on The Old New Thing.
28 May
Sharing the result of a single Windows Runtime IAsyncOperation among multiple coroutines, part 2
Raymond ChenJust let each person take turns trying. The post Sharing the result of a single Windows Runtime IAsyncOperation among multiple coroutines, part 2 appeared first on The Old New Thing.
27 May
Sharing the result of a single Windows Runtime IAsyncOperation among multiple coroutines, part 1
Raymond ChenCaching the result and knowing when the cache is valid. The post Sharing the result of a single Windows Runtime IAsyncOperation among multiple coroutines, part 1 appeared first on The Old New Thing.
26 May
If C# and JavaScript lets me await a Windows Runtime asynchronous operation more than once, why not C++/WinRT?
Raymond ChenA difference in philosophy. The post If C# and JavaScript lets me await a Windows Runtime asynchronous operation more than once, why not C++/WinRT? appeared first on The Old New Thing.
25 May
A hypothetical redesign of System.Diagnostics.Process to avoid confusion over properties that are valid only when you are the one who called Start
Raymond ChenPutting them in a place that can access only if you call Start. The post A hypothetical redesign of <CODE>System.<WBR>Diagnostics.<WBR>Process</CODE> to avoid confusion over properties that are valid only when you are the one who called <CODE>Start</CODE> appeared first on The Old New Thing.
22 May
Why do you say that a COM STA thread must pump messages if I see sample code creating STA threads and not pumping messages?
Raymond ChenYou need to pump messages when idle, but maybe you are never idle. The post Why do you say that a COM STA thread must pump messages if I see sample code creating STA threads and not pumping messages? appeared first on The Old New Thing.
21 May
Trick question: You can't. But maybe you can fake it. The post How do I use Win32 structures from the Windows Runtime? appeared first on The Old New Thing.
20 May
You need to arrange to get one from the other. The post The classic TreeView control lets me sort by name or by lParam, but why not both? appeared first on The Old New Thing.
15 May
Maybe because it already exists? The post The case of the <CODE>CreateFileMapping</CODE> that always reported <CODE>ERROR_<WBR>ALREADY_<WBR>EXISTS</CODE> appeared first on The Old New Thing.
14 May
A constant-space linear-time algorithm for deleting all but the 10 most recent files in a directory
Raymond ChenUsing data structures you already knew. The post A constant-space linear-time algorithm for deleting all but the 10 most recent files in a directory appeared first on The Old New Thing.
13 May
Keeping things moving. The post The case of the hang when the user changed keyboard layouts appeared first on The Old New Thing.
11 May
Putting the handles in a private container. The post Additional notes on controlling which handles are inherited by <CODE>CreateProcess</CODE> appeared first on The Old New Thing.
8 May
You can track the file ID. The post Developing more confidence when tracking renames via <CODE>ReadDirectoryChangesW</CODE> appeared first on The Old New Thing.
7 May
When you upgrade your resource strings to Unicode, don’t forget to specify the L prefix
Raymond ChenOtherwise, it'll get mapped back down to the 8-bit code page. The post When you upgrade your resource strings to Unicode, don’t forget to specify the L prefix appeared first on The Old New Thing.
6 May
Static libraries don't stand a chance. The post Why not have changes in API behavior depend on the SDK you link against? appeared first on The Old New Thing.
4 May
You don't. All files are binary at the file system level. The post How do I inform Windows that I’m writing a binary file? appeared first on The Old New Thing.
1 May
Developing a cross-process reader/writer lock with limited readers, part 4: Abandonment
Raymond ChenRecovering from death of the owner. The post Developing a cross-process reader/writer lock with limited readers, part 4: Abandonment appeared first on The Old New Thing.
30 Apr
Let the exclusive acquisition have a fair chance against shared acquisitions. The post Developing a cross-process reader/writer lock with limited readers, part 3: Fairness appeared first on The Old New Thing.
29 Apr
Developing a cross-process reader/writer lock with limited readers, part 2: Taking turns when being grabby
Raymond ChenPlease, not everybody, everything all at once. The post Developing a cross-process reader/writer lock with limited readers, part 2: Taking turns when being grabby appeared first on The Old New Thing.
28 Apr
Developing a cross-process reader/writer lock with limited readers, part 1: A semaphore
Raymond ChenA pot of tokens. The post Developing a cross-process reader/writer lock with limited readers, part 1: A semaphore appeared first on The Old New Thing.
24 Apr
But maybe it's not worth it. The post Defending against exceptions in a <CODE>scope_exit</CODE> RAII type appeared first on The Old New Thing.
23 Apr
Inadvertently destroying a staircase while standing on it. The post Another crash caused by uninstaller code injection into Explorer appeared first on The Old New Thing.
22 Apr
So-called "fractal page mapping". The post Mapping the page tables into memory via the page tables appeared first on The Old New Thing.
20 Apr
How did code handle 24-bit-per-pixel formats when using video cards with bank-switched memory?
Raymond ChenYou still have to use aligned accesses, even though the pixels might not be aligned. The post How did code handle 24-bit-per-pixel formats when using video cards with bank-switched memory? appeared first on The Old New Thing.
16 Apr
Trespassing on system messages. The post What’s up with window message <CODE>0x0091</CODE>? We’re getting it with unexpected parameters appeared first on The Old New Thing.
15 Apr
Why is there a long delay between a thread exiting and the WaitForSingleObject returning?
Raymond ChenMaybe it didn't really exit. The post Why is there a long delay between a thread exiting and the <CODE>WaitForSingleObject</CODE> returning? appeared first on The Old New Thing.
13 Apr
Taking advantage of special characteristics of the array. The post Finding a duplicated item in an array of <VAR>N</VAR> integers in the range 1 to <VAR>N</VAR> − 1 appeared first on The Old New Thing.
10 Apr
Waiting for the waiting thread to acknowledge the change. The post How do you add or remove a handle from an active <CODE>WaitForMultipleObjects</CODE>?, part 2 appeared first on The Old New Thing.
9 Apr
You can't, but you can cooperate with the other thread. The post How do you add or remove a handle from an active <CODE>WaitForMultipleObjects</CODE>? appeared first on The Old New Thing.
8 Apr
You can't, but you can arrange for the waiter to do it for you. The post How do you add or remove a handle from an active <CODE>MsgWaitForMultipleObjects</CODE>? appeared first on The Old New Thing.
6 Apr
If the compiler is complaining about things you didn't write, find out who wrote them. The post Learning to read C++ compiler errors: Illegal use of <TT>-></TT> when there is no <TT>-></TT> in sight appeared first on The Old New Thing.
3 Apr
How can I use ReadDirectoryChangesW to know when someone is copying a file out of the directory?
Raymond ChenFile copying is not a fundamental operation, nor is it even detectable at the file system layer. The post How can I use <CODE>ReadDirectoryChangesW</CODE> to know when someone is copying a file out of the directory? appeared first on The Old New Thing.
2 Apr
Why doesn’t the system let you declare your own messages to have the same semantics as WM_COPYDATA?
Raymond ChenTempting but misleading. The post Why doesn’t the system let you declare your own messages to have the same semantics as <CODE>WM_<WBR>COPYDATA</CODE>? appeared first on The Old New Thing.
30 Mar
A question about the maximimum number of values in a registry key raises questions about the question
Raymond ChenWhy is this even a question? The post A question about the maximimum number of values in a registry key raises questions about the question appeared first on The Old New Thing.
26 Mar
Because it opted out. The post Why doesn’t <CODE>WM_<WBR>ENTERIDLE</CODE> work if the dialog box is a <CODE>MessageBox</CODE>? appeared first on The Old New Thing.
25 Mar
How can I change a dialog box’s message loop to do a MsgWaitForMultipleObjects instead of GetMessage?
Raymond ChenThe dialog box lets you change how it waits. The post How can I change a dialog box’s message loop to do a <CODE>MsgWaitForMultipleObjects</CODE> instead of <CODE>GetMessage</CODE>? appeared first on The Old New Thing.
23 Mar
You'll have to ask nicely. The post How can I make sure the anti-malware software doesn’t terminate my custom service? appeared first on The Old New Thing.
19 Mar
Reaching the modern day. The post Windows stack limit checking retrospective: amd64, also known as x86-64 appeared first on The Old New Thing.
18 Mar
Double the size, double the fun. The post Windows stack limit checking retrospective: Alpha AXP appeared first on The Old New Thing.
17 Mar
Appeasing the invisible return address predictor. The post Windows stack limit checking retrospective: x86-32 also known as i386, second try appeared first on The Old New Thing.
16 Mar
Doing the math backwards. The post Windows stack limit checking retrospective: PowerPC appeared first on The Old New Thing.
13 Mar
Optimizing out the unnecessary probes comes with its own complexity. The post Windows stack limit checking retrospective: MIPS appeared first on The Old New Thing.
12 Mar
One of the weirdest calling conventions you'll see. The post Windows stack limit checking retrospective: x86-32, also known as i386 appeared first on The Old New Thing.
11 Mar
Don't take steps that are too large. The post How do compilers ensure that large stack allocations do not skip over the guard page? appeared first on The Old New Thing.
9 Mar
Look for the conflicting definitions to see where they are coming from. The post Learning to read C++ compiler errors: Ambiguous overloaded operator appeared first on The Old New Thing.
6 Mar
When ReadDirectoryChangesW reports that a deletion occurred, how can I learn more about the deleted thing?
Raymond ChenIt's already gone. If you need more information, you should have been remembering it. The post When <CODE>ReadDirectoryChangesW</CODE> reports that a deletion occurred, how can I learn more about the deleted thing? appeared first on The Old New Thing.
5 Mar
The mystery of the posted message that was dispatched before reaching the main message loop
Raymond ChenPerhaps it's because you dispatched it. The post The mystery of the posted message that was dispatched before reaching the main message loop appeared first on The Old New Thing.
4 Mar
Aha, I found a counterexample to the documentation that says that QueryPerformanceCounter never fails
Raymond ChenOf course, anything can happen if you break the rules. The post Aha, I found a counterexample to the documentation that says that <CODE>QueryPerformanceCounter</CODE> never fails appeared first on The Old New Thing.
2 Mar
What sort of horrible things happen if my dialog has a non-button with the control ID of IDCANCEL?
Raymond ChenYou get notifications that might not make sense. The post What sort of horrible things happen if my dialog has a non-button with the control ID of <CODE>IDCANCEL</CODE>? appeared first on The Old New Thing.
27 Feb
Making sure it triggers when you need it, and not when you don't. The post Intercepting messages inside <CODE>IsDialogMessage</CODE>, fine-tuning the message filter appeared first on The Old New Thing.
26 Feb
Using an IsDialogMessage extension point. The post Intercepting messages inside <CODE>IsDialogMessage</CODE>, installing the message filter appeared first on The Old New Thing.
25 Feb
Process the message before you let IsDialogMessage see it. The post Intercepting messages before <CODE>IsDialogMessage</CODE> can process them appeared first on The Old New Thing.
24 Feb
Intercepting the flow in your message loop. The post Customizing the ways the dialog manager dismisses itself: Isolating the Close pathway appeared first on The Old New Thing.
23 Feb
Customizing the ways the dialog manager dismisses itself: Detecting the ESC key, second (failed) attempt
Raymond ChenSniffing the synchronous keyboard state is still not precise enough. The post Customizing the ways the dialog manager dismisses itself: Detecting the ESC key, second (failed) attempt appeared first on The Old New Thing.
20 Feb
Customizing the ways the dialog manager dismisses itself: Detecting the ESC key, first (failed) attempt
Raymond ChenSniffing the asynchronous keyboard state. The post Customizing the ways the dialog manager dismisses itself: Detecting the ESC key, first (failed) attempt appeared first on The Old New Thing.
19 Feb
Summarizing the flow. The post Exploring the signals the dialog manager uses for dismissing a dialog appeared first on The Old New Thing.
18 Feb
I guess it could, but why bother? The post Could <CODE>WriteProcessMemory</CODE> be made faster by avoiding the intermediate buffer? appeared first on The Old New Thing.
16 Feb
It rather involved being on the other side of the airtight hatchway: Tricking(?) a program into reading files
Raymond ChenIs it really a trick when reading the file is the purpose of the program? The post It rather involved being on the other side of the airtight hatchway: Tricking(?) a program into reading files appeared first on The Old New Thing.
13 Feb
How can I distinguish between the numeric keypad 0 and the top-row 0 in the WM_CHAR message?
Raymond ChenSee if it matches the scan code. The post How can I distinguish between the numeric keypad 0 and the top-row 0 in the <CODE>WM_<WBR>CHAR</CODE> message? appeared first on The Old New Thing.
12 Feb
How can I distinguish between the numeric keypad 0 and the top-row 0 in the WM_KEYDOWN message?
Raymond ChenCheck whether it is an extended key. The post How can I distinguish between the numeric keypad 0 and the top-row 0 in the <CODE>WM_<WBR>KEYDOWN</CODE> message? appeared first on The Old New Thing.
11 Feb
How do I suppress the hover effects when I put a Win32 common controls ListView in single-click mode?
Raymond ChenYou can prevent the item from becoming hot-tracked. The post How do I suppress the hover effects when I put a Win32 common controls ListView in single-click mode? appeared first on The Old New Thing.
9 Feb
It's your one chance to make amends. The post What should I do if a wait call reports <CODE>WAIT_<WBR>ABANDONED</CODE>? appeared first on The Old New Thing.
6 Feb
How can I prevent the user from changing the widths of ListView columns in version 5 of the common controls?, part 2
Raymond ChenPreventing the resize cursor from appearing. The post How can I prevent the user from changing the widths of ListView columns in version 5 of the common controls?, part 2 appeared first on The Old New Thing.
5 Feb
How can I prevent the user from changing the widths of ListView columns in version 5 of the common controls?
Raymond ChenDeny changes to the width. The post How can I prevent the user from changing the widths of ListView columns in version 5 of the common controls? appeared first on The Old New Thing.
4 Feb
You can ask the header to be non-resizing. The post How can I prevent the user from changing the widths of ListView columns? appeared first on The Old New Thing.
2 Feb
Are you even compiling the correct file? The post Studying compiler error messages closely: Input file paths appeared first on The Old New Thing.
30 Jan
Why not store the SAFEARRAY reference count as a hidden allocation next to the SAFEARRAY?
Raymond ChenThe case of "Bring your own SAFEARRAY." The post Why not store the <CODE>SAFEARRAY</CODE> reference count as a hidden allocation next to the <CODE>SAFEARRAY</CODE>? appeared first on The Old New Thing.
29 Jan
Find a way to take ownership. The post How can I retain access to the data in a <CODE>SAFEARRAY</CODE> after my method returns? appeared first on The Old New Thing.
28 Jan
You have to use the original pointer, but even that won't be good enough. The post Why did I lose the data even though I called <CODE>SafeArrayAddRef</CODE>? appeared first on The Old New Thing.
27 Jan
A digression on the design and implementation of SafeArrayAddRef and extending APIs in general
Raymond ChenThe concerns when adding a feature to an existing API. The post A digression on the design and implementation of <CODE>SafeArrayAddRef</CODE> and extending APIs in general appeared first on The Old New Thing.
26 Jan
Two ways of preserving the data. The post What’s the difference between <CODE>SafeArrayAccessData</CODE> and <CODE>SafeArrayAddRef</CODE>? appeared first on The Old New Thing.
23 Jan
C++ has scope_exit for running code at scope exit. C# says “We have scope_exit at home.”
Raymond ChenYou can wrap it in an IDisposable. The post C++ has <CODE>scope_exit</CODE> for running code at scope exit. C# says “We have <CODE>scope_exit</CODE> at home.” appeared first on The Old New Thing.
22 Jan
A simple helper function for attaching a progress handler to a Windows Runtime IAsyncActionWithProgress or IAsyncOperationWithProgress
Raymond ChenIt doesn't do much, but it saves typing. The post A simple helper function for attaching a progress handler to a Windows Runtime IAsyncActionWithProgress or IAsyncOperationWithProgress appeared first on The Old New Thing.
21 Jan
You are replacing the window procedure, not the dialog procedure. The post On the proper usage of a custom Win32 dialog class appeared first on The Old New Thing.
16 Jan
The tab index number is an authoring concept, not a runtime concept. The post How can I get the tab index number from a dialog box control? appeared first on The Old New Thing.
15 Jan
The strings are an implementation detail. The post When programs assume that the system will never change, episode 4: Stealing strings appeared first on The Old New Thing.
14 Jan
Finding all the clipping parents. The post Clipping the focus item when looking for its on-screen location, part 3 appeared first on The Old New Thing.
13 Jan
Finding the correct clipping parent. The post Clipping the focus item when looking for its on-screen location, part 2 appeared first on The Old New Thing.
29 Oct 2025
Most browsers have the ability to launch different browser profiles. Each profile can come with a different theme and a different set of website logins (cookies, application state, etc). This can be helpful if you want to segregate browsing behavior. For example, I have different browser profiles set up for my personal email, my "consulting" […]
25 May 2025
One of the first ever Redis libraries for Go was hosted at github.com/garyburd/redigo. It has been deprecated for some time and has now been finally removed altogether from Github. If you still have a dependency on this project, this means that will be broken now. github.com/gomodule/redigo should be a drop-in replacement for github.com/garyburd/redigo. If you […]
30 Dec 2021
Sara Soueidan is an independent Web UI and design engineer, author, speaker, and trainer from Lebanon. Currently, she’s working on a new course, "Practical Accessibility," meant to teach devs and designers ways to make their products accessible. We chatted with Sara about front-end web development, the importance of design and her appreciation of birds. The post Hacks Decoded: Sara Soueidan,…
4 Aug 2021
When you sign up for Datadog, you are immediately asked to choose whether you want to have your data stored in US1, US3, or Europe. This is an odd UI decision because Datadog provides no other information about US1 and US3, for example, where they are located or how old the infrastructure is in each […]
4 Sept 2020
I finally got my home network in a place where I am happy with it. I wanted to share my setup and what I learned about it. There has never been a better time to set up a great home network; there are several new tools that have made this easier and better than in […]
3 Apr 2020
So, I just watched Michał Muskała ’s talk at CodeBEAMSF, and I have something to say… https://medium.com/media/111e462a24f172ad0b245a48d12b0a27/href As you might know, I’m also working with Juan Bono , Diego Calero , Facundo Olano , and others on our own formatter for Erlang (just like Daniel Tipping is working on steamroller ). I could write an article on how our formatter…
12 Mar 2019
Say you have a Aurora RDS PostgreSQL database that you want to use as the source database for Amazon Database Manager Service. The documentation is unclear on this point so here you go: you can't use an Aurora RDS PostgreSQL database as the source database because Aurora doesn't support the concept of replication slots, which […]
17 Feb 2019
Three years ago I quit my job and started consulting full time. It's worked out really well. I get to spend more time doing things I like to do and I've been able to deliver great products for clients. I wanted to go over some tips for starting a successful consulting business. Charge more - […]
20 Jul 2018
Last week I wrote about how AWS ALB's do not validate TLS certificates from internal services. Colm MacCárthaigh, the lead engineer for Amazon ELB, writes: I’m the main author of Amazon s2n, our Open Source implementation of TLS/SSL, and a contributor to the TLS/SSL standards. Hopefully I’m qualified to chime in! You’re right that ALB […]
10 Jul 2018
If you are using an Amazon Application Load Balancer, and forwarding traffic to internal services using HTTPS, the ALB will not validate the certificate presented by the internal service before forwarding the traffic. So we're clear here, let's say you are running a web server on Amazon ECS. The webserver is configured to present TLS […]
26 Apr 2018
Want to know how to get rough profiling of any tool written in any language, whether you control the source or not? Keep reading. For example, here's the output you get when you compile Go from source code. Each of these lines prints out a few seconds apart. How would you go about getting timings […]
4 Nov 2017
It's a common, and distressing, pattern to have factories in tests that call out to a library like Faker to "randomize" the returned object. So you might see something like this: User.create({ id: uuid(), email: faker.random.email(), first_name: faker.random.firstName(), last_name: faker.random.lastName(), address: faker.random.address(), }); package = Package.create({ width: faker.math.range(100), height: faker.math.range(200), length: faker.math.range(300), }) This is […]
23 Oct 2017
There are a number of Unix commands that manipulate something about the environment or arguments in some way before starting a subcommand. For example: xargs reads arguments from standard input and appends them to the end of the command. chpst changes the process state before calling the resulting command. envdir manipulates the process environment, loading […]
22 Oct 2017
Bazel is a build system that was recently open sourced by Google. Bazel operates on configuration files - a WORKSPACE file for your entire project, and then per-directory BUILD.bazel files. These declare all of the dependencies for your project, using a language called Skylark. There are a number of Skylark rules for things like downloading […]
16 Oct 2017
It's easier than you think to make a software package installable via Homebrew. If you depend on a very specific version of a software package (say, Postgres 9.5.3 with readline support), I highly recommend creating a Homebrew repository and publishing recipes to it. Then your team can install and update packages as easily as: brew […]
10 Oct 2017
When you navigate to your project in CircleCI's UI, Javascript from eight different analytics companies gets loaded and executed in your browser. Pusher Intercom Launch Darkly Amplitude Appcues Quora (??) elev.io Optimizely You can see this in my Network tab here: This is a problem because the CircleCI browser context has full access to the […]
1 Sept 2017
Node string encoding is all over the place. Let's try to straighten out how it works. First, some very basics about string encoding. A string is a series of bytes. A byte is 8 bits, each of which can be 0 or 1, so a byte can have 28 or 256 different values. Encoding is […]
8 May 2017
You might have heard that you shouldn't be using JWT. That advice is correct - you really shouldn't use it. In general, specifications that allow the attacker to choose the algorithm for negotiation have more problems than ones that don't (see TLS). N libraries need to implement M different encryption and decryption algorithms, and an […]
28 Apr 2017
In my experience, code can rot in two distinct ways. The first case is code that hasn’t been used in a long time, but where the environment has changed so it is no longer possible to run the code. In … Continue reading →
10 Apr 2017
You should write your next web server in Go. Yes, you! Compared with Ruby, PHP, Python, or Javascript, you're going to get great memory and latency performance, and libraries that do what you expect. The standard library can be a bit lacking though, if you are used to developing with a tool like Rails. I […]
3 Jan 2017
You may have seen this on New Year's Eve: Another leap second, another slew of outages. Handling time correctly is hard!https://t.co/kJepOfsKkv pic.twitter.com/Fwz2Xtpzkd— Dan Luu (@danluu) January 1, 2017 I'd heard a little about this problem, but I didn't understand how it broke code, and what to do about it. So here is an explainer. Background […]
27 Nov 2016
A while ago my friend Alan and I were discussing configuration management. In particular we wondered why every configuration management tool has to ship a DSL, or be loaded from YAML files. We wondered if it would be possible to just write code that deploys servers — it might let you describe what you want […]
7 Nov 2016
For the past few weeks I've been working on Logrole, a Twilio log viewer. If you have to browse through your Twilio logs, I think this is the way that you should do it. We were able to do some things around performance and resource conservation that have been difficult to accomplish with today's popular […]
3 Sept 2016
I have seen a few databases recently that could have saved a lot of space by being more efficient with how they stored data. Sometimes this isn't a big problem, when a table is not going to grow particularly quickly. But it can become a big problem and you can be leaving a lot of […]
3 Jul 2016
I've been following the commits to the Go project for some time now. Occasionally someone will post a commit with benchmarks showing how much the commit improves performance along some axis or another. In this commit, they've increased the performance of division by 7 (a notoriously tricky number to divide by) by about 40% on […]
16 Jun 2016
I have a lot of tests in Go that integrate with Postgres, and test the interactions between Go models and the database. A lot of these tests can run in parallel. For example, any test that attempts to write a record, but fails with a constraint failure, can run in parallel with all other tests. […]
7 Jun 2016
Recently I put the maximum amount of cash into my IRA account. Since stock prices jump up and down all the time, I wondered whether the current price would be the best one to buy the stock at. In particular, I'm not withdrawing money from my IRA for the better part of 40 years, so […]
26 May 2016
This is the story about an error that caused our tests to fail maybe one out of one hundred builds. Recently we figured out why this happened and deployed code to fix it. The Problem I've been fighting slow test times in Javascript and Sails since pretty much the day I started at Shyp. We […]
3 May 2016
I was hired in December 2014 as the sixth engineer at Shyp. Shyp runs Node.js on the server. It's been a pretty frustrating journey, and I wanted to share some of the experiences we've had. There are no hot takes about the learning curve, or "why are there so many frameworks" in this post. Initially […]
7 Apr 2016
Often the best way to learn a new language is to implement something you know with it. Let’s take a look at some common async Javascript patterns, and how you’d implement them in Go. Callbacks You can certainly implement callbacks in Go! Functions are first class citizens. Here we make a HTTP request and hit […]
12 Feb 2016
This is a pretty common task: encode JSON and send it to a server, decode JSON on the server, and vice versa. Amazingly, the existing resources on how to do this aren't very clear. So let's walk through each case, for the following simple User object: type User struct{ Id string Balance uint64 } Sending […]
9 Feb 2016
You might want/need to check out repos locally as several different Github users. For example, my Github account is kevinburke, but I push code at work as kevinburkeshyp. If I could only commit/push as one of those users on each machine, or I had to manually specify the SSH key to use, it would be […]
14 Jan 2016
Recently there's been a trend in API's to return more than one error, or to always return an array of errors, to the client, when there's a 400 or a 500 server error. From the JSON API specification: Error objects MUST be returned as an array keyed by errors in the top level of a […]
27 Dec 2015
This past week the team at Shyp decided to fork the framework we use (Sails.js) and the ORM it uses (Waterline). It was an interesting exercise in JS tooling, and I wasted a lot of time on busywork, so I thought I'd share a little bit about the process. Why Fork? We've been on an […]
18 Nov 2015
Do you have objects in your system that can be in different states (accounts, invoices, messages, employees)? Do you have code that updates these objects from one state to another? If so, you probably want a state machine. What is a state machine? At its root, a state machine defines the legal transitions between states […]
13 Oct 2015
Adrian Colyer wrote a great summary of a recent paper by Peter Bailis et al. In the paper the database researchers examine open source Rails applications and observe that the applications apply constraints - foreign key references, uniqueness constraints - in a way that's not very performant or correct. I was pretty surprised to read […]
26 Sept 2015
There's a distressing feeling in the Node.js community that apps without up-to-date dependencies are somehow not as good, or stable, as apps that always keep their dependencies up to date. So we see things like greenkeeper.io and badges that show whether the project's dependencies are up to date (and, implicitly, shame anyone whose dependencies aren't […]
6 Sept 2015
The Shyp API currently runs on top of the Sails JS framework. It's an extremely popular framework - the project has over 11,000 stars on Github, and it's one of the top 100 most popular projects on the site. However, we've had a very poor experience with it, and with Waterline, the ORM that runs […]
31 Aug 2015
Okay! You had an idea for how to improve the project, the maintainers indicated they'd approve it, you checked out a new branch, made some changes, and you are ready to submit it for review. Here are some tips for submitting a changeset that's more likely to pass through code review quickly, and make it […]
25 Aug 2015
Our test suite has been failing maybe 2% of the time with a pretty opaque error message. I thought the database logs would have more information about the failure so I figured out how to turn them on with Circle. Add the following to the database section of your circle.yml: database: override: - sudo sed […]
20 Apr 2015
Our test environment takes 6-9 seconds to load before any tests get run. I tire of this during the ~30 times I run the test suite a day,1 so I wanted to make it faster. For better or worse, the API runs on Sails.js. Before running model/controller tests, a bootstrap file in our tests calls […]
29 Nov 2014
Recently I had a very weird problem with iTerm where new login shells were being created with environment variables already present. Restarting my machine made the issue go away, and I wasn't able to reproduce it again. But I got curious about how long ZSH spends in various parts of the startup process. A new […]
1 Aug 2014
I used to play a ton of Roller Coaster Tycoon when I was a kid. I loved the game but I was never very good at making the roller coasters. They always felt too spread out, or too unnatural looking. As a ten year old I idly wondered about writing a computer program that was […]
22 Jul 2014
You have photos on your computer. You would probably be really sad if you lost them. Let's discuss some strategies for ensuring that doesn't happen. What you are doing now is probably not enough. Your current strategy is to have photos and critical files stored on your most current laptop and maybe some things in […]
You kick off a long running job - maybe a data migration script that operates on a large data set, or you're copying a large file from one disk to another, or from the Internet to your local computer. Then a few minutes in, you realize the job is going to take longer than you […]
4 Jun 2014
It's important to recognize the people that have contributed to your project, but it can be annoying to keep your project's AUTHORS file up to date, and annoying to ask everyone to add themselves in the correct format. So I did what any good engineer should do, and automated the process! I added a simple […]
21 Apr 2014
The Heartbleed bug was really bad for OpenSSL - it let you ask a server a simple question like "How are you" and then have the server tell you anything it wants (password data, private keys that could be used to decrypt all traffic), and the server would have no idea it was happening. A […]
24 Mar 2014
"Build software like a tank." I am not sure where I read this, but I think about it a lot, especially when writing HTTP clients. Tanks are incredible machines - they are designed to move rapidly and protect their inhabitants in any kind of terrain, against enemy gunfire, or worse. HTTP clients often run in […]
29 Dec 2013
This will be short, but it seems there's some difficulty doing this, so I thought I'd share. The gist is, any time you reference a class or method in your own library, in the Python standard library, or in another third-party extension, you can provide a link directly to that project's documentation. This is pretty […]
20 Oct 2013
Over on the Twilio Engineering Blog, I have a new post about optimizing your HAProxy configuration. I wrote this mostly because we had some confusion in our configuration about setting options, and if I had it I figured others would as well. Here's a sample: When I said a 30 second connect timeout meant HAProxy […]
31 Aug 2013
A lot of code I come across consists of relatively few, but long, methods. The code does what it is supposed to do. However, it could be improved a lot. Refactoring to use more methods can produce better structured programs … Continue reading →
18 Aug 2013
Recently I've fallen in love with the IPython Notebook. It's the Python REPL on steroids and I've probably just scratched the surface of what it can actually do. This will be a short post because long posts make me feel pain when I think about blogging more again. This is also really more about setting […]
13 Aug 2013
Yesterday I sped up our unit/integration test runs from 16 minutes to 3 minutes. I thought I'd share the techniques I used during this process. We had a hunch that an un-mocked network call was taking 3 seconds to time out. I patched this call throughout the test code base. It turns out this did […]
1 Jun 2013
I really enjoyed Sam Saffron's post about eliminating trivial inconveniences in his development process. This resonated with me as I tend to get really distracted by minor hiccups in the development process (page reload taking >2 seconds, switch to a new tab, etc). I took a look at my development process and found a few […]
17 Feb 2013
Do you write forms on the Internet? Are you planning to send them to your server with Javascript? You should read this. The One-Sentence Summary It's okay to submit forms with Javascript. Just don't break the internet. What Do You Mean, Break the Internet? Your browser is an advanced piece of software that functions in […]
12 Feb 2013
If you've ever tried to teach someone HTML, you know how hard it is to get the syntax right. It's a perfect storm of awfulness. Newbies have to learn all of the syntax, in addition to the names of HTML elements. They don't have the pattern matching skills (yet) to notice when their XML is […]
29 Jan 2013
I've worked with Twilio's client libraries pretty much every day for the last year and I wanted to share some of the things we've learned about helper libraries. Should you have helper libraries? You should think about helper libraries as a more accessible interface to your API. Your helper libraries trade the details of your […]