Find UNIX files in the past day that contains a keyword

Trying to find a file that was modified in the past day that contains a certain keyword…

Here’s the trick:

find -type f -name “<filename search string>” -mtime -1 -exec grep -l “<keyword>” {} \;

Where filename search string is any help you can give it to filter down the file type, such as *.txt or s* and keyword is the phrase you are searching for.

mtime -1 could be modified to be any time frame, such as the past week (mtime -7).

CSS Buttons

I was looking for a GIF image of a + and a X with a box around it.  After some searching, I found an easier way to customize one…use CSS.

Here’s the class code:


.red_button {
background-color: red;
border: none;
color: white;
padding: 2px 2px;
text-align: center;
text-decoration: none;
display: inline-block;
margin: 2px 2px;
cursor: pointer;
font-size: 10px;
width: 20px;
height: 20px;
}

.green_button {
background-color: green;
border: none;
border-radius: 10px;
color: white;
padding: 2px 2px;
text-align: center;
text-decoration: none;
display: inline-block;
margin: 2px 2px;
cursor: pointer;
font-size: 10px;
width: 20px;
height: 20px;
}

The red button is a square and the green one is a circle.

Little Red update

Little Red now has a new home. Yeah for better protection from the weather and a way to work no matter the weather!

I was able to make some progress, although it does not look like much. The main goal was to get the radiator off so I could get better access to the belts.

Removing the front bolts was not bad, but it took some creative work to get some of the back ones off.

Turning a bolt an eighth of a turn at a time was really slow going.

After getting the radiator off, I drained out some additional coolant, leaving behind a nasty sludge.

I was hoping to be able to get better access to where the hand crank connects. I now have the access, but we still cannot find the old crank. I’ll have to order one. I just wish I could get the motor to turn over. I do still have the cylinders soaking. I’ll order a crank and then hopefully I’ll get it to turn over next time.

Find WiFi Password

More than a few times now I have had to look up how to find the password for a WiFi network saved on my laptop.  It always takes a while to find a website that accurately/correctly tells the steps.  So, here they are so I can find them again:

  1. Start
  2. Type CMD
  3. Right click on “Command Prompt” an select “Run as Administrator”
  4. To get the names of all saved networks: netsh wlan show profiles
  5. To get the password: netsh wlan show profile name=”name_of_network” key=clear

This will then show the contents of the saved keys, including the password.

Daylight Savings Time Check in Oracle

I needed a way to find if a given date is within a DST date range.  We observe DST here, so I needed to know if I needed to adjust the time or not.  The main purpose was so I could convert a date/time to GMT, which does not observe DST.

First column is current date/time
DST_START is the day DST starts
DST_END is the day DST ends
DST_CHECK will be “Y” if we are currently in DST, “N” if not.
CURRENT_TIME_GMT converts the current time to what it would be in GMT

SELECT SYSDATE,
NEXT_DAY (
TO_DATE (TO_CHAR (SYSDATE, 'YYYY') || '/03/01 02:00 AM',
'YYYY/MM/DD HH:MI AM')
- 1,
'SUN')
+ 7
dst_start,
NEXT_DAY (
TO_DATE (TO_CHAR (SYSDATE, 'YYYY') || '/11/01 02:00 AM',
'YYYY/MM/DD HH:MI AM')
- 1,
'SUN')
dst_end,
CASE
WHEN SYSDATE >=
NEXT_DAY (
TO_DATE (
TO_CHAR (SYSDATE, 'YYYY')
|| '/03/01 02:00 AM',
'YYYY/MM/DD HH:MI AM')
- 1,
'SUN')
+ 7
AND SYSDATE <
NEXT_DAY (
TO_DATE (
TO_CHAR (SYSDATE, 'YYYY') || '/11/01 02:00 AM',
'YYYY/MM/DD HH:MI AM')
- 1,
'SUN')
THEN
'Y'
ELSE
'N'
END
AS dst_check,
NEW_TIME (
SYSDATE,
CASE
WHEN SYSDATE >=
NEXT_DAY (
TO_DATE (
TO_CHAR (SYSDATE, 'YYYY')
|| '/03/01 02:00 AM',
'YYYY/MM/DD HH:MI AM')
- 1,
'SUN')
+ 7
AND SYSDATE <
NEXT_DAY (
TO_DATE (
TO_CHAR (SYSDATE, 'YYYY')
|| '/11/01 02:00 AM',
'YYYY/MM/DD HH:MI AM')
- 1,
'SUN')
THEN
'CDT'
ELSE
'CST'
END,
'GMT')
AS current_time_gmt
FROM DUAL;

To give credit, I used the info from:
https://www.techonthenet.com/oracle/functions/new_time.php
https://stackoverflow.com/questions/287563/in-oracle-how-can-i-detect-the-date-on-which-daylight-savings-time-begins-end

