Skip to content

Instantly share code, notes, and snippets.

View linevych's full-sized avatar
🐴

Anton Linevych linevych

🐴
View GitHub Profile
@victorono
victorono / remove_duplicates.py
Last active April 26, 2024 17:57
Django - remove duplicate objects where there is more than one field to compare
from django.db.models import Count, Max
unique_fields = ['field_1', 'field_2']
duplicates = (
MyModel.objects.values(*unique_fields)
.order_by()
.annotate(max_id=Max('id'), count_id=Count('id'))
.filter(count_id__gt=1)
)
@codingjoe
codingjoe / django_docs.md
Last active July 24, 2022 23:16
Build Django docs like a pro!

Build Django docs like a pro!

Sphinx config

docs/conf.py

import importlib
import inspect
import os
import sys

Build a scalable Twitter clone with Django and GetStream.io

In this tutorial we are going to build a Twitter clone using Django and GetStream.io, a hosted API for newsfeed development.

We will show you how easy is to power your newsfeeds with GetStream.io. For brevity we leave out some basic Django-specific code and recommend you refer you to the Github project for the complete runnable source code. At the end of this tutorial we will have a Django app with a profile feed, a timeline feed, support for following users, hashtags and mentions.

I assume that you are familiar with Django. If you're new to Django the [official tutorial] (https://docs.djangoproject.com/en/2.0/intro/) explains it very well.

@redguardtoo
redguardtoo / .ctags.sample
Last active March 21, 2024 16:55
my ~/.ctags. Please note this is configuration for Exuberant Ctags. If you use Universal Ctags, you need run `ctags --options="$HOME/.ctags" -e -R` in shell at least once and fix all the warnings.
--c++-kinds=+p
--fields=+iaS
--extra=+q
--exclude=*/.hg/*
--exclude=.hg/*
--exclude=*/.cvs/*
--exclude=.cvs/*
--exclude=*/.svn/*
--exclude=.svn/*
--exclude=*/.git/*
@lirenlin
lirenlin / gist:9892945
Last active April 21, 2024 17:27
i3 wm, hide window title bar
@erobert17
erobert17 / bootstrap-3-vert-offset-shim.css
Last active May 2, 2022 18:36
Adds a vertical offset top and bottom to Bootstrap 3 to be used within columns. Currently no vertical offset is available as standard in Bootstrap 3.
/*
Include this after bootstrap.css. Add class of
vert-offset-top-value or vert-offset-bottom-value
to your Bootstrap 3 default rows to prevent row content
from touching the row content above or below.
*/
/* Vertical Offset Bottom */
.vert-offset-top-12{
margin-top: 12em;
@bobjackman
bobjackman / myUnmerged.sh
Last active February 22, 2017 13:55
Find all branches that have unmerged commits authored by me. This is my first attempt at a bash script, so if you have suggestions for better/clearer/faster code, please let me know!
#!/usr/bin/env bash
# usage:
# local branches only: `myUnmerged`
# remote branches only: `myUnmerged -r`
# all branches: `myUnmerged -a`
#
# example output:
#
# BRANCH TOTAL COMMITS KOGI KOGI UNMERGED
@griiettner
griiettner / Bootstrap Smooth Scroll to Anchor
Last active November 1, 2017 14:23
Bootstrap Smooth Scroll to Anchor
!function ($) {
$(function(){
$('#home, #me, #footer').carousel({});
var $root = $('html, body');
$('a').click(function() {
var href = $.attr(this, 'href');
$root.animate({
scrollTop: $(href).offset().top
@plentz
plentz / nginx.conf
Last active June 3, 2024 07:49
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048