Skip to content

Instantly share code, notes, and snippets.

View saippuakauppias's full-sized avatar
🤔
/dev/random

Denis Veselov saippuakauppias

🤔
/dev/random
View GitHub Profile
@nyumatova
nyumatova / install.sh
Created January 9, 2012 16:49
Virtualenv
sudo apt-get -y install git
sudo apt-get -y install curl
sudo apt-get -y install postgresql
sudo apt-get -y install libpq-dev
sudo apt-get -y install python-dev
sudo apt-get -y install libjpeg8-dev
sudo apt-get -y install libfreetype6-dev
curl http://python-distribute.org/distribute_setup.py | sudo python
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
@kmike
kmike / gist:2049651
Created March 16, 2012 11:21
SplitDateField
class SplitDateInput(forms.MultiWidget):
"""
Виджет для ввода даты с 3 полями.
"""
def __init__(self, attrs=None):
widgets = [
forms.TextInput(attrs=attrs), # день
forms.Select(attrs=attrs, choices=MONTHS.items()), # месяц
forms.TextInput(attrs=attrs), # год
]
@justinfx
justinfx / cache_generics.py
Created July 12, 2012 02:17
forwards generic relations
'''
Cache the generic relation field of all the objects
in the queryset, using larger bulk queries ahead of time.
Improved from original by Daniel Roseman:
http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/
'''
def cache_generics(queryset):
@asvetlov
asvetlov / hack.py
Created October 29, 2012 20:42
Hack to print Russian letters in unittests
# -*- encoding: utf-8 -*-
import unittest
class TestSomething(unittest.TestCase):
def test_unicode(self):
self.assertEqual(u'Русский', u'Текст')
if __name__ == '__main__':
import sys
We found a way that includes 23 stations and requires 2 transfers
Route plan: Akademmistechko -> Zhytomyrska -> Sviatoshyn -> Nyvky -> Shuliavska -> Politekhnichnyi Instytut -> Vokzalna -> Universytet -> Teatralna -> Khreshchatyk -> Maidan Nezalezhnosti -> Ploshcha Lva Tolstoho -> Palats Sportu -> Klovska -> Pecherska -> Druzhby Narodiv -> Vydubychi -> Slavutych -> Osokorky -> Pozniaky -> Kharkivska -> Vyrlytsia -> Boryspilska
Consider make a transfer from Khreshchatyk to Maidan Nezalezhnosti
Consider make a transfer from Ploshcha Lva Tolstoho to Palats Sportu
We found a way that includes 21 stations and requires 1 transfers
Route plan: Akademmistechko -> Zhytomyrska -> Sviatoshyn -> Nyvky -> Shuliavska -> Politekhnichnyi Instytut -> Vokzalna -> Universytet -> Teatralna -> Zoloti Vorota -> Palats Sportu -> Klovska -> Pecherska -> Druzhby Narodiv -> Vydubychi -> Slavutych -> Osokorky -> Pozniaky -> Kharkivska -> Vyrlytsia -> Boryspilska
Consider make a transfer from Teatralna to Zoloti Vorota

Nginx+gunicorn

Схема работы в данном случае такая:

  1. Nginx является frontend-ом, и браузеры общаются именно с ним. Мультидоменной конфигурацией рулит именно Nginx. Приняв запрос он решает какому backend-у его пробросить.
  2. Gunicorn - это WSGI веб-сервер. Каждый django-проект запускается на отдельном инстансе гуникорна. Именно ему будут приходить запросы от nginx-а
  3. Чтобы Gunicorn неожиданно не упал, а точнее, чтобы поднялся, если неожиданно упадет, запускать его будем с помощью supervisor. Вообще, есть несколько вариантов, но пока разберем только этот.
{% macro pagination(total, per_page, curr_page, sorting, order, search_id) %}
{% set pages_quantity = (total / per_page) | round(1, 'floor') | int %}
{% if pages_quantity != 0 %}
<div class="pages">
<div class="content pagination">
<div class="pagination">
<ul>
<li {% if curr_page -1 <= 0 %}class="disabled"{% endif %}><a href="?page={{ curr_page - 1 }}&amp;sorting={{ sorting }}&amp;order={{ order }}{% if search_id %}&amp;search_id={{ search_id }}{% endif %}">&laquo;</a></li>
curl -XDELETE localhost:9200/test-idx
curl -XPUT localhost:9200/test-idx -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"region_analyzer": {
"tokenizer": "my_ngram"
@yumike
yumike / feed.py
Last active December 22, 2015 17:58
from django.contrib.syndication.views import Feed
from django.views.generic import View
class FeedView(View, Feed):
def get(self, request, *args, **kwargs):
return self(request, *args, **kwargs)
@joeblau
joeblau / OSX Secure Disk Wipe.md
Last active June 12, 2023 07:37
Securely erase an external disk using dd on OSX

Securely erase an external disk using dd on OSX

  1. Plug in your SD card, HDD, or other block device and then use the following command to see which /dev/diskN node it's located on:
diskutil list
  1. Unmount the disk where “N� is the number of the disk taken from the above command: