Feeds:
Posts
Comments

The repo is private for the moment while I get some things sorted, but in the meantime you can submit bug reports here.

Advertisements

I like the Ribbon. I’ve liked it since Office 2007 and I still find it useful. A lot of third-party apps have started using a similar interface concept. It works in Office, but it seems like it doesn’t work as well elsewhere. Foxit Reader recently added a new Ribbon-like interface. It’s easy enough to change, though:

Just go to File->Change Toolbar Mode, If you want to switch it back, go to VIew->UI Options->Change Toolbar Mode.

You can also still hide the ad at the top, but the location to do it has changed. Now you have to uncheck the “Show Advertisement” box in File (or Edit if the Ribbon is turned off)->Preferences->General.

[Sic] semper tyrannis

The [sic] that you sometimes see in quotes means that it was an error by the original author, and not one introduced by the quoter. But it doesn’t stand for anything. It’s not an acronym. It’s actually a Latin word meaning “thus”.

And the Virginia state motto is “Sic semper tyrannis,” or “Thus always to tyrants.”

Just a cool connection there.

I’m a huge nerd, so a lot of my time online is spent browsing technology news and learning about computer stuff. These are some of the sites I use for that.

News

Programming

General

YouTube channels

Subreddits on Reddit (multireddit for all of them)

  • Single quotes and double quotes are the same
  • How to check if strings are anagrams of each other (I’m really proud of the way I did this)
  • Non-recursive factorials. I cheated a tad, but I almost had what was suggested. I fixed it on my own, though.
  • How to convert decimal to binary (not in Python, by hand, but it was in a video series about Python)
  • How to use Wing IDE to view a watch window for Python
  • What <> means, and that it’s no longer supported

I like game shows and trivia questions. I like Python and computers. I thought it would be fun to try to merge the two. I found a list of Family Feud questions from the SNES game of the same name on GameFAQs. I copied it out to a file and tried to parse it through Python so it would give me a random question and its answers.

I started in January but just managed to get it working yesterday. I need to redo it into a dictionary or something with key-value pairs (The question string, and a set of answers). There are also some cases where it doesn’t work.

It’s heavily commented because I hate doing something like this and coming back to it later with no idea how it works.

This might seem simple (and it is) but it’s a big step for me because I figured it out of my own volition and some Googling. I usually just search until I find the code I want, but this was different because I thought it through until I figured out the pieces I needed and looked up those pieces.

import random
f = open("C:\\path\\to\\questions.txt" , 'rU')
questions = []
answers = []
ansq = []
#most of this could be changed. I don't need that answers list I don't think
for line in f:
    if ".." not in line: #if it's a question (i.e. without leader lines to the point amount, thus not an answer)
        if line == "\n":
            pass
        else:
            questions.append(line)
    else: #if it's not a question, then it's an answer (which is a wrong assumption I need to fix)
        if line == "\n":
            pass
        else:
            answers.append(line) #so add it to the answers list instead

#if question matches line
#look for the answers below it until the next question
#    while line not in questions
#    print line
            
qtoask = random.choice(questions) #pick a random question from the questions list

f.seek(0) # go back to beginning of file
for line in f:
    if line == qtoask: #rescan it; if the line matches the random question
        line = f.next() #go to the next line
        #ansq.append(line)
        while ".." in line:#and find all the responses to that question (they all have dotted leader lines)
            #This if condition will never be true if it's in this while block. Duh.
            if line == "\n": #if the line is a newline (Enter)
                pass #skip it
            else:
                ansq.append(line) #otherwise, add it to the list of answers to the question
                line = f.next() #go to the next line and do it again

print qtoask
for a in ansq: #Beautify. Just print the list of answers so it's easy to read
    print a + "\n"
f.close()

#TODO: refactor into lists (or dictionaries?)

Things I’ve learned from this so far:

  • You have to manually reset the file (via seek())
  • It’s easier to exclude than include in order to get a specific set of data
  • The next() function
  • I was really happy to find out about random.choice()

I’m not a math person, but I’ve been wanting to redo an old project for a little while now. I don’t understand stuff like vectors and deltas. However, I found these two links yesterday and I think they’ll really help me.

If you’re wondering, I want to remake my Pong clone so the ball bounces at angles other than 90 degrees. I’d also like to fix the collision detection (which the second link handles).