#100DaysofCode Day 16

Started working on a local weather app (which is subject to change/improvements without notice).

My goal was to communicate with the API today, which I did, but I’ll add some style next.

May end up taking a few days off from #100DaysofCode for medical reasons this week, but when I’ve had some bad days (I’m disabled), coding is something I can do more often than not… so it’ll be a good test to see what happens during an actual recovery-from-something-specific situation.

My weather app goals: the FCC project has specific requirements, but when I’m done, I want to fork it and make it so users can enter cities or airport codes (or something) to get weather that way.

#100DaysofCode Day 14 & 15

Finished my Quote Generator!

I had a little trouble finding a free API to get the job done… but then I got too picky about the quotes (most quotes in a lot of these collections are kind of terrible…?)

I plan on revisiting this someday and seeing about using something like the Goodreads API because then I could pull quotes from favorite authors or topics from books. 🙂

Next, I’ll be working on this Free Code Camp project to display the weather.

#100DaysofCode Day 13

For the last two days, I’ve been working on a website for The Whisker Shop, my spouse’s cat furniture store we’ve been talking about making for ages. This started out as my capstone for WD4E, but it’s turning into a pretty awesome project: my spouse is also doing a Coursera capstone, but it’s for the project management specialization. So he’ll be focusing on implementing the business’s online presence, and I’m focused on making the website happen. If anyone from Coursera ever reads this, I hope you get a kick out of this capstone crossover collaboration. 🙂

Here is the link to The Whisker Shop’s Codepen, and I post this with the caveat that it will change over time, and will eventually be migrated to a live site. Some features so far:

  • Responsive design: mobile first, with an alternate wide screen view
  • Currently only utilizes HTML and CSS
  • Monochromatic color scheme for accessibility

    Wishlist and future plans:

  • Lightbox for displaying photos
  • Must pass validators, including accessibility validators
  • Minimal JavaScript for simplicity and ease, with a noscript option
  • I need to start taking some photos to display!

#100DaysofCode Day 12

I fully admit I’m slacking with the documenting– I’m getting so wrapped up in whatever’s caught my eye that day, that I forget to jot it down here after I jot it down in my notebook when it’s time to walk away for the day. (as an aside: all this learnin’ has reminded me how much I love to just WRITE stuff in notebooks. I retain everything a lot better if I physically write it with a pen and paper. So far I’ve gone through half a box of pens, and countless random pens, several notebooks, and my hands are TIRED.)

I’ve been working with Django more. Current project: a CATalogue of my cats. (get it? CATalogue?) I’ve created the model and the view(s) and next on my agenda is to figure out how to get image files in on this action. Because what’s the point of cataloguing my cats, if I’m not including pictures with adorable captions and descriptions?

example: models.py
from django.db import models
class CatProfile(models.Model):
cat_name = models.CharField(max_length=200)
# should change this to approximate year of birth:
cat_age = models.IntegerField("cat's age")
cat_desc = models.CharField(max_length=200)
def __str__(self):
return self.cat_name
def elderly(self):
return self.cat_age >= 10
elderly.short_description = 'Is this cat a senior?'

#100DaysofCode Day 11

I took the previous day‘s code for the Morse Translator and changed it to include list comprehension.

Through a series of unfortunate events, I had an unexpected allergic reaction two days in a row. One reaction often throws me for a loop for a day or two, requiring extra rest, but two in a row have left me feeling pretty wiped. It can take a short minute to get back in the swing of things when something like this happens (I partly blame the Benadryl hangover). This is one of life’s minor annoyances when living with chronic illness or disability. Some annoyances are bigger than others, of course. This could’ve been much worse, all things considered.

#100DaysofCode Day 10

I didn’t get too fancy with the Morse code converter… I ended up reading a whole lot of stuff about testing, though. The Hitchhiker’s Guide to Python has a great primer on code testing to start.

I really like testing.

I dropped today’s code on Github.

#100DaysofCode Day 9

