From 366a9f4f66da4a242c45a8159e9e589affe53b2c Mon Sep 17 00:00:00 2001 From: Amolith Date: Mon, 22 Mar 2021 02:55:30 -0400 Subject: [PATCH] fix file name and code block syntax --- ...scroll-to-top-button-without-javascript.md | 1 + ...fications.md => calcurse-notifications.md} | 10 +++++----- content/posts/custom-streaming-setup.md | 12 +++++------ content/posts/documenting-with-mediawiki.md | 9 +++++++-- content/posts/forecasting-with-a-command.md | 3 ++- content/posts/lossless-screen-recording.md | 8 ++++---- content/posts/replacing-youtube-invidious.md | 2 +- .../posts/typing-international-characters.md | 10 +++++----- content/posts/vim-as-a-markdown-editor.md | 20 +++++++++---------- 9 files changed, 41 insertions(+), 34 deletions(-) rename content/posts/{calcurse notifications.md => calcurse-notifications.md} (99%) diff --git a/content/posts/adding-a-better-scroll-to-top-button-without-javascript.md b/content/posts/adding-a-better-scroll-to-top-button-without-javascript.md index 7693c96..36fae1a 100644 --- a/content/posts/adding-a-better-scroll-to-top-button-without-javascript.md +++ b/content/posts/adding-a-better-scroll-to-top-button-without-javascript.md @@ -49,6 +49,7 @@ The basic HTML above is exactly the same as what Kev's article has. The CSS is w cursor: pointer; } ``` + The `position`, `bottom`, and `right` lines are what tell your browser to render the item in the bottom right. The position is `fixed` so that means we can put it wherever on the page we want and it will stay there as the user scrolls. `right` and `bottom` say that the element is to be positioned 10 pixels above the bottom of the page and 10 pixels from the right. It's rather hidden on desktop but I'm not expecting desktop users to click it very often; that's what the `Home` key is for, after all, and it works across every website. I'm expecting mobile users to make use of it the most. --- diff --git a/content/posts/calcurse notifications.md b/content/posts/calcurse-notifications.md similarity index 99% rename from content/posts/calcurse notifications.md rename to content/posts/calcurse-notifications.md index adb615c..4e25594 100644 --- a/content/posts/calcurse notifications.md +++ b/content/posts/calcurse-notifications.md @@ -15,7 +15,7 @@ tags: I recently started using [calcurse](https://github.com/lfos/calcurse) for my calendar and one of its limitations is good notification support in the generally accepted meaning of the word. The developer has [a different opinion](https://github.com/lfos/calcurse/issues/285#issuecomment-620841221) and that's perfectly alright but traditional notifications are a feature I heavily rely on and calcurse doesn't handle handle them very well; it leaves the user to figure something out on their own. Inspired by [one individual's issue](https://github.com/lfos/calcurse/issues/286#issue-608118188), I did just that. A quick glance at `man calcurse` reveals this section: -``` +```text -n, --next Print the first appointment within the next 24 hours. The printed time is the number of hours and minutes left before @@ -23,7 +23,7 @@ A quick glance at `man calcurse` reveals this section: ``` The output of running `calcurse -n`, for me and at the moment, looks like this: -``` +```text ❯ calcurse -n next appointment: [17:25] DnD on Mumble @@ -43,17 +43,17 @@ Now we're actually getting somewhere. With my setup, the notification looks like ![It's a screenshot of my desktop with a notification in the top right corner. The title is "Calcurse Event" and the text below is "DnD on Mumble". Surrounding the text is a solid border. Its position and the border are all that designate it as a notification: the background and text colour match the rest of my desktop which is themed with the base16-unikitty-dark scheme](/assets/jpgs/notification.jpg) It's certainly passable and sufficient for some but I'd like an icon so I can see what the notification is for out of the corner of my eye and decide whether or not to glance over. Thankfully, `notify-send` has this built in with the `-i` flag. -``` +```text -i, --icon=ICON[,ICON...] Specifies an icon filename or stock icon to display. ``` Now it's just a matter of figuring out what icon to use. You can certainly pass the path of whatever image you want to it, such as `~/Pictures/calendar-icon.png`, but I want something that fits in with the rest of my icons. These are found in: -``` +```bash /usr/share/icons//it/depends/on/theme ``` I use [Suru++ Dark](https://github.com/gusbemacbe/suru-plus-dark) and the icon I'm using can be found at: -``` +```bash /usr/share/icons/Suru++-Dark/apps/32@2x/calendar.svg ``` It's different for Adwaita and all the rest though; you'll have to do some digging. It's also worth noting that, if you don't have this theme installed on another device, the icon won't show up. diff --git a/content/posts/custom-streaming-setup.md b/content/posts/custom-streaming-setup.md index 3588485..4c9b495 100644 --- a/content/posts/custom-streaming-setup.md +++ b/content/posts/custom-streaming-setup.md @@ -29,7 +29,7 @@ RTMP stands for [Real-Time Messaging Protocol](https://wikipedia.org/wiki/Real-T On Debian-based systems, adding RTMP functionality to NGINX is as simple as `apt install libnginx-mod-rtmp`. After that, you'll need to add some things to your `nginx.conf` and whatever host file you're using for your website. -```conf +```c rtmp { server { listen 1935; @@ -50,13 +50,13 @@ rtmp { ``` `1935` is the default RTMP port. `deny publish all` means you are denying *anyone* from publishing a stream (that includes you. `allow publish 127.0.0.1` allows *local* connections to publish content. I'm using this as a form of authentication---before streaming anything, I have to tunnel my connection to my server via SSH or a VPN. At the moment, I'm using SSH: -``` +```text ssh -L 1935:localhost:1935 user@example.com ``` The other options are just the basics needed to get DASH and HLS to work. The only other thing to do is use NGINX as a reverse proxy (sort of) to serve the streams. Add this to your site's virtual host. -``` +```c location /dash { root /tmp; } @@ -67,12 +67,12 @@ location /hls { That's it! Now you'll need to test your stream and verify that it actually works. -``` +```bash ffmpeg -re -i video.mp4 -vcodec copy -loop -1 -c:a aac -b:a 160k -ar 44100 -strict -2 -f flv rtmp://example.com/live/stream ``` This command has FFmpeg play the video and stream it to the server. You should then be able to open the stream in something like [VLC](https://www.videolan.org/) or [MPV](https://mpv.io/) and watch it from anywhere. -``` +```bash mpv https://example.com/dash/stream.mpd ``` @@ -102,7 +102,7 @@ Finally, I landed on [qwebirc](https://qwebirc.org/) and it was pretty much *exa **EDIT:** Since the time of writing, I have switched to hosting [KiwiIRC](https://kiwiirc.com/) on [Secluded.Site](https://chat.secluded.site) so all of the trackers and third parties aren't in use. My configs are below but I recommend going through [the wiki](https://github.com/kiwiirc/kiwiirc/wiki/Configuration-Options) and making your own decisions. `/etc/kiwiirc/config.conf` -``` +```ini logLevel = 3 identd = false gateway_name = "webircgateway" diff --git a/content/posts/documenting-with-mediawiki.md b/content/posts/documenting-with-mediawiki.md index 850d282..f1ae780 100644 --- a/content/posts/documenting-with-mediawiki.md +++ b/content/posts/documenting-with-mediawiki.md @@ -20,7 +20,7 @@ After [downloading](https://www.mediawiki.org/wiki/Download) and [installing](ht ## URLs The first thing in `LocalSettings.php` is `$wgScriptPath`. Different wikis take vastly different approaches for this. Some fill that variable with `"/w"` (default), some with `"/view"`, and some with something entirely different. [Wikipedia](https://wikipedia.org/wiki/MediaWiki) and all of its children use `"/wiki"`. While well and good, the default configuration will have your URLs appearing as `example.com/wiki/index.php?title=` and this is bad practise for SEO; if you want your pages easily discoverable, the URLs need to be a bit shorter. The easiest way I've found to do this is add all of six lines to my NGINX config and set `$wgScriptPath` to `""` (an empty string). -``` +```text location / { try_files $uri $uri/ @rewrite; } @@ -28,6 +28,7 @@ location @rewrite { rewrite ^/(.*)$ /index.php?title=$1&$args; } ``` + The snippet above tells NGINX to rewrite all of your site's base URLs and remove `index.php?title=` from them. This is a similar approach to what [Mozilla](https://wiki.mozilla.org/Main_Page) has done. The result is cleaner URLs that comply with SEO best practises and a setup that avoids [moving MediaWiki to the site's root](https://www.mediawiki.org/wiki/Manual:Wiki_in_site_root_directory). ## Mobile view @@ -42,6 +43,7 @@ wfLoadExtension( 'MobileFrontend' ); $wgMFDefaultSkinClass = 'SkinMinerva'; $wgMFAutodetectMobileView = true; ``` + With the skin and extension in place and those lines in your config, save and reload and there should be a link at the bottom of your wiki called `Mobile view`. Click it and you'll see Minerva! On a phone, MobileFrontend will automatically serve it but you can force your default theme by clicking `Desktop view` in the same location. ![Screenshot of the mobile versions of my MediaWiki instance. The left uses Minerva Neue and the right uses Vector. The left has buttons and icons that are much larger and easier to tap making for better accessibility. Though the text is readable, the touch targets are much too small navigation is hell](/assets/pngs/mediawiki-skins.png) @@ -59,8 +61,9 @@ As I said, the left works but most people wouldn't know what to do when given th wfLoadExtension( 'Echo' ); wfLoadExtension( 'Flow' ); ``` + Running the following commands is necessary because MediaWiki's database needs modification to support the extension. General talk pages are `--ns=1` and `User:Talk` pages are `--ns=3`. If you only want Structured Discussions enabled for one of them, only run that one. I personally recommend doing it for all. -``` +```text php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=revision php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=archive php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=page @@ -69,6 +72,7 @@ php maintenance/populateContentModel.php --wiki=somewiki --ns=3 --table=revision php maintenance/populateContentModel.php --wiki=somewiki --ns=3 --table=archive php maintenance/populateContentModel.php --wiki=somewiki --ns=3 --table=page ``` + After that, add these to actually enable the extension. To temporarily disable it, you can comment them out but I don't know how that will affect talk pages that already exist. ```php # Flow (discussions) configuration @@ -91,6 +95,7 @@ wfLoadExtension( 'CodeMirror' ); # Enables it by default but allows users to disable it $wgDefaultUserOptions['usecodemirror'] = 1; ``` + ![screenshot of the mediawiki editor. headers are larger, code blocks are highlighted, links blue with link text black so it's easy to pick out, etc. In all, it's a much nicer experience.](/assets/pngs/mediawiki-highlight.png) ## Editing in Vim diff --git a/content/posts/forecasting-with-a-command.md b/content/posts/forecasting-with-a-command.md index 34e5792..d127d70 100644 --- a/content/posts/forecasting-with-a-command.md +++ b/content/posts/forecasting-with-a-command.md @@ -19,8 +19,9 @@ We all love the CLI *(and if we don't, we should)* so wouldn't it be great if th + Weather for today - `$ curl sky.webionite.com/f/location/t` A great way to make this faster and simpler is to put an alias in your shell's `rc` file. For bash, you can do that with: -``` +```bash echo "alias weather='curl sky.webionite.com/f/location'" >> ~/.bashrc ``` + If you ever forget how to use the tool, just run `curl sky.webionite.com` and you'll be given instructions. ![screenshot of the output of the command. it shows two rows of four boxes with ascii art depicting rain, overcast clouds, and the sun obscured by clouds. it shows the temperature and the time of day. everything is coloured and looks very attractive.](/assets/pngs/weather.png) diff --git a/content/posts/lossless-screen-recording.md b/content/posts/lossless-screen-recording.md index d903048..d7eb552 100644 --- a/content/posts/lossless-screen-recording.md +++ b/content/posts/lossless-screen-recording.md @@ -13,13 +13,13 @@ tags: --- I've been trying off and on for the past few weeks to figure out how to record my 1920x1080 monitor. The recording is going to be some music videos for a friend. Originally, it was just going to be a single background image for the whole video then I had the idea of using [cava](https://github.com/karlstav/cava) in a transparent terminal on top of the background. This didn't work at all because it actually kept freezing when I tried to record it. So I tried switching to [ncmpcpp](http://ncmpcpp.rybczak.net/)'s visualiser. This still had horrible lag so I've been puzzling over how to use ffmpeg to *losslessly* record my second monitor. The reason OBS and similar screen recorders are so slow is because, most of the time, they encode to the end format while recording and that uses a lot of system resources. I finally figured it out and have pasted the command below. -``` +```bash ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -draw_mouse 0 -i :0.0+1366,0 -c:v libx264 -crf 0 -preset ultrafast output.mkv ``` Above is exactly what I used for my 1080p monitor with 768p laptop screen. I've modified the command so you can see what you need to edit for your use-case. -``` +```bash ffmpeg -video_size -framerate 30 -f x11grab -i :0.0+,0 -c:v libx264 -crf 0 -preset ultrafast .mkv ``` @@ -27,11 +27,11 @@ If you do *not* want the cursor recorded, add `-draw_mouse 0` directly after `x1 My video was 470mb for a ~13 minute video. If you're going to archive the recording or are concerned about file size, re-encode it with a slower preset. This will be a lot slower and take a lot of CPU but the resulting file is *significantly* smaller than the original and still lossless. I this as a general purpose screen recorder. Previously, I was using OBS and the lag in the video was incredible but with ffmpeg, it's smooth as butter. The command for re-encoding is below: -``` +```bash ffmpeg -i output.mkv -c:v libx264 -crf 0 -preset veryslow output-smaller.mkv ``` ![](/assets/gifs/ffmpeg-lossless.gif) -# Note +## Note This command only works with X, not Wayland. Skimming `ffmpeg`'s man page, I see that `video4linux2` is another option for capturing video so you may be able to replace `x11grab` with it for the same result. I have not tested this so I don't know if it'll work or not. diff --git a/content/posts/replacing-youtube-invidious.md b/content/posts/replacing-youtube-invidious.md index c34c53f..f7932b3 100644 --- a/content/posts/replacing-youtube-invidious.md +++ b/content/posts/replacing-youtube-invidious.md @@ -182,7 +182,7 @@ dl linustechtips https://www.youtube.com/user/LinusTechTips ``` The result would be this directory structure: -``` +```text YouTube ├── .archives │   └── linustechtips.txt diff --git a/content/posts/typing-international-characters.md b/content/posts/typing-international-characters.md index aef734a..f6f3a19 100644 --- a/content/posts/typing-international-characters.md +++ b/content/posts/typing-international-characters.md @@ -22,7 +22,7 @@ I'm not exactly sure why but dead keys don't have to be held down when you want Dead keys allow writers to use far more characters that just the accented ones found in various alphabets. Indeed, one can type a *very* wide variety of symbols: -``` +```text ™ © ® § ¶ ∵ € ¢ ¥ ⅞ x³ ∞ ¬ ÷ ± × ≠ ♪ ♬ ♭ ♮ ♯ → ⇒ ☭ ㉔ ⓐ ß æ ø Œ ``` @@ -39,17 +39,17 @@ How you enable dead keys or the compose key depends *entirely* on your operating Depending on whether you want dead keys or a compose key, there are different commands to run. I'm not sure how to enable the former—you'll need to read [the page for that](https://wiki.archlinux.org/index.php/Xorg/Keyboard_configuration) yourself—but mapping an existing key to compose is really easy. List what your options are -``` +```text grep "compose:" /usr/share/X11/xkb/rules/base.lst ``` Copy which first column you want and paste it into this command -``` +```text setxkbmap -option ``` I mapped mine to the right `Alt` key as I never use it and it's near the space bar. The command for that would simply be: -``` +```text setxkbmap -option compose:ralt ``` @@ -57,7 +57,7 @@ For other interesting things you can do with your keyboard, check [that whole se ## Edit Since the time of publication, I've started using [Wayland](https://wayland.freedesktop.org/) and configuring your keyboard with `setxkbmap` doesn't work. Instead, assuming you're running [sway](https://github.com/swaywm/sway/), add something along this vein to your config. If you want to use something other than your right `Alt` key, make sure you change that. -``` +```text input type:keyboard xkb_options compose:ralt ``` diff --git a/content/posts/vim-as-a-markdown-editor.md b/content/posts/vim-as-a-markdown-editor.md index d9484c3..55eaa78 100644 --- a/content/posts/vim-as-a-markdown-editor.md +++ b/content/posts/vim-as-a-markdown-editor.md @@ -17,20 +17,20 @@ I've recently decided to attempt to keep all of my notes and everything I've lea Because it's all in a simple text file, I'm also able to create a keybinding in [Sway](https://github.com/swaywm/sway/) that will open it in Vim, jump to the bottom, and have a nice markdown environment ready for me to write in. It did take a bit of configuration and looking around for different plugins but I'm very happy with what I have so far. The first thing is telling Vim to treat all `.md` files as Markdown -``` +```vim " Treat all .md files as markdown autocmd BufNewFile,BufRead *.md set filetype=markdown ``` ## Visuals In a long text file with a great many lines, it can be useful to find your cursor quickly without having to search around the screen for it. -``` +```vim " Highlight the line the cursor is on autocmd FileType markdown set cursorline ``` It can also be nice to not see a ton of \[links](https\://example.com) and \*\*bold** or \*italic* text everywhere. Sure, my eye has gotten used to it but still. I'd rather have my terminal actually render bold text as bold. -``` +```vim " Hide and format markdown elements like **bold** autocmd FileType markdown set conceallevel=2 ``` @@ -38,7 +38,7 @@ If you use the `vim-markdown` plugin mentioned further on, I recommend using its ## Spell check One of the things every good editor needs is spell check and Vim is no exception. This line enables spell check with British English for all markdown files. -``` +```vim " Set spell check to British English autocmd FileType markdown setlocal spell spelllang=en_gb ``` @@ -52,18 +52,18 @@ Here's a short crash course in Vim spelling commands: ## Goyo The very first component is something I use across *all* markdown files. [Goyo](https://github.com/junegunn/goyo.vim) is one of the first plugins I install on any machine I'll be writing with. It enables a "distraction-free writing environment" and I absolutely love it. It disables pretty much all visual elements in Vim except for what mode you're in: visual, command, insert, etc. I have a keybinding set to quickly open/close Goyo because there is an odd issue when I switch workspaces to and away from Vim. With two taps of `Ctrl+g`, it's back to normal. -``` +```vim nnoremap :Goyo ``` Another line in my Vim config automatically opens Goyo for all markdown files: -``` +```vim autocmd FileType markdown Goyo ``` ## vim-markdown That latest plugin I installed is [vim-markdown](https://github.com/plasticboy/vim-markdown) and it is *wonderful*. I really recommend reading about all of the options but here's what I have set. -``` +```vim " Configuration for vim-markdown let g:vim_markdown_conceal = 2 let g:vim_markdown_conceal_code_blocks = 0 @@ -80,7 +80,7 @@ In addition to the rest of the awesome features, the main one I wanted is the la ## General Vim things Other, more general Vim settings that I use globally but might also be nice for editing markdown -``` +```vim " Have lines wrap instead of continue off-screen set linebreak @@ -111,14 +111,14 @@ In all, I'm hoping that the work I've done today for improving my markdown workf ## Edit ### Time stamps -``` +```vim " Insert timestamp at the end of the line in this format: 20200527T113245 nnoremap m'A=strftime('%Y%m%dT%H%M%S') ``` ### Portable `autocmd`s Put all the `autocmd` lines in the `if` statement so they don't throw errors when the config is added to a version of vim without `autocmd` support -``` +```vim " Only enable autocommands when Vim supports them if has("autocmd") ""