Learning something new every day
Posted by christine - 12/02/09 at 03:12:34 amAfter staring at a rake task for twenty minutes and manually testing some cases in a console, I’ve got some interesting larnin’s about ActiveRecord::Base.find and what it does with an options hash.
Background
There are typically two ways to provide conditions for a database search via ActiveRecord. The first is find, which looks like this most of the time: User.find(:all, :conditions => {:first_name => 'Bob', :last_name => 'Smith'}, :limit => 5). find takes two arguments: {:all, :first, :last}, and an options hash (more here).
Or taking advantage of existing relationships, which basically ORM-magic away a one-to-many foreign-key relationship between tables, e.g. some_user.files would return an array of some_user’s File objects. So on and so forth.
And a third way, which I like and think cleans things up really nicely but is apparently not relevant to this bit of learning, is using named scopes (more references) – essentially, a way to wrap up any part of that options hash into what looks like a method on the model itself. An example involving a female named scope on our beloved Usermodel.
class User < ActiveRecord::Base
named_scope :female, :conditions => {:gender => 'female'}
end
This allows you to not only get all female Users by calling User.female, but also allows combining of named scopes and the find method to minimize repetition and narrow the scope of a query. For example:
User.female.find(:all, :conditions => {:first_name => 'Christine'})
But wait!
In a script I was working on recently, I needed to loop through an array, and look something up at each step:
args = { :select => 'some_attr_id', :limit => 5 }
user_array.each do |user|
if condition
files = user.files.published.find(:all, args)
else
files = user.files.unpublished.find(:all, args)
end
... < do stuff with the files >
end
Interestingly enough, as args passed through the loop each time, it picked up the parameters added by the user-files relationship! Meaning, the first time through the loop with User 1, the args hash looked like this:
{:include=>nil, :readonly=>nil,
:conditions=>"`files`.user_id = 1",
:joins=>nil, :select=>"some_attr_id", :group=>nil,
:offset=>nil, :limit=>5, :having=>nil, :order=>"files.created_at DESC"}
… which makes all sorts of sense, considering a query like user.files.published would just be a search across some files table with user_id and a published conditions, but how irritating that the args hash was 1) mutable at all, and 2) modified by being passed into the ActiveRecord query!,
Who doesn’t love pretty pictures?
Posted by christine - 10/21/09 at 02:10:02 amMy ‘persona,’ via some crazy Media Lab grad student’s project – mostly (it seems) built from some snippet of text a friend wrote about me once, that seems to have since dropped off the internet.
Everyone likes pretty pictures. And most of the nerdy part of “everyone” likes graphs. And everyone definitely likes to learn about themselves – which is why I have so much fun exploring sites like
![]() |
![]() |
mint and me-trics – though it seems like other random takes on personal analytics (e.g. your.flowingdata – more details here) are popping up left and right as well.
All the pain in these applications, though, is the actual collection of the data – I think it’d be incredibly interesting (if extraordinarily creepy) if the information was captured for me, and all I had to do was consume it. Mint does a decent job, though it’s focused on the area of “personal data” that leaves the largest paper trail – so it still can’t tell me how many snack breaks I take while at my computer, or the average number of times I hit ’snooze’ before I get up on work days.
One of these days. Someone needs to build an accelerometer-equipped-image-recognition-machine-learningy widget to capture this data, and the software to process it :)
Satisfaaaacation.
Posted by christine - 09/04/09 at 05:09:16 pmI think I wrote something awhile back about good companies vs. good people – but what about good companies vs. good work? I just finished up a conversation with a friend who’s in the situation of being in love with the company he works at, but hates the tedious, somewhat degrading, but admittedly necessary work he actually does there. (Yes, he was an intern – but what an awful experience to have, and lesson to be taught!)
When should you sacrifice your own happiness / career development / intellectual stimulation for a product you’re excited about? Can you love the product and love the work? Or does loving the product just blind you to what you’re doing (and vice versa)?
I suppose it all boils down to how idealistic you are. Is this going to be the game-changer? Is there really nowhere else as, or almost as, exciting – but where you get to do interesting and challenging work? I usually think so – he may not. How does loyalty play into this – when are you obligated to stay with a company when you’re only being satisfied ideologically and not intellectually? (I say almost never – or that it’s only up to you to effect a change so that you are intellectually satisfied. But I’m only selectively idealistic, and incredibly selfish when it comes to my development.)
(p.s. – failed a bit with blogging once a week – but hopefully I can put something up soon about last weekend, which I spent at http://w2sf.startupweekend.org/ , and get back on track.)
You should be prepared to make this start-up the primary focus of your life.
Posted by christine - 08/07/09 at 05:08:00 pmI saw this line recently in the middle of a job posting, and I had a strong reaction – two, actually, in opposite directions. First, one of amusement and being mildly taken aback. Sure, they’re honest, but that’s a bit of an aggressive and unrealistic requirement, isn’t it? I almost wanted to scoff, ‘Who are you to demand to rearrange my priorities?’
But of course, the other side had its say as well – why, after all, shouldn’t these founders (who were looking for their third) hold any new teammates to standards as high as those that they themselves adhere? At least they list their expectations out for everyone to see, and hopefully avoid problems further down the road.
I’m torn – what is the right way to handle your pet project? I came into this summer wanting a ‘real startup experience,’ one with late nights and young techies bonding over their mutual misery labor. I complained about most people in my office heading home by 7, despite the smaller and otherwise generally ’startup-y’ feel. But then, faced with an opportunity to interview with a company that would expect more of me – expect me to make it the primary (only) focus in my life. And I don’t know, after all, if that’s what I want anymore.
I do want to care a lot about my work, be heavily emotionally and professionally invested in my product, and I wouldn’t mind it if everyone stuck around until 9 or 10 most nights… but I also appreciate having good friends outside of the company, and coming home to a roommate who cares more about my personal and emotional health than necessarily the health of my professional career.
In any case, I think this is going to be something I’ll be revisiting over and over again in the coming years, and something that will be heavily dependent on my professional focus. We’ll see what happens… and I’ll leave with a quote from a serial entrepreneur’s thoughts* on “Rules for Web Startups”:
#10: Be Balanced
What is a startup without bleary-eyed, junk-food-fueled, balls-to-the-wall days and sleepless, caffeine-fueled, relationship-stressing nights? Answer?: A lot more enjoyable place to work. Yes, high levels of commitment are crucial. And yes, crunch times come and sometimes require an inordinate, painful, apologies-to-the-SO amount of work. But it can’t be all the time. Nature requires balance for health—as do the bodies and minds who work for you and, without which, your company will be worthless. There is no better way to maintain balance and lower your stress that I’ve found than David Allen’s GTD process. Learn it. Live it. Make it a part of your company, and you’ll have a secret weapon.
* I actually hate the term ’serial entrepreneur.’ But I suppose Evan Williams has done pretty damn well for himself, and while I want to resent him for trashing this style of working, some part of me supposes he can’t be entirely wrong about everything.
Impetus
Posted by christine - 07/29/09 at 01:07:50 amI’ve been trying to be on my own case this summer. Last summer I was in San Francisco, I was very comfortable – I took the last shuttle home (at 7pm!) every day, couldn’t do work at home (no VPN access for interns!), so did a lot of relaxing, watching Alias, and cooking.
I’d had the goal of going out and “doing the SF tech thing,” which to me at the time meant going to tech meetups and talks and meeting all sorts of cool people, and learning all sorts of cool things. Clearly, it didn’t happen.
So this year I’m trying something different. I’ve been much more proactive about getting out and talking to people – an interesting union of MIT friends in and out of the startup world, acquaintances with interesting backgrounds and experiences, and now and then the occasional stranger whose blog I find fascinating. (I hate the term networking. I prefer “being-enriched-by-the-wisdom-of”.)
While the first category of dinner partners definitely keeps me from feeling like I’m becoming a hermit, it’s the second two categories that are really pushing this summer and myself forward. I walk out of each of these dinners excited about everything I can and want to do, and even more convinced of the importance of constant self-improvement.
So. In the interest of committing myself to a number of things to achieve this goal, here goes the list:
- Blog at least once a week. I’m going to set an alarm on my iCal and commit to posting something interesting I learned, or thought, or accomplished.
- Read 1 ‘improvement’ book for every fun book. I’m in the middle of reading the LOTR series (for the first time!), and once I finish The Two Towers, until I finish a programming- or startup- or productivity-related book, I won’t let myself read Return of the King. Sniff.
- Keep working a few nights a week on my side project (more later) – I feel like I need at least one or two non-school- or work-related projects under my belt before I can respect myself as a hacker. Or, as a lower standard, any sort of programmer.
- Along that line of thought – be more disciplined about said project! Don’t just sit down and start coding. Plan out the project a little more (what do I want it to do? How should it behave?) and use version control / repo management tools as well.
(Side note: am still probably far too awkward to be going around meeting people and making these first impressions. Need to work on that, too – for now, just sadface)
(Last note: tonight’s conversation was described as “covering a lot of ground, both philosophically and academically.” Last week’s was described as “spontaneously deep conversation with strangers.” Good nights, both. :))
Readymades
Posted by christine - 07/15/09 at 03:07:32 amI was at the SF MoMA this past weekend – and if you’ve ever been, you’ll (hopefully) know that in their standing collection is a set of art from a number of particularly interesting artists, one of whom (Duchamp) is known best for a work photographed here. This is Fountain:
It’s a urinal. It’s a run-of-the-mill, yes-he-really-did, urinal. Made into art (and thus deserving of a spot inside the MoMA) simply by declaring it as such.
Of course, some amount of reputation was required to pull that off, and some other, more traditionally respectable work had to be done to acquire said reputation, but in the end – he’s able to pull something someone else technically “made,” and enhance it for his own purposes.
In the software world, there are those who seem to find it unthinkable to use off-the-shelf products to help with the engineering process in-house. While this attitude has certainly led to plenty of innovation (thank you for Cassandra, BigTable, etc), these special cases seem to really only be the extreme of the “there’s nothing out there just for us” attitude. And, I suppose, to play devil’s advocate, in their situation, off-the-shelf tools probably aren’t quite right for their incredibly unique case. (Or maybe they just had too many engineers and not enough game-changing projects?)
In any case. One of the things I’m getting used to at Aardvark – and starting to really appreciate the wisdom of – is utilizing existing and established solutions when necessary. We need bug/ticket tracking? There’re tons of solutions out there – done! Better log analysis? Found, installed, done. System and cluster monitoring? Perhaps not entirely ideal, but good enough – done. It lets the team know what we need to know, and gets us free to focus on what we really need to get done – the core product and infrastructure.
I joined a conversation this past weekend with a couple of people just starting to get their startup off the ground, and they were embroiled in a CouchDB vs MySQL debate – are relational databases really outdated, or are document-based databases just overhyped? Which is the better to start with for their startup? My answer – whichever makes your actual job easier. There are lots of cool toys out there, but there’s a careful risk vs. reward tradeoff you have to make – and when you’re focused on startups, can you really afford an awkward risk down the line with your data or architecture?
I suppose this is a long, elaborate rephrasing of “Worse is Better.” Take shortcuts and the quick, easy, established route to change the world, first – then figure out how to make it happen better.
whoa! tcpdump
Posted by christine - 06/10/09 at 01:06:41 amInteresting UNIX trick of the week: $ sudo tcpdump -s0 -i en1 -A
(via unixjunkie)
MIT 6.001 and the new curriculum
Posted by christine - 05/11/09 at 03:05:03 amA recent post about the death of 6.001 caught my attention earlier today, and I’ve been stuck composing this blog post in my head for awhile.
As one of many MIT Course 6 students who took 6.001, I’m crushed they’ve been changing the curriculum. When it happened, student speculation ran along the lines of – enrollment in Course 6 has been dropping since the introduction of Course 20 (Biological Engineering). And because 6.001 was so heavily CS-oriented, the department didn’t want to continue losing the set of students who were turned off by the lack of hands-on appeal – so they wanted to make the class more accessible and exciting to the largest number of students.
While, from what I’ve seen and of 6.01, the class lacks not only the pure coolness of Scheme versus Python, but also 1) the ability to even the playing field for students, regardless of their previous programming knowledge, 2) the radically different way of thinking about computer programming that Scheme and SICP provided, and 3) an actual solid grounding in thinking about problems computationally and breaking them down. (One of the upsides I think I would have appreciated, however, is the ability to put an industry-relevant language on my resume. “Scheme” got a lot more raised eyebrows than job offers.)
What MIT offers now for those looking for CS grounding is an “intro intro” course called 6.00 – a class required for Course 20 but not for Course 6, and a class designed specifically to teach students how to think computationally and design software programs. 6.00 covers CS basics from recursion to performance to basic Big-O notation. Part of me wishes this class was included in the required curriculum, and part of me thinks it would be too easy / a waste of time for those who have programmed in the past.
I wonder whether this argument boils down to – how should students learn? By learning the basics and theory (math, physics, basic CS classes like 6.001 / 6.00), or by exciting students first by offering hands-on classes and lots of options (6.01, removing 8.02, the E&M class, from the General Institute Requirements, etc.). Unfortunately, the latter approach feels like MIT is relaxing its standards for its students – trying to make things exciting now so that students stick with the program, instead of building a solid foundation for later… and if that’s true, it’s not a trend I’m comfortable with.
For more discussion – the original Hacker News thread here (which actually links the article at the top of this post. How circular!)
Edit: A great point (from a MIT ‘08 sitting right in front of me in class, incidentally) made in an identical thread a month+ ago –
I think there’s something else here, implicit in Sussman’s comment, that’s important. MIT was founded on a philosophy of practicality, and everything else is secondary. If you couple that with the belief that fundamental computer science is the most efficient way to enhance practical software engineering, Scheme was a wonderful choice…
Python (and, frankly, a number of the scripting languages-turned-mainstream) combines this clarity of computer science with a practicality that Scheme never had. If you can convey 95% of the basic ideas in Python, and you can also open the door to learning how to deal with 3rd party code, you’d be a fool not to. It was never about programming purity anyway, so there’s no reason to mourn the passing of Scheme. It’s progress.
Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.


