Skip to content

Instantly share code, notes, and snippets.

@0xPIT
0xPIT / hexdump.c
Last active October 31, 2022 23:17
Simple hex + ASCII dump
void hexdump(const void* data, size_t size) {
size_t j;
size_t i;
#define nexti (i + 1)
const uint8_t wrap = 16;
char ascii[wrap + 1];
memset(ascii, 0, sizeof(ascii));
for (i = 0; i < size; ++i) {
@0xPIT
0xPIT / exponentialAverageFilter.h
Created December 20, 2021 20:16
Exponential Moving Average Filter
template<typename T>
T exponentialAverageFilter(const T& value, T& pastValue, const float& filterWeight = 0.8) {
return static_cast<T>((1.0 - filterWeight) * pastValue + (filterWeight * value));
}
@0xPIT
0xPIT / encrypt_openssl.md
Created September 24, 2021 08:32 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@0xPIT
0xPIT / gist:133dbdcce613eff8ab60aeeb117fed70
Created June 11, 2020 16:55 — forked from simonw/gist:68d19a46e8edc2cd8c68
Fix "Do you want the application "python" to accept incoming network connections?" by code signing the python executable in your virtualenv - copied here in case https://www.darklaunch.com/2014/02/02/fix-do-you-want-the-application-python-to-accept-incoming-network-connections ever goes away.
With the OS X firewall enabled, you can remove the "Do you want the application "python" to accept incoming network connections?" message.
Create a self-signed certificate.
Open Keychain Access. Applications > Utilities > Keychain Access.
Keychain Access menu > Certificate Assistant > Create a Certificate...
Enter a Name like "My Certificate".
Select Identity Type: Self Signed Root
Select Certificate Type: Code Signing
Check the Let me override defaults box
@0xPIT
0xPIT / stacktrace.cxx
Created November 12, 2017 14:21 — forked from fmela/stacktrace.cxx
A C++ function that produces a stack backtrace with demangled function & method names.
/*
* Copyright (c) 2009-2017, Farooq Mela
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright

Disk Loader Protocol

Baud Rate: 4800

Return Values:

  0   - success
  A   - aborted
  C   - error input tray missing
  E   – input tray empty
@0xPIT
0xPIT / WordsPOsDontUse.md
Last active August 10, 2022 13:00
Words, great agile Product Owners never use

Words (and Phrase) great agile Product Owners never use (in User Stories)

  • About
  • Applicable
  • Approximate
  • Automatic
  • Bad
  • Best
  • Best Practice
  • Between

Programming Principles by John Romero

  1. No prototypes. Just make the game. polish as you go. Don't depend on polish happening later. Always maintain constantly shippable code.

  2. It is incredibly important that your game can always be run by your team. Bulletproof your engine by providing defaults upon load failure.

  3. Keep your code absolutely simple. Keep looking at your functions and figure out how you can simplify further.

  4. Great tools help make great games. Spend as much time on tools as possible.

typedef struct __attribute__((packed)) {
double kP;
double kI;
double kD;
uint8_t checksum;
} PID_t;
PID_t pidParam = { 16.0, 0.10, 1.0, 0 };
@0xPIT
0xPIT / gist:7dd7f043dc55a0a097b3
Created October 31, 2014 16:16
Bit Fields in Gcc: Don't forget to pack!
#include <stdio.h>
typedef struct bits_packed {
unsigned int b0:1;
unsigned int b1:1;
unsigned int b2:1;
unsigned int b3:1;
unsigned int b4:1;
unsigned int b5:1;
unsigned int b6:1;