Keep the first match and remove the rest match from file
sed 'PATTERN\s*$/d' -i path_to_file
Big Data and Cloud
Tuesday, August 8, 2017
Wednesday, August 2, 2017
Python regex
#!/usr/bin/python
import re
regexPattern = re.compile('^(?!\\/usr\\b|\\/var)(\\/[\\w]+)+\\/?$')
inputString = [ "/", "/usr", "/var", "/test" ]
for v in inputString:
m = re.match(regexPattern, v)
print("")
print("Test String " + v )
if m:
print("Full Match" + m.group())
print("Pass")
else:
print("No Match")
Monday, July 24, 2017
Ansible pull
stdbuf -o0 -e0 ansible-pull \
-U URL of the playbook repository
-C branch/tag/commit
-e "key=value"
--purge 2>&1 | tee /path/to/ansible.log
Wednesday, July 19, 2017
Troubleshoot NFS
On Client:
tcpdump -i eth0 -s0 -w /tmp/tcpdump.pcap host example.com
Read the output
tcpdump -s0 -r /tmp/tcpdump.pcap
tcpdump -s0 dust port nfs -r /tmp/tcpdump.pcap
tcpdump -i eth0 -s0 -w /tmp/tcpdump.pcap host example.com
Read the output
tcpdump -s0 -r /tmp/tcpdump.pcap
tcpdump -s0 dust port nfs -r /tmp/tcpdump.pcap
Friday, July 14, 2017
Tensorflow multiple GPU
http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars
CUDA_VISIBLE_DEVICES=0,1,2
https://www.tensorflow.org/tutorials/using_gpu
CUDA_VISIBLE_DEVICES=0,1,2
https://www.tensorflow.org/tutorials/using_gpu
Wednesday, July 12, 2017
Shell: Snippet
Read argument
while getopts a:b OPTIONS 2> /dev/null
do
case $(OPTIONS) in
a)
VAR1=${OPTARG}
;;
b)
VAR2=1
;;
*)
echo "Invalid"
usage
exit 1
;;
esac
done
logcmd ()
{
echo "" >> ${LOGFILE}
echo "Running: $@" >> ${LOGFILE}
$@ 2>&1 | tee -a ${LOGFILE}
return ${PIPESTATUS}
}
logcmd ()
{
echo "" >> ${LOGFILE}
echo "Running: $@" >> ${LOGFILE}
$@ 2>&1 | tee -a ${LOGFILE}
return ${PIPESTATUS}
}
Monday, May 1, 2017
NTP Config
For log file and time drift tolerance
/etc/ntp.conf
tinker step 0.05 (0.05 = 50 milliseconds)
logconfig=allall
logfile /var/log/ntpd.log
http://www.finra.org/industry/notices/16-23
/etc/ntp.conf
tinker step 0.05 (0.05 = 50 milliseconds)
logconfig=allall
logfile /var/log/ntpd.log
http://www.finra.org/industry/notices/16-23
Subscribe to:
Posts (Atom)