Skip to content

Instantly share code, notes, and snippets.

View jfjensen's full-sized avatar

Jes Fink-Jensen jfjensen

View GitHub Profile
@payoung
payoung / tsp_plot.py
Created July 26, 2013 07:51
Python function that plots the data from a traveling salesman problem that I am working on for a discrete optimization class on Coursera. It can take multiple iterations of the path between nodes and plot out the current path as well as the old paths. Helps with troubleshooting and improving the algorithms that I am working on.
import matplotlib.pyplot as plt
def plotTSP(path, points, num_iters=1):
"""
path: List of lists with the different orders in which the nodes are visited
points: coordinates for the different nodes
num_iters: number of paths that are in the path list
"""
@iirelu
iirelu / libstuff.py
Created November 30, 2014 16:02
A small python library for rendering generative art gifs
from __future__ import division
import os
import numpy
from PIL import Image, ImageDraw
class Renderer():
def __init__(
self, size=(640, 480), sampler=None,
@mds
mds / dropbox-redirect.html
Created March 5, 2015 16:42
A Simple JS Redirect
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- Replace with your own title -->
<title>Your Project's Title</title>
<script>
// Add your own shareable dropbox link
window.location.replace("https://www.dropbox.com");
</script>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'threading_design.ui'
#
# Created: Thu Aug 6 13:47:18 2015
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
@geffy
geffy / stacking_example.py
Created October 7, 2017 17:33
Stacking example
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 23 23:16:44 2017
@author: Marios Michailidis
This is an example that performs stacking to improve mean squared error
This examples uses 2 bases learners (a linear regression and a random forest)
and linear regression (again) as a meta learner to achieve the best score.
The initial train data are split in 2 halves to commence the stacking.
@kirkegaard
kirkegaard / tamagotchi.py
Last active September 18, 2024 19:26
a tamagotchi simulator in python
import os
import time
import sched
import threading
import inquirer
class Tamagotchi:
age = 0
bored = 0
@HandsomeManKris
HandsomeManKris / order_book.py
Created November 3, 2021 14:18
Simple python order book
import enum
import queue
import time
from collections import defaultdict
class Side(enum.Enum):
BUY = 0
SELL = 1