Skip to content

Instantly share code, notes, and snippets.

@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 / steps.txt
Last active Jan 12, 2020
MariaDB configurator and rough steps for RHEL 8
View steps.txt
yum -y install <pkgname>
cmake
gperftools-devel
git clone https://github.com/MariaDB/server.git
cd server
mkdir mariadb-server && cd mariadb-server
cmake -DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc' -DWITH_SAFEMALLOC=OFF ../
@Dracovian
Dracovian / nginx.conf
Last active Jan 12, 2020
Nginx configurator and rough steps for RHEL 8
View nginx.conf
user nobody; # Set the default user for nginx.
worker_processes auto; # The number of worker processes.
worker_rlimit_nofile 1024; # The maximum number of open files per worker process.
events {
worker_connections 512; # The number of worker connections.
use epoll; # Using epoll to handle connection processing (Linux 2.6+ only)
multi_accept on; # Allows for a worker process to accept multiple connections simultaneously.
}
@Dracovian
Dracovian / confphp.sh
Last active Jan 12, 2020
PHP 8 configurator and rough steps for RHEL 8
View confphp.sh
#!/bin/bash
./configure \
--enable-fpm \
--with-fpm-systemd \
--with-fpm-acl \
--enable-fd-setsize=2048 \
--with-openssl \
--with-zlib \
--enable-bcmath \
--with-bz2 \
@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 / with_base32_module.php
Created Sep 8, 2019
2FA token generation with and without a Base32 module.
View with_base32_module.php
<?php
$token = base32_encode('onomatopoeia');
const tokenexp = 10;
function mfa_get_timestamp() : int {
return floor(microtime(true) / tokenexp);
}
const tokenlen = 6;
function mfa_oath_truncate(string $hash) : int {
@Dracovian
Dracovian / PHP_8_JIT.debug
Last active Dec 5, 2019
PHP 8.0.0-dev JIT debug
View PHP_8_JIT.debug
[vagrant@fedora30 ~]$ php -d opcache.enable_cli=1 -d opcache.jit_buffer_size=50000000 -d opcache.jit=1235 -d opcache.jit_debug=1 jit.php
JIT$/home/vagrant/jit.php: ; (/home/vagrant/jit.php)
sub $0x10, %rsp
lea 0x50(%r14), %rdi
cmp $0xa, 0x8(%rdi)
jnz .L1
mov (%rdi), %rdi
cmp $0x0, 0x18(%rdi)
jnz .L7
add $0x8, %rdi
You can’t perform that action at this time.