TIL: polling rates for keyboards

I was setting up my GMMK Pro keyboard over the weekend and I ran into an interesting feature in the Glorious Core software, “polling rate” which is the first time I’ve seen this feature.

I went looking around and from reddit I got linked to this Geekhack thread: Keyboard polling rate

Simply put, the keyboard’s polling rate is at what frequency the computer checks for input from the keyboard. Since this keyboard is meant for gaming, it of course comes with the ability to change it from 125hz to 1000hz.

1000hz refers to every 1 milliseconds.

125hz refers to every 8 milliseconds.

Local .vimrc for neovim settings and differences

For directory-specific vim settings, you can use .vimrc but when using neovim, you’ll need to use .nvimrc instead.

To get it all working, add the following to your init.nvim file:

set exrc
set secure

Using set secure will disable/disallow using autocmd settings

In the directory with vim settings, add an .nvimrc file.

I was struggling with this b/c I was using .vimrc for neovim which didn’t work for me.

Running a local docker instance for WordPress theme development

I wanted to update the Leaf theme (the one I’m currently using) and I haven’t had wordpress on my computer in a long time.

Instead of going through the whole set up again, I decided to use docker for this.

I wanted to keep the setup to a minimal and also make it portable for future use, below are the steps you’ll need to get it running.

  1. Install Docker (I’m on mac, so I just have the docker app).
  2. Make a directory that you can call something like wordpress-docker, this is where the docker-compose.yml file will live.
  3. Add the following to the docker-compose.yml file:
version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: password
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - wordpress:/var/www/html
      - ../leaf:/var/www/html/wp-content/themes/leaf # --- this assumes we have leaf one dir up


  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: password
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

4. Start up the docker instances by running docker-compose up (from within wordpress-docker)

5. Go to localhost:8080, you should see the wordpress instance.

6. After the setup is complete, go to localhost:8080/wp-admin/themes.php and you should see the theme for development too.

TIL: tempfile in ruby, use it for easy garbage collection afterwards

Today, I was working on a script at work where I ultimately needed to export a 2MB file and although this isn’t a large file, I know I will forget about getting rid of it so while searching around, I came across tempfile.

Tempfile simply will be garbage collected at some time because the file is stored in /tmp and you can make your own copy if you need it. Here’s an example from the ruby docs:

require 'tempfile'

file = Tempfile.new('foo')
file.path      # => A unique filename in the OS's temp directory,
               #    e.g.: "/tmp/foo.24722.0"
               #    This filename contains 'foo' in its basename.
file.write("hello world")
file.rewind
file.read      # => "hello world"
file.close
file.unlink    # deletes the temp file

Make sure to run file.unlink if you want it to be deleted right away.

Using Numi app for calculations

I’ve used the Calculator app on the iPhone for as long as I’ve had a smartphone and I think on the computer, it’s a weird thing that’s been missing for a long time. Recently, Apple brought the Calculator app to Mac but I don’t think it’s as useful as I want it to be so I recently discovered an app called Numi.

https://numi.app/

It’s a super simple app that just works and the best part about it is that it supports setting variables and making conversions between many units extremely easy.

Here’s an example of a time difference comparsion:

Using the correct divisors is amazing in this app. So on mac you can use / or alt + / to type out รท, Numi handles both of these the same way.

Some more examples: