Skip to content

Instantly share code, notes, and snippets.

View jirfag's full-sized avatar

Denis Isaev jirfag

View GitHub Profile
#include <stdio.h>
#define TOKENPASTE(x, y) x ## y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define UNIQUE_FUNC_NAME TOKENPASTE2(cleanuper_func_, __LINE__)
#define UNIQUE_VAR_NAME TOKENPASTE2(cleanuper_var_, __LINE__)
#define SCOPE_EXIT(code_) \
void UNIQUE_FUNC_NAME(int *t __attribute__((unused))) \
code_ \
@jirfag
jirfag / haystack.py
Created December 2, 2015 08:20
Haystack setup for Django 1.8
#app/settings.py
INSTALLED_APPS = (
#...
'haystack',
)
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
# 1. go to https://aws.amazon.com and launch t2.nano instance with Ubuntu 14.04, opening ports 11212 and 11211 in security group settings
# 2. connect via ssh to it
# 3. curl http://download.tarantool.org/tarantool/1.6/gpgkey | sudo apt-key add -
# 4. run next commands for installation of tarantool (it's from http://tarantool.org/download.html)
curl http://download.tarantool.org/tarantool/1.6/gpgkey | sudo apt-key add -
release=`lsb_release -c -s`
sudo rm -f /etc/apt/sources.list.d/*tarantool*.list
sudo tee /etc/apt/sources.list.d/tarantool_1_6.list <<- EOF
deb http://download.tarantool.org/tarantool/1.6/ubuntu/ $release main
@jirfag
jirfag / simple_gen.py
Created April 23, 2016 10:55
Simple generation of questions and answers for Django app
from django.core.management.base import BaseCommand
from qa.models import Question, Answer
from lib.models import Liker, Tag
import random
#cd /Users/denis/track/env/lib/python2.7/site-packages/django && fgrep -lr "def " . | xargs -P8 -n1 cat | perl -lne '/^def (\w+)\(/ && print $1' >/tmp/all_django_funcs.txt
with open('/tmp/all_django_funcs.txt', 'r') as f:
all_django_funcs = f.read().splitlines()
question_text_templates = (
@jirfag
jirfag / fast_gen.py
Created April 23, 2016 11:01
Fast objects generation with bulk operations for Django app
from django.core.management.base import BaseCommand
from qa.models import Question, Answer
from lib.models import Liker, Tag
import random
#cd /Users/denis/track/env/lib/python2.7/site-packages/django && fgrep -lr "def " . | xargs -P8 -n1 cat | perl -lne '/^def (\w+)\(/ && print $1' >/tmp/all_django_funcs.txt
with open('/tmp/all_django_funcs.txt', 'r') as f:
all_django_funcs = f.read().splitlines()
question_text_templates = (
@jirfag
jirfag / install_es.sh
Created April 23, 2016 11:36
ElasticSearch instllation on ubuntu for Django Haystack
# wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
# echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
# sudo apt-get update
# sudo apt-get install –y openjdk-7-jre-headless elasticsearch
# pip install elasticsearch
@jirfag
jirfag / tnt_vs_memc_bench_cfg.lua
Created April 24, 2016 08:09
tnt_vs_memc_bench_cfg.lua
-- This is default tarantool initialization file
-- with easy to use configuration examples including
-- replication, sharding and all major features
-- Complete documentation available in: http://tarantool.org/doc/
--
-- To start this example just run "sudo tarantoolctl start example" or
-- use init scripts provided by binary packages.
-- To connect to the instance, use "sudo tarantoolctl enter example"
-- Features:
-- 1. Database configuration
@jirfag
jirfag / memc.conf
Created April 24, 2016 08:10
memc.conf
# memcached default config file
# 2003 - Jay Bonci <[email protected]>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.
# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d
@jirfag
jirfag / inst_cent.sh
Created April 25, 2016 08:14
Install centrifugo
wget https://github.com/centrifugal/centrifugo/releases/download/v1.4.5/centrifugo-1.4.5-linux-amd64.zip
unzip centrifugo-1.4.5-linux-amd64.zip
cd centrifugo-1.4.5-linux-amd64/
./centrifugo -h
@jirfag
jirfag / inst_cent_js.sh
Created April 25, 2016 08:19
install centrifugo js client
wget https://raw.githubusercontent.com/centrifugal/centrifuge-js/master/centrifuge.js -O static/js/centrifuge.js
./manage.py collectstatic