Skip to content

Instantly share code, notes, and snippets.

Avatar
😀
Some shit

Alexey Kuzyashin Kuzyashin

😀
Some shit
View GitHub Profile
@Kuzyashin
Kuzyashin / library.md
Created Sep 15, 2021 — forked from Rheola/library.md
Материалы по Go (golang)
View library.md
View 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:
#
# {
View 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
View admin.py
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', ),
View 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>
View django_pagination.py
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 / find_remoteness_btw_cords.sql
Created May 26, 2019
find_remoteness_btw_cords.sql
View 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;
$$;
View 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
View fuck.sql
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 заказе