Skip to content

Instantly share code, notes, and snippets.

Avatar
🐙
eight times a thing

Ben Stähli benzkji

🐙
eight times a thing
View GitHub Profile
@benzkji
benzkji / search_indexes.py
Last active Jun 20, 2019
filer haystack pdf integration
View search_indexes.py
# full of prints, forgive me ;-)
# coding: utf-8
from __future__ import unicode_literals
import os
from pdfminer.pdfdocument import PDFEncryptionError
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
View backboneView.js
define("text", ["module"], function(t) {
"use strict";
var e, a, i = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0"], o = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, s = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im, r = "undefined" != typeof location && location.href, n = r && location.protocol && location.protocol.replace(/\:/, ""), d = r && location.hostname, h = r && (location.port || void 0), m = [], l = t.config && t.config() || {};
return e = {
version: "2.0.1",
strip: function(t) {
if (t) {
t = t.replace(o, "");
var e = t.match(s);
e && (t = e[1])
View gitea stack trace
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 362 bytes | 362.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: runtime/cgo: pthread_create failed: Resource temporarily unavailable
remote: SIGABRT: abort
remote: PC=0x1261fd8 m=11 sigcode=18446744073709551610
remote:
remote: goroutine 0 [idle]:
@benzkji
benzkji / cms_plugins.py
Created Oct 31, 2018
move first / last cms plugin context menu
View cms_plugins.py
# add to your normal cms_plugins.py whateverplugin
class DemoPlugin(CMSPluginBase):
model = Demo
...
def get_plugin_urls(self):
@benzkji
benzkji / search_indexes_untranslated.py
Created Nov 6, 2017
search_indexes_untranslated.py haystack aldryn_search
View search_indexes_untranslated.py
from aldryn_search.search_indexes import TitleIndex
from cms.models import CMSPlugin
from djangocms_misc.global_untranslated_placeholder.utils import get_untranslated_default_language
class UntranslatedTitleIndex(TitleIndex):
def get_plugin_queryset(self, language):
queryset = CMSPlugin.objects.filter(
language=get_untranslated_default_language()
@benzkji
benzkji / rename-tables-for-django.py
Last active Dec 6, 2017
rename-tables-for-django.py (needed for updates to django-cms 3.0)
View rename-tables-for-django.py
=> ./manage.py datamigration your_app rename_plugin_tables
def rename_tables(db, table_mapping, reverse=False):
"""
renames tables from source to destination name, if the source exists and the destination does
not exist yet.
"""
from django.db import connection
if reverse:
@benzkji
benzkji / admin.py
Last active Oct 14, 2017 — forked from wullerot/admin.py
django-modeltranslation-language-tabs
View admin.py
from __future__ import unicode_literals
from django.conf import settings
class LanguageTabsMixin(object):
change_form_template = 'admin/modeltranslation/change_form.html'
def change_view(self, request, object_id, form_url='', extra_context=None):
context = extra_context or {}
@benzkji
benzkji / hvad2modeltranslation.py
Created Oct 8, 2017
hvad2modeltranslation.py
View hvad2modeltranslation.py
def migrate_to_modeltranslation(queryset, fields):
"""
to be used in data migrations, for migrating nani/hvad to modeltranslation
:param queryset:
:param fields:
:return:
"""
if not queryset.count():
@benzkji
benzkji / jquery-plugin-base.js
Last active Sep 8, 2017
A simple construct for having jquery plugins with state
View jquery-plugin-base.js
var WhatEverPlugin = (function ($) {
'use strict';
var $plugins;
// public api
var api = {
reset_all: reset_all,
reset_by_selector: reset_by_selector
};
@benzkji
benzkji / convert_to_ckeditor_link.py
Created Sep 6, 2017
management command, for converting form old school djangocms-text-ckeditor img tags to django-ckeditor-link style
View convert_to_ckeditor_link.py