Skip to content

Latest commit

 

History

History
207 lines (146 loc) · 7.08 KB

ubuntu_dev.md

File metadata and controls

207 lines (146 loc) · 7.08 KB

Latest Chrome

Unix

Check encoding for sed

  • sed-and-utf-8-encoding
  • Bash printf à | wc -c must say 2, not 1
  • Bash locale should list "UTF-8" or "utf8" in the LC_CTYPE line

Using sed with multiple files

find app/scripts -type f -name "*.js" | xargs sed -b -i -- '/\/\* eslint max-len: \["error", 160\] \*\//d'
find app/scripts -type f -name "*.js" | xargs sed -b -i -- 's/, max-len: \["error", 160\]//g'

Find stuff in files via grep

# recursive grep, includes file names though
grep -r -o "data-page-id=\".*\"" uat_F_20220517_001_STE_Pages_20220518/en-gb
grep -r -o "@wizzair-onewizz/design-system-accordion" .

# find with xargs 1 line
find uat_F_20220517_001_STE_Pages_20220518/en-gb -type f | xargs -L 1 grep -o "data-page-id=\".*\""
find node_modules f | xargs -L 1 grep -o "ovz1.j19544519.pr46m.vps.myjino.ru"

# find with -exec
find uat_F_20220517_001_STE_Pages_20220518/en-gb -type f -exec grep -o "data-page-id=\".*\"" {} \;

Find files where first line includes pattern

head -n1 -v app/scripts/components/base-input/basic/index.js | egrep -B1 "\/* eslint" | egrep "==>"

Prepend header and append footer with sed

find app/scripts/components/ -name "template.html" | xargs - L 1 sed -b -i -e $'1i<template>' -e $'$a</template>'

find ./app/scripts -name "*.spec.js" | xargs sed -b -i -e $'1i import { describe, it, expect } from \'vitest\';'

find ./app/scripts -name "*.spec.js" | xargs sed -b -i -e $'1 import sinon from \'sinon\';'
egrep --include=\*.spec.js -Rnwl './app/scripts' -e 'sinon.' | xargs sed -b -i -e $'1 import sinon from \'sinon\';'

Remove first and last line with sed

find app/scripts/components/ -name "template.html" | xargs -p -L 1 sed -b -i '1d;$d'

more info

Find directories recursively

find /path/ -type d -print

Find files which contains text

egrep --include=\*.js --exclude=\*.spec.js -Rnwl './app/scripts/components' -e '@vue/component'
egrep --include=\*.spec.js -Rnwl './app/scripts' -e 'sinon.'

xargs multiple commands / input arg usage

# -I can give a name to input arg to be used in commands
cat foo.txt | xargs -I % sh -c 'echo %; mkdir %'

Run script in the current shell

. ./somescript.sh

Git

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

Git Flow

Python 2.7

# refreshing the repositories
sudo apt update
# its wise to keep the system up to date!
# you can skip the following line if you not
# want to update all your software
sudo apt upgrade
# installing python 2.7 and pip for it
sudo apt install python2.7 python-pip
# installing python-pip for 3.6
sudo apt install python3-pip

NOTE: Do not try to remove python 3.6 as it will screw up your system

# for python 2.7
pip2 install <package>

# for python 3.6
pip install <package>

Resources

Diff and merge tools

Node JS + NPM

NVM - Node Version Manager

n - node version manager

cd somewhere
git clone https://github.com/tj/n.git
cd n
PREFIX=$HOME make install  # will install to $home/bin/n

Add the following to the end of $HOME/.bashrc

export N_PREFIX="$HOME"  # node versions will be installed under $HOME/n/versions

note: something happens with npm when switching between versions eg if you installed the latest npm in 6.x then switch to 7.x and back the version of npm will be reset to 3.x

npm fix if needed (won't fix the problem above)

$ curl -0 -L https://npmjs.org/install.sh | sudo sh

Pomodoro

OpenConnect

sudo apt-get install network-manager-openconnect-gnome # will be visible in GUI as well
sudo openconnect vpn.acme.com

VirtualBox