Skip to content

Instantly share code, notes, and snippets.

View jgibbard's full-sized avatar

James jgibbard

View GitHub Profile
@jgibbard
jgibbard / cartesian_to_lat_lon.py
Created November 19, 2023 21:43
Geodesic Calculations Checker
#!/usr/bin/env python3
# Tested with python3.11, geographiclib==2.0, matplotlib==3.8.2, numpy==1.26.2
import math
import numpy as np
import csv
import argparse
def get_x_y_data(filename):
@jgibbard
jgibbard / map_gen.py
Last active January 22, 2023 21:46
Generate a PNG map image from a shapefile
#!/usr/bin/env python3
import math
import shapefile
from PIL import Image, ImageDraw
# Longitude range to display in degrees
x_range = [-180,180]
# Latitude range to display in degrees
y_range = [-90,90]
@jgibbard
jgibbard / timesheet.ipynb
Last active January 23, 2023 21:29
Timesheet calculator
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import select, socket, sys, queue, time
from threading import Thread
from threading import Event
import logging
class TcpClient(Thread):
def __init__(self, ipAddress, port, recvQueue, sendQueue, stopEvent):
Thread.__init__(self)
@jgibbard
jgibbard / FM_Demod.ipynb
Created November 27, 2019 16:23
FM demod
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jgibbard
jgibbard / led.py
Created November 3, 2019 21:06
DE10 Nano LED / Key demo
from mmap import mmap
import time
import struct
LWFPGASLVS_OFST = 0xFF200000
LED_PIO_BASE = 0x3000
LED_SPAN = 0x10
KEY_BASE = 0x5000
KEY_SPAN = 0x10
@jgibbard
jgibbard / pythonInstall.sh
Last active November 10, 2020 08:52
CentOS7 - Install Python 2.7 and 3.6 from source
#!/bin/bash
# Python 2.7 and 2.6 install script for CentOS 7
# Instructions mainly taken from tutorial by Daniel Eriksson
# https://danieleriksson.net/2017/02/08/how-to-install-latest-python-on-centos/
python27_version=2.7.15
python36_version=3.6.6
build_dir=python_build_temp
example_environment_dir=pythonEnv
@jgibbard
jgibbard / latLongCalcs.py
Created October 22, 2017 17:44
Functions to calculate APPROXIMATE range, bearing, and XY offset between two lat/long positions
# Functions to calculate APPROXIMATE range, bearing, and XY offset between two lat/long positions
# Uses the Haversine Formula
# See http://www.movable-type.co.uk/scripts/latlong.html for more details
# Math library needed for cos, sine, atan2, sqrt, degrees, and radians
import math
# This is the mean radius of the earth in metres
EARTH_RADIUS = 6371000.0
@jgibbard
jgibbard / enigma.c
Created February 8, 2015 21:15
Enigma Machine Emulator
//Emulates the output of a WWII German Enigma encryption machine
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#define DEBUG
#define MAX_MESSAGE_LENGTH 100
//Strut Prototypes
@jgibbard
jgibbard / FPGA_VGA.vhd
Last active January 1, 2024 16:15
VHDL VGA PONG
--VHDL VGA PONG demo
--An FPGA version of the classic pong game
--Score counts up to 9
--Right player uses buttons 0 and 1
--Left player uses Switch 0 (Much harder!)
--Button 2 resets the game and score
library ieee; use ieee.std_logic_1164.all; USE ieee.std_logic_arith.all;
entity FPGA_VGA is