Skip to content

Instantly share code, notes, and snippets.

View JNjenga's full-sized avatar

James Njenga JNjenga

View GitHub Profile
@JNjenga
JNjenga / skeleton_win32_app.cpp
Created May 22, 2024 19:30
Skeleton win32 app window
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#pragma comment(lib, "kernel32")
#pragma comment(lib, "user32")
HWND create_window(const wchar_t* class_name, WNDPROC windproc, const wchar_t* window_name, HWND parent, HINSTANCE h_instance, int x, int y, int w, int h);
@JNjenga
JNjenga / create_ca_cert.sh
Created September 1, 2023 09:00
Generate a CA and client certificate and sign client certificate with CA cert with openssl
# Reference: https://learn.microsoft.com/en-us/azure/application-gateway/self-signed-certificates
#
NAME=$1
DAYS=365
echo "Generating key.."
openssl ecparam -out "$NAME.key" -name prime256v1 -genkey
echo "Generating csr.."
@JNjenga
JNjenga / diction.py
Last active January 8, 2022 12:19
Converts website to text and prints a sorted list of unique words and their occurrences
from bs4 import BeautifulSoup
from collections import OrderedDict
from urllib import request
from urllib.error import URLError, HTTPError
import sys
import re
def get_text(page):
"""
Retrieve text from a site
@JNjenga
JNjenga / log.cpp
Last active October 20, 2020 07:55
A simple C++ logging application using to demonstrate the use of variadic templates and variadic macros
#include <stdio.h>
#include <string>
#define RESET_COLOR "\x1B[0m"
#define INFO_COLOR "\x1B[1;34m"
#define DEBUG_COLOR "\x1B[1;30m"
#define WARNING_COLOR "\x1B[1;33m"
#define ERROR_COLOR "\x1B[31m"
#define LOG(f, ...) log("[LOG]", RESET_COLOR,f, __VA_ARGS__)
@JNjenga
JNjenga / gol.c
Created August 18, 2020 14:43
John Conway's Game of life
#include <stdio.h>
#include <unistd.h>
#ifdef _WIN32
#define clear() printf("\e[1;1H\e[2J");
#else
#define clear() write(STDOUT_FILENO, "\e[1;1H\e[2J",12);
#endif
#define MAX 1000