There are times that you will need to show files starting with a “.” in MacOS. This is useful in editors or to dig into configuration directories. CMD+Shift+”.” is the sequence that will show those “hidden” directories. This is temporary for the current finder window and will not persist once the finder window is closed.
Using a Node script to query a database to do corrections was working fine on my local Windows based system until we tried to automate the process. We moved it to a Jenkins server which happened to be on a Linux system and the script stopped working. After some debugging it turned out that the way we were attempting to differentiate data returns from the queries depended on the line ending.
On a Windows system, the line endings are ‘\r\n’ or carriage return, new line. This had worked well while we were running the script locally, but once it went to the Linux system the line endings were just a ‘\n’ or new line. The line ending was not being matched so this led us to figure out how to tell what platform was being used. The process.platform variable contains the platform name.
The process.platform returns ‘win32’ for Windows, ‘darwin’ for MacOS and ‘linux’ for linux systems. There are other platforms supported but these are all that mattered to us. Using this variable we were able to replace the line endings and the data started working as expected on all our platforms.
The following code snippet sets the lineendings for our sql code:
let platform = process.platform;
let lineendings = '\n';
if (platform == 'win32') {
lineendings = '\r\n';
}
Recently I was helping my daughter with some homework and it was going well. That is until I tried to take a screen shot. The screen shot came out with a red tint to everything I captured. It took me a while as I worked through if it was a Snipping Tool issue or a general screen shot issue. It was any screen shot which was even more frustrating. I searched the internet for answers and saw some issues with Lenovo laptops but I am on a HP Laptop so that was no help. I tried updating the drivers for my video cards and that was no help.
Finally I thought of what could be adjusting colors on my computer and remembered I had installed f.lux to help with my sleep patterns as it helps to make the color levels of your monitor change as the night time arrives. It turns out that f.lux was messing with the screen capture and disabling f.lux made my screen captures look correct.
I was recently trying to read a large log file and I needed to rotate my screen to portrait mode in order to read more text. Sadly, I learned that the CTRL+ALT+<LEFT ARROW> and CTRL+ALT+<RIGHT ARROW> key combinations are not implemented by the Windows OS but with each graphic card manufacturer. And sadly many of the more recent drivers no longer support this functionality.
In order to rotate the screen you need to use the display settings.
Either : Right-Click the desktop and choose “Display Settings”
or
Start > Settings > System > Display
Next: Select the display you want to rotate and scroll down to “Display Orientation”
Choose the orientation depending on the rotation of your mount. The options are:
Landscape
Portrait
Landscape (flipped)
Portrait (flipped)
Sadly the quick switching of displays may be gone but at least the ability still exists.
When developing an application for Android you will require additional resources. This data is kept in resource files. The resource files live under the /res directory and consist of the following items:
Colors
Strings
Dimensions
Drawables (Images and Icons)
Sounds
Videos
Data Files
Layout Files
The Rules for resource files are:
Must be lowercase
May contain: letters, numbers, underscores and periods
Filenames must be unique
XML Name attributes must be unique as well
To reference the resources from a compiled resource you would use something like the following format depending on the type of resource:
There is a simple Linux utility for counting characters, lines and words in files called wc. This allows you to give a file as an argument or a stream and get the counts of the aforementioned items.
wc <filename>
or
cat <filename> | wc
The options that wc accepts
-c,–bytes
print the byte counts
-m,–chars
print the character counts
-l,–lines
print the line counts
-L,–max-line-length
print the length of the longest line
-w,–words
print the word counts
The ouput with no arguments will be three numbers (words,lines,characters. Otherwise the the number will reflect the argument you have passed.
And if you pass multiple filenames the output displays counts for all files and totals.
>wc -l HelloWorld.java sample.txt
8 HelloWorld.java
25 sample.txt
33 total
Working with data feeds is sometimes frustrating when you have over 50 columns and are trying to find the field that is too long for your insert into your database system of choice. I have found processing the files with different Linux utilities useful and one that I regularly use it “awk”. I was trying to get the substring of all fields in a product feed the other day and used the following trick.
The for loop iterates over all the fields separated by a tab in each line and the prints out the field with a length of 50 characters or less. The extra print is for the newline at the end of each line.
When you are using the Linux tool screen, there are times
that I need to send a ctrl-a character. This is a special command key in
screen that drives most of the other commands. But I use the ctrl-a to go
to the beginning of some of my commands and in order for the terminal to
get a ctrl-a you need to use the following key sequence:
ctrl-a a
So to explain, you need to hold ‘control’ or ‘ctrl’ key and the ‘a’ key together
and then release the ‘ctrl’ key and press ‘a’ key and it will send a ctrl-a to
the terminal.