https://github.com/gerdesque/til
📝 Today I Learned
https://github.com/gerdesque/til
javascript til today-i-learned writing
Last synced: 9 months ago
JSON representation
📝 Today I Learned
- Host: GitHub
- URL: https://github.com/gerdesque/til
- Owner: gerdesque
- Created: 2018-04-06T07:25:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T08:09:33.000Z (about 1 year ago)
- Last Synced: 2025-01-30T19:27:24.976Z (11 months ago)
- Topics: javascript, til, today-i-learned, writing
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
javascript:document.body.contentEditable='true';document.body.spellcheck='true';void%200
```
[source](https://developer.paciellogroup.com/blog/2017/02/in-browser-spellchecking/)
## Cronjobs
- Run brew update every monday at 11 am
```bash
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
```bash
$ 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
```bash
$ 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
```bash
$ 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
```bash
$ 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:
```sql
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
```bash
#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
```javascript
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;
}
}
```
```javascript
document.getElementById("piano-inline").style.display = "none";
document.getElementById('article-content-bottom').className = '';
```
## Image Converter
```bash
for F in *.jpg; do cwebp -q 80 $F -o `basename ${F%.jpg}`.webp; done
```