title
stringlengths 15
150
| body
stringlengths 38
32.9k
| label
int64 0
3
|
---|---|---|
Flask-WTF: CSRF token missing | <p>What seemed like a simple bug - a form submission that won't go through due to a "CSRF token missing" error - has turned into a day of hair pulling. I have gone through every SO article related to Flask or Flask-WTF and missing CSRF tokens, and nothing seems to be helping. </p>
<p>Here are the details:</p>
<p>Following <a href="https://stackoverflow.com/a/21501593/5578714" title="Martijin's guidelines">Martijin's guidelines</a> to an earlier question:</p>
<blockquote>
<p>The Flask-WTF CSRF infrastructure rejects a token if:</p>
<p>1) the token is missing. Not the case here, you can see the token in the form.</p>
</blockquote>
<p>The token is definitely present in my form, and being POST'ed successfully</p>
<blockquote>
<p>2) it is too old (default expiration is set to 3600 seconds, or an hour).
Set the TIME_LIMIT attribute on forms to override this. Probably not the
case here.</p>
</blockquote>
<p>Also OK for me - the token is well within the default expiration time </p>
<blockquote>
<p>3) if no 'csrf_token' key is found in the current session. You can
apparently see the session token, so that's out too.</p>
</blockquote>
<p>In my case, session['csrf_token'] is properly set and seen by Flask</p>
<blockquote>
<p>4) If the HMAC signature doesn't match; the signature is based on the
random value set in the session under the 'csrf_token' key, the
server-side secret, and the expiry timestamp in the token.</p>
</blockquote>
<p><strong>This is my problem</strong>. The HMAC comparison between the submitted form's CSRF and the session CSRF fails. And yet I don't know how to solve it. I've been desperate enough (as with the other questioner) to dig into Flask-WTF code and set debugging messages to find out what's going on. As best I can tell, it's working like this:</p>
<p>1) <code>generate_csrf_token()</code> in "form.py" (Flask-WTF) wants to generates a CSRF token. So it calls:</p>
<p>2) <code>generate_csrf()</code> in "csrf.py". That function generates a new session['csrf_token'] if one does not exist. <strong>In my case, this always happens</strong> - although other session variables appear to persist between requests, my debugging shows that I <strong>never</strong> have a 'csrf_token' in my session at the start of a request. Is this normal?</p>
<p>3) The generated token is returned and presumably incorporated into the form variable when I render hidden fields on the template. (again, debugging shows that this token is present in the form and properly submitted and received)</p>
<p>4) Next, the form is submitted.</p>
<p>5) Now, <code>validate_csrf</code> in csrf.py is called. But since another request has taken place, and generate_csrf() has generated a new session CSRF token, the two timestamps for the two tokens (in session and from the form) will not match. And since the CSRF is made up in part by expiration dates, therefore validation fails.</p>
<p>I suspect the problem is in step #2, where a new token is being generated for every request. But I have no clue why <strong>other</strong> variables in my session are persisting from request to request, but not "csrf_token".</p>
<p>There is no weirdness going on with SECRET_KEY or WTF_CSRF_SECRET_KEY either (they are properly set).</p>
<p>Anyone have any ideas?</p> | 0 |
Jenkins server is running slow | <p>My Jenkins server is so slow. Java takes 120% or CPU. How can I give Jenkins more memory access.</p>
<p>Of what steps can I take to improve the load time for Jenkins </p> | 0 |
Angular 2 Unit Tests: Cannot find name 'describe' | <p>I'm following <a href="https://angular.io/docs/ts/latest/guide/testing.html#!#jasmine-101" rel="noreferrer">this tutorial from angular.io</a></p>
<p>As they said, I've created hero.spec.ts file to create unit tests:</p>
<pre><code>import { Hero } from './hero';
describe('Hero', () => {
it('has name', () => {
let hero: Hero = {id: 1, name: 'Super Cat'};
expect(hero.name).toEqual('Super Cat');
});
it('has id', () => {
let hero: Hero = {id: 1, name: 'Super Cat'};
expect(hero.id).toEqual(1);
});
});
</code></pre>
<p>Unit Tests work like a charm. The problem is: I see some errors, which are mentioned in tutorial:</p>
<blockquote>
<p>Our editor and the compiler may complain that they don’t know what <code>it</code>
and <code>expect</code> are because they lack the typing files that describe
Jasmine. We can ignore those annoying complaints for now as they are
harmless.</p>
</blockquote>
<p>And they indeed ignored it. Even though those errors are harmless, it doesn't look good in my output console when I receive bunch of them.</p>
<p>Example of what I get:</p>
<blockquote>
<p>Cannot find name 'describe'.</p>
<p>Cannot find name 'it'.</p>
<p>Cannot find name 'expect'.</p>
</blockquote>
<p>What can I do to fix it?</p> | 0 |
Using docker-compose to set containers timezones | <p>I have a docker-compose file running a few Dockerfiles to create my containers. I don't want to edit my Dockerfiles to set timezones because they could change at any time by members of my team and I have a docker-compose.override.yml file to make local environment changes. However, one of my containers (a Selenium based one) seems to not pull host time zone and that causes problems for me. Based on that I want to enforce timezones on all my containers. In my Dockerfiles right now I do</p>
<pre><code>ENV TZ=America/Denver
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
</code></pre>
<p>And everything works fine. How do I replicate the same command in docker-compose syntax?</p> | 0 |
Variable 'a' implicitly has an 'any[]' type | <p>I try to run <code>npm start</code> for my angular2 project</p>
<p>but get this error:</p>
<pre><code> push_quick git:(master) npm start
> [email protected] start /Users/eladb/WorkspaceQa/SupporTool/src/main/webapp/html/push_quick
> tsc && concurrently "tsc -w" "lite-server"
app/shared/stringUtils.service.ts(8,9): error TS7005: Variable 'a' implicitly has an 'any[]' type.
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/6.3.1/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.3.1
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 2
npm ERR!
</code></pre>
<p>for this method:</p>
<pre><code>@Injectable()
export class StringUtilsService {
mapToFormParamsString( dict : any) : string{
var a:any[] = []
for (var key in dict) {
if (dict.hasOwnProperty(key)) {
a.push(key+"="+dict[key]);
}
}
return a.join("&");
}
}
</code></pre>
<p>how can i fix this?</p>
<p>changing <code>var a = string[]</code> or <code>var a = any[]</code></p>
<p>didn't help. same compilation error.</p>
<p>btw, I didn't have thi error when compiling with <code>ng start</code> or in intellij</p>
<p>Is <code>ng start</code> calling <code>mpn start</code> or visa versa ?</p> | 0 |
how to fix Call to a member function prepare() on string | <p>I have been trying to fix this error: <code>PHP Fatal error: Call to a member function prepare() on string in /home/...../lib/library.php on line 91</code>
I have also check this link: <a href="https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851">Reference - What does this error mean in PHP?</a>
and i don't seem to understand how to relate it to my problem at hand. Can anyone help? this is the script line affected: </p>
<pre><code>public function Login($username, $password)
{
try {
$db = DB();
$query = $db->prepare("SELECT user_id FROM users WHERE (username=:username OR email=:username) AND password=:password");
$query->bindParam("username", $username, PDO::PARAM_STR);
$enc_password = hash('sha256', $password);
$query->bindParam("password", $enc_password, PDO::PARAM_STR);
$query->execute();
if ($query->rowCount() > 0) {
$result = $query->fetch(PDO::FETCH_OBJ);
return $result->user_id;
} else {
return false;
}
} catch (PDOException $e) {
exit($e->getMessage());
}
}
</code></pre> | 0 |
access host's ssh tunnel from docker container | <p>Using ubuntu tusty, there is a service running on a remote machine, that I can access via port forwarding through an ssh tunnel from <code>localhost:9999</code>.</p>
<p>I have a docker container running. I need to access that remote service via the host's tunnel, from within the container.</p>
<p>I tried tunneling from the container to the host with <code>-L 9000:host-ip:9999</code> , then accessing the service through <code>127.0.0.1:9000</code> from within the container fails to connect. To check wether the port mapping was on, I tried
<code>
nc -luv -p 9999 # at host
nc -luv -p 9000 # at container
</code></p>
<p>following <a href="http://www.binarytides.com/netcat-tutorial-for-beginners/" rel="noreferrer">this, parag. 2</a> but there was no perceived communication, even when doing
<code>
nc -luv host-ip -p 9000
</code> at the container</p>
<p>I also tried mapping the ports via <code>docker run -p 9999:9000</code> , but this reports that the bind failed because the host port is already in use (from the host tunnel to the remote machine, presumably).</p>
<p>So my questions are</p>
<p>1 - How will I achieve the connection? Do I need to setup an ssh tunnel to the host, or can this be achieved with the docker port mapping alone?</p>
<p>2 - What's a quick way to test that the connection is up? Via bash, preferably.</p>
<p>Thanks.</p> | 0 |
"Cannot inherit from non-open class" swift | <p>As of Xcode 8 beta 6 I now get the compile error "Cannot inherit from non-open class (Class)" outside of its defining module"</p>
<p>The class I was inheriting from was part of a separate Swift framework but my project compiled for Xcode 8 beta 5. What do I need to change to get my project to compile again?</p> | 0 |
Removing Duplicates From Array of Custom Objects Swift | <p>I have a custom class defined as follows : </p>
<pre><code>class DisplayMessage : NSObject {
var id : String?
var partner_image : UIImage?
var partner_name : String?
var last_message : String?
var date : NSDate?
}
</code></pre>
<p>Now I have an array <code>myChats = [DisplayMessage]?</code>. The <code>id</code> field is unique for each <code>DisplayMessage</code> object. I need to check my array and remove all duplicates from it, essentially ensure that all objects in the array have a unique <code>id</code>. I have seen some solutions using <code>NSMutableArray</code> and <code>Equatable</code> however I'm not sure how to adapt them here; I also know of <code>Array(Set(myChats))</code> however that doesn't seem to work for an array of custom objects.</p> | 0 |
Is there a way to use javascript variable inside Laravel blade template? | <p>I will automatically create the rows of a table in jQuery . by clicking addRow button , function addRow() will do it like below:</p>
<pre><code>function addRow(){
var rowCount = $("table tr").length - 1;
var row = '<tr><td><input name=“item[‘+ (rowCount+1) + ']" type="text" value="{{ old(‘item') }}”> @if ($errors->has(‘item’)){{ $errors->first(‘item’) }}@endif<td></tr>' ;
$("table").append(row);
}
</code></pre>
<p>I will call this method 5 times and it will create 5 input areas which name are item1. item2, item3, item4, item5.</p>
<p>in server side ,I use Laravel 5.2 Form Request Validation to validate every input field. </p>
<p>But if the validation failed , the old input and error will not set to the correct input field because </p>
<p>I can’t put the javascript variable rowCount into "{{ old(‘item') }}” which is a blade template.
and the same is {{ $errors->first(‘item’) }}.</p>
<p>I tried to write like this </p>
<pre><code>'value="{{ old('giftValue[' . $rowCount .']') }}">'
</code></pre>
<p>and this</p>
<pre><code>'value="{{ old('giftValue[' + $rowCount +’]’) }}">'
</code></pre>
<p>but does’t work.</p>
<p>does anyone have a good idea to solve this problem ?</p> | 0 |
Verilog - difference between %0d and %d | <p>I don't understand why some of the code example in the internet uses <code>%0d</code> to display the value of the variables and some of the code use <code>%d</code>? what are the difference between <code>%0d</code> and <code>%d</code>?</p>
<pre><code> data_1bit = {32{4'b1111}};
$display("data_1bit = %0d",data_1bit);
data_1bit_unsigned = {32{4'b1111}};
$display("data_1bit_unsigned = %d",data_1bit_unsigned);
</code></pre> | 0 |
searching gridview in asp.net C# | <p>I am trying to look for a way to search a grid view in asp.net using C# programming language. I dont want the grid view to have paging enabled. I would like it to bring up the result of the input typed in. E.g. If i typed in 's', all records starting with s would only be visible. </p>
<p>I have looked up on some sites which have databind in the code. </p>
<pre><code>GridView1.DataSource = dt;
GridView1.DataBind();
</code></pre>
<p>Do I need to have this? What does this do? </p>
<p>Can I please get some help with advice or links that can answer my question. Thank you. </p> | 0 |
How to set UTF-8 character encoding in Spring boot? | <p>I use spring-boot in my project, and I run this jar file which is built by spring-boot as a service on Centos. When I run this service: </p>
<blockquote>
<p>service myApp start</p>
</blockquote>
<p>I always get the below error messages:</p>
<pre><code>2016-08-26 09:11:02.002 ERROR 31900 --- [ main] o.s.b.c.FileEncodingApplicationListener : System property 'file.encoding' is currently 'ANSI_X3.4-1968'. It should be 'UTF-8' (as defined in 'spring.mandatoryFileEncoding').
2016-08-26 09:11:02.018 ERROR 31900 --- [ main] o.s.b.c.FileEncodingApplicationListener : Environment variable LANG is 'null'. You could use a locale setting that matches encoding='UTF-8'.
2016-08-26 09:11:02.018 ERROR 31900 --- [ main] o.s.b.c.FileEncodingApplicationListener : Environment variable LC_ALL is 'null'. You could use a locale setting that matches encoding='UTF-8'.
2016-08-26 09:11:02.031 ERROR 31900 --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalStateException: The Java Virtual Machine has not been configured to use the desired default character encoding (UTF-8).
at org.springframework.boot.context.FileEncodingApplicationListener.onApplicationEvent(FileEncodingApplicationListener.java:74) ~[spring-boot-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
</code></pre>
<p>If I run this jar file directly, then this application runs properly.</p>
<blockquote>
<p>java -jar target/myApp-1.0.jar</p>
</blockquote>
<pre><code> . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.7.RELEASE)
......
2016-08-26 09:54:34.954 DEBUG 32035 --- [ main] o.s.w.s.resource.ResourceUrlProvider : Found resource handler mapping: URL pattern="/**", locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@1817d444]
2016-08-26 09:54:35.051 INFO 32035 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8000 (http)
2016-08-26 09:54:35.053 DEBUG 32035 --- [ main] o.s.w.c.s.StandardServletEnvironment : Adding [server.ports] PropertySource with highest search precedence
2016-08-26 09:54:35.061 INFO 32035 --- [ main] co.nz.myApplication : Started myApplication in 12.339 seconds (JVM running for 13.183)
</code></pre>
<p>This is pom.xml:</p>
<pre><code><project>
....
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.7.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
....
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<jvmArguments>-Dfile.encoding=UTF8 -Dspring.profiles.active="production"</jvmArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
</code></pre>
<p>application.properties:</p>
<pre><code>....
spring.mandatory-file-encoding=UTF-8
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
....
</code></pre>
<p>locale setting on Centos:</p>
<pre><code>$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
</code></pre>
<p>I check all files setting as possible as I do, however I still have no idea how to solve this problem. I would appreciate if you can give me any suggestion.</p> | 0 |
How to check all select option value is not an empty? | <p>I'm having 5 select option drop down menu. Future it will get increase based on the requirement. The problem is if i select last element i'm getting the value is true. Other elements not filled, it is empty only. It should through false only, if anyone element value is null.</p>
<p>This is my code</p>
<pre><code><form name="selectForm" action="" onSubmit="return selectValidation();" method="POST">
<div>
<select class="selectmenu">
<option value="">Select the value</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<div>
<select class="selectmenu">
<option value="">Select the value</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<div>
<select class="selectmenu">
<option value="">Select the value</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<div>
<select class="selectmenu">
<option value="">Select the value</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<div>
<select class="selectmenu">
<option value="">Select the value</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<div>
<button type="submit" class="btn">
<i class="fa fa-btn fa-user"></i> Submit Answers
</button>
</div>
</form>
</code></pre>
<p>Javascript function</p>
<pre><code>function selectValidation() {
var selectIsValid = true;
$('.selectmenu').each(function(){
if($(this).val()==='') {
selectIsValid = false;
} else {
selectIsValid = true;
}
});
console.log(selectIsValid);
if(selectIsValid) {
}
return false;
}
</code></pre> | 0 |
Usage of javascript `this.closest` in IE11 and Chrome | <p>In IE11 the below code shows the following error, But it is working in Chrome</p>
<blockquote>
<p>Object doesn't support property or method 'closest'4:31 PM 09/07/16</p>
</blockquote>
<pre><code>assetTable.on("click", "td.clickProgress", function onDataTableRowClicked(event) {
var tr = this.closest("tr");
var assetId = tr.id.replace("asset_", "");
LoadDialog(assetId);
}
</code></pre>
<p>However, when I change it to <code>$(this)</code> it is working in both IE and Chrome</p>
<pre><code>assetTable.on("click", "td.clickProgress", function onDataTableRowClicked(event) {
var tr = $(this).closest("tr");
var assetId = tr.attr('id').replace("asset_", "");
LoadDialog(assetId);
}
</code></pre>
<p>Any reason behind this compatibility issue between browsers?</p> | 0 |
sql/spark-sql: if statement syntax in a query | <p>I am looking into some existing spark-sql codes, which trying two join to tables as below:</p>
<pre><code>items_t1_t2 as (
select *,
if(id_t1 is not Null, True, False) as in_t1,
if(id_t2 is not Null, True, False) as in_t2
from item_t2 full join item_t1
on id_t2 = id_t1)
</code></pre>
<p>I am wondering why there is three elements in the if parentheses? What does the if statement mean here and how it works here? Thanks a lot!</p> | 0 |
ImportError: No module named keras.optimizers | <p>I have this import statement in Keras:</p>
<pre><code>from keras.optimizers import SGD, RMSprop
</code></pre>
<p>But getting this error on this error:</p>
<pre><code>ImportError: No module named keras.optimizers
</code></pre>
<p>Why is that? And, how can I solve this issue?</p>
<p>Thanks.</p> | 0 |
Swift3 : how to handle precedencegroup now operator should be declare with a body? | <p>Former Swift 3 code for operator was: </p>
<pre><code>infix operator × {associativity left precedence 150}
</code></pre>
<p>But now, as per Xcode 8 beta 6, this generate the following warning:</p>
<pre><code>"operator should not be declared with body"
</code></pre>
<p>What's the right way to use precedencegroup predicate as no doc exists right now?</p>
<p>I have tried this, but does not work:</p>
<pre><code>infix operator × : times
precedencegroup times {
associativity: left
precedence: 150
}
</code></pre> | 0 |
How to convert Timestamp to Date Data Type in Google Bigquery | <p>I am trying to convert Timestamp data type columns to Date datatype using:</p>
<p><code>bq query -q --destination_table=NEW_DATE_TABLE --replace "SELECT DATE(CURR_DT) AS CURR_DT from TEST.DATE_TABLE"</code></p>
<p>The new table shows the column as <code>STRING</code> rather than <code>date</code>. Is there a way to convert timestamp to <code>date</code> data type.</p>
<p><a href="https://i.stack.imgur.com/ZmAwu.png" rel="noreferrer">Requested Screenshot</a></p> | 0 |
How to enable TLS 1.2 in Java 7 | <p>I am trying to enable TLS 1.2 in my web app which uses JBoss 6.4 and Java 1.7. I have <code>-Dhttp.protocols = TLSv1.2</code> in my application environment but it doesn't seem to work for me. </p>
<p>Is there anything I could do to enable TLS 1.2?</p>
<p>I wrote a simple program </p>
<pre><code>context = SSLContext.getInstance("TLSv1.2");
context.init(null,null,null);
SSLContext.setDefault(context);
SSLSocketFactory factory = (SSLSocketFactory)context.getSocketFactory();
SSLSocket socket = (SSLSocket)factory.createSocket();
protocols = socket.getEnabledProtocols();
</code></pre>
<p>After running this program within the app the TLS 1.2 gets enabled. I do not want to run this program but I want to directly enable it during app startup. Is there any way to do it?</p> | 0 |
Java home supplied via 'org.gradle.java.home' is invalid. Invalid directory: /usr/local/java/jdk1.8.0_05 | <p>I'm using gradle 2.9, intellij and Win10 for spring development. In one particular project I encountered this error:</p>
<pre class="lang-none prettyprint-override"><code>Java home supplied via 'org.gradle.java.home' is invalid. Invalid directory: /usr/local/java/jdk1.8.0_05
</code></pre>
<p>Neither
<a href="https://stackoverflow.com/questions/22307516/gradle-finds-wrong-java-home-even-though-its-correctly-set">solution 1</a> nor <a href="https://stackoverflow.com/questions/26882221/gradle-does-not-recognize-the-java-home-i-have-set">solution 2</a> work for me.</p> | 0 |
How to enable AutoStart option for my App in Xiaomi phone Security App programmatically in android | <p>My App is working with good remarks in all mobile except MI. Because MI restricting my App background service to run. After enabling App in Autostart in Security, it working perfectly. So can I enable that AutoStart Option for my app in MI Security App through programmatically. Please let me know your valuable suggestions.</p>
<p>And My doubt is how whatsapp , facebook and many more apps default enabling Autostart Option in Security App in Xiaomi?</p>
<p>Thanks in Advance. </p> | 0 |
C# WPF Indeterminate progress bar | <p>Please could someone suggest why the following doesn't work? All I want to do is display an indeterminate progress bar which starts when the button is clicked, then after I've done some work I set the indeterminate progress bar to false to stop it.</p>
<p>However when I run the code below the indeterminate progress bar doesn't even start. I tried commenting out the line <code>this.progressBar.IsIndeterminate = false</code> and when I do this the progress bar does start but then doesn't terminate.</p>
<pre><code>private void GenerateCSV_Click(object sender, RoutedEventArgs e)
{
this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate ()
{
this.progressBar.IsIndeterminate = true;
// do some work
Thread.Sleep(10 * 1000);
this.progressBar.IsIndeterminate = false;
}));
}
</code></pre> | 0 |
Is it safe to store a sensitive data in Local Stoarge or session storage? Localstorage allows to any attacks for sensitive data | <p>In web application , How secure is local storage in Html5 or else is there any other way to secure the sensitive data in local storage.</p>
<p>Project Structure:</p>
<p>Front End: Html5,Angular js, <strong>Middletier:</strong> Asp.net webApi , <strong>BackEnd</strong> :Sql Server.</p>
<p>Once user login into the page, that credentials is encrypted by using some cryptography algorithms.It will be stored in db.</p>
<p>After that every child action like products list, order details, book history ,add product need to validate that.</p>
<p>While refresh after the page, data gets lossed so need to persist the data so i have choose localstorage. stored the username and password encrypted using some js algorithms and in put in local storage.</p>
<p>I feel it as not safe , because of any one can steal the data from the browser tools.</p>
<p>Is there any alternative approach in this scenario or else this approach is secure.</p>
<p>can anyone help me to process.</p> | 0 |
WFLYCTL0412: Required services that are not installed: | <p>I'm trying to add a datasource in Wildfly 10.0, but when i test connection this the error message that throws:</p>
<pre><code>Unexpected HTTP response: 500
Request
{
"address" => [
("subsystem" => "datasources"),
("data-source" => "PostgreCrawlazo")
],
"operation" => "test-connection-in-pool"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0042: failed to match pool. Check JndiName: java:/crawlazo",
"rolled-back" => true,
"response-headers" => {"process-state" => "reload-required"}
}
</code></pre>
<p>The error from the server log:</p>
<pre><code>2016-09-01 16:28:40,524 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "PostgreCrawlazo")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.postgres",
"jboss.jdbc-driver.postgres"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:/crawlazo is missing [jboss.jdbc-driver.postgres]",
"org.wildfly.data-source.PostgreCrawlazo is missing [jboss.jdbc-driver.postgres]",
"org.wildfly.data-source.PostgreCrawlazo is missing [jboss.jdbc-driver.postgres]"
]
}
</code></pre>
<p>i'm replicating the same configuration files from standalone.xml and module.xml</p>
<p>here is part how i set up the datasource in standalone.xml:</p>
<pre><code> <datasource jndi-name="java:/crawlazo" pool-name="PostgreCrawlazo" enabled="true">
<connection-url>jdbc:postgresql://x.x.x.x:5432/crawlazo</connection-url>
<driver>postgres</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>40</max-pool-size>
</pool>
<security>
<user-name>someUser</user-name>
<password>somePasswd</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="postgres" module="org.postgres">
<driver-class>org.postgresql.Driver</driver-class>
</driver>
</drivers>
</code></pre>
<p>and the module.xml:</p>
<pre><code><module xmlns="urn:jboss:module:1.0" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.2-1004.jdbc3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
</code></pre>
<p>I have a postgresql-9.2-1004.jdbc3.jar in the deployment folder.</p>
<p>Why this error appears? what i could have forgotten to config?</p> | 0 |
Jenkins multibranch pipeline with Jenkinsfile from different repository | <p>I have a Git repository with code I'd like to build but I'm not "allowed" to add a <code>Jenkinsfile</code> in its root (it is a Debian package so I can't add files to upstream source). Is there a way to store the <code>Jenkinsfile</code> in one repository and have it build code from another repository? Since my code repository has several branches to build (one for each Debian release) this should be a multibranch pipeline. Commits in either the code or <code>Jenkinsfile</code> repositories should trigger a build.</p>
<p><strong>Bonus complexity:</strong> I have several code/packaging repositories like this and I'd like to reuse the same <code>Jenkinsfile</code> for all of them. Thus it should somehow dynamically fetch the right Git URL to use. The branches to build have the same names across all repositories.</p> | 0 |
How to use VBA to add new record in MS Access? | <p>I'm using bound forms for the user to update information on new or existing customers. Right now I'm using a Add New Record macro on the submit button (because I'm not sure how to add or save a new record through VBA). </p>
<p>I added a before update event (using VBA) to have the user confirm they want to save changes before exiting the form. For some reason this is overriding the add record button and now users cannot add new record until exiting the forms.</p>
<p>How can I use VBA to add new customer information to the correct table? Is this something that should be done with macros instead?</p>
<p>Form BeforeUpdate Code:</p>
<pre><code>Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strmsg As String
strmsg = "Data has been changed."
strmsg = strmsg & " Save this record?"
If MsgBox(strmsg, vbYesNo, "") = vbNo Then
DoCmd.RunCommand acCmdUndo
Else
End If
End Sub
</code></pre>
<p>Add Record Button:</p>
<pre><code>Private Sub btnAddRecord_Click()
Dim tblCustomers As DAO.Recordset
Set tblCustomers = CurrentDb.OpenRecordset("SELECT * FROM [tblCustomers]")
tblCustomers.AddNew
tblCustomers![Customer_ID] = Me.txtCustomerID.Value
tblCustomers![CustomerName] = Me.txtCustomerName.Value
tblCustomers![CustomerAddressLine1] = Me.txtCustomerAddressLine1.Value
tblCustomers![City] = Me.txtCity.Value
tblCustomers![Zip] = Me.txtZip.Value
tblCustomers.Update
tblCustomers.Close
Set tblCustomers = Nothing
DoCmd.Close
End Sub
</code></pre> | 0 |
Firebase deployment error | <p>I've deployed in the past many times before. For some reason, today I am getting this error I can't seem to fix. I've tried changing tabs out with 2 or 4 spaces. I've tried different formats, and nothing works.</p>
<p>Here's what it says:</p>
<pre><code>Error: There was an error loading firebase.json
Trailing comma in object at 29:9
}
^
</code></pre>
<p>Here is my firebase.json</p>
<pre><code>{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "public"
}
}
</code></pre>
<p>How do I solve it?</p>
<p>PS: If you need anything else please ask.</p> | 0 |
Cannot invoke initializer for type: with an argument list of type '(_Element)' | <p>I am new on Swift. I am trying to convert string to character array and I want the integer value of character. Here is my code:</p>
<pre><code>var string = "1234"
var temp = Array(string.characters)
var o = Int(temp[0])
</code></pre>
<p>But at line 3 I am getting above error. What's wrong with this code?
Please help me </p> | 0 |
geom_text overlapping with data points despite using nudge_x and nudge_y | <p>I'm trying to have text labels not overlap with the data points in a scatterplot made in <code>ggplot2</code>.</p>
<p>I've tried using the <code>nudge_</code> arguments in <a href="http://docs.ggplot2.org/current/geom_text.html" rel="nofollow noreferrer"><code>geom_text()</code></a>:</p>
<pre class="lang-r prettyprint-override"><code>library(ggplot2)
df <- data.frame(trt = c("a", "b", "c"),
resp = c(2, 3, 4))
ggplot(df, aes(resp, trt)) +
geom_point() +
geom_text(aes(label = resp , nudge_y = 2, nudge_x = 2))
</code></pre>
<p>However, as we can see, the text overlaps with the point:
<a href="https://i.stack.imgur.com/nMGBe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nMGBe.png" alt="current output" /></a></p>
<p>Is there any way we can fix this? Also, what's the use of <code>nudge_x</code> and <code>nudge_y</code>? I don't quite get it from the manual.</p> | 0 |
Angular 2 reload route on param change | <p>I am currently writing my first Angular 2 Application.
I have an OverviewComponent which has the following simple template:</p>
<pre><code><div class="row">
<div class="col-lg-8">
<router-outlet></router-outlet>
</div>
<div class="col-lg-4">
<app-list></app-list>
</div>
</div>
</code></pre>
<p>when accessing the url <code>/</code> my router redirects me to <code>/overview</code> which then loads a map within the router-outlet. The <code><app-list></code> has a list of clickable items which triggers a <code><app-detail></code> to be displayed instead of the app component. Therefor I pass the id of the referring json file in the url like that: <code>/details/:id</code> (in my routes).</p>
<p>All of the above works totally fine. If I now click on one of the list items the details are shown, BUT when I select another list element the view doesn't change to the new details. The URL does change but the content is not reloaded. How can I achieve a Reinitialization of the DetailComponent?</p> | 0 |
Use None instead of np.nan for null values in pandas DataFrame | <p>I have a pandas DataFrame with mixed data types. I would like to replace all null values with None (instead of default np.nan). For some reason, this appears to be nearly impossible. </p>
<p>In reality my DataFrame is read in from a csv, but here is a simple DataFrame with mixed data types to illustrate my problem. </p>
<pre><code>df = pd.DataFrame(index=[0], columns=range(5))
df.iloc[0] = [1, 'two', np.nan, 3, 4]
</code></pre>
<p>I can't do:</p>
<pre><code>>>> df.fillna(None)
ValueError: must specify a fill method or value
</code></pre>
<p>nor:</p>
<pre><code>>>> df[df.isnull()] = None
TypeError: Cannot do inplace boolean setting on mixed-types with a non np.nan value
</code></pre>
<p>nor:</p>
<pre><code>>>> df.replace(np.nan, None)
TypeError: cannot replace [nan] with method pad on a DataFrame
</code></pre>
<p>I used to have a DataFrame with only string values, so I could do:</p>
<pre><code>>>> df[df == ""] = None
</code></pre>
<p>which worked. But now that I have mixed datatypes, it's a no go.</p>
<p>For various reasons about my code, it would be helpful to be able to use None as my null value. Is there a way I can set the null values to None? Or do I just have to go back through my other code and make sure I'm using np.isnan or pd.isnull everywhere? </p> | 0 |
HeadersTooLargeException - response headers | <p>I have implmented file download in my project in Spring mvc and while downloading the file it gives me below error on tomcat 7 server:</p>
<pre><code>org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer.
Increase maxHttpHeaderSize on the connector or write less data into the response headers.
</code></pre>
<p>I have also tried increasing the header size using below code in server.xml</p>
<pre><code><Connector port="8080" maxHttpHeaderSize="65536" protocol="HTTP/1.1" ... />
</code></pre>
<p>However, this is also not working and I still get the above error.</p>
<p>Below is the controller code for file download:</p>
<pre><code>@RequestMapping(value = "/admin/file/download", method = RequestMethod.GET)
public @ResponseBody ModelAndView download(HttpServletRequest request,
HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
Files file = this.filesManager.find(id);
response.setContentType(file.getType());
response.setContentLength(file.getFile().length);
response.setHeader("Content-Disposition", "attachment; filename=\""+ file.getFilename() + "\"");
FileCopyUtils.copy(file.getFile(), response.getOutputStream());
response.flushBuffer();
return null;
}
</code></pre>
<p>The class Files stores the file information from database:</p>
<pre><code> public class Files {
private int id;
private String filename;
private String type;
private byte[] file;
}
</code></pre>
<p>I have also tried removing the below line but still gives the same error:</p>
<pre><code> response.setHeader("Content-Disposition",
"attachment; filename=\""+ file.getFilename() + "\"");
</code></pre> | 0 |
primeng issues with rc5 | <p>After upgrading to rc5, and reinstalling primeng with the new release, I receive the following error:</p>
<p>zone.js?1472019041780:484 Unhandled Promise rejection: Template parse errors: Can't bind to 'icon' since it isn't a known property of 'button'. ("ver':hovered,'ui-state-focus':focused,'ui-state-disabled':disabled}" >][icon]="icon" pButton *ngIf="showIcon" (click)="onButtonClick($event,in)" [ngClass]="): <strong>Calendar@7:31</strong> ; Zone: ; Task: Promise.then ; Value:</p>
<p>I tried removing all references to calendar, so I can at least get the app up and running, and got another issue:</p>
<pre><code>Can't bind to 'rows' since it isn't a known property of 'p-paginator'.
1. If 'p-paginator' is an Angular component and it has 'rows' input, then verify that it is part of this module.
2. If 'p-paginator' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message.
(" <ng-content select="header"></ng-content>
</div>
<p-paginator [ERROR ->][rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="ui"): DataTable@6:25
Can't bind to 'first' since it isn't a known property of 'p-paginator'.
1. If 'p-paginator' is an Angular component and it has 'first' input, then verify that it is part of this module.
2. If 'p-paginator' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message.
("<ng-content select="header"></ng-content>
</div>
</code></pre>
<p>dependancies:</p>
<pre><code>import { NgModule, ElementRef } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { HttpModule } from '@angular/http';
import { Calendar, DataTable, Column, InputMask } from 'primeng/primeng';
</code></pre> | 0 |
Adjusting the container div's size to exactly fit the rendered React component | <p>I am trying to render a component whose style and position are determined based on some cases. In order to do that, I am rendering it in a container which occupies the entire body and the component moves inside it. Instead of doing that, how to make sure the styles of container are the same as that of the component? I don't want the container to occupy the entire body, I only want it to occupy the component. </p>
<p>code:</p>
<pre><code>var componentStyle;
//cases
componentStyle = {}; //some css properties
var MyComponent = React.createClass({
render: function(){
return(
<div style = {componentStyle}>Some content</div>
)
}
})
var container = document.createElement("div");
container.id = "container";
document.body.appendChild(container);
ReactDOM.render(<MyComponent/>,container);
</code></pre>
<p>css for container:</p>
<pre><code>#container {
position: absolute;
top:0;left: 0;
font-family: Arial, Helvetica, sans;
background: transparent;
height: 100%;
width: 100%;
z-index:9999999;
}
</code></pre> | 0 |
How can I visualize a histogram with Promdash or Grafana? | <p>I'm attracted to prometheus by the histogram (and summaries) time-series, but I've been unsuccessful to display a histogram in either promdash or grafana. What I expect is to be able to show:</p>
<ul>
<li>a histogram at a point in time, e.g. the buckets on the X axis and the count for the bucket on the Y axis and a column for each bucket</li>
<li>a stacked graph of the buckets such that each bucket is shaded and the total of the stack equals the inf bucket</li>
</ul>
<p>A sample metric would be the response time of an HTTP server.</p> | 0 |
Set KeyPressed event for a TextField in JavaFX | <p>I have number of <code>TextField</code> objects inside a pop up window called dialog (type : <code>Stage</code>).</p>
<p>I am trying to define an action handler for them which aims to close the stage once the escape button is clicked on the key board.</p>
<p>Here is my function for the stage closer :</p>
<pre><code>public void escapeKeyPressed(KeyCode keyCode , Stage dialog){
if (keyCode == KeyCode.ESCAPE ){
dialog.close();
System.out.println("escape got called");
}
}
</code></pre>
<p>and the following is where I call it : </p>
<pre><code>textUsername.setOnAction((event) -> {escapeKeyPressed(KeyCode.ESCAPE ,dialog );});
textAddress.setOnAction((event) -> {escapeKeyPressed(KeyCode.ESCAPE ,dialog );});
textwp.setOnAction((event) -> {escapeKeyPressed(KeyCode.ESCAPE ,dialog );});
textState.setOnAction((event) -> {escapeKeyPressed(KeyCode.ESCAPE ,dialog );});
textloginName.setOnAction((event) -> {escapeKeyPressed(KeyCode.ESCAPE ,dialog );});
</code></pre>
<p>The problem is that the function doesn't get called.</p>
<p>Any idea how can I fix that? It's woth mentioning that the function by itself works fine if I replace the caller out of <code>setOnAction();</code></p> | 0 |
Spark - How to update value using data frame Scala | <p>I have two files with following structure</p>
<h2>File 1</h2>
<pre><code>gnk_id, matchId, timestamp
</code></pre>
<h2>File 2</h2>
<pre><code>gnk_matchid, matchid
</code></pre>
<p>I want to update value of <code>gnk_id</code> in file 1 with value of <code>matchid</code> in file 2 if <code>file1.gnk_id = file2.gnk_machid</code>.</p>
<p>For this I created two data frame in Spark. I was wondering whether we can update values in Spark? If not, is there any workaround for this which will provide updated final file?</p>
<p>UPDATE</p>
<p>I did something like this</p>
<pre class="lang-scala prettyprint-override"><code>case class GnkMatchId(gnk: String, gnk_matchid: String)
case class MatchGroup(gnkid: String, matchid: String, ts: String)
val gnkmatchidRDD = sc.textFile("000000000001").map(_.split(',')).map(x => (x(0),x(1)) )
val gnkmatchidDF = gnkmatchidRDD.map( x => GnkMatchId(x._1,x._2) ).toDF()
val matchGroupMr = sc.textFile("part-00000").map(_.split(',')).map(x => (x(0),x(1),x(2)) ).map( f => MatchGroup(f._1,f._2,f._3.toString) ).toDF()
val matchgrp_joinDF = matchGroupMr.join(gnkmatchidDF,matchGroupMr("gnkid") === gnkmatchidDF("gnk_matchid"),"left_outer")
matchgrp_joinDF.map(x => if(x.getAs[String]("gnk_matchid").length != 0 ) {MatchGroup(x.getAs[String]("gnk_matchid"), x.getAs[String]("matchid"),x.getAs[String]("ts"))} else {MatchGroup(x.getAs[String]("gnkid"), x.getAs[String]("matchid"),x.getAs[String]("ts"))}).toDF().show()
</code></pre>
<p>But at last step it's failing for NULLpointerEXception</p> | 0 |
Merge two objects with ES6 | <p>I'm sure this question has been asked before but I can't quite find the answer I'm looking for, so here goes:</p>
<p>I have two objects, as follows:</p>
<pre><code>const response = {
lat: -51.3303,
lng: 0.39440
}
let item = {
id: 'qwenhee-9763ae-lenfya',
address: '14-22 Elder St, London, E1 6BT, UK'
}
</code></pre>
<p>I need to merge these together to form this:</p>
<pre><code>item = {
id: 'qwenhee-9763ae-lenfya',
address: '14-22 Elder St, London, E1 6BT, UK',
location: {
lat: -51.3303,
lng: 0.39440
}
}
</code></pre>
<p>I know I could do it like this:</p>
<pre><code>item.location = {}
item.location.lat = response.lat
item.location.lng = response.lng
</code></pre>
<p>However, I feel that this is not the best way to do it anymore, because ES6 introduced the cool destructuring/assignment stuff; I tried deep object merging but it's unfortunately not supported :( I also looked through some ramda functions but couldn't see anything that was applicable.</p>
<p>So what is the best way to merge these two objects using ES6? </p> | 0 |
Comparing two timestamps in php | <p>SO the scene is, I have a store which opens at 1:00am at night, and closes at 10:00pm.
For any current time i just want to check whether that timestamp lies between store open and close times.</p>
<p>Yeap that's very simple, and still I don't know why, am finding it difficult.
below is a piece of epic shit i am trying.</p>
<pre><code><?php
$t=time(); //for current time
$o = date("Y-m-d ",$t)."01:00:00"; //store open at this time
$c = date("Y-m-d ",$t)."22:00:00"; //store closes at this time
//Yes, its crazy .. but I love echoing variables
echo "current time = ".$t;
echo PHP_EOL;
echo "Start = ".strtotime($o);
echo PHP_EOL;
echo "End = ".strtotime($c);
echo PHP_EOL;
// below condition runs well, $t is always greater than $o
if($t>$o){
echo "Open_c1";
}else{
echo "Close_c1";
}
//Here's where my variable $t, behaves like a little terrorist and proclaims itself greater than $c
if($t<$c){
echo "Open_c2";
}else{
echo "Close_c2";
}
?>
</code></pre>
<p>OUTPUT: on phpfiddle</p>
<p>current time = 1472765602 Start = 1472706000 End = 1472781600 Open_c1 Close_c2</p>
<p>Just one help, why ( $t < $c ) condition is false.
Am I missing something very common or making a serious blunder.</p>
<p>Thank you.</p> | 0 |
Postfix - Must issue a STARTTLS command first | <p>I am trying to send email through gmail via postfix, but it shows me the following error:</p>
<p><strong>Must issue a STARTTLS command first.</strong></p>
<pre><code>Sep 6 01:11:34 NovusTec postfix/smtp[10889]: 1284460D68: to=<[email protected]>, relay=smtp.gmail.com[64.233.190.108]:587, delay=2882, delays=2881/0.02/0.83/0.19, dsn=5.7.0, status=bounced (host smtp.gmail.com[64.233.190.108] said: 530 5.7.0 Must issue a STARTTLS command first. k65sm16819558qkf.7 - gsmtp (in reply to MAIL FROM command))
</code></pre>
<p>/etc/postfix/main.cf</p>
<pre><code># See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localdomain, localhost, localhost.localdomain, localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
smtp_use_tls=yes
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_tls_CAfile = /etc/ssl/certs
</code></pre>
<p>I tried several configurations informed on other sites without success = \</p>
<p>Can anybody help me?</p> | 0 |
angular2 will not disable input based on true or false condition | <p>I have a input box based on the below:</p>
<p>If a change a radio I see that the value changes to true for false:</p>
<pre><code><pre> {{model_parameters_general.estimationmethod=='ew'}} </pre>
</code></pre>
<p>So wow why will the input box be disabled based on true for false?</p>
<pre><code><input [disabled]="model_parameters_general.estimationmethod=='ew'" [(ngModel)]="model_parameters_general.lambda"
formControlName="lambda" type="text" class="form-control">
</code></pre>
<p>EDIT:</p>
<p>In the logs I get this:</p>
<pre><code>It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
you. We recommend using this approach to avoid 'changed after checked' errors.
Example:
form = new FormGroup({
first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
last: new FormControl('Drew', Validators.required)
});
</code></pre>
<p>So I am using a reactive from in rc6. </p>
<p>I set the initial disable to the below:</p>
<pre><code>this.myForm = fb.group({
lambda: new FormControl({value: .99, disabled: true}, Validators.required),
})
</code></pre>
<p>So do I enable based on a toggle of a radio input?</p> | 0 |
Failed to establish a new connection | <pre><code>import requests
url = 'http://ES_search_demo.com/document/record/_search?pretty=true'
data = '{"query":{"bool":{"must":[{"text":{"record.document":"SOME_JOURNAL"}},{"text":{"record.articleTitle":"farmers"}}],"must_not":[],"should":[]}},"from":0,"size":50,"sort":[],"facets":{}}'
response = requests.get(url, data=data)
</code></pre>
<p>when i run this code i get this error </p>
<pre><code> Traceback (most recent call last):
File "simpleclient.py", line 6, in <module>
response = requests.get(url, data=data)
File "/home/ryan/local/lib/python2.7/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/home/ryan/local/lib/python2.7/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/home/ryan/local/lib/python2.7/site-packages/requests/sessions.py", line 471, in request
resp = self.send(prep, **send_kwargs)
File "/home/ryan/local/lib/python2.7/site-packages/requests/sessions.py", line 581, in send
r = adapter.send(request, **kwargs)
File "/home/ryan/local/lib/python2.7/site-packages/requests/adapters.py", line 481, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='es_search_demo.com', port=80): Max retries exceeded with url: /document/record/_search?pretty=true (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f544af9a5d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
</code></pre> | 0 |
How can I add Font Awesome to my Aurelia project using npm? | <p>I have been following the <a href="http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/contact-manager-tutorial" rel="noreferrer">Contact Manager</a> tutorial and would like to add <em>Font Awesome</em> to the project. Here's what I have done so far:</p>
<ul>
<li><code>npm install Font-Awesome --save</code></li>
<li>Added the following to <code>aurelia.json</code>under the <em>dependencies</em> array of the <code>vendor-bundle.js</code>:</li>
</ul>
<p><br></p>
<pre><code>...
{
"name": "font-awesome",
"path": "../node_modules/font-awesome",
"resources": [
"css/font-awesome.min.css"
]
},
...
</code></pre>
<p>But when running <code>au run --watch</code> I get the error:</p>
<blockquote>
<p>error
C:\Users\node_modules\font-awesome.js</p>
</blockquote>
<p>Why is it looking for the <em>.js</em> file?</p> | 0 |
How to block ads with HTML/JS? | <p>I have a site (<a href="http://forum.tdp4teambattle.com" rel="nofollow">forum.tdp4teambattle.com</a>) and recently, I started getting ads in the footer. I looked in the footer and there is no code for the ad. I'm thinking they put it in another file and specified it to a certain div ID. What code in HTML or JavaScript can I use to hide the ad so others don't see it?</p>
<p>Here is the ad image: <a href="http://is.mixmarket.biz/images/um/95480.gif" rel="nofollow">http://is.mixmarket.biz/images/um/95480.gif</a>
it is 468x60 (maybe you can give me a code to block images of that specific size from showing up).</p>
<p>Edit, solved: if anybody was using "listbb.ru" or "getbb.ru", here is the solution. You'll need to view source on your index page and do CTRL+F. Search for "mix", or "market" or similar. You will see something along the lines of "mix_block_{identifier}". To remove it, you'll need to navigate to ACP>Styles>Templates>{Theme}>Overall_header.html>
find </p>
<pre><code></head>
</code></pre>
<p>and before, enter:</p>
<pre><code><style>
#mix_block_1294937123 {
display: none;
}
</style>
</code></pre> | 0 |
How to clean old deployed versions in Firebase hosting? | <p>Every time you deploy to Firebase hosting a new deploy version is created so you can roll back and see who deployed. This means that each time every file you deploy is stored and occupying more space.</p>
<p>Other than manually deleting each deployed version one by one, is there any automated way to clean those useless files?</p> | 0 |
Hibernate naming strategy changing table names | <p>I'm a little bit confused by hibernates (version 5.1) naming strategy - namely it changes my table name and I'd like to avoid that. Also - <code>spring.jpa.hibernate.naming_strategy</code> seems to be deprecated according to intelij, but I can't find a (nother) way of configuring it correctly.</p>
<p>I have the following configuration in application.properties:</p>
<pre><code>spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.properties.hibernate.current_session_context_class=thread
</code></pre>
<p>The first one is marked as depracted, as said. </p>
<p>Now I have an entity:</p>
<pre><code>@Entity
@Table(name = "usaUploadTable", schema = "usertable201", catalog = "")
public class UsaUploadTable {
....
}
</code></pre>
<p>The table name is, like in <code>@Table(name = "")</code> usaUploadTable. </p>
<p>Now when I run my application, I get </p>
<blockquote>
<p>Table 'usertable201.usa_upload_table' doesn't exist</p>
</blockquote>
<p>which is correct - it isn't named like how hibernate is changing it. </p>
<p>What can I do to make hibernate use my table name correctly?</p>
<p>Edit: </p>
<p>I've also tried</p>
<pre><code>DefaultNamingStrategy
ImprovedNamingStrategy
</code></pre>
<p>All of them change it</p>
<p>Versions:</p>
<pre><code>spring-boot-1.4.0.RELEASE
hibernate 5.1
javax-transaction-api 1.2
hibernate-validator 5.2.4
javassist 3.20
</code></pre> | 0 |
Chrome Developer Tools: Missing "Resources" Tab | <p>I am running <strong>Chrome Version 52.0.2743.116 (64-bit)</strong> on OS X 10.11.3 and upon trying to debug a website realized that the <em>Resources</em> tab in my <em>Developer Tools</em> is just completely gone. What gives / has anyone else noticed this?</p>
<p><img src="https://s3-us-west-1.amazonaws.com/productionsf/Screen+Shot+2016-08-16+at+10.17.19+AM.png" alt="screenshot1"></p>
<p><img src="https://s3-us-west-1.amazonaws.com/productionsf/Screen+Shot+2016-08-16+at+10.17.49+AM.png" alt="screenshot2"></p> | 0 |
What does "... resolves to a non-module entity and cannot be imported using this construct" mean? | <p>I have some TypeScript files:</p>
<p><em>MyClass.ts</em></p>
<pre><code>class MyClass {
constructor() {
}
}
export = MyClass;
</code></pre>
<p><em>MyFunc.ts</em></p>
<pre><code>function fn() { return 0; }
export = fn;
</code></pre>
<p><em>MyConsumer.ts</em></p>
<pre><code>import * as MC from './MyClass';
import * as fn from './MyFunc';
fn();
</code></pre>
<p>This gives me errors when trying to use <code>new</code></p>
<blockquote>
<p>Module "MyClass" resolves to a non-module entity and cannot be imported using this construct.</p>
</blockquote>
<p>and when trying to call <code>fn()</code></p>
<blockquote>
<p>Cannot invoke an expression whose type lacks a call signature.</p>
</blockquote>
<p>What gives?</p> | 0 |
UnityException: Tag: is not defined | <p>I'm following the <a href="https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial" rel="nofollow">Unity Roll A Ball Tutorial</a> but I'm having an issue picking up the spinning objects. Whenever I roll over them I get this error: </p>
<blockquote>
<p>UnityException: Tag: PickUp is not defined.
PlayerController.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Scripts/PlayerController.cs:30)</p>
</blockquote>
<p>I've made sure my tag <code>PickUp</code> is exactly the same as in the code, and still it doesn't work. I've been trying to fix this for a long some so any help is appreciated.</p> | 0 |
Can you set the qDebug() floating point precision and number format globally? | <p>I want to use qDebug(), qInfo() and so on with a custom default floating point precision and number format.</p>
<p>Is there a way to define this globally?</p>
<p>Imagine this: </p>
<pre><code>double num = 1.2;
qDebug() << "My floating point Number is: " << QString::number(num, 'f', 2);
//Output: My floating point Number is 1.20
</code></pre>
<p>Now I would like to avoid QString::number(num, 'f', 2) everytime I write a number and would much rather like to use a standard percision and format.</p> | 0 |
Cannot set property 'width' of undefined | <pre><code>function size(){
for(i=0; i<squares; i++){
document.getElementById('table').innerHTML += "<div class='squareCell' id='objetive"+i+"'></div>";
}
document.getElementsByClassName('squareCell').style.width="300px";
document.getElementsByClassName('squareCell').style.height="300px";}
</code></pre>
<p>Still getting "Cannot set property 'width' of undefined" and dont know why. I'm not trying to just solve this, I want to learn what is exactly happening here.</p>
<p>Greetings.</p> | 0 |
Googlemaps API Key for Localhost | <p>How do I get Google Maps API key to work on localhost?</p>
<p>I've created an API key and under referrers I add the following:</p>
<pre><code>Accept requests from these HTTP referrers (websites) (Optional)
Use asterisks for wildcards. If you leave this blank, requests will be
accepted from any referrer. Be sure to add referrers before using this key
in production.
localhost
</code></pre>
<p>This doesn't work and if I exclude the API key it doesn't work, either.</p> | 0 |
How to mock/create X509Certificate2 for unit testing? | <p>I have handler which creates jwt token with utilization of X509Certificate2. For unit test I need to provide certificate and it is not possible for me take it from the local store. Is there way, how to mock, create or load certificate from the file? </p>
<p>So far I tried BouncingCastle method from <a href="https://stackoverflow.com/questions/2315257/how-to-create-a-completely-new-x509certificate2-in-net">this</a> ticket, but with no success. The method ToX509Certificate2() does convert certificate, but without keys. So if this is good way to go, is possible to generate these keys somehow?</p>
<p>Thanks a lot for hints</p> | 0 |
Add empty (blank) space under (in the end of) UITableView | <p>My app has the <code>UITableView</code> which have variable quantity of cells inside.</p>
<p>How can I add empty (blank) space with certain height under the <code>UITableView</code>? Or in the very end of <code>UITableView</code>? So that after the very last cell there will be more blank space.</p> | 0 |
JsonMappingException: Can not find a deserializer for non-concrete Map type | <pre><code> String str = commonClient.authorizedRequestBuilder(commonClient.webTarget
.path("/apps/get_current_version/default/"+appName+"/"+appName)
.queryParam("object_type", "app"))
.accept(MediaType.APPLICATION_JSON_TYPE)
.get()
.readEntity(String.class);
</code></pre>
<p>i get </p>
<pre><code>str = {"versions": {"ap": "Not Set", "am": "topic-test-publisher-1.0.16", "il": "topic-test-publisher-1.0.16", "row": "topic-test-publisher-1.0.49"}, "provider": "gce"}
</code></pre>
<p>Then i have changed to this code</p>
<pre><code> Version version = commonClient.authorizedRequestBuilder(commonClient.webTarget
.path("/apps/get_current_version/default/"+appName+"/"+appName)
.queryParam("object_type", "app"))
.accept(MediaType.APPLICATION_JSON_TYPE)
.get(ClientResponse.class)
.readEntity(new GenericType<Version>(){});
</code></pre>
<p>and got an exception:</p>
<pre><code>Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not find a deserializer for non-concrete Map type [map type; class javax.ws.rs.core.MultivaluedMap, [simple type, class java.lang.String] -> [collection type; class java.util.List, contains [simple type, class java.lang.Object]]]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:269)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:428)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:947)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:439)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:296)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:428)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:947)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:439)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:296)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:461)
at com.fasterxml.jackson.databind.ObjectReader._findRootDeserializer(ObjectReader.java:1749)
at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1465)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:912)
at com.fasterxml.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:810)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:256)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:235)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:808)
at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:326)
at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:803)
... 32 more
Caused by: java.lang.IllegalArgumentException: Can not find a deserializer for non-concrete Map type [map type; class javax.ws.rs.core.MultivaluedMap, [simple type, class java.lang.String] -> [collection type; class java.util.List, contains [simple type, class java.lang.Object]]]
at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.createMapDeserializer(BasicDeserializerFactory.java:1158)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:380)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
... 59 more
</code></pre>
<p>where:</p>
<pre><code>@JsonIgnoreProperties(ignoreUnknown = true)
public class Version {
@JsonProperty("am")
public String am;
@JsonProperty("row")
public String row;
@Override
public String toString() {
return "VersionDto{" +
"am='" + am + '\'' +
", row='" + row + '\'' +
'}';
}
}
</code></pre>
<p>How can i deserialize it differently?</p>
<p><strong>UPDATE</strong></p>
<p>I have tried:</p>
<p>with</p>
<pre><code>public class Version {
public Map<String, String> versions;
public String provider;
// getters, setters, etc
}
</code></pre>
<p>and</p>
<pre><code> Version version = commonClient.authorizedRequestBuilder(commonClient.webTarget
.path("/apps/get_current_version/gce/waze-prod/default/"+appName+"/"+appName)
.queryParam("object_type", "app"))
.accept(MediaType.APPLICATION_JSON_TYPE)
.get(ClientResponse.class)
.readEntity(Version.class);
</code></pre>
<p>but got the same error</p> | 0 |
Python Decryption using private key | <p>I have an encrypted string. The Encryption is done using java code. I decrypt the encrypted string using following java code</p>
<pre><code>InputStream fileInputStream = getClass().getResourceAsStream(
"/private.txt");
byte[] bytes = IOUtils.toByteArray(fileInputStream);
private String decrypt(String inputString, byte[] keyBytes) {
String resultStr = null;
PrivateKey privateKey = null;
try {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(keyBytes);
privateKey = keyFactory.generatePrivate(privateKeySpec);
} catch (Exception e) {
System.out.println("Exception privateKey::::::::::::::::: "
+ e.getMessage());
e.printStackTrace();
}
byte[] decodedBytes = null;
try {
Cipher c = Cipher.getInstance("RSA/ECB/NoPadding");
c.init(Cipher.DECRYPT_MODE, privateKey);
decodedBytes = c.doFinal(Base64.decodeBase64(inputString));
} catch (Exception e) {
System.out
.println("Exception while using the cypher::::::::::::::::: "
+ e.getMessage());
e.printStackTrace();
}
if (decodedBytes != null) {
resultStr = new String(decodedBytes);
resultStr = resultStr.split("MNSadm")[0];
// System.out.println("resultStr:::" + resultStr + ":::::");
// resultStr = resultStr.replace(salt, "");
}
return resultStr;
}
</code></pre>
<p>Now I have to use Python to decrypt the encrypted string. I have the private key. When I use Cryptography package using following code </p>
<pre><code>key = load_pem_private_key(keydata, password=None, backend=default_backend())
</code></pre>
<p>It throws <code>ValueError: Could not unserialize key data.</code></p>
<p>Can anyone help what I am missing here?</p> | 0 |
Consuming web service with c# and basic authentication | <p>I want to consume a web service with this code:</p>
<pre><code>WebService.GenRelClient client = new WebService.GenRelClient();
client.ClientCredentials.UserName.UserName = @"UserName";
client.ClientCredentials.UserName.Password = @"Password";
var response = client.returnString("test");
</code></pre>
<p>And my config looks like this:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="GenRelClientPortBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://ws.domain.com/GenRel/GenRel"
binding="basicHttpBinding"
bindingConfiguration="GenRelClientPortBinding"
contract="WebService.GenRelClientPort"
name="GenRelClientPort" />
</client>
</system.serviceModel>
</configuration>
</code></pre>
<p>The request is sent to the web service and the response is sent back with incorrect message about that it need <strong>Basic Authentication</strong> because the request was sent probably without credentials, so I don't know where is the mistake.</p>
<p>Thank you for your help</p> | 0 |
WebAPI error reading MIME multipart body part | <p>My team recently refactored a Web API service to move some of the repetitive code into static methods. One method is related to extracting an uploaded file from the request. The method works in unit testing, but under load, is throwing exceptions. Part of the code was found in an SO post, but I'm concerned that, overall, we're not using it correctly. Here's the code:</p>
<pre><code>internal static string ExtractFile(HttpRequestMessage request)
{
if (request.Content.IsMimeMultipartContent())
{
string uploadRoot = ServiceHelper.GetUploadDirectoryPath();
var provider = new MultipartFormDataStreamProvider(uploadRoot);
try
{
Task.Factory
.StartNew(() => provider = request.Content.ReadAsMultipartAsync(provider).Result,
CancellationToken.None,
TaskCreationOptions.LongRunning, // guarantees separate thread
TaskScheduler.Default)
.Wait();
}
catch(System.AggregateException ae)
{
if(log.IsErrorEnabled)
{
foreach(var ex in ae.InnerExceptions)
{
log.Error("ReadAsMultipartAsync task error.", ex);
}
}
var errorResponse = request.CreateErrorResponse(HttpStatusCode.InternalServerError, "An error occurred while extracting the uploaded file from the request.");
throw new HttpResponseException(errorResponse);
}
var fileData = provider.FileData.First();
var localName = fileData.LocalFileName;
var content = File.ReadAllText(localName);
if (log.IsDebugEnabled)
{
var embeddedName = fileData.Headers.ContentDisposition.FileName;
log.DebugFormat("File {0} was successfully uploaded as '{1}'.", embeddedName, localName);
}
return content;
}
else
{
log.Error("Invalid request received. Request must be in a multipart/form-data request.");
var errorResponse = request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Request must be a multipart/form-data request and contain one file.");
throw new HttpResponseException(errorResponse);
}
}
</code></pre>
<p>Walking thru the logs, I see errors like these:</p>
<p>System.IO.IOException: Error reading MIME multipart body part. ---> System.IO.IOException ---> System.Net.HttpListenerException: The I/O operation has been aborted because of either a thread exit or an application request</p>
<p>HttpListenerRequest disposed</p>
<p>System.IO.IOException: Error reading MIME multipart body part. ---> System.IO.IOException ---> System.Net.HttpListenerException: An operation was attempted on a nonexistent network connection</p>
<p>This web service is running as a self-hosted OWIN Windows service. The file uploads are small (3k to 4k).</p>
<p>I can't recreate the issue with a single upload. The client that is talking to the service uses tasks to post files, but it doesn't usually run more than 4 or 5 tasks concurrently. My team and I are relatively new to .NET tasks. One of the developers is wondering if the TaskCreationOptions.LongRunning parameter is actually hurting more than it helps. Any suggestions?</p>
<p><strong>Update:</strong></p>
<p>I tried switching out the Task.Factory code with this:</p>
<pre><code>var task = Task.Run(async () => await request.Content.ReadAsMultipartAsync(provider));
task.Wait();
provider = task.Result;
</code></pre>
<p>I'm still having some issues, but this seems to work better. Not sure why, though.</p> | 0 |
Export the dataGridView to Excel with all the cells format | <p>I have this code that I know that it works fast</p>
<pre><code>CopyAlltoClipboard(dataGridViewControl);
Microsoft.Office.Interop.Excel.Application xlexcel;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlexcel = new Excel.Application();
xlexcel.Visible = true;
xlWorkBook = xlexcel.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkSheet.Name = page.Name;
Excel.Range CR = (Excel.Range)xlWorkSheet.Cells[1, 1];
CR.Select();
xlWorkSheet.PasteSpecial(CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true);
((Microsoft.Office.Interop.Excel.Range)xlWorkSheet.Range["A1"]).EntireColumn.Delete(null); // delete the first column that has rows indexes
xlWorkBook.SaveAs(fileName);
private void CopyAlltoClipboard(DataGridView dataGridViewControl)
{
dataGridViewControl.SelectAll();
DataObject dataObj = dataGridViewControl.GetClipboardContent();
if (dataObj != null)
Invoke((Action)(() => { Clipboard.SetDataObject(dataObj); }));
}
</code></pre>
<p>The code works fine, but it does copy only the values is the excel, doesn't copy also the cells format (wrap text, backcolor, font, borders etc)
Can anyone help me on this one? How to complete this code the have the exact format like in DataGridView?</p> | 0 |
You have to be inside an angular-cli project in order to use the build command after reinstall of angular-cli | <p>I had the latest angular-cli installed globally and my project was building successfully. </p>
<p>While reading a suggested solution for another issue, (<a href="https://github.com/angular/angular-cli/issues/917" rel="noreferrer">https://github.com/angular/angular-cli/issues/917</a>) I uninstalled the global angular-cli and installed it as a dev-dependency. </p>
<p>That other issue wasn't solved so I uninstalled the dev-dependency and reinstalled angular-cli globally once again.
Now when I try to do an <strong>ng build</strong> I'm getting the error: </p>
<p><em>You have to be inside an angular-cli project in order to use the build command</em> </p>
<p>My angular-cli version did not change. Why isn't my project being recognised as an angular-cli project??</p> | 0 |
How to write NSData to a new file in Swift? | <p>I am working to get the contents of an NSData instance written to a file. I am currently using an Xcode playground. </p>
<p>This is my code:</p>
<pre><code>let validDictionary = [
"numericalValue": 1,
"stringValue": "JSON",
"arrayValue": [0, 1, 2, 3, 4, 5]
]
let rawData: NSData!
if NSJSONSerialization.isValidJSONObject(validDictionary) {
do {
rawData = try NSJSONSerialization.dataWithJSONObject(validDictionary, options: .PrettyPrinted)
try rawData.writeToFile("newdata.json", options: .DataWritingAtomic)
} catch {
// Handle Error
}
}
</code></pre>
<p>I have a file named newdata.json located in resources but when I check it there is nothing inside. I also tried deleting and seeing if the file will be created but it still doesn't work. </p> | 0 |
"auth/user-not-found" when signing in user with Firebase | <p>I have a firebase app connected to monaca CLI and OnsenUI. I am trying to create a user and log them in in the same action. <strong>I can successfully create a user</strong>, <strong>but I can't log in.</strong> When I log them in I get the following error</p>
<pre><code>auth/user-not-found
</code></pre>
<p>and</p>
<pre><code>There is no user record corresponding to this identifier. The User may have been deleted
</code></pre>
<p>I confirmed that the new user is in the db...Here is my code for the signup and signin</p>
<pre><code>//signup function stuff
var login = function() {
console.log('got to login stuff');
var email = document.getElementById('username').value;
var password = document.getElementById('password').value;
//firebases authentication code
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
console.log('User did not sign up correctly');
console.log(errorCode);
console.console.log(errorMessage);
});
firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
console.log(error.code);
console.log(error.message);
});
fn.load('home.html');
};
</code></pre> | 0 |
Why in Scala Long cannot in initialized to null whear as Integer can | <p>I am creating my Scala bean which is a configuration to be loaded from a YML config. I want a long property to be null if not specified, but I'm facing below issue. Any idea why?</p>
<pre><code>startOffset: Integer = null
scala> var endOffset: Long = null
<console>:11: error: an expression of type Null is ineligible for implicit conversion
var endOffset: Long = null
^`
</code></pre>
<p>PS: Yes I can use <code>Option[Long]</code> but wanted clarity and is there anything wrong with this approach.</p> | 0 |
Visual C++ for Python failed with exit status 2 | <pre><code> File "c:\users\user\appdata\local\temp\pip_build_user\ssdeep\.eggs\cff
i-1.8.2-py2.7-win32.egg\cffi\ffiplatform.py", line 65, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.ffiplatform.VerificationError: CompileError: command 'C:\\Users\\user\\
AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin
\\cl.exe' failed with exit status 2
</code></pre>
<hr>
<p>Cleaning up...
Command python setup.py egg_info failed with error code 1 in c:\users\</p>
<hr>
<p>I keep getting this error. I have tried multiple other solutions on here but no luck. Am I missing something. Thanks</p> | 0 |
difference between standard's atomic bool and atomic flag | <p>I wasn't aware of the <code>std::atomic</code> variables but was aware about the <code>std::mutex</code> (weird right!) provided by the standard; however one thing caught my eye: there are two seemingly-same (to me) atomic types provided by the standard, listed below:</p>
<ol>
<li><p><a href="http://en.cppreference.com/w/cpp/atomic/atomic" rel="noreferrer"><code>std::atomic<bool></code></a></p></li>
<li><p><a href="http://en.cppreference.com/w/cpp/atomic/atomic_flag" rel="noreferrer"><code>std::atomic_flag</code></a></p></li>
</ol>
<p>The <code>std::atomic_flag</code> contains the following explanation:</p>
<blockquote>
<p><code>std::atomic_flag</code> is an atomic boolean type. Unlike all specializations of <code>std::atomic</code>, it is guaranteed to be lock-free. Unlike <code>std::atomic<bool></code>, <code>std::atomic_flag</code> does not provide load or store operations.</p>
</blockquote>
<p>which I fail to understand. Is <code>std::atomic<bool></code> not guaranteed to be lock-free? Then it's not atomic or what?</p>
<p>So what's the difference between the two and when should I use which?</p> | 0 |
Tampermonkey script run before page load | <p>I need to hide a section from an html page:</p>
<pre><code><h1 data-ng-show="!menuPinned &amp;&amp; !isSaaS" class="logo floatLeft" aria-hidden="false"><span>XXX&nbsp;</span><span style="font-weight: bold;">XXX&nbsp;</span><span>XXXXX</span></h1>
</code></pre>
<p>The following code works fine in Chrome dev. tools</p>
<pre><code>var ibmlogo = document.querySelectorAll('h1.logo.floatLeft');
ibmlogo[1].remove();
</code></pre>
<p>But when I load the page with the script active, the section (h1) won't disappear.
I believe this is because when the script runs, the DOM has not been completed loaded yet, hence the script fails to find the selector.</p>
<p>I have tried many different things (e.g. window.onLoad) but still my script is not effective. Last attempt (failed) is the following:</p>
<pre><code>var logo = document.querySelectorAll('h1.logo.floatLeft');
logo.onload = function() {removeLogo()};
function removeLogo(){
console.log("### logo array lenght: " + logo.length);
logo[1].remove();
};
</code></pre> | 0 |
limit concurrent sessions to Apache tomcat web application | <p>I am using a web application based on Apache Tomcat. How can I limit the number of concurrent connections to this application in order to prevent more than a specific number of users from accessing it?</p>
<p>I am not a programmer, so if there is a way without a code it will be perfect.</p> | 0 |
How to loop video with AVPlayerLooper | <p>I try to loop a video in a TV OS app with the <code>AVPlayerLooper</code> because this should get rid of the pause/hicup when playing the video again. I watched the <code>WWDC2016</code> video <a href="https://developer.apple.com/videos/play/wwdc2016/503/" rel="noreferrer">https://developer.apple.com/videos/play/wwdc2016/503/</a> and try to implement the code but it doesn't loop.
I have one <code>PlayerViewController</code> which inherits <code>AVPlayerViewController</code>. I put the code to let the video loop. If I have the following code, it shows nothing. If I change the second line to <code>self.queuePlayer = AVQueuePlayer(playerItem:playerItem)</code>, it only plays once. </p>
<pre><code> let playerItem = AVPlayerItem(url: url as URL)
self.queuePlayer = AVQueuePlayer() //I declared this as a variable in the view controller
self.playerLayer = AVPlayerLayer(player: self.queuePlayer) //I declared this as a variable in the view controller
let playerLooper = AVPlayerLooper(player: self.queuePlayer!, templateItem: playerItem)
self.view.layer.addSublayer(self.playerLayer!)
self.playerLayer?.frame = self.view.frame
self.queuePlayer?.play()
</code></pre>
<p>Have any of you succeeded in playing looped video with the latest <code>AVPlayerLooper</code>?</p> | 0 |
How to create an overlay page in ionic 2? | <p>How to creating an transparent guide overlay page when i enter into new page </p>
<p>How can i implement in ionic 2 ?</p>
<p><a href="https://i.stack.imgur.com/zlu9a.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/zlu9a.jpg" alt="enter image description here"></a></p> | 0 |
What does the := operator mean in mysql? | <p>I have a <code>mysql</code> table (<code>scho_id</code>,<code>school_name</code>,<code>school_views</code>). </p>
<p>I was looking for a <code>mysql</code> query to get <code>rank</code> of schools on the basis of <code>school_views</code>.</p>
<p>I found this solution on stackoverflow.</p>
<pre><code>SET @points := -1, @num := 0;
SELECT scho_id
, school_views
, @num := if(@points = school_views, @num, @num + 1) as school_rank
, @points := school_info.school_views as dummy
FROM school_info
ORDER BY school_views desc, scho_id asc;
</code></pre>
<p>This solved my problem but I notice a new operator <code>:=</code> in this query. I am curious to know the meaning and uses of this operator.</p> | 0 |
Calling "fit" multiple times in Keras | <p>I've working on a CNN over several hundred GBs of images. I've created a training function that bites off 4Gb chunks of these images and calls <code>fit</code> over each of these pieces. I'm worried that I'm only training on the last piece on not the entire dataset.</p>
<p>Effectively, my pseudo-code looks like this:</p>
<pre><code>DS = lazy_load_400GB_Dataset()
for section in DS:
X_train = section.images
Y_train = section.classes
model.fit(X_train, Y_train, batch_size=16, nb_epoch=30)
</code></pre>
<p>I know that the API and the Keras forums say that this will train over the entire dataset, but I can't intuitively understand why the network wouldn't relearn over just the last training chunk.</p>
<p>Some help understanding this would be much appreciated.</p>
<p>Best,
Joe</p> | 0 |
Mock for context-manager fails with AttributeError: __exit__ | <p>I am trying to patch some context manager function using a Mock so I can test that the code does sensible things given good, bad, and garbage input. Here is the test code with the <code>with</code> statement in it. The patch is done in the correct place in my code.</p>
<pre><code>@patch("__main__.opened_w_error")
def test_get_recipe_file(self, mo):
mo.return_value = (Mock(), None)
mo.__enter__ = Mock(return_value=None)
mo.__exit__ = Mock(return_value=None)
with mo(…) as (fd, err): # AttributeError: __exit__ is raised here.
print(fd)
print(err)
</code></pre>
<p>However the <code>with mo(…) as (fd, err)</code> raises <code>AttributeError: __exit__</code>.</p>
<p>The <a href="http://www.voidspace.org.uk/python/mock/magicmock.html?highlight=__exit__" rel="noreferrer">documentation for mocking magic methods</a> states the you should use it as</p>
<pre><code>with mo as (fd, err):
…
</code></pre>
<p>The latter piece of code is what I am trying to mock.
but that is not how I use it in my code. For those really interested, I am trying to mock <a href="https://www.python.org/dev/peps/pep-0343/" rel="noreferrer">example 6 <code>opened_w_error()</code> in PEP 343</a> which deals with opening files and catching errors. Thus the code is:</p>
<pre><code>with open_w_error(filename, 'r') as (fd, err):
…
</code></pre>
<p>The latter is what I am trying to mock.</p> | 0 |
DataTables Bootstrap pagination not rendering | <p>I have the sample DataTable working on my test server. However, for some reason the Bootstrap pagination is not rendering properly.</p>
<p><img src="https://i.imgur.com/CUrdDr3.png" alt="Rendering issue"></p>
<p>This is not the Bootstrap styling. Here is the code:</p>
<pre><code> <!DOCTYPE html>
<html>
<head>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'></script>
<link href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' rel='stylesheet'>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css">
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js" charset="utf-8"></script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js" charset="utf-8"></script>
</head>
<body>
<table id="example" class="table display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
...
<script>
$(document).ready(function(){
$("#example").DataTable({
// "sPaginationType": "bootstrap",
});
});
</script>
</code></pre>
<p>How can the standard Bootstrap styling be rendered in this example?</p>
<p><strong>EDIT:</strong>
Table markup:</p>
<pre><code> <table id="example" class="table display" cellspacing="0" width="100%">
<thead>
<tr>
<th>User ID</th>
<th>Name</th>
<th>Company name</th>
<th>Joining date</th>
<th>Plan</th>
<th>Commission</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008/11/28</td>
<td>$162,700</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration Specialist</td>
<td>New York</td>
<td>61</td>
<td>2012/12/02</td>
<td>$372,000</td>
</tr>
<tr>
<td>Herrod Chandler</td>
<td>Sales Assistant</td>
<td>San Francisco</td>
<td>59</td>
<td>2012/08/06</td>
<td>$137,500</td>
</tr>
<tr>
<td>Rhona Davidson</td>
<td>Integration Specialist</td>
<td>Tokyo</td>
<td>55</td>
<td>2010/10/14</td>
<td>$327,900</td>
</tr>
<tr>
<td>Colleen Hurst</td>
<td>Javascript Developer</td>
<td>San Francisco</td>
<td>39</td>
<td>2009/09/15</td>
<td>$205,500</td>
</tr>
<tr>
<td>Sonya Frost</td>
<td>Software Engineer</td>
<td>Edinburgh</td>
<td>23</td>
<td>2008/12/13</td>
<td>$103,600</td>
</tr>
<tr>
<td>Jena Gaines</td>
<td>Office Manager</td>
<td>London</td>
<td>30</td>
<td>2008/12/19</td>
<td>$90,560</td>
</tr>
<tr>
<td>Quinn Flynn</td>
<td>Support Lead</td>
<td>Edinburgh</td>
<td>22</td>
<td>2013/03/03</td>
<td>$342,000</td>
</tr>
<tr>
<td>Charde Marshall</td>
<td>Regional Director</td>
<td>San Francisco</td>
<td>36</td>
<td>2008/10/16</td>
<td>$470,600</td>
</tr>
<tr>
<td>Haley Kennedy</td>
<td>Senior Marketing Designer</td>
<td>London</td>
<td>43</td>
<td>2012/12/18</td>
<td>$313,500</td>
</tr>
<tr>
<td>Tatyana Fitzpatrick</td>
<td>Regional Director</td>
<td>London</td>
<td>19</td>
<td>2010/03/17</td>
<td>$385,750</td>
</tr>
<tr>
<td>Michael Silva</td>
<td>Marketing Designer</td>
<td>London</td>
<td>66</td>
<td>2012/11/27</td>
<td>$198,500</td>
</tr>
<tr>
<td>Paul Byrd</td>
<td>Chief Financial Officer (CFO)</td>
<td>New York</td>
<td>64</td>
<td>2010/06/09</td>
<td>$725,000</td>
</tr>
<tr>
<td>Gloria Little</td>
<td>Systems Administrator</td>
<td>New York</td>
<td>59</td>
<td>2009/04/10</td>
<td>$237,500</td>
</tr>
<tr>
<td>Bradley Greer</td>
<td>Software Engineer</td>
<td>London</td>
<td>41</td>
<td>2012/10/13</td>
<td>$132,000</td>
</tr>
<tr>
<td>Dai Rios</td>
<td>Personnel Lead</td>
<td>Edinburgh</td>
<td>35</td>
<td>2012/09/26</td>
<td>$217,500</td>
</tr>
<tr>
<td>Jenette Caldwell</td>
<td>Development Lead</td>
<td>New York</td>
<td>30</td>
<td>2011/09/03</td>
<td>$345,000</td>
</tr>
<tr>
<td>Yuri Berry</td>
<td>Chief Marketing Officer (CMO)</td>
<td>New York</td>
<td>40</td>
<td>2009/06/25</td>
<td>$675,000</td>
</tr>
<tr>
<td>Caesar Vance</td>
<td>Pre-Sales Support</td>
<td>New York</td>
<td>21</td>
<td>2011/12/12</td>
<td>$106,450</td>
</tr>
<tr>
<td>Doris Wilder</td>
<td>Sales Assistant</td>
<td>Sidney</td>
<td>23</td>
<td>2010/09/20</td>
<td>$85,600</td>
</tr>
<tr>
<td>Angelica Ramos</td>
<td>Chief Executive Officer (CEO)</td>
<td>London</td>
<td>47</td>
<td>2009/10/09</td>
<td>$1,200,000</td>
</tr>
<tr>
<td>Gavin Joyce</td>
<td>Developer</td>
<td>Edinburgh</td>
<td>42</td>
<td>2010/12/22</td>
<td>$92,575</td>
</tr>
<tr>
<td>Jennifer Chang</td>
<td>Regional Director</td>
<td>Singapore</td>
<td>28</td>
<td>2010/11/14</td>
<td>$357,650</td>
</tr>
<tr>
<td>Brenden Wagner</td>
<td>Software Engineer</td>
<td>San Francisco</td>
<td>28</td>
<td>2011/06/07</td>
<td>$206,850</td>
</tr>
<tr>
<td>Fiona Green</td>
<td>Chief Operating Officer (COO)</td>
<td>San Francisco</td>
<td>48</td>
<td>2010/03/11</td>
<td>$850,000</td>
</tr>
<tr>
<td>Shou Itou</td>
<td>Regional Marketing</td>
<td>Tokyo</td>
<td>20</td>
<td>2011/08/14</td>
<td>$163,000</td>
</tr>
<tr>
<td>Michelle House</td>
<td>Integration Specialist</td>
<td>Sidney</td>
<td>37</td>
<td>2011/06/02</td>
<td>$95,400</td>
</tr>
<tr>
<td>Suki Burks</td>
<td>Developer</td>
<td>London</td>
<td>53</td>
<td>2009/10/22</td>
<td>$114,500</td>
</tr>
<tr>
<td>Prescott Bartlett</td>
<td>Technical Author</td>
<td>London</td>
<td>27</td>
<td>2011/05/07</td>
<td>$145,000</td>
</tr>
<tr>
<td>Gavin Cortez</td>
<td>Team Leader</td>
<td>San Francisco</td>
<td>22</td>
<td>2008/10/26</td>
<td>$235,500</td>
</tr>
<tr>
<td>Martena Mccray</td>
<td>Post-Sales support</td>
<td>Edinburgh</td>
<td>46</td>
<td>2011/03/09</td>
<td>$324,050</td>
</tr>
<tr>
<td>Unity Butler</td>
<td>Marketing Designer</td>
<td>San Francisco</td>
<td>47</td>
<td>2009/12/09</td>
<td>$85,675</td>
</tr>
<tr>
<td>Howard Hatfield</td>
<td>Office Manager</td>
<td>San Francisco</td>
<td>51</td>
<td>2008/12/16</td>
<td>$164,500</td>
</tr>
<tr>
<td>Hope Fuentes</td>
<td>Secretary</td>
<td>San Francisco</td>
<td>41</td>
<td>2010/02/12</td>
<td>$109,850</td>
</tr>
<tr>
<td>Vivian Harrell</td>
<td>Financial Controller</td>
<td>San Francisco</td>
<td>62</td>
<td>2009/02/14</td>
<td>$452,500</td>
</tr>
<tr>
<td>Timothy Mooney</td>
<td>Office Manager</td>
<td>London</td>
<td>37</td>
<td>2008/12/11</td>
<td>$136,200</td>
</tr>
<tr>
<td>Jackson Bradshaw</td>
<td>Director</td>
<td>New York</td>
<td>65</td>
<td>2008/09/26</td>
<td>$645,750</td>
</tr>
<tr>
<td>Olivia Liang</td>
<td>Support Engineer</td>
<td>Singapore</td>
<td>64</td>
<td>2011/02/03</td>
<td>$234,500</td>
</tr>
<tr>
<td>Bruno Nash</td>
<td>Software Engineer</td>
<td>London</td>
<td>38</td>
<td>2011/05/03</td>
<td>$163,500</td>
</tr>
<tr>
<td>Sakura Yamamoto</td>
<td>Support Engineer</td>
<td>Tokyo</td>
<td>37</td>
<td>2009/08/19</td>
<td>$139,575</td>
</tr>
<tr>
<td>Thor Walton</td>
<td>Developer</td>
<td>New York</td>
<td>61</td>
<td>2013/08/11</td>
<td>$98,540</td>
</tr>
<tr>
<td>Finn Camacho</td>
<td>Support Engineer</td>
<td>San Francisco</td>
<td>47</td>
<td>2009/07/07</td>
<td>$87,500</td>
</tr>
<tr>
<td>Serge Baldwin</td>
<td>Data Coordinator</td>
<td>Singapore</td>
<td>64</td>
<td>2012/04/09</td>
<td>$138,575</td>
</tr>
<tr>
<td>Zenaida Frank</td>
<td>Software Engineer</td>
<td>New York</td>
<td>63</td>
<td>2010/01/04</td>
<td>$125,250</td>
</tr>
<tr>
<td>Zorita Serrano</td>
<td>Software Engineer</td>
<td>San Francisco</td>
<td>56</td>
<td>2012/06/01</td>
<td>$115,000</td>
</tr>
<tr>
<td>Jennifer Acosta</td>
<td>Junior Javascript Developer</td>
<td>Edinburgh</td>
<td>43</td>
<td>2013/02/01</td>
<td>$75,650</td>
</tr>
<tr>
<td>Cara Stevens</td>
<td>Sales Assistant</td>
<td>New York</td>
<td>46</td>
<td>2011/12/06</td>
<td>$145,600</td>
</tr>
<tr>
<td>Hermione Butler</td>
<td>Regional Director</td>
<td>London</td>
<td>47</td>
<td>2011/03/21</td>
<td>$356,250</td>
</tr>
<tr>
<td>Lael Greer</td>
<td>Systems Administrator</td>
<td>London</td>
<td>21</td>
<td>2009/02/27</td>
<td>$103,500</td>
</tr>
<tr>
<td>Jonas Alexander</td>
<td>Developer</td>
<td>San Francisco</td>
<td>30</td>
<td>2010/07/14</td>
<td>$86,500</td>
</tr>
<tr>
<td>Shad Decker</td>
<td>Regional Director</td>
<td>Edinburgh</td>
<td>51</td>
<td>2008/11/13</td>
<td>$183,000</td>
</tr>
<tr>
<td>Michael Bruce</td>
<td>Javascript Developer</td>
<td>Singapore</td>
<td>29</td>
<td>2011/06/27</td>
<td>$183,000</td>
</tr>
<tr>
<td>Donna Snider</td>
<td>Customer Support</td>
<td>New York</td>
<td>27</td>
<td>2011/01/25</td>
<td>$112,000</td>
</tr>
</tbody>
</table>
</code></pre> | 0 |
Procedure expects parameter '@params' of type 'ntext/nchar/nvarchar' | <p>this is my stored procedure:</p>
<pre><code>ALTER PROCEDURE [dbo].[sp_Update_Projecttijden]
@tabelnaam NVARCHAR(30) ,
@starttijd DATETIME,
@eindtijd DATETIME,
@tijd FLOAT,
@startid INT,
@eindid INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
-- DECLARE @DATEVARCHAR NVARCHAR(4000);
DECLARE @SQLCommand NVARCHAR(MAX) = N'
UPDATE ' + QUOTENAME(@tabelnaam) + N'
SET Start = @starttijd
, Einde = @eindtijd
, Tijd = @tijd
, StartID = @startid
, EindID = @eindid
WHERE StartID = @startid AND EindID=@eindid';
EXECUTE dbo.sp_executesql @sqlCommand,
' N @starttijd DATETIME, @eindtijd DATETIME, @tijd FLOAT, @startid INT, @eindid INT'
, @starttijd
, @eindtijd
, @tijd
, @startid
, @eindid;
END
</code></pre>
<p>The error thrown is this:</p>
<blockquote>
<p>Msg 214, Level 16, State 3, Procedure sp_executesql, Line 3 Procedure
expects parameter '@params' of type 'ntext/nchar/nvarchar'.</p>
</blockquote>
<p>I have been looking at similar questions/answers, but could not really solve my problem.
All help is very much appreciated.</p> | 0 |
How to specify JSON-formatted string in Cloudformation? | <p>I have the following resource on my CloudFormation template to create a rule to run a Lambda function, from the AWS documentation:</p>
<pre><code> "ScheduledRule": {
"Type": "AWS::Events::Rule",
"Properties": {
"Description": "ScheduledRule",
"ScheduleExpression": "rate(5 minutes)",
"State": "ENABLED",
"Targets": [{
"Arn": { "Fn::GetAtt": ["myLambda", "Arn"] },
"Id": "TargetFunctionV1"
}]
}
}
</code></pre>
<p>I would like to specify the Input:</p>
<pre><code>{
"Arn" : String,
"Id" : String,
"Input" : String,
"InputPath" : String
}
</code></pre>
<p>and Input is a JSON-formatted text string that is passed to the target. This value overrides the matched event.</p>
<p>I would like my JSON formatted text to be:</p>
<pre><code>{
"mykey1": "Some Value"
}
</code></pre>
<p>I do not know how to specify it in the Input, when I put:</p>
<pre><code> "ScheduledRule": {
"Type": "AWS::Events::Rule",
"Properties": {
"Description": "ScheduledRule",
"ScheduleExpression": "rate(5 minutes)",
"State": "ENABLED",
"Targets": [{
"Arn": { "Fn::GetAtt": ["myLambda", "Arn"] },
"Id": "TargetFunctionV1",
"Input": { "mykey1": "Some Value" }
}]
}
}
</code></pre>
<p>I will get error:</p>
<pre><code>Value of property Input must be of type String
</code></pre>
<p>How should I specify it correctly?</p> | 0 |
Unable to start spring-boot application in IntelliJ Idea | <p><strong>Overview</strong></p>
<p>I can run the application by using maven plugin of spring-boot but not run it with the IDE. The following lines give some detail about my program.</p>
<p>The application class is as follows: </p>
<pre><code>package com.blss.retailServices.dataExportRouter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.velocity.VelocityAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan
@EnableAutoConfiguration(exclude = { VelocityAutoConfiguration.class })
public class DataExportRouterApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(DataExportRouterApplication.class, args);
}
}
</code></pre>
<p>The exception stack trace is as follows: </p>
<pre><code>org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at com.blss.retailServices.dataExportRouter.DataExportRouterApplication.main(DataExportRouterApplication.java:14) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_74]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_74]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_74]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_74]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:185) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
... 13 common frames omitted
</code></pre>
<p>I used @SpringbootApplication but to no avail. </p>
<p><strong>Question</strong></p>
<p>So I would appreciate it if anyone could help me solve this issue.</p> | 0 |
manually add breaks to both x and y axis in ggplot2 | <p>I've typically changed the scale breaks for continuous variables in ggplot2 using <code>scale_y_continuous</code> (or <code>scale_x_continuous</code>). I also usually set the axis limits using <code>coord_cartesian(xlim=)</code> (or <code>ylim=</code> for y axis). All that works just fine like in the following:</p>
<pre><code>#Some example data
set.seed(100)
b<-sample(1:10, 10)
a<-sample(1:10, 10)
df<-data.frame(a,b)
#Graph without scales set (just default)
library(ggplot2)
ggplot(data=df, aes(a,b))+
theme_bw() + theme(panel.border = element_rect(colour = "black", fill=NA, size=1),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"))+
geom_text(aes(label=rownames(df)), color="black")
</code></pre>
<p>That produces the following plot with default scales:</p>
<p><a href="https://i.stack.imgur.com/wldM5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wldM5.png" alt="enter image description here"></a></p>
<p>If I want to adjust the x-axis to, say, 1-13 (i.e. 13 tick marks starting at 1 and ending at 13) I would do the following:</p>
<pre><code>ggplot(data=df, aes(a,b))+
theme_bw() + theme(panel.border = element_rect(colour = "black", fill=NA, size=1),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"))+
geom_text(aes(label=rownames(df)), color="black")+
scale_x_continuous(breaks = c(1,3,5,7,9,11,13))+
coord_cartesian(xlim=c(0, 13))
</code></pre>
<p><a href="https://i.stack.imgur.com/v4EYc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v4EYc.png" alt="enter image description here"></a></p>
<p>...and for the y-axis...</p>
<pre><code>ggplot(data=df, aes(a,b))+
theme_bw() + theme(panel.border = element_rect(colour = "black", fill=NA, size=1),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"))+
geom_text(aes(label=rownames(df)), color="black")+
scale_y_continuous(breaks = c(1,3,5,7,9,11,13))+
coord_cartesian(ylim=c(0, 13))
</code></pre>
<p><a href="https://i.stack.imgur.com/aQa9T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aQa9T.png" alt="enter image description here"></a></p>
<p>However, when I try to accomplish the very same scale adjustment for both axes at the same time, the output does not produce what I would expect (which is 1-13 on both the x and y axes).</p>
<pre><code>ggplot(data=df, aes(a,b))+
theme_bw() + theme(panel.border = element_rect(colour = "black", fill=NA, size=1),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"))+
geom_text(aes(label=rownames(df)), color="black")+
scale_y_continuous(breaks = c(1,3,5,7,9,11,13))+
coord_cartesian(ylim=c(0, 13))+
scale_x_continuous(breaks = c(1,3,5,7,9,11,13))+
coord_cartesian(xlim=c(0, 13))
</code></pre>
<p><a href="https://i.stack.imgur.com/xhEuA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xhEuA.png" alt="enter image description here"></a></p>
<p>As you can see, the x and y axis are not equivalent even though the exact same code has been passed to both axes. I don't understand why. Any help is much appreciated.</p> | 0 |
Exporting Datagridview to Excel in C# | <p>This code always skips last row after exporting excel, can you check what's wrong in the code?</p>
<p><strong>I changed</strong></p>
<pre><code>transcationTableDataGridView.Rows.Count - 1
</code></pre>
<p><strong>to</strong> </p>
<pre><code>transcationTableDataGridView.Rows.Count + 1
</code></pre>
<p>it does export all rows to excel but throws index should be non-negative error this exception: <a href="https://i.stack.imgur.com/y8Wxu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y8Wxu.jpg" alt="enter image description here"></a></p>
<pre><code> private void exportToExcel_Click(object sender, EventArgs e)
{
try
{
Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
app.Visible = true;
worksheet = workbook.Sheets["Sheet1"];
worksheet = workbook.ActiveSheet;
worksheet.Name = "Records";
try
{
for (int i = 1; i < transcationTableDataGridView.Columns.Count + 1; i++)
{
worksheet.Cells[1, i] = transcationTableDataGridView.Columns[i - 1].HeaderText;
}
for (int i = 0; i < transcationTableDataGridView.Rows.Count - 1; i++)
{
for (int j = 0; j < transcationTableDataGridView.Columns.Count; j++)
{
if (transcationTableDataGridView.Rows[i].Cells[j].Value != null)
{
worksheet.Cells[i + 2, j + 1] = transcationTableDataGridView.Rows[i].Cells[j].Value.ToString();
}
else
{
worksheet.Cells[i + 2, j + 1] = "";
}
}
}
//Getting the location and file name of the excel to save from user.
SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.Filter = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
saveDialog.FilterIndex = 2;
if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
workbook.SaveAs(saveDialog.FileName);
MessageBox.Show("Export Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
app.Quit();
workbook = null;
worksheet = null;
}
}
catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
}
</code></pre>
<p><strong>It also gives me error during export in some computers</strong></p>
<p>I was using this code:</p>
<pre><code>using Excel=Microsoft.Office.Interop.Excel;
</code></pre>
<p>to this code: </p>
<pre><code>using System.Runtime.InteropServices;
</code></pre>
<p>can anyone explain what is the difference between two?</p> | 0 |
Retrofit java.net.SocketTimeoutException | <p>Retrofit Call:</p>
<pre><code> RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("BASE URL")
.setLogLevel(RestAdapter.LogLevel.FULL)
.setClient(new OkClient(getOkHttpClient()))
.build();
</code></pre>
<p>Dependencies:</p>
<pre><code>compile 'com.squareup.okhttp:okhttp:2.7.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
</code></pre>
<p>Error:
user_id=XXXX&item_id=X&item_quantity=1&item_cost=XXXX&pay_id=stripe&process_fee=XXX&total_cost=XXX&is_nagotiation=0&negotiate_id=&tips=XXX&card_id=XXXX</p>
<blockquote>
<p>09-07 11:45:08.628 23473-24373/com.bridgellc.bridge D/Retrofit: --->
END HTTP (177-byte body) 09-07 11:45:18.635
23473-24373/com.bridgellc.bridge D/Retrofit: ---- ERROR http:XXXXXX
09-07 11:45:18.650 23473-24373/com.bridgellc.bridge D/Retrofit:
java.net.SocketTimeoutException</p>
</blockquote> | 0 |
HackerRank says ~ no response on stdout ~ | <p>So I was solving this Question on HackerRank (Project Euler Q1) <a href="https://www.hackerrank.com/contests/projecteuler/challenges/euler001" rel="nofollow">link here</a>, and have used the following code to solve it</p>
<pre><code>import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
int T = 0;
ArrayList<Integer> N = new ArrayList<Integer>();
String[] Input = args;
if (args.length>1){
T = Integer.parseInt(args[0]);
if(T<1||T>Math.pow(10,6))
System.exit(0);
}
if (args.length-1 == T){
for (int i=1;i<args.length;i++){
N.add(Integer.parseInt(args[i]));
int sum3=0,sum5=0,sum15=0;
int count=0;
while (count<N.get(i-1)){
sum3+=count;
count+=3;
}
count =0;
while (count<N.get(i-1)){
sum5+=count;
count+=5;
}
count =0;
while (count<N.get(i-1)){
sum15+=count;
count+=15;
}
N.set(i-1,(sum3+sum5-sum15));
}
}
for(int j=0;j<N.size();j++)
System.out.println(N.get(j));
}
}
</code></pre>
<p>This gives me the following output on an IDE :</p>
<pre><code>23
2318
</code></pre>
<p>While Inputting : </p>
<pre><code>2
10
100
</code></pre>
<p>And this matches the expected output on HackerRank, but however When I use this code on the website, It says :</p>
<p>Input (stdin)</p>
<pre><code>2
10
100
</code></pre>
<p>Your Output (stdout)</p>
<pre><code>~ no response on stdout ~
</code></pre>
<p>Expected Output</p>
<pre><code>23
2318
</code></pre>
<p>Compiler Message</p>
<pre><code>Wrong Answer
</code></pre>
<p>One thing I could observe was I couldn't print anything from inside a loop on HackerRank. What would the solution to this be?</p> | 0 |
Chart.js click on labels, using bar chart | <p>i need help with my Chart.js interactivity. When I click on the label, I need to return the column(index) number at which I clicked.</p>
<p>I tried to use getElementsAtEvent but it only work if I click directly at chart.</p>
<p>This <a href="http://jsfiddle.net/yxz2sjam/" rel="nofollow">http://jsfiddle.net/yxz2sjam/</a> is pretty much what I am looking for but getPointsAtEvent is no longer available in the new versions.</p>
<pre><code>canvas.onclick = function (evt) {
var points = chart.getPointsAtEvent(evt);
alert(chart.datasets[0].points.indexOf(points[0]));
};
</code></pre>
<p>I also found this <a href="http://jsfiddle.net/1Lngmtz7/" rel="nofollow">http://jsfiddle.net/1Lngmtz7/</a> but it isn't working with bar chart.</p>
<pre><code>var ctx = document.getElementById("myChart").getContext("2d");
var myRadarChart = new Chart(ctx, {
type: 'radar',
data: data
})
$('#myChart').click(function (e) {
var helpers = Chart.helpers;
var eventPosition = helpers.getRelativePosition(e, myRadarChart.chart);
var mouseX = eventPosition.x;
var mouseY = eventPosition.y;
var activePoints = [];
helpers.each(myRadarChart.scale.ticks, function (label, index) {
for (var i = this.getValueCount() - 1; i >= 0; i--) {
var pointLabelPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.options.reverse ? this.min : this.max) + 5);
var pointLabelFontSize = helpers.getValueOrDefault(this.options.pointLabels.fontSize, Chart.defaults.global.defaultFontSize);
var pointLabeFontStyle = helpers.getValueOrDefault(this.options.pointLabels.fontStyle, Chart.defaults.global.defaultFontStyle);
var pointLabeFontFamily = helpers.getValueOrDefault(this.options.pointLabels.fontFamily, Chart.defaults.global.defaultFontFamily);
var pointLabeFont = helpers.fontString(pointLabelFontSize, pointLabeFontStyle, pointLabeFontFamily);
ctx.font = pointLabeFont;
var labelsCount = this.pointLabels.length,
halfLabelsCount = this.pointLabels.length / 2,
quarterLabelsCount = halfLabelsCount / 2,
upperHalf = (i < quarterLabelsCount || i > labelsCount - quarterLabelsCount),
exactQuarter = (i === quarterLabelsCount || i === labelsCount - quarterLabelsCount);
var width = ctx.measureText(this.pointLabels[i]).width;
var height = pointLabelFontSize;
var x, y;
if (i === 0 || i === halfLabelsCount)
x = pointLabelPosition.x - width / 2;
else if (i < halfLabelsCount)
x = pointLabelPosition.x;
else
x = pointLabelPosition.x - width;
if (exactQuarter)
y = pointLabelPosition.y - height / 2;
else if (upperHalf)
y = pointLabelPosition.y - height;
else
y = pointLabelPosition.y
if ((mouseY >= y && mouseY <= y + height) && (mouseX >= x && mouseX <= x + width))
activePoints.push({ index: i, label: this.pointLabels[i] });
}
}, myRadarChart.scale);
var firstPoint = activePoints[0];
if (firstPoint !== undefined) {
alert(firstPoint.index + ': ' + firstPoint.label);
}
});
</code></pre>
<p>Thank for response.</p> | 0 |
Where the Microsoft.Management.Infrastructure | <p>I need to get hdd info, and I want to use WMI.</p>
<p>example from msdn</p>
<pre><code>using Microsoft.Management.Infrastructure;
...
string Namespace = @"root\cimv2";
string className = "Win32_LogicalDisk";
CimInstance myDrive = new CimInstance(className, Namespace);
</code></pre>
<p>I'm using <code>Visual Studio 2015</code>. I've created a <code>console application</code> in solution for testing WMI. There is no Microsoft.Management.Infrastructure, how to add it?</p> | 0 |
Avoid double quotes around column while spooling to csv from oracle | <p>I need to export a select query output to text file using spool. The output by default adds double quotes around the column. How to Prevent it?
The query returns only one column. </p>
<p>Ideally i need to remove headers as well as the double quotes from the output. below is the script file i use in oracle Developer. but heading is also not removed.</p>
<pre><code>set echo off
SET HEADING OFF
SET PAGESIZE 0
SET COLSEP ''
spool 'D:\public\cvs_txPCG.txt'
select /*csv*/
pcg from temptx;
spool off;
</code></pre>
<p>output</p>
<pre><code>"PCG"
"76259737020150320000504281565213310052440093515652109.2909.290101"
"19519905620160502000504283153419040044861008644759203.3903.390101"
"49424051620160220000504284594314590009220713032964404.3804.380202"
"88761197020151025000504284594315180036700812132964401.9901.990101"
</code></pre> | 0 |
EL1008E:(pos 8):Property or field cannot be found on object of type '...security.web.access.expression.WebSecurityExpressionRoot' maybe not public? | <p>I am developing <code>Spring-Security-Access-Control-Example</code> using <strong>Spring MVC</strong> (version <code>4.3.1.RELEASE</code>) <strong>+ Spring Security</strong> <code>(4.1.1.RELEASE)</code>. Simply looking to implement access control or authorization on web application. When I simply lauch the URL: <a href="http://localhost:8080/Spring-Security-Access-Control-Example/admin" rel="noreferrer">http://localhost:8080/Spring-Security-Access-Control-Example/admin</a>. I get the following error and I really exhausted in solving the issue.</p>
<p>The error message/stack:</p>
<pre><code>java.lang.IllegalArgumentException: Failed to evaluate expression 'hasRole(ROLE_ADMIN)'
at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:30)
at org.springframework.security.web.access.expression.WebExpressionVoter.vote(WebExpressionVoter.java:52)
at org.springframework.security.web.access.expression.WebExpressionVoter.vote(WebExpressionVoter.java:33)
at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:63)
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:233)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:124)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:158)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:177)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 8): Property or field 'ROLE_ADMIN' cannot be found on object of type 'org.springframework.security.web.access.expression.WebSecurityExpressionRoot' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81)
at org.springframework.expression.spel.ast.MethodReference.getArguments(MethodReference.java:154)
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:84)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299)
at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:26)
... 59 more
</code></pre>
<p><strong>WelcomeController.java</strong></p>
<pre><code>@Controller
public class WelcomeController {
@RequestMapping(value = "/admin", method = RequestMethod.GET)
public String welcomeAdmin(ModelMap model) {
model.addAttribute("message", "Spring Security - ROLE_ADMIN");
return "hello";
}
}
</code></pre>
<p><strong>hello.jsp:</strong></p>
<pre><code><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
<h3>Message : ${message}</h3>
<a href="<c:url value="j_spring_security_logout" />" > Logout</a>
</body>
</html>
</code></pre>
<p><strong>mvc-dispatcher-servlet.xml</strong></p>
<pre><code><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.mkyong.common.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>mymessages</value>
</list>
</property>
</bean>
</beans>
</code></pre>
<p><strong>spring-security.xml</strong></p>
<pre><code><beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/admin*" access="hasRole(ROLE_ADMIN)" />
<logout logout-success-url="/admin" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="mkyong" password="password" authorities="ROLE_USER" />
<user name="eclipse" password="password" authorities="ROLE_ADMIN" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
</code></pre>
<p><strong>web.xml</strong></p>
<pre><code><web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Spring MVC Application</display-name>
<!-- Spring MVC -->
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-dispatcher-servlet.xml,
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
</code></pre>
<p><strong>pom.xml</strong></p>
<pre><code><properties>
<jdk.version>1.8</jdk.version>
<springframework.version>4.3.1.RELEASE</springframework.version>
<springsecurity.version>4.1.1.RELEASE</springsecurity.version>
<logback.version>1.1.7</logback.version>
<jcl-over-slf4j.version>1.7.21</jcl-over-slf4j.version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${springsecurity.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${springsecurity.version}</version>
</dependency>
<!-- logging, slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${jcl-over-slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</code></pre>
<p>Note: I followed many links, but whatever solution had provided I already applied that still its not working. Why ?</p> | 0 |
Why my alert function is not working when I click on button in Vue.js | <p>This is my index.html</p>
<pre><code><body>
<app></app>
</body>
</code></pre>
<p>This is my main.js</p>
<pre><code>import Vue from 'vue'
import App from './App'
new Vue({
el: 'body',
components: { App }
})
</code></pre>
<p>This is my App.vue</p>
<pre><code><template>
<div id="app">
<img class="logo" src="./assets/logo.png">
<hello></hello>
</div>
</template>
<script>
import Hello from './components/Hello'
export default {
components: {
Hello
}
}
</script>
</code></pre>
<p>and this is my Hello.vue</p>
<pre><code><template>
<div class="hello">
<h1>
{{ msg }}
</h1>
<button v-on:click="showAlert">Click</button>
</div>
</template>
<script>
export default {
data () {
return {
msg: 'Hello World!'
}
},
showAlert: () => {
alert('test')
}
}
</script>
</code></pre>
<p>Here is the error message from the Chrome console:</p>
<blockquote>
<p>[Vue warn]: v-on:click="showAlert" expects a function value, got undefined (found in component: )</p>
</blockquote>
<p>I can see "Hello world!" on my screen and the button but nothing happened when I click on it.</p>
<p>I suppose I will have "test" alert message.</p>
<p>Did I do something wrong?</p> | 0 |
SCSS color variables that belong to an object | <p>I am refactoring a project's SCSS to map colors to their own variable in a <code>_colors.scss</code> file.</p>
<p>More often than not, I am encountering the situation in which a selector has a <code>background-color</code> and <code>color</code>. So, I end up writing the following variables:</p>
<pre><code>$cool-table-bg: $brand-primary;
$cool-table-text: $white;
</code></pre>
<p>Pretty soon I end up with many, many versions of the above.</p>
<p>What I want to know is, can I assign the above to an object like you would do in JavaScript? For example:</p>
<pre><code>$cool-table: {
bg: $brand-primary;
text: $white;
}
</code></pre>
<p>I'd like to be able to refer to such colors as <code>$cool-table.bg</code>.</p>
<p>Is this possible?</p> | 0 |
Check if battery optimization is enabled or not for an app | <p>Android 6 and 7 have some power optimizations (doze mode) which restrict app networking when device is not used.</p>
<p>User may disable optimization mode for any app in Battery settings:</p>
<p><a href="https://i.stack.imgur.com/iXk8X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iXk8X.png" alt="android settings screenshot"></a></p>
<p>Is it possible to check if optimization is enabled for my app or not? I need to ask user to disable optimization for better app functionality, but I don't know how to check it programatically.</p> | 0 |
How to use js modules from non-module files | <p>I'm a beginner at using js modules.</p>
<p>I'm working on a fairly simple web application. It uses typescript and angular 2, which heavily relies on modules.</p>
<p>Most of my app ts files 'import' one or many js modules (usually mostly angular 2 modules).</p>
<p>As I understand, because my app ts files have a top level 'import', they are automatically considered a js module by typescript.</p>
<p>However, I want any of my app ts files to be accessible by any other of my app ts files, without having to 'import' each other. But because they are now modules themselves, ts requires me to do that...</p>
<p>Is it possible?</p>
<p>It seems crazy to me that for each of my app ts file, I should have to declare every other of my app ts files that are used in there (I like to have tiny files with a single class/interface). In addition, this relies on relative paths which breaks as soon as I restructure my folder structure.</p>
<p>Am I thinking about this the wrong way?</p> | 0 |
how to remove standard background color of text in a div | <p><strong>EDIT: Solved it. I had to change from the tag html to body { background. Thank you for your help everyone</strong></p>
<p>I've searched on here and on google but I only get the opacity example, if I use opacity 0 then the text disappears too.</p>
<p>I have a html background meaning the complete page and in the code I've placed a div with a h1 and p tag with some text and then a white box-like background around the div of the text appears and I can't remove it.</p>
<pre><code><div class="container">
<div class="header-pris">
<h1>Pris alternativ:</h1>
<p>Skulle du vilja pröva enstaka timmar eller kanske tom mer timmar än vad som anges nedan så går det självklart också att annordna, kontakta oss direkt på
<a href="mailto:[email protected]"> [email protected]</a></p>
</div>
</div>
.header-pris {
text-align:center;
background-color:none;
}
</code></pre>
<p>tried with none as color but that doesn't do it so I don't know where I'm doing wrong or what the correct command should be to have no background on the div with the text so that you can see the image background</p> | 0 |
How to customize the reports for serenity BDD | <p>I wish to change the CSS and logos in Serenity reports. Also I want to add some custom text or links to some tests in the Serenity reports.Like there is an excel report gets generated and I wish to provide a link of it in the test step in the report. What is the best way to achieve this?</p> | 0 |
extract individual words from string c++ | <p>I am trying to make a C++ program that receives user input, and extracts the individual words in the string, e.g. "Hello to Bob" would get "Hello", "to", "Bob". Eventually, I will be pushing these into a string vector. This is the format I tried to use when designing the code:</p>
<pre><code>//string libraries and all other appropriate libraries have been included above here
string UserInput;
getline(cin,UserInput)
vector<string> words;
string temp=UserInput;
string pushBackVar;//this will eventually be used to pushback words into a vector
for (int i=0;i<UserInput.length();i++)
{
if(UserInput[i]==32)
{
pushBackVar=temp.erase(i,UserInput.length()-i);
//something like words.pushback(pushBackVar) will go here;
}
}
</code></pre>
<p>However, this only works for the first space encountered in the string.It does not work if there are any spaces before the word (e.g. if we have "Hello my World", pushBackVar will be "Hello" after the first loop, and then "Hello my" after the second loop, when I want "Hello" and "my".) How do I fix this? Is there any other better way to extract individual words from a string? I hope I haven't confused anyone. </p> | 0 |
ABAP hard code value into SELECT and field into another field | <p>It is possible in ABAP to make a select and include a hard code value and to put a value in any field.</p>
<p>In my exemple I have to fill a range with Company code BUKRS according to VKORG so I have to do a select on TVKO like that:</p>
<pre><code>DATA : lt_rtvko TYPE RANGE OF bukrs.
SELECT 'I' as sign 'EQ' as option bukrs as low
INTO CORRESPONDING FIELDS OF TABLE lt_rtvko
FROM tvko
WHERE vkorg EQ p_vkorg.
</code></pre>
<p>But I have a dump.</p>
<p>I know a longer solution to do this, To fill manually a table of TVKO and make a LOOP to fill the range, BUT I am sure that we have a solution to do that in one operation like in my example.</p>
<p>Thanks, Experts.</p> | 0 |
How to install firefoxdriver webdriver for python3 selenium on ubuntu 16.04? | <p>I installed python3-selenium apt package on Ubuntu 16.04. While installing, got a message:</p>
<pre><code>Suggested packages:
chromedriver firefoxdriver
The following NEW packages will be installed:
python3-selenium
</code></pre>
<p>When I try to run the following python code,</p>
<pre><code>#! /usr/bin/python3.5
from selenium import webdriver
import time
def get_profile():
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.privatebrowsing.autostart", True)
return profile
def main():
browser = webdriver.Firefox(firefox_profile=getProfile())
#browser shall call the URL
browser.get("http://www.google.com")
time.sleep(5)
browser.quit()
if __name__ == "__main__":
main()
</code></pre>
<p>I get the following error:</p>
<blockquote>
<p>Traceback (most recent call last):
File "./test.py", line 19, in
main()
File "./test.py", line 11, in main
browser = webdriver.Firefox(firefox_profile=getProfile())
File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox /webdriver.py", line 77, in <strong>init</strong>
self.binary, timeout),
File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in <strong>init</strong>
self.profile.add_extension()
File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 91, in add_extension
self._install_extension(extension)
File "/usr/lib/python3/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 251, in _install_extension
compressed_file = zipfile.ZipFile(addon, 'r')
File "/usr/lib/python3.5/zipfile.py", line 1009, in <strong>init</strong>
self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib /firefoxdriver/webdriver.xpi'</p>
</blockquote>
<p>I did searching for packages name firefoxdriver in Ubuntu repositories but none exist.
How do I solve this problem?</p>
<p>Any help with installing the webdrivers appreciated!</p> | 0 |
Python - SQLite JSON1 load extension | <p>I want to use the json1 extension for SQLite within Python. According to the <a href="http://sqlite.org/json1.html" rel="noreferrer">official documentation</a>, it should be a loadable extension. I got the json1.c file from the <a href="http://sqlite.org/cgi/src/raw/ext/misc/json1.c?name=9799e4252b305edcbe659329eec3ca80ed85f968" rel="noreferrer">source</a> and compiled it into json1.so as per the <a href="http://sqlite.org/loadext.html#build" rel="noreferrer">official instructions</a> without any errors.</p>
<pre><code>$ gcc -g -fPIC -shared json1.c -o json1.so
</code></pre>
<p>The trouble came up when I tried to load the extension in Python 2.7.12 (and 3.5.2) according to the <a href="http://docs.python.org/2/library/sqlite3.html" rel="noreferrer">sqlite3 documentation</a>.</p>
<pre><code>>>> import sqlite3
>>> con = sqlite3.connect(":memory:")
>>> con.enable_load_extension(True)
>>> con.load_extension("./json1.so")
</code></pre>
<p>I received the following traceback error message. I ran the Python interpreter from the folder with the json1.so file in it. Even though it seems like there should be more information due to the last colon, the following is the complete error message.</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: error during initialization:
</code></pre>
<p>Is it actually not possible to use json1 as a loadable extension within Python? Is my only option to recompile SQLite, pysqlite2, etc. as explained in <a href="http://charlesleifer.com/blog/using-the-sqlite-json1-and-fts5-extensions-with-python/" rel="noreferrer">this</a> blog post by Charles Leifer?</p>
<p>EDIT:</p>
<p>As it turns out, I was receiving the error because my machine already had this and other extensions already enabled. The action of enabling an already enabled extension triggered the error. So far, all linux computers I have access to already have the json1 and fts5 extensions enabled in the SQLite that comes with Python. You can check which compile options have been used by connecting to a SQLite database and running the following query.</p>
<pre><code>PRAGMA compile_options;
</code></pre> | 0 |
Custom Cell Reorder Behavior in CollectionView | <p>I am able to reorder my collectionView like so:</p>
<p><a href="https://i.stack.imgur.com/BbqAL.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/BbqAL.gif" alt="enter image description here"></a></p>
<p>However, instead of all cells shifting horizontally, I would just like to swap with the following behavior (i.e. with less shuffling of cells):</p>
<p><a href="https://i.stack.imgur.com/HLhAO.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/HLhAO.gif" alt="enter image description here"></a></p>
<p>I have been playing with the following delegate method:</p>
<pre><code>func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt originalIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath
</code></pre>
<p>however, I am unsure how I can achieve custom reordering behavior. </p> | 0 |
Redux: Create root reducer from combineReducers and "loose" properties | <p>I want to create a Redux store that has this shape:</p>
<pre><code>store = {
loaded: Boolean,
loading: Boolean,
view: Object, // uses combineReducers
layers: Object // uses combineReducers
}
</code></pre>
<p>So far, my root reducer looks like this:</p>
<p><strong>rootReducer.js</strong></p>
<pre><code>import view from './view';
import layers from './layers';
const initialState = {
loaded: false,
loading: false,
};
function loadState(state = initialState, action = {}) {
switch (action.type) {
case 'LOADED':
return {
...state,
loaded: true,
loading: false,
};
case 'LOADING':
return {
...state,
loaded: false,
loading: true,
};
default:
return state;
}
}
export default combineReducers({
view,
layers,
// hmmmm, putting loadState here would give me a loadState object property,
// not loose 'loaded' and 'loading' properties
});
</code></pre>
<p>How do I also have these "loose" properties like <code>loaded</code> and <code>loading</code> alongside them?</p> | 0 |
How to download specific Google Drive folder using Python? | <p>I'm trying to download specific folders from Google Drive.</p>
<p>I tried this example
<a href="http://www.mwclearning.com/?p=1608" rel="noreferrer">http://www.mwclearning.com/?p=1608</a> but its download all the files from G-Drive.</p>
<p>EX: If I have two folders in Google Drive say..</p>
<ul>
<li>A folder having -> 1 , 2 Files </li>
<li>B folder having -> 3, 4, 5 Files </li>
</ul>
<p>If I want to download folder A then only 1 , 2 files should get downloaded.. </p>
<p>Any suggestion or help could be very helpful.</p>
<p>Thanks in advance.</p> | 0 |
re-enable disabled menu "save video as" chrome ext or chrome itself "Save Video As" | <p>How can I re-enable the "Save Video As" option when it is disabled on a video?</p>
<p>This is basically the opposite of <a href="https://stackoverflow.com/questions/9756837/prevent-html5-video-from-being-downloaded-right-click-saved">this question</a>.</p>
<p>Is there a global command I can send to the chrome command line which re-enables this option?</p>
<p>Or is there a simple extension I could use?</p> | 0 |
Setup One to Many without Foreign Key Entity Framework | <p>I have the following design.
<a href="https://i.stack.imgur.com/bghEf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bghEf.png" alt="enter image description here"></a>
As we can see from this image, an Episode will have multiple EpisodePatients, and each of these EpisodePatients, will point to one Episode.</p>
<p>Here are my two models corresponding to the tables.</p>
<pre><code>public class EpisodeModel
{
public int ID { get; set; }
public virtual EpisodePatientModel EpisodePatient { get; set; }
}
public class EpisodePatientModel
{
public int EpisodePatientID { get; set; }
public virtual EpisodeModel Episode { get; set; }
}
</code></pre>
<p>How do I setup the One to Many relationship between <code>EpisodeModel</code> and <code>EpisodePatientModel</code>?</p>
<p>Since <code>EpisodeModel</code> does not contain a foreign key to EpisodePatient, I cannot do the following.</p>
<pre><code>modelBuilder.Entity<EpisodeModel>().HasRequired(r => r.EpisodePatient).WithMany().HasForeignKey() //No foreign key
</code></pre>
<p>I have tried this.</p>
<pre><code>modelBuilder.Entity<EpisodeModel>().HasRequired(r => r.EpisodePatient);
</code></pre>
<p>But with this approach, the EpisodeModel is not Lazy loaded when loading all EpisodePatientModels form the DB</p> | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.