Skip to content

Instantly share code, notes, and snippets.

View CalebMuhia's full-sized avatar

John Njoroge CalebMuhia

  • Ovtygen Web Solutions
  • Nairobi
  • 05:20 (UTC +03:00)
View GitHub Profile
@CalebMuhia
CalebMuhia / example.md
Created June 3, 2021 17:24 — forked from sdnts/example.md
Postman pm.sendRequest example

To send a request via the sandbox, you can use pm.sendRequest.

pm.test("Status code is 200", function () {
    pm.sendRequest('https://postman-echo.com/get', function (err, res) {
        pm.expect(err).to.not.be.ok;
        pm.expect(res).to.have.property('code', 200);
        pm.expect(res).to.have.property('status', 'OK');
    });
});
@CalebMuhia
CalebMuhia / custom_elasticsearch.md
Created December 6, 2021 02:08 — 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…

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
@CalebMuhia
CalebMuhia / bank_test.py
Created June 13, 2022 17:44 — forked from mrcfps/bank_test.py
Exploration of how to test concurrency in Python
from __future__ import print_function
import platform
import sys
import threading
import time
class UnsyncedBankAccount(object):
"""Bank account with no synchronization lock, prone to race condition."""