Skip to content

Latest commit

 

History

History
335 lines (277 loc) · 12.8 KB

_catchall.md

File metadata and controls

335 lines (277 loc) · 12.8 KB

todos

# I always forget how to do this #######
# posix compliant
# if ! type poop &> /dev/null; then
# then
#     echo "poop could not be found"
#     exit
# fi
########################################
# other ways, but use the one above
# https://stackoverflow.com/questions/592620/how-can-i-check-if-a-program-exists-from-a-bash-script
# https://unix.stackexchange.com/questions/86012/what-is-the-purpose-of-the-hash-command
# $ command -v foo >/dev/null 2>&1
# $ type foo >/dev/null 2>&1
# $ hash foo 2>/dev/null
# 2>/dev/null # only redirct errs
# &> /dev/null # redirect erything
########################################

TODO: still not happy with this setup; incorporate update-alternatives binaries vs git pkgs read this for the fkery place binaries directly in ~/.local/share and symlink to /opt/bin sudo ln -s ~/.local/share/CMD /opt/bin place git repos in your git dir, make, and symlink to /opt/bin sudo ln -s ~/git/whatev /opt/bin ^ allows you to keep /opt/bin owned by root, while keeping track of wtf you've downloaded as thats whats /opt is for ^ I think the recommened approach is to download to /opt directly, but whatev ^ or directly in /usr/local for opt packages, but fkn linux history n shit

expect(some).toHaveBeenCalledWith( expect.objectContaining(someObject) );

import * as poop from '../some/folder' jest.Mock('../some/folder'); https://jestjs.io/docs/mock-functions poop.someFn.mockImplementation(async () => 'return this')

@see https://stackoverflow.com/questions/4937792/using-variables-inside-a-bash-heredoc bash fn to curl some endpoint register_no_pass() { curl -X POST $SOME_URL
-H 'Content-Type: application/json; charset=utf-8'
-d @- << EOF { "field1": "value" "field2": "$ANOTHER_VAR" } EOF }

wifi iw dev # see network interfaces and what hteir connected to

linux

  • [increasing file descriptors]https://docs.oracle.com/cd/E19476-01/821-0505/file-descriptor-requirements.html

    • $ ulimit -aH see humand readabile limits
  • users, groups, and permissions

    • exec su -l $USER reload session, e.g. to reload group assignments
    • x: execute 1
    • w: write 2
    • r: read 4
    • and...
      • read & execute: 5
      • read & write: 6
      • read & write & execute = 7
    • what it means
      • For files:
        • r = read
        • w = write
        • x = execute
      • For directories:
        • r = list (read directory contents)
        • w = write
        • x = can access the directory (i.e., cd to the directory)
  • system info (just use neofetch, but these are useful for scripting)

    • lsb_release -a all info
    • lsb_release -cs e.g impish
    • dpkg-architecture -q DEB_BUILD_ARCH e.g. amd64, but can be used to query anything
    • dpkg --print-architecture e.g. amd64
    • grep '/usr/s\?bin' /etc/systemd/system/display-manager.service find your display manager, e.g. gdm3
    • lsmod | grep kvm find the name of your hypervisor
    • lshw -short list hardware
  • files & disk

    • find ~/all/files/in/dir -type f -size +100k
    • tar -czvf as_this_file.tar.gz from_this_file
    • tar xvzf unzip_this_file.tar.gz -C to/this/dir
  • disable webcam

    1. find the cam from the list of devices lsusb -t
    2. get some tape from one of your kitchen drawers
    3. and use the tape to cover the device you found in step 1
  • repos/packages

    • sudo add-apt-repository -r ppa:remove/this/ppa
    • sudo add-apt-repository ppa:add/this/ppa
    • sudo dpkg -i installme.deb
    • whereis somecmd binary, source & man pages for a cmd
  • networking

    • hostname -I your ip
    • ifconfig | grep inet all your ips
    • whats on 80
      • lsof -i :80
        • sudo apt install lsof
      • netstat -ltnp | grep -w :80
      • netstat -ltnp | grep -E ':80 |:443 '
        • ^ notice the spaces, works better than the first
      • sudo apt install net-tools
      • fuser 80/tcp
        • sudo apt install psmisc
        • the most concise
      • ps -p THE_PID -o comm=
        • get the name of the process
      • cat /proc/net/tcp
        • for embedded devices
  • ssh

    • eval \ssh-agent -s`` start the ssh agent
    • ssh-add add identities in ~/.ssh can also append a specific private key
    • ssh-add -l list identities
    • id_rsa.pub == your public key (share this)
    • id_rsa === your private key
  • terminal

    • ctrl shift t new tab
    • tree --dirsfirst --charset=ascii SOME_DIR show tree of dir
  • settings

    • sudo update-alternatives --config choose the default cmd
      • set the default for common cmds
        • x-terminal-emulator
        • editor
      • create a new cmd (e.g. in /opt/bin/CMD) that can be used to switch between multiple versions
        • sudo update-alternatives --install ~/opt/bin/CMD CMD /some/path/to/actual/cmd 20
          • /opt/bin is where the cmd will be installed
          • CMD is the name of the alternative to invoke the cmd
          • /some/path/to/actual/cmd is the path to the actual cmd
          • 20 is the priority of the alternative
            • repeat this for each cmd you want to use
  • aws

    • export AWS_DEFAULT_PROFILE=poop
    • aws configure list safely list current aws config
    • aws configure get aws_access_key_id show the world your access key
  • docker networking

    • docker network ls
    • docker inspect network some_network
  • eslint

    • /eslint-disable/
    • // eslint-disable-next-line
    • // eslint-disable-line

