/// Captures are the macro equivalent of enums and macro 1.1 match arms. The capture either
/// contains one anonymous match arm or any number of named match arms. Captures are reusable,
/// i.e. they can be bound to scoped constants which can then be referred to any number of
/// times.
[pub] [macro] capture vertex_attribute {
/// you can use braces, brackets, or parentheses after the colon
unnamed: ( $kind:ty ),
named: {
$name:ident : $kind:ty
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
use std::fmt::Debug; | |
trait BtreeTrait: Debug {} | |
#[derive(Debug)] | |
struct Btree<T: Debug, Tail: BtreeTrait> { | |
val: T, | |
left: Option<Tail>, | |
right: Option<Tail>, | |
} |
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
fn main() { | |
use shape_args::Dot; | |
draw(Dot(5.5)); | |
} | |
// I need a function that works like this: | |
// pub fn draw<D: Drawable, T: Into<D>>(d: T) { | |
// but where Rust can always infer what D is | |
pub fn draw<T: DrawableArg>(d: T) { |
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
fn evaluate_bin_sum(expr: &syn::ConstExpr) -> u64 { | |
match expr { | |
// TODO: Fix the pattern (first match is left == literal, right == binary op, second match should be both are literals) | |
&syn::ConstExpr::Binary(syn::BinOp::Add, ref left, ref right) => { | |
extract_int_value(left) + evaluate_bin_sum(right) | |
}, | |
&syn::ConstExpr::Binary(syn::BinOp::Add, ref left, ref right) => { | |
extract_int_value(left) + extract_int_value(right) | |
}, | |
_ => { |
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
rem add this command to the shortcuts file in Notepad++ | |
rem run_python.bat "$(FULL_CURRENT_PATH)" | |
@echo off | |
Set filename=%1 | |
For %%A in (%filename%) do ( | |
Set Folder=%%~dpA | |
Set Name=%%~nxA | |
) |
I've written this like a billion times because it's fun. The above code is pretty gross but it works...
It will kind of ignore commented lines, assuming those lines are commented out with //.
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
""" | |
This script is designed to export a mass amount of MagicaVoxel .vox files | |
to .obj. Unlike Magica's internal exporter, this exporter preserves the | |
voxel vertices for easy manipulating in a 3d modeling program like Blender. | |
Various meshing algorithms are included (or to be included). MagicaVoxel | |
uses monotone triangulation (I think). The algorithms that will (or do) | |
appear in this script will use methods to potentially reduce rendering | |
artifacts that could be introduced by triangulation of this nature. | |
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
/* An example implemenation of data structures to support a 2D Renderer in (semi) Java... */ | |
class abstract Body { | |
public Vector2f posNext; | |
public Vector2f posPrev; | |
/** | |
* The actual position of the object at time t = t0 + dt * alpha. | |
*/ | |
protected Vector2f pos = new Vector2f(0f, 0f); |
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
/* This is a work in progress, not done yet (doesn't do anything in fact!).*/ | |
// I don't have a website, so it's just my screen name... feel free to refactor | |
// package name how you like. But credit me plz ;D | |
package shivshank.engine.physics; | |
import somepackage.that.doesnt.exist.yet.Vector2f; | |
import java.util.List; | |
import java.util.ArrayList; |
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
#### | |
# Monitor new files in a directory for changes. | |
#### | |
import os, time | |
# basic ideas from here: | |
# http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes.html#poll_with_listdir | |
dir = "." |