Skip to content

Instantly share code, notes, and snippets.

@Andrej1A
Andrej1A / run_docker_neo4j_bloom.sh
Created March 5, 2023 19:55 — forked from sarmbruster/run_docker_neo4j_bloom.sh
Run Neo4j in a docker container together with apoc and Bloom installed.
#!/bin/sh
# start a neo4j docker container with apoc and bloom (server variant) configured
# this requires to have
# * curl, unzip and jq being installed
# * having a valid bloom license file
# released under the WTFPL (http://www.wtfpl.net/)
# (c) Stefan Armbruster
@Andrej1A
Andrej1A / terraform.py
Created June 1, 2022 18:39 — forked from leogsilva/terraform.py
How to discover ip from hosts inside terraform.tfstate. Execute terraform.py --hostfile | more in the directory containing the tfstate file. Code by cisco
#!/usr/bin/env python
#
# Copyright 2015 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@Andrej1A
Andrej1A / UuidHelper.java
Created May 17, 2022 17:54 — forked from jeffjohnson9046/UuidHelper.java
Convert UUID to byte array and vice versa. Useful for when UUIDs are stored in MySQL tables as VARBINARY(16)
import java.nio.ByteBuffer;
import java.util.UUID;
public class UuidAdapter {
public static byte[] getBytesFromUUID(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
// https://github.com/Zhuinden/fragmentviewbindingdelegate-kt
import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.Observer
import androidx.viewbinding.ViewBinding
import kotlin.properties.ReadOnlyProperty
@Andrej1A
Andrej1A / ViewLifecycleBinding.kt
Created May 4, 2021 12:45 — forked from jamiesanson/ViewLifecycleBinding.kt
Kotlin Property Delegate for Fragment view lifecycle binding
fun <T> Fragment.viewLifecycle(bindUntilEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY): ReadWriteProperty<Fragment, T> =
object: ReadWriteProperty<Fragment, T>, LifecycleObserver {
// A backing property to hold our value
private var binding: T? = null
private var viewLifecycleOwner: LifecycleOwner? = null
init {
// Observe the View Lifecycle of the Fragment
@Andrej1A
Andrej1A / start_wsgi_server.sh
Created July 13, 2020 12:35
Script to start wsgi server for Django
#!/bin/sh
# NOTE: this script will be executed inside a docker container
# parameter
# start_wsgi_server.sh dev sms_api_gateway.settings.cloud_dev
if [ $# -ne 2 ]; then
echo $0: usage: start_wsgi_server.sh DJANGO_ENV DJANGO_SETTINGS
exit 1
@Andrej1A
Andrej1A / entrypoint.sh
Created July 13, 2020 12:34
entry point for Django application
#!/bin/bash
set -e
cmd="$@"
function postgres_ready(){
python << END
import sys
import psycopg2
try:
@Andrej1A
Andrej1A / Dockerfile
Created July 13, 2020 12:33
Dockerfile for Django-Application
FROM python:3.6-stretch
ARG DJANGO_ENV=dev
ENV PYTHONUNBUFFERED 1
# Requirements have to be pulled and installed here, otherwise caching won't work
COPY ./requirements/base.txt /base.txt
COPY ./requirements/cloud_production.txt /cloud_production.txt
COPY ./requirements/${DJANGO_ENV}.txt /requirements_${DJANGO_ENV}.txt
#!/bin/bash
docker build \
--file Dockerfile \
--tag registry.andrej-albrecht.com/sms-api-gateway/sag-web-backend/cloud_test:latest \
--build-arg DJANGO_ENV=cloud_test \
.
@Andrej1A
Andrej1A / android-kotlin-custom-view-template
Last active September 25, 2019 11:41
Template for an Android custom view. The example shows a vertical dotted line.
/**
* VerticalDottedLineView
* Add to attrs.xml:
* <declare-styleable name="VerticalDottedLineView">
* <attr name="dots_color" format="color" />
* </declare-styleable>
*/
class VerticalDottedLineView : View {
private var dotColor: Int = 0