Skip to content

Instantly share code, notes, and snippets.

frnhr /
Last active October 28, 2020 17:10 — forked from ObserverOfTime/
A form field to handle validation of image + svg, Django 3.1
from django.core import validators
from lxml import etree
from django.core.exceptions import ValidationError
from django.forms import ImageField
# monkeypatch allowed file extensions:
_original = validators.get_available_image_extensions
validators.get_available_image_extensions = lambda: _original() + ["svg"]
frnhr /
Created January 30, 2017 20:09
StopLight IO workflow for hosted docs from Django Rest Framework docstrings


One-time only.

  1. We export a Swagger spec file (api_swagger.json) from DRF code and import it into StopLight as a new API, first version.
  2. Commit this file on dev branch on GitHub.
  3. In StopLight we make any necessary changes:
    • assign groups to the API endpoints
    • we should not edit descriptions that were imported, because of possible Git merge conflicts later on
  4. Export a Swagger spec file from StopLight.
frnhr / gist:b9d597458c73c7a33f1bc18f0dc652e5
Created May 3, 2016 13:43 — forked from marcoslhc/gist:3909289
Using node.js in webfaction
#taken from //
#the "forever" part taken from //
#thanks to [Ryan s]( and [Dave Stevens](
mkdir -p $HOME/src
cd $HOME/src
wget ''
tar -xzf node-v0.8.9.tar.gz
cd node-v0.8.9
frnhr / .bash_profile
Created March 17, 2016 22:39
Show current pyenv python version in bash prompt, and also color virtual envs differently
#### pyenv-virtualenv bash prompt customization
# pyenv
eval "$(pyenv init -)"
# pyenv-virtualenv:
frnhr / gist:84a6593459986cce3ebc
Created July 31, 2015 06:55
Usage patterns for MeteoDoc2CSV
MeteoDoc2CSV 0.0.1
Parse Word files of a proprietary format into CSV files.
Usage: <input_file>... [-o=<output_file>] <input_file>... [--append=<append>] [--prepend=<prepend>] -d <input_dir> [--append=<append>] [--prepend=<prepend>] [--join] (-h | --help) --version
frnhr / qtranslate_cleanup.sql
Last active October 28, 2020 07:56
clean database after qTranslate uninstall
# create temp column to separate post content on <!--more--> tag to simplify queries
ALTER TABLE `wp_posts` ADD `tmp_excerpt` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
# split content
## fill `tmp_exceprt` column
UPDATE wp_posts SET tmp_excerpt =
frnhr / uncheckable_radio.js
Created November 1, 2012 00:08
uncheckable radio buttons
* Uncheckable radio buttons o_O
* usage:
* <input type="radio" name="something" class="uncheckable" />
$('input[type=radio].uncheckable').on('click', function(event){
var $this = $(this);
var was_checked = $'checked');
$('input[name='+$this.prop('name')+']').data('checked', false);