Skip to content

Instantly share code, notes, and snippets.

@frnhr
frnhr / svgimagefield.py
Last active October 28, 2020 17:10 — forked from ObserverOfTime/svgimagefield.py
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
frnhr / README.md
Created January 30, 2017 20:09
StopLight IO workflow for hosted docs from Django Rest Framework docstrings

Setup

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
frnhr / gist:b9d597458c73c7a33f1bc18f0dc652e5
Created May 3, 2016 13:43 — forked from marcoslhc/gist:3909289
Using node.js in webfaction
#taken from //community.webfaction.com/questions/4888/install-nodejs-with-express-framework
#the "forever" part taken from //shkfon.tumblr.com/post/27178918675/real-world-nodejs-part-1
#thanks to [Ryan s](http://community.webfaction.com/users/16/ryans/) and [Dave Stevens](http://shkfon.tumblr.com/)
mkdir -p $HOME/src
cd $HOME/src
wget 'http://nodejs.org/dist/v0.8.9/node-v0.8.9.tar.gz'
tar -xzf node-v0.8.9.tar.gz
cd node-v0.8.9
@frnhr
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
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:
meteo_doc2csv.py <input_file>... [-o=<output_file>]
meteo_doc2csv.py <input_file>... [--append=<append>] [--prepend=<prepend>]
meteo_doc2csv.py -d <input_dir> [--append=<append>] [--prepend=<prepend>] [--join]
meteo_doc2csv.py (-h | --help)
meteo_doc2csv.py --version
@frnhr
frnhr / qtranslate_cleanup.sql
Last active October 28, 2020 07:56
clean database after qTranslate uninstall
# QTRANSLATE CLEANUP QUERIES
# 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
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 = $this.data('checked');
$('input[name='+$this.prop('name')+']').data('checked', false);