Skip to content

Instantly share code, notes, and snippets.

View paulthomas's full-sized avatar

Paul Thomas paulthomas

View GitHub Profile
@JessyGreben
JessyGreben / Binary Search Tree - Ruby
Last active September 25, 2020 11:14
Binary Search Tree - Ruby
class Node
attr_reader :value
attr_accessor :left, :right
def initialize(value=nil)
@value = value
left = nil;
right = nil;
end
end
@skeeto
skeeto / Makefile
Created October 21, 2014 03:51
C Object Oriented Programming Example
CFLAGS = -std=c99 -Wall
main : main.o
.PHONY : test clean
test : main
./$^ "*regex*" "*vtable*" < main.c
clean :
@alan-mushi
alan-mushi / fields_magic.c
Created July 29, 2014 10:05
Simple ncurses form example with fields that actually behaves like fields
/*
* Simple ncurses form example with fields that actually behaves like fields.
*
* How to run:
* gcc -Wall -Werror -g -pedantic -o test fields_magic.c -lform -lncurses
*/
#include <ncurses/ncurses.h>
#include <ncurses/form.h>
#include <assert.h>
#include <string.h>
@reagent
reagent / .gitignore
Last active September 13, 2021 15:13
Curses + C Example
demo
*.swp
@davidzchen
davidzchen / sample-google.c
Last active June 16, 2024 18:55
Sample C code using the Google C++ style guide
// Sample file using the Google C++ coding standard.
//
// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
//
// General rules:
// - Indents are two spaces. No tabs should be used anywhere.
// - Each line must be at most 80 characters long.
// - Comments can be // or /* but // is most commonly used.
// - File names should be lower_case.c or lower-case.c
//
@biwakonbu
biwakonbu / quicksort.c
Last active March 26, 2018 16:51
quicksort with c language.
#include <stdio.h>
#include <stdlib.h>
#define STRINGS_SIZE 32
#define DATA_SIZE 10000000
#define SWAP(a,b) {int temp; temp = a; a = b; b = temp;}
void quick_sort(int *, int);
void quick_sort_sub(int *, int, int);
@deekayen
deekayen / 1-1000.txt
Last active July 5, 2024 20:24
1,000 most common US English words
the
of
to
and
a
in
is
it
you
that
@PforPeterPaul
PforPeterPaul / euclidean.c
Created October 14, 2012 17:22 — forked from yankees714/euclidean.c
Implementation of the Euclidean algorithm
int gcd(int a, int b){
if(a%b == 0)
return b;
else
return gcd(b,a%b);
}
@tonious
tonious / hash.c
Last active June 21, 2024 00:57
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
@dafrancis
dafrancis / color.h
Created November 14, 2011 21:29
"Zed's Awesome Debug Macros" from Exercise 20 of "Learn C the Hard Way" (http://c.learncodethehardway.org/). Now with added colours! (Yes I know I use "color" in the code)
#ifndef __color_h__
#define __color_h__
/*
* I got some of the colour codes (as well as having the idea of putting them in a macro) from here:
* http://stackoverflow.com/questions/3506504/c-code-changes-terminal-text-color-how-to-restore-defaults-linux
*/
#define RED "\e[31m"
#define GREEN "\e[32m"