#
# Hello World Get Opt for Python
#
#
import getopt
import sys
import getpass
#Describe usage
def usage():
print "-h, --help\n -v, --verbose\n -u, --username\n -p, --password\n"
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "h:u:pv", ["help", "username=", "password"])
except getopt.GetoptError, err:
#print help information and exit:
print str(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
username = None
password = None
verbose = False
for o, a in opts:
if o == "-v":
verbose = True
elif o in ("-h", "--help"):
usage()
sys.exit()
elif o in ("-u", "--username"):
username = a
print "username: " + username
elif o in ("-p", "--password"):
password = getpass.getpass("Enter password: ")
print "password: " + password
else:
assert False, "unhandled option"
if __name__ == "__main__":
main()
Tuesday, March 02, 2010
March Madness Challenge - Day 2
Ok. Time was a bit of challenge today. I wanted to learn more about getopt, and figure out how it differed from optparse. I definitely learned about some of those differences. So tonights program uses getpass to collect a username, password combination. This is pretty unoriginal, but it did help me learn about getopt. I would like to try variation on determining mandatory fields, optional fields, and fields in combination.
Monday, March 01, 2010
March Madness Challenge - Day 1
Several of my partners in craziness at FUBAR Labs, the local New Jersey Hackerpsace. Have taken on March Madness. Write a program a day for a month. Well I'm jumping in on day one with a piece of code that solves one of PIAs I experience when trying to get the emails off of Google Calendar Events. Wish there was a feature that allowed you to make a group based off of an event. Anyway, the following code is how to get a list of guests from a Google Calendar event. Pop the list into an alert box, then cut and paste for your own use.
Another way to run this would be as a Greasemonkey script. Hey, that might be a good project for tomorrow.
I did discover the source code for Google Hosted applications is not quite the same as it's standard gmail offerings. To run this in a hosted environment you would need to use the following to select the guests:
---
/** Get list of emails address from the guests invited to a Google event
*/
(function () {
var guests, emails;
//Handily there is class associated to each guest
guests = document.getElementsByClassName("guest");
emails = "";
//iterate the guests
for (var i in guests)
{
if (guests.hasOwnProperty(i))
{
//each guest name/email is the first child textContent of guest element
emails = emails + guests[i].childNodes[0].textContent + ",\n";
}
}
alert(emails);
})();
---In order to run this you need to can run it in the Firebug console. Testing this, you need to create a Google Calendar Event add a few people to it. Find an old event with people in the guest list.Another way to run this would be as a Greasemonkey script. Hey, that might be a good project for tomorrow.
I did discover the source code for Google Hosted applications is not quite the same as it's standard gmail offerings. To run this in a hosted environment you would need to use the following to select the guests:
(function () {//Final Note: Not Happy with editor at Blogger.com
var guests, emails, guest, tmp;
guests = document.getElementsByClassName("ep-gl-guest");
emails = "";
guest = "";
tmp = "";
for ( var i in guests)
{
if (guests.hasOwnProperty(i))
{
guest = guests[i].id;
tmp = guest.split(":i");
emails = emails + tmp[1] + ",\n";
}
}
alert(emails);
})();
Sunday, December 20, 2009
Bug in the fire
Bug in the fire
Originally uploaded by flirianders.
Played around with a glue gun, and an led at the Fubarlabs Hackathon. Ended up with atmega168 powered LED that lit up chilled hot glue, and formed a fire breathing bug.
Monday, June 04, 2007
Iron Man Kills Dr. Lucky's dog
Iron Man Kills Dr. Lucky's dog
Originally uploaded by flirianders.
Kill Dr. Lucky is a great Cheapass game. We scavenged both the Marvel Monopoly and the classic Monopoly pieces for this game. The variation we played was Kill Dr. Lucky and his dog. I as Iron man finally killed Dr. Lucky's dog. I was so satisfied with the moment, it had to have a photo. I no longer remember the final outcome, but that pesky dog was finally eliminated.
Saturday, April 14, 2007
Thoughts on Django
I've just started really looking into Django and so far I've been impressed. I've bee pleasantly surprised that things were easier than I thought and nicely organized. I really like the Models, Templates, and Admin interface. The model concept provides a nice database independent data structure. For simple test projects it's really simple to use SQLite. The key feature I like about the Templates is the ability to create base templates and extend them for specific task. Allows for efficient coding of pages. The automatically generated Admin interface has received a lot of deserved attention it's a great concept.
Areas that I'm looking into more. If the Admin interface is based off a template structure can it be extended for basic user/member of the site. So a regular user could change their profile without me having to duplicate the coding that would be auto generated in the Admin interface.
Also, as a new user it looks like I need to build a base set of templates that can be used and reused through out all my Django projects. Once that basic set is created I could stamp out a lot of variations on a theme for projects I'd like to build in django. It would be nice to have an application theme that could be modded. It might make Django more cookie cutter but it would awesome to not have test projects look junky while the admin interface is clean and usable.
As for test projects I've been enamored with creating a list of lists project. I have simple prototype that was fun. Now I want to revise it and make it have user registration, RSS, atom, and list sharing. As this goes I'd like to examine how the Model resolves recursion. Lists of lists of lists, etc.
Another project that I've been terribly interested in is using an interpreted environment to dynamically build applications and interact with applications from interpreted shell type environment.
Figured I get these thoughts written down before I forgot.
Areas that I'm looking into more. If the Admin interface is based off a template structure can it be extended for basic user/member of the site. So a regular user could change their profile without me having to duplicate the coding that would be auto generated in the Admin interface.
Also, as a new user it looks like I need to build a base set of templates that can be used and reused through out all my Django projects. Once that basic set is created I could stamp out a lot of variations on a theme for projects I'd like to build in django. It would be nice to have an application theme that could be modded. It might make Django more cookie cutter but it would awesome to not have test projects look junky while the admin interface is clean and usable.
As for test projects I've been enamored with creating a list of lists project. I have simple prototype that was fun. Now I want to revise it and make it have user registration, RSS, atom, and list sharing. As this goes I'd like to examine how the Model resolves recursion. Lists of lists of lists, etc.
Another project that I've been terribly interested in is using an interpreted environment to dynamically build applications and interact with applications from interpreted shell type environment.
Figured I get these thoughts written down before I forgot.
Friday, February 09, 2007
Thoughts for a Documentary Movie Series
When I was I kid I loved TV. Once when my parents decided to limit access, I argued that it was an important learning tool. We learned about relationships, technology, what to do in a disaster, what was happening in the world, and how to tell time by the plot. I believed I put together a pretty compelling argument. However, that stiil was the end of the all night Friday night TV. I looked at TV as the source of knowledge about the world I lived in. Looking at TV, Movies, and fiction as documentary and learning is a common strategic approach to understanding the world. The series I'm envisioning would take the documentary which is supposed to be a representation of the real, show reality is shaped by some very familiar dramatic arcs and emotional themes. Documentaries like a photograph show more context than the main subject. Documentaries tell a story that pulls from a specific moment the recordings, images, documents, people, and film, that can be found that are not created with the POV of the now. These objects, however, are wedged into the frame of documentary. The documentary and the objects of the past locked in a battle for context.
The Mechaton Lego Madness
Getting the Mechs to the field battle is a difficult, but important task. I had assembled my bricks into a mighty prescribed army according to the manuals provide in the boxes they came in, but as the battle approached, and I started customizing the army they have devolved back into a pile of bricks no longer contained in neat ready to assemble little containers. They are now contained in the one plastic box that forms the miasma of creation, which I will call "The Sea of Corruption," for all freshly hatched lego Mecha. Much like the "God Warriors" from Nausicaa, they will rise, and unleash destruction upon the world. But not to soon. I don't want any of them to melt.
Subscribe to:
Posts (Atom)