Computing‎ > ‎

Misc

  • Emacs configuration by Jess Hamrick (highly recommended!)
  • How to change text like 'how-to-learn-30-languages' to 'How to Learn 30 Languages' in Emacs?
             (1) Change word from lower case to upper case (pressing the same key stroke again it will jump one word forward),

                    M-c 

             (2) Go back to the beginning of the text, start incremental search with,

                    C-s

                    Then type hyphen; all hyphen instances will be highlighted. Start query-replace with,

                    M-%

Then type space; confirm replacement by typing 'y' in minibuffer. The next hyphen from current point will be replaced with space. Press 'y' again will have next hyphen replaced.
             (3) Macros can also be used to repeat replacement many times. 

                    C-x (
                    C-x )
                    C-x e
                    C-u NUM C-x e
                    C-u 0 C-x e

The above key strokes are start defining a macro, stop defining a macro, execute a macro (once), execute the macro NUM times, and in particular NUM=zero means infinite number of times.
  • How to go back to previous position in Emacs?
Use C-u C-SPACE.
  • How to use helm-mode in Emacs?
  • How to auto complete (like vanilla Tab in Emacs) with helm-mode on?
             Use Ctrl-z to auto complete :)
Add the following lisp snippet to.emacs init file,

; set PragmataPro font
(defvar is-windows-p (eq system-type 'windows-nt))
(defvar is-osx-p (eq system-type 'darwin))
(defvar is-linux-p (eq system-type 'gnu/linux))

(defvar default-font-namematikfreunde.org/
  (cond (is-windows-p "PragmataPro-11") ; you can change font size by changing the number
        (is-osx-p "PragmataPro-12")
        (is-linux-p "PragmataPro-11")
        (t "PragmataPro-10")))

(add-to-list 'default-frame-alist `(font . ,default-font-name))

  • How to use flyspell in Emacs?
          Add the following lisp snippet to.emacs init file,

;; set up aspell for spell checking
(setq ispell-program-name "aspell") ; could be ispell as well, depending on your preferences
(setq ispell-dictionary "english") ; this can obviously be set to any language your spell-checking program supports
;; speed up aspell at the expense of suggestion quality
(setq ispell-extra-args '("--sug-mode=fast"))

;; If you want to use the english dictionary in a particular buffer instead, put the following on the first line of the buffer
;  -*- ispell-dictionary: "english" -*-

;; turn on flyspell for latex writing
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
  • How to use flyspell and auto-complete at the same time?
           All you need is to add the workaround to init file, (ac-flyspell-workaround)
             Add the following lisp snippet to.emacs init file,

     ; load matlab-mode folder
(add-to-list 'load-path "~/.emacs.d/el-get/matlab-mode/") ; you can change the path to where matlab-mode files are saved
(require 'matlab-load)
The quotes are not saved in image files; instead, they are directly implemented in embedded *.svg tags in html code. The reverse engineering'ed svg code of the opening quote is (use base64 -d 'long encrypted string', the string after 'base64,' in the URL field of the bottom right pane of the above picture),

<svg xmlns="http://www.w3.org/2000/svg" width="39" height="25">
<path d="M0 0v25h39V0H0zm11.79 8.18c-2.12-.038-4.028.838-5.39 2.25-.076-.497-.12-1.008-.112-1.54.066-3.672 3.442-5.99 7.214-5.925l-.646-.882C6.924 1.783 2.18 6.42 2.08 12.2c-.102 5.78 3.348 10.53 9.284 10.634l.005-.02c.057.005.107.023.16.023 4.048.07 7.386-3.155 7.458-7.2.07-4.047-3.153-7.386-7.2-7.458zm17.767.028c-2.118-.036-4.027.838-5.39 2.25-.075-.497-.12-1.006-.11-1.537.065-3.673 3.442-5.99 7.214-5.926l-.644-.882c-5.934-.3-10.677 4.337-10.78 10.117-.1 5.78 3.35 10.528 9.288 10.633l.003-.02c.057.005.108.023.162.023 4.046.07 7.384-3.155 7.456-7.2.07-4.047-3.152-7.386-7.2-7.458z" fill="#fff" fill-rule="evenodd"/>
</svg>



<svg xmlns="http://www.w3.org/2000/svg" width="39" height="25">
<path d="M0 0v25h39V0H0zm11.79 8.18c-2.12-.038-4.028.838-5.39 2.25-.076-.497-.12-1.008-.112-1.54.066-3.672 3.442-5.99 7.214-5.925l-.646-.882C6.924 1.783 2.18 6.42 2.08 12.2c-.102 5.78 3.348 10.53 9.284 10.634l.005-.02c.057.005.107.023.16.023 4.048.07 7.386-3.155 7.458-7.2.07-4.047-3.153-7.386-7.2-7.458zm17.767.028c-2.118-.036-4.027.838-5.39 2.25-.075-.497-.12-1.006-.11-1.537.065-3.673 3.442-5.99 7.214-5.926l-.644-.882c-5.934-.3-10.677 4.337-10.78 10.117-.1 5.78 3.35 10.528 9.288 10.633l.003-.02c.057.005.108.023.162.023 4.046.07 7.384-3.155 7.456-7.2.07-4.047-3.152-7.386-7.2-7.458z" fill="#fff" fill-rule="evenodd"/>
     </svg>

             Use Adobe Illustrator or Inkscape to edit the *.svg file. The Guardian navy blue is #005689
             See the example of the decoded quotes used in LaTeX. Closing quotes can be inserted by using rotated (180 degrees) opening quotes.

  • How to trim footer length when fancyhdr is used?
             Use the code snippet to redefine the \footrule,

% this huge block is dedicated to trimming footer fule according to usr control
% http://tex.stackexchange.com/questions/55981/headrule-length-in-fancyhdr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Length to control the \fancyheadoffset and the calculation of \headline simultaneously
\newlength\FHoffset
\setlength\FHoffset{0cm}

%\addtolength\headerwidth{2\FHoffset}

\fancyheadoffset{\FHoffset}

% these lengths will control the headrule trimming to the left and right 
\newlength\FHleft
\newlength\FHright

% here the trimmings are controlled by the user
\setlength\FHleft{0cm}
\setlength\FHright{1.35cm}

% The new definition of headrule (or footrule)that will take into acount the trimming(s)
\newbox\FHline
\setbox\FHline=\hbox{\hsize=\paperwidth%
  \hspace*{\FHleft}%
  \rule{\dimexpr\headwidth-\FHleft-\FHright\relax}{\headrulewidth}\hspace*{\FHright}%
}
\renewcommand\footrule{\vskip-1.0\baselineskip\copy\FHline} % change \footfule in our case
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     ifort f77code.o f90code1.f90 f90code2.f90
  • Color management
I bought a used Monaco OptixXR colorimeter (calibration software support has been dropped by X-rite) and use open source dispcalGUI to manage colour profiles on Windows/Mac/Linux. It was all because a photo I edited on my Mac was washed out on a Windows display. I was driven mad so I decided to sync colour profiles with hardware calibration. Before I found dispcalGUI, I tried proprietary basICColor Display 5 ; it was a piece of crap (shame this is one of the rare occasions on which you chance upon crap made by the Germans): there are numerous typos in their English user guide and the calibration was far worse than dispcalGUI. How dare they charge 100 euros for such a shoddy product?!

I also compared prints colour profiles from Mpix and AdoramaPix; for my images in ProPhoto RGB space, when trimmed to sRGB for printing, 

1. Editing in ProPhoto RGB in Photoshop;

2. Go to Edit/Convert to Profile, and set

a) Destination Space: sRGB IECXXXX
b) Intent: Relative Colorimetric

3. Soft proof photo with Mpix/AdoramaPix colour profiles;

4. Save a copy of the photo as a jpeg without embedding colour profile;

5. Upload the jpeg to Mpix/AdoramaPix and leave it as is.

Choose Metallic paper for prints.
See also this post, it is a manual approach. http://tex.stackexchange.com/a/70030