better living through python

An adventure in programming and recovery.

A little Thanksgiving reflection regarding social skill acquisition

November 25, 2011

 

It’s Thanksgiving day and I’m sitting at home programming.  Oh how the world has changed.  This year instead of the normal, smaller Thanksgiving gathering of my family and then subsequent gathering up at Robey’s parent’s house, my family pretty much decided to have an impromptu family reunion.  Most of my immediate family (1st cousin’s and Aunt’s and Uncle’s) are all living in Alabama.  But my family likes to stay ‘tight’, and thus an impromptu reunion consists of mostly second and third cousins, all from the local northwest region.  

So this Saturday I’ll be gathering with about 40 of my closest relatives for a day of shared goodies, chatter, and general loudness.  Some families may be quite, my family is quite the opposite.  There will be at least 12 kids there that I know of, not including other random add ins that might occur last minute.  

On top of it all Robey and I will be hosting my two nieces Kate and Liz for at least one, if not two nights, while all the extended family is housed at other varying family residential locations.  It will be fun to have the girls over for a sleep over.  I don’t know how we’re going to get any rest this upcoming weekend though.  Let’s just say it’s going to be busy.  

One of the things I do enjoy about Thanksgiving (besides all the amazing holiday traditional food items), is that it provides for a grand opportunity to see people you might not normally visit with.  Even if family can get crazy, or awkward conversations occur, family helps to provide context for the rest of the world in a safe way.  From my experiences, there is almost no family in existence that doesn’t have it’s own share of differing opinions between it’s members.  Family also has the tendency to forgive more often, and let go, because, well, ‘you’re family’.  When all is said and done you’re still expected to see them next year at the gathering.  

So if you’re Holiday season this year is stressing you out, remember that your family was and always will be the first battle ground towards social prowess.  You learn to slide over topics, or you learn when it’s okay to delve in a little deeper.  You also learn how to identify certain types of people in a crowd, like who has the power in a group.  So, from a much more business’esque standpoint take a step back and try to view your family as how someone from the outside might see them.  That’s how some of my best personal growth has occurred.  

Up Next Time: My first attempt at an HTML5 game: Science Fiction Tower Power

 

Symbol shock and subsequent javascript woes

November 23, 2011

 

Learning how to code javascript (and understand it’s inter-connectivity with HTML for pulling in user input) has been something else.  First off I began this exercise by learning how to use a new text-editor, Vim.  Next I also had to start learning how to use my programming knowledge and match it up with a new language.  Previously I had been reading up about javascript on W3schools, and had gotten through most of the basics.  Just last week I started learning a bit of javascript and jQuery to add some bits to our website.  

That was definitely not enough to have me sufficiently prepared for the symbol shock I later experienced.  These past 4 days have been filled with consistent questions and checking for syntax errors.  In all honesty I don’t know why someone felt it was necessary to make semicolons such an integral part of this language.  Sometimes it just makes the screen feel ridiculously busy.  Maybe it’s just me as I’ve only really learned python at this point.  Python doesn’t have some of these additional curly bracket/semicolon requirements that are a necessary part of javascript.  

I think one of the more difficult parts of javascript so far is simply learning the different terminologies to use when I want to do certain things I would have done in Python.  Such as using console.log() instead of print.  Or learning how to take in information from the HTML and how to alter it in the javascript(JS).  Learning when to create firm CSS or when to not create any and just create a div that you alter in the JS.  

So yes, plenty of new things to spark my brain into activity.  Today I’m hoping to finish creating the particles that come into existence when a ship is blown up from a correct answer, and also to create the bombs that hit them.  That means some additional graphical creation, but that’s just play work at this point.  Despite working pretty consistently to learn as much as I can and finish this project by my deadline, I don’t feel like I’m working.  I already feel like I’m on vacation, because what I’m doing creates so many instances of ‘woo I just made it do that’ excitement.  I guess this is what finding your dream job is like.  Never knew I would find it in programming.  Glad I never gave up on learning new things.  :)

Up Next Time: A little Thanksgiving reflection regarding social skill acquisition

 

New images and more description regarding our math game

November 22, 2011

 

I’ve been working all day on this math game.  As promised here is a  little more detail about our game.  First I’ll show you a couple of sample spaceship images.
These are a couple of our spaceships that are invading.  The spaceships come across the screen towards your base.  Your base will fire rockets at them and blow them up, but only if you answer the supplied math problem.  There is a choice between simple addition, subtraction, and multiplication.  In the future we’re hoping to add in ‘ten pair’ practice and number/letter recognition.  This game is mainly aimed at providing a fun alternative for learning needed math skills for my nieces and nephews.  

