Tasty Science with a Side of Baloney
Snakey.png

baby snakes

Baby Snakes: Mark's journey into Python

Snakey.png

entry.9 May 15, 2018

Look it up, Scotty

bloghb.jpg

These last few weeks have served up some real humdingers. Last Wednesday I torpedoed my project - I did some copy/paste coding that honestly I didn't understand. And like a first-year attempting some forbidden Ravenclaw sorcery, it cursed my whole kit and kaboodle, making my html pages refuse to load. I didn't understand what I did wrong, and I didn't know how to fix it. What's worse, my project ran just fine on my mentor's computer. Was I the problem all along?

Turns out that Django is a real fickle pickle when it comes to how your folders are organized and where you shove your files. Ultimately, I remade my whole project in a new directory using PyCharm - a feature-packed text editor/terminal/file viewer doohickey.

My seemingly insurmountable problem with retrieving form data (you know, real complicated stuff like, when you type your name into a website's form field and then on the next page YOUR NAME APPEARS - WHAT!) was ultimately overcome through a combination of mentor advice, web videos, documentation, and good ol' fashioned burn-it-down-and-start-overitude. I made some compromises, but ultimately I got the name generator part of my project to... generate names. Score?

The next hurdle was to get django to display image files. This is a pretty simple thing to do in html. But django's all like, "why would you type out all that html code when you can just go {% everything you ever wanted appears in these bubble brackets like elegant swan magic %}?" The bubble bracket technique (not an actual term) looks nice and neat on the page, but to pull it off you have to be a real behind-the-scenes watch maker - setting all the appropriate cogs in motion. Right now I'm not at watch maker level. I'm a finger painter. So to me much of the back end coding was arcane runes and maddening glyphs. But after much toil, I got the web pages to display images. How? Moving folders around! Django's a fickle pickle about that, remember?

My final thing - which, admittedly, is just bragging at this point - is that I wanted an image of a bear to appear on the final page which corresponded to the user's randomly generated "bear type".  Roll a panda, see a panda. Conceptually, pretty basic stuff. But to make it happen, I had to swim the uncharted waters of writing a conditional statement (e.g. if x than y) in jinja. Jinja is like a mini code language that lives in Django and connects what you write in Python code with html. It's like some uber-nerd who speaks both parseltongue and l33t. ANYWAY. I did some surfing around, found a copy/pastable formula (which didn't work), then swapped out some important bits (did you know that a ~ does something useful when you put it in {% %}s?) and my frankenformula worked! AHAHAHAHA! Now the bearacter generator can look at the words "Honey Badger" and poot out a picture of a Honey Badger. I am so proud.

Computer is magic, children. Computer is magic.


entry.8 May 1, 2018

Code Magic

omg bearacter image.PNG

Sometimes working on my Python project (really a django project) is so frustrating that it makes me doubt whether this whole coding business is right for me. Admittedly, I've only been at it for 4 months. With that in mind, I suspect that my anger and existential melancholy are cut from the same cloth as a petulant 2-year-old's insistence that they'll never learn read because it is dumb. I don't think coding is dumb. I think that I am dumb when I try to code/read about how to code/watch video tutorials on how to code/imagine myself interviewing for jobs that require coding. I think that's the big difference between me and my 2-year-old self: child-Mark fought against learning, modern Mark fights against modern Mark. I could learn something from my larval form. 

All that really compelling drama aside, I am happy to report that tonight I captured that rare and beautiful bird - the "win" of a newly functioning feature. My project now has a final page that will list the user's character stats and randomly generated name. I want to use forms (ugh. Don't get me started) to provide the option of filling in your own character name, but for now the minimum viable product is doing its job. It is a rough beast, but it trundles along inside my laptop, following the carrot that I dangle. And while it is ugly and unfinished, while it drives spines of self-criticism into my ego, I've become quite fond of it. Like a little baby golem made of glowing nonsense words. Coding is magic. I just hope I'm not a squib. 


entry.7 Apr 12, 2018

Slaying the Djangogre

2018-04-12 (3).png

I am steeped in the heady, bone-loosening broth of relief. After what seems like an eternity (irl - maybe 3 days), I finally discovered a solution to what seemed like a monumental problem in advancing my project. Lemme break it down for you, like real smooth:

1. My project (the Honey Heist Bearacter Generator - GET IT?) is basically a series of questions, written in Python, that the user answers in order to generate a set of character stats and a fun name. A bear name. I know, most of us could probably build the same thing with an Excel spreadsheet and a thesaurus, but I'VE ONLY BEEN CODING FOR 3 MONTHS, PAL! And I think the idea's pretty keen. I mean, I like Honey Heist and I hope that someday the other good nerds out there will appreciate what I've built for them.

2. At the time of writing, the HHBG exists solely in Python as a .py file. Useless to most of the sapient world. So then, Mr. Potter, how does one get the magic words out of the grimoire and into the hands of the muggle world? DJANGO, my dear heart, DJANGO! *Side note: Did you know that improvisers call people of the the non-improv world "muggles"? I mean, I bet a lot of niche communities do that, but still it's a little shitty.  Of course, I'll wager that the muggles are more likely than the improvisers to have health insurance and earn enough to put something aside for retirement, so joke's on the wizards I guess? I was an improviser. I ran out of youth and juice. Now I'm recharging. Training to be a codesman. I'm Luna Lovelace.

3. Django is a framework, as I mentioned in my last post. It lets you put your Python code on a website. Django is not its own programming language, but it does have special rules and syntax that you gots to learn. I wish I had a clever and suitable metaphor for it but I don't. It reminds me of a video game editor that I used in the 90's to build my own DOOM levels. The sprites and terrain looked familiar, but there was still much to learn before I could produce anything to write home about. Not that I'd write home about making a DOOM level. In fact, no one writes home about anything anymore. Writing home is even older than DOOM.

4. My boggle, my CONUNDRUM, was that I needed to find a way to use Django to put the HHBG on the web, so that everyone can enjoy(?) it. To do this, I need to make a series of web pages that include my Python code. Each page will gently guide the user towards the ultimate goal of assembling their bear character. This plan is dependent upon the creation of pages that link to each other. AND FOR THE LAST MILLION YEARS I COULDN'T GET DJANGO TO MAKE PAGES LINK TO EACH OTHER. It seems so easy. In HTML (which is like the Miller High Life of coding - so basic, but so necessary) you can just type out a hyperlink in a .txt file, open it in your browser and SHABOOSH you're there. That's not the case with Django.

5. Django, you see, employs an interdependent system of .py files. There's one for URLs (I still don't know what those is), there's one for Settings, one for Templates, one for Views(what? even?), one for Models(WHO ARE THESE MODELS), and all the online documentation on how to navigate these files seems to be written for people with larger, shinier brains than I. Even getting started was daunting. Frankly, I had trouble keeping my discouragement and frustration in check. But I kept reminding myself when I'd run into yet another obstacle, that Django is like a labyrinth: convoluted, but unchanging. Time is on my side. I can take wrong turns over and over again, and eventually I will figure out how to traverse this wrinkly behemoth. So I spent 3 days of life trying to figure out how to make a hyperlink work. So what? Now I know (sort of). And according to a children's cartoon about war; knowing makes up at least some percentage of the battle.

