itertools.groupby allows you to group a sorted list (or any sorted iterable) by some key, giving you the grouping key and the list of items grouped by that key.
For example, say you have a Django the model:
class Item(models.Model): user = models.ForeignKey( User, verbose_name="User", db_index …
Note to self: I quite stupidly merged and committed an unwanted branch into master. Took a surprisingly long time to figure out how to get rid of it:
git reset --hard HEAD^
Which means reset git to one commit before the current head, effectively getting rid of the last commit …More
I needed to efficiently find large images (those with dimensions greater than x). Here's what I came up with:
First, find images whose file size is greater than 3M:
find . -name '*jpg' -size 3M > /tmp/big-receipts.txt
Now, get the dimensions of each of those images using imagemagick's identify command …More
Over the weekend I attended the Blackberry hackathon with the hopes of creating an Xpenser blackberry app. The RIM folks were nice enough to give away a Playbook to everyone who presented, so I ended up with one.
I was skeptical, to say the least. I expected a sluggish, ugly …More
This page is helpful.
sftp -v -oPort=6636 -o IdentityFile=keys/my-key.ssh [[email protected]](/web/20120914064722/http://cloudflare.com/email-protection.html)
If you know me you know I'm a huge fan of entrepreneurship - instead of renting yourself out to someone else, start a business that scales. Be your own pimp.
I gave a guest lecture at UCSD recently espousing this viewpoint. You are cheap right now, I told them, so take …More
Here's how you import a python module dynamically: say your module is called "mysettings" and it's in the directory "config". Make sure you have a
__init__.py in your "config" directory and use:
mysettings = __import__("config.mysettings", fromlist=["config"])
This is equivalent to
from config import mysetings
My new printer has a document feeder which makes scanning of multiple pages easy, but I didn't know how to kick off the scan on OS X. Turns out it's quite easy:
Apparently with Titanium Studio it's not possible to see log messages in the Titanium console.
Here's how you see your log messages:
adb logcat | grep "TiAPI"
adb is in the tools directory of your Android sdk.More
Here's an easy way to see the cookies for the current site in Chrome:
I went to a school that required uniforms (private school in England). We were forced to be uniform.
This afternoon driving by the high school near my house I was amused to see uniforms everywhere - here a patch of girls all wearing the same types of shorts, with hair pulled …More
My friend Paul Kedrosky's post on one of his main investment theses, the application of currently consumer oriented technologies to business (DropBox, Twitter, FaceBook, Yelp, …), got me thinking about how the future of work will look.
I've made a career of working far from where I live. I've generally considered …More
Note to self, for future reference.
Generating static html:
import markdown2 file('classification.html','w').write( markdown2.markdown_path('classification.md', extras=["code-friendly"]) )
Retention bonuses don't work because they only motivate presence, not contribution.More
The lovely folks at mo.com recently asked me about my experiences at Yahoo, the background and business model for Xpenser, and thoughts on funding and raising VC money. The interview has been published here, drop by and take a gander.More
Here's a handy way of running a command on multiple boxes. In this case I wanted to check disk space on a series of machines.
Assuming you're using bash as your shell, the following will list the hostname and run df on machines racb13 through racb28 and spit out the …More
Mark Suster and Fred Wilson have both posted on the topic of being a good panelist. I'll throw in the best advice I ever got on the topic (from Alex, who got it from someone else):
Disagree with other panelists.
A panel of people agreeing with each other is generally …More
I was surprised at how little information I found on making use of Django's permission system. Here are some quick notes on one way to use it:
Groups are groups of users. For example, you could define a group of users who have premium accounts, or have been verified in …More
I remarked to a friend that Mark Suster's entrepreneurial roots show in his approach to being a VC - he's come out of nowhere and in short order aggressively pushed himself into being one of the most relevant voices out there. He seems to be working a lot harder than …More