Skip to content

Instantly share code, notes, and snippets.

View byBretema's full-sized avatar
🎨
I make computers draw things!

Daniel Brétema byBretema

🎨
I make computers draw things!
View GitHub Profile
@byBretema
byBretema / unity_DebugUVs.shader
Created April 25, 2020 18:24
Quick shader to debug texture coordinates of a given mesh
Shader "Custom/DebugUVs" {
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
@byBretema
byBretema / ootb_timer.hpp
Last active January 20, 2021 10:14
Timer Snippet - OOTB
#include <iostream>
#include <string>
#include <chrono>
using Clock = std::chrono::high_resolution_clock;
class Timer {
public:
Timer(std::string const & msg = "") : m_msg(msg), m_iTime(Clock::now()) {}
@byBretema
byBretema / timer.cpp
Last active November 10, 2019 09:53
For easy benchmarking - Timer object that show time when is destroyed.
#include <chrono>
// ------------------------------------------
// Timer
// ------------------------------------------
struct Timer {
using clock = std::chrono::high_resolution_clock;
using unit = std::chrono::duration<double, std::nano>;
private:
std::string_view msg;
@byBretema
byBretema / fake_fmt.cpp
Last active November 10, 2019 09:53
A quick print function that wraps std::cout and allow pass elems of any type to be printed in a function-like way.
#include <iostream>
// ------------------------------------------
// Quick print
// ------------------------------------------
void _printRest(void){}
template <typename H, typename ...T>
void _printRest(const H& head, T&&... tail){ std::cout << " " << head; _printRest(tail...); }
void _printFirst(void){}
template <typename H, typename ...T>
@byBretema
byBretema / safe_mt.hpp
Last active November 2, 2019 10:38
Snippet for C++ multi-thread stuff
#pragma once
#include <functional>
#include <mutex>
class safe_mt {
private:
std::mutex m_mutex;
std::condition_variable m_condvar;
@byBretema
byBretema / .dotfiles
Last active June 20, 2019 16:08
macOS .dotfiles
/**/
@byBretema
byBretema / string_split.cpp
Last active December 5, 2019 12:08
Split an string in c++
std::vector<std::string> strSplit(const std::string& str,
const std::string& delimeter) {
std::string token;
std::vector<std::string> splitted;
size_t ini{0}, end{0};
while ((end = str.find(delimeter, ini)) <= str.size()) {
token = str.substr(ini, end - ini);
ini = end + delimeter.size();
splitted.push_back(token);
@byBretema
byBretema / makefile
Last active January 18, 2019 11:16
Base makefile for c++ projects
# ################## #
# ------------------ #
# MAKEFILE BASE #
# ------------------ #
# By @cambalamas #
# ------------------ #
# ################## #
@byBretema
byBretema / Carbon.ps1
Last active December 1, 2018 20:07
Get 'carbon.now.sh' image on clipboard from the code that was previously on the clipboard :D
# CARBON-NOW-SH : 'npm i -g carbon-now-cli'.
# '-i' to setup your preset
# '-o' to open img on photos
# '--clear' remove all imgs from the folder
# '--path' open the path of imgs
function Carbon {
$path = "${env:LOCALAPPDATA}\CarbonNow\"
$file = "$path\carbon.data"
$imgName = $(Get-Date).Ticks
$imgPath = "$path\$imgName.png"
@byBretema
byBretema / GenericJsonTools.go
Last active October 3, 2018 14:45
Golang funcs that wraps json operations with "generics" and fix .0 floats values in marshal process
package jst
// Made with <3 by @cambalamas
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"