Skip to content
/ til Public

πŸ“ Today I Learned

Notifications You must be signed in to change notification settings

gerdesque/til

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 

Repository files navigation

TIL

πŸ“ Today I Learned

A collection of concise write-ups on small things I learn day to day across a variety of languages and technologies.

A11Y

  • Enable in browser spellchecking via bookmark
javascript:document.body.contentEditable='true';document.body.spellcheck='true';void%200

source

Cronjobs

  • Run brew update every monday at 11 am
0 11 * * 1 /usr/local/bin/brew update && /usr/local/bin/brew upgrade

Git

  • Use git move to inform git about a case change of a file
$ git mv it.json IT.json
  • Get every ticket number (commit message should be in the format [#12345] Add foo) of a period of time
$ git log --after 2018-03-26 | egrep -o '\[#\d*\]' | sort | uniq
  • Get every ticket number and commit message (commit message should be in the format [#12345] Add foo) of a period of time
$ git log --after 2016-07-15 | egrep -o '\[#\d*\](.*)' | sort | uniq

Mac

  • By default, Mac saves all screenshots to the desktop. If you'd like screenshots to be dumped somewhere else, you have to configure it manually from the command line with
$ defaults write com.apple.screencapture location ~/Downloads
$ killall SystemUIServer

MySQL

  • You can run the following command to get a list of the databases on your server and the size in GB they are consuming:
SELECT table_schema "Databases", sum( data_length + index_length ) / 1024 / 1024 / 1024 "Size (GB)" FROM information_schema.TABLES GROUP BY table_schema;

Regex

  • To anonymize files this regex replaces the full name with the initials of the person
#find expression
(\w{1}).*\.(\w{1}).*

#text
Test.Nutzer

#replace expression
$1.$2

#result
T.N

JS

  • To read article of local journalism parse the content and display text
const demandForPayment = document.querySelector('.pdb-article-paidcontent-registration');
if(demandForPayment) {
    demandForPayment.remove();
}
const article = document.querySelector(".pdb-article script[type='application/ld+json']");
if(article) {
    const articleContent = JSON.parse(article.textContent);
    const scrambledArticleText = document.querySelector(".pdb-article-body");
    if(scrambledArticleText) {
        scrambledArticleText.innerText = articleContent.articleBody;
    }
}
document.getElementById("piano-inline").style.display = "none";
document.getElementById('article-content-bottom').className = '';

Image Converter

for F in *.jpg; do cwebp -q 80 $F -o `basename ${F%.jpg}`.webp; done