Skip to content

Instantly share code, notes, and snippets.

View mp035's full-sized avatar

Mark Pointing mp035

View GitHub Profile
@mp035
mp035 / setup_python_environment.sh
Created July 18, 2024 07:48
Shell script to create a python virtualenv with it's own python version different to any installed python.
#!/bin/bash
set -e
sudo apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
# buid interpreter if it does not exist.
PYEXEC="python_interpreter/bin/python3"
if [ ! -f "$PYEXEC" ]
@mp035
mp035 / app_adc.c
Created February 24, 2021 23:56
STM32F030F4P6 App ADC Code
/*
* app_adc.c
*
* Created on: 20 Feb 2021
* Author: mark
*/
#include "main.h" // for access to hardware functions
#include "app.h"
#include <string.h>
@mp035
mp035 / axios_to_fetch.js
Last active June 7, 2023 11:29
Replace axios requests with fetch interface.
//This adds axios.get, axios.post, axios.put, and axios.delete compatible methods to
//the global namespace. It is intened for json transactions.
let token = document.head.querySelector('meta[name="csrf-token"]');
class HTTPError extends Error {
constructor(response, ...params) {
// Pass remaining arguments (including vendor specific ones) to parent constructor
super(...params);
@mp035
mp035 / laravel-ajax-form.js
Last active October 5, 2022 22:14
Convert any standard HTML form to ajax by adding a few classes to the components and including this file. (see comments)
// notes on using this file:
// This file is intended to work with a standard html form the same as what you use for server side rendered laravel projects.
// The only changes you need to make to the form are:
// 1. Add the class "ajax-submit" to any form you want to be submitted via ajax.
// 2. If you have a "Cancel" button on your form, mark it with the class "form-cancel"
// 3. Add a bootstrap alert in your form, marked with the class "ajax-error-alert" and "collapse" (to keep it initally hidden). This alert will display any error messages.
// Then call the function "AttachAjaxSubmit()" after the DOM is loaded.
// NOTE: This script requires bootstrap to style the components during the submission process.
@mp035
mp035 / tk_scroll_demo.py
Last active June 19, 2024 08:19
A simple scrollable frame class for tkinter, including example usage.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
import tkinter as tk
import platform
# ************************
# Scrollable Frame Class
# ************************