better living through python

An adventure in programming and recovery.

CSP Game Schedule Converter

January 23, 2012
My brain feels like mush.  Real mush.  Coffee doesn’t seem to be making a difference, or candy, or anything.  Normally that quick sugar rush really does the trick..but not today.
 
All weekend I was working on a project.  This project is what Google Chrome documentation calls a page action.  As with many programming projects start, this one started with an annoyance.  I hate...really hate, entering in all my soccer team game times on my Gmail calendar.  
 
You see, the games are 50 minutes long, so they don’t fill up the entire hour, and they don’t start on the hour.  This means I’m interacting with the specifics interface for each game I enter.  I’m also on three different teams, so putting in all the necessary information (team name, if we’re home or away, the time and so forth), is a real drag.  In total I enter in 24 games ever 8 weeks.  That means 168 entries a year, just for soccer.  I don’t mind entering in odd coffee dates or other such things, but when the schedule I’m following is already online, why isn’t there something that will allow me simply to upload the information already?

There isn’t, and that is exactly where I come in.  After a long time of complaining and being slightly late to games, and after I’d finally learned enough javascript to take it up as a personal project I made the plunge.  I decided to program my way out of this annoying little problem.

Robey and I try, once per month, to allow ourselves a weekend to devote to a new project and new learning experiences.  This month I decided to make a page action.  This page action collects the schedule data for a team, once you’re on the team’s page.  Then it alters the html slightly to create a new button.  Here is the original tool box for the team page:
 
Here is the update one, once my page action is uploaded to your version of Chrome.
The basic idea was to use the current framework to my benefit.  Use the divs and classes they had already created to create a new button.  The only difference is that once you click the ‘Download Calendar’ button a pop-up box shows up.  Here it is:
As you can see, this popup box will use the team page the person is currently on, collect the schedule listed there, and create either a csv or ics file.  Next you save the file somewhere on your computer.  Then file (both formats) can be imported into iCalendar, Microsoft Outlook or Gmail.  Importing will add all games to your calendar, with additional information as shown in the example below:
Thus I’ve made my life, and hopefully the lives of my fellow soccer friends, much less annoying.  You know, this really wasn’t that difficult.  I think if I had been able to get more time in it over the weekend I could have finished it Sunday.  Except I had soccer games to go to.  

Even better is that now if the local Indoor Sports Park decides to change their game times for any reason, it won’t mess with me anymore.  I won’t miss my games or be late because this page action will already have entered them in correctly.  In case you’re a fellow soccer friend, or are simply interested in my tool you can find it here on the Chrome web store.          

  

 

Icon ideas for our Kickstarter, Betwixt!

January 19, 2012

 

Today I was working a bunch on creating an Icon for our Kickstarter Project, Betwixt.  We’re starting to get to that point where a finalized Icon is a necessity so we can start sending out all the goodies we promised people who backed our project.  I’m in charge of creating the image.
 
We’ve chatted with some of our backers about what kind of image they’re looking for, but I honestly have to say that some days I feel a little at a loss for icon imagery ideas.  It’s difficult to know what people will always recognize, so I’m creating as many ideas as I can.  For those who are interested/pay attention to my blog, let me know what you think.

A quick reminder: our Kickstarter project is a text editor that is accessible via the web.  Basically, this is an icon that will exist on your browser bar in Chrome (for many), so it needs to be easily distinguishable in smaller form.  The colors are also arbitrary at this point.  I’m using the same scheme for simplicity sake.  If you have suggestions on color combinations please also let us know.

 



  

 

Learning how to create code that 'pauses' my game

January 18, 2012

 

Identifying that I’ve pressed the space bar is only the beginning.  Now I have to create a function that will determine what needs to be done when the space bar is pressed.  As mentioned last time, making pause only apply to the appropriate aspects of the code is the more difficult part.  Robey indicated that it would be helpful if I created a separate function to pause the game, so that it was clean cut when pause needed to happen.  Suffice it to say, Robey helps me a bunch.

After much work (and frustration) this morning, I realized that my main problem was not understanding what the variable elapsedtime collects.  This variable monitors, as the name indicates, the current elapsed time of the game between each time the tick() function runs.  What I had thought, was that elapsedtime was the total time the game had been played.  Due to this misunderstanding, I kept trying to make adjustments to that variable, not realizing that the actual value of that number never increased (as I had presumed).  Therefore it never made any difference in my attempts to pause the game.    

