All posts by Matt Schlosser

Setting up shared directories on Linux

Recently I wanted to setup a shared directory to share between certain users on a Linux system. In my context, it was for a Plex media server. I wanted to create a directory where I could add files to it, and the plex user account would be able to access and manage files as needed. To do this, plex needed to read/write access to the files and directories in the shared folder.

However, on most distributions of Linux, the default permissions when creating new files/directories is to give read/write access only to the owner of the files. I needed to find a way to grant write access to plex automatically when creating new files from my normal user account.

i needed to just run three commands to do this

# change the owner of the shared directory to plex
chgrp -R plex /path/to/dir
# set the gid bit only on directories, so new files/directories set to same group as parent
find . -type d -exec chmod g+s {} \;
# set ACL so group has write permissions by default
setfacl -Rd -m plex:rwx /path/to/dir

Then, you need to add your user to the plex group so they can edit this directory too

usermod -a -G plex $USER

A Guide to Lodash’s Different String Transformation Functions

Transforming text into various capitalization styles is a common task in programming. Whether for readability, consistency, or adhering to coding conventions, Lodash, a popular JavaScript library, provides a comprehensive set of functions to achieve these transformations. Let’s delve into these functions and understand their distinct purposes:

  • startCase: This function converts a string to start case, where the first letter of each word is capitalized, and the rest are lowercase. It’s ideal for converting delimited strings (kebab-case, snake_case) into a more readable format, resembling sentence case.
  • upperFirst: As the name suggests, this function capitalizes only the first letter of the string, leaving the remaining characters unchanged. It’s useful when you want to emphasize the first letter but maintain lowercase for the rest.
  • capitalize: It behaves similarly to upperFirst, capitalizing the first letter and converting the rest to lowercase. This provides a convenient way to achieve consistent capitalization at the beginning of a string.
  • kebabCase: This function converts a string into kebab-case, where words are separated by hyphens (-). It’s commonly used for filenames, CSS class names, or URLs to enhance readability.
  • camelCase: Converts a string to camelCase, where the first letter of each word (except the first) is capitalized, and separators are removed. This is a popular choice for variable or property names in JavaScript.
  • snakeCase: This function transforms a string into snake_case, where words are separated by underscores (_). This convention is often used for variable names or database column names.
  • lowerCase: Converts the entire string to lowercase.
  • upperCase: Conversely, this function converts the entire string to UPPERCASE.

Here’s a table summarizing the key differences:

FunctionDescriptionExample
upperFirstCapitalizes the first letter of the string“hello-world” -> “Hello-world”
capitalize Capitalizes the first letter and converts rest to lowercase“hello-World” -> “Hello-world”
startCaseConverts string to start case (first letter of each word capitalized)“this-is-a-string” -> “This Is A String”
kebabCase Converts string to kebab-case (words separated by hyphens)“ThisIsAString” -> “this-is-a-string”
camelCaseConverts string to camelCase (capitalized words)“this-is-a-string” -> “thisIsAString”
snakeCaseConverts string to snake_case (words separated by underscores)“thisIsAString” -> “this_is_a_string”
lowerCaseConverts entire string to lowercase“HELLO WORLD” -> “hello world”
upperCaseConverts entire string to uppercase“hello world” -> “HELLO WORLD”

Choosing the right transformation function depends on your specific context. Here’s a quick guide:

  • Use startCase for converting delimited strings to readable text.
  • Apply upperFirst or capitalize to emphasize the first letter.
  • For filenames, CSS classes, or URLs, prefer kebabCase.
  • Use camelCase for variable or property names in JavaScript.
  • When dealing with variable or database column names, snake_case is a common choice.
  • Utilize lowerCase or upperCase for complete lowercase or uppercase conversion, respectively.

By mastering these string transformation functions in Lodash, you can effectively manipulate text in your code, ensuring consistent formatting and improved readability for both you and your collaborators.

Handling Warnings in an API

Recently, I was trying to find a way to handle warnings for an API.

Here was ChatGPT’s response:

To handle warnings for an API action that partially completed successfully, you can design the JSON response in a way that includes both success status and warning messages. Here’s a possible structure for the JSON response:

