This file contains hidden or 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
<!-- templates/admin/custom_view.html --> | |
{% extends "admin/base_site.html" %} | |
{% load i18n %} | |
{% block breadcrumbs %} | |
<ul class="breadcrumb"> | |
<li class="active"> | |
<i class="icon-home"></i> | |
{% trans "Custom view" %} |
This file contains hidden or 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
from celery import Task | |
from celery.task import task | |
from my_app.models import FailedTask | |
from django.db import models | |
@task(base=LogErrorsTask) | |
def some task(): | |
return result | |
class LogErrorsTask(Task): |
This file contains hidden or 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
ROOT_DIR="$1" | |
mkdir "$ROOT_DIR" | |
cd "$ROOT_DIR" | |
#setup venv | |
virtualenv env --distribute | |
source env/bin/activate | |
#install django so we can start up an app |
This file contains hidden or 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
import os | |
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__) + '/../') | |
ENV_ROOT = os.path.abspath(PROJECT_ROOT + '/../') | |
ADMINS = ( | |
('XX', '[email protected]'), | |
) | |
MANAGERS = ADMINS |
This file contains hidden or 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
curl -XGET "http://localhost:9200/movies/_search" -d' | |
{ | |
"query": { | |
"nested": { | |
"path": "credits", | |
"query": { | |
"match": { | |
"credits.person_id": 1 | |
} | |
} |
This file contains hidden or 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
#!/bin/bash | |
# ======================================== | |
curl -X DELETE localhost:9200/movies | |
curl -X PUT localhost:9200/movies -d ' | |
{ | |
"mappings": { | |
"movie": { | |
"properties": { | |
"name": { "type": "string" }, |
This file contains hidden or 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
#!/bin/bash | |
# ======================================== | |
# Nested facets filtering by parent in ElasticSearch | |
# -------------------------------------------------- | |
# I need to get facets of departments for specific person for one movie genre: | |
# facets for credit.department where genre=comedy, credits.person_id=1 | |
# I am using include_in_parent:true mapping to be able to facet_filter by parent genre | |
# ======================================== | |
curl -X DELETE localhost:9200/movies |
This file contains hidden or 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 | |
class TagTrans extends Tag { | |
function generate() | |
{ | |
$value = '""'; | |
$lng = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : 'en'; | |
if(isset($this->parameters[$lng])){ | |
$value = '"' . $this->attr_parse($this->parameters[$lng]) . '"'; |
This file contains hidden or 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
#!/bin/bash | |
# ======================================== | |
# Testing simple analyzer in ElasticSearch | |
# ======================================== | |
curl -X DELETE localhost:9200/hotels | |
curl -X PUT localhost:9200/hotels -d ' | |
{ | |
"index": { | |
"analysis": { |
This file contains hidden or 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
q = { | |
"query": { | |
"function_score": { | |
"boost_mode": "replace", | |
"query": { | |
"ids": { | |
"values": [ | |
50, | |
80, | |
44, |