Language Selection

English French German Italian Portuguese Spanish

Programming Leftovers

Filed under
Development

  • Joachim Breitner: A mostly allocation-free optional type

    The Motoko programming language has a built-in data type for optional values, named ?t with values null and ?v (for v : t); this is the equivalent of Haskell’s Maybe, Ocaml’s option or Rust’s Option. In this post, I explain how Motoko represents such optional values (almost) without allocation.

  • C++ pragma directive

    Pragma is a compiler directive that allows us to add additional information to the compiler so that it can compile the code effectively. This information, once added, is not then in our hands to control it and can change the details of compilation. This directive is used to access compiler-related specific processor extensions.

  • Extracting Data From Smart Scale Gives Rube Goldberg A Run For His Money | Hackaday

    [Kevin Norman] got himself a smart body scale with the intention of logging data for his own analysis, but discovered that extracting data from the device was anything but easy. It turns out that the only way to access data from his scale is by viewing it in a mobile app. Screen-scraping is a time-honored method of pulling data from uncooperative systems, so [Kevin] committed to regularly taking a full-height screenshot from the app and using optical character recognition (OCR) to get the numbers, but making that work was a surprisingly long process full of dead ends.

  • Ruby String Replace

    A fundamental method to search and replace a string is using regular expressions. RegEx is powerful in finding patterns, filtering, and more.

    In this guide, we will discuss various ways to manipulate strings in Ruby. We will cover how to perform string substation, insertion, and replacement.

  • Ruby String Interpolation

    String interpolation refers to the process of adding placeholders that reference other values in a string object. The values interpolated into a string are evaluated to their corresponding values. String interpolation can be seen as a form of template injection.

    In this guide, we will discuss how to interpolate strings in the Ruby programming language.

  • Ruby String Concatenation

    Strings are an array of one or more alphanumerical characters and symbols. It is almost a guarantee you are going to use strings in your programs. They allow you to accept input from the users and display information to the users.

    This tutorial will help you understand how to create strings, print strings, and string concatenation.

  • Ruby Reverse String

    Strings are a fundamental building block in programming, and it is nearly impossible to imagine a functional program that doesn’t use strings.

    This guide will look at various ways we can reverse a string in the Ruby programming language.

  • Ruby Find Elements In An Array

    In Ruby and other programming languages, arrays allow you to store related information in a list and manage them by a single variable.

    Once you have an array, you can manipulate the elements stored in it, such as creating, reading, updating, and deleting elements.

    In this short guide, we will explore various ways to find elements in an array.

  • Ruby Check If An Array Contains Values

    Arrays are a collection of ordered items. Arrays are crucial in many programming languages because they provide flexibility, performance, and refactored code when used appropriately.

    An individual item in the array is an array’s element. Each element is identifiable by an index which is a value that describes the element’s position in the collection.

    In Ruby, the index of elements in the array starts at 0 from left to right. Hence, the first element in the array is at an index of 0.

  • Convert List to DataFrame Python

    In this tutorial, you will learn about lists and data frames. Also, we discussed different list conversion methods to the data frame in python language. The list in python is the most vital data structure. The important thing about the list is that the list items are not forcibly the same data type, and all the string operations are equally applied on the list data types. Come let’s talk about the data frames.

    In python, panda’s library is used for data handling and analysis. Pandas Dataframe is a 2D size-changeable and varied tabular data constructor with marked axes. In Dataframe, knowledge is ranged in a tabular way in columns and rows. Pandas Dataframe contains 3 main essentials, i.e., data, columns, and rows. We will implement our scenarios in Spyder Compiler so let’s get started.

  • Convert Set to list Python

    In Python, sets and lists both contain collections of objects, but there are significant differences between these two. If we talk about sets, they are valuable for executing a massive range of intersections and unions. On the other hand, lists provide those operations that help you to find duplicated items. In other words, a list contains identical items, while a set contains exceptional values. Another distinct quality is that the list uses square brackets, while the set uses curly brackets. Keep in mind that a dictionary in Python also uses curly braces. The common thing in sets and lists is that they hold strings, floats, integers, or other data types. So, if you have a set of elements in Python, you can also make a set of strings in python.

  • Python Write List to file

    In python language, writing or reading files is a significant functionality. If you want to read or write files, then computer languages provide input or output libraries with built-in approaches that allow the formation, modification, reading, or writing of data from the files. Python has no exemption. Python also provides various in-built techniques to perform file operations. In Python, the I/O module is used for file handling.

    Today, our focus is python writing lists to a file. We elaborate the whole process of python write list by applying different operations with the help of Spyder Compiler in Windows 10. Since there are numerous ways of python writing lists, we also discuss different example codes to elaborate on them further.

  • Python List Pop

    Several times when programming, a programmer needs to remove the very last item from a list. The pop() method eliminates and returns the final item of the list if there is no index. This function returns the element you deleted, permitting you to see what variations were made to your list. The index of the element you have to remove is the only parameter to pop(). You might opt to remove a particular item from a list. Assume you are creating a program to keep track of the books accessible in a bookstore. When a book is taken out, you may choose to remove it from the set of possible books and return it. Pop is a built-in method in the Python language that may be used to eliminate an item from a list. The pop() method returns the removed item after removing an element from a given place in a list.

    This article will look at the pop() function in Python, how it’s utilized, and what parameters it accepts. Then, to demonstrate how the function can be used with lists, we will look at a few examples.

  • Python List Length

    Python List is a changeable and ordered sequence, as we all know about this fact. It may contain both heterogeneous and homogeneous elements. In Python, it is a widely used data structure. We occasionally need to know the length of a list to traverse it or perform other operations on it. Len() is a built-in function that returns the total number of elements in a list, sequence, arrays, dictionary, or other data structure. The length of a given list is returned by the len() method, which accepts a list as an input. In Python, the len() function is one of the most popular methods for determining the size of a provided list.

    This part will look at the various methods for determining the length of a list in Python. The length of the list refers to determining the size of the list’s size or the number of items.

    Note: All three examples demonstrated in this guide will use the “temp.py” file that is created in the Spyder IDE tool. The operating system used for the implementation of these three examples is “Windows 10”. The choice of operating system and compiler are all dependent on user convenience.

  • 7 Vital Commands to Get Started With Python for Beginners

    Learning a new programming language like Python becomes effortless if you have a comprehensive roadmap detailing which concepts to learn as a beginner and how to progress further to reach the next milestone. Even intermediate programmers should frequently brush up on their basics to build a solid foundation for themselves.

    By the end, you'll find yourself stuck to your computer writing Python code using the fundamental commands enlisted in this article. We'll also discuss how you can set up a Python environment on your machine to be able to write and execute Python code.

