sqrt() in threaded environment returns nan when it should not [on hold]

Uncategorized
Question: The code below is part of my threaded function where I pass output data to an array. In my square root function I have sum of two squares which means values inside of brackets is never negative. Somehow some of the values in output is nan. for(i=0; ibase[i].re * data->base[i].re) + (data->base[i].im * data->base[i].im)); printf("%d - %f - %f - %fn", i, data->base[i].re*data->base[i].re, data->base[i].im*data->base[i].im, sqrt((data->base[i].re * data->base[i].re)+ (data->base[i].im * data->base[i].im))); } Answer: You must be sure that vars used in threads, eg. for loop indices used to access arrays, are private to the calling thread when the need to be, eg. automatic storage or thread-local. In your code, it is possible that 'i', if not private to the thread could be changed by another thread while the sqrt() expression…
Read More

accessing an objects key in js

javascript
Question: I have this array of objects const relationData = [ { kids: [ { text: 'Newborn', value: 'newborn' }, { text: 'For under 5's', value: 'under5' }, { text: 'Teenagers', value: 'teenagers' } ] }, how would i access the word kids in here? i want to check if myvalue == kids? i have tried doing:for (var key in data) { console.log(key); } but this just seems to return me an index PS I DONT WANT TO MENTION THE WORD KIDS AS I WONT IT TO BE RESUABLE Answer: You can loop through the keys of each obj in relationData like below for (var index in relationData) { var keys = Object.keys(relationData[index]); console.log(keys.indexOf("kids") > -1)// then relationData has an object with a key of "kids" } "kids" can be…
Read More

Laravel 5 mimetypes validation not working?

Uncategorized
Question: I want to upload PHP File, Here is my validation 'fileName' => 'required|mimetypes:application/x-php', But what I get is The file name must be a file of type: application/x-php. already try mimes:x-php but result still same. Here is dump for uploaded file "fileName" => UploadedFile {#295 ▼ -test: false -originalName: "file.php" -mimeType: "application/x-php" ... } Here is my Request header payload ------WebKitFormBoundaryT3tTSUWDyAThwRK6 Content-Disposition: form-data; name="fileName"; filename="file.php" Content-Type: application/x-php Where I'm doing wrong? Thanks in advance. Answer: Read more
Read More

pygame selection menu navigation using arrow keys and return

Uncategorized
Question: I am trying to make it so I can generate a group of options to select from and using the up and down arrows the user can navigate between them the current option being highlighted and if you press enter it calls the function that option contains. Excuse the mess, I had it cleaner, but was trying several things to try to get the intended result. The selection function works fine by itself def selection(text, selected_status, x, y, function):if selected_status:fill_rect(black, x, y, display_width - x, font_size + 2) fill_rect( settings[3], x, y, display_width - x, font_size +2) message_to_screen("["+ text + "]", settings[3], black, x, y) if event_handler() == pygame.K_RETURN:function() return True elif not selected_status:fill_rect(black, x, y, display_width - x, font_size + 2) message_to_screen("["+ text + "]", black, settings[3], x,…
Read More

Chicky – WordPress Fashion Marketplace Theme

Uncategorized
Hello Visitor We’d like to offer Chicky – WordPress Fashion Marketplace Theme. Chicky WordPress Theme is unique in its style, just take a look at theme’s live demo. If you would like your online shop to stand out, consider Chicky WooCommerce Marketplace Theme. Our Primary live demo of the theme is Fashion Marketplace, but the theme will suite for any kind of online shop, more demos are coming. Chicky WooCommerce Fashion Theme is packed with features:
Read More

How to get zsh to start automatically in Mac iTerm?

Uncategorized
Question: I am sure this is a configuration issue, but I cannot find what is wrong. I have zsh and oh-my-zsh installed on my new Mac view homebrew. When I start terminal it doesn't load zhs theme or autocomplete unless I run zsh command to start it. After that all works fine. However, all the aliases I setup in .zshrc file works fine without running zsh and there is no .bashrc file in the machine. How can I make zsh to start automatically when I open iTerm. Answer: Read more
Read More

Ionic CLI 3.8 Update – Cordova is not available

Uncategorized
Question: Background After updating my Ionic CLI on two completely separate Ionic apps (for verification of the error), I have tried compiling, building, running, and emulating these apps both on my iPhone and on the XCode emulator. Here is the warning I received after the update:> twine-app@0.0.1 run /Users/Anthony/dev/twine-app > ionic cordova run ios --l --consolelogs ✖ cordova platform add ios --save - failed! [WARN] Platform already added. Saving platforms to config.xml. ✔ cordova platform save - done! [WARN] Detected @ionic/cli-plugin-cordova in your package.json. As of CLI 3.8, it is no longer needed. You can uninstall it. [WARN] Multiple network interfaces detected! So, after seeing this warning, I tried running the app both using livereload on my iPhone and in the XCode emulator using the following lines of code:ionic cordova…
Read More