Skip to content

Instantly share code, notes, and snippets.

@Geal
Geal / client.rs
Last active March 7, 2022 21:54
Rust and Unix domain sockets usage example * stream sockets (client.rs and server.rs) * datagram sockets (datagram_client.rs and datagram_server.rs) * example of writing to syslog (incomplete for now)
extern mod native;
use std::io::net::unix::UnixStream;
use std::path::posix::Path;
use std::str;
use std::rt::rtio::IoFactory;
use native::io;
fn main() {
@Geal
Geal / fun.rs
Created January 16, 2014 18:30
Fun with mutable readers!
use std::io;
pub struct A<'a, R> {
reader: &'a R
}
pub fn init<'a, R: io::Reader>(r: &'a R) -> ~Parser<'a, R> {
~A {
reader: r
}
../../extras/package/macosx/../../../modules/codec/avcodec/fourcc.c:448:23: error: use of undeclared identifier 'AV_CODEC_ID_OPUS'
{ VLC_CODEC_OPUS, AV_CODEC_ID_OPUS, AUDIO_ES },
^
../../extras/package/macosx/../../../modules/codec/avcodec/fourcc.c:487:43: error: invalid application of 'sizeof' to an incomplete type 'const struct <anonymous struct at
../../extras/package/macosx/../../../modules/codec/avcodec/fourcc.c:39:14> []'
static const size_t codecs_count = sizeof (codecs_table)
^~~~~~~~~~~~~~
2 errors generated.
make[4]: *** [codec/avcodec/libavcodec_plugin_la-fourcc.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
@Geal
Geal / install-sysdig.sh
Last active May 20, 2020 13:44
Curl install pattern
v=`curl -s https://s3.amazonaws.com/download.draios.com/stable/install-sysdig`; if [ "7777a6bb3188993fc70fd8124c03e2880f034be6 -" != "`echo -n "$v" | sha1sum`" ]; then echo "invalid hash"; else `echo "$v" | sudo bash`; fi
package main
import (
"fmt"
"runtime"
"time"
"sync"
)
func main() {
package main
import (
"fmt"
"runtime"
"time"
)
type State struct {
counter int
@Geal
Geal / trait.rs
Last active August 29, 2015 14:04
#![crate_type = "lib"]
#![crate_id = "conveyor"]
#![desc = "A conveyor belt for bytes"]
#![license = "MIT"]
use std::str;
pub trait Producer<T> {
fn take(&mut self, nb: uint) -> & [T];
}
package epsi.com.phototest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Camera;
import android.media.MediaScannerConnection;
import android.net.Uri;
@Geal
Geal / future.c
Last active January 22, 2023 10:07
small future and promise library in C with pthreads
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <stdbool.h>
#include <time.h>
#include <stdarg.h>
#include <string.h>
#include "future.h"
fn main() {
let a = |input: &[u8]| {
input.slice_from(1)
};
println!("a: {}", a("abc".as_bytes()));
}