Showing posts from September, 2017

En Dash with ComposeKey (Shift+AltGr)

AltGr is short for "alternative grammar". It doesn't do much on Windows, outside of adding acute accents to vowels and turning '4' into '€'. On Linux it does a much wider variety of things and more things still with 'AltGr+Shift', just give it a try. It's not just for foreign characters but also fractions and arrows. There is also a program called ComposeKey , which Ubuntu and probably many other distros, comes with automatically. If you type 'Shift+AltGr' the next few characters you type will be composed into  a character that sort of resembles that combination e.g. Shift+AltGr, s, s => ß  and Shift+AltGr, =, > => ⇒ . You can alter the config for combinations here:   /usr/share/X11/locale/en_US.UTF-8/Compose  (or similar). Although 3 hyphens does make an 'em dash', 2 hyphens doesn't make an 'en dash'. What I didn't realise until I looked in the config file was that you need 2 hyphens followed by

Mass File Renaming

The rename command uses a regular expression to modify a list of files given to it. The regular expression is formatted like as with  sed  i.e. rename 's/find/replace/' file1 file2 file3 It's installed by default.

Internal Domain Names

You can edit /etc/hosts/  to add domain names and which IP addresses they refer to. Any IP address through to "loop back" to the machine itself. [x] Apache2 listens to anything coming to the machine itself regardless of IP Address, then the configs in /etc/apache2/sites-enabled  are used to decide what to do based on the domain name used. So any domains that loop back can be used to access separate internal sites by whatever name you like. /etc/hosts/ can only contain IP addresses that refer to the machine itself, so unfortunately you can't visit via

'git add' Part of a File

It's the kind of thing you would assume is too good to be true. It's a more advanced feature and so most people don't get taught it when introduced to 'git'. git add [-p | --patch] I remember it as -p for partial, but never mind . It brings up a small interface that displays one hunk of code at a time. The question mark command will explain how to use it.  However it's not obvious that 'e' for 'edit' allows you to edit which changes are made rather than edit the changes themselves. It opens up what looks like a 'git diff', where you remove changes you don't want to 'git add' by removing '+' lines or removing the '-' in front of lines to be taken away. i.e. choosing which '+' to add and which '-' to add. Anyway if you're adding part of a file, if you have access to a GUI, it's going to be easier to do it that way.

'scp' Outside of Userspace

When performing for the first time a command such as scp ./src user@url:dir , one immediately learns that the directory after the colon is relative to "user's" home folder. So one assumes that if you write scp ./src user@url:/dir ,   the string "/dir" will be concatenated to "user's" home directory path and therefore still refer to the contents of the home directory. However this isn't the case; "/dir" will refer to "dir" at the file system's root. So scp can be used to modify any part of a file system so long as the permissions are right.

Rsync Remote Sync and Folder Merging

The 'r' in 'rsync' Stands for Remote I knew that you were able to sync folders such as with a USB but it I didn't realise that you can synchronise folders with a server, including those in your ~/.ssh/config . You just need to put a colon after the name so it knows it's not a directory. Good Defaults and a Million Options When I first used rsync I copied a very long command from Stack Overflow, having read what each argument was for and deciding well this is going to take ages to learn. I'll wait until I need this tool again so I don't forget. When I went to use it again, I had a look at the manpage. It turns out that -a (short for archive) does basically everything you need; it's short for -rlptgoD . I've seem some examples online that use those letters in combination with -a unnecessarily. This looks daunting but in fact only does the following: -r recursive -l copying symlinks as symlinks preserve file metadata: -p perm

Apache2 Port Rerouting

I wanted to run a server written in NodeJS and have it accessible on localhost port 80 without having to run the server as root (because ports below 1024 iirc are reserved). You can get the server to listen on a different port such as 8080. You need to ask Apache to send anything it receives on 80 to 8080 and also anything going out of 8080 to go out of 80. If you look online for an explanation for how to do this, often people will show code without an explanation of where it goes and some will reference a httpd.conf file, which didn't even exist on my machine. I'm running Ubuntu 16.04. Things may be different on your machine. 1. Add the module that allows rerouting sudo a2enmod proxy_http 2. Set up the config /etc/apache2/sites-available has a number of config files for websites, including 000-default.conf , which is the default. Apache2 only looks at the config files in /etc/apache2/sites-enabled . This folder should contain symlinks to sites-available . Y