Skip to content

Instantly share code, notes, and snippets.

Dracovian

Block or report user

Report or block Dracovian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Dracovian
Dracovian / openlibrary.c
Created Mar 28, 2020
Cross-platform method of accessing functions within shared objects/libraries.
View openlibrary.c
#include <stdio.h>
#include <string.h>
/* Preprocessor Macros */
#ifdef _WIN32
#include <windows.h>
#define EXTENSION ".dll"
#define OPENLIB(a) LoadLibrary(a)
#define CALLFUNC(a, b) GetProcAddress(a, b)
#define CLOSELIB(a) FreeLibrary(a)
@Dracovian
Dracovian / pytime.cc
Last active Feb 18, 2020
Incomplete C++ stuff for ArchAlessus
View pytime.cc
#ifdef __cplusplus
#include <cstdio>
#include <cstdlib>
#include <ctime>
/*
* We're not going to bother to extern "C" this whole file despite that
* being the preferred route to take when writing code that can be compiled
* as C or C++.
*
View CIDR Ranges IPv4
Legend:
IPv4/CIDR = Starting IPv4 - Ending IPv4 | Number of IP addresses (Binary Formatting of Subnet) - Subnet Address
0.0.0.0/32 = 0.0.0.0 - 0.0.0.0 | 1 address (11111111 11111111 11111111 11111111) - 255.255.255.255
0.0.0.0/31 = 0.0.0.0 - 0.0.0.1 | 2 addresses (11111111 11111111 11111111 11111110) - 255.255.255.254
0.0.0.0/30 = 0.0.0.0 - 0.0.0.3 | 4 addresses (11111111 11111111 11111111 11111100) - 255.255.255.252
0.0.0.0/29 = 0.0.0.0 - 0.0.0.7 | 8 addresses (11111111 11111111 11111111 11111000) - 255.255.255.248
0.0.0.0/28 = 0.0.0.0 - 0.0.0.15 | 16 addresses (11111111 11111111 11111111 11110000) - 255.255.255.240
0.0.0.0/27 = 0.0.0.0 - 0.0.0.31 | 32 addresses (11111111 11111111 11111111 11100000) - 255.255.255.224
0.0.0.0/26 = 0.0.0.0 - 0.0.0.63 | 64 addresses (11111111 11111111 11111111 11000000) - 255.255.255.192
@Dracovian
Dracovian / archiver.py
Created Jan 27, 2020
What I used to manage my master tracks.
View archiver.py
from os import makedirs, getcwd, walk, path
from zipfile import ZipFile, ZIP_DEFLATED
def create_archive(filename, root, files):
zipfile = path.join(getcwd(), 'Archives')
if not path.exists(zipfile):
makedirs(zipfile)
zipfile = path.join(zipfile, filename)
@Dracovian
Dracovian / pcg.c
Created Jan 11, 2020
Taking another stab at PCG random.
View pcg.c
#include <stdio.h>
#include <malloc.h>
#include <pthread.h>
#include <time.h>
#define MULTIPLIER 0x5851F42D4C957F2DULL
typedef struct {
pthread_mutex_t *mutex;
long long max, mod;
@Dracovian
Dracovian / dynfunc.cc
Created Dec 24, 2019
Dynamic function declaration and execution in C++14
View dynfunc.cc
/* -*-C++-*- */
#include <functional>
#include <cstdarg>
#include <cstdio>
#include <map>
namespace dyn {
template<class Input, class Output>
class DynFunctions {
@Dracovian
Dracovian / 00-about.txt
Last active Nov 30, 2019
Use-case specific PHP tutorials.
View 00-about.txt
Let's assume that we're developing on a Linux server and we have the following project layout:
- /var/www/html
- /private
- /classes
- /a
- class_a.php
- /b
- class_b.php
- /c
- class_c.php
@Dracovian
Dracovian / inverter.c
Created Nov 9, 2019
Inverting a 3x3 Matrix in C
View inverter.c
#include <stdio.h>
typedef struct {
int R1_C1, R1_C2;
int R2_C1, R2_C2;
} Matrix_2x2;
typedef struct {
int R1_C1, R1_C2, R1_C3;
int R2_C1, R2_C2, R2_C3;
View inverse-matrices.md

The Matrix Layout

R1-C1 R1-C2 R1-C3
R2-C1 R2-C2 R2-C3
R3-C1 R3-C2 R3-C3

Let's create a matrix to get the inverse:

A =

| 0 | 0 | 1 |

@Dracovian
Dracovian / libread.cpp
Created Nov 8, 2019
Loading libraries in Windows
View libread.cpp
#include <cstdio>
#include <windows.h>
// I know this is bad practice, but it's only for the sake of example.
using namespace std;
// Prototype our library function in an explicit manner.
typedef int (*AddFunc)(int, int);
int main() {
You can’t perform that action at this time.