Skip to content

Instantly share code, notes, and snippets.

@dmregister
dmregister / gist:6583514
Last active December 23, 2015 04:59
This is in my Application module onBootstrap. I downloaded the library with composer.
return array(
doctrine => array(
...
'configuration' => array(
'orm_default' => array(
'string_functions' => array(
'acos' => 'DoctrineExtensions\Query\Mysql\Acos',
'cos' => 'DoctrineExtensions\Query\Mysql\Cos',
'radians' => 'DoctrineExtensions\Query\Mysql\Radians',
'sin' => 'DoctrineExtensions\Query\Mysql\Sin'
@dmregister
dmregister / gist:6595079
Created September 17, 2013 14:29
This is passed to a ZF2 http client then set as raw body after it is json_encoded.
$search = array(
'filtered' => array(
'query' => array(
'match_all' => array()
),
'filter' => array(
'geo_distance' => array(
'distance' => '1mi',
'pin.location' => array(
'lat' => '25.756205',
stdClass Object
(
[listing] => stdClass Object
(
[properties] => stdClass Object
(
[bedrooms] => stdClass Object
(
[type] => long
[store] => 1
@dmregister
dmregister / gist:6596884
Created September 17, 2013 16:33
Sample data
[0] => stdClass Object
(
[_index] => listings
[_type] => listing
[_id] => V3orbrdXQ06F4mJye7fT_Q
[_score] => 1
[_source] => stdClass Object
(
[mlsId] => MAORFL
[mlsNumber] => A1593964
@dmregister
dmregister / gist:6629208
Created September 19, 2013 20:14
ES query
'query' => array(
'filtered' => array(
'query' => array(
'bool' => array(
'must_not' => array(
'ids' => array(
'values' => array($listing_ids)
)
)
)
Zend\Http\PhpEnvironment\Response Object
(
[version:protected] =>
[contentSent:protected] =>
[recommendedReasonPhrases:protected] => Array
(
[100] => Continue
[101] => Switching Protocols
[102] => Processing
[200] => OK
Attemp 1:
--------
$response
->getHeaders()
->addHeaderLine('Location', $uri->toString());
$response->sendHeaders();
exit;
$queryBuilder = $objectManager->createQueryBuilder();
$queryBuilder->select('*')
->from('Application\Entity\Thing','n')
->where("Intersects(GeomFromText('Polygon((?1,?2,?3,?4,?5))'),n.geom)")
->andWhere('n.type = ?6');
Additional information:
Doctrine\ORM\EntityNotFoundException
File:
\vendor\doctrine\orm\lib\Doctrine\ORM\Proxy\ProxyFactory.php:177
Message:
Entity was not found.
Stack trace:
#0 \data\DoctrineORMModule\Proxy\__CG__ApplicationEntityCharacteristic.php(208): Doctrine\ORM\Proxy\ProxyFactory->Doctrine\ORM\Proxy\{closure}(Object(DoctrineORMModule\Proxy\__CG__\Application\Entity\Characteristic), 'getName', Array)
#1 \data\DoctrineORMModule\Proxy\__CG__ApplicationEntityCharacteristic.php(208): Closure->__invoke(Object(DoctrineORMModule\Proxy\__CG__\Application\Entity\Characteristic), 'getName', Array)
#2 \module\Listing\view\listing\index\index.phtml(94): DoctrineORMModule\Proxy\__CG__\Application\Entity\Characteristic->getName()
@dmregister
dmregister / gist:9467385
Last active August 29, 2015 13:57
Elasticsearch completion data and cmd
#bulk cmd
curl -XPOST http://127.0.0.1:9200/_bulk --data-binary @file.json
#json file
{"index":{"_index":"autocompletezipcode","_type":"zipcode","_id":41782}}
{"zip":"99830","city":"Kake","state":"AK","suggest":{"input":["99830"],"output":"Kake, AK"}}
{"index":{"_index":"autocompletezipcode","_type":"zipcode","_id":41783}}
{"zip":"99832","city":"Pelican","state":"AK","suggest":{"input":["99832"],"output":"Pelican, AK"}}