Skip to content

Instantly share code, notes, and snippets.

@abbaswasim
abbaswasim / convert.lex
Last active September 17, 2018 16:35 — forked from rodamber/convert.lex
CamelCase to lower_with_underscore conversion for C/C++ files except symbols starting with two upper characters.
%option 8bit noyywrap yylineno stack
%{
#include <algorithm>
#include <iostream>
#include <cctype>
bool all_caps(const std::string &s) {
return std::none_of(s.begin(), s.end(), ::islower);
}
@abbaswasim
abbaswasim / cpp_legacy_inheritance_vs_std_variant.md
Last active November 21, 2020 23:47 — forked from olibre/cpp_legacy_inheritance_vs_std_variant.md
C++ legacy inheritance vs CRTP + std::variant
@abbaswasim
abbaswasim / param_pack_to_string_vector.cpp
Created March 25, 2021 12:35 — forked from alepez/param_pack_to_string_vector.cpp
C++ parameter pack of any type to vector of strings
template <typename... Args>
std::vector<std::string> toStringVector(Args... args) {
std::vector<std::string> result;
auto initList = {args...};
using T = typename decltype(initList)::value_type;
std::vector<T> expanded{initList};
result.resize(expanded.size());
std::transform(expanded.begin(), expanded.end(), result.begin(), [](T value) { return std::to_string(value); });
return result;
}
@abbaswasim
abbaswasim / xcode-inherit-env.sh
Last active April 5, 2021 00:17 — forked from paulz/xcode-inherit-env.sh
Allow Xcode to access shell environment variables
It was possible to allow Xcode to access shell environment variables like the following:
defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment -bool NO
This doesn't work anymore unfortunatley for some reason, for me what works is to load xcode project with 'open xcode-project' from command line.
@abbaswasim
abbaswasim / disney_brdf.glsl
Created September 1, 2021 00:34 — forked from mateuszwojt/disney_brdf.glsl
Disney Principled BRDF GLSL shader implementation
// Principled PBR Path tracer. Except where otherwise noted:
// Copyright © 2019 Markus Moenig Distributed under The MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
@abbaswasim
abbaswasim / enable_metal_api_validation.sh
Last active September 16, 2022 18:30 — forked from giraphics/run.sh
Enabling Metal Validation Layer through command line application
# Enable Metal validation layer: 0FF-0, ON-1
export METAL_DEVICE_WRAPPER_TYPE=1
export METAL_ERROR_MODE=5
export METAL_DEBUG_ERROR_MODE=5
# Clean and make
make clean && make
# Execute
./YourExecutableName