выдержки из статьи (https://gmsservices.ru/blog/2016/03/22/programmer-interview/)
1. Следует проверить, насколько кандидат любит программирование
Разработчик из лондонского офиса Google Йон Скит (Jon Skeet) советует интервьюерам больше говорить о том, что интересно кандидату-программисту. Страсть, с которой человек говорит о своей работе и своих достижениях – самый надежный индикатор его профессионализма. Скит говорит, что за свою многолетнюю практику не встречал программиста, увлеченно рассказывающего о разработках, но не способного написать качественный код.
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
''' | |
So my layers would be like this: | |
1. Presentation Layer: Used for translation from HTTP to Python and Python to HTTP | |
2. Authentication and Authorization Layer: for identifying the user and his information and permissions | |
3. Service Layer: For executing the Business Logic | |
4. Validation Layer: For validating the integrity and constraint of the data that is gonna be store | |
5. Data Layer: Orm layer | |
1. Represented by a URL of the router function of DRF and a ViewSet of DRF as well |
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
import sys | |
import pika | |
# prerequisites are that you have RabbitMQ installed | |
# create a "darkmatter" named VirtualHost (VHOST) | |
# rabbitmqctl.bat add_vhost darkmatter | |
# create a user APP_USER with associated APP_PASS word | |
# rabbitmqctl add_user darkmatteradmin <password> | |
# give the APP_USER the necessary permissions | |
# rabbitmqctl set_permissions -p darkmatter darkmatteradmin ".*" ".*" ".*" |
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 FieldPermissionsMixin(object): | |
""" | |
A Serializer mixin for controlling which fields are included based on user permissions | |
Usage: | |
class MySerializer(FieldPermissionsMixin, serializers.ModelSerializer): | |
class Meta: | |
model = MyModel | |
field_permissions = { | |
'field': ['app.permission'], |
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
var result=[]; | |
for (var i = 0; i<5; i++){ | |
result[i] = (function(x){ | |
console.log(x); | |
})(i); | |
}; | |
result[0](); | |
result[1](); | |
result[2](); | |
result[3](); |
Пропустить теорию и перейти прямо к задачам
Ссылка на учебник: http://learn.javascript.ru
Сразу расскажу про несколько особенностей яваскрипта, о которых может быть не написано (или мало написано) в учебниках, но которые стоит понимать:
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
# views.py - django app called ajx | |
from django.shortcuts import render, get_object_or_404, redirect, HttpResponse, render_to_response, HttpResponseRedirect | |
from django.core.urlresolvers import reverse | |
from django.contrib.auth import authenticate, login | |
import json | |
def mygetview(request): | |
if request.method == 'GET': |
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
// Для отправки вормы использовать jQuery ajax forms (http://jquery.malsup.com/form/) | |
// Показывает ошибки формы | |
function show_form_errors(form, error_json) | |
{ | |
clear_form_errors(form); | |
for (name in error_json) { | |
var elem = form.find('input[name=' + name + '], textarea[name=' + name + ']'); | |
elem.closest('.control-group').addClass('error'); | |
elem.parent().prepend($('<span class="help-inline">*' + error_json[name] + '</span>')); | |
} |
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
import functools | |
import sys | |
import re | |
from django.conf import settings | |
from django.db import connection | |
def shrink_select(sql): | |
return re.sub("^SELECT(.+)FROM", "SELECT .. FROM", sql) | |
def shrink_update(sql): |