Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am raymondberg on github.
  • I am raymondberg (https://keybase.io/raymondberg) on keybase.
  • I have a public key whose fingerprint is BB28 7750 1288 C82F 46BE 18CB B593 A105 FEE2 03E5

To claim this, I am signing this object:

@raymondberg
raymondberg / an_email.py
Created April 8, 2021 14:23
Simple, full-featured sendgrid email sending
from send import send_email
def main(sandbox_mode=True):
send_email(
to_emails=["person1@example.com"],
from_email="my@email",
subject="Catchup",
html_content="Hello Umm Greg Universe,<br/>How are you?",
cc_emails=["an-email"],
reply_to=("my@example.com", "Me"),
@raymondberg
raymondberg / awsomeRegex.txt
Created January 25, 2021 20:13
On September 1, 2007 I created the following file. No idea why.
(.+)\n
>>>>>>>>>>>>>
mkdir \1\ncacls \1 /G Administrators:F \1:F SYSTEM:F\n\n
@raymondberg
raymondberg / FirstPython.py
Created January 25, 2021 19:46
My First Python Scripts were written on Jan 4 of 2007. Here they are for posterity
from itertools import count
def generate_primes(stop_at=None):
primes = []
for n in count(2):
if stop_at is not None and n > stop_at:
return
composite = False
for p in primes:
if not n % p:
composite = True
@raymondberg
raymondberg / randomize_imports.py
Created May 20, 2020 16:04
Diabolical Import Randomizer
import os
import random
import re
import shutil
def all_python_files():
for basedir, _, filenames in os.walk("."):
for filename in filenames:
if filename.endswith(".py") and "gotcha" not in filename:
@raymondberg
raymondberg / clip_extractor.py
Created July 25, 2019 15:50
Extract clips from videos
import os
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
OUTPUT_DIRECTORY = 'done'
clips = [
{'output': 'baby_peek_a_boo.mp4', 'input': 'baby_peek_a_boo.mp4', 'start': 0, 'end': 23},
{'output': 'tickle_me_elmo.mp4', 'input': 'tickle_me_elmo.mp4', 'start': 39, 'end': 74},
//... As many clips as you need
@raymondberg
raymondberg / delete_them_all.py
Created May 14, 2019 17:59
Delete All Versions of S3 Objects based on bucket and prefix
import sys
import boto3
def delete_all_version_fuzzy(bucket_name, prefix, do_it=False):
s3 = boto3.resource('s3')
bucket = s3.Bucket(bucket_name)
count = 0
print("Searching bucket({}) for prefix({})".format(bucket.name, prefix))
@raymondberg
raymondberg / bash.sh
Created May 6, 2019 14:41
Simple test wrapper for vimux stuff while I build out modules for custom tox/etc integrations
run_tests_as_modules () {
args=$@
args_with_dots=${args//\//.}
args_without_semicolon=${args_with_dots//:/.}
args_without_py_suffix=${args_without_semicolon/.py}
echo "Running 'python3 manage.py test $args_without_py_suffix'"
python3 manage.py test $args_without_py_suffix
}
@raymondberg
raymondberg / our_results.py
Created April 27, 2019 16:47
Remote Lab Results
import curses
import os
import sys
## Contributors: Richa, Pedro, Ramon, Doug, Ray
def draw_house(screen, color, offset_x=0, offset_y=0):
# Your job is to draw a house! Feel free to get creative!
draw_horizontal_line(screen, color, 0 + offset_x, 20 + offset_x, 8 + offset_y)
draw_horizontal_line(screen, color, 0 + offset_x, 20 + offset_x, 18 + offset_y)
@raymondberg
raymondberg / draw_a_house.py
Last active February 18, 2019 19:10
Group Programming Problem to Use Curses to Draw a House
import sys,os
import curses
def draw_house(screen):
# Your job is to draw a house! Feel free to get creative!
pass
def draw_square(screen, color, offset_x=0, offset_y=0):
screen.addstr(0 + offset_x, 0 + offset_y, 'X', color)