Posts
Install Ruby With rbenv
I attempted to install Ruby with rbenv on a Ubuntu Linux 22.04 AWS EC2 VM, having used only rvm in the past, and this was my experience…
First, I see from the rbenv official docs that I have to use the OS package manager - this gives me a version (rbenv v.1.1.2 - released March 25, 2019) older than the latest (rbenv v.1.2.0 - released September 29, 2021), which was released before CoVID became a pandemic.
Posts
Hugo's Ananke Theme Sets Robot NoIndex-NoFollow
If you are using the Hugo static site generator with the Ananke theme, you should review the META tags being generated in the static HTML to ensure that it isn’t generating the Robot NoIndex-NoFollow tag that prevents search engines from indexing your website.
The reason for the tag is that Ananke uses the HUGO_ENVIRONMENT environment variable to determine if the execution environment is production or development - in development mode, it prevents search engine bots from indexing the site.
Posts
Set Linux FileSystem ACL
Access control lists can be read and set on Linux file systems with the commands getfacl and setfacl.
To get user IDs instead of usernames for the owner and group, use the -n parameter like this: getfact -n /my_data.
Example of setting an acl entry: setfacl -m u:nitin:rw myfile.txt (-m is to modify, -x is to remove Eg. setfacl -x u:nitin myfile.txt)
ACLs can be copied with: getfacl directory_1 | setfact -R --set-file=- directory_2 (the hyphen for the --set-file tells setfacl to read the filename from STDIN)
Posts
Set SELinux Type
When running RedHat Enterprise Linux, SELinux (abbreviation for Security Enhanced Linux) is often enabled - and not everybody is comfortable with configuring it. SELinux offers Mandatory Access Control (MAC) for Linux.
Let’s start by explaining MAC. There are different access control models, and the most commonly-discussed are:
Discretionary access control (DAC), which involves granting different security levels (or groups) for users based on which they can access resources. An example is the r-w-x Linux file system permissions Mandatory access control (MAC), which labels resources to which users gain access through their security levels through system-wide policies.
Posts
Extract the Access Key, Secret Key and Session Token for AWS
When you need to retrieve the AWS access and secret keys and the session token, some Python code can help. See the following code snippet:
import boto3 cred = boto3.Session().get_credentials() print( "Access key: " + cred.access_key + "\n" + "Secret key: " + cred.secret_key + "\n" + "Session token: " + cred.token ) This is particularly useful if your organization uses Single Sign-On.
Posts
Polyglot Persistence
Neal Ford created the term “Polyglot Programming” in 2006 based on the idea that different programming languages are suited to different kinds of problems. The same concept has recently been applied to databases. The use of multiple database engines and paradigms to suit different workloads enables organizations to take advantage of each database engine’s strengths is referred to as Polyglot Persistence (Google Scholar shows me a post from Scott Leberknight’s blog in 2008 as one of the earliest references to the term).
Posts
Why MacOS Changed the Default Shell From bash to zsh
If you are familiar with older versions of MacOS, when MacBooks still had Intel CPUs, touchbars, and thick bezels, the default shell providing a command line interface was bash. The version of the bash shell that MacOS provides is version 3.2, which is from the year 2006.
The older versions of the bash shell was distributed under the GNU GPL v2 license, and Apple was perfectly happy to comply with the terms of the license when bundling it with MacOS.
Posts
Bash Is Not Zsh - Whitespace in variables
If you think bash and zsh are alike, ask someone who has had to spend hours trying to get a shell script to work after switching between shells.
One difference that many shell scripters encounter is the bash behavior of splitting a string with whitespaces when used with a for-in loop. The behavior makes it easy to quickly write scripts with minimal repetitions. For example:
ULIMIT_PARAMS="cpu as memlock fsize" for p in $ULIMIT_PARAMS do echo "* soft $p unlimited" >> /etc/security/limits.
Posts
Bash (and Zsh) Previous Argument
In Bash and Zsh, $_ is a variable that includes the last argument of the previous command. This is quite useful when you type a long argument and want to pass the argument to another command.
For example:
mkdir -p /tmp/something/long cd $_ …or, with the Hugo static site generator:
hugo new posts/something.md code content/$_ (assumes that you have VSCode setup to open with the “code” command - if you don’t have this in your Mac, within VSCode press Cmd+Shift+P, type “Shell”, and select “Command: Install code in PATH”)
Posts
Running Eventmachine on Windows for Mailcatcher
The current build of EventMachine available on RubyGems.org doesn’t work on Windows, at least with pure Ruby functionality.
Attempting to get the bug files from the repo HEAD, I cloned and built the gem:
git clone https://github.com/eventmachine/eventmachine gem build eventmachine.gemspec gem install eventmachine-1.3.0.dev.1.gem I then set this version number in the mailcatcher.gemspec and attempted to build the mailcatcher gem, but:
bundle exec rake assets rake aborted! ExecJS::ProgramError: TypeError: Object doesn't support this property or method (in C:/Users/nitin.