id
stringlengths
5
11
text
stringlengths
0
146k
title
stringclasses
1 value
doc_23538900
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. OPTIONS https://localhost:8081/TestResteasy/rest/servlet/post Can anyone tell me what i did wrong? If i type the link directly,the service works just fine. js file $(document).ready(function() { $("button").click(function() { var dataT = { "name" : "Daniel", "password" : "1234" }; $.ajax({ type : "POST", data : JSON.stringify(dataT), dataType : "json", contentType : "application/json", url : "https://localhost:8081/TestResteasy/rest/servlet/post", success : function(data) { alert(data); } }); }); }); web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>JAXRS-RESTEasy</display-name> <servlet-mapping> <servlet-name>resteasy-servlet</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> <!-- Auto scan REST service --> <context-param> <param-name>resteasy.scan</param-name> <param-value>true</param-value> </context-param> <!-- this should be the same URL pattern as the servlet-mapping property --> <context-param> <param-name>resteasy.servlet.mapping.prefix</param-name> <param-value>/rest</param-value> </context-param> <listener> <listener-class> org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap </listener-class> </listener> <servlet> <servlet-name>resteasy-servlet</servlet-name> <servlet-class> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher </servlet-class> </servlet> the service @Path("/servlet") public class RESTEasyHelloWorldService { @GET @Path("/get/{pathParameter}") public Response responseMsg( @PathParam("pathParameter") String pathParameter, @DefaultValue("Nothing to say") @QueryParam("queryParameter") String queryParameter) { String response = "Hello from: " + pathParameter + " : " + queryParameter; return Response.status(200).entity(response).build(); } @POST @Path("/post") @Consumes("application/json") public Response createProductInJSON(Product product) { String result = "Product created : " + product.getName(); System.out.println(product.getName()); return Response.status(201).entity(result).build(); } } the object package com.javacodegeeks.enterprise.rest.domain; public class Product { String name; String password; public Product(String name, String password) { this.name = name; this.password = password; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "Product [name=" + name + ", qty=" + password + "]"; } } pom.xml <dependencies> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>3.0.4.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jackson-provider</artifactId> <version>3.0.2.Final</version> </dependency> </dependencies> A: Sorry for late reply but may be this will be helpful in future for others Step 1:Add the runtime support for RESTEasy JSAPI <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jsapi</artifactId> <version>2.3.1.GA</version> </dependency> Step 2: Add JSAPI servlet mapping in web.xml <servlet> <servlet-name>RESTEasy JSAPI</servlet-name> <servlet-class>org.jboss.resteasy.jsapi.JSAPIServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>RESTEasy JSAPI</servlet-name> <url-pattern>/rest-js</url-pattern> </servlet-mapping> for more detail kindly visit the link http://docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html/AJAX_Client.html
doc_23538901
A: As far as I know you can't currently stop the use of this directory, but you can redefine the state_dir variable to put it somewhere else. You can conveniently redefine variables at the command line, so you could invoke Bro via something like this: bro -r some.pcap state_dir=$(mktemp -d -p . bro.XXXX) This will make each run use a new state directory in the current directory. There may be a catch — the DNS manager seems to have a hardcoded .state directory, so if your configuration uses this feature (i.e. DNS lookups conducted by Bro itself), the above may not work.
doc_23538902
URL: https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&start=latest&airport=SACO A: it was solved with script like: https://www.benlcollins.com/apps-script/beginner-apis/ A: you can use IMPORTDATA: =IMPORTDATA("https://rucsoundings.noaa.gov/get_soundings.cgi?data_source=GFS&start=latest&airport=SACO")
doc_23538903
* *Imported the ML Agents Package by Unity Package Manager. *Copied the ML Agent example Assets from Unity's official GitHub to My Project File. Then, I opened the example scene and played that scene. But every code which contains "using Unity.MLAgents.Actuators" fails with the following error: Assets\test.cs(5,22): error CS0234: The type or namespace name 'Actuators' does not exist in the namespace 'Unity.MLAgents' (are you missing an assembly reference?) So, I've tried to find MLAgents.Actuator module's source code. But I didn't find anything yet. Someone said Actuator Module is applied after ML Agent 1.0.3, but I imported the lasted version (v. 1.0.4). How can I import the ML Agents package properly? Every YouTube tutorial does not show the problem I've encountered. Here is my environment: * *Unity version: Unity 2020.1.0f *ML Agents version: version 1.0.4 *ML Agents example: version Release 7 A: Update the package to a 1.4.0-preview or later (depending on your Unity version, you may need to change some package manager settings to be able to see preview packages). Get the examples from a tag that corresponds to the 1.0.x package, for example com.unity.ml-agents_1.0.6 A: You have to manually install it from the repository you cloned. A: I added the project from "Unity Hub" rather than inserting asset folder to a new project. And then everything works fine. Even the preview packages like [com.unity.ml-agents.extensions": "file:../../com.unity.ml-agents.extensions] added automatically to the project from my project directory! A: If you need to use the 1.0.x pacakage, make sure you're getting the examples from a compatible version (not the master branch). For example, here's the 1.0.2 tag: github.com/Unity-Technologies/ml-agents/tree/…. Looks like 1.03 and 1.0.4 tags are missing but I'll update them tomorrow. – celion Sep 27 '20 at 20:27 Celion had the right answer A: I have the same problem, I am very new to Unity. I figured out it is something with the versioning. You need to use the proper version of the package. By installing from the Unity Registry, I was not able to install the last version. I just install the package from the Disk. Here follow the Install the com.unity.ml-agents Unity package. It fixed my problem. A: Unity.MLAgents.Actuators this package is in preview till this date, if you want to use this package you need to update your MLAgents package from package manager.
doc_23538904
I've tried box-sizing with no success. Here you have the HTML code: <br /> <div style="background-color:#0f0;"> <a href="#" class="button">EDIT CART</a> ...... <a href="#" class="button">UPDATE</a> ...... <a href="#" class="button">PROCEED TO CHECKOUT</a> </div> <br /><br /><br /> <div style="background-color:#0f0;width:200px;"> <a href="#" class="button">EDIT CART</a> ...... <a href="#" class="button">UPDATE</a> ...... <a href="#" class="button">PROCEED TO CHECKOUT</a> </div> Here you have the CSS code: .button { color: #fff; background-color: #0778bd; font-family: "Tahoma"; font-size: 25px; text-decoration: none; padding: 20px 25px; } And here you have the JSFiddle link: https://jsfiddle.net/ox6yzpfa/ Any idea on how to solve this? Please, if you get it working, give me back a JSFiddle link with the code fixed. A: a is an inline element, which does not have vertical layout or affect other elements in the DOM vertically. To give an a element vertical layout, so it can affect elements around it vertically, make the element display: block; or display: inline-block; depending on your needs. Here's a demo https://jsfiddle.net/ox6yzpfa/1/ A: By default, anchor tags are inline elements and lack the box-model. You need to set the display to inline-block: .button { color: #fff; background-color: #0778bd; font-family: "Tahoma"; font-size: 25px; text-decoration: none; padding: 20px 25px; display: inline-block; /* Add this! */ } Fiddle: https://jsfiddle.net/u37Ljn3g/ A: you are trying to assign padding to an inline element, try this: .button { color: #fff; background-color: #0778bd; font-family: "Tahoma"; font-size: 25px; text-decoration: none; padding: 20px 25px; display: inline-block; margin-left: 20px }
doc_23538905
[Bindable]public var total:Number=0; private function gridClickEvent(event:ListEvent):void { var quantity:Number=acCart[event.columnIndex].quantity; var price:Number=acCart[event.columnIndex].price; total += quantity * price; } My calculated total will be shown in a label <s:Label id="prijs" text="{total}" /> What I want is to calculate a total price. I have an arraycollection with 3 fielddata's (Nameproduct, quantity and price). In a function I want to pull the data "quantity" and the data "price" out of the arraycollection so that I calculate a "totalprice". At the moment the function i wrote is not working. I don't recieve any data. A: It's total+= not total=+. You have a syntax error in the operator. A: Do some debugging: private function gridClickEvent(event:ListEvent):void { //see if getting expected values trace(event.rowIndex); trace(acCart[event.rowIndex].quantity); trace(acCart[event.rowIndex].price); var quantity:Number=parseFloat(acCart[event.rowIndex].quantity); var price:Number=parseFloat(acCart[event.rowIndex].price); total += quantity * price; } A: Why not just private function gridClickEvent(event:ListEvent):void { .... // your math here trace("old total = "+ total); total += quantity * price; trace("new total = "+ total); // forget about binding and manually set the property prijs.text = total.toString(); } Binding sometimes is crazy in flex, and even if you/I understand the mechanism of Binding perfectly it may still be the chance that the binding is not working or the values are set N times instead of just once (case of several MVC frameworks out there). For this reason I hate binding, and I am reserved in using it. PS: what would your trace output be ? (please "debug", not run, to get console output)
doc_23538906
eg. If query string parameter ID = '123' then I want to rewrite the value as 'abc' And this should work regardless of the form of the URL: http://mysite/page.aspx?ID=**123** should resolve to http://mysite/page.aspx?ID=**abc** http://mysite/?ID=**123** should resolve to http://mysite/?ID=**abc** http://mysite/page.aspx?name=bob&ID=**123** should resolve to http://mysite/page.aspx?name=bob&ID=**abc** http://mysite/page.aspx?name=bob&ID=**123**&age=33 should resolve to http://mysite/page.aspx?name=bob&ID=**abc**&age=33 A: This rule will work for you. <rule name="replace query string" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{QUERY_STRING}" pattern="(.*)(id=123)(.*)" /> </conditions> <action type="Redirect" url="{R:0}?{C:1}id=abc{C:3}" appendQueryString="false" logRewrittenUrl="true" /> </rule>
doc_23538907
For what I can understand, from gitlab, the code and pipelines live in the same git repository. In my scenario the pipelines are responsibility of devops team and code from develop team. How, in git lab, is possible to prevent developers of changing the pipeline? I understand it's possible to add devops team as maintainer to review pull requests, but this will create a dependency of devops teams in every change. thanks A: GitLab is not really designed for the scenario you describe. The general idea is that developers look after the CI configuration themselves. You could try using the includes feature to store the bulk of the CI configuration in a separate repository. In the application repository you would have a .gitlab-ci.yml file that pulls the CI configuration in from another repository using include-project: include: - project: 'my-group/my-ciproject' ref: master file: '/ci/.gitlab-ci-myappproject.yml' Then in the my-group/my-ciproject repository you would have a file .gitlab-ci-myappproject.yml that contains the GitLab CI jobs configuration. build: script: - dobuild Only the DevOps team would have access to the my-group/my-ciproject repository so developers can't edit the CI config (although could mess with the .gitlab-ci.yml` file in the app repository). Alternatively you could protect the master branch and have all changes approved before merging to master. Then developers would not be able to make changes to the CI without an approval.
doc_23538908
A: The current contenders for "best" library for consuming External SOAP services seems to be either Savon or Handsoap. There is a comparison between the two here I can't comment on handsoap as I haven't used it by I am happy with Savon which is working well for me. In terms of Application structure then I would create a folder under lib for the interface named after the external entity and then store files under there using the namespacing features of rails. So an example I have an external interface to a system called Sentinel. So I have RAILS_ROOT/lib/sentinel and then all classes within that folder are declared within a Sentinel module. A: The first thing to do would be to see if there are any gems for the API's you want to interface with. Write a small wrapper class for the gem or just include it and use it where needed. If you're looking to talk to a REST service, I would suggest the rest-client gem. If you want to do something completely custom you could make use of Jon Nunemaker's HTTParty. Nokogiri, an XML parser gem is useful for consuming XML-based services as well.
doc_23538909
- Actual Syntax: CREATE DATABASE SCOPED CREDENTIAL AzureStorageCredential WITH IDENTITY = 'user', SECRET = 'azure_storage_account_key' ; --Can we specify as below? CREATE DATABASE SCOPED CREDENTIAL AzureStorageCredential WITH IDENTITY = 'user', SECRET = 'KEY-URI' ; A: You could use a Shared Access Signature as per here which would give you greater control over, eg you could set a time-limit on it. For me, creating scoped credentials is an admin task which you only need to do once per server, so I probably wouldn't automate it. It's then as secure as your source-code control process. You could use secondary keys and cycle them for example.
doc_23538910
The reason is that I'm using some URL techniques to turn plain text links into URLs. When the user clicks on the div, jeditable is turning them into <a href=>..</a> Is there a "beforeSubmit" option in jeditable? http://www.appelsiini.net/projects/jeditable A: Jeditable has a data function which edits your editable text before form submit. Try: $('#sampleDiv').editable('blahblah...', { data: function(value, settings){ return stripTags(value); } }); A: In Jeditable you can pass options object parameter to the editable function. So in this option parameter specify an event that triggers starting to edit the item so you have complete control on the element before & after starting to edit. Example: $('#sampleDiv').editable(callBackFunction, { event: 'edit', //the event that will trigger the editing cssclass:'editForm' //the class of the form that will have the input textbox //some other options refer to Jeditable website for other options }); now all you have to do is create a function that will trigger the editing and bind it to the doubleclick, click or whatever event you like I'm going to use click for this example. $('#sampleDiv').click(function () { $('#sampleDiv').trigger('edit'); //now the input box is appearing so you can change the value here or do whatever u want var input = $('.editForm input'); input.val(stripTags(input.val())); });
doc_23538911
I didn't found any solution that fulfill the requirements: * *bottom only *contained in a rounded view and ideally, a solution working with UIButton. A: While this is possible, it's a bit tricky and it will require you to draw shadows using CGPath: https://developer.apple.com/documentation/quartzcore/calayer/1410771-shadowpath Probably a simpler way would be to use a resizable image: https://developer.apple.com/documentation/uikit/uiimage/1624102-resizableimage You would make a smaller image like this mock below, and then simply resize it to increase the frame like so: let resized = mockImage.resizableImage(withCapInsets: UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 56), resizingMode: .stretch) A: I have created a button extension for you to add the bottom shadow. Please check it out. You just need to call the "bottomShadow()" function with your button refrence e.g. override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.button?.bottomShadow() } /*Button Extension*/ extension UIButton { func bottomShadow() { let shadowHeight: CGFloat = 5.0 let shadowframe = CGRect.init(x: 0, y: self.bounds.height - shadowHeight, width: self.bounds.width, height: shadowHeight) let path = UIBezierPath(roundedRect: shadowframe, byRoundingCorners: [.topLeft , .topRight], cornerRadii: CGSize(width: self.layer.cornerRadius, height: self.layer.cornerRadius)) let mask = CAShapeLayer() mask.fillColor = UIColor.lightGray.cgColor mask.path = path.cgPath self.layer.addSublayer(mask) } }
doc_23538912
It's about an older version of the WordPress Shortcode API. Example: function bartag_func( $atts ) { extract( shortcode_atts( array( 'foo-bar' => 'something' ), $atts ) ); return "foo = ${foo-bar}"; } add_shortcode( 'bartag', 'bartag_func' ); A: It is still not possible. However, for the PHP.net engine, I have an RFC under discussion that would make it possible in PHP 8. A: shortcode_atts returns an array so just use it. function bartag_func( $atts ) { $params = shortcode_atts( array( 'foo-bar' => 'something' ), $atts ) ); return "foo = " . $params['foo-bar']; } add_shortcode( 'bartag', 'bartag_func' );
doc_23538913
Three pages before the page (setoffscreenlimit=3): D/Fragment: ON START Currently on the page: D/Fragment: ON RESUME Navigating backwards: D/Fragment: ON PAUSE Navigating back to the page: D/Fragment: ON RESUME
doc_23538914
<tr> <td ng-click="pbmain.selectWC(WC.WCName)" ng-repeat="WC in pbmain.WCList"> md-button(ng-class="WC.WCName == pbmain.selectedWCName ? 'md-raised md-primary' : 'md-raised'") {{WC.WCName}} </td> </tr> The number of buttons and text on the buttons can be quite long and the row is often 2-3 times the width of the browser window. For the moment, I scroll across but I am looking for a more user-friendly solution. I would like to be able to split the row automatically, according to the page width - something like the example below. A: You can achieve this by applying proper CSS to table and button elements. No need to split a row into multiple rows. Example: <table border="0" cellspacing="0" cellpadding="0"> <tr> <td> <span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span><span>TEST</span> </td> </tr> CSS table { table-layout: fixed; width: 100% } span { border: 1px solid black; margin: 10px; width: 100px; display: inline-block; } Have a look at this fiddle. A: I have no idea how to accomplish this easily within a table. Maybe you could make some pre-work on your array to make it two-dimensional and then ng-repeat tr and td tags as well. My solution would be a clean grid system with Bootstrap. With this you can achieve a fully responsive screen. If you do not need to stick with a table system, then you should consider this. A: Well, I was searching by splitting rows into multiple rows and I got here. It seems that your problem could be better solver by using display: inline-block; for every button. However, if you really need a table for other purpose check at this next approach. It would redrawn your linear tabular long table into a multilined table by only using css. Than you can play around with your screen size.
doc_23538915
Now using the markup below I am oh so close (!) except for the following… When the page loads the first link’s content is displayed as I want to be, but whenever you click one of the other 3 links it is only div1’s content that successfully loads while the other two divs become empty. I have attempted to alter the toggleVisibility coding (quite crudely I know!) so that each of the 4 links are dealt with as follows; <a href=“#” onclick=“togglevisibility(‘link1div1’); togglevisibility(‘link1div2’);togglevisibility(‘link1div3’);”>Link 1</a> Is there a way to fix this error from within the link line (above) so that clicking the link loads the corresponding content into all three divs and not just the first? I am sure it is something simple that I have overlooked or ill-coded! Thanks very much for your time and advice in advance. CSS .section {display:none;} #link1div1 {display:block;} #link1div2 {display:block;} #link1div3 {display:block;} HTML <a href=“#” onclick=“togglevisibility(‘link1div1’); togglevisibility(‘link1div2’);togglevisibility(‘link1div3’);”>Link 1</a> <a href=“#” onclick=“togglevisibility(‘link2div1’); togglevisibility(‘link2div2’);togglevisibility(‘link2div3’);”>Link 2</a> <a href=“#” onclick=“togglevisibility(‘link3div1’); togglevisibility(‘link3div2’);togglevisibility(‘link3div3’);”>Link 3</a> <a href=“#” onclick=“togglevisibility(‘link4div1’); togglevisibility(‘link4div2’);togglevisibility(‘link4div3’);”>Link 4</a> <div id=“div1”> <div id=“link1div1” class=“section”></div> <div id=“link2div1” class=“section”></div> <div id=“link3div1” class=“section”></div> <div id=“link4div1” class=“section”></div> </div> <div id=“div2”> <div id=“link1div2” class=“section”></div> <div id=“link2div2” class=“section”></div> <div id=“link3div2” class=“section”></div> <div id=“link4div2” class=“section”></div> </div> <div id=“div3”> <div id=“link1div3” class=“section”></div> <div id=“link2div3” class=“section”></div> <div id=“link3div3” class=“section”></div> <div id=“link4div3” class=“section”></div> </div> JS <script type="text/javascript"> function toggleVisibility(selectedTab) { var section = document.getElementsByClassName('section') for(var i=0; i<section.length; i++) { if(section[i].id == selectedTab) { section[i].style.display = 'block'; } else { section[i].style.display = 'none'; } } } </script> A: I would minimise the use of javascript and do that using css, like this: DEMO HERE javascript: function clickHandler(lnk) { document.getElementById('sections').className = lnk; return false; } css: #sections .section {display:none;} #sections.link1 .link1, #sections.link2 .link2, #sections.link3 .link3, #sections.link4 .link4 { display: block; } html: <a href="#" onclick="clickHandler('link1')">Link 1</a> <a href="#" onclick="clickHandler('link2')">Link 2</a> <a href="#" onclick="clickHandler('link3')">Link 3</a> <a href="#" onclick="clickHandler('link4')">Link 4</a> <div id="sections" class="link1"> <div id="div1"> <div id="link1div1" class="section link1">11</div> <div id="link2div1" class="section link2">21</div> <div id="link3div1" class="section link3">31</div> <div id="link4div1" class="section link4">41</div> </div> <div id="div2"> <div id="link1div2" class="section link1">12</div> <div id="link2div2" class="section link2">22</div> <div id="link3div2" class="section link3">32</div> <div id="link4div2" class="section link4">42</div> </div> <div id="div3"> <div id="link1div3" class="section link1">13</div> <div id="link2div3" class="section link2">23</div> <div id="link3div3" class="section link3">33</div> <div id="link4div3" class="section link4">43</div> </div> </div> A: The reason only one of those is showing is because when you run toggle visibility youre getting every element with the class section then toggling them all off except for the ONE that is called into the function. So when your onclick is done running youve turned on the first two then turned them off when you call the last one. A simple fix would be to give each div in the big div a classname determining the link. <div id=“div3”> <div id=“link1div3” class=“section link1”></div> <div id=“link2div3” class=“section link2”></div> <div id=“link3div3” class=“section link3”></div> <div id=“link4div3” class=“section link4”></div> </div> Do the same for the other divs. Then your links be like this .... <a href=“#” onclick=“togglevisibility(‘link1’);>Link 1 </a> Change your javascript to. <script type="text/javascript"> function toggleVisibility(selectedClass) { var turnOn = document.getElementsByClassName('selectedClass'); var allDivs = document.getElementsByClassName('section'); for(var i=0; i<section.length; i++) { //this for loop hides all the divs section[i].style.display = 'none'; } for(var i=0; i<turnOn.length; i++) { // this for loop shows the divs turnOn[i].style.display = 'block'; // with the link1 class } } </script> This solution if it works (I havent been able to test) will also keep something on the page at all times which I saw you mentioned in bold in your post.
doc_23538916
Entity @PrimaryGeneratedColumn({ type: "int", name: "Id", }) id: number; @Column("nvarchar", { nullable: false, unique: true, name: "Name" }) name: string; @Column("nvarchar", { nullable: false, name: "ParentId" }) parentId: number; Controller @Get('/parentSection') async getSectionHelp(@Req() req, @Param() params):Promise<HelpEntity[]>{ return this.helpService.getHelpbySection(req.user, params.id); } Service constructor(@InjectRepository(HelpEntity) private readonly helpRepo: Repository<HelpEntity>, async getHelpbySection(gmid: string, id: number) : Promise<any>{ let check = await this.checkIfAdmin(gmid); if (!check) { throw new HttpException('Unauthorized', 401); } else { const res = await this.helpRepo.find() if (!res) { throw new NotFoundException(`This ID: ${id} is not found`) } return res; } } In my database all my parent section has NULL in ParentId. A: You simply have to specify it in the find function: import {IsNull} from "typeorm"; ... ... async getHelpbySection(gmid: string, id: number) : Promise<any>{ let check = await this.checkIfAdmin(gmid); if (!check) { throw new HttpException('Unauthorized', 401); } else { const res = await this.helpRepo.find({parentId: IsNull()}) if (!res) { throw new NotFoundException(`This ID: ${id} is not found`) } return res; } }
doc_23538917
headers = {'Authorization': 'bearer %s'% api_key} #making it bearer, not changing it throughout response3 = requests.get(url = endpoint, headers = headers) business_data2 = response3.json() for item in business_data2['categories']: itemname = item['title'] If I say itemname = item['title'] and I get only the last thing in my API But if I say print(item['title']) I get all my list but only in my for loop. I tried to do that in terminal and I got only the last string I don't know how to fix it I tried to index it by saying [0:-1] but I only get the last element as well. A: By doing the following, you keep overwriting itemname value, so you see only the last one for item in business_data2['categories']: itemname = item['title'] To collect them all use a list itemnames = [] for item in business_data2['categories']: itemnames.append(item['title']) # or directly a list comprehension itemnames = [item['title'] for item in business_data2['categories']] # pythonic equivalent from operator import itemgetter itemnames = list(map(itemgetter('title'), business_data2['categories']))
doc_23538918
Code in question: def run(encoder, port, channel): decoder_socket = socket.socket() decoder_socket.connect((decoder, port)) decoder_fp = decoder_socket.makefile("r", 0) parser = xml.sax.make_parser(['xml.sax.IncrementalParser']) parser.setContentHandler(RftDecoder()) while True: data = decoder_fp.readline().strip("\x00") if not(data): raise socket.error("no data") LOG.info("%s" % data.strip()) parser.feed(data) If the connection is actively closed by the other side, the exception is raised as expected, no problems. However when the connection is dropped (e.g., if Decoder crashes, or if the cable is unplugged), then the decoder_fp.readline() call blocks indefinitely. Strace doesn't show anything when this happens, it just continues sitting on a recv() call. So my question is, how can I detect when the connection is lost as described, and reconnect?
doc_23538919
I want users to be able to run MyApp without being admisn or fighting the UAC screen everytime they run the app. If they have to get through UAC to install the app, that's OK though still not optimal. I thought I had this set up, but it's not working: [Setup] PrivilegesRequired=admin AppName=My App AppVerName=My App 1.0 DefaultDirName={pf}\MyApp DefaultGroupName=MyApp UninstallDisplayIcon={app}\bin\MyApp.ico OutputDir=..\Installer ChangesAssociations=yes [Dirs] Name: "{app}\"; Permissions: everyone-modify Name: "{app}\redist"; Flags: deleteafterinstall; Specifically I thought Name: "{app}\"; Permissions: everyone-modify would let normal users run it, removing UAC protection on Program Files\MyApp. I am picking at values a bit by random, can anyone suggest some changes? Again, the aim is that once installed, normal users in non-admin accounts can run it even though files are saved in Program Files, without UAC kicking in. As a secondary thing, the installation itself should not be too crazy... a single prompt for admin password or UAC authorization. A: Don't install under {pf}. Instead, install to a user-writeable location (for instance, {localappdata}). http://www.kinook.com/blog/?p=53 A: You should change your app so that is saves shared data in some other folder. Granting write permissions for any user to a folder in PF that contains executable code (exe,dll's etc) is a security issue (Evil user could modify exe file and wait for admin to run it) Alernativly you could store the files in a subfolder in PF and only grant write access to it, that way your executables are safe.
doc_23538920
var arr = [0,0,1,2,2,3,4,5,5,5,6,7,7,7,7,8,9,10,10,10] My goal is to throw unique elements in the array and get the most repeated numbers. var arr = [7,7,7,7] How can this be achieved in JavaScript? A: var arr = [0, 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 7, 7, 7, 8, 9, 10, 10, 10] var uniq = arr.reduce((all, next) => { var exist = all.find(v => v.key === next) if (exist) { exist.count += 1 exist.val.push(next) } else { all.push({ key: next, count: 1, val: [next] }) } return all }, []) var max = uniq[0] uniq.forEach(item => { if (item.count > max.count) { max = item } }) console.log(max.val)
doc_23538921
>>> df Out[126]: score id 0 0.999989 654153 1 0.992971 941351 2 0.979518 701608 3 0.972667 564000 4 0.936928 999843 and want to convert to a prettytable (in order to write to a text file with a better readability) import prettytable as pt x = pt.PrettyTable() for col in list(df.columns): x.add_column(col,df[col]) then inside a function, I use print(x.get_string()) and get this error File "<ipython-input-130-8db747160a67>", line 5, in <module> verbose = True) File "<ipython-input-129-4e27c067e0b5>", line 104, in lda_save_eval print(x.get_string()) File "C:\Users\USER\Anaconda3\envs\tensorflow\lib\site-packages\prettytable.py", line 990, in get_string self._compute_widths(formatted_rows, options) File "C:\Users\USER\Anaconda3\envs\tensorflow\lib\site-packages\prettytable.py", line 894, in _compute_widths widths = [_get_size(field)[0] for field in self._field_names] File "C:\Users\USER\Anaconda3\envs\tensorflow\lib\site-packages\prettytable.py", line 894, in <listcomp> widths = [_get_size(field)[0] for field in self._field_names] File "C:\Users\USER\Anaconda3\envs\tensorflow\lib\site-packages\prettytable.py", line 77, in _get_size lines = text.split("\n") AttributeError: 'int' object has no attribute 'split' Any clues? A: try print (x.get_string()) instead of print(x.get_string) For improvement try this, In order to write to a text file with a better readability you don't need for loop use tabulate it gives you more flexible. try this, from tabulate import tabulate print (tabulate(df,df.columns,tablefmt='psql')) In tablefmt you can provide many options to get different styles. for more details refer this link
doc_23538922
At this time, pstack for the process in deadloop failed to print anything. At the same time, pstack for any other processes works well. Could anyone please help to let me know why? Thanks! A: try in this way, put the debuger command in a free core with taskset -c corenumber /path/command and after this try change the scheduling class in fifo of your debug process using chrt command I think you found this problem, because the fifo process cannot be stoped by normal process
doc_23538923
Failed to make the following project runnable: MyProject (.NETFramework,Version=v4.6) reason: The process cannot access the file '~\MyProject.exe' because it is being used by another process. File: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets I have no clue why this error is coming. Any solution? A: Here is a silly solution to this problem that actually worked! I stopped debugging and closed Visual Studio. Then I restarted the computer. Upon opening Visual Studio again after restarting the computer, I was able to run the application without any error. It seems the process was still running in the background even though the application had been stopped from Visual Studio. Source: Basic troubleshooting
doc_23538924
A: The autocomplete attribute is ignored and therefore not rendered in the output html. I had a similar problem, i wanted to use placeholder attribute. I ended up using jquery to accommodate the need <script type="text/javascript"> jQuery(document).ready(function() { document.getElementById("entityForm:searchField").setAttribute('placeholder','Search'); }); </script> You can use this to set the autocomplete attribute document.getElementById("passwordField").setAttribute('autocomplete','off'); A: You will never find a way to achieve this, cause the autocomplete in this case is happening on the client-side. You can make it a little more difficult, but at the end of a day it's the users browser which decideds whether to store a password or not. If a user wants to store the password, he can always do it. (A Lot of Browsers are simply ignoring things like autocomplete="false", because its a user decision, nothing the website should decide.) A: Hi all thanks fr yur solutions , Fixed the issue , just made some work around so that code is compatable with both Firefox and Chrome , * *Use "p:inputText"(Primefaces Component) instead of "h:inputSecret" Code : p:inputText onfocus="validate('Id')" use javascript to change type to "password" upon focus : function validate(Id){ document.getElementById(pwd).type = 'password'}; then comes the important workaround,adding tags before and after <input type="text" name="faketext" id="faketext" style="display:none;"/> <input type="password" value=" " name="fakepassword" id="fakepassword" style="display:none;" /> <!-- - After <p:inputText> --> <input type="password" value=" " name="fakepassword1" id="fakepassword1" style="display:none;"/> Thus issue Resolved.
doc_23538925
I like to think I know JS decent enough, and I see common characters in all the XSS examples I've come accoss, which I am somewhat familiar with. I am lacking good XSS examples that could bypass a securely sound, rationally programmed system. I want people to upload html5 canvas creations onto my site. Any sites like this yet? People get scared about this all the time it seems, but what if you just wanted to do it for fun for yourself and if something happens to the server then oh well it's just an animation site and information is spread around like wildfire anyway so if anyone cares then i'll tell them not to sign up. If I allow a single textarea form field to act as an IDE using JS for my programming language written in JS, and do string replacing, filtering, and validation of the user's syntax before finally compiling it into JS to be echoed by PHP, how bad could it get for me to host that content? Please show me how you could bypass all of my combined considerations, with also taking into account the server-side as well: * *If JavaScript is disabled, preventing any POST from getting through, keeping constant track of user session. *Namespacing the Class, so they can only prefix their functions and methods with EXAMPLE. *Making instance *Storing my JS Framework in an external (immutable in the browser?) JS file, which needs to be at the top of the page for the single textarea field in the form to be accepted, as well as a server-generated key which must follow it. On the page that hosts the compiled user-uploaded canvas game/animation (1 per page ONLY), the server will verify the correct JS filename string before echoing the rest out. *No external script calls! String replacing on client and server. *Allowing ONLY alphanumeric characters, dashes and astericks. *Removing alert, eval, window, XMLHttpRequest, prototyping, cookie, obvious stuff. No native JS reserved words or syntax. *Obfuscating and minifying another external JS file that helps to serve the IDE and recognize the programming language's uniquely named Canvas API methods. *When Window unloads, store the external JS code in to two dynamically generated form fields to be checked by the server in POST. All the original code will be cataloged in the DB thoroughly for filtering purposes. *Strict variable naming conventions ('example-square1-lengthPROPERTY', 'example-circle-spinMETHOD') *Copy/Paste Disabled, setInterval to constantly check if enabled by the user. If so, then trigger a block to the database, change window.location immediately and check the session ID through POST to confirm in case JS becomes disabled between that timeframe. I mean, can I do it then? How can one do harm if they can't use HEX or ASCII and stuff like that? A: I think there are a few other options. Good places to go for real-life XSS tests, by the way, are the XSS Cheat Sheet and HTML5 Security Cheetsheet (newer). The problem with that, however, is that you want to allow Javascript but disallow bad Javascript. This is a different, and more complex, goal than the usual way of preventing XSS, by preventing all scripts. Hosting on a separate domain I've seen this referred to as an "iframe jail". The goal with XSS attacks is to be able to run code in the same context as your site - that is, on the same domain. This is because the code will be able to read and set cookies for that domain, intiate user actions or redress your design, redirect, and so forth. If, however, you have two separate domains - one for your site, and another which only hosts the untrusted, user-uploaded content, then that content will be isolated from your main site. You could include it in an iframe, and yet it would have no access to the cookies from your site, no access to redress or alter the design or links outside its iframe, and no access to the scripting variables of your main window (since it is on a different domain). It could, of course, set cookies as much as it likes, and even read back the ones that it set. But these would still be isolated from the cookies for your site. It would not be able to affect or read your main site's cookies. It could also include other code which could annoy/harrass the user, such as pop-up windows, or could attempt to phish (you'd need to make it visually clear in your out-of-iframe UI that the content served is not part of your site). However, this is still sandboxed from your main site, where you own personal payload - your session cookies and the integrity of your overarching page design and scripts, is preserved. It would carry no less but no more risk than any site on the internet that you could embed in an iframe. Using a subset of Javascript Subsets of Javascript have been proposed, which provide compartmentalisation for scripts - the ability to load untrusted code and have it not able to alter or access other code if you don't give it the scope to do so. Look into things like Google CAJA - whose aim is to enable exactly the type of service that you've described: Caja allows websites to safely embed DHTML web applications from third parties, and enables rich interaction between the embedding page and the embedded applications. It uses an object-capability security model to allow for a wide range of flexible security policies, so that the containing page can effectively control the embedded applications' use of user data and to allow gadgets to prevent interference between gadgets' UI elements. One issue here is that people submitting code would have to program it using the CAJA API. It's still valid Javascript, but it won't have access to the browser DOM, as CAJA's API mediates access. This would make it difficult for your users to port some existing code. There is also a compilation phase. Since Javascript is not a secure language, there is no way to ensure code cannot access your DOM or other global variables without running it through a parser, so that's what CAJA does - it compiles it from Javascript input to Javascript output, enforcing its security model. A: htmlprufier consists of thousands of regular expressions that attempt "purify" html into a safe subset that is immune to xss. This project is bypassesed very few months, because it isn't nearly complex enough to address the problem of XSS. Do you understand the complexity of XSS? Do you know that javascript can exist without letters or numbers? Okay, they very first thing I would try is inserting a meta tag that changes the encoding to I don't know lets say UTF-7 which is rendered by IE. Within this utf-7 enocded html it will contain javascript. Did you think of that? Well guess what there is somewhere between a hundred thousand and a a few million other vectors I didn't think of. The XSS cheat sheet is so old my grandparents are immune to it. Here is a more up to date version. (Oah and by the way you will be hacked because what you are trying to do fundamentally insecure.)
doc_23538926
function resizeImage($filename, $max_width, $max_height) { list($orig_width, $orig_height) = getimagesize($filename); $width = $orig_width; $height = $orig_height; # taller if ($height > $max_height) { $width = ($max_height / $height) * $width; $height = $max_height; } # wider if ($width > $max_width) { $height = ($max_width / $width) * $height; $width = $max_width; } $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $orig_width, $orig_height); return $image_p; } However, I'm not sure what I should put for the parameter, $filename. I have this code $target_file = ($_FILES["fileToUpload"]["name"]);. Could my $target_file variable be put in for the parameter $filename to be resized? For example, $image = addslashes(file_get_contents($_FILES['fileToUpload']['tmp_name'])); $max_width = 100; $max_height = 100; $image = resizeImage($image, $max_width, $max_height); Would this resize the image to be 100x100?
doc_23538927
if(window.location.host === 'example.com'){ passToken('SECRET_TOKEN'); } else { error(); } So, I was wondering if someone can bypass this and get the function passToken() to work from another host. doing window.location.host = 'something.com' does a redirect to that host, is it possible to change that value? Thanks! A: I do believe it is a JS reserved word https://www.w3schools.com/js/js_reserved.asp
doc_23538928
$var->doSomething(['chris' => ['age' => 22], 'evan']); I'm sending an array via a formData (not like the above question, obviously), and php reads the array perfectly like this: $array = $_POST('arrayOfValues'); $var->doSomething($array); The data on my js formdata is the following: var array = ['chris', 'evan']; var data = new FormData(); array.forEach(function(item){ data.append('arrayOfValues[]', item); }); I have no idea how to accomplish it, an acquaintance told me to try an object, but it didn't work (I dunno if I have to parse it somehow in php or js). PD: JQuery or JS are accepted, but I'd prefer the latter for learning purposes A: The formData creates only a set of key/values pairs representing form fields. If you want to send complex objects to PHP you have to use JSON. To create JSon objects use: var myArrayObj = { ... }; var json = JSON.stringify( myArrayObject); More information on json: http://www.json.org/js.html So, in PHP, use: var_dump(json_decode($json)); //where $json is your data from JS
doc_23538929
I also have code that imports new data on a daily basis which is also pushed to the existing database tables in the same format. I want to write tests that make sure that the contents of the database are correct at any given moment (after the initial data migrations have been applied, after a new import, etc.). The tests will check things like whether a particular column which is not expected to have null values indeed doesn't, if a derived field's value is correct, etc. My issue is that, django attempts to create a test database by applying all migrations every time I run the tests. But since the data migrations take a long time to be applied, running tests like that becomes very impractical. I also don't want to use the keepdb option, as I want to run those tests after changes to the original database as well. I'm not sure what the general best idiomatic django approach is for such cases. A: You can use pytest to acess / reuse database. Just use @pytest.mark.django_db in your test case. pytest is great for testing your django code. I definitely recommend it. See here for more information A: you can run the django test case to persistence the test db. python manage.py test -k It will create test database onece, it keeps that. A: Make a backup of your current database and name it as 'test_database_name'. Eg. DB_name = django. Then keep the backup database's name as test_django. mysqldump -u username -p database_name > database_backup.sql mysql -u username -p test_database_name < database_backup.sql When you run the tests, use this command python manage.py test --keepdb Django will use the backup DB for testing and then you don't have to apply migrations again and again. But make sure the name of the test database is correct. The command --keepdb will keep the DB and won't allow Django to delete the database everytime you run tests. Also, every time you run the tests, Django will flush all the data in the backup DB but it won't flush migrations. So every time you run the test you have to make a SetUp class to set all the users, permissions, groups etc.
doc_23538930
But as following links forces more features, further development time and a smarter client, the actual reality is that most of the restful apis that I have written and used are partially restful: they are a collection of well defined URIs and methods, all previously known to the user by some documentation. In the end, the State Transfer part of what REST means is not present in most of them. Well, following that reality where URLs are previously known, the 404 code turns to be an issue: How to differentiate the 2 meanings that 404 can have: * *A correct 404 that means "Resource not found, but you can try again in the future". Example: GET /user/mario while mario is not a registered user *A incorrect usage of the api that means "No resource will ever be found here, you are using this API incorrectly". Example: GET /foobar/123 It is kinda important to differentiate those two scenarios because as a service maintainer, they are basically telling me if its an expect error and I should not be worried (first case) or an unexpected error and I should be worried as the service integration with my clients has issues (second case) I tried searching for a better status code to represent the second case, and the closest ones I found were the 406 Not Acceptable (but it is a response directed to an Accept header that cannot be fulfilled) and the 410 Gone (that can be confusing as no resource was there, but the good part is that it tells the client to never try that URL again). Nevertheless, none of the two are good enough to be used for solving this How did you or would you do to solve that? Side node: python eve is an interesting project that tries to be a restful api with the State Transfer part. It implements HATEOAS for that A: What about using 403 for the first case (together with the explanation) and 404 for the second? Since the RFC 403 refers to 404 as an alternative response code they might be related... 403 Forbidden: The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead. 403: You understand what the client wants but refuse to fulfill it. The client should not try again - it's forbidden until this resource is created - which you can explain as part of the answer. 404: You know that the client wants something you won't provide and can tell him in good faith, that this resource will never exists. Update: RFC 2119 explains how the "SHOULD NOT" has to be interpreted: SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean that there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood and the case carefully weighed before implementing any behavior described with this label. I think for your use case this is true. The client request shouldn't be repeated *without solving the reason stated in the 403 answer: "accessing this resource is forbidden because no user named mario exists". But if the client is sure that the reason went away, he is free to try again. But this might be only my interpretation of the 403 "should not be repeated" statement. A: There is no way to differentiate the two reasons, by design of RFC 2616 Section 10.4.5: 10.4.5 404 Not Found The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.
doc_23538931
I'm using Angular Reactive Forms and subscribing to form control value changes Observable as follows. this.form.get('someSelection').valueChanges.susbscribe(value => this.selectionValue = value); In some cases, I want to manually update the value of the control but by doing so the valueChanges observable emits the new value. Is there any way to silently update the observable without notifying the subscribers? A: Use the emitEvent option when setting a new value : this.form.setValue(value, {emitEvent:false});
doc_23538932
Sample link below <a href="https:\\..?serachid=1" onclick="window.open(this.href,'popupwindow','scrollbars=no,resizable=no')return false" >click to download</a> Link's href doesn't have .pdf at the end. on clicking on the link, I am getting IE popup which has embedded pdf. clicking on print from popup makes a processing window which takes quit a lot of time and we are unable to track the progress. Rather clicking on save a copy button ( from flier which appears below works fine) if I click it manually, but I couldn't find a way to click on same from code.) I am looking for option to right click and clicking on "save target as" or option to click the "save a copy" buttonenter image description here I have tried quit a lot of suggestions still I am unable to find a solution which works for me, please help. Note: I can't modify html. and I can't use selenium. [Edit] I have tried to add download attribute as follows, still am getting IE popup, not direct download option as expected. <a href="https:\\..?serachid=1" onclick="window.open(this.href,'popupwindow','scrollbars=no,resizable=no')return false" download="">click to download</a> A: IE doesn't support download attribute in <a> so it doesn't work in IE. You can check the browser compatibility table. For IE, if you want to click the link to download, you can only convert the pdf file to blob data then download it using msSaveBlob. msSaveBlob is IE's own API for creating and downloading files. You can refer to the code below: <a href="your_file_link" onclick="downloadpdf();return false">click to download</a> <script> function downloadpdf() { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { //console.log(this.response, typeof this.response); window.navigator.msSaveBlob(this.response, 'testpdf.pdf'); } } xhr.open('GET', 'your_file_link'); xhr.responseType = 'blob'; xhr.send(); } </script> Result in IE 11:
doc_23538933
A: Well you can add a label to your view and change your label text to what you want to print. or you can show an alert view with the content of what you want to print. Here's an example to add an alert view (sender being the view controller calling this method). func showSimpleAlert(_ title:String, message:String, sender:AnyObject) { let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil) alertController.addAction(defaultAction) sender.present(alertController, animated: true, completion: nil) } Then you just need to convert the object you want to print (Date, Double, etc.) to a String object EDIT: When you call the alert view, here's what you can do: // Assuming we're in the ViewController class let alertString = String(format:"one: %@\ntwo: %@\nthree: %@\nfour: %@\nfive: %@", Formatter.string(from: houses.one), Formatter.string(from: houses.two), Formatter.string(from: houses.three), Formatter.string(from: houses.four), Formatter.string(from: houses.five)) showSimpleAlert("Debug print", message: alertString, sender: self) A: For detailed output of your print logs, use a developer only trick. Add a tap gesture (which is only known to you) and continuous 3 taps in that area within 2 seconds should invoke the hidden feature from your app where you display all the logs in a UITextView. You should implement a custom logger class which logs the required outputs to a plain text file which should be used to recall the logs. Adding a UILabel will impact the UI of your app and you may not want these logs to be available to all the users. Hence having a hidden area to check the logs would be an elegant approach.
doc_23538934
\newcommand{\vhlines}[1]{ \hspace{1em} \setlength{\unitlength}{0.75cm} \begin{picture}(22,#1) \color{lightgray} \linethickness{0.075mm} \multiput(0,0)(1,0){21} {\line(0,1){#1}} % need to subtract 1 from #1 \multiput(0,0)(0,1){#1} {\line(1,0){20}} \end{picture} } If I call, e.g., \vhlines{16} I find the vertical lines to be too long on the upper end. They are correct if I write a 15 instead of the #1 in the line with the comment. Is there an elegant way to do this? A: You can perform elementary numeric (integer) expressions using \numexpr: \documentclass{article} \usepackage{xcolor} \newcommand{\vhlines}[1]{% \hspace{1em}% \setlength{\unitlength}{0.75cm}% \begin{picture}(22,#1) \color{lightgray} \linethickness{0.075mm} \multiput(0,0)(1,0){21} {\line(0,1){\numexpr#1-1}} \multiput(0,0)(0,1){#1} {\line(1,0){20}} \end{picture} } \begin{document} \noindent \vhlines{4} \end{document} Alternatively, for more complex expressions, add to your preamble \usepackage{xparse} \ExplSyntaxOn \cs_new_eq:NN \calc \fp_eval:n \ExplSyntaxOff which would allow you to use \calc{<your numerical expression>}.
doc_23538935
My C code, sorry if its a little messy it was supposed to be temporary for a quick fix #include <stdio.h> #include <stdlib.h> #include <string.h> #include <Windows.h> #include <d2d1.h> #pragma comment(lib, "d2d1.lib") extern "C" ID2D1Bitmap* mybitmapcreate(ID2D1DCRenderTarget*); float left = 5; float top = 10; float Bottom = 10; float Right = 30; ID2D1Bitmap* picbitmap; D2D1_RECT_F myrect = D2D1::RectF(left, top, Bottom, Right); ID2D1DCRenderTarget* pow; ID2D1Bitmap* mybitmap; ID2D1Factory *l; REFIID x = __uuidof(ID2D1Factory); struct D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE), 0, 0, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT ); struct D2D1_BITMAP_PROPERTIES bitmapprops = D2D1::BitmapProperties( D2D1::PixelFormat(DXGI_FORMAT_R8G8B8A8_UINT, D2D1_ALPHA_MODE_UNKNOWN), 96.0, 96.0 ); int main() { /* long bufferend; FILE* mybitmapfile; char* mybitmaparray; //size_t result; mybitmapfile = fopen("bitmap.bin", "rb"); if (mybitmapfile == NULL) { fputs("File error", stderr); exit(1); } fseek(mybitmapfile, 0, SEEK_END); //bufferend = ftell(mybitmapfile); bufferend = 1204097; rewind(mybitmapfile); mybitmaparray = (char*) malloc(sizeof(char)*bufferend); if (mybitmaparray == NULL) { fputs("Memory error", stderr); exit(2); } fread(mybitmaparray, 1, bufferend, mybitmapfile); fclose(mybitmapfile); */ HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &l); l->CreateDCRenderTarget(&props, &pow); picbitmap = mybitmapcreate(pow); pow->BeginDraw(); while (true) { pow->DrawBitmap(picbitmap, myrect, 1.0F, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, myrect); }; pow->EndDraw(); return 0; } This is mybitmapcreate, its return value is the bitmap. includelib user32.lib includelib D2D1.lib include externals.asm include wincons.asm include vtable.asm .data include variables.asm include pic.asm include riid.asm include structures.asm .code public mybitmapcreate bitmapcreate proc frame mybitmapcreate:: DB 48h push rbx .pushreg rbx push r13 .pushreg r13 push rbp .pushreg rbp sub rsp, 80 .allocstack 80 lea rbp, [rsp + 80] .setframe rbp, 80 .endprolog mov ID2D1DCRenderTarget, rcx call __imp_GetDesktopWindow mov rcx, 0 mov rbx, rax getdcfail: call __imp_GetDC cmp rax, 0 je getdcfail mov rcx, rbx lea rdx, ScreenSize mov screendc, rax call __imp_GetWindowRect mov rcx, ID2D1DCRenderTarget mov rbx, [rcx] mov rdx, ScreenDC lea r8, ScreenSize call ID2D1DCRenderTarget_BindDC mov rcx, ID2D1DCRenderTarget mov rbx, [rcx] mov rdx, 000000199000002E0h lea r8, pic1colorbytes mov r9, 2944 lea rax, pic1properties mov qword ptr [rsp + 20h], rax lea rax, ID2D1Bitmap1 mov qword ptr [rsp + 28h], rax call ID2D1DCRenderTarget_CreateBitmap mov rax, ID2D1Bitmap1 mov rsp, rbp pop rbp pop r13 pop rbx ret bitmapcreate endp end This is my vtable ;ID2D1RenderTargetVtbl ID2D1RenderTarget_QueryInterface textequ <qword ptr [rbx+0]> ID2D1RenderTarget_AddRef textequ <qword ptr [rbx+8]> ID2D1RenderTarget_Release textequ <qword ptr [rbx+16]> ID2D1RenderTarget_GetFactory textequ <qword ptr [rbx+24]> ID2D1RenderTarget_CreateBitmap textequ <qword ptr [rbx+32]> ID2D1RenderTarget_CreateBitmapFromWicBitmap textequ <qword ptr [rbx+40]> ID2D1RenderTarget_CreateSharedBitmap textequ <qword ptr [rbx+48]> ID2D1RenderTarget_CreateBitmapBrush textequ <qword ptr [rbx+56]> ID2D1RenderTarget_CreateSolidColorBrush textequ <qword ptr [rbx+64]> ID2D1RenderTarget_CreateGradientStopCollection textequ <qword ptr [rbx+72]> ID2D1RenderTarget_CreateLinearGradientBrush textequ <qword ptr [rbx+80]> ID2D1RenderTarget_CreateRadialGradientBrush textequ <qword ptr [rbx+88]> ID2D1RenderTarget_CreateCompatibleRenderTarget textequ <qword ptr [rbx+96]> ID2D1RenderTarget_CreateLayer textequ <qword ptr [rbx+104]> ID2D1RenderTarget_CreateMesh textequ <qword ptr [rbx+112]> ID2D1RenderTarget_DrawLine textequ <qword ptr [rbx+120]> ID2D1RenderTarget_DrawRectangle textequ <qword ptr [rbx+128]> ID2D1RenderTarget_FillRectangle textequ <qword ptr [rbx+136]> ID2D1RenderTarget_DrawRoundedRectangle textequ <qword ptr [rbx+144]> ID2D1RenderTarget_FillRoundedRectangle textequ <qword ptr [rbx+152]> ID2D1RenderTarget_DrawEllipse textequ <qword ptr [rbx+160]> ID2D1RenderTarget_FillEllipse textequ <qword ptr [rbx+168]> ID2D1RenderTarget_DrawGeometry textequ <qword ptr [rbx+176]> ID2D1RenderTarget_FillGeometry textequ <qword ptr [rbx+184]> ID2D1RenderTarget_FillMesh textequ <qword ptr [rbx+192]> ID2D1RenderTarget_FillOpacityMask textequ <qword ptr [rbx+200]> ID2D1RenderTarget_DrawBitmap textequ <qword ptr [rbx+208]> ID2D1RenderTarget_DrawText textequ <qword ptr [rbx+216]> ID2D1RenderTarget_DrawTextLayout textequ <qword ptr [rbx+224]> ID2D1RenderTarget_DrawGlyphRun textequ <qword ptr [rbx+232]> ID2D1RenderTarget_SetTransform textequ <qword ptr [rbx+240]> ID2D1RenderTarget_GetTransform textequ <qword ptr [rbx+248]> ID2D1RenderTarget_SetAntialiasMode textequ <qword ptr [rbx+256]> ID2D1RenderTarget_GetAntialiasMode textequ <qword ptr [rbx+264]> ID2D1RenderTarget_SetTextAntialiasMode textequ <qword ptr [rbx+272]> ID2D1RenderTarget_GetTextAntialiasMode textequ <qword ptr [rbx+280]> ID2D1RenderTarget_SetTextRenderingParams textequ <qword ptr [rbx+288]> ID2D1RenderTarget_GetTextRenderingParams textequ <qword ptr [rbx+296]> ID2D1RenderTarget_SetTags textequ <qword ptr [rbx+304]> ID2D1RenderTarget_GetTags textequ <qword ptr [rbx+312]> ID2D1RenderTarget_PushLayer textequ <qword ptr [rbx+320]> ID2D1RenderTarget_PopLayer textequ <qword ptr [rbx+328]> ID2D1RenderTarget_Flush textequ <qword ptr [rbx+336]> ID2D1RenderTarget_SaveDrawingState textequ <qword ptr [rbx+344]> ID2D1RenderTarget_RestoreDrawingState textequ <qword ptr [rbx+352]> ID2D1RenderTarget_PushAxisAlignedClip textequ <qword ptr [rbx+360]> ID2D1RenderTarget_PopAxisAlignedClip textequ <qword ptr [rbx+368]> ID2D1RenderTarget_Clear textequ <qword ptr [rbx+376]> ID2D1RenderTarget_BeginDraw textequ <qword ptr [rbx+384]> ID2D1RenderTarget_EndDraw textequ <qword ptr [rbx+392]> ID2D1RenderTarget_GetPixelFormat textequ <qword ptr [rbx+400]> ID2D1RenderTarget_SetDpi textequ <qword ptr [rbx+408]> ID2D1RenderTarget_GetDpi textequ <qword ptr [rbx+416]> ID2D1RenderTarget_GetSize textequ <qword ptr [rbx+424]> ID2D1RenderTarget_GetPixelSize textequ <qword ptr [rbx+432]> ID2D1RenderTarget_GetMaximumBitmapSize textequ <qword ptr [rbx+440]> ID2D1RenderTarget_IsSupported textequ <qword ptr [rbx+448]> ;ID2D1Factory ID2D1Factory_QueryInterface textequ <qword ptr [rbx+0]> ID2D1Factory_AddRef textequ <qword ptr [rbx+8]> ID2D1Factory_Release textequ <qword ptr [rbx+16]> ID2D1Factory_ReloadSystemMetrics textequ <qword ptr [rbx+24]> ID2D1Factory_GetDesktopDpi textequ <qword ptr [rbx+32]> ID2D1Factory_CreateRectangleGeometry textequ <qword ptr [rbx+40]> ID2D1Factory_CreateRoundedRectangleGeometry textequ <qword ptr [rbx+48]> ID2D1Factory_CreateEllipseGeometry textequ <qword ptr [rbx+56]> ID2D1Factory_CreateGeometryGroup textequ <qword ptr [rbx+64]> ID2D1Factory_CreateTransformedGeometry textequ <qword ptr [rbx+72]> ID2D1Factory_CreatePathGeometry textequ <qword ptr [rbx+80]> ID2D1Factory_CreateStrokeStyle textequ <qword ptr [rbx+88]> ID2D1Factory_CreateDrawingStateBlock textequ <qword ptr [rbx+96]> ID2D1Factory_CreateWicBitmapRenderTarget textequ <qword ptr [rbx+104]> ID2D1Factory_CreateHwndRenderTarget textequ <qword ptr [rbx+112]> ID2D1Factory_CreateDxgiSurfaceRenderTarget textequ <qword ptr [rbx+120]> ID2D1Factory_CreateDCRenderTarget textequ <qword ptr [rbx+128]> ;dcrendertarget ID2D1DCRenderTarget_QueryInterface textequ <qword ptr [rbx+0]> ID2D1DCRenderTarget_AddRef textequ <qword ptr [rbx+8]> ID2D1DCRenderTarget_Release textequ <qword ptr [rbx+16]> ID2D1DCRenderTarget_GetFactory textequ <qword ptr [rbx+24]> ID2D1DCRenderTarget_CreateBitmap textequ <qword ptr [rbx+32]> ID2D1DCRenderTarget_CreateBitmapFromWicBitmap textequ <qword ptr [rbx+40]> ID2D1DCRenderTarget_CreateSharedBitmap textequ <qword ptr [rbx+48]> ID2D1DCRenderTarget_CreateBitmapBrush textequ <qword ptr [rbx+56]> ID2D1DCRenderTarget_CreateSolidColorBrush textequ <qword ptr [rbx+64]> ID2D1DCRenderTarget_CreateGradientStopCollection textequ <qword ptr [rbx+72]> ID2D1DCRenderTarget_CreateLinearGradientBrush textequ <qword ptr [rbx+80]> ID2D1DCRenderTarget_CreateRadialGradientBrush textequ <qword ptr [rbx+88]> ID2D1DCRenderTarget_CreateCompatibleRenderTarget textequ <qword ptr [rbx+96]> ID2D1DCRenderTarget_CreateLayer textequ <qword ptr [rbx+104]> ID2D1DCRenderTarget_CreateMesh textequ <qword ptr [rbx+112]> ID2D1DCRenderTarget_DrawLine textequ <qword ptr [rbx+120]> ID2D1DCRenderTarget_DrawRectangle textequ <qword ptr [rbx+128]> ID2D1DCRenderTarget_FillRectangle textequ <qword ptr [rbx+136]> ID2D1DCRenderTarget_DrawRoundedRectangle textequ <qword ptr [rbx+144]> ID2D1DCRenderTarget_FillRoundedRectangle textequ <qword ptr [rbx+152]> ID2D1DCRenderTarget_DrawEllipse textequ <qword ptr [rbx+160]> ID2D1DCRenderTarget_FillEllipse textequ <qword ptr [rbx+168]> ID2D1DCRenderTarget_DrawGeometry textequ <qword ptr [rbx+176]> ID2D1DCRenderTarget_FillGeometry textequ <qword ptr [rbx+184]> ID2D1DCRenderTarget_FillMesh textequ <qword ptr [rbx+192]> ID2D1DCRenderTarget_FillOpacityMask textequ <qword ptr [rbx+200]> ID2D1DCRenderTarget_DrawBitmap textequ <qword ptr [rbx+208]> ID2D1DCRenderTarget_DrawText textequ <qword ptr [rbx+216]> ID2D1DCRenderTarget_DrawTextLayout textequ <qword ptr [rbx+224]> ID2D1DCRenderTarget_DrawGlyphRun textequ <qword ptr [rbx+232]> ID2D1DCRenderTarget_SetTransform textequ <qword ptr [rbx+240]> ID2D1DCRenderTarget_GetTransform textequ <qword ptr [rbx+248]> ID2D1DCRenderTarget_SetAntialiasMode textequ <qword ptr [rbx+256]> ID2D1DCRenderTarget_GetAntialiasMode textequ <qword ptr [rbx+264]> ID2D1DCRenderTarget_SetTextAntialiasMode textequ <qword ptr [rbx+272]> ID2D1DCRenderTarget_GetTextAntialiasMode textequ <qword ptr [rbx+280]> ID2D1DCRenderTarget_SetTextRenderingParams textequ <qword ptr [rbx+288]> ID2D1DCRenderTarget_GetTextRenderingParams textequ <qword ptr [rbx+296]> ID2D1DCRenderTarget_SetTags textequ <qword ptr [rbx+304]> ID2D1DCRenderTarget_GetTags textequ <qword ptr [rbx+312]> ID2D1DCRenderTarget_PushLayer textequ <qword ptr [rbx+320]> ID2D1DCRenderTarget_PopLayer textequ <qword ptr [rbx+328]> ID2D1DCRenderTarget_Flush textequ <qword ptr [rbx+336]> ID2D1DCRenderTarget_SaveDrawingState textequ <qword ptr [rbx+344]> ID2D1DCRenderTarget_RestoreDrawingState textequ <qword ptr [rbx+352]> ID2D1DCRenderTarget_PushAxisAlignedClip textequ <qword ptr [rbx+360]> ID2D1DCRenderTarget_PopAxisAlignedClip textequ <qword ptr [rbx+368]> ID2D1DCRenderTarget_Clear textequ <qword ptr [rbx+376]> ID2D1DCRenderTarget_BeginDraw textequ <qword ptr [rbx+384]> ID2D1DCRenderTarget_EndDraw textequ <qword ptr [rbx+392]> ID2D1DCRenderTarget_GetPixelFormat textequ <qword ptr [rbx+400]> ID2D1DCRenderTarget_SetDpi textequ <qword ptr [rbx+408]> ID2D1DCRenderTarget_GetDpi textequ <qword ptr [rbx+416]> ID2D1DCRenderTarget_GetSize textequ <qword ptr [rbx+424]> ID2D1DCRenderTarget_GetPixelSize textequ <qword ptr [rbx+432]> ID2D1DCRenderTarget_GetMaximumBitmapSize textequ <qword ptr [rbx+440]> ID2D1DCRenderTarget_IsSupported textequ <qword ptr [rbx+448]> ID2D1DCRenderTarget_BindDC textequ <qword ptr [rbx+456]> A: You lack some necessary conditions: * *need a win32 window refer: Creating a Window *need to initialize IWICImagingFactory interface refer: How to Load a Bitmap from a File *need to use BindDC method to associate it with a GDI DC. refer: Direct2D and GDI Interoperability Overview Modified code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <Windows.h> #include <d2d1.h> #include <wincodec.h> #pragma comment(lib, "d2d1.lib") #pragma comment(lib, "Windowscodecs.lib") #define SAFE_RELEASE(P) if(P){P->Release() ; P = NULL ;} extern "C" ID2D1Bitmap* mybitmapcreate(ID2D1DCRenderTarget*); float left = 5; float top = 10; float Bottom = 10; float Right = 30; ID2D1Bitmap *pBitmap = NULL; IWICImagingFactory *pIWICFactory = NULL; void initize(); void draw(); D2D1_RECT_F myrect = D2D1::RectF(left, top, Bottom, Right); ID2D1DCRenderTarget* pow; ID2D1Bitmap* mybitmap; ID2D1Factory *l; REFIID x = __uuidof(ID2D1Factory); HRESULT LoadBitmapFromFile( ID2D1RenderTarget *pRenderTarget, IWICImagingFactory *pIWICFactory, PCWSTR uri, UINT destinationWidth, UINT destinationHeight ) { HRESULT hr = S_OK; IWICBitmapDecoder *pDecoder = NULL; IWICBitmapFrameDecode *pSource = NULL; IWICStream *pStream = NULL; IWICFormatConverter *pConverter = NULL; IWICBitmapScaler *pScaler = NULL; hr = pIWICFactory->CreateDecoderFromFilename( uri, NULL, GENERIC_READ, WICDecodeMetadataCacheOnLoad, &pDecoder ); if (SUCCEEDED(hr)) { // Create the initial frame. hr = pDecoder->GetFrame(0, &pSource); } if (SUCCEEDED(hr)) { hr = pIWICFactory->CreateFormatConverter(&pConverter); } // If a new width or height was specified, create an // IWICBitmapScaler and use it to resize the image. if (destinationWidth != 0 || destinationHeight != 0) { UINT originalWidth, originalHeight; hr = pSource->GetSize(&originalWidth, &originalHeight); if (SUCCEEDED(hr)) { if (destinationWidth == 0) { FLOAT scalar = static_cast<FLOAT>(destinationHeight) / static_cast<FLOAT>(originalHeight); destinationWidth = static_cast<UINT>(scalar * static_cast<FLOAT>(originalWidth)); } else if (destinationHeight == 0) { FLOAT scalar = static_cast<FLOAT>(destinationWidth) / static_cast<FLOAT>(originalWidth); destinationHeight = static_cast<UINT>(scalar * static_cast<FLOAT>(originalHeight)); } hr = pIWICFactory->CreateBitmapScaler(&pScaler); if (SUCCEEDED(hr)) { hr = pScaler->Initialize( pSource, destinationWidth, destinationHeight, WICBitmapInterpolationModeCubic ); } if (SUCCEEDED(hr)) { hr = pConverter->Initialize( pScaler, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0.f, WICBitmapPaletteTypeMedianCut ); } } } if (SUCCEEDED(hr)) { // Create a Direct2D bitmap from the WIC bitmap. hr = pRenderTarget->CreateBitmapFromWicBitmap( pConverter, NULL, &pBitmap ); } SAFE_RELEASE(pDecoder); SAFE_RELEASE(pSource); SAFE_RELEASE(pStream); SAFE_RELEASE(pConverter); SAFE_RELEASE(pScaler); return TRUE; } LRESULT CALLBACK WndProcFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { RECT rc; switch (message) { case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rc); pow->BindDC(ps.hdc, &rc); draw(); EndPaint(hwnd, &ps); } break; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); } int main(int argc, char* argv[]) { WNDCLASS wc{}; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProcFunc; wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = L"Class_Name"; wc.hCursor = LoadCursor(nullptr, IDC_ARROW); RegisterClass(&wc); HWND hWnd = CreateWindow(L"Class_Name", L"Test", WS_OVERLAPPEDWINDOW, 100, 100, 1000, 500, NULL, NULL, GetModuleHandle(NULL), NULL); initize(); ShowWindow(hWnd, 1); UpdateWindow(hWnd); MSG Msg; while (GetMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return 0; } void initize() { CoInitializeEx(NULL, COINIT_MULTITHREADED); CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, reinterpret_cast<void **>(&pIWICFactory)); // Create a Direct2D render target. D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE), 0, 0, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT ); HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &l); l->CreateDCRenderTarget(&props, &pow); } void draw() { LoadBitmapFromFile(pow, pIWICFactory, L"Path\\test.bmp", 650, 400); pow->BeginDraw(); pow->Clear(D2D1::ColorF(D2D1::ColorF::White)); D2D1_SIZE_F size = pBitmap->GetSize(); D2D1_POINT_2F upperLeftCorner = D2D1::Point2F(0.f, 0.f); // Draw bitmap pow->DrawBitmap( pBitmap, D2D1::RectF( upperLeftCorner.x, upperLeftCorner.y, upperLeftCorner.x + size.width, upperLeftCorner.y + size.height) ); pow->EndDraw(); } There may be some redundancy in the code, you can freely add and delete. Debug:
doc_23538936
A: In general, there are two approaches for a given route: (1) go immediately to the page and fill in data as it becomes available (2) wait for the data to be fetched before transitioning. Case 1 is quite straightforward. You create an instance of the model class, call fetch, and return it. var FooRoute = Em.Route.extend({ model: function(params) { var foo = Foo.create({ id: params.id }); foo.fetch(); return foo; }, setup: function(foo) { // foo is a Foo, but may not have its data populated } }); Case 2 is more complicated because Ember-Resource's fetch method returns a promise that resolves with two arguments -- the underlying JSON data and the model itself. An Ember.Route that returns such a promise will only pass the first to setup, so we have to create our own promise: var FooRoute = Em.Route.extend({ model: function(params) { var foo = Foo.create({ id: params.id }), deferred = $.Deferred(); foo.fetch().then( function(json, model) { deferred.resolve(model); }, function(error) { deferred.reject(error); } ); return deferred.promise(); }, setup: function(foo) { // foo is a Foo with its data populated } });
doc_23538937
As far as understand, it should not be affected by the Operation System since it is the same jar (hsqldb-2.3.2.jar), same JDK version (7) and exact same myapp.ear file. So, my straight question is: what could be the reason for "NoSuchMethodError: javax/persistence/Table.indexes" during entityManagerFactory creation? What make my life harder is that the exact same ear deployed in my local Websphere doesn't pop up such error. An indirect question could be, is any trick to make in memory HSQLDB run in Unix? Am I reading wrongly the logs and such error is in fact caused by some wrong Spring config? I don't think so because exact same ear runs in another Websphere as said. I have been struggling for 4 days to find a possible reason but I couldn't. Any suggestion will be highly appreciatted. Error Logs: WebSphere non-WLM Dispatch Thread t=009bb7a0¨ ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in myapp.config.root.TestConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/persistence/Table.indexes()ÝLjavax/persistence/Index; at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java TestConfiguration.java @Configuration @EnableTransactionManagement public class TestConfiguration { @Bean(initMethod = "init") public TestDataInitializer initTestData() { return new TestDataInitializer(); } @Bean(name = "datasource") public DriverManagerDataSource dataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(org.hsqldb.jdbcDriver.class.getName()); dataSource.setUrl("jdbc:hsqldb:mem:mydb"); dataSource.setUsername("sa"); dataSource.setPassword("jdbc:hsqldb:mem:mydb"); System.out.println("Untill here was printed without error"); return dataSource; } @Bean(name = "entityManagerFactory") public LocalContainerEntityManagerFactoryBean entityManagerFactory(DriverManagerDataSource dataSource) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); entityManagerFactoryBean.setPackagesToScan(new String[]{"myapp.model"}); entityManagerFactoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); Map<String, Object> jpaProperties = new HashMap<String, Object>(); jpaProperties.put("hibernate.hbm2ddl.auto", "create"); jpaProperties.put("hibernate.show_sql", "true"); jpaProperties.put("hibernate.format_sql", "true"); jpaProperties.put("hibernate.use_sql_comments", "true"); entityManagerFactoryBean.setJpaPropertyMap(jpaProperties); System.out.println("Untill here was printed without error also"); return entityManagerFactoryBean; } } TestDataInitializer import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.persistence.EntityManagerFactory; @Component public class TestDataInitializer { @Autowired private EntityManagerFactory entityManagerFactory; @Autowired AnotherModelRepository anotherModelRepository; public void init() throws Exception { SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class); Session session = sessionFactory.openSession(); Transaction transaction = session.beginTransaction(); … few session.persit(mymodel)… POM: <properties> <java-version>1.7</java-version> <org.springframework-version>4.1.3.RELEASE</org.springframework-version> <spring-security-version>3.2.5.RELEASE</spring-security-version> <hibernate.version>4.3.7.Final</hibernate.version> <org.slf4j-version>1.6.1</org.slf4j-version> <jackson-version>2.4.4</jackson-version> <postgres.driver.version>9.3-1100-jdbc41</postgres.driver.version> </properties> <dependencies> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework-version}</version> <exclusions> <!-- Exclude Commons Logging in favor of SLF4j --> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${org.springframework-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${org.springframework-version}</version> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>${postgres.driver.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${org.springframework-version}</version> </dependency> <!-- Hibernate --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate.version}</version> </dependency> <!-- Spring security --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>${spring-security-version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>${spring-security-version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>${spring-security-version}</version> </dependency> <dependency> <groupId>com.allanditzel</groupId> <artifactId>spring-security-csrf-token-filter</artifactId> <version>1.1</version> </dependency> <!-- Logging --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${org.slf4j-version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${org.slf4j-version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${org.slf4j-version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <!-- Jackson JSON Processor --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson-version}</version> </dependency> <!-- servlet container provided dependencies --> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-servlet-api</artifactId> <version>7.0.30</version> <scope>provided</scope> </dependency> <!-- test dependencies --> <dependency> <groupId>com.jayway.jsonpath</groupId> <artifactId>json-path</artifactId> <version>0.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.3.2</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>2.3.2</version> </dependency> </dependencies> <build> <finalName>my-app</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>${java-version}</source> <target>${java-version}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build> </project> **** Added in August 28th 2016 2:45am Brazil, São Paulo timezone Thanks to the excellent answers provided, I finaly have my application running in both Windows Websphere 8.5 Liberty Profile as in Mainframe z/OS390 Websphere ND 8.5. I added here my solution for future readers. The basic trick was (1) downgrade Hibernate in order to use JPA2 and use EntityManager.getDelegate() @Component public class TestDataInitializer { @Autowired private EntityManagerFactory entityManagerFactory; @Autowired AnotherModelRepository anotherModelRepository; // I TOOK @PersistenceContext OUT /* @PersistenceContext private EntityManager em;*/ public void init() throws Exception { // I REPLACED entityManagerFactory.unwrap AND sessionFactory.openSession OUT //SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class); //Session session = sessionFactory.openSession(); // BY createEntityManager AND getDelegate EntityManager em = entityManagerFactory.createEntityManager(); Session session = (Session) em.getDelegate(); Transaction transaction = session.beginTransaction(); … @Repository public class MyModelRepository { /* @PersistenceContext private EntityManager em;*/ @Autowired private EntityManagerFactory entityManagerFactory; public MyModel findMyModelById(Long MyModel) { EntityManager em = entityManagerFactory.createEntityManager(); List<MyModel> MyModels = em.createNamedQuery(MyModel.FIND_BY_ID, MyModel.class).setParameter("MyModelId", MyModel).getResultList(); return MyModels.size() == 1 ? MyModels.get(0) : null; } public List<MyModel> findOutByIn(Integer certainId){ //SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class); EntityManager em = entityManagerFactory.createEntityManager(); Session session = (Session) em.getDelegate(); String query = "select c from … c " + " inner join … o " + " where …; //Session session = sessionFactory.openSession(); Transaction transaction = session.beginTransaction(); List<MyModel> l = session.createQuery(query).list(); return l; } A: You are getting below error. Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax/persistence/Table.indexes()ÝLjavax/persistence/Index; This error is indicating that required method is not available in the particular class. The "indexes()" method is available at "javax.persistence.Table" class of JPA 2.1 jar (hibernate-jpa-2.1-api). Some how in your deployment it is picking up JPA 2.0 jar (hibernate-jpa-2.0-api) which doesn't have this method in Table class. In your pom.xml you are using "hibernate-entitymanager 4.3.7.Final", which provides JPA 2.1 jar file. Please look for the JPA 2.0 jars file in your server where you are getting this error.
doc_23538938
The way I converted my MySQL DB was simple exported DB and copied all "INSERTS" with edited syntax, import was successful because I can see all the data correct. SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "elements_pkey" DETAIL: Key (id)=(1) already exists. Is there any way to fix issues with id's? A: It works after reset the sequence. SELECT setval('my_sequence_name', (SELECT max(id) FROM my_table));
doc_23538939
These menu items open pages which allow me to make some settings and access data, and I am using jquery dialogs to display and edit the data. Everything works fine except, when the dialogs are opened (any of them, there are several) they always open with all the defined buttons overlapping eachother in the top right of the title pane. They do not appear in the button pane as expected. I have tried deregistering the standard Wordpress jquery-ui-dialog and loading from a source I have used before, it makes no difference. I have tried including my own css and can successfully change the font sizes, background, dialog position etc... but nothing I have found corrects the position of the dialog buttons. (Or for that matter, the colour of the buttons... cannot change them with css for some reason?) Have queued my own css file as below: add_action( 'admin_enqueue_scripts', 'queue_LD4U_admin_scripts'); function queue_LD4U_admin_scripts() { wp_enqueue_script( 'jquery-ui-dialog' ); wp_enqueue_style('kastech-LD4U-manager-admin-ui-css', plugins_url() . '/kastech-LD4U-manager/includes/css/ld4u_dialogs.css', false); } I can set font sizes etc. all other aspects of the dialog style... but, the buttons still all appear at the top right of the dialog, all overlapping. All other aspects of the dialogs are working, and I have used them many times before in the front end of sites, but this is the first time tried to use in Admin of Wordpress site, and the only thing that doesnt seem to work is this, the position of the buttons. Makes it unuseable. This is my css. As I said, it correctly controls style of the dialog. /* style for all JQuery dialogs */ .ui-dialog, .ui-dialog-content { border:5px solid #1E1F22; } .ui-dialog-titlebar { background-image: none; background-color: #0088BE; } .ui-dialog-title { background-color: #ff88BE; color: green; font-size: 0.7em; } .ui-dialog-titlebar-close { display: none; } .ui-dialog-buttonpane { background-color: #aaaaaa; font-size: 0.7em; } .ui-dialog-buttonset .ui-button-spl1 { background:blue; } .ui-widget-overlay { background-color: red; background-image: none; opacity: 0.7; height:3000px; } The other thing that I have noticed is that the enqueue-ing of the Wordpress jquery-ui-dialog does not seem to be working.. the dialogs do not appear at all unless I include <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> somewhere in my script section. A: There was actually another css file being loaded that was changing the default behaviour of dialog buttons. I included .ui-dialog button { position: inherit !important; } in my css file and now have complete control over styling. There still seems to be the issue that wp_enqueue_script( 'jquery-ui-dialog' ); doesn't seem to do what it is supposed, but I have the workaround that I just include the js file from code.jquery.com directly in my script.
doc_23538940
cmake_minimum_required(VERSION 3.13 FATAL_ERROR) project(CUDA_MPI LANGUAGES CXX CUDA) find_package(CUDA REQUIRED) find_package(MPI REQUIRED) add_library(Timer STATIC timer.h timer.cpp) add_library(Coll STATIC collectives.h collectives.cu) add_executable(CUDA_MPI ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp) include_directories(/usr/lib/x86_64-linux-gnu/openmpi/include) target_link_libraries(CUDA_MPI PUBLIC Timer Coll MPI::MPI_CXX ${CUDA_LIBRARIES}) My configuration log is as the following. It seems that CMake tool can find the library of OpenMPI but it cannot find the head file. -- The CXX compiler identification is GNU 7.3.0 -- The CUDA compiler identification is NVIDIA 10.0.130 -- Check for working CXX compiler: /home/szhangcj/.conda/envs/distributed/bin/x86_64-conda_cos6-linux-gnu-c++ -- Check for working CXX compiler: /home/szhangcj/.conda/envs/distributed/bin/x86_64-conda_cos6-linux-gnu-c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc -- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc -- works -- Detecting CUDA compiler ABI info -- Detecting CUDA compiler ABI info - done -- Looking for C++ include pthread.h -- Looking for C++ include pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Found CUDA: /usr/local/cuda (found version "10.0") -- Found MPI_CXX: /home/szhangcj/.conda/envs/distributed/lib/libmpi_cxx.so (found version "3.1") -- Found MPI: TRUE (found version "3.1") -- Configuring done -- Generating done -- Build files have been written to: /home/szhangcj/HPC/MPI/baidu-allreduce/build The error message from the generating stage is as the following. Scanning dependencies of target Timer [ 14%] Building CXX object CMakeFiles/Timer.dir/timer.cpp.o [ 28%] Linking CXX static library libTimer.a [ 28%] Built target Timer Scanning dependencies of target Coll [ 42%] Building CUDA object CMakeFiles/Coll.dir/collectives.cu.o /home/szhangcj/HPC/MPI/baidu-allreduce/collectives.cu:9:10: fatal error: mpi.h: No such file or directory #include <mpi.h> ^~~~~~~ compilation terminated. CMakeFiles/Coll.dir/build.make:62: recipe for target 'CMakeFiles/Coll.dir/collectives.cu.o' failed make[2]: *** [CMakeFiles/Coll.dir/collectives.cu.o] Error 1 CMakeFiles/Makefile2:147: recipe for target 'CMakeFiles/Coll.dir/all' failed make[1]: *** [CMakeFiles/Coll.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2 I have checked the installation directory and I found that there is no include directory under the openmpi folder. How can I fix this? What's more, on another machine, I repeat the same process to install the Openmpi by using conda. After that, I even cannot find the MPI library.
doc_23538941
I would like to select data for each unique species, so loop through all the unique species names, and create an interpolated layer for each species. Then name the result by species name. The interpolation part is working fine….I just can’t figure out how to loop through each species name and do the naming….. I've pasted the working code below for selecting one species name and creating an interpolated layer. SP_NAME sno swgt latdd londd 1 ILLEX ILLECEBROSUS 33.7542857 2.94582857 43.28667 -60.99367 2 CHLOROPHTHALMUS AGASSIZI 13.2971429 0.09205714 43.28667 -60.99367 3 ILLEX ILLECEBROSUS 0.9657143 0.16417143 43.94750 -58.72417 4 ZOARCES AMERICANUS 0.9657143 0.02897143 43.94750 -58.72417 5 AMBLYRAJA RADIATA 2.0457143 1.00240000 43.86483 -59.19717 6 MYOXOCEPHALUS OCTODECEMSPINOSUS 1.0228571 0.10228571 43.86483 -59.19717 setwd("C:/Michelle/Michelle/R/WCTS/Boundaries") strata <- readOGR(".", "SurveyStrataWGS84") strata<-spTransform(strata,CRS("+proj=utm +zone=20 ellps=WGS84")) es_tows1 <- es_tows[which(es_tows$SP_NAME == "HIPPOGLOSSOIDES PLATESSOIDES"),] ext = extent(strata) rb <- raster(ext, ncol=554, nrow=279) stratar <- rasterize(strata, rb) plot(stratar) idw.grid<- rasterToPoints(stratar, spatial=TRUE) gridded(idw.grid) <- TRUE proj4string(es_tows1) <- CRS("+proj=utm +zone=20 ellps=WGS84") idw(log(es_tows1$swgt+ 0.00001) ~1 , es_tows1, idw.grid) pal <- colorRampPalette(rev(brewer.pal(11, "Spectral")))(100) spplot(idw.out, "var1.pred", col.regions=pal) A: library(rgdal) library(raster) strata <- readOGR(".", "SurveyStrataWGS84") strata <- spTransform(strata,CRS("+proj=utm +zone=20 ellps=WGS84")) ext <- extent(strata) rb <- raster(ext, ncol=554, nrow=279) # I think this is all you need to do here idw.grid <- as(rb, 'SpatialGrid') # list of species species <- unique(es_tows$SP_NAME) for (sp in species) { es_tows1 <- es_tows[es_tows$SP_NAME == sp, ] out <- idw(log(es_tows1$swgt+ 0.00001) ~1 , es_tows1, idw.grid) # ... save the results .... writeRaster(raster(out), filename=sp) }
doc_23538942
I made a form with react-form-hooks and tried to implement a custom range slider (I’m sorry that it’s not all broken out to components and is mainly single file). I’m new to React, JS and TSX (there’s a sandbox at the bottom of the post). *Side-note: the form is loading pretty slow right now, any tips on improving performance would be greatly appreciated. (: (Actually at this point appreciative for any ideas and open to feedback). Advanced Search Form What I am trying to achieve: I am trying to take input as a range of values from 0 to 100 in a form. The values can be passed as [0,100] on default or if they are updated, on pressing submit the current values ([min, max]) of their state would be submitted. The information would be passed as a json response to an api backend through a post request. I found some options online on implementing a range slider with react-hooks-form but could not get any of them to work unfortunately. Could someone please help me implement the range slider (I will need to use 3 of them in my form)? If this is not possible, could you please assist with one of the following alternatives: Option 1: Setting up a select box/combo-box that does the following: Provides the user a max or min option based off the corresponding max/min option. I.e. if there is no input in either the Max or Min select/combo-box: Then both boxes would have 0-100 as the possible range of values. If the value of one box was touched: then the second select/combo fields values would be of the corresponding remainder of the range. E.g. If I selected 70 for my minimum value my other select/combo would provide for me to either leave it blank, or give me the options 70 to 100. Or if I selected 82 for the max input field- the select for min would only allow me to use 0 to 82 for my min or leave it blank. Option 2: Text input fields with the same validation schema as above that would become an error state if the user entered something like: artist-rating min: 40 artist-rating max: 20 Here is the sandbox: https://codesandbox.io/s/advanced-search-form-forked-0lhgrv A: Thanks for updating the post. You problem is that Mui Slider Component, doesn't take the default input props, so you can't spread the register method returned by react-hook-form since it returns the default value and onChange props. But react-hook-form is a great library and it already addressed the integration with the main react UI libs: https://react-hook-form.com/get-started#IntegratingwithUIlibraries I implemented a basic example here: https://codesandbox.io/s/wonderful-silence-9qlfbj?file=/src/App.js They expose quite extensive and clear APIs, take your time to study them if you plan to use it as your form management library.
doc_23538943
**Dates_only:** ID Quart_y Quart 1 1118 2017Q3 0.25 2 1118 2017Q4 0.50 3 1118 2018Q1 0.75 4 1118 2018Q2 1.00 5 1118 2018Q3 1.25 6 1118 2018Q4 1.50 7 1118 2019Q1 1.75 8 1118 2019Q2 2.00 9 1119 2017Q3 0.25 10 1119 2017Q4 0.50 11 1119 2018Q1 0.75 12 1119 2018Q2 1.00 13 1119 2018Q3 1.25 14 1119 2018Q4 1.50 15 1119 2019Q1 1.75 16 1119 2019Q2 2.00 17 13PP 2017Q3 0.25 18 13PP 2017Q4 0.50 19 13PP 2018Q1 0.75 20 13PP 2018Q2 1.00 21 13PP 2018Q3 1.25 22 13PP 2018Q4 1.50 23 13PP 2019Q1 1.75 24 13PP 2019Q2 2.00 And the second dataset: **Values** ID Day Value 1 1118 0 7.6 2 1119 0 6.2 3 13PP 0 6.8 4 1118 0.14 7.1 5 1119 0.13 6.2 6 13PP 0.13 5.9 7 1118 0.20 6.8 8 1119 0.23 5.8 9 13PP 0.24 4.6 10 1118 0.27 6.5 11 1119 0.28 5.4 12 13PP 0.32 4.2 13 1118 0.32 6.3 14 1119 0.32 4.8 15 13PP 0.44 4.0 16 1118 0.47 6.0 17 1119 0.49 4.3 18 13PP 0.49 3.8 19 1118 0.59 5.9 20 1119 0.64 4.0 21 13PP 0.61 3.6 22 1118 0.72 5.6 23 1119 0.71 3.8 24 13PP 0.73 3.4 25 1118 0.95 5.4 26 1119 0.86 3.2 27 13PP 0.78 3.0 28 1118 1.10 5.0 29 1119 0.93 2.9 30 13PP 1.15 2.9 What I want to do is to create another column (a fourth) in the Dates_only called Value_average, and it will contain average scores extracted from Values dataframe from the column Values$Value. Specifically, as you can observe in Dates_only the Quart_y represents quarters/year, the Quart quantify this with a number from 0.25:2. So, the pattern goes like this Q3 - x.25, Q4 - x.50, Q1 - x.75, Q2 - x.00. In the second dataframe, Values, we have some scores that represent days of the year. The concept is that for days that have scores 0<Day<0.25 belong to the 2017Q3, days with scores 0.25<Day<0.50 belong to 2017Q4, and days with scores 1.00<Day<1.25 belong to 2018Q3. I want for each ID from Dates_only dataframe to find the average of the Values$Value numbers that belong to the appropriate time frame: For ID=1118 and for 2017Q3 the 'Values$Day' elements that are between 0<Day<=0.25 are (0, 0.14, 0.20) and the equivalent Values$Value are (7.6, 7.1, 6.8) so the Dates_only$Value_average is going to be 7.16. The next will average values for days 0.25<Day<=0.50 etc. **Dates_only:** ID Quart_y Quart Value_average 1 1118 2017Q3 0.25 7.16 2 1118 2017Q3 0.50 6.27 The code that I have used is: Dates_only$Value_average <- 0 for (i in 1:length(Dates_only$ID)){ id <- as.character(Dates_only$ID[i]) quart <- as.numeric(Dates_only$Quart[i]) quart_prev <- quart-0.25 count_d <- 0 sum_val <- 0 for (k in 1:length(Values$ID)){ if (id==as.character(Values$ID[k]) && quart>=as.numeric(Values$Day[k]) && as.numeric(Values$Day[k])>quart_prev){ sum_val <- as.numeric(Values$Value[k]) + sum_val count_d <- count_d + 1 } } av_value <- sum_val/count_d Dates_only$Value_average[i] <- av_value } Is there a more efficient code to do that in very large datasets (over 300K observations)? I am pretty sure there is but my novice skills on R do not help a lot. To replicate the two dataframes: Dates_only <- data.frame(ID=c('1118','1118','1118','1118','1118', '1118','1118','1118','1119','1119', '1119','1119','1119','1119','1119', '1119','13PP','13PP','13PP','13PP', '13PP','13PP','13PP','13PP'), Quart_y=c('2017Q3','2017Q4','2018Q1','2018Q2', '2018Q3','2018Q4','2019Q1','2019Q2', '2017Q3','2017Q4','2018Q1','2018Q2', '2018Q3','2018Q4','2019Q1','2019Q2', '2017Q3','2017Q4','2018Q1','2018Q2', '2018Q3','2018Q4','2019Q1','2019Q2'), Quart=c(0.25,0.50,0.75,1.00,1.25,1.50,1.75,2.00, 0.25,0.50,0.75,1.00,1.25,1.50,1.75,2.00, 0.25,0.50,0.75,1.00,1.25,1.50,1.75,2.00)) Values <- data.frame(ID=c('1118','1119','13PP','1118','1119','13PP', '1118','1119','13PP','1118','1119','13PP', '1118','1119','13PP','1118','1119','13PP', '1118','1119','13PP','1118','1119','13PP', '1118','1119','13PP','1118','1119','13PP'), Day=c(0,0,0,0.14,0.13,0.13,0.2,0.23,0.24,0.27,0.28, 0.32,0.32,0.32,0.44,0.47,0.49,0.49,0.59,0.64, 0.61,0.72,0.71,0.73,0.95,0.86,0.78,1.1,0.93,1.15), Value=c(7.6,6.2,6.8,7.1,6.2,5.9,6.8,5.8,4.6,6.5,5.4, 4.2,6.3,4.8,4,6,4.3,3.8,5.9,4,3.6,5.6,3.8, 3.4,5.4,3.2,3,5,2.9,2.9)) A: We can accomplish almost all of this using the dplyr package library(dplyr) Values %>% mutate(Day = ifelse(Day == 0, 0.01, Day)) %>% mutate(Quart = ceiling(Day / 0.25) * 0.25) %>% full_join(., Dates_only, by = c("ID", "Quart")) %>% group_by(ID, Quart, Quart_y) %>% summarise(Value_average = mean(Value, na.rm = TRUE)) Which gives you: ID Quart Quart_y Value_average <fctr> <dbl> <fctr> <dbl> 1 1118 0.25 2017Q3 7.166667 2 1118 0.50 2017Q4 6.266667 3 1118 0.75 2018Q1 5.750000 4 1118 1.00 2018Q2 5.400000 5 1118 1.25 2018Q3 5.000000 6 1118 1.50 2018Q4 NaN 7 1118 1.75 2019Q1 NaN 8 1118 2.00 2019Q2 NaN 9 1119 0.25 2017Q3 6.066667 10 1119 0.50 2017Q4 4.833333 # ... with 14 more rows See below for a breakdown of each line of code for any questions: # Start with your `Values` data frame Values %>% # Recode `Day` that are '0.00', as they currently will be excluded from # the rule 2017Q3: 0<Day<=0.25 # I picked 0.01 arbitrarily to fit this rule mutate(Day = ifelse(Day == 0, 0.01, Day)) %>% # Now round all `Day` values up to the nearest 0.25 mutate(Quart = ceiling(Day / 0.25) * 0.25) %>% # Now join the two data frames using a `full_join` # A left_join may also be used if you are uninterested in NA's full_join(., Dates_only, by = c("ID", "Quart")) %>% # Finally, designate groupings to calculate the mean values # for each ID for each quarter group_by(ID, Quart, Quart_y) %>% summarise(Value_average = mean(Value, na.rm = TRUE))
doc_23538944
The state should contain the userId and some structs of the user info, and should be kept during the whole session of the user while he's logged in (across http requests) The important criteria: 1) Support scalability 2) Performance The easy way is to use the Session object, but it doesn't support scalability. If different requests during the session go through different IIS servers, the session won't be kept. Although I've heard of load balancing tools which route all requests of a single session through the same machine, I'm not sure that it's a good practice to rely on it (isn't it?) Another option that I've read about, is keeping the state data in special state servers which are running a RAM DB (like Cassandra for Linux or Redis for Windows). But it seems to me an overkill at this stage of the development. Do you have any other suggestions? I would like to start with something simple at the moment, but keep the design ready for a more advanced solution at the future. Any best practice or code/design suggestions will be appreciated. Thanks, Edi. A: (1) Use Sql Server to Store Session State (2) Use Memcached as a Session State Provider (3) Cook up your own solution using Caching on an external caching provider: look into using something like the ServiceStack Caching Framework. Using this, you can use Redis, Memcached, Azure or AWS to handle caching. Next, create a KeyFactory to handle generation of keys for specific items. The item keys would include the UserId (which you would always have from FormsAuthentication UserId (assuming that you are using FormsAuthentication). Then store any Session data for the user in the cache. Using this approach you are using Caching in place of Session, and the cache can be shared across multiple servers. Note: you can have different approaches regarding clearing out the user's data whenever they begin a new session. Potential approaches include: * *Include the user's session start dateTime in the cacheKey, and auto-expire entries when they are no longer fresh *Clear out all potential entries for a user when they begin a new session A: If you are using .NET 4.5 and dependent on the type and amount of information you are keeping on users you may want to look at using claims to store information about the user. In .NET 4.5 all Principals inherit from ClaimsPrincipal. ClaimsPrincipal already uses claims to store the user name, roles and other information. You can create your own service to transform claims, which will allow you to add additional information to the Principal user.
doc_23538945
data: () => ({ total: [], }); A method called getAmount(): getAmount(item){ // gets individual amount and pushes it to the total array var amount = 0; // Skipping the amount calculation to keep the // question as small as possible amount = item.price + 10; this.total[this.total.length] = amount; return amount; } And a computed property called getTotal(): getTotal(){ if(this.total.length > 0){ return this.total.reduce((x,y) => x+y); } else { return 0; } }, In the template I am accessing the getAmount() method and getTotal computed property like this: <v-data-table :headers="headers" :items="orderShares" hide-actions class="elevation-1" > <template slot="items" slot-scope="props"> <td class="text-xs-left">{{ props.item.order.order_code }}</td> <td class="text-xs-left">{{ getAmount(props.item) }}</td> </template> </v-data-table> <p> Total Amount: {{ getTotal }} </p> The total amount always remains 0. But what I was expecting is that it should update as many times as the getAmount() method is called. Because getAmount() triggers a change in the total prop, theoretically, computed property getTotal should also be updated since it depends on total. But that's not what's happening here. How can I fix this? A: You likely want to do this in your method instead due to array detection caveats (https://v2.vuejs.org/v2/guide/list.html#Caveats) this.total.push(amount) Also, that getTotal computed can simply be: return this.total.reduce((x, y) => x + y, 0)
doc_23538946
So, here is my problem: I am using retrofit + okhttp to fetch some data from API and I'd like to cache them. Unfortunately, I don't have admin access to the API server so I can't modify headers returned by the server. (currently, server returns Cache-control: private) So I decided to use okhttp header spoofing to insert appropriate cache headers. Sadly, no matter what I do, caching doesn't seem to work. I initialise the api service like this: int cacheSize = 10 * 1024 * 1024; // 10 MiB File cacheFile = new File(context.getCacheDir(), "thumbs"); final Cache cache = new Cache(cacheFile, cacheSize); OkHttpClient client = new OkHttpClient(); client.setCache(cache); client.interceptors().add(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .removeHeader("Access-Control-Allow-Origin") .removeHeader("Vary") .removeHeader("Age") .removeHeader("Via") .removeHeader("C3-Request") .removeHeader("C3-Domain") .removeHeader("C3-Date") .removeHeader("C3-Hostname") .removeHeader("C3-Cache-Control") .removeHeader("X-Varnish-back") .removeHeader("X-Varnish") .removeHeader("X-Cache") .removeHeader("X-Cache-Hit") .removeHeader("X-Varnish-front") .removeHeader("Connection") .removeHeader("Accept-Ranges") .removeHeader("Transfer-Encoding") .header("Cache-Control", "public, max-age=60") //.header("Expires", "Mon, 27 Apr 2015 08:15:14 GMT") .build(); } }); RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(API_ROOT) .setLogLevel(RestAdapter.LogLevel.HEADERS_AND_ARGS) .setClient(new OkClient(client)) .setConverter(new SimpleXMLConverter(false)) .setRequestInterceptor(new RequestInterceptor() { @Override public void intercept(RequestFacade request) { if (Network.isConnected(context)) { int maxAge = 60; // read from cache for 2 minutes request.addHeader("Cache-Control", "public, max-age=" + maxAge); } else { int maxStale = 60 * 60 * 24 * 28; // tolerate 4-weeks stale request.addHeader("Cache-Control", "public, only-if-cached, max-stale=" + maxStale); } } }) .build(); api = restAdapter.create(ApiService.class); Of course, it's not necessary to remove all these headers, but I wanted to make the response as clean as possible to rule out some interference from these extra headers. As you can see, I tried to also spoof Expires and Date header (I tried removing them, setting them so that there is exactly max-age differnece between them and also setting Expires far into future). I also experimented with various Cache-control values, but no luck. I made sure the cacheFile exists, isDirectory and is writeable by the application. These are the request and response headers as logged directly by retrofit: Request: Cache-Control: public, max-age=60 ---> END HTTP (no body) Response: Date: Mon, 27 Apr 2015 08:41:10 GMT Server: Apache/2.2.22 (Ubuntu) Expires: Mon, 27 Apr 2015 08:46:10 GMT Content-Type: text/xml; charset=UTF-8 OkHttp-Selected-Protocol: http/1.1 OkHttp-Sent-Millis: 1430124070000 OkHttp-Received-Millis: 1430124070040 Cache-Control: public, max-age=60 <--- END HTTP (-1-byte body) <--- BODY: ... And, finally one strange incident: At some point, the cache worked for a few minutes. I was getting reasonable hit counts, even offline requests returned cached values. (It happened while using the exact setting posted here) But when I restarted the app, everything was back to "normal" (constant hit count 0). Co if anyone has any idea what could be the problem here, I'd be really glad for any help :) A: Use networkInterceptors() instead of interceptors(). That in combination with your strategy of removing any headers that are somewhat related to caching will work. That's the short answer. When you use interceptors to change headers it does not make any adjustments before CacheStrategy.isCacheable() is called. It's worthwhile to look at the CacheStrategy and CacheControl classes to see how OKHttp handles cache-related headers. It's also worthwhile to do ctrl+f "cache" on http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html I am not sure if the networkInterceptors() and interceptors() documentation is just unclear or if there is a bug. Once I look into that more, I will update this answer. A: One more thing to add here, Apart from Brendan Weinstein's answer just to confirm OkHttp3 cache will not work with post requests. A: After a full day, I found that my offline caching was not working just because I was using POST in the API type. The moment I changed it to GET, it worked! @GET("/ws/audioInactive.php") Call<List<GetAudioEntity>> getAudios(); My entire Retrofit class. import android.util.Log; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.limnet.iatia.App; import com.limnet.iatia.netio.entity.registration.APIInterfaceProviderIMPL; import java.io.File; import java.io.IOException; import java.util.concurrent.TimeUnit; import okhttp3.Cache; import okhttp3.CacheControl; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class RHTRetroClient { public static final String BASE_URL = "https://abc.pro"; private static Retrofit retrofit = null; private static RHTRetroClient mInstance; private static final long cacheSize = 10 * 1024 * 1024; // 10 MB public static final String HEADER_CACHE_CONTROL = "Cache-Control"; public static final String HEADER_PRAGMA = "Pragma"; private RHTRetroClient() { Gson gson = new GsonBuilder() .setLenient() .create(); HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); Cache cache = new Cache(new File(App.getAppContext().getCacheDir(), "soundbites"),cacheSize); OkHttpClient client = new OkHttpClient.Builder() .cache(cache) .addInterceptor(httpLoggingInterceptor()) // used if network off OR on .addNetworkInterceptor(networkInterceptor()) // only used when network is on .addInterceptor(offlineInterceptor()) .build(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .client(client) .addConverterFactory(GsonConverterFactory.create(gson)) .build(); } /** * This interceptor will be called both if the network is available and if the network is not available * * @return */ private static Interceptor offlineInterceptor() { return new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Log.d("rht", "offline interceptor: called."); Request request = chain.request(); // prevent caching when network is on. For that we use the "networkInterceptor" if (!App.hasNetwork()) { CacheControl cacheControl = new CacheControl.Builder() .maxStale(7, TimeUnit.DAYS) .build(); request = request.newBuilder() .removeHeader(HEADER_PRAGMA) .removeHeader(HEADER_CACHE_CONTROL) .cacheControl(cacheControl) .build(); } return chain.proceed(request); } }; } /** * This interceptor will be called ONLY if the network is available * * @return */ private static Interceptor networkInterceptor() { return new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Log.d("rht", "network interceptor: called."); Response response = chain.proceed(chain.request()); CacheControl cacheControl = new CacheControl.Builder() .maxAge(5, TimeUnit.SECONDS) .build(); return response.newBuilder() .removeHeader(HEADER_PRAGMA) .removeHeader(HEADER_CACHE_CONTROL) .header(HEADER_CACHE_CONTROL, cacheControl.toString()) .build(); } }; } private static HttpLoggingInterceptor httpLoggingInterceptor() { HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() { @Override public void log(String message) { Log.d("rht", "log: http log: " + message); } }); httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); return httpLoggingInterceptor; } public static synchronized RHTRetroClient getInstance() { if (mInstance == null) { mInstance = new RHTRetroClient(); } return mInstance; } public APIInterfaceProviderIMPL getAPIInterfaceProvider() { return retrofit.create(APIInterfaceProviderIMPL.class); } } A: Check if there is a Pragma header in your response. Caching with max-age will not work if Pragma: no-cache header is present. If it does have Pragma header, remove it by doing the following in your Interceptor: override fun intercept(chain: Interceptor.Chain): Response { val cacheControl = CacheControl.Builder() .maxAge(1, TimeUnit.MINUTES) .build() return originalResponse.newBuilder() .header("Cache-Control", cacheControl.toString()) .removeHeader("Pragma") // Caching doesnt work if this header is not removed .build() }
doc_23538947
Let's say i have a jquery click event bellow (which is in Script A). $selector.on('click', function(e) { // 30 lines of code [it doens't matter what it does] }); Now i want to call function MyFunction() when that click event fires. Now the tricky bit, MyFunction() is in Script B (which is loaded after Script A).And it should be executed right after the click event is handled and not after the 30 lines of code inside it have been executed. Naturally, editing Script A is out of the question since it's a 3rd party lib. If i didn't explain it properly i can upload a flow chat.
doc_23538948
One of those fragments (called TabFragment) uses tabs, which are populated with (List)fragments (similar to http://developer.android.com/reference/android/support/v4/view/ViewPager.html example, but I dont use Actionbar Tabs, but the old ones). The first time I show the TabFragment, everything works. The TabFragment is called, there I "populate the tabs" (--> like in the example above I actually just populate the viewpager) with my ListFragments (there onCreateView etc. is called). It works. Then I try to put another instance of the TabFragment on the screen (I need to show different lists and want to be able to use the back button -> backstack), the TabFragment is called, I add the Fragments to the TabsAdapter, but no lifecycle methode of the ListFragments is called ... why? [I know that this isn't the best way to go and there are plenty of options to rewrite this to get the same effect, but since it works the first time I'd really like to know where this is going wrong] Activity Code Fragment search1 = new MainListFr(); Bundle test1 = new Bundle(); test1.putInt(Constants.FRAGMENT_SEARCH_ID, 1); g1.setArguments(test1); m_fragmentTransaction = m_fragmentManager.beginTransaction(); m_fragmentTransaction.add(R.id.main_fragment_container, search1, "search1"); m_fragmentTransaction.addToBackStack("search1"); m_fragmentTransaction.commit(); m_layout.toggleSidebar(); MainListFr (=TabFragment) public class MainListFr extends Fragment { TabHost m_tabHost; ViewPager m_viewPager; TabsAdapter m_tabsAdapter; @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.stub_main, null); m_tabHost = (TabHost) view.findViewById(android.R.id.tabhost); m_tabHost.setup(); m_viewPager = (ViewPager) view.findViewById(R.id.main_pager); m_tabsAdapter = new TabsAdapter(getActivity(), m_tabHost, m_viewPager); View v1 = inflater.inflate(R.layout.tab_left, null); View v2 = inflater.inflate(R.layout.tab_right, null); Bundle args = getArguments(); m_tabsAdapter.addTab(m_tabHost.newTabSpec("topsearch").setIndicator(v1), SearchListFr.class, args); m_tabsAdapter.addTab(m_tabHost.newTabSpec("topsuggestion").setIndicator(v2), SuggestionListFr.class, args); if (savedInstanceState != null) { m_tabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); } return view; } } SearchListFr (=ListFragment) private ListView m_list = null; private View m_progress = null; private View m_noRes = null; SearchAdapter m_searchAdapter = null; private Vector<SearchItem> m_searchList = null; private int m_searchId = 0; @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fr_videolist, null); m_list = (ListView) view.findViewById(R.id.fr_videolist_list); m_progress = view.findViewById(R.id.progress_root); m_noRes = view.findViewById(R.id.noresult_root); m_list.setVisibility(View.GONE); m_noRes.setVisibility(View.GONE); m_progress.setVisibility(View.VISIBLE); Bundle args = getArguments(); if (args != null) { m_searchId = args.getInt(Constants.FRAGMENT_SEARCH_ID); } // load the content here (asynctask) new LoadSearchList().execute(); return view; } @Override public void onActivityCreated(Bundle _savedInstanceState) { super.onActivityCreated(_savedInstanceState); m_searchAdapter = new SearchAdapter(getActivity()); m_list.setAdapter(m_searchAdapter); m_list.setItemsCanFocus(true); m_list.setOnItemClickListener(this); } TabsAdapter /** * This is a helper class that implements the management of tabs and all * details of connecting a ViewPager with associated TabHost. It relies on a * trick. Normally a tab host has a simple API for supplying a View or * Intent that each tab will show. This is not sufficient for switching * between pages. So instead we make the content part of the tab host * 0dp high (it is not shown) and the TabsAdapter supplies its own dummy * view to show as the tab content. It listens to changes in tabs, and takes * care of switch to the correct paged in the ViewPager whenever the selected * tab changes. */ public class TabsAdapter extends FragmentPagerAdapter implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener { private final Context mContext; private final TabHost mTabHost; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle args; TabInfo(String _tag, Class<?> _class, Bundle _args) { clss = _class; args = _args; } } static class DummyTabFactory implements TabHost.TabContentFactory { private final Context mContext; public DummyTabFactory(Context context) { mContext = context; } @Override public View createTabContent(String tag) { View v = new View(mContext); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } } public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mTabHost = tabHost; mViewPager = pager; mTabHost.setOnTabChangedListener(this); mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); mTabs.add(info); mTabHost.addTab(tabSpec); notifyDataSetChanged(); } @Override public int getCount() { return mTabs.size(); } @Override public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.args); } @Override public void onTabChanged(String tabId) { int position = mTabHost.getCurrentTab(); mViewPager.setCurrentItem(position); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { // Unfortunately when TabHost changes the current tab, it kindly // also takes care of putting focus on it when not in touch mode. // The jerk. // This hack tries to prevent this from pulling focus out of our // ViewPager. TabWidget widget = mTabHost.getTabWidget(); int oldFocusability = widget.getDescendantFocusability(); widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); mTabHost.setCurrentTab(position); widget.setDescendantFocusability(oldFocusability); } @Override public void onPageScrollStateChanged(int state) { } }
doc_23538949
I've worked out this code from some snippets: CGRect _frameIWant = CGRectMake(100, 100, 100, 100); UIGraphicsBeginImageContext(view.frame.size); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; //STEP A: GET AN IMAGE FOR THE FULL FRAME UIImage *_fullFrame = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); //STEP B: CLIP THE IMAGE CGImageRef _regionImage = CGImageCreateWithImageInRect([_fullFrame CGImage], _frameIWant); UIImage *_finalImage = [UIImage imageWithCGImage:_regionImage]; CGImageRelease(_regionImage); 'view' is the UIView which I'm clipping and _finalImage is the UIImage I want. The code works without problem, however is kind of slow. I believe that some performance could be gained by taking just the portion of the screen directly in Step A. I'm looking for something like renderInContext: withRect: or UIGraphicsGetImageFromCurrentImageContextWithRect() hehe. Still haven't found anything yet :(, please help me if you know of some alternative. A: This method clips a region of the view using less memory and CPU time: -(UIImage*)clippedImageForRect:(CGRect)clipRect inView:(UIView*)view { UIGraphicsBeginImageContextWithOptions(clipRect.size, YES, 1.f); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(ctx, -clipRect.origin.x, -clipRect.origin.y); [view.layer renderInContext:ctx]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } A: You could try rasterizing the UIView first: view.layer.shouldRasterize = YES; I have limited success using this but is saying that I'm doing the same thing as you (plus the above line) and it works fine. In what context are you doing this in? It may be your performance issue. EDIT: Also you could try using the bounds of the view instead of the frame of the view. They are not always the same. A: Swift version of @phix23 solution . adding scale func clippedImageForRect(clipRect: CGRect, inView view: UIView) -> UIImage { UIGraphicsBeginImageContextWithOptions(clipRect.size, true, UIScreen.mainScreen().scale); let ctx = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(ctx, -clipRect.origin.x, -clipRect.origin.y); view.layer.renderInContext(ctx!) let img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img }
doc_23538950
I have hadded a product panel & 2 meta for my option and its price. If the user checks a checkbox in the product page, then the option is added to the cart page, the checkout page, thank you page, email and so on... My problem is that i actually can update the initial product price in the product row, in cart & checkout tables but i need to : 1 : insert the additionnal service (the option) as a separate row in the checkout review order table and in the cart total table; 2 : dislay initial product price in the product row and udpdate only the total adding the option price in those 2 tables. I'm really stuck here, any help would be great. Thank's A: OK, For the solution is quiet simple : 1 : add a product dropdow in admin tab to let user choose a linked product as a product option and register its ID a product meta; 2 : use woocommerce_add_to_cart_validation to intercept the option checkbox value from the product page and add the product option to cart from the initial product meta : add_action( 'woocommerce_add_to_cart_validation', 'my_cart_validation' ); function my_cart_validation(){ if( isset( $_POST['my-service-option'] ) ){ WC()->cart->add_to_cart( get_post_meta( $_POST['add-to-cart'], 'service-option', true ) ); } } 3 : If the optional service is not supposed to be displayed in the shop loop, just remove it from the WC Query : add_action( 'woocommerce_product_query', 'remove_optional_services' ); function remove_optional_services( $q ){ $not_in = $q->get('post__not_in' ); array_push( $not_in, 75 ); // you can grab your product ids from an option or whatever fits your needs $q->set('post__not_in', $not_in); } The good thing is you keep a simple control on taxes and prices with this method.
doc_23538951
@GraphQLTest public class UserQueryTest { @Autowired private GraphQLTestTemplate graphQLTestTemplate @MockBean private UserQuery userQuery; @MockBean private UserConverter userConverter; @Test public void getUser() throws IOException { // Given when(userQuery.user(anyString())).thenReturn(User.builder().build()); when(userConverter.convert(any(UserDomain.class))).thenReturn(User.builder().build()); // When GraphQLResponse response = graphQLTestTemplate.postForResource( "graphql/get-user.graphql"); assertThat(response).isNotNull(); //Then assertThat(response.get("$.data.user")).isNotNull(); } } The test above returns the following stacktrace: Failed to load ApplicationContext java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123) at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.postProcessFields(MockitoTestExecutionListener.java:95) at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.injectFields(MockitoTestExecutionListener.java:79) at org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener.prepareTestInstance(MockitoTestExecutionListener.java:54) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244) at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:98) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$5(ClassBasedTestDescriptor.java:341) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:346) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$6(ClassBasedTestDescriptor.java:341) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312) at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:340) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:263) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:256) at java.base/java.util.Optional.orElseGet(Optional.java:369) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:255) at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:29) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:108) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:107) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:71) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:107) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:107) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:75) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy5.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:133) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ... 89 more Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:437) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:191) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:178) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:158) ... 98 more Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLServletRegistrationBean' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLServletRegistrationBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLHttpServlet' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLHttpServlet' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLServletConfiguration' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLServletConfiguration' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'invocationInputFactory' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'invocationInputFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchemaProvider' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchemaProvider' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchema' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchema' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'schemaParser' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'schemaParser' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productQuery' defined in file x: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:538) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:211) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:202) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:96) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:85) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:255) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:229) at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5128) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:843) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) ... 103 more Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLHttpServlet' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLHttpServlet' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLServletConfiguration' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLServletConfiguration' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'invocationInputFactory' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'invocationInputFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchemaProvider' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchemaProvider' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchema' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchema' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'schemaParser' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'schemaParser' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productQuery' defined in file: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLServletConfiguration' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLServletConfiguration' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'invocationInputFactory' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'invocationInputFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchemaProvider' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchemaProvider' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchema' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchema' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'schemaParser' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'schemaParser' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productQuery' defined in file : Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'invocationInputFactory' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'invocationInputFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchemaProvider' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchemaProvider' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchema' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchema' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'schemaParser' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'schemaParser' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productQuery' defined in file : Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchemaProvider' defined in graphql.kickstart.spring.web.boot.GraphQLWebAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchemaProvider' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchema' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchema' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'schemaParser' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'schemaParser' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productQuery' defined in file: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchema' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'graphQLSchema' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'schemaParser' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'schemaParser' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productQuery' defined in file: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'schemaParser' defined in graphql.kickstart.tools.boot.GraphQLJavaToolsAutoConfiguration: Unsatisfied dependency expressed through method 'schemaParser' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productQuery' defined in file : Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productQuery' defined in file : Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '<package>.ProductService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Shouldn't Spring create the other beans by default when the application context starts?
doc_23538952
The problem that I'm having is the data being passed through to the database is showing function light at 0x76c12bb0 I want the actual lux data reading to be passed through as a string, so I'll need to define the light reading, correct? Here's what I have: DEVICE = 0x23 # Default device I2C address POWER_DOWN = 0x00 # No active state POWER_ON = 0x01 # Power on RESET = 0x07 # Reset data register value ONE_TIME_HIGH_RES_MODE = 0x20 bus = smbus.SMBus(1) def convertToNumber(data): # Simple function to convert 2 bytes of data # into a decimal number return ((data[1] + (256 * data[0])) / 1.2) def light(addr=DEVICE): data = bus.read_i2c_block_data(addr,ONE_TIME_HIGH_RES_MODE) return convertToNumber(data) And then in my main() I have: print (""), light, " lux"
doc_23538953
require(['jquery', 'owl.carousel/owl.carousel.min'], function($) { $("#banner-slider-demo-1").owlCarousel({ // carousel settings }); }); However I noticed sometimes when I load the homepage (where the carousel is used) the carousel doesn't display, and there are errors in the console Uncaught TypeError: $(...).owlCarousel is not a function Thinking jQuery might not be loaded, I changed the require code to serialize the requirements require(['jquery'], function($) { require(['owl.carousel/owl.carousel.min'], function () { $("#banner-slider-demo-1").owlCarousel({ // ... but this had no effect... Sometimes the carousel loads and there are no errors, other times there are errors and it doesn't load. Even when there is an error the carousel file has been fetched by the browser. It also seems require has loaded the carousel script per developer tools Any idea what could be going on? A: Your issue is that you are loading jQuery through a script element and through RequireJS. You have to use one method, not both. If I run this in the console: console.log("owlCarousel", typeof jQuery.fn.owlCarousel) I get: owlCarousel function But with this: require(["jquery"], function ($) { console.log("owlCarousel", typeof $.fn.owlCarousel); }) I get: owlCarousel undefined And if you try require(["jquery"], function ($) { console.log("equal", $ === window.jQuery); }) you'll get equal false. So you have two instances of jQuery loaded. The code that uses RequireJS to access jQuery gets a version without .owlCarousel. That's because Owl Carousel installed itself on window.jQuery. If you must load jQuery through script for some reason, you should move the script element that loads it before you load RequireJS. (You should do this for all scripts you load that you want to load with script and that are AMD-aware.) Then for RequireJS, you should just define this fake module: define("jquery", function () { return jQuery; }); This makes it so that when RequireJS loads jQuery it just uses the jQuery already defined in the global space. The ideal place for this fake module would be just before you configure RequireJS. While you're at it you should define a shim for owl.carousel/owl.carousel.min: `owl.carousel/owl.carousel.min`: ['jquery'] This way there's no need to nest the call to load owl.carousel/owl.carousel.min inside a call to load jquery. You can just do what you were trying initially: require(['jquery', 'owl.carousel/owl.carousel.min'], function($) { $("#banner-slider-demo-1").owlCarousel({ // carousel settings }); });
doc_23538954
The table is generated by mapping through an array. {objInnerValues[shopIndex].map((thing, outerIndex) => ( // Ternary operator to stop creating rows from element 0 (outerIndex === 0) ? console.log("outerIndex WAS 0") : (outerIndex %2 === 0) ? Object.values(thing).map((innerThing, innerIndex) => ( <> {/* Tooltip popup for item blurb */} <HtmlTooltip title={ //a tooltip component, from MUI. Gets a string to display } > {/* Table rows for each record */} <TableRow //style definitions, then an id for the row... id = {"rowID-"+thing[0][0]} > {AR_RowRefs.push("rowID-"+thing[0][0])} {/* Indidivual td elements to display each item in a row*/} <SuperTD NoHoverTD> {//Items name} </SuperTD> <SuperTD NoHoverSmallTxtTD> {//category the item belongs to} <Button> //a visibility button, part of what I'm trying to work on </Button> </SuperTD> <SuperTD NoHoverSmallTxtTD> { //Get weight of item from array and format it } </SuperTD> <SuperTD NoHoverSmallTxtTD> { //Get price from array and format it } </SuperTD> {/* Checkbox for if item is available */} <SuperTD> <input type="checkbox" defaultChecked={innerThing[6]}/> </SuperTD> {/* Checkbox for if item is limited */} <SuperTD> <input type="checkbox" defaultChecked={innerThing[7]}/> </SuperTD> </TableRow> </HtmlTooltip> </> Above my return block I have an array I want to use to store the ID of each table row that is generated. I have a function (fired from an onClick of each visibility button). I wrote this in my return block, inside the array map: {AR_RowRefs.push("rowID-"+thing[0][0])} However, when I save this and it renders, it creates an extra column of data: I thought that an extra <td> would only render if I put tags around it. This is just a JSX snippet so is there any particular reason its creating its own <td>? Can I still have this snippet push ids to an array without rendering an extra element? A: I thought that an extra <td> would only render if I put tags around it. This is just a JSX snippet so is there any particular reason its creating its own <td>? The browser is attempting to recover from your error of putting a number (which gets converted to a string) as a child of a tr. Can I still have this snippet push ids to an array without rendering an extra element? The quick and dirty approach (which I haven't tested) would be to change the expression so it doesn't evaluate as a number. {void AR_RowRefs.push("rowID-"+thing[0][0])} The sensible approach would be to split your data manipulation logic and your display logic. Object.values(thing).map((innerThing, innerIndex) => { AR_RowRefs.push("rowID-"+thing[0][0]); return <> ... </>; };
doc_23538955
2020-11-25T14:22:41.3539327Z Into a column that stores a datetime datatype. A: Provided that all your data is in the format yyyy-MM-ddThh:mm:ss.nnnnnnn then you can just change the data type of the column: ALTER TABLE dbo.YourTABLE ALTER COLUMN YourColumn datetime2(7); If you need the timezone in there, then use datetimeoffset(7) instead. A: -- to fix it you can use convert, below uses GetDate for examaple SELECT convert(varchar, getdate(), 120) depending on what precision you need you can use the link below to find it and change the 120 to whatever number you need for that precision. https://www.mssqltips.com/sqlservertip/1145/date-and-time-conversions-using-sql-server/ To fix your table you should follow these steps: * *Add a new column to your table for DateTime *Run an update on your table using the Convert above to update the new column with the converted value from your varchar field. *Then drop the column with the varchar data. Code to do the steps I outlined above ALTER TABLE dbo.TableName ADD NewDateTimeCOL DATETIME -- NOTE if your table is LARGE you will not want to do a direct update like this but do looping for performace purposes UPDATE dbo.TableName SET NewDateTimeCOL = convert(varchar, OldDateTimeCOL, 120) ALTER TABLE dbo.TableName DROP COLUMN OldDateTimeCOL
doc_23538956
The usual work flow should be something like this: * *Everyone is welcome to register as a member; each member should have a name, email address and password. *Each week a new betting contest is opened, each contest has a fixed set of "questions" (in this case each "question" is basically in the form of "Home Team - Visiting Team"). *Each member is free to cast his prognostic in the form of "1 X 2" (1: Home Wins, X: Draw, 2: Visiting Wins; for each "question") on all the open contests available together with an amount of money (see point 5). Only one prognostic per contest is allowed. *On the end of each week all the contests are closed and a real bet is placed based on all the individual bets and the performance of each member (see also this related question). The placed bet should be publicly available for everyone to see. *When the result of all matches is known it should be possible to "attach" (sorry, I'm missing the word) the amount of money of the prize (if the community gets lucky, of course). The prize should then be proportionally divided by the amount each team member placed on the bet. *Each member can at any given time deposit or withdraw a variable amount of money to / from his account, there should also be a transactions page where all the deposits, prizes and withdraws are presented. Bonus Question: Since I'm still pretty much green at "SEO friendly" URLs I would also be interested in learning how would you name all the segments involved in this system. I would very much appreciate any help in the design of a DB schema that can accommodate this whole scenario. PS: I'll open up a bounty for this question, I'm currently having some issues with my Internet connection so I might take some time to read / comment on your answers. Thanks in advance! A: Quite a task, but here is my attempt: * *Members table stores members data; including PerformanceFactor which is periodically re-calculated based on correctness of one's answers. *Transactions table tracks money deposits and withdrawals for each member. The Type field could be 1=deposit, 2=withdrawal, 3=transfer from winnings. *One contest can have many questions, a question belongs to one contest only. *One member can place many member-bets, a member-bet belongs to one member only.Place UNIQUE constraint on MemberID, ContestID to prevent member placing several bets for a specific contest *One member-bet has several answers, each answer belongs to one member bet only; each answer relates to a question. Place UNIQUE constraint on MemberBetID, QuestionID to prevent member placing several answers for a specific question. *DerivedAnswers table contains answers obtained by "statistical analysis" of member answers for a specific contest. Place UNIQUE constraint on ContestID, QuestionID to prevent repeating an answer for a specific question.
doc_23538957
The problem is that when I use textstat_collocation or tokens_compound, I am forced to tokenize the corpus and, in so doing, I lose the structure (233 by 4) that is crucial to apply topic models. In fact, once I apply those functions, I just get one row of bigrams and trigrams which is useless to me. So my question is: do you know any other way to look for bigrams and trigrams in a dfm without necessarily tokenizing the corpus? Or, in other words, what do you usually do to look for multiwords in a dfm? Thanks a lot for your time!
doc_23538958
Now, I'd like to expand the size of the polygon when I do a mouseover. With rectangles or circles I can just write a function to expand the width or radius. Does anyone know how to go about doing this? Here is an example of my code: var svg = d3.select("#map") .append( "svg" ) .attr( "width", width ) .attr( "height", height ); var g = svg.append( "g" ); var albersProjection = d3.geo.albers() .scale( 190000 ) .rotate( [71.057,0] ) .center( [0, 42.313] ) .translate( [width/2,height/2] ); var geoPath = d3.geo.path() .projection( albersProjection ); var mapProperties = g.selectAll( "path" ) .data(data.features, function(d, i) {return d + i}) .enter() .append( "path" ) .attr( "fill", "#150000" ) .attr( "d", geoPath ) .style("stroke", "#FFFFFF") .style("stroke-width", 2)
doc_23538959
I used the appdelegates method applicationWillTerminate to call .subscribe(toTopic:xxx) and log a message to confirm that the method got called. I have a background mode active, so the method gets called only when the app is destroyed, and works as intended. However, I cannot see a any logs from firebase that the topic sync succeeded or not. I assume it didn't succeed because I'm not receiving any push notifications and because if I do subscribe to the same topicswhen the app starts, I receive all the notifications correctly. I read that when the app gets destroyed, I have 5 seconds from generous apple's iOS to complete the tasks I need. This amount of time should be more than enough to sync all the topics, however I can't find any logs to debug. I looked through the logs available in the devices and simulators window, but didn't find anything, not event the message i printed inside the applicationWillTermiate method. I know that on android, a topic sync will log the message topic sync succesfull, but what about iOS? A: Well have you checked the documentation? For apps that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the app. For apps that support background execution, this method is generally not called when the user quits the app because the app simply moves to the background in that case. However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason. So if you have enabled background execution this is most likely not called, unless the system needs to terminate your app As for the correct subscription, I guess you can check the Firebase console and see if the topic exists in the Compose message, although be advised it can take a few hours before the topic appears on the console it self.
doc_23538960
library(tidyverse) library(papaja) library(kableExtra) #> #> Attaching package: 'kableExtra' #> The following object is masked from 'package:dplyr': #> #> group_rows holiday_schedule <- tibble( day1 = c("surfing", "siesta", "cocktails"), day2 = c("beach", "walk", "restaurant") ) apa_table(holiday_schedule, format = "latex") %>% column_spec(2, bold = TRUE) #> Error in if (!kable_format %in% c("html", "latex")) {: argument is of length zero Created on 2021-09-23 by the reprex package (v2.0.0) It is like setting the format (in format = "latex") was not taken into account. How can I go about this? A: The output object from apa_table() does not have the "format" attribute set, which is why column_spec() from the kableExtra package cannot recognize the output. A workaround is to manually set the attribute. For your simple example, this would look like: apa_table(holiday_schedule, format = "latex") %>% `attr<-`("format", "latex") %>% column_spec(2, bold = TRUE) However, note that apa_table() can produce more-complex output that deviates from what knitr::kable() produces; I assume that kableExtra will eventually break sooner or later.
doc_23538961
How to find every occurrence of that string in notepad++ and replace the whole line with this new string ") ON [PRIMARY]" A: Notepad++ is very good at this kind of task. It has a Search and Replace feature which lets you specify a regular expression (also known as "RegEx") for the text to find and its replacement. You can access it from the Search menu or by pressing Ctrl+H. In your case, the text to find is: ^\) ON \[SQLTest.* and its replacement is \) ON [PRIMARY] Round and square brackets have significance in regular expressions, so I "escaped" them by preceding them with a backslash. The caret symbol means "start of line" and .* matches all characters (if there are any) until the end of the line. Note: if you want to retain the text after "SQLTest" you can capture it by enclosing .* in parentheses then refer to it as \1 in the replacement expression. Searching for "online regex tester" will reveal many sites where you can experiment to get your expression right.
doc_23538962
int main () { string s{}; std::cout << "Enter CMD: \n"; getline(cin,s); system(s); } But since I can use only const char on system, its not working at all, is there any different solution to this? mabye shellexecute? A: You can use std::string::c_str(). system(s.c_str());
doc_23538963
2020-06-01 18:19:05.738 WARN 4824 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Connection to node -1 (/127.0.0.1:9092) could not be established. Broker may not be available. 2020-06-01 18:19:12.203 WARN 4824 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Bootstrap broker 127.0.0.1:9092 (id: -1 rack: null) disconnected Here you can see both containers running: 4f74ceac73ba wurstmeister/kafka:2.12-2.5.0 "start-kafka.sh" 0.0.0.0:9092->9092/tcp kafka fc958792a4a0 zookeeper:3.6.1 "/docker-entrypoint.…" 2888/tcp, 3888/tcp, 0.0.0.0:2181 >2181/tcp, 8080/tcp zookeeper Here you can see zookeeper logs: 2020-06-01 13:17:39,518 [myid:1] - INFO [main:SnapStream@61] - zookeeper.snapshot.compression.method = CHECKED 2020-06-01 13:17:39,519 [myid:1] - INFO [main:FileTxnSnapLog@470] - Snapshotting: 0x0 to /data/version-2/snapshot.0 2020-06-01 13:17:39,536 [myid:1] - INFO [main:ZKDatabase@289] - Snapshot loaded in 45 ms, highest zxid is 0x0, digest is 1371985504 2020-06-01 13:17:39,543 [myid:1] - INFO [main:FileTxnSnapLog@470] - Snapshotting: 0x0 to /data/version-2/snapshot.0 2020-06-01 13:17:39,544 [myid:1] - INFO [main:ZooKeeperServer@519] - Snapshot taken in 2 ms 2020-06-01 13:17:39,571 [myid:1] - INFO [main:RequestThrottler@74] - zookeeper.request_throttler.shutdownTimeout = 10000 2020-06-01 13:17:39,671 [myid:1] - INFO [main:ContainerManager@83] - Using checkIntervalMs=60000 maxPerMinute=10000 maxNeverUsedIntervalMs=0 2020-06-01 13:17:39,674 [myid:1] - INFO [main:ZKAuditProvider@42] - ZooKeeper audit is disabled. 2020-06-01 13:17:40,943 [myid:1] - INFO [SyncThread:0:FileTxnLog@284] - Creating new log file: log.1 and docker-compose file to bootstrap containers: version: "3.7" networks: kafka-net: name: kafka-net driver: bridge services: zookeeper: image: zookeeper:3.6.1 container_name: zookeeper restart: always networks: - kafka-net ports: - "2181:2181" volumes: - c:/kafka/docker-data/zookeeper:/bitnami/zookeeper kafka: image: wurstmeister/kafka:2.12-2.5.0 container_name: kafka restart: always networks: - kafka-net ports: - "9092:9092" volumes: - c:/kafka/docker-data/kafka:/bitnami/kafka environment: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: DOCKER_INTERNAL:PLAINTEXT,DOCKER_EXTERNAL:PLAINTEXT KAFKA_LISTENERS: DOCKER_INTERNAL://:29092,DOCKER_EXTERNAL://:9092 KAFKA_ADVERTISED_LISTENERS: DOCKER_INTERNAL://kafka:29092,DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092 KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER_INTERNAL KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" KAFKA_BROKER_ID: 1 KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 depends_on: - zookeeper There is no additional configuraion in application-properties. Any help would be appreciated, I am pretty much stuck with it :(
doc_23538964
The problem that I have is that the letter grade doesn't return the letter grade based on the scale (ex: 0-59= F, 90-100= A). It keeps on printing F This is my code that returns the letter grade AlphaGrade PROC USES EAX ;letter grade cmp EAX, 90 jae gradeA ;jump if grade>= 90 cmp EAX, 80 jae gradeB ;jump if grade >= 80 cmp EAX, 70 jae gradeC ;jump if grade >= 70 cmp EAX, 60 jae gradeD ;jump if grade >= 60 cmp EAX, 0 jae gradeF ;jump if grade < 60 gradeA: mov al, 'A' ;mov grade A to al call WriteChar ;display the letter jmp okay ;jump to okay gradeB: mov al, 'B' ;mov grade B to al call WriteChar ;display the letter jmp okay ;jump to okay gradeC: mov al, 'C' ;mov grade C to al call WriteChar ;display the letter jmp okay ;jump to okay gradeD: mov al, 'D' ;mov grade D to al call WriteChar ;display the letter jmp okay ;jump to okay gradeF: mov al, 'F' ;mov grade F to al call WriteChar ;display the letter jmp okay ;jump to okay okay: ret AlphaGrade ENDP
doc_23538965
#!/usr/bin/env python def hello(): local = locals() c = 1 for i in ['x', 'y', 'z']: local[i] = c c += 1 print(x) hello() However it is incorrect, with the error message: Traceback (most recent call last): File "./ttt.py", line 11, in <module> hello() File "./ttt.py", line 9, in hello print(x) NameError: global name 'x' is not defined Seems that Python would look the global 'x' rather than the local one. Surely I can use print(local['x']) at Line 9, but is there another way? update: What I really need is to "automatically" create several variables related to a list of strings: each of these variables' name and value are a transformation of one string in the list. For example, # given list_of_string = ['clang', 'scan-build'] # I hope to create two variables: clang = '/usr/bin/clang' scan_build = '/usr/local/bin/scan-build' Here the name of the variables (clang, scan_build) is the string in list_of_string except that '-' is replaced with '_', and the value is the really location of the string (generated by some function works as unix which). A: From the docs about the dictionary returned by locals() Note: The contents of this dictionary should not be modified; changes may not affect the values of local and free variables used by the interpreter. A: Technically you could use eval but I would find another way to do what you want: print(eval("x")) Also local = locals() stores a reference to itself in locals. If you want to store variables dynamically just use a normal dict and access by key: def hello(): local = {} c = 1 for i in ['x', 'y', 'z']: local[i] = c c += 1 print(local["x"]) print(local["y"]) print(local["z"]) hello() 1 2 3 If you need to share the variables amongst other functions just return the dict add pass the returned value to the other functions. A: You cannot assign to local variables dynamically. As you don't write your actual use case, I can only give a common use case: you have some dictionary with default values: def hello(values): x = values.get('x', 1) y = values.get('y', 2) z = values.get('z', 3) print(x) A: Don't mess with locals. Use a dictionary: import subprocess list_of_strings = ['clang', 'no-name', 'xml2-config'] d={} for s in list_of_strings: try: rtr=subprocess.check_output(['which',s]) d[s.replace('-','_')]=rtr.rstrip() except subprocess.CalledProcessError: print '"{}" not found'.format(s) print d Prints (on OS X): "no-name" not found {'clang': '/usr/bin/clang', 'xml2_config': '/usr/bin/xml2-config'}
doc_23538966
$(document).keydown(function(e) { if (e.which == 37) { //37 left arrow key. $('div').css('left', '-=10px') } }); Check http://jsfiddle.net/QLFEy/3 A: Your code is correct and should work. Looking at jQuery bug tracker, i found an already open ticket for this at http://bugs.jquery.com/ticket/9237. It works with width and height but not with left at least. According to the ticket, fix should be available in 1.6.2 Update 05/13/11 The issue has been fixed and the fix is currently available in the WIP version which can be found at http://code.jquery.com/jquery-git.js. This is the very latest non production version of jQuery with most recent fixes. The fix should be be officially available in the upcoming 1.6.2 version. A: Obviously a bug in jQuery. It seems like jQuery is not adding "px" after the value. [2011-05-12 21:46:17] CSS - file://localhost/D:/test.html DOM style property Invalid value for property: margin-left Line 1: 260 ---^
doc_23538967
I tried the following however it does not work: var wheight = $(window).height() - 140; $(window).resize(function() { wheight = $(window).height() - 140; $('.slide').css({"height":slideHeight+"px"}); }); It works fine if I dont try to minus the 140px. Any ideas? A: I think you want this: $(window).resize(function() { wheight = $(window).height() - 140; $('.slide').css({"height":wheight +"px"}); });
doc_23538968
const listOfPrimaryId = [{ primary_id: '1234' }, { primary_id: '2345' }, { primary_id: '3456' }] const arrayNumberOne = [{ main_id: '1234', sub_id: 'htx', indv_ids: 'bf' }, { main_id: '2345', sub_id: 'htx', indv_ids: 'gg' }, { main_id: '3456', sub_id: 'sam', indv_ids: 'bg' }, { main_id: '3456', sub_id: 'sam', indv_ids: 'hh' }, { main_id: '1234', sub_id: 'kev', indv_ids: 'app' }] const arrayExample = [] for (let j = 0; j < listOfPrimaryId.length; j++) { let diffPrimaryId = listOfPrimaryId[j]['primary_id'] for (let i = 0; i < arrayNumberOne.length; i++) { let primaryId = arrayNumberOne[i]['main_id']; let subId = arrayNumberOne[i]['sub_id']; let iDOptions = arrayNumberOne[i]['indv_ids'] if (primaryId == diffPrimaryId) { type InnerFish = { sub_id: string; id_opt: string[]; } type MainFish = { primary_id: string; package: InnerFish } let sampleData2: InnerFish = { sub_id: subId, id_opt: [iDOptions] } let sampleData: MainFish = { primary_id: primaryId, package: sampleData2 } arrayExample.push(sampleData) } } } After the above is performed, I have the below output from arrayExample. [ { primary_id: '1234', package: { sub_id: 'htx', id_opt: ['bf'] } }, { primary_id: '1234', package: { sub_id: 'kev', id_opt: ['app'] } }, { primary_id: '2345', package: { sub_id: 'htx', id_opt: ['gg'] } }, { primary_id: '3456', package: { sub_id: 'sam', id_opt: ['bg'] } }, { primary_id: '3456', package: { sub_id: 'sam', id_opt: ['hh'] } } ] arrayExample doens't combine the primary_id or sub_id. I'm trying to build the data to be similar to the below output. [ { primary_id: '1234', package: [ { sub_id: 'htx', id_opt: ['bf'] }, { sub_id: 'kev', id_opt: ['app'] } ] }, { primary_id: '2345', package: [ { sub_id: 'htx', id_opt: ['gg'] } ] }, { primary_id: '3456', package: [ { sub_id: 'sam', id_opt: ['bg', 'hh'] } ] }, ] A: You're never actually merging the array in your example. This might be a better solution. type InnerItem = { main_id: string, sub_id: string, indv_ids: string }; const arrayExample = listOfPrimaryId.map((primaryItem:{ primary_id: string }) => { const package: {sub_id: string, id_opt: string[]} = []; arrayNumberOne.forEach((innerItem: InnerItem ) => { if(innerItem.main_id === primaryItem.primary_id){ // check if we added sub item to package array already const existingIndex = package.findIndex((val)=> val.sub_id === innerItem.sub_id); if(existingIndex >= 0) // if we have package[existingIndex].id_opt.push(innerItem.indv_ids) else // if not add it package.push( {sub_id: innerItem.sub_id, id_opt: [innerItem. indv_ids]} } }); return { primary_id: primaryItem.primary_id, package}; }); You can change up the typing declarations.
doc_23538969
I have a var that is set up as a new object of my class. However, I keep getting error 1120 whenever I test it. I know that error means it's an undefined property. I tried changing the scope of it (to every possible place in the main class. Namely the class, just after the imports and the constructor). The code is supposed to be part of a character creator for Dungeons and Dragons 4e. Have tried for hours to find a solution but I'm just not sure. Will include my Attributes class if it's any help. var Humon:Attributes = new Attributes It's declared as part of my main class: package { //imports import com.Classes.Attributes; import flash.text.*; public class Main extends MovieClip() { private var Humon:Attributes = new Attributes; public function Main() { Atties.text = (Humon.getStr()+", "+Humon.getDex()+", "+Humon.getCon()+", "+Humon.getInt()+", "+Humon.getWis()+", "+Humon.getCha()+"."); var res:int = Humon.getStr(); trace("Humon Str is "+res+"."); } } } And here's the class Attributes. //This class defines the frame work for all classes used package { public class Attributes extends Object { //vars go here //saves variables (get auto updated through function makeDefaultModsAndSaves()) static var refSave:int = 0; static var forSave:int = 0; static var wilSave:int = 0; //attribute modifiers (get auto updated through function makeDefaultModsAndSaves()) static var StrMod:int = 0; static var DexMod:int = 0; static var ConMod:int = 0; static var IntMod:int = 0; static var WisMod:int = 0; static var ChaMod:int = 0; //2d array to store attributes [x][y] where x is str/dex/con/int/wis/cha and y is value static var Attrs:Array = new Array(); Atts[0] = [10]; Atts[1] = [10]; Atts[2] = [10]; Atts[3] = [10]; Atts[4] = [10]; Atts[5] = [10]; function Attributes() { //constructor trace("Attributes loaded"); } //functions to GET Attributes function getStr():int { var Str:int = 0; Str = Atts[0][0]; trace ("Getting Str. It is " + Str); return Str; } //different functions, same syntax as getStr above function getDex():int { var Dex:int = 0; Dex = Atts[1][0]; trace ("Getting Dex. It is" + Dex); return Dex; } function getCon():int { var Con:int = 0; Con = Atts[2][0]; trace ("Getting Con. It is" + Con); return Con; } function getInt():int { var Int:int = 0; Int = Atts[3][0]; trace ("Getting Int. It is" + Int); return Int; } function getWis():int { var Wis:int = 0; Wis = Atts[4][0]; trace ("Getting Wis. It is" + Wis); return Wis; } function getCha():int { var Cha:int = 0; Cha = Atts[5][0]; trace ("Cha is" + Cha); return Cha; } //functions to SET Attributes function setStr(input:int) { //trace old value trace("Old Strength is: "+Atts[0][0]+"."); //assign new value from whatever source Atts[0][0] = input; //check new strength trace("New Strength is: "+Atts[0][0]+"./n"); //and update mods/saves makeDefaultModsAndSaves() } //different functions, same syntax as getStr above function setDex(input:int) { trace("Old Dexterity is: "+Atts[0][0]+"."); Atts[1][0] = input; trace("New Dexterity is: "+Atts[0][0]+"./n"); makeDefaultModsAndSaves() } function setCon(input:int) { trace("Old Constitution is: "+Atts[2][0]+"."); Atts[2][0] = input; trace("New Constitution is: "+Atts[2][0]+"./n"); makeDefaultModsAndSaves() } function setInt(input:int) { trace("Old Intelligence is: "+Atts[3][0]+"."); Atts[3][0] = input; trace("New Intelligence is: "+Atts[3][0]+"./n"); makeDefaultModsAndSaves() } function setWis(input:int) { trace("Old Wisdom is: "+Atts[4][0]+"."); Atts[4][0] = input; trace("New Wisdom is: "+Atts[4][0]+"./n"); makeDefaultModsAndSaves() } function setCha(input:int) { trace("Old Charisma is: "+Atts[5][0]+"."); Atts[5][0] = input; trace("New Charisma is: "+Atts[5][0]+"./n"); makeDefaultModsAndSaves() } //function to calculate and apply modifiers based off of ATTRIBUTES ONLY function makeDefaultModsAndSaves():int { for(var i:int = 0; i < Atts.length; i++) { var modifier: int = 0; trace("Current loop: "+i); modifier = (((Atts[i][0])-10)/2); switch (i) { case 0: StrMod = modifier; trace("Strength is "+Atts[i] +" and has a modifier of "+StrMod+".\n"); break; case 1: DexMod = modifier; trace("Dexterity is "+Atts[i]+" and has a modifier of "+DexMod+". The reflex save bonus is "+refSave+".\n"); break; case 2: ConMod = modifier; forSave = modifier; trace("Constitution is "+ Atts[i]+" and has a modifier of "+ConMod+". The fortitude save bonus is "+forSave+".\n"); break; case 3: IntMod = modifier; trace("Intelligence is " +Atts[i]+" and has a modifier of "+IntMod+".\n"); break; case 4: WisMod = modifier; trace("Wisdom is "+Atts[i]+" and has a modifier of "+WisMod+". The will save bonus is "+wilSave+".\n"); break; case 5: ChaMod = modifier; trace("Charisma is "+Atts[i]+" and has a modifier of "+ChaMod+".\n"); break; } } return modifier; } //temporary var to initialise function. var arse:int = makeDefaultModsAndSaves() } } A: * *Remove the parentheses: public class Main extends MovieClip() public class Main extends MovieClip *Ensure that Main.as and Attributes.as placed in the same folder. Remove unnecessary import statement: import com.Classes.Attributes; *There is an error here: static var Attrs:Array = new Array(); Atts[0] = [10]; Atts[1] = [10]; Atts[2] = [10]; ... Rename Attrs to Atts. *In the Main.as class you address to the Atties. What is Atties?
doc_23538970
topmostSubform[0].Page1[0].CheckBox2A[0] topmostSubform[0].Page1[0].CheckBox2A[1] topmostSubform[0].Page2[0].CheckBox2A[0] topmostSubform[0].Page2[0].CheckBox2A[1] topmostSubform[0].Page3[0].CheckBox2A[0] topmostSubform[0].Page3[0].CheckBox2A[1] I use the next line of code to fill CheckBox2A[0] on the second page. fields.SetField("topmostSubform[0].Page2[0].CheckBox2A[0]", "1") Instead of CheckBox2A[0] on the second page, CheckBox2A[0] on the first page gets checked. A: iTextSharp (and also iText for Java, tested here) does not correctly associate the reference derived from the XFA template structure topmostSubform[0].Page2[0].CheckBox2A[0] with the matching entry in the one XFA dataset: <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" > <xfa:data > <topmostSubform > <!-- vvv the incorrect match by iText --> <CheckBox2A >0</CheckBox2A > <!-- ^^^ the incorrect match by iText --> <CheckBox2A >0</CheckBox2A > <CheckBox2B >0</CheckBox2B > <CheckBox2B >0</CheckBox2B > <Voorletters /> <Achternaam /> <CheckBox2C >0</CheckBox2C > <CheckBox2C >0</CheckBox2C > <DatumDag /> <DatumMaand /> <DatumJaar /> <TextField1 /> <HuisNrTekst5 /> <HuisNrNummer5 /> <Straat /> <PostcodeNr1c /> <PostcodeAlpha1c /> <Plaats /> <HuisNrTekst5 /> <HuisNrNummer5 /> <TextField1 /> <PostcodeNr1c /> <PostcodeAlpha1c /> <Plaats /> <TextField1 /> <CheckBox2D >0</CheckBox2D > <CheckBox2D >0</CheckBox2D > <IBANREKC_1 /> <IBANREKB_1 /> <IBANREKA_1 /> <IBAN_1 /> <BurgerserviceNr /> <Voorletters /> <Achternaam /> <CheckBox2E >0</CheckBox2E > <CheckBox2E >0</CheckBox2E > <HuisNrTekst5 /> <HuisNrNummer5 /> <Straat /> <PostcodeNr1c /> <PostcodeAlpha1c /> <Plaats /> <DatumDag /> <DatumMaand /> <DatumJaar /> <IBANREKC_2 /> <IBANREKB_2 /> <IBANREKA_2 /> <IBAN_2 /> <Telefoon /> <!-- vvv the correct match --> <CheckBox2A >0</CheckBox2A > <!-- ^^^ the correct match --> <CheckBox2A >0</CheckBox2A > <CheckBox2B >0</CheckBox2B > <CheckBox2B >0</CheckBox2B > <IBANREKC_1 /> <IBANREKB_1 /> <IBANREKA_1 /> <IBAN_1 /> <CheckBox2C >0</CheckBox2C > <CheckBox2C >0</CheckBox2C > <TextField1 /> <TextField1 /> <CheckBox2D >0</CheckBox2D > <CheckBox2D >0</CheckBox2D > <Telefoon /> <CheckBox2E >0</CheckBox2E > <CheckBox2E >0</CheckBox2E > <CheckBox2F >0</CheckBox2F > <CheckBox2F >0</CheckBox2F > <TextField1 /> <TextField1 /> <CheckBox2G >0</CheckBox2G > <CheckBox2G >0</CheckBox2G > <CheckBox3B >0</CheckBox3B > <CheckBox3B >0</CheckBox3B > <CheckBox3B >0</CheckBox3B > <IBAN_1E_01 /> <IBAN_1D_01 /> <IBAN_1C_01 /> <IBAN_1A_01 /> <IBAN_1B_01 /> <IBANREKC_1 /> <IBANREKB_1 /> <IBANREKA_1 /> <IBAN_1 /> <IBAN_1E_02 /> <IBAN_1D_02 /> <IBAN_1C_02 /> <IBAN_1B_02 /> <IBAN_1A_02 /> <CheckBox3D >0</CheckBox3D > <CheckBox3D >0</CheckBox3D > <CheckBox3D >0</CheckBox3D > <CheckBox3A >0</CheckBox3A > <CheckBox3A >0</CheckBox3A > <CheckBox3A >0</CheckBox3A > <CheckBox2A >0</CheckBox2A > <CheckBox2A >0</CheckBox2A > <CheckBox3B >0</CheckBox3B > <CheckBox3B >0</CheckBox3B > <CheckBox3B >0</CheckBox3B > <DatumDag /> <DatumMaand /> <DatumJaar /> <TextField1 /> <DatumDag /> <DatumMaand /> <DatumJaar /> <TextField1 /> <Telefoon /> </topmostSubform > </xfa:data > </xfa:datasets > Thus, the wrong dataset element is changed. I'm afraid this has to be looked into by iText development, I have no fix at hand. You might be in luck, though: The form in your document actually is a hybrid with both an AcroForm and an XFA representation. During your fields.SetField call iText attempts to set the value in both representations, and indeed, in the AcroForm representation it sets the correct one. Thus, if the result PDF is not required to carry that XFA structure anymore, you can simply drop the XFA structure: using (var pdfReader = new PdfReader(file)) using (FileStream output = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write)) using (PdfStamper pdfStamper = new PdfStamper(pdfReader, output)) { AcroFields fields = pdfStamper.AcroFields; fields.SetField("topmostSubform[0].Page2[0].CheckBox2A[0]", "1"); fields.RemoveXfa(); } Doing that you get the tick on page 2:
doc_23538971
In class we created both a stack and queue implementation using a dynamic array. My teacher used pointers to create these arrays on the heap. int* data = new int[25]; What I don't understand is how can you insert values into the array with "data[top]"? I thought pointers just held the memory address? I would ask my teacher how this works but I'm on a time crunch and she won't be able to get back to me till tomorrow afternoon >.< Stack::push(int value) { if(top==size) { resize(); } data[top] = value; top++; } A: I thought pointers just held the memory address? Yes, but you're allowed to do things with that memory address. In particular C++ allows something called 'pointer arithmetic' which allows you to use a memory address to obtain the address of other memory located relative to the memory you already have the address for. E.g., if you have a memory address you can get the address of the memory located immediately after it. (the squares are memory locations) ☐ ☐ ☐ ← I have the address of this memory in variable A ☐ ← I would like to get the address of this memory location and to store it in X ☐ ☐ ☐ int *A = ...; int *X = A + 1; // compute the address of the next memory location So an array is a series of memory locations. To access any element of the array you simply take the address you have, compute the address of the element you want to access, and then use that new address. int *A = new int[10]; int *X = A + 5; // get the address of the memory five locations past where A points to *X = 999; You don't have to store the address you compute in a variable: int *A = new int[10]; *(A+5) = 999; C++ provides a shorthand for the syntax *(A+5), this is the array index operator: int *A = new int[10]; A[5] = 999; One thing that's interesting is that the array index operator really is just shorthand for this *(A+5) expression. Since you can flip around the operands and do *(5+A) you can do the same with the array index operator: 5[A] = 999; You shouldn't do that though, because it's not very readable. Another thing to know about pointers: Java has pointers. When you do String s = new String(); in Java s is a pointer. Java just tries to hide this fact at the same time that it requires the use of pointers to a much greater extent than C++ does. Java doesn't have pointer arithmetic, and you don't have to manually dereference pointers in Java like you have to in C++. But consider: List<String> l = new List<String>(); List<String> m = l; // Do I have two lists, l and m, that can be modified independently? Or do I have two entities, l and m, that both refer to the same List object? And remember those Null Pointer exceptions you get in Java. If you've been using Java then you've already been using pointers. They're not really all that different in C++, but they're directly visible and explicit in C++ instead of being poorly hidden the way Java has them. A: One way to look at it is data[top] is the same as *(data + top). So you take the pointer data, add the value top to it (multiplied by the size of an int), then read or write that location. A: See: C++ Pointers & Arrays And you are correct, pointers only hold addresses to points in memory where the data is actually found. The stack you are creating is just a class that provides a specific way of getting memory from and adding memory to the array. Also check out: C++ STL Stack That should clarify how stacks work.
doc_23538972
Thank you for your help! A: I don't know if it works in AppMaker but you could try window.close(); A: You can't use window.close() directly otherwise sometimes you may get errors like Scripts may close only the windows that were opened by it. So here the first line of code is doing magic. It is opening nothing (first argument) and second argument i.e '_self' specifying to open in same page. window.open('', '_self', ''); window.close();
doc_23538973
Product and ProductImage has one to many relationship. My database has two tables named Product(id, name, price,..) and ProductImage(id, productid, image, place) which contains three images('Main Product IMG', 'Sub Img 1', 'Sub Img 2') Here is my models.py from django.db import models from django.contrib.auth.models import User class Product(models.Model): name = models.CharField(max_length=200) desc = models.TextField() price = models.DecimalField(max_digits=10, decimal_places=2) discount = models.DecimalField(max_digits=4, decimal_places=0) def __str__(self): return self.name class ProductImage(models.Model): PLACEHOLDER= ( ('Main Product Image', 'Main Product Image'), ('Sub Img 1', 'Sub Img 1'), ('Sub Img 2', 'Sub Img 2'), ) product = models.ForeignKey(Product, related_name='image_set', on_delete=models.CASCADE) image = models.ImageField(upload_to='images/') place = models.CharField(max_length=20, choices=PLACEHOLDER) def __str__(self): return str(self.id) views.py def menu(request): products = Product.objects images = ProductImage.objects context = {'products': products, 'images': images} return render(request, 'store/menu.html', context) Template {% for product in products.all %} <a href="#"> <img src="{{ images.filter(product__id=product.id, place='Main Product Image')[0].image.url }}" class="img-fluid mt-3"> {% if product.discount != 0 %} <span class="bonus">{{ product.discount }}% off</span> {% endif %} </a> settings.py STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] # Media files MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR urls.py urlpatterns = [ path('admin/', admin.site.urls), path('menu', views.menu, name='menu'), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) I was able to write a query in the shell to do that >>> images = ProductImage.objects >>> images.filter(product__id='1', place='Main Product Image')[0].image <ImageFieldFile: images/img3.jpg> The rest of the operations are working correctly. I've been trying to solve this issue for many hours now but keep getting TemplateSyntaxError at /menu Could not parse the remainder: '(product__id=product.id, place='Main Product Image')[0].image.url' from 'images.filter(product__id=product.id, place='Main Product Image')[0].image.url' Any help that is appreciated. A: You can not make method calls in a Django template, the parenthesis is deliberately not allowed to prevent people from writing business logic in the template. You can define a method, for example in the Product model: class Product(models.Model): name = models.CharField(max_length=200) desc = models.TextField() price = models.DecimalField(max_digits=10, decimal_places=2) discount = models.DecimalField(max_digits=4, decimal_places=0) @property def main_product_image(self): return self.image_set.filter(place='Main Product Image').first() def __str__(self): return self.name and then render this with: <img src="{{ product.main_product_image.image.url }}"; class="img-fluid mt-3"> but this will result in an N+1 problem, if method calls with parameters were allowed, this would also result in an N+1 problem. You can make use of a Prefetch object [Django-doc] to load the main images in bulk instead: from django.db.models import Prefetch def menu(request): products = Product.objects.prefetch_related( Prefetch( 'image_set', ProductImage.objects.filter(place='Main Product Image'), to_attr='main_images' ) ) context = {'products': products} return render(request, 'store/menu.html', context) then you can render this with: {% for product in products %} <img src="{{ product.main_images.0.image.url }}" class="img-fluid mt-3">; … {% endfor %}
doc_23538974
V - Visitors 2009 - S01e11-12.torrent V - Visitors (2009) S02e04.torrent V - Visitors (2009) S01e01-12.torrent V S02e02.torrent V S02e05.torrent Valentina S01e01-13.torrent Valeria Medico Legale S01-02e01-16.torrent Veep - Season 1 BDMux.torrent Veep - Season 2 BDMux.torrent Veep - Season 3.torrent Veep - Season 4.torrent Vegas S01e01-21.torrent Velvet S01e13.torrent Velvet S01e15.torrent Vikings.S03E03.torrent Vikings.S03E04.torrent Vikings.S03E05.torrent Velvet_S03e02.torrent Velvet_S03e03.torrent Velvet_S03e04.torrent I want a regex to delete repeated first-second words lines (veep - veep) to have a final list like this V - Visitors 2009 - S01e11-12.torrent V S02e02.torrent Valentina S01e01-13.torrent Valeria Medico Legale S01-02e01-16.torrent Veep - Season 1 BDMux.torrent Vegas S01e01-21.torrent Velvet S01e13.torrent So if I have Veep - Season 1 BDMux.torrent Veep - Season 2 BDMux.torrent I want only first line Veep - Season 1 BDMux.torrent A: Do a regular expression find/replace like this: * *Open Replace Dialog *Find What: ^([^ _.-]+[ _.-]+([^ _.-]++)?)(.*?\R)(\1.*?\R)+ *Replace With: \1\3 *check regular expression *click Replace or Replace All Explanation * *precondition is that the file is sorted *the first part ^([^ _.-]+[ _.-]+([^ _.-]++)?) deals with getting the first word on a line followed by the separator " ", "_", "." or "-". * *the first word is everything not a separator *the second word (([^ _.-]++)?) is optional to accomodate for the velvet example *due to the use of parenthesis the first word, the separator and optional second word are captured into \1 and what follows up to and including the linebreak is cptured into \3 for later reuse *the (.*?\R) captures everything up to the linebreak (\R *the last parrt (\1.*?\R)+ matches all following lines that begin with whatever is captured in \1 *the match spans all the lines, they are replace with \1\3 and that only reconstructs the first line, thus deleting the following line
doc_23538975
<div class = "content_wrapper"> <div class = "left_side"> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> </div> <div class = "right_side"> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> </div> <div class = "bottom"> bottom content </div> </div> The following CSS: #content_wrapper { width: 960px; margin: 0 auto; } div.left_side{margin:0px; width:100px; padding:0px 0 0 5px; float:left;} div.right_side{margin:0px; width:100px; padding:0px 0 0 5px; float:right;} div.bottom {clear:both; margin-top:20px;} And the following question: How can I make the bottom div have some margin from the content wrapper container? You can see it live here , that the margin is not being applied. A: If you add float:left to div.bottom the margin will work. If you do not wish to use float, padding-top{20px) will work like Koby mentioned. Also in your HTML you have <div class="contentWrapper"> but in your CSS #content_wrapper.. change that to .content_wrapper { A: change HTML into: <div class = "content_wrapper"> <div class = "left_side"> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> </div> <div class = "right_side"> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> </div> <div style="clear:both;" /> <div class = "bottom"> bottom content </div> </div> And CSS into: #content_wrapper { width: 960px; margin: 0 auto; } div.left_side{margin:0px; width:100px; padding:0px 0 0 5px; float:left;} div.right_side{margin:0px; width:100px; padding:0px 0 0 5px; float:right;} div.bottom {margin-top:20px;} See: http://jsfiddle.net/L8YN6/11/ ​ A: What about using padding-top instead of margin-top ? it will push the content of the div 20px to the bottom: div.bottom {clear: both; padding-top:20px;} A: I would approach this a little differently, using a separate but reusable "clearing" element: http://jsfiddle.net/L8YN6/16/ <div class = "content_wrapper"> <div class = "left_side"> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> LEFT SIDE<br> </div> <div class = "right_side"> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> RIGHT SIDE<br> </div> <div class="clearing">&nbsp;</div> <div class = "bottom"> bottom content </div> </div> And the CSS becomes: #content_wrapper { width: 960px; margin: 0 auto; } div.left_side {margin:0px; width:100px; padding:0px 0 0 5px; float:left;} div.right_side {margin:0px; width:100px; padding:0px 0 0 5px; float:right;} div.clearing { clear: both; line-height: 0; font-size: 0; overflow: hidden; } div.bottom { margin-top: 20px } ​I prefer this approach to wrestling with different browser's interpretations of the "float" specification for CSS. Alternatively, you could employ the self-clearing floats method.
doc_23538976
task copyFiles(type: Copy) { def folder = rootProject.file('/a/b/c') println folder.absolutePath println folder.exists() from(folder) { include '*.*' } into(rootProject.file('/c/b')) } I am trying to execute this task as a standalone copy task, so without any binding to the compiling of the project etc. The problem is that the task is never executed (NO-SOURCE) despite the folder existing: C:\...\a\b\b true :projectName:copyFiles NO-SOURCE A: NO-SOURCE means that the copy task did not find any files to copy based on your configuration. If /a/b/c are directories as sub-directories in relation to your build.gradle project file then this should work provided that the /c folder contains any files that follow the *.* pattern for names. https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Copy.html
doc_23538977
I subclassed UINavigationBar, and I'm trying to override hitTest:withEvent:, but I'm really confused what I'm doing, and searching has been of little help. How do I tell it, "if alpha is 0, send touch to self.view, otherwise keep on navigation bar"? A: You will need to send a reference of your view into the navigation bar, set it as a property called behindView or something. if(self.alpha == 0.0f) { return behindView; } return [super hitTest:point withEvent:event]; Another way would be to override pointInside:withEvent: like this: if(self.alpha == 0.0f) { return NO; } return [super pointInside:point withEvent:event]; A: Swift 4 version. Code: class NavigationBar: UINavigationBar { override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { if self.alpha == 0 { return false } return super.point(inside: point, with: event) } }
doc_23538978
TypeError: react__WEBPACK_IMPORTED_MODULE_1___default is not a function or its return value is not iterable Following is my code: import './RouteDetails.css'; import useState from 'react'; ... ... .. export default function RouteDetails() { const [show, setShow] = useState(false); return( <div> <Row className="route-details-heading"> <Col className="d-none d-sm-block" md={4}><b>Route Name</b></Col> <Col className="d-none d-sm-block" md={4}><b>Difficulty</b></Col> <Col className="d-none d-sm-block" md={1}><b>Length</b></Col> <Col className="d-none d-sm-block" md={1}><b>Time</b></Col> </Row> </div> ) } React and React-dom is of the same version. Can anyone please tell me what I am doing wrong here? Also, I am not using jest A: Try importing useState like import { useState } from 'react'. It is not a default.
doc_23538979
Please help me with this. Thanks in advance!!!! A: Power BI is just a data visualization platform, not a replacement for app development. When you want to do such things like clickable action in each row of PowerBI report list of records - maximum possibility is hyperlink (url). Unfortunately CRM Custom action is not url accessible, but that too you want with paramters. Forget it. I have other ideas shared in this SO answer, like you can try Power Automate (MS Flow) or custom API to explore by url accessibility. A: You can also achieve your requirement with the help of Power Automate. Steps - * *Create new flow with Http Trigger *Invoke flow URL from power BI *Call custom action from flow Please mark my answer verified if i were helpful
doc_23538980
Here is my source for my fragment: public class Test extends Fragment { private VideoView vid; private Button playpause1; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { root = (ViewGroup) inflater.inflate(R.layout.test, null); vid = (VideoView) root.findViewById(R.id.videoView1); vid.requestFocus(); vid.setVideoURI(Uri.parse("my_path")); playpause1 = (Button) root.findViewById(R.id.playpause1); playpause1.setText(R.string.buffering); playpause1.setEnabled(false); playpause1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if vid.isPlaying()) { vid.pause(); } else { vid.start(); } } }); vid.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { playpause1.setEnabled(true); mp.setOnInfoListener (new MediaPlayer.OnInfoListener() { @Override public boolean onInfo (MediaPlayer mp, int what, int extra) { if (what == MediaPlayer.MEDIA_INFO_BUFFERING_START) { playpause1.setEnabled(false); } if(what == MediaPlayer.MEDIA_INFO_BUFFERING_END) { playpause1.setEnabled(true); } return false; } }); } }); } } A: * *Create a new Fragment with its own layout (which contains the full-sized videoView). *the new Fragment should get the current played state: public static FullVideoFragment newInstance(final long playedDuration) { final FullVideoFragment fragment = new FullVideoFragment(); final Bundle bundle = new Bundle(); bundle.putLong("playedDuration", playedDuration); fragment.setArguments(bundle); return fragment; } *get the playedDuration in the same Fragment @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); this.playDuration = getArguments().getLong("playedDuration"); initializeViews(); //get video URI... } *In the clickListener of your fragment: use the FragmentManager to add the full-sized Video Fragment and pass the play duration. *Seek in the new Full sized Fragment to the given playedDuration and play the video.
doc_23538981
I have this fake JSON... [ { "user": { "type": "PF", "code": 12345, "Name": "Darth Vader", "currency": "BRL", "status": "ACTIVE", "localization": "NABOO", "createDate": 1627990848665, "olderAdress": [ { "localization": "DEATH STAR", "status": "BLOCKED", "createDate": 1627990848665 }, { "localization": "TATOOINE", "status": "CANCELLED", "createDate": 1627990555665 }, { "localization": "ALDERAAN", "status": "INACTIVED", "createDate": 1627990555665 }, ] } } ] I would like to remove the field code if the status equals "BLOCKED" or "CANCELLED". I'm using aggregate because I'm doing a lot of things before Practical Example. How can I do that?? I need this result: [ { "_id": ObjectId("5a934e000102030405000000"), "user": { "Name": "Darth Vader", "createDate": 1.627990848665e+12, "currency": "BRL", "localization": "DEATH STAR", "status": "BLOCKED", "type": "PF" } }, { "_id": ObjectId("5a934e000102030405000000"), "user": { "Name": "Darth Vader", "createDate": 1.627990555665e+12, "currency": "BRL", "localization": "TATOOINE", "status": "CANCELLED", "type": "PF" } }, { "_id": ObjectId("5a934e000102030405000000"), "user": { "Name": "Darth Vader", "code": 12345, "createDate": 1.627990555665e+12, "currency": "BRL", "localization": "ALDERAAN", "status": "INACTIVED", "type": "PF" } }, { "_id": ObjectId("5a934e000102030405000000"), "user": { "Name": "Darth Vader", "code": 12345, "createDate": ISODate("2021-09-16T17:36:26.405Z"), "currency": "BRL", "localization": "NABOO", "status": "ACTIVE", "type": "PF" } } ] Soo...Independent of the name, I will check the status and if you contemplate the condition I will remove the field code. A: Query * *uses a system variable $$REMOVE if a field gets this value its removed *so the condition is user.code , keep old value if not "BLOCKED","CANCELLED" , else "$$REMOVE" the field Test code here db.collection.aggregate([ { "$set": { "user.code": { "$cond": [ { "$in": [ "$user.status", [ "BLOCKED", "CANCELLED" ] ] }, "$$REMOVE", "$user.code" ] } } } ]) Edit The above code checks the user.status but you want remove code or not based onthe user.olderAdress.status (after the unwind) (its 2 fields with same name status) Query (add this after the stages you already have) Test code { "$set": { "user.code": { "$cond": [ { "$in": [ "$user.status", [ "BLOCKED", "CANCELLED" ] ] }, "$$REMOVE", "$user.code" ] } } }
doc_23538982
How can I fix them? Do i: * *Delete the current AMI, go back to the EC2 instance from which the AMI was created, make the changes and create a new AMI? *Or Can I somehow start the current AMI, SSH into it and make the necessary changes? A: The best practice is to build a repeatable process for creating your AMIs from a base operating system image (typically AWS Linux, Ubuntu, etc.). The reason is that you have many more updates ahead of you: * *You might not succeed at fixing the identified issues completely to Amazon's satisfaction *Future scans may find new, different issues *AWS Marketplace staff will manually check some things with your AMI *You might find your own bugs *You will eventually want to deploy new software versions Yes, you could launch an instance from your your image, modify it, save it, and make a new image. It might be worth doing that to learn something about the AMI scanning criteria. But you would not make any progress towards a reliable, repeatable image building flow. I strongly recommend looking into tools like Packer that can help you automate the AMI building process.
doc_23538983
<script type="text/javascript" src="files/swfobject.js">//</script> <script type="text/javascript" src="files/swfaddress.js">//</script> <script type="text/javascript" src="files/facebook.js">//</script> <script type="text/javascript"> var assetsFolder = 'assets'; var mobileFolder = 'mobile'; var changeURL = function(){ if(document.getElementById('hrefMobile'))document.getElementById('hrefMobile').href = dir+mobileFolder+'/index.html'; if(document.getElementById('hrefSEO'))document.getElementById('hrefSEO').href = dir+assetsFolder +'/seo/toc.html'; delete changeURL; } if (document.addEventListener){ document.addEventListener("DOMContentLoaded", changeURL, false); } else { document.attachEvent("onDOMContentLoaded", changeURL); } function afterLoad(){ checkPage(); setFocusOnFlash(); } function setFocusOnFlash(){ var f=swfobject.getObjectById('content'); if (f) { f.tabIndex = 0; f.focus(); } } function getURLParam() { var returnObject = {}; var href = window.location.href; if ( href.indexOf("?") > -1 ) { var param = href.substr(href.indexOf("?")); var arrayParam = param.split("&"); returnObject['assets'] = assetsFolder; for ( var i = 0; i < arrayParam.length; i++ ) { var value = arrayParam[i].split("="); returnObject[value[0]] = value[1]; } } return returnObject; } var dir = "./files/"; var getURI = function(){ var URIArray = document.location.href.split('/'); URIArray.length = URIArray.length-1; var URIstr = URIArray.join('/'); URIArray = null; var URIarr = dir.split('/'); URIarr[0] = URIarr[0]=='.'?'':URIarr[0]; var dirStr = URIarr.join('/'); URIstr = URIstr+dirStr; return URIstr; } var swfName = "flippingbook.swf?rnd=a920e3f104e299e21a8f93f76594fff6"; var ua = navigator.userAgent.toLowerCase(), platform = navigator.platform.toLowerCase(), UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0], mode = UA[1] == 'ie' && document.documentMode; var Browser = { extend: Function.prototype.extend, name: (UA[1] == 'version') ? UA[3] : UA[1], version: mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]), Platform: { name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android|bada|symbian|palm|blackberry)/) || platform.match(/mac|win|linux/) || ['other'])[0] }, Features: { xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector), json: !!(window.JSON) }, Plugins: {} }; if(Browser.Platform.name == 'android' || Browser.Platform.name == 'ios') window.location = dir+mobileFolder+"/index.html"; if(Browser.Platform.name == 'webos' || Browser.Platform.name == 'bada' || Browser.Platform.name == 'symbian' || Browser.Platform.name == 'palm' || Browser.Platform.name == 'blackberry') window.location = dir+assetsFolder+"/seo/page1.html"; var flashvars = getURLParam(); var params = {baseURI: getURI(), base: dir, allowFullScreen: true, allowScriptAccess: "sameDomain", quality: "high", scale: "noscale",bgcolor:"FFFFFF"}; var attributes = {align: "middle"}; swfobject.embedSWF(dir + swfName, "content", "100%", "100%", "10.0.0", dir + "expressInstall.swf", flashvars, params, attributes);</script> and <body style="padding: 0px; margin: 0px; height:100%; width:100%;" onLoad="afterLoad()"> I would like to make the flash animation transparent when I load this page in an iframe, so it doesn't cover the drop down menu ... A: Set the flash' to use wmode transparent. That will make it respect the z-ordering of your elements. Replace your current params line with this: var params = { baseURI: getURI(), base: dir, allowFullScreen: true, allowScriptAccess: "sameDomain", quality: "high", scale: "noscale", bgcolor:"FFFFFF", wmode:"transparent" };
doc_23538984
at java.lang.Object.wait(Native Method) - waiting on <0x17351c50> (a weblogic.rjvm.ResponseImpl) at weblogic.rjvm.ResponseImpl.waitForData(ResponseImpl.java:76) - locked <0x17351c50> (a weblogic.rjvm.ResponseImpl) at weblogic.rjvm.ResponseImpl.getTxContext(ResponseImpl.java:104) at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:104) at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:164) at ROIDLookupImpl_WLStub.lookupROIDS(Unknown Source) at weblogic.servlet.internal.HttpServer.lookupROIDS(HttpServer.java:1101) at weblogic.servlet.internal.session.ReplicatedSessionContext.getROIDSFromRemote(ReplicatedSessionContext.java:309) at weblogic.servlet.internal.session.ReplicatedSessionContext.getSessionInternal(ReplicatedSessionContext.java:421) at weblogic.servlet.internal.ServletRequestImpl.getValidSession(ServletRequestImpl.java:2632) at weblogic.servlet.internal.ServletRequestImpl.getSession(ServletRequestImpl.java:2248) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3742) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183) " this pattern in a log file and count the number of times it occurs in the large log file using unix. so how can i do that? A: you can try pcregrep, as suggested in this: https://stackoverflow.com/a/2686705/2380702 This line should output the number of occurences: pcregrep -c -M -f testsnippet.txt logfile.txt where logfile.txt is your log you want to scan, and testsnippet.txt contains your snippet, with line-endings replaced by \n, and all dots and brackets preceded by slashes. In other words: at java\.lang\.Object\.wait\(Native Method\)\n - waiting on <0x17351c50> \(a weblogic\.rjvm\.ResponseImpl\)\n at weblogic\.rjvm\.ResponseImpl\.waitForData\(ResponseImpl\.java:76\)\n - locked <0x17351c50> \(a weblogic\.rjvm\.ResponseImpl\)\n at weblogic\.rjvm\.ResponseImpl\.getTxContext\(ResponseImpl\.java:104\)\n at weblogic\.rjvm\.BasicOutboundRequest\.sendReceive\(BasicOutboundRequest\.java:104\)\n at weblogic\.rmi\.internal\.BasicRemoteRef\.invoke\(BasicRemoteRef\.java:164\)\n at ROIDLookupImpl_WLStub\.lookupROIDS\(Unknown Source\)\n at weblogic\.servlet\.internal\.HttpServer\.lookupROIDS\(HttpServer\.java:1101\)\n at weblogic\.servlet\.internal\.session\.ReplicatedSessionContext\.getROIDSFromRemote\(ReplicatedSessionContext\.java:309\)\n at weblogic\.servlet\.internal\.session\.ReplicatedSessionContext\.getSessionInternal\(ReplicatedSessionContext\.java:421\)\n at weblogic\.servlet\.internal\.ServletRequestImpl\.getValidSession\(ServletRequestImpl\.java:2632\)\n at weblogic\.servlet\.internal\.ServletRequestImpl\.getSession\(ServletRequestImpl\.java:2248\)\n at weblogic\.servlet\.internal\.WebAppServletContext\.invokeServlet\(WebAppServletContext\.java:3742\)\n at weblogic\.servlet\.internal\.ServletRequestImpl\.execute\(ServletRequestImpl\.java:2766\)\n at weblogic\.kernel\.ExecuteThread\.execute\(ExecuteThread\.java:224\)\n at weblogic\.kernel\.ExecuteThread\.run\(ExecuteThread\.java:183\) You may want to replace the memory addresses by something like <0x[0-9a-f]+>, to catch different addresses, but I have not tested this, since that was not your question :) Above example does exactly what you asked. A: printf "multi\nline\ninput\n" | grep -Pzo "(?s)mul.*put" | wc -l you'll have to divide that by number of lines you expect your multiline pattern to span though. A: When you find an at at the start of the line add to your count and stop counting until you see a line that does not start with at. awk 'BEGIN {count=0; boolCount=0}; /^at/ {if (boolCount==0) count++; boolCount=1}; !/^at/ {boolCount=0}; END {print "Found: " count} ' logfile
doc_23538985
const ldap = require('ldapjs'); class AD { /** * Create Connection Active Directory */ async createConnection(){ return new Promise((resolve, reject) => { var options = { 'rejectUnauthorized': false, }; this.ADConnnection = ldap.createClient({ url: [ process.env.LDAP_SERVER_1 + ':' + process.env.LDAP_SERVER_PORT, ], reconnect: true, tlsOptions: options }); this.ADConnnection.on('error', (err) => { reject(err) }) this.ADConnnection.bind(this.ldapUsername, this.ldapPassword, async (err) => { if (err) { reject(err) } }); resolve(true) }); } /** * Create Record in Active Directory * @param {*} oRequest * @param {*} oEntry */ async create(oRequest, oADCreateUserDT) { const sUsername = oRequest.vpnUsername; this.adOu = oRequest.apiUser; let oEntry = oADCreateUserDT.ADCreateUserData(); if(oEntry.hasOwnProperty('msRADIUSFramedIPAddress')){ this.adOu = ADConstant.AD_PARAMS.OU_DED; oADCreateUserDT.setTitle(ADConstant.AD_PARAMS.OU_DED); oEntry = oADCreateUserDT.ADCreateUserData(); } return new Promise(async (resolve, reject) => { this.ADConnnection.add('cn=' + sUsername + ',ou=' + this.adOu + ',' + this.dc, oEntry, (err) => { if (err) { reject(err); } else { resolve(true); } }); await this.closeConnection() }); } async closeConnection() { this.ADConnnection.unbind(err => { if (err) { reject(err) } }, () => { this.ADConnnection.destroy(); }); } } module.exports = AD; Now this is my test class (I am using jest for nodejs testing) const AD = require("../../app/libraries/AD"); const ldap = require('ldapjs'); jest.mock('ldapjs', () => { return jest.fn().mockImplementation(() => { return { createClient: jest.fn(), add: jest.fn(() => Promise.resolve(true)), } }) }); const isDedicatedIP = true; const oRequest = { uuid: "vpn00s01" } const oEntry = { UserAccountControl: ADConstant.AD_PARAMS.AD_ACC_CONTROL_ENABLE } const oSearch = { attributes: ["cn", "Accountexpires", "UserAccountControl"], scope: "sub", filter: "" } describe('should test all cases of ldap function', () => { test('should test constructor', async () => { const oAD = new AD() const response = oAD expect(JSON.stringify(response)).toBe(JSON.stringify({ "dc": "dc=undefined,dc=undefined", "adOu": "purevpn", "objectclass": "user" })); }); test('should set Adu', async () => { const oAD = new AD() const response = oAD.setAdOu(isDedicatedIP) expect(JSON.stringify(response)).toBe(JSON.stringify({})); }); test('should test create form ldap', async () => { const oAD = new AD() const response = oAD.create(oRequest, oADCreateUserDT) expect(JSON.stringify(response)).toBe(JSON.stringify({})); }); }); While running this jest test facing this issue I don't understand how to mock my ldapjs methods. Even after adding in in mock implementation still having the same issue
doc_23538986
When it try to run this line python.exe go-mapfish-framework-2.2.py --no-site-packages env I got this message in my cmd : Traceback (most recent call last): File "go-mapfish-framework-2.2.py", line 2055, in main() File "go-mapfish-framework-2.2.py", line 797, in main never_download=options.never_download) File "go-mapfish-framework-2.2.py", line 897, in create_environment search_dirs=search_dirs, never_download=never_download) File "go-mapfish-framework-2.2.py", line 590, in install_setuptools search_dirs=search_dirs, never_download=never_download) File "go-mapfish-framework-2.2.py", line 564, in _install_req cwd=cwd) File "go-mapfish-framework-2.2.py", line 865, in call_subprocess % (cmd_desc, proc.returncode)) OSError: Command c:\Python27\env\Scripts\python.exe -c "#!python \"\"\"Bootstra...sys.argv[1:]) " --always-copy -U setuptools failed with error code 1 I don't know what is wrong,can anyone help me?
doc_23538987
Details: I'm creating a CV using the vitae package in r, using the awesome cv template. The text formatting for the # Education section can be found in the awesome cv CSS file as part of the vitae package. Reproducible example below: name: Charles surname: Darwin position: "Naturalist" address: "Down House, Luxted Rd, Downe, Orpington BR6 7JT" www: "wikipedia.org/Charles_Darwin" email: "darwin@gmail.com" twitter: chucky_D linkedin: charlesRdarwin headcolor: 0B90B4 date: "`r format(Sys.time(), '%B %Y')`" header-includes: \usepackage{float} \usepackage{colortbl} \arrayrulecolor{white} output: vitae::awesomecv: page_total: true --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE) library(vitae) library(kableExtra) ``` # Education ```{r} degree <- "Bachelor of Arts" dates <- 1831 institution <- "University of Cambridge" details <- "Unable to qualify for the Tripos, had to take the ordinary degree. Preferred riding and shooting to studying. Studied Paley's Natural Theology or Evidences of the Existence and Attributes of the Deity (first published in 1802), which made an argument for divine design in nature, explaining adaptation as God acting through laws of nature." education <- data.frame(degree, dates, institution, details) education %>% detailed_entries( what = institution, with = degree, where = dates, why = details ) ``` # Grants and Awards ```{r} dates2 <- c(1864,1879,2022) details2 <- c("Copley Medal - award given by the Royal Society, for outstanding achievements in research in any branch of science.","Baly Medal - The Baly Medal is a biennial award awarded by the Royal College of Physicians of London. Founded by a gift from Frederick Daniel Dyster (1809–93) received in 1866, confirmed by deed 1930 – in memory of William Baly: £400 to provide a gold medal for the person deemed to have most distinguished himself in the science of physiology, especially during the previous two years.","Pour le Mérite - The Pour le Mérite was awarded as both a military and civil honour and ranked, along with the Order of the Black Eagle, the Order of the Red Eagle and the House Order of Hohenzollern, among the highest orders of merit in the Kingdom of Prussia. The order of merit was the highest royal Prussian order of bravery for officers of all ranks.") value <- c("£1000","£1500","£2000") awards <- data.frame(dates2,details2,value) options(knitr.kable.NA = '') kable( align = 'llr', awards, booktabs="TRUE", col.names = NULL, escape = FALSE) %>% kable_styling(font_size = 8.5) %>% column_spec(1, bold = FALSE, color = "#696969", width = "2em") %>% column_spec(2, bold = FALSE, color = "#696969", width = "52.5em") %>% column_spec(3, bold = FALSE, italic = TRUE, color = "#0B90B4", width = "2em") %>% kable_styling(bootstrap_options ="hover") %>% kable_styling(latex_options = "HOLD_position") ```
doc_23538988
http://rapcom.dk/profil/index/KoS but i think im doing it work cause it works on my local PC :S, here is my controller function index() { $this->load->model('profil_model'); $data['query'] = $this->profil_model->vis_profil($this->uri->segment(3)); //Henter lib profilwall så man kan vise wall beskeder i profilen $this->load->library('profilewall'); $data['queryWall'] = $this->profilewall->wallShow(); $this->template->write_view('content', 'profil_view', $data); $this->template->render(); } And my library called profileWall.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Profilewall { private $CI; public function __construct() { $this->CI =& get_instance(); } public function wallShow() { $this->CI->load->model('profil_model'); return $this->CI->profil_model->wallGet($this->CI->uri->segment(3)); } } do you know what can be wrong? and im 100% sure it is uploaded du the server A: This may have to do with how you are naming the actual file. Could you try naming the file profilewall.php rather than profileWall.php and see if that works. For the most part you should be mindful of case issues, especially with CodeIgniter. Generally the rule of thumb is to use lowercase characters in filenames, models, etc.
doc_23538989
It works fine when I run it as Java Application in Eclipse. However, the xml file can't be found and read when I export the program to jar file and run it in DOS command prompt. Have found how to set the classpath for some time. But still don't know how to make it works. Hope someone can help... Thank you. MANIFEST.MF Manifest-Version: 1.0 Class-Path: . Main-Class: hk.net.tsl.scanimagereport.run.FtpFilesSvcTesting Name: org/apache/xml/serializer/ Implementation-Vendor: Apache Software Foundation Implementation-Title: org.apache.xml.serializer Implementation-Version: 2.7.0 Specification-Vendor: W3C Recommendation 16 November 1999 Specification-Title: XSL Transformations (XSLT), at http://www.w3.org/ TR/xslt Implementation-URL: http://xml.apache.org/xalan-j/usagepatterns.html Specification-Version: 1.0 Comment: Serializer to write out XML, HTML etc. as a stream of charact ers from an input DOM or from input SAX events. Name: javax/mail/internet/ContentDisposition.class SHA1-Digest: bY8UAj9xFRzI4/VCQoGyGPwOknY= Name: com/sun/mail/pop3/Protocol.class SHA1-Digest: wAZ7DkPdNZ+OYMCu0UtkSziBRB4= Name: com/sun/mail/iap/Response.class SHA1-Digest: tFgqRdpA3+0smuOFCBibO03uhGo= Name: com/sun/mail/smtp/DigestMD5.class SHA1-Digest: 8CdePxmLZUwQUSN6YGvMX9U/ml0= Name: javax/mail/internet/MimePart.class SHA1-Digest: V5t0/G+DkCx8EdNkvIdq+1R6IH0= Name: com/sun/mail/imap/IMAPMessage.class SHA1-Digest: S7pebUjNqfxvaK2ELFhBqa0Nr8s= Name: com/sun/mail/imap/Rights.class SHA1-Digest: ilk6VAwKfEvDqMSeBypwRK7kSqU= Name: javax/mail/Message.class SHA1-Digest: krXNUG849vk3hdRK5/IJ7/RPAQQ= Name: com/sun/mail/util/SocketFetcher.class SHA1-Digest: T77YEuZtS8y6usz9EfITXwz3l5o= Name: javax/mail/ReadOnlyFolderException.class SHA1-Digest: S0Nq1oqW9uyNAyk/Kqqr/1kYQA0= Name: com/sun/mail/pop3/POP3Store.class SHA1-Digest: tfboxyMbD/NbEBFQTb2cz+3cuJ8= Name: javax/mail/event/TransportListener.class SHA1-Digest: ZsaUmiJzCAKO4AcGnHFxgUVLA1Q= Name: javax/mail/SecuritySupport12$2.class SHA1-Digest: E2rXTlPkQT/6PiuZBBW3ffk61qE= Name: javax/mail/search/HeaderTerm.class SHA1-Digest: lZ/h2u1F6TnaF0Ih840anZ3HtC8= Name: org/apache/xml/ Implementation-Vendor: Apache Software Foundation Implementation-Title: org.apache.xml Implementation-URL: http://xml.apache.org/xalan-j/dist/ Implementation-Version: 2.7.0 Comment: DTM implementation and utilities Name: javax/mail/AuthenticationFailedException.class SHA1-Digest: Y9+glLmoLdTkOLCbedr8fyTC+eY= Name: com/sun/mail/imap/protocol/SearchSequence.class SHA1-Digest: t2xolWv3jNpoa9CE+SfEORDRuXk= Name: javax/mail/Session.class SHA1-Digest: dG/hsdEjivnjb5tL4PAX2sIYOQE= Name: com/sun/mail/imap/protocol/Item.class SHA1-Digest: jt+5t84a7Lj6fTDiFf92jLnL904= Name: javax/mail/search/IntegerComparisonTerm.class SHA1-Digest: hsilLJNY6jikGSPm1rGXFdopW8Q= Name: javax/mail/search/DateTerm.class SHA1-Digest: sJMnSc8K9JfZvo9PWwDOYAKOGU8= Name: javax/mail/internet/MimeUtility$1$NullInputStream.class SHA1-Digest: M9e0IjrHqAAdEVS3miejIauY4KA= Name: javax/mail/Address.class SHA1-Digest: X7VSByL8WAotQCpAT/5Q5AKA89c= Name: com/sun/mail/util/QPEncoderStream.class SHA1-Digest: FuVz6KvMT/IkJop8gKdaPktAC+I= Name: javax/mail/MessageRemovedException.class SHA1-Digest: flx99/N4bVa1FiDB42u8k5xn8sI= Name: javax/mail/event/MessageChangedEvent.class SHA1-Digest: Iglkwqm3yZsZ6oA1fCkyEiPF0N0= Name: com/sun/mail/imap/IMAPMultipartDataSource.class SHA1-Digest: O4vXDVAskJ8+XwSGq+zSIWNMO1Q= Name: javax/mail/internet/NewsAddress.class SHA1-Digest: CpknF4BJMRS67HdzJm6Jxq/ZsYc= Name: javax/mail/MultipartDataSource.class SHA1-Digest: q5t9m5Z6jIVYd+Ndb52UMWIX9Sw= Name: com/sun/mail/iap/ConnectionException.class SHA1-Digest: sDlarplfMMKV4E9T0ytDBg1+AJc= Name: com/sun/mail/imap/protocol/FetchResponse.class SHA1-Digest: 3rfxnONvQhT88oHQfH2h9gX5Z5E= Name: javax/mail/search/OrTerm.class SHA1-Digest: LEcwqC/g3wjd7vvkRv87Brz8LHE= Name: com/sun/mail/iap/BadCommandException.class SHA1-Digest: j+cPDx9IHpfzOGLdgxIVf7Hne00= Name: com/sun/mail/imap/DefaultFolder$2.class SHA1-Digest: 8Vp1Jwzz1Xz0gg5F0hQ5uLiT+O0= Name: javax/mail/event/MessageChangedListener.class SHA1-Digest: CO4WmyMgpnfmTeMqRB10BP3E/IQ= Name: com/sun/mail/imap/protocol/IMAPResponse.class SHA1-Digest: 9IZiUHugnKLCAsUg98xb/zjcVBU= Name: javax/mail/search/MessageNumberTerm.class SHA1-Digest: gSem31OGV4jMswkFOm1jvgJZ8aY= Name: com/sun/mail/util/SharedFileInputStream.class SHA1-Digest: dDw5OXYtjVCV4Q8Maq8O/J5Jp1Q= Name: com/sun/mail/iap/LiteralException.class SHA1-Digest: Jag5t9w1nm01xHUIN48a5ZG41hU= Name: com/sun/mail/iap/Literal.class SHA1-Digest: jMeEDxmF2B1WQSZegHaS20Z3nDU= Name: javax/mail/MessageAware.class SHA1-Digest: jp3hq8pfG9lfLtSB0cL2M85ccSQ= Name: org/apache/xpath/ Implementation-Vendor: Apache Software Foundation Implementation-Title: org.apache.xpath Implementation-URL: http://xml.apache.org/xalan-j/dist/ Implementation-Version: 2.7.0 Comment: XPath engine Name: com/sun/mail/imap/ACL.class SHA1-Digest: lLEvhMBKrtNrsJguz0kzaRmS/oU= Name: com/sun/mail/imap/protocol/ListInfo.class SHA1-Digest: OVcXT5i+QD+NA8zn2JMxd1FbKhk= Name: javax/mail/internet/MimeMultipart.class SHA1-Digest: 4rkNeeC9kyNgI3WY1yn7cTVsHPA= Name: javax/mail/search/SearchException.class SHA1-Digest: rquY7mBKZYtM4ee2teSKciP2FDI= Name: com/sun/mail/imap/IMAPFolder$6.class SHA1-Digest: dvZwqaJ3yuk1N1q6tQ26H2MQOns= Name: org/apache/xalan/ Implementation-Vendor: Apache Software Foundation Implementation-Title: org.apache.xalan Implementation-Version: 2.7.0 Specification-Vendor: Sun Microsystems Inc. Specification-Title: Java API for XML Processing Implementation-URL: http://xml.apache.org/xalan-j/dist/ Specification-Version: 1.3 Comment: Main Xalan engine implementing TrAX/JAXP Name: javax/mail/Transport.class SHA1-Digest: 5sAOVdCTkoP/4FEaCxalhGC8T/s= Name: com/sun/mail/util/LineInputStream.class SHA1-Digest: w8HgIwmzknu+2uR7DQjevxjhLvc= Name: JBossRemoting Implementation-Vendor: JBoss Inc. Implementation-Title: JBossRemoting Implementation-Version: 2.2.2.SP8 Implementation-Vendor-Id: http://www.jboss.org Specification-Vendor: JBoss Inc. Specification-Title: JBossRemoting Specification-Version: 2.2.2.SP8 Name: javax/mail/Header.class SHA1-Digest: 4kh6YmNXUKdkArYO5u312kmV3eQ= Name: javax/mail/internet/MailDateParser.class SHA1-Digest: yNuQXmcNZcKpBtxXKb2Dgr/jhKY= Name: com/sun/mail/imap/protocol/BODYSTRUCTURE.class SHA1-Digest: 0+l+fhktBXRP0MOfnYM9Z/MHkP0= Name: javax/mail/internet/ParameterList.class SHA1-Digest: 9jIFa9qxIjZM0ff35d85/YgdRQM= Name: javax/mail/URLName.class SHA1-Digest: vs7Akz89DBR8IJvhvziUuBai8lc= Name: javax/xml/transform/ Implementation-Vendor: Sun Microsystems Inc. Implementation-Title: javax.xml.transform Implementation-Version: 1.3.02 Specification-Vendor: Sun Microsystems Inc. Specification-Title: Java API for XML Processing Implementation-URL: http://java.sun.com/xml/jaxp.html Specification-Version: 1.3 Comment: based on xml-commons external 1.3.02 Name: javax/mail/event/ConnectionEvent.class SHA1-Digest: cjGrDkhnqGTdPV0/0/s8u2HOmoY= Name: org/xml/sax/ Implementation-Vendor: David Megginson Implementation-Title: org.xml.sax Implementation-Version: 2.0.2 Specification-Vendor: David Megginson Specification-Title: Simple API for XML Implementation-URL: http://www.saxproject.org/ Specification-Version: 2.0.2 Comment: based on xml-commons external 1.3.01 Name: org/w3c/dom/ Implementation-Vendor: World Wide Web Consortium Implementation-Title: org.w3c.dom Implementation-Version: 1.0 Specification-Vendor: World Wide Web Consortium Specification-Title: Document Object Model, Level 3 Core Implementation-URL: http://www.w3c.org/DOM/ Specification-Version: 1.0 Comment: based on xml-commons external 1.3.02 Name: javax/mail/search/FlagTerm.class SHA1-Digest: ywIxPYyzdgTa1BL7sXuKb3hcyGo= Name: com/sun/mail/iap/ResponseHandler.class SHA1-Digest: PscpGXa4y5TeSxv6FO/YCRiALUA= Name: com/sun/mail/imap/Utility.class SHA1-Digest: pNQrlz/sCl8/CIAqurzRkI4UaXA= Name: javax/mail/FolderClosedException.class SHA1-Digest: qEdMfsKFRg3FBlByevo1dfnzS24= Name: javax/mail/event/FolderEvent.class SHA1-Digest: 5HsowfXxLX3Ss7m8/9ST2fbmBIc= Name: javax/mail/internet/hdr.class SHA1-Digest: Jpc1bcsAto5zLWEO7SJcKRAMTbg= Name: javax/mail/FetchProfile.class SHA1-Digest: xNwmiCwbbGCR4kuX6B6G+8M7BDQ= Name: org/apache/xerces/xni/ Implementation-Vendor: Apache Software Foundation Implementation-Title: org.apache.xerces.xni Implementation-Version: 1.2 Specification-Vendor: Apache Software Foundation Specification-Title: Xerces Native Interface Implementation-URL: http://xml.apache.org/xerces2-j/ Specification-Version: 1.2 Comment: Xerces Native Interface Name: javax/mail/search/FromTerm.class SHA1-Digest: x+5mIhEcfAXJ/sUmZhH1ZxHaG4g= Name: com/sun/mail/util/BASE64DecoderStream.class SHA1-Digest: ZSQx/Xuh240EOCqvhQUa8UQQOh0= Name: com/sun/mail/iap/AString.class SHA1-Digest: bluH0peRMsEKAiWMP1qzis3DMsc= Name: org/apache/xml/serializer/utils/ Implementation-Vendor: Apache Software Foundation Implementation-Title: org.apache.xml.serializer.utils Implementation-Version: 2.7.0 Comment: Utilities used internally by the Serializer. Not for external use. Name: com/sun/mail/imap/Quota$Resource.class SHA1-Digest: 3eBjXbAl4KtqOWEpvcH1D/RvcEQ= Name: javax/mail/search/ReceivedDateTerm.class SHA1-Digest: LWp9MpPLe4p6rErKZJ6TAWFQIwc= Name: com/sun/mail/imap/protocol/BASE64MailboxDecoder.class SHA1-Digest: lfv5JKcYNaWKMPVDOn4BH1r79DA= Name: javax/mail/search/AddressTerm.class SHA1-Digest: pb5Rfd3vghsJVORVFbLQUqFCdnk= Name: com/sun/mail/imap/protocol/FLAGS.class SHA1-Digest: mb8PjIrqAtlNre35gTEGyZXpjSs= Name: org/apache/log4j/ Implementation-Vendor: "Apache Software Foundation" Implementation-Title: log4j Implementation-Version: 1.2.14 Name: com/sun/mail/util/BASE64EncoderStream.class SHA1-Digest: PhRNdEecTpSsRiJY0pUZmmXcU6Q= Name: com/sun/mail/handlers/message_rfc822.class SHA1-Digest: 7f7lLHDJiiIYozmNRJdWXmanucc= Name: javax/mail/search/AddressStringTerm.class SHA1-Digest: Py9AXA8H4FCAA1Rpo3I+2fwSISM= Name: com.sun.xml.bind.v2.runtime Implementation-Version: 2.1.4-b02-fcs Name: javax/mail/Part.class SHA1-Digest: 9G9aj3EQEFJkLkGaVyAjesSW1Jk= Name: javax/mail/EventQueue$QueueElement.class SHA1-Digest: kb93WyA+TadV3l1mZgGC43UqvKg= Name: com/sun/mail/smtp/SMTPMessage.class SHA1-Digest: j3wY+vqZdAJDt5bYwAH8b9cXFVE= Name: com/sun/mail/util/CRLFOutputStream.class SHA1-Digest: rwRM031H5Ig0KwZzxonnczWv+Gc= Name: com/sun/mail/util/TraceOutputStream.class SHA1-Digest: WCddxU42jQ0RGVNqA5yGJFMq0a4= Name: com/sun/mail/imap/Utility$Condition.class SHA1-Digest: /RP1IP2+QlNdpHguqi8189/a+To= Name: javax/mail/internet/UniqueValue.class SHA1-Digest: vCW0ebHrlwjGPsbOMsBGX0WTMbg= Name: com/sun/mail/pop3/POP3Folder.class SHA1-Digest: WrNgKCK4DRFoeC6ho3nsu6I1QkI= Name: javax/xml/xpath/ Implementation-Vendor: Sun Microsystems Inc. Implementation-Title: javax.xml.xpath Implementation-Version: 1.3.02 Specification-Vendor: Sun Microsystems Inc. Specification-Title: Java API for XML Processing Implementation-URL: http://java.sun.com/xml/jaxp.html Specification-Version: 1.3 Comment: based on xml-commons external 1.3.02 Name: com/sun/mail/util/BEncoderStream.class SHA1-Digest: 158qvZlZGzLcn6a63B9AUAXNLwQ= Name: javax/xml/validation/ Implementation-Vendor: Sun Microsystems Inc. Implementation-Title: javax.xml.validation Implementation-Version: 1.3.02 Specification-Vendor: Sun Microsystems Inc. Specification-Title: Java API for XML Processing Implementation-URL: http://java.sun.com/xml/jaxp.html Specification-Version: 1.3 Comment: based on xml-commons external 1.3.02 Name: javax/mail/PasswordAuthentication.class SHA1-Digest: AxiQvAJATUJleqC60z610xs8g+U= Name: javax/mail/event/MailEvent.class SHA1-Digest: u9B1y8KPBhV1Ed+aWQyRygUbMIo= Name: javax/mail/search/NotTerm.class SHA1-Digest: 9jEpMz7+rJDYS/tetftLnAfmX+g= Name: com/sun/mail/pop3/SharedByteArrayOutputStream.class SHA1-Digest: /vMClZ7vApKknSHh4DYTgxq8LfA= Name: com/sun/mail/handlers/multipart_mixed.class SHA1-Digest: K+HJksRgguqxMKJBs5g4R6YJYzg= Name: com/sun/mail/imap/MessageLiteral.class SHA1-Digest: j2NWZ8O36Q9/FOnXPBfbq1nxDdA= Name: javax/mail/search/ComparisonTerm.class SHA1-Digest: Hqg2WBMxwFjUeTR5siK6oPwzhJg= Name: com/sun/mail/imap/IMAPFolder$ProtocolCommand.class SHA1-Digest: Cc5PabNTstl9FZGDbvKfazJYpIE= Name: javax/mail/internet/HeaderTokenizer$Token.class SHA1-Digest: SdpqfjRihm+RWmMXQjk4rLJDBOU= Name: javax/mail/UIDFolder$FetchProfileItem.class SHA1-Digest: UZ6YlRdOxpDooMPI151mGK6iwFk= Name: com/sun/mail/util/UUEncoderStream.class SHA1-Digest: 1FKVJAR2xe3T8zlYClQKj+5QT+I= Name: javax/mail/BodyPart.class SHA1-Digest: BsFiU1h2qvnQYWF+pimUhYdFAc4= Name: com/sun/mail/imap/Rights$Right.class SHA1-Digest: MEdUSVTUiMgh/oVFPKQIsJCXIsM= Name: javax/mail/Session$1.class SHA1-Digest: e4wJlpIisoJspf9x4oSZOGI3kgw= Name: com/sun/mail/imap/protocol/ENVELOPE.class SHA1-Digest: AKOoOtwyQs+R1gioc4dB4gYGlXg= Name: javax/mail/SecuritySupport12.class SHA1-Digest: eT4XVb3oRIvJ66uqfekxCwmckwE= Name: com/sun/mail/handlers/text_xml.class SHA1-Digest: g7n0q3rrqP8AB7DpixFPfZUTsGs= Name: com/sun/mail/imap/IMAPFolder$16.class SHA1-Digest: 2SN4v7moBEXLRjwCjPEaQiWwFr8= Name: javax/mail/internet/matchEnum.class SHA1-Digest: AYU3f3sVLGSxNtVvpHgilUZtMdE= Name: com/sun/mail/smtp/SMTPTransport.class SHA1-Digest: IpGFoVESnGL0JZ5nAehbn7dkF9A= Name: javax/mail/internet/SharedInputStream.class SHA1-Digest: c2F/FBldF/b33VUKlcLjUNAuLjY= Name: javax/mail/event/MessageCountAdapter.class SHA1-Digest: F4FDThh6Tw1mwpcB0x4leDu9sVI= Name: com/sun/mail/handlers/text_plain.class SHA1-Digest: pxlsPjnIr/1GOG19sL+DhVewDdE= Name: javax/mail/IllegalWriteException.class SHA1-Digest: uD4M1sQ1nnWMV+bRzoDpxKBQasM= Name: com/sun/mail/imap/IMAPFolder$7.class SHA1-Digest: 9hF9nPPs1WwGrid1x+S0KxYhJTs= Name: com/sun/mail/smtp/SMTPOutputStream.class SHA1-Digest: B3x0//NSC0q9yO1h+1//o30T5NQ= Name: com/sun/mail/imap/IMAPInputStream.class SHA1-Digest: lQwWSrVpg++AHFC+A5nOiVGaqk0= Name: javax/mail/event/TransportEvent.class SHA1-Digest: pnUMWFijO6HrDrKOri7+qjJvDMI= Name: com/sun/mail/util/QPDecoderStream.class SHA1-Digest: t0U0mXoOcBmhtoFDiIUOeWkhLgY= Name: javax/mail/internet/MimeMessage.class SHA1-Digest: 5TM+LONcq9eJRXSr8kZiQ8RURhw= Name: xmlsec Implementation-Vendor: Apache Software Foundation Implementation-Title: Apache-XML-Security-J Implementation-Version: 1.3.0 ${TODAY} Name: com/sun/mail/imap/IMAPStore$ConnectionPool.class SHA1-Digest: /D/WTm4svWHBoEF6XSkgrzoGrWs= Name: com/sun/mail/imap/IMAPFolder$4.class SHA1-Digest: iNTeoQpCZZ0whXKFRMMuT5ZGRd0= Name: com/sun/mail/imap/IMAPFolder.class SHA1-Digest: gPfyYKWWL/oCdUd2Vb0m3uYqWpA= Name: javax/mail/Message$RecipientType.class SHA1-Digest: ZxVgRaRunSIe3CZDlzJMtzc3SJo= Name: com/sun/mail/imap/IMAPBodyPart.class SHA1-Digest: RD1b0rrHv8PkoTG0+lf38u67J9s= Name: javax/mail/event/ConnectionAdapter.class SHA1-Digest: 8RjzjNXIgyIXH8t2T2bpydcBdXM= AComment: Xerces-J 2.7.1 Name: com/sun/mail/imap/IMAPFolder$9.class SHA1-Digest: MQf35USIXPJrXjj5Ki1RSrvVodY= Name: javax/mail/event/FolderAdapter.class SHA1-Digest: tI5Fs0LNbR4IjjKeY8V7TVyzAp8= Name: com/sun/mail/iap/CommandFailedException.class SHA1-Digest: FisOBME0Jn/0jDFXtyP3YFtgNn0= Name: javax/mail/UIDFolder.class SHA1-Digest: qDcdba2rD5hvk4Quzsc3l/5nCYc= Name: javax/mail/NoSuchProviderException.class SHA1-Digest: iDaY5ddbHNXqCcj3Ax/lgjbYznY= Name: com/sun/mail/iap/ResponseInputStream.class SHA1-Digest: NINscpCgiFusy38qZ3HPNGEDW4A= Name: com/sun/mail/handlers/image_jpeg.class SHA1-Digest: 6TaMpH7WcS1cmCIy8xim7c2mlMo= Name: com/sun/mail/imap/protocol/Namespaces.class SHA1-Digest: BNur7ins+4sfwuAAN73GtwQoex4= Name: javax/mail/search/RecipientStringTerm.class SHA1-Digest: 1DpAxvvp5gdr78CYLqGwto+8CQ8= Name: javax/mail/StreamLoader.class SHA1-Digest: g6CPWHycDJJb8j348nZJgiptnhI= Name: com/sun/mail/imap/protocol/IMAPProtocol.class SHA1-Digest: Aq7kw1Ub31S7KU5YlN7DXqW5OAc= Name: com/sun/mail/imap/IMAPFolder$FetchProfileItem.class SHA1-Digest: LkmXNiLVyrrVqMcCUnn9edV3fn0= Name: javax/mail/MessagingException.class SHA1-Digest: cL2aRjUjhxIC5JL+CcY0p9Ad+Js= Name: com/sun/mail/imap/IMAPFolder$1.class SHA1-Digest: l8llUp8Gt6sj3cyskVkrNGzGCZ8= Name: javax/mail/internet/AsciiOutputStream.class SHA1-Digest: cu/3EooiZShegX1fHymNyl4Cth8= Name: javax/mail/Folder$1.class SHA1-Digest: OHS5c6BnZdXIgNrrBBx0mi6t7wE= Name: javax/mail/SecuritySupport12$3.class SHA1-Digest: yDdyXTFIs4BTndtx7OFKrFjAuQU= Name: javax/mail/event/TransportAdapter.class SHA1-Digest: cvgC7kfs1+pCQaYoHMWV5/XCDKY= Name: com/sun/mail/iap/ParsingException.class SHA1-Digest: PRxKcl5jpj1vPZ0mAJsBAa2UutM= Name: com/sun/mail/iap/ProtocolException.class SHA1-Digest: 4on9Lc30QQL04SEyVMwC3oN5EAY= Name: com/sun/mail/imap/protocol/RFC822DATA.class SHA1-Digest: sKQ0fzKLJc3jSlJhnZ/ttup0trg= Name: javax/mail/search/MessageIDTerm.class SHA1-Digest: gxqAwr9Ky5QBQ4WLHaidz8Wfl0c= Name: com/sun/mail/imap/protocol/Namespaces$Namespace.class SHA1-Digest: MLQ6Lg884SnA22FsSGuyTU8pRQI= Name: com/sun/mail/iap/Argument.class SHA1-Digest: fWv6G11Gdr7PTv1lXwv4Ouf1nJw= Name: javax/mail/Service.class SHA1-Digest: xrYis0Dww/bXojy8+7bNNCLhIMk= Name: com/sun/mail/imap/IMAPFolder$5.class SHA1-Digest: 5/iaFe4/s7DD01HGuK8QpuZT3ns= Name: com/sun/mail/imap/protocol/MessageSet.class SHA1-Digest: 0mPbryDKktQyU9DxoogzZI/OuRU= Name: com/sun/mail/imap/IMAPFolder$2.class SHA1-Digest: ePbkzBKBH7BkdNRCH7JdHMKmkz8= Name: com/sun/mail/imap/IMAPFolder$3.class SHA1-Digest: aiYwHPzTZExKxPxBHRAha393GEk= Name: javax/mail/Provider.class SHA1-Digest: dbZGmDHtZuDmyidl20bXUly3ntY= Name: javax/mail/Store.class SHA1-Digest: 6X6bFhPHLQAp042kca7jrYqB4A4= Name: com/sun/mail/imap/protocol/RFC822SIZE.class SHA1-Digest: 7ZaQnODL+5VxGAb9ycDby9Ouevo= Name: com/sun/mail/imap/protocol/INTERNALDATE.class SHA1-Digest: ZOQno39toT/YTc6HNUz9Ot5kslw= Name: javax/mail/internet/InternetHeaders.class SHA1-Digest: RQeLWpUfmOqQfGWEu9FS5ooSci4= Name: javax/mail/Flags$Flag.class SHA1-Digest: 5tFlGWtctB1STMq6HFWqe3YPWdA= Name: javax/mail/internet/MimeMessage$RecipientType.class SHA1-Digest: QUAovn/JOd/+1m4qD5xqVQmMSpI= Name: com/sun/mail/pop3/Status.class SHA1-Digest: SR9k4yO5yUi3auYkMROvXaSQj/c= Name: javax/mail/Session$2.class SHA1-Digest: zdKuQllpPYSwE5dM4TxikcU47D0= Name: javax/mail/SecuritySupport12$1.class SHA1-Digest: 78ePYKf7KntiHRdJeZxFhRlPqRM= Name: javax/mail/SecuritySupport.class SHA1-Digest: qnl/waFwFYQyq91x1V1aJKwCBmE= Name: com/sun/mail/util/ASCIIUtility.class SHA1-Digest: Ita7PGvkIyz2jTTu9mx141dsXxc= Name: com/sun/mail/imap/DefaultFolder$1.class SHA1-Digest: qxsVgVMkqllunfxi5r1jLNJ0SAQ= Name: javax/mail/Multipart.class SHA1-Digest: HHrJ9a6oO/+IOtqFiyioBdwGono= Name: javax/mail/SecuritySupport12$4.class SHA1-Digest: NoAN8f0FUah3e/PGT3CeOUiofws= Name: com/sun/mail/imap/IMAPFolder$10.class SHA1-Digest: alJp1A7OZ/Xt7nMBMGEWCMpZ3mw= Name: com/sun/mail/imap/Quota.class SHA1-Digest: j7ukKu2EeyGl/eAHZ+/ECrdNCz0= Name: com/sun/mail/imap/protocol/BODY.class SHA1-Digest: v0SA4XHDRpb0BCGg8kSocc0T30Y= Name: javax/mail/Folder.class SHA1-Digest: XoN7VPgeYxy4m+kCXGZ/nirX4oA= Name: com/sun/mail/imap/protocol/BASE64MailboxEncoder.class SHA1-Digest: iydFl9/wfg/yHBRrdSREJB3QBzI= Name: com/sun/mail/util/QEncoderStream.class SHA1-Digest: tvaNY/BbDF2f2RzwolLV9GJ28g8= Name: javax/mail/search/BodyTerm.class SHA1-Digest: VenGJGuQmPZg+hZXZu4TGpX60wk= Name: com/sun/mail/imap/protocol/IMAPAddress.class SHA1-Digest: KpETkeeQHQAD71WnOab9yDJyK0o= Name: com/sun/mail/imap/IMAPFolder$12.class SHA1-Digest: 7eCG0Qe4DSe2ItuD/QrxWKBZHyI= Name: com/sun/mail/util/SharedByteArrayInputStream.class SHA1-Digest: 7KmfanNYyL3FvWv1/BG6LnYuNUA= Name: javax/mail/internet/AddressException.class SHA1-Digest: nmhHxY3nr8aaWER9KJswQnH/QPA= Name: javax/mail/internet/HeaderTokenizer.class SHA1-Digest: evwKRf8YAcnb4E1fLoXQM04KKDs= Name: javax/mail/search/StringTerm.class SHA1-Digest: eFEtsGgraACS3eRdhJYG+AerOy4= Name: javax/mail/Flags.class SHA1-Digest: VQdqDOtD5OuUb5Tks3n23OGskqc= Name: com/sun/mail/imap/protocol/Status.class SHA1-Digest: zSxif54SoBUiOYxeDwmfE/pHsK4= Name: javax/mail/search/FromStringTerm.class SHA1-Digest: wQSeBiGfGcNWhmePYpfJWcFFSdg= Name: com/sun/mail/pop3/Response.class SHA1-Digest: +akWna4FnmxyvZXRTnlTJmAdcY8= Name: javax/mail/event/StoreListener.class SHA1-Digest: +BM2MswIMrP3NN235/bFi+oCxDg= Name: javax/mail/search/SentDateTerm.class SHA1-Digest: rmVF+9qq651v1D5sHDooDB0wn5Y= Name: javax/mail/internet/MimeUtility.class SHA1-Digest: Jq5L22gxOICsQIi3Ze5jGlom5NM= Name: javax/mail/MethodNotSupportedException.class SHA1-Digest: GZ0I8HAcU5XdSKh2v7UfmO7lSqQ= Name: javax/mail/internet/MailDateFormat.class SHA1-Digest: HBPhiNfmi6tT/fAtlkyH7DBIMYg= Name: com/sun/mail/iap/Atom.class SHA1-Digest: RVCLbNsyfmwlX0+ftqL58RrM6wI= Name: com/sun/mail/iap/ByteArray.class SHA1-Digest: fTXycdWBnCWVYNUQebkjG+GT9u8= Name: com/sun/mail/iap/Protocol.class SHA1-Digest: pmZrpW1MvmKsNOPy5+W+CSxA1vE= Name: javax/mail/internet/MimePartDataSource.class SHA1-Digest: g5wQCNeUiNfmDw5Xuj1z/9P3diM= Name: com/sun/mail/util/UUDecoderStream.class SHA1-Digest: oH5S9MZumNu8SpE1RxHVOjONPMU= Name: javax/mail/search/RecipientTerm.class SHA1-Digest: p+BJdGRzjmgR9Pij0ONNlPHo7OA= Name: com/sun/mail/imap/protocol/UID.class SHA1-Digest: eGTQIQT9Z9jmP9GTZkcqMpdD7HI= Name: com/sun/mail/imap/IMAPFolder$13.class SHA1-Digest: 4i39Jgvxw/dEexNwwKMw6B5n3oA= Name: javax/mail/search/SearchTerm.class SHA1-Digest: yjIhhlZywZvYMXYZaVO6lk4IPUo= Name: javax/mail/event/MessageCountEvent.class SHA1-Digest: o2C/asucfo+KOYru8x7VeJsn8kw= Name: com/sun/mail/pop3/DefaultFolder.class SHA1-Digest: GsDmlFLNmrbfYTrSTMTGWECJFck= Name: com/sun/mail/imap/IMAPNestedMessage.class SHA1-Digest: mfO927rh3+qEycUHWmk4pwEF/LM= Name: javax/mail/SecuritySupport12$5.class SHA1-Digest: i7seT9W0U85Jd2nKKjMSx6zgp8E= Name: com/sun/mail/pop3/POP3Message.class SHA1-Digest: S/w1qKjKQto7oUrZQgNz/1v+uJo= Name: javax/mail/search/SizeTerm.class SHA1-Digest: 4of7XuYNceiEA/lBA6xGAXcK4Xo= Name: javax/mail/internet/InternetAddress.class SHA1-Digest: 71RGXBkLFr0AgQLh5PEspZilkB0= Name: javax/mail/event/ConnectionListener.class SHA1-Digest: 4a5cGqI0/mOkMii7FKm6AFct87k= Name: javax/mail/internet/ParseException.class SHA1-Digest: I/lti4miXWMbcfnqpz9B3JxTQKs= Name: javax/mail/MessageContext.class SHA1-Digest: lVLgWBtydsok5CyBBmfmCZEtqCk= Name: javax/mail/search/SubjectTerm.class SHA1-Digest: gc4Tg1cF79H1C95Wp+IPDFlNHFQ= Name: com/sun/mail/imap/IMAPFolder$8.class SHA1-Digest: JFPV/sFmaiU2Z6f5xiM4jKd6W98= Name: javax/mail/internet/ContentType.class SHA1-Digest: 6+UWkjb+XJlZzA1QHVPAcKVrYZk= Name: com/sun/mail/imap/LengthCounter.class SHA1-Digest: eSbjrIQyrkq9zP8NSivzcH3WwRA= Name: javax/xml/parsers/ Implementation-Vendor: Sun Microsystems Inc. Implementation-Title: javax.xml.parsers Implementation-Version: 1.3.02 Specification-Vendor: Sun Microsystems Inc. Specification-Title: Java API for XML Processing Implementation-URL: http://java.sun.com/xml/jaxp.html Specification-Version: 1.3 Comment: based on xml-commons external 1.3.02 Name: javax/mail/StoreClosedException.class SHA1-Digest: yujVPRQ6gZ+KvY8ooBhUB//p5iU= Name: javassist/ Name: com/sun/mail/imap/IMAPFolder$14.class SHA1-Digest: cuazmZMG6nzn/imJnlXNQaTwpXY= Name: javax/mail/Provider$Type.class SHA1-Digest: RcBrLjSqBKbkGphUggeKQ8tmEyU= Name: javax/mail/Service$1.class SHA1-Digest: bBcqbuXIYK/pb3sTabo2Uld357Q= Name: org/w3c/dom/ls/ Implementation-Vendor: World Wide Web Consortium Implementation-Title: org.w3c.dom.ls Implementation-Version: 1.0 Specification-Vendor: World Wide Web Consortium Specification-Title: Document Object Model, Level 3 Load and Save Implementation-URL: http://www.w3c.org/DOM/ Specification-Version: 1.0 Comment: based on xml-commons external 1.3.02 Name: com/sun/mail/imap/IMAPFolder$11.class SHA1-Digest: +wtemvzDRw+zsO1mzBNhdyDXH7A= Name: com/sun/mail/util/QDecoderStream.class SHA1-Digest: M6+HVAW/8N4oOb88TOW+tHuk0mQ= Name: com/sun/mail/imap/DefaultFolder.class SHA1-Digest: VUosUn+a14PkAQGfJrbeL+4vj1g= Name: javax/mail/event/FolderListener.class SHA1-Digest: jqyODyE3T/VwXhIxZxtt2HKNfRE= Name: com/sun/mail/util/LineOutputStream.class SHA1-Digest: 9iehnKKwfZLXws9+dOwvIf2T58Q= Name: com/sun/mail/handlers/text_html.class SHA1-Digest: 6wEn4h3CORSNSHsC4RULxcumKD4= Name: javax/mail/event/MessageCountListener.class SHA1-Digest: Y/DnFhVvjkIMkoV+0T8TXX0uERs= Name: com/sun/mail/imap/protocol/MailboxInfo.class SHA1-Digest: X++C/B5b480R2j2rQDR4mqMf0o0= Name: javax/mail/FetchProfile$Item.class SHA1-Digest: YZ+BcYG1+A9vIxiM/W4iR7JT8/A= Name: javax/mail/Authenticator.class SHA1-Digest: mMAnLkTKyL7vIjp5a4Xh6FTkX4M= Name: com/sun/mail/imap/IMAPFolder$17.class SHA1-Digest: LwVyEhLhp83Kn7kqKqk8I6eFGqg= Name: javax/mail/SendFailedException.class SHA1-Digest: ejXXQU/1Npebx+Wu8U94NzNuM8w= Name: com/sun/mail/handlers/image_gif.class SHA1-Digest: sJ1kzJrdJJCjgrUs6CTtUqQJokQ= A: try adding the location of the "scanimagereport-data.xml" in the Class-Path: entry of your MANFIEST.INF
doc_23538990
When I attempted this, I received a ooxmlIsMalformated exception when calling the insertFileFromBase64 method. I've inserted the same base64 string into empty document everything is ok.
doc_23538991
For me, it acts as a the Service Locator, because it looks for the proper "file" to load, and return an object. (For example in PHP, require somewhat load the file in the memory but doesn't construct). Example: var Foo = function() { console.log("I'm the Foo object"); }; module.exports = Foo; Then, to use it I'll do: var Foo = require('foo'); and var foo = new Foo(); Note, that the exported function is NOT constructed. I could have done: var foo = require('foo')(); None of those methods seems right to me (I may are wrong). * *1) Is it common to do it like this? Or should exported the executed function? Anyway, this introduction is to understand how I should play with the require function. For example if I've a Foo object, which is depends of Bar, I've two way to do: Service Location: var Foo = function() { var Bar = require('bar')(); Bar.doSomethingAwesome(); }; module.exports = Foo; or I can do: Dependency Injection var Foo = function(bar) { bar.doSomethingAwesome(); }; module.exports = Foo; // And at a latter time var foo = require('foo')(require('bar')); /// eurk I obviously know that that's two different things and serve different purposes. * *2) But I'm wondering what is the common/right way to do in JS, is there any commonly admitted rules? A: Browserify allows you to program with modules, there's not much more to it. It's not really a DI container or service locator per se, although you can probably make it work like one. So doing this is perfectly fine: var Foo = require('foo'); var foo = new Foo(); In that case, it makes sense to simply place all require calls at the top of your file, similar like you would do with using in C# or import in Java. I personally wouldn't scatter require calls since don't help much with readability. You can also export an instance which doesn't have to be newed up anymore, as long as that is appropriate for what you want to do (in that case module.exports = Foo() would lead to a singleton). Also see this related question: Dependency Injection with RequireJS A: The rewire library provides module injection for Node.js. A couple of solutions have been discussed and presented in this Github issue to support browserify. Usage example from the project README: var myModule = rewire("../lib/myModule.js"); myModule.__set__("fs", fsMock); // set private variable A: Use Browserify so you can require npm packages from your browser just like node. Then you can use Weather.js or require it, then inject it in any way you like.
doc_23538992
I'm getting the following error when trying to connect to postgres: /home/German/Desktop/ger/code/projects/mixr/mixr-back/node_modules/pg-protocol/src/parser.ts:202 assert.fail(`unknown message code: ${code.toString(16)}`) ^ AssertionError [ERR_ASSERTION]: unknown message code: 5b at Parser.handlePacket (/home/German/Desktop/ger/code/projects/mixr/mixr-back/node_modules/pg-protocol/src/parser.ts:202:16) at Parser.parse (/home/German/Desktop/ger/code/projects/mixr/mixr-back/node_modules/pg-protocol/src/parser.ts:103:30) at Socket.<anonymous> (/home/German/Desktop/ger/code/projects/mixr/mixr-back/node_modules/pg-protocol/src/index.ts:7:48) at Socket.emit (node:events:394:28) at Socket.emit (node:domain:475:12) at addChunk (node:internal/streams/readable:315:12) at readableAddChunk (node:internal/streams/readable:289:9) at Socket.Readable.push (node:internal/streams/readable:228:10) at TCP.onStreamRead (node:internal/stream_base_commons:199:23) { generatedMessage: false, code: 'ERR_ASSERTION', actual: undefined, expected: undefined, operator: 'fail' } I understand it's a connection problem, but I'm not sure why I'm getting this. This is my connection code: export const knex = require('knex')({ client: 'pg', connection: { host : 'localhost', port : 3306, user : 'notTheRealUser', password : 'notTheRealPassword', database : 'pgdb' } }) knex.raw("SELECT 1").then(() => { console.log("PostgreSQL connected") }) .catch((e: Error) => { console.log("PostgreSQL not connected") console.error(e) }) And then I'm importing the Knex object on the different routes to make queries, like so: import { knex } from '../db/db' router.post('/register', async (req: Request, res: Response) => { // Check if the email isn't already taken try { const emailIsTaken = await knex('users').where({ email: req.body.email }) if (emailIsTaken) return res.status(500).json('Email already used') } catch (err) { res.status(500).send(err) console.error(err) } }) Full code can be found here: https://github.com/coccagerman/mixr-back A: you are using MySQL port 3306, PostgresQL uses port 5432
doc_23538993
I am also maintaining a status column in the table to keep track of my current record progress.For Eg. initially record status is 'N' after selecting I am updating it to 'U' and at the end change it to 'P'. Now my problem is I want to run many instance of this application but blocker is same row might be selected by different instance because selecting and updating status to 'U' is not a single query.So it might happen Process 1 select then Process2 select same record then Process1 update status to 'U'.I have to solve this problem to make my application distributed. I have created select and update query as a single transaction but I guess because that won't solve the problem .My this logic is correct right? I am using Hibernate to access database .Any one has idea how can I achieve this using Hibernate java? If my above logic(about transaction) is correct then I can do this by 2 ways if any of these is offered by hibernate. 1-Select and update the record in 1 query 2-Select a row and lock it in 1 query and then run another query in same transaction to update status to 'U' . In Sql I can do this by using 'for update' at end of query but I am not sure how to do this using 'Hibernate criteria'.Criteria also has an API 'forUpdate' but I guess that is not functional because query generated by Hibernate in that case doesn't have 'for update' in last. Can someone please help me in this A: Yes, it is possible to one query using criteria. I am writing one example. I hope it is helpful to you. public void updateEmployee(int empid,String firstname, String lastname, String email) { sf=connect(); // get connection Session session=sf.openSession(); Transaction t=session.beginTransaction(); Employee emp= (Employee) session.get(Employee.class, empid); emp.setFirstname(firstname); emp.setLastname(lastname); emp.setEmail(email); session.update(emp); // Update employee t.commit(); session.close(); }
doc_23538994
This is the error log. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'staffController': Unsatisfied dependency expressed through field 'staffService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'staffServiceImpl': Unsatisfied dependency expressed through field 'staffRepository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'staffRepositoryImpl': Unsatisfied dependency expressed through field 'jdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.DatabaseException: NULL not allowed for column "ID"; SQL statement: INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654') [23502-200] [Failed SQL: (23502) INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654')] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.18.jar:5.3.18] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.18.jar:5.3.18] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.6.jar:2.6.6] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.6.jar:2.6.6] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.6.jar:2.6.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.6.jar:2.6.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.6.jar:2.6.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.6.jar:2.6.6] at com.oze.hospitalservice.HospitalServiceApplication.main(HospitalServiceApplication.java:10) ~[classes/:na] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'staffServiceImpl': Unsatisfied dependency expressed through field 'staffRepository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'staffRepositoryImpl': Unsatisfied dependency expressed through field 'jdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.DatabaseException: NULL not allowed for column "ID"; SQL statement: INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654') [23502-200] [Failed SQL: (23502) INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654')] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.18.jar:5.3.18] ... 20 common frames omitted Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'staffRepositoryImpl': Unsatisfied dependency expressed through field 'jdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.DatabaseException: NULL not allowed for column "ID"; SQL statement: INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654') [23502-200] [Failed SQL: (23502) INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654')] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.18.jar:5.3.18] ... 34 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.DatabaseException: NULL not allowed for column "ID"; SQL statement: INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654') [23502-200] [Failed SQL: (23502) INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654')] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.18.jar:5.3.18] ... 48 common frames omitted Caused by: liquibase.exception.LiquibaseException: liquibase.exception.DatabaseException: NULL not allowed for column "ID"; SQL statement: INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654') [23502-200] [Failed SQL: (23502) INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654')] at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:124) ~[liquibase-core-4.5.0.jar:na] at liquibase.Liquibase.lambda$null$0(Liquibase.java:265) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.lambda$child$0(Scope.java:177) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:186) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:176) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:155) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:239) ~[liquibase-core-4.5.0.jar:na] at liquibase.Liquibase.lambda$update$1(Liquibase.java:264) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.lambda$child$0(Scope.java:177) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:186) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:176) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:155) ~[liquibase-core-4.5.0.jar:na] at liquibase.Liquibase.runInScope(Liquibase.java:2404) ~[liquibase-core-4.5.0.jar:na] at liquibase.Liquibase.update(Liquibase.java:211) ~[liquibase-core-4.5.0.jar:na] at liquibase.Liquibase.update(Liquibase.java:197) ~[liquibase-core-4.5.0.jar:na] at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314) ~[liquibase-core-4.5.0.jar:na] at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269) ~[liquibase-core-4.5.0.jar:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.18.jar:5.3.18] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.18.jar:5.3.18] ... 60 common frames omitted Caused by: liquibase.exception.DatabaseException: NULL not allowed for column "ID"; SQL statement: INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654') [23502-200] [Failed SQL: (23502) INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654')] at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:393) ~[liquibase-core-4.5.0.jar:na] at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:82) ~[liquibase-core-4.5.0.jar:na] at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:150) ~[liquibase-core-4.5.0.jar:na] at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:134) ~[liquibase-core-4.5.0.jar:na] at liquibase.changelog.StandardChangeLogHistoryService.setExecType(StandardChangeLogHistoryService.java:391) ~[liquibase-core-4.5.0.jar:na] at liquibase.database.AbstractJdbcDatabase.markChangeSetExecStatus(AbstractJdbcDatabase.java:1136) ~[liquibase-core-4.5.0.jar:na] at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:60) ~[liquibase-core-4.5.0.jar:na] at liquibase.changelog.ChangeLogIterator$2.lambda$null$0(ChangeLogIterator.java:111) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.lambda$child$0(Scope.java:177) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:186) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:176) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:155) ~[liquibase-core-4.5.0.jar:na] at liquibase.changelog.ChangeLogIterator$2.lambda$run$1(ChangeLogIterator.java:110) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.lambda$child$0(Scope.java:177) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:186) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:176) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:155) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:239) ~[liquibase-core-4.5.0.jar:na] at liquibase.changelog.ChangeLogIterator$2.run(ChangeLogIterator.java:94) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.lambda$child$0(Scope.java:177) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:186) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:176) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:155) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:239) ~[liquibase-core-4.5.0.jar:na] at liquibase.Scope.child(Scope.java:243) ~[liquibase-core-4.5.0.jar:na] at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:66) ~[liquibase-core-4.5.0.jar:na] ... 78 common frames omitted Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: NULL not allowed for column "ID"; SQL statement: INSERT INTO PUBLIC.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (NULL, NULL, 'classpath:/db/changelog/db.changelog-master.yaml', NOW(), 1, '8:d41d8cd98f00b204e9800998ecf8427e', 'empty', '', 'EXECUTED', NULL, NULL, '4.5.0', '9921389654') [23502-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:459) ~[h2-1.4.200.jar:1.4.200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) ~[h2-1.4.200.jar:1.4.200] at org.h2.message.DbException.get(DbException.java:205) ~[h2-1.4.200.jar:1.4.200] at org.h2.message.DbException.get(DbException.java:181) ~[h2-1.4.200.jar:1.4.200] at org.h2.table.Column.validateConvertUpdateSequence(Column.java:374) ~[h2-1.4.200.jar:1.4.200] at org.h2.table.Table.validateConvertUpdateSequence(Table.java:845) ~[h2-1.4.200.jar:1.4.200] at org.h2.command.dml.Insert.insertRows(Insert.java:187) ~[h2-1.4.200.jar:1.4.200] at org.h2.command.dml.Insert.update(Insert.java:151) ~[h2-1.4.200.jar:1.4.200] at org.h2.command.CommandContainer.update(CommandContainer.java:198) ~[h2-1.4.200.jar:1.4.200] at org.h2.command.Command.executeUpdate(Command.java:251) ~[h2-1.4.200.jar:1.4.200] at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228) ~[h2-1.4.200.jar:1.4.200] at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201) ~[h2-1.4.200.jar:1.4.200] at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-4.0.3.jar:na] at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-4.0.3.jar:na] at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:389) ~[liquibase-core-4.5.0.jar:na] ... 103 common frames omitted This is my changelog-master.yaml file databaseChangeLog: - changeSet: id: 1 author: gafar changes: - createTable: tableName: hospital_staff columns: - column: name: id type: serial autoIncrement: true constraints: primaryKey: true nullable: false - column: name: name type: varchar(255) constraints: nullable: false - column: name: password type: text constraints: nullable: false - column: name: staff_id type: uuid default: uuid.random() constraints: nullable: false - column: name: registration_date type: date default: date.now() constraints: nullable: false A: there are multiple options to solve your here, which is a missing ID during the insert statement. * *Let it be handled by DB: Depending on your database you not only have to set ID to not nullable, but also specify how the ID would be generated. For PostgreSQL you for example could specify the keyword 'SERIAL' in addition to your ID column specification. This would create a sequence and auto generate IDs. *Specify the IDs within your liquibase scripts as part of your insert statements. Just preferable, if there is an interest to referring to the IDs in a later stage of the script e.g. for specifying relations properly.
doc_23538995
https://github.com/HarrisonJackson/HJImagesToVideo When I compiled the sample code provided by him, it is working fine with Xcode 7.2 but when I am using this in my swift project it is not working and showing some errors on buffer = [HJImagesToVideo pixelBufferFromCGImage:[array[i] CGImage] size:CGSizeMake(480, 320)]; //line # 212 of HJImagesToVideo.m buffer = [HJImagesToVideo crossFadeImage:[array[i] CGImage] toImage:[array[i + 1] CGImage] atSize:CGSizeMake(480, 320) withAlpha:j/framesToFadeCount]; //line # 241 of HJImagesToVideo.m UISaveVideoAtPathToSavedPhotosAlbum(tempPath, self, nil, nil); //line # 150 of and the errors are: /Users/Raza/my apps/appname/app-name/HJImagesToVideo.m:213:64: No known instance method for selector 'CGImage' and /Users/Raza/my apps/appname/app-name/HJImagesToVideo.m:213:54: Implicit conversion of Objective-C pointer type 'id' to C pointer type 'CGImageRef' (aka 'struct CGImage *') requires a bridged cast on line # 213 and 241 and on line # 150 error is: Users/Raza/my apps/appname/app-name/HJImagesToVideo.m:150:28: Implicit declaration of function 'UISaveVideoAtPathToSavedPhotosAlbum' is invalid in C99 Can anyone can help me to figure out these problem? Thanks in advance A: UISaveVideoAtPathToSavedPhotosAlbum is defined in UIKit. Have you forgot to import UIKit ?
doc_23538996
This is the form: and this is the Model: public class Movie { public int Id { get; set; } [Required] [StringLength(255)] public string Name { get; set; } [Required] [Display(Name="Created on")] public DateTime DateAdded { get; set; } [Required] [Display(Name = "Release Date")] public DateTime ReleaseDate { get; set; } [Required] [Range(1,20)] [Display(Name = "Number in Stock")] public int NumberInStock { get; set; } public Genre Genre { get; set; } [Required] [Display(Name="Genre")] public int GenreId { get; set; } } a snippet of one property from the view looks like this: <div class="form-group"> @Html.LabelFor(m => m.Movie.DateAdded) @Html.TextBoxFor(m => m.Movie.DateAdded, "{0:d MMM yyyy}", new { @class = "form-control" }) @Html.ValidationMessageFor(m => m.Movie.DateAdded) </div> A: If you're fine with your model always being populated with a specific default value (so, not only in this view but wherever you create a new instance of your model), then DefaultValueAttribute is probably the best solution. e.g. [Required] [Display(Name = "Release Date")] [DefaultValue(typeof(DateTime), "2019-01-01 00:00:00")] public DateTime ReleaseDate { get; set; } More info on DefaultValueAttribute in MSDN.
doc_23538997
struct A { void f(); }; struct B : virtual A {}; struct C : virtual A {}; struct D : B, C {}; What can I say? that D has two different member functions B::A::f and C::B::f which are called over a same object? or they are just aliases of a same member function? For example, for the non-virtual case, struct A { void f(); }; struct B : A {}; struct C : A {}; struct D : B, C {}; D has two different member functions B::A::f and C::A::f because they just have different names, so, calling D().f() is an ambigüity because I have to specify to which member I want to call. However, in the virtual inhericante case, that isn't required anymore because calling by one path or another resolves to call the function over a same object, and I don't know anymore if, in the virtual inheritance case, I have two different member functions which resolves or are executed over a same object, or they are just aliases of a same member function. Anyway, from a practical point of view that difference doesn't matter, but from a more formal point of view I'm not sure about what to say. A: In the virtual inheritance case you have D::A::f() and no specific overridden versions in the two middle inheritance levels. D().B::A::f() works for the same reason that it works in this straightforward case (it inherits the parent version): struct A { void f(); }; struct B : A {}; struct D : B {};
doc_23538998
Ext.onReady(function(){ // create the Data Store var store = new Ext.data.JsonStore({ root: 'topics', totalProperty: 'totalCount', idProperty: 'threadid', remoteSort: true, fields: [ 'title', 'forumtitle', 'forumid', 'author', {name: 'replycount', type: 'int'}, {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'}, 'lastposter', 'excerpt' ], // load using script tags for cross domain, if the data in on the same domain as // this page, an HttpProxy would be better proxy: new Ext.data.ScriptTagProxy({ url: 'http://extjs.com/forum/topics-browse-remote.php' }) }); store.setDefaultSort('lastpost', 'desc'); // pluggable renders function renderTopic(value, p, record){ return String.format( '<b><a href="http://extjs.com/forum/showthread.php?t={2}" target="_blank">{0}</a></b><a href="http://extjs.com/forum/forumdisplay.php?f={3}" target="_blank">{1} Forum</a>', value, record.data.forumtitle, record.id, record.data.forumid); } function renderLast(value, p, r){ return String.format('{0}<br/>by {1}', value.dateFormat('M j, Y, g:i a'), r.data['lastposter']); } var grid = new Ext.grid.GridPanel({ width:700, height:500, title:'ExtJS.com - Browse Forums', store: store, trackMouseOver:false, disableSelection:true, loadMask: true, // grid columns columns:[{ id: 'topic', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 }) header: "Topic", dataIndex: 'title', width: 420, renderer: renderTopic, sortable: true },{ header: "Author", dataIndex: 'author', width: 100, hidden: true, sortable: true },{ header: "Replies", dataIndex: 'replycount', width: 70, align: 'right', sortable: true },{ id: 'last', header: "Last Post", dataIndex: 'lastpost', width: 150, renderer: renderLast, sortable: true }], // customize view config viewConfig: { forceFit:true, enableRowBody:true, showPreview:true, getRowClass : function(record, rowIndex, p, store){ if(this.showPreview){ p.body = '<p>'+record.data.excerpt+'</p>'; return 'x-grid3-row-expanded'; } return 'x-grid3-row-collapsed'; } }, // paging bar on the bottom bbar: new Ext.PagingToolbar({ pageSize: 25, store: store, displayInfo: true, displayMsg: 'Displaying topics {0} - {1} of {2}', emptyMsg: "No topics to display", items:[ '-', { pressed: true, enableToggle:true, text: 'Show Preview', cls: 'x-btn-text-icon details', toggleHandler: function(btn, pressed){ var view = grid.getView(); view.showPreview = pressed; view.refresh(); } }] }) }); // render it grid.render('topic-grid'); // trigger the data store load store.load({params:{start:0, limit:25}});}); Now, when I am including the normal ext-base.js and ext-all.js I am getting the error: b is null and when I include ext-base-debug.js and ext-all-debug.js I get the error: ct is null and on IE I am getting: Dom is null Has anybody faced the same problem and has any solution for it? A: Sounds like a DOM element is missing, and from the looks of it its in your render call: grid.render('topic-grid'); You can remove the 'topic-grid' parameter, or create a <div> element with that ID in your markup. A: b is null possibly, you will forget to use same id name used for div id and renderTo in panel. i.e <div id="ltGrid"/> and renderTo : 'ltGrid'
doc_23538999
e.g.: I have a file named "blablie rel blub.pdf" And I am searching for either rel or musik. If its rel it should go in the Religion folder and if its musik it should go in the Musik folder. Thats what I have: from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler import fnmatch import os import json import time class MyHandler(FileSystemEventHandler): i = 1 def on_modified(self, event): for file in os.listdir('.'): if fnmatch.filter(file, '[rel]'): for filename in os.listdir(folder_to_track): src = folder_to_track + "/" + filename new_destination = folder_destination + "/Religion/" + filename os.rename(src, new_destination) elif fnmatch.filter(file, '[musik]'): for filename in os.listdir(folder_to_track): src = folder_to_track + "/" + filename new_destination = folder_destination + "/Musik/" + filename os.rename(src, new_destination) folder_to_track = "/Users/Nils/Downloads/oldfold" folder_destination = "/Users/Nils/Downloads/newfold" event_handler = MyHandler() observer = Observer() observer.schedule(event_handler, folder_to_track, recursive=True) observer.start() try: while True: time.sleep(10) except KeyboardInterrupt: observer.stop() observer.join() A: [mus] matches one character which can be m, u, or s. Aren't you simply looking for this? if 'mus' in file: Though perhaps it could be slightly more specific, like perhaps if ' mus ' in file: with spaces on both sides, if your example is representative.