Browse Source

add til.md

master
Markus Bergholz 4 years ago
parent
commit
2c82c77348
  1. 62
      til.md

62
til.md

@ -0,0 +1,62 @@
# til
## javascript
Write code like it's synchrone
```javascript
let get = async (URL) => {
const retval = await fetch(URL)
if (retval.ok) {
this.playlists = await retval.json()
} else {
console.error("doh! network error")
}
}
get()
```
Or use promise chaining
```javascript
fetch(URL)
.then(stream => stream.json())
.then(data => this.playlists = data)
.catch(error => console.error(error))
```
## bash
auto-reply `y` on installations or `fsck` repairs
yes | pacman -S <something>
## ffmpeg
extract audio-only from video file with ID3 tags
ffmpeg -i <input video> -metadata title="Title" -metadata artist="Artist" -ab 256k file.mp3
## html
```html
<style type="text/css">
table { page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
thead { display:table-header-group }
tfoot { display:table-footer-group }
</style>
```
## iptables
drop all but accept from one ip
iptables -A INPUT -p tcp --dport 8000 -s 1.2.3.4 -j ACCEPT
iptables -A INPUT -p tcp --dport 8000 -j DROP
drop all incomming ssh connections
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j DROP
Loading…
Cancel
Save