An interesting mistake with Go's context package that I (sort of) made
https://utcc.utoronto.ca/~cks/space/blog/programming/GoContextValueMistake [utcc.utoronto.ca]
2020-08-30 16:29
tag: intro-programming
An interesting mistake with Go's context package that I (sort of) made
https://utcc.utoronto.ca/~cks/space/blog/programming/GoContextValueMistake [utcc.utoronto.ca]
2020-08-30 16:29
How can CharUpper and CharLower guarantee that the uppercase version of a string is the same length as the lowercase version?
https://devblogs.microsoft.com/oldnewthing/20200804-00/?p=104040 [devblogs.microsoft.com]
2020-08-05 00:49
The CharUpper function tries to convert the string in place, but if the uppercase and lowercase versions of a character are not the same length, then it panics and does something strange.
Also: https://devblogs.microsoft.com/oldnewthing/20200803-00/?p=104038
Let's build a Full-Text Search engine
https://artem.krylysov.com/blog/2020/07/28/lets-build-a-full-text-search-engine/ [artem.krylysov.com]
2020-07-30 16:48
Today we are going to build our own FTS engine. By the end of this post, we’ll be able to search across millions of documents in less than a millisecond. We’ll start with simple search queries like “give me all documents that contain the word cat” and we’ll extend the engine to support more sophisticated boolean queries.
source: L
Using Go build directives to optionally use new APIs in the standard library
https://utcc.utoronto.ca/~cks/space/blog/programming/GoBuildUsingNewAPIs [utcc.utoronto.ca]
2020-07-19 06:42
I mentioned recently that new APIs in the Go standard library were relatively easy to optionally support, because such new APIs only appear in new Go releases and you can conditionally build files based on the Go release that’s building your program. But that’s a pretty abstract description, so let’s make it concrete.
Why strace doesn't work in Docker
https://jvns.ca/blog/2020/04/29/why-strace-doesnt-work-in-docker/ [jvns.ca]
2020-05-04 14:43
But I wasn’t interested in fixing it, I wanted to know why it happens. So why does strace not work, and why does --cap-add=SYS_PTRACE fix it?
source: HN
Making Illegal States Unrepresentable
https://buttondown.email/hillelwayne/archive/making-illegal-states-unrepresentable/ [buttondown.email]
2020-04-19 14:43
It’s a concept I find very helpful. But if you look for examples online almost everything either “let’s prevent dividing-by-zero” or “let’s enumerate the cases in a data type”. We can more creative than that! Some examples of “illegal states unrepresentable” that I found useful but have not seen anyone else talk about online:
source: L
Rust Ownership Rules
https://www.geekabyte.io/2020/02/rust-ownership-rules.html [www.geekabyte.io]
2020-03-03 03:26
In this post, I took the opportunity to re-summarise what I consider to be the essence of this ownership rules in Rust.
source: L
Addressing of AF_INET, AF_INET6 and AF_UNIX sockets
https://idea.popcount.org/2019-12-06-addressing/ [idea.popcount.org]
2019-12-02 06:05
A freshly created socket isn’t very useful. We have to tell it to either listen for incoming data, or connect to a remote peer. To achieve anything useful we need to perform a syscall dance, which involves either bind() or connect() or both.
And some notes about the DNS resolver rabbit hole.
source: L
kill tail(1) when sh exits
https://dacav.roundhousecode.com/blog/2019-10/17-kill-tail-1-when-sh-exits.html [dacav.roundhousecode.com]
2019-10-17 17:24
As a solution, the POSIX shell provides a built-in named trap, documented here. In short it allows to define actions to be executed upon signaling, and that includes shell termination. It is similar to atexit(3) in POSIX C.
source: L
Function Currying in Go
https://medium.com/@meeusdylan/function-currying-in-go-a88672d6ebcf [medium.com]
2019-10-11 15:17
Go can be used to program in a functional style, previously I’ve written about how we can use this to implement Continuation Passing Style programming. As such, it is possible to implement currying in Go as well. Before we take a look at how we can implement this in Go, let’s take a practical look at what function currying actually is, and why we want this.
source: HN
Beginner Problems With TCP & The socket Module in Python
https://blubberquark.tumblr.com/post/186695350125/beginner-problems-with-tcp-the-socket-module-in [blubberquark.tumblr.com]
2019-08-12 00:15
Your operating system will deceive you and re-assemble the string you sock.recv(n) differently from the ones you sock.send(data). But here is the deceptive part. It will work sometimes, but not always. These bugs will be difficult to chase. If you have two programs communicating over TCP via the loopback device in your operating system (the virtual network device with IP 127.0.0.1), then the data does not leave your RAM, and packets are never fragmented to fit into the maximum size of an Ethernet frame or 802.11 WLAN transmission. The data arrives immediately because it’s already there, and the other side gets to read via sock.recv(n) exactly the bytestring you sent over sock.send(data). If you connect to localhost via IPv6, the maximum packet size is 64 kB, and all the packets are already there to be reassembled into a bytestream immediately! But when you try to run the same code over the real Internet, with lag and packet loss, or when you are unlucky with the multitasking/scheduling of your OS, you will either get more data than you expected, leftover data from the last sock.send(data), or incomplete data.
Not strictly a python problem, either.
source: Dfly
rustlings
https://github.com/rust-lang/rustlings [github.com]
2019-07-30 02:08
This project contains small exercises to get you used to reading and writing Rust code. This includes reading and responding to compiler messages!
source: L
Execute Program
https://www.executeprogram.com/ [www.executeprogram.com]
2019-07-23 21:08
Execute Program is for people who already know a programming language. We’ll help you to fill in gaps in your existing knowledge.
At least in the beginning, seems introductory. Not sure how advanced it goes.
A program to detect mojibake that results from a UTF-8-encoded file being misinterpreted as code page 1252
https://devblogs.microsoft.com/oldnewthing/20190701-00/?p=102636 [devblogs.microsoft.com]
2019-07-02 16:29
It is not uncommon to see UTF-8-encoded data misinterpreted as code page 1252, due to file content lacking an explicit encoding declaration, such as you might encounter with the Resource Compiler. So let’s write a program to detect that specific kind of mojibake.
Why you should learn just a little Awk: An Awk tutorial by Example
https://gregable.com/2010/09/why-you-should-know-just-little-awk.html [gregable.com]
2019-06-18 23:15
In grad school, I once saw a prof I was working with grab a text file and in seconds manipulate it into little pieces so deftly it blew my mind. I immediately decided it was time for me to learn awk, which he had so clearly mastered.
source: vermaden
Things I Learnt The Hard Way
https://blog.juliobiason.net/thoughts/things-i-learnt-the-hard-way/ [blog.juliobiason.net]
2019-06-12 04:25
This is a cynical, clinical collection of things I learnt in 30 years working with software development. Again, some things are really cynical, others are long observations on different jobs.
source: L
Weird Ruby: Positive and Negative Strings
https://metaredux.com/posts/2019/05/10/weird-ruby-positive-and-negative-strings.html [metaredux.com]
2019-05-10 15:29
Turns out that when frozen string literals were introduced in Ruby 2.3 a couple of unary methods were added to the String class - namely unary + and -. They made it possible to have “positive” and “negative” string literals. What does this mean exactly? Let’s figure this out together!
source: L
Representative Line: Log Every Error
https://thedailywtf.com/articles/log-every-error [thedailywtf.com]
2019-04-25 18:01
This code knows that accessing the logger object is code that can throw an error, so if it gets an error fetching the logger object it… logs the error. With the logger object that returned some kind of error.
Recursive failure is best failure.
powerpc64 architecture support in FreeBSD ports
https://doi.asiabsdcon.org/10.25263/asiabsdcon2019/p02a [doi.asiabsdcon.org]
2019-04-25 15:55
For my project, I build the whole ports tree using Poudriere and fix the compilation errors I meet. In this paper, I specify challenges met during porting software to work on POWER processors on FreeBSD and show how most problems can be solved.
Trivial stuff, if only people cared. Relevant beyond narrow scope of FreeBSD PowerPC as well.
What I Learnt Building a Lobsters TUI in Rust
https://www.wezm.net/technical/2019/04/lobsters-tui/ [www.wezm.net]
2019-04-25 15:36
As a learning and practice exercise I built a crate for interacting with the Lobsters programming community website. It’s built on the asynchronous Rust ecosystem. To demonstrate the crate I also built a terminal user interface (TUI).
source: L