Skip to content

Instantly share code, notes, and snippets.

View lsloan's full-sized avatar

Mr. Lance E Sloan «UMich» lsloan

  • Teaching and Learning (@tl-its-umich-edu) at University of Michigan: Information and Technology Services
  • Ann Arbor, Michigan, USA
  • 13:33 (UTC -05:00)
  • X @lsloan_umich
View GitHub Profile
@lsloan
lsloan / pycon_pdf_to_png.py
Last active May 22, 2024 01:41
A small program to convert the PDF of the PyCon US 2024 venue map to individual PNG images.
import urllib.request
import pymupdf # pip install PyMuPDF
url = ('https://pycon-assets.s3.amazonaws.com/2024/media/'
'documents/DLCC-Floorplan-Marked_up_PyCon_US_2024.pdf')
# url = 'file:DLCC-Floorplan-Marked_up_PyCon_US_2024.pdf'
with urllib.request.urlopen(url) as response:
pdfStream = response.read()

Mathematical Summations in Python

Problem

I saw a video that claimed the following mathematical summation…

$$\sum_{\substack{i=0 \\ i\neq 4}}^{n} i$$
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lsloan
lsloan / periodFormatIso8601.py
Last active November 10, 2023 18:43
Two functions for creating a timestamp from a number of seconds. One from StackOverflow and mine. I thought I could do better.
def time_format(seconds: int) -> str:
"""
From: https://stackoverflow.com/a/68321739/543738
"""
if seconds is not None:
seconds = int(seconds)
d = seconds // (3600 * 24)
h = seconds // 3600 % 24
m = seconds % 3600 // 60
@lsloan
lsloan / caliper_custom_action_example.php
Last active September 13, 2023 14:30
Caliper: An example of using caliper-php to send an event with custom action and context.
<?php
require_once 'vendor/autoload.php';
use IMSGlobal\Caliper\actions\Action;
use IMSGlobal\Caliper\Client;
use IMSGlobal\Caliper\context\Context;
use IMSGlobal\Caliper\entities\agent\Person;
use IMSGlobal\Caliper\entities\agent\SoftwareApplication;
use IMSGlobal\Caliper\entities\media\MediaLocation;
use IMSGlobal\Caliper\entities\media\VideoObject;
@lsloan
lsloan / decrypt_dbeaver.py
Created August 11, 2023 02:44 — forked from felipou/decrypt_dbeaver.py
DBeaver password decryption script
# https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection
import sys
import base64
print(sys.argv[1])
PASSWORD_ENCRYPTION_KEY = b"sdf@!#$verf^wv%6Fwe%$$#FFGwfsdefwfe135s$^H)dg"
@lsloan
lsloan / decrypt_dbeaver.py
Created August 11, 2023 02:43 — forked from felipou/decrypt_dbeaver.py
DBeaver password decryption script - for newer versions of DBeaver
# https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection
# requires pycryptodome lib (pip install pycryptodome)
import sys
import base64
import os
import json
from Crypto.Cipher import AES
@lsloan
lsloan / umich-udp-bigquery-to-pandas-dataframe.ipynb
Last active July 19, 2023 02:46
umich-udp-bigquery-to-pandas-dataframe.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lsloan
lsloan / copy-of-pandas-101-data-cleaning-in-pandas.ipynb
Last active July 18, 2023 02:42
Copy of Pandas 101 - Data Cleaning in Pandas.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lsloan
lsloan / ChatGPT.py
Last active May 17, 2023 20:23
ChatGPT experiment in Python
import json
import os
import openai
class ChatApp:
def __init__(self, model='gpt-3.5-turbo', load_file=''):
# Setting the API key to use the OpenAI API
# openai.api_key = os.getenv('OPENAI_API_KEY')