Ken 的个人资料Ken's Space日志列表 工具 帮助

日志


6月26日

Gangsters are nice

Quirky, dark, urban hip, uncanny and nice gangsters... Wait, "nice gangesters"?
  
  Yes, Sir Ben Kingsley and Morgan Freeman as mob bosses - Who would've thunk?
  
  Gangsters are supposed to be merciless, smart and violent - not the fatherly figure Mr. X-Men or the straight-faced US army general. Put the slick-tongued Mr. Slevin in front of Tony Soprano or Don Corleone, he wouldn't have survived for more than 5 minutes. Or maybe gangsters are nice guys who loves to talk a lot and let people carry big guns into their offices, who knows.
  
  But don't get me wrong, I LOVE this movie even though the gangsters are little bit too nice: acting is first rated - Ben Kingsley, Morgan Freeman, Josh Hartnett and even Lucy, everybody delivered tour de force performance. (Bruce Willis? Don't go there... :-) Josh and Lucy had great chemistry hitting off the scene when they first met in the apartment, and Lucy's monologue rocks! "You mean this isn't the first time a crime lord has asked you to kill the gay son of a rival gangster to pay off a debt that belongs to a friend whose place you're staying in as a result of losing your job, your apartment and finding your girlfriend in bed with another guy." - you just gotta love those good screenwrites.
  
  OK, so you want to talk about Bruce Willis? My favorite scene of him in the whole god damn movie is when he said this at the end: "I am a world-class assassin, fuckhead." Now that sums up Bruce's entire career - man in trench coat, both hands straight with big guns and an intense look on the face, frozen forever, appropriate in every action movie he's done. In the bonus material he asked Morgan Freeman: "Career advice, do you think I chose the right career?" Freeman laughed, didn't say a thing.


Some things about the south

If you're not a South junkie you may not enjoy this movie at all - it was all about the South, the music, the story, the weird yet profound deep south of the Americana. We travel with Jim White, a folk singer, to various small town USA and visited barber shops, fast food joints, trailer parks and... you get it, churches, everywhere we go, we see and hear things so ordinary yet so iconic, mesmerizing and poignant.
  
  "I love the small town. It's not even a half-mile across the whole town. Very small. This way over here we have the church. Over here we have a truck stop. Over here we have the juke joint. Back behind me we have the prison. It's your typical Southern town. Some people go to church. Some don't. It's just one of those small towns." — The Mayor, Ferriday, Louisiana
  
  Some complain this movie is stereotyped since all it portrays was how poor and strange the South is - get over it, if it's part of the South then why not show it? I am sure there're movies depicting filthy rich white Southerners (maybe a redneck too, like the chimpanzee who's ruling the US of A) that make people think the South is all rosy and elegant and gone-with-the-windish, then so be it. You see only what you choose to see.
  
  Love the music and the cinematography in this flick. Heck, you can't get a bad picture of the South.




Federated SVN

One of the many issues we ran into with a distributed development team literally across the globe is sluggish connectivity - it was so painful that a mere check-in will cost you the time to prepare and finish an entire cup of cappuccino - good for the coffee lovers but not for geek heads.

So without further ado, here's how we build our in-house federated SVN system.

1 Set up SVN servers on both locations.

2 Dump the entire SVN repository from the primary US server and load it to the remote China server, this ensures a equal starting point. The following steps should be done on both servers:

3 Create a synchronization user account

4 Set up password-less SSH for the aforementioned user.

5. Create two new directories: svnlocalcommit and svnremotecommit under /tmp

6 Edit the post-commit script of SVN to include the following: echo $REV > /tmp/svnlocalcommit/$REV, for every commit, this will create a new file under the directory /tmp/svnlocalcommit

7 Load the following "svnpush.sh" script onto the server's /usr/bin directory:

##################################################
#!/bin/bash

VERSION="$1"
DUMPFILE=svndump$VERSION

# create a dump file
svnadmin dump [svn repo path] -r $VERSION --incremental > $DUMPFILE

# push it to remote SVN server
scp $DUMPFILE <user>@<server>:/tmp

# load commit on remote SVN server
ssh <user>@<server> /usr/bin/load_commit.sh $DUMPFILE
exit

##################################################

8 Load the following "load_commit.sh" onto /usr/bin directory:

##################################################

#!/bin/bash

DUMPFILE="$1"

svnadmin load [svn repo path] < /tmp/svnremotecommit/$DUMPFILE

##################################################

9 Load SvnAgent program as the synchronization user

10. Kick off SvnAgent, you're all set.

So here's how it works:

1. Someone makes a commit, the post-commit script will create an empty file named with the rev # under /tmp/svnlocalcommit directory and return, this will be very fast since it's done locally.
2. SyncAgent scans the svnlocalcommit directory every 5 seconds, once a new file is found it'll invoke the svnpush script
3. The svnpush script dumps the local commit (also to /tmp/svnlocalcommit folder but with a "svndump" prefix)
4. The svnpush script then scp the local dump file to the remote server (under remote server's /tmp/svnremotecommit directory)
5. Once scp is successful, the script then commits the uploaded file remotely and returns
6. The SyncAgent daemon receives the return status from the svnpush script
7. If the status was successful, the SyncAgent removes the empty file from svnlocalcommit and sleeps until next scan
8. If the status returns failure, the SyncAgent goes to sleep and try again next time.

Not that hard isn't it?

This works well when commits are coming from one way at a time mostly - namely, one teams works actively while the other team isn't.

Ah, want a copy of the SvnAgent source code? Email me here: k e n 0 6 2 4 7 0 0 [ a t ] g m a i l . c o m

Now get back to work you slacker!