C++ cover

C++ Convert String to Int

Previously discussed Convert Char to Int in C++, in which we converted a single character to an integer. In this article we will build upon that idea by converting multiple characters to an integer. C++ Standard Library If want to use the built-in functions, the C++ standard has a couple built-in functions for converting strings to an integer. Namely there is atoi and std::stoi. atoi atoi is part of “C Standard General Utilities Library in the header <cstdlib>. ...

May 23, 2023
PowerShell cover

PowerShell: Create Shortcut

How do you create a shortcut in Windows via scripts? Easy use PowerShell! Below is the script to create a shortcut named “MyShortcut”. One can additionally create shortcuts to URLs too. I commented everything so it is easy to follow. The only parameter you must set is the $Shortcut.TargetPath everything else is optional. The Windows Script Host (WSH) is a Windows administration tool. Within the Windows Script Host object model the root is Wscript and a sub-node which is WshShell (Wscript.Shell). WshShell object can run programs locally, modify the registry, create shortcuts, or access system folder. Specifically we’re interesting in creating shortcuts. We will access the WSH via the PowerShell script by utilizing the Windows Script Host (WScript) object (via COM) to create the shortcut. ...

May 23, 2023
C++ cover

C++ Convert Char to Int

C/C++’s char built-in type is a 1-byte type. char can hold a value [-128, 127]. The name char can be confusing because a char can range from printable characters to non-printable characters. It is easier to think of char as a 1-byte signed integer. Convert Character char to Integer int - Modern C++ Since C++11, new C++ expressions have been added to do compile time type checking. Type-safe casting is safer as conversion errors are caught at compile time as errors can be checked during compile-time over run-time. Specifically, static_cast was added which is perfect usage for converting character to integer. ...

May 20, 2023
C++ cover

How to Use C++ Substring with Examples

C++’s substring function substr returns a newly constructed string (copy of a portion of the original string) with the parameters of substr. More importantly, C++’s substring is a source of confusion. I wanted to discuss how the substring works and what are the common pitfalls. What does Substr do? substr copies a substring of the original string. A substring is a contiguous sequence of characters within a string. For example, nate is a substring of donate. A substring can also contain the entire original string. ...

May 20, 2023
Generic cover

Algorithms: Fibonacci Sequence

The Fibonacci sequence is a sequence in which each number is the sum of the two previous ones, starting with 0 and 1 as the base cases. A Fibonacci number is a number in the Fibonacci sequence. The golden ratio can be computed from the ratio between two Fibonacci numbers in consecutive sequence, as the sequence approaches infinity. Here we will talk about how to compute the nth number in the Fibonacci sequence. ...

April 25, 2023
Windows cover

Windows: Backup Files

Backing up files on Windows without any additional software is best done by Robocopy. Robocopy is short for “Robust File Copy” and is a command-line utility for file and directory copying for Windows. Using Robocopy is the easiest way to backup files in Windows without using any additional software. The command is robocopy. Basic usage is: robocopy <source> <destination> To use it to back up files, there are two general approaches (more exist but this is a good start): ...

February 22, 2022
Windows cover

How to Convert an Image to PDF on Windows

Adobe Acrobat is probably the most professional way to convert an image to a PDF but it requires creating/signing into an account and paying a monthly fee – no thanks! I propose alternative ways to convert an image to a PDF depending what is available on your computer. Method 1: Convert Image to PDF using MS Word If Microsoft Word is available then the easiest method is to use Word and Export to a PDF. The easiest and highest quality method to convert an image (e.g., jpg, png, bmp, etc) to pdf is to use Microsoft Word. No need for external apps or websites. ...

September 6, 2021
PowerShell cover

PowerShell: Stop-Process to End Process in Windows

Fastest way to close a running executable in PowerShell is with Stop-Process (alias: kill). Stop-Process is a great tool for developers, especially when developing an application that sometimes doesn’t close properly, has stopped responding, are not shown on screen, or run multiple processes. Stop-Process PowerShell PowerShell 5 and newer can stop processes with Stop-Process (or alias kill) using the process name: Stop-Process -Force -Name 'ProcessName' For example, to close all instances of notepad.exe: ...

April 21, 2021

Abstraction Turtles All the Way Down: An important mental model in computer science and software engineering Logical and Physical: The Mental Model That Unifies Computer Science We can call it logical and physical layer, but its not always A concept I always struggled with in my head was thinking about the graphics pipeline and the physical GPU. I knew about the graphics pipeline from university. I’ve studied the GPU but for the longest time had difficulty merging the concepts. The graphics pipeline is a logical concept, or an abstraction. We have to think about the problem of rendering triangles in a logical way. We then map that concept to generalized template abstraction. That abstraction at somepoint needs to be implemented into the physical world. This is the idea behind logical and physical layers. However, its not always logical to physical. Sometimes it is logical to logical to phsyical. Or Physical to physical, etc. So it is easier to call it an abstraction to another abstraction. ...