Skip to content

Instantly share code, notes, and snippets.

@barseghyanartur
barseghyanartur / currency_helper.py
Last active Aug 29, 2015
Get all currencies in a dict or a list
View currency_helper.py
__all__ = (
'ALL_CURRENCIES', 'ALL_CURRENCIES_LIST', 'ALLOWED_CURRENCIES',
'CURRENCIES', 'CURRENCIES_LIST',
)
from pycountry import currencies
# Getting a list of all currencies to be used in Django
ALL_CURRENCIES = {c.letter: c.name for c in list(currencies)}
ALL_CURRENCIES_LIST = sorted(list(ALL_CURRENCIES.items()), key=lambda i: i[0])
@barseghyanartur
barseghyanartur / multiple_ssh_setting.md
Last active Aug 29, 2015 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@barseghyanartur
barseghyanartur / gist:b7e85802efdfec683456
Created Oct 9, 2015
Genymotion installation instructions on Ubuntu
View gist:b7e85802efdfec683456
https://cloud.genymotion.com/page/launchpad/download/
Download one
Move the downloaded file to ~/
mv genymotion-2.5.2_x64_debian.bin ~/
chmod +x ./genymotion-2.5.2_x64_debian.bin
@barseghyanartur
barseghyanartur / gist:b407148d06b973158382
Created Oct 13, 2015 — forked from AliMD/gist:3344523
All github Emoji (Smiles)
View gist:b407148d06b973158382

All github Emoji (Smiles)

ali.md/emoji

:bowtie: | 😄 | 😆 | 😊 | 😃 | ☺️ | 😏 | 😍 | 😘 | :kissing_face: | 😳 | 😌 | 😆 | 😁 | 😉 | :wink2: | 👅 | 😒 | 😅 | 😓

😩 | 😔 | 😞 | 😖 | 😨 | 😰 | 😣 | 😢 | 😭 | 😂 | 😲 | 😱 | :neckbeard: | 😫 | 😠 | 😡 | 😤 | 😪 | 😋 | 😷

😎 | 😵 | 👿 | 😈 | 😐 | 😶 | 😇 | 👽 | 💛 | 💙 | 💜 | ❤️ | 💚 | 💔 | 💓 | 💗 | 💕 | 💞 | 💘 |

View es 2.0 integration
# -*- coding: utf-8 -*-
"""
Search features for :
* :mod:`elasticsearch.elasticsearch`
* :mod:`haystack:haystack`
* :mod:`elasticstack:elasticstack`
:creationdate: 05/11/15 15:05
:moduleauthor: François GUÉRIN <fguerin@ville-tourcoing.fr>
@barseghyanartur
barseghyanartur / httpie.sh
Created Apr 11, 2016 — forked from chris-rock/httpie.sh
Httpie Quick Install Ubuntu 14.04
View httpie.sh
apt-get update && apt-get install -y curl && curl --silent https://bootstrap.pypa.io/get-pip.py |python3 && pip install --upgrade httpie
@barseghyanartur
barseghyanartur / README.txt
Created May 11, 2016 — forked from mattweber/README.txt
ElasticSearch Multi-Select Faceting Example
View README.txt
This is an example how to perform multi-select faceting in ElasticSearch.
Selecting multiple values from the same facet will result in an OR filter between each of the values:
(facet1.value1 OR facet1.value2)
Faceting on more than one facet will result in an AND filter between each facet:
(facet1.value1 OR facet1.value2) AND (facet2.value1)
I have chosen to update the counts for each facet the selected value DOES NOT belong to since we are performing an AND between each facet. I have included an example that shows how to keep the counts if you don't want to do this (filter0.sh).
@barseghyanartur
barseghyanartur / custom_elasticsearch.md
Created May 17, 2016 — forked from aolieman/custom_elasticsearch.md
Haystack provides an interface similar to Django's QuerySet, which instead enables easy querying in one or more popular search backends. Because the Haystack API is meant to hook up to several search backends, however, not all the functionality of the backends has been implemented in the API. In this post we show how Haystack's Elasticsearch bac…
View custom_elasticsearch.md

Extending Haystack's Elasticsearch backend

Haystack provides an interface similar to Django's QuerySet, which instead enables easy querying in one or more popular search backends. Because the Haystack SearchQuerySet API is meant to hook up to several search backends, however, not all the functionality of the backends has been implemented in the API. In this article we show how Haystack's Elasticsearch backend can be extended with advanced querying functionality.

As an exemplary use case, we'll focus on implementing Elasticsearch's Nested Query in the SearchQuerySetAPI, to enable e.g. weighted tags on documents. The usage of this extended API will be shown first, after which we'll go through the necessary implementation steps.

ConfigurableSearchQuerySet API Usage

import search.custom_elasticsearch as ces
from files import FileObject
@barseghyanartur
barseghyanartur / mapping.sh
Created May 23, 2016 — forked from zwrss/mapping.sh
Mappings for elasticsearch not nested stuff
View mapping.sh
#!/bin/sh
echo
curl -XDELETE 'http://localhost:9200/items'
echo
curl -XPUT 'localhost:9200/items' -d '
{
"mappings" : {
"Item" : {
"dynamic" : false,
View kill_django.sh
# -*- mode: shell-script -*-
function kill_django {
# Assuming that Django runs on port 8000, we find
# the process with netstat and kill it.
DJANGO_PORT=':8000'
DJANGO_INFO=$(sudo netstat -ntlp | cat | grep $DJANGO_PORT)
#echo $DJANGO_INFO
DJANGO_PID_PROC=$(echo $DJANGO_INFO | cut -d ' ' -f 7-)
#echo $DJANGO_PID_PROC