Sunday, March 29, 2020

13 Pin Accessory Connector CAT for IC-706 Rig

I am an amateur radio operator (extra class, call sign: N7DSP) and I made a rig control interface cable for my Icom 706 many years ago. I've been working from home during this COVID-19 quarantine and have had a little time to get it back up and running with the hope of getting email via Winlink 2000 up and running.

To my surprise, I couldn't remember how to get the dang thing working with fldigi (http://www.w1hkj.com/) so I'm trying to capture that information here.

The interface cable I made apparently used the USB to RS232's RTS line to signal the radio to transmit (or virtually to push the PTT or push-to-talk button) so that was the first mystery. The second mystery was that I needed to use a "separate serial port" under the "hardware ptt" tab even though both USB devices turned out to be the same.

Cables


The green 8mm stereo jack line is my transmit audio cable and should be hooked up to the headphones or line out jack, a second separate 8mm stereo cable (not connected to the USB, green audio, or 13-pin accessory cable) needs to attach to the phones line on my front panel and it should hook up to the line in or microphone jack on my computer.

The black cable attached to the 13-pin accessory jack connector with an 8mm stereo connector is for the CV-I interface (multi-drop serial port that Icom uses to control radios) and hooks up in the back of the 706. It connects to the 8mm jack that is closest to the 8p8c (colloquially known as the RJ45 jack) used for the HM-103 mic.

The remaining black cable is the USB cable which is an RS232 serial emulator chip and cable and needs to be plugged into a free USB port, I'm assuming above that it's the only USB serial port you've plugged in otherwise the "device" might be /dev/ttyUSB1 or /dev/ttyUSB2 or something.

With the below fldigi settings, if you run fldigi and the radio isn't powered and the USB control cable isn't plugged into your computer, fldigi will not start! Once you plug in the USB cable and power the radio it will run.

Settings


Here is a summary of the settings I need for my interface cable:
Rig Control:
Use Hamlib: checked
Rig: Icom IC-706
Device: /dev/ttyUSB0 (add yourself to the dialout group on Ubuntu to get permissions correct, else chmod 777 /dev/ttyUSB0 everytime you want to use it)
Baud rate: 19200
Stopbits: 1
All other settings at defaults which are:
Retries: 3
Retry interval: 1000
Write delay: 0
Post write delay: 0
PTT via hamlib command: unchecked
Audio on Auxiliary port: unchecked
DTR +12: unchecked
RTS +12: unchecked
RTS/CTS flow control: unchecked
XON/XOFF flow control: unchecked
CW is LSB mode: unchecked
RTTY is USB mode: unchecked
Sideband: Rig mode
Mode delay: 200
Polling Interval: 250
Advanced configuration:



Hardware PTT:
PTT tone on right audio channel: unchecked
h/w ptt device-pin
Use separate serial port PTT: checked
Use RTS: checked
RTS = +V: unchecked
Use DTR: unchecked
DTR = +V: unchecked
Device: /dev/ttyUSB0
Use parallel port PTT: unchecked
PTT delays valid for all CAT/PTT types
Start of trasmit PTT delay: 0
PTT end of transmit delay: 0



While debugging all of this, occasionally the PTT button would get stuck "on" so I wrote this python script to force it back off:
#!/usr/bin/python3
import serial

ser = serial.Serial()
ser.baud = 19200
ser.port = '/dev/ttyUSB0'
ser.setRTS(0)
ser.setDTR(0)
ser.open()
ser.close()

Wednesday, July 22, 2015

Fake BSOD Ransomware

Background


Tonight a loved one's computer was hit by ransomware. I rarely have to deal with viruses and malware because I run only Linux and OS X at home. That's not to say that neither of those platforms are without security issues--they're not. It comes down to numbers. OS X has maybe 10% of the desktop market share and Linux has may 1%. In a ransomware scheme it's all about getting it in front of as many people as you can.

The problem


A very unconvincing "blue screen of death" was displayed with a customer support number to call. Surely if I called a friendly customer support rep. would have fixed my problem for a small fortune. The going rate seems to be around $150 if my googling is accurate.

