This file contains hidden or 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
using UnityEngine; | |
[System.Serializable] | |
public struct MinMax { | |
public float min; | |
public float max; | |
public MinMax(float min, float max) { | |
this.min = min; | |
this.max = max; |
This file contains hidden or 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
public static class VectorExtensions { | |
public static Vector2 Add(this Vector2 vector, float x = 0, float y = 0) { | |
return new Vector2(vector.x + x, vector.y + y); | |
} | |
public static Vector3 Add(this Vector3 vector, float x = 0, float y = 0, float z = 0) { | |
return new Vector3(vector.x + x, vector.y + y, vector.z + z); | |
} | |
public static Vector2 Scale(this Vector2 vector, float x = 1, float y = 1) { |
This file contains hidden or 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
def of_types(*types, omit_error=False): | |
def decorator(function): | |
def wrapper(*args, **kwargs): | |
for arg, t in zip(args, types): | |
if not isinstance(arg, t): | |
if omit_error: | |
return | |
raise TypeError(f"Invalid arguement type {t}({arg}) in {function.__name__}{args}") | |
return function(*args, **kwargs) | |
return wrapper |
This file contains hidden or 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 <chrono> | |
#include "math.h" | |
#include <tuple> | |
#include <vector> | |
#include <set> | |
#define printl(o) std::cout << o << std::endl; | |
#define print(o) std::cout << o; | |
#define number long double |
This file contains hidden or 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
import numpy as np | |
from manimlib import * | |
import math | |
class NewtonRaphsonExample(Scene): | |
def newton_raphson_solve(self, x): | |
result = x - self.f(x)/self.df(x) | |
# It is possible that the result will be infinite, | |
# In that case, we just return a large number. |
This file contains hidden or 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 <string> | |
#include <map> | |
#include <functional> | |
#include <iterator> | |
int main() { | |
//Define operations and their respective function | |
std::map<std::string, std::function<int(int, int)>> operations; | |
operations["+"] = [&](int lhs, int rhs) { return lhs + rhs; }; |
This file contains hidden or 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
# requires ffmpeg-python and click | |
import click | |
import ffmpeg | |
import os.path | |
def extract_track(filepath, track_index, output_path): | |
file = ffmpeg.input(filepath) | |
output = ffmpeg.output(file[f"{track_index}"], output_path) | |
ffmpeg.run(output) |
This file contains hidden or 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
struct Vector3 { | |
union { float x; float r; }; | |
union { float y; float g; }; | |
union { float z; float b; }; | |
// return a normalized vector | |
static Vector3 Normalize(const Vector3& v) { | |
float magnitude = Vector3::Magnitude(v); | |
return v * (1 / magnitude); | |
} |
This file contains hidden or 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
using System; | |
using UnityEditor; | |
using UnityEngine; | |
public static class RenderTextureUtils { | |
public static TextureFormat DEFAULT_TEXTURE_FORMAT = TextureFormat.RGBA64; | |
public static String DEFAULT_FILE_FORMAT = "png"; | |
/// <summary> | |
/// Export a RenderTexture asset to a file |