Skip to content

Instantly share code, notes, and snippets.

View harshkn's full-sized avatar

Harsha K N harshkn

View GitHub Profile
@harshkn
harshkn / MainTextBoxWithBckSpace
Created May 18, 2011 03:18
Focus MainTextBox on load with backspace functionality
window.onload = function () {
// focus on the input field for easy access...
var input = document.getElementById ('focusme');
input.focus ();
// ...but if someone wishes to go back in their history, let them!
document.onkeydown = function (e) {
if (!e) {
var e = window.event;
}
if (e.keyCode === 8 && !input.value) {
@harshkn
harshkn / CircBuffer.c
Created April 8, 2011 09:26
C Implementation of simple circular buffer, Functionality provided are add to queue, read latest
typedef struct circular_buffer
{
void *buffer; // data buffer
void *buffer_end; // end of data buffer
size_t capacity; // maximum number of items in the buffer
size_t count; // number of items in the buffer
size_t sz; // size of each item in the buffer
void *head; // pointer to head
void *tail; // pointer to tail
} circular_buffer;