The Solution (sort of)

Anyway, most online resources instruct you to do the following to remove this ransomeware:
(quoting from http://sdpcfix.com/computer-security/ransomlock-fake-blue-screen-tech-support-scam/)
1. Press Ctrl+Alt+Del
2. Open Task Manager
3. Look for the ransomware entry on the Processes tab, which should be ‘diagnostics.exe’, and end the process.
4. Go to the registry editor by clicking on Start -> Run -> Typing ‘regedit’ and pressing enter.
5. Delete the following registry entry: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\”Diagnostics” = “[PATH TO MALWARE]”
6. Delete the file folder from the directory.

Ok, sounds reasonable. Unfortunately for me, this particular version had a few tricks up its sleave. First, I couldn't move the mouse away from the top lefthand corner of the screen. Second, the BSOD drew itself on top of all other windows so starting task manager or cmd.exe or anything else useful was, well, kind of useless.

The Solution (for real)

Over time I realized that at least the keyboard focus was still going to the current window, so using Alt-tab I could navigate from the BSOD to cmd.exe and task manager and anything else I needed. I also found that when I held Alt-tab down I could see the selected window briefly, but the Alt-tab menu itself often occluded important information. After letting go, however, the BSOD would draw over it again. Ugh. The last discovery that I needed to lick this one was that hitting Ctrl+Alt+Del then selecting task manager let me use the mouse for a second and then if I hovered the mouse over the task manager icon or the cmd.exe icon on the start menu bar then I could see selected window in its entirety!

Being a Linux guy I'm still appalled at how crappy Microsoft's command line utilities are. I finally googled enough to find:

dir /b /s
That lets you list files recursively.
tasklist /v
Shows running tasks and their run times.
taskkill /f /im <glob>.exe
Kills a task matching the glob expression.

Using those commands and with the Ctrl+Alt+Del and Alt-Tab tricks above I was finally able to find the offending process. Final trick up this ransomware's sleave: the process was called "windows.exe", not "diagnostics.exe" like above. It was pretty satisfying to kill that nasty with taskkill. A quick search then yielded its location: c:\Users\Public\windows.exe (or close to that, I didn't write it down).

So kids if you're hit with a nasty fake BSOD that doesn't let you use your mouse, don't give up just be on the lookout for "windows.exe".