Thus I changed tactics.  What I ended up doing was creating a new variable called gameisrunning.  This variable simply holds two values, true and false.  The value is changed based on pressing the spacebar.  This is determined within my keypress() jQuery function.  If you press the spacebar, the value changes to true.  If you press it again it changes back to false.

In my tick() function, I created an if block that checks the current value of gameisrunning.  True to it’s name if gameisrunning == true, the functions shipopacity(), shipmovement(), problemtype(), kersplaty(), particlerotation(), and newproblemy() are processed.  If gameisrunning == false then none of the normal game functions will be processed, and thus the game is for all intents and purposes ‘paused’.  

As mentioned previously, the variable gameisrunning is changed in my $(window).keypress () function(remember that a dollar sign ‘$’ in front of functions like this means it is a jQuery function).  Here is the function:

$(window).keypress(function(e) {

   if(e.keyCode == 32) {

     if(!gameisrunning){

$("#paused").css({'display':'none'});

       $("#startgame").css({'display':'none'});

$("#problem1").css({'display':'block'});

$("#problem2").css({'display':'block'});

$("#problem3").css({'display':'block'});

gameisrunning = true;

     }else {

       gameisrunning = false;

$("#begin").css({'display':'none'});

$("#problem1").css({'display':'none'});

$("#problem2").css({'display':'none'});

$("#problem3").css({'display':'none'})

$("#paused").css({'display':'block'});

     }

   }

 });

     

To use the keypress function from jQuery, you need to know the keyCode identifier of the key you want (in my case spacebar = 32).  Then I create an if block that asks if my variable gameisrunning is false (in many programming languages !gameisrunning is the same thing as stating gameisrunning is false).  If it’s false and the spacebar has just been pressed, then my piece of html div #paused doesn’t show up, my #startgame div is also not displayed, and the problems can be displayed.  If gameisrunning is true and the spacebar is pressed, then the #paused div is displayed, all the functions mentioned above stop processing, and my problems are not visible.  It also resets gameisrunning to false.  

Specific problems I faced:  I seem to continue to have difficulties in coming up with using a variable with true/false to help process code.  There have been several times now when that has been the most effective way to solve the problem, but when thinking of solutions it isn’t coming to mind.  

I also feel that I better understand what the data is that some of my variables are collecting.  I can tell that this may be a problem of mine, and something I will have to stay aware of in the future.  

What helped me: I took the time to reorganize my code.  My tick() function had been huge, but I simplified it down to being a function that simply ran a bunch of smaller functions.  This helped hugely in being able to understand what was happening and when.  Imagine that, compartmentalizing your subject matter helps you to more easily identify where the problem is.  Who knew?!?  

 

Old wounds revisited

January 17, 2012

 

I saw my old boss for the first time this past Sunday.  She was driving down the road in the opposite direction.  I was heading towards a soccer game.  She had a smirk on her face.  I felt...hardly anything.  

It was so surprising how little it affected me.  After a little bit I had my momentary feelings of anger and frustration.  Mainly feelings of resentment.  Knowing how much I want her to see me succeed, and realize how wrong she was about it, about me.  But what does this really mean?

That somewhere deep inside me I still think that they might be partially right, and it scares me.  Somewhere I still feel like I wasn’t doing enough, or trying hard enough.  I feel that everyday.  How can I ever expect to get over that feeling, unless I’m able to accept myself?

I don’t think I’m a slacker.  I don’t think I’m a poor worker, but I know I have fairly high expectations of myself.  If I don’t meet some of those expectations I chide myself.  I can’t accept the mistakes.  Because I can’t accept my mistakes from my time at my last job, because I know I have the capability to have noticed them.  I wasn’t pushing myself hard enough.  So, in the darkest places of my mind, they had a right to blame me.

How do you know when your work is good enough?  Where is the cut off point?  Where do you know that it wasn’t you, and it had nothing to do with your work ethic, it had to do with someone else not pulling their weight?  Especially if they are doing their best to cover their own....backside?

The one thing I could think about when seeing my former boss was that I want her to know she was wrong about me.  That I’m intelligent and hard working and that all of her concerns and criticisms were unjust.  I wanted to prove her wrong.  What would that do?  Why do I care what her opinion is of me anymore?  I still let her have power over me.  I want justice for the wrongful way I feel I was treated.  I want an apology.  I want recognition from them.  

