Git — Change Branch for Uncommitted Working Copy

Say you’re working on branch x and you started to make some changes.

You suddenly realize you meant to be on branch master.

You can’t switch branches w/o committing.

Here’s how to switch:

git stash
git checkout master (or whatever branch you meant to be in)
got stash pop

Resolve the conflicts you get, and you’re good to go.

Jquery — Selectors. Select one child element

Finally, found a reference to my favorite method.

I needed something that traverses the DOM DOWN, not UP, but behaves like $.closest and $.parents

That is: $(TYPE, $JQUERY)

For an image inside a div you’re clicking:

$("div").click(function() { 
   $('img', this).show();  
});

Linode — filesystem is read-only after cloning

Quick tip here for those who just cloned a linode and their newly cloned filesystem says it’s read-only.

As a relative newblet to Sys Admin stuff, I submitted a ticket and got an answer in 30 mins w/ the solution.

Indeed, I did a clone while the source system was online.

The fix

http://library.linode.com/troubleshooting/finnix-recovery

  • Make a new boot configuration in the linode manager.
  • Load the finnix recovery kernel, mount the 3 disks as shown in the image. The finnix partition, your partition, and your swap.
  • Don’t forget the initrd image at the bottom.
  • Boot the system
  • Launch ajax console
  • Type in..
fsck /dev/xvdb
#note: xvdb is the second slot in the mounted disks in your setup. xvdc if you used the third, dvdd if fourth, etc.

and if you don’t want to type yes over and over for a few days, append a -y to it.

fsck /dev/xvdb -y

Reboot your initial configuration, and you’re good to go.

Slicehost to Linode VPS

This is hardly a technical comparison other than citing a benchmark. This is my experience in researching whether I should move from Slicehost to Linode.

The answer I got from my research is that Slicehost appears to be lagging behind due to being acquired by Rackspace. The bottom line though, is real hard data on performance, server hardware, cost per Storage GB, Ram, Bandwidth.

Slicehost acquired by Rackspace: management shift slows down progress.

Slicehost has been very behind these past 2 years — they have made no changes due to their being acquired by Rackspace.

They even admit it in their forums: they are disappointed with where they’ve gone. Lots of talk, no action, etc.

Slicehost admits fault on their forums.

You Guys Really Should…: Start trying to compete again?

When hit with the big question of: “your slices are expensive” their response is that they can scale if you suddenly get a ton of traffic on Christmas eve, which I have no doubt linode can do too.

I’ve read in slicehosts very own forums that many have been switching to linode over the years, including their guru base. I believe it!

In Slicehosts defence:  they claim you pay a premium for their support

But for me, my support has been great on both sides. Starting to claim you pay a premium for the quality, service, etc., is the last pitch you say when you can’t think of any other answers.

I’ve switched my DNS to linode, have used their clone service, resize op,  already submitted a ticket about / got an answer within 30 minutes.

Slicehost has better cloning/resizing, but how often do I use that..?

But to be honest, I don’t care about that too much. I’m not in a position to know how much work they did or didn’t do / what that means for the end consumer.

The bottom line is…

Linode wins performance benchmark of 5 VPS providers.

Check this VPS benchmark for the final answer: http://journal.uggedal.com/vps-performance-comparison

Linode beats the other VPSes on the market. The margin is VERY significant. I’ve already read that Linode simply uses better processors as you can check on your slices vs linodes.

Linode performance /should/ be up considering better processors.

My linode has 4 x Intel Xeon L5520 @ 2.27ghz, 8192kb cache.

Linode: more stuff for your money.

So far, I’m loving that the same $20 buys me 360mb of ram on FASTER servers vs 256mb of ram on slower servers.

  • Linode: $20 – 360mb ram – 16gb storage – 200gb bandwidth
  • Slicehost: $20 – 256mb ram – 10gb storage – 150gb bandwidth

Some straight out of the box features I’ve stumbled upon in linode

  • Web console
  • Major downside of linode was not having clone backups. They added it last month.
  • Private IP for free in-datacenter communication (my backups)
  • Admin with CPU/Traffic/Disk IO graphs for past 24 hrs, 30 days, and archive.
  • Auto reboot
  • One click server deployment scripts (I used one that sets up fail2ban, basic iptables, apache, django_wsgi, postgres / db…)
  • Ability to use different kernels. I used a recovery partition already.
  • Cool SSH access by whitelisted IP only. non whitelisted IP login attempt generates email to you to ask if you want to whitelist it. Simple. Effective.
  • Notifications on cpu/disk/traffic over certain threshold
  • and find the rest yourself! they have money back guarantee and it’s not like it’s expensive.

Here’s a referral link to linode

Assembla / Git — Delete a Repository within Space

Deleting a git / svn repository without deleting the whole space.

I gave up since I couldn’t google the answer.

Deleting repo:

Go to the space specific page, where you see all the repo tabs.

Click Admin tab.

Scroll to “tools”.

Click the “more” link on the right of  “tools”

Delete specific repositories on the right sidebar under “installed tools”

By the way, assembla is a host for Subversion and Git version control. They offer 2gb, FREE and PRIVATE hosting for git.

I highly recommend them.

PostgreSQL — pg_dump permission denied – LOCK TABLE

Check if the user running pg_dump has access to the tables.

For me, I had 2 tables owned by postgres instead of my usual user for some reason.

Check by going into psql, connecting to your DB, and typing \d

To change your table owner, type

ALTER TABLE tablename USER TO user;