Skip to content

Instantly share code, notes, and snippets.

View apfohl's full-sized avatar
🎓
learning...

Andreas Pfohl apfohl

🎓
learning...
View GitHub Profile
@apfohl
apfohl / mcstatus.js
Last active December 10, 2021 07:29
Scriptable.app Minecraft server status widget
/*
The MIT License (MIT)
Copyright (c) 2020 Andreas Pfohl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@apfohl
apfohl / git-commands.md
Last active July 26, 2017 08:37
Git Commands

Git Commands

General

Command Description
git init Create Git repository
git clone [repository] Clone Git repository
git add [file] Add file to staging area
git rm --cached [file] Remove file from staging area
@apfohl
apfohl / shm.c
Created December 17, 2015 15:16
Shared memory example
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/shm.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
/* shared memory segment */
@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;
@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 / 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 / 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 / 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;