How do you take the step back from your dark places?  How do you forgive when you still anger?  How do you let go?  I’m still working on that one.  Is time and simply forgetfulness the answer to letting go?  Is it required to forgive the person?  What if they were right?  They undoubtedly think so, so then, if they will always feel they are right how do I go on when I want them to admit their fault?  My emotions want validation, but no one else went through what I went through with me.  

The only validation I can receive is from myself, and I don’t seem to trust myself enough to realize I couldn’t have done anything else.  I must forgive myself, and accept myself for all my faults.  I must learn to be okay with days when I lack focus, or days when things are harder than normal.  They occur for everyone.  Once I can accept and I can fully recognize that my emotions were valid, and I will no longer care.  

But humans, we are an odd bunch.  Many of us need validation from those around us.  We need others.  We are not creatures that can easily live on our own.  We need company, either large or small, we need the approval of others.  In the end, it’s really that I need these things.  If I need these things (validation, acceptance, approval, company) from others, but I cannot truly trust my own self interpretations, how can I expect them to feel the same way about me?  I cannot trust what comes out of my mouth, so how should I expect them to?  

Once I accept and trust myself I will find peace.  I must not expect others to provide it for me.  

 

My life TODO list

January 16, 2012

 

I thought about this quite a bit, whether or not it would be something interesting for others, if it’s even appropriate to share.  Well, I think making others aware of what you want out of life can help them put theirs in perspective.  It also sometimes allows more easily for personal forgiveness, or the realization that perhaps what you want in life really isn’t that crazy after all.

What I’ve been talking about is my current Life TODO list (Not a fan of the term ‘Bucket List’, as I feel that kind of list isn’t subject to change if need be).  I thought I might share it with you all.  I’ve been writing these since I was in 3rd or 4th grade.  Maybe one day I’ll have the...’guts’....to share my old ones.

Without further ado:
  1. Ride an Ostrich
  2. Learn how to program in python fluently
  3. Live in Germany for at least another six months
  4. Improve my German dramatically so I can read almost anything without a dictionary
  5. Learn Spanish enough to have decent conversations   
  6. Hike the Oregon Portion of the Pacific Crest Trail
  7. Own Chickens
  8. Make a Quilt
  9. Visit Prague
  10. Live on a sunny beach for a good period of time (where I can go swimming)
  11. Get into ridiculous shape, if only for a couple of months
  12. Run a marathon (or at least a half-marathon).

 

The Wall

January 13, 2012

 

Most of you know what this is like.  When you come upon a problem, could be a really simple problem, but for some reason it seems tougher than normal.  So you put off climbing over this wall, you put off digging your hands in, and plan to do it the next day.  But what happens if all your problems have become a wall?  What if your problems were big to begin with, but you get to a point with each one, that seems fairly complicated and insurmountable, that you don’t know where to go or where to start?

More than that, what happens when it’s not actually happening to you, but to someone else you care about?  What do you do then.  How do you help them, but not be overbearing?  I know what I would do if it was happening to me.  Take it bit by bit, do small bits I know how to do, slowly getting it all together.  

But telling someone that, and doing it yourself are different.  You make suggestions all you want to this other person, but how much is that really going to help them?  Especially when you’ve had the conversation multiple times.  Each conversation then is a reminder to the other person, of their wall.  By talking about it, in the end, you’ve simply stressed them out even more.  

Having patience is one of the hardest things for me to do.  It’s something I always struggle with.  When it comes to me learning to have patience with those I care about, I find life very difficult.  Not only is my concern eating my up, but I’m constantly striving to be more patient.  But when you are in a situation such as this, patience is one of the few correct choices.  Support and patience.  Difficult, stressful, but more rewarding than anything else you could be doing for them.      

 

More work on Science Fiction Tower Power

January 12, 2012

 

Last night I started working on my game again.  It felt good to start looking at the code and figuring out what I was doing where.  Even better, is that I started to organize my code, something I’ve been meaning to do for a while.  I am still working on my ‘using space bar as a pause button’, but until I can more easily read through my code and know what’s happening I think that any further progress is going to be difficult.

At least, for me.  I have a good idea of most of what’s in my js file (javascript file), but sometimes recognizing what interacts with what appropriately enough to know how to alter things.  Well, yes, that is the difficult part.  Robey discussed a normal practice, that if you can’t see an entire function on your screen, then it’s too big.  That means you need to subdivide, and separate out the parts into smaller functions.  That had happened with my tick() function.  

