1 line
No EOL
86 KiB
JSON
1 line
No EOL
86 KiB
JSON
[{"content":"I like to watch twitch streams. Watching them in the browser at twitch.tv is generally not an experience which sparks joy though. I\u0026rsquo;m buffering. I\u0026rsquo;m declining cookies. I\u0026rsquo;m getting spammed with notifications to claim a sick new overwatch skin. There\u0026rsquo;s a little channel point button twerking for me to click it. You get the idea; it\u0026rsquo;s a heavy noisy experience.\nAs a result I set out to devise a solution which does spark joy. I came up with a script which leans on DIY desktop staples (dunst, tofi, mpv) and the very nice cli utility streamlink. Here it is:\nPLAYER=\u0026#34;mpv\u0026#34; LAUNCHER=\u0026#34;tofi\u0026#34; NOTIFY=\u0026#34;dunstify\u0026#34; # you need an api key, get them here # https://dev.twitch.tv/docs/api/get-started/ CLIENT_ID=\u0026#34;id-here\u0026#34; CLIENT_SECRET=\u0026#34;secret-here-please-sssshh\u0026#34; # list of streams to check STREAMS=( \u0026#34;limmy\u0026#34; \u0026#34;fl0m\u0026#34; \u0026#34;northernlion\u0026#34; \u0026#34;caedrel\u0026#34; ) # reassure user that something is happening \u0026#34;${NOTIFY}\u0026#34; \u0026#34;twitch -- checking who\u0026#39;s live beep boop be patient\u0026#34; # get auth token from twitch ACCESS_TOKEN=$(curl -s -X POST \\ \u0026#34;https://id.twitch.tv/oauth2/token\u0026#34; \\ -d \u0026#34;client_id=$CLIENT_ID\u0026#34; \\ -d \u0026#34;client_secret=$CLIENT_SECRET\u0026#34; \\ -d \u0026#34;grant_type=client_credentials\u0026#34; \\ | jq -r \u0026#39;.access_token\u0026#39;) # define empty list LIVE=() # loop through streams, check if live and append info to list for STREAM in \u0026#34;${STREAMS[@]}\u0026#34;; do RESPONSE=$(curl -s -H \u0026#34;Client-ID: $CLIENT_ID\u0026#34; \\ -H \u0026#34;Authorization: Bearer $ACCESS_TOKEN\u0026#34; \\ \u0026#34;https://api.twitch.tv/helix/streams?user_login=$STREAM\u0026#34;) LIVE_STATUS=$(echo \u0026#34;$RESPONSE\u0026#34; | jq \u0026#39;.data | length\u0026#39;) if [ \u0026#34;$LIVE_STATUS\u0026#34; -gt 0 ]; then TITLE=$(echo \u0026#34;$RESPONSE\u0026#34; | jq -r \u0026#39;.data[0].title\u0026#39;) GAME=$(echo \u0026#34;$RESPONSE\u0026#34; | jq -r \u0026#39;.data[0].game_name\u0026#39;) LIVE+=(\u0026#34;$STREAM | $GAME | $TITLE\u0026#34;) fi done # pipe list items into tofi with new lines at the end choice=\u0026#34;$( printf \u0026#34;%s\\n\u0026#34; \u0026#34;${LIVE[@]}\u0026#34; | \u0026#34;${LAUNCHER}\u0026#34;)\u0026#34; if [[ -n \u0026#34;$choice\u0026#34; ]]; then # get first column from selection aka stream name meat=$(echo \u0026#34;$choice\u0026#34; | awk \u0026#39;{print $1}\u0026#39;) \u0026#34;${NOTIFY}\u0026#34; \u0026#34;twitch -- launching twitch.tv/$meat\u0026#34; streamlink twitch.tv/\u0026#34;$meat\u0026#34; 1080p60 --player \u0026#34;${PLAYER}\u0026#34; fi What it does: talk to twitch api to get auth token loop trough list of streams to check if they\u0026rsquo;re live (using auth token) grab some info about streams that are live and append it to a list pipe said list into tofi capture user\u0026rsquo;s choice open choice in mpv using streamlink Dependencies curl jq tofi (would work with other launchers dmenu etc.) mpv (would work with other media players vlc etc.) dunst (would work with other notification daemons mako etc.) Positive :) no chat (you don\u0026rsquo;t have to read the degenerates spamming LUL) you can customise the script to use your favourite desktop tools can rewind! Negative :( no chat (you might want to spam LUL) takes a second to talk to the internet so things don\u0026rsquo;t launch immediately have to faff with getting api key - how to get one btw Hope you enjoyed bye\n","summary":"\u003cp\u003eI like to watch twitch streams.\nWatching them in the browser at \u003ccode\u003etwitch.tv\u003c/code\u003e is generally not an experience which sparks joy though.\nI\u0026rsquo;m buffering.\nI\u0026rsquo;m declining cookies.\nI\u0026rsquo;m getting spammed with notifications to claim a sick new overwatch skin.\nThere\u0026rsquo;s a little channel point button twerking for me to click it.\nYou get the idea; it\u0026rsquo;s a heavy noisy experience.\u003c/p\u003e","title":"Handy script for a more zen twitch experience","url":"https://nonsense.dymc.win/handy-script-for-a-more-zen-twitch-experience/"},{"content":"As is traditional with people hosting their own blog I\u0026rsquo;m going to do a post detailing EXACTLY how I\u0026rsquo;m hosting my blog. Down to the last dirty detail. I have nothing better to talk about.\nHere is a diagram I edited to illustrate (credit to xkcd I think?).\nI host my site on a hetzner vps running nixos. I also have a git repo where all the static files for my blog live. I had previously been manually rsyncing the website up to my vps from my laptop. Qute an easy, efficient solution; it worked well. But not very nixos; far too simple, not sufficiently over-engineered. So in true nixos fashion I decided I\u0026rsquo;d spend a couple of hours sorting the problem so I\u0026rsquo;d maybe save a minute once a year when I write a blog post.\nRemote Rebuilds First, I\u0026rsquo;ll show the fancy way to rebuild your remote nixos systems via ssh. In my case, this means I can rebuild my hetzner box from my laptop. You can read the wiki about it here.\nThis sets up ssh with key-based authentication and lets our local user in. This config belongs on the remote machine.\nusers.users.blog-king.openssh.authorizedKeys.keys = [ # ssh public key on computer you\u0026#39;re deploying from \u0026#34;ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPzFa1hmmmmmPL5HvJZhXVEaWiZIMi34oR6AOcaaaaaaa\u0026#34; ]; nix.settings.trusted-users = [ \u0026#34;blog-king\u0026#34; ]; # ssh daemon services.openssh = { enable = true; openFirewall = true; settings = { PasswordAuthentication = false; PermitRootLogin = \u0026#34;no\u0026#34;; }; }; Once you have this going on your remote machine (in my case the hetzner vps) you should be able to rebuild the remote machine with nixos-rebuild --target-host blog-king@remote-ip-here --ask-sudo-password switch. The --ask-sudo-password is not required if you ssh in as root though that would be a touch gauche.\nCaddy You can do this with whatever your preferred webserver is. I am a caddy stan. This opens the necessary ports in the firewall and sets up caddy in file server mode pointing at /etc/blog.\nnetworking.firewall.allowedTCPPorts = [ 80 443 ]; services.caddy = { enable = true; extraConfig = \u0026#39;\u0026#39; blog.example.org { root * /etc/blog file_server } \u0026#39;\u0026#39;; }; Getting the files from git We have a web server pointing at /etc/blog. The last piece of the puzzle is to get the static files from our git repo and spit them out in that directory.\nI\u0026rsquo;m using the fetchFromGitea helper here which works for gitea and forgejo instances. The fetchFromGitHub helper would look very similar.\nYou can get the rev and sha256 of the commit using nix-prefetch-git.\nAlso note the little /public at the end of the source string. That\u0026rsquo;s the directory of the git repo that the website source lives.\nenvironment.etc.\u0026#34;blog\u0026#34; = { enable = true; target = \u0026#34;blog\u0026#34;; source = \u0026#34;${ pkgs.fetchFromGitea { domain = \u0026#34;git.example.org\u0026#34;; owner = \u0026#34;james\u0026#34;; repo = \u0026#34;blog\u0026#34;; rev = \u0026#34;32d81f01388c88a259eed2ba52f4545dbcb1eb07\u0026#34;; sha256 = \u0026#34;173g99dj8y4sw1v7f1s5f7zgcrrlr6dly9n6ysr2i4jg095lkxw8\u0026#34;; } }/public\u0026#34;; user = \u0026#34;caddy\u0026#34;; group = \u0026#34;caddy\u0026#34;; }; So now with all that setup the blog post work flow is:\nCommit rebuilt website to repo Update the rev and sha256 to the new commit (this is annoying and I\u0026rsquo;m trying to work out a good way to automate it) Rebuild vps from laptop Not necessarily faster than the old rsync method but it\u0026rsquo;s pretty damn declarative, that\u0026rsquo;s for sure.\n","summary":"\u003cp\u003eAs is traditional with people hosting their own blog I\u0026rsquo;m going to do a post detailing EXACTLY how I\u0026rsquo;m hosting my blog.\nDown to the last dirty detail.\nI have nothing better to talk about.\u003c/p\u003e","title":"Over-engineered (?) nixos blog deployment setup","url":"https://nonsense.dymc.win/over-engineered-nixos-blog-deployment-setup/"},{"content":"I\u0026rsquo;ve recently been messing around with writing neovim plugins. When I initially got going I found it a little tricky to know how to get started. There\u0026rsquo;s the official neovim docs which are great; but in my beginner experience exhaustive to the point of slight impenetrability. Beyond that, the thing I found most useful was simply reading the source of some popular plugins to get an idea of how things worked. I would recommend sticking to plugins with a smaller scope though.\nAs a demostrative MVP (minimal viable plugin) jumping-off-point, I\u0026rsquo;m going to make a very simple note-taking plugin. It will provide a command to neovim which when run opens a file titled with the date and time in a specific notes directory. Vamos.\nThis is what you will want your directory structure to look like.\n├── lua │ └── note │ └── init.lua └── plugin └── note.vim The plugin/note.vim file will look like this.\ncommand! Note lua require(\u0026#34;note\u0026#34;).main() This creates a custom command Note which when run will call a lua function. Now on to where that function and the meat of the plugin logic will live: the lua/note/init.lua file. With more complex plugins this section will often be split into many files but we\u0026rsquo;ve just got one here as it\u0026rsquo;s so simple.\nFirst things first we create a plugin object.\nlocal note = {} Then we will define some default options for the plugin in a table. These are variables you want the user to be able to change when they call the setup function.\nlocal defaults = { note_directory = \u0026#34;~/notes/\u0026#34;, date_format = \u0026#34;%Y-%m-%d %H:%M\u0026#34;, file_extension = \u0026#34;.md\u0026#34;, } Next we need the setup function. This takes the user\u0026rsquo;s options and merges them with our default options.\nfunction note.setup(user_options) options = vim.tbl_deep_extend(\u0026#34;force\u0026#34;, defaults, user_options or {}) end This is the main function where the magic happens.\nfunction note.main() local dir = options.note_directory local name = os.date(options.date_format) local ext = options.file_extension local filename = string.format(\u0026#34;%s%s%s\u0026#34;, dir, name, ext) local command = string.format(\u0026#34;edit %s\u0026#34;, filename) vim.api.nvim_command(command) end Finally we return the plugin obect.\nreturn note At this point you should have a working plugin :) As a little coda, this is how you can use your fancy new plugin using lazy.nvim.\nrequire(\u0026#34;lazy\u0026#34;).setup({ { -- local dir = \u0026#34;~/neovim-note-plugin\u0026#34;, -- github -- \u0026#34;me/neovim-note-plugin\u0026#34;, -- alternative non github hosting -- url = \u0026#34;https://git.example.com/me/neovim note-plugin\u0026#34;, config = fucntion() require(\u0026#34;note\u0026#34;).setup({ file_extension = \u0026#34;.org\u0026#34;, }) end, } }) Hope you\u0026rsquo;ve enjoyed.\n","summary":"\u003cp\u003eI\u0026rsquo;ve recently been messing around with writing neovim plugins.\nWhen I initially got going I found it a little tricky to know how to get started.\nThere\u0026rsquo;s the \u003ca href=\"https://neovim.io/doc\"\u003eofficial neovim docs\u003c/a\u003e which are great; but in my beginner experience exhaustive to the point of slight impenetrability.\nBeyond that, the thing I found most useful was simply reading the source of some popular plugins to get an idea of how things worked.\nI would recommend sticking to plugins with a smaller scope though.\u003c/p\u003e","title":"So you want to write a neovim plugin with lua","url":"https://nonsense.dymc.win/so-you-want-to-write-a-neovim-plugin-with-lua/"},{"content":"I recently started fiddling around with home-managerifying my neovim config. After moving across most of my stuff I came across the problem of how to hook things up with with nix-colors so that my neovim theme would follow color changes in home-manager.\nLuckily, I came across this handy little plugin from the lovely mini.nvim suite of plugins which lets you create your own theme with your custom colors.\nBeneath is a little snippet of how you could make it all happen.\n{ inputs, pkgs, ... }: { imports = [ inputs.nix-colors.homeManagerModules.default ]; scheme = inputs.nix-colors.schemes.onedark; programs.neovim = { enable = true; plugins = with pkgs.vimPlugins; [ { plugin = mini-nvim; config = \u0026#39;\u0026#39; lua \u0026lt;\u0026lt; END require(\u0026#39;mini.base16\u0026#39;).setup({ palette = { base00 = \u0026#39;#${scheme.colors.base00}\u0026#39;, base01 = \u0026#39;#${scheme.colors.base01}\u0026#39;, base02 = \u0026#39;#${scheme.colors.base02}\u0026#39;, base03 = \u0026#39;#${scheme.colors.base03}\u0026#39;, base04 = \u0026#39;#${scheme.colors.base04}\u0026#39;, base05 = \u0026#39;#${scheme.colors.base05}\u0026#39;, base06 = \u0026#39;#${scheme.colors.base06}\u0026#39;, base07 = \u0026#39;#${scheme.colors.base07}\u0026#39;, base08 = \u0026#39;#${scheme.colors.base08}\u0026#39;, base09 = \u0026#39;#${scheme.colors.base09}\u0026#39;, base0A = \u0026#39;#${scheme.colors.base0A}\u0026#39;, base0B = \u0026#39;#${scheme.colors.base0B}\u0026#39;, base0C = \u0026#39;#${scheme.colors.base0C}\u0026#39;, base0D = \u0026#39;#${scheme.colors.base0D}\u0026#39;, base0E = \u0026#39;#${scheme.colors.base0E}\u0026#39;, base0F = \u0026#39;#${scheme.colors.base0F}\u0026#39;, }, }) END \u0026#39;\u0026#39;; } ]; }; } Happy theming!\n","summary":"\u003cp\u003eI recently started fiddling around with home-managerifying my neovim config.\nAfter moving across most of my stuff I came across the problem of how to hook things up with with \u003ca href=\"https://github.com/misterio77/nix-colors\"\u003enix-colors\u003c/a\u003e so that my neovim theme would follow color changes in home-manager.\u003c/p\u003e","title":"Making nix-colors talk to neovim","url":"https://nonsense.dymc.win/making-nix-colors-talk-to-neovim/"},{"content":"Sometimes when I\u0026rsquo;m trawling the internet and happen upon a particularly nice looking website, I develop css and javascript FOMO. The thing I\u0026rsquo;ve been lusting after above all else is one of those fancy little dark theme toggle buttons. As you can probably tell from the website you\u0026rsquo;re looking at my web dev skills are limited. As a result of this I had assumed such niceties were out of reach.\nLast week though I decided it was time for this to change! I would do a teeny bit of javascript. I could have nice things. This is a rundown of the very simple implementation I came up with.\nHTML First things first, we\u0026rsquo;ll need a button for users to click. This can be plopped wherever you want on your site.\n\u0026lt;button id=\u0026#34;themeButton\u0026#34; onclick=\u0026#34;toggleTheme()\u0026#34; class=\u0026#34;theme-button\u0026#34;\u0026gt; The id will let us reference the button from our javascript, onclick tells the button to call the toggleTheme() function we\u0026rsquo;ll write in a minute, and the theme-button class will let us theme the button from our css.\nCSS In order to achieve our magic theme switching we\u0026rsquo;re going to split our css out in to three files: base.css, dark.css, and light.css. The dark.css and light.css files will do the same thing: import all the common css and define a root pseudo-class to store our color variables. For example a very simple dark.css would look like this.\n/* import common css */ @import url(\u0026#34;base.css\u0026#34;); /* define colors */ :root { --bg: black; --fg: white; } The base.css will simply store all the other styling you want. Here you can reference the color variables defined in the dark.css and light.css.\nbody { background-color: var(--bg); color: var(--fg); } JS Now with the groundwork in place we can stick it all together with the javascript. The gameplan here is to check the href attribute of the stylesheet element. Then if it\u0026rsquo;s set to dark.css switch it to light.css and vice-versa. my toggleTheme function looked like this.\nfunction toggleTheme() { var stylesheet = document.getElementById(\u0026#39;stylesheet\u0026#39;); if (stylesheet.getAttribute(\u0026#39;href\u0026#39;) === \u0026#39;/dark.css\u0026#39;) { // update stylesheet stylesheet.setAttribute(\u0026#39;href\u0026#39;, \u0026#39;/light.css\u0026#39;); } else { // update stylesheet stylesheet.setAttribute(\u0026#39;href\u0026#39;, \u0026#39;/dark.css\u0026#39;); } } This works well except for one little problem: when you refresh or load a new page, the stylesheet is returned to its default. This short term memory can be fixed though so theme changes persist through page loads.\nFirst we need to update our toggleTheme function to store our theme changes locally.\nfunction toggleTheme() { var stylesheet = document.getElementById(\u0026#39;stylesheet\u0026#39;); if (stylesheet.getAttribute(\u0026#39;href\u0026#39;) === \u0026#39;/dark.css\u0026#39;) { // update stylesheet stylesheet.setAttribute(\u0026#39;href\u0026#39;, \u0026#39;/light.css\u0026#39;); // store theme localStorage.setItem(\u0026#39;stylesheet\u0026#39;, \u0026#39;/light.css\u0026#39;); } else { // update stylesheet stylesheet.setAttribute(\u0026#39;href\u0026#39;, \u0026#39;/dark.css\u0026#39;); // store theme localStorage.setItem(\u0026#39;stylesheet\u0026#39;, \u0026#39;/dark.css\u0026#39;); } } We then add an event listener to check if there is a theme stored on page loads.\nwindow.addEventListener(\u0026#39;load\u0026#39;, function() { // get stored style var storedStyle = localStorage.getItem(\u0026#39;stylesheet\u0026#39;); var stylesheet = document.getElementById(\u0026#39;stylesheet\u0026#39;); // set stored style if it exists if (storedStyle) { stylesheet.setAttribute(\u0026#39;href\u0026#39;, storedStyle); } }); Finally, don\u0026rsquo;t forget to add your javascript to your html somewhere.\n\u0026lt;script src=\u0026#34;/toggle.js\u0026#34;\u0026gt;\u0026lt;/script\u0026gt; Hope you\u0026rsquo;ve enjoyed. Toggle toggle toggle!\n","summary":"\u003cp\u003eSometimes when I\u0026rsquo;m trawling the internet and happen upon a particularly nice looking website, I develop css and javascript FOMO. The thing I\u0026rsquo;ve been lusting after above all else is one of those fancy little dark theme toggle buttons. As you can probably tell from the website you\u0026rsquo;re looking at my web dev skills are limited. As a result of this I had assumed such niceties were out of reach.\u003c/p\u003e","title":"Vanilla javascript theme toggle for simpletons","url":"https://nonsense.dymc.win/vanilla-javascript-theme-toggle-for-simpletons/"},{"content":"For a little while now I\u0026rsquo;ve been running some services (jellyfin etc.) on an old laptop in my house. I\u0026rsquo;m not trying to sound like a podcast ad but as a networking novice, the simplicity tailscale brings to accessing these services remotely is very nice. Until recently though, I had been accessing my services like a heathen with http and port numbers (eg http://tailscale-ip:service-port). This works and is perfectly secure thanks to tailscale though it lacks a certain finesse. In an ideal world you\u0026rsquo;d have a reverse proxy and set up SSL certs so your browser doesn\u0026rsquo;t get stressed and you dont have to rememeber ip addresses and port numbers.\nWhen I initially looked at how to do this it seemed like it was above my paygrade and not worth the stress; that was until I came across this. This works great and is as simple as advertised though there is one drawback: you can only reverse proxy one service per host. So for my usecase of the laptop with multiple services running on it I could only use the magic caddy tailscale auto-https thing for one of them.\nwhat to do? Seeing as I was already using nixos on my latop server I turned to a slightly cumbersome nixos solution. One nixos-container for each service I wanted over https. I\u0026rsquo;d be lying If I said I completely understand all of this NAT business but this was the config I cobbled together (copied from the nixos docs).\nnetworking.nat = { enable = true; internalInterfaces = [\u0026#34;ve-+\u0026#34;]; externalInterface = \u0026#34;ens3\u0026#34;; }; containers.jellyfin = { autoStart = true; enableTun = true; privateNetwork = true; hostAddress = \u0026#34;192.168.100.10\u0026#34;; localAddress = \u0026#34;192.168.100.11\u0026#34;; bindMounts = { \u0026#34;/films\u0026#34; = { hostPath = \u0026#34;/mnt/films\u0026#34;; }; }; config = { pkgs, ... }: { services.tailscale = { enable = true; # permit caddy to get certs from tailscale permitCertUid = \u0026#34;caddy\u0026#34;; }; services.jellyfin = { enable = true; openFirewall = true; }; services.caddy = { enable = true; extraConfig = \u0026#39;\u0026#39; jellyfin.tailnet-name.ts.net { reverse_proxy localhost:8096 } \u0026#39;\u0026#39;; }; # open https port networking.firewall.allowedTCPPorts = [ 443 ]; system.stateVersion = \u0026#34;23.05\u0026#34;; }; }; } This example enables the jellyfin, tailscale, and caddy services, mounts a film folder from the host, and lets the container talk to the internet.\nOnce you\u0026rsquo;ve logged into the container sudo nixos-container root-login jellyfin and authenticated with tailscale sudo tailscale up, you should be able to access your jellyfin in your browser at https://jellyfin.tailnet-name.ts.net.\nAs well as solving the multiple services problem, separating services onto their own hosts is nice if you want to share a particular service with someone else. I personaly feel happier just sharing one container running jellyfin rather than the whole host with multiple things on it. Anyway thanks for listening to my TED talk.\n","summary":"\u003cp\u003eFor a little while now I\u0026rsquo;ve been running some services (jellyfin etc.) on an old laptop in my house. I\u0026rsquo;m not trying to sound like a podcast ad but as a networking novice, the simplicity \u003ca href=\"https://tailscale.com/\"\u003etailscale\u003c/a\u003e brings to accessing these services remotely is very nice. Until recently though, I had been accessing my services like a heathen with http and port numbers (eg http://tailscale-ip:service-port). This works and is perfectly secure thanks to tailscale though it lacks a certain finesse. In an ideal world you\u0026rsquo;d have a reverse proxy and set up SSL certs so your browser doesn\u0026rsquo;t get stressed and you dont have to rememeber ip addresses and port numbers.\u003c/p\u003e","title":"Tailscale, caddy, and nixos containers","url":"https://nonsense.dymc.win/tailscale-caddy-and-nixos-containers/"},{"content":"I\u0026rsquo;m a person who has spent an unreasonable amount of time making minute changes to the appearance of my bar in qtile. Despite the very nice selection of widgets availabe by default with qtile, it was only a matter of time before I decided I wanted to experiment with making my own custom widget. Fortunately, if you can do a bit of python this is quite an approachable undertaking.\nThe dream widget I was lacking was a little live crikcet score ticker type thing; something which would scroll along on my bar showing me the score in live cricket matches. I\u0026rsquo;m sure this will interest very few people but I learnt some good stuff along the way.\nHello World?! As far as I can tell from looking at the code for some of the built-in widgets and this very helpful guide, a basic hello world widget would look something like this.\nfrom libqtile.widget import base class HelloWorld(base._TextBox): def __init__(self, **config): super().__init__(\u0026#34;\u0026#34;, **config) self.text = \u0026#39;Hello world!\u0026#39; Qtile provides a selection of base widget classes to do various useful things. This example uses the simple _TextBox which displays the content of the self.text property.\nHello World Version 2 Very nice, but for the cricket widget we\u0026rsquo;ll need something which lets us update the text. The answer is ThreadPoolText. This class lets you periodically update the text by overridding its poll method with a function that returns the updated text.\nThis example updates itself with hello world in a different language every five seconds.\nimport random class HolaMundo(base.ThreadPoolText): defaults = [ (\u0026#34;update_interval\u0026#34;, 5, \u0026#34;Update interval for the widget\u0026#34;), ] def __init__(self, **config): super().__init__(\u0026#34;\u0026#34;, **config) self.add_defaults(HolaMundo.defaults) def poll(self): messages = [ \u0026#39;Hola mundo\u0026#39;, \u0026#39;Ciao mondo\u0026#39;, \u0026#39;مرحبا بالعالم\u0026#39;, \u0026#39;Saluton Mondo\u0026#39;, \u0026#39;Sawubona Mhlaba\u0026#39; ] return random.choice(messages) Along with the whole poll thing, this example also introduces defaults. This is a list of tuples which define parameters that the user can configure. Here we\u0026rsquo;ve added update_interval which defines how often the widget is updated.\nCricket Scores For getting the cricket scores we\u0026rsquo;ll be using a handy rss feed from cricinfo so no brute force scraping will be required, just my beloved feedparser. This doesn\u0026rsquo;t involve anything directly widget related, just massaging the rss feed into something that would look useful on your bar. Anyway, this is what the finished item looked like.\nfrom libqtile.widget import base import feedparser class CricketScores(base.ThreadPoolText): defaults = [ (\u0026#34;update_interval\u0026#34;, 60, \u0026#34;Update interval for the cricket scores widget\u0026#34;), (\u0026#34;teams\u0026#34;,[],\u0026#34;Teams to display scores for\u0026#34;), (\u0026#34;separator\u0026#34;,\u0026#34; \\U0001F3CF \u0026#34;,\u0026#34;Text to place between scores\u0026#34;), (\u0026#34;no_scores_string\u0026#34;,\u0026#34;\u0026#34;,\u0026#34;Text to show when there are no scores to show\u0026#34;), ] def __init__(self, **config): super().__init__(\u0026#34;\u0026#34;, **config) self.add_defaults(CricketScores.defaults) def get_scores(self): # parse rss feed and get # live matches from title field feed = feedparser.parse(\u0026#34;http://static.cricinfo.com/rss/livescores.xml\u0026#34;) scores = [] for match in feed.entries: # filter live matches if \u0026#34;*\u0026#34; in match.title: scores.append(match.title) # remove scores not involving chosen teams filtered_scores = [] for score in scores: for team in self.teams: if team in score: filtered_scores.append(score) # if no scores, show no_scores_string if len(filtered_scores) == 0: return self.no_scores_string else: # form pretty string with separators final_scores = \u0026#34;\u0026#34; for score in filtered_scores: if score != filtered_scores[-1]: final_scores += score + self.separator else: final_scores += score return final_scores def poll(self): return get_scores() Actaully Using It In Your Config Assuming you have a my_widget.py file in the same directory as your config.py, you simply have to import it and add it your list of widgets.\nfrom my_widget import LovelyWidget screens = [ Screen( top = bar.Bar( widgets = [ LovelyWidget(), widget.GroupBox(), ] ) ) ] Happy widget writing.\n","summary":"\u003cp\u003eI\u0026rsquo;m a person who has spent an unreasonable amount of time making minute changes to the appearance of my bar in qtile. Despite the very nice selection of widgets availabe by default with qtile, it was only a matter of time before I decided I wanted to experiment with making my own custom widget. Fortunately, if you can do a bit of python this is quite an approachable undertaking.\u003c/p\u003e\n\u003cp\u003eThe dream widget I was lacking was a little live crikcet score ticker type thing; something which would scroll along on my bar showing me the score in live cricket matches. I\u0026rsquo;m sure this will interest very few people but I learnt some good stuff along the way.\u003c/p\u003e","title":"Learning about qtile widgets with cricket","url":"https://nonsense.dymc.win/learning-about-qtile-widgets-with-cricket/"},{"content":"As I fall deeper and deeper down the nixos rabbit hole, I find myself becoming more and more obsessed with controlling every little thing on my computers declaratively. It starts with: \u0026lsquo;oh this is cool I can specify which desktop environment to use in my configuration.nix\u0026rsquo;. Next thing you know you\u0026rsquo;ve discovered home-manager and every program on every linux system you use needs to be controlled in your nix-config. Of course this slightly insane approach has its downsides; it also opens some doors though.\nNix-colors lets you dyanmically change the theming of programs controlled in your nix config. So when you want to change the color of everything and have it match and all be pretty lol, you are able to do so with one word as opposed to poring over everything changing each individual color. For a certain type of person, this is very nice!\nhow to make it work This will be a quick rundown of how I\u0026rsquo;ve got things set up; this is basically just a rehash of this.\nFirst of all, you need to add nix-colors to your flake inputs and then point home-manager in its direction. The relevant parts of my flake.nix look something like this.\n{ inputs = { nix-colors.url = \u0026#34;github:misterio77/nix-colors\u0026#34;; }; homeConfigurations = { \u0026#34;randy@computer\u0026#34; = home-manager.lib.homeManagerConfiguration { extraSpecialArgs = { inherit nix-colors; }; }; } Then you can import the module into your home-manager config, specify a scheme (available schemes here), and get to theming.\nHere\u0026rsquo;s a simple example where I make my dunst notifications follow the everforest theme.\n{ pkgs, config, nix-colors, ... }: { imports = [ nix-colors.homeManagerModule ]; colorScheme = nix-colors.colorSchemes.everforest; services.dunst = { enable = true; urgency_normal = { background = \u0026#34;#${config.colorScheme.colors.base01}\u0026#34;; foreground = \u0026#34;#${config.colorScheme.colors.base05}\u0026#34;; }; }; } a couple of additional tips and tricks First tip and trick: generate and dynamically alter gtk themes depending on current nix-colors theme.\n{ config, pkgs, inputs, ... }: let inherit (inputs.nix-colors.lib-contrib { inherit pkgs; }) gtkThemeFromScheme; in rec { gtk = { enable = true; theme = { name = \u0026#34;${config.colorScheme.slug}\u0026#34;; package = gtkThemeFromScheme { scheme = config.colorScheme; }; }; }; services.xsettingsd = { enable = true; settings = { \u0026#34;Net/ThemeName\u0026#34; = \u0026#34;${gtk.theme.name}\u0026#34;; \u0026#34;Net/IconThemeName\u0026#34; = \u0026#34;${gtk.iconTheme.name}\u0026#34;; }; }; } Second tip and trick: if you\u0026rsquo;re not using nix to configure everything you can still pass your colors across in the relevant format with home.file. I do this for qtile.\n{config, pkgs, ... }: let c = config.colorScheme.colors; in { home.file = { \u0026#34;.config/qtile/colors.py\u0026#34; = { text = \u0026#39;\u0026#39; scheme = { \u0026#39;yellow\u0026#39;: \u0026#34;#${c.base0A}\u0026#34;, \u0026#39;orange\u0026#39;: \u0026#34;#${c.base09}\u0026#34;,\t\u0026#39;red\u0026#39;: \u0026#34;#${c.base0F}\u0026#34;,\t\u0026#39;magenta\u0026#39;: \u0026#34;#${c.base08}\u0026#34;,\t\u0026#39;violet\u0026#39;: \u0026#34;#${c.base0E}\u0026#34;, \u0026#39;blue\u0026#39;: \u0026#34;#${c.base0D}\u0026#34;, \u0026#39;cyan\u0026#39;: \u0026#34;#${c.base0C}\u0026#34;,\t\u0026#39;green\u0026#39;: \u0026#34;#${c.base0B}\u0026#34;, } \u0026#39;\u0026#39;; }; }; } You can then import the colors into your config.py and use them as you see fit.\nfrom colors import scheme layouts = [ layout.MonadTall( border_normal = scheme[\u0026#39;yellow\u0026#39;], border_focus = scheme[\u0026#39;green\u0026#39;], ), ] That\u0026rsquo;s it for today. Thank you to the hero that made this.\n","summary":"\u003cp\u003eAs I fall deeper and deeper down the nixos rabbit hole, I find myself becoming more and more obsessed with controlling every little thing on my computers declaratively. It starts with: \u0026lsquo;oh this is cool I can specify which desktop environment to use in my configuration.nix\u0026rsquo;. Next thing you know you\u0026rsquo;ve discovered \u003ca href=\"https://github.com/nix-community/home-manager\"\u003ehome-manager\u003c/a\u003e and every program on every linux system you use needs to be controlled in your nix-config. Of course this slightly insane approach has its downsides; it also opens some doors though.\u003c/p\u003e","title":"Achieve peak rice with nix-colors","url":"https://nonsense.dymc.win/achieve-peak-rice-with-nix-colors/"},{"content":"In my opinion, there are moments when the convenience of docker and its surrounding ecosystem can\u0026rsquo;t be beat. I\u0026rsquo;ve been dabbling in the self hosting world and oftentimes the best maintained packaging option is a docker image. As a result of this I\u0026rsquo;ve been playing around with the nixos approach to managing docker containers.\nnix -\u0026gt; docker compose -\u0026gt; docker run To illustrate how to translate a simple example from the world of docker to nix let\u0026rsquo;s have a look at the config for my searxng instance.\nvirtualisation.oci-containers.containers.\u0026#34;searxng\u0026#34; = { autoStart = true; image = \u0026#34;searxng/searxng\u0026#34;; volumes = [ \u0026#34;/srv/searx:/etc/searxng\u0026#34; ]; environment = { BASE_URL = \u0026#34;https://searx.jdysmcl.xyz/\u0026#34;; INSTANCE_NAME = \u0026#34;go on big boy dont be shy\u0026#34;; }; ports = [ \u0026#34;8080:8080\u0026#34; ]; }; Here is the same thing written in a docker-compose.yml style format.\nservices: searxng: image: searxng/searxng volumes: - /srv/searxng:/etc/searxng environment: - BASE_URL=https://searx.jdysmcl.xyz/; - INSTANCE_NAME=go on big boy dont be shy; ports: - \u0026#34;8080:8080\u0026#34; Also, this is what it would look like as a simple old docker run.\n$ docker pull searxng/searxng $ docker run --rm \\ -d -p 8080:8080 \\ -v \u0026#34;/srv/searxng:/etc/searxng\u0026#34; \\ -e \u0026#34;BASE_URL=http://searx.jdysmcl.xyz/\u0026#34; \\ -e \u0026#34;INSTANCE_NAME=go on big boy dont be shy\u0026#34; \\ searxng/searxng bits and bobs As you can see, nix very kindly provides you with convenient options for the most essential tasks: mounting volumes, exposing ports, passing environment variables etc. But what about some more niche configurations that aren\u0026rsquo;t exposed in oci-containers.nix. As far as I can tell, your best bet in these scenarios is virtualisation.oci-containers.containers.\u0026lt;name\u0026gt;.extraOptions; this lets you pass a list of command line arguments to your docker run command. For example, I had this in my config for a vpn container.\nvirtualisation.oci-containers.containers.\u0026#34;vpn\u0026#34;.extraOptions = [ \u0026#34;--cap-add=net_admin\u0026#34; \u0026#34;--device=/dev/net/tun\u0026#34; \u0026#34;--network=bridge\u0026#34; ]; With a mishmash of these different bits and bobs I was able to do everything that I needed to. It doesn\u0026rsquo;t really open any more doors than docker compose but it\u0026rsquo;s nice to have the option when you\u0026rsquo;re already invested in the nix ecosystem.\nOne final note: nix provides the option to choose between docker and podman with virtualisation.oci-containers.containers.backend. This defaults to podman.\n","summary":"\u003cp\u003eIn my opinion, there are moments when the convenience of docker and its surrounding ecosystem can\u0026rsquo;t be beat. I\u0026rsquo;ve been dabbling in the self hosting world and oftentimes the best maintained packaging option is a docker image. As a result of this I\u0026rsquo;ve been playing around with the nixos approach to managing docker containers.\u003c/p\u003e\n\u003ch3 id=\"nix---docker-compose---docker-run\"\u003enix -\u0026gt; docker compose -\u0026gt; docker run\u003c/h3\u003e\n\u003cp\u003eTo illustrate how to translate a simple example from the world of docker to nix let\u0026rsquo;s have a look at the config for my \u003ca href=\"https://docs.searxng.org/\"\u003esearxng\u003c/a\u003e instance.\u003c/p\u003e","title":"Translating docker to nix?!","url":"https://nonsense.dymc.win/translating-docker-to-nix/"},{"content":"Setting up a little static site is something I\u0026rsquo;ve done a few different times on a few different operating systems. It\u0026rsquo;s a slightly fiddly task with a few disparate jobs that all need looking after: ssh, let\u0026rsquo;s encrypt, nginx. In my opinion, it is one of the moments where consolidating all the little bits and bobs you need to setup into one common configuration is very useful.\nI\u0026rsquo;m going to go through a bit of the nixos config I\u0026rsquo;ve got for my vps.\nSSH Having a way to to get into your server is useful. Managing ssh on nix is very simple; this enables the ssh daemon, tells it what port to run on, disables plain text passwords, and disables root login.\nservices.openssh = { enable = true; ports = [ 69 ]; settings = { passwordAuthentication = false; permitRootLogin = \u0026#34;no\u0026#34;; }; }; ADDING A USER Generally, it\u0026rsquo;s nice to have a user so you\u0026rsquo;re not just rawdogging everything as root. This adds a user called ronald, sets their default shell, and adds them to some useful groups. You can even add your public ssh keys here for ultimate convenience.\nusers.users = { ronald = { isNormalUser = true; shell = pkgs.fish; extraGroups = [ \u0026#34;wheel\u0026#34; \u0026#34;nginx\u0026#34; ]; openssh.authorizedKeys.keyFiles = [ \u0026#34;/path/to/public/key/file\u0026#34; ] }; }; NGINX I use nginx to serve my sites. Compared to the nginx config I used to mess around with, the equivalent nix config is very clean. This chunk tells nginx to serve the contents of /var/www/example-site at example-site.here. It also opens the ports for http and https in the firewall.\nservices.nginx = { enable = true; virtualHosts.\u0026#34;example-site.here\u0026#34; = { enableACME = true; forceSSL = true; root = \u0026#34;/var/www/example-site/\u0026#34;; }; }; networking.firewall.allowedTCPPorts = [ 80 443 ]; HTTPS You can also make nix deal with all the let\u0026rsquo;s encrypt certbot stuff. It looks like this:\nsecurity.acme = { acceptTerms = true; defaults.email = \u0026#34;ronald@email.yes\u0026#34;; }; This will set up certificates for any sites you set the enableAMCE to true option for.\nCRON This is one final little tidbit I set up the other day. I had got bored of having to ssh into my server to manually copy my updated site to the website root. The problem was I would need root privileges on the server to rsync the files to the website root. This seemed like a whole minefield I didn\u0026rsquo;t want to mess with. Instead I set up a little cron job which copies a directory from my home to the website root every hour.\nservices.cron = { enable = true; systemCronJobs = [ \u0026#34;@hourly root cp -r /home/ronald/example-site /var/www/\u0026#34; ]; }; This means I can just rsync the updated site from my laptop to the server and it\u0026rsquo;ll be updated within the hour. Good enough for me.\n","summary":"\u003cp\u003eSetting up a little static site is something I\u0026rsquo;ve done a few different times on a few different operating systems. It\u0026rsquo;s a slightly fiddly task with a few disparate jobs that all need looking after: ssh, let\u0026rsquo;s encrypt, nginx. In my opinion, it is one of the moments where consolidating all the little bits and bobs you need to setup into one common configuration is very useful.\u003c/p\u003e\n\u003cp\u003eI\u0026rsquo;m going to go through a bit of the nixos config I\u0026rsquo;ve got for my vps.\u003c/p\u003e","title":"Simple nixos config for vps static site","url":"https://nonsense.dymc.win/simple-nixos-config-for-vps-static-site/"},{"content":"I have an old sad android phone with 2GB of ram which nowadays seems struggles these days. As a result of this I have been \u0026lsquo;podcast-player-hopping\u0026rsquo; without success for the last couple of months trying to find something which doesn\u0026rsquo;t nuke my phone whenever I use it. In a moment of desperation it occured to me that a creative solution might be required. The gameplan was this:\nwrite python script to download podcasts set up cron job on my server to run script every couple of hours sync podcasts across my devices using the lovely syncthing listen to podcasts using vlc which my phone loves For the python script I used the lovely feedparser module for easy talking to my rss feeds.\nWHERE THE PODCASTS GO First thing I would want my script to do is create a subdirectory of my main podcast directory for each individual podcast. After plopping all my feeds in a list like this:\nrss_urls = [ \u0026#39;https://anchor.fm/s/1311c8b8/podcast/rss\u0026#39;, \u0026#39;https://feeds.acast.com/public/shows/5e7b777ba085cbe7192b0607\u0026#39; ] I wrote a little function that would parse each of these feeds get its name, and make a directory if one does not already exist.\ndef create_dirs(): for url in rss_urls: f = feedparser.parse(url) feed_name = f[\u0026#39;feed\u0026#39;][\u0026#39;title\u0026#39;] current_feeds = os.listdir(pod_dir) if feed_name not in current_feeds: os.makedirs(pod_dir + feed_name) DOWNLOADING With this sorted I now turned to the actual downloading of podcasts. This function parses each rss feed, filters it for entries from the last week, then grabs a title and a url for the audio file. These are stuck together into a list of lists with each list representing a separate entry.\ndef get_pods(): global feed_info feed_info = [] for url in rss_urls: f = feedparser.parse(url) for pod in f.entries: if time.time() - time.mktime(pod.published_parsed) \u0026lt; (86400*7): feed_name = f.feed.title pod_name = pod.title pod_dl = pod.enclosures[0].href pod_info = [ feed_name, pod_name, pod_dl ] feed_info.append(pod_info) return feed_info This next function looks at all the podcast subdirectories and returns a list of all the podcasts I already have downloaded. This can be used when downloading to only get new podcasts.\ndef get_downloads(): downloads = [] pods = os.listdir(pod_dir) for dir in pods: if os.path.isdir(pod_dir + dir): for file in os.listdir(pod_dir + dir): downloads.append(file) return downloads Now for the actual getting of the audio files. Here we use requests to make a request to the audio file url and write the content to the relevant directory. I also append a .mp3 to the filenames so they play nice with media players.\ndef download(): a = get_pods() for pod in a: b = get_downloads() if pod[1]+\u0026#39;.mp3\u0026#39; not in b: try: dl = requests.get(pod[2]) except: print(\u0026#39;Download Error\u0026#39;) with open(pod_dir + pod[0] + \u0026#39;/\u0026#39; + pod[1] + \u0026#39;.mp3\u0026#39;, \u0026#39;wb\u0026#39;) as file: file.write(dl.content) PRUNING As it stands, the script does downloading great. The only thing we need is some kind of automatic deletion so my phone doesnt get clogged up with old podcasts. This function checks for files which were created over a week ago and deletes the offenders.\ndef trim(): for dir in os.listdir(pod_dir): if os.path.isdir(pod_dir + dir): pods = os.listdir(pod_dir + dir) for pod in pods: st = os.stat(pod_dir + dir + \u0026#39;/\u0026#39; + pod) mtime=st.st_mtime if time.time() - mtime \u0026gt; (86400*trim_age): os.remove(pod_dir + dir + \u0026#39;/\u0026#39; + pod) The last thing is to call the functions:\ncreate_dirs() download() trim() Of course this slightly ramshackle approach is certainly not for everyone lol but as it stands it\u0026rsquo;s working quite nicely for me. Lots of love and happy listening :)\n","summary":"\u003cp\u003eI have an old sad android phone with 2GB of ram which nowadays seems struggles these days. As a result of this I have been \u0026lsquo;podcast-player-hopping\u0026rsquo; without success for the last couple of months trying to find something which doesn\u0026rsquo;t nuke my phone whenever I use it. In a moment of desperation it occured to me that a creative solution might be required. The gameplan was this:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003ewrite python script to download podcasts\u003c/li\u003e\n\u003cli\u003eset up cron job on my server to run script every couple of hours\u003c/li\u003e\n\u003cli\u003esync podcasts across my devices using the lovely \u003ca href=\"https://syncthing.net/\"\u003esyncthing\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003elisten to podcasts using vlc which my phone loves\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eFor the python script I used the lovely \u003ca href=\"https://feedparser.readthedocs.io/en/latest/introduction.html\"\u003efeedparser\u003c/a\u003e module for easy talking to my rss feeds.\u003c/p\u003e","title":"Python podcast scripting","url":"https://nonsense.dymc.win/python-podcast-scripting/"},{"content":"INGREDIENTI flour (ideally bread flour but if you don\u0026rsquo;t have it, it\u0026rsquo;s not the end of the world) water salt yeast (i use the little dried packet stuff) RATIOS To start measure the weight of flour; this is what we\u0026rsquo;ll work from. You can now work out how much of the other ingredients you need using these ratios:\n65% water 2% salt 0.5% yeast (this amount doesn\u0026rsquo;t particularly matter, as long as it\u0026rsquo;s in this ballpark) So if we used 1kg of flour for example, the recipe would look like this:\n1000g flour 650g water 20g salt 5g yeast STEPS Put all the ingredients in a bowl nad mix until the flour is hydrated (you do not need to knead it, just bring it together). Put in the fridge to slowly proof for at least a day. Remove dough as required from the fridge and place in desired baking vessel (you don\u0026rsquo;t have to bake it all at once, I sometimes make a big batch and bake multiple things over the cours of a few days). Proof in vessel for an additional hour or so at room temperature. Bake! SOME HELPFUL RESOURCES Jim Lahey no knead bread Kenji video Ragusea pizza video ","summary":"\u003ch3 id=\"ingredienti\"\u003eINGREDIENTI\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003eflour (ideally bread flour but if you don\u0026rsquo;t have it, it\u0026rsquo;s not the end of the world)\u003c/li\u003e\n\u003cli\u003ewater\u003c/li\u003e\n\u003cli\u003esalt\u003c/li\u003e\n\u003cli\u003eyeast (i use the little dried packet stuff)\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3 id=\"ratios\"\u003eRATIOS\u003c/h3\u003e\n\u003cp\u003eTo start measure the weight of flour; this is what we\u0026rsquo;ll work from. You can now work out how much of the other ingredients you need using these ratios:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e65% water\u003c/li\u003e\n\u003cli\u003e2% salt\u003c/li\u003e\n\u003cli\u003e0.5% yeast (this amount doesn\u0026rsquo;t particularly matter, as long as it\u0026rsquo;s in this ballpark)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eSo if we used 1kg of flour for example, the recipe would look like this:\u003c/p\u003e","title":"Bread dough for lazy boys","url":"https://nonsense.dymc.win/bread-dough-for-lazy-boys/"},{"content":"This post is going to detail how I solved a very particular problem I had created for myself. First, a quick description of the problem. I use home-manager on nixos to declaratively configure what happens on my computer. In the cases where home-manager does not expose sufficient configuration options for my liking (qtile for example), I instead link a configuration file from my nixos config to where it belongs in my home using xdg.configFile. This is what I do with my qtile config.py. I use qtile on my desktop and laptop but I dont want an identical setup on the two machines. I have jumped through many different slightly silly hoops in my nixos config sort of solving this problem until the other day it occured to me this could all be achieved with my python in my qtile config.\nTHE NUB OF THE PROBLEM I basically just want the config to work out which computer it\u0026rsquo;\u0026rsquo;s on and then change some things accordingly. This can be achieved by getting the hostname with the socket module:\nif socket.gethostname() == \u0026#39;baron\u0026#39;: # some stuff i want to happen on my desktop elif socket.gethostname() == \u0026#39;countess\u0026#39;: # some stuff i want to happen on my laptop There are three main things that I like to differ between my two computers:\nwidgets on my bar (I don\u0026rsquo;t need brightness and battery on my desktop) keybindings programs to autostart WIDGETS My current solution for this is to define to separate lists of widgets and then point to each one when I make my bar for each computer. This isn\u0026rsquo;t perfect; it would be nice to have a list of all common widgets and then add to that with the unique ones. I haven\u0026rsquo;t worked out a way to add the additional widgets without just plopping them all at the end of the bar which isn\u0026rsquo;t necessarily where I want them (thinking about this now I think I might be able to use the insert method with a little for loop).\ncountess_widgets = [ # all the great widgets i want on my laptop ] screens = [ Screen( top = bar.Bar( widgets = countess_widgets ), ), ] KEYBINDINGS For keybindings I use extend to add some additional bindings to my global ones. This is mainly useful for the ones I use to change brightness on my laptop.\ncountess_keys = [ Key([m], \u0026#39;Up\u0026#39;, lazy.spawn(\u0026#39;light -A 5\u0026#39;), desc=\u0026#39;backlight up\u0026#39; ), Key([m], \u0026#39;Down\u0026#39;, lazy.spawn(\u0026#39;light -U 5\u0026#39;), desc=\u0026#39;backlight down\u0026#39; ), ] keys.extend(countess_keys) You could even change a specific global binding on one computer if you knew its index in the list:\nkeys[420] = Key([m], \u0026#39;d\u0026#39;, lazy.spawn(\u0026#39;dmenu_run\u0026#39;), desc = \u0026#39;dmenu\u0026#39; ) AUTOSTART Finally, I use this to autostart different programs which I want to change on each computer. For example I use an xrandr command to make sure my desktop monitor is at 144hz. It looks like this:\n@hook.subscribe.startup_once def autostart(): processes = [ [ \u0026#39;feh\u0026#39;, \u0026#39;--bg-scale\u0026#39;, \u0026#39;/home/james/pics/wallpapers/beaut.jpg\u0026#39; ], [ \u0026#39;xrandr\u0026#39;, \u0026#39;--output\u0026#39;, \u0026#39;DisplayPort2\u0026#39;, \u0026#39;--primary\u0026#39;, \u0026#39;--mode\u0026#39;, \u0026#39;1920x1080\u0026#39;, \u0026#39;--rate\u0026#39;, \u0026#39;143.85\u0026#39; ] ] for p in processes: subprocess.Popen(p) Of course, there are many ways that this could all be achievd but I think it\u0026rsquo;s quite neat having it all in my one qtile config. That\u0026rsquo;s about it for today. lots of love x\n","summary":"\u003cp\u003eThis post is going to detail how I solved a very particular problem I had created for myself. First, a quick description of the problem. I use home-manager on nixos to declaratively configure what happens on my computer. In the cases where home-manager does not expose sufficient configuration options for my liking (qtile for example), I instead link a configuration file from my nixos config to where it belongs in my home using \u003ccode\u003exdg.configFile\u003c/code\u003e. This is what I do with my qtile \u003ccode\u003econfig.py\u003c/code\u003e. I use qtile on my desktop and laptop but I dont want an identical setup on the two machines. I have jumped through many different slightly silly hoops in my nixos config sort of solving this problem until the other day it occured to me this could all be achieved with my python in my qtile config.\u003c/p\u003e","title":"Multi user qtile fiddling","url":"https://nonsense.dymc.win/multi-user-qtile-fiddling/"},{"content":"This is my attempt at a neofetch, pfetch, whateverfetch style system info utility. My main concern was making something which looked nice, was easily configurable, and as portable as possible (I didn\u0026rsquo;t really try that hard with the portability). I didn\u0026rsquo;t think much about performance; I\u0026rsquo;m personally not a man who stresses too much when a command takes a quarter of a second instead of a tenth. The basic gameplan was to get an array of bash commands which would fetch various bits and bobs, then loop through this array formatting the text with ANSI escape codes. First things first, this was the associative array I came up with:\ndeclare -A fetch=( [user]=\u0026#34;$USER\u0026#34; [host]=\u0026#34;$(cat /etc/hostname)\u0026#34; [uptime]=\u0026#34;$(uptime | awk \u0026#39;{print $3}\u0026#39; | sed \u0026#39;s/:/h / ; s/,/m/\u0026#39;)\u0026#34; [kernel]=\u0026#34;$(awk \u0026#39;{print $3}\u0026#39; /proc/version)\u0026#34; [distro]=\u0026#34;$(sed -n \u0026#39;s/^PRETTY_NAME=\u0026#34;//p\u0026#39; /etc/os-release | sed \u0026#39;s/\u0026#34;//\u0026#39;)\u0026#34; [shell]=\u0026#34;$(basename $SHELL)\u0026#34; [de]=\u0026#34;$XDG_CURRENT_DESKTOP\u0026#34; [terminal]=\u0026#34;$TERM\u0026#34; [editor]=\u0026#34;$EDITOR\u0026#34; [root]=\u0026#34;$(df -Th / | tail -n 1 | awk \u0026#39;{print $6}\u0026#39;), $(df -Th / | tail -n 1 | awk \u0026#39;{print $2}\u0026#39;)\u0026#34; [ip]=\u0026#34;$(host myip.opendns.com resolver1.opendns.com | tail -n 1 | awk \u0026#39;{print $4}\u0026#39;)\u0026#34; [battery]=\u0026#34;$(cat /sys/class/power_supply/BAT0/capacity)%\u0026#34; [cpu]=\u0026#34;$(sed -n 5p /proc/cpuinfo | cut -d: -f2)\u0026#34; [ram]=\u0026#34;$(free -h | sed -n 2p | awk \u0026#39;{print $3}\u0026#39;) / $(free -h | sed -n 2p | awk \u0026#39;{print $2}\u0026#39;)\u0026#34; [swap]=\u0026#34;$(free -h | sed -n 3p | awk \u0026#39;{print $3}\u0026#39;) / $(free -h | sed -n 3p | awk \u0026#39;{print $2}\u0026#39;)\u0026#34; [display]=\u0026#34;$(xrandr | grep \u0026#39;*\u0026#39; | awk \u0026#39;{print $1}\u0026#39;), $(xrandr | grep \u0026#39;*\u0026#39; | awk \u0026#39;{print $2}\u0026#39; | sed \u0026#39;s/*/Hz/ ; s/+//\u0026#39;)\u0026#34; ) Each of these elements fetches a differenet piece of info. You could just use environment variables to get quite a few things (user), some were an issue of grabbing a particular piece of info from a file (distro name), and some of the more complicated ones I just reformatted output from other commands (ram usage).\nNext order of business: colors. I wanted to put a chunk or randomly colored text at the start of each line so that each time you ran the command you got something that looked a little different. I made this array of escape codes each one referring to a different bold color:\ndeclare -a colors=( \u0026#34;\\e[0;1;30m\u0026#34; # black \u0026#34;\\e[0;1;31m\u0026#34; # red \u0026#34;\\e[0;1;32m\u0026#34; # green \u0026#34;\\e[0;1;33m\u0026#34; # blue \u0026#34;\\e[0;1;34m\u0026#34; # yellow \u0026#34;\\e[0;1;35m\u0026#34; # pink \u0026#34;\\e[0;1;36m\u0026#34; # magenta \u0026#34;\\e[0;1;37m\u0026#34; # white ) I then repurposed a nice function from someone on stackoverflow to get a random element from this array. The variable \u0026lsquo;pre\u0026rsquo; here is the text that I want formatted:\npre=\u0026#34;-\u0026gt;\u0026#34; random_color () { size=${#colors[@]} index=$(($RANDOM % $size)) echo \u0026#34;${colors[$index]}${pre}\\e[0m\u0026#34; } My plan was then to simply loop through the array, \u0026rsquo;echo-ing\u0026rsquo; out the random_color function, the key from the fetch array, a separator, and then the value form the fetch array. This worked mainly, the only issue being that each element from the fetch was not printed in the order it was declared. Ideally, I wanted the fetch elements to be printed in the order they were put in the array so you could configure the how they appeared. Once again my primitive understanding of bash had let me down; I turned to stackoverflow. I found the solution was to define another array containing the fetch keys and then use it to attack the other associative \u0026lsquo;fetch\u0026rsquo; array:\ndeclare -a order=( \u0026#34;user\u0026#34; \u0026#34;host\u0026#34; \u0026#34;uptime\u0026#34; # uses uptime command \u0026#34;kernel\u0026#34; \u0026#34;distro\u0026#34; \u0026#34;shell\u0026#34; \u0026#34;de\u0026#34; \u0026#34;terminal\u0026#34; \u0026#34;editor\u0026#34; # \u0026#34;ip\u0026#34; # uses host command # \u0026#34;cpu\u0026#34; # \u0026#34;ram\u0026#34; # uses free command # \u0026#34;swap\u0026#34; # uses free also # \u0026#34;root\u0026#34; # uses df command # \u0026#34;battery\u0026#34; # \u0026#34;display\u0026#34; # uses xrandr ) for info in \u0026#34;${order[@]}\u0026#34;; do echo -e \u0026#34;$(random_color) \\e[0;1;3m$info\\e[0m${sep}${fetch[$info]}\u0026#34; done This had the happy unintended consequence of allowing you to very easily configure which items you wanted in the fetch by simply commenting out keys from the order array. You can check out the script in its entirety here. This is a pretty picture of a few variations.\n","summary":"\u003cp\u003eThis is my attempt at a neofetch, pfetch, whateverfetch style system info utility. My main concern was making something which looked nice, was easily configurable, and as portable as possible (I didn\u0026rsquo;t really try that hard with the portability). I didn\u0026rsquo;t think much about performance; I\u0026rsquo;m personally not a man who stresses too much when a command takes a quarter of a second instead of a tenth. The basic gameplan was to get an array of bash commands which would fetch various bits and bobs, then loop through this array formatting the text with ANSI escape codes. First things first, this was the associative array I came up with:\u003c/p\u003e","title":"Teeny tiny bash fetch script","url":"https://nonsense.dymc.win/teeny-tiny-bash-fetch-script/"},{"content":"Since getting going with emacs I\u0026rsquo;ve gone down the org-mode rabbit hole a little bit. In particular the very nice org-journal package. It basically does what it says on the tin: maintains a journal with a selection of org files. This has been very nice for me. I have often thought about journalling but never really got up a head of steam. Somehow having an entry a keybinding away while I\u0026rsquo;m doing something with my text editor makes it a lot more palletable.\nHaving said all this, I am not completely converted to the church of emacs. Thus, I thoght it would be nice to write a little editor agnostic script which would emulate some of org-journal\u0026rsquo;s features but allow you to use whatever editor you like with markdown.\nWHAT\u0026rsquo;S THE TIME? First things first, I wrote this little function that would give you a formatted version of your local time. This will be important as a lot of this comes down to dates and times really. It uses python\u0026rsquo;s time module:\ndef whats_the_time(format): return time.strftime(format, time.localtime(time.time())) This function takes a string using python date format codes and spits out the corresponding time. For example, '%A %d %B, %Y' would give you Wednesday 12 December, 2022.\nWHAT TO CALL THE FILES? My plan is to have three options for journal_frequency: daily, monthly, and yearly. Depending on the value of this variable, each journal file the script creates will represent a day, month, or year. This function gives you a different filename depending on the journal_frequency that is set:\ndef make_filename(): if journal_frequency == \u0026#39;daily\u0026#39;: return whats_the_time(\u0026#39;%Y%m%d\u0026#39;)+\u0026#39;.md\u0026#39; elif journal_frequency == \u0026#39;monthly\u0026#39;: return whats_the_time(\u0026#39;%Y%m\u0026#39;)+\u0026#39;.md\u0026#39; elif journal_frequency == \u0026#39;yearly\u0026#39;: return whats_the_time(\u0026#39;%Y\u0026#39;)+\u0026#39;.md\u0026#39; DO WE NEED A NEW FILE? As I could see it, the next problem was determining whether a new journal file was needed. This would only happen if it was the first entry for a day, month, or year. Otherwise, you would simply want to add to the existing file. I came up with this little function using the os module to check if the file that would be created already exists:\ndef new_file_required(): if os.path.exists(os.path.join(journal_dir,make_filename())): return False else: return True MAKING FILES AND PUTTING THINGS IN THEM\nNow we have that admin out the way, we\u0026rsquo;re on the home straight. This function creates a file and adds a little title heading at the top using the title_string variable. This will be called when we do need a new file:\ndef create_file(): path = os.path.join(journal_dir,make_filename()) with open(path, \u0026#39;w\u0026#39;) as f: f.write(\u0026#39;# \u0026#39; + whats_the_time(title_string)) This guy adds a subheading wtih the current time as default using the entry_string variable. If you had journal_frequency set to monthly or yearly though you would likely want to edit this to include bits fo the date. This is called evry time you run the script.\ndef write_date(): path = os.path.join(journal_dir,make_filename()) with open(path, \u0026#39;a\u0026#39;) as f: f.write(\u0026#39;\\n\u0026#39;*2+\u0026#39;### \u0026#39;+ whats_the_time(entry_string)) OPENING A TEXT EDITOR Final order of business: how to open the appropriate journal file with the user\u0026rsquo;s chosen editor. For this we can use the subprocess module and Popen. By default I have this set to get your EDITOR environemnt variable and use that (come to think of it that probs won\u0026rsquo;t work with tui programs) but it could be set to anything.\ndef open_editor(): cmd = [ editor, os.path.join(journal_dir, make_filename()) ] process = subprocess.Popen(cmd, stdout=subprocess.PIPE) Now it\u0026rsquo;s just a matter of sticking all the functions together:\ndef main(): if new_file_required(): create_file() write_date() open_editor() else: write_date() open_editor() main() As simple as it is, it works reasonalby well as it stands. I would though like to add the ability to customise the file format you want to use so you could have org, plain text, markdown, or whatever. I\u0026rsquo;ve got the script set to just run with a keybinding at the moment so it fulfils the immediacy I was enjoying with org-journal. You can find the script here atm. BYEBYE xxx\n","summary":"\u003cp\u003eSince getting going with emacs I\u0026rsquo;ve gone down the org-mode rabbit hole a little bit. In particular the very nice \u003ca href=\"https://github.com/bastibe/org-journal\"\u003eorg-journal\u003c/a\u003e package. It basically does what it says on the tin: maintains a journal with a selection of org files. This has been very nice for me. I have often thought about journalling but never really got up a head of steam. Somehow having an entry a keybinding away while I\u0026rsquo;m doing something with my text editor makes it a lot more palletable.\u003c/p\u003e","title":"Get the thoughts out of your head and into a digital format with this python journalling script","url":"https://nonsense.dymc.win/get-the-thoughts-out-of-your-head-and-into-a-digital-format-with-this-python-journalling-script/"},{"content":"About a month ago I was a little bored and thought I\u0026rsquo;d give emacs a go. There\u0026rsquo;s something fun about trying out these mythical pieces of software that have been around forever; kind of like watching The Godfather for the first time. Like many extensible, super configurable programs, emacs seems kind of impenetrable at first glance. I tried doing the tutorial but kind of glazed over after a while with the endless stream of C-a C-b C-c. There\u0026rsquo;s also the quite jarring default theme which wasn\u0026rsquo;t vibing with the lovely screenshots I had seen on the internet. Anyway, after quite a bit of fiddling I\u0026rsquo;ve landed on a simple little setup that I\u0026rsquo;ve been quite enjoying. Here are a few little pointers to hopefully ease you in.\nAESTHETIC NICETIES First things first, assuming you\u0026rsquo;re on linux emacs is configured with a file at ~/.emacs.d/init.el. As a terrible aesthete, the first thing I was worried about was changing the theme. This can be achieved with M-x load-theme; if you want the setting to persist though you can add this to you init.el:\n(load-theme \u0026#39;misterioso t) There are a few themes out of the box but if you\u0026rsquo;re looking for some more I would recomment the doom-themes package. Speaking of packages, emacs has a built in package-manager that installs packages from the Emacs Lisp Package Archive (GNU ELPA); I unfortunately know very little about this as I\u0026rsquo;ve been using nix to manage my emacs packages.\nAnyway we\u0026rsquo;ve got a theme, how about a custom startup message for our initial buffer:\n(setq inhibit-startup-message t inhibit-startup-echo-area-message t initial-scratch-message \u0026#34;;;oh how i adore to edit text with emacs!\u0026#34;) Maybe you dont want those big old cumbersome toolbars cluttering up your screen:\n(scroll-bar-mode -1) (tool-bar-mode -1) (menu-bar-mode -1) Perhaps some line highlighting and numbering:\n;;line numbering (global-display-line-numbers-mode) (setq display-line-numbers-type \u0026#39;relative) ;;line higlight (global-hl-line-mode t) Custom font?\n(setq default-frame-alist \u0026#39;((font . \u0026#34;agave Nerd Font 14\u0026#34;))) CUSTOM KEYBINDINGS AND EVIL I don\u0026rsquo;t know if it\u0026rsquo;s just sunk cost fallacy or what but having gone to the trouble of learning to some extent how vim works, I kind of feel incomplete without vim keybindings now. Fortunately, emacs has evil mode which effectively emulates vim modal editing in emacs. To configure evil in our init.el we\u0026rsquo;ll use use-package. This is a macro which - to my understanding - talks to your package manager allowing you to configure installed packages in a nice neat efficient manner. To enable it, add this to your init.el:\n(eval-when-compile (require \u0026#39;use-package)) These are the keybindings that I currently have going; nothing too crazy just a few simple things:\n(use-package evil :config (evil-mode 1) (evil-select-search-module \u0026#39;evil-search-module \u0026#39;evil-search) ;;manage panes (define-key evil-normal-state-map (kbd \u0026#34;M-s\u0026#34;) \u0026#39;evil-window-split) (define-key evil-normal-state-map (kbd \u0026#34;M-v\u0026#34;) \u0026#39;evil-window-vsplit) (define-key evil-normal-state-map (kbd \u0026#34;M-h\u0026#34;) \u0026#39;evil-window-left) (define-key evil-normal-state-map (kbd \u0026#34;M-j\u0026#34;) \u0026#39;evil-window-down) (define-key evil-normal-state-map (kbd \u0026#34;M-k\u0026#34;) \u0026#39;evil-window-up) (define-key evil-normal-state-map (kbd \u0026#34;M-l\u0026#34;) \u0026#39;evil-window-right) ;;get files open quick (define-key evil-normal-state-map (kbd \u0026#34;M-f\u0026#34;) \u0026#39;find-file) (define-key evil-normal-state-map (kbd \u0026#34;M-b\u0026#34;) \u0026#39;dired-jump) ;;terminal (define-key evil-normal-state-map (kbd \u0026#34;M-t\u0026#34;) \u0026#39;ansi-term) ;;nav buffers (define-key evil-normal-state-map (kbd \u0026#34;M-,\u0026#34;) (kbd \u0026#34;C-x \u0026lt;left\u0026gt;\u0026#34;)) (define-key evil-normal-state-map (kbd \u0026#34;M-.\u0026#34;) (kbd \u0026#34;C-x \u0026lt;right\u0026gt;\u0026#34;)) ) SOME FRIEDNLY IDE FEATURES YOU MAY LIKE I don\u0026rsquo;t know about you but having used vscode here and there I\u0026rsquo;ve become accustomed to a lot of these little IDE crutches (completion, autopair and the like) and now when I don\u0026rsquo;t have thme I feel a little sad. Emacs has it covered though as long as you\u0026rsquo;re happy with installing some additional stuff. Auto-completion? Try company:\n;; enable company in all buffers (add-hook \u0026#39;after-init-hook \u0026#39;global-company-mode) (use-package company\t:commands company-tng-configure-default :custom ;; delay to start completion (company-idle-delay 0) ;; nb of chars before triggering completion (company-minimum-prefix-length 1) You want the nice little autopair brackets?\n(use-package flex-autopair :config (flex-autopair-mode 1)) Clever commenting?\n(use-package smart-comment :bind (\u0026#34;M-c\u0026#34; . smart-comment)) Here\u0026rsquo;s a little pic of the current setup :)\n","summary":"\u003cp\u003eAbout a month ago I was a little bored and thought I\u0026rsquo;d give emacs a go. There\u0026rsquo;s something fun about trying out these mythical pieces of software that have been around forever; kind of like watching The Godfather for the first time. Like many extensible, super configurable programs, emacs seems kind of impenetrable at first glance. I tried doing the tutorial but kind of glazed over after a while with the endless stream of C-a C-b C-c. There\u0026rsquo;s also the quite jarring default theme which wasn\u0026rsquo;t vibing with the lovely screenshots I had seen on the internet. Anyway, after quite a bit of fiddling I\u0026rsquo;ve landed on a simple little setup that I\u0026rsquo;ve been quite enjoying. Here are a few little pointers to hopefully ease you in.\u003c/p\u003e","title":"Lowkey emacs setup bits and bobs","url":"https://nonsense.dymc.win/lowkey-emacs-setup-bits-and-bobs/"},{"content":"Last time we worked out how to get info for all the games played by titled players in a particular month. Today, we have three objectives:\nParse this info for the pgn (portable game notation) of each game. Write these to a file so we dont have to spend forever downloading them everytime we run the script. Devise a way to convert this pgn to a more convenient pythonic format so we can analyse it later. First of all, I wrote a little function to get the pgn from the games we downloaded. I added this KeyError exception, but if I\u0026rsquo;m honest I\u0026rsquo;m not sure why I was getting this error. Maybe, chess.com doesn\u0026rsquo;t store pgn for all games? I don\u0026rsquo;t know.\ndef get_pgns(games): pgns = [] for game in games: try: pgn = game[\u0026#39;pgn\u0026#39;] pgns.append(pgn) except KeyError: print(\u0026#39;key error um\u0026#39;) return pgns Now we have this list of pgns, the next goal is to write them to a file so we theoretically only have to run the stuff from last post once. All the analysis we do on the games can then just be done on the files we save without any talking to the internet required.\ndef write_pgns(pgns): with open(month.replace(\u0026#39;/\u0026#39;,\u0026#39;_\u0026#39;)+\u0026#39;.csv\u0026#39;, \u0026#39;w\u0026#39;) as f: for pgn in pgns: f.write(pgn) Now a pgn looks something like this if it\u0026rsquo;s just printed as a string:\nIt contains lots of very useful info but for our purposes of finding en passant checkmates, we would ideally just have a list of each move looking something like this:\nmoves = [ \u0026#39;e4\u0026#39;, \u0026#39;e5\u0026#39;, \u0026#39;Bc4\u0026#39;, \u0026#39;Nc6\u0026#39;, \u0026#39;Qh5\u0026#39;, \u0026#39;Nf6\u0026#39;, \u0026#39;Qxf7#\u0026#39;] We don\u0026rsquo;t need the headers, we don\u0026rsquo;t need the result, and we don\u0026rsquo;t really need the move numbers (these can be deduced from the list indexes). So the challenge is how to convert the pgn to a list; this is the slightly janky solution I came up wtih.\ndef get_move_list(pgn): x = pgn.split() moves = [] for item in x: # start fresh list at move 1 - effectively skipping the headers from the list if item == \u0026#39;1.\u0026#39;: moves = [] moves.append(item) # gets rid of clock bits and bobs elif item[0] == \u0026#39;{\u0026#39; or item[-1] == \u0026#39;}\u0026#39;: pass else: moves.append(item) #remove even indexes from list #this gets rid of move numbers and the result of the game del moves[::2] return moves I don\u0026rsquo;t doubt it could be done more elegantly but it works I guess. Next time, we\u0026rsquo;ll deal with working out what a list containing an en passant checkmate would look like.\n","summary":"\u003cp\u003eLast time we worked out how to get info for all the games played by titled players in a particular month. Today, we have three objectives:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eParse this info for the pgn (portable game notation) of each game.\u003c/li\u003e\n\u003cli\u003eWrite these to a file so we dont have to spend forever downloading them everytime we run the script.\u003c/li\u003e\n\u003cli\u003eDevise a way to convert this pgn to a more convenient pythonic format so we can analyse it later.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eFirst of all, I wrote a little function to get the pgn from the games we downloaded. I added this KeyError exception, but if I\u0026rsquo;m honest I\u0026rsquo;m not sure why I was getting this error. Maybe, chess.com doesn\u0026rsquo;t store pgn for all games? I don\u0026rsquo;t know.\u003c/p\u003e","title":"The search for en passant checkmates 2: Electric Boogaloo","url":"https://nonsense.dymc.win/the-search-for-en-passant-checkmates-2-electric-boogaloo/"},{"content":"The chess.com API gives you access to a crazy amount of data on games played on the site. Armed with the knowledge that this data was at my fingertips, I set out to do what any sane person would do: find en passant checkmates. For those not in the know, en passant check mate is kind of the king of moves in chess meme circles. So some sort of python script that identified en passant check mates that occured on the site would be of great value to me.\nFirst things first, I would need a method of grabbing lots of games from the api. This would be achieved by looking at players on the site and searching their game archives. As I couldn\u0026rsquo;t think of any obvious way to get completely random players on the site, I used the API\u0026rsquo;s lists of all titled players (GM, IM, WIM, etc.) on the site. This is what I came up with -\u0026gt;\ndef get_archive_urls(titled_urls): players = [] for url in titled_urls: title_list = requests.get(url).json() title_list = title_list[\u0026#39;players\u0026#39;] players.extend(title_list) archive_urls = [] for username in players: games = \u0026#39;https://api.chess.com/pub/player/\u0026#39; + username + \u0026#39;/games/2022/05\u0026#39; archive_urls.append(games) return archive_urls get_archive_urls([ \u0026#39;https://api.chess.com/pub/titled/GM\u0026#39;, \u0026#39;https://api.chess.com/pub/titled/WGM\u0026#39; ]) This function reads a list of urls, gets a list of all the usernames from the api and then inserts this username into a new url which will allow us to access their games from a particular month. I then returns a list of all of these game archive urls.\nThe next order of business is taking this list of urls and turning it into a list of games. It looks quite similar to the previous example -\u0026gt;\ndef grab_games(archive_urls): games = [] for url in archive_urls: archive = requests.get(url).json() archive_games = archive[\u0026#39;games\u0026#39;] games.extend(archive_games) return games Feeding the first function into the second -\u0026gt;\ngrab_games(get_archive_urls([ \u0026#39;https://api.chess.com/pub/titled/GM\u0026#39;, \u0026#39;https://api.chess.com/pub/titled/WGM\u0026#39; ])) We get a very long list of json objects (is that the right phrase? um). Each corresponding to one of games played by GMs and WGMs on chess.com during May of 2022. Come back next time to see what we can do with this very long list. Here\u0026rsquo;s a taster of what the list looks like printed to a terminal - lots of possiblities.\n","summary":"\u003cp\u003eThe chess.com API gives you access to a crazy amount of data on games played on the site. Armed with the knowledge that this data was at my fingertips, I set out to do what any sane person would do: find en passant checkmates. For those not in the know, en passant check mate is kind of the king of moves in chess meme circles. So some sort of python script that identified en passant check mates that occured on the site would be of great value to me.\u003c/p\u003e","title":"The search for en passant checkmates","url":"https://nonsense.dymc.win/the-search-for-en-passant-checkmates/"},{"content":"As a man who finds himself reinstalling his OS more than is probably sensible, any opportunity to minimise the post install admin of sorting out all your settings is an attractive one. With that in mind lets take a look at some of the firefox (my current browser of choice) configuration options avilable to you through home-manager. This assumes you have some sort of home-manager setup working. If you do not I found this friendly githubber\u0026rsquo;s templates to be very helpful.\nFirst of all you\u0026rsquo;ll need to enable firefox with programs.firefox.enable = true;\nEXTENSIONS This will require having the NUR (nix user repo) enabled. But once you do, you can configure any extension you want to be auto installed with something like this:\n{pkgs, ... }: let addons = pkgs.nur.repos.rycee.firefox-addons; in { programs.firefox = { extensions = with addons; [ ublock-origin bitwarden darkreader ]; }; } This is the list of all extensions available in the repo.\nBOOKMARKS Bookmarks can be added per profile. The format for it goes something like this:\nprofiles.james = { bookmarks = [ { name = \u0026#34;best website ever!\u0026#34;; url = \u0026#34;https://jdysmcl.xyz\u0026#34;; } { name = \u0026#34;best OS ever\u0026#34;; url = \u0026#34;https://nixos.org\u0026#34;; } ]; }; SETTINGS Again, these can be added per profile. Basically, any option you can find in about:config can be added here; this is a selection of potentially useful options I have set:\nprofiles.james = { settings = { #newtab stuff \u0026#34;browser.startup.homepage\u0026#34; = \u0026#34;https://searx.jdysmcl.xyz\u0026#34;; \u0026#34;browser.newtabpage.enabled\u0026#34; = false; \u0026#34;browser.newtabpage.activity-stream.enabled\u0026#34; = false; #some firefox features i don\u0026#39;t really want \u0026#34;extensions.pocket.enabled\u0026#34; = false; \u0026#34;extensions.formautofill.creditCards.enabled\u0026#34; = false; \u0026#34;identity.fxaccounts.enabled\u0026#34; = false; \u0026#34;signon.rememberSignons\u0026#34; = false; \u0026#34;browser.search.suggest.enabled\u0026#34; = false; #some privacy stuff \u0026#34;privacy.resistFingerprinting\u0026#34; = true; \u0026#34;privacy.trackingprotection.enabled\u0026#34; = true; \u0026#34;dom.security.https_only_mode\u0026#34; = true; }; }; Of course I am sure there are many more exciting things that could be done here but this is as far as I have got. For all avilable options you can check out this or alternatively run a man home-configuration.nix. Hope this has been helpful :)\n","summary":"\u003cp\u003eAs a man who finds himself reinstalling his OS more than is probably sensible, any opportunity to minimise the post install admin of sorting out all your settings is an attractive one. With that in mind lets take a look at some of the firefox (my current browser of choice) configuration options avilable to you through home-manager. This assumes you have some sort of home-manager setup working. If you do not I found \u003ca href=\"https://github.com/misterio77/nix-starter-configs\"\u003ethis\u003c/a\u003e friendly githubber\u0026rsquo;s templates to be very helpful.\u003c/p\u003e","title":"Declarative firefox config with home-manager on nixos","url":"https://nonsense.dymc.win/declarative-firefox-config-with-home-manager-on-nixos/"},{"content":"I didn\u0026rsquo;t know you could do this until recently, very fun and playful little feature. How you want to do it will depend slightly on how you have your groups set up but I start with importing the relevant libraries and defining an empty list.\nfrom libqtile.config import Dropdown, Scratchpad groups = [] I\u0026rsquo;m then able to append all the groups I want to this list. For the dropdown terminal you need the ScratchPad group which to quote the qtile docs is a \u0026ldquo;special - by default invisible - group which acts as a container for DropDown configurations\u0026rdquo;. My configuration looks like this:\ngroups.append( ScratchPad( \u0026#34;scratchpad\u0026#34;, [ DropDown( \u0026#34;term\u0026#34;, kitty, opacity = 0.9, ), ] ), ) This gives you a terminal (kitty in this case) with a little tranparency. By default, it will pop up with this size:\nThough this can easily be altered with the x, y, height, and width keys:\ngroups.append( ScratchPad(\u0026#34;scratchpad\u0026#34;, [ DropDown( \u0026#34;term\u0026#34;, kitty, opacity = 0.9, x = 0, y = 0, width = 0.3, height = 0.5, ), ]) ) This gives us a little boxy guy in the top left corner:\nWe also have the option to set keybindings to toggle the appearance of the window. I\u0026rsquo;ve got this in my config.py now:\nkeys = [ Key([m, \u0026#34;shift\u0026#34;], \u0026#34;Return\u0026#34;, lazy.group[\u0026#34;scratchpad\u0026#34;].dropdown_toggle(\u0026#34;terminal\u0026#34;), desc=\u0026#39;dropdown term\u0026#39; ), ] Anyway, hope this was useful, happy configurating :)\n","summary":"\u003cp\u003eI didn\u0026rsquo;t know you could do this until recently, very fun and playful little feature. How you want to do it will depend slightly on how you have your groups set up but I start with importing the relevant libraries and defining an empty list.\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-python\" data-lang=\"python\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"kn\"\u003efrom\u003c/span\u003e \u003cspan class=\"nn\"\u003elibqtile.config\u003c/span\u003e \u003cspan class=\"kn\"\u003eimport\u003c/span\u003e \u003cspan class=\"n\"\u003eDropdown\u003c/span\u003e\u003cspan class=\"p\"\u003e,\u003c/span\u003e \u003cspan class=\"n\"\u003eScratchpad\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"n\"\u003egroups\u003c/span\u003e \u003cspan class=\"o\"\u003e=\u003c/span\u003e \u003cspan class=\"p\"\u003e[]\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eI\u0026rsquo;m then able to append all the groups I want to this list. For the dropdown terminal you need the ScratchPad group which to quote the \u003ca href=\"https://docs.qtile.org/en/latest/manual/config/groups.html\"\u003eqtile docs\u003c/a\u003e is a \u0026ldquo;special - by default invisible - group which acts as a container for DropDown configurations\u0026rdquo;. My configuration looks like this:\u003c/p\u003e","title":"Upgrade your qtile setup with a cute dropdown terminal","url":"https://nonsense.dymc.win/upgrade-your-qtile-setup-with-a-cute-dropdown-terminal/"},{"content":"There are lots of music players on linux. I have used lots of them, I quite like some of them. But for some reason I decided I wanted more. With this in mind, over the past few months I have been constructing a sprawling ecosystem of bash scripts all geared towards delivering a customised listening experience tailored perfectly to my every need. In short, the setup uses a simple dmenu file manager to browse my local files and mpv to play them. Today I\u0026rsquo;ll be talking specifically about my setup for recording the albums I\u0026rsquo;ve been listening to.\nLET\u0026rsquo;S GET DOWN TO BUSINESS Whenever I select a file to be played with my script I am effectively selecting a path to a file or a path to a directory with files in it which is then fed to mpv. For example, if I\u0026rsquo;m playing the classic album Lemonade by Beyonce it would look like this:\n/home/randy/music/Beyonce/Lemonade/\nTo append this path to a file called scrobble while removing the first three directories (or the first 18 characters) rather inelegantly:\nprintf \u0026#34;%s\u0026#34; \u0026#34;$selected_path\u0026#34; | cut -c 18- \u0026gt;\u0026gt; scrobble As new paths are appended to the file, this will will result in a scrobble file made up of three columns: the first for artists, the second for albums, and the third for songs.\nAbdullah Ibrahim/South Africa Darkside/Psychic SOPHIE/OIL OF EVERY PEARL\u0026#39;S UN-INSIDES Nicolas Jaar/Space Is Only Noise/2 Colomb.flac Townes Van Zandt As you can see here, unless you only play music song by song, not all columns will always be populated. Now we have a file that contains this information we can do stuff to it. For example, to show our listening history and display it in columns with some pretty labels:\ntac scrobble | column -t -s \u0026#34;/\u0026#34; -N \u0026#34; ,artist,album,track\u0026#34; Maybe you only want the last ten things you listened to:\ntail -n 10 scrobble | column -t -s \u0026#34;/\u0026#34; -N \u0026#34; ,artist,album,song\u0026#34; To find our most played atrists it\u0026rsquo;s a little more complicated. We can use awk to extract the artist column and remove all duplicate entries with sort -u to get a list of all played artists to iterate over. Then for each unique artist we grep for instances of them in the artist column and append that number of instances and the artist to a temporary file. This can then displayed as you see fit:\nfor album in $(awk -F/ \u0026#39;{ print $2 }\u0026#39; scrobble | sort -u) do echo \u0026#34;\u0026#39;$album\u0026#39;/\u0026#34;$(awk -F/ \u0026#39;{ print $2 }\u0026#39; \u0026#34;$scrob_file\u0026#34; | grep $album | wc -l)\u0026#34;\u0026#34; \u0026gt;\u0026gt; temp done So these are just a few examples; the real point is once you have that file of three columns the world is your oyster. You could probably even use something a little less cumbersome such as python.\nFinally, disclaimer: I am a bash amateur so I hope nothing you\u0026rsquo;ve seen here was too upsetting. Lots of love x\n","summary":"\u003cp\u003eThere are lots of music players on linux. I have used lots of them, I quite like some of them. But for some reason I decided I wanted more. With this in mind, over the past few months I have been constructing a sprawling ecosystem of bash scripts all geared towards delivering a customised listening experience tailored perfectly to my every need. In short, the setup uses a simple dmenu file manager to browse my local files and mpv to play them. Today I\u0026rsquo;ll be talking specifically about my setup for recording the albums I\u0026rsquo;ve been listening to.\u003c/p\u003e","title":"Rudimentary local scrobbling with bash","url":"https://nonsense.dymc.win/rudimentary-local-scrobbling-with-bash/"},{"content":"This is a place to document bits and bobs I\u0026rsquo;ve been up to that have interested me. Expect linux and self-hosting tinkering, some novice programming, and maybe the occasional recipe. I tend to be a fool so take anything written here with a pinch of salt :)\nrss feed here!\n","summary":"\u003cp\u003eThis is a place to document bits and bobs I\u0026rsquo;ve been up to that have interested me.\nExpect linux and self-hosting tinkering, some novice programming, and maybe the occasional recipe.\nI tend to be a fool so take anything written here with a pinch of salt :)\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"../index.xml\"\u003erss feed here!\u003c/a\u003e\u003c/p\u003e","title":"","url":"https://nonsense.dymc.win/info/"}] |