#Mac OS X
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
brew install git bash-completion
Configure things:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:
- Hulu / HuluPlus
- CBS
- ABC
- MTV
- theWB
- CW TV
- Crackle
- NBC
<?php | |
/** | |
* Create a web friendly URL slug from a string. | |
* | |
* Although supported, transliteration is discouraged because | |
* 1) most web browsers support UTF-8 characters in URLs | |
* 2) transliteration causes a loss of information | |
* | |
* @author Sean Murphy <[email protected]> | |
* @copyright Copyright 2012 Sean Murphy. All rights reserved. |
This is just a quick response to http://me.veekun.com/blog/2012/07/28/quick-doesnt-mean-dirty/. I won't bother to write a proper blog post for this, so a Gist will have to do ;)
When I read that article, one thing really striked me: If you want to quickly create a web app in PHP, you do exactly the same. I mean, exactly.
I never used the Silex microframework before, so I took this as a chance to see how it works. I'll just do the same as eevee did, only with a bit less commentary (this is a Gist after all!)
I hope that this will show you that PHP and Python are really similar to work with. Also this should show that just because you're using PHP, doesn't mean that you write dirty code. The similarity in the process and code is really incredible :)
# Example from http://mikepackdev.com/blog_posts/31-exhibit-vs-presenter | |
class Decorator < SimpleDelegator | |
end | |
class Car | |
def price | |
1_000_000 | |
end | |
end |
<?php | |
namespace Acme\DemoBundle\Twig; | |
use Twig_Extension; | |
use Twig_Filter_Method; | |
class ChunkExtension extends \Twig_Extension | |
{ | |
public function getFilters() |
<?php | |
if (isset($_GET['progress_key'])) { | |
$status = apc_fetch('upload_' . $_GET['progress_key']); | |
// Return null if total is empty to avoid divide by zero error below. | |
if (empty($status['total'])) { | |
exit; | |
} | |
echo ($status['current'] / $status['total'] * 100); |