This post is in Swiss German for obvious reasons.
I han chrüzlech so ne ultra-cooli Mac-Alu-Taschtatur übercho. En Mac-Mini hani scho, aber MacOS hani ned wölle... Ubuntu funktioniert rächt guet uf Mac-Hardware. Die folgendi Aaleitig sött aber ou for Mac-Taschtature a nid-Macs funktioniere.
Mac-Tastatur aschliesse: d'Helfti vo de Taschte sind falsch beleit. Compi unbruchbar.
Ubuntu> sudo dpkg-reconfigure keyboard-configuration
-> "Generische PC-Tastatur mit 105 Tasten (Intl)"
-> Swizerland
-> Switzerland - Deutsch (Schweiz, Macintosh)
-> Der Standard für die Tastenbelegung
-> Keine Compose-Taste
Denn neu boote (Login isch ned gnueg).
Erklärig: De Trick isch die erschti Iischtellig "Generischi 105-Taschte", und nid öppe "Macintosh", wie me jo vermuete chönnt.
Jetzt chunnt no d'Fiinarbet.
Es sind no zwöi Taschte vertuuscht: Paragraph/Grad linggs obe, und grösser/chliner linggs unde. Die chamer zom Biispil so tuusche:
echo "keycode 49 = less greater less greater lessthanequal greaterthanequal lessthanequal" >> .Xmodmap
echo "keycode 94 = section degree section degree NoSymbol NoSymbol NoSymbol NoSymbol section degree NoSymbol NoSymbol section degree" >> .Xmodmap
echo /usr/bin/xmodmap $HOME/.Xmodmap >> .xinitrc
Jetz sind alli Symbol uf de richtige Taschte. Leider sind aber nid alli aagschribe. Als Programmierer fähled mir do extrem wichtegi Symbol wie: gschweifti und eggigi Chlammere, Backslash, Tilde usw.
Mit Mac-Benutzer diskutiere nützt nüt. Die findet das guet. Sie chönnd ihre Taschte usswändig und findet, wer das nid chönn, söll sich doch en PC choufe, oder wenigschtens e Logitech-Taschtatur. Mac-User sind e Ploog.
Ich ha drum en wasserunlösliche Folieschriiber gnoh und folgendi Taschte annotiert:
N: Tilde
S: Doppel-S ("esszett")
3: Gartehaag
5: offni eggigi Chlammere
6: gschlossni eggigi Chlammere
7: sänkrächte Strich (unde), Backslash (obe)
8: offni gschweifti Chlammere
9: gschlossni gschweifti Chlammere
fn: Insert
Pfiil lings ufe: Home
Pfiil rächts abe: End
Jetz isch die Taschtatur einigermasse bruuchbar, wemme sich merkt, dass me die undere Symbol mit der rächte "alt"-Taschte erreicht, die obere Symbol mit rächts-alt-Shift.
S'isch echli blöd, dass me für eis vo de meischtbenützte Symbol, de Backslash, grad drüü Taschte gliichziitig trücke mues. Vilich mach ich mer do schpäter ou no en "modmap".
Wiitere Knackpunkt: alt-Space macht nid öppen es normals Läärzeiche wie die normal PC-Taschtatur, sondern es Unicode-Läärzeiche, wo uusgseeht wienes normals, aber imene Programm-File zum Biischpil es Riesen-Unheil aarichte chann:
> file prog.c
prog.c: C source, UTF-8 Unicode text
Das git Ärger. Such die Ziile mitem Unicode-Läärzeiche:
> grep -P "[\x80-\xFF]" prog.c
und ersetzes
> vi prog.c
> file prog.c
prog.c: C source, ASCII text
grettet!
2016-09-06
Extract subversion metadata directly from checkout, without subversion tools
Hello readers!
By now, you suspect that I am an avid subversion user, or at least a professional programmer, so yes. I might as well admit it.
The following trick is not for the showroom. I had to work with incompatible subversion versions. It usually is a pain to work with different versions of subversion. Checkouts are incompatible.
Anyway, I had to find the author and revision number of the last commit in a given checkout, without having the proper subversion command line tool at hand. It can be done, because subversion metadata resides in a sqlite3 database in the .svn directory.
This is the magic incantation:
sqlite3 .svn/wc.db "select changed_author,changed_revision from NODES order by changed_revision desc limit 1;"
There are many other interesting items to be found in .svn/wc.db and the database schema seems to be fairly stable since subversion 1.6 or so.
By now, you suspect that I am an avid subversion user, or at least a professional programmer, so yes. I might as well admit it.
The following trick is not for the showroom. I had to work with incompatible subversion versions. It usually is a pain to work with different versions of subversion. Checkouts are incompatible.
Anyway, I had to find the author and revision number of the last commit in a given checkout, without having the proper subversion command line tool at hand. It can be done, because subversion metadata resides in a sqlite3 database in the .svn directory.
This is the magic incantation:
sqlite3 .svn/wc.db "select changed_author,changed_revision from NODES order by changed_revision desc limit 1;"
There are many other interesting items to be found in .svn/wc.db and the database schema seems to be fairly stable since subversion 1.6 or so.
2016-09-02
following code through history, in subversion and git
Both, git and subversion, have the famous "blame" command, which allows me to see, line by line, who changed this line of code last.
Sometimes it is not the latest modifier of a line who is its true author. For example when a programmer added or removed whitespace for better readability, she will then be "blame"d as it's author, even though she is not.
In this case, it is possible to give the blame command an additional agrument, saying "look at the file in this revision, and tell me who brought it up to that state, line by line".
in subversion:
$svn blame filename
649 joe today's code
$svn blame filename -r648
171 jim previous code
$svn blame filename -r170
svn: Unable to find repository location for 'filename' in revision 170
in git:
$ git blame filename
3c9fb2a17 (Joe 2016-09-01 16:43:11 +0200 1) today's code
$ git blame filename 3c9fb2a17^
98bcec40b (Jack 2016-06-23 18:04:55 +0200 1) previous code
$ git blame filename 98bcec40b^
fatal: no such path filename in 98bcec40b^
Note the caret (^) you have to add to the end of the git hash. It means "the previous commit from that designated by the hash". In subversion, where everything is nicely ordered, you simply subtract one in order to get the same effect.
One day I might write a script that traces the history of a single line of code back to its creation. Please tell me if this has already been done.
Sometimes it is not the latest modifier of a line who is its true author. For example when a programmer added or removed whitespace for better readability, she will then be "blame"d as it's author, even though she is not.
In this case, it is possible to give the blame command an additional agrument, saying "look at the file in this revision, and tell me who brought it up to that state, line by line".
in subversion:
$svn blame filename
649 joe today's code
$svn blame filename -r648
171 jim previous code
$svn blame filename -r170
svn: Unable to find repository location for 'filename' in revision 170
in git:
$ git blame filename
3c9fb2a17 (Joe 2016-09-01 16:43:11 +0200 1) today's code
$ git blame filename 3c9fb2a17^
98bcec40b (Jack 2016-06-23 18:04:55 +0200 1) previous code
$ git blame filename 98bcec40b^
fatal: no such path filename in 98bcec40b^
Note the caret (^) you have to add to the end of the git hash. It means "the previous commit from that designated by the hash". In subversion, where everything is nicely ordered, you simply subtract one in order to get the same effect.
One day I might write a script that traces the history of a single line of code back to its creation. Please tell me if this has already been done.
2013-10-30
Subversion: find all files with keyword but without the svn:keywords property
The subversion source control system replaces certain keywords like $Id$ with some very useful metadata, if and only if the file in question is configured to do so. Normally, file properties are added automatically to subversion at the time the file is added. Unless..., unless there was a mistake. Mistakes happen.
Unfortunately, subversion is not very keen to discover and fix such inconsistencies. That's why I came up with this one-liner:
find . -name .svn -prune -o -type f | while read f; do if egrep -q '\$Id|\$HeadURL' $f; then test "$(svn pget svn:keywords $f)" = "Id HeadURL" || echo $f; fi ; done
This finds all files that contain the $Id$ or $HeadURL$ keywords anywhere in the text, and at the same time do not have the svn:keywords property set to "Id HeadURL".
You might be using other subversion keywords: just change the regexp and the property string accordingly.
This helped me a lot, lately, and I thought I wanted to share it.
Unfortunately, subversion is not very keen to discover and fix such inconsistencies. That's why I came up with this one-liner:
find . -name .svn -prune -o -type f | while read f; do if egrep -q '\$Id|\$HeadURL' $f; then test "$(svn pget svn:keywords $f)" = "Id HeadURL" || echo $f; fi ; done
This finds all files that contain the $Id$ or $HeadURL$ keywords anywhere in the text, and at the same time do not have the svn:keywords property set to "Id HeadURL".
You might be using other subversion keywords: just change the regexp and the property string accordingly.
This helped me a lot, lately, and I thought I wanted to share it.
2012-05-25
Static network configuration in Ubuntu 12.04 "Precise Pangolin"
After upgrading my Ubuntu to Pangolin, my DNS resolution would not work any more. The exact reasons are not of interest here, I am in a corporate environment with a complicated proxy setup. I must edit /etc/resolv.conf, and configure my static DNS settings there.
However, Pangolin keeps overwriting this file, replacing it with a symlink, and tries to be clever in destructive ways. After a bit of fiddling, I found that Pangolin installs and runs a local DNS server (dnsmasq) without asking. This may make sense in a mobile environment, but here in my static setup, this makes no sense. Get rid of it.
Next, keep Network Manger from overwriting my configuration. Edit /etc/network/interfaces thus:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.177
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
iface wlan0 inet manual
This works for me. When clicking the network icon in the panel, the items "wired network" and "wireless network" are greyed out. That's OK for me, ymmv.
However, Pangolin keeps overwriting this file, replacing it with a symlink, and tries to be clever in destructive ways. After a bit of fiddling, I found that Pangolin installs and runs a local DNS server (dnsmasq) without asking. This may make sense in a mobile environment, but here in my static setup, this makes no sense. Get rid of it.
sudo apt-get purge dnsmasq
rm -f /etc/resolv.conf
echo search mydomain.com > /etc/resolv.conf
echo nameserver 208.67.222.222 >> /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.177
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
iface wlan0 inet manual
This works for me. When clicking the network icon in the panel, the items "wired network" and "wireless network" are greyed out. That's OK for me, ymmv.
double colons in Bourne Shell function names
Bourne shell does not like double colons ("::") in identifiers. Other shells, e.g. bash, have no problems with them, and programmers like to use them for generating a pseudo-namespace look.
A problem arises when I want to write an include file that works for both, bash and sh.
Here is a workaround that lets me define function names in Bourne Shell with double colons in their name:
function foo__bar() {
...
}
alias foo::bar=foo__bar
A problem arises when I want to write an include file that works for both, bash and sh.
Here is a workaround that lets me define function names in Bourne Shell with double colons in their name:
function foo__bar() {
...
}
alias foo::bar=foo__bar
2012-04-10
ext2fs_check_if_mount: No such file or directory
My mke2fs suddenly started to print this error:
ext2fs 1.40.2 (12-Jul-2007)
ext2fs_check_if_mount: No such file or directory while determining whether /dev/sda1 is mounted.
(It's a very old binary, see, it's not mke2fs that broke.)
This and similar sounding error messages can have various causes. In my case, it was a missing /etc/mtab.
I fixed it with
ln -s /proc/mounts /etc/mtab
ext2fs 1.40.2 (12-Jul-2007)
ext2fs_check_if_mount: No such file or directory while determining whether /dev/sda1 is mounted.
(It's a very old binary, see, it's not mke2fs that broke.)
This and similar sounding error messages can have various causes. In my case, it was a missing /etc/mtab.
I fixed it with
ln -s /proc/mounts /etc/mtab
Subscribe to:
Posts (Atom)