Skip to content

Instantly share code, notes, and snippets.

View dradtke's full-sized avatar

Damien Radtke dradtke

View GitHub Profile

Keybase proof

I hereby claim:

  • I am dradtke on github.
  • I am dradtke (https://keybase.io/dradtke) on keybase.
  • I have a public key ASBD_MPXtGPr6V6O_-rzBlHlXlkqnppmmyRpdiaBNbxdOAo

To claim this, I am signing this object:

extern crate dylib;
extern crate notify;
use dylib::DynamicLibrary;
use notify::Watcher;
use std::fs;
use std::mem::transmute;
use std::path::Path;
use std::sync::mpsc::channel;
use std::thread;
@dradtke
dradtke / main.go
Created February 4, 2016 16:48
Go's "hello world" of web applications.
package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <linux/inotify.h>
#define EVENT_SIZE (sizeof (struct inotify_event))
#define EVENT_BUF_LEN (1024 * (EVENT_SIZE + 16))
int main()
@dradtke
dradtke / main.c
Created February 4, 2015 19:53
A first attempt to stream Spotify music through Allegro.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <libspotify/api.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_audio.h>
@dradtke
dradtke / cards.rs
Last active August 29, 2015 14:09
Rustic deck of cards.
use std::rand::{task_rng, Rng};
#[allow(dead_code)]
enum Value {
Ace,
Two,
Three,
Four,
Five,
Six,
@dradtke
dradtke / lib.rs
Last active August 29, 2015 14:07
An experiment in designing a turn-based concurrent game architecture.
//! Source file for the `game` crate.
#![allow(dead_code)]
/// The `Player` trait.
pub trait Player {
/// Gets called when it's time for this player to take their turn.
///
/// The game is played by sending commands on `pipe` and checking
/// the responses that are returned.
fn take_turn(&self, pipe: &PlayerActionPipe, round: uint);
package main
import (
"github.com/dradtke/allegory"
)
type MyState struct {
allegory.BaseState
}
package main
import (
"github.com/dradtke/allegory"
"github.com/dradtke/allegory/config"
"github.com/dradtke/go-allegro/allegro"
"math"
)
var (
@dradtke
dradtke / hello-allegro.c
Created May 5, 2014 15:12
Testing cgo with Allegro 5 on Windows.
// Built with:
// gcc -I/Opt/allegro-5.0.10-mingw-4.7.0/include -m32 -L/Opt/allegro-5.0.10-mingw-4.7.0/bin -lallegro-5.0.10-monolith-md hello-allegro.c
//
#include <stdio.h>
#include <allegro5/allegro.h>
int main(void)
{
al_init();