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 os, time, sched | |
| MB = 1048576 | |
| def measure_write_speed(file_path): | |
| string = "Let's test write speed..." | |
| n = (100 * MB) // len(string) | |
| start = time.time() | |
| file = open(file_path, 'w') | |
| for i in range(n): |
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 python:3 | |
| ADD script.py / | |
| CMD [ "python", "-u", "./script.py" ] |
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
| downloadFile(dataToBeDownloaded): void { | |
| let a = document.createElement("a"); | |
| let dataURI = "data:text/plain;base64," + btoa(dataToBeDownloaded); | |
| a.href = dataURI; | |
| a['download'] = this._sddcInformation.id + ".pem"; | |
| a.click(); | |
| a.remove(); | |
| } |
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 nginx:latest | |
| # dist includes the built output - npm build | |
| COPY dist /usr/share/nginx/html | |
| # nginx*conf to copy all the nginx configuration files to image. | |
| COPY nginx*conf /opt/app-name/ | |
| # copy app entrypoint shell script | |
| COPY entrypoint.sh /opt/app-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
| cal_add_mod_dict = {} | |
| cal_sub_mod_dict = {} | |
| cal_mul_mod_dict = {} | |
| cal_pow_mod_dict = {} | |
| def cal_add_mod(a, b, n): | |
| """Calculates (a+b) mod n""" | |
| t = (a,b,n) | |
| if t not in cal_add_mod_dict: | |
| cal_add_mod_dict[t] = (a % n + b % n) % n |
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_prime_numbers(n): | |
| prime = [True for i in range(n+1)] | |
| res = [] | |
| p = 2 | |
| while (p * p <= n): | |
| # If prime[p] is not changed, then it is a prime | |
| if (prime[p] == True): | |
| res.append(i) | |
| # Update all multiples of p | |
| for i in range(p * p, n+1, p): |
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
| # roles as Python list of dictionaries | |
| roles = [ | |
| {'org': 'ABC', 'permissions':['RO', 'RW']}, | |
| {'org': 'DEF', 'permissions':['RO', 'RW']}, | |
| {'org': 'GHI', 'permissions':['RO', 'RW']}, | |
| {'org': 'JKL', 'permissions':['RO', 'RW']}, | |
| ] | |
| # get user object | |
| user = User.objects(id=ObjectId('user_id')).first() |
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 | |
| def test_function(n): | |
| return n ** 2 | |
| # initiate a thread pool executor | |
| executor = concurrent.futures.ThreadPoolExecutor(max_workers=10) | |
| # 1. submit jobs to the executor and track in a list | |
| jobs = [] |
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 | |
| def test_function(n): | |
| return n ** 2 | |
| # initiate a process pool executor | |
| # by default, number of workers = number of CPU cores | |
| executor = concurrent.futures.ProcessPoolExecutor(max_workers=10) | |
| # 1. submit jobs to the executor and track in a list |
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.example.org.schedules | |
| import com.example.org.services.ConstructorInjection | |
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | |
| import org.springframework.scheduling.annotation.EnableScheduling | |
| import org.springframework.scheduling.annotation.Scheduled | |
| import org.springframework.stereotype.Component | |
| /** | |
| * TestScheduler to schedule a method to run with fixedDelay |