Skip to content

Instantly share code, notes, and snippets.

View xfenix's full-sized avatar
😏
All commits are lost

Denis xfenix

😏
All commits are lost
View GitHub Profile
@xfenix
xfenix / vscode_config.json
Created February 1, 2021 00:55
My config
{
"editor.fontSize": 14,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/*.pyc": true
},
@xfenix
xfenix / extensions_list.txt
Created August 18, 2020 19:01
My Vscode setup (python, black, isort, react autoformat)
akamud.vscode-theme-onedark
alefragnani.project-manager
amatiasq.sort-imports
bibhasdn.django-html
bungcip.better-toml
eamodio.gitlens
ecmel.vscode-html-css
emmanuelbeziat.vscode-great-icons
esbenp.prettier-vscode
golang.go
let jq = document.createElement('script');
jq.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
$('.message-body-link > .fa-pencil').click();
$('.message-body-link > .fa-trash').each(function() {
$(this).click();
$('.swal2-confirm').click();
})
@xfenix
xfenix / diff_dict.py
Last active December 28, 2023 06:08
Diff dict function
def compare_dicts(old_dict, new_dict):
diff_items = {}
for key, value in old_dict.items():
if isinstance(value, dict):
result = compare_dicts(value,
new_dict[key] if key in new_dict and isinstance(new_dict[key], dict) else {})
diff_items.update(
{'{}.{}'.format(key, sub_key): value for sub_key, value in result.items()})
elif key not in new_dict or value != new_dict[key]:
diff_items[key] = value
@xfenix
xfenix / fizz_buzz_fast_and_functional.py
Created February 28, 2019 12:05
Another fizz buzz version
from functools import reduce
def reducer(acc, number):
local_buf = []
local_buf.append('Fizz' if number % 3 == 0 else '')
local_buf.append('Buzz' if number % 5 == 0 else '')
acc.append(''.join(local_buf) or str(number))
return acc
@xfenix
xfenix / Yzhasnii_kod_kak_slomat_piton_with_eto.py
Last active August 2, 2020 15:24
Beautiful fork of python newbies group code example. SyntaxError: too many statically nested blocks -- FUCK YEAH
n=22
z=[0]*(n-1)
for z[0] in range(z[-1],(n-sum(z[:0]))//(n-0)+1):
for z[1] in range(z[0],(n-sum(z[:1]))//(n-1)+1):
for z[2] in range(z[1],(n-sum(z[:2]))//(n-2)+1):
for z[3] in range(z[2],(n-sum(z[:3]))//(n-3)+1):
for z[4] in range(z[3],(n-sum(z[:4]))//(n-4)+1):
for z[5] in range(z[4],(n-sum(z[:5]))//(n-5)+1):
for z[6] in range(z[5],(n-sum(z[:6]))//(n-6)+1):
for z[7] in range(z[6],(n-sum(z[:7]))//(n-7)+1):
@xfenix
xfenix / ellipsis.py
Last active July 27, 2020 20:58
Space/speed effective string by word cutting algorithm
from ctypes import c_uint32
def ellipsis(string: str, str_length: int, suffix: str = '...') -> str:
max_len: int = str_length + 1
space: str = ' '
if len(string) > max_len:
if string[max_len] == space:
return string[:max_len] + suffix
else:
@xfenix
xfenix / fizzbuzz.py
Created August 17, 2018 13:09
FizzBuzz in one row (Don't do this. Ever)
for item in range(1,101): print((('Fizz' if item % 3 == 0 else '') + ('Buzz' if item % 5 == 0 else '')) or item)
@xfenix
xfenix / missing.js
Last active December 12, 2018 00:05
/**
* Функция missing(), которая принимает неотсортированный массив уникальных
* чисел (то есть, числа в нём не повторяются) от 1 до некоего числа n, и возвращает число,
* отсутствующее в последовательности. Там может быть либо одно отсутствующее число,
* либо их может не быть вовсе. Сложность O(n)
*/
function missing(seq) {
max_item = Math.max(...seq);
actual_summ = seq.reduce((acc, val) => acc + val, 0);
@xfenix
xfenix / django_cached_tpl_loader.py
Last active July 26, 2018 09:51
Django template file loader (for 1.7, maybe suits for later versions, idk, did not tested) with cache framework (i reccomend to use redis)
"""
Wrapper for loading templates from the filesystem.
Cached version of https://github.com/django/django/blob/stable/1.7.x/django/template/loaders/filesystem.py
"""
from django.conf import settings
from django.template.base import TemplateDoesNotExist
from django.template.loader import BaseLoader
from django.utils._os import safe_join
from django.core.cache import cache as redis_cache