Notes

Elisp let bounding

In summary, setq in let doesn’t affect global variable scope. (setq test-value 1) ;; => 1 (let ((test-value 2)) (print test-value) (setq test-value 10) (print test-value)) ;; => 2 ;; => 10 (print test-value) ;; => 1

Elisp change a value in a list

In elisp, you can use setf to change a “generalized variables”. In this way you can change a value in a list. To my understanding, a “generalized variable” is some value “of another value”. Usage of setf: (setf PLACE VAL PLACE VAL ...) PLACE is the place to be set, which should be a generalized variable. Following functions can produce a “generalized variable” and fit into PLACE: (according to http://www.delorie.com/gnu/docs/emacs/cl_16.html)

SSH and keys

This article shows how to setup ssh key and login to your server with it. Reason It is safer than passwords. Generate keys ssh-keygen It generates two files in ~/.ssh/ if you don’t change the default value in prompt. Private key is id_rsa .This is the “key”, which you should keep secret and save. Public key is id_rsa.pub. This is the one you send everybody. Copy keys to remote server Before copying, check the permission of your private key.

Make file icons for a particular application (Emacs)

I’m doing this for Emacs, but the process can apply to any application. Also this is mainly for macOS since it relate file icons to a default application, rather than a systemwise register like what Windows does. Template file First you need a “template” file, I use a svg file because it can be edited by a text editor. That makes scripting really easy. Here is the template, I skip the photoshop part since it’s not related.

Moody configuration

Moody is a pretty yet simple mode-line package of emacs. However, it doesn’t come with any examples of configuration. I’ll explain how does moody works with my config. It looks like this: Basically each construct is (:eval (moody-tab STRING WIDTH UP/DOWN)). And that’s all. moody-tab will turn your string into a “tab”, which is something like this: By default, a tab will have the same background color of your page (I mean (face-attribute 'default :background)).

Open current dir in iTerm2

open current dir in Emacs in iTerm2 (defun moon/open-in-iterm () "Open current current dir in iTerm2." (interactive) (shell-command-to-string (format "open %s -a iterm" default-directory))) open current dir in Finder in iTerm2 copy this app object to anywhere and commad+drag to finder toolbar. The app is just a automater script: on run {input, parameters} tell application "Finder" set dir_path to quoted form of (POSIX path of (folder of the front window as alias)) end tell do shell script ({"open ", dir_path, " -a iterm"} as string) end run It gets the current dir in Finder and open it with open in commandline.

How to package a python module

ref: https://packaging.python.org/tutorials/distributing-packages/#description setup.py example code: from setuptools import setup setup( name='launchdman', version='0.1.2', description='The launchd parser and manager for Python', long_description= # follow rst format '''launchdman is a parser and manager for launchd, the service management framework used by macOS. If you want to schedule to run certain tasks or programs, or run them in certain conditions, launcd is what you use on macOS. launchdman lets you build your configurations and manage(add, remove, group, etc) them on the fly.

Good books

The Practice of Programming by Brian W. Kernighan and Rob Pike. Have you ever… wasted a lot of time coding the wrong algorithm? used a data structure that was much too complicated? tested a program but missed an obvious problem? spent a day looking for a bug you should have found in five minutes? needed to make a program run three times faster and use less memory? struggled to move a program from a workstation to a PC or vice versa?

tilling windows manager for macOS

Chunckwm is a nice tilling windows manager for macOS. https://github.com/koekeishiya/chunkwm How to configure this desktop Install To install it, use homebrew: brew tap crisidev/homebrew-chunkwm # stable version brew install chunkwm # HEAD brew install --HEAD chunkwm # start the service brew services start chunkwm # other avaliable options are restart and stop chunckwm is made of several modules and works in a client-server structure: chunkwm-core core chunkwm-tiling provides tiling functions chunckwm-boder show a highlight border of current active window chunkwm-ffm provides window follow mouse function Configuration Configuration is in ~/.