Skip to content

Instantly share code, notes, and snippets.

View mitchellvitez's full-sized avatar

Mitchell Vitez mitchellvitez

View GitHub Profile
-- Tree drawings
-- Left click and drag to pan the drawing
-- Right click and drag to zoom
-- install this by running `cabal install gloss`
-- You may need to install/update opengl
import Graphics.Gloss
-- Config variables for n-ary tree with k levels of depth
@mitchellvitez
mitchellvitez / Relativity.elm
Created January 22, 2019 21:16
A relativity calculator for finding the Lorentz factor at various velocities
module Relativity exposing (main)
import Html exposing (..)
import Html.Attributes exposing (style, src, min, max, type_, value)
import Html.Events exposing (onClick, onInput, onMouseEnter, onMouseDown, onMouseUp)
type Msg
= SetMacro String
| SetMedium String
import requests
from bs4 import BeautifulSoup
def soupify(url):
page = requests.get(url)
return BeautifulSoup(page.text, 'html.parser')
parks = soupify('https://www.nps.gov/planyourvisit/fee-free-parks-state.htm').find_all('a')
for park in parks:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.State
import Data.Word
import Foreign.C.Types
import Graphics.UI.GLUT as GL hiding (Window, createWindow, bitmap, get, renderer)
import SDL hiding (get)
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
module Main where
import Control.Applicative
import Data.Aeson
import Data.Char
import GHC.Generics
import Numeric
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilyDependencies #-}
module Nat where
-- Our own little prelude with just Bool and not
import Prelude((++), Show(..), error)
@mitchellvitez
mitchellvitez / curate.py
Last active August 5, 2019 04:00
Simple genetic-ish algorithm
import random
POPULATION_SIZE = 1000
HEIGHT = 5
WIDTH = 20
MUTATION_CHANCE = 1 / (WIDTH * HEIGHT)
def randChar():
"""Get a random gene.
@mitchellvitez
mitchellvitez / magic_square.rs
Created November 6, 2019 04:09
magic square generator, using backtracking
const SIZE: usize = 3;
const SUM: u32 = magic_constant(SIZE as u32);
const fn magic_constant(n: u32) -> u32 {
return n * (n * n + 1) / 2;
}
const fn initial() -> [[u32; SIZE]; SIZE] {
return [[0; SIZE]; SIZE];
}
// https://www.realtimerendering.com/raytracing/Ray%20Tracing%20in%20a%20Weekend.pdf
use cgmath::Vector3;
use rand::prelude::*;
type Point = Vector3<f64>;
fn point(x: f64, y: f64, z: f64) -> Point {
return Vector3::new(x, y, z);
}
@mitchellvitez
mitchellvitez / spotify_links_to_playlist.py
Created January 26, 2020 19:30
download all spotify links from a website into a playlist