{
  "success": true,
  "message": "Event time adjusted successfully.",
  "warnings": [
    "Google Calendar sync failed. Please check your Google Calendar integration."
  ]
}

Let’s break down the response components:

  1. "success" (boolean): This field indicates whether the primary action (adjusting the time of the event in your scheduling system) was successful. If this value is true, it means the event was successfully moved in your system.
  2. "message" (string): This field provides a general success message describing the outcome of the primary action. In this case, it confirms that the event time was adjusted successfully.
  3. "warnings" (array of strings): This field contains warning messages to inform the user about any issues that occurred during secondary actions (e.g., the API call to sync with Google Calendar). If there are no warnings, this array can be empty. In the example above, we have a warning message related to the Google Calendar sync failure.

In your JavaScript code, when you receive the API response, you can check the "success" field first. If it’s true, you can display the "message" to inform the user that the event time has been adjusted successfully. Then, you can check if the "warnings" array is not empty. If there are warning messages present, you can display them to the user as well, alerting them about any secondary actions that might have failed.

Here’s an example of how you might handle the JSON response in JavaScript:

// Assuming you have received the API response as 'apiResponse' variable
if (apiResponse.success) {
  // Display success message to the user
  console.log(apiResponse.message);

  if (apiResponse.warnings.length > 0) {
    // Display warning messages to the user
    console.warn("Warnings:");
    apiResponse.warnings.forEach((warning) => {
      console.warn(warning);
    });
  }
} else {
  // Handle API failure here, if necessary
  console.error("API call failed:", apiResponse.message);
}

This way, you inform the user about the successful adjustment of the event in your system and any potential warnings related to the synchronization with external services like Google Calendar.

https://chat.openai.com/share/bd4ff3d8-f366-4645-a781-f488ad2e02fa

Taming YouTube Music – How to have restricted Mode on for YouTube Music and Off for YouTube

If you’re like me, you’ve been a fan of Google Play Music for a long time. I signed up for the service when it first came out. In fact, I was so early to the party, that I receive a discount of $2/month.

However, times have changed. Google Play Music is no longer a thing, and in it’s place, we have been given YouTube Music. While many would say that YouTube Music is an awful replacement for GPM, I have found it quite alright.

Yet there is one setting that YouTube Music lacks that Google Play Music had. It was called “Block Explicit Songs in Radio.” And it did just that. It blocks songs with foul language; songs which I would rather not hear.

YouTube Music’s replacement, though, is something called Restricted Mode. While this certainly does it’s job, it does it too well. It also applies the setting to YouTube proper, which isn’t what I want. If you’ve ever tried to browse YouTube with Restricted Mode on, it’s essentially like a baby filter. Everything is kid friendly. I often find myself turning off Restricted Mode on YouTube, only to be upset when YouTube Music is playing an explicit song again, resulting in me having to turn on Restricted Mode again. Round and round it goes, until …

Firefox – Multi-Account Containers

I’m a fan of Firefox. It’s an alternative web browser to Google Chrome. It’s focus is privacy. No large corporation taking your data. No manipulating you into sharing your data. Just a simple program for browsing the web.

But how does Firefox solve my problem?

Firefox has an extension called multi-account containers. It has the ability to open tabs in different sessions. This means I can be logged into one account in one tab, and into a completely different account in another, or into the same account, twice. To the web site, it looks like I am logged in in two different places.

Firefox’s Multi-Account Container Extension

Because YouTube’s Restricted Mode only applies per device, container tabs makes it look like two different devices. I simple created a container for YouTube Music, and have Restricted Mode turned on for that container. When I visit YouTube Music, it automatically opens in that container, and Restricted Mode is on. 🙂

Then when I visit YouTube, it just opens under a regular tab. Because it is separate from the YouTube Music container, I can have Restricted Mode off, and I can freely browse YouTube, without constantly seeing “Restricted Mode is On” for every second video I want to watch.

Android 11 – 11 New Features

Android 11 has been released. Here are 11 new features you may not otherwise know about. Some of these are exclusive to the Pixel range of devices.

