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
@wangruohui
wangruohui / intel-nvidia.md
Last active June 26, 2024 08:59
Intel for display, Nvidia for computing

Intel for display, NVIDIA for computing

This guide will show you how to use Intel graphics for rendering display and NVIDIA graphics for CUDA computing on Ubuntu 18.04 / 20.04 desktop.

I made this work on an ordinary gaming PC with two graphics devices, an Intel UHD Graphics 630 plus an NVIDIA GeForce GTX 1080 Ti. Both of them can be shown via lspci | grep VGA.

00:02.0 VGA compatible controller: Intel Corporation Device 3e92
01:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
@tomschr
tomschr / test_mock.py
Last active January 12, 2024 21:45
Example of mocking os.path.isfile
#!/usr/bin/env python3
#
# Use py.test:
# $ pytest test_mock.py
from unittest.mock import patch
import os.path
def my_isfile(filename):
@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:
@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)
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"
{% 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>

Nginx+gunicorn

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

  1. Nginx является frontend-ом, и браузеры общаются именно с ним. Мультидоменной конфигурацией рулит именно Nginx. Приняв запрос он решает какому backend-у его пробросить.
  2. Gunicorn - это WSGI веб-сервер. Каждый django-проект запускается на отдельном инстансе гуникорна. Именно ему будут приходить запросы от nginx-а
  3. Чтобы Gunicorn неожиданно не упал, а точнее, чтобы поднялся, если неожиданно упадет, запускать его будем с помощью supervisor. Вообще, есть несколько вариантов, но пока разберем только этот.
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
@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
@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):