Skip to content

Instantly share code, notes, and snippets.

View etale-cohomology's full-sized avatar

Diego etale-cohomology

View GitHub Profile
/*
A Minimal Capture Program
This program opens an audio interface for capture, configures it for
stereo, 16 bit, 44.1kHz, interleaved conventional read/write
access. Then its reads a chunk of random data from it, and exits. It
isn't meant to be a real program.
From on Paul David's tutorial : http://equalarea.com/paul/alsa-audio.html
@ankurs
ankurs / thread.c
Created September 2, 2009 15:50
A Simple Pthread example
#include<pthread.h>
#include<stdio.h>
// a simple pthread example
// compile with -lpthreads
// create the function to be executed as a thread
void *thread(void *ptr)
{
int type = (int) ptr;
fprintf(stderr,"Thread - %d\n",type);
/* TinyWM is written by Nick Welch <[email protected]>, 2005.
* TinyWM-XCB is rewritten by Ping-Hsun Chen <[email protected]>, 2010
*
* This software is in the public domain
* and is provided AS IS, with NO WARRANTY. */
#include <xcb/xcb.h>
int main (int argc, char **argv)
{
@codeslinger
codeslinger / black-scholes.c
Created July 12, 2010 02:50 — forked from ecounysis/LICENSE.txt
Black-Scholes Option Pricing Model in C
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
double Normal(double);
double N(double, double, double, double, double);
double delta(double, double, double, double, double);
double delta2(double, double, double);
double ND2(double, double, double);
@cournape
cournape / gist:1077528
Created July 12, 2011 07:00
cython c++ example
# rectangle.pyx
cdef extern from "Rectangle.h" namespace "shapes":
cdef cppclass Rectangle:
Rectangle(int, int, int, int)
int x0, y0, x1, y1
int getLength()
int getHeight()
int getArea()
void move(int, int)
@GlassGhost
GlassGhost / glxcb.c
Created October 10, 2011 19:23
proper use of xcb and opengl involves x11 since most manufacturers only write libs for x11
/* glxcb.c taken from:
http://xcb.freedesktop.org/opengl/
to compile it use :
gcc -std=c99 -Wall glxcb.c -lxcb -lX11 -lGL -lX11-xcb -o glxcb
*/
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
@rafalrusin
rafalrusin / fbtest.c
Created December 15, 2011 20:22
Linux Frame Buffer Test
#include <linux/fb.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
@dpiponi
dpiponi / example.cu
Created December 20, 2011 17:36
Minimal CUDA example (with helpful comments).
#include <stdio.h>
//
// Nearly minimal CUDA example.
// Compile with:
//
// nvcc -o example example.cu
//
#define N 1000
@submachine
submachine / xrenderstring.c
Created July 27, 2012 10:50
A program that takes: font, string, and renders accordingly using Xlib. Almost a verbatim copy of the one at: http://www.lemoda.net/c/xlib-text-box/index.html
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
/* The window which contains the text. */
struct
{
int width;
@rygorous
rygorous / gist:4172889
Created November 30, 2012 00:28
SSE/AVX matrix multiply
#include <immintrin.h>
#include <intrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
union Mat44 {
float m[4][4];
__m128 row[4];
};