Skip to content

Instantly share code, notes, and snippets.

@peterspackman
peterspackman / mingw-w64-x86_64.cmake
Last active April 1, 2025 13:46
cmake toolchain file for mingw-w64 x86_64 builds on Ubuntu
# Sample toolchain file for building for Windows from an Ubuntu Linux system.
#
# Typical usage:
# *) install cross compiler: `sudo apt-get install mingw-w64`
# *) cd build
# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/mingw-w64-x86_64.cmake ..
# This is free and unencumbered software released into the public domain.
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
@atoponce
atoponce / gist:07d8d4c833873be2f68c34f9afc5a78a
Last active April 8, 2025 14:06 — forked from tqbf/gist:be58d2d39690c3b366ad
Cryptographic Best Practices

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

@Overv
Overv / HelloTriangle.cc
Created April 24, 2016 18:54
Vulkan hello triangle
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <chrono>
#include <functional>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
@foobaz
foobaz / sqrt.c
Last active September 1, 2024 07:25
Integer square root algorithm
/*
Just like integer division, these functions round down to an integer.
Running this program should produce the following output:
sqrt(3735928559) == 61122
61122^2 == 3735898884
sqrt(244837814094590) == 15647294
15647294^2 == 244837809522436
This algorithm comes from Jack W. Crenshaw's 1998 article in Embedded:
@ELLIOTTCABLE
ELLIOTTCABLE / maintained-badges.markdown
Last active February 8, 2020 02:38
Replacements for StillMaintained badges

Since http://stillmaintained.com is, ironically, no longer maintained, here's some custom GitHub badges for your dead, stale, or frozen projects:

: https://img.shields.io/badge/maintained%3F-no!-red.svg?style=flat
: https://img.shields.io/badge/maintained%3F-seeking:_help_me!-yellow.svg?style=flat
: https://img.shields.io/badge/maintained%3F-rapidly_changing!-orange.svg?style=flat
: https://img.shields.io/badge/maintained%3F-yes!-brightgreen.svg?style=flat
: https://img.shields.io/badge/maintained%3F-feature--frozen-lightgrey.svg?style=flat

You can modify these using [Shields.

@ChiChou
ChiChou / unhex.sql
Last active October 11, 2023 05:44
SQLite3 convert hex string to int (requires sqlite >= 3.8.3)
WITH RECURSIVE
unhex(str, val, weight) AS (
SELECT 'deadbeef', 0, 1
UNION ALL
SELECT
substr(str, 1, length(str) - 1),
val + (instr('0123456789ABCDEF', substr(str, length(str), 1)) - 1) * weight,
weight * 16
FROM unhex WHERE length(str) > 0
)
@paragonie-scott
paragonie-scott / crypto-wrong-answers.md
Last active August 17, 2024 06:33
An Open Letter to Developers Everywhere (About Cryptography)
@rnapier
rnapier / NSData.bytesView.swift
Last active January 30, 2019 00:40
Bytes collection for NSData
import Foundation
// Why bytesView rather than just extending NSData directly?
// Because this way we can keep our extension internal and not conflict
// with someone who imports us and has also extended NSData.
// If you're top-level code, you can just hoist everyting up to NSData directly.
internal extension NSData {
var bytesView: BytesView { return BytesView(self) }
}
@mattbierner
mattbierner / integral_constant_literal.cpp
Last active November 22, 2018 14:41
std::integral_constant user defined literal
/**
Defines a user defined literal that can create std::integral_constant values.
http://blog.mattbierner.com/stupid-template-tricks-stdintegral_constant-user-defined-literal/
*/
constexpr unsigned digit_to_value(char c) {
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
else if (c >= 'A' && c <= 'F') return c - 'A' + 10;
else if (c >= '0' && c <= '9') return c - '0';
else throw std::invalid_argument("c");
@martinmoene
martinmoene / value-semantics-sean-parent.cpp
Created August 18, 2015 15:07
Code from talk: Inheritance Is The Base Class of Evil by Sean Parent at Going Native 2013
// Sean Parent. Inheritance Is The Base Class of Evil. Going Native 2013
// Video: https://www.youtube.com/watch?v=bIhUE5uUFOA
// Code : https://github.com/sean-parent/sean-parent.github.io/wiki/Papers-and-Presentations
/*
Copyright 2013 Adobe Systems Incorporated
Distributed under the MIT License (see license at
http://stlab.adobe.com/licenses.html)
This file is intended as example code and is not production quality.