title
stringlengths 15
150
| body
stringlengths 38
32.9k
| label
int64 0
3
|
---|---|---|
FCM: Message to multiple registration ids limit? | <p>As per this quote I found:</p>
<blockquote>
<ul>
<li><strong>registration_ids</strong> – Type String array – (Optional) [Recipients of a message]
Multiple registration tokens, min 1 max 1000.</li>
</ul>
</blockquote>
<p>Is this the actual limit of device tokens I can send a single message to? And do messages to topics have the same limit?</p>
<p>ex: </p>
<pre><code>{
"to": [reg_token_01, reg_token_02, ..., reg_token_1000],
"priority": "high",
"data": {
"title": "Hi Peeps!",
"message": "This is a special message for only for you... More details are available..."
}
}
</code></pre>
<p>As always, thanks for the info and direction!</p> | 0 |
How to send and receive custom data with AirDrop | <p>I've been struggling with this for ages now as I can't find any detailed examples.</p>
<p>In my app I have an array of custom data that I want to send to another user with the same app, via AirDrop.</p>
<p>The first step is sending the data:</p>
<pre><code>@IBAction func share_Button_Click(sender: UIBarButtonItem)
{
let dataToShare: NSData = getMyCustomNSData()
let controller = UIActivityViewController(activityItems: [dataToShare], applicationActivities: nil)
controller.excludedActivityTypes = [UIActivityTypePostToFacebook, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypePostToFlickr, UIActivityTypePostToTencentWeibo, UIActivityTypeMail, UIActivityTypeAddToReadingList, UIActivityTypeOpenInIBooks, UIActivityTypeMessage]
self.presentViewController(controller, animated: true, completion: nil)
}
</code></pre>
<p>This converts my data to an NSData object, the user gets the AirDrop share option, and of the data goes to another phone. So far so good...</p>
<p>But how does the other user's app know how to receive it?</p>
<p>I've read about custom UTI types and have declared one, but to be honest I don't know what to put in the declaration. And how do you indicate to iOS that the data you are sending conforms to this particular UTI?</p>
<p>There are AirDrop examples here and there online, but they focus on sharing common types like images, and no one I have found has worked through sharing a custom data type in detail.</p>
<p>Can anyone help?</p> | 0 |
Move button when keyboard appears swift | <p>In a UIViewController I have several text fields and a button is on the bottom of the UIViewController.
For the button, I have set a bottom constraint with a constant of 0.
Then I made an outlet from the bottom constraint to the UIViewController. </p>
<p>When I run my code, the button does not move upwards. I have seen suggestions on stackoverflow that I should add UIScrollView, but that means, I would have to delete all the objects on the UIViewController, put the UIScrollView and then put my objects on the UIVIewController again. </p>
<pre><code>@IBOutlet weak var bottomConstraint: NSLayoutConstraint!
// When tapping outside of the keyboard, close the keyboard down
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
self.view.endEditing(true)
}
// Stop Editing on Return Key Tap. textField parameter refers to any textfield within the view
func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
// When keyboard is about to show assign the height of the keyboard to bottomConstraint.constant of our button so that it will move up
func keyboardWillShow(notification: NSNotification) {
if let userInfo = notification.userInfo {
if let keyboardSize: CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
bottomConstraint.constant = keyboardSize.size.height
view.setNeedsLayout()
}
}
}
// When keyboard is hidden, move the button to the bottom of the view
func keyboardWillHide(notification: NSNotification) {
bottomConstraint.constant = 0.0
view.setNeedsLayout()
}
</code></pre>
<p><a href="https://i.stack.imgur.com/qIWcR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qIWcR.png" alt="enter image description here"></a></p> | 0 |
Comparison operator in PySpark (not equal/ !=) | <p>I am trying to obtain all rows in a dataframe where two flags are set to '1' and subsequently all those that where only one of two is set to '1' and the other <strong>NOT EQUAL</strong> to '1'</p>
<p>With the following schema (three columns),</p>
<pre><code>df = sqlContext.createDataFrame([('a',1,'null'),('b',1,1),('c',1,'null'),('d','null',1),('e',1,1)], #,('f',1,'NaN'),('g','bla',1)],
schema=('id', 'foo', 'bar')
)
</code></pre>
<p>I obtain the following dataframe:</p>
<pre><code>+---+----+----+
| id| foo| bar|
+---+----+----+
| a| 1|null|
| b| 1| 1|
| c| 1|null|
| d|null| 1|
| e| 1| 1|
+---+----+----+
</code></pre>
<p>When I apply the desired filters, the first filter (foo=1 AND bar=1) works, but not the other (foo=1 AND NOT bar=1)</p>
<pre><code>foobar_df = df.filter( (df.foo==1) & (df.bar==1) )
</code></pre>
<p>yields:</p>
<pre><code>+---+---+---+
| id|foo|bar|
+---+---+---+
| b| 1| 1|
| e| 1| 1|
+---+---+---+
</code></pre>
<p><strong>Here is the non-behaving filter:</strong></p>
<pre><code>foo_df = df.filter( (df.foo==1) & (df.bar!=1) )
foo_df.show()
+---+---+---+
| id|foo|bar|
+---+---+---+
+---+---+---+
</code></pre>
<p>Why is it not filtering? How can I get the columns where only foo is equal to '1'?</p> | 0 |
Max-width not breaking single words, exceeding max-width | <p>When using <code>max-width</code> why won't it "break" words that are longer than allowed and how would I go about making it work?</p>
<p><strong><a href="https://jsfiddle.net/rfo7y3om/3/" rel="noreferrer">JSFiddle</a></strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function input() {
var inputText = document.getElementById("inputField").value;
document.getElementById("changingParagraph").innerHTML = inputText;
}</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#changingParagraph {
max-width: 100px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="text" id="inputField" oninput="input()">
<p id="changingParagraph">
</p></code></pre>
</div>
</div>
</p> | 0 |
JS - Get top 5 max elements from array | <p>How can I get top 5 max elements from array of ints with the standard library of es2015? Thanks for help.</p> | 0 |
Java - Access-Control-Allow-Origin Multiple Origin Domains? | <p>So I have read through the other threads regarding this and have not found a solution.</p>
<p>The problem Im having is because im setting "access-control-allow-methods" "true" I cant use <code>setHeader("Access-Control-Allow-Origin", "*");</code></p>
<p>I need to set two specific domains...any help is appreciated. </p> | 0 |
Angular2: Error: unexpected value 'AppComponent' declared by the module 'AppModule' | <p>I'm working through the tutorial at <a href="https://angular.io/docs/ts/latest/tutorial/toh-pt2.html">https://angular.io/docs/ts/latest/tutorial/toh-pt2.html</a> and get the following error after creating the array of heroes:</p>
<pre><code>Error: Error: Unexpected value 'AppComponent' declared by the module 'AppModule'
at new BaseException (localhost:3000/node_modules/@angular/compiler//bundles/compiler.umd.js:5116:27)
at eval (localhost:3000/node_modules/@angular/compiler//bundles/compiler.umd.js:13274:35)
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (localhost:3000/node_modules/@angular/compiler//bundles/compiler.umd.js:13261:53)
at RuntimeCompiler._compileComponents (localhost:3000/node_modules/@angular/compiler//bundles/compiler.umd.js:15845:51)
at RuntimeCompiler._compileModuleAndComponents (localhost:3000/node_modules/@angular/compiler//bundles/compiler.umd.js:15769:41)
at RuntimeCompiler.compileModuleAsync (localhost:3000/node_modules/@angular/compiler//bundles/compiler.umd.js:15746:25)
at PlatformRef_._bootstrapModuleWithZone (localhost:3000/node_modules/@angular/core//bundles/core.umd.js:9991:29)
at PlatformRef_.bootstrapModule (localhost:3000/node_modules/@angular/core//bundles/core.umd.js:9984:25)
at Object.eval (localhost:3000/app/main.js:4:53)
Evaluating localhost:3000/app/main.js
Error loading localhost:3000/app/main.js
</code></pre>
<p>My app.module.ts file at this point is:</p>
<pre><code>import { NgModule } from '@angular/core';
import { BrowserModule }from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, FormsModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule {}
</code></pre>
<p>My app.components.ts file at this point is:</p>
<pre><code>import { Component } from '@angular/core';
export class Hero {
id: number;
name: string;
}
@Component ({
selector: 'my-app',
template: `
<h1>{{title}}</h1>
<h2>My Heroes</h2>
<ul class="heroes">
<li *ngFor="let hero of heroes">
<span class="badge">{{hero.id}}</span> {{hero.name}}
</li>
</ul>
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name">
</div>
`
})
const HEROES: Hero[] = [
{ id: 11, name: 'Mr. Nice' },
{ id: 12, name: 'Narco' },
{ id: 13, name: 'Bombasto' },
{ id: 14, name: 'Celeritas' },
{ id: 15, name: 'Magneta' },
{ id: 16, name: 'RubberMan' },
{ id: 17, name: 'Dynama' },
{ id: 18, name: 'Dr IQ' },
{ id: 19, name: 'Magma' },
{ id: 20, name: 'Tornado' }
];
export class AppComponent {
title = 'Tour or Heroes';
heroes = HEROES;
}
</code></pre>
<p>Everything was working up to this point. New to Angular and not sure how to debug this.</p>
<p>Edit:</p>
<p>The error occurs in (index) at:</p>
<pre><code> <!-- 2. Configure SystemJS -->
<script src = "systemjs.config.js"></script>
<script>
System.import('app').catch(function(err) {
console.error(err);
});
</script>
</head>
</code></pre>
<p>Thanks,</p> | 0 |
'create-react-app' is not recognized as an internal or external command | <p>I am trying to set up react app using create-react-app command on windows pc. I already used it on my mac computer, and it works well. But I encounter a problem. Here my steps on command line. Am i missing something?</p>
<pre><code>C:\Windows\system32>cd C:\Users\ugur\Desktop\deneme
C:\Users\ugur\Desktop\deneme>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See 'npm help json' for definitive documentation on these fields
and exactly what they do.
Use 'npm install <pkg> --save' afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
name: (deneme)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
license: (ISC)
About to write to C:\Users\ugur\Desktop\deneme\package.json:
{
"name": "deneme",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Ugur <[email protected]> (http://www.abc.com.tr)",
"license": "ISC"
}
Is this ok? (yes)
C:\Users\ugur\Desktop\deneme>npm install -g create-react-app
C:\Users\ugur\AppData\Roaming\npm\create-react-app -> C:\Users\ugur\
AppData\Roaming\npm\node_modules\create-react-app\index.js
C:\Users\ugur\AppData\Roaming\npm
`-- [email protected]
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| `-- [email protected]
+-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| `-- [email protected]
| `-- [email protected]
+-- [email protected]
`-- [email protected]
C:\Users\ugur\Desktop\deneme>create-react-app new_app
'create-react-app' is not recognized as an internal or external command, operable program or batch file.
</code></pre>
<p>Also npm configuration path is like</p>
<p>C:\Users\ugur\AppData\Roaming\npm\node_modules\create-react-app\</p> | 0 |
Using position: relative inside a flex container | <p>I am making preview of post like its text and image as a background with some filters.</p>
<p>The problem is that I want to have the whole div not <code>1300px</code>, but only <code>650px</code>.</p>
<p>However, this way I will not be able to use <code>display: flex</code> and will not have div with img the same height as the div with text.</p>
<p>Is there any possible way to solve this problem only with css (without js)? </p>
<p>Here is the code: <a href="http://codepen.io/anon/pen/RGwOgN?editors=1111" rel="noreferrer">http://codepen.io/anon/pen/RGwOgN?editors=1111</a></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.post {
width: 650px;
padding: 25px 25px;
z-index: 10;
position: relative;
color: white;
}
.flex-row {
display: flex;
width: 1300px; /* here is a problem */
}
.back-img {
width: 650px;
background-size: cover;
position: relative;
z-index: 0;
left: -650px;
filter: blur(3px);
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-o-filter: blur(3px);
-ms-filter: blur(3px);
filter: url(#blur);
overflow: hidden;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="flex-row">
<div class="post">
<h1>Lorem ipsum</h1>
<h2>text here</h2>
<p class="lead">text hete</p>
</div>
<div class="back-img" style="background-image: linear-gradient(
rgba(0, 0, 0, 0.3),
rgba(0, 0, 0, 0.3)
),url(http://unsplash.com/photos/g-AklIvI1aI/download)">
<div></div>
</div>
</div></code></pre>
</div>
</div>
</p>
<p>So as you see it works fine, but only if parent element (<code>flex-row</code>) is set to size*2, because another way the size of children elements will be automatically reduced.</p> | 0 |
[Docker]: Connecting PHPMyAdmin to MySQL doesnt work | <p>I'm trying to connect a PHPMyAdmin-Container to a MySQL-Container to view the databases.</p>
<p>I have started the MySQL container via <code>$ docker run --name databaseContainer -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql</code> </p>
<p>and the PHPMyAdmin-Container via <code>$ docker run --name myadmin -d --link databaseContainer:mysql -p 8080:8080 phpmyadmin/phpmyadmin</code></p>
<p>When trying to login on PHPMyAdmin, I get:
mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name does not resolve</p>
<p>and</p>
<p>mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name does not resolve</p>
<p>By the way, I have also started a wordpress container and also linked it to mysql, there it works...</p> | 0 |
Setting the value of an Access combobox with VBA comparison | <p>I'm trying to figure out where I went wrong with this.</p>
<p>I have two tables <code>Request</code> and <code>Parent</code>. <code>Request</code> can only have one related <code>Parent</code> record, but <code>Parent</code> can have many related <code>Request</code> records. So I have the <code>Request</code> table containing the foreign key to <code>Parent</code>.</p>
<p>I have an unbound combobox that pulls it's data from the <code>Parent</code> table using a query (contains company name and ID bound to column 0 and 1, with column 1 being hidden so the user doesn't see the numeric ID). It's unbound because the form's recordset has a lot of complex joins, making anything on that form unable to be updated. So I created an "On Change" event on the combo box to fill in the foreign key using a querydef SQL update query:</p>
<pre><code>Private Sub Combo217_Change()
Dim ComboID As String
Dim ReqID As Long
Dim dbs As DAO.Database
Dim qdfUpdateParentExisting As DAO.QueryDef
ReqID = Me.RequestID.Value
ComboID = Me.Combo217.Column(1)
Set dbs = CurrentDb
Set qdfUpdateParentExisting = dbs.QueryDefs("UpdateReqExistingParent")
qdfUpdateParentExisting.Parameters("VBParent").Value = ComboID
qdfUpdateParentExisting.Parameters("VBReqID").Value = ReqID
qdfUpdateParentExisting.Execute
qdfUpdateParentExisting.Close
DoCmd.Save acForm, "DT2"
Me.Requery
End Sub
</code></pre>
<p>This works just fine, but once you exit the form and re-enter it, the value in the combo box is blank and I would like this to contain the same value that was selected.</p>
<p>I've been trying to do an "On load event" with the following code but it's not working</p>
<pre><code>Dim ParID
ParID = Me.ParentID.Value
Me.Combo217.Column(1).Value = ParID
</code></pre>
<p>Any input on getting this to work would be fantastic!</p> | 0 |
How to set heap size in spark within the Eclipse environment? | <p>I am trying to run the simple following code using spark within Eclipse:</p>
<pre class="lang-java prettyprint-override"><code>import org.apache.spark.sql.SQLContext
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
object jsonreader {
def main(args: Array[String]): Unit = {
println("Hello, world!")
val conf = new SparkConf()
.setAppName("TestJsonReader")
.setMaster("local")
.set("spark.driver.memory", "3g")
val sc = new SparkContext(conf)
val sqlContext = new SQLContext(sc)
val df = sqlContext.read.format("json").load("text.json")
df.printSchema()
df.show
}
}
</code></pre>
<p>However, I get the following errors:</p>
<pre><code>16/08/18 18:05:28 ERROR SparkContext: Error initializing SparkContext.
java.lang.IllegalArgumentException: System memory 259522560 must be at least 471859200. Please increase heap size using the --driver-memory option or spark.driver.memory in Spark configuration.
</code></pre>
<p>I followed different tutorials like this one: <a href="https://stackoverflow.com/questions/26562033/how-to-set-apache-spark-executor-memory">How to set Apache Spark Executor memory</a>. Most of time either I use <code>--driver-memory</code> option (not possible with Eclipse) or by modifiying the spark configuration but there is no corresponding file.</p>
<p>Does anyone have any idea about how to solve this issue within Eclipse environment?</p> | 0 |
How to escape @ in a password in pymongo connection? | <p>My question is a specification of <a href="https://stackoverflow.com/questions/29508162/how-can-i-validate-username-password-for-mongodb-authentication-through-pymongo">how can i validate username password for mongodb authentication through pymongo?</a>.</p>
<p>I'm trying to connect to a MongoDB instance using PyMongo 3.2.2 and a URL that contains the user and password, as explained in <a href="https://docs.mongodb.com/manual/reference/connection-string/#standard-connection-string-format" rel="noreferrer">MongoDB Docs</a>. The difference is that the password I'm using contains a '@'.</p>
<p>At first I simply tried to connect without escaping, like this:</p>
<blockquote>
<p>prefix = 'mongodb://'</p>
<p>user = 'user:passw_with_@_'</p>
<p>suffix = '@127.0.0.1:27001/'</p>
<p>conn = pymongo.MongoClient(prefix + user + suffix)</p>
</blockquote>
<p>Naturally I got the following error:</p>
<pre><code>InvalidURI: ':' or '@' characters in a username or password must be escaped according to RFC 2396.
</code></pre>
<p>So I tried escaping the user:pass part using <a href="https://docs.python.org/2/library/urllib.html?highlight=urllib#urllib.quote" rel="noreferrer">urllib.quote()</a> like this:</p>
<blockquote>
<p>prefix = 'mongodb://'</p>
<p>user = urllib.quote('user:passw_with_@_')</p>
<p>suffix = '@127.0.0.1:27001/'</p>
<p>conn = pymongo.MongoClient(prefix + user + suffix)</p>
</blockquote>
<p>but then I got a:</p>
<pre><code>OperationFailure: Authentication failed.
</code></pre>
<p>(Important to say that using a GUI MongoDB Management Tool (<a href="https://robomongo.org/" rel="noreferrer">Robomongo</a>, if that matters) I'm able to connect to the MongoDB using the (real) address and credentials.)</p>
<p>Printing user variable in the code above generated a <code>'user:passw_with_%40_'</code> String (that is '@' became '%40') and according to <a href="https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters" rel="noreferrer">wikipedia</a> that's the expected escaping.</p>
<p>I even tried escaping the @ with single and double backslashes (<code>user = 'user:passw_with_\\@_'</code> and <code>user = 'user:passw_with_\@_'</code>), but those failed with the InvalidURI exception.</p>
<p><strong>TL;DR;</strong></p>
<p>My question is: How do I escape a '@' in the password part of a MongoDB URL?</p> | 0 |
mongodb aggregate with $group and $lookup | <p>I'm trying to perform a "group by" on a table and "join" it with another table.
Corresponding SQL statement would be:</p>
<pre><code>SELECT T1.total, T1.email, T1.type, table_2.name FROM
(SELECT SUM(amount) AS total, email, type
FROM table_1
GROUP BY email, type) T1
INNER JOIN table_2
on T1.email = table_2.email
</code></pre>
<p>But since mongodb still doesn't have inner join feature, I tried to use "$lookup" and do the task. here's my code:</p>
<pre><code>db.table_1.aggregate([
{$group : {_id : {email: "$email", type:"$type"},total: { $sum: "$amount" }}},
{$lookup: {from: "table_2", localField: "email", foreignField: "email", as: "details"}} ]);
</code></pre>
<p>But in the results I'm getting, details returns and empty object:</p>
<pre><code>{ "_id" : { "user" : "[email protected]", "type" : "Car" }, "total" : 2, "details" : [ ] }
{ "_id" : { "user" : "[email protected]", "type" : "Bike" }, "total" : 3, "details" : [ ] }
{ "_id" : { "user" : "[email protected]", "type" : "Car" }, "total" : 1, "details" : [ ] }
</code></pre>
<p>But if I run the query without using $group, it works fine. So I'm wondering whether the $group and $lookup functions cannot be used together. If so is there a work-around or what would be the optimal way to get the query done?</p>
<p>[mongo db version I'm using: > db.version() 3.2.7]</p> | 0 |
Deploy Angular 2 App with Webpack to Tomcat - 404 Errors | <p>I want to build and deploy my Angular 2 front end to a Tomcat application server. For getting started I've followed exactly the steps of the following introduction: <a href="https://angular.io/docs/ts/latest/guide/webpack.html">https://angular.io/docs/ts/latest/guide/webpack.html</a>.</p>
<p>So I have the following project structure (all files are exactly as in the introduction mentionend above):</p>
<p>angular2-webpack<br>
---config<br>
-------helpers.js<br>
-------karma.conf.js<br>
-------karma-test-shim.js<br>
-------webpack.common.js<br>
-------webpack.dev.js<br>
-------webpack.prod.js<br>
-------webpack.test.js<br>
---dist<br>
---node_modules<br>
---public<br>
-------css<br>
--------------styles.css<br>
-------images<br>
--------------angular.png<br>
---src<br>
-------app<br>
--------------app.component.css<br>
--------------app.component.html<br>
--------------app.component.spec.ts<br>
--------------app.component.ts<br>
--------------app.module.ts<br>
-------index.html<br>
-------main.ts<br>
-------polyfills.ts<br>
-------vendor.ts<br>
---typings<br>
---karma.conf.js<br>
---package.json<br>
---tsconfig.json<br>
---typings.json<br>
---webpack.config.js</p>
<p><strong>npm start</strong> respectively <code>webpack-dev-server --inline --progress --port 3000</code> on the console or in Webstorm →works as expected</p>
<p>When I run <strong>npm build</strong> respectively <code>rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail</code> it builds the app without errors and the output bundle files get physically placed in the dist folder as expected.</p>
<p>dist<br>
---assets<br>
-------angular.png<br>
---app.css<br>
---app.css.map<br>
---app.js<br>
---app.js.map<br>
---index.html<br>
---polyfills.js<br>
---polyfills.js.map<br>
---vendor.js<br>
---vendor.js.map<br></p>
<p>Next I copied the content of the dist folder to the webapps directory of a Tomcat 9.0. When I try to access the installed app I get an 404 error for the .css- and .js-files (<a href="http://i.stack.imgur.com/twslK.png">which can be seen in the attached picture</a>).
It tries to get the files from the wrong URLs →"/obv/" is missing.</p>
<p>I'm really stuck here and I have the feeling that I've tried already everything I could find in the Internet regarding this topic. </p>
<p>Could someone please tell me what I'm doing wrong? Thank you in advance.</p> | 0 |
Slick.js center mode for 3 slides with navigation | <p>Is it possible to just have 3 slides on a Slick.js carousel with navigation so essentially the middle slide becomes larger.</p>
<p>I've setup a codepen showing first how more than 3 slides operates but when you only have 3 slides, Slick.js removes the navigation and it no longer works.</p>
<p><a href="http://codepen.io/mellomedia/pen/GqLjjX" rel="nofollow">http://codepen.io/mellomedia/pen/GqLjjX</a></p>
<pre><code>$(document).on('ready', function() {
$(".center").slick({
dots: true,
infinite: true,
centerMode: true,
slidesToShow: 3,
slidesToScroll: 3
});
});
</code></pre> | 0 |
SONAR complaining about Make the enclosing method "static" or remove this set | <p>I have the following piece of code in my program and I am running SonarQube 5 for code quality check on it after integrating it with Maven.</p>
<p>However, Sonar is asking to Make the enclosing method "static" or remove this set. the method is setApplicationContext. </p>
<p>How to remove this error? Why this error is coming?</p>
<pre><code>public class SharedContext implements ApplicationContextAware {
public static final String REPORT_ENGINE_FACTORY = "reportEngineFactory";
private static ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
SharedContext.applicationContext = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
public Object getBean(String name) {
return applicationContext.getBean(name);
} }
</code></pre> | 0 |
PHP - Type hint for Laravel Collection or Array | <p>I would like to create a function which accepts any traversable object as parameter, for example Laravel Collection/Array. Is there any way to type hint this condition in the function parameter??</p>
<p>I want the effect of both the following in single definition:</p>
<pre><code>function test(array $traversable)
{
print_r($traversable);
}
</code></pre>
<p>AND</p>
<pre><code>function test(Illuminate\Support\Collection $traversable)
{
print_r($traversable);
}
</code></pre>
<p>AND the DocBlock should be</p>
<pre><code>/**
* Function to do something
*
* @param Collection|Array $traversable Traversable parameter
* @return null Absolutely nothing
*/
</code></pre> | 0 |
How to create object for a struct in golang | <p><em>File1.go</em></p>
<pre><code>Package abc
type ECA struct {
*CA
obcKey []byte
obcPriv, obcPub []byte
gRPCServer *grpc.Server
}
type ECAP struct {
eca *ECA
}
func (ecap *ECAP) ReadCACertificate(ctx context.Context, in *pb.Empty) (*pb.Cert, error) {
Trace.Println("gRPC ECAP:ReadCACertificate")
return &pb.Cert{Cert: ecap.eca.raw}, nil
}
</code></pre>
<p><em>File2.go</em></p>
<pre><code>package main
import "abc"
var ecap abc.ECAP //creating instance
func main() {
err = ecap.ReadCACertificate(floo,floo)
}
</code></pre>
<p>I am a newbie. I want to create instance of ECAP struct and call ReadCACertificate method. Right now i am creating like this "var ecap abc.ECAP //creating instance" which is giving "nil" and nil pointer error.</p>
<p>Can anyone help how to call the ReadCACertificate method in efficient way.</p>
<p>Thanks in advance.</p> | 0 |
What is the equivalent of np.std() in TensorFlow? | <p>Just looking for the equivalent of np.std() in TensorFlow to calculate the standard deviation of a tensor.</p> | 0 |
Ajax post with ASP.NET Webforms | <p>I want to post data to server with ajax call but i am getting an error.</p>
<pre><code> var userdata = {};
userdata["Name"] = "Saran";
var DTO = { 'userdata': userdata };
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/update",
data: JSON.stringify(DTO),
datatype: "json",
success: function (result) {
//do something
alert("SUCCESS = " + result);
console.log(result);
},
error: function (xmlhttprequest, textstatus, errorthrown) {
alert(" conection to the server failed ");
console.log("error: " + errorthrown);
}
});//end of $.ajax()
</code></pre>
<p>I have created a function in Default.aspx.cs and tried to access that function with the above call.</p>
<pre><code> [WebMethod]
public static string update(string userdata)
{
return "Posted";
}
</code></pre>
<p>Error :</p>
<blockquote>
<pre><code>POST http://localhost:33762/Default.aspx/update 401 Unauthorized 52ms
</code></pre>
<p>Message "Authentication failed." StackTrace null ExceptionType<br>
"System.InvalidOperationException"</p>
</blockquote> | 0 |
fold/unfold selection only in Notepad++ | <p>Notepad++ has commands to fold/unfold all the document. Is that possible to select some of the lines and fold/unfold only the blocks lying inside the selection?</p>
<h1>EDIT1</h1>
<p>Any notepad++ plugin which enables this capability?</p> | 0 |
Last margin / padding collapsing in flexbox / grid layout | <p>I have a list of items that I'm trying to arrange into a scrollable horizontal layout with flexbox.</p>
<p>Each item in the container has a margin left and right, but the right margin of the last item is being collapsed.</p>
<p>Is there a way to stop this happening, or a good workaround?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>ul {
list-style-type: none;
padding: 0;
margin: 0;
display: flex;
height: 300px;
overflow: auto;
width: 600px;
background: orange;
}
ul li {
background: blue;
color: #fff;
padding: 90px;
margin: 0 30px;
white-space: nowrap;
flex-basis: auto;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>
</div></code></pre>
</div>
</div>
</p> | 0 |
How should I calculate Ramp-up time in Jmeter | <p>There are many questions/answers available here to understand <code>Ramp up time</code> but I want to get something in detail for my test case.</p>
<p><strong>Test Case</strong> : Expecting 1200 users per 5 minutes on the home page. So it will be like 5 users/second.</p>
<p>I have set following <code>thread properties</code> :</p>
<pre><code>No. of Threads : 1200
Ramp-up Time - ? [I am not sure what to set]
Loop count - Forever
Scheduler - 300 Seconds[5 Minutes]
</code></pre>
<p>Can anyone please help me to set <code>ramp up time</code> for my test case? I am running the test on my local machine.</p>
<p>I want to check that how many users server can handle in 5 minutes. Our expectation is <code>1200 users</code>.</p> | 0 |
Does renewing SSL certificate require re-issuing the cert? | <p>I have an SSL certificate that I am using to secure port 443 (HTTPS) on my nginx server running on Ubuntu for about 10 months now.</p>
<p>When I bought the cert, I got it for one year, so I have about 2 more months with this certificate.
My question is: "When I renew this cert, Will I just need to pay for renewal? or will I have to re-issue the cert with a new CSR, and have a potential downtime while installing?</p>
<p>I need to plan for any downtime from now.</p>
<p>Thanks in advance for your answers.</p> | 0 |
how to rerender a component when hash change and change the state | <p>I want to monitor hash change and then change the state and rerender the component. so I want to know where to monitor the hash change in component lifecycle</p>
<p>example:</p>
<pre><code>#/detail/:id => #/detail
{info:[a:1,b:2]} => {info:[]}
</code></pre>
<p>.#/detail/:id and #/detail are the same components</p> | 0 |
Adjusting QML Image display size | <p>I have a QML window with a nested <code>RowLayout</code>. In the inner row I have two images. The source <code>.png</code> files for these images are (intentionally) rather large. When I attempt to set the <code>height</code> property on these images to make them smaller, they are still drawn large.</p>
<p><strong>Desired Appearance</strong>:<br>
<a href="https://i.stack.imgur.com/m8fjF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/m8fjF.png" alt="Two images side-by-side, taking up 1/3 of the window height"></a></p>
<p><strong>Actual Appearance</strong>:<br>
<a href="https://i.stack.imgur.com/oiUlf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oiUlf.png" alt="Two images side-by-side, far larger than their desired size"></a></p>
<p>The only way I have been able to get them to be small is to set the <code>sourceSize.height:100</code> instead of <code>height:100</code>; however, this is not what I want. I want them to be able to scale up and down without reloading.</p>
<p>How can I fix my QML so that the images take on the height of their containing <code>RowLayout</code>?</p>
<pre class="lang-qml prettyprint-override"><code>import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
width:600; height:300
visible:true
Rectangle {
color:'red'
anchors { top:header.bottom; bottom:footer.top; left:parent.left; right:parent.right }
}
header:RowLayout {
id:header
spacing:0
height:100; width:parent.width
RowLayout {
id:playcontrol
Layout.minimumWidth:200; Layout.maximumWidth:200; Layout.preferredWidth:200
height:parent.height
Image {
// I really want these to take on the height of their row
source:'qrc:/img/play.png'
width:100; height:100
fillMode:Image.PreserveAspectFit; clip:true
}
Image {
source:'qrc:/img/skip.png'
width:100; height:100
fillMode:Image.PreserveAspectFit; clip:true
}
}
Rectangle {
color:'#80CC00CC'
Layout.minimumWidth:200
Layout.preferredWidth:parent.width*0.7
Layout.fillWidth:true; Layout.fillHeight:true
height:parent.height
}
}
footer:Rectangle { height:100; color:'blue' }
}
</code></pre> | 0 |
How to display html formatted text in unity new ui Text? | <p>How could i display html formatted text to unity's new ui Text?</p>
<p>Ex.</p>
<pre><code><p>This is some <b><font size="3" color="red">Text</b></p>
</code></pre> | 0 |
List VMs and their cluster | <p>I'd like to be connected to multiple VIservers and list all the VMs + their respective clusters. Is this possible?</p>
<p>I've gotten as far as <code>Get-VM | Select Name,VMHost</code>. What property in place of VMHost would list the cluster?</p> | 0 |
Using RewriteCond with %{REQUEST_URI} for mod_rewrite | <p>I would like the URL:</p>
<pre><code>http://domain.com/category/subcategory/title
</code></pre>
<p>To point to:</p>
<pre><code>http://domain.com/posts/category/subcategory/title.php
</code></pre>
<p>My .htaccess file looks like this:</p>
<pre><code>RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} !^.+
#RewriteCond post/%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ post/$1.php [L]
</code></pre>
<p>This works however when I uncomment the line above it does not work.</p>
<p>I have tried:</p>
<pre><code>RewriteCond /post/%{REQUEST_URI}.php -f
RewriteCond post/%{REQUEST_URI}.php -f
RewriteCond post%{REQUEST_URI}.php -f
</code></pre>
<p>None of these work. What am I doing wrong?</p>
<p>Also is there an easy way to debug these rules? Like console logging variables or something?</p> | 0 |
Storing injector instance for use in components | <p>Before RC5 I was using appref injector as a service locator like this:</p>
<p>Startup.ts</p>
<pre><code>bootstrap(...)
.then((appRef: any) => {
ServiceLocator.injector = appRef.injector;
});
</code></pre>
<p>ServiceLocator.ts</p>
<pre><code>export class ServiceLocator {
static injector: Injector;
}
</code></pre>
<p>components:</p>
<pre><code>let myServiceInstance = <MyService>ServiceLocator.injector.get(MyService)
</code></pre>
<p>Now doing the same in bootstrapModule().then() doesn't work because components seems to start to execute before the promise. </p>
<p>Is there a way to store the injector instance before components load?</p>
<p>I don't want to use constructor injection because I'm using the injector in a base component which derived by many components and I rather not inject the injector to all of them.</p> | 0 |
What's the difference between """ and ''' in terms of running a shell script within a Jenkins pipeline step? | <p>In Jenkins pipeline, what's the difference between:</p>
<pre><code>sh """
...
...
...
"""
</code></pre>
<p>and</p>
<pre><code>sh '''
...
...
...
'''
</code></pre>
<p>Thanks in advance</p> | 0 |
How to import fonts to Notepad++? | <p>I use Notepad++ to write websites and I'm using the "consolas" font, but I would like to use "inconsolata" which is not available in the Style Configurator (version 6.9.2). Is there a way to import a font to Notepad++?</p> | 0 |
Error Creating Bean in Spring, dependency is declared in pom, spring cannot find class | <p>I am trying to Inject a rest client into a class, but for some reason spring is failing to create the bean. </p>
<p>First off all, I have the dependency declared in my POM.XML, and the project builds fine:</p>
<pre><code> <dependency>
<groupId>com.company</groupId>
<artifactId>event-service-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</code></pre>
<p>But when spring tries to run, and create the bean I've declared in dispatcher-servlet.xml: </p>
<pre><code><bean id="eventClient" class="com.company.client.EventServiceRestClient">
<constructor-arg type="java.lang.String" value="http://localhost:9353"/>
<constructor-arg type="java.lang.String" value="v1"/>
</bean>
</code></pre>
<p>I get the following stack of errors: </p>
<pre><code>Aug 31, 2016 1:59:41 PM org.springframework.web.servlet.DispatcherServlet initServletBean
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'auditLogController' defined in file [/Users/tshibley/spog/spog/target/classes/com/company/controller/AuditLogController.class]: Post-processing failed of bean type [class com.company.controller.AuditLogController] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.company.controller.AuditLogController] for resource metadata: could not find class that it depends on
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:940)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Failed to introspect bean class [com.company.controller.AuditLogController] for resource metadata: could not find class that it depends on
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:334)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:935)
... 28 more
Caused by: java.lang.NoClassDefFoundError: Lcom/company/client/EventServiceRestClient;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:710)
at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:652)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:351)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:330)
... 30 more
Caused by: java.lang.ClassNotFoundException: com.company.client.EventServiceRestClient
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 37 more
Aug 31, 2016 1:59:41 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'auditLogController' defined in file [/Users/tshibley/PS/spog/spog/target/classes/com/company/controller/AuditLogController.class]: Post-processing failed of bean type [class com.company.controller.AuditLogController] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.company.controller.AuditLogController] for resource metadata: could not find class that it depends on
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:940)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Failed to introspect bean class [com.company.controller.AuditLogController] for resource metadata: could not find class that it depends on
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:334)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:935)
... 28 more
Caused by: java.lang.NoClassDefFoundError: Lcom/company/client/EventServiceRestClient;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:710)
at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:652)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:351)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:330)
... 30 more
Caused by: java.lang.ClassNotFoundException: com.company.client.EventServiceRestClient
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 37 more
Aug 31, 2016 1:59:41 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet threw load() exception
java.lang.ClassNotFoundException: com.company.client.EventServiceRestClient
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:710)
at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:652)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:351)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:330)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:935)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
</code></pre> | 0 |
XlsxWriter: set_column() with one format for multiple non-continuous columns | <p>I want to write my Pandas dataframe to Excel and apply a format to multiple individual columns (e.g., A and C but not B) using a one-liner as such:</p>
<pre><code>writer = pd.ExcelWriter(filepath, engine='xlsxwriter')
my_format = writer.book.add_format({'num_format': '#'})
writer.sheets['Sheet1'].set_column('A:A,C:C', 15, my_format)
</code></pre>
<p>This results in the following error:</p>
<blockquote>
<p>File ".../python2.7/site-packages/xlsxwriter/worksheet.py", line 114, in column_wrapper</p>
<p>cell_1, cell_2 = [col + '1' for col in args[0].split(':')]
ValueError: too many values to unpack</p>
</blockquote>
<p>It doesn't accept the syntax <code>'A:A,C:C'</code>. Is it even possible to apply the same formatting without calling <code>set_column()</code> for each column?</p> | 0 |
Specify an array of strings as body parameter in swagger API | <p>I would like to post an array of strings like</p>
<pre><code>[
"id1",
"id2"
]
</code></pre>
<p>to a Swagger based API. In my swagger file, I have those lines:</p>
<pre><code>paths:
/some_url:
post:
parameters:
- name: ids
in: body
required: true
</code></pre>
<p>What is the correct way to specify the type of <code>ids</code> as an array of strings?</p>
<p><strong>Update:</strong></p>
<p>According to the specification, the following should work in my option:</p>
<pre><code> parameters:
- in: body
description: xxx
required: true
schema:
type: array
items:
type: string
</code></pre>
<p><a href="https://github.com/Yelp/swagger_spec_validator" rel="noreferrer">https://github.com/Yelp/swagger_spec_validator</a> does not accept it and returns a long list of convoluted errors, which look like the code expects some <code>$ref</code>.</p> | 0 |
Angular 2 HTTP POST does an OPTIONS call | <p>I'm encountering a really strange problem with my Angular 2 application. I actually want to make a POST call containing a JSON to my Play Scala API, but it keeps want to try to make an OPTIONS call.</p>
<p>Here is my code :</p>
<p><strong>LoginService</strong></p>
<pre><code>constructor (private _apiEndpoint: ApiEndpoint) {}
postLogin(login: string, credential: string): Observable<AuthToken> {
let headers = new Headers({ "Content-Type": "application/json" })
let jsonLogin = {"login": login, "password": credential}
return this._apiEndpoint.postLogin(JSON.stringify(jsonLogin), headers)
.map(this._apiEndpoint.extractData)
}
</code></pre>
<p><strong>ApiEndpoint</strong></p>
<pre><code>constructor (private _http: Http) {}
postLogin(body: string, options: any) {
return this._http.post("http://localhost:9000/login", body, {
headers: options
})
}
</code></pre>
<p>And then when I try to make the call (I've tried to console.log to check the JSON and it's correct), and the call tries to make an OPTIONS call for whatever reason :</p>
<p><a href="https://i.stack.imgur.com/ESuvD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ESuvD.png" alt="Google request picture"></a></p>
<p>Has anyone an idea ? Thanks !</p> | 0 |
Cannot find class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] for bean with name 'hibernate5AnnotatedSessionFactory' | <p>Please help me I am a beginner in Maven project I try to connect to my MySQL database with hibernate but I have this error. If anyone could help me
it will be friendly! </p>
<pre><code>org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] for bean with name 'hibernate5AnnotatedSessionFactory' defined in ServletContext resource [/WEB-INF/spring-database.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate5.LocalSessionFactoryBean
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1328)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:622)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:591)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1397)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:968)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:735)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.orm.hibernate5.LocalSessionFactoryBean
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:249)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1349)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1320)
... 19 more
</code></pre>
<p>This is my spring-database.xml for hibernate</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/church" />
<property name="username" value="root" />
<property name="password" value="carthy-2" />
</bean>
<!-- Hibernate 4 SessionFactory Bean definition -->
<bean id="hibernate5AnnotatedSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.church.metier.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<bean id="HibernateUtil" class="com.church.util.HibernateUtil">
<property name="sessionFactory" ref="hibernate5AnnotatedSessionFactory" />
</bean>
</beans>
</code></pre>
<p>my web.xml</p>
<pre><code><?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"
version="3.0">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>webmvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webmvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/webmvc-dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/views/errors/error500.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/views/errors/error404.jsp</location>
</error-page>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value> /WEB-INF/spring-database.xml</param-value>
</context-param>
</web-app>
</code></pre>
<p>my webmvc-dispatcher-servlet</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="META-INF/messages/messages" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="fr" />
</bean>
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
</mvc:interceptors>
<context:component-scan base-package="com.church.controller" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
</beans>
</code></pre>
<p>and my pom.xml</p>
<pre><code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.agnc</groupId>
<artifactId>church</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>church Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<org.springframework.version>4.1.7.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/jstl/jstl -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- HIBERNATE -->
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.2.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.2.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.common/hibernate-commons-annotations -->
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.0.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.2.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<!-- MYSQL Connector -->
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
</dependencies>
<build>
<finalName>church</finalName>
</build>
</project>
</code></pre>
<p>thanks for your answers</p> | 0 |
Jackson JsonNode to typed Collection | <p>What is the proper way to convert a Jackson <code>JsonNode</code> to a java collection?</p>
<p>If it were a json string I could use <code>ObjectMapper.readValue(String, TypeReference)</code> but for a <code>JsonNode</code> the only options are <code>ObjectMapper.treeToValue(TreeNode, Class)</code> which wouldn't give a typed collection, or <code>ObjectMapper.convertValue(Object, JavaType)</code> which feels wrong on account of its accepting any POJO for conversion. </p>
<p>Is there another "correct" way or is it one of these?</p> | 0 |
............Error | java.lang.NullPointerException: Cannot invoke method saveDataentryDetails() on null object | <p>I got below error when i try to save a form details. (when i click submit button from my dataentry.gsp file)
I think the error occured at my controller where i calling the service.</p>
<pre><code>Error | java.lang.NullPointerException: Cannot invoke method saveDataentryDetails() on null object
</code></pre>
<p>here is my dataentry.gsp</p>
<pre><code><%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta name="layout" content="main"/>
<title>Data Entry</title>
</head>
<body>
<div id="saveMsgDiv"></div>
<g:formRemote name="dataEntryForm" update="saveMsgDiv" url="[controller: 'DataEntry', action:'saveAjax']">
<table align="center">
<tr>
<td>
<label for='employeeId'>EmployeeID:</label>
</td>
<td>
<g:textField name='employee_id' required id='employee_id'/>
</td>
</tr>
<tr>
<td>
<label for='team'>Team:</label>
</td>
<td>
<g:select name='team' required id='team' from="${['Java', 'QA', 'Database']}"
noSelection="['':'---select---']"/>
</td>
</tr>
<tr>
<td>
<label for='receiptDate'>Receipt Date:</label>
</td>
<td>
<g:textField name='receipt_dt' required id='receipt_dt'/>
</td>
</tr>
<tr>
<td>
<label for='restaurantName'>Restaurant Name:</label>
</td>
<td>
<g:textField name='restaurant_name' required id='restaurant_name'/>
</td>
</tr>
<tr>
<td>
<label for='numberOfPersons'>Number of Persons:</label>
</td>
<td>
<g:textField name='number_of_persons' required id='number_of_persons' maxlength="3"/>
</td>
</tr>
<tr>
<td>
<label for='amount'>Amount:</label>
</td>
<td>
<g:textField name='amount' required id='amount'/>
</td>
</tr>
<tr>
<td>
<label for='billSubmittedDate'>Bill Submitted Date:</label>
</td>
<td>
<g:textField name='bill_submitted_dt' required id='bill_submitted_dt'/>
</td>
</tr>
<tr>
<td>
<label for='reImbursed'>Reimbursed:</label>
</td>
<td>
<g:textField name='reimbursed' required id='reimbursed'/>
</td>
</tr>
<tr>
<td>
<label for='submitBank'>Submitted to Bank:</label>
</td>
<td>
<g:textField name='presented_bank_fl' required id='presented_bank_fl'/>
</td>
</tr>
<tr>
<td>
<label for='dateOfSubmission'>Date of Bank Submission:</label>
</td>
<td>
<g:textField name='presented_bank_dt' required id='presented_bank_dt'/>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center;">
<g:submitButton name="Submit" style="cursor:pointer"/>
</td>
</tr>
</table>
</g:formRemote>
</body>
</html>
</code></pre>
<p>here is my DataEntryController.groovy</p>
<pre><code>package com.standout.utilityapplication
import java.util.Map;
import grails.plugin.springsecurity.annotation.Secured
import groovy.sql.Sql
@Secured(['ROLE_DATAENTRY'])
class DataEntryController {
def dataSource
DataEntrySevice service
def index() { }
def dataentry(){
println("Inside DataEntryController")
}
def saveAjax(){
def result
try{
service.saveDataentryDetails(params)
}
catch(Exception e){
e.printStackTrace();
}
}
}
</code></pre>
<p>here is my DataEntryService.groovy</p>
<pre><code>package com.standout.utilityapplication
import grails.transaction.Transactional
import groovy.sql.Sql
import org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap
@Transactional
class DataEntrySevice {
def dataSource
def int saveDataentryDetails(Map params) {
def result
try{
println("Inside saveDataentryAjax() method of dataentry")
Dataentry d = new Dataentry();
d.amount = params.amount
d.bill_submitted_dt = params.bill_submitted_dt
d.employee_id = params.employee_id
d.number_of_persons = params.number_of_persons
d.presented_bank_dt = params.presented_bank_dt
d.presented_bank_fl = params.presented_bank_fl
d.receipt_dt = params.receipt_dt
d.reimbursed = params.reimbursed
d.restaurant_name = params.restaurant_name
d.team = params.team
d.save(failOnError:true);
}
catch(Exception e){
e.printStackTrace();
}
catch(Exception e){
println(e)
}
return result
}
}
</code></pre>
<p>Can anyone help?</p> | 0 |
Exception: Error when checking model target: expected dense_3 to have shape (None, 1000) but got array with shape (32, 2) | <p>How do I create a VGG-16 sequence for my data?</p>
<p>The data has the following :</p>
<pre><code>model = Sequential()
model.add(ZeroPadding2D((1, 1), input_shape=(3, img_width, img_height))) model.add(Convolution2D(64, 3, 3, activation='relu', name='conv1_1')) model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(64, 3, 3, activation='relu', name='conv1_2'))
model.add(MaxPooling2D((2, 2), strides=(2, 2)))
model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(128, 3, 3, activation='relu', name='conv2_1')) model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(128, 3, 3, activation='relu', name='conv2_2'))
model.add(MaxPooling2D((2, 2), strides=(2, 2)))
model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(256, 3, 3, activation='relu', name='conv3_1')) model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(256, 3, 3, activation='relu', name='conv3_2'))
model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(256, 3, 3, activation='relu', name='conv3_3')) model.add(MaxPooling2D((2, 2), strides=(2, 2)))
model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(512, 3, 3, activation='relu', name='conv4_1')) model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(512, 3, 3, activation='relu', name='conv4_2'))
model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(512, 3, 3, activation='relu', name='conv4_3')) model.add(MaxPooling2D((2, 2), strides=(2, 2)))
model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(512, 3, 3, activation='relu', name='conv5_1')) model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(512, 3, 3, activation='relu', name='conv5_2'))
model.add(ZeroPadding2D((1, 1)))
model.add(Convolution2D(512, 3, 3, activation='relu', name='conv5_3')) model.add(MaxPooling2D((2, 2), strides=(2, 2)))
model.add(Flatten())
model.add(Dense(4096, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(4096, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1000, activation='softmax'))
sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(optimizer=sgd, loss='categorical_crossentropy')
train_datagen = ImageDataGenerator(
rescale=1./255,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True)
test_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size=(img_width, img_height),
batch_size=32)
validation_generator = test_datagen.flow_from_directory(
validation_data_dir,
target_size=(img_width, img_height),
batch_size=32)
model.fit_generator(
train_generator,
samples_per_epoch=2000,
nb_epoch=1,
verbose=1,
validation_data=validation_generator,
nb_val_samples=800)
json_string = model.to_json()
open('my_model_architecture.json','w').write(json_string)
model.save_weights('Second_try.h5')
</code></pre>
<p>I got an error:</p>
<blockquote>
<p>Exception: Error when checking model target: expected dense_3 to have
shape (None, 32) but got array with shape (32, 2)</p>
</blockquote>
<p>How do I change <code>Dense</code> to make it work?</p> | 0 |
how to use Run Keyword If with 2 conditions in Robot Framework? | <p>Hi I am using the <a href="http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keyword%20If" rel="nofollow">Run Keyword If</a> in the <a href="http://robotframework.org/robotframework/latest/libraries/BuiltIn.html" rel="nofollow">builtin library</a>, and I want to run a keyword if two conditions are satisfied.
with one condition I was doing it like this:</p>
<pre><code>Scale Down Service Should Succeed
Get Services
:For ${Service} IN @{BODY.json()}
\ Run Keyword If ${Service['DOWN']} Scale Down Service With Correct ID And Can be Scaled Down ${Service['ID']} ${Service['ContainersRunning']}
</code></pre>
<p>now my question is how can I do this with 2 conditions for example ${Service['DOWN']} (type boolean) and ${Service['Name']}="service"</p> | 0 |
What is the meaning of void -> (void) in Swift? | <p>I know the meaning of (void) in objective c but I want to know what is the meaning of this code:</p>
<pre><code>(Void) -> (Void)
</code></pre>
<p>In Swift.</p> | 0 |
Exception in thread "main" java.lang.IllegalStateException | <p>I am studying automation testing tutorial by selenium and was writing my first script in java language and have got that message in "Console" at Eclipse.</p>
<pre><code>Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:91)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:245)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
at automationFramework.FirstTestCase.main(FirstTestCase.java:12)
</code></pre>
<p>My Code : </p>
<pre><code>package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirstTestCase {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
// Create a new instance of the Firefox driver
WebDriver driver = new FirefoxDriver();
//Launch the Online Store Website
driver.get("http://www.store.demoqa.com");
// Print a Log In message to the screen
System.out.println("Successfully opened the website www.Store.Demoqa.com");
//Wait for 5 Sec
Thread.sleep(5);
// Close the driver
driver.quit();
}
}
</code></pre>
<p>The Tutorial Link :
<a href="http://toolsqa.wpengine.com/selenium-webdriver/first-test-case/" rel="nofollow">http://toolsqa.wpengine.com/selenium-webdriver/first-test-case/</a></p> | 0 |
Make container accessible only from localhost | <p>I have Docker engine installed on Debian Jessie and I am running there container with nginx in it. My "run" command looks like this:</p>
<pre><code>docker run -p 1234:80 -d -v /var/www/:/usr/share/nginx/html nginx:1.9
</code></pre>
<p>It works fine, problem is that now content of this container is accessible via <code>http://{server_ip}:1234</code>. I want to run multiple containers (domains) on this server so I want to setup reverse proxies for them. </p>
<p>How can I make sure that container will be only accessible via reverse proxy and not directly from <code>IP:port</code>? Eg.:</p>
<pre><code>http://{server_ip}:1234 # not found, connection refused, etc...
http://localhost:1234 # works fine
</code></pre>
<p><strong>//EDIT:</strong> Just to be clear - I am not asking how to setup reverse proxy, but how to run Docker container to be accessible only from localhost.</p> | 0 |
java.sql.SQLException: ORA-00257: Archiver error. Connect AS SYSDBA only until resolved | <p>I am getting below error while connecting to oracle database.</p>
<pre><code>java.sql.SQLException: ORA-00257: Archiver error. Connect AS SYSDBA only until resolved.07-09-2016 12:25:44 ERROR DBUtils:122 - loginUser Exception :java.sql.SQLException: ORA-00257: Archiver error. Connect AS SYSDBA only until resolved.
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:444)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOSESSKEY(T4CTTIoauthenticate.java:407)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:416)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.sne.dao.DBUtils.loginUser(DBUtils.java:55)
at com.sne.servlets.SELogin.doPost(SELogin.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:306)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:323)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1719)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
</code></pre>
<p>Error While Connecting db through SQL Developer...</p>
<p><a href="https://i.stack.imgur.com/8Fzp5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Fzp5.png" alt="enter image description here"></a></p> | 0 |
Jenkins groovy pipeline - retrieve build number of built job | <p>I have a pipeline my team is using to spin up cloud VM's and deploy a software stack to them. Part of this process is to bundle up the artifacts from the builds they select. Right now im just grabbing last success of the jobs listed but ive encountered issues of that job being built again in another process before the pipeline can create its bundle, making the bundle grab an artifact built with the wrong dependencies. </p>
<pre><code>def DeployModule(jobName, jobBranch, serverHostName, database){
build job: jobName, parameters: [[$class: 'StringParameterValue', name: 'Branch', value: jobBranch], [$class: 'StringParameterValue', name: 'DatabaseAction', value: database], [$class: 'StringParameterValue', name: 'Profile', value: serverHostName]]
println "$jobName Succesfull"
}
</code></pre>
<p>Is there any way to alter my simple build job method to pull out the actual build number that was triggered? The pipeline console prints what build number is created im just not sure how to get it in my groovy code.</p>
<pre><code>[Pipeline] build (Building tms-auto-build)
Scheduling project: tms-auto-build
Starting building: tms-auto-build #298
</code></pre> | 0 |
Subscribing to ActivatedRoute Params in Angular 2 does not update view templates | <p>I'm not sure why the change detection wouldn't work here. I've tried a few things, including a setTimeout. I'm using RC5. Basically I want to change the content based off of a parameter in my URL. Should be pretty simple right?</p>
<p>thanks.ts</p>
<pre><code>import { Component } from '@angular/core';
import { Card } from '../../components/card/card';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'sd-thanks',
styleUrls: ['thanks.css'],
directives: [Card],
templateUrl: 'thanks.html'
})
export class Thanks {
params: any;
coming: any;
constructor(public route: ActivatedRoute) {
this.params = this.route.params.subscribe(
params => {
this.coming = params['coming'];
console.log(this.coming); // this consoles the correct true/false value
}
);
}
}
</code></pre>
<p>thanks.html</p>
<pre><code><card>
<div *ngIf="coming" class="card-content">
<span class="card-title">We can't wait to see you!</span>
</div>
<div *ngIf="!coming" class="card-content">
<span class="card-title">We will certainly miss you!</span>
</div>
</card>
</code></pre> | 0 |
react: addEventListener is not a function error | <p>i have this div inside my render method in a component</p>
<pre><code><div ref={node => this.domNode = node} style={this.getStyle()}>{ this.props.children }</div>
</code></pre>
<p>when i do this in componentDidMount</p>
<pre><code>this.domNode.addEventListener('mousedown', this.onDrag);
</code></pre>
<p>there is an error</p>
<pre><code>this.domNode.addEventListener is not a function
</code></pre> | 0 |
Xcode 8 "The application does not have a valid signature" | <p>Xcode 8 throws the following error despite provisioning seems to be fine:</p>
<p><a href="https://i.stack.imgur.com/LqaRx.png"><img src="https://i.stack.imgur.com/LqaRx.png" alt="App installation failed. The application does not have a valid signature"></a></p>
<p>How to fix it?</p> | 0 |
Using font-awesome in ionic 2 | <p>How can i use <strong><a href="http://fontawesome.io/icons/">fontawesome</a></strong> with <code>ionic 2</code>, i've following <a href="https://forum.ionicframework.com/t/extend-ionic2-add-custom-fonts-icons-ionic-config-json/48589">this tutorial</a> but it's not working.</p> | 0 |
How can I get the stemlines color to match the marker color in a stem plot? | <p>Stem lines are always blue:</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0.1, 2*np.pi, 10)
plt.stem(x, np.sin(x), markerfmt='o', label='sin')
plt.stem(x+0.05, np.cos(x), markerfmt='o', label='cos')
plt.legend()
plt.show()
</code></pre>
<p>produce:
<a href="https://i.stack.imgur.com/ypiW1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ypiW1.png" alt="stem lines don't match markers" /></a></p>
<p>I want the stem lines to match the color of the markers (blue for the first dataset, green for the second).</p> | 0 |
serve public static files with webpack | <p>I struggle to get webpack configured as I want it to be.
I run my dev-server on <strong>localhost:8080</strong> and want to serve my app through <strong>localhost:8080/static/js/bundle.js</strong> and that is what I get with this webpack.config.js file I've attached below. in my file structure i've alse attached I want to serve also the other files located in <strong>dist/static</strong> as static files, so <strong>localhost:8080/static/css/style.css</strong> will be serving this <strong>dist/static/css/style.css</strong> file for example.</p>
<p>it is probably something wrong i did in the config file, and i'm not that familiar with webpack so i don't know if im asking the question so you can understand.</p>
<p>My directory tree is:</p>
<pre><code>client
-- /dist
-- /templates
-- /admin
-- index.html
-- /static
-- /css
-- style.css
-- /js
-- /node_modules
-- /src
-- /test
-- package.json
-- webpack.config.json
</code></pre>
<p>webpack.config.js</p>
<pre><code>var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var plugins = [
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
new ExtractTextPlugin('app.css', {
allChunks: true
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
})
];
var cssLoader = {};
if(process.env.NODE_ENV == 'production'){
plugins.push(
new webpack.optimize.UglifyJsPlugin()
);
cssLoader = {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]')
};
} else {
cssLoader = {
test: /\.css$/,
loaders: [
'style?sourceMap',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
]
}
}
module.exports = {
entry: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'./src/index.js'
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel']
},
cssLoader
]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
output: {
path: __dirname + '/dist/static',
publicPath: '/static/js',
filename: 'bundle.js'
},
devServer: {
contentBase: './dist/templates/admin',
hot: true,
historyApiFallback: true
},
plugins: plugins
};
</code></pre>
<p>dist/templates/admin/index.html</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>My App</title>
<link href="static/css/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="app"></div>
<script src="static/js/bundle.js"></script>
</body>
</html>
</code></pre>
<p>thanks guys :)</p> | 0 |
Firebase retrieve the user data stored in local storage as firebase:authUser: | <p>I am working with Firebase and AngularJS. I am using Auth authentication for google login and i completed the process.Now i need to retrieve the user data that is stored in local storage like firebase:authUser:.</p>
<p>Once i login with google account in local storage you have firebase:authUser:.created and i need to fetch these details.</p>
<p>I used the following method to store user data </p>
<pre><code>firebase.database().ref('users/' + user.uid).set
({
name: user.displayName,
email: user.email,
token: token
});
</code></pre> | 0 |
How to stop http.ListenAndServe() | <p>I am using the Mux library from Gorilla Web Toolkit along with the bundled Go http server.</p>
<p>The problem is that in my application the HTTP server is only one component and it is required to stop and start at my discretion.</p>
<p>When I call <code>http.ListenAndServe(fmt.Sprintf(":%d", service.Port()), service.router)</code> it blocks and I cannot seem to stop the server from running.</p>
<p>I am aware this has been a problem in the past, is that still the case? Are there any new solutions?</p> | 0 |
Load file with environment variables Jenkins Pipeline | <p>I am doing a simple pipeline:</p>
<p><em>Build -> Staging -> Production</em></p>
<p>I need different environment variables for staging and production, so i am trying to <em>source</em> variables.</p>
<pre><code>sh 'source $JENKINS_HOME/.envvars/stacktest-staging.sh'
</code></pre>
<p>But it returns <em>Not found</em></p>
<pre><code>[Stack Test] Running shell script
+ source /var/jenkins_home/.envvars/stacktest-staging.sh
/var/jenkins_home/workspace/Stack Test@tmp/durable-bcbe1515/script.sh: 2: /var/jenkins_home/workspace/Stack Test@tmp/durable-bcbe1515/script.sh: source: not found
</code></pre>
<p>The path is right, because i run the same command when i log via ssh, and it works fine.</p>
<p>Here is the pipeline idea:</p>
<pre><code>node {
stage name: 'Build'
// git and gradle build OK
echo 'My build stage'
stage name: 'Staging'
sh 'source $JENKINS_HOME/.envvars/stacktest-staging.sh' // PROBLEM HERE
echo '$DB_URL' // Expects http://production_url/my_db
sh 'gradle flywayMigrate' // To staging
input message: "Does Staging server look good?"
stage name: 'Production'
sh 'source $JENKINS_HOME/.envvars/stacktest-production.sh'
echo '$DB_URL' // Expects http://production_url/my_db
sh 'gradle flywayMigrate' // To production
sh './deploy.sh'
}
</code></pre>
<p>What should i do?</p>
<ul>
<li>I was thinking about not using pipeline (but i will not be able to use my Jenkinsfile).</li>
<li>Or make different jobs for staging and production, using EnvInject Plugin (But i lose my stage view)</li>
<li>Or make withEnv (but the code gets big, because today i am working with 12 env vars)</li>
</ul> | 0 |
swift, alamofire cancel previous request | <p>I have an NetworkRequest class, where all my alamofire requests made:</p>
<pre><code> class NetworkRequest {
static let request = NetworkRequest()
var currentRequest: Alamofire.Request?
let dataManager = DataManager()
let networkManager = NetworkReachabilityManager()
let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
func downloadData<T: Film>(slug: String, provider: String, section: String, dynamic: String, anyClass: T, completion: ([T]?) -> Void ) {
var token: String = ""
if LOGGED_IN == true {
token = "\(NSUserDefaults.standardUserDefaults().valueForKey(TOKEN)!)"
}
let headers = [
"Access": "application/json",
"Authorization": "Bearer \(token)"
]
let dataUrl = "\(BASE_URL)\(slug)\(provider)\(section)\(dynamic)"
print(headers)
print(dataUrl)
if networkManager!.isReachable {
currentRequest?.cancel()
dispatch_async(dispatch_get_global_queue(priority, 0)) {
if let url = NSURL(string: dataUrl) {
let request = Alamofire.request(.GET, url, headers: headers)
request.validate().responseJSON { response in
switch response.result {
case .Success:
if let data = response.result.value as! [String: AnyObject]! {
let receivedData = self.dataManager.parseDataToFilms(data, someClass: anyClass)
completion(receivedData)
}
case .Failure(let error):
print("Alamofire error: \(error)")
if error.code == 1001 {
self.goToNoConnectionVC()
}
print("canceled")
}
}
}
}
} else {
goToNoConnectionVC()
}
}
}
</code></pre>
<p>And I need to cancel previous downloadData request, when the new one starts, tried to cancel using currentRequest?.cancel(), but it doesn't help. </p>
<p>Already tried to cancelOperations using NSOperationsBlock, but it doesn't cancels current operation. </p>
<p>I block UI now, so that user can't send another request. But this is not correct, causes some errors later...</p>
<p>Pls, help</p> | 0 |
How does 1 left shift by 31 (1 << 31) work to get maximum int value? Here are my thoughts and some explanations I found online | <p>I'm fairly new to bit manipulation and I'm trying to figure out how (1 << 31) - 1 works.</p>
<p>First I know that 1 << 31 is </p>
<pre><code>1000000000000000000000000000
</code></pre>
<p>and I know it's actually complement of minimum int value, but when I tried to figure out (1 << 31) - 1, I found an explanation states that, it's just </p>
<pre><code>10000000000000000000000000000000 - 1 = 01111111111111111111111111111111
</code></pre>
<p>I was almost tempted to believe it since it's really straightforward. But is this what really happening? If it's not, why it happens to be right?</p>
<p>My original thought was that, the real process should be: the two's complement of -1 is</p>
<pre><code>11111111111111111111111111111111
</code></pre>
<p>then (1 << 31) - 1 =</p>
<pre><code>(1)01111111111111111111111111111111
</code></pre>
<p>the leftmost 1 is abandoned, then we have maximum value of int.</p>
<p>I'm really confused about which one is right.</p> | 0 |
Is it possible to declare local anonymous structs in Rust? | <p>Sometimes I like to group related variables in a function, without declaring a new struct type.</p>
<p>In C this can be done, e.g.:</p>
<pre><code>void my_function() {
struct {
int x, y;
size_t size;
} foo = {1, 1, 0};
// ....
}
</code></pre>
<p>Is there a way to do this in Rust? If not, what would be the closest equivalent?</p> | 0 |
Start Confluent Schema Registry in windows | <p>I have windows environment and my own set of kafka and zookeeper running. To use custom objects, I started to use Avro. But I needed to get the registry started. Downloaded Confluent platform and ran this:</p>
<pre><code>$ ./bin/schema-registry-start ./etc/schema-registry/schema-registry.properties
/c/Confluent/confluent-3.0.0-2.11/confluent-3.0.0/bin/schema-registry-run-class: line 103: C:\Program: No such file or directory
</code></pre>
<p>Then I see this on the installation page:</p>
<p>"Confluent does not currently support Windows. Windows users can download and use the zip and tar archives, but will have to run the jar files directly rather than use the wrapper scripts in the bin/ directory."</p>
<p>I was wondering how do I go about starting confluent schema registry in Windows environment ?</p>
<p>Looked at contents of scripts and it is difficult to decipher. </p>
<p>Thanks</p> | 0 |
Java 8 foreach add subobject to new list | <p>Is it possible in Java 8 to write something like this: </p>
<pre><code>List<A> aList = getAList();
List<B> bList = new ArrayList<>();
for(A a : aList) {
bList.add(a.getB());
}
</code></pre>
<p>I think it should be a mix of following things: </p>
<pre><code>aList.forEach((b -> a.getB());
</code></pre>
<p>or</p>
<pre><code>aList.forEach(bList::add);
</code></pre>
<p>But I can't mix these two to obtain the desired output.</p> | 0 |
Keras: How to use fit_generator with multiple outputs of different type | <p>In a Keras model with the Functional API I need to call fit_generator to train on augmented images data using an ImageDataGenerator.<br />
The problem is my model has two outputs: the mask I'm trying to predict and a binary value.<br />
I obviously only want to augment the input and the mask output and not the binary value.<br />
How can I achieve this?</p> | 0 |
Django REST Framework ManyToMany filter multiple values | <p>I have two models, one defining users, the other defining labels on these users. I am using Django REST Framework to create an API. I would like to be able to query users containing at least the label ids 1 and 2.</p>
<p>For instance if the user's labels are:
<code>[(1,2), (1,2,3), (2,3), (1,3)]</code> I want the query to return
<code>[(1,2), (1,2,3)]</code>.</p>
<p>So far, I've managed to query users with a given label (let's say id=1) by doing: <code>/api/users/?labels=1</code>, but I am unable to query users with labels 1 and 2. I've tried <code>/api/users/?labels=1,2</code> or <code>/api/users/?labels=1&labels=2</code> but it returns some invalid users, i.e. users without labels 1 or 2...</p>
<p><strong>Github test repo:</strong></p>
<p><a href="https://github.com/TheDimLebowski/drf-m2m-filter" rel="nofollow noreferrer">https://github.com/TheDimLebowski/drf-m2m-filter</a></p>
<p><strong>Code:</strong></p>
<h2>models.py</h2>
<pre><code>class Label(models.Model):
name = models.CharField(max_length = 60)
class User(models.Model):
labels = models.ManyToManyField(Label)
</code></pre>
<h2>filters.py</h2>
<pre><code>class UserFilter(django_filters.FilterSet):
labels = django_filters.filters.BaseInFilter(
name='labels',
lookup_type='in',
)
class Meta:
model = User
fields = ('labels',)
</code></pre>
<h2>serializers.py</h2>
<pre><code>class LabelSerializer(serializers.ModelSerializer):
class Meta:
model = Label
fields = ('id','name')
class UserSerializer(serializers.ModelSerializer):
labels = LabelSerializer(many = True)
class Meta:
model = User
fields = ('labels',)
</code></pre>
<h2>views.py</h2>
<pre><code>class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_class = UserFilter
filter_fields = ('labels',)
</code></pre> | 0 |
How to automatically rescale axis in QtCharts? | <p>I am using <a href="https://doc.qt.io/qt-5/qtcharts-index.html" rel="noreferrer">QtCharts</a>.</p>
<p>I need both axes to be rescaled after appending values. The values I appended are not between 0 and 1 and also not from the year 1970.</p>
<p><a href="https://i.stack.imgur.com/73HO3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/73HO3.png" alt="QtChart axis wrong scaled"></a></p>
<p>Constructor code of my dialog looks like this:</p>
<pre><code>m_series = new QLineSeries;
m_series->setName(name);
auto chart = new QChart;
chart->legend()->setVisible(false);
chart->addSeries(m_series);
m_axisX = new QDateTimeAxis;
//m_axisX->setFormat("HH:mm:ss");
m_axisX->setTitleText(tr("Zeitpunkt"));
chart->addAxis(m_axisX, Qt::AlignBottom);
m_series->attachAxis(m_axisX);
auto axisY = new QValueAxis;
axisY->setTitleText(unit);
chart->addAxis(axisY, Qt::AlignLeft);
m_series->attachAxis(axisY);
auto chartView = new QChartView(chart, this);
chartView->setRenderHint(QPainter::Antialiasing);
</code></pre>
<p>My MainWindow emits signals containg new values. Multiple opened chart dialogs are connected to that signal.</p>
<pre><code>void ChartDialog::liveUpdate(const RealTimeMeasureRegisters &registers)
{
auto result = ((&registers)->*m_methodPtr)();
m_series->append(registers.timestamp(), result);
}
</code></pre>
<p><strong>Is there some easy way to tell QDateTimeAxis (in my case <code>m_axisX</code>) to automatically adjust to the new values?</strong></p>
<p><a href="https://doc.qt.io/qt-5/qdatetimeaxis.html#setRange" rel="noreferrer">QDateTimeAxis::setRange()</a> does not look good, because I need to set a minimum and maximum.</p> | 0 |
Want to change opacity with react native refs on click | <p>Here is my code. I want to change the opacity of refs when i click on any TouchableOpacity component.Please guide me how i can change opacity or change colour in react native with refs.
When i click my redirect function calls so i wanna change the opacity of particular ref in redirect function, i am passing ref and routename is redirect function.</p>
<p>i</p>
<pre><code>mport React, { Component } from 'react';
import {
View,
Text,
TouchableOpacity,
StyleSheet
} from 'react-native';
export default class Navigation extends Component {
redirect(routeName,ref)
{
console.log(this.refs[ref]]);
this.props.navigator.push({
ident: routeName
});
}
render() {
return (
<View style={style.navigation}>
<View style={[style.navBar,styles.greenBack]}>
<TouchableOpacity style={style.navPills} onPress={ this.redirect.bind(this,"AddItem","a")} ref="a">
<Text style={[style.navText,style.activeNav]}>HOME</Text></TouchableOpacity>
<TouchableOpacity style={style.navPills} onPress={ this.redirect.bind(this,"AddItem","b")} ref="b">
<Text style={style.navText}>ORDER</Text></TouchableOpacity>
<TouchableOpacity style={style.navPills} onPress={ this.redirect.bind(this,"ListItem","c")} ref="c">
<Text style={style.navText}>SHOP LIST</Text></TouchableOpacity>
<TouchableOpacity style={style.navPills} onPress={ this.redirect.bind(this,"ListItem","d")} ref="d">
<Text style={style.navText}>DUES</Text></TouchableOpacity>
</View>
<View style={style.titleBar}>
<Text style={style.titleBarText}>{this.props.title}</Text>
</View>
</View>
);
}
}
const style = StyleSheet.create({
navigation:{
top:0,
right:0,
left:0,
position:'absolute'
},
navBar:{
flexDirection:'row',
padding:10,
paddingTop:15,
paddingBottom:15,
},
navPills:{
flex:1,
alignItems:'center'
},
navText:{
flex:1,
textAlign:'center',
fontSize:16,
fontWeight:'bold',
color:'#ffffff',
opacity:0.7
},
titleBar:{
backgroundColor:'#ffffff',
flex:1,
padding:8,
alignItems:'center',
borderBottomWidth:1,
borderBottomColor:'#dddddd'
},
titleBarText:{
fontSize:18
},
activeNav:{
opacity:1
}
});
</code></pre> | 0 |
Spring Boot Too Many Redirects | <p>I'm developing a simple login Form using a Thymeleaf & Spring Boot. When i try hitting the following URL in Chrome: "<a href="http://localhost:8080/login" rel="noreferrer">http://localhost:8080/login</a>" i get an error saying "ERR_TOO_MANY_REDIRECTS". I've tried clearing my cache & cookies in the browser and still get the same error.</p>
<p>I tried disabling the default security login screen by putting the following property into my application.properties: <code>security.basic.enabled=false</code></p>
<p>and added the following configuration to my SecurityConfig so any URL except "/login" and "/resources" would get authenticated:</p>
<pre><code>@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserRepository userRepository;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
</code></pre>
<p>My LoginController is strightforward: </p>
<pre><code>@Controller
public class LoginController {
@RequestMapping(value="/login", method=RequestMethod.GET)
public String loadForm(Model model) {
model.addAttribute("user", new User());
return "redirect:/login";
}
</code></pre>
<p>Anyone have any idea's why this happens?</p> | 0 |
How to execute a sql file | <p>I have .sql file which has lots of database creation, deletion, population stuff. Is it possible to have a go function which can excute a sql file. I am using postgres as my database and using lib/pq driver for all database transactions. But I am open to any library for executing this sql file in my Go project.</p> | 0 |
Override a single @Configuration class on every spring boot @Test | <p>On my spring boot application I want to override just one of my <code>@Configuration</code> classes with a test configuration (in particular my <code>@EnableAuthorizationServer</code> <code>@Configuration</code> class), on all of my tests.</p>
<p>So far after an overview of <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html" rel="noreferrer">spring boot testing features</a> and <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/integration-testing.html" rel="noreferrer">spring integration testing features</a> no straightforward solution has surfaced:</p>
<ul>
<li><code>@TestConfiguration</code>: It's for extending, not overriding;</li>
<li><code>@ContextConfiguration(classes=…)</code> and <code>@SpringApplicationConfiguration(classes =…)</code> let me override the whole config, not just the one class;</li>
<li>An inner <code>@Configuration</code> class inside a <code>@Test</code> is suggested to override the default configuration, but no example is provided;</li>
</ul>
<p>Any suggestions?</p> | 0 |
LazyInitializationException in Hibernate : could not initialize proxy - no Session | <p>I call dao from my service as </p>
<pre><code>@Override
@Transactional
public Product getProductById(int id) {
return productDao.getProductById(id);
}
</code></pre>
<p>and in the dao I am getting product as </p>
<pre><code>@Override
public Product getProductById(int id) {
Product p = sessionFactory.getCurrentSession().load(Product.class, id);
System.out.print(p);
return p;
}
</code></pre>
<p>This runs fine but if I change my dao class to</p>
<pre><code>@Override
public Product getProductById(int id) {
return sessionFactory.getCurrentSession().load(Product.class, id);
}
</code></pre>
<p>I get org.hibernate.LazyInitializationException: could not initialize proxy - no Session. The exception occurs in view layer where I am just printing the product. I do not understand why returning in same line in dao method results in exception in view layer but works fine if I save it in a reference and then return that.</p> | 0 |
Jenkins Setup Wizard Blank Page | <p>I have just installed Jenkins on my RHEL 6.0 server via npm:</p>
<pre><code>npm -ivh jenkins-2.7.2-1.1.noarch.rpm
</code></pre>
<p>I have also configured my port to be 9917 to avoid clashing with my Tomcat server, allowing me to access the Jenkins page at <code>ipaddress:9917</code>. After entering the initial admin password at the <strong>Unlock Jenkins</strong> page, I am presented with a blank page, with the header "SetupWizard [Jenkins]".</p>
<p>Anyone knows why am I getting a blank page, and how do I solve it?</p> | 0 |
In TensorFlow, how can I get nonzero values and their indices from a tensor with python? | <p>I want to do something like this.<br>
Let's say we have a tensor A. </p>
<pre><code>A = [[1,0],[0,4]]
</code></pre>
<p>And I want to get nonzero values and their indices from it. </p>
<pre><code>Nonzero values: [1,4]
Nonzero indices: [[0,0],[1,1]]
</code></pre>
<p>There are similar operations in Numpy.<br>
<code>np.flatnonzero(A)</code> return indices that are non-zero in the flattened A.<br>
<code>x.ravel()[np.flatnonzero(x)]</code> extract elements according to non-zero indices.<br>
Here's <a href="http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.flatnonzero.html" rel="noreferrer">a link</a> for these operations.</p>
<p>How can I do somthing like above Numpy operations in Tensorflow with python?<br>
(Whether a matrix is flattened or not doesn't really matter.)</p> | 0 |
Terminate all dialogs and exit conversation in MS Bot Framework when the user types "exit", "quit" etc | <p>I can't figure out how to do the a very simple thing in MS Bot Framework: allow the user to break out of any conversation, leave the current dialogs and return to the main menu by typing "quit", "exit" or "start over". </p>
<p>Here's the way my main conversation is set up:</p>
<pre><code> public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
try
{
if (activity.Type == ActivityTypes.Message)
{
UserActivityLogger.LogUserBehaviour(activity);
if (activity.Text.ToLower() == "start over")
{
//Do something here, but I don't have the IDialogContext here!
}
BotUtils.SendTyping(activity); //send "typing" indicator upon each message received
await Conversation.SendAsync(activity, () => new RootDialog());
}
else
{
HandleSystemMessage(activity);
}
}
</code></pre>
<p>I know how to terminate a dialog with <code>context.Done<DialogType>(this);</code>, but in this method, I do not have access to the IDialogContext object, so I cannot call <code>.Done()</code>. </p>
<p>Is there any other way to terminate the whole dialog stack when the user types a certain message, other than adding a check for that in each step of all dialogs?</p>
<p><strong>Posted bounty:</strong></p>
<p>I need a way to terminate all <code>IDialog</code>s without using the outrageous hack that I've posted here (which deletes all user data, which I need, e.g. user settings and preferences). </p>
<p>Basically, when the user types "quit" or "exit", I need to exit whatever <code>IDialog</code> is currently in progress and return to the fresh state, as if the user has just initiated a conversation. </p>
<p>I need to be able to do this from <code>MessageController.cs,</code> where I still do not have access to <code>IDialogContext</code>. The only useful data I seem to have there is the <code>Activity</code> object. I will be happy if someone points out to other ways to do that. </p>
<p>Another way to approach this is find some other way to check for the "exit" and "quit" keywords at some other place of the bot, rather than in the Post method.</p>
<p>But it shouldn't be a check that is done at every single step of the <code>IDialog</code>, because that's too much code and not even always possible (when using <code>PromptDialog</code>, I have no access to the text that the user typed). </p>
<p><strong>Two possible ways that I didn't explore:</strong> </p>
<ul>
<li>Instead of terminating all current <code>IDialog</code>s, start a new conversation
with the user (new <code>ConversationId</code>) </li>
<li>Obtain the <code>IDialogStack</code> object and do something with it to manage the dialog stack.</li>
</ul>
<p>The Microsoft docs are silent on this object so I have no idea how to get it. I do not use the <code>Chain</code> object that allows <code>.Switch()</code> anywhere in the bot, but if you think it can be rewritten to use it, it can be one of the ways to solve this too. However, I haven't found how to do branching between various types of dialogs (<code>FormFlow</code> and the ordinary <code>IDialog</code>) which in turn call their own child dialogs etc.</p> | 0 |
Getting error using mvn spring-boot:run "A child container fail to start" | <p>If I am run using my spring tool suites, then it's working fine, but while running using command prompt <strong>mvn spring-boot:run</strong> I am getting these error:</p>
<pre><code>8564: ERROR ContainerBase - A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_71]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_71]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.30.jar:8.0.30]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_71]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_71]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_71]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) [tomcat-embed-core-8.0.30.jar:8.0.30]
... 6 common frames omitted
Caused by: java.lang.SecurityException: class "javax.servlet.http.HttpSessionIdListener"'s signer information does not match signer information of other classes in the sa
ackage
at java.lang.ClassLoader.checkCerts(ClassLoader.java:895) ~[na:1.8.0_71]
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:665) ~[na:1.8.0_71]
at java.lang.ClassLoader.defineClass(ClassLoader.java:758) ~[na:1.8.0_71]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_71]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[na:1.8.0_71]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_71]
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[na:1.8.0_71]
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[na:1.8.0_71]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_71]
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[na:1.8.0_71]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_71]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_71]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4752) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
... 6 common frames omitted
8564: ERROR ContainerBase - A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_71]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_71]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:344) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:89) [spring-boot-1.2.8.RELEASE.j
.2.8.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:76) [spring-boot-1.2.8.RELEASE.jar:1
.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.
:384) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:1
[spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159) [spring-boot-1.2
ELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) [spring-boot-1.2.8.RELEASE.jar:1.2.8.
ASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474) [spring-context-4.1.9.RELEASE.jar:4.1.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RE
E]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:690) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:970) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:959) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at com.hm.msp.event.EventHubServer.main(EventHubServer.java:23) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_71]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_71]
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:478) [spring-boot-maven-plugin-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_71]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) [tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_71]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_71]
... 1 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.0.30.jar:8.0.30]
... 6 common frames omitted
8564: WARN AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.
icationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to st
embedded Tomcat
8564: ERROR SpringApplication - Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServlet
ainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.2.8.RELEASE.jar:1.2.8
EASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474) ~[spring-context-4.1.9.RELEASE.jar:4.1.9.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.2.8.RELEASE.jar:1.2.8.R
SE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:690) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:970) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:959) [spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at com.hm.msp.event.EventHubServer.main(EventHubServer.java:23) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_71]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_71]
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:478) [spring-boot-maven-plugin-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_71]
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99) ~[spring-boot-1.2.8.RELEASE.
1.2.8.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:76) ~[spring-boot-1.2.8.RELEASE.jar:
8.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.
:384) ~[spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:1
~[spring-boot-1.2.8.RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159) ~[spring-boot-1.
RELEASE.jar:1.2.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.2.8.RELEASE.jar:1.2.8
EASE]
... 13 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:344) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:89) ~[spring-boot-1.2.8.RELEASE.
1.2.8.RELEASE]
... 18 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
... 20 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
... 22 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.0.30.jar:8.0.30]
... 24 common frames omitted
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:478)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.Embe
ServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:690)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:970)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:959)
at com.hm.msp.event.EventHubServer.main(EventHubServer.java:23)
... 6 more
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:76)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.
:384)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:1
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 13 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:344)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:89)
... 18 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 20 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 22 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 24 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.858 s
[INFO] Finished at: 2016-08-16T16:33:40+05:30
[INFO] Final Memory: 50M/521M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE:run (default-cli) on project core.eventhub: An exception occurred while run
. null: InvocationTargetException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Un
to start embedded Tomcat: Failed to start component [StandardServer[-1]]: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[
at]]: A child container failed during start -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
</code></pre>
<p>This is the pom.xml I am using ,</p>
<pre><code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hm.msp.services</groupId>
<artifactId>sample.springboot</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>sample-server</name>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Angel.SR6</version>
</parent>
<properties>
<start-class>com.hm.msp.event.Main</start-class>
<mstack.version>2.0.1</mstack.version>
<json-lib.version>2.4</json-lib.version>
<msp.blp.version>0.2.0</msp.blp.version>
<msp.collection.version>2.0.1</msp.collection.version>
<msp.bundle.version>0.2.0</msp.bundle.version>
<camel.version>2.17.0</camel.version>
<xbean-spring-version>4.5</xbean-spring-version>
<!--following activemq version has dependencies. If you upgrade activemq
libs make sure to pick up the right version -->
<activemq-version>5.11.1</activemq-version>
<activemq-pool-version>5.7.0</activemq-pool-version>
<logback-version>1.1.3</logback-version>
<storm.version>0.10.0</storm.version>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
<!-- <exclusions>
<exclusion>
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions> -->
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<!-- Testing starter -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<!-- Setup Spring Data JPA Repository support -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- Spring Cloud starter -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!-- Swagger dependency for mIDAS webservice -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>${storm.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j-slf4j-impl</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-kafka</artifactId>
<version>${camel.version}</version>
<exclusions>
<exclusion>
<artifactId>netty</artifactId>
<groupId>io.netty</groupId>
</exclusion>
</exclusions>
</dependency
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.3.3.RELEASE</version>
<configuration>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
</code></pre> | 0 |
Mongorestore in a Dockerfile | <p>I want to create a Docker image that starts a mongo server and automatically restores from a previous <code>mongodump</code> on startup.</p>
<hr>
<p>Here is my Dockerfile for the image:</p>
<pre><code> FROM mongo
COPY dump /home/dump
CMD mongorestore /home/dump
</code></pre>
<p>When I run this, I run into this error:</p>
<blockquote>
<p><code>Failed: error connecting to db server: no reachable servers</code></p>
</blockquote>
<hr>
<p><strong>Is there any way to get the <code>mongorestore</code> command to run through Docker?</strong></p> | 0 |
Connect R to a SQL Server database engine | <p>At my work I have R-Studio (Microsoft R Open 3.2.5) installed and would like to connect to a Microsoft SQL Server database, to run scripts using the tables I have. </p>
<p>Is there any chance that I can connect to a SQL Server database using Pentaho and then using the object Execute R-Script to make an OLAP Cube?
Do I need a package to connect SQL engine?
What would be the steps to perform?</p>
<p>I already have the snowflake arquitectura of the data base. With the fact table and the state tables. But I do not know where to start.</p> | 0 |
SQL Azure Integrated Authentication with a cloud-only Azure Active Directory fails | <p>I have created an Azure tenancy and configured the following: </p>
<p><strong>Azure AD with:</strong></p>
<ul>
<li>A simple custom domain name (less than 15 characters). DNS verified etc. All good.</li>
<li>Users and Admins groups</li>
<li>Users in both groups</li>
<li>A VNET and DNS and IP Addresses</li>
<li>Enabled Device Management</li>
<li>Enabled Domain Services and connected to the VNET</li>
</ul>
<p><em>Note that there is nothing on premise, this is all in the cloud. My physical laptop is effectively being used just as a jump box.</em> </p>
<p><strong>A SQL Azure database and server with:</strong></p>
<ul>
<li>Firewall rules open for all necessary incoming connections</li>
<li>An Active Directory admin set as the Admins group I created in Azure AD</li>
<li>The AD users all created in SQL Azure using CREATE USER FROM EXTERNAL PROVIDER;</li>
</ul>
<p><em>I can connect fine to the SQL Azure database from SSMS on my laptop using either Active Directory Universal Authentication or Active Directory Password Authentication. For both of these I get challenged for the username and password as would be expected.</em></p>
<p><strong>Objective:</strong>
I want to be able to use integrated authentication so that can seamlessly flow identity from a) A machine, b) A ASP.NET MVC site. I have not tried Scenario b yes, so let's park that. For scenario a, I have done the following. </p>
<p>Configured an Azure VM:</p>
<ul>
<li>Standard D2 - Windows 10 fully patched</li>
<li>Connected to the same VNET as the domain</li>
<li>SQL Server Management Server 2016 (SSMS) installed (latest and patched - 13.0.15700.28)</li>
<li>ODBC 13.1 installed (though I think this is not relevant)</li>
<li>ADAL</li>
<li>Microsoft Online Services Sign-In Assistant for IT Professionals RTW</li>
</ul>
<p><em>In short, my full "environment" consists of an Azure AD, A SQL Azure DB and a client VM.</em> </p>
<p><strong>Problem:</strong>
I join the VM to my Azure Active Directory using Directory Services, sign out and log in as a valid domain user (valid in AD and SQL Azure with appropriate logins and permissions). When I open SSMS I can connect fine with Active Directory Universal Authentication or Active Directory Password Authentication but when I try connect with Active Directory Authenticated Security, I get the error below. This also happens if I join the VM directly to Azure AD. My deployment is 100% cloud, so there is no federation in place. </p>
<p>So I have two questions: </p>
<ul>
<li>Am I missing something in my configuration or approach or is there a work around? <a href="https://connect.microsoft.com/SQLServer/feedback/details/3101098/active-directory-integrated-authentication-add-support-for-aad-ds-joined-vms" rel="nofollow">It may be an existing issue - see here</a></li>
<li>Would this connectivity (pass through) work if coded in .net 4.6.2 with C# and deployed in the cloud? Possibly with the ODBC 13.1 driver?</li>
</ul>
<p>Thanks</p>
<blockquote>
<p>===================================</p>
<p>Cannot connect to .database.windows.net.</p>
<p>===================================</p>
<p>Failed to authenticate the user NT Authority\Anonymous Logon in Active
Directory (Authentication=ActiveDirectoryIntegrated). Error code
0xCAA9001F; state 10 Integrated Windows authentication supported only
in federation flow. (.Net SqlClient Data Provider)</p>
<p>------------------------------ For help, click: <a href="http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=0&LinkId=20476" rel="nofollow">http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=0&LinkId=20476</a></p>
<p>------------------------------ Server Name: .database.windows.net Error Number: 0 Severity: 11 State: 0
Procedure: ADALGetAccessToken</p>
<p>------------------------------ Program Location:</p>
<p>at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions
userOptions) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource<code>1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource</code>1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource<code>1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource</code>1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1
retry) at System.Data.SqlClient.SqlConnection.Open() at
Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo
ci, IServerType server) at
Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()</p>
</blockquote> | 0 |
Error in ui kit Consistency error | <p>I am having a issue accesing a text box in a view controller .cs file</p>
<pre><code> async partial void loginUser(UIButton sender)
{
// Show the progressBar as the MainActivity is being loade
Console.WriteLine("Entered email : " + txtEmail.Text);
// Create user object from entered email
mCurrentUser = mJsonHandler.DeserialiseUser(txtEmail.Text);
try
{
Console.WriteLine("Starting network check");
// Calls email check to see if a registered email address has been entered
if (EmailCheck(txtEmail.Text) == true)
{
await CheckPassword();
}
else
{
UIAlertView alert = new UIAlertView()
{
Title = "Login Alert",
Message = "Incorrect email or password entered"
};
alert.AddButton("OK");
alert.Show();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("An error has occured: '{0}'", ex);
}
</code></pre>
<p>It is within this funciton that it complains it cannot access a text box which is on a aynsc method</p>
<pre><code> public Task CheckPassword()
{
return Task.Run(() =>
{
// Creates instance of password hash to compare plain text and encrypted passwords.
PasswordHash hash = new PasswordHash();
// Checks password with registered user password to confirm access to account.
if (hash.ValidatePassword(txtPassword.Text ,mCurrentUser.password)==true)
{
Console.WriteLine("Password correct");
UIAlertView alert = new UIAlertView()
{
Title = "Login Alert",
Message = "Password Correct Loggin In"
};
alert.AddButton("OK");
alert.Show();
//insert intent call to successful login here.
}
else
{
UIAlertView alert = new UIAlertView()
{
Title = "Login Alert",
Message = "Incorrect email or password entered"
};
alert.AddButton("OK");
alert.Show();
}
Console.WriteLine("Finished check password");
});
}
</code></pre>
<p>Its this line the error occurs:</p>
<pre><code>txtPassword.Text
</code></pre>
<p>The error is as follows: </p>
<blockquote>
<p>UIKit.UIKitThreadAccessException: UIKit Consistency error: you are
calling a UIKit method that can only be invoked from the UI thread.</p>
</blockquote>
<p>Also my Password Correct does not show even though if it is a correct password.
Do i have to run the UI Alerts on a seperate thread?</p> | 0 |
Get and Set class of an element in AngularJs | <p>I've added the ng-click to my icon like this:</p>
<pre><code><img src="images/customer_icon.png" class="customer" ng-click="processForm($event)">
</code></pre>
<p>And here's the js-file.</p>
<pre><code> var app = angular.module('myapp', []);
app.controller('mycontroller', function($scope) {
$scope.processForm = function(obj) {
var elem = angular.element(obj);
alert("Current class value: " + elem.getAttribute("class"));
};
});
</code></pre>
<p>I'm getting the "elem.getAttribute is not a function" error. Trying to switch "class" to "ng-class", i faced another problem: "ng-class" is not recognised by my css files. </p>
<p>Is there any way I can get/set the "class" attribute directly?</p> | 0 |
Angular2 - 'then' does not exist on type 'void' | <p>I try simple app where I delete user after clicking on delete button.</p>
<p>When I try to run server like this I get error on <code>then</code> in <code>deleteUser()</code>
component:</p>
<pre><code> deleteUser(user: User, event: any) {
event.stopPropagation();
this.userService
.deleteUser(user)
.then(res => {
this.httpUsers = this.httpUsers.filter(h => h !== user);
if (this.selectedUser === user) { this.selectedUser = null; }
})
.catch(error => this.error = error);
}
</code></pre>
<p>service:</p>
<pre><code> deleteUser(user: User) {
console.log('Deleting user');
}
</code></pre>
<p>Error message:</p>
<blockquote>
<p>app/users.component.ts(46,8): error TS2339: Property 'then' does not
exist on type 'void'.</p>
</blockquote>
<p>Line 46 from error is one above with <code>.then(res => {</code></p>
<p>While googling I found <a href="https://stackoverflow.com/questions/37986102/property-then-does-not-exist-on-type-void">this question</a> so I removed void from deleteUser function, however nothing changed.</p>
<p><strong>Any hint what I'm doing wrong?</strong></p> | 0 |
How to Set & Get in angular2-localstorage? | <p>From this <a href="https://github.com/marcj/angular2-localstorage" rel="nofollow noreferrer">repo</a>, I've successfully configured this:</p>
<pre><code>import {Component} from "angular2/core";
import {LocalStorageService} from "angular2-localstorage/LocalStorageEmitter";
@Component({
provider: [LocalStorageService]
})
export class AppRoot{
constructor(private storageService: LocalStorageService){}
...
}
</code></pre>
<p>How can I use storageService to set or get in local storage? I can't find example anywhere even in the doc. </p>
<h2>Updated</h2>
<p>After some testing, I've managed it to get it working with Decorator through WebStorage:</p>
<pre><code>import {LocalStorage, SessionStorage} from "angular2-localstorage/WebStorage";
@Component({})
export class LoginComponent implements OnInit {
@LocalStorage() public username:string = 'hello world';
ngOnInit() {
console.log('username', this.username);
// it prints username hello world
}
}
</code></pre>
<p>However, when I used Chrome Dev to see my localstorage, I see nothing there:
<a href="https://i.stack.imgur.com/5fTD9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5fTD9.png" alt="enter image description here"></a></p>
<p>And In another component, </p>
<pre><code>import {LocalStorage, SessionStorage} from "angular2-localstorage/WebStorage";
@Component({})
export class DashboardComponent implements OnInit {
@LocalStorage() public username:string;
ngOnInit() {
console.log(this.username);
// it prints null
}
}
</code></pre> | 0 |
What SQL Functions are Available in NetSuite saved searches? | <p>What SQL functions are available in NetSuite saved searches (formulas)?</p> | 0 |
Get Total Number of Cores from a computer WITHOUT HyperThreading | <p>This is a tough one.</p>
<p>I need to use a command to output the exact number of cores from my servers.</p>
<p>My tests: </p>
<ul>
<li><strong><code>X</code>:</strong> On a Windows server with 4 processors (sockets) and 2 cores each without HT.</li>
<li><strong><code>Y</code>:</strong> On a Windows Server with 2 processors (sockets) and 6 cores each with HT.</li>
</ul>
<p><strong><a href="https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getsysteminfo" rel="noreferrer">GetSystemInfo</a></strong> only gets me the number of processors installed: 4 for X, 2 for Y.</p>
<pre><code>| | X: 8 cores | Y: 12 cores |
| | 4x2 (no HT) | 2x6 (HT) |
|----------------|-------------|-------------|
| Desired output | 8 | 12 |
| GetSystemInfo | 4 | 2 |
</code></pre>
<p><code>%NUMBER_OF_PROCESSORS%</code> is a good one, but it takes HT into account. It tells me 8 for X and 24 for Y (since it has HT, I needed it to show 12 instead).</p>
<pre><code>| | X: 8 cores | Y: 12 cores |
| | 4x2 (no HT) | 2x6 (HT) |
|------------------------|-------------|-------------|
| Desired output | 8 | 12 |
| GetSystemInfo | 4 | 2 |
| %NUMBER_OF_PROCESSORS% | 8 | 24 |
</code></pre>
<p><code>"wmic cpu get NumberOfCores"</code> gets me info for each socket. For example:</p>
<p><strong>X:</strong></p>
<pre><code>>wmic cpu get NumberOfCores
NumberOfCores
2
2
2
2
</code></pre>
<p><strong>Y:</strong></p>
<pre><code>>wmic cpu get NumberOfCores
NumberOfCores
6
6
</code></pre>
<p>Meaning</p>
<pre><code>| | X: 8 cores | Y: 12 cores |
| | 4x2 (no HT) | 2x6 (HT) |
|----------------------------|-------------|-------------|
| Desired output | 8 | 12 |
| GetSystemInfo | 4 | 2 |
| %NUMBER_OF_PROCESSORS% | 8 | 24 |
| wmic cpu get NumberOfCores | 2,2,2,2 | 6,6 |
</code></pre>
<p>Sigh.</p>
<p>I wished to keep it simple, inside the CMD, but I'm thinking about starting a Powershell script to do all that math and stuff.</p>
<p>Any thoughts?</p> | 0 |
difference between int and Integer type in groovy | <p>I have just started learning groovy and I am reading "Groovy in Action".
In this book I came across a statement that <strong>it doesn’t matter whether you declare or cast a variable to be of type int or Integer.Groovy uses the reference type ( Integer ) either way.</strong></p>
<p>So I tried to assign <strong>null</strong> value to a variable with type <strong>int</strong></p>
<pre><code>int a = null
</code></pre>
<p>But it is giving me below exception</p>
<blockquote>
<p>org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead
at Script1.run(Script1.groovy:2)</p>
</blockquote>
<p>Then I tried to assign <strong>null</strong> value to a variable with type <strong>Integer</strong></p>
<pre><code>Integer a = null
</code></pre>
<p>and it is working just fine.</p>
<p>Can anyone help me understand how <code>groovy</code> behaves such way or the reason behind it?</p> | 0 |
How can I create a PNG blob from binary data in a typed array? | <p>I have some binary data that happens to be a PNG. I'd like turn it into a blob, get a URL for the blob and display it as an image (or any places else an image URL is valid like css etc..)</p>
<p>Here's what I tried. First I made a small 8x8 red square with yellow "F" image and used pngcrush to make it smaller</p>
<p>You can see the original 91 byte image displays just fine (it's only 8x8 pixels)</p>
<p><img src="https://greggman.github.io/doodles/assets/tiny-crush.png" alt="91 byte png"></p>
<p>Then, for this sample, I converted that to an JavaScript array, I copy it into a Uint8Array, I make a blob from that and a URL from the blob, assign that to an image but the image does not display.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var data = new Uint8Array([
137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,8,0,0,
0,8,8,2,0,0,0,75,109,41,220,0,0,0,34,73,68,65,84,8,215,99,120,
173,168,135,21,49,0,241,255,15,90,104,8,33,129,83,7,97,163,136,
214,129,93,2,43,2,0,181,31,90,179,225,252,176,37,0,0,0,0,73,69,
78,68,174,66,96,130]);
var blob = new Blob(data, { type: "image/png" });
var url = URL.createObjectURL(blob);
var img = new Image();
img.src = url;
console.log("data length: " + data.length);
document.body.appendChild(img);</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>img { width: 100px; height: 100px; }</code></pre>
</div>
</div>
</p>
<p>How can I get it to display as a blob url?</p> | 0 |
How to capture value of dropdown widget in bokeh python? | <p>The official documentation of bokeh 0.12.1 in the link give the below code for creating a dropdown. </p>
<p><a href="http://docs.bokeh.org/en/latest/docs/user_guide/interaction/widgets.html#userguide-interaction-widgets" rel="nofollow noreferrer">http://docs.bokeh.org/en/latest/docs/user_guide/interaction/widgets.html#userguide-interaction-widgets</a></p>
<p>But it doesn't clearly mention how to capture the value of the dropdown widget when someone click and selects a value from the dropdown.</p>
<pre><code>from bokeh.io import output_file, show
from bokeh.layouts import widgetbox
from bokeh.models.widgets import Dropdown
output_file("dropdown.html")
menu = [("Item 1", "item_1"), ("Item 2", "item_2"), None, ("Item 3", "item_3")]
dropdown = Dropdown(label="Dropdown button", button_type="warning", menu=menu)
show(widgetbox(dropdown))
</code></pre>
<p><strong>Question</strong></p>
<p>Is see that there are 2 methods called on_click() & on_change() but from the documentation couldn't figure out how to capture the value.
How can we assign the selected value to a new variable?</p>
<p><strong>EDIT</strong></p>
<p>Based on input from @Ascurion i have updated my code as shown below. But when i select a value in dropdown nothing is printed in ipython console in Spyder.
Please advise.</p>
<pre><code> from bokeh.io import output_file, show
from bokeh.layouts import widgetbox
from bokeh.models.widgets import Dropdown
output_file("dropdown.html")
menu = [("Item 1", "item_1"), ("Item 2", "item_2"), None, ("Item 3", "item_3")]
dropdown = Dropdown(label="Dropdown button", button_type="warning", menu=menu)
def function_to_call(attr, old, new):
print dropdown.value
dropdown.on_change('value', function_to_call)
dropdown.on_click(function_to_call)
show(widgetbox(dropdown))
</code></pre> | 0 |
How to create a Grouped TableView with sections programmatically in Swift | <p>I would like to know how to create a grouped/sectioned tableview programmatically. The design I am trying to create is this:</p>
<p><a href="https://i.stack.imgur.com/j6bL6.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/j6bL6.jpg" alt="enter image description here"></a></p>
<p>I want there to be a <code>UIImageView</code> at the top with a 160 height, followed by 3 sections, each with a different number of rows. I will then place static labels in each row and then update their labels with my data.</p>
<p>My code for this VC is as follows:</p>
<pre><code>import UIKit
class SelectedFilmTableViewController: UITableViewController {
var film: Film? {
didSet {
navigationItem.title = film?.Film_Name
}
}
var cellId = "cellId"
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: cellId)
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(cellId, forIndexPath: indexPath) as UITableViewCell
cell.textLabel?.text = film?.Directed_By
cell.detailTextLabel?.text = film?.Film_Poster_Image_URL
return cell
}
}
</code></pre>
<p>I have tried adding the method to state the <code>numberOfSections</code> etc but I don't seem to see them when I build the app. All I see is a normal looking tableview. Am I missing some setup?</p>
<p>Because I am navigating to this VC programmatically, I need to set this up without using the storyboard. </p>
<p>Any help on how to create the look I need above is appreciated, thanks!</p> | 0 |
Fixed height for bootstrap pre-scrollable DIV | <p>In my application I have to display bootsatarp grid for database records. Since the number of records count are large enough to view without full page scrolling I wrap my table with bootstrap pre-scrollable div and it gave me the functionality to scroll the table. However all the time DIV size is half of the browser windows. I tried almost every stack overflow posts and suggestions and simply they not work for me. I also tried to fix this with support of java script and it also failed. </p>
<p>This is my HTML code </p>
<pre><code><div class="col-md-9">
<div class="pre-scrollable">
<table class="table table-bordered table-hover header-fixed" id="sometable">
<thead>
<tr>
<th>EMP_No</th>
<th>Name</th>
<th>Designation</th>
<th>Department</th>
<th>Type</th>
<th>#Days</th>
<th>Start Date</th>
<th>End Date</th>
<th>Half day</th>
<th>Status</th>
</tr>
</thead>
<tbody>
</tbody>
<?php //php code for print the table
?>
</div>
</div>
</code></pre>
<p>I populate above table with the results of PHP code. I have not idea how to set this DIV's height to fixed value or full value of the browser windows.below are the CSS that are use </p>
<pre><code><style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: center;
padding: 1px;
}
thead th {
text-align: center;
background-color: #3498db;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</code></pre>
<p><a href="http://imgur.com/a/pdowa" rel="noreferrer">This is the result web page</a></p> | 0 |
PostgreSQL could not open file "base/xxxx/xxxxx" no such file or directory | <p>Recently I had a Hardware failure on my linux machine and after fixing hardware problem and bringing back my linux machine up, when I execute query against one of my table, following error is returned.</p>
<pre><code>ERROR: could not open file "base/17085/281016": No such file or directory.
</code></pre>
<p>When checked in postgresql/base/17085 directory, file 281016 does not exist.</p>
<p>Would the issue be resolved if I create file manually by using below commands? or is it a bad approach causing more troubles in future?</p>
<pre><code>#touch 281016
#chown postgres:postgres 281016
#chmod 600 281016
</code></pre> | 0 |
extend a pipe like currency or number on a custom pipe on angular2 | <p>I would like to call the numberPipe on my custom pipe I find this answer </p>
<p><a href="https://stackoverflow.com/questions/35808272/angular2-use-basic-pipe-in-custom-pipe">Angular2 use basic pipe in custom pipe</a></p>
<p>but I this solution don't work for me. I have an error
"The pipe 'bigInteger' could not be found"</p>
<pre><code>import { Pipe, PipeTransform } from "@angular/core"
import { CurrencyPipe } from "@angular/common"
@Pipe({
name: "bigInteger"
})
export class BigInteger extends CurrencyPipe implements PipeTransform {
transform(value: any): string {
return value
}
}
</code></pre> | 0 |
if -OR statement with comparison operators not working as expected | <p>I have the following code snippet and I cannot figure out why the <code>if</code> is not working. </p>
<p>The goal is to get some input from the user, and if it is a valid input, carry on. If not, then keep asking until it is a valid entry. </p>
<p>No matter what value I enter on the first question (e.g. wmic), it ALWAYS goes into the <code>do loop</code>. When entering, say wmic, on the second pass, it breaks the do as desired. Invalid entries keep me in the loop until I enter a correct entry.</p>
<pre><code>$query_means = read-host 'Enter one of psinfo, powershell or wmic'
if ($query_means -ne "wmic" -OR $query_means -ne "psinfo" -OR $query_means -ne "powershell")
{
do {
$query_means = read-host 'Invalid entry. Enter one of psinfo, powershell or wmic'
}Until ($query_means -eq "wmic" -OR $query_means -eq "psinfo" -OR $query_means -eq "powershell")
}
</code></pre>
<p>The <code>until</code> comparisons works just fine, breaking when desired.</p> | 0 |
Loop through json using jq to get multiple value | <p>Here is volumes.json :</p>
<pre><code>{
"Volumes": [
{
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Value": "vol-rescue-system",
"Key": "Name"
}
],
"VolumeId": "vol-00112233",
},
{
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Value": "vol-rescue-swap",
"Key": "Name"
}
],
"VolumeId": "vol-00112234",
},
{
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Value": "vol-rescue-storage",
"Key": "Name"
}
],
"VolumeId": "vol-00112235",
}
]
}
</code></pre>
<p>I need to get both the value of <code>VolumeId</code> and <code>Tags.Value</code> to be used as the input to invoke another command. It is easy to get a single value from the json array, but I am not able to extract <strong>multiple value</strong> from it and pass it to another bash command. </p>
<p>I can get a single value using this:</p>
<pre><code>cat volumes.json |jq -r '.Volumes[].VolumeId' |while read v; do another_bash_command $v; done
</code></pre>
<p>but I am not able to get multiple value cause this is wrong:</p>
<pre><code> cat volumes.json |jq -r '.Volumes[].VolumeId, .Volumes[].Tags[].Value' |while read v w; do another_bash_command $v $w; done
</code></pre>
<p>as it will then loop 6 times of the outcome instead of 3.</p>
<p><strong>And</strong>, how do I pass those multiple json value in the loop to a bash array so I can use the value in a better way ? Like <code>VolumeId-> $arr[0][0]</code>, <code>Tags.Value-> $arr[0][1]</code>, <code>AvailabilityZone-> $arr[0][2]</code>...etc. I have searched through SO and the jq docs, and tried <code>readarray</code>, but still not able to find out the solution :( Thanks for any help given. </p> | 0 |
Use return value of a function as a string in Angular 2 | <p>This is the markup I want to place the returned value:</p>
<pre class="lang-html prettyprint-override"><code><h2>{{getSelectedUserName}}</h2>
</code></pre>
<p>This is the function I want to use, which returns a string:</p>
<pre class="lang-typescript prettyprint-override"><code>public getSelectedUserName(): string {
let firstName = this.selectedUser.name.split("\\s+")[0];
console.log(this.selectedUser.name.split("\\s+"));
console.log(firstName);
return firstName;
}
</code></pre> | 0 |
Sampling n= 2000 from a Dask Dataframe of len 18000 generates error Cannot take a larger sample than population when 'replace=False' | <p>I have a dask dataframe created from a csv file and <code>len(daskdf)</code> returns 18000 but when I <code>ddSample = daskdf.sample(2000)</code> I get the error</p>
<pre><code>ValueError: Cannot take a larger sample than population when 'replace=False'
</code></pre>
<p>Can I sample without replacement if the dataframe is larger than the sample size?</p> | 0 |
Google Sheets Error "Array Arguments to SUMIFS are of different size" | <p>Converting from an Excel file (where this works fine), I have a SUMIFS formula that is returning an error "Array Arguments to SUMIFS are of different size". The formula in question looks like this:</p>
<pre><code>=SUMIFS($G9:$EA9,$F$2:$DZ$2,">=1/1/"&A$2,$F$2:$DZ$2,"<=12/31/"&A$2)
</code></pre>
<p>The array arguments are:</p>
<ul>
<li>G9:EA9 - 125 columns, 1 row</li>
<li>F2:DZ2 - 125 columns, 1 row</li>
<li>F2:DZ2 - 125 columns, 1 row</li>
</ul>
<p>The criteria arguments are values. I'm not looking for a workaround or hack - just want to know if I'm somehow misusing the SUMIFS formula so I can maintain consistency with Excel</p> | 0 |
Is there a way to view whitespace in SQL Server Management Studio 2016? | <p>It doesn't look to me like there's any menu option which enables whitespace to be viewed in the text editor.</p>
<p>There's a similar question <a href="https://stackoverflow.com/questions/2760124/is-there-any-way-to-view-whitespace-in-the-query-editor-for-sql-server-managemen" title="Is there any way to view whitespace in the query editor for SQL Server Management Studio Express 2005?">here</a>, however this is referring to SSMS Express 2005 . An answer to this question shows how whitespace viewing can be enabled by editing registry values. However, i don't have that path specified in my registry. (I've checked each dir in the SQL Server registry and can't find a 'Visible Whitespace' entry)</p>
<p>I am using <code>SQL Server Management Studio 2016 (v 13.0.15500.91)</code></p>
<p>Surely there must be a way to achieve this. It's not really required but I would like my settings to match my other versions of SSMS.</p> | 0 |
thresholds in roc_curve in scikit learn | <p>I am referring to the below link and sample, and post the plot diagram from this page where I am confused. My confusion is, there are only 4 threshold, but it seems the roc curve has many data points (> 4 data points), wondering how roc_curve working underlying to find more data points?</p>
<p><a href="http://scikit-learn.org/stable/modules/model_evaluation.html#roc-metrics" rel="noreferrer">http://scikit-learn.org/stable/modules/model_evaluation.html#roc-metrics</a></p>
<pre><code>>>> import numpy as np
>>> from sklearn.metrics import roc_curve
>>> y = np.array([1, 1, 2, 2])
>>> scores = np.array([0.1, 0.4, 0.35, 0.8])
>>> fpr, tpr, thresholds = roc_curve(y, scores, pos_label=2)
>>> fpr
array([ 0. , 0.5, 0.5, 1. ])
>>> tpr
array([ 0.5, 0.5, 1. , 1. ])
>>> thresholds
array([ 0.8 , 0.4 , 0.35, 0.1 ])
</code></pre>
<p><a href="https://i.stack.imgur.com/s3AVy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/s3AVy.png" alt="enter image description here"></a></p> | 0 |
How can I get the status code from an HTTP error in Axios? | <p>This may seem stupid, but I'm trying to get the error data when a request fails in Axios.</p>
<pre class="lang-js prettyprint-override"><code>axios
.get('foo.example')
.then((response) => {})
.catch((error) => {
console.log(error); //Logs a string: Error: Request failed with status code 404
});
</code></pre>
<p>Instead of the string, is it possible to get an object with perhaps the status code and content? For example:</p>
<pre><code>Object = {status: 404, reason: 'Not found', body: '404 Not found'}
</code></pre> | 0 |
How to toggle between bootstrap button classes onClick? | <p>I am using Bootstrap buttons and would like them to change color when clicked. For example, the button is originally gray (btn-default) and should change to green (btn-success) on click. I would like the button to change back to the default class when clicked again. So far I have created an if statement and added the following code, however it is only changing color once, and will not return to the default class when clicked again.</p>
<pre><code>$("#critical_btn").click(function () {
if (this.class= 'btn-default'){
$('#critical_btn').removeClass('btn-default').addClass('btn-success ');
$(this).addClass('btn-success').removeClass('btn-default');
}
else if (this.class= 'btn-success'){
$('#critical_btn').removeClass('btn-success').addClass('btn-default ');
$(this).addClass('btn-default').removeClass('btn-success');
}
});
</code></pre>
<p>I am fairly new to this, so any help would be greatly appreciated!</p> | 0 |
pandas get_level_values for multiple columns | <p>Is there a way to get the result of <a href="http://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.Index.get_level_values.html" rel="noreferrer"><code>get_level_values</code></a> for more than one column?</p>
<p>Given the following <code>DataFrame</code>:</p>
<pre><code> d
a b c
1 4 10 16
11 17
5 12 18
2 5 13 19
6 14 20
3 7 15 21
</code></pre>
<p>I wish to get the values (<em>i.e.</em> list of tuples) of levels <code>a</code> and <code>c</code>:</p>
<pre><code>[(1, 10), (1, 11), (1, 12), (2, 13), (2, 14), (3, 15)]
</code></pre>
<p><strong>Notes:</strong></p>
<ul>
<li><p>It is impossible to give <code>get_level_values</code> more than one level (<em>e.g.</em> <code>df.index.get_level_values(['a','c']</code>)</p></li>
<li><p>There's a workaround in which one could use <code>get_level_values</code> over each desired column and <code>zip</code> them together:</p></li>
</ul>
<p>For example:</p>
<pre><code>a_list = df.index.get_level_values('a').values
c_list = df.index.get_level_values('c').values
print([i for i in zip(a_list,c_list)])
[(1, 10), (1, 11), (1, 12), (2, 13), (2, 14), (3, 15)]
</code></pre>
<p>but it get cumbersome as the number of columns grow.</p>
<ul>
<li>The code to build the example <code>DataFrame</code>:</li>
</ul>
<p><code>df = pd.DataFrame({'a':[1,1,1,2,2,3],'b':[4,4,5,5,6,7,],'c':[10,11,12,13,14,15], 'd':[16,17,18,19,20,21]}).set_index(['a','b','c'])</code></p> | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.