(I wish I'd written down the tech. support phone number.)

As recommended above, delete "windows.exe" and remove the corresponding "Run" key from the registery.

(BTW, I was able to run regedit in safe mode, but for some reason I missed the c:\Users\Public\windows.exe "Run" key when I looked for it. Finding it there would have been a much faster way to resolve this.)
(Also BTW, this was Windows 8 if that matters.)

Tuesday, April 10, 2012

GNU Global in vim (and emacs!)

I know, I know, this blog is for emacs, but Wade's post on getting GNU global to work with vim was too good to pass up.  (Thanks for the shout out, Wade.) I've been meaning to write a similar post for emacs for years.  Enjoy...

http://wadeberrier.blogspot.com/2012/04/source-code-navigation-with-vim.html

Monday, January 2, 2012

Binding or Setting Function Keys in GNU Emacs

After learning the basics of emacs, you'll want to start customising your keys.  Function keys are a great place to start since few have default bindings in the stock emacs.

For instance.  If you're a C, C++, or Java developer you'll likely want to compile from within emacs so that you can easily jump to compiler errors.

Last I checked, there is no default key binding for doing this besides
M-x compile
(to set the compile command) and
M-x recompile
(to instantly compile after the compile command has been set.)

I like to compile with F9 (force of habit from an old tool), debug with F10, and set my compile string with F11.

For the above key bindings, add this to the end of your .emacs file:
(global-set-key [f9] 'recompile)
(global-set-key [f10] 'gdb)
(global-set-key [f11] 'compile)

Wednesday, December 7, 2011

How to return a function pointer without a typedef in C/C++

The intertubes are full of examples on how to use function pointers in C/C++. Most try to simplify things by typedef'ing the function signature. What if you're a glutton for punishment like me and want to do it the "hard" way?

Ok, here's the background. Let's say you want to be able to find the cosine of an array of doubles, but you also want to be able to find the sine, tangent, etc.

You could do this:
#include <math.h>

void apply_sin(double *dat, int length, int type)
{
    int k;
    for (k=0;k<length;k++)
    {
        dat[k] = sin(dat[k]);
    }
}

void apply_cos(double *dat, int length, int type)
{
    int k;
    for (k=0;k<length;k++)
    {
        dat[k] = cos(dat[k]);
    }
}

void apply_tan(double *dat, int length, int type)
{
    int k;
    for (k=0;k<length;k++)
    {
        dat[k] = tan(dat[k]);
    }
}

void apply_square(double *dat, int length, int type)
{
    int k;
    for (k=0;k<length;k++)
    {
        dat[k] *= dat[k];
    }
}


But this leaves a lot to be desired. Each operation requires a new function that is nearly identical to all the rest. Can't we factor out the commonality?

Ok, how about this:

#include <math.h>
#include <stdio.h>

double square(double val)
{
    return val * val;
}

void apply_operation(double *dat, int length, double (*oper)(double))
{
    int k;
    for (k=0;k<length;k++)
    {
        dat[k] = oper(dat[k]);
    }
}

void print_vector(double *dat, int length)
{
    int k;
    for (k=0;k<length;k++)
    {
        printf("%g ", dat[k]);
    }
    printf("\n");
}

void call_it(void)
{
    double vals[] = {1,2,3};
    apply_operation(vals, sizeof(vals)/sizeof(vals[0]), sin);

    print_vector(vals, sizeof(vals)/sizeof(vals[0]));
    apply_operation(vals, sizeof(vals)/sizeof(vals[0]), cos);
    print_vector(vals, sizeof(vals)/sizeof(vals[0]));
    apply_operation(vals, sizeof(vals)/sizeof(vals[0]), tan);

    print_vector(vals, sizeof(vals)/sizeof(vals[0]));
    apply_operation(vals, sizeof(vals)/sizeof(vals[0]), square);
    print_vector(vals, sizeof(vals)/sizeof(vals[0]));
}

int main(int argc, char *argv[])
{
    call_it();
}


So that's a bit better. Only one implementation of the loop code, simple implementations for each operation, only the overhead of an additional pointer dereference per element. How did we pull this off?

void apply_operation(double *dat, int length, double (*oper)(double))


apply_operation() takes a function pointer as a parameter (the last argument). This makes it so that apply_operation() can take any function that takes a single double as input and returns a single double as output. Slick.

Now, the next step: returning a function pointer (without typedefing the signature). Let's say we have a table of operations and we associate each operation type with a function pointer so that we can do a simple lookup to get a pointer to the desired operation function. So, in other words, we're returning a function pointer. Here's how to do it without a typedefed function signature.

#include <math.h>
#include <stdio.h>

enum
{
    OPER_SIN,
    OPER_COS,
    OPER_TAN,
    OPER_SQUARE
};

struct oper
{
    int type;
    double (*func)(double);
};

double square(double val)
{
    return val * val;
}

struct oper oper_lut[] =
{
    {OPER_SIN, sin},
    {OPER_COS, cos},
    {OPER_TAN, tan},
    {OPER_SQUARE, square},

};

double (*get_oper(int oper_type))(double)
{
    int n;
    for (n=0;n<(sizeof(oper_lut)/sizeof(oper_lut[0]));n++)
    {
        if (oper_type == oper_lut[n].type)
        {
            return oper_lut[n].func;
        }
    }
}

void apply_operation(double *dat, int length, double (*oper)(double))
{
    int k;
    for (k=0;k<length;k++)
    {
        dat[k] = oper(dat[k]);
    }
}

void print_vector(double *dat, int length)
{
    int k;
    for (k=0;k<length;k++)
    {
        printf("%g ", dat[k]);
    }
    printf("\n");
}

void call_it(void)
{
    double vals[] = {1,2,3};
    double (*func)(double);
    func = get_oper(OPER_SIN);
    apply_operation(vals, sizeof(vals)/sizeof(vals[0]), func);
    print_vector(vals, sizeof(vals)/sizeof(vals[0]));
    func = get_oper(OPER_COS);
    apply_operation(vals, sizeof(vals)/sizeof(vals[0]), func);
    print_vector(vals, sizeof(vals)/sizeof(vals[0]));
    func = get_oper(OPER_TAN);
    apply_operation(vals, sizeof(vals)/sizeof(vals[0]), func);
    print_vector(vals, sizeof(vals)/sizeof(vals[0]));
    func = get_oper(OPER_SQUARE);
    apply_operation(vals, sizeof(vals)/sizeof(vals[0]), func);
    print_vector(vals, sizeof(vals)/sizeof(vals[0]));
}

int main(int argc, char *argv[])
{
    call_it();
}


The magic is in get_oper(). Did you catch it?

double (*get_oper(int oper_type))(double)


This means that get_oper() is a function that takes a single int as a parameter and returns a function pointer to a function that returns a double and takes a single double as its only argument. Simple, right? There it is--returning a function pointer from a function without typedefing the signature (the "hard" way).

This is the best reference I've seen so far on function pointers http://www.newty.de/fpt/fpt.html.

Wednesday, March 3, 2010

Surviving Visual Studio

I love emacs. I can't describe how much I miss it when I have to do development in Windows. Yes, I know there's a version of emacs for Windows, but it seems like if you're developing for Windows it's easier to give into the borg than to fight them.
My tip for the day:
C-k C-f indents a region similar to C-M-\ in emacs.

Sunday, October 19, 2008

Now the Economic Crisis is Personal ... Mother's Cookie Company Goes Out of Business

The economic crisis hasn't really made a big difference in my life until today. I just heard that Mother's Cookie Company is going under. I bought one last bag of pink and white "Circus Animals". Apparently it will have to last me for ETERNITY. Where's the 700 billion dollar bailout for cookie companies? Forget the whales, SAVE THE COOKIES! Check out the AP story.

Thursday, August 14, 2008

gtk.FileChooserDialog() mini-HOWTO

Enough is enough! It seems like every time I write a pygtk app I end up needing a file chooser dialog yet every time I can't remember the details. The reference page for gtk.FileChooserDialog() is excellent--for reference. I need a gtk.FileChooserDialog() mini-HOWTO. Here it is:

fc = gtk.FileChooserDialog(title='Open File...',
                                   parent=None,
                                   action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                   buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
        fc.set_current_folder(g_directory)
        fc.set_default_response(gtk.RESPONSE_OK)
        filter = gtk.FileFilter()
        filter.set_name('Audio Files')
        filter.add_pattern('*.wav')
        filter.add_pattern('*.mp3')
        filter.add_pattern('*.flac')
        fc.add_filter(filter)
        response = fc.run()
        if response == gtk.RESPONSE_OK:
            print 'ok'
            print fc.get_filename()
            self.entry.set_text(fc.get_filename())
            g_directory = fc.get_current_folder()
        else:
            print 'not ok'
        fc.destroy()
There, done! This page is also an excellent, more complete, example.

Wednesday, June 25, 2008

I knew I Could Do Better

After brushing up on the periodic table, and embellishing my education a little ... I am nerdier than 100% of all people. Are you a nerd? Click here to find out! Beat that!

Mindless Drivel, but Entertaining Nonetheless

I am nerdier than 94% of all people. Are you a nerd? Click here to find out!

Saturday, April 12, 2008

Review of "King of Kong: A Fist Full of Quarters"

Over the last three days (it's been several months ago now) I've had the extreme pleasure of watching "King Kong: A Fist Full or Quarters". You must see this movie.

It is, in my opinion, the quintessential American underdog story set to the music of Donkey Kong. On one side you have Billy Mitchell, a superstar in his own world. Arguably the best gamer of all time, but certainly the best classic gamer of all time. Billy is amazing--He's truly gifted. Unfortunately, like a lot of us in this world, his head is much bigger than it aught to be. (In Billy's case, his hair is longer than it aught to be too.)

On the other side you have Steve Wiebe, an apparent "screw up" (and I mean that in the nicest way possible). Of his own admission, he hasn't lived up to his true potential throughout his live. Highly athletic yet subject to "the chokes", gifted musically but prohibitively shy, highly intelligent yet awkward and sheepish.

"King of Kong: A Fist Full of Quarters" is their story.

I won't spoil the rest, but I will say this: be prepared for the subculture of classic gaming's superstars, groupies, officials, desperate wannabees, outsiders, insiders, family members, winners, and losers. It's a strange world, beyond description, even for a geek like me. After you've watched the movie, go check out the current record at Twin Galaxies.

Saturday, February 16, 2008

Rock it out with Heart

Though I consider myself mostly an 80's-synth-pop-new-wave-2-tone kind of person, I still have a great love for classic rock. I think it was Homer Simpson who once said "rock peaked in '74, everyone knows that!" Amen, Homer, Amen.

I've been trying to play this song for +10 years now, oh well, someday I'll get it. Enjoy...

Saturday, October 27, 2007

PyGTK Treeview digest

I'm always forgetting how to use the TreeView widget to display columnar data. In PyGTK (well, GTK+ in general) a TreeView is used to display trees (TreeStores) and columnar data (ListStores) like in the screenshot below. In this mini HOWTO I'm restricting the post to ListStores, however, many of the concepts below apply to TreeStores.)

A ListStore keeps track of the values you want to display in your TreeView. You create one like this:
liststore = gtk.ListStore(type1, type2, type3, ...)

Where typen can be a Python type int, str, a PyGTK type gtk.Button..., or a gobject type like gobject.TYPE_CHAR or 'gchar'.

Once your ListStore or "model" is created, you'll want to put things in it and take things out. To add a row you use append or prepend like so
iter=liststore.append([1,2,3,'a','b','c']) iter=liststore.prepend([1,2,3,'a','b','c'])
The iterator iter can be used by other calls like
new_iter=liststore.insert_before(iter, [1,2,3,'a','b','c']) new_iter=liststore.insert_after(iter, row=[...]).

So what about accessing/changing things after the fact?
value=liststore.get_value(iter, column)
will get a single column from a single row at iter.
values=liststore.get(iter,col1,col2,col3,...)
gets multiple rows from iter just as
vala, valb=liststore.get(iter, 0, 2)
does.

Conversly,
liststore.set(iter,col,val)
sets a single column in iter to value. As does
liststore.set(iter,col,val,col,val,...,...)
for multiple columns and values. To remove a single row do
liststore.remove(iter)
, and
liststore.clear()
to remove them all.

The model (ListStore) is essentially a database. To actually see the contents of it in a widget you'll need a TreeView, TreeViewColumns, and CellRenderers.
view=gtk.TreeView(model=None)
does the job of creating a TreeView, optionally setting the model off of which it's based. Otherwise it can be set and retrieved with
view.set_model(model) model=view.get_model().

TreeViewColumns hold the CellRenderers and are managed by the TreeView. You add a TreeViewColumn to a TreeView like this:
view.append_column(column).
You make one thus
col=gtk.TreeViewColumn('Heading').

CellRenderers do the work of displaying a particular column in the store. CellRenderers get packed into the TreeViewColumns (which manage the column headers), therefore you can have multiple CellRenderers under one column heading. It is a common practice to put an image and text together under the same column heading. Different Cellrenderers exist for different types namely pixmaps, text, and toggle buttons. (And, of course, you can always make your own.) It is easy to create a Cellrenderer:
cell=gtk.CellRendererText() cell=gtk.CellRendererPixbuf() cell=gtk.CellRendererToggle()
. You can then pack it into the the desired TreeViewColumn with
column.pack_start(cell,expand=True)
and
column.pack_end(cell,expand=False).

Here is the part I have the hardest time remembering... How do you associate data in the store with what gets displayed in the CellRenderers? The answer is column attributes. So, to associate the text of column 0 in the model with the text in a particular CellRenderer cell you do
col.add_attribute(cell, 'text', 0)
or equivalently
col.set_attributes(cell, text=0, prop1=modelcol1, prop2=modelcol2, ...)
. There are many other attributes besides 'text' that can be tied to your data model. Some include 'markup' (simple HTML), 'font', 'background' (color), 'foreground' (color).

Here is a minimalist example that ties it all together:

import gtk

store = gtk.ListStore(int,str,str,str)
view = gtk.TreeView(model=store) # Associate the store with the view

column_int = gtk.TreeViewColumn('Integer') # These will be our column
column_str = gtk.TreeViewColumn('String')  #  headings in the TreeView widget

view.append_column(column_int) # Associate the columns with the TreeView
view.append_column(column_str) #

cell_int = gtk.CellRendererText()
cell_hex = gtk.CellRendererText()
cell_dec = gtk.CellRendererText()

column_int.pack_start(cell_int) # This column only has one CellRenderer

column_str.pack_start(cell_hex) # This column has two
column_str.pack_start(cell_dec) #

column_int.add_attribute(cell_int, 'text', 0)       # Associate col 0 of model with text of cell_int
column_int.add_attribute(cell_int, 'background', 3) # Associate col 3 of model with the cell background

column_str.add_attribute(cell_hex, 'text', 1)       # Associate col 1 of model with text of cell_hex
column_str.add_attribute(cell_dec, 'text', 2)       #    ditto for cell_dec
column_str.add_attribute(cell_hex, 'background', 3) # Associate col 3 of model with the cell background
column_str.add_attribute(cell_dec, 'background', 3) # Associate col 3 of model with the cell background

store.append([1,'0x01','1','red'])   # Add items to the store
store.append([2,'0x02','2','green']) #
store.append([3,'0x03','3','blue'])  #
store.append([4,'0x04','4','wheat']) #
store.append([5,'0x05','5','gray'])  #
store.append([0,'','',''])           #

window = gtk.Window()
window.add(view)

window.show_all()
window.connect('delete_event', gtk.main_quit)
gtk.main()

I've written it to be as simple as possible, (hence no classes, functions, etc.), so that the associations between the ListStore, TreeView, TreeViewColumns, and CellRenderers are obvious. The result is ugly (both the code and the screenshot!), but effective at achieving the desired result. Note that the hex and dec CellRenderers are both under the 'Strings' heading and how you can associate the model with more than just the text, in this case the background color of the cell.

For more details including sorting, additional attributes, and signals see chapter 14 of the PyGTK tutorial http://www.pygtk.org/pygtk2tutorial/sec-TreeModelInterface.html upon which this post is heavily based.

Wednesday, July 25, 2007

Predefined Macros in gcc

gcc (well cpp, the preprocessor) provides several predefined macros. Many of these are platform independent, for instance __FILE__ and __LINE__. Others are platform dependent (or "system-specific" as the gcc manual puts it). So how do you know what your particular platform defines? Try this:
cpp -dM /dev/null I stumbled across this trick the other day on Apple's mailing lists archives.

Linux Kernel Threads Can Have Priorities and Can Dereference current

My memory failed me on some points of kernel threads today so hopefully this post will solidify my knowledge.
  • Kernel threads can have a priority via the "nice" mechanism. It is set using set_user_nice(tsk, nice_level), just as for userspace processes/threads.
  • As a consequence of the above point, kernel threads have a task structure and it may be referred to by the current pointer, again, the same as is the case with userspace processes/threads.
set_user_nice() should be called from within the task callback function supplied to kthread_create().

Friday, July 20, 2007

"Real HTML" in blogger

Ok, first things first... If you're a control freak like I am and want to actually use "real" HTML (tables, div, etc.) in your posts to blogger, the first thing you should do is disable the automatic conversion of line breaks to the <br /> tag.

Of course, then you'll have to explicitly add <br /> tags to format your posts, but at least then you won't waste an hour trying to figure out why your tables look atrocious. (Not that I did that or anything ;)

To do this, log in, hit the "Settings" tab, then the "Formatting" tab, then set "Convert Line Breaks" to "No".

In other words "Settings"->"Formatting"->"Convert Line Breaks" = "No".

Thursday, July 19, 2007

Emacs Notes

This is my general emacs knowledge base. Some of these keys/features I use everyday others I always forget about, hence the existence of these notes.

//           When opening (visiting) a file (C-x C-f), disregards everything before //
M-\          Kills whitespace pointed to by point
M-^          Merge the current line with previous line (taking away whitespace)
C-x C-x      swap mark and point
C-space      set new mark
C-u C-space  goto next mark in ring
C-M-space    mark to end of paren
C-t          transpose two chars
M-t          transpose two words
C-M-t        transpose two balanced expressions
C-M-f        move forward one balanced expression
C-M-b        move backward one balanced expression
C-M-k        kill balanced expression forward
C-M-<del>    kill balanced expression backward
C-x C-t      transpose two lines
M-m          move to first non-whitespace on line
C-c C-e      in C-mode expands macros into new buffer
C-M-q        toggle-read-only
C-x w h      highlight a regexp
C-x w r      unhighlight a regexp
M-x find-file-at-point Opens file at point
M-x apropos  Find an emacs command based on regexp
M-x woman    Advanced manual page browser
C-x >        scroll right
C-x <        scroll left
C-x C-+      Increase font size
C-X C--      Decrease font size

Narrowing
C-x n d      Narrow to defun  (one C-function)
C-x n n      Narrow to region
C-x n w      widen

Minibuffer
M-s          Search minibuffer history forward
M-r          Search minibuffer history backward

Kill Ring
C-h v kill-ring    View contents of kill ring
C-u C-y            Yank, but leave point at beginning of yanked text

TAGS (old tags)
M-. TAG            Find a TAG
C-u M-.            Find next TAG
C-M-. PATTERN      Find a TAG using regexp PATTERN
C-x 4 . TAG        Find a tag but put in another window
M-*                Pop back to where you invoked a TAG search
M-x tags-search    Search multiple files for regexp
M-,                Continue tags search
M-x list-tags FILE Lists all tags in a file
M-x tags-apropos   Lists all tags matching a regexp

GTAGS
M-. TAG                find TAG
M-? TAG                find all references to TAG
[f3] TAG               create TAG completion list "global -c TAG"
M-x gtags-symbol-find  find a symbol (similar to [f6])

M-x ps-spool-region-with-faces
M-x desktop-read
M-x desktop-save

"C-mode"
M-a  backward statement
M-e  forward statement
C-M-u  up conditional (block)
C-M-d  down conditional (block)
C-M-n  next conditional (block)
C-M-p  prev conditional (block)
C-c C-a  Toggle Autonewline minor mode
C-c C-d  Toggle Hungry Delete minor mode
C-c C-t  Toggle both Autnewline and Hungry Delete minor modes
C-c C-\  Add \'s to a region for multi-lined macros
C-u C-c C-\  Remove \'s from multi-line macros
M-q  In a C comment, wrap text appropriately.
M-j  Add a line break in a comment.
C-x `  go to next compilation error

DIRED
(to enter)
C-x d                Enter dired mode
C-x f [tab] [enter]  Enter dired mode while visiting file
(once in)
i                    Show contents of directory at point
g                    Update buffer (reread directory from disk)
d                    Mark file at point for deletion ('D' not '*')
u                    Ummark file at point
x                    Delete (expunge) files marked for deletion
% d <regexp>         Mark files for deletion matching regexp
% m <regexp>         Mark files matching regexp
% g <regexp>         Mark all files which contain regexp (like grep)
[del]                Unmark move point up one line
[enter]              Visit file at point
f                    Visit file at point (Same as [enter])
e                    Visit file at point (Same as [enter])
o                    Visit file at point in other window
C-o                  Visit file at point in other window, but stay in dired window
v                    View file at point (read only, q to quit)
^                    Move up to parent directory (..)
m                    Mark a file (with '*' not 'D')
* s                  Mark all files in current dired window
* t                  Toggle marked files (unmark all marked, mark all unmarked)
* %                  Same as  % m <regexp>  above
* !                  Unmark all marked
* /                  Mark all directories except . and ..
C <name>             Copy current file, see manual for multiple files (marked files)
R <name>             Rename current file, see manual for multiple files
M <mode>             Change mode of file(s) (uses chmod modes)
G <newgroup>         Like chgrp
O <newowner>         Like chown
S <name>             Make symbolic link
Z                    Compress marked files (or uncompress if compressed)
! <cmd>              Run shell command <cmd> on all marked files.  If <cmd> contains '*', '*' expands to all marked files
X <cmd>              Same as ! <cmd>
% R <from> <to>      Use regular expression to rename file ^.*$ to x-^.*$ adds "x-" to all marked files
% C <from> <to>      Use regular expression to copy file ^.*$ to x-^.*$ makes new files with "x-"
% S <from> <to>      Use regular expression to symlinks files ^.*$ to x-^.*$ adds "x-" to all symlinks
q                    Quit (kill dired buffer)
=                    diff files at point and mark (uses dired-diff as command)
M-=                  diff file at point with it latest backup (.*~)
C-x u                (undo, unmark all marked, restore names of renamed files)
M-x find-dired       Use the 'find' command to fill dired buffer
M-x find-name-dired  Use the 'find' command employing -name to fill dired buffer
M-x find-grep-dired  Use the 'find' command with grep to fill dired buffer
M-x locate           Similar to 'locate' command

VC (clearcase.el)
C-x C-q              Toggle read-only on non-version controlled element
                   Checkout or checkin (whatever makes sense) version controlled element
C-x v v              Checkout or checkin (whatever makes sense) version controlled element
C-x v ~ <version>    View a specific version of a file (dired mode kicks in on tab)
C-x v i              Runs mkelem on current buffer (NOT TESTED!)
C-x v l              Display history on current buffer
C-x v u              Revert element (uncheckout current buffer)
C-x v e              Edit config spec
C-c C-c              Finishes a comment session (on checkin or checkout)
v v                  (In dired mode) Checkout or checkin all marked files (whatever makes sense for each file)

Emacs server/client
(server-start)       Starts emacs server. Clients connect with emacsclient command.
C-x #                Unblock emacsclient and kill emacsclient buffer
EDITOR               (Environment variable, set this to emacsclient)
ALTERNATE_EDITOR     (Environment variable, set to a different editor if emacs server not running)

International input mode
C-\                  Enter\Get out of international input mode.
_a                   1ª (feminine ordinal)
_o                   1º (masculine oridinal)
~c                   ç (ce com cedilha)
~a                   ã,õ - nasals
^a                   â,ô,ê - circumflex (hat)
'a                   á,é,í,ó,ú, - accent (acento agudo)
`a                   à - grave accent (acento grave)

Environment Variables
M-x getenv
M-x setenv

GDB mode
C-x space            Set breakpoint at point
M-s                  step
M-n                  next
M-i                  stepi
M-c                  continue

Filtering/Searching
M-x occur <RET> REGEXP <RET>        Lists in a buffer all lines matching REGEXP
M-x how-many <RET> REGEXP <RET>     Shows how many lines match REGEXP
M-x flush-lines <RET> REGEXP <RET>  Filter out lines matching REGEXP
M-x keep-line <RET> REGEXP <RET>    Filter out all lines not matching REGEXP 

Rectangles
C-x r k              Kill a rectangle
C-x r y              Yank a rectangle
C-x r d              Delete contents of a rectangle
C-x r o              "open" a rectangle, inserts spaces the same size as the rectangle
C-x r t string       Replace contents of a rectangle with string
C-x r c              Clears a rectangle (replaces with spaces)