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 TwiMLDialConferenceView(APIView): | |
""" | |
This view responds with a Conference Dial which puts the call in scope in the specified conference room | |
""" | |
def post(self, request, *args, **kwargs): | |
response = VoiceResponse() | |
dial = Dial() | |
end_conference_on_exit = request.GET.get("end_conference_on_exit", '').lower() == 'true' | |
dial.conference(request.GET["conference_room"], end_conference_on_exit=end_conference_on_exit) | |
response.append(dial) |
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 FirstLegDisconnectedView(APIView): | |
def post(self, request, *args, **kwargs): | |
call_sid = request.POST['CallSid'] | |
conference_room = get_conference_room() # get the conference same as the customer's one | |
response = VoiceResponse() | |
dial = Dial() | |
dial.conference(request.GET["conference_room"], end_conference_on_exit=False) |
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 connect_second_agent_to_conference(cls, second_agent_number, conference_room): | |
response = TwilioClient.conferences(conference_room).participants.create( | |
from_=twilio_caller_id, | |
to=second_agent_number, | |
early_media=True | |
) | |
return response |
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 Home(object): | |
def __init__(self): | |
self._fan_state = "OFF" | |
self._fan_speed = 0 | |
def turn_fan_on(self): | |
self._fan_state = "ON" | |
def turn_fan_off(self): |
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
""" | |
Scamming the Coding Interview | |
""" | |
def generate_super_sets(power_set, elements, running_set, start_index): | |
if start_index > len(elements): | |
return |
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
""" | |
Scamming the coding interview | |
""" | |
def is_valid(sudoku_grid, i, j): | |
is_board_valid = check_the_grid(sudoku_grid, i, j) and \ | |
check_row(sudoku_grid, i, j) and \ | |
check_col(sudoku_grid, i, j) |
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
""" | |
Scamming the coding interview | |
""" | |
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' | |
memory_db = {} | |
def get_shorten_url(long_url, url_id): |
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
""" | |
Scamming the coding interview | |
""" | |
def color_graph(graph_adjacency, number_of_vertices): | |
# First vertex gets the first color | |
vertex_to_color_map = { | |
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
""" | |
Scamming the coding interview | |
""" | |
from hashlib import md5 | |
class MerkerFile(object): | |
def __init__(self): |
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
""" | |
Scamming the coding interview | |
""" | |
def generate_all_combinations(nums, combinations, start_index, running_set): | |
""" | |
Generates all the combinations a given list of numbers | |
""" | |
if start_index >= len(nums): | |
return |