Skip to content

Instantly share code, notes, and snippets.

@dvirsky
dvirsky / tasks.json
Created September 20, 2016 11:41
tasks.json for building and testing generic go projects in vscode
{
"version": "0.1.0",
"isShellCommand": true,
"showOutput": "always",
"command": "go",
"echoCommand": true ,
"options": {
"cwd": "${fileDirname}"
},
"tasks": [
@dvirsky
dvirsky / example.txt
Last active September 26, 2016 16:15
index example
# creating an index:
127.0.0.1:6379> IDX.CREATE users TYPE HASH SCHEMA name STRING age INT32
OK
# running HASH commands while indexing them:
127.0.0.1:6379> IDX.INTO users HMSET user1 name "alice" age 24
OK
127.0.0.1:6379> IDX.INTO users HMSET user2 name "bob" age 19
not connected> IDX.CREATE users TYPE HASH SCHEMA tm TIME
OK
127.0.0.1:6379> IDX.INTO users HMSET user1 tm 1476119602
(integer) 1
127.0.0.1:6379> IDX.INTO users HMSET user2 tm 1476019602
(integer) 1
127.0.0.1:6379> IDX.FROM users WHERE "tm < NOW" HGETALL $
1) user2
2) 1) "tm"
@dvirsky
dvirsky / gendocs.py
Last active September 12, 2021 16:12
Generate Markdown documentation from a python package
# This script generates mkdocs friendly Markdown documentation from a python package.
# It is based on the the following blog post by Christian Medina
# https://medium.com/python-pandemonium/python-introspection-with-the-inspect-module-2c85d5aa5a48#.twcmlyack
import pydoc
import os, sys
module_header = "# Package {} Documentation\n"
class_header = "## Class {}"
function_header = "### {}"
@dvirsky
dvirsky / Extensions.md
Last active March 12, 2017 14:34
RediSearch Extensions

Extending RediSearch

RediSearch supports an extension mechanism, much like Redis supports modules. The API is very minimal at the moment, and it does not yet support dynamic loading of extensions in run-time. Instead, extensions must be written in C and compiled into the engine when building it.

There are two kinds of extension APIs at the moment:

  1. Query Expanders, whose role is to expand query tokens (i.e. stemmers).
  2. Scoring Funtions, whose role is to rank search results in query time.

Registering Extensions

@dvirsky
dvirsky / redis-bashcomplete
Last active July 20, 2017 00:47
Bash completion for redis server and cli
# bash completion for redis-cli and redis-server
have redis-server &&
_redisserver()
{
local cur prev split=false
COMPREPLY=()
_get_comp_words_by_ref cur prev
@dvirsky
dvirsky / crc16_slottable.h
Last active May 6, 2024 03:14
A table of the shortest possible alphanumeric string that is mapped by redis' crc16 to any given cluster slot. the
#ifndef _CRC16_TABLE_H__
#define _CRC16_TABLE_H__
/* A table of the shortest possible alphanumeric string that is mapped by redis' crc16
* to any given redis cluster slot.
*
* The array indexes are slot numbers, so that given a desired slot, this string is guaranteed
* to make redis cluster route a request to the shard holding this slot
*/
/* Helloblock module -- An example of blocking command implementation
* with threads.
*
* -----------------------------------------------------------------------------
*
* Copyright (c) 2016, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@dvirsky
dvirsky / Makefile
Last active June 15, 2017 12:50
Minimal makefile for a redis module
DEBUGFLAGS = -g -ggdb -O2
ifeq ($(DEBUG), 1)
DEBUGFLAGS = -g -ggdb -O0
endif
# find the OS
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
CFLAGS = -Wall -Wno-unused-function $(DEBUGFLAGS) -fPIC -std=gnu99 -D_GNU_SOURCE
CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
#ifndef NS_HEADER_NAME_H_
#define NS_HEADER_NAME_H_
/* Enums are defined like data types */
typedef enum {
/* Options of enums are documented */
NSEnum_Foo,
/* Options of enums are documented */