Author: Sean
Programming Party
Real Source Control
Python: Lambda Expression Using a Dictionary
Quick hit for self future reference as usual, so I don’t care what you think:
filter(lambda (key, value): key == "someValue", directories.iteritems())
BAM!
CruiseControl.Net and CVS: Multiple Modules
Something I ran into is trying to check multiple modules for changes since the project I am trying to “modernize” is spread across what cvs calls modules. Really all they are is projects separated in the same trunk, but whatever. The point is I didn’t want to have to check the root directory where all projects are housed in order to see if just 5 have changed. Turns out it’s pretty easy. Just a disclaimer though: I’m still learning Cruise Control from scratch which means there might be a better way. This one however is simple and works… just like me. Well at least he simple part.
<sourcecontrol type="multi"> <sourceControls> <cvs> <executable>C:\Program Files (x86)\cvsnt\cvs.exe</executable> <cvsroot>yourCvsRoot> <module>location/of/theModule</module> </cvs> <cvs> <executable>C:\Program Files (x86)\cvsnt\cvs.exe</executable> <cvsroot>yourCvsRoot</cvsroot> <module>location/of/theSecondModule</module> </cvs> <cvs> <executable>C:\Program Files (x86)\cvsnt\cvs.exe</executable> <cvsroot>yourCvsRoot</cvsroot> <module>location/of/theThirdModule</module> </cvs> <cvs> <executable>C:\Program Files (x86)\cvsnt\cvs.exe</executable> <cvsroot>yourCvsRoot</cvsroot> <module>location/of/theFourthModule</module> </cvs> </sourceControls> </sourcecontrol>
The secret is the “multi” key word in the sourcecontrol tag and then adding the many cvs tags with the correct values.
Embrace the Unknown
As programmers its no secret that we like comfort. Well at least most of us. I mean every so often you’ll run into the uncanny ADD-man. You know the guy that is so in need of finding the next thing to jump to you’re pretty convinced he has a deep rooted issue involving being moved around from city to city because of a parent’s career… or paint chips.
For the most part though, we do like a certain comfort zone, and fuck if someone will convince us to get out of the comfort. And why would we? I mean it’s something we know. Something we understand. And isn’t life easier when there’s understanding?
I ran into this a couple jobs ago (I’m a job whore) when I asked for two monitors. Now this idea was something completely foreign and oddly scary to the people there. I mean, alt-tab is just fine, amirite? Wasn’t soon after getting the second one I was being looked at like some kind of child molester.
All I can say is: Don’t knock it until you try it. I meant two monitors, not child molestation. Well at some point the old light bulb went up on someone (Which makes me wonder what turned on before there were lights).
That person dared to start using two monitors. Next thing you know, there was a rash wave of double monitor usage. The world had changed forever. There were whispers of possibly having three monitors.
Side thought: I wonder if this is how the double razor to triple razor to n razor thing started. One guy was all like, “Hey guys, what if we had two razors on a shaver.” and then promptly speared for such thoughts that most likely were from satan. That was until some boss guy who was too high up to spear uttered the same words. Then everyone just went bat f–king crazy and started just throwing on arbitrary numbers out like some kind of reverse auction. And thus the razor wars began.
Anyways, back to the monitor thing. The moral of the story is that you can’t know what you can dare to dream if you have no concept of what’s out there.
Ok I lied sort of. Usually people use the line “The moral of the story” to end a thing like this, but I actually am being all sneaky and I tricked you into something bigger: Programming languages.
I have a confession. Well I have two, but one has to do with a having a song by Miley Cyrus… ok multiple songs… OK EVERY F–KING ALBUM… but that’s not important. The important part is that I’ve been a hardcore Microsoft guy for all 10 or so years of programming. I did not stray at all really. At least not much…
And why not? Microsoft has done a good job keeping the carrot in front of my face.
So why would I want to go anywhere else? I mean, I’m diverse. I use javascript. Besides, I have everything I need just given to me. Read that again. Actually I’ll type it again then just read it: I have everything I need just given to me. There are so many things that .net technologies do for me I really don’t have to do a whole lot. Or know a whole lot. Most lower level language ideas are just completely paved over with easy to use classes and controls. And that’s the problem.
I’ve been on a quest in the last year or two to really push myself to have a much better understanding of important programming concepts… that Microsoft has been so kind to hide from me as to not worry my pretty little face.
And maybe you are ok with that. Maybe you like to just take a pay check or just produce mass quantities of semi working code. Nothing supremely wrong with that. Just realize your career at some point will flat line.
But I say screw that. I need more and damnit I’m going to get out of my comfort level. I will brave the unknown (actually I already have with java and python) and in the long run I’ll be much better off. Why? Because not only do I diversify my languages, I also am privy to new and weird concepts that I would never see if it weren’t for venturing into new languages. Not only that, but I’ve found that some of the concepts and features just being added to C# have been around for a long time in other languages. So why wait for them to mature when you can use them now?
No really, I’m asking that. Give me a good answer…
jQuery: Find a Form Action Using Jquery
This is pretty useful for people trying to pass in a generated action to a javascript file. Eh?
SKIP IF YOU DON’T CARE ABOUT A REASON FOR USING THIS:
Say you are using the jQuery post method to send things back to the server but all the code for that is in a seperate javascript file. Well you can’t really do this:
jQuery.ajax({ type:'POST', url: <%= someMethodForCreatingAUrl('controller', 'action') %>, dataType:'json', data:{ email: user.userName, password: user.password }, success: function(result){ onSuccess(result); }, error:function (xhr, ajaxOptions, thrownError){ alert(xhr.status); } });
if that is in the javascript file.
What you can do is this on the html file:
<form id="formCreateUser" name="formCreateUser" method="post" action="${someMethodForCreatingAUrl('controller', 'action')}">
And in the javascript file:
ANSWER:
var formAction = jQuery(ELEMENT_LOGIN_FORM).attr('action');
And there you go. You have the action.
Python / Pylons… Setting the CSS Class on a webhelpers.html.tags Select List
Real quick one, once again just for my future searching concerns, just wanted to point out how to set the css class on a select list when using the webhelpers.html.tags.select helper. Won’t get into how I hate html helper classes, but in this case it’s for something so simple AND it makes it easier to hook into a precreated list. Anyways, it’s me being lazy and breaking my rules.
With that being said, took me a bit to find out how to set the css class on the created select list:
${h.select('selectGender', '', h.lookups.list(h.lookups.GENDER_LOOKUP), 'selectGender', class_='input' ) }
Its that “class_=” part. Really simple once you see it, but annoying if you don’t know it.
Just a quick break down on what the select method takes in:
h.select(name, selected option, list, id, extra stuff)
Off Topic: My Love For Star Trek The Motion Picture
There are few things that I accept about myself: I’m ruggishly handsome, I have a superior intellect, and I’m the only person on the planet that thinks Star Trek the Motion Picture is the best Star Trek movie out there. And no I’m not talking about the 2009 movie, though I really enjoy that one, but the 1979 one. People usually just stare at me when I confess this after way too many drinks, but its true. Its my go to movie. If I don’t feel like watching anything else, I can always watch it. Actually I just had to adjust the TV as I am watching it right now.
Most people think it’s boring or something, but in my mind it’s by far the most true to the original series and by far the most intriguing. If nothing else, it keeps the original series’s flair for the unknown. You really aren’t given a lot of information off the bat except that what ever is out there just made the feared Klingons look like little bitches. I’m sorry, but any one who was brought up on the original knows there’s only one force in the universe that can go toe to toe with them and still survive… James T f—ing Kirk. This thing makes him look like a complete tool. Right off the bat you’re just thinking “Oh s—, what can stop this?” This thing makes the doomsday machine look like a ice cream vendor.
And I think that’s part of where my love comes in. The other movies, except maybe that disaster IV, you knew it was just the normal foe. Even Khan was assumed he would in some way get his a– handed to him James T Kirk style. But this thing (Why is every object we don’t understand called a thing?) is so far beyond powerful that you just can’t possibly accept that Kirk would kill or bang it. There is a feeling of complete and utter danger that none of the other movies really have. That feeling of powerlessness.
The next thing is the total seventies feeling too it. Yeah I know there are a lot of bad movies from that era, but the ones that we remember have something in common, a magically weaving of music and sight. There is something just… eh visceral about this movie that you can’t replicate in a movie. Something about the visual feel and the way the music just seems to draw out everything the eyes can’t see is something I think is the only part of the seventies worth noting. It was a time of experimenting with just about everything and as the saying goes sometimes the blind squirrel finds a nut. That is how I feel about this movie. The deliberate nature of it’s filming being paced by its music brings a certain overload of the senses at times. Some people call it slow or dull, but I call it purposeful and enveloping. It draws you in and tries to tell you a story that words could never do.
Beyond all of that, the twist at the end is so out there but makes so much sense that you can’t deny its possibility. I’m sorry but every times I hear the “V…g..e..r….voy…g…er…. Voyager” it just makes me think, “Now that’s an idea.” Well actually I end up repeating the line in only the way Shatner could deliver, but after that I think about the idea thing.
I understand that most people won’t watch this movie and get what I’m talking about. I get that I might be insane. I’m ok with that. Because as I sit here watching this movie for what is probably well beyond the 100th time, I know that I will enjoy every stupid second of it. You can go watch the stupid one with the whales if you want. This motion picture is mine.
Python: Getting the Current Year, Day, Month, Hour, Minute, Second… Even Microsecond? EH?
This is more to be filed under “I don’t want to have to search the wabz for this again so I’m using my blog to post something so I don’t have to”, but if someone else in this world gets something from this, then well someone else in the world gets something from this. As I’m the only person I care about, helping myself is about as far as my concern goes.
This is really simple:
import datetime from datetime def someMethod(): currentSecond= datetime.now().second currentMinute = datetime.now().minute currentHour = datetime.now().hour currentDay = datetime.now().day currentMonth = datetime.now().month currentYear = datetime.now().year
And actually there is one more if you print out datetime.now():
2010-09-24 10:06:06.599000
That .599000 is called microsecond:
datetime.now().microsecond
Anyhow, thanks for playing.