Lightweight Deployment With Git

I’ve used this setup so many times now that I wanted to write up a list post explaining how I do it. This method is something I found on this site, but I just wanted to add my own commentary.

The idea is that you are developing a website locally using git, and you want to be able to easily push to your live site with git. We will set up a remote repository on your server, and push to it.

Let’s say you have your local repository already set up. Log on to your remote machine. Navigate to a directory where you want to keep your repository. This does not necessarily need to be the same location as your code, and you actually probably want it to b e a different place.

### On the remote machine
corn03:/afs/ir/group/paperless2> mkdir repo.git && cd repo.git
corn03:/afs/ir/group/paperless2/repo.git> git init --bare
Initialized empty Git repository in /afs/ir.stanford.edu/group/paperless2/repo.git/

The way this is going to work, is that we are going to create a post-receive hook. A post-receive hook means you can run some script after this repo has received a push. What we are doing here is checking out the current gode to some directory, which we define as the GIT_WORK_TREE. You can make the GIT_WORK_TREE wherever you want. Then we make the script executable.

corn03:/afs/ir/group/paperless2/repo.git> cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/afs/ir/group/paperless2/cgi-bin git checkout -f
corn03:/afs/ir/group/paperless2/repo.git> chmod +x hooks/post-receive

Now, on your local machine, add the remote you want to push to. On this first one, make sure you include the branch you are including, like master.

## Locally
> git remote add web ssh://jkeeshin@corn23.stanford.edu/afs/ir/group/paperless2/repo.git
> git push web master

For any future updates

> git push web

It’s pretty basic, easy to use, and works for lightweight deployment for a site by yourself or with a few other people.

The only issue I had was one time, my internet connection went down in the middle of deployment and the git process crashed. Then the next time I tried to push, nothing happened. After a little bit of searching, the fix was that there was a file “index.lock” that was created, and once we removed that file, it worked again.

Jitterbunk. Bunk Your Friends.

If you read tech news or startup news, you are probably numb to it.

“Here is a new startup that will revolutionize our daily lives.”
“This site promises to forever change the way we communicate.”
“This one is a new twist on local deals.”
“You can watch videos or listen to music—but with your friends.”

This list keeps going. But that’s why we’ve built jitterbunk. We did away with all the fluff of new social sites and created a site where you can simply bunk your friends.

Read more about the founding of jitterbunk here.

If you like jitterbunk, you’ll definitely like raunk.

If you thought that was interesting…

Then head over to raunk.com. This is the startup I’ve been working on this summer with four friends. It’s a site where you can rate anything, and from the ratings, see best-of lists from different perspectives. Since the best-of lists are generated dynamically and from tags, we can generate really amazing and specific lists.

Let me give you a few examples:

Best Programming Languages According To Stanford Computer Science Majors
Best Movies According to Me
Best Season 8 Curb Your Enthusiasm Episodes According to my friends Zach and Daniel
Best Books According to my friend Eric
Best Free Mac Software According to Everyone
Best Harry Potter Characters According to my friend David

Let me explain why this site has the potential to be an amazing resource for you:

There already are many sites that rate things and review things–but most of these are for very common areas such as movies and restaurants. However, it is very common to start googling for the “best something.” But often you are looking for something that doesn’t have a review community like the Best Domain Name Registrars or the Best Stanford Traditions.

These are things I’ve been looking for recently. Our hope with raunk is that if we can can create a platform where people can rate anything, then raunk can be the primary resource for any specific list you have. If you look up best domain name registrars on google, what you’ll find at the top is just a blog post. What would be more helpful to me is if I could see the opinion of the internet, experts in this area, and people whose opinions I respect.

If you head over to raunk.com and check it out, send me an email and let me know what you think, or comment here.

Who Does Facebook Think You Are Searching For?

Have you ever wondered how Facebook orders your search results? Clearly they have some ordering about who they think you are looking for, and they seem to guess pretty well. I can only guess, but it seems like they order it based on who you interact with, whose profile you look at and who you have recently become friends with.

Well Facebook gives explicit numbers to the directed edges (connection going from you to your friend), about how much they think you are looking for this person. I wrote a bookmarklet that makes it easy to see this list. Although you already know who you look at most, it is eerie to see the list they have come up with—and the numbers they give. The more negative the number, the more Facebook thinks you are looking for them.

To try it out, just drag the image here up to your browser’s bookmark bar. Then go to Facebook and click the bookmarklet. More explanation below.

Note: This is really interesting, but may be embarrassing to you.

Facebook Friends

Try dragging this link if the image doesn’t work for you.
Facebook Friends

Tested on Chrome, Firefox, and Safari. If bookmarklet does not work on chrome, just try creating a new bookmark with the javascript as the url.

(Note: If you have https on, it won’t work. You can disable it temporarily by going to Account Settings/Security/Secure Browsing.)

How We Discovered this Link

We were working on our autocomplete search for the website we are building this summer called raunk.com and we were wondering why our autocomplete was so slow. If we typed fast, we could type faster than the results would show up. I thought, “Maybe I just type really fast, faster than the results can load.” We then checked Facebook. If we typed faster than Facebook autocomplete then it had to be okay. Well we started typing, and no matter how fast we typed, they already had results showing up.

How did they do this? Were their servers just that much faster than ours? (They are that much faster than ours.) But what turned out to be the difference was this file that they were preloading called first_degree.php. If you open up the Network panel in the Chrome Inspector or Firebug, you can see this file being requested asynchronously. Select XHR to only see AJAX requests.

Well in this file there is a lot of great information. It’s just JSON. There are probably two files, one which loads your first degree friends, and one which loads your “first degree” pages and events. Well if you open up the JSON file you will see, an ordered list of who Facebook thinks you are looking for.

Basically, you will find a list which is mostly who Facebook thinks you are Facebook stalking. And if you expand the entry you will see a field called ‘index’. ‘index’ is the number they give to that edge. The lower the number the earlier they show up on your search results.

And this stuff is all client-side, so it is all visible to you, and most likely will be for quite some time. This list is surprisingly interesting to check every now and then, and it will make you wonder how their algorithm is working and how those people go there.

Other Interesting Parts of this File

If you look a little more at this file you will find lots of other interesting information. There is an optional field that shows up in some results called ‘tokens’. This ‘tokens’ field stores common aliases to your friend’s name. For example, I have a friend named Michael, and his tokens says ‘mike’. My brothers is named Zach, but his tokens says ‘Brother’. Under Daniel it has ‘dan danny’. So look through the tokens, and find a friend who has a token that is not all close to his or her name. If you search it, you’ll notice that your friend will come up. That’s how it works. These are just common aliases for the name–not ones specific to your friend.

How the Bookmarlet Works

Here is how the bookmarklet works: It creates a script element on the page, gets a javascript file from my blog, and this file makes a request to the file first_degree.php with the correct parameters, and then it displays the results formatted nicely on your page.

UPDATE: Thanks for all the comments and feedback! I really appreciate and am glad you found the bookmarklet interesting and entertaining. If you’d like to contact me about the bookmarklet or about our website raunk.com, just shoot me an email or find me on Twitter @jkeesh.