Skip to content

Instantly share code, notes, and snippets.

View sacko87's full-sized avatar

John T. Saxon sacko87

View GitHub Profile
@sacko87
sacko87 / Makefile
Created August 11, 2012 21:42
IPC Sender and Receiver Example
# the compiler to use
CC =gcc
# flags to send to the compiler
CFLAGS = -O2 -Wall
# executable names
SENDER_EXEC = Sender
RECEVIER_EXEC = Receiver
# compile the message queue programs
@sacko87
sacko87 / Base.cpp
Last active December 10, 2023 09:14
Factory Pattern in C++ with templates (using the confusingly recurring template and registry patterns)
#include "Base.h"
Base::Base() :
IsRegistered_(false)
{ }
Base::Base(bool isRegistered) :
IsRegistered_(isRegistered)
{ }
@sacko87
sacko87 / regex.01.c
Created September 11, 2012 09:26
Regular Expressions in C
/**
* file : regex.match.1.c
* author : John Saxon (09-Mar-2010)
* revision : $Rev$
*
* this program is to demonstrate how to use the POSIX regular
* expression functions (defined in regex.h).
*
* this particular program shows you how to simply say whether
* a give string (argv[1]) is a match for a given regular
@sacko87
sacko87 / signal.c
Last active December 17, 2015 18:29
Signal Handling in C $ gcc -Wall -Werror -pedantic -o signal signal.c
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <execinfo.h>
#ifndef ACTION
#define ACTION SIGSEGV
#endif
@sacko87
sacko87 / utf8.c
Last active August 29, 2015 13:57
#include "utf8.h"
#include <errno.h>
uint8_t
isutf8(const unsigned char *string)
{
int nbytes;
unsigned char *ptr = (unsigned char *) string;
while(*ptr) {
nbytes = 1;
#include "utf16.h"
#include <errno.h>
uint8_t
isutf16(const unsigned char* string)
{
uint16_t W1, W2;
unsigned char *ptr = (unsigned char*) string;
while((W1 = *((uint16_t*) ptr)) != 0x0L) {
if(W1 < 0xd800 || W1 > 0xdfff) {
@sacko87
sacko87 / aria.html
Created May 11, 2014 18:54
A quick example of ARIA.
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>WAI-ARIA Test</title>
</head>
<body>
<div role="application" tabindex="0">
<p id="i1" role="alert" aria-live="assertive">i am text.</p>
<ul role="navgation">
@sacko87
sacko87 / aria.2.html
Created May 11, 2014 19:13
Another example of ARIA without the buttons, instead attaching the events to the div.
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>WAI-ARIA Test</title>
</head>
<body>
<div role="application" aria-controls="p1" class="ctrl" tabindex="0" aria-describedby="i1">
<p id="p1" role="alert" aria-live="assertive">i am text.</p>
<div id="i1">

Keybase proof

I hereby claim:

  • I am sacko87 on github.
  • I am sacko87 (https://keybase.io/sacko87) on keybase.
  • I have a public key ASCNXDKnG-FEgladOQoSvdWNqLIXPlVGhVEN4UVVSFoRXgo

To claim this, I am signing this object:

% draft stuffs
\usepackage{lineno}
\usepackage{totcount}
\@ifpackageloaded{lineno}{}{\newcommand\linenumbers\relax}
\@ifpackageloaded{totcount}{
\newtotcounter{citnum}
\AtEveryBibitem{\stepcounter{citnum}}
\newcommand\refcount{\todo{This document contains \total{citnum}\ references.}}