Technical Trivia
Wednesday, March 20, 2019
Monday, January 21, 2019
Grepping specific files recursively
To search the pattern PAT in all csv and csv.bak files in the directory DIR and its subdirectories, do
grep --include=*.csv* -ER "PAT" DIR
[Courtesy: this]
grep --include=*.csv* -ER "PAT" DIR
[Courtesy: this]
Monday, December 24, 2018
Finding files after excluding some directories
Normally, to find a file recursively under a directory, we do something like
find path/to/directory -name "*filename*"
To exclude finding in some sub-directories under directory, we can do
find path/to/directory -name "*filename*" -not -path "*subdir1*" -not -path "*subdir2*"
[Courtesy: this]
find path/to/directory -name "*filename*"
To exclude finding in some sub-directories under directory, we can do
find path/to/directory -name "*filename*" -not -path "*subdir1*" -not -path "*subdir2*"
[Courtesy: this]
Tuesday, December 4, 2018
Python regex to match decimal numbers
Here is a Python regex to match regular decimal numbers (without the e or exponent part):
r'([+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+))'
r'([+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+))'
Monday, November 5, 2018
Lenovo Motorola G5 Plus wifi issue after update
After a recent update on my Lenovo Motorola G5 Plus phone, I started facing wireless connectivity issues. It would randomly get disconnected from wifi and connect again. My laptop was connected to the same wifi and did not have this problem, so it was not a problem with the wifi. I tried restarting the phone, the modem and the router. I tried resetting the phone wireless settings, forgetting the network, and restarting (phone, modem, router). None of these worked. Finally, the following action worked for me.
- Open the wifi router's settings page in the browser (for me, this was at http://192.168.0.1).
- Login and check the Wireless settings. Under "Channel", the value will "auto" or some particular channel (e.g. channel 1, channel 2, etc.).
- Change the value to channel 10.
This fixed the problem for me.
[Courtesy: this]
Tuesday, October 9, 2018
Taking screenshot on Moto G5 Plus
To take a screenshot on the Moto G5 Plus phone, press the Volume-Down button and the Power button together. To see the screen shot, go to Photos --> Albums --> Screenshots.
Wednesday, October 3, 2018
Timing code in Python
To time a particular code block in Python, do this:
import time
t = time.time()
#<code_block>
print(f'code-block-name:{time.time()-t})
[Courtesy: this]
import time
t = time.time()
#<code_block>
print(f'code-block-name:{time.time()-t})
[Courtesy: this]
Subscribe to:
Posts (Atom)