#1. Conversations

The latest version of Android has added a new section in notifications. This one is labelled Conversations. This puts chat and text messages first, so it’s easy to see and reply to them. Conversations can also be marked as priority, giving them special preference over other conversations, allowing them to appear at the top of the list, and override Do Not Disturb when necessary.

#2. A Redesigned App Switcher

Long time users of Android will notice the app switcher has changed again. The recent app icons were removed in favour of two new buttons: Screenshot and Select. Select is an quick way to highlight text from any app, even apps that may not support it otherwise. Tapping Select scans the image with Google Lens to find text, and make those regions easy to select and copy. Screenshot does what you expect, and also shows a dialog that allows quick and easy editing of the shot afterwards, such as cropping and markup.

# 3. Redesigned Media Controls

Media controls have a new home. Instead of having to find the notification in an ever growing list of all the apps vying for attention these days, media controls have been moved into the quick actions toolbar, along with all other other buttons such as WiFi, Bluetooth, etc. Media Controls allows access to all devices playing media, even those on connected devices such as smart speakers and Bluetooth headsets.

# 4. A Power Menu for Power Users

Once again, the power menu has been redesigned. Smart home controls have been added directly to the power menu, making it easy to control smart home devices. Turning off lights is as easy as long pressing the power button and tapping the appropriate icon.

# 5. A Smarter Launcher

With the removal of the suggested apps from the recent apps screen, these suggestions have moved to the bottom row of the launcher. If any free spaces are available in the dock, a suggested app will appear depending on the time of day and the habits recognized by the device. Take the bus every day at 8 am (or perhaps did before a global pandemic)? The launcher should suggest the app used to get transit directions to work.

# 6. Nearby Share

While not exclusive to Android 11, this new feature allows users in close proximity to one another easily share files with one another. This comes after the removal on Android Bean, the previous way for sharing files between devices, was removed in Android 10. Users simply have to be in close proximity to one another, open the Files app, and click send or receive from the Share offline in the side menu.

# 7. Chat Bubbles

Along with Conversations above, Android has introducted a Bubbles feature that apps can use to show conversations in a floating bubble, similar to Facebook’s chat heads that have been around for years on Android. These allow any app to easily add a Bubble for their conversation, and for users to manage all their different conversations across different apps all in one place!

# 8. Built in Screen Recording

That’s right. While I like to argue that you could always record your screen by going into Google Play Games, and then picking a game, and then clicking Record, and then just switching away from the game…. I digress. Android 11 finally has a way to record the screen, without the need for a third-party app. It can be found in the quick-tiles section. Users even have the option to record both device audio, the microphone, or both. Fancy

# 9. Live View

Live View builds upon Google Maps use of AR tech to show directions over top of a view of your surroundings. Live View allows you to share your location with nearby friends so they can easily track down where you are. Users can share locations with one another, and use their camera’s to point them in the right direction.

# 10. Smart Folder Naming

The number of apps on a modern smartphone seems to grow more and more every year. Now, the Pixel Launcher helps you do this by automatically suggesting a name when creating folders, based on the types of apps. Put two web browsers in the same folder? The folder will automatically be labelled Browsers. Nice!

# 11. Easter Egg

The new Android volume control

As with every version of Android, a new Easter egg has been added to the version screen. Clicking the version number multiple times will show a volume nob with 10 notches. Turning the nob gives some nice haptic feedback between the notches. Of course, you can turn it up to 11.

Text From Your PC – Your Phone App for Windows 10 – October 2018 Update

While Microsoft is still in the process of fixing their October 2018 update, I managed to download it before they pulled it. I did not encounter any issues with the installation process, nor did I lose any files.

Included in the latest update is the Your Phone app. This app lets a user view photos from their phone, as well as send and receive texts from your phone on Windows. While there are apps that already have this functionality, most you either need to pay for, or have ads. I have used MightyText for a few years, but recently it has become more restrictive. You used to be able to send 250 texts a month for free, but now just 125. Windows does not enforce such a limitation.

