Skip to content

Instantly share code, notes, and snippets.

View troykinsella's full-sized avatar

Troy Kinsella troykinsella

  • Collective[i]
  • BC, Canada
View GitHub Profile
@troykinsella
troykinsella / gist:7cecadc164aa95e943c9d0e26f8915cc
Created January 19, 2023 23:38
Bevy Mesh to Geo Polygon conversion
This is surely incorrect, and possibly terrible. Do not use!
```
use bevy::prelude::Mesh;
use geo_types::{Coordinate, LineString, Polygon};
pub fn mesh_to_clipper_polygon(mesh: &Mesh) -> Option<Polygon> {
let vertex_count = mesh.count_vertices();
if let Some(positions) = mesh.attribute(Mesh::ATTRIBUTE_POSITION) {
@troykinsella
troykinsella / fetch_gh_release.sh
Last active October 12, 2018 18:41
fetch_gh_release.sh
#!/usr/bin/env bash
set -e
GH_USER=${GH_USER:-$1}
GH_REPO=${GH_REPO:-$2}
ASSET=${ASSET:-$3}
VERSION=${VERSION:-${4:-latest}}
usage() {

Keybase proof

I hereby claim:

  • I am troykinsella on github.
  • I am troykinsella (https://keybase.io/troykinsella) on keybase.
  • I have a public key ASCRymHFy0wBxt-Wq918MyP0Xg_vmM3WOw7TH7IkqDBStAo

To claim this, I am signing this object:

@troykinsella
troykinsella / process-erb.rb
Created February 2, 2017 23:56
Evaluate an ERB template, injecting a YAML file of variables.
#!/usr/bin/env ruby
require 'erb'
require 'yaml'
class HashBinding
def initialize(hash)
@hash = hash.dup
end
def method_missing(m, *args, &block)
@troykinsella
troykinsella / json2txt.js
Created November 4, 2016 01:07
Convert json into a flat text format
#!/usr/bin/env node
var fs = require('fs');
var str = fs.readFileSync("/dev/stdin", "utf8");
var json = JSON.parse(str);
function print(path, o) {
if (Array.isArray(o)) {
printArray(path, o);
} else if (typeof o === 'object') {
@troykinsella
troykinsella / string-interp.rb
Created September 26, 2016 20:50
A super basic command-line string interpolator in Ruby
#!/usr/bin/env ruby
require 'optparse'
class StringInterpolator
def initialize(inFile, vars)
@in = File.open(inFile).read
@vars = vars
end