This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.7-alpine | |
MAINTAINER London App Developer Ltd. | |
ENV PYTHONUNBUFFERED 1 | |
# Install dependencies | |
COPY requirements.txt ./ | |
RUN pip install -r requirements.txt | |
# Setup directory structure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to display only interesting fields for a Django Rest Framework API | |
# /?fields=field1,field2,field3 | |
from rest_framework import serializers, pagination | |
class DynamicFieldsModelSerializer(serializers.ModelSerializer): | |
""" | |
A ModelSerializer that takes an additional `fields` argument that | |
controls which fields should be displayed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo mkdir /var/www/www.example.com | |
sudo nano /etc/apache2/sites-available/www.example.com.conf | |
<VirtualHost *:80> | |
ServerName www.example.com | |
DocumentRoot /var/www/www.example.com | |
<Directory /var/www/www.example.com> | |
AllowOverride All | |
</Directory> | |
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName xyz.example.com | |
ServerAdmin [email protected] | |
ErrorLog /var/www/web.example.com/error.log | |
CustomLog /var/www/web.example.com/access.log combined | |
Alias /static /var/www/web.example.com/static | |
<Directory /var/www/web.example.com/static> | |
Require all granted | |
</Directory> | |
<Directory /var/www/web.example.com/example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_nearest_cities(lat, lng, in_radius): | |
earth_radius = 6371 | |
cities = Location.objects.filter().annotate( | |
distance=earth_radius * ACos(Cos(Radians(lat)) * Cos(Radians("latitude")) * Cos( | |
Radians("longitude") - Radians(lng)) + Sin(Radians(lat)) * Sin( | |
Radians('latitude')))).filter(distance__lt=in_radius).order_by("distance") | |
return cities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JSONViewMixin(object): | |
def json_response(self, data, status=200): | |
return JSONResponse(self.request, data, status=status) | |
class DataTableView(JSONViewMixin, View): | |
def get(self, request, *args, **kwargs): | |
params = request.GET | |
sort_col_num = params.get('iSortCol_0', 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
label | |
input#test-checkbox type="checkbox" | |
|Test checkbox | |
table#test-table | |
javascript: | |
$(document).ready(function() { | |
var table = $("#test-table").dataTable( { | |
"ajaxSource": '#{test_datatable_path}', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const CommonMixin = { | |
data() { | |
return { | |
dialog: false, | |
snackbar: { | |
show: false, | |
message: null, | |
color: null | |
}, | |
search: "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requiredRule: [v => !!v || "This Field is required."], | |
if (this.$refs.accountForm.validate()) { | |
} | |
<v-form ref="accountForm"> | |
<v-text-field | |
v-model="account.father_name" | |
label="Father Name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE `table_name` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; |
OlderNewer