Skip to content

Instantly share code, notes, and snippets.

Andrej1A /
Created March 5, 2023 19:55 — forked from sarmbruster/
Run Neo4j in a docker container together with apoc and Bloom installed.
# 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 (
# (c) Stefan Armbruster
Andrej1A /
Created June 1, 2022 18:39 — forked from leogsilva/
How to discover ip from hosts inside terraform.tfstate. Execute --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
Andrej1A /
Created May 17, 2022 17:54 — forked from jeffjohnson9046/
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]);
return bb.array();
import android.view.View
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.Observer
import androidx.viewbinding.ViewBinding
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 /
Created February 14, 2019 10:51 — forked from emil2k/
Android utility class for checking device's network connectivity and speed.
* Copyright (c) 2017 Emil Davtyan
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
Andrej1A /
Created February 2, 2019 19:58 — forked from isaac-jordan/
An updated version of django-premailer that works with Django 1.9 and Python 3.
# Put in 'templatetags' folder in your Django app.
from __future__ import absolute_import
from django import template
from django.utils.encoding import smart_text
from django.contrib.staticfiles import finders
from import staticfiles_storage
from django.conf import settings
from premailer import Premailer
Andrej1A /
Created May 23, 2017 05:31 — forked from jseabold/
Use Google Translate API from Python
# -*- coding: utf-8 -*-
You need to fill in your API key from google below. Note that querying
supported languages is not implemented.
Language Code
-------- ----
Afrikaans af
Albanian sq
Arabic ar
Andrej1A /
Created May 8, 2017 03:18 — forked from artschwagerb/
Django Database Routers Master-Slave
import random
class MasterSlaveRouter(object):
def db_for_read(self, model, **hints):
Reads go to a randomly-chosen slave.
return random.choice(['master','slave1', 'slave2'])
def db_for_write(self, model, **hints):
Andrej1A /
Created April 11, 2017 06:45 — forked from fiee/
fabric for deployment of django apps on Debian servers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
fabfile for Django
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle)
several additions, corrections and customizations, too