Skip to content

Instantly share code, notes, and snippets.

View jirfag's full-sized avatar

Denis Isaev jirfag

View GitHub Profile
@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 / 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 = (
# 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 / 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/',
#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_ \