Skip to content

Instantly share code, notes, and snippets.

View greyblue9's full-sized avatar
A day of coding is never a waste. Take 100 lines daily for 10 years 💻 🌟

David Reilly greyblue9

A day of coding is never a waste. Take 100 lines daily for 10 years 💻 🌟
View GitHub Profile
@greyblue9
greyblue9 / bf_format2.py
Created June 11, 2022 20:01
Brainfuck formatter (aggressive linebreaks versiom)
#!/usr/bin/env python3
# bf_format - format brainfuck code listings using nested indentation
# originally from https://pastebin.com/raw/FN1YMQ6r
# updated 2019-05-26-09:23 comment out the lf insertion for ']'
# I think it looks better this way, also results in shorter listing
# updated 2022-06-11 convert to use argv, add '-i' arg
# and indent every [ and ]
from io import StringIO
from pathlib import Path
from sys import argv, stdout
@greyblue9
greyblue9 / mandelbrot.bf
Last active June 11, 2022 19:41
"A mandelbrot set fractal viewer in brainfuck written by Erik Bosman", formatted with bf_format.py
+++++++++++++
[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++
[
[>>>>>>>>>]+
[<<<<<<<<<]>>>>>>>>>-]+
[>>>>>>>>
[-]>]<<<<<<<<<
[<<<<<<<<<]>>>>>>>>
[-]+<<<<<<<+++++
[-
@greyblue9
greyblue9 / bf_format.py
Created June 11, 2022 19:35
Format brainfuck code listings using nested indentation
#!/usr/bin/env python3
# bf_format - format brainfuck code listings using nested indentation
# originally from https://pastebin.com/raw/FN1YMQ6r
# updated 2019-05-26-09:23 comment out the lf insertion for ']'
# I think it looks better this way, also results in shorter listing
# updated 2022-06-11 convert to use argv, add '-i' arg
from io import StringIO
from pathlib import Path
from sys import argv, stdout
@greyblue9
greyblue9 / imap_gmail.py
Created June 8, 2022 08:55
Retrieve messages from gmail using imaplib
from dotenv import load_dotenv
from email import message_from_bytes
from imaplib import IMAP4_SSL
from itertools import islice
from os import getenv
from pathlib import Path
load_dotenv()
username = getenv("GMAIL_USERNAME")
password = getenv("GMAIL_APP_PASS")
@greyblue9
greyblue9 / smtp_gmail.py
Created June 8, 2022 07:33
Send email with smtplib and gmail
# Script to send email with optional
# attachments using gmail
#
import re
import smtplib
from pathlib import Path
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
@greyblue9
greyblue9 / download_website_images.py
Last active May 30, 2022 14:38
Download images from website using requests, lxml, bs4
import re
import bs4
import sys
import time
import random
import requests
import urllib.parse
import urllib.request
from urllib.error import HTTPError as UrllibHTTPError
from requests.exceptions import HTTPError
#!/usr/bin/env python3
from datetime import datetime
from sys import argv
from bs4 import BeautifulSoup, GuessedAtParserWarning, Tag
from warnings import simplefilter
from urllib.request import Request, urlopen
from urllib.parse import quote_plus, urljoin
simplefilter(category=GuessedAtParserWarning,action="ignore")
query = " ".join(argv[1:]) if argv[1:] else "gif"
@greyblue9
greyblue9 / Gmoney_123.html
Created April 13, 2022 04:08
HTML created by `markdown_py`
<h1>Thank you for using this library! Here are the basic ways to use it:</h1>
<h2>To import, do:</h2>
<blockquote>
<p>from G_Sketch import *</p>
</blockquote>
<h2>To create an object do:</h2>
<blockquote>
<p>my_sketch = Sketch("path/to/file.png")</p>
</blockquote>
<p>There are 3 functions for a sketch:</p>
@greyblue9
greyblue9 / json2py.py
Created December 19, 2021 09:59
JSON to Python classes converter
#!/usr/bin/env python3
# Modified 2021-12-19 by @greyblue92
# - Convert from python 2 to python 3
# - Add API call to convert json to C#
# - Fix a bunch of problems with the python output
# - Type renaming and generics
# Original code from https://github.com/shannoncruey/csharp-to-python
########################################################################
# Apache License, Version 2.0 (the "License");
# the License.
# EDITOR=vi
export EDITOR='vim'
export CLICOLOR=1;
export LSCOLORS=exfxcxdxbxegedabagacad;
PATH=.:~/bin:/usr/local/mysql/bin:/usr/local/bin:~/local/node/bin:$PATH
alias ll="ls -golAF"
alias lll="ls -lAF"