Concatenate multiple PDF files into one
Posted at 2017-Aug-16 16:57
It is easy with PDFtk, a cross-platform tool. On Ubuntu, one can easily obtain PDFtk via:
sudo apt-get install pdftk
Then using it is to concatenate multiple PDF files into one is trivial:
pdftk <file-1.pdf> <file-2.pdf> <...> <file-N.pdf> cat output combined.pdf
Insert code snippets with syntax highlighting into office suites
Posted at 2017-Aug-06 15:44
When preparing slides/documents with technical content, it's often useful to be able to include some code snippets, ideally with syntax highlighting for the sake of readability.
One way to do it, is to perhaps export the code from a certain editor, with the highlighting style encapsulated in certain special formats, and then import that back in one of the softwares of your office suite.
Copying code snippets with syntax highlighting from Atom
Atom, one of the highly customisable editors out there, has a package to do exactly that. To begin with, open Atom, search for the
copy-as-rtf package and have it installed.
Then, open up your source file, and select the portion of code that you would like to be exported, and press
Now the corresponding RTF of the selected code, styled with syntax highlighting, has been be copied.
Pasting into Microsoft Office (e.g. Microsoft Word, Powerpoint, etc.)
Pasting into Microsoft Powerpoint is easy. Just paste with
Ctrl+v should work.
Pasting into LibreOffice (e.g. LibreOffice Writer, Impress, etc.)
As of version 184.108.40.206, if you paste directly into LibreOffice, it will not parse and render the RTF but instead it would paste verbatim. You would most likely get something like this:
The "Paste Special" function isn't much more helpful though:
An easy workaround, is to paste it into Atom, save it as a temporary file, and have LibreOffice import that file instead:
The imported RTF would result in a textbox containing the code, nicely formatted:
Since it's a textbox, not an image, you can also easily adjust the size of the textbox to adjust line wrapping, and change the size of the font:
My examples above are done in LibreOffice Impress. You can do the same in LibreOffice Writer too. The only difference is that instead of
Insert -> File... (Impress), you have to use
Insert -> Document... (Writer).
Check if running with superuser (root) permission inside a
Posted at 2017-Jul-15 14:43
The idea is to check the current
uid and see if it has a value of zero.
if test $(id -u) -ne 0; then echo "not running as root" exit 1 fi
fcitx input method modules
Posted at 2017-Jul-01 11:53
To be able to use
fcitx with certain programs, you might need to add
export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx
to your desktop start up script (typically
~/.xprofile for most display managers). Re-login for the change to take effect.
Convert RSA public key on X.509 Certificates into SSH RSA public key
Posted at 2017-Jun-30 23:37
# extract the public key on certificate openssl.exe x509 -inform der -in cert.cer -noout -pubkey > pubkey.pem # print the public key in a ssh-friendly way ssh-keygen -f pubkey.pem -i -m PKCS8
The above commands assume the X.509 Certificate is DER-encoded as