vEnhance's avatar
Hacking Page 1 of 1

Oct 31, 2024

🖉 Hangul spellcheck for Vim

There’s got to be a better way to do this. Someone please enlighten me.

Modern Korean is written in 한글 (Hangul), which uses a syllabic alphabet. It includes spaces between words, unlike Chinese or Japanese, which means that it’s possible to have meaningful spellchecking.

So of course one day I decided I wanted to configure Vim to support spellchecking Hangul. Unfortunately, there’s no file ko.utf-8.spl at ftp.vim.org, and in a cursory search I couldn’t find an.

On the other hand, the hunspell tool does have a Korean dictionary, and there’s a PKGFILE provided for ARCH, so by running pikaur -S hunspell-ko I was able to obtain the files

  • /usr/share/hunspell/ko_KR.aff
  • /usr/share/hunspell/ko_KR.dic.

In theory, if you then run the Vim command

:mkspell /tmp/ko /usr/share/hunspell/ko_KR

then Vim would create the file …

Read more...

Nov 18, 2022

🖉 Why Evan does not like JavaScript as a first language

Some people have asked me why I anti-recommend JavaScript for beginners on my website FAQ. This post will try to give a few reasons why.

Some notes:

  • I’m referring to base JS. I like TypeScript a lot for example (it’s high on my tier list of programming languages for beginners). And I know about eslint, but you asked me about recommendations for beginners, and I think beginners shouldn’t have to worry about setting up an IDE with strict linting until after they can write a for loop by themselves without screwing up.
  • I have multi-file projects in mind. I don’t have a problem with using inline JavaScript for tiny 20-line snippets of code embedded in a webpage.
  • I’m an amateur programmer. Professional programming is a different ball game.

Weak typing

I’m clumsy. I make many more mistakes than the average programmer. The other day …

Read more...

Dec 14, 2016

🖉 SysRq on Arch Linux Mac Mini

This post documents my adventures of getting the SysRQ key working on my Mac Mini and Macbook (both running Arch Linux). The suggestions of loadkeys and keyfuzz that are the first search entries don’t work for me, so some more sophisticated black magic was necessary.

Remapping the Fn keys

This step is technically optional, but I did it because the function keys are a pain anyways. Normally on Apple keyboards one needs to use the Fn key to get the normal Fn keys to behave as a F<n> keystroke. I prefer to reverse this behavior, so that the SysRq combinations is Alt+F13+F rather than Fn+Alt+F13+F, say.

For this, the advice on the Arch Wiki worked, although it is not thorough on some points that I think should’ve been said. On newer kernels, one does this by creating the file /etc/modprobe.d …

Read more...

Nov 10, 2016

🖉 DNSCrypt Setup with PDNSD

Here are notes for setting up DNSCrypt on Arch Linux, using pdnsd as a DNS cache, assuming the use of NetworkManager. I needed it one day since the network I was using blocked traffic to external DNS servers (parental controls), and the DNS server provided had an outdated entry for hmmt.co. (My dad then pointed out to me I could have just hard-coded the necessary IP address in /etc/hosts, oops.)

For the whole process, useful commands to test with are:

  • nslookup hmmt.co will tell you the IP used and the server from which it came.
  • dig www.hmmt.co gives much more detailed information to this effect. (From bind-tools.)
  • dig @127.0.0.1 www.hmmt.co lets you query a specific DNS server (in this case 127.0.0.1).
  • drill @127.0.0.1 www.hmmt.co behaves similarly.

First, pacman -S pdnsd dnscrypt-proxy (with …

Read more...

Apr 03, 2016

🖉 Shifting PDF's using gs

Some time ago I was reading the 18.785 analytic NT notes to try and figure out some sections of Davenport that I couldn’t understand. These notes looked nice enough that I decided I should probably print them out, But much to my annoyance, I found that almost all the top margins were too tiny, and the bottom margins too big. (I say “almost all” since the lectures 19 and 24 (Bombieri proof and elliptic curves) were totally fine, for inexplicable reasons).

Thus, instead of reading Davenport like I told myself to, I ended up learning enough GhostScript flags to write the following short script, which I’m going to share today so that other people can find better things to do with their time.

#!/bin/bash
for file in $@
  do
    echo "Shifting $file ..."
    gs \
      -sDEVICE=pdfwrite \
      -o shifted-$file \
 -dPDFSETTINGS=/prepress \
 -c "<</PageOffset [0 -36]>> setpagedevice" \
 -f $file …
Read more...

Oct 25, 2015

🖉 Git Aliases

For Git users:

I’ve recently discovered the joy that is git aliases, courtesy of this blog post. To return to the favor, I thought I’d share the ones that I came up with.

For those of you that don’t already know, Git allows you to make aliases – shortcuts for commands. Specifically, if you add the following lines to your .gitconfig:

[alias]
    cm = commit
    co = checkout
    br = branch

Then running git cm will expand as git commit, git co master is git checkout master, and so on. You can see how this might make you happy because it could save a few keystrokes. But I think it’s more useful than that – let me share what I did.

The first thing I did was add

pu = pull origin
psh = push origin

and permanently save myself the frustration of forgetting to type origin. Not bad. Even more helpful was …

Read more...

Oct 07, 2014

🖉 Arch Linux on a Mac Mini

This post briefly outlines the process of setting up a dual boot OSX and Arch Linux on a Mac Mini. This is mostly for my reference in the likely event that I will be doing anything similar in some years, so it assumes some competence; fortunately, the Arch Wiki’s Beginner’s Guide probably fills in any gaps I left out. Obligatory Disclaimer: Use at your own risk or not at all.

This is almost the same as any other installation of Arch Linux, with a few changes that took some hours of frustration to figure out because of the EFI booter. My method is to create the partitions in Disk Utility, install rEFInd, and then install the grub bootloader into /dev/sda1.

Setup done in OSX

  1. First, install rEFInd. This worked out of the box for me, and makes it possible to boot via USB.
  2. Create a Arch Linux …
Read more...

Feb 01, 2014

🖉 PDF Compression

I always scan copies of letters into my computer before I send them out. So I had a bunch of large PDF’s sitting around hogging my Dropbox space.

One day I found this blog post which claimed that simply running (in Bash) the commands

$ pdf2ps original.pdf temp.ps
$ ps2pdf temp.ps new.pdf

would decrease the file size. (The two commands are part of GhostScript, which I had installed on my Linux boxes anyways.) I couldn’t resist trying it – and miraculously, it worked. It generally decreases my scans by a factor of 10 (from 20MB to 2MB or so).

I have no clue why this works, although it probably has something to do with the fact that the PDF’s are scanned pages . Anyone care to enlighten me?

Hacking Page 1 of 1