Skip to content

Instantly share code, notes, and snippets.

View reqshark's full-sized avatar
🪂
ridge soaring

Bent Cardan reqshark

🪂
ridge soaring
View GitHub Profile
@reqshark
reqshark / coro.c
Created April 7, 2016 15:08 — forked from lpereira/coro.c
Simple coroutine implementation in C
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
typedef struct coro_t_ coro_t;
typedef struct thread_t_ thread_t;
typedef int (*coro_function_t)(coro_t *coro);
typedef enum {
CORO_NEW,
@reqshark
reqshark / parse-number.c
Created April 7, 2016 15:02 — forked from lpereira/parse-number.c
Number parsing using C11 _Generic
/* parse_number() using C11 _Generic */
/* @lafp, 2015-06-07 */
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <errno.h>
#define parse_number(Input, Output) \
_Generic((*Output), \
int: parse_number_strtoint, \
@reqshark
reqshark / configure.js
Created April 5, 2016 06:44
after ./autogen.sh && ./configure
require('fs').readFile('libsodium/config.log', 'utf8', (err, l) => {
var f = l.split('## Output variables. ##')[1].split('## confdefs.h. ##')
var cflags = f[0].split('\n').filter(i => /^CFLAGS/.test(i))
var defs = f[1].split('\n')
.filter(i => /define/.test(i))
.map(i => i.slice(8)
.split(' ')
.join('='))
console.log(cflags)
@reqshark
reqshark / protocol.c
Created April 4, 2016 19:40
some protocol.c
/*
Copyright (c) 2016 Bent Cardan
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 furnished to do so, subject to the following conditions:
@reqshark
reqshark / client.js
Created March 26, 2016 22:15
a nanomsg ws pub/sub
/**
* websocket
*/
module.exports = sp
var timeo
function sp (ip) {
clearTimeout(timeo)
var ws = new WebSocket('ws://' + ip + ':49001', [ 'pub.sp.nanomsg.org' ])
@reqshark
reqshark / sodium_demo.c
Created March 4, 2016 07:23 — forked from GraxRabble/sodium_demo.c
This c file demostrates how to use each libsodium functions and lets you play with them to see their outputs.
/*
* GraxRabble
* 04 MAY 2014
* Note this was created for the 4.5 version of libSodium.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sodium.h" /* library header */
@reqshark
reqshark / asymmetric.c
Created March 4, 2016 07:15
libsodium diffie hellman key exchange
#include <sodium.h>
// also check out https://gist.github.com/GraxRabble/cd9b3a2a1072522d6ba2
#define MAX_INPUT_LEN 4096
/*
* print_hex() is a wrapper around sodium_bin2hex() which allocates
* temporary memory then immediately prints the result followed by \n
*/
static void print_hex(const void *bin, const size_t bin_len) {
@reqshark
reqshark / errs.h
Created March 3, 2016 16:22
errnos
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
@reqshark
reqshark / ipc.c
Created February 28, 2016 22:05
trigger mill panic
/*
Copyright (c) 2016 Bent Cardan
Copyright (c) 2016 Fatih Kaya
Copyright (c) 2016 Martin Sustrik
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,
@reqshark
reqshark / oak.markdown
Created February 23, 2016 10:45
oak git style guide

oak git style guide by reqshark

dont push the big green button!

That's how we get extra merge commits and a bunch of noise on the commit log.

the oak workflow for collaborative PR merge on github

also same as nodejs or expressjs collaborative git style

​lets run through an example workflow and of merging a branch called ayyyeeee