Setting up the app was easy. I had to download the Your Phone Companion app on my Android device. After signing into my Microsoft account on both my phone and the Your Phone app, I was good to go.

The downside with the Your Phone app is that it currently only syncs if the PC and phone are on the same network. The app is still in its early stages. I sometimes can’t connect to the phone at all, even when both are on the same network. But when it works, it works great. Windows-style notifications show you when a new text comes in. Contact names are synced as well; however, contact photos are not. MMS messages also don’t sync yet.

The Photos functionality in the Your Phone app is also limited. It currently only shows the last 25 photos you’ve taken/downloaded on your phone. This could be useful if you need to take a photo of something and transfer it to your computer quickly for work purposes or whatever. But it won’t be useful if you want to back up the photos on your phone. (For that, I recommend Google Photos). It would be nice to see access to all my photos.

That’s all for now. I figured I should write a blog post, since I haven’t done any since 2016!

How to Chat on Facebook Without Using the Messenger App

It’s been in the news lately. If you want to chat with someone on Facebook on mobile, you’ll soon be required to use the Messenger app. A few years ago, Facebook removed the ability to chat with your friends through the Facebook app, but retained the ability to chat with friends through its mobile web app. Now, they plan to remove the ability to chat from the web app as well. A lot of people are furious over Facebook’s decision for various reasons: having to download a separate app, the many permissions the app requests, et cetera.

But going forward, there is a way that people can still access there messages on mobile without the Messenger app. Go to the App Store/Play Store on your device and download Opera Mini.

Opera Mini is a data savings app. It runs a different version of Facebook

A version of Facebook which still has access to messages, with no indication that it is going to be taken away.

Sure, you are still downloading a separate app, but this one does not require as nearly as many permissions as Facebook’s Messenger, plus it saves you tons of data.

I’ve saved 72% in data savings. A normal browser would have used 900 MB in the lifetime I’ve had Opera Mini installed. Opera Mini has used 259 MB in comparison.

Facebook Posting Without Your Knowledge? Try This!

For those of you having issues with your Facebook posting things you didn’t, and you use Facebook on a computer, I would advise you to run Avast Browser Clean-Up on your computer. It will scan for any add-ons in your browser(s) that could be using Facebook without your permission and remove them.

These unsolicited postings could also be caused by apps you’ve authorized on Facebook that you don’t use anymore or had a malicious intent when you signed into an app/website with Facebook. Go to your Facebook Settings > Apps and remove any Facebook applications you don’t use anymore, specifically those that have the ability to post content on your behalf, as those ones can like posts on your behalf.

A third culprit is websites that ask you to push the like button in order to see a video/content. In this case, pressing the like button could like something else instead on Facebook.

Also, it’s recommended that you change your Facebook password regularly. Use unique passwords for each website you login to. That way, if one website is hacked, and hackers are able to decrypt your password, they won’t be able to use it on any other site.

Stay safe out there.

Can’t Connect to Public WiFi? Try This

If you are ever in a restaurant that offers free WiFi, but it seems to not be working, it’s because you need to sign in to the network. The method to do this, though, is where many people get confused. Many people assume that if the WiFi icon says it is connected, then it should work. However, that is not the case. You usually have to agree to the terms and conditions of the free WiFi, which are automatically presented when you go to a non-HTTPS* website (see below for an explanation). So open your web browser and go to aw.ca. Any website will do as long as it does not use HTTPS. I use aw.ca because it is short and simple. The internal WiFi system will then redirect you to a webpage that usually has a check box and a button to agree to the terms and conditions and then connect.

HTTPS explanation: Simply trying to Google search for anything won’t get you online. Google uses HTTPS. The reason you won’t get online is the request to redirect the website is blocked because of the S in HTTPS, which stands for secure. It ensures the website you are visiting is encrypted so that all data is secure while in transit. You wouldn’t want to go to Facebook and have the system redirect you to a fake Facebook login page? Therefore, you must go to a website which does not use HTTPS. Then the system will be able to redirect your request and present you with the login page.

Some phones will automatically detect that you need to sign in to the network to use it. In that case, simply select the “Sign into network” in your notifications and accept the terms and conditions from there.