Tar a directory without including its parents

To tar a directory without its parent, simply use the -C or –directory flag to specify the directory to "cd" into, then provide "." as the directory to tar.

Example:

To tar everything in /foobar/ without including /foobar/ in the path names, run

tar -zcvf foobar.tar.gz -C foobar/ .

That simple.

Google maps V3 API Wrong Marker Position

Don’t use zoom values that are not integers (2.7) caused huge problems for me.

It may have to do with the supporting marker customization libraries, as this problem was only apparent when customizing the marker heavily.

HTML Tidy Sublime + Django Remove %20 Characters

The HTML Tidy plugin for Sublime is amazing when people like to code with no line breaks.. but by default breaks django tags by converting spaces in django statements to %20.

I found HTMLTidy has a suspicious option called "fix-uri". Disable that in your sublime package preferences (you’ll have to add the key/value yourself) and voila everything is clean!

Ultimately, I use HTML Tidy to indent, not modify my code.

"fix-uri": false

Custom Desk.com Chat Icon

Desk.com doesn’t have very much documentation on their chat widget.

If there is, let me know.

All I needed was a custom icon for the chat button. I had to hack it into place by continually checking to see if the widget has initialized yet. Once it has initialized, hide the desk.com chat icon and attach a click handler to our own button, which merely proxies the click to the hidden original button.

// <a href="http://desk.com">desk.com</a> hack; custom chat now button.
var $chatButton = $(&quot;.my-chat-button&quot;);

var intervalID = setInterval(function() {
$widget = $(&quot;.a-desk-widget&quot;);
if ($widget.length != 0) {
clearInterval(intervalID);
$widget.hide();

$chatButton = $(&quot;.chat-now-button&quot;);

$chatButton.click(function() {
$widget.click();
})
}
})

Disable Mobile Safari Top/Bottom Bar auto show/hide viewport changes

Turns out you can disable the top/bottom bar auto show and hide nonsense which changes the size of the viewport, often causing full screen elements to need to be recalculated.

Add "minimal-ui" to the viewport meta tag to remove the behavior.

<meta name="viewport" content="width=device-width, minimal-ui">

Thanks to ayr.com for showing me it’s even possible.

Django – Cannot force an update in save() with no primary key.

If all debugging steps lead you nowhere with this problem, make sure you are not deferring any fields on your queryset prior to an insert attempt.

For example, I was calling save() on a recently copied object which initially had a deferred field.

Example:

obj = Object.objects.defer('foo')[0]

<a href="http://obj.id">obj.id</a> = None
obj.save() # triggers error

OSX: Easily SSH into local computer via ngrok

Enable remote login via going to “Sharing” in preferences, then clicking the “Remote Login” checkbox.

Next, download ngrok
https://ngrok.com/

Once set up, simply write into the command line:

ngrok -proto=tcp 22

Now you can SSH into your computer from the port number specified.

Example: ssh myusername -p PORT_THEY_SPECIFIED

This method bypasses any IP configuration at all, making it bullet proof.

Update: Ngrok2

Ngrok 2 requires authentication. Sign up for an account, authenticate via single command line ngrok authtoken <TOKEN>

Run

ngrok tcp 22

Conntect via SSH via ssh <user>@<HOSTNAME> -p <PORT>