Skip to content

Instantly share code, notes, and snippets.

Avatar
💾

John James sojohnnysaid

💾
View GitHub Profile
@sojohnnysaid
sojohnnysaid / encode_decode.py
Last active Jan 19, 2021
encoding/decoding data in python using the cryptography, dotenv libraries
View encode_decode.py
import os
import json
import time
from dotenv import load_dotenv
from cryptography.fernet import Fernet
load_dotenv()
timestamp = time.time()
my_secret_key = str.encode(os.getenv('email_confirmation_secret_key'))
crypto = Fernet(my_secret_key)
View bouncing-balls.rkt
;; CMPU 101 Assignment 3
;; <YOUR NAME>
;;
;; Description: Uses a list of bouncing balls to animate many balls
;; of different sizes and colors, all moving in the same scene at
;; different speeds.
(require 2htdp/image)
(require 2htdp/universe)
@sojohnnysaid
sojohnnysaid / HtDF_example1.rkt
Created May 8, 2020
Simple Data Course section 1b - HtDF example
View HtDF_example1.rkt
;; Signature
;; String -> String
;; Purpose
;; adds "!" to the end of s
;; Examples
(check-expect (yell "hello") "hello!") ; elborate - "hello" + "!"
(check-expect (yell "goodbye") "goodbye!") ; elborate - string-append "goodbye" "!"
@sojohnnysaid
sojohnnysaid / problem_sets.rkt
Last active Jan 19, 2021
How to code simple data 1a: Beginning Student Language - my problem set solutions
View problem_sets.rkt
;;---------------------------
;; arithmetic expression
;;---------------------------
(* 3 5 7)
(* (* 3 5) 7)
;;---------------------------
@sojohnnysaid
sojohnnysaid / email_monthly_coach_stats.gs
Created Jan 18, 2020
get dotafromzero coach stats via email
View email_monthly_coach_stats.gs
function email_Monthly_Coach_Stats() {
// get the current sheet as a 2d array
sheetData = getSheetData();
// filter the data by current month
sheetData = filterByCurrentMonth(sheetData);
// process the sheet and get back a nicely formatted object for emailing
sheetData = processData(sheetData);
View apology.html
{% extends "layout.html" %}
{% block title %}
Apology
{% endblock %}
{% block main %}
<img alt="{{ top }}" class="border" src="http://memegen.link/custom/{{ top | urlencode }}/{{ bottom | urlencode }}.jpg?alt=https://i.imgur.com/CsCgN7Ll.png"/>
{% endblock %}
@sojohnnysaid
sojohnnysaid / models.py
Created Dec 29, 2019
models file I created for the CS50 finance project
View models.py
from cs50 import SQL
import sqlite3
class users_db:
def __init__(self, conn):
self.id = ''
self.conn = conn
self.c = conn.cursor()
def register(self, username, hash):
@sojohnnysaid
sojohnnysaid / application.py
Created Nov 29, 2019
flask app using sessions and the flask session extension
View application.py
from flask import Flask, redirect, render_template, request, session
from flask_session import Session
# Configure app
app = Flask(__name__)
# Configure sessions
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)
@sojohnnysaid
sojohnnysaid / helpers.py
Created Nov 23, 2019
similarities less helpers.py, and index.html
View helpers.py
from nltk.tokenize import sent_tokenize
def lines(a, b):
"""Return lines in both a and b"""
(a, b) = (a.split('\n'), b.split('\n'))
# TODO
return [line for line in a if line in b]
@sojohnnysaid
sojohnnysaid / caesar.py
Created Nov 16, 2019
caesar python version
View caesar.py
import sys
if len(sys.argv) != 2:
print("Usage: python3 caesar.py key")
sys.exit(0)
key = int(sys.argv[1])
message = input("enter a secret message: ")
def cipher(letter, key):