For educational reasons I've decided to create my own CA. Here is what I learned.
Lets get some context first.
/* | |
* MIT License | |
* | |
* Copyright (c) 2021-2022 John "Nielk1" Klein | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |
qApp->setStyle(QStyleFactory::create("Fusion")); | |
QPalette darkPalette; | |
darkPalette.setColor(QPalette::Window, QColor(53,53,53)); | |
darkPalette.setColor(QPalette::WindowText, Qt::white); | |
darkPalette.setColor(QPalette::Base, QColor(25,25,25)); | |
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53)); | |
darkPalette.setColor(QPalette::ToolTipBase, Qt::white); | |
darkPalette.setColor(QPalette::ToolTipText, Qt::white); | |
darkPalette.setColor(QPalette::Text, Qt::white); |
import sys | |
count=0 | |
sys.setrecursionlimit(50000) | |
cache={} | |
def a(m,n): | |
global count | |
global cache | |
count=count+1 | |
if cache.has_key(m) and cache[m].has_key(n): | |
return cache[m][n] |
// Assume we need 32-byte alignment for AVX instructions | |
#define ALIGN 32 | |
void *aligned_malloc(int size) | |
{ | |
// We require whatever user asked for PLUS space for a pointer | |
// PLUS space to align pointer as per alignment requirement | |
void *mem = malloc(size + sizeof(void*) + (ALIGN - 1)); | |
// Location that we will return to user |
HDC hdc = GetDC(NULL); // get the desktop device context | |
HDC hDest = CreateCompatibleDC(hdc); // create a device context to use yourself | |
// get the height and width of the screen | |
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN); | |
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN); | |
// create a bitmap | |
HBITMAP hbDesktop = CreateCompatibleBitmap( hdc, width, height); |
#include <stdio.h> | |
#include <stdlib.h> // atoll | |
#include <stdint.h> // uint64_t | |
#include <inttypes.h> // PRIu64 | |
static const char *humanSize(uint64_t bytes) | |
{ | |
char *suffix[] = {"B", "KB", "MB", "GB", "TB"}; | |
char length = sizeof(suffix) / sizeof(suffix[0]); |
public class LogonTime | |
{ | |
public DayOfWeek DayOfWeek { get; set; } | |
public DateTime BeginTime { get; set; } | |
public DateTime EndTime { get; set; } | |
public LogonTime(DayOfWeek dayOfWeek, DateTime beginTime, DateTime endTime) | |
{ | |
DayOfWeek = dayOfWeek; | |
BeginTime = beginTime; |
#include <iostream> | |
#include <vector> | |
#include <string> | |
using namespace std; | |
void split(string source, string delim, vector<string>& result) | |
{ | |
string tmp; | |
size_t now=-1, next=-1; |
In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:
This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d