This started as a list of things I wanted to note somewhere, but it evolved into a list of links I find interesting or useful.
About Git and other VCSes
- On undoing, fixing, or removing commits in Git: looks kinda comprehensive and useful
Understanding the Git Workflow: why one shouldn’t use
--no-ffin general, and generally go against the default Git workflow
- Comparing Workflows: a nice tutorial about the classic Git workflows
- Interesting web interfaces: git2html (generates static pages), cgit (dynamic interface, written in C)
- Rules about how to write a Git commit message, by Chris Beams
git-reparent, a script to easily change the parents of a commit. This is a good example of what bugs me in Git: how comes there are so many obscure commands and options, but it's so complicated to do something this trivial?
- Rewrite committer names in a Git repository
- Change commit author at one specific commit (using
Merge a project into another project:
git remote add my-subproject path/to/subproject
git fetch my-subproject
git merge my-subproject/master
git remote remove my-subproject
- Import existing Git repository into another: got to test this
- Modify a specified commit:
rebase -ion its parent, then
- Dealing with line endings. Also, specifying setting per repo with
.gitattributescould be useful.
- Storing HTTPS authentication:
cachewith a timeout feels like a good compromise between simplicity, usability and security.
- Git merge vs. rebase: seems to make sense. Avoid merge commits that result from
git pull, but force a merge commit when a feature branch lands in master.
- Before Git 2.4, tags are not pushed by default; one has to use
git push --follow-tags(not
- List branches/tags that contain (or do not contain) a specific commit:
git for-each-ref --contains abcdef
- Get the path of a directory relative to the root of the git path:
git rev-parse --show-prefix
Move a directory with its history from one repo to another: the simplest approach seems to create patches from the source repo, and apply them on the destination repo.
# creates patches starting at the beginning.
# this works if the whole repo should be imported as a directory of another.
# otherwise there are other things to do. be careful about
# renamings of the directory.
git format-patch --root
# pour des fichiers spécifiques (attention aux renommages):
# git format-patch --root fichier.txt toto.py auie.c
for patch in "$SRC_REPO"/*.patch; do
git am "$patch" --directory=$(git rev-parse --show-prefix)
# --directory option changes the dest dir of the patch;
# git am also has a -p option to kill parts of the input path
- Split some files from a repo into a new one, and edit commit messages to remove the “tag string” at the beginning of the commit: I used the following
# in the old repo
git fast-export HEAD mytag1 mytag2 -- file1 file2 >/tmp/toto.fi
git fast-import </tmp/toto.fi
git filter-branch --tag-name-filter cat --msg-filter 'sed "1s/^tag-string //"'
--tag-name-filter catoption attaches tags to the re-created commits without changing their content (since the filter is
cat). Check the result carefully (
git filter-branchis infamous for being very fragile). NB:
fast-export/importcould probably be used for the previous bullet point. NB: in that case the files had never changed names, I don't know if there's a way to follow renamings (there is no
Importing a Git repo into a newly created SVN repo
That was harder than I thought it would. I tried a straightforward
git svn init then merge and
git svn dcommit,
but it failed with
Unable to determine upstream SVN information from HEAD history.. I figured it was because the SVN repo was empty,
so I added a dummy commit in the SVN repo before merging. It seemed to work, but actually all Git commits that were before the dummy commit couldn’t be added in the SVN history.
Then, I tried this solution, but it changed the timestamps in my Git repo. Finally, this one seemed to do the trick when testing out, but when I deployed it for real it did not work as well.
So basically I’m not sure there’s a way. The actual Git commits are still there in another branch though.
Update: the only solution seems to be to work in a Git branch and commit to svn in another branch. Since it is cumbersome to manage, I wrote a (not so) little script to do it.
- How to use downloaded fonts with fontspec: put them in
fc-listto list the fonts available. Use
otfinfo -i font-fileto get the font name to be used with fontspec (it does not recognize names like
- Some rules and tips about displayed math, by A.J. Hildebrand
- Why one should not use
eqnarray[PDF], by Lars Madsen
- Good examples of symbol construction, and also there
- Writing your own documentclass (other useful pages linked at the bottom)
- changing size of arrow tips (could be useful)
\newifworks (spoiler: this is horrible)
- Keys Under Doormats: Mandating insecurity by requiring government access to all data and communications, technical report of the CS and AI lab at MIT, about the effects of imposing “exceptional access” to encrypted communications for governments.
- Don't Distract New Programmers with OOP and its follow-up OOP Isn't a Fundamental Particle of Computing
- About exceptions: Cleaner, more elegant, and wrong, and Cleaner, more elegant, and harder to recognize
Learning to Love Python from a C/C++ background:
I like his characterization of Java:
Java is a bureaucratic language. You have to cross your t’s dot your i’s, fill out your requests in triplicate at the FactoryFactoryFactory to get the objectOfYourDesire.and its explanation of why it is so.
- How to get a triple-keyed HashMap in Java? As it seems to turn out, there's no method that does not suck.
- Creating a JAR file
- Handling “impossible” exceptions in Java: it makes sense to throw an
- String concatenation with Java 8
- MinLog: a tiny, overhead-free (provided that some fields are declared
final) Java logging library
- Interesting remarks and links about micro-benchmarks in Java
- A demo class with some reminders about casting (because it was not clear for everyone, including me)
- Random numbers in Java, with alternatives to
- Built-in types: I use this all the time because
help()is not helpful for basic things…
- Abstract Base Classes for Containers (I still haven't decided whether this is awesome or horrible)
- Why should I use Python 3? Lots of interesting and potentially useful things that I didn't know existed
About Unix tools
- Tutorials on Unix shell programming, by Bruce Barnett; in particular
sh. Since it was written before 1995 and has been regularly updated, it carefully separates POSIX from GNU extensions, which is not always the case with recent tutorials.
- Bash Guide, by Maarten Billemont: clearer, more up to date and more complete than most other guides; plus it warns about bashisms and gives POSIX solutions for them. Particularly noteworthy: a useful diagram showing how the (ba)sh parser works.
- Illustrated redirection tutorial on the Bash Hackers wiki: redirection is a lot more subtle than appears at first glance. This tutorial makes it very clear.
- A simple step-by-step tutorial about reading columned input in the shell
- Common shell script mistakes, by Pádraig Brady
sh(POSIX shell) tricks, a condensed summary of shell syntax, and this useful
tryconstruct, via this thread
- Signals and
- Sending and Trapping Signals, a good intro at the Bash Guide
- Explanation of the various termination signals (glibc docs); see also this SO question with useful references
- Proper handling of SIGINT/SIGQUIT, by Martin Cracauer: interesting, but the WUE approach seems the simplest/most robust, since it does not require cooperation of all programs. I wonder why it's not the programs using SIGINT as part of their UI that are considered broken.
- A little demo script with my current understanding of how it should probably be done in the POSIX shell.
- Introduction to named pipes
- Guide for writing
- The TTY demystified, by Linus Åkesson: very interesting info about the interactions between the kernel and the pty (line discipline, signals, job control) with a historical perspective.
Converting PDFs to PNGs:
convert -density 300 toto.pdf -quality 90 -resize 500x toto.png. This may look obvious, but there's a trick: the density setting must be given before the PDF file! (I didn't bother to check why yet.)
A difference I'd not been aware of until today (2016-08-03) between using
>/dev/stderrto write on standard error:
I suppose that
$ cat usingfd2.sh echo "one" >&2 echo "two" >&2 $ sh usingfd2.sh 2>usingfd2.log $ cat usingfd2.log one two $ cat usingstderr.sh echo "one" >/dev/stderr echo "two" >/dev/stderr $ sh usingstderr.sh 2>usingstderr.log $ cat usingstderr.log two
/dev/stderrbehaves more or less as if it was replaced by what standard error points to, so if it's a file, the second write clobbers it. It means that if you want to use
/dev/stderryou should be careful to always append to it. It's not surprising that I didn't realized this before (I generally write only once on standard error, and then call
exit), but I can't seem to find a tutorial that warns about this. I've only seen it stated explicitly in a comment to this StackOverflow answer.
- wget command to download a course page with linked PDFs on another server, explained using
explainshell.com. The UI of wget is really ugly.
Useful “non-standard” Unix tools
pass, a good candidate for being “the standard unix password manager” (as they call it). A little more detailed presentation can be found here.
- ShellCheck: finds bugs in your shell scripts
desc, “a fast and simple descriptive statistics tool for the UNIX command line”: I'm surprised that there isn't such a thing in the standard toolchest. Got to try this one.
Vim is unfathomably awful, but looking for another editor isn’t a priority for me right now.
Hitting escape too soon after closing a brace did not work. Turns out it was because of
showmatch, which was set by vim-sensible. How it could have been decided that this behavior was a sensible default is beyond me.
The features related to indentation are incredibly complex. Sometimes I think I get it, but no.
The classicAlso, all indent scripts are executed after
filetype plugin indent onstanza does not seem to change anything. I wanted to disable indentation in an HTML file because it messed up the indentation of the CSS in
styleelements; I tried to understand this page, but the only thing that worked was to
:set indentexpr=, which is not mentioned… Moreover, adding this to my filetype-specific settings (in
.vim/after/ftplugin) has no effect: Vim still sets it to
HtmlIndent(), apparently because of
/usr/share/vim/vim74/indent/html.vim(as seen by
:verbose set indentexpr?), whereas the files in
.vim/after/ftpluginare supposed to be executed after everything…
after/ftplugin, thanks to an autocommand. That was not obvious.
:filetypecommand looks like it could help debug ftplugin problems.
- Info about buffer switching; doc about window creation/movement; info about using tab pages.
- Some Vim plugins that could be interesting. Most seem overkill though.
- Could be worth trying: vim-sleuth, which
automatically adjusts 'shiftwidth' and 'expandtab' heuristically based on the current file, or, in the case the current file is new, blank, or otherwise insufficient, by looking at other files of the same type in the current and parent directories.(Not sure I want
smarttabthough, and not sure how to use it to set defaults, but it could be useful for shared projects.)
Making vim respect XDG, by Tom Vincent:
You useBe careful: the
vimas your primary editor and take active measures in keeping your
vimis one of those “traditional” apps that stores it’s runtime files in a myriad of places. Thankfully, it’s customisable enough to solve this.
runtimepathgiven in this article is wrong, the
afterdirectories should be at the end. I ended up adapting the default path as given in
- Using abbreviations seems like it could be useful?
- Learn Vimscript the Hard Way: a great reference for an awful language.
- Character Encoding Tricks for Vim: e.g., how to force Vim to interpret a file as being in a specific encoding (this is highly nonobvious).
- useful to understand what's happening:
the :verbose command,
the :scriptnames command. More complete : option
-V(shows the files that were tried, not only those that existed)
It's horrible, but what can I do.
Things to configure when creating a new profile (because the previous one stopped working for some reason, yes this happened enough times that I felt the need to write this down):
- Unicaen email :
- Uncheck “Compose messages in HTML format” in the account settings “Composition & Addressing”
- “Plain text e-mail” (MozillaZine) (I don't think I had to change anything)
- Quicktext extension: link to directory in my etc/
- Nostalgy++ extension
- Retrieve address books in
abook.sqliteat the root of the profile directory
Extensions I no longer use (for various reasons):
- Quickarchiver: it made Thunderbird lag a lot in some version. Removed it, should try again sometime.
About the Web & Web languages
About software development
The netscape dorm (don't mind the disclaimer and just scroll down):
excerpts from Jamie Zawinski's diary during the development of Mozilla (the codename for what was to become Netscape Navigator 1.0).
It's funny & frightening, with this exciting “writing history” feeling amidst the madness.
By the way, the homepage of Mosaic Communications from this period (1994) is still online and it’s awesome
(gotta love the big caps in headers, very clever use of the
- Lessons learned from 30 years of MINIX, by Andrew S. Tanenbaum.
- McDonald’s Theory
- Kernighan's Lever, by Linus Åkesson
- Don't Let Architecture Astronauts Scare You, by Joel Spolsky
About the English language
- Guide to Punctuation, by Larry Trask. A remark about bracketing commas: a sentence is “destroyed” if its structure has changed, not if its meaning changes. This is not clear in his example “Note that, in each of these examples…”, since the interruption is not really necessary. This post makes it clear that the rule which this example illustrates also applies e.g. to “Note that, to do this, you must do that”.
- Why two spaces after a period isn’t wrong (or, the lies typographers tell about history), by heraclitus
- A Rule Which Will Live in Infamy, by Geoffrey K. Pullum; more articles about which versus that
- Fear and Loathing of the English Passive, by Geoffrey K. Pullum
- The rule about how to use whom, by John Lawler
- “Conjunctive Adverbs: Words in Endless Grammatical Angst!”
Some references about mathematical writing:
- Mathematical Writing [PDF], by Donald E. Knuth, Tracy Larrabee, and Paul M. Roberts
- How To Write Mathematics [PDF], by Paul Halmos
- MathOverflow discussion about Periods and commas in mathematical writing: I find the contrarian point of view really interesting. Formulas are displayed for clarity reasons, in order to be separated from the text. It makes sense that they live in a pure mathematical world, with its own punctuation rules.
- Other references. (There are lots of dead links, but it's still useful as hyperlesstext. The book by Steven G. Krantz seems interesting.)
- The Land of the Free and The Elements of Style, by Geoffrey K. Pullum (turns out I rather like Geoffrey K. Pullum)
- Go at Google: Language Design in the Service of Software Engineering
- Systemd: The Biggest Fallacies, by Jude C. Nelson
- Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...), by Russ Cox
- Likert Scales: Dispelling the Confusion, by John S. Uebersax
- A statistics tutorial, and some simpler step-by-step examples: support or reject null hypothesis, hypothesis testing examples.
- Useful Unicode chars: ←↑→↓↔ ⇐⇒⇔ ∨∧¬ φΦᴪΨΔδ∇ ∀∃∄ ∈∉ ∅ ∩∪ ≈≤≥⊂⊆ ⊕⊗⊙ ⊨≡ ⟦⟧⟨⟩ (useful blocks: Greek and Coptic; Mathematical Operators; Arrows; Miscellaneous Mathematical Symbols-A; Supplemental Mathematical Operators).