Skip to content

Instantly share code, notes, and snippets.

View chris-marsh's full-sized avatar

Chris Marsh chris-marsh

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE 1
#define FALSE 0
typedef struct {
char *key;
char *value;
@chris-marsh
chris-marsh / gui.c
Created January 5, 2017 21:14
Design pattern: First Class Abstract Data Type
#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
typedef struct Window* WindowPtr;
struct Window {
char *title;
GtkWidget *win;
};
@chris-marsh
chris-marsh / grok_vi.mdown
Created February 16, 2016 15:32 — forked from nifl/grok_vi.mdown
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@chris-marsh
chris-marsh / split_opts.sh
Last active February 3, 2016 21:48
Shell script to take an argument list and expand any grouped short options. For example; -lotr becomes -l -o -t -r.Compatible with most shells. Tested on Bash, Dash and BusyBox.
#!/bin/bash
#
# Chris Marsh 2016
# Written for compatibility. Tested on Bash and BusyBox.
#
# -----------------------------------------------------------------------------
# Takes an argument list and expand any group short arguments into seperate
# options.
# Usage: eval "set -- $(split_opts "$@")"
# eval "set -- $(split_opts "-lotr -file /some/file.txt)"
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree.git'
Plugin 'kien/ctrlp.vim'
Plugin 'flazz/vim-colorschemes'