124 private links
Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It’s the “Command Line Interface Creation Kit”. It’s highly configurable but comes with sensible defaults out of the box.
It aims to make the process of writing command line tools quick and fun while also preventing any frustration caused by the inability to implement an intended CLI API.
Click in three points:
- arbitrary nesting of commands
- automatic help page generation
- supports lazy loading of subcommands at runtime
Error handling is an integral part of programming, but in many popular languages, it comes as an afterthought.
The godfather of numerous programming dialects, C, never had a dedicated error or exception mechanism in the first place. It is up to the programmer to accurately report whether the function did what it was intended to do, or threw a tantrum—usually by relying on integers. In case of a segmentation fault—well, all bets are off.
This post goes through the experience of the author in the adaptation to the Golang error management workflow.
Contains clickable links to The Book, Rust by Example, Std Docs, Nomicon, Reference. Furthermore, entries are marked as largely deprecated, have a minimum edition, or are bad.
It summarizes concept including: Data Structures, References & Pointers, Functions & Behaviors, Control Flow, Organizing code, Type Aliases and Cast, Code Generation, Pattern Matching, Generics & Constraints, Strings & Chars, Comments, Common Operators, Idiomatic Rust.
From Josh Mcguigan.
This is a tutorial on building your own shell using Rust, in the spirit of the build-your-own-x list. Creating a shell is a great way to understand how the shell, terminal emulator, and OS work together.
Inspired by Ollie Charles and his excellent 24 days of Hackage series, I'm going to try and introduce you to a number of Rust language features, useful libraries and cool projects built with Rust.
In fact this is a learning opportunity for me too - as much as I love Rust, I'm just diving in. If you think I'm wrong or know an interesting library you want me to write about, feel free to comment!
There’s a fairly common argument that pops up on programming forums, and it’s about the nature of what “garbage collection” means. In the research world, this is what GC means: Garbage collection (GC), also known as automatic memory management, is... | Steve Klabnik | “The most violent element in society is ignorance.” - Emma Goldman
I’ve almost never been able to write correct Python import statements on the first go. Behavior is inconsistent between Python 2.7 and Python 3.6 (the two versions that I test here), and there is no single method for guaranteeing that imports will always work.
This post is my dive into how to resolve common importing problems. Unless otherwise stated, all examples here work with both Python 2.7 and 3.6.
Examples of Python and Rust code to illustrate the concept of ownership.
Very good tutorial.
It’s hard for me to teach an in-depth Python class without discussing lambda expressions. I almost always get questions about them. My students tend to see them in code on StackOverflow or they see them in a coworker’s code (which, realistically, may have also come from StackOverflow).
I get a lot of questions about lambda, I’m hesitant to recommend my students embrace Python’s lambda expressions. I have had an aversion to lambda expressions for many years, and since I started teaching Python more regularly a few years ago, my aversion to lambda expressions has only grown stronger.
I’m going to explain how I see lambda expressions and why I tend to recommend my students avoid using them.
Experienced programmers often need to use online resources to pick up new programming languages. However, we lack a comprehensive understanding of which resources programmers find most valuable and utilize most often. In this paper, we study how experienced programmers learn Rust, a systems programming language with comprehensive documentation, extensive example code, an active online community, and descriptive compiler errors. We develop a task that requires understanding the Rust-specific language concepts of mutability and ownership, in addition to learning Rust syntax.
Our results show that users spend 42% of online time viewing example code and that programmers appreciate the Rust Enhanced package’s in-line compiler errors, choosing to refresh every 30.6 seconds after first discovering this feature. We did not find any significant correlations between the resources used and the total task time or the learning outcomes. We discuss these results in light of design implications for language developers seeking to create resources to encourage usage and adoption by experienced programmers.
molten is a minimal, extensible, fast and productive framework for building HTTP APIs with Python.
See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
where <scope>
is optional.
Example
feat: add hat wobble
^--^ ^------------^
| |
| +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.
More Examples:
feat
: new feature for the user, not a new feature for build scriptfix
: bug fix for the user, not a fix to a build scriptdocs
: changes to the documentationstyle
: formatting, missing semi colons, etc; no production code changerefactor
: refactoring production code, eg. renaming a variabletest
: adding missing tests, refactoring tests; no production code changechore
: updating grunt tasks etc; no production code change
Adapted from http://www.possibility.com/Cpp/CppCodingStandard.html and NetBSD's style guidelines.
Line-breaking algorithms take a paragraph's-worth of words, and split the words into line-lengthed chunks. The two algorithms many programmer's know of are:
- The greedy algorithm; and,
- The Knuth-Plass algorithm (the 'latex one').
Most programmers "know" the following three facts:
- Knuth-Plass produces the 'best' line breaks;
- Knuth-Plass is a quadratic algorithm; and,
- Knuth-Plass uses dynamic programming and is impossible for mere mortals to code.
While we happen to agree with (1), we will demonstrate that (2) and (3) are, respectively, not true, and unnecessarily obscure. In fact, the Knuth-Plass algorithm---even in its most naive implementation---is strongly dominated by a light-weight linear run-time, and the implementation of the core algorithm is remarkably straightforward.
How many times have you repeatedly typed out a long command on the command line and wished there was a way to save it for later? This is where Bash aliases come in handy. They allow you to condense long, cryptic commands down to something easy to remember and use. Need some examples to get you started? No problem!
I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).
You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL
A collection of design patterns/idioms in Python. Contribute to faif/python-patterns development by creating an account on GitHub.
I’ve been programming for 15 years now. Recently our industry’s lack of care for efficiency, simplicity, and excellence started really getting to me, to the point of me getting depressed by my own career and the IT in general.
Modern cars work, let’s say for the sake of argument, at 98% of what’s physically possible with the current engine design. Modern buildings use just enough material to fulfill their function and stay safe under the given conditions. All planes converged to the optimal size/form/load and basically look the same.
Only in software, it’s fine if a program runs at 1% or even 0.01% of the possible performance. Everybody just seems to be ok with it. People are often even proud about how much inefficient it is, as in “why should we worry, computers are fast enough”...
At the North America edition of the 2018
Linux Security Summit (LSS NA), which was held in late August in Vancouver,
Canada, Kees Cook gave a presentation on some of the dangers that come with
programs written in C. In particular, of course, the Linux kernel is
mostly written in C, which means that the security of our systems rests on
a somewhat dangerous foundation. But there are things that can be done to
help firm things up by "Making C Less Dangerous" as the title
of his talk suggested.