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 requests | |
CRLF = '\r\n' | |
DEFAULT_HTTP_VERSION = 'HTTP/1.1' | |
class RequestParser(object): | |
def __parse_request_line(self, request_line): | |
request_parts = request_line.split(' ') |
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 heapq | |
def k_closest_points(points_list, point, k): | |
# Find k closest points to point in points_list | |
points_distance = [] | |
for p in points_list: | |
distance = (p[0] - point[0]) ** 2 + (p[1] - point[1]) ** 2 | |
points_distance.append((distance, p)) | |
heapq.heapify(points_distance) |
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 __future__ import print_function | |
import pickle | |
import os.path | |
from io import StringIO | |
from googleapiclient.discovery import build | |
from google_auth_oauthlib.flow import InstalledAppFlow | |
from google.auth.transport.requests import Request | |
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly'] |
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 {Directive, ElementRef, Renderer2} from '@angular/core'; | |
/** | |
* This directive is used with <ion-item-sliding> tag to enable clicking to see | |
* the option buttons seen when swiping. | |
*/ | |
@Directive({ | |
selector: '[click-for-options]', | |
host: { | |
'(click)': 'toggleOptions()', |
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
""" | |
Bucket Fill Exercise | |
Imagine you are working on an image editing application. You need to implement a bucket fill tool similar to the one | |
in paint. The user will use the tool by selecting a color and clicking on the canvas. The tool fills the selected | |
region of color with the new color. | |
When a pixel is filled, all of its neighbors (above, below, left, or right) of the same color must also be filled, | |
as well as their neighbors, and so on, until the entire region has been filled with the new color. |
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
var objs = [ | |
{ | |
"name":"a", | |
"age":19 | |
}, { | |
"name":"b", | |
"age":15 | |
}, { | |
"name":"c", | |
"age":16 |
NewerOlder