DjangoCMS and ManifestStaticFilesStorage

  • https://docs.djangoproject.com/en/2.1/ref/contrib/staticfiles/#ManifestStaticFilesStorage
  • Allows to remove hashing from the webpack setup which is convenient
  • Allows to also hash images via {% static 'path/to/asset.jpg' %}, respectively assets that are not bundled via webpack
  • Hashing is only active if debug is False
  • The collectstatic will fail if any app that includes static assets in templates is not in INSTALLED_APPS
  • On production, collectstatic will also sometimes fail, in such cases, DEBUG has to be turned on, ./manage.py collectstatic has to be run, then DEBUG can be turned off again. See https://github.com/divio/djangocms-text-ckeditor/issues/474

NEO python Shortcuts

Installation

  • create a python virtualenv
  • pip install neo-python

Usage

  • np-prompt in your console

Private Network Setup

  • docker pull cityofzion/neo-privatenet (see https://github.com/CityOfZion/neo-privatenet-docker)
  • np-prompt -p connects to your docker private network
  • then you can import the wallet that is provided in the documentation. It has already all the NEO and GAS.

Clean up Jenkins to save disk space

-> Manage Jenkins -> Script Console

from https://gist.github.com/pkouman/c987ce8cd622820cce9111ea34662c6b

MAX_BUILDS = 10 // max builds to keep

def jobs = Jenkins.instance.items;

for (job in jobs) {
    println "Job: " + job.name
    def recent = job.builds.limit(MAX_BUILDS)
    println "Recent Builds: "  + recent
    println "============================="
    for (build in job.builds) {
        if (!recent.contains(build) && !build.isBuilding()) {
            println "Deleting: " + build
            build.delete()
            println ""
        }
    }
}

replace raven with sentry-sdk

since raven is now deprecated, this is how we should integrate sentry into our django projects: via the new pip install sentry-sdk:

settings.py: No more messing around with LOGGING is required, the following code plugs right into django:

import sentry_sdk
import logging
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration

sentry_sdk.init(
   dsn="https://1234@sentry.io/123",
   integrations=[
      DjangoIntegration(),
      LoggingIntegration(
         level=logging.INFO, # Capture info and above as breadcrumbs
         event_level=None # Send no events from log messages
      )
   ],
   environment=env('DJANGO_ENV', 'develop'),
)

django makemessages and gettext pitfalls

“Fuzzy” messages for not make it into the translation. They are not considered to be translated correctly, but they are not deleted, since they are likely to be “almost correct” and just need a small update.

Part of normal translator operations is to search out any “fuzzy” messages and verify that they are either still correct (just delete the fuzzy comment, but do not delete the python-format bit) or update them and then remove the “fuzzy”.

This isn’t anything special to Django, by the way. It’s the way
gettext-backed i18n support operates.

Malcolm Tredinnick at https://groups.google.com/forum/#!msg/django-users/SjqjUhZwJzU/DaHmdwZeZLkJ

Always use the `trimmed` option:

{% blocktrans trimmed %}
You're receiving this email because you requested a password reset for your user account at {{ business_name }}.
{% endblocktrans %}

Django Project Dockerization

docker-compose.yml

version: "2"

services:
  web:
    build: "."
    ports:
      - "8000:80"
    volumes:
      - ".:/app:rw"
    command: python manage.py runserver 0.0.0.0:80

Dockerfile

FROM aldryn/base-project:py3-3.23

# System upgrade
RUN apt-get update && apt-get upgrade -yq

# Setup for ssh onto github
RUN mkdir -p /root/.ssh
ADD credentials/divio-deploy-key.pem /root/.ssh/id_rsa
RUN chmod 700 /root/.ssh/id_rsa
RUN echo "Host gitlab.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config

# Python
# we want to keep project-specific sources in the "wee" folder
ENV PYTHONPATH=/app/wee:$PYTHONPATH
COPY requirements.txt /app/
RUN pip install -r requirements.txt

# nvm environment variables
ENV NODE_VERSION=8.11.3
RUN . $NVM_DIR/nvm.sh && nvm install $NODE_VERSION

# add node and npm to path so the commands are available
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
COPY package.json /app/
RUN npm install

COPY . /app

RUN npm run build

RUN DJANGO_MODE=build python manage.py collectstatic --noinput

Das isch Züri

Das muss man über Züri einfach wissen, no excuse
– So werden in der Schweiz Freunde gemacht, gilt auch für Züri: https://www.swissinfo.ch/eng/multimedia/an-animated-guide_how-to-make-friends-with-a-swiss-person-/43930494
https://www.vice.com/de_ch/article/ex8x54/the-vice-guide-to-zurich-2014
https://www.vice.com/de_ch/article/gq3373/so-verbringst-du-den-sommer-in-zuerich-389
https://www.watson.ch/Emily+National
tagesanzeiger.ch musst Du einfach gelesen haben, sonst weisst Du nicht was hier läuft, sorry.

Das muss man in Züri (mindestens) einmal gemacht haben (vielleicht):
https://www.seeueberquerung.ch/
https://www.limmatschwimmen.ch/
https://www.nightskate.ch/

Ab in die Berge…
– Wanderungen ab Zürich: https://www.wanderungen.ch/

create ethereum keystore from private key

I havent yet found a python way of doing this but here is an npm solution:

https://ethereum.stackexchange.com/questions/11166/how-to-generate-a-keystore-utc-file-from-the-raw-private-key

npm install ethereumjs-wallet
node

then:

var Wallet = require('ethereumjs-wallet');
var key = Buffer.from('<private key>', 'hex');
var wallet = Wallet.fromPrivateKey(key);
wallet.toV3String('<empty string or password');