Skip to content

Instantly share code, notes, and snippets.

View apfohl's full-sized avatar

Andreas Pfohl apfohl

View GitHub Profile
@apfohl
apfohl / makeindex-fix.patch
Created October 17, 2013 17:55
This patch fixes the makeindex path problem with Rubber.
diff --git a/src/latex_modules/index.py b/src/latex_modules/index.py
index eb59023..a682788 100644
--- a/src/latex_modules/index.py
+++ b/src/latex_modules/index.py
@@ -38,7 +38,7 @@ this argument, they apply to all indices declared at the point where they
occur.
"""
-import os, os.path, re
+import os, os.path, re, string
@apfohl
apfohl / install.md
Last active August 29, 2015 14:05
Installing GitLabHQ with FreeBSD 10

/etc/make.conf

WITH_PKGNG=       yes
WITH_PGSQL_VER=   93
DEFAULT_VERSIONS= ruby=2.1 python=2.7

commands

% cd /usr/ports/ports-mgmt/pkg

% make install clean

@apfohl
apfohl / va_arg.c
Created November 13, 2014 17:05
va_arg c example
#include <stdio.h>
#include <stdarg.h>
int sum(int argc, ...)
{
int res = 0;
va_list ap;
va_start(ap, argc);
@apfohl
apfohl / astyle.c
Created March 6, 2015 12:28
astyle example
/* astyle --style=kr --indent=spaces=4 --indent-switches --pad-oper --pad-header --align-pointer=name --add-brackets -n main.c
* astyle -A3s4SpHk3jn main.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum state {
NONE = 1,
@apfohl
apfohl / getline.c
Created June 14, 2015 18:41
getline example
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fp = fopen("file.c", "r");
char *line = NULL;
size_t linelen = 0;
ssize_t len;
@apfohl
apfohl / sort.cpp
Created June 26, 2015 20:49
Sort array in C++
/*
* Save as "sort.c".
* Compile with "CXXFLAGS=-std=c++11 make sort".
*/
#include <iostream>
#include <algorithm>
struct Distance {
int index;
@apfohl
apfohl / funcptr.c
Created September 15, 2015 18:27
C Function Pointer passing
#include <stdio.h>
union env {
void (*func)();
};
void foo(int a, int b)
{
printf("%d\n", a + b);
}
@apfohl
apfohl / ppp.c
Created November 26, 2015 18:31
Pointer Pointer Pointer
#include <stdlib.h>
#include <stdio.h>
#include <gc/gc.h>
struct node {
int i;
};
struct node *new_node(int i)
{
@apfohl
apfohl / msg.c
Last active April 24, 2020 19:35
C message queue example
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/msg.h>
#include <sys/wait.h>
#include <string.h>
/* message structure */
struct message {
long mtype;