Skip to content

Instantly share code, notes, and snippets.

Andrej1A / CsvResponse.php
Created November 14, 2015 13:02 — forked from mathewbyrne/CsvResponse.php
A small Symfony 2 class for returning a response as a CSV file. Based on the Symfony JsonResponse class.
namespace Jb\AdminBundle\Http;
use Symfony\Component\HttpFoundation\Response;
class CsvResponse extends Response
protected $data;
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
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 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 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 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 / Android-Tint-LottieAnimationView.kt
Created September 11, 2019 14:07
Android Kotlin Tint LottieAnimationView JSON
* Tint LottieAnimationView
private fun LottieAnimationView.tintColor(@ColorInt tintColor: Int) {
{ PorterDuffColorFilter(tintColor, PorterDuff.Mode.SRC_ATOP) }
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
docker build \
--file Dockerfile \
--tag \
--build-arg DJANGO_ENV=cloud_test \
Andrej1A / Dockerfile
Created July 13, 2020 12:33
Dockerfile for Django-Application
FROM python:3.6-stretch
# 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