This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://godbolt.org/z/vsacWP36z | |
// Note: Only works with x86_64 GCC (trunk) on Godbolt.org --must have a C++ stdlib that supports constexpr vector | |
#include <cstddef> | |
#include <vector> | |
class Storage { | |
private: | |
std::vector<int> foo; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> | |
#include <iostream> | |
#include <string> | |
#include <cstddef> | |
std::array<std::string, 12> ORDINAL_DAYS = { | |
"first", | |
"second", | |
"third", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Produce a Graphviz DOT graph for the entire Factorio crafting tree | |
-- Written by Joshua Saxby (saxbophone) 2021 | |
-- This work is released into the public domain. | |
-- set recipe_data to a table using the official Wube Factorio recipe data Lua | |
-- file, available at: | |
-- https://github.com/wube/factorio-data/blob/7cab1a0d2d0df5029d3208a56636abf5548e955d/base/prototypes/recipe.lua | |
print("digraph {") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import acos, cos, sqrt | |
def dot(x: tuple, y: tuple): | |
return (x[0] * y[0]) + (x[1] * y[1]) | |
def vector_length(v: tuple): | |
return sqrt(v[0] ** 2 + v[1] ** 2) | |
def angle_between(x: tuple, y: tuple): | |
x_len = vector_length(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
struct LinkedList { | |
constexpr LinkedList(const char* name) : next(nullptr), name(name) {} | |
constexpr LinkedList(const char* name, LinkedList* previous) : LinkedList(name) { | |
previous->assign(this); | |
} | |
constexpr void assign(LinkedList* next) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source='source=%s;print(source %% repr(source))';print(source % repr(source)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
// R - return type, Args - argument types, Func - Function taking Args returning R, to call | |
template <typename R, typename ...Args, R Func(Args... args)> | |
R do_something(Args... args) { | |
return Func(args...); | |
} | |
int twice(double v) { | |
return (int)v * 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstddef> | |
char f[] = "caba"; | |
template <std::size_t L, char name[L]> | |
void something() { | |
std::cout << name << std::endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <bitset> | |
#include <iostream> | |
#include <string> | |
#include <cstddef> | |
template<std::size_t INPUT, std::size_t OUTPUT> requires (INPUT >= OUTPUT) | |
std::bitset<OUTPUT> subset(std::bitset<INPUT> input, std::size_t start) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# NOTE: Set your mod's version in your info.json file to "___MOD_VERSION___" to | |
# allow this script to substitute the most recent Git tag in its place at | |
# bundle time. Tags are expected to be in the vX.X.X format. | |
# get current revision from git tag | |
GIT_DESCRIBE=$(git describe) && | |
# omit first character of git-describe output to remove the leading "v" | |
CURRENT_REVISION=$(cut -d '-' -f 1 <<< ${GIT_DESCRIBE:1}) && |