There will be a calculated score shown.  Spaceships will explode (minor javascript stuffs), and I’m aiming at shooting rockets towards them once a correct solution is submitted.  There will also be a print option so that my nieces and nephews can play the game and practice, then print the screen to show their parents how many points they’ve scored.  That way parents can use it to track practice.  Points only go up with correct answers, in more difficult settings incorrect answers will take away points (and in the future create additional ships coming towards you).

My hope is to offer a couple of adjustment options in the Menu bar, mainly difficulty setting and the ability to specify problem type.  In total I’m hoping to get the rough version out on Thanksgiving.  My translation services haven’t been in much need this week, so I’ve devoted myself to developing this game to jump start my jQuery/javascript education.  

In the future I will be adding a tutorial option, so that people can learn how it works (mainly so that younger children can learn with fewer spaceships in the beginning and move up to more difficult levels).  I hope to add simple shining stars, possible multiple ships per row, sharing tools, and maybe a way for a person to keep track of their total score (or a way to share that as well).  

Up Next Time: Symbol shock and subsequent javascript woes   

 

Using Vim, a beginners experience

November 21, 2011

 

This past weekend I was fairly busy working on a new side project of ours.  This side project is a math learning tool for my nieces and nephews in HTML5.  It’s a space invaders type game, with graphics created by yours truly, where for each successfully solved problem a creature is blown up.  This is my first time through the entire game development process.  Robey is helping me along, but I’m writing most of the code.  On top of that I’ve also been learning how to use a different text editor than the one I had been using (Sublime Text), Vim.  Vim has a variety of different key-stroke combinations that made writing code in the beginning a little choppy, but it’s slowly becoming much easier, and in some cases surprisingly faster.

There are some awesome things about this text editor that don’t exist in the one I’ve tended to use.  One example is the easy copy/paste key-strokes, that is once you get used to them.  You can copy paste things via key-stroke simply by hitting the number for the amount of lines below where you are that you want to copy, and then hit d twice in quick succession.  That then deletes the amount of lines you selected from the code.  However, they are not permanently deleted, as they are now accessible if you simply type the letter ‘p’.  Just locate yourself within the text as appropriate, and it allows you to simply copy that same text as much as you want.  In many way I feel that this kind of key-stroke would be helpful for writers in a word file.

Some key strokes definitely slowed things up at first, mainly the save key-stroke combination.  To save you must hit the esc key if you’re in edit mode and then type in :w and hit enter to save.  I’m so attuned to the ctrl+s combination that I using it quite often still when learning the new save method.  I also had a hard time remembering to type in i when I wanted to type in anything.  I do enjoy using just my keyboard if possible, so I think that I will find many of these combinations to be much more natural as time goes on.  It also helps that some of these key combinations will be added into our Kickstarter text editor project, Betwixt.  

The last thing I wanted to mention about Vim, was that the original screen coloring really threw me off.  At one point when we were discussing the organization of the HTML (which I’ve interacted with HTML a fair amount and know most of the terms/organization), I had serious issues even understanding what Robey was asking me about because I wasn’t connecting the screen I was looking at with the HTML I knew.  So when I had simply typed in some divs without thinking about nesting, Robey tried to walk me through why it would be a bad idea...which I couldn’t even understand what he was talking about.  That just reminds me how much a simple change in font and organization can block understanding.  One could also think of it as akin to symbol shock.  

Up Next Time: New images and more description regarding our math game

 

Lorry the Lion

November 18, 2011

I've been busy the past two days making this story for my nieces and nephews.  Let me know what you think.  Lorry the Lion

Betwux, Betwixt, Between.....a short literary job-chunk

November 16, 2011

 

Betwux two worlds is a sea of foam.  A place where the warm fluffy ocean tickles your hips and calves.  The sun is both rising and setting, whilst it warms your back with midday strength.  The sky is a rich mixture of yellows and pinks and blues.  You are awake and yet asleep.  Floating on foam that feels like oil yet with a fresh sting like arctic water.  Scents of a salty sweet sea, you relax in a Candy-Land.  One of dreams and passions enriched with the fat of youth.  Yellow brick pathways towards growth and adventure, to fanciful places and far-out landscapes.  British Taxi’s take you from country cottage to Highland manor.  Tropical birds swoop into your Siberian menagerie, delighting upon boiled peanuts and flower petals.  Your hound-dogs transport you on hunts as your horses chase your prey.  Through a glass flask and back again out the other side.  Traveling midst the depths of thought and time.  Waves propel you forwards and Betwux.

 

My final two functions and the winning name from our Kickstarter poll

November 15, 2011

 

The first function that I created was to verify that all ‘unique identifiers’ were valid.  To do so I simply compared my two lists.  By that I mean I used a for loop and compared the two lists.  The yellow highlighted sections are the variables that contain the lists of words/tokens from the text files, explained in the post from Monday.  The orange highlighted section, for those unfamiliar, is me running the function verifytoken() within the code.  
    

 

