Skip to content

Instantly share code, notes, and snippets.

View bmihelac's full-sized avatar

Bojan Mihelac bmihelac

View GitHub Profile
<div x-data="{ count: 0, replaced: false,
message: 'Change me, then press the button!' }">
<input type="text" x-model="message">
<div x-text="count"></div>
<button x-bind:style="replaced && {'backgroundColor': '#fecaca'}"
x-on:click="replaced = true; count++"
hx-get="/swap">
Morph
</button>
</div>
@bmihelac
bmihelac / wagtail_struct_block_validation.py
Created January 5, 2017 15:28
Example validating wagtail StructBlock
from django.core.exceptions import ValidationError
from django.forms.utils import ErrorList
from wagtail.wagtailcore import blocks
class MyLinkBlock(blocks.StructBlock):
"""
Example validating StructBlock.
"""
@bmihelac
bmihelac / blocks.py
Created May 11, 2016 17:42
Wagtail FormattedDateBlock
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django import forms
from django.utils.functional import cached_property
from wagtail.wagtailcore.blocks.field_block import DateBlock
class FormattedDateBlock(DateBlock):
diff --git a/feincms/admin/tree_editor.py b/feincms/admin/tree_editor.py
index d3e040b..65e6a2a 100644
--- a/feincms/admin/tree_editor.py
+++ b/feincms/admin/tree_editor.py
@@ -235,7 +235,7 @@ class TreeEditor(admin.ModelAdmin):
Handle an AJAX toggle_boolean request
"""
try:
- item_id = int(request.POST.get('item_id', None))
+ item_id = int(requestsOST.get('item_id', None))
@bmihelac
bmihelac / django-rename-contenttypes
Created June 28, 2012 09:07
Refresh django ContentType names
# changing verbose name of model does not change ContentType name
# this script will loop through all ContentType objects and refresh names
# optional activate translation
from django.utils import translation
translation.activate('en')
from django.contrib.contenttypes.models import ContentType
content_types = ContentType.objects.all()
@bmihelac
bmihelac / import.py
Created September 30, 2015 08:34
Import management command for django-import-export
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import mimetypes
from optparse import make_option
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from django.core.management.base import BaseCommand
@bmihelac
bmihelac / i3-gaps_installation_guide.md
Created April 23, 2019 18:36 — forked from boreycutts/i3-gaps_installation_guide.md
A simple installation guide for i3-gaps

Installing i3-gaps

Dependencies

i3-gaps has some packages that are required for it to work so install these things:

sudo apt install libxcb1-dev libxcb-keysyms1-dev libpango1.0-dev libxcb-util0-dev libxcb-icccm4-dev libyajl-dev libstartup-notification0-dev libxcb-randr0-dev libev-dev libxcb-cursor-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev autoconf xutils-dev libtool automake

You also need to install libxcb-xrm-dev, but I got Unable to locate package libxcb-xrm-dev when trying to install from the apt repositories on Ubuntu 16.04. If this happens to you, just install it from source using these commands:

mkdir tmp
@bmihelac
bmihelac / NestedIntlProvider.js
Last active October 26, 2018 08:25
react-intl message lookup bubbling, see: https://github.com/yahoo/react-intl/issues/1109
import React from 'react'
import { injectIntl, IntlProvider } from 'react-intl'
/**
* Merges previous and current messages
* See: https://github.com/yahoo/react-intl/issues/1109
*/
const NestedIntlProvider = ({intl, ...props}) => {
const { messages, ...otherProps } = props
const nestedMessages = {
@bmihelac
bmihelac / gatsby-node.js
Created October 17, 2018 09:56
Copy pages starting with prefix for every language. Add lang to context.
import { getLanguageFromPath } from './utils'
exports.onCreatePage = ({ page, actions }, pluginOptions) => {
const languages = pluginOptions.languages
if (!languages) {
throw Error(
`Plugin "gatsby-plugin-i18n-pages" require languages`
)
}
const { createPage, deletePage } = actions
version: '3'
services:
db:
image: postgres:9.6.5
volumes:
- postgres_data:/var/lib/postgresql/data/
web:
build: .
command: bash -c "python /code/manage.py migrate --noinput && python /code/manage.py runserver 0.0.0.0:8000"