wifi

dkms status sudo dkms remove 8814au -v 5.8.5.1 -k $(uname -r) sudo dkms uninstall rtl8814au -v 5.8.5.1 sudo rm -rf /usr/src/rtl8814au-5.8.5.1/ sudo rm -rf /usr/src/8814au-5.8.5.1/

sync computer & network time

curl

use the --data-urlencode option

  • inspect the response via jq curl really-long-curl-options | jq .
aws_statemachine_run() {
  # todo
  aws stepfunctions start-execution help
  # args:
  # --state-machine-arn some_arn_from_aws
  # --input file://some_file_path.json
}
# @see https://github.com/donnemartin/saws

aws_routetable_create() {
  # $1 vpc-id
  # $2 profile
  # aws ec2 create-route-table --vpc-id $1 --profile $2
  echo 'not setup'
}

aws_routetable_route_create() {
  # $1 route table ID (make sure its the one attached to the subnet you want)
  # $2 destination (ip cidr range)
  # $3 this links it to an internet gateway
  # ^ may have to update this fn in the future to specify a different target
  # $4 profile name

  # aws ec2 create-route --route-table-id $1 --destination-cidr-block $2 --gateway-id $3 --profile $4
  echo 'not setup'
}

aws_internetgateway_create() {
  # $1 profile
  # aws ec2 create-internet-gateway --profile $1
  echo 'not setup'
}

aws_tag_create() {
  # $1 resource ids
  # $2 tagKey e.g. Name
  # $3 tagValue e.g. poop-dev
  # $4 profile

  # aws ec2 create-tags --resources $1 --tags Key=$2,Value=$3 --profile $4
  echo 'not setup'
}

aws_routetable_link() {
  # $1 route table id
  # $2 subnet-id
  # $3 profile
  # aws ec2 associate-route-table --route-table-id $1 --subnet-id $2 --profile $3
  echo 'not setup'
}

aws_internetgateway_link() {
  # $1 gateway id
  # $2 vpc id
  # $3 profile
  # aws ec2 attach-internet-gateway --internet-gateway-id $1 --vpc-id $2 --profile $3
  echo 'not setup'
}

# todo: i need to setup named params before using any of this
aws_instance_run() {
  # $1 ami-id
  # $2 count of instances e.g. 1
  # $3 instance type e.g. t2.micro
  # $4 key pair name (rememer scoped to region)
  # $5 subnet id
  # $6 security group ids
  # $7 user data, e.g. file://somefile.sh (ensure you use -y in the script)
  # $8 profile to use
  # $9 tag key e.g. Name
  # $10 tag value e.g. poop-dev
  # aws ec2 run-instances --image-id $1 --count $2 --instance-type $3 --key-name $4 --subnet-id $5 --security-group-ids $6 --user-data $7 --tag-specifications --profile $8 "ResourceType=instance,Tags=[{Key=$9,Value=$10}]"
  echo 'not setup'
}

desktop integration

links: move these into the appropriate files

# prefix each line with a value
sed -e 's/^/0002,/' inthisfile.csv > copytothisfile.csv