Skip to content

Instantly share code, notes, and snippets.

View cgobat's full-sized avatar
🛰️

Caden Gobat cgobat

🛰️
View GitHub Profile
@cgobat
cgobat / cputemp.py
Created December 8, 2024 21:18
Script to easily print current CPU temperature
#!/usr/bin/env python
"""Display/print current CPU temperature.
Copyright Caden Gobat (@cgobat on GitHub)
This program is free software. You may use, copy, modify, and/or redistribute it under the terms of the GNU GPL v3.
The lm-sensors package (or whatever provides the `sensors` command on your distro) is required to run this program.
This file is most useful if it is made executable and placed somewhere on your $PATH.
@cgobat
cgobat / 01_start.gcode
Created May 16, 2024 22:41
Creality Ender 3 v2 start/end gcode
M104 S160 ; Start warming extruder to 160
M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature
G28 ; Home all axes
G29 L ; Load UBL
G29 A ; Activate the UBL System.
G29 J ; 3-point level
G92 E0 ; Reset Extruder
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z0.5 F5000.0 ; Move to start position
@cgobat
cgobat / 00_readme.md
Last active March 21, 2024 11:57
Alpine Linux setup tools
@cgobat
cgobat / astro_hq.py
Last active October 11, 2023 16:03
Raspberry Pi setup script for astronomy. Portions from https://github.com/rlancaste/AstroPi3. Run `git clone https://gist.github.com/72d5705e65822a4e06363a444b1d2022.git scripts` to start.
print("This script has moved to https://github.com/cgobat/astro-instruments/blob/main/AstroHQ/astro_hq.py")

Turns a FITS binary table of Gaia DR3 stars with $m_G\leq8$ into a pseudo-tetra3-style database of stars with $m_V\leq7$.

@cgobat
cgobat / stdev_confidence_conversions.py
Created February 9, 2023 00:35
Functions to easily convert between number of sigma (standard deviations) and percent confidence intervals.
# see https://en.wikipedia.org/wiki/68–95–99.7_rule
import numpy as np
from scipy import special
def sigma_to_pct_conf(z: float) -> float:
"""If an uncertainty is ±zσ, what is the corresponding confidence interval?"""
return special.erf(z/np.sqrt(2))
def pct_conf_to_sigma(conf: float) -> float:
@cgobat
cgobat / subprocess.md
Created September 2, 2022 17:44
Python subprocess quick reference guide

Python subprocess quick reference guide

Some methods for running shell commands from within Python, depending on what the expected behavior and desired output are.


Popen

class subprocess.Popen(args, bufsize=- 1, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, universal_newlines=None, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=(), *, group=None, extra_groups=None, user=None, umask=- 1, encoding=None, errors=None, text=None, pipesize=- 1)

@cgobat
cgobat / cspice_exes.py
Last active October 13, 2022 19:19
NAIF CSPICE executable utilities made available within Python
import os, sys, platform
import subprocess
CSPICE_dir = "/absolute/path/to/cspice/"
__doc__ = """
SPICE executables, made available from within Python.
Available executables:
""" + "\n".join([os.path.splitext(exe)[0] for exe in os.listdir(os.path.join(CSPICE_dir,"exe"))]) + """
"""
@cgobat
cgobat / github_intro.pdf
Last active February 24, 2022 01:17
Work-in-progress introduction to GitHub slide deck I created, aimed at peers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cgobat
cgobat / activity recognition.ipynb
Last active February 20, 2022 01:54
Classifying physical activity using smartphone motion data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.