Skip to content

Instantly share code, notes, and snippets.

View justinmeiners's full-sized avatar

Justin Meiners justinmeiners

View GitHub Profile
@justinmeiners
justinmeiners / MultiplyPoint.cs
Last active June 23, 2018 06:12
Difference between MultiplyPoint and MultiplyPoint3x4
// See my SO answer https://stackoverflow.com/questions/35208476/unity3d-difference-between-multiplypoint-and-multiplypoint3x4
// https://github.com/jameslinden/unity-decompiled/blob/master/UnityEngine/UnityEngine/Matrix4x4.cs
public Vector3 MultiplyPoint(Vector3 v)
{
Vector3 vector3;
vector3.x = ( m00 * v.x + m01 * v.y + m02 * v.z) + m03;
vector3.y = ( m10 * v.x + m11 * v.y + m12 * v.z) + m13;
vector3.z = ( m20 * v.x + m21 * v.y + m22 * v.z) + m23;
float num = 1f / ( ( m30 * v.x + m31 * v.y + m32 * v.z) + m33);
vector3.x *= num;
@justinmeiners
justinmeiners / parenscript-first-trial.lisp
Created July 15, 2018 01:41
Playing around with ParenScript.
; ParenScript experiment
; https://common-lisp.net/project/parenscript/reference.html
; https://gitlab.common-lisp.net/parenscript/parenscript
; typical functions
(defun fib (n)
(cond ((= n 0) 0)
((= n 1) 1)
(t (+ (fib (- n 1)) (fib (- n 2))))))
@justinmeiners
justinmeiners / teaching_python.py
Last active September 15, 2018 05:23
Examples from python lessons I taught.
# Created By: Justin Meiners (2017)
# simple calculations
# -------------------------------
import math
def volume_cone(radius, height):
volume = math.pi * (radius**2.0) * (height / 3.0)
return volume
@justinmeiners
justinmeiners / dutch_auction.sol
Last active September 15, 2018 05:53
Dutch auction smart contract for a presentation.
// Created By: Justin Meiners (2018)
pragma solidity ^0.4.24;
// https://en.wikipedia.org/wiki/Dutch_auction
contract DutchAuction {
uint public askingPrice;
address public auctioneer;
address public winner;
address public seller;
# Created By: Justin Meiners (2012)
# This was really useful at one point. I doubt it still is.
from pymel.all import *
import pymel
selection_list = pymel.core.ls(type="transform", selection=True)
for node in selection_list:
node.centerPivots()
point = node.getRotatePivot(space="world")
@justinmeiners
justinmeiners / write_struct.c
Created October 30, 2018 03:28
How to copy a struct into a byte buffer.
// how to write a struct to a buffer.
typedef struct {
int version;
int count;
char id[8];
} FileInfo;
FileInfo info;
@justinmeiners
justinmeiners / downloader.js
Last active November 28, 2018 21:06
Delegate example.
// notice that downloader doesn't need to import user interface
class Downloader {
// delegate has startDownload and finishDownload
constructor(delegate) {
this.delegate = delegate;
}
downloadFile() {
python -m json.tool
(use srfi-1)
; partition(0)
; (null)
; partition(n)
; (n) + part(0)
; (n - 1) + part(1)
; (n - 2) + part(2)
; ...
@justinmeiners
justinmeiners / sample_net.net
Created February 5, 2019 03:49
Sample of hosting a Neural Net in a gist.
fAEBABAAEgDgAAoBAQAAAAEABQAAAAEAAQBOAdwABAAAAAQAAAAAAAEAAAACAAAAAwAAAAEACADmAMQAAQAAAAEABAAAAAEAAADmAEYBAQAAAAEABgAAAAEAAgDqAJIBAQAAAAEABwAAAAEAAwByAP8AAAAAAAAABAAEAAUABgAHAIIB4AABAAAAAQAIAAAAAQAJAMUB4AABAAAAAQAJAAAAAQAKAPwB4gABAAAAAQAKAAAAAQALAP0BFgEBAAEAAQALAAAAAQAMAMQBGAEBAAEAAQAMAAAAAQANAIMBGgEBAAEAAQANAAAAAQAOAIYBUgEBAAAAAQAOAAAAAQAPAMIBUQEBAAAAAQAPAAAAAQAQAAACTwEBAAAAAQAQAAAAAQARAGwC9QABAAAAAQARAAAAAAACAAEAAAABAAMAAQAEAAEABQACAAUAAAAFAAMABQAEAAEABgAGAAcABwAIAAgACQAJAAoACgALAAsADAAMAA0ADQAOAA4ADwA=