Skip to content

Instantly share code, notes, and snippets.

View D2theR's full-sized avatar

Dan Rerko D2theR

View GitHub Profile
@D2theR
D2theR / main.py
Created September 21, 2022 19:16
Raspberry Pi Pico Python Scale Simulator & Button Interface
"""
BEHOLD!!!
A 'SCALE-Y' solution for the Python tinkerer masses!
This should work on any Pi model with a little bit of tweaking to
the GPIO pins. Read comments below for more information.
Feel free to fork and contribute!
"""
from machine import Timer, Pin, PWM, UART, ADC
from time import sleep
@D2theR
D2theR / pubchem_vue.html
Created February 8, 2022 20:44
Generic VueJS and PubChem REST API Example using Axios
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js" crossorigin="anonymous"></script>
<style type="text/css">
body {
margin:15px;
@D2theR
D2theR / README.md
Last active February 28, 2024 17:34
Auto-generates Serializers & ModelViewSets in a Django API using just models

Why?

I got sick of writing the same Serializer & ModelViewSet classes over and over so I found and wrote some code to do it for me, and somehow it works! Please note that there are a lot of caveats to running an API like this and while this may work, I know there's A LOT of room for improvement, feel free to fork and help!

USAGE

Import the router module to your main sites urls.py file as the injection point like so... Make sure to remove any other imports from other viewsets that you don't need that may conflict!

@D2theR
D2theR / pubrestvue.html
Last active July 1, 2021 20:13
PubChem Rest API Widget Example with Axios & VueJS
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js" crossorigin="anonymous"></script>
<script scr="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js" crossorigin="anonymous"></script>
<style type="text/css">
body {
@D2theR
D2theR / ANX_IN-17x8v2.0wLEDS.ino
Created January 31, 2021 21:39
This is Arduino UNO Arduinix Nixie Tube drive code that also attempts to drive some NeoPixel Flora v2.
// This code was taken and modified from http://www.arduinix.com/Main/Code/ANX_IN-17x8_v1.0.txt
// Fading transitions sketch for 8-tube board with default connections.
// based on 6-tube sketch by Emblazed
// 01/28/2013 - expanded to 8 digit crossfade by Brad L.
// 06/16/2011 - 4-tube-itized by Dave B.
//
// 08/19/2011 - modded for six bulb board, hours, minutes, seconds by Brad L.
//
// 09/03/2010 - Added Poxin's 12 hour setting for removing 00 from hours when set to 12 hour time
@D2theR
D2theR / gunicorn.conf.py
Last active June 1, 2023 21:10
A simple Gunicorn config script that can be used to add your Django template file directories the reload engine to prevent having to reloading the server in development every time you make a change.
##Gunicorn config file
"""
USAGE
gunicorn -b 127.0.0.1:8888 -c gunicorn.conf.py myapp.wsgi
"""
import os, pathlib
template_root = pathlib.Path('/full/path/to/myapp/templates/')
template_list = []
for path, subdirs, files in os.walk(template_root):
@D2theR
D2theR / CSV_ACCESS_DUMP.py
Last active February 7, 2020 00:58
Dump Access database to PostgreSQL.
#!/usr/bin/env python
#
# A simple script to dump the contents of
# Microsoft Access Database tables to CSV & then to a PostgreSQL Database
# It depends upon the mdbtools suite:
# http://sourceforge.net/projects/mdbtools/
# Can be installed in most Debian based Linux distros with:
#
# sudo apt install mdbtools
#
@D2theR
D2theR / DOE-Excel-Generator.py
Created October 17, 2019 18:03
Generate Excel .xlsx file using Pandas for DOX/DOE recipe/ingredient formulations.
import itertools
from pandas import DataFrame
from IPython.core.display import display, HTML
#List of ingredients
DOX_INGREDIENTS = [
'Ingredient A',
'Ingredient B',
'Ingredient C',
'Ingredient D',