Skip to content

Instantly share code, notes, and snippets.

@JostTim
JostTim / emojis.md
Last active March 19, 2021 12:13 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@JostTim
JostTim / ByteFlip.cpp
Last active March 28, 2021 20:13
Flip bytes inside a variable, independantly of variable type. C++ - Arduino friendly
#include <cmath>
#include <iostream>
// Swaps the bytes of an arbitrary sized variable in the same variable type.
// Lightweigted memory usage and compatible with Arduino
// For a more lightweighted memory usage, comment shift_buffer and declare it
// inside output_variable value update line (lesser readability but smaller memory impact)
// TODO : For greater efficiency, could use a kinf of Look Up Table with a list of 8 64 bits shift buffers
// depending on index, and reinterpret_cast them to smaller variable type depending on "any_type".
// Would use a littel bit more space (64 more bytes) but could be more efficient than calculating power of 2 every call.
@JostTim
JostTim / CRC16.cpp
Last active March 28, 2021 21:46
Computes the Cyclic Redundancy Check (CRC) over 2 bytes (16bits) (CCITT-FALSE algorithm) for a variable of any type. C++ - Arduino friendly
#include <cmath>
#include <iostream>
// Swaps the bytes of an arbitrary sized variable in the same variable type.
// Fast and compatible with Arduino.
void CalculateTable_CRC16(uint16_t crctable16[256]){
const uint16_t generator = 0x1021;
const uint16_t checker = 0x8000; // or 0x8000
for (int divident = 0; divident < 256; divident++){ /* iterate over all possible input byte values 0 - 255 */
uint16_t curByte = (uint16_t(divident << 8)); /* move divident byte into MSB of 16Bit CRC */
@JostTim
JostTim / VariableFromByteArray.cpp
Last active March 28, 2021 22:00
Merges and casts 8bit chunks of data (recieved via UART for example) into any ariable type. C++ - Arduino Friendly
#include <iostream>
// Merge a variable from a byte (or basically any 8bit data) array
// into a variable with any given type.
// Small memory inprint. C++ and Arduino Friendly
template <typename any_type>
any_type VariableFromByteArray(char* values) {
uint64_t buffer_variable = 0;
for (uint8_t i = 0; i < sizeof(buffer_variable); i++) {
buffer_variable = buffer_variable | (((uint64_t)values[i]) << 8 * i);
@JostTim
JostTim / .gitconfig
Created May 18, 2021 15:48 — forked from shawndumas/.gitconfig
Using WinMerge as the git Diff/Merge Tool on Windows 64bit
[mergetool]
prompt = false
keepBackup = false
keepTemporaries = false
[merge]
tool = winmerge
[mergetool "winmerge"]
name = WinMerge
@JostTim
JostTim / knownpaths.py
Created August 9, 2021 09:49 — forked from mkropat/knownpaths.py
Python wrapper around the SHGetKnownFolderPath Windows Shell function
import ctypes, sys
from ctypes import windll, wintypes
from uuid import UUID
class GUID(ctypes.Structure): # [1]
_fields_ = [
("Data1", wintypes.DWORD),
("Data2", wintypes.WORD),
("Data3", wintypes.WORD),
("Data4", wintypes.BYTE * 8)