Do something like “svn export” with git

Zend framework recently moved to git and I'm starting to integrate it into our release scripts.
The previous command used svn export and the tag for the release I wanted.
It took a little while to figure out how to do this with git:

git clone --depth 1 --branch release-1.12.3 https://github.com/zendframework/zf1.git /where/do/you/want/it/zf1/1.12.3/
rm -f -r /var/www/vhosts/ZendFramework/1.12.3/.git

A few differences from svn:

  • git has the complete revision history in every checkout. By adding the –depth 1, we're only getting the history relevant to our selected 'branch' and greatly speeding up the checkout of this giant project.
  • git doesn't do tags like svn/cvs. A tag isn't a branch, its a human friendly name for a revision hash. The command is –branch but it doesn't have to be a branch. It can also be a tag or commit hash. You'll get a warning about head being disconnected, its not relevant in my case because I'm not making change to or managing this folder with .git after I get it checked out.
  • git doesn't have an 'export' method because it doesn't need it. All the git revisions are in the .git folder in the root of the project instead of spread all over kingdom come like svn and cvs. Just delete the .git folder and now the project is no longer under git revision control.

This helped a lot and has other possible solutions.
http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export

Use PHP-CLI to publish server stats via json

If you need great server monitoring, use copper egg. It inexpensive, easy to install and very very good.

If you happen to use PHP with Linux, a lot of usesful information can be extracted from the /proc filesystem. Enough to provide basic monitoring. The attached script dumps and processes the output from proc every minute as json.

Make sure to protect the directory you're outputing this into to.

Download livestats.php code

Is this a private IP address?

I need to show different content to folks who are outside our network.
This snippet will detect a private ip address using php's built in filter class.

function is_private_ip($ip) {
return !filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
}

FILTER_FLAG_NO_PRIV_RANGE gets you:

"Fails validation for the following private IPv4 ranges:10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.

Fails validation for the IPv6 addresses starting with FDor FC."

and FILTER_FLAG_NO_RES_RANGE gets you:

"Fails validation for the following reserved IPv4 ranges:0.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24 and224.0.0.0/4. This flag does not apply to IPv6 addresses."

Source: PHP Docs

Create a google account without a gmail account.

We like being able to associate google analytics access to our corperate email address, but google is in the process of bringing all its authentication services under gmail, which seems to require creating a gmail account to access their services.

This isn't 100% the case yet.

You can still get to the old sign up form with this link.

https://accounts.google.com/NewAccount?service=analytics