tokenlist = load_tokens()
usedtokenlist = load_usedtokens()

def verifytoken(tokenlist,usedtokenlist):
   for u in usedtokenlist:
       if u not in tokenlist:
           print "Token " + u + " is NOT valid."
       else:
           print "Token " + u + " is valid."

verifytoken(tokenlist,usedtokenlist)

 


My for loop starts be going through each token in the usedtokenlist, and then seeing if that token exists in the valid tokenlist.  If it’s not in the list, then my function prints that it’s NOT valid, otherwise it prints that it is valid.  Once that function runs I just have to visually check to see if any NOT’s show up.  Otherwise I’m good to go, of which I was.

My last function was to add up all the votes, and determine which name was the winner.  To do so I decided to collect the names together into a dictionary, where the key was the name and the value was the total amount of votes.  Here is my function:

 

pollresults = load_kickstarterpoll() 

def kickstarterresults(pollresults):
   finalresults = {}
   for k in pollresults:
       if k in finalresults:
           finalresults[k] += 1  
       else:
           finalresults[k] = 1
   return finalresults

print kickstarterresults(pollresults)

 


As above, the yellow highlighted section is the variable identifying the list of all names, thus designated pollresults.  The orange section is the activation and running of the function kickstarterresults().  In the beginning of my function I create a variable to house the dictionary results called finalresults.  The I use a for loop and if statement combination to process the names.  If the name is not already in the dictionary, then it is added as a key/value combination with the value equalling to 1.  Beyond that, if the key already exists in the dictionary, then I simply add one to the current value associated with that key.  Thus I collect and add up all name votes.  Once the process is complete I print my function results (as there weren’t a whole lot of names).  Then, as with the last set of results, I simply optically review it for the winner.  WHICH, the WINNER IS Betwixt!!

For anyone interested in participating in the Icon discussion forum, please visit and contribute.  I was thinking a worm-hole type idea, but we are open to ‘mostly’ anything.  Look forward to hearing from people.  

 

I guess I'm learning, a python script is easier than using formulas in a spreadsheet!

November 14, 2011
This past Friday I analyzed our voting data from the Kickstarter naming poll.  I used to interact with Excel a ton, but when I started looking at the results from the googledocs spreadsheet I realized that I could just as easily (if not more so), get the information I needed by creating a small python script.  So I cut and pasted the three things I needed into text (.txt) files and got to it.
 
There were five main things I needed to accomplish, before I could analyze my data.  First I needed to create some text files for my data.  I needed three text files.  The first one was a list of all the acceptable ‘unique-identifiers’.  These ‘unique-identifiers’ were a tool we used to verify that those who voted were eligible to do so.  They were automatically inputted into the form once the ‘voter’ reached the link provided.  Robey had created a list of such identifiers before and sent them out to all participating voters.  The next text file was a list of all the ‘unique-identifiers’ that our googledocs form received.  I simply copy-pasted them into a file and saved it as text.  The final text file was a list of all of the names voted for.  Each ‘voter’ was allowed to select more than one name, and so I was able to copy paste my column, but afterwards I had to go back through and set it up so that there was only one name per line, and that each line had no spaces at the beginning or end (so that none of the names were mistakenly counted).  
 
Once I had all of these text files complete, I started writing my python script.  Secondly I identified the text files as variables in my code.

tokens_FILENAME = "tokens.txt"
usedtokens_FILENAME = "usedtokens.txt"
kickstarterpoll_FILENAME = "kickstarterpoll.txt"
 
Next I borrowed a little function from my MIT Programming course to interpret the file and make it into usable data.  Each text file was interpreted the same way.  As an example, here is one of my functions:

def load_tokens():
   print "Loading token list from file..."
   # inFile: file
   inFile = open(tokens_FILENAME, 'r', 0)
   # wordlist: list of strings
   wordlist = []
   for line in inFile:
       wordlist.append(line.strip().lower())
   print "  ", len(wordlist), "words loaded."
   return wordlist
 
The function returns a list of valid tokens. Each token in the list is a string of lowercase letters.     These lists helped me to analyze my data.  Before I could use them, however, I had to run the functions so that I can get the results I need.  Thus I created new variables, that are simply representations of the results of the functions.

tokenlist = load_tokens()
usedtokenlist = load_usedtokens()
pollresults = load_kickstarterpoll()

The two tasks I needed to complete were to verify that all ‘unique identifiers’ (in my code I call them tokens) submitted in the googledocs form were valid ones that Robey sent out to the ‘voters’.  The last and most important task was to count the resultant names submitted and find the winning one.


Up Next Time: My final two functions and the winning name from our Kickstarter poll.

 

What are your limits, and where are they hiding?

