Skip to content

Instantly share code, notes, and snippets.

View fabiocolacio's full-sized avatar

Fábio Colácio fabiocolacio

  • Long Beach, California
View GitHub Profile
@fabiocolacio
fabiocolacio / cyberpunk.pl
Created April 11, 2020 20:33
cyberpunk character generator
#!/usr/bin/env perl
use warnings;
use strict;
sub show_help {
print <<~EOH;
USAGE
=====
@fabiocolacio
fabiocolacio / main.go
Created February 20, 2020 04:38
Golang Mqtt
package main
import (
// Install with `go get github.com/eclipse/paho.mqtt.golang
mqtt "github.com/eclipse/paho.mqtt.golang"
"os"
"time"
"fmt"
)
@fabiocolacio
fabiocolacio / slow.go
Created October 29, 2019 20:05
SlowLoris in Go
package main
import (
"time"
"net"
"fmt"
"flag"
"os"
)
@fabiocolacio
fabiocolacio / twitch
Last active February 14, 2020 22:06
Stream audio or video from online sources
#!/usr/bin/perl
use strict;
if (scalar @ARGV < 1) {
print "No stream specified.\n";
exit 0;
}
sub show_help {
print <<~EOH;
@fabiocolacio
fabiocolacio / sdl-joystick-polling.c
Created December 15, 2017 02:37
A demonstration of using SDL2 to poll the state of buttons and axes on a joystick
#include <SDL2/SDL.h>
// This program shows how to work with joysticks using SDL2.
// This example shows how to do it by manually polling the joystick
// rather than using the sdl event queue.
int main() {
// Initialize the joystick subsystem
SDL_Init(SDL_INIT_JOYSTICK);
// If there are no joysticks connected, quit the program
@fabiocolacio
fabiocolacio / sdl-joystick.c
Created December 14, 2017 23:57
Beginner-friendly demonstration using SDL2 to read from a joystick.
#include <SDL2/SDL.h>
// This program opens a joystick and tells you
// when a button is pressed or an axis is moved.
// This demsontrates how to read from the joystick
// using an event-based system. In another example
// I will show how to poll the state of each button.
int main() {
// Initialize the joystick subsystem for SDL2
int joysticks = SDL_Init(SDL_INIT_JOYSTICK);
@fabiocolacio
fabiocolacio / joy_tester.c
Last active December 23, 2022 06:36
Joystick Test Code for Linux
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/joystick.h>
/*
* Compiles on linux systems only!
*