Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle McDonald kylemcdonald

View GitHub Profile
@kylemcdonald
kylemcdonald / ZoomableRegion2D.h
Created Jan 30, 2019
2D Zoomable Region for openFrameworks. Right click and drag to zoom. Left click and drag to translate.
View ZoomableRegion2D.h
#pragma once
#include "ofMain.h"
class ZoomableRegion2D {
private:
float speed = 5;
float zoom = 1;
ofVec2f offset, startOffset, startDrag;
float startZoom;
@kylemcdonald
kylemcdonald / main.cpp
Last active Jan 27, 2019
Example of loading an obj file with ofxAssimpModelLoader.h and rendering with just ofMesh and ofTexture.
View main.cpp
#include "ofMain.h"
#include "ofxAssimpModelLoader.h"
class ofApp : public ofBaseApp {
public:
ofxAssimpModelLoader loader;
ofMesh mesh;
ofTexture tex;
@kylemcdonald
kylemcdonald / CUDA Argmax Comparison.ipynb
Created Jan 8, 2019
argmax with CUDA in cupy vs pytorch vs tensorflow
View CUDA Argmax Comparison.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / auction.py
Created Dec 24, 2018
Auction algorithm using numba.
View auction.py
from numba import jit
import numpy as np
index_dtype = np.int32
cost_dtype = np.int32
@jit(nopython=True)
def auction(a, eps=1):
n = len(a)
p = np.zeros(n, dtype=cost_dtype)
View KMNIST to Grid.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / CONSTELLATION.BAS
Last active Dec 20, 2018
Some of the first generative code I ever wrote, for QBASIC. Written some time between 1997-2003.
View CONSTELLATION.BAS
DECLARE SUB redrawLine (n%)
DECLARE SUB drawDots (ntot%)
DECLARE SUB drawLines (ntot%)
CLS
SCREEN 12 '7 is white, 8 is gray, screen 7 is 320x200, screen 9 is 640x350, screen 12 is 640x480
ntot% = 55
DIM SHARED m(ntot%, 3) 'm(numberDot, [x, y, connected Dot, distance])
DIM SHARED bound(1)
bound(0) = 640
@kylemcdonald
kylemcdonald / Convolutional Photomosaic NN L2 Baseline.ipynb
Created Dec 14, 2018
Recreating baseline for "Convolutional photomosaic..." by Tesfaldet et al.
View Convolutional Photomosaic NN L2 Baseline.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / csa.c
Last active Dec 13, 2018
WIP wrapping Andrew Goldberg's CSA as a Python extension with Cython. Solves a real 1.6B arc problem in 3m26s.
View csa.c
#include "csa.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#define sort_insert(best, size, a, a_prc, nsize) \
\
{\
unsigned si_i, si_j;\
\
View lap-toy-problem.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View photomosaic.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.