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
  • 16:48 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile

Mathematical Summations in Python

Problem

I saw a video that claimed the following mathematical summation…

$$\sum_{\substack{i=0 \\ i\neq 4}}^{n} i$$
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
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
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')
@lsloan
lsloan / canvas_API_query.js
Created April 12, 2023 18:08
Run a Canvas API query from the browser using CSRF token set by the site.
var csrfToken = getCsrfToken();
console.log('crsfToken', csrfToken);
fetch('/api/v1/conversations/unread_count', {
method: 'GET',
credentials: 'include',
headers: {
"Accept": "application/json",
"X-CSRF-Token": csrfToken
}