Skip to content

Instantly share code, notes, and snippets.

View darklow's full-sized avatar

Kaspars Sprogis darklow

View GitHub Profile
@darklow
darklow / TsvectorType.php
Created July 17, 2012 12:13
Doctrine2 PostgreSQL tsvector type class
<?php
namespace Acme\AcmeBundle\Dbal;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
class TsvectorType extends Type
{
public function getName()
{
@darklow
darklow / gist:2757570
Created May 20, 2012 10:16
Elasticsearch log mapping
// Index config
{
"number_of_shards": 5,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"log_analyzer": {
"type": "custom",
"tokenizer": "pattern",
"filter": [
@darklow
darklow / gist:2483009
Created April 24, 2012 19:37
Elasticsearch geo search debug
// Create index with mapping
curl -XPUT http://192.168.0.10:9200/geotest/ -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"places" : {
"properties" : {
"name" : { "type" : "string" },
"location" : { "type" : "geo_point", "lat_lon": true }
@darklow
darklow / json_encode_pretty.php
Created April 18, 2012 13:53
JSON Encode pretty
<?php
function json_encode_pretty($obj, $indentation = 0)
{
switch (gettype($obj))
{
case 'object':
$obj = get_object_vars($obj);
case 'array':
if (!isset($obj[0]))