Skip to content

Instantly share code, notes, and snippets.

@che0
che0 / userChrome.css
Created January 25, 2011 19:03
userChrome.css to make Thunderbird 3.1 a bit bearable
/* other actions on e-mail toolbar */
#otherActionsButton { display: none !important; }
/* remove padding around e-mail stuffbar */
#expandedHeaderRows { padding-top: 0px !important; }
/* folder view switch */
#folderPaneHeader { display: none !important; }
toolbarbutton { font-size: 9pt !important; }
@che0
che0 / fix_plugin_languages.py
Created August 22, 2014 15:18
One-time fix of bad language info in django-cms plugin instances. Suitable for pasting info manage.py shell.
from cms.models import CMSPlugin
loop_again = True
while loop_again:
loop_again = False
lang_map = {}
for p in CMSPlugin.objects.all():
lang_map[p.id] = p.language
if p.parent_id is None:
continue
@che0
che0 / exiffield.py
Created January 4, 2015 22:25
Skeleton for a Django ImageField that lets updates other model fields with info from Exif (provided that you can extract those for yourself :-)
from django.db.models.fields.files import ImageField, ImageFileDescriptor
class ExifFileDescriptor(ImageFileDescriptor):
""" Image field descriptor that updates Exif fields on set """
def __set__(self, instance, value):
previous_file = instance.__dict__.get(self.field.name)
super(ExifFileDescriptor, self).__set__(instance, value)
if previous_file is not None:
self.field.update_exif_fields(instance, force=True)
@che0
che0 / screen.html
Created February 13, 2015 10:25
HTML page switcher for touchscreen info displays
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body { background: #ddd; font-family: sans-serif; }
iframe#page { width: 100%; height: 93%; margin: 0; padding:0; border: none; border-bottom: solid #aaa 1px; background: white; }
html, body { height:100%; margin:0; padding:0; overflow: hidden; }
#indicator { position:fixed; bottom:10px; left:10px; font-size: 5mm; text-align: center; background-color: black; color: white; padding: .65em 1em; border-radius: .3em; }
.desc { font-size: 50%; color: #aaa; white-space: pre-wrap; }
#directs { position:fixed; bottom:10px; right:10px; padding: 0 .5em 0 0; text-align: center; font-size: 5mm; }
@che0
che0 / zlobot-afd-notices.py
Created August 28, 2016 23:36
pywikibot script that handles AfD notifications on Czech Wikipedia
# -*- coding: utf-8 -*-
import datetime
import pywikibot
import time
import sys
import re
import logging
logger = logging.getLogger("pywiki")
@che0
che0 / nadace.md
Last active December 22, 2018 20:33
Seznam rozličných nadací

Seznam rozličných nadací

Název telefon web co
Hestia, o.s. 224872075 http://www.hest.cz/cz/co-delame/darcovsky-program-etela osobní, osobní asistence, pomůcky, léčebné výlohy
Nadace Charty 77 - Konto Bariéry 224230216 224225092 224214452 www.bariery.cz osobní, motorové vozidlo, osobní asistence, pomůcky, léčebné výlohy
Nadace Dagmar a Václava Havlových VIZE 97 234097811 www.vize.cz osobní, pomůcky, léčebné výlohy
Nadace Dětský mozek 603258852 326303770 www.detskymozek.cz osobní, osobní asistence, pomůcky
Nadace KB, a.s. - Jistota www.nadacejistota.cz osobní, pomůcky
@che0
che0 / pandas-cheat-sheet.md
Last active February 8, 2019 14:42
cheat sheet for pandas, so I don't have to read the docs all the time

Pandas cheat sheet

  • dataframe from records: pd.DataFrame.from_records([['A', 4], ['B', 2]], columns=['g', 'legs'], index=['g'])
  • (un)pickle: orders.to_pickle('saved.pkl'); pd.read_pickle('saved.pkl')
  • filter data frame per (part of) index: frame.loc[580]
  • timestamp: pd.Timestamp('2017-05-01')
  • random sample: frame.sample(n=20, random_state=42)
  • columns list: list(frame.columns)
  • rename columns: frame.rename({'from': 'to'})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@che0
che0 / dedicnost.py
Last active March 24, 2019 20:30
Přenesení do nadtřídy na příkladu per-object pole v ModelAdminu
from django.contrib import admin
class PredtimModelAdmin1(admin.ModelAdmin):
def predim_get_formfield1(self, db_field, request, obj, **kwargs):
return buhvico_1
def get_form(self, request, obj=None, change=False, **kwargs):
...
defaults = {
'form': form,
@che0
che0 / szn-photos.geojson
Created August 6, 2019 13:48
szn photos
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.