Skip to content

Instantly share code, notes, and snippets.

@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>
@dbrockman
dbrockman / degrees-radians.h
Created February 12, 2013 21:52
Convert degrees <-> radians C macros
// Converts degrees to radians.
#define degreesToRadians(angleDegrees) (angleDegrees * M_PI / 180.0)
// Converts radians to degrees.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / M_PI)
@gotcake
gotcake / reference_counting.c
Created October 29, 2013 19:45
A small implementation of reference counting for C. Frees the programmer from keeping track of pointers and knowing when to free them when they are shared between multiple structures and functions.
#include "reference_counting.h"
#include <stdio.h>
#define NULL 0
// reference counting....
static struct m_ref {
void *ptr;
int count;
struct m_ref *next;
@Brick85
Brick85 / somagic_rec_and_play.sh
Created July 21, 2014 11:50
somagic record and play
#!/bin/sh
PIPE=/tmp/somagic-pipe
OUTFILEDIR=~/dirs/Videos/
LOGDIR=~/.somagic-log/
NOW=`date +"%m_%d_%Y_%H_%M_%S"`
OUTFILE=${OUTFILEDIR}fpv_video_${NOW}.mp4
mkdir $LOGDIR
http://homepage.ntlworld.com/edmund.grimley-evans/bcompiler.html
Bootstrapping a simple compiler from nothing
============================================
This document describes how I implemented a tiny compiler for a toy
programming language somewhat reminiscent of C and Forth. The funny
bit is that I implemented the compiler in the language itself without
@laobubu
laobubu / ABOUT.md
Last active October 16, 2024 06:05
A very simple HTTP server in C, for Unix, using fork()

Pico HTTP Server in C

This is a very simple HTTP server for Unix, using fork(). It's very easy to use

How to use

  1. include header httpd.h
  2. write your route method, handling requests.
  3. call serve_forever("12913") to start serving on port 12913
@DmitrySoshnikov
DmitrySoshnikov / writing-a-mark-sweep-garbage-collector.cpp
Created March 15, 2020 08:35
Writing a Mark-Sweep Garbage Collector
/**
* Writing a Mark-Sweep Garbage Collector in C++.
*
* This is a source code for the Lecture 9 from the
* Essentials of Garbage Collectors course:
*
* http://dmitrysoshnikov.com/courses/essentials-of-garbage-collectors/
*
* See full details in:
*