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 java.util.HashMap; | |
import java.util.Scanner; | |
public class QHEAP1 { | |
private static int count = 1; | |
private static MinimumHeap<Integer> root = null; | |
HashMap<Integer,Integer> h = new HashMap<>(); | |
public static void main(String args[]) { | |
long startTime = System.currentTimeMillis(); | |
Scanner sc = new Scanner(System.in); |
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 get_nested_values_from_dict(data, attrs, index=0): | |
""" | |
get values from nested dictionary | |
Example: | |
>>> data = {"a": {"b": {"c": 3}} | |
>>> get_nested_values_from_dict(data, ["a", "b", "c"]) | |
>>> 3 | |
:param data: dict | |
:param attrs: list | |
:param index: int |
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 concurrent.futures | |
import logging | |
import random | |
import threading | |
SENTINEL = object() | |
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 asyncio | |
import json | |
import time | |
import aiohttp | |
result = [] | |
async def download_site(session, url): |
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 concurrent.futures | |
import json | |
import time | |
import requests | |
URLS = [ | |
"https://reqres.in/api/users", | |
"http://dummy.restapiexample.com/api/v1/employees", | |
# "https://jsonplaceholder.typicode.com/todos", | |
# "https://jsonplaceholder.typicode.com/posts", |
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.json | |
{ | |
"devDependencies": { | |
"eslint-config-airbnb": "^17.1.0", | |
"eslint-config-prettier": "^5.0.0", | |
"eslint-plugin-import": "^2.17.3", | |
"eslint-plugin-react": "^7.14.1", | |
"husky": "^2.5.0", | |
"lint-staged": "^8.2.1", | |
"prettier": "^1.18.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
BASE62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
def encode(num, alphabet=BASE62): | |
"""Encode a positive number in Base X | |
Arguments: | |
- `num`: The number to encode | |
- `alphabet`: The alphabet to use for encoding | |
""" | |
if num == 0: |
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 divide(data, n_column=3): | |
result = [] | |
cur_index = 0 | |
n = len(data) | |
while cur_index < n/n_column: | |
result.append(data[cur_index*n_column: (cur_index+1)*n_column]) | |
cur_index += 1 | |
if n%n_column != 0: | |
result.append(data[cur_index*n_column: (cur_index+1)*n_column]) | |
return result |
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 get_starting_date_minus_n_months(curr_date, num_months): | |
""" | |
Given the curr_date (datetime) object and num_months, returns the starting date | |
minus "num_months" months. Note that time won't change | |
for example: curr_date is "2019-10-22 23:59:59" and num_months is 3 | |
it returns "2019-07-01 23:59:59" | |
""" | |
if num_months < 0: | |
raise ValueError( |
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
const path = require("path"); | |
const webpack = require("webpack"); | |
const TerserPlugin = require("terser-webpack-plugin"); | |
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); | |
module.exports = ({ mode, presets } = { mode: "production", presets: [] }) => ({ | |
devtool: "eval-cheap-module-source-map", |
OlderNewer