Skip to content

Instantly share code, notes, and snippets.

@azimjohn
azimjohn / action_confirmation.html
Last active May 13, 2024 20:38
Django Admin Action Confirmation
{% extends "admin/base_site.html" %}
{% load i18n l10n admin_urls %}
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation
delete-selected-confirmation{% endblock %}
{% block content %}
<p>Are you sure you want to {{ action }}?</p>
<ul style="padding: 0">
{% for object in queryset.all %}
@azimjohn
azimjohn / internet-speed-logger.py
Created July 16, 2019 15:25
Internet Speed Test logger with SpeedTest CLI
# pip install speedtest-cli
import os
import csv, json
import subprocess
from datetime import datetime
res = subprocess.run(["speedtest-cli --server 6982 --json"], stdout=subprocess.PIPE, shell=True)
now = datetime.now()
@azimjohn
azimjohn / ticket.py
Created July 13, 2019 12:38
Generate ticket for event
from PIL import Image, ImageFont, ImageDraw # Pillow==6.0.0
WIDTH = 480
HEIGHT = 640
def get_font(size, is_bold=False):
"""https://fonts.google.com/specimen/Open+Sans"""
if is_bold:
@azimjohn
azimjohn / number_reader.go
Created July 9, 2019 19:28
Number Reader in Uzbek
package main
import (
"fmt"
)
func main() {
fmt.Print("Sonni kiriting: ")
var input string
fmt.Scanln(&input)
@azimjohn
azimjohn / swagger-yaml-to-html.py
Last active December 4, 2018 06:20 — forked from oseiskar/swagger-yaml-to-html.py
Converts Swagger YAML to a static HTML document (needs: pip install PyYAML)
#!/usr/bin/python
"""
Usage:
python swagger-yaml-to-html.py < /path/to/api.yaml > doc.html
"""
import yaml, json, sys
TEMPLATE = """