Terminate command after keyword in output in Linux Posted: 08 May 2022 07:03 PM PDT I want to send a SIGKILL if a certain keyword is shown in the output of the command. Eg, if issue the following command: ubuntu@ip-172-31-24-250:~$ ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=109 time=0.687 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=109 time=0.704 ms 64 bytes from 8.8.8.8: icmp_seq=3 ttl=109 time=0.711 ms 64 bytes from 8.8.8.8: icmp_seq=4 ttl=109 time=0.809 ms 64 bytes from 8.8.8.8: icmp_seq=5 ttl=109 time=0.727 ms 64 bytes from 8.8.8.8: icmp_seq=6 ttl=109 time=0.835 ms ^C After seeing the output "icmp_seq=6" I'd like the command to automatically halt. I know that ping 8.8.8.8 -c 6 will have the same results, but it's just for the example. |
Signin error about twitter and unity in Firebase Posted: 08 May 2022 07:03 PM PDT I can use email google and facebook login in firebase project. I can get each twitter account's Access Token and Secret even username via twitter unity sdk. However when I try to login via twitter, it has One or more errors occurred problem. I tried to use Reauthenticate but it doesn't work. Does anyone who knows how to solve this problem? thx [Error] : SignInWithCredentialAsync fatal. an error: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Firebase.FirebaseException: The supplied auth credential is malformed or has expired. --- End of inner exception stack trace --- --- End of inner exception stack trace --- ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> Firebase.FirebaseException: The supplied auth credential is malformed or has expired. --- End of inner exception stack trace --- ---> (Inner Exception #0) Firebase.FirebaseException: The supplied auth credential is malformed or has expired.<--- <--- (System.Threading.Tasks.Task`1<Firebase.Auth.FirebaseUser>) System.Threading._ThreadPoolWaitCallback:PerformWaitCallback () public void LoginWithTwitter() { FirebaseAuth auth = FirebaseAuth.DefaultInstance; _twitterCredential = TwitterAuthProvider.GetCredential(_twitterAccessToken, _twitterSecret); //Reauthenticate(_twitterCredential); auth.SignInWithCredentialAsync(_twitterCredential).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("[Info] : SignInWithCredentialAsync canceled."); return; } if (task.IsFaulted) { Debug.LogError("[Error] : SignInWithCredentialAsync fatal. an error: " + task.Exception); if (task.Exception != null) UIManager.sInstance.infoText.text = task.Exception.Message; return; } FirebaseUser authUser = task.Result; UIManager.sInstance.providerText.text = _twitterCredential.Provider; UIManager.sInstance.providerIdText.text = authUser.ProviderId; }); } |
I'm getting following Error while doing terraform apply Posted: 08 May 2022 07:03 PM PDT [root@terraform ~]# terraform plan -out terraform.tfstate ╷ │ Error: Error acquiring the state lock │ │ Error message: 2 problems: │ │ - Unsupported state file format: The state file could not be parsed as JSON: │ syntax error at byte offset 1. │ - Unsupported state file format: The state file does not have a "version" │ attribute, which is required to identify the format version. │ │ Terraform acquires a state lock to protect the state from being written │ by multiple users at the same time. Please resolve the issue above and try │ again. For most commands, you can disable locking with the "-lock=false" │ flag, but this is not recommended. |
Unreal Engine C++: How to iterate all the bones? Posted: 08 May 2022 07:03 PM PDT Above picture shows a "Modify Bone" node inside an AnimGraph. Circle part is a list that we can manually choose which bone to modify. Is it possible to iterate all these bones with C++ code? I need to get the correspondance between the bone name (e.g. a string) and its Compact Pose Bone Index. |
How to encode a grid of 9 gray pixels intensity into a single number? Posted: 08 May 2022 07:02 PM PDT So I have 9 pixels on a square grid. Each one is 0..255 (a shade of grey image). I want to get a kind of fingerprint out from it. I have 20 possible options, and I want to find the closest to a given image. - 4 types of center fill,
- 6 types of line fill,
- 2 types of angled fill,
- 4 types of direction fill
- 4 types of cross fill
like this: So how to get to which one of 20 my current given image is the closest? |
How can I query last 10 data in Influxdb2.0 Posted: 08 May 2022 07:02 PM PDT I tried to query the latest 10 of data, but I only saw from the official documentation how to query the latest 1 of data, has anyone tried it? |> last() |
tailwind flex classes not showing up Posted: 08 May 2022 07:01 PM PDT I'm trying to setup tailwind. When I use classnames of flex I expect the flex css property to show up in the element styles. All other element styles show up, but the flex related ones don't. This is in a new react app. Why is this happening? I setup tailwind using the tailwind cli with npx. <div className="flex flex-row justify-between mx-auto bg-gray-200 shadow border p-8 m-10"> <h1> Trending </h1> <h1> My Faves </h1> </div> my index.css file has the @tailwind base; @tailwind components; @tailwind utilities; Is flex not a part of tailwind or something? |
Why android-basic-samples could not load? Posted: 08 May 2022 07:01 PM PDT https://github.com/playgameservices/android-basic-samples I used this sample project and completed the settings according to the instructions, after successfully logging in and saving, I found that it could not be loaded. Automatically crashes when I select a save to load. Is this normal? Or do I need to set something extra? |
Is there a way to get predicted probabilities from a logistic regression using the logbin package? Posted: 08 May 2022 07:01 PM PDT Because of convergence issues, I have been using the logbin package with "em" method to calculate relative risks. Usually after running a glm model, I would run ggpredict() and get predicted probabilities. However, when I use ggpredict after the logbin model, it gives me predicted probabilities from the odds scale rather than risk. Does anyone know how I can change this? longcovid_adjusted <- glm(sixmonths_bin + sex + age_bin, family=binomial(link="logit"), data=final) longcovid_adjusted2 <- logbin(longcovid_adjusted, method="em") ggpredict(longcovid_adjusted2, terms=c("sex")) |
how to translate express.js to typescript code Posted: 08 May 2022 07:00 PM PDT I am new to Angular 13. Any help or hint would be greatly appreciated it!! I have the following express.js code. I need to translate it to equivalent to typescript for Angular 13: presentWallets(walletApps) { let wallets = this.querySelector('#aqWallets'); var innerhtml = "<table style='margin:auto 0; display:inline-block'><tr>"; for (var walletApp of walletApps) { var app = `<td align='center'> <div> <button class="aqButton" onclick="getQRCode('${this.id}', '${this.role}','${walletApp.id}')" alt="Get ${this.role} QR Code for ${walletApp.name} wallet"><img src="${walletApp.image}" class="appImage" alt="${walletApp.description}"></button> </div> </td>` innerhtml += app; } innerhtml += "</tr></table>"; wallets.innerHTML = innerhtml } |
Heroku Deployment issue with MongoDB Posted: 08 May 2022 07:00 PM PDT I'm having some issues getting this application deployed. This has been an ongoing issue with some of my MERN stack applications and am needing some guidance. My app works fine locally but the deployed application wont grab anything from the MongoDB. Any help would be greatly appreciated. Here is my connection to mongo. import mongoose from 'mongoose' const connectDB = async () => { try { const conn = await mongoose.connect(process.env.MONGO_URI, { useUnifiedTopology: true, useNewUrlParser: true, //useCreateIndex: true, }) console.log(`MongoDB Connected: ${conn.connection.host}`.cyan.underline) } catch (error) { console.error(`Error: ${error.message}`.red.underline.bold) process.exit(1) } } export default connectDB Here is my server.js file import path from 'path' import express from 'express' import dotenv from 'dotenv' import morgan from 'morgan' import colors from 'colors' import { notFound, errorHandler } from './middleware/errorMiddleware.js' import connectDB from './config/db.js' import productRoutes from './routes/productRoutes.js' import userRoutes from './routes/userRoutes.js' import orderRoutes from './routes/orderRoutes.js' import uploadRoutes from './routes/uploadRoutes.js' dotenv.config() connectDB() const app = express() if (process.env.NODE_ENV === 'development') { app.use(morgan('dev')) } app.use(express.json()) app.use('/api/products', productRoutes) app.use('/api/users', userRoutes) app.use('/api/orders', orderRoutes) app.use('/api/upload', uploadRoutes) app.get('/api/config/paypal', (req, res) => res.send(process.env.PAYPAL_CLIENT_ID) ) const __dirname = path.resolve() app.use('/uploads', express.static(path.join(__dirname, '/uploads'))) if (process.env.NODE_ENV === 'production') { app.use(express.static(path.join(__dirname, 'client/build'))) app.get('*', (req, res) => res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html')) ) } else { app.get('/', (req, res) => { res.send('API is running....') }) } app.use(notFound) app.use(errorHandler) const PORT = process.env.PORT || 5000 app.listen( PORT, console.log( `Server running in ${process.env.NODE_ENV} mode on port ${PORT}`.yellow.bold ) ) I have my MONGO_URI set up in .env("i've blahblah sensitive info") NODE_ENV = development PORT = 5000 MONGO_URI = mongodb+srv://BLAHBLAHBLAH:BLAHBLAHBLAH@hacatac.bpdba.mongodb.net/blahblahblahblahblah?retryWrites=true&w=majority JWT_SECRET = abc123 JWT_EXPIRES_IN = 30d PAYPAL_CLIENT_ID = blahblahblahblah I've set up my Heroku with my .env variables correctly. Then this is my heroku log --tails: $ heroku logs --tail 2022-05-09T00:42:38.130855+00:00 app[api]: Release v26 created by user jhack00@icloud.com 2022-05-09T00:42:38.130855+00:00 app[api]: Set MONGO_URI config vars by user jhack00@icloud.com 2022-05-09T00:42:38.787198+00:00 heroku[web.1]: State changed from crashed to starting 2022-05-09T00:42:45.377858+00:00 heroku[web.1]: Starting process with command `node server/server.js` 2022-05-09T00:42:48.258404+00:00 app[web.1]: Server running in production mode on port 11841 2022-05-09T00:42:48.261117+00:00 app[web.1]: Error: Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://" 2022-05-09T00:42:48.390717+00:00 heroku[web.1]: Process exited with status 1 2022-05-09T00:42:48.627944+00:00 heroku[web.1]: State changed from starting to crashed 2022-05-09T00:42:49.633539+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hacshopapp.herokuapp.com request_id=4e4f098d-d10c-4eeb-ba47-750268bb57cc fwd="47.221.164.46" dyno= connect= service= status=503 bytes= protocol=https 2022-05-09T00:42:50.016318+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hacshopapp.herokuapp.com request_id=bc712ccd-a0cc-40c2-9bf9-57788b3b64d1 fwd="47.221.164.46" dyno= connect= service= status=503 bytes= protocol=https 2022-05-09T00:43:39.455744+00:00 app[api]: Set MONGO_URI config vars by user jhack00@icloud.com 2022-05-09T00:43:39.455744+00:00 app[api]: Release v27 created by user jhack00@icloud.com 2022-05-09T00:43:39.738765+00:00 heroku[web.1]: State changed from crashed to starting 2022-05-09T00:43:47.883607+00:00 heroku[web.1]: Starting process with command `node server/server.js` 2022-05-09T00:43:50.342543+00:00 app[web.1]: Server running in production mode on port 47260 2022-05-09T00:43:50.345909+00:00 app[web.1]: Error: option usecreateindex is not supported 2022-05-09T00:43:50.542669+00:00 heroku[web.1]: Process exited with status 1 2022-05-09T00:43:50.648320+00:00 heroku[web.1]: State changed from starting to crashed 2022-05-09T00:43:51.762536+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hacshopapp.herokuapp.com request_id=9f86fdc6-ef4d-4f2b-b4b6-046ce120ac82 fwd="47.221.164.46" dyno= connect= service= status=503 bytes= protocol=https 2022-05-09T00:43:52.162367+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hacshopapp.herokuapp.com request_id=1ba12a63-1815-4159-b449-ac8ac7374691 fwd="47.221.164.46" dyno= connect= service= status=503 bytes= protocol=https 2022-05-09T00:46:05.000000+00:00 app[api]: Build started by user jhack00@icloud.com 2022-05-09T00:47:35.755042+00:00 app[api]: Deploy cda37fb8 by user jhack00@icloud.com 2022-05-09T00:47:35.755042+00:00 app[api]: Release v28 created by user jhack00@icloud.com 2022-05-09T00:47:36.120750+00:00 heroku[web.1]: State changed from crashed to starting 2022-05-09T00:47:37.000000+00:00 app[api]: Build succeeded 2022-05-09T00:47:43.649226+00:00 heroku[web.1]: Starting process with command `node server/server.js` 2022-05-09T00:47:45.871284+00:00 app[web.1]: Server running in production mode on port 59501 2022-05-09T00:47:45.998312+00:00 heroku[web.1]: State changed from starting to up 2022-05-09T00:47:47.299139+00:00 heroku[router]: at=info method=GET path="/" host=hacshopapp.herokuapp.com request_id=26dd3a60-6e55-40af-828d-e02cbf406d51 fwd="47.221.164.46" dyno=web.1 connect=0ms service=12ms status=200 bytes=1425 protocol=https 2022-05-09T00:47:47.387721+00:00 heroku[router]: at=info method=GET path="/static/css/main.0e05c2f1.css" host=hacshopapp.herokuapp.com request_id=b8a93410-a844-4047-a280-d8edf0d0cb75 fwd="47.221.164.46" dyno=web.1 connect=0ms service=6ms status=200 bytes=142010 protocol=https 2022-05-09T00:47:47.499049+00:00 heroku[router]: at=info method=GET path="/static/js/main.7deaca53.js" host=hacshopapp.herokuapp.com request_id=90aad3c4-2473-4bea-96ae-82d7b2ce788a fwd="47.221.164.46" dyno=web.1 connect=0ms service=10ms status=200 bytes=384181 protocol=https 2022-05-09T00:47:47.617127+00:00 heroku[router]: at=info method=GET path="/static/css/main.0e05c2f1.css.map" host=hacshopapp.herokuapp.com request_id=32ae14cf-b8eb-4f34-b20f-3747c247680d fwd="47.221.164.46" dyno=web.1 connect=0ms service=8ms status=200 bytes=215548 protocol=https 2022-05-09T00:47:47.862944+00:00 heroku[router]: at=info method=GET path="/static/js/main.7deaca53.js.map" host=hacshopapp.herokuapp.com request_id=ec0b91fd-d279-4cb4-bb68-080ae7941ad7 fwd="47.221.164.46" dyno=web.1 connect=0ms service=19ms status=200 bytes=1372956 protocol=https 2022-05-09T00:47:48.015574+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=hacshopapp.herokuapp.com request_id=29e102e1-3719-4285-9cea-059a5e66898f fwd="47.221.164.46" dyno=web.1 connect=0ms service=2ms status=200 bytes=1427 protocol=https 2022-05-09T00:47:48.103904+00:00 heroku[router]: at=info method=GET path="/manifest.json" host=hacshopapp.herokuapp.com request_id=c87ac006-fed8-4cd9-bdaa-8fb0391699c9 fwd="47.221.164.46" dyno=web.1 connect=0ms service=2ms status=200 bytes=787 protocol=https 2022-05-09T00:47:48.164221+00:00 heroku[router]: at=info method=GET path="/logo192.png" host=hacshopapp.herokuapp.com request_id=e7c65952-c40b-4007-b414-b23c491f35c7 fwd="47.221.164.46" dyno=web.1 connect=0ms service=5ms status=200 bytes=5622 protocol=https 2022-05-09T00:47:57.985147+00:00 heroku[router]: at=info method=GET path="/api/products?keyword=&pageNumber=1" host=hacshopapp.herokuapp.com request_id=0f808a0e-1aa2-43a5-b1b9-a61c4be13aa0 fwd="47.221.164.46" dyno=web.1 connect=0ms service=10006ms status=500 bytes=327 protocol=https 2022-05-09T00:48:15.871453+00:00 app[web.1]: Error: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ 2022-05-09T00:48:15.892331+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/api/products/top" host=hacshopapp.herokuapp.com request_id=810d4f40-4a93-4d87-8c3b-92125d881f2c fwd="47.221.164.46" dyno=web.1 connect=0ms service=28039ms status=503 bytes=0 protocol=https 2022-05-09T00:48:16.097582+00:00 heroku[web.1]: Process exited with status 1 2022-05-09T00:48:16.227130+00:00 heroku[web.1]: State changed from up to crashed 2022-05-09T00:55:17.911074+00:00 app[api]: Set MONGO_URI config vars by user jhack00@icloud.com 2022-05-09T00:55:17.911074+00:00 app[api]: Release v29 created by user jhack00@icloud.com 2022-05-09T00:55:18.280948+00:00 heroku[web.1]: State changed from crashed to starting 2022-05-09T00:55:24.509046+00:00 heroku[web.1]: Starting process with command `node server/server.js` 2022-05-09T00:55:26.485352+00:00 app[web.1]: Server running in production mode on port 16363 2022-05-09T00:55:26.591153+00:00 app[web.1]: MongoDB Connected: cluster0-shard-00-02.6ttdd.mongodb.net 2022-05-09T00:55:26.977598+00:00 heroku[web.1]: State changed from starting to up 2022-05-09T01:27:57.664303+00:00 heroku[web.1]: Idling 2022-05-09T01:27:57.667363+00:00 heroku[web.1]: State changed from up to down 2022-05-09T01:27:58.284974+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2022-05-09T01:27:58.483665+00:00 heroku[web.1]: Process exited with status 143 2022-05-09T01:30:21.709404+00:00 app[api]: Remove MONGO_URI config vars by user jhack00@icloud.com 2022-05-09T01:30:21.709404+00:00 app[api]: Release v30 created by user jhack00@icloud.com 2022-05-09T01:30:22.035909+00:00 heroku[web.1]: State changed from down to starting 2022-05-09T01:30:29.430958+00:00 heroku[web.1]: Starting process with command `node server/server.js` 2022-05-09T01:30:30.562627+00:00 app[api]: Release v31 created by user jhack00@icloud.com 2022-05-09T01:30:30.562627+00:00 app[api]: Set MONGO_URI config vars by user jhack00@icloud.com 2022-05-09T01:30:30.819859+00:00 heroku[web.1]: Restarting 2022-05-09T01:30:31.798407+00:00 app[web.1]: Server running in production mode on port 26127 2022-05-09T01:30:31.801403+00:00 app[web.1]: Error: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string. 2022-05-09T01:30:31.953103+00:00 heroku[web.1]: Process exited with status 1 2022-05-09T01:30:51.676733+00:00 heroku[web.1]: Starting process with command `node server/server.js` 2022-05-09T01:30:53.919692+00:00 app[web.1]: Server running in production mode on port 15121 2022-05-09T01:30:54.237880+00:00 heroku[web.1]: State changed from starting to up 2022-05-09T01:31:23.945971+00:00 app[web.1]: Error: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ 2022-05-09T01:31:24.113842+00:00 heroku[web.1]: Process exited with status 1 2022-05-09T01:31:24.232028+00:00 heroku[web.1]: State changed from up to crashed 2022-05-09T01:31:24.235780+00:00 heroku[web.1]: State changed from crashed to starting 2022-05-09T01:31:30.618111+00:00 heroku[web.1]: Starting process with command `node server/server.js` 2022-05-09T01:31:32.452719+00:00 app[web.1]: Server running in production mode on port 9150 2022-05-09T01:31:32.900814+00:00 heroku[web.1]: State changed from starting to up 2022-05-09T01:32:02.487156+00:00 app[web.1]: Error: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ 2022-05-09T01:32:02.700936+00:00 heroku[web.1]: Process exited with status 1 2022-05-09T01:32:03.107391+00:00 heroku[web.1]: State changed from up to crashed 2022-05-09T01:44:19.000000+00:00 app[api]: Build started by user jhackworth00@outlook.com 2022-05-09T01:45:47.036387+00:00 app[api]: Deploy f6b9c3b4 by user jhackworth00@outlook.com 2022-05-09T01:45:47.036387+00:00 app[api]: Release v32 created by user jhackworth00@outlook.com Obviously this is an error with conneting to the MongoDB but I'm confused on what's goign wrong. I thought I added my IP in etc so would appreciate some help on this. Here is the link to my deployed site if you're curious whats happening. Link: https://hacshopapp.herokuapp.com/ |
How to compare two lists by sequence of ordered values in python? Posted: 08 May 2022 07:00 PM PDT I have two lists l1 = ['4', '3', '2', '7', '10', '15', '14', '11', '6', '5', 'd'] l2 = ['4', '3', '-2', '-1', 'A', '16', '9', '-12', 'e', '12', '11', '6', '5', 'd', '8',90'] and I want to calculate what is the largest sequence of ordered numbers of l2 that is repeated in l1 and their index in l2. In this case it would be result = ['11', '6', '5', 'd'] |
Looking for assistance with system cleanup/initial python configuration Posted: 08 May 2022 07:00 PM PDT I am trying to setup Python on IOS Catalina 10.15.7 and I'm really struggling. For starters, I am very green when it comes to using terminal and a lot of the relevant points when it comes to these sort of system level configurations are well over my head so please talk to me like I'm 5. My ultimate goal here is to get a clean and organized version of python installed on my machine. At this point I have tried installing python via the website as well as homebrew, and now I'm very confused about what versions I actually have installed, and where those are living. I'm not sure if this would actually be necessary, but I'm thinking I should try and delete all the versions I have installed? Once I get a clean version installed, my understanding is that I would need to define the path in terminal so that the new version of python3 will be the default for my system. Additionally, I want to use PYCharm, and ran into some issues there where it was basically saying that I hadn't linked it to the correct python directory yet. I watched some tutorials on this but couldn't emulate any of them because they were all referencing it to a python.exe file, which I couldn't find anywhere. Here are some terminal outputs which I think might be helpful. Also, FWIW, I changed from bash to ZSH (I don't really understand why or what this means but it was part of one of the tutorials I followed). I'm of course happy to provide any other terminal output if that helps diagnose this... reilly@Reillys-MacBook-Pro ~ % ls -ls /usr/bin/python 0 lrwxr-xr-x 1 root wheel 75 Feb 12 2020 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 reilly@Reillys-MacBook-Pro ~ % which -a python /usr/local/bin/python /usr/bin/python reilly@Reillys-MacBook-Pro ~ % ls -l /usr/bin/python* lrwxr-xr-x 1 root wheel 75 Feb 12 2020 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 lrwxr-xr-x 1 root wheel 82 Feb 12 2020 /usr/bin/python-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config lrwxr-xr-x 1 root wheel 75 Feb 12 2020 /usr/bin/python2 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 lrwxr-xr-x 1 root wheel 75 Feb 12 2020 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 lrwxr-xr-x 1 root wheel 82 Feb 12 2020 /usr/bin/python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config -rwxr-xr-x 1 root wheel 31488 Oct 30 2020 /usr/bin/python3 lrwxr-xr-x 1 root wheel 76 Feb 12 2020 /usr/bin/pythonw -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7 lrwxr-xr-x 1 root wheel 76 Feb 12 2020 /usr/bin/pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7 reilly@Reillys-MacBook-Pro ~ % python --version Python 3.10.4 reilly@Reillys-MacBook-Pro ~ % python3 --version Python 3.10.4 reilly@Reillys-MacBook-Pro ~ % Thanks so much in advance for any and all help! |
Is there a Numpy array broadcasting expression simpler than this list comprehension? Posted: 08 May 2022 07:00 PM PDT In this code snippet: triangles = np.float32([[[0, -2], [-2, 3], [1, 1]], [[0, -1], [-1, 3], [1, 1]]]) centers = np.average(triangles, axis=1) samples = np.float32([t-centers[i] for i, t in enumerate(triangles)]) I would like to express samples as an array broadcast subtraction, i.e. something similar to triangles-centers , which doesn't work due to: ValueError: operands could not be broadcast together with shapes (2,3,2) (2,2) Is there a simpler way to define samples than a list comprehension? |
Data is being displayed in the console but not in screen - react js Posted: 08 May 2022 07:00 PM PDT I am able to to display the data in the console but unable to display the same in the DOM page using react . I have seen this problem but none of the answers actually work for me .Can you please tell me where I am going . Am I accessing the wrong info in SetData() function Test() { const [loading, SetLoading] = useState(false); const [questions, SetData] = useState(null); const getData = async () => { try { const info = await axios.get("http://localhost:3000/info").then((res) => { console.log(res); SetData(res.data.info); }); SetLoading(true); } catch (err) { console.log(err); } }; useEffect(() => { getData(); }, []); return <div>{loading ? questions : <ReactBootstrap.Spinner animation="border" variant="success" />}</div>; } export default Test; API data format : { "info": [ { "question": "Angular 2 integrates easily with NativeScript, allowing you to code your native app in a . . . . . . . . . style that can run on any mobile device platform.", "options": ["a) declarative", "b) imperative", "c) interrogative", "d) exclamatory"], "answer": 0, "id": 0 }, { "question": "Angular 2 components can be described using ________is a way to do some meta-programming.", "options": [ "a) controllers, controller", "b) Loaders, loader", "c) typescripts, typescript", "d) decorators, decorator" ], "answer": 3, "id": 1 }, { "question": "The ______ directive substitutes the normal href property and makes it easier to work with route links in Angular 2.", "options": ["a) RouterLink", "b) RouterRend", "c) RouterLike", "d) RouterLayer"], "answer": 0, "id": 2 } ] } |
can mysql and php work together with react js? Posted: 08 May 2022 07:00 PM PDT I am a PHP developer wanting to learn react js. However, I tried googling for samples codes that i can pick up but found none. All my database are in mysql. Seeking any advise on this? |
When does the compiler need to compute an alias? Posted: 08 May 2022 07:02 PM PDT Consider the following code: template <class T> struct computation { using type = /* something based on T that takes time to compile */; }; Now consider two codes: using x = computation<T>; and: using y = typename computation<T>::type; I am wondering whether the standard implies that: - Option A) Any "reasonable" compiler will lead to a quick compile time for
x and long compile time for y - Option B) A compiler could totally compute
computation<T>::type even if only computation<T> is called, leading to long compile-time even for x In other words, I am trying to know if the standard specifies anything that would most likely translate into option A or option B for a "reasonable" compiler implemeter. I know that the standard says nothing about compiler implementation but for example if it requires that ::type does not have to exist until it's specifically called, that would be in favor of option A. NOTE: In my experience, I am pretty sure that g++ , clang++ , msvc , and intel are following option A), but I have no idea whether it's just by pure luck of it's related to something in the standard. |
Retrieving data from the preceding rows w/ Hlookup Posted: 08 May 2022 07:02 PM PDT first time posting so Im hoping for some assistance. I have a table of data, and the primary key for the Hlookup is sitting of the 3 row down. I need a Hlookup to retrieve the data above. For example... Row 1 Science Row 2 Period 1 Row 3 Eric The data cannot be changed due to the nature of the spreadsheet. But I need to build a timetable based on particular names and the information associated to that person. So Eric is teaching Science in Period 1. That needs to be added to a seperate sheet. Outcome Eric Science Period 1 A Hlookup would be perfect if it were possible to retrieve the preceding rows. Is there anyway to do this? Thanks in advance! |
Referencing column from outer-subquery in inner subquery where clause Posted: 08 May 2022 07:00 PM PDT I am pretty new to sql in general and I am running into some problems with a subquery in mysql. The subquery is: SELECT b.movie_id, title, summary, rating, num_ratings, freq, ct FROM (SELECT a.movie_id, freq, (SELECT count(*) from ((SELECT genre_name from movies.genre_table where movie_id = '21-jump-street') as x INNER JOIN (SELECT genre_name from movies.genre_table where movie_id = a.movie_id) as y on x.genre_name = y.genre_name)) as ct FROM (SELECT movie_id, count(movie_id) as freq from movies.user_movies WHERE user in (SELECT user FROM movies.user_movies WHERE movies.user_movies.movie_id = '21-jump-street' AND rating >= 4.5) AND rating >= 4.5 AND movie_id != '21-jump-street' GROUP BY movie_id) AS a) as b INNER JOIN movies.movie_table on b.movie_id = movie_table.movie_id ORDER BY count DESC, freq DESC My table schema is: genre_table has movie_id and genre_name, movie_table has movie_id, title, summary, ratings, and num_ratings, user_movies has user, movie_id, and rating. The goal of this query is to select all of the highly rated movies from user_movies that users who rated the input movie (21 jump street in this case) highly. Then it should compare the genres of the input movie to each movie to generate a count of matched genres. Finally the query returns the recommended movies descending by matching the most genres and thn by the frequency of times rated highly. However, when I run this, I receive Error Code 1054: Unknown column 'a.movie_id' in 'where clause'. I know you can't generally put subquery results in where clauses, because the where can be evaluated first. Is there anything I can do about this or a way I can change the query to get the desired result? Any help is appreciated. Thanks! |
How to create the folder structure from info in dataframe? Posted: 08 May 2022 07:01 PM PDT I created a dataframe that lists all files and folders in my Google Drive. I've been able to filter it down to only the folders. I now want to recreate that same folder structure on my local computer. So the dataframe has a unique folder id # for each folder, the name of the folder, and the id of each folder's parent folder, like this: I suspect I'll need to use Python os to recursively create this structure. So far I've been able to create the first level of folders (in the top level) by specifying the parent id #: parent_directory = 'test_dirs' for row in df.itertuples(): if getattr(row, 'parent_folder_id#') == '0': directory = getattr(row, 'folder_name') path = os.path.join(parent_directory, directory) os.mkdir(path) else: pass But how would I make this recursive to be able to create all of the nested folders at once? |
Why does std::is_invocable_r reject functions returning non-moveable types? Posted: 08 May 2022 07:03 PM PDT I'm curious about the definition of std::is_invocable_r and how it interacts with non-moveable types. Its libc++ implementation under clang in C++20 mode seems to be wrong based on my understanding of the language rules it's supposed to emulate, so I'm wondering what's incorrect about my understanding. Say we have a type that can't be move- or copy-constructed, and a function that returns it: struct CantMove { CantMove() = default; CantMove(CantMove&&) = delete; }; static_assert(!std::is_move_constructible_v<CantMove>); static_assert(!std::is_copy_constructible_v<CantMove>); CantMove MakeCantMove() { return CantMove(); } Then it's possible to call that function to initialize a CantMove object (I believe due to the copy elision rules): CantMove cant_move = MakeCantMove(); And the type traits agree that the function is invocable and returns CantMove : using F = decltype(MakeCantMove); static_assert(std::is_invocable_v<F>); static_assert(std::is_same_v<CantMove, std::invoke_result_t<F>>); But std::is_invocable_r says it's not possible to invoke it to yield something convertible to CantMove , at least in C++20 under clang: static_assert(!std::is_invocable_r_v<CantMove, F>); The definition of std::is_invocable_r is The expression INVOKE<R>(declval<Fn>(), declval<ArgTypes>()...) is well-formed when treated as an unevaluated operand with INVOKE<R> being defined as Define INVOKE<R>(f, t1, t2, …, tN) as [...] INVOKE(f, t1, t2, …, tN) implicitly converted to R . and INVOKE defined (in this case) as simply MakeCantMove() . But the definition of whether an implicit conversion is possible says: An expression E can be implicitly converted to a type T if and only if the declaration T t=E; is well-formed, for some invented temporary variable t ([dcl.init]). But we saw above that CantMove cant_move = MakeCantMove(); is accepted by the compiler. So is clang wrong about accepting this initialization, or is the implementation of std::is_invocable_r_v wrong? Or is my reading of the standard wrong? For the record, the reason I care about this question is that types like std::move_only_function (I'm using an advanced port to C++20 of this) have their members' overload sets restricted by std::is_invocable_r_v , and I'm finding that it's not possible to usefully work with functions that return a no-move type like this. Is that by design, and if so why? |
How do I create a program that replaces the CODE to VALUE? Posted: 08 May 2022 07:02 PM PDT I just wanted to help with my code here's my questions How can I input "computer" in any in any order and case insensitively and still get the correct output? Here are the replacement COMPUTERS.X 1234567890.X If I input other letters that is not included in the COMPUTERS.X the program will terminate and ask again if i should input again. example: Input Code: Most.x UNABLE TO CONVERT YOUR INPUT INPUT AGAIN? Type YES to input again, type NO to end program: Is there any way or method to replace the whole string array instead of replace(CODES.begin(),CODES.end(),'C','1'); here's my code #include <iostream> #include <string.h> #include <algorithm> using namespace std; int main() { string CODES; char choice[5]; do { cout << "Input code: "; cin >> CODES; replace(CODES.begin(),CODES.end(),'C','1'); replace(CODES.begin(),CODES.end(),'O','2'); replace(CODES.begin(),CODES.end(),'M','3'); replace(CODES.begin(),CODES.end(),'P','4'); replace(CODES.begin(),CODES.end(),'U','5'); replace(CODES.begin(),CODES.end(),'T','6'); replace(CODES.begin(),CODES.end(),'E','7'); replace(CODES.begin(),CODES.end(),'R','8'); replace(CODES.begin(),CODES.end(),'S','9'); replace(CODES.begin(),CODES.end(),'X','0'); replace(CODES.begin(),CODES.end(),'c','1'); replace(CODES.begin(),CODES.end(),'o','2'); replace(CODES.begin(),CODES.end(),'m','3'); replace(CODES.begin(),CODES.end(),'p','4'); replace(CODES.begin(),CODES.end(),'u','5'); replace(CODES.begin(),CODES.end(),'t','6'); replace(CODES.begin(),CODES.end(),'e','7'); replace(CODES.begin(),CODES.end(),'r','8'); replace(CODES.begin(),CODES.end(),'s','9'); replace(CODES.begin(),CODES.end(),'x','0'); cout << "Value: " << CODES << endl; cout << "Do you want to enter another code? (Y/N) "; cin >> choice; } while(strcmpi(choice, 'yes') == 0 ||strcmpi(choice, 'y') == 0 ); { if (strcmpi(choice, 'no') == 0 || strcpmi(choice, 'no' == 0); { cout << "Program terminate"; } } return 0; } any help will be appreciated, thank you very much ps. i prefer classic c++ |
Javascript canvas produces different base64 output [duplicate] Posted: 08 May 2022 07:00 PM PDT What I'm currently doing is to append a HTML canvas to my HTML body, draw a base64 image on it and afterwards call the toDataUrl() function to retrieve the base64 code back from the canvas (code developed in TypeScript): // draw base64 image on a canvas via an Image const canvas = document.createElement('canvas'); document.body.appendChild(canvas); const ctx = canvas!.getContext('2d'); const image = new Image(); image.src = base64data; // load image and retrieve base64 code from canvas image.onload = function () { ctx!.drawImage(image, -image.width / 2, -image.height / 2); canvas!.toDataURL('image/' + imageType, 1) document.body.removeChild(canvas); }; The issue here is that the toDataURL() function generates different base64 code in Firefox than in Chrome. Do I have to change anything? It is really important for me that the same base64 code is produced in all browsers. |
Vue slide animation doesn't animate container Posted: 08 May 2022 07:01 PM PDT I always struggle to grasp how simple concepts as slide down and up can be so problematic with nowadays powerful webdev tools. I have the following Vue transition: <transition :duration="1000" enter-active-class="transform transition duration-300 ease-custom" enter-from-class="-translate-y-1/2 scale-y-0 opacity-0" enter-to-class="translate-y-0 scale-y-100 opacity-100" leave-active-class="transform transition duration-300 ease-custom" leave-from-class="translate-y-0 scale-y-100 opacity-100" leave-to-class="-translate-y-1/2 scale-y-0 opacity-0" > This is a part of a scrollable landing page. Inside this transition I have a block of that page with full width: <div class='bg-red-500' v-show='anyActive'> <div class='max-w-7xl h-full mx-auto py-5 text-gray-100 font-titles px-5 relative'> Example content </div> </div> The transition works however, the content that is supposed to be beneath this animated div doesn't slide with it and instead just jumps to where it's supposed to be before and then after the animation finishes. |
Warning: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be Posted: 08 May 2022 07:01 PM PDT I get this warning every time I reload my browser. The warning is not saying which line or which component I need to modify/change to rid of this warning. How can I get rid of it? VM20439 react_devtools_backend.js:3973 Warning: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`. at select at div at form at div at div at ReviewForm at div at div at Home (http://localhost:3000/static/js/bundle.js:1407:86) at Routes (http://localhost:3000/static/js/bundle.js:91954:5) at div at div at App at Router (http://localhost:3000/static/js/bundle.js:91887:15) at BrowserRouter (http://localhost:3000/static/js/bundle.js:90697:5) enter image description here |
Concatenating arrays of different sizes Posted: 08 May 2022 07:03 PM PDT I am trying to do a quadtree algorithm on numpy array of points created by make_blobs function from sklearn . I am trying to create an Recursive Partition KMeans in which the centroids are found in each quadtree partition of the space. Here is my partitioning function: def partition(self, data): if data.size != 0: minX = np.min(data[:,0]) maxX = np.max(data[:,0]) minY = np.min(data[:,1]) maxY = np.max(data[:,1]) middleX = (maxX + minX)/2 middleY = (maxY + minY)/2 parts1 = np.array([i for i in data if i[0] < middleX and i[1] > middleY]) parts2 = np.array([i for i in data if i[0] > middleX and i[1] > middleY]) parts3 = np.array([i for i in data if i[0] < middleX and i[1] < middleY]) parts4 = np.array([i for i in data if i[0] > middleX and i[1] < middleY]) parts = np.array([parts1, parts2, parts3, parts4]) return parts else: return np.array([[], [], [], []]) My dataset created by the make_blobs function has the following structure: [[ 9.26360832 -9.18849755] [ 7.3971609 9.92622627] [ 7.29022892 -10.39359926] ... [ 8.66667995 -11.99184453] [ 5.80627027 10.53947197] [ 6.14214488 -0.73405016]] The example output of this function could be: [array([[3.95348068, 4.74190848]]) array([[4.47174131, 4.67345222], [4.73856072, 4.68464296]]) array([], dtype=float64) array([[4.48952751, 4.38898038], [4.47734611, 4.34300488]])] , which is shape (4,). However it could be also shape (4,1,2) like following: [[[-7.17718091 -4.92636967]] [[-6.66796907 -4.94025585]] [[-7.03501112 -5.17783394]] [[-6.45835039 -5.17271443]]] Then I am trying to concatenate the partitions, so that I get one big array of arrays with the partitions. This is the line responsible for concatenation: part_data = np.hstack([self.partition(d) for d in part_data if np.shape(self.partition(d)) != (4,0)]) The problem occurs when the partitions are empty or equal, so the shape is (4,0), (4,1,2) or (4,2,2). The arrays cannot get concatenated that way. The error states following: ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 10 has 3 dimension(s) Would it be possible to ignore these shapes or somehow reshape them to (4,)? Maybe there is some trick to append not as array but as an object? I would be grateful for any response. This is the whole code for this example: import numpy as np from sklearn.datasets import make_blobs def generateDataset(k, dimensions, n_samples): X, y_true = make_blobs(n_samples = n_samples, centers = k, n_features= dimensions, cluster_std = 1.1) return X, y_true X, y_true = generateDataset(3,2,10000) def partition(data): if data.size != 0: minX = np.min(data[:,0]) maxX = np.max(data[:,0]) minY = np.min(data[:,1]) maxY = np.max(data[:,1]) middleX = (maxX + minX)/2 middleY = (maxY + minY)/2 parts1 = np.array([i for i in data if i[0] < middleX and i[1] > middleY]) parts2 = np.array([i for i in data if i[0] > middleX and i[1] > middleY]) parts3 = np.array([i for i in data if i[0] < middleX and i[1] < middleY]) parts4 = np.array([i for i in data if i[0] > middleX and i[1] < middleY]) parts = np.array([parts1, parts2, parts3, parts4]) return parts else: return np.array([[], [], [], []]) part_data = partition(X) for i in range(6): if i >= 1: part_data = np.hstack([partition(d) for d in part_data if np.shape(partition(d)) != (4,0)]) |
apple pay option not coming in stripe Posted: 08 May 2022 07:01 PM PDT backend @app.route('/create-payment-intent', methods=['POST']) def create_payment(): try: data = json.loads(request.data) # Create a PaymentIntent with the order amount and currency intent = stripe.PaymentIntent.create( amount=calculate_order_amount(data['items']), currency='usd', automatic_payment_methods={ 'enabled': True, }, ) return jsonify({ 'clientSecret': intent['client_secret'] }) except Exception as e: return jsonify(error=str(e)), 403 frontend export default function App() { const [clientSecret, setClientSecret] = useState(""); useEffect(() => { // Create PaymentIntent as soon as the page loads fetch("/create-payment-intent", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ items: [{ id: "xl-tshirt" }] }), }) .then((res) => res.json()) .then((data) => setClientSecret(data.clientSecret)); }, []); const appearance = { theme: "stripe", }; const options = { clientSecret, appearance, }; return ( <div className="App"> {clientSecret && ( <Elements options={options} stripe={stripePromise}> <CheckoutForm /> </Elements> )} </div> ); } here is my stripe code where i am expecting google pay to come but it is not coming. I am using live stripe acccount for testing . https://dev.polyverse.app/pay here is the my application you can check. |
NumberFormatter and unsigned with UInt64.max Posted: 08 May 2022 07:00 PM PDT I'm trying to create a string representing UInt64.max using NumberFormatter . Here's the code: let formatter = NumberFormatter() formatter.usesGroupingSeparator = true formatter.numberStyle = .decimal formatter.positiveFormat = "# ##0.#########" formatter.maximumSignificantDigits = 20 formatter.usesSignificantDigits = false formatter.maximumFractionDigits = 20 formatter.minimumFractionDigits = 0 formatter.alwaysShowsDecimalSeparator = false // formatter.roundingMode = .halfUp let text1 = formatter.string(for: NSNumber(value: Int64.max)) let text2 = formatter.string(for: NSNumber(value: UInt64.max)) print(text1) print(text2) which prints: Optional("9,223,372,036,854,780,000") Optional("-1") but should print Optional("9223372036854775807") Optional("18,446,744,073,709,551,615") It looks like NSNumber is rounding Int64 and isn't taking the UIn64 . The obj-c version of NSNumberFormatter works fine. Am I missing something or is there a problem with NumberFormatter ? |
Error trying to create Mock.Of<ControllerContext>() for ASP.Net Core 3.1 Unit Test Posted: 08 May 2022 07:03 PM PDT As per last section of the Moq Quickstart defined here, I am trying to configure the following Mock in order to pass Form values to the controller method under test: var formCollection = new FormCollection( new System.Collections.Generic.Dictionary<string, Microsoft.Extensions.Primitives.StringValues>() { {"mAction", "someAction" }, {"mRefId", "0" } }); var controllerContext = Mock.Of<ControllerContext>(ctx => ctx.HttpContext.Request.Form == formCollection); controller.ControllerContext = controllerContext; However, when the run the test, it fails on the Mock.Of<> line with the following error: System.NotSupportedException : Unsupported expression: mock => mock.HttpContext Non-overridable members (here: ActionContext.get_HttpContext) may not be used in setup / verification expressions. What am I missing? Am I not doing it the same as per the example defined in the Quickstart document? |
Use textarea input in JavaScript Posted: 08 May 2022 07:03 PM PDT I'm trying to create a script that uses the input. <textarea id="textareabox" name="textarea1" placeholder="Start here..."></textarea> function hintbutton4() { document.getElementById("textareabox").innerHTML = 'ID=textareabox'; } I've got this, but I don't know how to grab the text as input... How can I do it? What should I search for? I want the input from the text area used in the script in the last part 'ID=textareabox'. That's all. |
No comments:
Post a Comment