Programming Leftovers
-
Qt as a Career – The Versatility of Technical Artistry
In this series, we'll be bringing you a variety of career stories from people working with Qt.
-
How to use valgrind to track file descriptors | Red Hat Developer
A file descriptor is a positive integer number representing resources that can do input or output. Naturally, they can represent files that your program opens, but also network sockets and pipes between programs. Also, file descriptors can be created for monitoring timers, signals, and process ids.
File descriptors are, by default, a limited resource. ulimit -n will show you what the default number of file descriptors that a program can open. A program can normally have only 1024 file descriptors open. Although this number can be increased (also using ulimit -n), you might still want to make sure you don't keep file descriptors open unnecessarily.
As long as a file descriptor is open, the resources associated with it cannot be released. For example, a file cannot be deleted from the disk if a program is still reading it, or a network port will be kept open. Also, open file descriptors are inherited by any program created by execve (unless it was opened with the O_CLOEXEC flag).
-
Boosting Win Probability accuracy with player embeddings
In my previous post Computing Win Probability of T20 matches I had discussed various approaches on computing Win Probability of T20 matches. I had created ML models with glmnet and random forest using TidyModels.
-
November 2022: 'Top 40' New CRAN Packages - R Views
One hundred sixty-seven new packages made it to CRAN in November: Here are my “Top 40” selections in fourteen categories: Climate Modeling: Computational Methods, Data, Ecology, Epidemiology, Genomics, Machine Learning, Mathematics, Networks, Pharma, Statistics, Time Series, Utilities, and Visualization.
-
Conditional API Responses For JavaScript vs. HTML Forms
Today, I’ll show you how to detect whether an HTTP request was submitted via HTML form or with JavaScript to the server.
The examples in this post are based on Nuxt.js and include references to a few global functions (defineEventHandler, getRequestHeaders, sendRedirect). It’s not important that you know how they work. Just focus on the concept. I’ll explicitly highlight the important bits
Here’s a very basic event handler for a Nuxt JS server. An “event handler” in Nuxt.js represents an HTTP endpoint.
-
Tribonacci sequence
-
Easily re-using self-written functions: the power of gist + code snippet duo
Quite often data processing or analysis needs bring us to write own functions. Sometimes these self-defined functions are only meaningful and useful within a certain workflow or even a certain script. But other self-written functions may be more generic and reusable in other circumstances. For example, one may want to have a version of ggsave() that always enforces bg = 'snow', or a theme_own() function with pre-saved preferences. Self-written functions live in {.GlobalEnv} and have to be re-defined in every new R session. Copying the same lines of code across projects can be boring. How to “bookmark” the useful little own functions and reuse them easier in other projects? This post offers an elegant solution.
-
How to Use Psycopg2 to Connect Python to PostgreSQL
PostgreSQL is an object-relational database system that you can link with different programming languages. When creating a Python application, you can connect it to the PostgreSQL database. Besides, connecting Python to PostgreSQL is simplified, thanks to the psycopg2 PostgreSQL database adapter.
Once you install the adapter on your Python development environment, you can execute all PostgreSQL database tasks directly from the Python application. This guide covers different ways of using the psycopg2 database adapter when working with a Python script.
-
Learn the Ada programming language by writing a simple game | Opensource.com
These concepts are the basis of most programming languages. Once you understand them, you can start figuring out the rest. Because programming languages usually share similarities, once you know one language, you can learn the basics of another by understanding its differences.
A good way to learn new languages is practicing with a standard program. This allows you to focus on the language, not the program's logic. I'm doing that in this article series using a "guess the number" program, in which the computer picks a number between one and 100 and asks you to guess it. The program loops until you guess the number correctly.
-
How to run the correct Java version after an update | Red Hat Developer
Your shell finds the proper Java environment through an environment variable called JAVA_HOME. It could point to either a JDK or a JRE. As the error message shown earlier indicates, you should point to your JDK if you have a JDK. When non-developers run Java, they don't need the entire JDK, so they can download a JRE and point JAVA_HOME to that. You can learn more about the Java platform components in the article, What is the Java Runtime Environment.
When you upgrade Java, the system installs a new JDK, and you need to update JAVA_HOME to point to the new location.
Environment variables used in the shell are generally defined in a start-up file. This file is located in your home directory and is called .bashrc if you use the Bash shell that is the default on Linux. Note the initial dot in the name .bashrc: this dot means that the file doesn't normally turn up when you display the contents of the directory.