Skip to content

Instantly share code, notes, and snippets.

View pybites's full-sized avatar

Pybites pybites

View GitHub Profile
JnyJny /
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:
def toplevel_imports(cls, root: Path, prune: list[str] = None) -> list[str]:
bryankimani /
Last active April 29, 2023 19:04
This shell function streamlines the process of visiting repository URLs for faster navigation.
# This shell function streamlines the process of visiting repository URLs for faster navigation.
# With a simple command, "openrepo", you can easily visit the repository URL associated with the current folder you're in.
# This is particularly useful when you need to quickly access the repository of the project you're working on, without
# having to navigate to the URL manually. By executing the "openrepo" command from the command line, the script will
# automatically open the associated repository URL in your default browser. This saves time and eliminates the need for
# manual navigation, making it an ideal solution for developers and anyone else who regularly interacts with repositories.
openrepo() {
remote_url=$(git remote get-url origin)
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
treyhunner /
Created January 21, 2022 18:21
Python script to identify all Unicode flags that represent a different flag when reversed
Script to print all Unicode flag emoji are also a valid flag when reversed.
Output of this script:
🇦🇬 (Antigua and Barbuda) reverses to 🇬🇦 (Gabon)
🇦🇱 (Albania) reverses to 🇱🇦 (Lao People's Democratic Republic)
🇦🇲 (Armenia) reverses to 🇲🇦 (Morocco)
🇦🇶 (Antarctica) reverses to 🇶🇦 (Qatar)
🇦🇸 (American Samoa) reverses to 🇸🇦 (Saudi Arabia)
The wins file generator script we use at PyBites
Because it matters!
from datetime import date, datetime
import sys
Script to post a code snippet to PyBites
If you see other use cases (e.g. process a csv file with snippets),
contact @bbelderbos on Twitter, thanks.
from pprint import pprint as pp
# pip install requests python-decouple
import requests
from decouple import config
kyokley /
Last active July 7, 2018 13:29
Dynamically set Python2/3 version in Syntastic

Determining Python 2/3 Version in VIM


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...


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

`.............`.`....````.``........`..`..``````````````````````````````````````````````````````````````````````````````````````;, ,;;;;;;;;:,,,,,,,,``````````````````
`.....................``..................```````````````````````````````````````````` ``,,``````````````````````````````````:;. .;;;;;;;;::,,,,,:::,````````````````
`.....................`.`.............` `,`````````````````````````````. +`,`````````` `,.`````````````````````````````````:,;;;;;;;;;;;;::::::::::::```````````````
`...............................``.,,.``.`````````````````````````````####+'.````````` `..```````````````````````````````,,,:;;;;;;;;;;;;:,:::::::::::`````````````
simecek / followers_wc.ipynb
Created August 18, 2017 14:00
Generate wordcloud of followers' descriptions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
clamytoe /
Last active June 4, 2017 18:02
"""Written on iPhone with the Pythonista 3 app
As a joke for the PyBites guys, I don't see why it wouldn't work anywhere else though. They always
start off their newsletter annoucements with:
from @PyBites import newsletter
So I turned it into actual code that pulls their feed and opens their latest newsletter in a browser :)
import os