Skip navigation

Escaping a forwardslash in awk like

awk  '/javascript\//'

doesn’t work
The way to do so is using the hexadecimal value of “/” which you can figure with the “od” unix command:

echo "/" | od -x

which returns:
0000000 0a2f

then doing:

awk '/javascripta2f/'

works fine!

This is a way to select whatever text we had just inserted inside a buffer. I forgotten this trick until now that used it again. A small tip worth annotating that might come in handy for somebody else as well:
1) yank(paste) the text “C-y”
2) mark the point where the cursor landed, (using point-to-register), do “C-x r SPC” and pick any letter ( a-z)
3) go back to the point where you initially were, by doing “C-u SPC”
4) set the mark there,“C-SPC”
5) use “C-x r j” (+ the letter picked) to go up the point where the yanked text ends inside your buffer.
6) Voila, the text yanked is highlighted ready for whatever manipulation you need to do onto it.

ps: Of course in case you pasted text at the end of the buffer is simpler,
just a matter of:
“C-u SPC”
“C-SPC” to mark
“M – >” to go to the end

UPDATE: Actually, thanks to Peter (see comment below) I learned that this is possible just doing “C-x C-x after the yank if you have transient mark mode enabled” .

A probably ridiculous thing to do, I know, but in hope of getting valuable help for you elisp expert guys out there (I’m all ears) I’m going ahead to show the unusual path I followed to simply bind the org-cicle invoked with an argument 64 (C-u C-u C-u)

(This is also a litle probe of how magnanimously flexible the emacs lisp environment can actually be to allow us to record processes we want automated for later reuse)
1) I started to record the macro “C-(
2) made the call to org-cycle to reveal-all by previously pressing C-u three times “C-u C-u C-u M-x org-cycle
3) stopped recording macro “C-)
4) did “M-x kmacro-name-last-macro” (which provides the lambda form of the last created macro)
5) ran “M-x insert-kbd-macro
6) assigned a key binding to it (global-set-key(kbd “C-+”) ‘my-org-reveal-all)

(fset 'my-org-reveal-all
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([21 21 21 134217816 111 114 103 45 99 121 99 108 101 return] 0 "%d")) arg)))

(global-set-key(kbd “C-+”) ‘my-org-reveal-all)

Due to a disk failure on a server I needed to preserve several databases created for students. Some of them were empty, consecuently doing:
mysqldump with the option --all-databases yielded an error and didn’t work.

What worked instead, was iterating through and mysqldumping them individually with this shell oneliner:

for I in $(mysql -uroot -p****** -e 'show databases'); do  mysqldump -uroot -p****** $I > $I.sql; done;

I compressed those created files into one tar inmediately after:

ls -1 | xargs tar -cvzf backupOfDatabases.tgz

I just wanted to free a shortcut I had for “C-1” to let it behave the way it was meant with the command “digit-arguments”. This answer came in handy.

(global-unset-key (kbd “C-1”))
(define-key global-map (kbd “C-1”) ‘digit-argument)

By the way (a little tip) you can go: C-<digit ARG) instead of the C-u method; say to move 11 characters back, “C-11 C-b” is quicker than “C-u 11 C-b”, one less hit!

I needed to inspect a relatively small portion of a large log file (~1Gb), which will make chock even powerfull text-editors like vi(m) or emacs

I proceded in two steps:
1) found the match in the file and pulled the line number

awk ‘/ May 10 /{a=$0; b = NR;}END{print a,” :: “,b}’ log.txt
which yielded:
Thu May 10 02:17:05 ART 2012 :: 29199076

2) then I dumped the content from the that line and filtered it with head
tail -n +29199076 log.txt | head -n 100
That is possible with the trick of using “tail -n +(N)” which brings lines from the N line onwards

As and alternative to the last one, as explained here, sed could’ve been used in the following manner:
sed -n -e 29199076,29199176 -e 29199077q log.txt
(the last parameter, for efficiency, tells to quit at the limit line + 1 )

I finally got it on how to alter the combination of ALT + (backtick|tilde) keys (the backtick is the one above the tab key), which Ubuntu Oniric Ocelot (11.10) assigned to a new functionality for flipping through windows in the switcher. This system shortcut could surely come as a nasty surprise when you upgrade from version 10.xx, turning unusable whatever command you might had bond in your applications. My emacs setup specially does make a lot of use of these two keys, so I wanted to thank the guy and record his solution found as a response buried in this support thread
Simply all it takes for disabling the default hotkeys is to:
1) get the CompizConfig Setting Manager
"sudo apt-get install config-editor" (it does not come included in Ubuntu Ocelot 11.10)
2) bring it up, (typing “CCSM” in your terminal)
3) look under Desktop -> Ubuntu Unity Plugin -> Switcher
resetting ALT+`
4) pick the last two shown there, and create a key combination for them (which very non-intuitively appear listed as “disabled”). The functions in question are:
:: key to flip through windows in the switcher
:: key to flip through windows in the switcher backwards
(note how in this case I had already set them to C-Alt 7 and C-Alt 8)

Yeah, it’s over babe, we’re back in business!

Darn!, this is nothing but a little note of caution, a sad admission of stupidity or maybe even a tip to someone: if you ever find yourself in a tight schedule doing extra hours to finish up a project, don’t waste precious minutes debugging your app only due to having foolishly picked the php ISO-8601 numeric representation of the day of the week “N” (mon=0 … sun=7). Completing the missing dates from a set of database records will work flawlessly just with date(“w”), specially if you had pulled the existing days using mysql date_format(“w”).

I have been enjoying the window placement hotkeys in Ubuntu ever since I accidentally discover them. The possibility to center/maximize or reposition windows to any side of the screen becomes essential when you tasted the power of mouseless interactions. I only wished to find something similar for my cygwinized laptop, and was happy to learn that Windows 7 alows some window management via the keyboard with the following shortcuts:
:: windows-key + up-arrow: maximizes the current window
:: windows-key + (left/right)-arrow: docks the current window in the left or right side of the screen
:: windows-key + down-arrow: minimizes, or restores the size of a maximized window

When in need to enter special character inside emacs you can quote it with “C-q” and enter the octal character code, so for instance to type “ñ” you will do: “C-q 361

I found a thorough description of iso-latin-1 on the web, plus a great deal of general info on character and encodings available there as well

Within emacs it’s easy to pull any charset-table by doing “M-x list-charset-chars“, say if we type latin-iso8859-1 at the prompt the program shows:

character set

Then, for specifics about any character, simply highlight it and do “M-x describe-char” to get a full detailed view like:

character: ñ (241, #o361, #xf1)
preferred charset: latin-iso8859-1
(Right-Hand Part of ISO/IEC 8859/1 (Latin-1): ISO-IR-100)
code point: 0x71
syntax: w which means: word
category: .:Base, j:Japanese, l:Latin
buffer code: #xC3 #xB1
file code: #xF1 (encoded by coding system iso-latin-1-unix)
display: by this font (glyph code)
uniscribe:-outline-Bitstream Vera Sans Mono-normal-normal-normal-mono-13-*-*-*-c-*-iso8859-1 (#x78)

Character code properties: customize what to show
general-category: Ll (Letter, Lowercase)
decomposition: (110 771) (‘n’ ‘̃’)

There are text properties here:
charset latin-iso8859-1

Awesome power!