Skip to content

Instantly share code, notes, and snippets.

@nikhilym
nikhilym / The Technical Interview Cheat Sheet.md
Last active September 13, 2017 16:07 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@nikhilym
nikhilym / jinja2_file_less.py
Created July 25, 2018 23:29 — forked from wrunk/jinja2_file_less.py
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@nikhilym
nikhilym / elicit_slot_handler_example.py
Last active September 6, 2018 11:19
Adding ElicitSlotDirective through ASK Python SDK
## Example directive, from https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#elicitslot
from ask_sdk_model.dialog import ElicitSlotDirective
from ask_sdk_model import (
Intent, IntentConfirmationStatus, Slot, SlotConfirmationStatus)
directive = ElicitSlotDirective(
slot_to_elicit="fromCity",
updated_intent=Intent(
name="planMyTrip",
@nikhilym
nikhilym / progressive_response_skill.py
Last active September 28, 2022 14:47
Example usage of Progressive Response in ASK Python SDK
from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.api_client import DefaultApiClient
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.dispatch_components import AbstractExceptionHandler
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_model.ui import SimpleCard
from ask_sdk_model.services.directive import (
SendDirectiveRequest, Header, SpeakDirective)
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model.response import Response
@nikhilym
nikhilym / display_check.py
Created August 24, 2018 22:00
Display check in ASK Python SDK
def is_display_supported(handler_input):
# type: (HandlerInput) -> bool
"""Check if display is supported by the skill."""
try:
if hasattr(handler_input.request_envelope.context.system.device.supported_interfaces, 'display'):
return handler_input.request_envelope.context.system.device.supported_interfaces.display is not None
except:
return False
@nikhilym
nikhilym / render_template_directive_skill.py
Created August 24, 2018 22:04
Render Template usage in skill with ASK Python SDK
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_core.utils import is_intent_name
from ask_sdk_core.response_helper import get_plain_text_content
from ask_sdk_model.response import Response
from ask_sdk_model.interfaces.display import (
ImageInstance, Image, RenderTemplateDirective,
BackButtonBehavior, BodyTemplate2)
from ask_sdk_model import ui
@nikhilym
nikhilym / audioplayer_sample.py
Created August 24, 2018 23:16
AudioPlayer play, stop stream handlers using ASK Python SDK
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.utils import is_intent_name
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model.response import Response
from ask_sdk_model.ui import StandardCard, Image, SimpleCard
from ask_sdk_model.interfaces.audioplayer import (
PlayDirective, PlayBehavior, AudioItem, Stream, AudioItemMetadata,
StopDirective)
from ask_sdk_model.interfaces import display
@nikhilym
nikhilym / python_decorator_guide.md
Created November 29, 2018 06:32 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@nikhilym
nikhilym / geolocation_skill.py
Created June 27, 2019 19:52
Geolocation sample skill hosted on HTTPS
# -*- coding: utf-8 -*-
# This is a skill for getting device location.
import logging
from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.api_client import DefaultApiClient
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.dispatch_components import AbstractExceptionHandler