Skip to content

Instantly share code, notes, and snippets.

@dvl
dvl / pdf.py
Created November 8, 2017 23:57
import io
import weasyprint
from django.template.response import TemplateResponse
class PDFResponse(TemplateResponse):
def __init__(self, *args, **kwargs):
syntax on
set number
set relativenumber
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
class FilterCurrentUserMixin(object):
def get_queryset(self):
queryset = super(FilterCurrentUserMixin, self).get_queryset()
queryset = queryset.filter(user=self.request.user)
return queryset
import datetime
import io
import time
import picamera
from PIL import Image, ImageStat, ImageFont, ImageDraw
with picamera.PiCamera() as camera:
#!/bin/bash
# de-fuck mysql 5.7
# This script allow you to log on MySQL as root user without use sudo
# sudo apt install postgresql
# sudo apt purge "mysql-*"
# you know, would be better...
sudo mysql -u root -e "CREATE USER 'root2'@'localhost';"
#!/bin/bash
set -x
EMAIL=''
API_KEY=''
ZONE_ID=''
RECORD_ID=''
# -*- coding: utf-8 -*-
import mock
import requests
def make_request():
try:
return requests.get('http://httpbin.org/ip').json()['origin']
@dvl
dvl / stargazers.py
Created March 23, 2016 03:24
Choosing a Go framework with Python...
# -*- coding: utf-8 -*-
import requests
API_URL = 'https://api.github.com/repos/{owner}/{repo}'
client = requests.Session()
client.auth = ('dvl', 'xx')
client.headers.update({
'Accept': 'application/vnd.github.v3+json',
@dvl
dvl / bobp-python.md
Created November 13, 2015 20:03 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@dvl
dvl / README.md
Last active November 5, 2015 06:13 — forked from magnetikonline/README.md
IE 7/8/9/10/11/Edge Virtual machines from Microsoft - Linux w/VirtualBox installation notes.