Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert M Lugg robertlugg

View GitHub Profile
View simple_network.py
from tensorflow import keras
import numpy as np
from IPython import embed
INPUT_SHAPE = (3, 3, 1)
CONV_SIZE = 3
model_name = 'test_model'
def create_model():
@robertlugg
robertlugg / enumerate.py
Created Jul 27, 2020
Example iterating through multiple lists
View enumerate.py
list_column_a = [1, 11, 22, 33]
list_column_b = ['one', 'eleven', 'twenty two', 'thirty three']
list_column_c = ['exciting', 'blah', 'somewhat ok', 'fishy']
for idx, a in enumerate(list_column_a):
print(f"{a}, {list_column_b[idx]}, {list_column_c[idx]}")
for a, b, c in zip(list_column_a, list_column_b, list_column_c):
print(f"{a}, {b}, {c}")
View sampler.html
<!DOCTYPE HTML><html lang="en"><head><title>Sampler1</title><meta charset="utf-8" /><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" /><meta name="description" content="A sampler1" /><meta property="og:site_name" content="Sampler1" /><meta property="og:title" content="Sampler1" /><meta property="og:type" content="website" /><meta property="og:description" content="A sampler1" /><meta property="og:image" content="https://asampler1.carrd.co/assets/images/card.jpg?v82476884724951" /><meta property="og:image:type" content="image/jpeg" /><meta property="og:image:width" content="1280" /><meta property="og:image:height" content="800" /><meta property="og:url" content="https://asampler1.carrd.co" /><meta property="twitter:card" content="summary_large_image" /><style>html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,f
View VSCode Settings.md

{ "editor.insertSpaces": true, "editor.fontFamily": "JetBrains Mono, Cascadia Code PL, Droid Sans Mono", "editor.fontLigatures": true, "editor.minimap.showSlider": "always", "editor.multiCursorModifier": "ctrlCmd", "editor.renderControlCharacters": true, "editor.renderIndentGuides": true, "editor.renderWhitespace": "boundary", "editor.rulers": [100],

@robertlugg
robertlugg / timer.py
Created Apr 15, 2020
Timer that prints on same line. Example of CR without newline.
View timer.py
import time
counter = 0
while counter < 10:
print(f'\r{counter}', end='')
time.sleep(1.0)
counter += 1
print("Done.")
View string_encrypt.py
# Fixed version.
# Minimal changes to get it working
my_string = "This is a bunch of words!"
print(f'{my_string}')
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
outputStr = ''
for i in my_string:
for idx, j in enumerate(alphabet):
@robertlugg
robertlugg / file_write.py
Created Apr 14, 2020
Make directory. Write file.
View file_write.py
import os
# User entry of folder name. Make it.
folder = input("Folder name:")
try:
os.makedirs(folder)
except:
pass
# User entry of file base. Build full path.
@robertlugg
robertlugg / timer.py
Created Apr 12, 2020
Python timer example
View timer.py
import time
while True:
print("How long or 'exit' when finished")
try:
uin = input(">> ")
except Exception:
break
if uin == 'exit':
break
@robertlugg
robertlugg / min_max.py
Created Mar 16, 2020
Example User entry and determine min and max values.
View min_max.py
""" Program to accept list of numbers and return smallest and largest """
def main():
print("Enter numbers. Type 'done' for the number to compute min and max")
smallest = largest = None
while True:
user_entry = input('enter a number ')
if user_entry == 'done':
break
try:
@robertlugg
robertlugg / .bash_prompt
Created Mar 15, 2020
Bash prompt with conda and git
View .bash_prompt
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch of the current git/mercurial repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
You can’t perform that action at this time.