Swift build does not work. Not even on brand new project. Example:
- Create new proejct
$ mkdir swift-app-test2; cd swift-app-test2
$ swift package init
""" | |
Terminal/Console flow control demo | |
Most terminals support ctrl+S/ctrl-Q for pausing and unpausing | |
writing to it, which can be useful in some situations. | |
However, note that the terminal pause does _not_ pause the whole process, | |
how terminal job control (ctrl-z) does. Instead, only the thread that | |
attempts to write to stdout will block, while other threads are free to | |
continue processing. Only way other threads would block is they, too, |
#!/usr/bin/env python3 | |
""" | |
Usage: | |
$ zip-dir -i path/to/directory -o myarchive.zip --level 0 | |
or more verbosely: | |
$ zip-dir --input-dir path/to/directory --output-zip myarchive.zip --level 0 | |
Install: |
import math | |
M = 80 | |
points = [(10, 20), (40, 30), (40, 35), (65, 25), (55, 60), (20,60), (75,75)] | |
def dist(p1, p2): | |
dx = abs(p1[0] - p2[0]) | |
dy = abs(p1[1] - p2[1]) | |
return math.sqrt(dx*dx + dy*dy) |
nanobind
is a tool and a library for implementing native C/C++ extensions for python.
You can implement such extensions in many ways, but nanobind
makes life a bit more
easier, especially if you write C++ and use CMake to build your native code.
nanobind
recommends using the scikit-build-core
as the build backend; it handles the
heavy lifting of building stuff through CMake during python package build process. It even
supports using Ninja. And as a cherry on top, it is able to download CMake and Ninja
from pypi
if they are not available locally.
// build and run with: | |
// $ gcc nullptr-shenanigans.c -Wall -Wextra -pedantic -std=c99 -O0 -o lol | |
// $ ./lol | |
// expected output: | |
// Got SIGSEGV at address: 0x0 (REG_RIP = 93937079497465) | |
// This should not print: p = (nil)? | |
// Allright then, we are done! | |
#define _GNU_SOURCE 1 /* To pick up REG_RIP */ |
2024-05-06: I was using telegram to send a message in one of the group chats I'm in.
2024-05-07: I noticed that a copy of my sent message was left as draft in the same chat (which is indicated by a red Draft:
prefix in the chat list). If I opened the chat group, the draft message would indeed be entered in the message
preparation box.
However, I could not erase the draft message; if I tried, it would simply return in a few seconds. I tried several times.
I noticed I could erase parts of the draft or add more. All those changes would be reflected between my phone and laptop.
""" | |
Are you tired of plain old integer-based indexing? | |
Use floats instead! | |
""" | |
# Author: Markus H (MawKKe) 2024-04 https://github.com/MawKKe | |
import math | |
import typing as t |
Most programming languages have basic types such as booleans, bytes, shorts, integers, floating point numbers, strings, lists, etc. If you squint your eyes a bit, you'll notice all of these are just a bunch of bytes with varying sizes and shapes.
Strings (arrays) are (possibly unbounded) sequence of bytes. Integers and floating point types are often represented as fixed number of bytes or bits. Booleans semantically means "one bit", but often are implemented as a single byte (for performance reasons).
Now, think how many different values or states can each of these represent. Well, obviously the answer if 2**(number of bits in the type), duh!