Skip to content

Instantly share code, notes, and snippets.

View JosephCatrambone's full-sized avatar

Joseph Catrambone JosephCatrambone

View GitHub Profile
@JosephCatrambone
JosephCatrambone / scrub.py
Last active August 29, 2015 14:04
Doing a "cast" from Unicode strings to look-alike ASCII characters
# coding=utf-8
import string
sourcemap = u"àáâãäåÀÁÂÃÄÅèéêëÈÉÊËìíîïÌÍÎÏòóôõöÒÓÔÕÖùúûüÙÚÛÜýÿÝñÑ¿¡";
destmap = "aaaaaaAAAAAAeeeeEEEEiiiiIIIIoooooOOOOOuuuuUUUUyyYnN?!";
def scrub(s, replacement_char=''):
"""Returns a new string with accented characters replaced by the closest ASCII character available.
This is conceptually similar to multiple passes with maketrans+translate."""
scrubbed_sentence = "";
@JosephCatrambone
JosephCatrambone / keybase.md
Created September 24, 2014 16:47
Public Keybase.io Proof

Keybase proof

I hereby claim:

  • I am josephcatrambone on github.
  • I am josephcatrambone (https://keybase.io/josephcatrambone) on keybase.
  • I have a public key whose fingerprint is 1B57 1051 DECE 2D9A 548F BE22 FC02 FC52 2A25 C920

To claim this, I am signing this object:

@JosephCatrambone
JosephCatrambone / NeuralNetwork
Last active December 3, 2015 23:37
Multi-Layer Neural Network
#!/usr/bin/env python
# Author: Joseph Catrambone <jo.jcat@gmail.com>
# Obtained from https://gist.github.com/JosephCatrambone/b8a6509384d3858974c2
# License:
# The MIT License (MIT)
#
# Copyright (c) 2015 Joseph Catrambone
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@JosephCatrambone
JosephCatrambone / fuse_color.py
Last active November 28, 2016 22:30
A simple tool to predict the color of a fuse in a given slot.
from __future__ import division
import sys
import math
from PIL import Image
def RGBToHSL(rgb):
"""Given an RGB tuple in the range of 0-255, returns HSL from 0-1."""
r = rgb[0]/255.0
g = rgb[1]/255.0
b = rgb[2]/255.0
@JosephCatrambone
JosephCatrambone / Planetary Name Generator
Created October 27, 2015 19:11
A way to generate planetary/system names from numbers.
lookup = ['Aleph', 'Alpha', 'Antares', 'Beta', 'Bootes', 'Barum', 'Ceres', 'Charion', 'Chardibus', 'Chalupa', 'Delta', 'Darion', 'Doolan', 'Echo', 'Eres', 'Eribus', 'Encephalus', 'Ender', 'Foxtrot', 'Famicom', 'Gamma', 'Gregorio', 'Grace', 'Gaea', 'Gaia', 'Howzer', 'Hera', 'Hosio', 'Ignus', 'Io', 'Ionus', 'Ibus', 'Jax', 'Jovia', 'Jolo', 'Keras', 'Kodia', 'Li', 'Libra', 'Lol', 'Orphius', 'Orchid', 'Odyssus', 'Persephone', 'Pax', 'Qualude', 'Qi', 'Ra', 'Rez', 'Radium', 'Tia', 'Tori', 'Uso', 'Ura', 'Varia', 'Verit', 'Wex', 'Woolio', 'X', 'Yota', 'Yttrius', 'Zoe', 'Zee', 'Zae', 'Zeebs']
def from_int(num):
base = len(lookup) # Base whatever.
name = list()
while num > 0:
digit = num%base
num = num//base
name.append(lookup[digit])
string = ""
@JosephCatrambone
JosephCatrambone / VariationalAutoencoder.py
Last active September 11, 2016 23:14
Experimental bugfixes on Tensorflow's Variational Autoencoder with an image batch loader.
import sys, os
import math
from random import randint, choice
from glob import glob
import tensorflow as tf
import numpy as np
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
#!/usr/bin/env python
# JAD: Joseph's Automatic Differentiation
from collections import deque
class Graph(object):
def __init__(self):
self.names = list()
self.operations = list()
self.derivatives = list() # A list of LISTS, where each item is the gradient with respect to that argument.
@JosephCatrambone
JosephCatrambone / image_network.py
Created October 22, 2016 12:49
A Simple Tensorflow Convolutional System for STL10
#!/usr/bin/env python
#@author: Joseph Catrambone <jo.jcat _ gmail>
import sys, os
import math
import random
import time
from glob import iglob
import numpy
import tensorflow as tf
@JosephCatrambone
JosephCatrambone / TriangleLineIntersection.js
Last active November 23, 2017 20:37
Companion Code for the Article on Ray Triangle Intersection
//@author Joseph Catrambone
// See https://www.josephcatrambone.com/?p=967 for the original blog post and the derivation of all formulas.
class Point {
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
dot(other) {
@JosephCatrambone
JosephCatrambone / octree.py
Last active March 7, 2018 05:47
A small octree implementation in pure python that supports arbitrary point dimensions and uses naive splitting.
#!/usr/bin/env python
#author: Joseph Catrambone
"""
Copyright 2018 Joseph Catrambone
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU