Skip to content

Instantly share code, notes, and snippets.

View timClicks's full-sized avatar
🏠
Working from home

Tim Clicks timClicks

🏠
Working from home
View GitHub Profile
@timClicks
timClicks / bfs.rs
Created February 15, 2022 03:19
Breadth-first search in Rust
// watch the video if you would like an explanation of this code
// https://youtu.be/FoNJ5zhL6bQ
use std::collections::{HashSet, VecDeque};
use std::hash::Hash;
trait Graph {
type Node: Hash + Eq + Clone + std::fmt::Debug;
fn neighbours(&self, node: &Self::Node) -> Vec<Self::Node>;
@timClicks
timClicks / Cargo.toml
Created June 25, 2020 09:55
Implementating Circle Packing in Rust
[package]
name = "circle-packing"
version = "0.1.0"
authors = ["Tim McNamara <paperless@timmcnamara.co.nz>"]
edition = "2018"
[dependencies]
nannou = "0.14"
@timClicks
timClicks / zip_arrays.rs
Last active June 21, 2020 09:01
How to .zip() through items in two arrays in Rust
fn main() {
let x_coordinates: [f32; 4] = [0., 1., 2., 3.];
let y_coordinates: [f32; 4] = [0., 1., 4., 9.];
for (x, y) in x_coordinates.iter().zip(y_coordinates.iter()) {
// Comparisons require that you dereference the values.
// iter() for arrays returns a reference to each element.
if *x <= 0.0 || *y <= 1.0 {
continue;

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@timClicks
timClicks / notebook_launcher.py
Created May 17, 2012 08:03 — forked from timo/notebook_launcher.py
branded ipython notebook launcher
"""==============================
Branded IPython Notebook Launcher
=================================
Executing this module will create an overlay over ipython notebooks own static
files and templates and overrides static files and templates and copies over all
example notebooks into a temporary folder and launches the ipython notebook server.
You can use this to offer an interactive tutorial for your library/framework/...