Skip to content

Instantly share code, notes, and snippets.

View klaxa's full-sized avatar

klaxa

  • Germany
View GitHub Profile
@klaxa
klaxa / stdtest.c
Created April 10, 2012 18:18
output test
#include <stdio.h>
int main(void) {
fprintf(stdout, "This is stdout\n");
fprintf(stderr, "This is stderr\n");
return 0;
}
@klaxa
klaxa / stream.bash
Created September 18, 2012 01:52
Streaming shit
#!/bin/bash
rm /tmp/bar /tmp/foo /tmp/stream
mkfifo /tmp/foo
mkfifo /tmp/bar
mkfifo /tmp/stream
# dump raw streams to fifo pipes
echo Started audio mplayer
screen -d -m mplayer "$1" -ao pcm:file=/tmp/bar -vo null
echo Started video mplayer
What the squid did you just squidding say about me, you little human? De geso. I'll have you know I graduated top of my class in the Navy Squids, and I've been involved in numerous secret raids on Fish Markets, and I have over 300 squidding gills. I am trained in tentacle warfare and I'm the top inker in the entire squid army de geso. You are nothing to me but just another servant. I will wipe you the squid out with precision the likes of which has never been seen before on this Surface World, mark my squidding words. You think you can get away with saying that fish to me over the Internet? Think again, human. As we speak I am contacting my secret network of squids across the Surface and your IP is being traced right now so you better prepare for the tsunami, human. The storm that wipes out the pathetic little thing you call your life. You're squid-ding dead, mouth breather. I can be anywhere, anytime, and I can gill you in over seven hundred kraken ways, and that's just with my bare tentacles. Not only am I
@klaxa
klaxa / muhmpd.lua
Created February 5, 2013 17:53
Fuck your mpd.lua vicious... Fuck it, it's shit and you know it!
-- {{{ Grab environment
local tonumber = tonumber
local io = { popen = io.popen }
local string = { gmatch = string.gmatch, format = string.format}
local helpers = require("vicious.helpers")
-- }}}
local muhmpd = {}
local function to_time(secs)
@klaxa
klaxa / frames.c
Last active December 12, 2015 08:18
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <inttypes.h>
int main(int argc, char **argv) {
if (argc < 2) {
fprintf(stderr, "No fuck you, give me a file to work with!\n");
exit(1);
#ifndef MP3SPLIT_H
#define MP3SPLIT_H
// MP3 FLAGS
#define MPEGV_MASK 0x180000
#define LAYER_MASK 0x60000
#define CRC 0x10000
#define BITRATE_MASK 0xF000
#define SAMPLING_MASK 0xC00
uint32_t get_first_header(int fd) {
uint8_t cur_byte;
uint32_t header = 0;
ssize_t n = 0;
while (n < 1) {
n = read(fd, &cur_byte, 1);
fprintf(stderr, "Read %d bytes\n", n);
if (n < 0) {
fprintf(stderr, "%s\n", strerror(errno));
exit(1);
@klaxa
klaxa / struct.h
Last active December 12, 2015 10:38
struct Frame {
uint32_t header;
uint8_t* content;
};
[...]
pid_t child;
child = fork();
/* the following part /looked/ like this:
if (child == 0)
fprintf(stderr, "mp3_stream fd: %d\n", mp3_stream);
serve_stream(mp3_stream, head_client);
*/
if (child == 0) {
if (child > 0) {
for(;;) {
listen(server, 10);
client_len = sizeof(client_addr);
client = accept(server, (struct sockaddr*) &client_addr, &client_len);
fprintf(stderr, "Got new client!\n");
if (client < 0) {
fprintf(stderr, "Something went wrong while accepting the client!\n");
exit(1);
}