Skip to content

Instantly share code, notes, and snippets.

View objectx's full-sized avatar

Masashi Fujita objectx

View GitHub Profile
@objectx
objectx / find-vc.cmake
Created August 31, 2021 08:03
Find a MSVC directory
# Copyright (c) 2021 Masashi Fujita.
# SPDX-License-Identifier: MIT
cmake_minimum_required (VERSION 3.20)
include_guard (GLOBAL)
define_property (GLOBAL PROPERTY MSVC_INSTALL_DIRECTORY
BRIEF_DOCS "Holds the MSVC installation directory"
FULL_DOCS "Holds the MSVC installation directory to cache the probing result")
@objectx
objectx / clang-nix.sh
Created March 17, 2021 18:11
Minimal clang-11 environment w/ Nixpkgs
nix-shell -p \
llvmPackages_11.libcxxStdenv \
llvmPackages_11.libcxx \
llvmPackages_11.libcxxabi \
llvmPackages_11.lld \
llvmPackages_11.lldClang
@objectx
objectx / findcl.fsx
Created February 26, 2021 06:45
Find installed cl.exe
#r "nuget: BlackFox.VsWhere"
open System.IO
open BlackFox.VsWhere
let findCL (includePrerelease: bool): Result<string, string> =
let vcComponent = "Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
let versionTextPath = "VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt"
/// @brief Helper function for using the `rapidcheck` under the `doctest`.
#pragma once
#include <doctest/doctest.h>
#include <rapidcheck.h>
#include <utility>
namespace rc {
template <typename Testable_>
@objectx
objectx / CMakeLists.txt
Last active July 13, 2020 04:51
Example for add_custom_command/target
cmake_minimum_required (VERSION 3.17)
project (custom_build)
function (build_foo_ var_)
set (artifacts_)
foreach (src_ IN LISTS ARGN)
if (src_ MATCHES "\.fuga$")
get_filename_component (base_ ${src_} NAME_WLE)
@objectx
objectx / build.fsx
Last active August 28, 2019 14:06
Fake script for C++ (with conan)
#r "paket: groupref Fake //"
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.Core.TargetOperators
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open BlackFox.CommandLine
@objectx
objectx / manips.h
Last active February 4, 2018 08:20
State preserving IO manipulator example
/*
* manips.h:
*
*/
#pragma once
#ifndef manips_h__f1fd7c75_0593_40cb_9c6b_848e2f1cd153
#define manips_h__f1fd7c75_0593_40cb_9c6b_848e2f1cd153 1
#include <iostream>
#include <iomanip>
@objectx
objectx / struct_generator.go
Created July 31, 2017 04:59
Q: How to construct a generator whose types are generated via `gopter/gen`
func genStruct() gopter.Gen {
return genStrucType().FlatMap(
func(arg interface{}) gopter.Gen {
// typ := arg.(reflect.Type)
// Q: How to construct a generator?
return nil
},
reflect.TypeOf((interface{})(nil)),
)
}
@objectx
objectx / beginning-gopter.md
Last active July 18, 2017 03:39
gopter 事始め

Go は吊しで testing/quick を property based testing 用に持っているけど、チト薄い感じだったので gopter を試す…


gopter(というか property based testing) の基本は、値の generator が作った値を不変条件を表す関数に流し込んで OK/NG を判定する事。値の生成は gopter がよしなにやってくれる(generator で頑張れば、失敗した後に失敗した事例の絞り込み(property test 界隈では Shrinking と呼称される)も出来る)

// Borrowed from official gopter documentation.
func TestSqrt(t *testing.T) {
	// Property holder
@objectx
objectx / .clang-tidy
Created May 8, 2017 18:29
Place this on the project root and run `clang-tidy -p <BUILD_DIR> -header-filter='.*' <source file>`
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,modernize-*,performance-*,readability-*'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: true
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'