Skip to content

Instantly share code, notes, and snippets.

@frnhr
frnhr / uncheckable_radio.js
Created Nov 1, 2012
uncheckable radio buttons
View uncheckable_radio.js
/**
* 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);
@frnhr
frnhr / qtranslate_cleanup.sql
Last active Oct 28, 2020
clean database after qTranslate uninstall
View qtranslate_cleanup.sql
# 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 / gist:84a6593459986cce3ebc
Created Jul 31, 2015
Usage patterns for MeteoDoc2CSV
View gist:84a6593459986cce3ebc
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 / .bash_profile
Created Mar 17, 2016
Show current pyenv python version in bash prompt, and also color virtual envs differently
View .bash_profile
####
#### pyenv-virtualenv bash prompt customization
####
# pyenv
eval "$(pyenv init -)"
# pyenv-virtualenv:
View gist:b9d597458c73c7a33f1bc18f0dc652e5
#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 / README.md
Created Jan 30, 2017
StopLight IO workflow for hosted docs from Django Rest Framework docstrings
View README.md

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 / svgimagefield.py
Last active Oct 28, 2020 — forked from ObserverOfTime/svgimagefield.py
A form field to handle validation of image + svg, Django 3.1
View svgimagefield.py
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"]