Strikingloo

Useful Bash Commands

How many lines with a given extension?

find . -name "*.$1" | xargs wc -l| tail -n 1


To run this site locally

sudo gem install rails
sudo gem install jekyll
sudo gem install jekyll bundler
cd ~/desiredFolder

bundle init
bundle install
bundle add jekyll
bundle exec jekyll serve

To turn .enex notes from Evernote into .md files directly: evernote2md


To find all files containing a given expression. grep -rnw '/path/to/somewhere/' -e 'pattern'


Tar commands:

To extract a tarfile:

tar -xzf myfile.tar.gz

x for extract, z for zip, f for file. -v for verbose, is optional.

tar -czf new_name.tar.gz source_directory

c for create, z for zip, v for verbose (optional) and f for file.

Note that source comes after destination, like in a ASM instruction!


Basic sed use case

echo 'this-is-a-path' | sed 's/-/\//g' output: this/is/a/path


Redshift copy from S3

copy $TABLE\_NAME
from 'S3\_PATH'
iam\_role '$iam\_role'
removequotes
emptyasnull
blanksasnull
maxerror 100
delimiter ','
IGNOREHEADER 1
; 

Watch example: watch -n 10 ls -lAhF


Classic nvidia commands:


python reindex after sorting panads dataframe:

limit_df.sort_values(['case', 'limit'],inplace = True)
limit_df.reset_index(drop=True, inplace = True)

Image compression with optimizt

npm i -g @funboxteam/optimizt
find . -iname \*.png -exec optimizt --lossless {} +

To find a book if it’s on the public domain, easily look for it on archive.org with this google search:

site:archive.org intitle:full/text/of intext:Lovecraft

Values for rel attribute in anchor tags.


Get all <p> from a site

To remove all ads and similar stuff and then get the cleaner text possible

document.querySelectorAll('iframe').forEach(iframe => iframe.remove());
document.querySelectorAll('img').forEach(iframe => iframe.remove());
document.querySelectorAll('ins').forEach(iframe => iframe.remove());
res = ''
document.querySelectorAll('p').forEach(p => res+=('<p>'+p.innerHTML + '</p>'));
res = res.replaceAll('\x3Cscript>(adsbygoogle = window.adsbygoogle || []).push({});\x3C/script>','');
res += '<style>
html {
  max-width: 70ch;
  padding: 3em 1em;
  margin: auto;
  line-height: 1.75;
  font-size: 1.25em;
}
</style>'

[Share on twitter]

04 Nov 2020 - importance: 3