For Windows 10/11 I'm on, the solution is to switch encoding in Python console to UTF-8.
(xxxxx) C:\Users\name>set PYTHONIOENCODING=UTF-8Then ensure running
pip install jupyter notebookInstead of
conda install jupyter notebook
For Windows 10/11 I'm on, the solution is to switch encoding in Python console to UTF-8.
(xxxxx) C:\Users\name>set PYTHONIOENCODING=UTF-8Then ensure running
pip install jupyter notebookInstead of
conda install jupyter notebook
#include <iostream>
#include <csignal>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
using namespace std;
void signalHandler( int signum ) {
cout << "Interrupt signal (" << signum << ") received.\n";
// cleanup and close up stuff here
// terminate program
exit(signum);
}
int main () {
// register signal SIGINT and signal handler
signal(SIGINT, signalHandler);
while(1) {
cout << "Going to sleep...." << endl;
sleep(1);
}
return 0;
}
Consider having json response from REST service stored internally in dictionary object. Now, following code converts content of the dictionary to instace of class Test.
Keep in mind though it's just simple demonstration. Enhancement in form of data validation might be required!
from collections import namedtuple
class Test:
def __init__(self, name : str, description : str, float_number : float):
self.name, self.descrition, self.float_number = name, description, float_number
def __repr__(self) -> str:
return f"Test class data: name='{self.name}', description='{self.descrition}', number={self.float_number}"
paramDict = dict(name="Name Property Value", description="Description Property Value", float_number=102.0036)
tstInstance = Test(*(namedtuple('x', paramDict.keys())(*paramDict.values())))
print(repr(tstInstance))
Running the code above prints following representation of the object on the std output:
Test class data: name='Name Property Value', description='Description Property Value', number=102.0036
Scenario:
Used Git Bash i.e. cygwin for this exercise, hence winpty presence on line with openssl command.
keytool -genkeypair -keyalg RSA -keysize 2048 -alias projenvlocal -dname "CN=projenvlocal" -ext SAN=DNS:projenvlocal,DNS:localhost,IP:127.0.0.1 -validity 3650 -keystore server.keystore.jks -storepass pwd1234 -keypass pwd1234 -deststoretype pkcs12 keytool -keystore server.truststore.jks -alias CARoot -import -file projEnvCALocal.crt -storepass pwd1234 -noprompt keytool -keystore server.keystore.jks -alias projenvlocal -certreq -file localhost.csr -storepass pwd1234 winpty openssl x509 -req -CA projEnvCALocal.crt -CAkey projEnvCALocal.key -in localhost.csr -out localhost-signed.crt -days 3650 -CAcreateserial -extfile sign-cert.cnf -extensions server_cert -passin pass:keypwd keytool -keystore server.keystore.jks -alias CARoot -import -file projEnvCALocal.crt -storepass pwd1234 -noprompt keytool -keystore server.keystore.jks -alias projenvlocal -import -file localhost-signed.crt -storepass pwd1234
* passwords are just illustrative of full command line
This part below is the main thing for being able to use certificate's CN as user name for Kafka authentication on localhost/127.0.0.1
-dname "CN=projenvlocal" -ext SAN=DNS:projenvlocal,DNS:localhost,IP:127.0.0.1
Performing of script above create two files, server.trustore.jks and server.keystore.jks .These files need to be used in ssl section of Kafka's server.properties and Zookeeper's zoo.cfg (file names may differ though).
Goodbye Kite.
Fast, feature-rich language support for Python in Visual Studio Code
The name Pylance serves as a nod to Monty Python’s Lancelot, who is the first knight to answer the bridge keeper’s questions in the Holy Grail.
Expecting Pybrian plugin in the near future :)
The Quantopian has been brought to the end but some of their valuable resources have been placed on the github.
[3] ... (?)
import numpy as np
from scipy.stats import norm
def delta(flag, s, k, t, r, v):
d1 = (np.log(s/k)+(r+v*v/2)*t)/(v*np.sqrt(t))
if flag == “C”:
return norm.cdf(d1)
else:
return norm.cdf(-d1) # +signed put deltaType = ‘C’ # call
S = 97.65 # underlying
K = 100.00 # strike
T = 30/365 # 30 days to expiry (in years)
R = 0.00 # “risk-free” rate
V = 0.12 # 12 vol
delta(Type, S, K, T, R, V)0.25044822
Type = ‘P’
S = 3000
K = 2900
T = 30/365
R = 0.00
V = 0.20
delta(Type, S, K, T, R, V)
0.27
S = 2950
T = 29/365
delta(Type, S, K, T, R, V)
0.37
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | class SessionStatusListenerCallback : public SessionStatusListener { public: SessionStatusListenerCallback(PyObject *pyObject) : self(pyObject) {} SessionStatusListenerCallback(PyObject* pyObject, const SessionStatusListener& listener) : self(pyObject), SessionStatusListener(listener) {} void onSessionStatusChanged(O2GSessionStatus status) { // GIL state handler PyGILState_STATE gstate; gstate = PyGILState_Ensure(); // Python callback call_method<void>(self, "onSessionStatusChanged", status); // GIL handler release PyGILState_Release(gstate); } void onLoginFailed(const char* error) { // GIL state handler PyGILState_STATE gstate; gstate = PyGILState_Ensure(); // Python callback call_method<void>(self, "onLoginFailed", error); // GIL handler release PyGILState_Release(gstate); } private: PyObject* const self; }; |