Skip to content

Instantly share code, notes, and snippets.

View bbelderbos's full-sized avatar

Bob Belderbos bbelderbos

View GitHub Profile
@JnyJny
JnyJny / find_imports.py
Last active July 27, 2023 08:46
Find Python Import Statements
"""Find import and import from statements
"""
import ast
from pathlib import Path
class ImportRecord:
@classmethod
def toplevel_imports(cls, root: Path, prune: list[str] = None) -> list[str]:
@ryaustin
ryaustin / vs_code_shortcuts.txt
Last active May 3, 2023 13:57
Visual Studio Code shortcuts for the productive developer.
**VS CODE Productivity Shortcuts** 👩‍💻🧑🏽‍💻👨🏼‍💻👩🏼‍💻👩🏾‍💻
A kind note: I haven't tested these on windows, if you notice an error, drop it in the comments :).
1. Opening and closing sidebar 📂
The sidebar can be opened and closed without clicking on the left-hand side tab using the following shortcuts.
Mac — Command + B
Windows — Ctrl + B
——
[
{"id": "1", "title": "PEP Purpose and Guidelines", "authors": "Warsaw, Hylton, Goodger, Coghlan", "discussions_to": null, "status": "Active", "type": "Process", "topic": "", "created": "13-Jun-2000", "python_version": null, "post_history": "21-Mar-2001, 29-Jul-2002, 03-May-2003, 05-May-2012, 07-Apr-2013", "resolution": null, "requires": null, "replaces": null, "superseded_by": null, "url": "https://peps.python.org/pep-0001/", "abstract": ""},
{"id": "2", "title": "Procedure for Adding New Modules", "authors": "Cannon, Faassen", "discussions_to": null, "status": "Active", "type": "Process", "topic": "", "created": "07-Jul-2001", "python_version": null, "post_history": "07-Jul-2001, 09-Mar-2002", "resolution": null, "requires": null, "replaces": null, "superseded_by": null, "url": "https://peps.python.org/pep-0002/", "abstract": "\nIntroduction\nThe Python Standard Library contributes significantly to Python's\nsuccess. The language comes with \"batteries included\", so it is easy\nfor people to become produ
@benevidesh
benevidesh / zn
Last active March 12, 2024 16:10
Zettelkasten Workflow (WIP)
#!/usr/bin/bash
# zn - as zettell
# new export variables EDITOR for your editor and
#+ NOTES for your notes folder.
main () {
note_id=$(date +'%Y%m%d%H%M%S')
$EDITOR $NOTES/"$note_id".md
}
@ryan-blunden
ryan-blunden / pybites-intro.py
Created November 30, 2021 11:58
Pybites commuity intro message fun
from dataclasses import dataclass
import random
pybites_init_questions = [
'If you were to build a chatbot what would it do'
]
@dataclass
class PybitesIntro:
@yaythomas
yaythomas / README.md
Last active November 28, 2021 16:12
pypyr video processing (untested) rough structural example

automating your video processing

[preamble]

what we want to achieve

TODO:

  1. download the video
  2. convert to different formats via ffmpeg
  3. create thumbnails
  4. use a trained ML model for scene classification
  5. make sub clips based on classification
@nnja
nnja / .pdbrc
Created August 2, 2019 12:55
My .pdbrc file with an interacti alias
# Install IPython: python3 -m pip install ipython
import IPython
from traitlets.config import get_config
cfg = get_config()
cfg.InteractiveShellEmbed.colors = "Linux" # syntax highlighting
cfg.InteractiveShellEmbed.confirm_exit = False
alias interacti IPython.embed(config=cfg)
@kyokley
kyokley / py23_check.md
Last active July 7, 2018 13:29
Dynamically set Python2/3 version in Syntastic

Determining Python 2/3 Version in VIM

Introduction

I am a big fan of the syntastic package. In python, it is useful for viewing both Pyflakes and Bandit errors. However, this only works if syntastic knows what python interpreter to use. Not everyone is fortunate enough to have upgraded all of their software to python3. For reasons out of my control, I end up spending most of my time writing python2 code. This means that the times when I finally get to write python3, all of my syntax checking is broken. How cool would it be to have VIM determine what version of python to use automatically? So, begins my grand experiment...

Prerequisites

For this to work, I will be using a virtualenv for python2 and one for python3. It's not absolutely necessary to use virtualenvs but I definitely recommend it. Setting up virtualenvs is out of the scope of this gist but make sure that each virtualenv

@clamytoe
clamytoe / pins.py
Last active April 15, 2023 14:54
Small script that generates all possible 4 number pin combinations.
"""pins.py
Small script that generates all possible 4 number
pin combinations. Inspired by @ThePracticalDev's tweet challenge:
https://twitter.com/thepracticaldev/status/1000191076106465281?s=21
Challenge Alert!!
Write a script that produces all possible 4-digit numbers (0000...9999),
then put them into a random order and save the output into a text file.
PYBITES_IMG = """
;;;;;;;;,,.`
:;;;;;;;;;;::,,,,,
`.............`.`....````.``........`..`..``````````````````````````````````````````````````````````````````````````````````````;, ,;;;;;;;;:,,,,,,,,``````````````````
`.....................``..................```````````````````````````````````````````` ``,,``````````````````````````````````:;. .;;;;;;;;::,,,,,:::,````````````````
`.....................`.`.............` `,`````````````````````````````. +`,`````````` `,.`````````````````````````````````:,;;;;;;;;;;;;::::::::::::```````````````
`...............................``.,,.``.`````````````````````````````####+'.````````` `..```````````````````````````````,,,:;;;;;;;;;;;;:,:::::::::::`````````````