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 / 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 / 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 / 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