Skip to content

Instantly share code, notes, and snippets.

View dkdndes's full-sized avatar

PR dkdndes

View GitHub Profile
A persona describes the behavior and risk profiles of a corporate customer or i.e. a Bank.
Customer Centering means holistically aligning your business with the needs of your customers while maintaining the economic interests of your own business.
@dkdndes
dkdndes / secret.py
Created July 9, 2019 09:51
Ensure unique django secret key at runtime
def ensure_secret_key_file():
"""Checks that secret.py exists in settings dir. If not, creates one
with a random generated SECRET_KEY setting."""
secret_path = os.path.join(BASE_DIR, 'secret.py')
if not os.path.exists(secret_path):
from django.utils.crypto import get_random_string
secret_key = get_random_string(
50, 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)')
with open(secret_path, 'w') as f:
f.write("SECRET_KEY = " + repr(secret_key) + "\n")
version: '3'
volumes:
whatsappMedia:
driver: local
services:
wacore:
image: docker.whatsapp.biz/coreapp:v${WA_API_VERSION:?Run docker-compose with env var WA_API_VERSION (ex. WA_API_VERSION=2.21.4 docker-compose <command> <options>)}
command: ["/opt/whatsapp/bin/wait_on_mysql.sh", "/opt/whatsapp/bin/launch_within_docker.sh"]
@dkdndes
dkdndes / iban.py
Last active July 25, 2022 07:45
IBAN check in python
import re
_country2length = dict(
AL=28, AD=24, AT=20, AZ=28, BH=22, BY=28, BE=16,
BA=20, BR=29, BG=22, CR=22, HR=21, CY=28, CZ=24,
DK=18, DO=28, EG=29, SV=28, EE=20, FO=18, FI=18,
FR=27, GE=22, DE=22, GI=23, GR=27, GL=18, GT=28,
VA=22, HU=28, IS=26, IQ=23, IE=22, IL=23, IT=27,
JO=30, KZ=20, XK=20, KW=30, LV=21, LB=28, LY=25,
LI=21, LT=20, LU=20, MT=31, MR=27, MU=30, MD=24,
function findPosX(obj) {
var curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
obj = obj.offsetParent;
}
// IE offsetParent does not include the top-level
if (isIE && obj.parentElement){
curleft += obj.offsetLeft - obj.scrollLeft;
"""This file checks, if the package is installed on the current system."""
import os
import sys
import argparse
from importlib import import_module
def main():
"""
Check if the package name is installed.
import os import os
from django.conf import settings
from django.contrib.auth import get_user_model
User = get_user_model()
print (os.environ['EMAIL'] + ' user already exists') if User.objects.filter(email=os.environ['EMAIL'],username=os.environ['USERNAME']) else User.objects.create_superuser(os.environ['USERNAME'], os.environ['EMAIL'], os.environ['PASSWORD'])
@dkdndes
dkdndes / docker_swarm_init_in_doid.sh
Last active May 29, 2018 09:01
Start a Docker Swarm Clustern within "Docker in Docker (doid)"
#!/bin/bash
# Init Swarm master
docker swarm init
# Get join token:
SWARM_TOKEN=$(docker swarm join-token -q worker)
echo $SWARM_TOKEN
# Get Swarm master IP (Docker for Mac xhyve VM IP)
@dkdndes
dkdndes / api_urls.py
Last active July 9, 2019 09:55
djstribe url missing in docu; place the code in /payments/ and /api/
# Payments
url(r'^payments/', include('djstripe.contrib.rest_framework.urls', namespace="rest_payments")),
@dkdndes
dkdndes / SpeiOneTimePayment.md
Created March 1, 2018 15:52 — forked from leofischer/SpeiOneTimePayment.md
SPEI One Time Payment

#Curl

curl --request POST \
  --url https://api.conekta.io/orders \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{
    "line_items": [{