Skip to content

Instantly share code, notes, and snippets.


Al-buharie harieamjari

View GitHub Profile
View x-ray.c
* Minimal deterministic parser
#include <stdio.h>
#include <stdlib.h>
#define ERROR(...) fprintf(stderr, __VA_ARGS__)
#define UNEXPECTED(x) {\
if (x!=TOK_ERR) \
View chunky64.c
/* chunky64: a chunky, fast, 64-bit, portable, keyed hash function
* This is free and unencumbered software released into the public domain.
#include <stddef.h>
#include <stdint.h>
static uint64_t
chunky64(const void *buf, size_t len, uint64_t key)
size_t nblocks = len / 8;
joepie91 / .md
Last active Apr 25, 2021
Prefix codes (explained simply)
View .md

A "prefix code" is a type of encoding mechanism ("code"). For something to be a prefix code, the entire set of possible encoded values ("codewords") must not contain any values that start with any other value in the set.

For example: [3, 11, 22] is a prefix code, because none of the values start with ("have a prefix of") any of the other values. However, [1, 12, 33] is not a prefix code, because one of the values (12) starts with another of the values (1).

Prefix codes are useful because, if you have a complete and accurate sequence of values, you can pick out each value without needing to know where one value starts and ends.

For example, let's say we have the following codewords: [1, 2, 33, 34, 50, 61]. And let's say that the sequence of numbers we've received looks like this:


tailriver / dlopen_sample.c
Created Nov 18, 2015
A sample of using dlopen library.
View dlopen_sample.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
int main(int argc, char** argv)
void *handle;
void (*func_print_name)(const char*);
courtneyfaulkner / devices.c
Created Dec 11, 2013
List OpenCL platforms and devices
View devices.c
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#include <CL/cl.h>
int main() {
niw / libpng_test.c
Last active Apr 11, 2021
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
View libpng_test.c
* A simple libpng example program
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng16 libpng_test.c
jandk / rpn.c
Created Jan 31, 2012
Simple RPN calculator in C
View rpn.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
typedef struct stack
int data;
struct stack *next;
} stack;
pazdera / gist:1121315
Created Aug 2, 2011
Brute-force string generation in Python (optimized for printable characters only)
View gist:1121315
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Brute-force string generation
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.