More in Tux Machines

digiKam 7.7.0 is released

After three months of active maintenance and another bug triage, the digiKam team is proud to present version 7.7.0 of its open source digital photo manager. See below the list of most important features coming with this release. Read more

Dilution and Misuse of the "Linux" Brand

Samsung, Red Hat to Work on Linux Drivers for Future Tech

The metaverse is expected to uproot system design as we know it, and Samsung is one of many hardware vendors re-imagining data center infrastructure in preparation for a parallel 3D world. Samsung is working on new memory technologies that provide faster bandwidth inside hardware for data to travel between CPUs, storage and other computing resources. The company also announced it was partnering with Red Hat to ensure these technologies have Linux compatibility. Read more

today's howtos

  • How to install go1.19beta on Ubuntu 22.04 – NextGenTips

    In this tutorial, we are going to explore how to install go on Ubuntu 22.04 Golang is an open-source programming language that is easy to learn and use. It is built-in concurrency and has a robust standard library. It is reliable, builds fast, and efficient software that scales fast. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel-type systems enable flexible and modular program constructions. Go compiles quickly to machine code and has the convenience of garbage collection and the power of run-time reflection. In this guide, we are going to learn how to install golang 1.19beta on Ubuntu 22.04. Go 1.19beta1 is not yet released. There is so much work in progress with all the documentation.

  • molecule test: failed to connect to bus in systemd container - openQA bites

    Ansible Molecule is a project to help you test your ansible roles. I’m using molecule for automatically testing the ansible roles of geekoops.

  • How To Install MongoDB on AlmaLinux 9 - idroot

    In this tutorial, we will show you how to install MongoDB on AlmaLinux 9. For those of you who didn’t know, MongoDB is a high-performance, highly scalable document-oriented NoSQL database. Unlike in SQL databases where data is stored in rows and columns inside tables, in MongoDB, data is structured in JSON-like format inside records which are referred to as documents. The open-source attribute of MongoDB as a database software makes it an ideal candidate for almost any database-related project. This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the MongoDB NoSQL database on AlmaLinux 9. You can follow the same instructions for CentOS and Rocky Linux.

  • An introduction (and how-to) to Plugin Loader for the Steam Deck. - Invidious
  • Self-host a Ghost Blog With Traefik

    Ghost is a very popular open-source content management system. Started as an alternative to WordPress and it went on to become an alternative to Substack by focusing on membership and newsletter. The creators of Ghost offer managed Pro hosting but it may not fit everyone's budget. Alternatively, you can self-host it on your own cloud servers. On Linux handbook, we already have a guide on deploying Ghost with Docker in a reverse proxy setup. Instead of Ngnix reverse proxy, you can also use another software called Traefik with Docker. It is a popular open-source cloud-native application proxy, API Gateway, Edge-router, and more. I use Traefik to secure my websites using an SSL certificate obtained from Let's Encrypt. Once deployed, Traefik can automatically manage your certificates and their renewals. In this tutorial, I'll share the necessary steps for deploying a Ghost blog with Docker and Traefik.