Skip to content

Instantly share code, notes, and snippets.

Bryce Glover RandomDSdevel

Block or report user

Report or block RandomDSdevel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shafik
shafik / bit_cast_array.md
Last active May 27, 2019
How to use bit_cast to type pun a unsigned char array
View bit_cast_array.md

In C++20 we will hopefully get bit_cast see the proposal and reference implementation. This utility should give us a simple and safe way to type pun.

The one issue I ran into with this utility is that is requires the size of the To and From type to be the same, as well as checking that To and From types are trivially copyable. The static_assert version of the check is as follows:

# define BIT_CAST_STATIC_ASSERTS(TO, FROM) do {                         \
    static_assert(sizeof(TO) == sizeof(FROM));                          \             
    static_assert(std::is_trivially_copyable<TO>::value);               \
    static_assert(std::is_trivially_copyable<FROM>::value);             \
} while (false)
@mbinna
mbinna / effective_modern_cmake.md
Last active Sep 14, 2019
Effective Modern CMake
View effective_modern_cmake.md

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

View NotchFix.swift
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
NSLayoutConstraint.activate([
tableView.topAnchor.constraint(equalTo: view.topAnchor),
@inamiy
inamiy / SwiftElmFrameworkList.md
Last active Sep 12, 2019
React & Elm inspired frameworks in Swift
View SwiftElmFrameworkList.md
@JohnSundell
JohnSundell / Perform.swift
Last active Feb 4, 2019
A function that enables you to easily wrap throwing APIs, to provide a custom error
View Perform.swift
/**
* Perform a throwing expression, and throw a custom error in case the expression threw
*
* - parameter expression: The expression to execute
* - parameter error: The custom error to throw instead of the expression's error
* - throws: The given error
* - returns: The return value of the given expression
*/
func perform<T>(_ expression: @autoclosure () throws -> T, orThrow errorExpression: @autoclosure () -> Error) throws -> T {
do {
@staltz
staltz / introrx.md
Last active Sep 15, 2019
The introduction to Reactive Programming you've been missing
View introrx.md
You can’t perform that action at this time.