Why is my custom WooCommerce code breaking the Ajax?

Uncategorized
Question: Please could you advice me what's wrong with my custom WooCommerce-code. I'm using it to make product quantity field for my archive pages (so that user can add multiple products to cart directly from archive - and no need to go single product -page if wants to choose more than one piece). Code of mine works great otherwise but when I active it - Ajax add to cart -system doesn't work. What would be the problem? Here's the code:add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 ); function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) { if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { $html = ''; $html .= woocommerce_quantity_input( array(), $product, false ); $html .= '' . esc_html( $product->add_to_cart_text() ) . ''; $html .= ''; }…
Read More

How to make Rect transparent in opencv

opencv
Question: I looked at the OpenCV Java doc for help with loading in images onto a frame. I did this by using frame however as my picture is transparent, the image has a black background inside its rectangular container. This is my Rect function : Mat submat = src.submat(new(Rect((int) facesArray[i].tl().x, (int) facesArray[i].tl().y, (int)(facesArray[i].br().x- facesArray[i].tl().x), (int)(facesArray[i].br().y- facesArray[i].tl().y)); Is there a way to set the background of the image to be transparent (I want to remove the black background and make it transparent). Please see the link for more info. enter image description here Answer: Read more
Read More

How to get text following a table/span with BeautifulSoup and Python?

Uncategorized
Question: I need to get the text 2,585 shown in the screenshot below. I very new to coding, but this is what i have so far:import urllib2 from bs4 import BeautifulSoup url= 'insertURL' r = requests.get(url) data = r.text soup = BeautifulSoup(data, 'html.parser') span = soup.find('span', id='d21475972e793-wk-Fact -8D34B98C76EF518C788A2177E5B18DB0') print (span.text) Any info is helpful!! Thanks. Website HTML Answer: 3 things, your using requests not urllib2. Your selecting XML with namespaces so you need to use xml as the parser. The element you want is not span it is ix:nonFraction. Here is a working example using another web-page (you just need to point it at your page and use the commented line). # Using requests no need for urllib2. import requests from bs4 import BeautifulSoup # Using this page as an…
Read More

What is the difference between a stream and a reader in Java?

Uncategorized
Question: Today I got this question for which I think I answered very bad. I said stream is a data that flows and reader is a technique where we read from that is a static data. I know this is an awful answer, so please provide me the crisp difference and definitions between these two with example in Java. Thanks. Answer: As others have said, the use cases for each are slightly different (even though they often can be used interchangeably) Since readers are for reading characters, they are better when you are dealing with input that is of a textual nature (or data represented as characters). I say better because Readers (in the context of typical usage) are essentially streams with methods that easily facilitate reading character input. Read…
Read More

What is the purpose of * in the ReaderT Monad Transformer?

Uncategorized
Question: I am looking at the documentation for the Reader monad and ReaderT monad transformer. The relevant definitions are:newtype ReaderT k r m a :: forall k. * -> (k -> *) -> k -> * type Reader r = ReaderT * r Identity I don't understand what the * are doing in the definitions. In particular I am attempting to derive a new monad from ReaderT with IO as the base monad and a class constraint on the r value. I am not sure why there is a fourth input to ReaderT (k) and what Reader is doing with that value when it puts a * in that position. Answer: * is the kind of types with values. forall k means k is not necessarily of that kind. you…
Read More

How to add `System.Web.Extensions` assembly to .net core project in vscode

Uncategorized
Question: I have installed c# support for vscode(version is 1.15.0) and created a HelloWorld project via dotnet new console. Now in Program.cs, I would like to use JavaScriptSerializer class which depends on System.Web.Extensions assembly. I typed using System.Web.Script.Serialization; and run dotnet restore ,but vscode cannot resolve it. The error is, The type or namespace name 'Web' does not exist in the namespace 'System' (are you missing an assembly reference?) It seems that System.Web is not part of .net core, but is there any way to add the assembly to the project? I cannot find a project.json file which is refered in other posts since it is a csproj project. Answer: System.Web.Extensions is part of full .net framework . If you want to serialize and deserialize object,You can use Newtonsoft.Json, #using…
Read More

Spring Rest template – 204 content in response from webservice

Uncategorized
Question: I have a rest service and is consumed using Spring's RestTemplate with Apache HttpClient as, @Autowired public ClientImpl(@Value("${base-uri}") final String baseUrl, @Qualifier("restOperations") RestOperations restTemplate) { serviceUrl = baseUrl; restTemplate = restTemplate; } private List processRequest(CustomRequest request) throws Exception { ResponseEntity responseEntity = restTemplate.exchange(serviceUrl, HttpMethod.POST, entity, ResponseDetails[].class); if (responseEntity.getStatusCode().value() == 204) { return Collections.emptyList(); } ResponseDetails[] response = responseEntity.getBody(); return response != null ? Lists.newArrayList(response) : Collections.emptyList(); } When the webservice returns 204 response, then the second service call after 204 response, fails with read timeout. Spring-web : 4.3.5 I cannot figure out the cause. Any help? EDIT: From debug logs, org.apache.http.impl.conn.DefaultHttpResponseParser;Garbage in response: ÿþ{"id":0}HTTP/1.1 204 Could not find Response in server logs by httpclient: Answer: Read more
Read More

How to benchmark npm/yarn install process?

Uncategorized
Question: I am working on a reactjs+mobx frontend project and using es6, babel, and webpack. I am using yarn install to download the dependencies and does the babel transpile work. In my project, yarn install takes more than 20 minutes to complete. I can say that the download only takes 1 or 2 mintues so most of them time is spent on babel or something else. Is there a way for me to figure out which part takes such a long time? My hardware is Mac Pro with 16GB memory. I don't have any performance on other open source reactjs project. It seems that only happen on my project so I am looking for a way to find the root course. Below is my project dependencies. "devDependencies": { "@blueprintjs/core": "^1.17.1",…
Read More

How to customize czml datasource?

Uncategorized
Question: I have a CZML data that I extracted via python. I have buildings, with their geometry, height, building ID, and intervals. each interval has a value. After loading the czml data to Cesium, I'd like to access the attributes and then customize the color of the buildings according to the value given. Here is a sample of my CZML: [{ "id": "document", "version": "1.0" }, { "id": 32, "availability": "2014-01-01T00:00:00Z/2014-12-31T00:00:00Z", "polygon": { "positions": { "cartographicDegrees": [54.7162360431897, 24.4519912715277, 0, 54.716219612921, 24.4519754832587, 0, 54.7162501395131, 24.4519488635358, 0, 54.7162465684811, 24.4519454316688, 0, 54.7162670831639, 24.4519275432238, 0, 54.7162707308589, 24.4519310439514, 0, 54.7163022563025, 24.4519035537608, 0, 54.7161962974502, 24.4518018819532, 0, 54.7161647729823, 24.4518293730395, 0, 54.7162035538772, 24.4520196028966, 0, 54.7162360431897, 24.4519912715277, 0] }, "someProperty": [{ "interval": "2014-00-01T00:00:00Z/2014-01-01T00:00:00Z", "En_C_need": 0.7 }, { "interval": "2014-01-01T00:00:00Z/2014-02-01T00:00:00Z", "En_C_need": 1.0 }, { "interval": "2014-02-01T00:00:00Z/2014-03-01T00:00:00Z", "En_C_need": 2.6 }, {…
Read More

JSON object inside Pandas DataFrame

Uncategorized
Question: I have a JSON object inside a pandas dataframe column, which I want to pull apart and put into other columns. In the dataframe, the JSON object looks like a string containing an array of dictionaries. The array can be of variable length, including zero, or the column can even be null. I've written some code, shown below, which does what I want. The column names are built from two components, the first being the keys in the dictionaries, and the second being a substring from a key value in the dictionary. This code works okay, but it is very slow when running on a big dataframe. Can anyone offer a faster (and probably simpler) way to do this? Also, feel free to pick holes in what I have…
Read More

Is it possible to join a hardware in the same subnet with Kubernetes pods?

Uncategorized
Question: I have setup a Kubernetes cluster with flannel network on bare metal. I have a service deployed and running in the cluster. The service would broadcast to discover the other end devices in the same subnet. The problem is that the client agents which receives the broadcasts are running on resource-constrained hardware. These devices are running in the same subnet with the Master and Worker Nodes. The deployed service in pods (netmask: 10.244.0.0/16) are unable to discover the clients running in the Host OS subnet (netmask: 192.168.0.0/24). How to join the clients in the pods' subnet? Any help is appreciate. Answer: The issue is that they are actually in different subnets: the pod network and the bare-metal network. Therefore you would have to check what options are available for…
Read More