TL;DR
Install Postgres 9.5, and then:
sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
import ujson | |
from kombu.serialization import kombu_register | |
kombu_register('ujson', ujson.dumps, ujson.loads, | |
content_type='application/x-ujson', | |
content_encoding='utf-8') | |
# Tell celery to use your ujson serializer: | |
CELERY_ACCEPT_CONTENT = ['ujson'] | |
CELERY_TASK_SERIALIZER = 'ujson' |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import Session | |
from myapp.models import BaseModel | |
import pytest | |
@pytest.fixture(scope="session") | |
def engine(): | |
return create_engine("postgresql://localhost/test_database") |
# /etc/systemd/system/iperf.service | |
[Unit] | |
Description=iperf server | |
After=syslog.target network.target auditd.service | |
[Service] | |
ExecStart=/usr/bin/iperf -s | |
[Install] | |
WantedBy=multi-user.target |
TL;DR
Install Postgres 9.5, and then:
sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
# How to run | |
# In the folder with these files | |
# sudo python -m SimpleHTTPServer 80 | |
# | |
# Update the ip at the bottom of this file to the output of | |
# hostname -I | |
# This is your ip | |
# | |
# Start debian cd | |
# Press esc on menu |
d-i debian-installer/locale string en_US | |
d-i keymap select de | |
d-i keyboard-configuration/xkb-keymap select de | |
d-i console-setup/ask_detect boolean false | |
d-i keyboard-configuration/layoutcode string de | |
d-i netcfg/choose_interface select auto | |
d-i netcfg/get_hostname string debianhost | |
d-i netcfg/get_domain string mydomain | |
d-i netcfg/wireless_wep string |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import Session | |
from myapp.models import BaseModel | |
import pytest | |
@pytest.fixture(scope='session') | |
def engine(): | |
return create_engine('postgresql://localhost/test_database) |
// we will use weak references with the Rc<T> (reference counting pointer) type | |
// weak references allow us to make references to a value that will -not- keep it alive | |
// this is perfect in the intsance of children, as we will soon see | |
use std::rc::{Rc,Weak}; | |
use std::cell::RefCell; | |
// this example builds upon the last by storing a vector of children as well as a parent | |
#[derive(Debug)] | |
struct Node { |
""" | |
This gist shows how to run asyncio loop in a separate thread. | |
It could be useful if you want to mix sync and async code together. | |
Python 3.7+ | |
""" | |
import asyncio | |
from datetime import datetime | |
from threading import Thread | |
from typing import Tuple, List, Iterable |
from rest_framework.filters import OrderingFilter | |
class CustomOrderFilter(OrderingFilter): | |
allowed_custom_filters = ['user_city', 'user_country'] | |
fields_related = { | |
'user_city': 'user__city__name', # ForeignKey Field lookup for ordering | |
'user_country': 'user__country__name' | |
} | |
def get_ordering(self, request, queryset, view): |