So, today, I'm working on a project, I've got it all mocked out with some sample forms and some throwaway objects to play with.
I realize 'Hey, I need an authorization/authentication system', so I have a dilemma.
On the one hand, my code is throwaway that I plan to evolve to fit what I end up actually doing with it long term.
On the other hand, I really don't want to have to redo it later, since I'll probably want to come back here after I build out the auth/auth system.
Git to the rescue.
I've been doing all my development on the 'experimental' branch locally, as one ought to do.
git commit -m 'End of tinkering, time to get serious'
git checkout master #Back to the beginning,
#or you can use git checkout HEAD~x where x is how many commits you want to go back
#create the new branch and check it out
#equivalent of git branch restful_auth; git checkout restful_auth
git checkout -b restful_auth #which is a wonderful plugin, btw
# do your install here...
git commit -m 'All restful, now lets go back to the other'
git checkout experimental
git rebase restful_auth
# fix the conflicts, I had three
And you're done. You just saved yourself a couple hours of rewriting throw-away bits of your app. And of course, this is completely doable with pretty much any type of edit. You can go back into the past and effectively 'redo it right' without having to worry about the time it takes up front.
Monday, February 25, 2008
Git is amazing
Posted by
Justin George
at
3:03 PM
0
comments
Thursday, January 17, 2008
Ibuprofen, Naproxsyn/Naproxsen, and Aspirin: Don't overdo it.
My girlfriend just got out of the hospital after having a bleeding ulcer as a result of taking ibuprofen, among other stressors.
Just a heads up, any of you who read this, go easy on the ibuprofen, because the effects can be very bad if you are unlucky, and it is surprisingly common.
Posted by
Justin George
at
11:25 PM
1 comments
Labels: medicine
Friday, January 11, 2008
multiurl
like tinyurl but with multiple pages. Pop page with previews, ask users if they want to open all, one, some, or play slideshow-style in frame?
Perhaps a bookmarklet interface, along the standard HTML paste-in-urls.
Edit: Already exists, ManyURL, works nice from what I see. Could use a bit more, though! Too simple, not complicated enough.
Posted by
Justin George
at
2:55 AM
0
comments
Labels: dontstealthis, ideas, short
Friday, December 14, 2007
When you're serving static files...
Never link http://yoursite.com/foo/bar/x to:
A) plain http://static.yoursite.com/foo_bar_x.ext
B) Never use plain hashes of the ID. e.g. .../hash_of_id_here.ext
C) Borderline, but even static salts are bad: .../hash_of_id_plus_'foobar'_here.ext
Basic is, use a variable salt for every item. It can ever be public info, like the title, creation time, or anything that varies sufficiently per-item. That's the beauty of salts.
Or, alternatively, as better people than I have mentioned, use bcrypt with a set difficulty value, and all your rainbow table type fears go away.
Posted by
Justin George
at
12:09 AM
0
comments
Labels: hash functions, hashes, security
Thursday, October 18, 2007
Emacs...
Biggest reason to switch to emacs I've found so far is that the commands work by default in bash, too.
Posted by
Justin George
at
5:17 PM
0
comments
Labels: bash, default keybindings, emacs, text editors
Friday, September 7, 2007
Code on the Road: Navigating The Minefield that is Visual Source Safe
Code on the Road: Navigating The Minefield that is Visual Source Safe
Such a no-brainer. Why do you even try VSS to begin with? Get the Subversion plugin, grab SVN, and 99% of these things go away.
If that's not enough, git, darcs, bzr, and mercurial provide reasonable distributed solutions. Miles ahead of VSS (Actually, three generations, but who's counting.)
Seems to me, if you're really running an 'ex-pat' office, you'd want distributed. That way you can all trade changes around without having to fight conflicts. Best part is, you can stage to production without branch/tag.
Basically, there's no excuse these days for using an old VCS. Or, dare I say, a Microsoft VCS.
Posted by
Justin George
at
11:31 AM
2
comments
Thursday, September 6, 2007
On convergent evolution, and the invocation of holy wars.
Python and Ruby are the same thing.
There, with that out of the way, let me explain myself.
I was looking at a post about scene carving image retargeting which thoughtfully includes a link to his python implementation of scene carving all nicely packaged into git.
So I grabbed it, used emacs to import it into a new file, and started converting it to Ruby, since that's the language which is hitting my happy button right now (Haskell is for when I want to hurt myself). (NB said conversion I plan to post here, or at least, link to SVN for it.)
Take a look at an excerpt:
class CostMatrix(ndarray):
def calculate(self, energy_map):
if not energy_map.shape == self.shape:
raise Exception, "Wrong shape"
(h, w) = self.shape
self[0] = energy_map[0].copy()
self[0] = self[0]
for y in range(1, h):
for x in range(0, w):
bestcost = inf
bestx = x
for dx in range(x - 1, x + 2):
if dx >= 0 and dx < w:
if self[y - 1, dx] < bestcost:
bestcost = self[y - 1, dx]
bestx = dx
self[y, x] = self[y - 1, bestx] + energy_map[y, x]
self._calculated = True
def _get_max_index(self, row, startcol = 0):
maxx = startcol
maxval = self[row, maxx]
for x in range(0, len(self[row])):
if self[row, x] > maxval:
maxx = x
maxval = self[row, x]
return maxx
def find_shortest_path(self):
(h, w) = self.shape
x = self._get_max_index(-1)
path = [x]
for y in range(h - 2, -1, -1):
bestcost = inf
for dx in range(x - 1, x + 2):
if dx >= 0 and dx < w:
if self[y, dx] < bestcost:
bestcost = self[y, dx]
x = dx
path.append(x)
path.reverse()
return path
def get_image(self):
scaling = 0.03
(h, w) = self.shape
im = Image.new("L", (w, h))
im.putdata(self.flatten() * scaling)
return im
Now, if you're a python person, that should be fine. But what if you're a ruby person? That looks like ruby, where someone added in a lot of colons, and didn't remember their end tags. Oh, and someone's using paretheses oddly.
So, having converted those things, I'm confronted with a syntactically valid chunk of ruby code. It no longer throws parse errors.
This is pretty mindblowing, to me. Maybe it's something that's long since been obvious to the old hands...
Anyway, this makes me wonder why Python and Ruby aren't implemented on the same core compiler/interpreter. I know Microsoft is doing something akin to this with their Dynamic Language Runtime, but why aren't the Ruby people stealing like mad from the Python people, and vice versa?
That said, this, to me, is only the midway step between Python and Haskell. Ruby will probably take a week to do anything fun with it, so, much as I might like to throw up a free image resizing service, I'm thinking I'd rather do it in HAppS, where at least it will be fast.
Any thoughts? Am I an idiot for not seeing this already?
PS there's also another implementation of scene carving based resizing that I've been looking at.
Posted by
Justin George
at
3:55 PM
8
comments
Tuesday, August 28, 2007
Lunar Eclipse
Taken last night. If I had a better camera, I'd have taken Mars during the eclipse too.
Posted by
Justin George
at
9:55 AM
1 comments