Drainage issue

I’m a little late posting this, but it’s still worthy of a post.

About a month ago we had a week plus long cold stretch. Towards the end of it, I noticed some pretty large puddles in the basement. I tracked it down to be from our softener and filter system purging themselves. Our basement floor drain was clogged.

I feed my 25′ snake into it. It did not clear the issue. So, I had to call a plumber. Their long snake cleared the drain and we found what it drains to. You see, this is the drain for our walk our basement. I figured that it did not drain to the sewer as I could see that main pipe in the basement ceiling. We discovered that this particular drain comes out along our backyard fence. That would explain why that area is always wet and muddy during the summer. My theory is that the builders put the drain in with the assumption that it would only be used during the summer, when the exit would not freeze. In this case, it was not only frozen, but the end was completely blocked as I had never even known it was there.

The plumbers got the water flowing, but the exact location of the exit was still unknown.

About a week later, puddles appeared again. This time, I bought a 50′ snake and a rubber bladder for the end of a garden hose. The snake still did not reach the clog, but hot water through the garden hose did the trick. I was then able to find and dig out the exit. To be extra safe, I also added a water sensor by the drain to alert us of any additional issues.

We were thankful for the water sensor as it alerted us to an issue soon after. I gave up and decided to do a more extreme fix. Here is the drain after this last issue, with the sensor moved up on top so I can clean. The pipe is what our utilities drain into.

This extreme fix will connect the basement drain exit to the rest of the yard drainage system that I added a couple of years ago. This will keep all the pipes underground, which should help both with freezing and with the wet fence line issue.

I left an access point if I do need to snake it as I am still a little worried about how shallow the pipes are. It did take some creativity to come up with the proper fittings to go from a 2″ PVC pipe to a 4″ corrugated drainage pipe. Our local Lowe’s crew did a good job at piecing together what I needed.

I plan on shortening the access pipe (by the fence) this summer after the ground settles and new grass seed is down.

batch remove periods from files

I had a user that had a folder of files that had a lot of .’s in the names.  As an example:
I.like.kayaking.txt
This.is.a.sample.file.txt

They needed all of the .’s replaced with a space.  Here is the contents of the batch file that I created to fix the issue:


@echo off
 setlocal enableextensions disabledelayedexpansion

for %%a in (*) do (
 set "filename=%%~na"
 setlocal enabledelayedexpansion
 for %%f in ("!filename:.= !") do (
 endlocal
 ren "%%~fa" "%%~f%%~xa"
 )
 )

All the user has to do is copy the .bat file into the directory that has the problem files and then run the .bat file.

This is a slightly modified version of the script found at: https://stackoverflow.com/questions/28558996/batch-file-for-replacing-dots-with-spaces-in-file-names

Siding updates

I haven’t posted about the siding project for awhile.

All of the old siding is off and new sheathing is in place.

I did discover that the ceiling above our dining room had no insulation on it.

So I learned how to use an insulation blower (not hard) to blow insulation 16+ feet in (challenging) I attached the blower nozzle to the end of a pool pole and then used a long 1×6 to move the insulation into place. It was a bit messy as I got closer to the opening, but not too bad.

With the sheathing up, I was able to get the house wrap on. There is much debate online as to of house wrap should go above or below polystyrene insulation. I chose below as it would be easier to secure around windows.

I worked from the bottom up, over lapping each layer by a foot.

I am now in the process of getting the polystyrene up.

So much of it is now up that I had to remove the scaffolding. I’m hoping that I will be able to get all the siding up without it. I do still have my hoist in place to help with the heavier lifting up high.

Shell script to concatenate multiple csv files

I had a unix directory with multiple CSV files, all with the same prefix.  I needed them to be concatenated together to make one large file using a shell script.

I used the below code, copied multiple times (one for each file prefix)

Sample files:
file20170804.csv
file20170803.csv
file20170802.csv


new_file=”/dir/file.csv”
if [ -f $new_file ] ; then
rm $new_file
fi

for file in /dir/file?*.csv
do
tail -n +2 “$file” >> $new_file
done


Here is the code with comments:

1 new_file=”/dir/file.csv”
2 if [ -f $new_file ] ; then
3 rm $new_file
4 fi

5 for file in /dir/file?*.csv
6 do
7 tail -n +2 “$file” >> $new_file
8 done

1 – Name of the file you are creating
2 – 4 Check if the file already exists.  If so, then remove it
5 Loop through the smaller files.  Note that I have a ? to make sure that it is not trying to add the big file back to itself.
6-8 Concatenate the file to the $new_file, but ONLY lines 2-end of file.  This omits the header record of the .csv file.