Skip to content

Instantly share code, notes, and snippets.

@cbscribe
cbscribe / lcd_char.c
Last active December 2, 2020 23:03
LCD animated character example
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte Alien[] = {
B11111,
B10101,
B11111,
B11111,
save_file = "passwords.txt"
logins = {}
customer = {"name": "google", "email": "[email protected]"
def save_data():
with open(save_file, "w") as f:
f.write(str(d))
def load_data():
@cbscribe
cbscribe / gist:78c8f18281653ab9cdf2fbcbd9e24946
Created December 15, 2020 19:15
NeoPixel example code - Lights up the string in two different colors
#include <Adafruit_NeoPixel.h>
#define LED_PIN 2
#define NUM_LEDS 12
Adafruit_NeoPixel pixels(NUM_LEDS, LED_PIN,
NEO_GRB + NEO_KHZ800);
void setup()
{
@cbscribe
cbscribe / db_example.py
Created January 20, 2021 18:06
Python SQL example
from cs50 import SQL
db = SQL("sqlite:///students.db")
name = input("Name: ")
student_id = db.execute("INSERT INTO people (name) VALUES (?)", name)
course_id = int(input("Course id: "))
results = db.execute("SELECT id FROM courses WHERE id = ?", course_id)
if len(results) == 0:
@cbscribe
cbscribe / application.py
Created February 2, 2021 18:16
Flask starter example
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html", name="Emily")
@cbscribe
cbscribe / example.py
Created February 10, 2021 20:54
Python: validating input
# Validating input
while True:
try:
num = int(input("Pick a number from 1 to 10: "))
except ValueError:
continue
if num >= 1 and num <= 10:
break
@cbscribe
cbscribe / biggest.py
Created February 12, 2021 21:27
FInd largest number in a list
numbers = [1, 5, 0, 39, 6, 809, 39, 2]
biggest = numbers[0]
for num in numbers:
if num > biggest:
biggest = num
print(biggest)
@cbscribe
cbscribe / scrabble.py
Created February 23, 2021 19:12
Scrabble lab starting code
# Points assigned to each letter of the alphabet
POINTS = {"a": 1, "b": 3, "c": 3, "d": 2, "e": 1,
"f": 4, "g": 2, "h": 4, "i": 1, "j": 8,
"k": 5, "l": 1, "m": 3, "n": 1, "o": 1,
"p": 3, "q": 10, "r": 1, "s": 1, "t": 1,
"u": 1, "v": 4, "w": 4, "x": 8, "y": 4,
"z": 10}
def score(word):
# TODO: Compute and return score for a word
@cbscribe
cbscribe / index.html
Created March 12, 2021 23:27
HTML First Example
<html>
<head>
<title>My First Page</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
color: green;
background: #cfb87e;
}
p {
@cbscribe
cbscribe / grade7.html
Created March 24, 2021 19:04
HTML Homepage Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mr. Bradfield's Classes</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!--navigation bar-->
<ul class="nav">
<li class="nav"><a href="index.html">Home</a></li>