Skip to content

Instantly share code, notes, and snippets.

View Torrencem's full-sized avatar

May Torrence Torrencem

  • Two Six Technologies
View GitHub Profile
@Torrencem
Torrencem / main.rs
Created June 4, 2019 14:51
Optimization example
#![feature(asm)]
use std::env::args;
#[cfg(target_arch = "x86_64")]
fn main() {
match args().nth(1).unwrap().as_ref() {
"a" => fa(),
"b" => fb(),
x => panic!("unknown arg: {}", x),
@Torrencem
Torrencem / fastmbrotdemo.py
Created February 5, 2018 13:11
Here's an example of optimized mandelbrot set rendering in Python using Numba
import numpy as np
from numba import jit
from math import sqrt
from PIL import Image
import time
# jit call tells numba we want to optimize this function
@jit
def generate_mbrot_img(res):
# create an array a of size WIDTH, HEIGHT, DEPTH (color-wise)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Torrencem
Torrencem / GeneticApproachN.ipynb
Created November 14, 2017 02:00
Genetic Reinforcement-Learning example, with a generic Approach-N Jeopardy Game as an example. The optimal policy is learned after (probably less than) 10 generations
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Torrencem
Torrencem / rendering.py
Created July 24, 2017 23:56
Rendering complex animations (https://youtu.be/hrV-2TqF_ec)
import numpy as np
import gizeh
import moviepy.editor as mpy
import logging
from math import e, pi, factorial
from cmath import sin, log, tan, cos, sinh
logging.basicConfig(filename='out.log',level=logging.DEBUG)
W,H = 1920, 1080
duration = 7
import numpy as np
import gizeh
import moviepy.editor as mpy
import logging
from math import e
logging.basicConfig(filename='out.log',level=logging.DEBUG)
# This is actually only part of the code! The grid drawing code is taken out for whatever reason (I lost it!)
W,H = 750, 750
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.