In case you’ve forgotten, my tick() function is the one that runs most of the aspects of the game.  it interprets time as it progresses throughout the game, and makes sure the the appropriate checks occur when they should.  Basically, it’s the type of function that can normally get really big anyways.  It was high time I went and chopped it up.  

Once I had reorganized my code I had a much better idea of what was going on.  Unfortunately it’s been long enough that parts of it are still a mystery, so I’m going to need to simply go back over everything.  Like with any organization, making sure that similar things are in the same place makes it easier overall.  

One of the things I’ve run into now, though, is how much more I want to know.  How much more I want to understand.  Problem is, ya gotta eat, and right now I’m paying off loans and credit cards with the money I’m earning from translation, so translation is always...first priority.

I miss the day when I was able to focus purely on FlamingLunchbox.  Oddly enough, I didn’t actually make my first game until after I started my translation job.  Did I need that stability, or more like, did I need the safety of a job that was sure to pay before I could feel able to devote time elsewhere?  It would be sad to say if that’s the case.  For some reason it makes me feel not quite devoted enough.  But I guess, that’s kinda the way it goes until you feel like you can actually do something without asking a bazillion questions.  You need a level of confidence in what you’re doing, before you can start to feel able to do it on your own.   

 

Advice from a high school Choir director

January 11, 2012

 

I took a walk yesterday.  I walked from our house to a local movie theater.  On my walk I was reminded of a phrase my high school choir director once told our choir, “If you can’t spend 10 minutes by yourself without going crazy, then you’re not okay.”

I’ve thought a lot about that phrase, and about what it means ever since.  My impression, is that if you can’t spend at least ten minutes alone with your thoughts, then you are unhappy with something in your life.  You’re so unhappy, that you should really do something about it.  

When I revisited where I was last year, at this time, I realized just how much has changed.  I’m....happy.  I’m truly happy with where my life is going right now.  Sure, learning how to do all of this is scary, and I have no idea where this will have me end up.  But, I feel like I actually have control of where I am.  I took a 45 minute walk with only my iPod to keep me company, and all I was, was happy.  

 

Turning 29 doesn't actually mean anything

January 10, 2012

 

It's quite satisfying that even though I'm actually on a personal vacation, one of the things I want to do is write. Would that be considered a sign of a lifestyle that truly works for you? I think so. I've been thinking a fair amount about my life over the past couple of days, as I recently turned 29. What I want out of life, and other serious reflections. 29 isn't a marker per se, but it is a stark reminder that I'm only a year from 30.

And that's where my mind wanders when I think about it. I had a couple of things I wanted to get done by the time I was 30. Now, as my time grows thin, I wonder if they will actually get done. The awesome part about being with someone who's awesome too, is that they want to help you reach those goals (if after reflection you still really want to do them).

What was one of my goals? I've always wanted to hike the entire Appalachian Trail. However, as I've gotten older I realized the reasoning behind the hoped endeavor. I wanted to do something that would show what I was capable of. Definitely part of the whole thing was for selfish reasons, I wanted something I could show off with. Not the best of reasons, but it would definitely have been a status item in my book. But, the main reason? I have always felt that such an experience would be an important experience to have in my life. So much time away from society, so much time away from the easy amenities. A chance to feel closer to nature, to realize existence as a wanderer. To have to endure the rain, wind and cold without an easy getaway. I want to push myself, and this was a test I felt I should take.

This kind of, actually, makes me think that it might be time to make another one of those life 'TODO' lists. Help me get things written down. Life priorities, they make things exciting.  

 

Day at the Beach

January 09, 2012

 

First off, my apologies for this past month. My entries have been all over the place due to holiday and family stuffs, as is natural, and I've been neglecting my duties as a blogger. Secondly, this is my first officially written post from 2012. I am writing this on my birthday getaway with Robey in Rockaway , Oregon. We rented this smaller Condo for a couple of days during midweek (because we can being self employed), and are currently enjoying coffee while staring at the ocean on a Tuesday morning in January.
So far 2012 is going splendidly. A relaxing birthday where I spent the day hanging out with friends and family, and the next day where Robey and I packed up and ventured out to our little getaway. My current sleeping pattern since the New Year leaves much to be desired, but I have no fear that I'll be able to jump on board my resolution of starting work at 8am once I return to work in rainy Corvallis on Thursday.

Is there not something incredibly inspiring about the ocean? The strength of the waves and the power they exude when crashing against the sand, it almost makes me feel like I did when watching the end of 'Return of the King' in theater for the first time. That's such a great movie...*sniff*.

 

Links