November 10, 2011
I mentioned earlier this week that I was going to start reading and learning how to use the jQuery library.  Well, I haven’t had a chance to look at it since I mentioned it.  Instead I’ve been fairly busy with some ‘priority projects’ for my part-time translation job.  Albeit I’m learning lots of new vocabulary, so it’s good for my intellect in that aspect.  Of which that brings me to today’s question; just how much learning at one time is too much? 
 
How does a person truly know what their limits are, when it comes to learning?  Colleges assume that only a certain amount of courses is plausible, if the student wishes to receive good marks.  The assumptions of just how much a person is able to work during a day without going wonky have changed over time, but there seems to have always been some kind of expectation.  It seems to depend, partially, on the mental and physical strain of the job they are doing.  

But like all things the more practiced you are at a particular thing the easier it is to do.  Therefore, the more physically practiced you are the more you can work that job without becoming exhausted.  That would then, subsequently, also apply to mental strain.  The more you strain yourself mentally at particular tasks you soon, after much experience, learn it is less taxing.  

Thus people learn and move up the career ladder in whatever field they choose after a period of time.  But how do you know what that limit is?  How do you know when you’re pushing yourself to your own personal limit?  Is it the stress building up in your shoulders?  Beyond the need for sleep or food, when do you come to that wall where you can’t go any further?  Especially if that wall is always expanding the more comfortable you get with your current work?

I would like to think that I’m pushing myself as hard as I can, but I don’t think I am.  I am getting work done, and learning new things all the time.  Still, I think there is a trick to it.  Many people push themselves so much because they are, I think, looking for that wall.  They are trying to find their limit, but they don’t realize they’ve passed it until they crash.  What seems to happen for me is that I start to feel a pressure, either mentally or physically, and will often flirt right beside the wall for a length of time.  Then I crash and spend an extra day recovering.  

With translation what I’ve found works, is that if I need to work longer hours I make sure to take substantial break between my work to keep my wits sharp.  I work two hours, and then take at least an hour break.  My work is much more spread throughout the day, but my translation stays more accurate for a longer period of time.  I have to do less re-reading or double-checking of my work.  I also keep my stress levels down.  I know that for many people this kind of work habit is not a possibility.  But, in all honesty, who doesn’t still accomplish a slight similar process even in the work place?  Instead of taking an hour like myself, one fills it with chatter with co-workers or meetings, coffee breaks and trips to the restroom.  Everyone does it until you reach that level of flexibility where you can choose to do a more obvious hour break and back again for a couple more.

But have I actually reached the wall?  Have I learned what my limits are?  I think each day has it’s own set of limits, based on the amount of sleep, quality of food intake, and general emotional stress levels you are currently experiencing.  Learning that each day does not mean 10 hours of exemplary work, but it may mean one day you spend 12 hours and the next 4.  Learning to allow for alterations in exemplary work within yourself is the most effective way to learn where your wall is.  It’s not pushing yourself to meet the 10 hours each day, because then, more often than not, you crash.  Crashing causes damage and recovery time.  Prevent crashing and you’ll push yourself harder and cover more distance than you would have thought possible.       

 

The South + Fancy Coffee == Oregon - Rain

November 09, 2011

 

Often I get this startling homesickness for a place, that honestly, is not my home anymore.  It was for so long, and much of my family is still down there.  Pine Hill, Alabama or Avinger, Texas, both pull at my heart strings.  Small southern towns of 3000 and less, where you can almost walk anywhere you want in the local area.  Places where to actually go shopping you have to drive at least 10 to 20 minutes to get to an actual grocery store.  

Places where swimming and humidity were common occurrences.  Where life ran slow, and roads were red.  Where fireflies and sounds of bullfrogs wandered the night air.  A place where I could eat grits, hush puppies, and boiled peanuts in silence.  Where armadillos were not uncommon, but the cold northwestern rain forest was.

Where I could smoke a cigarette (if I smoked), on my front porch, and where the only fancy coffee really was the black coffee you made at home.  Sometimes life seems so overwhelmingly complicated, with all of the choices that are available.  Choices of what to do with your life, or choices of what to eat (all the different options), or choices of what to do in your free time.  Granted, I know that by having those freedoms so readily available I’m not fully realizing how much they really make a difference in my life.  

When I was in Florida last year, I learned how difficult it was to get a fancy coffee in the South.  It was partially annoying, being that I was in Orlando (aka big city) and I couldn’t find a latte unless I drove at least 5-7 minutes to the nearest Starbucks (the only fancy coffee shop around really).  Being a resident of Corvallis, Oregon, where I can walk 5 minutes and get a fancy coffee from a local shop, in three different directions from where I live, having that freedom makes me realize Corvallis satisfies a hunger that I can’t truly explain.  

Despite all I miss the humidity, the red earth, and the drenching rain.    

 

Links