Skip to content

Instantly share code, notes, and snippets.

View cp2004's full-sized avatar
⚖️
Balancing code & education

Charlie Powell cp2004

⚖️
Balancing code & education
  • UK
  • 19:35 (UTC +01:00)
View GitHub Profile
@cp2004
cp2004 / instructions.md
Last active January 26, 2023 12:52
Download the plugin repository & search for usages with ripgrep

Script to download the entire plugin repository :)

  1. Create a new folder/directory and download the below script to it
  2. Create two new folders, plugins and extracted (I couldn't be bothered to make the script check & create them itself)
  3. Run the script (Python 3). It may not be the most efficient process, as it downloads & extracts one by one, but it only took around 5 mins for me. That's 5 mins waiting or the 40 mins I could have spent trying to make it a fast script...

Using ripgrep to search every plugin for a string

On Linux, I used ripgrep which is a very fast searching tool - it matches practically instantly against the whole repo.

@cp2004
cp2004 / marlin-sim-instructions.md
Created July 17, 2022 18:18
Setting up the Marlin Simulator and OctoPrint

Setting up the native Marlin Simulator and connecting to OctoPrint

This details the steps I had to go through to get this up & running on & connected to OctoPrint. It provides a GUI to simulate the printer, supporting a subset of the Marlin features. You can connect to it via OctoPrint, but it requires a small patch.

Windows Setup

Dependencies

  1. Git checkout of Marlin, setup with AutoBuildMarlin/Platformio in VS Code.
@cp2004
cp2004 / ws281x-docker-compose.yml
Last active February 5, 2021 19:19
How to get WS281x LED Status running in docker
version: '2.4'
services:
octoprint:
image: octoprint/octoprint
restart: unless-stopped
ports:
- 80:80
# devices:
# - /dev/ttyACM0:/dev/ttyACM0
from __future__ import absolute_import, unicode_literals
import octoprint.plugin
import threading
class BackupTestPlugin(octoprint.plugin.StartupPlugin):
def on_after_startup(self):
# waits for a minute, then tries to create a backup
t = threading.Timer(interval=60, function=self.create_backup)
t.daemon = True
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import re
import octoprint.plugin
TIME_REMAINING_THRESHOLD = 2 # mins
COOLDOWN_COMMAND = "M140 S0"
M73_R_REGEX = re.compile(r"R(\d*)")
@cp2004
cp2004 / how_to_versioneer_octoprint.md
Last active November 16, 2020 23:03
How to add versioneer to OctoPrint plugins

Adding python-versioneer to an OctoPrint plugin

This guide uses Gina's custom versioneer that allows for different branches to be versioned automatically, using a lookup file. If you want to use mainline versioneer, most of this applies with the exception of the lookupfile sections.

  1. Download Gina's custom versioneer.py file from the OctoPrint repository
  2. Add it to the project root of your plugin, eg OctoPrint-WS281x_LED_Status/versioneer.py
  3. Add the configuration:
    • setup.cfg:
@cp2004
cp2004 / octopi-wpa-supplicant.txt
Last active October 17, 2023 17:02
OctoPi wpa supplicant clean file (OctoPi 0.17+)
# Use this file to configure your wifi connection(s).
#
# Just uncomment the lines prefixed with a single # of the configuration
# that matches your wifi setup and fill in SSID and passphrase.
#
# You can configure multiple wifi connections by adding more 'network'
# blocks.
#
# See https://linux.die.net/man/5/wpa_supplicant.conf
# (or 'man -s 5 wpa_supplicant.conf') for advanced options going beyond
@cp2004
cp2004 / sqlite_test.py
Last active July 29, 2020 09:09
TPLink sqlite3 Test
import time
import os
import sqlite3
from datetime import datetime
class TPLinkTest:
def __init__(self):
self.init_time = time.time()
print("[{}] Init".format(self.init_time))
self.db_path = 'test.db'