Skip to content

Instantly share code, notes, and snippets.

@Sequoia
Created February 1, 2012 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sequoia/1718350 to your computer and use it in GitHub Desktop.
Save Sequoia/1718350 to your computer and use it in GitHub Desktop.
count some the languages mentioned in the HN jobs listings.
<?php
//explain usage
if( !isset( $argv[1] ) ){
echo "Usage: php " . basename(__FILE__) . " [url]";
die("\n");
}
$languages = array( 'python'=>0, 'php'=>0, 'node'=>0, 'ruby'=>0, 'java'=>0, 'javascript'=>0 );
$length = count( $languages );
$url = $argv[1];
$handle = curl_init();
curl_setopt_array( $handle, array(
CURLOPT_URL => $url,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true
));
$html = curl_exec($handle);
foreach($languages as $lang => $count){
preg_match_all("/$lang\b/i", $html, $matches);
$languages[$lang] = count($matches[0]);
}
arsort($languages);
foreach($languages as $lang => $count){
echo $lang, ": ", $count, "\n";
}
exit(0);
@Sequoia
Copy link
Author

Sequoia commented Feb 1, 2012

Note: this is so very highly unscientific :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment