How to build an ensemble by combining features extracted from gap layer of 3 pretrained deep learning models Posted: 05 Jul 2022 01:48 AM PDT I trained mobilenetv2, InceptionV3 and Xception pre-trained models with dataset. I saved them with .h5 format. Now i want to build an ensemble in this way. First to extract features from gap layer of all above 3 models, second concatenate these features and third give it to sigmoid layer for classification. I trained and saved models model1.save('models/model1.h5')# mobilenetv2 model2.save('models/model2.h5')# InceptionV3 model3.save('models/model3.h5')# Xception Iam not able to get idea to code to build an ensemble as per above specifications in python. Pls help me |
Do I have to use and 'extend' eslint-plugin-react in eslintrc.js config while using and extending 'eslint-config-airbnb' already Posted: 05 Jul 2022 01:48 AM PDT I updated my Eslint rules using airbnb in my React typescript project. My project doesn't use 'create-reac-app'. So I have to extend airbnb since I am also using and extending airbnb-typescript . eslint-plugin-react and eslint-plugin-react-hooks are peer dependencies of eslint-config-airbnb . So do I need to extend plugin:react/recommended' ? I have this in the extend property inside eslintrc.js: extends: [ 'airbnb', 'airbnb-typescript', 'airbnb/hooks', // "plugin:@typescript-eslint/recommended", // "plugin:@typescript-eslint/recommended-requiring-type-checking", // "plugin:eslint-comments/recommended", 'plugin:react/recommended', 'plugin:jest/recommended', 'plugin:prettier/recommended', ], To get the best out of Eslint and React, do I have to extend 'plugin:react/recommended', or something else or can I remove it since I am using airbnb and airbnb-typescript ? |
Laravel Eloquent giving different result from MySQL / MariaDB query when using "WHERE CONCAT" Posted: 05 Jul 2022 01:48 AM PDT I have a laravel eloquent query that is giving me a different result from the same query that I try at MariaDB Eloquent: $invoice = PurchaseInvoice::select("purchase_invoices.*", "purchase_contracts.contract_no", "partners.name as partner_name") ->join("purchase_contracts","purchase_contracts.id","purchase_invoices.purchase_contract_id") ->join("partners","partners.id","purchase_contracts.partner_id") ->join("commodity_po","purchase_contracts.id","commodity_po.purchase_contract_id") ->where("purchase_invoices.invoice_no", 'LIKE', '%'.$request->q.'%') ->orWhere("purchase_invoices.po_additional_no", 'LIKE', '%'.$request->q.'%') ->orWhere("purchase_contracts.contract_no", 'LIKE', '%'.$request->q.'%') ->orWhereRaw("(CONCAT(`contract_no`, `po_additional_no`) LIKE '%?%')", [$request->q])->get() and it will generate query like this : select `purchase_invoices`.*, `purchase_contracts`.`contract_no`, `partners`.`name` as `partner_name` from `purchase_invoices` inner join `purchase_contracts` on `purchase_contracts`.`id` = `purchase_invoices`.`purchase_contract_id` inner join `partners` on `partners`.`id` = `purchase_contracts`.`partner_id` inner join `commodity_po` on `purchase_contracts`.`id` = `commodity_po`.`purchase_contract_id` where (purchase_invoices.invoice_no LIKE '%SLP0622/6A-%' or purchase_invoices.po_additional_no LIKE '%SLP0622/6A-%' or purchase_contracts.contract_no LIKE '%SLP0622/6A-%' or (CONCAT(`contract_no`, `po_additional_no`) LIKE '%SLP0622/6A-%')) and `purchase_invoices`.`deleted_at` is null; when I run the query on laravel, it give me empty result but when I run the generated query on MySQL it give me 1 result Does anyone know why this can happened? is this because there is a slash '/' on the query? |
In ggplot, why does one have to separately set axis.text.x and axis.text.y to element_blank() instead of just axis.text? Posted: 05 Jul 2022 01:48 AM PDT This code produces this plot: ggplot(mtcars, aes(x = cyl, y = mpg))+ geom_line()+ theme(axis.text = element_blank()) Where it seems that axis.text argument doesn't work. In order to make it work, one needs to do this: ggplot(mtcars, aes(x = cyl, y = mpg))+ geom_line()+ theme(axis.text.x = element_blank(), axis.text.y = element_blank()) My question is why? |
how to check password reset link in email with selenium Posted: 05 Jul 2022 01:48 AM PDT how to check password reset link in email with selenium i checked with below code but getting error List<WebElement> a1 = driver.findElements(By.xpath("//*[@class='mail']/span")); System.out.println(a1.size()); for (int i = 0; i < a1.size(); i++) { System.out.println(a1.get(i).getText()); if (a1.get(i).getText().equals("reest password")) //to click on a mail. { a1.get(i).click(); } } could you help me to resolve |
How to distribute an iOS app to a client organisation's employees? Posted: 05 Jul 2022 01:47 AM PDT We are a contracting company and we develop software that we provide use to clients via subscription service. We've just built an app on iOS for the first time and are trying to figure out how to distribute it to our client's employees. Unfortunately our client has some roadblocks and will not be getting Apple Business Manager. The client would also like to use their MDM software Citrix to manage the app. No clue how to incorporate this. So from my understanding, the only other way to distribute it is to sign the app with their ad-hoc profile and then provide a download link? Is this correct or is there a better way to do it? I've looked at Enterprise distribution but it looks as if this method assumes the organisation distributing the app has full proprietary ownership of the application which is not the case here (we own it). Is there a way around this? I'm learning the ropes here so not really sure what the best approach is. Would appreciate any further insight given the context I've provided. Cheers! |
Is there a solution for this error `MSB6006`? Posted: 05 Jul 2022 01:47 AM PDT MSB6006: "java.exe" exited with code 2. 0 I have this error Severity Code Description Project File Line Suppression State Error MSB6006: "java.exe" exited with code 2. 0 I tried to 1 -enable multi_dex 2- downgrade vs to 2019 3- disable sign the .apk file 4- set code shrinker to r8 5-remove unsupported ( .net 5) run time 6- return to last backup. and I have searched at many websites for 7 days with out benefit . Note some of my trails I get the error ADB0010 |
what is the solution of this error in asp.net core 6 Posted: 05 Jul 2022 01:47 AM PDT |
Set size proportional to x and y axis Posted: 05 Jul 2022 01:47 AM PDT The x axis, y axis and size are dependent on 3 fields whose values are dynamic: x: population y: GDP size: land area There's a symbolSize property in option where we can set the bubble size, but I'm not sure what formula to use so size is proportional to x and y axis values. symbolSize: (d: any) => { return d[2]; }, |
How to save text written in a textbox in JS Posted: 05 Jul 2022 01:48 AM PDT Hello I am trying to save text from a text box in JS to a variable I have this code right now var option = document.createElement('li'); var optionDiv = document.createElement('div'); var nameDiv = document.createElement('div'); var textDiv = document.createElement('div'); var saveButton = document.createElement('span'); // Create: div id's var optionDivId = "option" + "" + questionNumber + subquestionNumber; var textBoxId = "checkbox" + "" + questionNumber + subquestionNumber; var labelId = "label" + "" + questionNumber + subquestionNumber; var saveButtonId = "save-shAnli" + "" + questionNumber + subquestionNumber; // Create label and textBox var textBox = document.createElement('textarea'); var label = document.createElement('label'); // Give id and attributes to textBox textBox.id = textBoxId; textBox.className = "shAnTextbox"; textBox.rows = "4"; textBox.cols = "30"; // Give id and attributes to label label.id = labelId; label.className = "shAnSubquestionName"; // Give id and attributes to optionDiv optionDiv.id = optionDivId; optionDiv.className = "shAnSubquestion"; saveButton.id = saveButtonId; saveButton.className = "save-shAnli"; textBoxId.htmlFor = option; label.appendChild(document.createTextNode('Your Question')); q.appendChild(option) // Add li as child of ul nameDiv.appendChild(label); //add label to nameDiv textDiv.appendChild(textBox); //add textBox to textDiv optionDiv.append(nameDiv) // Add nameDiv as child of li optionDiv.append(textDiv) // Add optionDiv as child of li optionDiv.appendChild(saveButton); saveButton.appendChild(document.createTextNode('Save Text')); option.append(optionDiv) // Add optionDiv as child of li var shtext = document.getElementById(textBoxId).value; Allquestions[questionNumber][4] = shtext; document.getElementById("testingBox6").innerHTML = shtext; document.getElementById("testingBox4").innerHTML = Allquestions; When I click the save button I want to get the text in shtext variable. Do you know any way I can do this? Thank you for your time enter code here |
Please help me to solve this java program (the whole question is attached below as pic(click the question link)) [closed] Posted: 05 Jul 2022 01:47 AM PDT question I tried, but it's not giving me the correct output |
In Dynamics NAV, what are the variables text@digits in C/AL? Posted: 05 Jul 2022 01:48 AM PDT I am new to Dynamics Navision, I have not been able to find and answer via web search. In the following few line of C/AL code, could someone please tell me what do @10000000 , @10002000 , Text[512] and Codeunit 50000 mean? PS: I made up the numbers for demo purpose. VAR abc@10000000 : Text[512]; def@10002000 : Codeunit 50000; |
how to span 2 row in "Bootstrap"? Posted: 05 Jul 2022 01:47 AM PDT so the question is clear. how can i span 2 row with bootstrap ? i wanna achieve exactly something like this. i will really appreciate some help. Please take a look at this image <div class="row"> <div class="col-2"> <h1>THIS SHOULD SPAN 2 COLUMN</h1> </div> <div class="col"> <div class="card">a card</div> </div> <div class="col"> <div class="card">a card</div> </div> <div class="col"> <div class="card">a card</div> </div> </div> |
CSV file in Python row Posted: 05 Jul 2022 01:48 AM PDT Why I am getting the space after one row and it is moving onto third row, when I write the code to open a CSV file in excel? I have used the code below. import csv with open("self_taught.csv", "w") as csvfile: spamwriter = csv.writer(csvfile, delimiter=",") spamwriter.writerow(["one", "two", "three"]) spamwriter.writerow(["four", "five", "six"]) |
String formatting vs String Interpolation Posted: 05 Jul 2022 01:48 AM PDT Please help me understand the difference between the two concepts of String Formatting and String Interpolation. From Stackoverflow tag info for string-interpolation : String interpolation is the replacement of defined character sequences in a string by given values. This representation may be considered more intuitive for formatting and defining content than the composition of multiple strings and values using concatenation operators. String interpolation is typically implemented as a language feature in many programming languages including PHP, Haxe, Perl, Ruby, Python, C# (as of 6.0) and others. From Stackoverflow tag info for string-formatting : Commonly refers to a number of methods to display an arbitrary number of varied data types into a string. To me, they appear to be similar, but I hope there's some difference. Also, kindly clarify whether these are some technology-specific concepts, or, technology-agnostic concepts. (I was reading about these concepts in the context of Python. But quick google and bing searches brought up related articles in other programming languages such as Java, C#, etc.) |
D3 - migrate multi column chart code from v3 to v7 Posted: 05 Jul 2022 01:47 AM PDT I have multi column chart in D3 v3 and I have to port this code to new D3 v7. In old version column generated, in new i have column groups but not generate column in groups. What I doing wrong? // serries let series = this.seriesContainer.selectAll('.series') .data(this.data.series); series.enter() .append('g') .classed('series', true) .attr('fill', (s, i) => colorTable[i]) .attr('transform', (s, i) => this.createTranslateProperty((i * (categoryScale.bandwidth() / this.data.series.length)))); series.exit().remove(); // columns let dataSelector = (s: ColumnChartDataSeriesModelI) => s.values let columns = series.selectAll('.columnChartColumn').data(dataSelector); columns.enter() .append('rect') .classed('columnChartColumn', true); columns.attr("rx", 5) .attr("font-size", 10) .attr('width', (categoryScale.bandwidth() / this.data.series.length) - 2) .attr('height', 10) .attr('y', 10) .attr('x', (v, i) => categoryScale(this.data.categories[i])); columns.exit().remove(); // data model export interface ColumnChartDataSeriesModelI { values: Array<number> }; In effect in V7 I got HTML ... <g class="columnChartSeriesContainer"> <g class="series" fill="#0084F5" transform="translate(0,0)"></g> <g class="series" fill="#FA8F32" transform="translate(23,0)"></g> </g> ... when old V3 generate HTML <g class="columnChartSeriesContainer"> <g class="series" fill="#0084F5" transform="translate(0,0)"> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="270" y="0" x="1"></rect> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="210" y="60" x="63"></rect> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="150" y="120" x="125"></rect> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="150" y="120" x="187"></rect> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="240" y="30.000000000000014" x="249"></rect> </g> <g class="series" fill="#FA8F32" transform="translate(25,0)"> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="60" y="210" x="1"></rect> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="180" y="90.00000000000001" x="63"></rect> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="89.99999999999997" y="180.00000000000003" x="125"></rect> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="30" y="240" x="187"></rect> <rect class="columnChartColumn" rx="5" font-size="10" width="23" height="60" y="210" x="249"></rect> </g> </g> |
Don't allow one ubuntu user to see data from other user in ubuntu [closed] Posted: 05 Jul 2022 01:47 AM PDT I have two users inside the home directory (home/user1 and home/user2). I want to give them all permissions but I don't want user2 to see data from user1. He could be able to install whatever he wants but he could not get into the user1 directory. How can I do that? I am bit loss managing permissions of this kind. Thanks. |
Mongodb qoery containing a JS function returning missing ")" error when passed as string in python file Posted: 05 Jul 2022 01:48 AM PDT I'm having one database with nested fields, To iterate over nested fields and to get find a specific value, I'm having this query, which is working fine in robo3t, but when I put it into python file for using in project. I get error. Query in robo3t is this- db.collection.find({$where: function() { function deepIterate(obj, value) { for (field in obj) { if (obj[field] == value){ return true; } found = false; if ( typeof obj[field] === 'object' ) { found = deepIterate(obj[field], value) if (found) { return true; } } } return false; }; return deepIterate(this, "10.174.113.7") }} ) Passing it in python after converting to string like this - db.collection.find({"$where" : "function() {" "function deepIterate(obj, value) {" "for(field in obj) {" "if (obj[field] == value ) {" "return obj;" "};" "found = false;" "if" "(typeof obj[field] === 'object') {" "found" "=" "deepIterate(obj[field], value);" "if" "(found)" "{return true};" "};" "};" "return false;" "};" "return deepIterate(this," + "58:FB:96:16:1D:F0"+ ")" "}" }) Errors that I'm getting - Traceback (most recent call last): File "test.py", line 39, in <module> for a in collection.find(db_query): File "/usr/local/lib/python3.8/dist-packages/pymongo/cursor.py", line 1238, in next if len(self.__data) or self._refresh(): File "/usr/local/lib/python3.8/dist-packages/pymongo/cursor.py", line 1155, in _refresh self.__send_message(q) File "/usr/local/lib/python3.8/dist-packages/pymongo/cursor.py", line 1044, in __send_message response = client._run_operation( File "/usr/local/lib/python3.8/dist-packages/pymongo/mongo_client.py", line 1424, in _run_operation return self._retryable_read( File "/usr/local/lib/python3.8/dist-packages/pymongo/mongo_client.py", line 1525, in _retryable_read return func(session, server, sock_info, secondary_ok) File "/usr/local/lib/python3.8/dist-packages/pymongo/mongo_client.py", line 1420, in _cmd return server.run_operation( File "/usr/local/lib/python3.8/dist-packages/pymongo/server.py", line 130, in run_operation _check_command_response(first, sock_info.max_wire_version) File "/usr/local/lib/python3.8/dist-packages/pymongo/helpers.py", line 167, in _check_command_response raise OperationFailure(errmsg, code, response, max_wire_version) pymongo.errors.OperationFailure: SyntaxError: missing ) in parenthetical @:1:235 , full error: {'ok': 0.0, 'errmsg': 'SyntaxError: missing ) in parenthetical @:1:235\n', 'code': 139, 'codeName': 'JSInterpreterFailure'} Please help!! |
Forge CSV Data Adapter - Reference Application Data Visualization Posted: 05 Jul 2022 01:48 AM PDT I hope you are all doing well. I've been recently trying to modify the AutoDesk reference application to allow me to create a heat-map with my own sensors data and my own model. However, I have been having difficulties. Has anyone done something similar before? Do you have to create two separate .env files or do you just change both the credentials for the FORGE_ID portion and the CSV portion in the same one? Thank You, (I attached an example of what it looks like with only the CSV portion change.) Changed CSV portion |
Where and how should I initialize service which is used for sending requests like HttpClient? Posted: 05 Jul 2022 01:48 AM PDT I am using Google Vision API and its C# library. I want to understand where should I initialize ImageAnnotatorClient and how should I register GoogleVisionApiService . ImageAnnotatorClient is used for sending images to the Google Vision API, like this _imageAnnotatorClient.DetectSafeSearchAsync(image) . First way - register service as Singleton and initialize ImageAnnotatorClient in the constructor public class GoogleVisionApiService : IGoogleVisionApiService { private readonly IGoogleCredentialFactory _googleCredentialFactory; private readonly ImageAnnotatorClient _imageAnnotatorClient; public GoogleVisionApiService(IGoogleCredentialFactory googleCredentialFactory) { _googleCredentialFactory = googleCredentialFactory; _imageAnnotatorClient = InitializeClient(); } private ImageAnnotatorClient InitializeClient() { var googleCredential = _googleCredentialFactory.GetGoogleCredentialAsync().Result; var credential = googleCredential.UnderlyingCredential as ServiceAccountCredential; var imageAnnotatorClientBuilder = new ImageAnnotatorClientBuilder { Credential = credential }; var imageAnnotatorClient = imageAnnotatorClientBuilder.Build(); return imageAnnotatorClient; } public async Task<SafeSearchAnnotation> GetSafeSearchAnnotationAsync(string imageBase64) { var image = Image.FromBytes(Convert.FromBase64String(requestImage)); var labels = await _imageAnnotatorClient.DetectSafeSearchAsync(image); return labels; } } Second way is to register service as Transient and initialize client every time service is called public class GoogleVisionApiService : IGoogleVisionApiService { private readonly IGoogleCredentialFactory _googleCredentialFactory; public GoogleVisionApiService(IGoogleCredentialFactory googleCredentialFactory) { _googleCredentialFactory = googleCredentialFactory; } public async Task<SafeSearchAnnotation> GetSafeSearchAnnotationAsync(string imageBase64) { var googleCredential = await _googleCredentialFactory.GetGoogleCredentialAsync(); var credential = googleCredential.UnderlyingCredential as ServiceAccountCredential; var imageAnnotatorClientBuilder = new ImageAnnotatorClientBuilder { Credential = credential }; var imageAnnotatorClient = await imageAnnotatorClientBuilder.BuildAsync(); var image = Image.FromBytes(Convert.FromBase64String(requestImage)); var labels = await _imageAnnotatorClient.DetectSafeSearchAsync(image); return labels; } } |
Stop breaking up html elements in vscode - format on save Posted: 05 Jul 2022 01:47 AM PDT how can I stop my HTML code in VScode from breaking up the element into a new line with save on format? I have tried to check off multiple options but can't seem to find the one to stop this, I want it to format automatically but without those line breaks. I tried installing "prettier" extension now but have the same problem. Here is how I want it: <% layout('layouts/boilerplate')%> <div class="row"> <div class="col-6"> <div class="card mb-3"> <img src="<%= campground.image%>" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title"><%= campground.title%></h5> <p class="card-text"><%= campground.description%></p> </div> <ul class="list-group list-group-flush"> <li class="list-group-item text-muted"><%= campground.location%></li> <li class="list-group-item text-muted"><%= author.name%></li> <li class="list-group-item">$<%= campground.price%>/night</li> </ul> <div class="card-body"> <a class="card-link btn btn-info" href="/campgrounds/<%=campground._id%>/edit">Edit</a> <form class="d-inline" action="/campgrounds/<%=campground._id%>?_method=DELETE" method="POST"> <button class="btn btn-danger">Delete</button> </form> </div> <div class="card-footer text-muted"> 2 days ago </div> </div> </div> <div class="col-6"> <h2>Leave a Review</h2> <form action="/campgrounds/<%= campground._id %>/reviews " method= "POST" class="mb-3 validated-form" novalidate> <div class="mb-3"> <label class="form-label" for="rating">Rating</label> <input class="form-range" type="range" min="1" max="5" id="rating" name="review[rating]"> </div> <div class="mb-3"> <label class="form-label" for="body">Review</label> <textarea class="form-control" name="review[body]" id="body" cols="30" rows="3" required></textarea> <div class="valid-feedback"> Looks good! </div> </div> <button class="btn btn-success">Submit</button> </form> <% for( let review of campground.reviews) { %> <div class="card mb-3"> <div class="mb-2 card-body"> <h5 class="card-title">Rating: <%= review.rating %></h5> <p class="card-text">Rating: <%= review.body %></p> <form action="/campgrounds/<%= campground._id %>/reviews/<%= review._id %>?_method=DELETE" method="POST"> <button clasS="btn btn-sm btn-danger ">Delete</button> </form> </div> </div> <% } %> </div> </div> <!-- form -> class="mb-3 validated-form" novalidate < required> <div class="valid-feedback"> Looks good! </div> class in boilerplate db.reviews.deleteMany({}) --> Here is how it is changed: <% layout('layouts/boilerplate')%> <div class="row"> <div class="col-6"> <div class="card mb-3"> <img src="<%= campground.image%>" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title"> <%= campground.title%> </h5> <p class="card-text"> <%= campground.description%> </p> </div> <ul class="list-group list-group-flush"> <li class="list-group-item text-muted"> <%= campground.location%> </li> <li class="list-group-item text-muted"> <%= author.name%> </li> <li class="list-group-item">$<%= campground.price%>/night</li> </ul> <div class="card-body"> <a class="card-link btn btn-info" href="/campgrounds/<%=campground._id%>/edit">Edit</a> <form class="d-inline" action="/campgrounds/<%=campground._id%>?_method=DELETE" method="POST"> <button class="btn btn-danger">Delete</button> </form> </div> <div class="card-footer text-muted"> 2 days ago </div> </div> </div> <div class="col-6"> <h2>Leave a Review</h2> <form action="/campgrounds/<%= campground._id %>/reviews " method="POST" class="mb-3 validated-form" novalidate> <div class="mb-3"> <label class="form-label" for="rating">Rating</label> <input class="form-range" type="range" min="1" max="5" id="rating" name="review[rating]"> </div> <div class="mb-3"> <label class="form-label" for="body">Review</label> <textarea class="form-control" name="review[body]" id="body" cols="30" rows="3" required></textarea> <div class="valid-feedback"> Looks good! </div> </div> <button class="btn btn-success">Submit</button> </form> <% for( let review of campground.reviews) { %> <div class="card mb-3"> <div class="mb-2 card-body"> <h5 class="card-title">Rating: <%= review.rating %> </h5> <p class="card-text">Rating: <%= review.body %> </p> <form action="/campgrounds/<%= campground._id %>/reviews/<%= review._id %>?_method=DELETE" method="POST"> <button clasS="btn btn-sm btn-danger ">Delete</button> </form> </div> </div> <% } %> </div> </div> <!-- |
Newton's Fractal optimising Posted: 05 Jul 2022 01:48 AM PDT recently I wrote a program to graph Newton's Fractal, being able to move the roots of the equation around. However, the execution is very slow, and I am considering switching to a faster language. Is it possible to speed up the implementation more that I have or is it unfeasible? I have though about Pypy but it does not support cython. Is my use of numpy correct or can it be further optimised? import cython import numpy as np # cimport numpy as np import math from matplotlib.widgets import Slider # cimport matplotlib.plt as plt # plt.rcParams["figure.figsize"] = [7.50, 3.50] # plt.rcParams["figure.autolayout"] = True min, max = -2, 2 step = 0.01 def cmp(x,y): return x + 1j * y def faster_polyval(p, x): y = np.zeros(x.shape, dtype=np.complex128) for i, v in enumerate(p): y *= x y += v return y def newton(val, it, roots): eq = np.polynomial.polynomial.polyfromroots(roots) der = np.polyder(eq) li = 0 still_going = np.zeros(val.shape) for i in range(it): li = val # r = polyval_factory(eq) # k = polyval_factory(der) # val = val - np.polyval(eq,val)/np.polyval(der,val) # val = val - r(val)/k(val) val = val-faster_polyval(eq,val)/faster_polyval(der,val) converged = np.invert(abs(val-li) < 0.00000001) still_going[converged] = i return still_going fig, ax = plt.subplots() a = np.arange(min,max+step,step) b = np.arange(min,max+step,step) x, y = np.meshgrid(a, b) roots = [cmp(1,0), cmp(-0.5,math.sqrt(3)/2),cmp(-0.5,-math.sqrt(3)/2)] # eq = np.polynomial.Polynomial.fromroots(roots) # der = eq.deriv() ax.imshow(newton(cmp(x,y), 15, roots), cmap = 'inferno') ax_slider = plt.axes([0.20, 0.01, 0.65, 0.03], facecolor='yellow') slider = Slider(ax_slider, 'Root 1 real part', valmin=-2, valmax=2, valinit = roots[0].real) ax_slider = plt.axes([0.20, 0.04, 0.65, 0.03], facecolor='yellow') slider1 = Slider(ax_slider, 'Root 1 img part', valmin=-2, valmax=2, valinit = roots[0].imag) ax_slider = plt.axes([0.20, 0.07, 0.65, 0.03], facecolor='yellow') slider2 = Slider(ax_slider, 'Root 2 real part', valmin=-2, valmax=2, valinit = roots[1].real) ax_slider = plt.axes([0.20, 0.10, 0.65, 0.03], facecolor='yellow') slider3 = Slider(ax_slider, 'Root 2 img part', valmin=-2, valmax=2, valinit = roots[1].imag) ax_slider = plt.axes([0.20, 0.13, 0.65, 0.03], facecolor='yellow') slider4 = Slider(ax_slider, 'Root 3 real part', valmin=-2, valmax=2, valinit = roots[2].real) ax_slider = plt.axes([0.20, 0.16, 0.65, 0.03], facecolor='yellow') slider5 = Slider(ax_slider, 'Root 3 img part', valmin=-2, valmax=2, valinit = roots[2].imag) def update(val): roots[0] = cmp(val,roots[0].imag) ax.imshow(newton(cmp(x,y), 15, roots), cmap = 'inferno') fig.canvas.draw_idle() def update1(val): roots[0] = cmp(roots[0].real, val) ax.imshow(newton(cmp(x,y), 15, roots), cmap = 'inferno') fig.canvas.draw_idle() def update2(val): roots[1] = cmp(val,roots[1].imag) ax.imshow(newton(cmp(x,y), 15, roots), cmap = 'inferno') fig.canvas.draw_idle() def update3(val): roots[1] = cmp(roots[1].real,val) ax.imshow(newton(cmp(x,y), 15, roots), cmap = 'inferno') fig.canvas.draw_idle() def update4(val): roots[2] = cmp(val,roots[2].imag) ax.imshow(newton(cmp(x,y), 15, roots), cmap = 'inferno') fig.canvas.draw_idle() def update5(val): roots[2] = cmp(roots[2].real, val) ax.imshow(newton(cmp(x,y), 15, roots), cmap = 'inferno') fig.canvas.draw_idle() slider.on_changed(update) slider1.on_changed(update1) slider2.on_changed(update2) slider3.on_changed(update3) slider4.on_changed(update4) slider5.on_changed(update5) plt.show()``` |
PrimeFaces 11 fileupload Posted: 05 Jul 2022 01:48 AM PDT I am just trying to run simple fileupload with primefaces 11. My body is: <h:body> <h:form enctype="multipart/form-data"> <p:fileUpload value="#{fileUploadBean.uploadedFile}" mode="simple" skinSimple="true"/> <p:commandButton value="Submit" ajax="false" action="#{fileUploadBean.upload}" styleClass="p-mt-3 ui-button-outlined p-d-block"/> </h:form> </h:body> My bean is @Component public class FileUploadBean { private UploadedFile uploadedFile; private UploadedFiles files; public void upload() { String fileName = uploadedFile.getFileName(); String contentType = uploadedFile.getContentType(); byte[] contents = uploadedFile.getContent(); // Or getInputStream() } public void uploadMultiple() { System.err.println("uploadMultiple"); if (files != null) { for (UploadedFile f : files.getFiles()) { FacesMessage message = new FacesMessage("Successful", f.getFileName() + " is uploaded."); FacesContext.getCurrentInstance().addMessage(null, message); } } } public void handleFileUpload(FileUploadEvent event) { UploadedFile uploadedFile = event.getFile(); System.err.println(uploadedFile.getFileName()); FacesMessage message = new FacesMessage("Successful", event.getFile().getFileName() + " is uploaded."); FacesContext.getCurrentInstance().addMessage(null, message); } public UploadedFile getUploadedFile() { return uploadedFile; } public void setUploadedFile(UploadedFile uploadedFile) { this.uploadedFile = uploadedFile; } public UploadedFiles getFiles() { return files; } public void setFiles(UploadedFiles files) { this.files = files; } } I added this ones to web.xml <context-param> <param-name>primefaces.UPLOADER</param-name> <param-value>auto</param-value> </context-param> <filter> <filter-name>PrimeFaces FileUpload Filter</filter-name> <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class> </filter> <filter-mapping> <filter-name>PrimeFaces FileUpload Filter</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Map these files with JSF --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.faces</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> The problem is "upload" function is not triggering. If I delete the enctype="multipart/form-data" part "upload" function is triggering but uploadedFile field is getting null. Also I tried all examples in primefaces demo page and nothing is working. Is anyone has any idea ? I couldn`t find any answer that uses primefaces 11. Thanks |
How to resolve Network Error(CORS error) in REACT-Axios request call with ASP.NET Core 6 with Identity server Posted: 05 Jul 2022 01:47 AM PDT I am trying to add Google authentication to my website which is been developed using ASP.NET 6 with web API controller along with react and axios. The request call from axios is throwing Network error. As shown below Error: Network Error at createError (https://localhost:44331/static/js/bundle.js:48536:15) at XMLHttpRequest.handleError (https://localhost:44331/static/js/bundle.js:47921:14) message: "Network Error" isAxiosError: true When I check the browser console it throws error stating --> Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Access to XMLHttpRequest at 'https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=610964943445-9jinqs228qqa64kt9fqdsmo1mtkbg9ni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Flocalhost%3A44331%2Fsignin-google&scope=openid%20profile%20email&state=CfDJ8If3moGK8nFOrHvENOPET4upw6kmRMdILweas1dhbMn4xPQuR1iRNG_YyZmLF5U-1BGJAYpW2XDf_38k7Glu2UGC2MGe4lEP3G1kUm4FhQ39A4Cw3Mq9G3W4E9t7xJltqSWiDuNdu-MyJr39ykiFRYMziYWVcIhf9J-Ju6R4LlqQKpw5WL2BV2s84_vl8l1z1TCH2QX0Ifz6XPlEdpqK3G6MqI8OFsjMd96RimTzZIL00Q3Bkeb6JOpMl5TWoP3lRYPsR0sf2vEVnX1xYxoGFU0' (redirected from 'https://localhost:44331/signin/ExternalLogin?provider=Google') from origin 'https://localhost:44331' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Below are my code details--> Startup.cs--> public void ConfigureServices(IServiceCollection services) { services.AddAuthentication().AddGoogle(googleOptions => { googleOptions.ClientId = configuration.Google.ClientId; googleOptions.ClientSecret = configuration.Google.ClientSecret; }); services.AddCors(options => options.AddPolicy("MyPolicy", builder => { builder .WithOrigins("https://localhost:44331") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); })); services.AddAuthentication(IISDefaults.AuthenticationScheme); services.AddControllers(); services.AddMvc(); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; }); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { .. app.UseRouting(); app.UseAuthentication(); app.UseCors("MyPolicy"); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); } SignInController.cs--> [ApiController] [Route("[controller]/[action]")] public class SignInController : ControllerBase { ... [EnableCors("MyPolicy")] [AllowAnonymous] [HttpPost] public IActionResult ExternalLogin(string provider, string returnUrl=null) { var redirectUrl = Url.Action("ExternalLoginCallback", "SignIn", new { ReturnUrl = returnUrl }); var properties = _signInManager .ConfigureExternalAuthenticationProperties(provider, redirectUrl); return new ChallengeResult(provider, properties); } } reactapicall.jsx--> import axios from "axios"; const baseUrl = "/signin/" export default { login(url = baseUrl) { return { gmail: providerName => axios.post(url + "ExternalLogin?provider=" + providerName, null, { headers: { 'content-type': 'application/json', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': '*'} }) } } } launchSettings.json--> "iisSettings": { "windowsAuthentication": true, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "https://localhost:44331", "sslPort": 44331 } package.json--> { "name": "best_ui_react_app", "version": "0.1.0", "private": true, "proxy": "https://localhost:44331", "dependencies": { "@emotion/react": "^11.4.1" } .. } I have tried all the approaches but none of them worked. Please give me some suggestions so that I can fix this issue. |
IIS rewrite still active eventhough it is disabled Posted: 05 Jul 2022 01:47 AM PDT I have this iis site for which I have added some rewrite rules. The rewrite rule itself is simple If I access the site www.a.com rewrite/redirect to www.b.com and redirect subpages to corresponding subpages on www.b.com So have via IIS manager setup some rewrite rules. <rewrite> <rules> <clear /> <rule name="Redirect to https" stopProcessing="true"> <match l=".*" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" l="https://{HTTP_HOST}{REQUEST_I}" redirectType="Permanent" appendQueryString="false" /> </rule> <rule name="https://shop.a.com/5e/ -> https://www.b.com/products/5/" enabled="true" patternSyntax="ExactMatch" stopProcessing="true"> <match l="https://shop.a.com/5e/" /> <action type="Redirect" l="https://www.b.com/products/5/" logRewrittenl="false" /> </rule> <rule name="https://shop.a.com/5e/ -> https://www.b.com/products/5/" enabled="true" patternSyntax="ExactMatch" stopProcessing="true"> <match l="https://shop.a.com/5e/" /> <action type="Redirect" l="https://www.b.com/products/5/" logRewrittenl="false" /> </rule> <rule name="https://shop.a.com/10e/ -> https://www.b.com/products/10/" enabled="false" patternSyntax="ExactMatch" stopProcessing="true"> <match l="https://shop.a.com/10e/" /> <action type="Redirect" l="https://www.b.com/products/10/" logRewrittenl="true" /> </rule> <rule name="https://shop.a.com/16e/ -> https://www.b.com/products/16/" enabled="false" patternSyntax="ExactMatch" stopProcessing="true"> <match l="https://shop.a.com/16e/" /> <action type="Redirect" l="https://www.b.com/products/16/" logRewrittenl="true" /> </rule> <rule name="https://shop.a.com/3e/ -> https://www.b.com/products/3/" enabled="false" patternSyntax="ExactMatch" stopProcessing="true"> <match l="https://shop.a.com/3e/" /> <action type="Redirect" l="https://www.b.com/products/3/" logRewrittenl="true" /> </rule> </rules> </rewrite> prior to this I had a rewrite that rewrote shop.a.com to www.b.com This one should not be active anymore, but for somereason is this still active, and all the other rules listed here does not seem to work. When I access shop.a.com/5e I enter www.b.com. The network tab in chrome states that the url is being redirected to www.b.com, but have no idea where this redirect is listed if not in the web.config? the url mentioned here are only examples and not the actual sites being managed. Any idea on why this redirect is doing this? |
Export a folder of SQL queries into CSV in SSIS Posted: 05 Jul 2022 01:48 AM PDT I am a newbie to SSIS and currently struggling with executing SQL task saving the result in a result set and exporting each table to a respective CSV using a data flow task. There are 15 .sql files stored in a folder which I am creating a variable called FolderPath pointing towards them. Then I create a for each container that reads from a folder and create a variable in the variable mapping which is called SQLfile . Inside the for-each container I have an execute SQL task which I changed its file connection variable and edited the expression to FolderPath + SQLfile . Executing this loop works, when the result set value is set to none. Now I am trying to connect the tables created from this loop in a data flow task. I have no idea how to do this but I am guessing it has something to do with the result set. When I change the result set to full result set my loop breaks. I am assuming you cant have a result set inside a loop. Now I am completely lost as I don't know how to save the result of those 15 tables and how to declare them as source in the data flow task. |
How to plot geodesic curves on a surface embedded in 3D? Posted: 05 Jul 2022 01:47 AM PDT I have in mind this video, or this simulation, and I would like to reproduce the geodesic lines on some sort of surface in 3D, given by a function f(x,y), from some starting point. The midpoint method seems computationally and code intense, and so I'd like to ask if there is a way to generate an approximate geodesic curve based on the normal vector to the surface at different points. Each point has a tangent vector space associated with it, and therefore, it seems like knowing the normal vector does not determine a specific direction to move forward the curve. I have tried working with Geogebra, but I realize that it may be necessary to shift to other software platforms, such as Python (or Poser?), Matlab, or others. Is this idea possible, and can I get some ideas as to how to implement it? In case it provides some ideas as to how to answer the question, there previously was an answer (now unfortunatley erased) suggesting the midpoint method for a terrain with the functional form z = F(x,y), starting with the straight line between the endpoints, splitting in short segments [I presume the straight line on the XY plane (?)], and lifting [I presume the nodes between segments on the XY plane (?)] on the surface. Next it suggested finding "a midpoint" [I guess a midpoint of the segments joining each consecutive pairs of projected points on the surface (?)], and projecting "it" [I guess each one of these midpoints close, but not quite on the surface(?)] orthogonally on the surface (in the direction of the normal), using the equation Z + t = F(X + t Fx, Y + t Fy) [I guess this is a dot product meant to be zero... (?)], where (X,Y,Z) are the coordinates of the midpoint, Fx, Fy the partial derivatives of F, and t the unknown [that is my main issue understanding this... What am I supposed to do with this t once I find it? Add it to each coordinate of (X,Y,Z) as in (X+t, Y+t, Z+t)? And then?]. This is a non-linear equation in t, solved via Newton's iterations. As an update / bookmark, Alvise Vianello has kindly posted a Python computer simulation of geodesic lines inspired on this page on GitHub. Thank you very much! |
Ribbon chart in R Posted: 05 Jul 2022 01:47 AM PDT I search in R implementation (may be html widget on java script) a stacked bar chart in ribbon style, which allows you to see the rating change for each category in the dynamics. It's look like ribbon chart in power bi desktop Search rseek.org gave no results. |
List of all possible classes of R objects Posted: 05 Jul 2022 01:48 AM PDT Assuming a fresh R installation, a clean .Rprofile , no additional packages loaded, and no previous calls of the kind class(x) <- "new.class" : What are the possible return values of class(x) ? |
Find and replace entire MySQL database Posted: 05 Jul 2022 01:48 AM PDT I would like to do a find and replace inside an entire database not just a table. How can I alter the script below to work? update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]'); Do I just use an asterix? update * set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]'); |
No comments:
Post a Comment