Skip to content

Instantly share code, notes, and snippets.

SELECT relname, reltuples FROM pg_class order by reltuples desc;
@bulv1ne
bulv1ne / .swiftlint.yml
Last active June 19, 2021 09:57 — forked from Baza207/.swiftlint.yml
Default rules for SwiftLint.
disabled_rules: # rule identifiers to exclude from running
- line_length
- force_cast
- trailing_whitespace
- todo
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- fastlane

Keybase proof

I hereby claim:

  • I am bulv1ne on github.
  • I am od1n (https://keybase.io/od1n) on keybase.
  • I have a public key whose fingerprint is 5D6F 8393 B743 1AA2 399B AD3E 9235 0ED2 2B51 1A0E

To claim this, I am signing this object:

from typing import List
from .models import Customer
def bulk_fetch_customer(ids:List[int]) -> List[Customer]:
hash_table = {
instance.pk: instance
for instance in ModelClass.objects.filter(id__in=ids)
}
instances = []
{% load i18n static %}
{% get_current_language as LANGUAGE_CODE %}
<!doctype html>
<html lang="{{ LANGUAGE_CODE }}">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="{% static 'main.css' %}">
from django.utils.decorators import method_decorator
./configure --enable-python3interp=yes \
            --with-python3-config-dir=/usr/local/lib/python3.6/config-3.6m-x86_64-linux-gnu \
            --prefix=/home/ec2-user/
#!/usr/bin/env python
import argparse
import sys
def line_numbers(lnos):
l = []
for lno in map(lambda v: v.split('-'), lnos.split(',')):
try:
@bulv1ne
bulv1ne / random.py
Created May 20, 2017 11:32
Django random templatetag for random integers (mainly used in cache busting)
import random
from django import template
register = template.Library()
@register.simple_tag
def random_int(a, b=None):
'''
@bulv1ne
bulv1ne / admin.py
Last active December 1, 2022 00:40
Django MultipleChoiceField JSONField
from django.contrib import admin
from django.template.loader import render_to_string
from .forms import UserRoleAdminForm
from .models import UserRole
@admin.register(UserRole)
class UserRoleAdmin(admin.ModelAdmin):
list_display = ('name', 'fields_data',)