Dropbox + github workflow for environment standardization
Add these keycodes to the Terminal profile:
⇧↑ \033[1;2A
⇧↓ \033[1;2B
$ xxd
$ cat >/dev/null
$ sed -n l
$ od -c
$ vim -> i -> <C-v><key>
ack ctrl- | perl -ne 'm/(CTRL-.?)/g; print $1."\n";' | sort| uniq
###Reverse shell [in tmux session on local host]
ssh -p 143 -R 1234:localhost:22 router.
[in tmux session on remote host, prefix is alt+1 + [ for remote copy mode] [select some text]
tmux save-buffer - | ssh -p 1234 localhost pbcopy
tm
(tmux session chooser)login-shell
(tmux pbcopy || pbpaste)slog
(mesos logger/grepper)
Run it like so:
$ ./slog dw-loan-app prod && vi /tmp/slog.log
or, with a --syslog
tag:
$ ./slog --syslog-tag no-soap-for-you no-soap-for-you/opportunity-to-avro uat && vi /tmp/slog.log
for f in *.pdf ; do mv $f $(echo $f | sed -e 's/eStmt_//') ; done
ls -l -t | tail -n 2 | head -2
for i in {1..7}; do cd ..; done
grep -rn my_search_dir -e my_search_term
find / -type d -name '*openvpn*' -print
ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=2 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'
ps -o pid,user,rss,comm,args
cat ubuntu.deb | ssh -p 43 router. "cat > ~/ubuntu.deb"
ssh pi1 'cat /tmp/remotefile.conf' > file.conf
scp ubuntu.deb pi1:~/ubuntu.deb
Using the REPL to re-load code:
(refresh)
(use '[clojure.tools.namespace.repl :only (refresh)])
(require '[crawlingchaos.domain.document-management.api :as api])
(def loan-name "L18-CA-0021179")
(api/copy-loan-documents-to-capital-provider-folder loan-name)
docker-machine create --driver "virtualbox" --virtualbox-hostonly-cidr "192.168.99.1/24" default
docker-machine stop default
docker-machine start default
docker-machine regenerate-certs default
VBoxManage controlvm "default" natpf1 "tcp-port8080,tcp,,8080,,8080";
VBoxManage controlvm "default" natpf1 "tcp-port8443,tcp,,8443,,8443";
$ docker -u root exec -it <container-id> bash
or
$ docker exec -it [container_id] bash [or sh]
docker run --privileged -t -i jpetazzo/dind
psql -h docker -U postgres -c 'create database dev;' ; psql -h docker -U postgres -d dev -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' && ./bin/create│ _dw_ddl | psql -h docker -U postgres -d dev
docker-machine stop
VBoxManage modifyvm default --cpus 2
VBoxManage modifyvm default --memory 4096
docker-machine start
sudo docker rmi --force $(sudo docker images | grep monitoring | awk '{print $3}')
sudo docker run -it --rm -e VAULT_TOKEN=$(vault_token_for us_datawarehouse_monitoring) quay.io/fundingcircle/us-datawarehouse-monitoring bash
$ kafka-console-consumer --zookeeper zookeeper.service.consul --topic opportunity-soap-untrusted --from-beginning > opportunitysoap.xml
$ scp server:file .
$ cat opportunity-soap.xml | kafka-console-producer --zookeeper docker:2181 --topic opportunity-soap-untrusted
$ kafka-configs --zookeeper zookeeper.service.consul:2181 --alter --entity-type topics --entity-name opportunity-updated --add-config retention.ms=3000000000000
ssh zookeeper-3
/opt/mesosphere/zookeeper/bin/zkCli.sh
rmr /brokers/topics/dnb-joined-file-prepped-pre-release-1
$ git fetch origin ; git rebase origin/master
$ docker run -e "SALESFORCE_USER=$SALESFORCE_USER" -e "SALESFORCE_PASSWORD=$SALESFORCE_PASSWORD" quay.io/fundingcircle/heroku-force "select applicant_email__c, decline_codes__c from Opportunity limit 5" | uniq -c | sort
ssh $(consul members | grep slave | grep alive | awk '{print $1}' | head -n1)
$ for host in $(consul members | grep mesosslave-private | awk '{print $1}'); do ssh $host -t "sudo docker ps | head -n1"; done
sudo docker run -it --rm -e VAULT_TOKEN=$(vault_token_for my_app) quay.io/fundingcircle/my_app bash
sudo docker rmi --force $(sudo docker images | grep my_app | awk '{print $3}')
for s in $(consul members | grep mesosslave-private | grep alive | awk '{print $1}'); do ssh -oStrictHostKeyChecking=no $s "sudo docker ps | grep marketplace-etl"; done
jstack -l $(ps | grep 'java -classpath' | tail -n2 | head -n1 | awk '{print $1}') | grep main
ssh bastion
container_id=$(for s in $(consul members | grep mesosslave-private | grep alive | awk '{print $1}'); do ssh -oStrictHostKeyChecking=no $s "sudo docker ps | grep marketplace-etl"; done | awk '{print $1}')
ssh mesosslave-private
sudo docker cp /usr/java/jdk1.8.0_162 $container_id:/
sudo docker exec -it $container_id bash
bash-4.4# ps
PID USER TIME COMMAND
1 root 0:00 /bin/sh -c /usr/local/deploy/bin/run-job -m jobs.bank-tra
7 root 0:00 bash /usr/local/deploy/bin/run-job -m jobs.bank-transacti
10 root 0:01 /usr/bin/envconsul -consul=192.20.0.1:1520 -config /etc/e
42 root 0:30 java -Duser.timezone=UTC -Xms256m -Xmx2g -XX:MaxMetaspace
82 root 0:00 bash
90 root 0:00 ps
bash-4.4# jdk1.8.0_162/bin/jstack
Usage:
jstack [-l] <pid>
(to connect to running process)
jstack -F [-m] [-l] <pid>
(to connect to a hung process)
jstack [-m] [-l] <executable> <core>
(to connect to a core file)
jstack [-m] [-l] [server_id@]<remote server IP or hostname>
(to connect to a remote debug server)
bash-4.4# jdk1.8.0_162/bin/jstack -l 42
"main" #1 prio=5 os_prio=0 tid=0x00007f419000a000 nid=0x2b runnable [0x00007f4198e7e000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:140)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:109)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:67)
at org.postgresql.core.PGStream.receiveChar(PGStream.java:288)
at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:329)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:148)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194)
at org.postgresql.Driver.makeConnection(Driver.java:450)
at org.postgresql.Driver.connect(Driver.java:252)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:255)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:176)
at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:239)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:176)
at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:242)
at jobs.bank_transaction_received$_main.invokeStatic(bank_transaction_received.clj:229)
at jobs.bank_transaction_received$_main.doInvoke(bank_transaction_received.clj:225)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.main$main_opt.invokeStatic(main.clj:317)
at clojure.main$main_opt.invoke(main.clj:313)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
Linux is often useful as a build tool. Here are some helpful links to get started:
- https://askubuntu.com/questions/539243/how-to-change-visudo-editor-from-nano-to-vim
- https://askubuntu.com/questions/192050/how-to-run-sudo-command-with-no-password
- https://linuxconfig.org/how-to-install-docker-engine-on-debian-9-stretch-linux
- https://stackoverflow.com/questions/5906441/how-to-ssh-to-a-virtualbox-guest-externally-through-a-host
- https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo