Skip to content

Instantly share code, notes, and snippets.

View themorgantown's full-sized avatar

Daniel themorgantown

View GitHub Profile
@themorgantown
themorgantown / laser_pointed_from_the_moon.py
Last active April 2, 2024 01:56
You're standing on the moon, and you locked a laser into a tripod and pointed it at the Earth's equator. What shape does your laser make across the earth as the moon orbits the Earth? Taking into account the moon's wobble, libation, and eccentricities, this draws a wobbly line up and down the equator about 10% of the earth's height (I think).
# pip install matplotlib astropy jplephem
from astropy import units as u
from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, get_body, EarthLocation, GeocentricTrueEcliptic
import numpy as np
import matplotlib.pyplot as plt
# Ensure astropy.units is correctly imported and used
initial_time = Time('2019-01-01 00:00:00', scale='utc')
@themorgantown
themorgantown / .htaccess
Last active February 6, 2024 16:08
Show an emoji of the Moon based on the current date (works well with Sendy on a PHP server). An example of using this in a sendy template: `https://example.com/moonphase/moonphase/[currentmonthnumber]-[currentdaynumber]-[currentyear].png` Requires png files in the moon_phases directory with these filenames: waning_crescent.png first_quarter.png …
# place this in the folder 'moonphase' at the top level directory to load
# https://example.com/moonphase/moonphase/02-03-2024.png
RewriteEngine On
# Check if mod_rewrite is enabled
<IfModule mod_rewrite.c>
# Rewrite only if the request is for a moon phase image
RewriteRule ^moonphase/([0-9]{2})-([0-9]{2})-([0-9]{4})\.png$ moonphase.php?month=$1&day=$2&year=$3 [L,QSA]
</IfModule>
// run on scene load....
// Function to update and set up the checkbox
function setupAutoPlayToggle() {
var checkBox = document.getElementById('autoPlayToggle'); // Get the checkbox element
if (checkBox) {
var autoPlayEnabled = localStorage.getItem('autoPlayEnabled') === 'true'; // Check if auto play is enabled
checkBox.checked = autoPlayEnabled; // Set the checkbox state based on the auto play status
checkBox.addEventListener('change', function() { // Add event listener for checkbox change
localStorage.setItem('autoPlayEnabled', this.checked); // Update the auto play status in local storage
@themorgantown
themorgantown / ttf_to_svg.py
Last active December 14, 2023 20:25
Get SVGs of every glyph in every TTF, organized into folders
# start with brew install fontforge
import fontforge
import os
import re
def sanitize_filename(name):
"""Sanitize the glyph name to be safe for filenames."""
return re.sub(r'[\\/*?:"<>|]', '_', name)
<?php
$upload_mb = upload_mb();
/**
* Calculate the maximum file upload size
*
* @return string Formatted size string
*/
function upload_mb() {
$max_upload = parse_size(ini_get('upload_max_filesize'));
@themorgantown
themorgantown / backup.php
Created April 5, 2023 17:36
Daily backups, keep 30: php / mysql, works on hosts that don't have mysqldump
<?php
// Database connection information
$dbhost = 'localhost';
$dbuser = '';
$dbpass = '';
$dbname = '';
// Backup folder location
$backup_folder = '/path/backups';
<!--
Manifest template to demonstrate the proper XML namespace declarations for
SCORM 1.2 manifests.
-->
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" identifier="com.scorm.manifesttemplates.scorm12" version="1" xsi:schemaLocation="http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
1
00:00:05,440 --> 00:00:09,279
thank you for joining the webinar
2
00:00:07,359 --> 00:00:12,960
we're going to talk about putting hype
3
00:00:09,279 --> 00:00:16,559
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=595,height=842" />
<title>Untitled-1-2</title>
<link href="css/idGeneratedStyles.css" rel="stylesheet" type="text/css" />
<script src="script/idGeneratedScript.js" type="text/javascript"></script>
</head>
# quick server for something in a folder called 'document' on your desktop.
# If your computer's hostname is 'Zappa' it will load http://zappa.local
myhost=`hostname` && cd ~/Desktop/document && open http://$myhost && python -m SimpleHTTPServer 80