Skip to content

Instantly share code, notes, and snippets.

View jehutymax's full-sized avatar
🌊
Coding physically-based animation software

Rafael Campos jehutymax

🌊
Coding physically-based animation software
  • Blizzard Entertainment; ICMC-USP
  • Irvine, CA
View GitHub Profile
@jehutymax
jehutymax / fd_bvp.py
Created December 3, 2019 17:53
Approximate u''(x) = sin^2(x/2), 0 < x < 2*Pi with boundary conditions u(0) = 0 and u(2*Pi) = 2*Pi. using: (1) 2nd-order accurate finite-difference approximation; (2) 4th-order accurate finite-difference approximation; (3) 4th-order extrapolation method on two grids; (4) 4th-order deferred correction; - spectral collocation Plot the error as h, …
import fd.fd_stencil as fd
import numpy as np
import math
import matplotlib.pyplot as plt
"""
Approximate u''(x) = sin^2(x/2), 0 < x < 2*Pi
with boundary conditions u(0) = 0 and u(2*Pi) = 2*Pi.
using:
- 2nd-order accurate finite-difference approximation;
@jehutymax
jehutymax / houdini-selectionToCurvePythonScript.py
Last active May 29, 2018 13:28
Houdini Shelf Tool - Transform point selection into a Curve SOP
import toolutils
# Works in Houdini 16.5, assumes points are selected inside /obj/geo1.
selection = toolutils.sceneViewer().currentGeometrySelection()
node = selection.nodes()[0]
points = node.geometry().globPoints(selection.mergedSelectionString())
curve = hou.node('/obj/geo1/').createNode('curve')
pstr = ''
for i in range(len(points)):
@jehutymax
jehutymax / python-mailgun.py
Created June 3, 2016 12:30
Send e-mails using Mailgun from a Python script
import string
import requests
html = 'https://s3.amazonaws.com/.../email.htm'
content = requests.get(html)
DJANGO_MAILGUN_SERVER_NAME = ''
DJANGO_MAILGUN_API_KEY = ''
recipient_list = ['email@one.com', 'email@two.com']
struct SillyFunction
{
SillyFunction() {}
Vec3d operator()(const Vec3d& xyz) const
{
return Vec3d(3.0 * xyz.y() + 1.0, 5.0 * xyz.z() + 7.0, -1.0 * xyz.x() - 9.0);
}
};
TEST(Grids, MacGrid)
struct SillyFunction
{
SillyFunction() {}
Vec3d operator()(const Vec3d& xyz) const
{
return Vec3d(3.0 * xyz.y() + 1.0, 5.0 * xyz.z() + 7.0, -1.0 * xyz.x() - 9.0);
}
};
TEST(Grids, MacGrid)
@jehutymax
jehutymax / guest_hash_generator.py
Created June 3, 2016 12:52
Create a 4-digit hash code for each guest loaded from a CSV file
import csv
import base64
import hashlib
f = open('guests.csv', "r", encoding='utf-8', errors='ignore')
csv_f = csv.reader(f)
for row in csv_f:
s = ''
for element in row:
s += element
## This is very Mac-specific, but there are other ways of obtaining the same package
brew install graphviz
pip install pygraphviz
## django-cookiecutter ships with 'django_extensions'
## if not being used, do it manually by
pip install django-extensions
## and in the settings.py config file of your django app,
## 'django_extensions' has to be added.