Skip to content


Killing unresponsive screen sessions (detached or otherwise)

Sometimes some screen sessions becomes unresponsive for whatever reason. To completely kill it, follow these steps:

  • Find sessions using screen -ls
  • Attached to sessions (which may not be responding) with screen -r [SESSION_ID]
  • Kill by pressing Ctrl+a then type :quit

There are also other methods, check http://stackoverflow.com/questions/1509677/kill-detached-screen-session

Posted in Linux. Tagged with .

Ctrl+S on Putty

I have a habit of pressing Ctrl+S on things, unfortunately this also happens a lot when I’m trying to save stuff on Vi through putty.

If you press Ctrl+S on a putty window, the window would freeze and you can’t type anything. Ctrl+S does XOFF so while it accepts commands nothing is returned. To recover, press Ctrl+O

Posted in Linux, Technology. Tagged with .

Diablo 3 installation stuck on Updating game files (Task Manager shows a lot of I/O)

Just tried to install Diablo 3, and it keeps on getting stuck on updating game files. Opening up the Task Manager shows that it is doing a lot of I/O

To fix this, go to services, and re-enable Secondary Logon, god knows why this fixes the game….

Posted in Rant. Tagged with .

LucidChart

For those who want a quick and easy way to draw charts like ERDs etc, check out Ludid Chart. Its seriously convenient and actually have features that most packages do not (such as double sided arrows that lets you pick the relationship on both sides of the entity)

Posted in Information. Tagged with , , .

Using Apple Remote in Windows 7

Recently bought an Apple Remote for presentations etc. for my MacBook Pro, to use it in Windows 7, do the following:

  • Download EventGhost (Mirrored here)
  • Device Manager -> Human Interface Devices, right click Apple IR -> Update Driver -> Browse for Driver -> Let me pick -> USB Input Device
  • Go into EventGhost, start a new tree (File -> New)
  • Configuration -> Add Plugin -> Generic HID -> Pick the USB Input Device (Should be called Apple IR)
  • Add Macro -> Tell it to press keys or whatever you want to do
  • Add Trigger (which should be the Remote button press, to see what ID the button presses are, press a button and see the ID on the left
  • Set auto start EventGhost when machine starts in File -> Options

I’m attaching the screenshot I have (only 2 buttons for presentation)

Posted in Technology. Tagged with , , .

Importing contacts onto iPhone

To import contacts into the iPhone is quite simple. Export the contacts into a vcf format (common contact book format), and simply email it to yourself. Then in iPhone, set up mailbox so you can receive email, and just click on the vcf.

Posted in iOS. Tagged with , , .

Eclipse CDT, MinGW, C99

So by default Eclipse + MinGW = no C99, this is somewhat annoying because initialization of variables in the for loop for example is allowed in C99

To enable, right click a C project -> Properties -> C/C++ Build -> Settings -> GCC C Compiler -> Miscellaneous -> Append -std=c99 to the Other flags text box

Posted in Technology. Tagged with , , , .

Canonical vs Non-canonical input mode for Terminal

Interesting read: http://stackoverflow.com/questions/358342/canonical-vs-non-canonical-terminal-input

Canonical Input:

  • Buffered input
  • CTRL+D (EOF) is processed, the buffer is returned to the program, and if this buffer is empty, read() will interpret that as an actual EOF

Non-canonical Input:

  • Input is immediately returned to pending read()
  • If there are no pending read(), the input buffer is still used to hold the data

Buffered input enables the editing in shells like bash, where you can go back n characters, delete a character, add one etc

EOF handling behavior in canonical input means that when a buffer is returned with a CTRL-D and nothing is in the buffer (if it is the only character available then EOF is generated by read()). This is quite interesting because if the program doesnt care about EOFs (i.e. if it doesnt stop reading on EOF), you can type stuff after a EOF and they get read anyway.

Buffer is used in both modes, its just that no editing is available in non-canonical mode

Posted in Rant. Tagged with , , .

Terminal buffer and getchar(), also side note on EOF

Ever tried this code in a terminal or windows commandline

main() {
    int c;
    while ((c=getchar()) != EOF)
        putchar(c);
}

and wondered why the code only return once a [Enter] key is pressed (thus appearing to be reading a line at a time rather than reading a character at a time)?

The reason is quite simple, when getchar() is called the control is passed to system, which then waits for the user input. Terminals have input buffers which buffers the user input until [enter] is pressed (at which time the buffer is given to the program). The program then of course reads a whole line (including the \n at the end). This can be configured by turning the terminal into non-canonical mode.

As a side note on EOF, in Windows, CTRL+z (^z) at the start of a new line is considered EOF (the character not on the start of the line is considered as the standard Substitute char according to the ASCII table), and on Linux CTRL+D at the beginning of a line sends a EOF.

Posted in C/C++. Tagged with , , , .

C Escape sequences, Hex and Octal

Simple post really, C/C++ escape sequences can include Hex (\xhhh) and Octal codes (\ooo), for example

printf("\135");
//or
printf("\0x5D");

Will both print the ] character (ASCII 93)

Posted in C/C++. Tagged with , , , .