Handy Commands

Contaminated Files (.DS_Store) in GIT Folder even with .gitignore settings

When you you find files (.DS_Store) files continually in your git repo, you can use this command to delete the files.

find git/repo -name .DS_Store -delete

Confirm there are no .DS_Store files left

find . | grep -c .DS_Store
0

StackOverflow:How to stop creating .DS_Store on Mac?

InboundBasicMessaging and Disable Features

I kept receiving “InboundBasicMessaging” disconnected on my WebSphere Liberty Instance SIBException and disconnections (I am using the j2ee-7 feature).

I added this snippet to disable

Git Repository Statistics Script

I needed to count the lines and authorship in a repository.


Based on the excellent post here –
https://stackoverflow.com/questions/4589731/git-blame-statistics

 Repository 1
 243 , Paul B
 5 , prb112
 Repository 2
 2 , Paul B

Vim Search forward and backward

/pattern    #search forward
?pattern    #search backward 

Diff Ignoring Whitespace (for use when people format the whole file instead of changing oneline)

diff --ignore-space-change original-file.sql replaced-file.sql
109c109
< DVC.NM, ?) --- > VC.)

Count over range with HBase

hbase org.apache.hadoop.hbase.mapreduce.RowCounter tableNameIsTHis --starttime=1528221151425 --endtime=1528492297952

Restart Cloudant

Cloudant LoadBalancers need needs a restart:

sv reload haproxy
sv stop haproxy
sv start haproxy

If you need to manage the backened services, then you should type/use cast

Loading Data in DB2

For importing IXF data into a db2 to replicate prior db exactly.

https://www.ibm.com/support/knowledgecenter/no/SSEPGG_9.7.0/com.ibm.db2.luw.admin.dm.doc/doc/c0004591.html

Exporting Data from DB2

DB=MYDB

UNIQ=</span><span style="color: #448c27; font-family: Monaco; font-size: small;">date +%s</span><span style="color: #777777; font-family: Monaco; font-size: small;">

db2 connect to $DB

# db2 list tables for schema $SCHEMA
# formatting sucks for prior

db2 SELECT TRIM(TABSCHEMA) || ‘.’ || TABNAME FROM SYSCAT.TABLES WHERE TYPE = ‘T’ AND TABSCHEMA = ‘MY_SCHEMA’ | grep -i MY_SCHEMA | grep -v SYSIBM | tee tables.log
#
for SCHTAB in cat tables.log
do
echo SCHEMA AND TABLE [$SCHTAB]
db2 EXPORT TO export-${SCHTAB}${UNIQ}.ixf OF IXF SELECT * FROM ${SCHTAB}”
done

# Unique Tar
find . -iname *${UNIQ}.ixf -print0 | tar -cvzf db-export-${UNIQ}.tgz –null -T –

IPA Enabled Environments and Shell Access

sudo runuser -l root -c 'bash'

Long Running HTTP-SSH Tunnel

I have a long running task, which I monitor via HTTP.  Here is a shortcut to keeping it alive via SSH.

ssh -L8443:destination:443 jump.server 'while true; do echo "waiting $(date)"; sleep 180; done'

Alternatively, one can change the .ssh/config to add the following (Thanks to this site https://bjornjohansen.no/ssh-timeout)

ServerAliveInterval 120

Comparing contents from find

I had to compare two directories to determine differences.  I used sha1sum to figure out the differences (thanks to SuperUser StackHub)
find . -type f ( -exec sha1sum “$PWD”/{} \; ) > /tmp/sha2.log

 

Check Last RUNSTATS time

I needed to validate the last time runstats was run manually. Thanks to this website https://www-01.ibm.com/support/docview.wss?uid=swg21270455 I have an answer

Commands
db2 connect to mydb
db2 "select substr(tabname,1,30),card,stats_time from syscat.tables where TABSCHEMA = 'myschema'"
Results
1                              CARD                 STATS_TIME
------------------------------ -------------------- --------------------------
FIELDS                               0               2018-07-20-12.51.21.674362
FCT                               97437              2018-08-07-04.24.41.481706
LOG                             645                  2018-07-20-12.51.24.491092
DIM1                            18623                2018-07-20-12.52.06.764779
DIM2                               47                2018-07-20-12.51.49.608522
IDX1                               97992             2018-08-13-18.44.34.912647

Port Forwarding Cannot Assign Requested Address

I ran into an issue port forwarding where ssh was unable to bind a port forwarding

bind: Cannot assign requested address

Thanks to https://www.electricmonk.nl/log/2014/09/24/ssh-port-forwarding-bind-cannot-assign-requested-address/ I learned of the -4 switch and now I can port forward

ssh -4 -i mykey -L3389:10.184.1.58:3389 myuserid@10.184.1.21