Skip to content

Instantly share code, notes, and snippets.

View astarasikov's full-sized avatar
🐈
🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈

Alexander Tarasikov astarasikov

🐈
🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈
View GitHub Profile
#define RPC_PACK_RAW(buffer, idx, pvalue, size) do {\
if (idx + size >= RPC_PAYLOAD_MAX) {\
RPC_ERROR("data too large");\
goto fail; \
}\
memcpy(buffer + idx, pvalue, size);\
idx += size;\
} while (0)
#define RPC_PACK(buffer, idx, value) \
@astarasikov
astarasikov / hamming.cpp
Created March 28, 2013 21:59
Hamming coding
/*
* Author: Alexander Tarasikov <[email protected]>
* Date: 2013-03-28
*
* Variant 5
* Hamming (15, 11) code
*
*/
#include <iostream>
@astarasikov
astarasikov / gist:5446478
Created April 23, 2013 19:09
C++ Resource Pool Implementation
#include <cstdio>
#include <pthread.h>
#define cas __sync_bool_compare_and_swap
#define TEST_MUTEX 0
#if TEST_MUTEX
#define MUTEX_TEST(x) x
#else
#!/bin/bash
#get the sources via
#svn cat http://svn.tudos.org/repos/oc/tudos/trunk/repomgr | perl - init http://svn.tudos.org/repos/oc/tudos fiasco l4re
#install the required software
#apt-get install make gawk g++ binutils pkg-config subversion grub2iso
#use double quotes in case some spaces or other weird chars are present
FOC_ROOT="$PWD"
# Generated by iptables-save v1.4.2 on Sun Mar 29 19:49:39 2009
*nat
:PREROUTING ACCEPT [612:120070]
:POSTROUTING ACCEPT [2011:162593]
:OUTPUT ACCEPT [2011:162593]
-A POSTROUTING -s 192.168.0.0/16 -o eth3 -j MASQUERADE
COMMIT
# Completed on Sun Mar 29 19:49:39 2009
# Generated by iptables-save v1.4.2 on Sun Mar 29 19:49:39 2009
*filter
-module(midi).
-export([parse/1, parse_file/1]).
-define(BEINT, big-unsigned-integer-unit).
-define(BEBIT, 1/?BEINT:1).
-define(BEINT7, 1/?BEINT:7).
-define(BEINT16, 1/?BEINT:16).
-define(BEINT32, 1/?BEINT:32).
-define(MIDI_HEADER, 16#4d546864:?BEINT32).
#include <iostream>
#include <cstdlib>
#include <pthread.h>
using namespace std;
#define LOOP_COUNT 30
#define NUM_THREADS 4
#define Q_SIZE 5
@astarasikov
astarasikov / gist:7794123
Created December 4, 2013 19:38
minimalistic OpenGL window in Objective-C
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <CoreVideo/CVDisplayLink.h>
@interface SxgeView : NSOpenGLView <NSWindowDelegate>
-(void)registerDisplayLink;
-(void)renderForTime:(CVTimeStamp)time;
-(void)windowWillClose:(NSNotification*)note;
<html>
<script type="text/javascript">
function d2xy(n, d) {
var rx, ry, s, t, x, y;
t = d;
x = y = 0;
for (s = 1; s < n; s *= 2) {
rx = 1 & (t / 2);
#include <stdio.h>
#include <signal.h>
#include <execinfo.h>
#include <ucontext.h>
#include <stdlib.h>
#include <sys/mman.h>
#define PAGE_SIZE 4096
#define PAGE_MASK (PAGE_SIZE - 1)