a friend posted a sentence in Morse code, and rather than looking up a translation directly, I decided to write a script to translate it. I’m going to clean this up and post it over in my code samples when it’s prettier and has more functions, and I’m hesitant to post a rough draft of something so basic, but in the interest of accountability to myself, here’s a (functional) early version anyway, followed by the tests to ensure it works:

# morse code tranlsator

# dict of Morse code
morseCode = { "a" : ".-", "b" : "-...", "c" : "-.-.", "d" : "-..", "e" : ".",
            "f" : "..-.", "g" : "--.", "h" : "....", "i": "..", "j" : ".---",
            "k" : "-.-", "l" : ".-..", "m" : "--", "n" : "-.", "o" : "---",
            "p" : ".--.", "q" : "--.-", "r" : ".-.", "s" : "..." , "t" : "-",
            "u" : "..-", "v" : "...-", "w" : ".--", "x" : "-..-", "y" : "-.--",
            "z" : "--..", "one" : ".----", "two" : "..---", "three" : "...--",
            "four" : "....-", "five" : ".....", "six" : "-....", "seven" : "--...",
            "eight" : "---..", "nine" : "----.", "zero" : "-----", " " : " " }

# alphanum-to-morse conversion
def alphaInput(secretMsg):
    translatedWords = []
    words = secretMsg.lower().split(' ')
    for word in words:
        tempChars = []
        for c in word:
            m = morseCode.get(c)
        tempWord = ' '.join(tempChars)
    return '  '.join(translatedWords)

# TODO: morse-to-alphanum
# TODO: swap "dot" and "dash"
def morseInput(secretMsg):
    translatedWords = []
    morseWordList = secretMsg.split('\n')
    # Look up Morse-word line by line; one row = one word
    for word in morseWordList:
        chars = []
        chars = word.split(' ') # splits each Morse-word-row into Morse-characters
        for c in chars:
            chardict = { k:v for k,v in morseCode.items() if v == c }
            char = list(chardict.keys())[0]
        word = ''.join(translatedChars)
    return ' '.join(translatedWords)

# TODO: input / output (can django do this?)
# should this be in another file?
secretMsg = "... --- -- . --- -. .\n-.- -. --- .--\n-- --- .-. ... .\n-.-. --- -.. ."
# TODO: FIX THIS so it knows when to translate inputs written out as dot/dash
# the comparators with 'dot' and 'dash' don't work
if ((secretMsg[0] in '.-') or (secretMsg[0:3] == 'dot') or (secretMsg[0:4] == 'dash')):
    translated = morseInput(secretMsg)
    translated = alphaInput(secretMsg)

and the tests:

import unittest, morse

class MorseTest(unittest.TestCase):
    def test_alpha_to_morse(self):
        self.assertEqual(morse.alphaInput('A'), '.-')
        self.assertEqual(morse.alphaInput('SOS'), '... --- ...')
        self.assertEqual(morse.alphaInput('This is a test'), '- .... .. ...  .. ...  .-  - . ... -')
        self.assertEqual(morse.alphaInput('Cats are awesome'), '-.-. .- - ...  .- .-. .  .- .-- . ... --- -- .')

    def test_morse_to_alpha(self):
        self.assertEqual(morse.morseInput('... --- ...'), 'sos')
        self.assertEqual(morse.morseInput('- .... .. ...\n.. ...\n.-\n- . ... -'), 'this is a test')
        self.assertEqual(morse.morseInput('-.-. .- - ...\n.- .-. .\n.- .-- . ... --- -- .'), 'cats are awesome')

#100 Days of Code Days 7 & 8

I finished the Django tutorial!! and read the docs.

Does it count as 100 days of code if there was more reading than coding? In MY 100 Days of Code, I say yes. It’s my 100 days to do with as I wish.

I really love Python.

#100DaysofCode Days 5 & 6

Continuing with the Django tutorial… and discovered Django Girls, too, a UK-based nonprofit.

I hadn’t yet seen SQL in classes, and it’s just so… eloquent. I like it.

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete = models.CASCADE)
    choice_text = models.CharField(max_length = 200)
    votes = models.IntegerField(default = 0)
    def __str__(self):
        return self.choice_text