Skip to content

Instantly share code, notes, and snippets.

@nafeesb
nafeesb / maya_loadPlugin.py
Created March 3, 2018 02:14
Maya load plugin in a standalone context
# good for testing frameworks
import maya.standalone
maya.standalone.initialize()
from maya import cmds
cmds.loadPlugin('path/to/plugin.so')
@nafeesb
nafeesb / upload_and_read_colaboratory.py
Created March 13, 2018 07:22 — forked from sagarhowal/upload_and_read_colaboratory.py
Upload Dataset on Google Colaboratory.
#Uploading the Dataset
from google.colab import files
uploaded = files.upload()
#Save uploaded file on the Virtual Machine's
#Thanks to user3800642 from StackOverflow
with open("breast_cancer.csv", 'w') as f:
f.write(uploaded[uploaded.keys()[0]])
@nafeesb
nafeesb / vex_avg_nbor_dist.cpp
Created June 8, 2018 00:50
Average distance to neighbor points
///
/// Average max distance
///
float maxdistance = 15;
int maxpoints = 5;
int closept[] = pcfind_radius(0, "P", "pscale", 1.0, @P, maxdistance, maxpoints);
f@dist = 0;
foreach (int opt; closept) {
vector npos = point(0, "P", opt);
# Restart the VM
!kill -9 -1
## Mount a google drive
# install prereqs
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
@nafeesb
nafeesb / orthonormal_basis.cs
Created November 16, 2018 00:43
Duff's branchless onb
void branchlessONB( Vector3 N, ref Vector3 A, ref Vector3 B)
{
float sign = N.z >= 0.0f ? 1.0f : -1.0f;
float a = 1.0f / (sign + N.z);
float b = N.x * N.y * a;
A.Set(1.0f + sign * N.x * N.x * a, sign * b, -sign * N.x);
B.Set(b, sign + N.y * N.y * a, -N.y);
}
@nafeesb
nafeesb / openaigym_install.md
Created November 21, 2018 19:00
Installing OpenAI Gym in Windows

Anaconda Configuration

conda create -n tensorflow tensorflow-gpu pip python=3.6
conda install ipython matplotlib cython mkl_random mkl mkl-devel swig

Install OpenAI Gym

Install from source: https://github.com/openai/gym

pip install -e .
@nafeesb
nafeesb / regression1d.py
Last active January 9, 2019 02:06
pytorch 1d regression
import numpy as np
import torch
from torch import nn
from itertools import count
import time
#%%
# make some data
N = 100
@nafeesb
nafeesb / zmq_pubsub.py
Created April 16, 2019 01:28
Example PUB/SUB from PyZMQ
import zmq
import sys,os,time
#%%
port = '5563'
def server():
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind('tcp://*:%s' % port)
@nafeesb
nafeesb / ue-python.md
Last active August 11, 2019 20:29
Unreal engine python snippets

Preamble

import unreal_engine as ue
from unreal_engine.classes import PoseableMeshComponent, SkeletalMesh, Skeleton, SkeletalMeshComponent
from unreal_engine import FTransform, FVector, FRotator, FQuat, FSoftSkinVertex

Access object from editor

actor = ue.editor_get_selected_actors()[0]