This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addressToCoordinates($address) { | |
$BASE_URL = 'http://maps.googleapis.com/maps/api/geocode/json'; | |
$socket = new HttpSocket(); | |
$args = array('address' => $address, | |
'sensor' => 'false'); | |
$results = json_decode($socket->get($BASE_URL, $args)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Application level Controller | |
* | |
* This file is application-wide controller file. You can put all | |
* application-wide controller-related methods here. | |
* | |
* PHP versions 4 and 5 | |
* | |
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <map> | |
#include <set> | |
#include <cfloat> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
typedef long poiid_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Earth radius | |
static const double EARTH_RADIUS = 6371400; | |
//! convert degrees to radians | |
double toRad(double degrees) | |
{ | |
return M_PI / 180 * degrees; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const double EARTH_RADIUS = 6371400; | |
//! WGS84 ellipsoid params (c) JCoord | |
static const double WGS84_MAJ = 6378137.000; | |
static const double WGS84_MIN = 6356752.3141; | |
static const double WGS84_ECC = ((WGS84_MAJ * WGS84_MAJ) - (WGS84_MIN * WGS84_MIN)) / (WGS84_MAJ * WGS84_MAJ); | |
inline void toUTM(double lat, double lon, double &east, double &north) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_random_item(weights): | |
num = random.uniform(0, 1) | |
for i, w in enumerate(weights): | |
if w > num: | |
return i | |
num -= w |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls 2012-12-{}.log | xargs -I file sh -c 'head -n 1000000 file > file.1m' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* insert and replace if an entry already exists | |
*/ | |
template <class TKey, class TVal> | |
void map_insert(std::map<TKey, TVal> &values, const std::pair<TKey, TVal> &val) | |
{ | |
std::pair<typename std::map<TKey,TVal>::iterator, bool> res = values.insert(val); | |
if (!res.second) | |
res.first->second = val.second; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: __PRETTY_FUNCTION__ only works for the GCC | |
#define NotImplementedException std::runtime_error(__PRETTY_FUNCTION__ + std::string(": not implemented ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ctime> | |
clock_t startTime = clock(); | |
// funciton here | |
cout << double(clock() - startTime) / CLOCKS_PER_SEC << endl; |
OlderNewer