My Chipy mentor said that the hard part is over, and from here on out it should be easy peasy. She is a bad liar, but nevertheless I applaud her support. It might not seem like a big deal to you, but making that "Roll page" link to another page was big for me. Baby steps, my mentor says. Baby snakes, motherfucker, baby snakes. 


entry.6 Mar 18, 2018

I am a Cat Chasing a Dot of Laser Light: Pip Install

Rejoice! My project (The Honey Heist Bearacter Generator) has grown into a robust enough assemblage of code organelles that it is time to consider how to wrap it in the cytoplasm and shiny new cell walls of Django.

What is Django?  It's a framework - which as far as I understand is like a skeleton that you drape your python snake all upons. Once activated, the skeleton bears the snake unto the internet and they fuse together like Skeksis and Mystics (spoilers, people reading this back in 1982) to become a web page - fueled by the might of python!

I have a lot of new stuff to learn (which is really the theme of this whole experience), and lots of additional jargon to ingest, but it is exciting to think that somehow, someday my humble code could move out of the house and make something of itself in this big, beautiful world.

Speaking of leaving the house - I made it out to my first ChiPy workshop night this week. I walked among the snake-folk all gathered after sundown to crush code and smorsh on pizza. I did one of those things. More on that in a later blog post.

Y'member how I'm always kvetching about being overwhelmed by the gyre of jargon through which I flounder? Here's a video which encapsulates my experience with coding terminology:

entry.5 Feb 25, 2018

Virtual Environment(al illness)

I'm wearing a hoodie, in a Starbucks, typing into my laptop like Real Legit Devs do. Those ChiPy chaps did  not forget my absence from their workshop 2 weeks ago - and now I'm digging into my make up assignment. 

20 minutes ago I was filled with the impotent rage of a thousand Theon Greyjoys. Ok, that may be a bit of an exaggeration.

The assignment began with the caveat that before beginning, one should:

  • Have some idea about virtualenv and installing packages with pip

I have some ideas about virtualenv and pip installations. One idea is that 'virtual env' is probably what the kids say when feeling covetous of somebody's new PSVR. 

     "Did you see the adjustable skulljack accessory on Hibiscus' new        Daydream headset?"

     "Sh'yeah. I'm, like, virtual env all day. Anyway. Let's do all the things."

     "Let's vote as well."

     "Lit."

     "Squad goals."

ANYWAY.

I spent an hour ramming my head against the dry wall of the project instructions, trying every terminal and black box available to set up my virtualenv and install stuff directly up my pip.

Ultimately, my girlfriend took humanitarian pity on me and walked me through the process. Success! I can now begin the make up project. Or CAN I?

Tune in next time for more adventures in: Mark's World of Nearly Coding.


entry.4 Feb 19, 2018

FOMO sapiens

 Cardboard Forest

Cardboard Forest

One of the reasons I'm learning to code is that my current job entails the routine moving of heavy boxes and the involuntary application of dust into my tender eyeballs. Don't get me wrong - my current job has a lot of great aspects, it's just that me and physical toil aren't the happiest of bedfellows.  

"This is why you're learning Python," I sometimes think to myself (I stopped thinking to others after I left that school for gifted mutants) as I hoist parcels overhead like a goddamned leafcutter ant. Coding may provide a new direction in life for this recovering man-of-Theatre, but as with most things in life, I have to actually show up to make it happen.

ChiPy had a mandatory workshop last week which I missed because more boxes needed to be moved at work. I felt real emo working late into the night, breathing the storage room air, gnawing through my granola bar dinner, while a cohort of my still-unmet colleagues enjoyed each other's company - and pizza. Pizza! But worse than the food-envy was the ugly feeling that I was missing out on something that could really improve my quality of life. Even if coding isn't my next career, just learning such a new and challenging skill is its own reward.

By the time I got home, I felt like the husk of a husk. Tired, falling behind at work, and AWOL for my second Python event. Crab city. But then my good girlfriend surprised me with takeout from my favorite restaurant. It was like sweet medicine for the soul.

Sometimes we fail to meet our own expectations. That's okay. A year ago I didn't even know what the hell Python was.

Three days after my night of frustration I added more code into the Honey Heist Bearacter Generator. It worked, and I felt really good. The world has all sorts of secret bonus levels that we never expected to find when first we set off on our quest. I am thankful that ChiPy accepted me and the fact that I felt so strongly about missing out is a good sign.


entry.3 Feb 11, 2018

A code sprouted!

 The Bearacterization begins...

The Bearacterization begins...

So. As part of Chipy I need to create something using python. My friend and fellow podcaster Grant Howitt (who makes table top role-playing games for a living!) wrote a delightful RPG called Honey Heist in which the players get to be criminal bears engaged in, well, a honey heist.

I vow to use python to liberate new Honey Heist players from the archaic rolling of dice. Through code, I will provide these brave gamesters a method of generating their characters via the electric euphoria of hitting the ENTER key! Forget the year of the dog, 2018 is the year of  the Honey Heist Bearacter Generator! And both Grant and Jaimie gave me permission, so I'm `onna do it.

I'm an adult.


entry.2 Feb 10, 2018

Gitbash whiplash

Gitbash is now my sworn nemesis.

Rewind.

I had my first meeting a few nights ago with my Chipy (Chicago Python if you're nasty) mentor, Jaimie. We sat down on a wintery night over decaff coffee and set up the "environment" in which I suppose the little electric python in my computer will live. The python, I assume, is like a tamagotchi egg - it needs a warm rock to rest upon and, I don't know, some fetal mice every two weeks? 

Nearby patrons regaled each other with happenings of the day, and my laptop familiar bore silent witness as I attempted to, without hyperbole, convey to Jaimie that when it comes to coding, I know nothing. I'm Jon Snowcrash.

Okay, that's a lie. Last month I started learning HTML and CSS through the Grow with Google web development challenge. But that coursework has nothing to do with the mysterious "back end" language of python.

Again, a lie. Apparently you can use something called a "framework" to make python code work on a website (HTML and CSS make up and modify the "front end", the stuff you see and click upon when you do an internet).

Anyway, long story long, Jaimie told me to use Gitbash to interface with Github (a website where the code folk share files with each other and ensure VERSION CONTROL - SWEET MOTHER OF MERCY WHY IS THERE SO MUCH JARGON IN MY WORLD NOW? What is a version and why must we enforce such strict control over it? Is it dangerous? Does it want to hurt the python? This must be why Jaimie had me install the python shell! To protec!

The DOS-like commands that make Gitbash git up and work don't make much sense to me. Push? Pull? Commit? - is this an application or a romantic comedy?* Sheesh!

Well, I tell myself, it's going to  be okay. This is the just the beginning of a journey. I'm sure within a few days Gitbash and I will be the best of pals. 

Flash forward. 

GITBAAAASH! I have no clue what I'm doing. And, without fail, I never try to use Gitbash until I've made progress in coding my project and am rarin' to upload the code.

So happy with my shiny new baby code, and then - eeeee!  The casket lid of that unholy prompt of darkness shudders open and I spend the next hour in its thrall. Like a fool, tilting at windmills, I blast word-spaghetti keystrokes into the void that stretches across innumerable realms, supposedly connecting my computer with the Shangri la known as my Github "repo".

On an intrinsic level, I know that Jaimie knows that I don't know how to Gitbash. And this failing on my part is a crime against all law-abiding code folk.  They know. They can smell my sacrilegious drag-and-drop uploads. They can feel them. They taste my shame.

tl:dr It's time to read the dang Gitbash instruction manual already. 

 

* pretty good.

entry.1 date: unknown

>>> print("Help computer.")

The aircraft landed  and all mammals seated within checked their phones. We have a real problem with that as a society, but that's another post for another day. One of said vertebrates (me, surprise!) gazed through the opalescent face-oils of his screen protector, and opened his gmail app: 1 new email.

The message conveyed that I had received a place in the Chicago Python Mentorship Program (a project under the auspices of the Chicago Python User Group).  Hot diggity-dog!

I zapped a screen grab of the email to my girlfriend (she was seated in a different aisle because for safety reasons airlines discourage amorous feelings  between passengers). 

You see?  I silently exclaimed to the imaginary authority figure that I keep around just in case I start to get too puffed up. I have done a thing of merit!  Even at my advanced age of 35  I can become a cyber-trainee! An acolyte of electromancy!  A fizz buzz wizard!

My gf sent me a congratulatory Line sticker of Rilakkuma and his family of bears clapping and dancing. And why not? It's a modern world after all. I was about to learn how to computer. I wasn't Mark Soloff, area podcaster anymore - I was a python mentee! There was just one teensy fly in this vast soup of fortune: I had no idea what people do with Python.