Skip to content

Instantly share code, notes, and snippets.

View dirediredock's full-sized avatar

Matt I.B. Oddo dirediredock

  • The University of British Columbia
  • Vancouver, BC.
  • X @dirediredock
View GitHub Profile
# by Matias I. Bofarull Oddo - 2022.08.16
# Pisano Cycle: https://oeis.org/A161553
# Pisano Period: https://oeis.org/A001175
import numpy as np
import matplotlib.pyplot as plt
def pisano_cycle_and_period(modulus):
@dirediredock
dirediredock / step_1.py
Last active June 17, 2022 06:10
Building a correlation matrix from scratch in Python
import matplotlib.pyplot as plt
plt.rcParams.update({"font.sans-serif": "Consolas"})
num_var = 5
fig = plt.figure(figsize=(9, 9))
for i in range(num_var ** 2):
ax = fig.add_subplot(num_var, num_var, i + 1)
# by Matias I. Bofarull Oddo - 2022.05.29
from random import randint
import matplotlib.pyplot as plt
points = [[randint(0, 999) for _ in range(2)] for _ in range(4)]
def linear_interpolation(array, line_ratio):
new_X = ((1 - line_ratio) * array[0][0]) + (line_ratio * array[1][0])
# by Matias I. Bofarull Oddo - 2022.05.03
from math import pi, cos, sin
from matplotlib.widgets import Slider
import matplotlib.pyplot as plt
plt.rcParams["font.sans-serif"] = "Consolas"
plt.rcParams["font.weight"] = "bold"
plt.rcParams["font.size"] = 10
# by Matias I. Bofarull Oddo - 2022.05.02
# A small demo of sliders in matplotlib.pyplot
from math import pi, cos, sin
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider
phi = (1 + (5 ** (1 / 2))) / 2 - 1
# by Matias I. Bofarull Oddo - 2022.04.20
# Inspired by Rafael Araujo's post:
# https://twitter.com/rafaela31416/status/1509334444976779264?s=20&t=mswbmkrYcJzZC5_5pbir7A
import matplotlib.pyplot as plt
Φ = (1 + (5 ** (1 / 2))) / 2
X_square = []
@dirediredock
dirediredock / SubmarineCablesViz.m
Created September 23, 2021 19:01
Quick parsing and visualization of telegeography's submarine cable JSON dataset in Matlab
close all; clear; clc; format long g;
% Extract submarine cable data from URL and convert to a struct variable
fileGeoJSON = webread("https://raw.githubusercontent.com/telegeography/www.submarinecablemap.com/master/web/public/api/v3/cable/cable-geo.json");
cables = jsondecode(fileGeoJSON);
% The following forloop parses the struct variable "cables" and 1. counts the
% unqiue XY coordinate pair instances (stored in "countPoints"), 2. counts