Skip to content

Instantly share code, notes, and snippets.

@TheBuzzSaw
TheBuzzSaw / Action.hpp
Created May 17, 2018 03:01
Action callback
#ifndef ACTION_HPP
#define ACTION_HPP
template<class T> struct Action
{
void (*callback)(T*);
T* data;
};
template<class T> void SafeCall(Action<T> action)
using System;
namespace _440
{
class Program
{
static void Main(string[] args)
{
int n = 440;
for (int i = 0; i < 8; ++i)
@TheBuzzSaw
TheBuzzSaw / FizzBuzz2017.cs
Created December 20, 2017 21:12
FizzBuzz just because
using System;
namespace FizzBuzz
{
class Program
{
static void PlayTheGame(int maxValue, params (int factor, string phrase)[] rules)
{
for (int i = 1; i <= maxValue; ++i)
{
@TheBuzzSaw
TheBuzzSaw / SecretSanta.cs
Created December 11, 2017 21:46
Secret Santa algorithm!
using System;
namespace SecretSanta
{
class Program
{
static void GenerateSecretSantas(Random random, params string[] people)
{
var assignments = new string[people.Length];
Array.Copy(people, assignments, people.Length);
@TheBuzzSaw
TheBuzzSaw / ImageFinder.cs
Created September 24, 2017 06:45
Takes card name and filters it down to proper image title
using System;
using System.Linq;
using System.Text;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace TheGreatRename
{
class Program
@TheBuzzSaw
TheBuzzSaw / Terrain2D.cpp
Last active September 10, 2017 23:08
2D Terrain Generation Sample
#include <iostream>
#include <vector>
#include <random>
#include <string>
#include <cstdint>
#include <cstring>
#include <ctime>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
@TheBuzzSaw
TheBuzzSaw / normal.cpp
Created August 21, 2017 22:35
Normal distributions
#include <iostream>
#include <random>
#include <ctime>
using namespace std;
int main(int argc, char** argv)
{
mt19937 mt(time(nullptr));
normal_distribution<double> distribution(0.0, 4.0);
@TheBuzzSaw
TheBuzzSaw / FizzBuzz2017.cpp
Created July 31, 2017 23:44
FizzBuzz with minimized redundant code
#include <iostream>
using namespace std;
struct Pair
{
int multiple;
const char* word;
};
int main(int argc, char** argv)
@TheBuzzSaw
TheBuzzSaw / trick.cpp
Created December 8, 2016 18:37
Trick C++ Question
#include <iostream>
using namespace std;
class Base
{
int _value;
public:
Base()
{
@TheBuzzSaw
TheBuzzSaw / VulkanDump.cpp
Created November 14, 2016 00:08
introductory headless Vulkan device data dump
#include <vulkan/vulkan.h>
#include <iostream>
#include <cassert>
using namespace std;
void DumpPhysicalDevice(VkPhysicalDevice physicalDevice)
{
VkPhysicalDeviceProperties properties;
vkGetPhysicalDeviceProperties(physicalDevice, &properties);