Skip to content

Instantly share code, notes, and snippets.

@afaikafk
afaikafk / qbasic.micro
Created February 26, 2022 11:58
micro qbasic color scheme
color-link default "#aaaaaa,#0000aa"
color-link comment "#aa00aa"
color-link identifier "#00aa00"
color-link constant "#aa00aa"
color-link constant.string "#ffff55"
color-link constant.string.char "#aa00aa"
color-link statement "#00aa00"
color-link symbol.operator "#ffff55"
color-link preproc "#ffff55"
color-link type "#55ffff"
@afaikafk
afaikafk / build_openssl.bat
Created February 6, 2022 00:20
Build OpenSSL Batch file (Windows)
REM Dependencies: git, 7zip, ActivePerl, NASM, PowerShell, MSBuild, Visual Studio 2015
REM @echo off
setlocal
set VCVARSALL=%VS140COMNTOOLS%..\..\VC\vcvarsall.bat
if not exist "%VCVARSALL%" (
echo "vcvarsall.bat was not found on this path: %VCVARSALL%"
exit /b
)
@afaikafk
afaikafk / django_mutant.md
Created July 12, 2020 15:29
django-mutant introduction

A few words about django-mutant

Setup

So, I just kicked off with django's standard project layout to get up quickly asap, and created an app named mutantgui. The first thing I did is added the database params for postgres in settings.py(so I can use the awesome pgAdmin tool to examine what mutant is doing exactly), enabled the django admin app, and added south, mutant and our mutantgui app to the INSTALLED_APPS list. After running python manage.py syncdb, a couple of mutant tables were created, specifically:

Creating table mutant_modeldefinition

Creating table mutant_basedefinition

@afaikafk
afaikafk / endianness.h
Created May 13, 2019 12:22 — forked from jtbr/endianness.h
cross-platform / cross-compiler standalone endianness conversion
/**
* @file endianness.h
* @brief Convert Endianness of shorts, longs, long longs, regardless of architecture/OS
*
* Defines (without pulling in platform-specific network include headers):
* bswap16, bswap32, bswap64, ntoh16, hton16, ntoh32 hton32, ntoh64, hton64
*
* Should support linux / macos / solaris / windows.
* Supports GCC (on any platform, including embedded), MSVC2015, and clang,
* and should support intel, solaris, and ibm compilers as well.
@afaikafk
afaikafk / jump_table.h
Created May 17, 2018 06:57
Elegant jump table abstraction
struct not_found
{
};
template <typename TKey, typename TValue, TKey...>
struct JumpTable;
template <typename TKey, typename TValue>
struct JumpTable<TKey, TValue>
{
#include <benchmark/benchmark.h>
#include <unordered_map>
struct EnumClassHash
{
template <typename T>
std::size_t operator()(T t) const
{
return static_cast<std::size_t>(t);
@afaikafk
afaikafk / enum_check.h
Created April 24, 2018 06:43
Check if an integral type could be safely cast to an enum.
template <typename TEnumType, TEnumType... EValues>
struct EnumCheck;
template <typename TEnumType>
struct EnumCheck<TEnumType>
{
template <typename IntegralType>
static constexpr bool is_valid(IntegralType value)
{
@afaikafk
afaikafk / gist:5b7a7d089b79395bbac9
Last active August 29, 2015 14:04
Helper decorator for Django unittests, used to make sure that the expected signals were fired the expected number of times.
"""
Helper decorator for Django unittests, used to make sure that the expected
signals were fired the expected number of times.
Usage:
class MyTestCase(TestCase):
@assert_signal_fired({
'my_signal_func': (my_signal_func, 1),
'other_signal_func': (other_signal_func, 0)
@afaikafk
afaikafk / graph.py
Last active December 10, 2015 18:38
edX MIT 6.00x Problem Set 10 solution / approach 2
# 6.00 Problem Set 10
# Graph optimization
#
# A set of data structures to represent graphs
#
class Node(object):
def __init__(self, name):
@afaikafk
afaikafk / graph.py
Last active April 16, 2016 08:36
edX MIT 6.00x Problem Set 10 solution
# 6.00 Problem Set 10
# Graph optimization
#
# A set of data structures to represent graphs
#
class Node(object):
def __init__(self, name):