Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Kuzyashin's full-sized avatar
😀
Some shit

Alexey Kuzyashin Kuzyashin

😀
Some shit
View GitHub Profile
@Kuzyashin
Kuzyashin / step_dna.py
Created November 17, 2018 20:20
step_dna.py
s = str(input())
l = len(s)-1
c = 1
t = ''
if len(s) == 1:
t = t + s +str(c)
else:
for i in range(0,l):
if s[i] == s[i+1]:
c += 1
@Kuzyashin
Kuzyashin / find_remoteness_btw_cords.sql
Created May 26, 2019 08:09
find_remoteness_btw_cords.sql
CREATE or REPLACE FUNCTION find_remoteness_btw_cords(lat1 double precision, lng1 double precision, lat2 double precision, lng2 double precision)
RETURNS double precision
LANGUAGE plpgsql AS $$
BEGIN
RETURN ACOS(SIN(PI()*lat1/180.0)*SIN(PI()*lat2/180.0)+COS(PI()*lat1/180.0)*COS(PI()*lat2/180.0)*COS(PI()*lng2/180.0-PI()*lng1/180.0))*6367000;
END;
$$;
@Kuzyashin
Kuzyashin / django_pagination.py
Created June 30, 2019 13:24
django_pagination
class ImageListView(ListView):
model = Image
template_name = "main/image_list.html"
paginate_by = 10
def get_context_data(self, **kwargs):
context = super(ImageListView, self).get_context_data(**kwargs)
image_list = Image.objects.all()
paginator = Paginator(image_list, self.paginate_by)
@Kuzyashin
Kuzyashin / template.html
Created June 30, 2019 13:29
template.html
{% if is_paginated %}
<ul class="pagination">
{% if page.has_previous %}
<li>
<span><a href="?page={{ page.previous_page_number }}">Previous</a></span>
</li>
{% endif %}
<li class="">
<span>Page {{ page.number }} of {{ page.paginator.num_pages }}.</span>
</li>
class RealtyObjectAdmin(admin.ModelAdmin):
list_display = ['realty_complex',
'square', 'rent_available',
'floor', 'flat_number', 'rent_price_eur']
search_fields = ['realty_complex', ]
autocomplete_fields = ('realty_complex', )
fieldsets = (
(None, {
'fields': (('realty_complex', 'created_at', 'photo', ),
SELECT
*
FROM profiles_courier
LEFT JOIN (SELECT ---- ДЖойним заказы с выручкой/предоплатой за последние 7 дней исключая now() - 1 day
courier_id,
count(orders.id) cashorders, -- Всего заказов
sum(declared_value) cashsum, -- Общая сумма
max(declared_value) maxcash -- Максимальная сумма в 1 заказе
@Kuzyashin
Kuzyashin / brew-redis-macos.md
Created July 24, 2020 15:21
brew-redis-macos.md

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@Kuzyashin
Kuzyashin / user-data.sh
Last active August 3, 2020 10:04
user-data.sh
#!/usr/bin/env bash
#
# Get the value of a tag for a running EC2 instance.
#
# This can be useful within bootstrapping scripts ("user-data").
#
# Note the EC3 instance needs to have an IAM role that lets it read tags. The policy
# JSON for this looks like:
#
# {
@Kuzyashin
Kuzyashin / library.md
Created September 15, 2021 13:41 — forked from Rheola/library.md
Материалы по Go (golang)