Skip to content

Instantly share code, notes, and snippets.

View dkdndes's full-sized avatar

Peter dkdndes

View GitHub Profile
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;
@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,
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 / 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")
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.
<!DOCTYPE html>
<meta charset="utf-8" />
<title>WebSocket Test</title>
<script language="javascript" type="text/javascript">
var wsUri = "ws://echo.websocket.org/";
var output;
@dkdndes
dkdndes / fontawesome_icons_free.json
Created February 25, 2020 20:12
Font Awesome Icons in Python JSON
# -*- coding: utf-8 -*-
# This file was generated automatically by fontawesome-python
#
# $ python fontawesome/generate.py > fontawsome.json
#
# It contains the icon set from: https://github.com/FortAwesome/Font-Awesome
# The content is licensed under the SIL OFL 1.1: http://scripts.sil.org/OFL
VERSION = 'master'

What is Visual Studio Code?

“Visual Studio Code is a lightweight source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (such as C++, C#, Java, Python, PHP, Go) and runtimes (such as .NET and Unity).” ~ Visual Studio Code

What is Homebrew?

Homebrew is a free and open-source software package management system for the Apple’s macOS operating system. It is known as „the missing package manager for macOS“; like „apt“ or „apt-get“ on Linux OS.

Quick Commands

# users = queryset.values_list('group', 'username').distinct()
users = [('admin', 'root'), ('group1', 'andy'), ('group1', 'tim')]
grouped_users = reduce(lambda d, (k, v): dict(d, **{k: d.get(k, [])+[v]}), users, {})
print grouped_users # {'admin': ['root'], 'group1': ['andy', 'tim']}
choices = map(lambda (k, v): (k, [('%s_%s' % (k, x), x) for x in v]), grouped_users.items())
print choices # [('admin', [('admin_root', 'root')]), ('group1', [('group1_andy', 'andy'), ('group1_tim', 'tim')])]