This file contains hidden or 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 json | |
import os | |
import random | |
from nats.aio.client import Client as NATS | |
from stan.aio.client import Client as STAN | |
import asyncio | |
class EventBus: |
This file contains hidden or 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 traceback | |
from asgiref.sync import sync_to_async | |
from ms_foobar_app.constants import EventSubjects, QueueGroupName | |
from ms_foobar_app.events.event_bus_root import EventBus | |
from ms_foobar_app.models import User | |
from ms_foobar_app.serializers import UserSerializer | |
from ms_foobar_app.utils.utilities import snake_case_dict_to_camel |
This file contains hidden or 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 django.utils.deprecation import MiddlewareMixin | |
# NOTE: This is not best practise, however, api requests from some browser would fail continuous so explains the use | |
# of this. Enhance this CSRF solution if necessary | |
class DisableCsrfCheck(MiddlewareMixin): | |
def process_request(self, req): | |
attr = '_dont_enforce_csrf_checks' | |
if not getattr(req, attr, False): | |
setattr(req, attr, True) |
This file contains hidden or 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
package com.codephillip.hello; | |
public class Main { | |
public static void main(String[] args) { | |
divider(); | |
} | |
} | |
This file contains hidden or 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 download_invoice(self, request, pk=None): | |
""" | |
Download Invoice Endpoint | |
--- | |
omit_serializer: True | |
omit_parameters: | |
- query | |
""" | |
current_url = '{}?{}'.format( | |
reverse(request.resolver_match.url_name, kwargs={'pk': pk}), |
This file contains hidden or 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
QUESTION 5 | |
CREDIT: http://www.cs.unc.edu/~stotts/COMP204/refactor/chap1.html | |
TIME: 15 minutes | |
Refactor the following code | |
public class DomainObject { | |
public DomainObject (String name) { | |
_name = name; |
This file contains hidden or 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
QUESTION 4 | |
TIME: 5 minutes | |
What will be the output of this code? | |
var x = 21; | |
var girl = function () { | |
console.log(x); | |
var x = 20; |
This file contains hidden or 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
QUESTION 3 | |
TIME: 5 minutes | |
Consider the following code. What will the output be, and why? | |
(function () { | |
try { | |
throw new Error(); | |
} catch (x) { | |
var x = 1, y = 2; |
This file contains hidden or 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
QUESTION 2 | |
TIME: 5 minutes | |
What is the output of this line of code? | |
console.log((function x(n){return ((n > 1) ? n * x(n-2) : n)})(10)); |
This file contains hidden or 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
QUESTION 1 | |
TIME: 10 minutes | |
Number is a palindrome if it is equal to the number with digits in reversed order. For example, 5, 44, 171, 4884 are palindromes and 43, 194, 4773 are not palindromes. | |
Write a method palindrome_chain_length which takes a positive number and returns the number of special steps needed to obtain a palindrome. The special step is: "reverse the digits, and add to the original number". If the resulting number is not a palindrome, repeat the procedure with the sum until the resulting number is a palindrome. | |
If the input number is already a palindrome, the number of steps is 0. | |
Input will always be a positive integer. | |
For example, start with 87: |