Skip to content

Instantly share code, notes, and snippets.

@Foxonn
Foxonn / gulpfile.js
Created September 8, 2018 10:21
Base settings to gulp
let gulp = require('gulp');
less = require('gulp-less'); //Подключаем less пакет
browserSync = require('browser-sync'); // Подключаем Browser Sync
concat = require('gulp-concat'); // Подключаем gulp-concat (для конкатенации файлов)
cssnano = require('gulp-cssnano'); // Подключаем пакет для минификации CSS
rename = require('gulp-rename'); // Подключаем библиотеку для переименования файлов
autoprefixer = require('gulp-autoprefixer');// Подключаем библиотеку для автоматического добавления префиксов
gulp.task('less', function(){ // Создаем таск "less"
return gulp.src('develop/less/main.less') // Берем источник
@Foxonn
Foxonn / .htaccess
Created June 21, 2019 10:28 — forked from VicVicos/.htaccess
Make your Website faster - a safe htaccess way
#
# Sources:
# http://stackoverflow.com/questions/7704624/how-can-i-use-gzip-compression-for-css-and-js-files-on-my-websites
# http://codex.wordpress.org/Output_Compression
# http://www.perun.net/2009/06/06/wordpress-websites-beschleuinigen-4-ein-zwischenergebnis/#comment-61086
# http://www.smashingmagazine.com/smashing-book-1/performance-optimization-for-websites-part-2-of-2/
# http://gtmetrix.com/configure-entity-tags-etags.html
# http://de.slideshare.net/walterebert/die-htaccessrichtignutzenwchh2014
# http://de.slideshare.net/walterebert/mehr-performance-fr-wordpress
# https://andreashecht-blog.de/4183/
@Foxonn
Foxonn / scratch.py
Last active January 21, 2020 09:12
Python | My variation binary search
def my_binary_search(_array, item):
n = 0 # iteration
i = 0 # finding index
array = _array[:]
if item > _array[-1] or item < _array[0]:
return None
while len(array) != 1:
n += 1
@Foxonn
Foxonn / scratch.py
Last active January 20, 2020 11:40
Python | Build tree from list [(parent, child),]
def to_tree(source):
parents = sorted([pair[1] for pair in source if pair[0] is None])
mod_source = sorted([pair for pair in source if pair[0] is not None])
def compile_branch(parent):
batch = []
for pair in mod_source:
_parent, _child = pair

In your models.py put:

from django.db import models

@classmethod
def model_field_exists(cls, field):
    try:
        cls._meta.get_field(field)
 return True
@Foxonn
Foxonn / change_ip.py
Created October 7, 2020 06:57 — forked from tarcisio-marinho/change_ip.py
change IP address using tor with Python3
# change IP via tor with python
import requests
from stem import Signal
from stem.control import Controller
import socks, socket
import time
# tuts
# https://www.torproject.org/docs/faq.html.en#torrc
# https://stem.torproject.org/tutorials/the_little_relay_that_could.html
@Foxonn
Foxonn / tor_test_429_error.py
Created October 21, 2020 11:04
python tor requests
import requests
import socks
import socket
from fake_useragent import UserAgent
from stem import Signal
from stem.control import Controller
controller = Controller.from_port(port=9051)
@Foxonn
Foxonn / gist:e7fa8d645c662a703b28d984db2d48c4
Last active March 10, 2021 11:39
Prepare linux before psycopg2 install
Прежде чем вы сможете установить psycopg2, вам нужно установить пакет python-dev.
Если вы работаете с Linux (и, возможно, с другими системами, но я не могу сказать по своему опыту), вам нужно быть очень точным в том, какую версию python вы используете при установке пакета dev.
Например, когда я использовал команду:
sudo apt-get install python3-dev
Я все еще сталкивался с той же ошибкой при попытке
pip install psycopg2
from shelve import DbfilenameShelf
from typing import Any
from typing import Type
from typing import TypeVar
T = TypeVar('T')
__all__ = ['ObjectsLocalStorage']
class ObjectsLocalStorage(DbfilenameShelf):
@Foxonn
Foxonn / lru_cache_manager.py
Last active June 28, 2023 12:06
Кэш управляемый единым классом
import time
import typing as t
from _functools import _lru_cache_wrapper
from functools import lru_cache
class LruCacheStorage(t.Dict[str, _lru_cache_wrapper]):
pass