Skip to content

Instantly share code, notes, and snippets.

View icedraco's full-sized avatar
🐲
Rawr

Artex icedraco

🐲
Rawr
View GitHub Profile
@icedraco
icedraco / CMakeLists.txt
Created January 10, 2016 20:35
Example cmake configuration file for working with OpenGL on JetBrains CLion
# NOTE: IF THIS FAILS, YOU MAY HAVE TO
# sudo apt-get install libxmu-dev libxi-dev
# http://ubuntuforums.org/showthread.php?t=1703770
cmake_minimum_required(VERSION 3.3)
project(ass4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#--- Find GLUT
@icedraco
icedraco / Linux.colorscheme
Last active December 25, 2015 19:53
KDE theme configuration I normally use on my Linux systems
[Background]
Color=0,0,0
[BackgroundIntense]
Color=104,104,104
[Color0]
Color=0,0,0
[Color0Intense]
@icedraco
icedraco / FakeInputStream.java
Created December 15, 2015 08:35
FakeInputStream / FakeOutputStream - InputStream and OutputStream that may help testing implementations that deal with I/O from packet-based streams in Java. Meant mostly for the VpnService-related testing on Android...
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* Simulates an InputStream that provides pre-determined packet data
*
@icedraco
icedraco / HexStreamParser.java
Last active December 10, 2015 14:20
Hexadecimal digit stream parser in Java + tests
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.LinkedList;
import java.util.List;
/**
* Extracts byte data from a text file with comments and a hex stream.
* The comments must start with '#' on each line.
@icedraco
icedraco / check-path.py
Created October 4, 2015 19:13
A script used to recursively check a path for suspicious (less compatible with portable devices) filenames
#!/usr/bin/python
import os
import sys
# Paths longer than this amount of bytes will generate a warning
MAX_PATH_LEN = 256
# Good characters
GOOD_CHARS = " 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?'._-()[]"
@icedraco
icedraco / buffer.c
Created September 12, 2015 21:12
Some circular buffer in C I felt like making once... :P
#include "buffer.h"
Buffer* buffer_create(int capacity) {
if (capacity <= 0)
return NULL;
Buffer* b = (Buffer*)malloc(sizeof(Buffer));
if (b) {
if (b->data = (char*)malloc(capacity * sizeof(char))) {
@icedraco
icedraco / relay.sh
Created September 1, 2015 07:12
BASH Proxy / Relay using NetCat
#!/bin/bash
# Adapted from the script on:
# http://notes.tweakblogs.net/blog/7955/
TMP=$HOME/tmp
PREFIX=proxy
FIFO=`mktemp -u -p $TMP -t $PREFIX.XXXXXXXXXXX`
@icedraco
icedraco / scandev.cpp
Created August 31, 2015 21:35
Obtaining network device details using getifaddrs(3)
#include <stdio.h>
#include <stdint.h>
#include <ifaddrs.h>
#include <netdb.h>
int main(int argc, char** argv) {
struct ifaddrs* addrs;
struct ifaddrs* ifa;
@icedraco
icedraco / ip-allocator.js
Last active September 1, 2015 16:26
JavaScript class that converts and allocates IP addresses in a given range
/**
* Responsible for allocating and deallocating IP addresses in a given range.
*/
var ip = require('./iptools.js');
/**
* @param {string} network IPv4 address of the network address (e.g. "10.0.0.0")
* @param {number} prefix (optional) Network prefix (e.g. 24 for a 10.0.0.0/24 net)
* @constructor
@icedraco
icedraco / pipetest.c
Created August 4, 2015 16:13
Connecting a stdin/stdout of a subprocess to the parent using pipes
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/wait.h>
#define BUFFER_SIZE 4096