Skip to content

Instantly share code, notes, and snippets.

View dyllandry's full-sized avatar
🍞

Dylan Landry dyllandry

🍞
  • Tactus Therapy
  • Toronto, ON, Canada
View GitHub Profile
@dyllandry
dyllandry / main.txt
Created July 7, 2023 01:30
Some context around my code examples for the Ought Full-Stack Software Engineer position
This bit of code is from a recent rust project where I'm making the board game snakes and ladders. Specifically, it's the code that creates a new "board" which contains pawns, tiles, and connections (the snakes and ladders).
https://github.com/dyllandry/ladders-and-slides/blob/f79a28fb057f8839dd9b1d2f09fa9c136c118d35/src/ladders_and_slides.rs#L132
The reason I like this function is because:
- It's not complex. It hides enough complexity to be useful & the interface it exposes is simple.
- It includes argument validation with errors, so you catch issues during development.
- It lacks side-effects, just receives and returns data.
- Includes a comment to communicate something non-obvious in the code.
@dyllandry
dyllandry / main.rs
Created December 9, 2021 16:20
Rust Fibonacci
fn main() {
test_fibonacci(10);
}
fn test_fibonacci(n: u32) {
println!("fibonacci({}) -> {}", n, fibonacci(n));
}
fn fibonacci(n: u32) -> u32 {
// Whenever I use recursion, I think of it in terms of what are the
@dyllandry
dyllandry / main.ts
Last active November 8, 2021 14:29
Gets all upcoming Stripe invoices into a csv that you can open in Excel.
/* Stripe doesn't provide an endpoint to get all upcoming invoices,
* instead you have to fetch them one by one for each subscriber.
* This script gets all upcoming stripe invoices and puts them in
* an easy to read CSV file you can open in excel.
*
* This tool can be useful for companies with few subscriptions to
* see which customer's subscriptions will renew soon so they can maybe
* get ahead of it, maybe provide some extra customer service
* in advance or something.
*/
@dyllandry
dyllandry / opengl-api.c
Last active September 3, 2023 10:19
Load OpenGL functions pointers with C
#include "opengl-api.h"
#include <dlfcn.h>
#include <stdio.h>
/* Here we define pointers to each of the opengl functions we use by defining a
* function-like macro "GL_FUNC" and applying it to each "GL_FUNC" macro
* contained by "GL_FUNC_LIST". This xmacro is defined in our header. */
#define GL_FUNC(returnType, funcName, ...) funcName##Type * funcName;
GL_FUNC_LIST
#undef GL_FUNC
@dyllandry
dyllandry / recursive-star-triangle.js
Last active June 20, 2021 16:13
I got this recursion question during an interview and totally blew it. I forgot recursion existed, and my implementation didn't go smoothly. Here's another try.
/**
* I got this recursion question during an interview and totally blew it. I
* forgot recursion existed, and my implementation didn't go smoothly. Here's
* another try.
*
* Question: Print a triangle of stars without using any loops, iteration, etc.
*
* Input: n = 3
* Output: *
* **
@dyllandry
dyllandry / gist:91fd772639c9f0b75143f982b6f29dea
Created March 16, 2021 14:13 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@dyllandry
dyllandry / toggle-touchpad.sh
Last active April 22, 2020 01:27
Toggle a touchpad on/off.
#!/bin/sh
# Toggles a touchpad on/off.
# Might only work computers that use xinput.
DEVICE_NAME="SynPS/2 Synaptics TouchPad"
ID=$(xinput list --id-only "$DEVICE_NAME")
IS_ENABLED=$(xinput --list-props "$DEVICE_NAME" | grep "Device Enabled" | grep -o "[01]$")
if [ $IS_ENABLED -eq 0 ]; then
xinput set-prop $ID "Device Enabled" 1
@dyllandry
dyllandry / doubly-linked-lists.js
Created June 27, 2019 12:42
Description and implementation of a doubly linked list data structure.
/**
* Title: Doubly Linked List
* Author: Dylan Landry
* Date: Wed 26 Jun 2019 16:00:15 EDT
* Permalink: https://gist.github.com/dyllandry/12d0a2f7f1b1cfc22169b1990bd89c2d
*
* Description:
* A kind of data structure similar to a train.
* Each node, a container for a value, knows of the node ahead of it and behind
* it. The list keeps references to the head node, the tail node, and the total
@dyllandry
dyllandry / singly-linked-list.js
Last active June 27, 2019 12:41
Description and implementation of a singly linked list data structure.
/**
* Title: Singly Linked List
* Author: Dylan Landry
* Date: Wed 26 Jun 2019 13:38:38 EDT
* Permalink: https://gist.github.com/dyllandry/371505391a608abb9d979a1ea258cff9
*
* Description:
* A kind of data structure similar to a train.
* Each node, a container for a value, knows only of the node ahead of it.
* The list keeps references to the head node, the tail node, and the total
@dyllandry
dyllandry / radix-sort.js
Created June 21, 2019 18:51
Description and implementation of a radix sort algorithm.
/**
* Radix Sort: Radix (or base) means: "the base of a
* system of numeration." Radix sorts by analyzing the
* place values of each number. Each number must be a
* whole number, or positive integer. Radix sort can be used
* with a variety of base values, though here I focus
* only on our decimal base 10 system.
*
* Process:
* Create an auxiliary array with a length of ten (one