Skip to content

Instantly share code, notes, and snippets.

View aliev's full-sized avatar
🎯
Focusing

Ali Aliyev aliev

🎯
Focusing
View GitHub Profile
package main
func gen(f int) chan int {
// Creating non-buffered channel
c := make(chan int)
go func() {
for i := 0; i < f; i++ {
// This part of the code will be blocked until someone will read from c channel.
c <- i
class Node:
def __init__(self, value, key=None, next=None, prev=None):
self.value = value
self.next = next
self.prev = prev
self.key = key
class LRUCache:
@aliev
aliev / gist:c11c141493c66326ef76275b549e80b6
Created December 25, 2018 14:51 — forked from ragtime/gist:2cfb981fbc5676182d64
simple example of a group definition for the relational algebra calculator
group: bank example
description[[ the data for this dataset was generated using <http://www.generatedata.com/>
* the relation _Customers_ contains basic information about the customers of the bank.
* the relation _Accounts_ contains the basic information of a single account. Note that a customer can have any number of accounts.
* the relation _PremiumCustomers_ contains the customer-ids of all customers with a total balance over 1000
]]
Customers = { cid firstname lastname
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aliev
aliev / join_promotion
Created April 2, 2018 04:00 — forked from akaariai/join_promotion
Django join promotion
=========================
Join promotion in the ORM
=========================
[NOTE: We need better terms than promote and demote for changing the join
type. These terms are extremely easy to mix up. Maybe the ORM methods could
be to_inner_joins and to_louter_joins instead of promote_joins and demote_joins?
I tried to clean up the mis-usages of promotion/demotion but there could still
be some cases where these are mixed up]
@aliev
aliev / migrations.md
Last active July 23, 2019 05:21 — forked from majackson/migrations.md
Django migrations without downtime

Good article also here: http://pankrat.github.io/2015/django-migrations-without-downtimes/

Django Migrations without Downtime

The following instructions describe a set of processes allowing you to run Django database migrations against a production database without having to bring the web service down.

Note that in the below instructions, migrations are all run manually at explicit points, and are not an automatic part of the deployment process.

Adding Fields or Tables

from django import template
register = template.Library()
@register.simple_tag
def url_encode(request, **kwargs):
"""
For example, on the page, we have
1. filters,
# Terminal
set -g default-terminal "screen-256color"
# No delay for escape key press
set -sg escape-time 0
# Enable mouse
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
@aliev
aliev / .settings
Last active September 10, 2015 16:51
Django project specific options for Vim
"let g:django_settings_module=".settings."
let $PYTHONPATH=""
if !exists("g:django_settings_module")
let $DJANGO_SETTINGS_MODULE = printf("%s.settings", split(getcwd(), '/')[-1:][0])
else
let $DJANGO_SETTINGS_MODULE = g:django_settings_module
endif