Skip to content

Instantly share code, notes, and snippets.

View AndreasDickow's full-sized avatar
🎯
Focusing

BIZ Factory GmbH AndreasDickow

🎯
Focusing
View GitHub Profile
@AndreasDickow
AndreasDickow / tests.py
Created March 29, 2023 09:12
Django Unit Test Templatetags: how to circumvent the WSGIRequest has no attribute 'request' Problem
class CustomTagTestCase(BaseTestCase):
"""_summary_: includes tests of custom templatetags from templatetags/custom_tags.py
Args:
BaseTestCase (_type_): _description_
"""
def test_count_session_time(self):
"""_summary_: test clean_text
@AndreasDickow
AndreasDickow / gist:efbbed745cb5e441ede92024a60fd70f
Created February 28, 2023 15:00
deployment from gitlab-ci with password protected ssh private key file
deploy to staging:
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/alpine:3.17.2
stage: deploy
before_script:
- "apk add openssh-client"
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo '#!/bin/sh' > ~/.ssh/tmp
- echo 'echo $SSH_PRIV_KEY_PASS' >> ~/.ssh/tmp && chmod 700 ~/.ssh/tmp
@AndreasDickow
AndreasDickow / views.py
Last active May 12, 2024 17:25
Fix object has no attribute 'object_list' when post create duplicate in Django-Tables2 ListView
class mylist(SingleTableMixin, FilterView):
...
def get_context_data(self, **kwargs):
queryset = kwargs.pop('object_list', None)
if queryset is None:
self.object_list = self.model.objects.all()
...
return super().get_context_data(**kwargs)
@AndreasDickow
AndreasDickow / base.py
Last active December 5, 2019 09:58
Set default schema for Postgresql DB in django
# with this trick it is possible to install django on schema access restricted databases
# within project root create folders like
# -app
# -pg
# |
# - __init__.py
# - base.py
from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper
@AndreasDickow
AndreasDickow / Apache FOP Maven Dependency Issues.md
Last active April 3, 2019 15:21
Solves dependency issues when adding apache fop to maven project

If you get errors like serializer.jar (No such file or directory) or xbean.jar (No such file or directory) when running a maven project with Apache FOP Usage , then try to change

<dependency>
            <groupId>org.apache.xmlgraphics</groupId>
            <artifactId>fop</artifactId>
            <version>2.3</version>
</dependency>

to

@AndreasDickow
AndreasDickow / variable.service.ts
Created September 12, 2017 10:01
Ionic2 check if Component is already in Navigation Stack
isAlready(name:string):number{
if(name in this.viewcomponents)
{
let comp = this.viewcomponents[name];
let views = this.nav.getViews();
return views.map(function(x) {return x.component; }).indexOf(comp);
}
return -1;
@AndreasDickow
AndreasDickow / app.scss
Created August 18, 2017 16:15
Fix IOS ionic2 app flicker when ion-input focused and keyboard typing
ion-app > .app-root > ion-nav > registerview > ion-content > .scroll-content,
ion-app > .app-root > ion-nav > creategroupview > ion-content > .scroll-content{
-webkit-overflow-scrolling: initial;
will-change: initial;
}
@AndreasDickow
AndreasDickow / filters.py
Created August 18, 2017 09:36
Django Rest Filter exclude CSV in url
class NumberInFilter(django_filters.BaseInFilter, django_filters.NumberFilter):
pass
class UsernameFilter(filters.FilterSet):
username = django_filters.CharFilter(lookup_expr='icontains')
id = NumberInFilter(name='id', lookup_expr='in',exclude=True)
class Meta:
model = User
fields = ['username','id']
@AndreasDickow
AndreasDickow / imagetools.py
Created August 11, 2017 08:59
PIL EXIF Fix for all 9 orientations
EXIF_ORIENTATION = 0x0112
def _orientation(image):
ret = {}
try:
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
@AndreasDickow
AndreasDickow / views.py
Created August 9, 2017 10:19
Angular2 Image Upload to Django Rest Framework with FormData
class ProfileViewSet(viewsets.ModelViewSet):
parsers = [parsers.MultiPartParser, parsers.FormParser]
queryset = Profile.objects.all()
serializer_class = ProfileSerializer
permission_classes = [
user_permissions.IsProfileOwner
]