-- Leo's gemini proxy
-- Connecting to gemini.tuxmachines.org:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini;lang=en-GB
Tux Machines
Posted by Roy Schestowitz on Feb 18, 2023
> Creating simple but realistic physics-based flight simulations from scratch with C++ and OpenGL.
> Technologies that can replace C++ in the near of far future are not compilers. They are Spiral, Numba, and ForwardCom.
> During a recent code review I found a hard to spot bug, a misplaced parenthesis in an `if` statement. I often employ a technique I call `named booleans`, which would have prevented this bug. It's a simple technique, instead of a long `if` statement, give every comparison a seperate boolean variable with a descriptive name and use those variables is the `if` statement. This post shows the bug in question, an example of my `named booleans` technique and another tip regarding naming magic numbers.
> To check if the string contains substring from the Python list, the “list comprehension”, the “any()” method, and the iterative function “for” loop is used.
> To divide two columns Pandas in the Python, the “/” divide operator, “div()” methods, and “np.where()” methods can be used.
> To convert a one-dimensional array into a two-dimensional array, the “reshape()” method, “np.reshape()” method and “np.arange()” method can be used.
> To remove the number from the string in Python, the “join()” and “isdigit()” methods, “translate()”, “filter()”, and “sub()” methods are used.
> To repeat a string “n” times in Python, the repetition “*” operator, “for” loop an iterative function, and user-defined function can be used.
> To initialize the dictionary, “fromkey()”, “defaultdict()”, “setdefault()”, “dict()”, “zip()”, passing arguments, and curley “{}” braces techniques are used.
> To get previous month's datetime in Python, the “datetime” module with “replace()” method and “datetime” module using the extension “dd” techniques can be used.
> To initialize the 2d list in Python, the “range()” method and “numpy.full()” method with the “tolist()” method are used.
> To remove the quotes from any Python string, the “for” Loop, the “replace()”, “re.sub()”, “strip()”, “Istrip()” and “rstrip()” methods are used.
> Sometimes it seems like accessibility experts and other web professionals hate JavaScript. This might be true for some, but most understand that JavaScript can be useful for improving UX and even accessibility. JavaScript solutions are often more accessible than their pure HTML or CSS counterparts.
> Generating PDF files is mostly (but not entirely) a serialization problem where you keep repeating the following loop:
>
> This means that you have to spend a fair bit of time without much to show for it apart from documents with various black boxes in them. However once you have enough foundational code, then suddenly you can generate all sorts of fun images. Let's look at some now.
-- Response ended
-- Page fetched on Thu Jun 13 11:04:27 2024