Skip to content

Instantly share code, notes, and snippets.

@Brandon-Rozek
Brandon-Rozek / ia-save.py
Created December 24, 2022 17:21
Script that takes a URL and requests the Internet Archive to snapshot it.
#!/bin/env python
from argparse import ArgumentParser
from urllib import request
from urllib.parse import urlparse
import sys
parser = ArgumentParser(description="Request Internet Archive to save the site")
parser.add_argument("URL", type=str, help="URL to save")
parser.add_argument("-s", action='store_true', help="Silent. Makes output less verbose")

openpgp4fpr:5F37830BFA46FF7881F47AC78DF79C3DC5FC658A

@Brandon-Rozek
Brandon-Rozek / photos_google_album.py
Created June 12, 2022 22:33
Grab photo information from a Google Photos Album URL (Not maintained)
"""
Tool to grab list of photo information (URLs/etc) of
images in Google Photos album.
Adapted from Matthieu Bessat
https://github.com/lefuturiste/google-photos-album-crawler/blob/f33026d379058912c597d5802296b55b62ed27a4/src/Crawler.php
"""
import json
import re
import sys
from http.client import HTTPResponse
@Brandon-Rozek
Brandon-Rozek / theme_browser.R
Created May 15, 2021 00:03
R Script to showcase different themes using sample data in a shiny app
library(shiny)
library(dplyr)
library(ggplot2)
library(GGally)
library(ggthemr)
library(gapminder)
gapminder_mediangdp = gapminder %>%
group_by(year, continent) %>%
summarize(medianGdp = median(gdpPercap))
@Brandon-Rozek
Brandon-Rozek / recursionCalculator.js
Created May 15, 2021 00:00
Different arithmetic calculations represented as tail recursions
// Addition & subtraction are independent implementations
var add = function(x, y) {
if (y == 0) {
return x;
}
if (y < 0) {
return add(x - 1, y + 1);
}
return add(x + 1, y - 1);
}
@Brandon-Rozek
Brandon-Rozek / approxPi.go
Created May 14, 2021 23:56
Approximation of Pi using Go
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
// Returns the number of successes, to approx pi use formula
@Brandon-Rozek
Brandon-Rozek / generatePrime.c
Created May 14, 2021 23:43
C code to generate prime numbers
#include <stdio.h>
#include <math.h>
int isPrime(unsigned long long n);
int main() {
printf("%d", 2);
unsigned long long i = 3;
while (1) {
if (isPrime(i)) {
var decay = function(initial, chance) {
var numDecayed = 0;
for (var i = 0; i < initial; i++) {
if (Math.random() < chance) {
numDecayed++
}
}
return numDecayed;
}
@Brandon-Rozek
Brandon-Rozek / MonteCristo.c
Created May 14, 2021 23:14
Monte Cristo Simulation
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//Amount of times for simulation to run
#define N 5000000
//The amount of times per simulation
#define R 1
//The amount of choices
#define C 4
@Brandon-Rozek
Brandon-Rozek / symmetricgroups.py
Created April 21, 2019 21:02
Symmetric Elements (Group Theory)
import numpy as np
class SymmetricElement:
def __init__(self, *args):
self.data = np.array(list(args), dtype=np.int64)
# Confirm that there is at least one mapping
assert len(self.data) > 0
# Check bijective
assert len(np.unique(self.data)) == len(self)
# Check that range is between 1-length