Skip to content

Instantly share code, notes, and snippets.

View Ravenstine's full-sized avatar

Ten Bitcomb Ravenstine

View GitHub Profile
@Ravenstine
Ravenstine / maya-websocket.py
Last active May 25, 2021 02:45
Maya Websocket
import maya.cmds
import maya.utils
from SimpleWebSocketServer import SimpleWebSocketServer, WebSocket
from threading import Thread
class SimpleEcho(WebSocket):
def handleMessage(self):
# echo message back to client
#self.sendMessage(maya.utils.executeInMainThreadWithResult(self.data))
@Ravenstine
Ravenstine / socket.py
Last active April 26, 2022 04:37
Maya Socket Server
import socket
import sys
from threading import Thread
import maya.cmds
import maya.utils
def server_start():
server_address = '0.0.0.0', 8765 # Usage: server.py <port>
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(server_address)
@Ravenstine
Ravenstine / maya-tick.py
Created April 20, 2017 17:38
Print current time on every frame advance in Autodesk Maya
import maya.cmds as cmds
cmds.expression(n='expressionName', s='currentTime -query;')
@Ravenstine
Ravenstine / hello-maya.py
Created April 20, 2017 17:35
Write to stdout(actual stdout) in Autodesk Maya w/ Python
import sys
import maya.cmds as cmds
sys.stdout = sys.__stdout__
dir(sys.stdout)
print cmds.currentTime(query=True)
# I HATE MY LIFE
ccbtitcomb-mbpr:assethostx btitcomb$ docker exec assethost server
/root/config/environments/production.rb:79:in `block in <top (required)>': undefined method `[]' for nil:NilClass (NoMethodError)
from /usr/local/bundle/gems/railties-5.0.2/lib/rails/railtie.rb:209:in `instance_eval'
from /usr/local/bundle/gems/railties-5.0.2/lib/rails/railtie.rb:209:in `configure'
from /root/config/environments/production.rb:1:in `<top (required)>'
from /usr/local/bundle/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /usr/local/bundle/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
from /usr/local/bundle/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
@Ravenstine
Ravenstine / alexa-audio-test.js
Last active April 12, 2017 20:16
Playing audio through Alexa/Echo is easy!
// This is how I was able to get an mp3 file to play through my Echo Dot.
//
// Most audioPlayer examples seem overcomplicated, but this is essentially
// all I had to do. I did not test pausing, but you can say "Alexa, stop"
// and the audio will quit.
//
// Thought this would be helpful for those having trouble with this and
// will prove useful for those who just want to play audio clips without
// a complicated "interface".
//
const fs = require('fs');
process.stdin.setEncoding('utf8');
var capturing, frame, melCode, triangles, trimatcher;
trimatcher = /<glTri>\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)\s(\-*\d+\.\d+)/
var euclidianizeVertex = function(w, x, y, z){
return {
x: x/w,
y: y/w,
z: z/w
@Ravenstine
Ravenstine / super.c
Created September 10, 2016 15:17
Super Function in C
// This isn't exactly like having super-methods, especially since there are no
// classes or inheritances in C, but this can be useful with things like LD_PRELOAD
// where you want to override or proxy an existing function, and want the function
// to continue executing as it usually would(vs being a no-op).
#define _GNU_SOURCE
#include <dlfcn.h>
void glVertex3f(float x, float y, float z){ // an OpenGL function
static void (*super)(float, float, float) = NULL;
@Ravenstine
Ravenstine / Makefile
Created September 10, 2016 01:31
Override Shared Library Function Calls
override.so:override.c
gcc -shared -fPIC $^ -o $@
test:
LD_PRELOAD=$(PWD)/override.so glxgears
clean:
rm $(PWD)/override.so
@Ravenstine
Ravenstine / DEPLOYMENT.md
Created September 8, 2016 16:27
KPCC Audiogram Deployment

Deployment

Prerequisites:

  • Docker w/ running docker-machine
  • brew install awscli

Instructions

  1. If you haven't already, run aws configure and enter your access ID and access secret, a long with us-west-1 as the region. Then initialize your environment by running eval $(docker-machine env default) and eval $(aws ecr get-login --region us-west-1). It may be wise to place those last two commands in your ~/.bash_profile if you are going to be interacting with Docker and Amazon ECS a lot.