Skip to content

Instantly share code, notes, and snippets.

View reedacartwright's full-sized avatar
💭
I may be slow to respond.

Reed A. Cartwright reedacartwright

💭
I may be slow to respond.
View GitHub Profile
@reedacartwright
reedacartwright / xorshift64.h
Last active October 18, 2022 01:36
A 64-bit Xorshift PRNG combined a Weyl Generator. Passes all BigCrush tests.
/*******************************************************************************
Copyright (C) 2009-2017 Reed A. Cartwright, PhD <[email protected]>
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 notice,
@reedacartwright
reedacartwright / pack.cc
Created June 10, 2016 23:27
Pack 4 ASCII Nucleotides into 1 byte
#include <cstring>
#include <cstdint>
#include <cstdio>
uint8_t pack_a(const char *cs) {
uint32_t u;
memcpy(&u,cs,4);
u &= 0x06060606;
u = (u | (u << 6) | (u << 12) | (u << 18)) >> 19;
return u;
@reedacartwright
reedacartwright / portable_endian.h
Created April 30, 2016 01:24 — forked from panzi/portable_endian.h
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, and Mac OS X. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put "port…
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
@reedacartwright
reedacartwright / shell_prompts.txt
Last active August 29, 2015 14:17
Shell Commands for Colorizing Shell Prompt and including error information
# Taken from https://github.com/reedacartwright/shell-config
#
# The following commands will produce a prompt that includes the error code of the
# last command run if it is not zero. E.g.
# [user@host dir $?=123]$
# If the user is not root, the prompt is green, except the error information which is red.
# If the user is root, the prompt is read, except the error information which is green.
# If the last commend exited with a 0, then the prompt looks normal. E.g.
# [user@host dir]$
#
@reedacartwright
reedacartwright / sync-ports
Last active April 15, 2021 04:07
A script to syncronize a local ports directory with the latest revision used to build FreeBSD packages.
#!/bin/sh
# Copyright (c) 2014-2015 Reed A. Cartwright <[email protected]>
# Copyright (c) 2014-2015 Alberto Villa <[email protected]>
# Copyright (c) 2015 Mike Clarke <[email protected]>
#
# This script determines the revision number used to build FreeBSD packages
# and syncs a local ports directory to match it.
#
# USAGE: sync-ports [name or abs_path]
#