RSS Amplifier

Blog

Mohamed Attia's Macrocosm

Recent content on Mohamed Attia's Macrocosm

mohamed.computerRSS feed ↗7 posts

Live Last read · last published · next check

Latest posts

The Message Arrived. Did the Operation Succeed?

Prelude Every few years, I revisit one of my favorite papers END-TO-END ARGUMENTS IN SYSTEM DESIGN and this time I decided I will write an exposition of it to maybe inspire others to read it but also serve as a set of notes for my future self. Introduction Imagine we have an application that holds bank accounts for Alice and Bob. Alice wants to transfer $50 from her account to Bob’s.

Please Use HTML data-attributes

If you need to attach custom attributes to an HTMLElement that you can also access from JavaScript or CSS , please use data-attributes . HTML Let&rsquo;s say you have a very simple gallery that has image thumbnails and it displays the full image when you click on a thumbnail and also displays a caption for the image, we can define this gallery in HTML as follows: < div id = 'gallery' > < img src =…

Quick journaling in org-mode in Emacs

A while back I started maintaining a journal, it can contain things that I&rsquo;ve learned like new programming techniques, new commands, new insights, &hellip;etc. The key for me to make this viable is to be low-friction, so I&rsquo;ve written an Emacs Lisp script that opens a journal in my journal directory with today&rsquo;s date as the filename, so whenever I want to write something, I just…

Barebones python project with a virtual environment in Emacs Lisp

A lot of the time I find myself wanting to have a directory with a basic Python virtual environment initialized in it, so I wrote the following Emacs Lisp script to do that, you can use it as an interactive function in emacs or as a script that you call from a shell. Remember to change the path and the keybinding to your liking # ! emacs --script ;;; Code: ( defun setup-python-project-in-directory…

Python Internals – CPython Bytecode

In this post, I am gonna walk you through compiling python code to CPython bytecode, what code objects are, how to construct them, how to disassemble them, and how to decompile them. I will be using CPython 3.6.5. A simple example >>> codestr = ''' print('Witness me!') ''' >>> compiled_codestr = compile ( codestr , '<string>' , 'exec' ) >>> type ( compiled_codestr ) < class ' code '> Whoo, we have…

ADTs (Algebraic Data Types) in Haskell

Update (2021-10-19) Correct inaccurate language referring to simple ADTs thanks to e01izuz Algebraic Data Types are a way for us to define types like the ones that come with Haskell e.g. Bool and Int . Single Constructor Without Arguments One of the simplest datatypes we can construct in Haskell is a type with a single constructor, data Frame = MkFrame x = MkFrame Examining the type in ghci :>…

Mathematical Induction

Suppose you want to sum up the first 10 natural numbers 1, 2, 3, ... The most obvious way to do it would be to add the numbers consecutively like so: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55 No big deal, but now you want to sum the first 1000 natural numbers i.e. 1, 2, 3, ..., 1000 . While you’re carrying out this laborious task, your friend Hypatia passes by and tells you with a confused look…