Skip to content

Instantly share code, notes, and snippets.

@johnnypeck
johnnypeck / gist:0233562686a17da1e39d
Created November 9, 2015 18:46 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...
@johnnypeck
johnnypeck / dbSelect
Created January 17, 2014 03:11
If I use the randProps variable as the identifiers Doctrine ORM somehow still returns records where the managedStatus is not 20.
if ($comparison->getIds()) {
$identifiers = $comparison->getIds();
$random = false;
} else {
// we go random
$random = true;
/* @var $conn \Doctrine\DBAL\Connection */
$conn = $this->get('database_connection');
$stmt = $conn->executeQuery('SELECT id, managedStatus FROM property p WHERE managedStatus = ?', array(20));
@johnnypeck
johnnypeck / Mapping.json
Last active December 19, 2015 06:19
Elastic search filter and with two ranges does not work. The idea is that if the leaseStartDate is less than the date submitted AND the leaseEndDate is greater than the date submitted this should return the document. It does not seem that the AND is actually working as intended.
{
"property" : {
"properties" : {
"id" : {
"type" : "string",
"include_in_all" : true
},
"leases" : {
"type" : "nested",
"include_in_all" : true,
@johnnypeck
johnnypeck / gist:4576776
Created January 20, 2013 05:12
Add form types from service definitions.
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('form.extension')) {
return;
}
$types = $container->getDefinition('form.extension')->getArgument(1);
foreach ($container->findTaggedServiceIds('jspeck_choices.form') as $id => $attributes) {
$def = $container->findDefinition($id);
@johnnypeck
johnnypeck / returnsAllRecords
Created November 13, 2012 20:55
returnsAllRecords
This returns all records when used in elastic search head. When used through elastica the response is "no query registered for not" from elastic search. I'm much more concerned about getting it to work in elastic search head so I at least know the query/mapping to use.
Mapping:
{
state: open
settings: {
index.number_of_shards: 5
index.number_of_replicas: 1
@johnnypeck
johnnypeck / noqueryregistered
Created November 13, 2012 19:03
No query registered for not
"query" : {
"filtered": {
"query": { "match_all" : {}},
"filter": {
"not": {
"nested": {
"path": "leases",
"filter": {
"and": [
{
{
"filtered": {
"query": {
"bool": {
"should": [
{
"text": {
"locationNeighborhood.name": {
"query": "dupont",
"analyzer": "snowball"
@johnnypeck
johnnypeck / property.json
Created November 8, 2012 21:31
elastic search json
{
_index: website
_type: property
_id: 9
_version: 1
_score: 1
_source: {
id: 9
unitNumber: 2009