Skip to content

Instantly share code, notes, and snippets.

View csprance's full-sized avatar
🐝

Chris Sprance csprance

🐝
View GitHub Profile

Rust Cheat Sheet

Variables & Mutability

Variables are immutable by default. This makes Rust safer and makes concurrency easier.
Immutable means once a value is bound to that variable, it cannot be changed.
For example:

fn main() {
 let x = 5;
@csprance
csprance / barycentric_coordinates.c
Created February 9, 2021 01:53
How to calculate barycentric coordinates in houdini using vex given 3 points making up a triangle and a point p we want to get the coordinates for
// This is the point we want to find barycentric coordinates of
vector p = point(0, "P", 3);
// These are the vertices of the main triangle we want to find coordinates for
vector v1 = point(0, "P", 0),
v2 = point(0, "P", 1),
v3 = point(0, "P", 2);
// Edge Vectors of the main triangle
vector e1 = v3 - v2,
@ItsVerday
ItsVerday / clover_noise_2d.fsh
Last active April 25, 2020 16:56
Clover Noise 2D GLSL (Optimized v3, commented)
// How far points in grid cells can go from the center of the grid cell. Setting this to a value above 0.5 will make the noise discontinuous, and there will be visible seams.
// It is reccomended to leave this at 0.3.
const float CLOVER_NOISE_2D_POINT_SPREAD = .3;
// The value of pi. Used in the offset function.
const float CLOVER_NOISE_2D_PI = radians(180.);
// Hashes a 2D vector into a point. It isn't 100% random, but it's good enough for clover noise to appear random.
float clover_noise_2d_hash(vec2 p) {
return fract(1e4 * sin(17.0 * p.x + p.y * 0.1) * (0.1 + abs(sin(p.y * 13.0 + p.x))));
@chris-lesage
chris-lesage / calculate_pole_vector.py
Last active April 15, 2024 19:29
Autodesk Maya script to calculate pole vector position based on 3 input objects
import pymel.core as pm
'''
An Autodesk Maya PyMEL script that calculates a pole vector position
based on 3 input PyNode objects. example: leg, knee, ankle bones.
Chris Lesage chris@rigmarolestudio.com
'''
def calculate_pole_vector(p1, p2, p3, poleDistance=1):
"""
@csprance
csprance / CSprance_Resume.md
Last active November 16, 2023 14:22
Chris Sprance - Character Technical Director - Resume

Chris Sprance

Character Technical Director/Web Developer/SysAdmin

My name is Chris Sprance. I am an artist, programmer, maker, and man of many hats. Proficient in the next-gen game art workflow with a deep understanding of the technical and procedural content pipeline including the constraints that revolve around games and real-time content. With over 13+ years of experience working in the AAA and indie games industry I've been a part of a lot of problem solving and enjoyed every second of it!

Work

<!DOCTYPE html>
<html>
<head><title>SOUND</title></head>
<body>
<div>Frequence: <span id="frequency"></span></div>
<script type="text/javascript">
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var oscillatorNode = audioCtx.createOscillator();
var gainNode = audioCtx.createGain();
@csprance
csprance / MiscreatedCVARHelp.md
Last active November 12, 2021 14:11
Miscreated Servers RCON commands and server configuration help

Miscreated Servers

RCON commands and server configuration help

Available Commands:

  • sv_servername "Name of server in quotes"
  • wm_timeScale 3 How Fast time moves
  • wm_forceTime -1 Force a current time
  • g_pinglimit 0 Ping required to join
@csprance
csprance / ckeditor.js
Last active April 12, 2017 15:54
Directus CKEditor WYSIWYG
// Description: CKEditor Custom UI for Directus
// Author: Chris Sprance (Entrada Interactive) - www.csprance.com
// CKEditor Docs: http://docs.ckeditor.com/
define(['app', 'core/UIComponent', 'core/CustomUIView', 'core/t', 'core/overlays/overlays'], function (app, UIComponent, UIView, __t, Overlays) {
var Input = UIView.extend({
events: {},
template: 'ckeditor/input',
serialize: function () {
@xem
xem / readme.md
Last active April 5, 2024 23:16
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@stasm
stasm / .env
Last active December 17, 2021 18:20
Pontoon in Docker
SECRET_KEY=hiphopopotamus
DJANGO_DEV=True
DJANGO_DEBUG=True
DATABASE_URL=postgres://pontoon:pontoon@localhost/pontoon
SESSION_COOKIE_SECURE=False
SITE_URL=http://localhost:8000
FXA_CLIENT_ID=2651b9211a44b7b2
FXA_SECRET_KEY=a3cafccbafe39db54f2723f8a6f804c337e362950f197b5b33050d784129d570
FXA_OAUTH_ENDPOINT=https://oauth-stable.dev.lcip.org/v1
FXA_PROFILE_ENDPOINT=https://stable.dev.lcip.org/profile/v1