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 multiprocessing | |
| import time | |
| def cube(x): | |
| return x**3 | |
| if __name__ == "__main__": | |
| pool = multiprocessing.Pool(3) | |
| start_time = time.perf_counter() | |
| processes = [pool.apply_async(cube, args=(x,)) for x in range(1,1000)] |
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 { execSync } from 'child_process'; | |
| export async function runTest(args: TestArgs) { | |
| execSync(`echo "run e2e for ${args.page} in ${args.browser}"`, {encoding: 'utf-8', stdio: ['pipline', 'inherit', 'inherit']}); | |
| execSync(`echo "run e2e for ${args.page} in ${args.browser}"`, {encoding: 'utf-8', stdio: 'inherit'}); // use parents config of stdio | |
| } |
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 child_process = require('child_process'); | |
| const ls = child_process.spawn('bash', [], { stdio: 'inherit' }); | |
| ls.on('close', (code) => { | |
| console.log(`child process exited with code ${code}`); | |
| }); |
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
| >>> b = '区块链是金融系统的未来'.encode('utf-8') | |
| >>> b | |
| b'\xe5\x8c\xba\xe5\x9d\x97\xe9\x93\xbe\xe6\x98\xaf\xe9\x87\x91\xe8\x9e\x8d\xe7\xb3\xbb\xe7\xbb\x9f\xe7\x9a\x84\xe6\x9c\xaa\xe6\x9d\xa5' | |
| >>> int.from_bytes(b, byteorder='big', signed=False) | |
| 26580042452449738111737693352426092008374866632327585440351958788959384868658597 | |
| >>> hex(int.from_bytes(b, byteorder='big', signed=False)) | |
| '0xe58cbae59d97e993bee698afe98791e89e8de7b3bbe7bb9fe79a84e69caae69da5' |
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
| trap 'kill -- $$' INT TERM QUIT; | |
| # -- is a conventional marker recognised by most argument parsers which means "consider everything beyond this to be positional arguments (not flags)". |
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
| add_header Last-Modified $date_gmt; | |
| add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; | |
| if_modified_since off; | |
| expires off; | |
| etag off; |
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 PIL import Image | |
| img = Image.open('image.png').convert('LA') | |
| img.save('greyscale.png') |
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
| //https://github.com/yargs/yargs/issues/225 | |
| var yargs = require('yargs') | |
| var argv = yargs | |
| .usage('usage: $0 <command>') | |
| .command('create', 'create a new [project|module]', function (yargs) { | |
| argv = yargs | |
| .usage('usage: $0 create <item> [options]') | |
| .command('project', 'create a new project', function (yargs) { | |
| console.log('creating project :)') |
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 our modules that we are using | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| # Create the vectors X and Y | |
| x = np.array(range(10)) | |
| y = x ** 2 | |
| # Create the plot | |
| plt.plot(x,y,label='y = x**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
| from datetime import datetime, timezone | |
| datetime.now(tz=timezone.utc).isoformat() | |
| #'2020-09-18T11:19:55.651168+00:00' | |
| def get_timestamp(): | |
| now = datetime.datetime.utcnow() | |
| t = now.isoformat("T", "milliseconds") | |
| return t + "Z" |
NewerOlder