Visual Studio Code is suddenly defaulting to PowerShell for integrated terminal and tasks

Update: Version v1.60.0 had a bug. Upgrade to v1.60.1 or higher for a fix. The bug manifested in the following symptoms: The Open in Integrated Terminal shortcut-menu command in the Explorer pane’s shortcut always uses the built-in default shell (PowerShell on Windows), ignoring the configured one. The same goes for running tasks (with or without … Read more

FastAPI python: How to run a thread in the background?

Option 1 You should start your Thread before calling uvicorn.run, as uvicorn.run is blocking the thread. import time import threading from fastapi import FastAPI import uvicorn app = FastAPI() class BackgroundTasks(threading.Thread): def run(self,*args,**kwargs): while True: print(‘Hello’) time.sleep(5) if __name__ == ‘__main__’: t = BackgroundTasks() t.start() uvicorn.run(app, host=”0.0.0.0″, port=8000) You could also start your thread using … Read more

Plotting 3D Polygons

I think you’ve almost got it. Is this what you want? from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection import matplotlib.pyplot as plt fig = plt.figure() ax = Axes3D(fig, auto_add_to_figure=False) fig.add_axes(ax) x = [0,1,1,0] y = [0,0,1,1] z = [0,1,0,1] verts = [list(zip(x,y,z))] ax.add_collection3d(Poly3DCollection(verts)) plt.show() You might also be interested in art3d.pathpatch_2d_to_3d.

How to safely output HTML from a PHP program?

You always want to HTML-encode things inside HTML attributes, which you can do with htmlspecialchars: <span title=”<?php echo htmlspecialchars($variable); ?>”> You probably want to set the second parameter ($quote_style) to ENT_QUOTES. The only potential risk is that $variable may already be encoded, so you may want to set the last parameter ($double_encode) to false.

Integer.toString(int i) vs String.valueOf(int i) in Java

In String type we have several method valueOf static String valueOf(boolean b) static String valueOf(char c) static String valueOf(char[] data) static String valueOf(char[] data, int offset, int count) static String valueOf(double d) static String valueOf(float f) static String valueOf(int i) static String valueOf(long l) static String valueOf(Object obj) As we can see those method are … Read more