Skip to content

Instantly share code, notes, and snippets.

View frkd-dev's full-sized avatar

Oleksandr frkd-dev

View GitHub Profile
@frkd-dev
frkd-dev / cpp_header_guard.json
Last active October 30, 2023 13:55
VSCode snippet: C++ include header guard from an uppercased relative path as __SRC_UTILS_FILE_HPP__
{
"C++ header guard": {
"prefix": "guard",
"description": "A C++ header include guard from uppercased file's relative path",
"body": [
"#ifndef __${1:${RELATIVE_FILEPATH/([\\/.-])|(.)/${1:+_}${2:/upcase}/g}}__",
"#define __${1}__",
"",
"$0",
"",
@frkd-dev
frkd-dev / AppleKeyboardLayouts-L.bt
Last active June 27, 2023 08:24
AppleKeyboardLayouts Binary Template for 010 Editor
//------------------------------------------------
//--- 010 Editor v13.0.2 Binary Template
//
// File: /System/Library/Keyboard Layouts/AppleKeyboardLayouts.bundle/Contents/Resources/AppleKeyboardLayouts-L.dat
// Authors: vit9696, frkd_dev
// Version: 0.2
// Purpose: Keyboard layout decoding (replacement of USBKeyboardLayouts.plist)
// Category: Operating System
// File Mask: *.dat
// ID Bytes: 02 EF CD AB
@frkd-dev
frkd-dev / tinyemmet.js
Last active January 13, 2018 13:36
Tiny emmet parser implementation
/*
Tiny emmet implementation.
Cleaned and improved fork of: github.com/valleykid/zen-coding
Supports:
">" - childs, "*" - multiplications, "+" - siblings, "()" - grouping, custom attributes, tag names, "#" - id, "." - class attributes
Usage: let html = emm('div#page>header.hd+(section.sc>div.main-wrap>span*3)+footer.ft>div.a');
*/
@frkd-dev
frkd-dev / time_perf.c
Last active April 13, 2022 08:53
Measure performance for different time functions
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <sys/time.h>
/*
Build:
gcc -o time_perf time_perf.c
@frkd-dev
frkd-dev / cache_test.cpp
Last active November 17, 2021 06:10
CPU cache lines and sizes test
// g++ -std=c++11 -O2 -o cache_test cache_test.cpp
#include <iostream>
#include <time.h>
#include <sys/mman.h>
#define KB * 1024
#define MB KB KB
const size_t memory_size = 32 MB; // memory size allocated for test
@frkd-dev
frkd-dev / directfb-alphablend-example.c
Last active February 28, 2017 11:10
DirectFB blitting and alpha blending documentation by generic code
// https://www.mail-archive.com/directfb-users@directfb.org/msg05080.html
//.------------------------------------------.
//| DirectFB - Hardware accelerated graphics |
//| http://www.directfb.org/ |
//"------------------------------------------"
#include "config.h"
#include <unistd.h>
#include <stdio.h>
@frkd-dev
frkd-dev / netatalk-build.sh
Last active June 15, 2018 18:21
Build netatalk 3.1.10 on Ubuntu 16.04
#!/bin/bash
# Get system to updated state and install required packages
sudo apt update
sudo apt full-upgrade
sudo apt install clang make libdb-dev libgcrypt20-dev libavahi-client-dev libpam0g-dev
# Build and install
./configure --with-init-style=systemd --disable-static
make -j $(grep -c ^processor /proc/cpuinfo)
@frkd-dev
frkd-dev / fast_itoa.c
Created August 12, 2016 13:28
Fastest INT to ASCII string conversion
void uintToCStr(unsigned int val, char* c)
{
static const char digitPairs[201] = {
"00010203040506070809"
"10111213141516171819"
"20212223242526272829"
"30313233343536373839"
"40414243444546474849"
"50515253545556575859"
"60616263646566676869"