Top.Mail.Ru
? ?

Nov. 15th, 2008

crop circle, pi, dot

Catch-Up Scraps

Was semi-offline for almost two weeks, and I've been too busy at work to make a substantive post but as the fires loom I wanted to share some things that I've been thinking & working on.

Halloween, or technically the day after, marked one year that I've been riding my recumbent to work. In that time I've crashed twice (one resulting in a pretty sweet scar), started a website for other combat cyclists (bumper stickers and t-shirts to follow), and gone through three playlists (thanks for the tunageImagemspinkie!). It's edifying to know that folks at work are surprised if they find out that I didn't ride on any given day, like my riding to work is part of their paradigm.

Wrote another program - this one to converts angles between degrees, microradians, and arcseconds. This program, once I incorporate symbols (ﹾ, μrad, arcsec) and make it an .exe program, will come in fairly handy at work. I have a little table from Excel but it's obviously not dynamic.

# ** begin file angle_converter **

#converts between arcseconds, degrees, and microradians
#2*pi radians = 360 degrees
#1 degree = 3600 arcseconds

#to-do list: display unicode; make the results appear in a table (somehow); make it .exe;

import math

def print_menu():
    print
    print "LIST OF OPTIONS (ENTER '0' TO SHOW THIS LIST)"
    print "1. Arcseconds to Degrees"
    print "2. Arcseconds to Microradians"
    print "3. Degrees to Arcseconds"
    print "4. Degrees to Microradians"
    print "5. Microradians to Arcseconds"
    print "6. Microradians to Degrees"
    print "7. Exit"

print_menu()
menu_choice=0
while menu_choice != 7:
    print
    menu_choice = input ("Select an option: ")
    if menu_choice == 1:                                               #Arcseconds to Degrees
        arcseconds_ = input ("Enter an angle in arcseconds: ")
        print arcseconds_, "arcseconds is equal to", round(arcseconds_/3600.0,6), "degrees."
    elif menu_choice == 2:                                            #Arcseconds to Microradians
        arcseconds_ = input ("Enter an angle in arcseconds: ")
        #arcsec2degrees2rad2microrad
        print arcseconds_, "arcseconds is equal to", round(math.radians(arcseconds_/3600.0)*1000000.0,6), "microradians."
    elif menu_choice == 3:                                            #Degrees to Arcseconds
        degrees_ = input ("Enter an angle in degrees: ")
        print degrees_, "degrees is equal to", round(degrees_*3600.0,6), "arcseconds."
    elif menu_choice == 4:                                            #Degrees to Microradians
        degrees_ = input ("Enter an angle in degrees: ")
        print degrees_, "degrees is equal to", round(math.radians(degrees_)*1000000.0,6), "microradians."
    elif menu_choice == 5:                                            #Microradians to Arcseconds
        microradians_ = input ("Enter an angle in microradians: ")
        #microrad2rad2deg2arcsec
        print microradians_, "microradians is equal to", round(math.degrees(microradians_/1000000.0)*3600.0,6), "arcseconds."       
    elif menu_choice == 6:                                            #Microradians to Degrees
        microradians_ = input ("Enter an angle in microradians: ")
        print microradians_, "microradians is equal to", round(math.degrees(microradians_/1000000.0),6), "degrees."
    elif menu_choice != 7:                                             #Exit
        print_menu()


I feel like I'm contributing more at work; last Thanksgiving my role changed from defining custom photonics systems to defining custom motion systems, and I finally feel like the pieces are starting to come together. It could be that our group has gotten a big bigger, giving me more resources, but i think it probably has more to do with my new meds - I'm not sleeping any better yet but my at-work focus is definitely on the rise.

Went to the courthouse yesterday to file one form and get a copy of another, and was reminded that it's not my responsibility to make sure that my ex-in-waiting is doing what she's supposed - at some point, in other words, some things stop being my problem. That is a lesson I've learned a few times over the last few years but I still struggle with it.

Bought a Moleskine journal the other day, on the recommendation of a friend. I felt lucky to snag a square grid version, and will use it - do use it - for my personal projects. I already have two journals running concurrently for my mental meandering, but not really for my projects. I don't feel like Hemingway yet, nor even Bohr, but maybe it's too soon to judge.

Ok, well, back to the BC-FL State game.

</lj>

Oct. 21st, 2008

enigma, computer

Phone Books In the Age Of Jet-Packs

Shortly after the obligatory "Hello World!" program in any high-level language comes the 'phone book' program. I have a smart phone for that. In this revisioning, a small (volatile) database is created that allows the user to add, delete, and view a table of web addresses with their associated username.

#Self-directed exercise to practice with dictionaries and keys.
#Create a non-permanent database of your account urls and usernames


banner = ['Top-Level Domain', 'Username']
url = {}

#Menu, user interface
def print_menu():
    print                                       #purely for aesthetics
    print "Press any number 6-9 to display this list"
    print "1. Print list of accounts"
    print "2. Add an account"
    print "3. Look up an account"
    print "4. Delete an account"
    print "5. Exit"

    
#Option 1 from the Menu. Don't sort the list yet, just get it running..
def print_accts():
    print
    print banner[0], '\t\t', banner[1]
    for var in url.keys():
        print var, '\t\t', url[var]

print_menu()
menu_choice = 0
while menu_choice != 5:
    print
    menu_choice = input("Select an option: ")   #taking in a number so don't need raw_input
    if menu_choice == 1:
        print_accts()
    elif menu_choice == 2:
        print "Add Top-Level URL and Username"
        addy = raw_input("URL: ")
        username = raw_input("Username: ")
        url[addy] = username                    #the KEY is the 'addy', the VALUE is the 'username'
    elif menu_choice == 3:
        print "Lookup Account Info"
        addy = raw_input("URL: ")
        if url.has_key(addy):                   #eg, if 'addy' is a valid key in the 'url' dictionary
            print "The username at", addy, "is [[", url[addy], " ]]"
        else:
            print addy, "was not found. Please check spelling or blink twice and try again."
    elif menu_choice == 4:
        print "Remove URL. Username is  auto-wiped."
        addy = raw_input("URL: ")
        if url.has_key(addy):
            del url[addy]
        else:
            print addy, "was not found. Please check spelling or make a sandwich and try again."
    elif menu_choice != 5:                   #this where the other numbers come into play (6-9)
        print_menu()


Oct. 18th, 2008

enigma, computer

Tough Decisions

I've been learning Python, slowly, and it's getting harder and harder to overcome obstacles in my coding. This is why I dropped the 'CS' emphasis from my degree.

My most recent assignment was to give a user three tries to guess the writer's name. No biggie in itself, but most sites don't allow me, the writer, to use a '.' so I go by dotplaid. Some folks know me as .plaid, though, and neither group of users should be punished, so I wanted to elegantly check for both .plaid and dotplaid - not so easy for my addled brain. In fact I gave up; I'll come back at some point when I have a better handle on what I'm doing.

Exercise 10 code:
#Write a program that has a user guess your name, but they only get 3 chances to do so until the program quits.

guess_attempt = 0
guess = "text"

while guess_attempt < 3 and not guess == ".plaid":
    guess = raw_input ("Enter name here: ")
    guess_attempt = guess_attempt + 1

if guess_attempt <= 2 or guess == ".plaid":
    print "Hi, ", guess
else:
    print "Away!"

I had lines while guess_attempt < 3 and not guess == (".plaid" or "dotplaid"): and if guess_attempt <= 2 or guess == (".plaid" or "dotplaid):, but only .plaid would trigger correctly, not the second or term. Grrrr

Image