Archive for March, 2011

Refresh a stale tmux session

Posted on March 31st, 2011 in ssh, tmux | 3 Comments »

Sometimes when you SSH into a machine and reattach your tmux session you’ll find that your SSH environment variable is stale so commands like “git pull” don’t work. Here’s a simple command that refreshes that variable. I simply type “r” anytime I notice my session is stale or a command requiring ssh authentication fails:

# used to refresh ssh connection for tmux 
# http://justinchouinard.com/blog/2010/04/10/fix-stale-ssh-environment-variables-in-gnu-screen-and-tmux/                                                                                                                                                                                         
function r() {   
  if [[ -n $TMUX ]]; then
    NEW_SSH_AUTH_SOCK=`tmux showenv|grep ^SSH_AUTH_SOCK|cut -d = -f 2`
    if [[ -n $NEW_SSH_AUTH_SOCK ]] && [[ -S $NEW_SSH_AUTH_SOCK ]]; then 
      SSH_AUTH_SOCK=$NEW_SSH_AUTH_SOCK  
    fi
  fi
}


I can’t take credit for this wonderful tidbit, it was written by Eivind Uggedal in a comment in this post.

Working with git repos on non-standard ports

Posted on March 30th, 2011 in git, ssh | 8 Comments »

Recently due to some SSH attacks I’ve had to change my default SSH port to something non-standard. While I’m not a proponent of security through obscurity, most automated botnets ping random IP addresses on port 22 to see if there’s an SSH daemon listening before relentlessly hammering down on them—it only makes sense to get off of that port. (I’ve obviously hardened my security in other ways as well.)

Since I run my own little version of GitHub (using a combination of Gitolite, git-commit-notifier, and other open-source tools) which I share with friends, I needed to send out a quick email on how to switch up existing checked-out repositories as well as how to clone new ones using this non-standard port. Since I did the research, I thought I might as well post it here, too:

Cloning a git repository on a non-standard port

The git man file says you can specify a port using the traditional git syntax but I couldn’t get it to work for the life of me, It always defaulted to port 22. Since git just uses SSH anyways, here’s the alternative syntax that also works:

old:

git clone git@domain.com:<project name>

new:

git clone ssh://git@domain.com:<port>/<project name>

Switching an existing checked-out repository to use a non-standard port

To prevent having to re-checkout an entire project, simply change the location of master and all will be fine. There’s a way to do this using a git shell command but I prefer to just modify the .git/config file directly, as that’s all the commands does anyways.

old:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@domain.com:<project name>


new:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://git@domain.com:<port>/<project name>

Set it and forget it method (.ssh/config)

Instead of doing any of the above, if you’re on a Mac or Linux environment, the config file inside of your ~/.ssh folder can save you from typing long ssh commands. It allows you to create short ssh alias’s that predefines a host, username, port, as well as more advanced functionality like running proxy commands, forwarding your ssh agent, etc. It’s well worth taking a look at. When you set an SSH alias anything that uses SSH (git, rsync, scp, etc) all have access to it.

Add the following lines to your ~/.ssh/config:

Host myrepo
     User git
     Port <port number>
     Hostname <hostname.com>

Now you can do a git clone by doing the following:

git clone myrepo:<project name>

Or in your current checked-out project change the remote “origin” url to:

myrepo:<project name>

It will automatically pick up your username, port, and hostname from your .ssh/config file.

The Android’s greatest flaw for developers and consumers alike: lack of web proxy

Posted on March 21st, 2011 in android | 1 Comment »

Update 6/17/2011: I received an email from GoogleCode that nonchalantly mentions that this feature has been added to Honeycomb (3.0). I confirmed that the ticket status is now changed to “released”. While it’s great that this feature is finally here, I wish that they had made more of a public announcement or address as to why it took so long. As of 14 hours ago ticket 1273 is still receiving plenty of comments (400 more since this post was written) and has been starred 3812 times. Google acquired the company that started Android over six years ago and I consider the lack of communication an utter failure.

Taken during the Q&A session at SV IGDA Game Technology and Career Night at Google March 16, 2010.

There’s endless amounts of comparisons between the iPhone and Android phones regarding which is better. While I prefer to stay out of that debate, it can’t be ignored that the Android platform lacks a built-in web proxy—and for over two years running now.

As a mobile web developer, this makes development increasingly hard as embedded web views inside of games and other mobile applications can’t be rerouted to your local machine easily. There’s no immediate way of analyzing or redirecting HTTP requests, using Charles, or other standard ways of debugging. Sure there’s hacks out there to install custom roms, modify the IP tables of your router, or use the Android SDK to modify the phone’s etc host—but none of them work as cleanly and efficiently as a simple option under system settings or at all in cases like my own where we need to redirect production requests to a remote dev server. My company had to actually spend developer time to build a web proxy option inside our Android-port of our iOS game for just this.

Consumers also are affected by this lack of proxy. Many secure corporations and college networks require you to set up a web proxy to access internal resources. View the sea of complaints on the official Android ticket, over 1,300 comments strong and mostly consumers. While 1,300 might not sound like a lot for a platform as far-reaching as Android, that’s only the people savvy enough to know what a bug tracking system is and how to use it.

In short, the Android platform is becoming the new IE for us and consumers. If you use or develop on an Android and would like this missing feature prioritized, please visit this link and star the post. Feel free to leave a comment. Then tweet it up: “Google: please fix Android issue 1273. We need a web proxy! http://code.google.com/p/android/issues/detail?id=1273″. Feel free to link to this post as well for a quick explanation of the situation.

Thanks.

Darndest CSS3 bug in iOS 3.1.3

Posted on March 17th, 2011 in iOS, iPhone | No Comments »

We were experiencing consistent bootup crashes for a game with embedded web views. Took us a while to track it down but if you use

display: table-cell;

with

-webkit-transform: translate3d(0,0,0);

or

-webkit-transform: translateZ(0);

in the same CSS declaration, it will trigger a bug in Mobile Safari and the game will crash.

Great way to check if you’re using hardware acceleration on your Safari mobile apps / webviews

Posted on March 16th, 2011 in iOS, mobile apps | No Comments »

The first thing you learn building HTML5/CSS3 web apps is that enabling hardware acceleration is must for smooth animations and transitions. Here’s a great tip by Thomas Fuchs that explains how you can see what parts of your web app are hardware accelerated: http://mir.aculo.us/2011/02/08/visualizing-webkits-hardware-acceleration/