input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Django Allauth and urls <p>I have a dev environment for a test of Django. I am running Python 3.5.2 out of a "local" <code>pyenv</code> install. I have Django 1.10.2. I discovered the <code>allauth</code> registration plugin yesterday and have been playing with it but have hit a snag.</p>
<p>My site is "dev.my.doma... | <p>In your <em>view.py</em> file, you just need to do a little "filter" before giving away the page to see if the user is authenticated.</p>
<p>An example for this will be:</p>
<pre><code>def myview(request):
if request.user.is_authenticated():
# do something if the user is authenticated, like showing a ... |
How to get a div to move while scrolling in angular 2 <p>I was looking for solutions for this in Angular 2 and I can't seem to find anything out there. I see many solutions that uses jquery but I'm not sure that jquery works well with angular 2 and is frowned upon(correct me if im wrong and if so can you please provide... | <p>You can either write your own directive that detects a window scroll and changes the css of the div to a fixed position or you can use <a href="http://www.github.com/makseo/ng2-sticky" rel="nofollow">www.github.com/makseo/ng2-sticky</a> ... I like writing my own directives, but this one is pretty well written and si... |
Invalid left-hand side expression <p>I'm trying to figure out why the bottom function I've written isn't working properly. Whenever I try to test it out, I get the following error: Uncaught ReferenceError: Invalid left-hand side expression in postfix operation. I'm assuming it's because the code is failing to recognize... | <p>What about put your data in a object like this:</p>
<pre><code>var _ = {
x : 0,
o : 0
};
</code></pre>
<p>and change the value like this:</p>
<pre><code>_[value]++;
</code></pre>
<p>I hope this helps.</p>
|
Merging multiple json objects fetched with async calls <p>I have a situation in my project(java based web app) in which I need to get service response from REST web service in multiple calls. Lets say web service contains 20K of records(large records containing very complex json structure) and in a go I can fetch 5K re... | <p>My opinion is:</p>
<ul>
<li><p>Answer to 1st query, It depends on the size of records and their structure, If it's in thousands then you can directly consume it and store it in database. But if it is in lacs then Store it in file because if in case any exception occurs or your database is down. In that case, you do... |
Storing objects in array (Haxe) <p>How would I go about sorting an new instance of an object into an array in Haxe? </p>
<p>For example I have a class called weapon and in the player class I gave an array inventory.
So how would I store this? </p>
<pre><code>private void gun:Weapon
gun = new Weapon; //into the arra... | <p>I think you are looking for this:</p>
<pre><code>private var inventory:Array<Weapon>;
</code></pre>
<p>This is an array of type <code>Weapon</code>.
To add stuff to it use <code>push()</code>, as seen in this example:</p>
<pre><code>class Test {
static function main() new Test();
// create new arra... |
htaccess rewrite URLby removing #! <p>I have a URL as below,</p>
<pre><code>http://localhost:8080/mysite/#!/skin-conditions/angioedema
</code></pre>
<p>I want this URL to be redirected to</p>
<pre><code>http://localhost:8080/mysitenew/?id=skin-conditions/angioedema
</code></pre>
<p>In here, I want redirected URL to... | <p>Sorry but this is not possible: the anchor (or fragment) part of an URL (<code>#!/skin-conditions/angioedema</code> in your example) is not sent by the client to the server (no way to rewrite something you don't have).</p>
|
Requiring tensorflow with Python 2.7.11 occurs ImportError <p>I tried <code>pip install tensorflow</code> on OS X El Capitan and it succeeded.
However, if I tried to import tensorflow, ImportError occured.
Please tell me when you know.</p>
<pre><code>>>> import tensorflow
Traceback (most recent call last):
Fi... | <p>I got the same question.
Try to follow the [official instruction] to install tensorflow: <a href="https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#pip-installation" rel="nofollow">https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#pip-installation</a></p>
<pre><code># Mac OS X
$ ... |
I want to display items in list according to Categories <p>I can't display products according to their Categories</p>
<p>Althought when i run the app all products are displayed and the category (either Men or Women) is written under every product but when i try choosing products from (Men Category) it displays EMPTY L... | <p>I think you should use</p>
<pre><code>p.Category.Equals(category, StringComparison.InvariantCultureIgnoreCase)
</code></pre>
<p>instead of</p>
<pre><code>p.Category.equal == category
</code></pre>
|
Highcharts Ajax Json not displaying Chart <p>I am trying to use the ajax line chart and I've created the following but it's not displaying anything.</p>
<p>What i am trying to achieve is to display the page views for the last 30 days. Hence my Json encode shows [date,page views]</p>
<p>I want the dates to display at ... | <p>You have two issues in your code. The first thing is you do not have to use data module to load json - actually it does nothing with the data - so your chart is empty.
You should put the data into series property - remember one thing that it requires array, not an object, so in this case it should be like this (such... |
NODE_ENV is not recognised as an internal or external command <p>I am developing in node.js and wanted to take into account both production and development environment. I found out that setting NODE_ENV while running the node.js server does the job. However when I try to set it in package.json script it gives me the er... | <p>Since you are using <code>windows operating system.</code>, the command varies from the unix system command that you are using.</p>
<p>In windows you have to modify you script as. </p>
<pre><code>"scripts": {
"start": " SET NODE_ENV=development & node ./bin/server",
"qa2": "SET NODE_ENV=qa2 & node... |
How to check if a factor variable has only the levels I want? <p>What's the simplest way to verify a factor variable has the levels I want to?</p>
<pre><code># I want to make sure a factor variable has 'FP', 'TP' but nothing else
a <- factor(c('TP','TP','FP')) # Return TRUE
b <- factor(c('TP')) # Return TRUE
c ... | <p>We can use <code>all</code> with <code>%in%</code></p>
<pre><code>all(levels(a) %in% c("FP", "TP"))
#[1] TRUE
all(levels(b) %in% c("FP", "TP"))
#[1] TRUE
all(levels(c) %in% c("FP", "TP"))
#[1] FALSE
</code></pre>
<hr>
<p>Just to avoid the repetition of code or in case if there are more levels that we need to chec... |
django - How to customise Model save method when a specified field is changed <p>I have a model, let's save A, the definition is as below:</p>
<pre><code>class A(models.Model):
name = models.CharField('name', max_length=10)
enabled = models.BooleanField('enabled', default=False)
field1 = models.CharField('fie... | <p>In short â no. But you can do it manually overloading the save method.</p>
<pre><code>class B(models.Model):
...
def save(self, *args, **kwargs):
if self.pk is not None:
original = B.objects.get(pk=self.pk)
if original.enabled != self.enabled:
C.enabled = ... |
How to validate web api response <p>I am working on a web api where I need to validate response returned. I want to write some generic code to ensure that response returned from api is in a correct format.</p>
<p>Basically there are fields like status, remarks etc which should be present in response if these are null ... | <p>The following might work for you. It assumes you're using an <code>ObjectResult</code> though you can adapt it to the <code>IActionResult</code> implementation that you're actually using. The following is not production code; rather, it gives a sense of what you could do. </p>
<pre><code>public class MyResultFilter... |
Sort a String array by second word <p>I have the following data</p>
<pre><code>1. John Smith
2. Tom Cruise
3. Chuck Norris
4. Bill Gates
5. Steve Jobs
</code></pre>
<p>As you can see, the data is in specific format, <code>[ID]. [Firstname] [Lastname]</code>. Is there a way to sort this array by <code>Firstname</code>... | <p>You can use lambda to pass your own comparison criteria.</p>
<pre><code>String[] names = {"1. John Smith", "2. Tom Cruise", "3. Chuck Norris", "4. Bill Gates", "5. Steve Jobs"};
ArrayList<String> namesList = new ArrayList<>();
for(int i=0; i<names.length; i++) {
namesList.add(names[i]);
}
Colle... |
Blank Datagridview <p>I have a function that populates a datagridview using the code given below. It basically displays a list of patients scheduled for a given timeslot and date for up to 7 days (Sun-Sat).</p>
<p>The datagridview is displaying fine on my machine on both release and debug versions. I also tried publis... | <p>Apparently, the blank datagridview is caused by the fact that I am using a prepared statement. There are no problems with the statement itself, it just so happens that that section of code doesn't work well with a prepared statement. </p>
<p>Based from what I've read so far, it's usually caused by different/older v... |
Implementing a Skiplist Node in C++ <p>I am looking to create a a Skip List data structure. Here is a snapshot of code that I have so far for Node. </p>
<pre><code> #define MAX_HEIGHT = 20;
struct Node {
int i;
Node *nodes[20];
}
</code></pre>
<p>I understand that if I used vector in thi... | <p>You can pass the height to the constructor of the node being created, inside the constructor you just <strong>dynamically allocate an array of pointers of <code>Node</code></strong>, and don't forget to free that memory in the destructor:</p>
<pre><code>struct Node {
int i;
int height;
Node* *nodes;
... |
SQL: Count of matches in WHERE clause <p>i need to find the number of expressions matched in WHERE clause for a SELECT statement. Sample data and table is as follows:</p>
<pre><code> declare @var1 varchar(10), @var2 varchar(10), @var3 varchar(10)
set @var1 = 'a'
set @var2 = null
set @var3 = 'c'
insert into tempTabl... | <pre><code>select id, cast ((case when @var1 = colA then 1 else 0 end) as int)
+cast ((case when @var2 = colB then 1 else 0 end) as int)
+cast ((case when @var3= colC then 1 else 0 end) as int) as MatchCount
from tempTable
</code></pre>
<p>Use Case</p>
|
How to make replacement in python's dict? <p>The goal I want to achieve is to exchange all items whose form is <code>#item_name#</code> to the from <code>(item_value)</code> in the dict. I use two <code>dict</code> named <code>test1</code> and <code>test2</code> to test my function. Here is the code:</p>
<pre><code>te... | <p>Your problem is caused by the fact that python dictionaries are unordered. Try using a <a href="https://docs.python.org/2/library/collections.html#collections.OrderedDict" rel="nofollow">OrderedDict</a> instead of <code>dict</code> and you should be fine. The OrderedDict works just like a normal <code>dict</code> bu... |
Postman oAuth2 error Unauthorized grant type <p>I have an application that use oAuth2, and I try to request an access token from terminal with this command </p>
<pre><code>curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=spring&username=roy&grant_ty... | <p>check the attached image, you need to pass like below .</p>
<p>And in header you also need to pass Authorization header.</p>
<p><code>Authorization</code> --> <code>Basic Y2xpZW50OnNlY3JldA==</code></p>
<p><a href="https://i.stack.imgur.com/EItxH.png" rel="nofollow"><img src="https://i.stack.imgur.com/EItxH.png... |
Use id to find the element to get information and add to array android java <p>I am getting element using </p>
<pre><code>JSONArray myArray = new JSONArray();
for (View touchable : allTouchables) {
JSONObject j = new JSONObject();
// To check if touchable view is button or not
//if( touchable instanceof LinearLayout) ... | <p>1) Instead of findViewById(touchable.getId())</p>
<p>Use this</p>
<pre><code>if( touchable instanceof TextView) {
TextView question = (TextView)touchable;
System.out.println("TextView "+ question.getText().toString());}
</code></pre>
<p>2) handle exception by proper try catch method</p>
<pre><code>try {
j.put... |
unable to convert string to integer using parseInt() <p>As a beginner I know that Integer.parseInt() is used to convert strings to integers but here I tried a program but its not working</p>
<pre><code>Public static void main(String args[])
{
Scanner sr=new Scanner(System.in);
String s=sr.nextLine();
int ... | <h2>Not all strings can be converted to integers.</h2>
<p>For example, how should <code>"xyz"</code> be converted to an integer? There's simply no way. Java notifies the programmer of such situations with an <code>NumberFormatExcpetion</code>. And we programmers should handle such exception properly.</p>
<pre><code>t... |
SQL Server Columns are equal but showing not equal. How are they different? <p>I have the following code</p>
<pre><code>select
Name, UniqueId,
checksum(Name) as CheckName,
checksum(UniqueId) as CheckId
from
DataManagementPipeline.dbo.pod_1801_energex_vegetation_zones
where
Name <> Unique... | <p><code>CHECKSUM</code> will return different values, if the types are different. See more at <a href="https://msdn.microsoft.com/en-us/library/ms189788.aspx" rel="nofollow">MSDN Checksum</a>. I think in your case, <em>Name</em> & <em>UniqueId</em> are of different types. Please see the example code below</p>
<pr... |
Verilog help needed. Unexpected output <pre><code>module hi (
input wire clk,
output wire [6:0] a
);
wire [7:0] b;
assign b= 8'd24;
assign a[6:0] = b[7:1];
initial $display ("%d", a);
endmodule
</code></pre>
<p>I get a high impedance 'z' output. Where am i going wrong?</p>
| <p>You didn't give the <code>assign</code> statement a chance to propagate the values on the wires. The <code>initial</code> block executes first. Add a delay before the <code>$display</code>, or use <code>$strobe</code> instead. </p>
|
ls Not Listing Documents <p>When I use ls in the terminal all that shows up is the bin folder, and I can't find the documents folder I need to git clone into: </p>
<p>vagrant@vagrant-ubuntu-wily-64:~$ ls bin </p>
<p>What should I do?</p>
| <p>If you're just writing <code>ls bin</code> in your terminal, that's absolutely the expected behaviour. The first argument after the <code>ls</code> command is the folder which contains the files you want to list.
Use <code>cd</code> and <code>pwd</code>commands to move through your folders : <a class='doc-link' href... |
The address of the specified listener name is incorrect while adding a listener <p>listener.ora</p>
<pre><code>CALLOUT_LISTENER =
(ADDRESS_LIST =
(ADDRESS= (PROTOCOL= IPC)(KEY=EXTPROC))
)
log_directory_callout_listener = /FIN10_2_17/finadm/assure
trc_directory_callout_listener = /FIN10_2_17/finadm/assure
SI... | <p>After few testing I came to know that you have a space in-front of the <code>SID_LIST_CALLOUT_LISTENER</code> name. </p>
<pre><code>[oracle@localhost admin]$ cat listener.ora
CALLOUT_LISTENER =
(ADDRESS_LIST =
(ADDRESS= (PROTOCOL= IPC)(KEY=EXTPROC))
)
log_directory_callout_listener = /FIN10_2_17/f... |
Want to make Superfish vertical menu Responsive <p>I am using super fish vertical menu but its not working on responsive view. Need to fix this for responsive. </p>
| <p>Media queries will help you make it responsive
Have a look at this <a href="https://codepen.io/Imperative/pen/qaskf" rel="nofollow">codepen</a> another great example given in <a href="http://stackoverflow.com/a/15928198/2299040">this question</a> </p>
<p>following code is taken from codepen which makes the menu res... |
In a UITableViewCell used with autosizing, what is missing from the vertical constraints to make the height as small as possible? <p>I'm trying to use dynamic heights in a UITableView with a specific cell layout. Consider the following illustrative representation of that layout: </p>
<p><a href="https://i.stack.imgur.... | <p>Reading the requirements you provided I have added constraints shown below:</p>
<p><a href="https://i.stack.imgur.com/LWsK0.png" rel="nofollow"><img src="https://i.stack.imgur.com/LWsK0.png" alt="enter image description here"></a></p>
<p>For demonstration purpose I have used a simple view container instead of a ce... |
How to conditionally add attributes to react DOM element <p>I have a scenario where I'm using React.js to create a div using the following code :</p>
<pre><code>React.createElement('div', {}, "div content")
</code></pre>
<p>Some additional javascript processing will allow me afterwards to deduce if this div needs to... | <p>This is a quite normal situation in React and requires virtually no special handling.</p>
<p><sup>Note: It is best to hand props down the component tree declaratively but if that is not an option you can bind listener functions in <code>componentDidMount</code> and unbind them in <code>componentWillUnmount</code> a... |
Django django.test django.db.models.fields.related_descriptors.ManyRelatedManager <p>Please assert type: 'django.db.models.fields.related_descriptors.ManyRelatedManager'. </p>
<p>In other words, how to import the module in order to assert that the field 'user.groups' is of type 'django.db.models.fields.related_descrip... | <p>You cannot make such an assertion on <code>user.groups</code> and <code>related_descriptors.ManyRelatedManager</code>. </p>
<p>The <code>ManyRelatedManager</code> class is not accessible using import like <code>from django.db.models.fields import related_descriptors</code> because if you look at the source code of ... |
$state.go on search input <p>I've built a small movies search app with AngularJS, UI Router, UI Bootstrap Typeahead and Elasticsearch. For reference, I asked <a href="http://stackoverflow.com/questions/40012048/search-input-and-state-go">this</a> yesterday here and received a good, quick answer. I managed to get it wor... | <p>You could pass the results along with the $state.go() like so:</p>
<pre><code> $state.go('search', { results: vm.autocomplete.suggestions });
</code></pre>
<p>You'll be needing to do the $state.go() in the section where you're returning the result ofc. In the config.routes.js file where you have 'search' defined,... |
Completely uninstall Xcode and all settings <p>I am trying to completely uninstall Xcode. However I followed the post <a href="http://stackoverflow.com/questions/31011062/how-to-completely-uninstall-xcode-and-clear-all-settings">How to Completely Uninstall Xcode and Clear All Settings</a></p>
<p>After following the in... | <p>refer this link and do something like this using terminal n your mac,</p>
<p><a href="http://recomhub.com/blog/how-to-uninstall-xcode-on-mac-os-x/" rel="nofollow">http://recomhub.com/blog/how-to-uninstall-xcode-on-mac-os-x/</a></p>
<pre><code>sudo /Developer/Library/uninstall-devtools --mode=all
</code></pre>
<p>... |
AngularJS - HTML Table handling of click events <p>I have the following table:</p>
<pre><code><table>
<tr data-ng-repeat-start=... data-ng-click="contactGroup.expanded = !contactGroup.expanded">
<td class="myColumn" data-ng-click=...>
</code></pre>
<p>when a row is clicked than the row... | <p>The reason it is happening because of event bubbling and to stop it <code>event.stopPropogation()</code> can be used.</p>
<p>While clicking the column bind a method; and use <code>$event</code> to prevent default</p>
<pre><code><table>
<tr data-ng-repeat-start=... data-ng-click="contactGroup.expanded ... |
broken dropdown menu code <p>I was following <a href="https://www.youtube.com/watch?v=PSm-tq5M-Dc" rel="nofollow">https://www.youtube.com/watch?v=PSm-tq5M-Dc</a> a tutorial for doing a drop-down menu in a gui. In the video the code works but i can't get mine too, I think it may have something to do with different pytho... | <p>You have few "typos"</p>
<ul>
<li><p>it has to be <code>root</code> instead <code>roo</code> in <code>roo.config()</code></p></li>
<li><p><code>)</code> has to be at the end of line in both</p>
<pre><code>subMenu.add_command(label="New Project..."), comand=doNothing #
subMenu.add_command(label="New"), comand=doNot... |
How to Bind Years in DropdownList <p>Here I have a task that Years Should be Bind in DropdownList Like 1947 to 2016 if I write Code Like</p>
<pre><code><select>
<option value="1947">1947</option>
<option value="2016">2016</option>
</select>
</code></pre>
<p>Its Taken whole... | <p>This could be done by javascript for example:</p>
<pre><code><select id="year"></select>
</code></pre>
<p>JScript:</p>
<pre><code>var year = 1947;
var till = 2016;
var options = "";
for(var y=year; y<=till; y++){
options += "<option>"+ y +"</option>";
}
document.getElementById("year")... |
Bootstrap date time picker <p>I am trying to implement the date time picker as explained here <a href="https://eonasdan.github.io/bootstrap-datetimepicker/#minimum-setup" rel="nofollow">https://eonasdan.github.io/bootstrap-datetimepicker/#minimum-setup</a>, I have downloaded the <code>js</code> file <code>css</code> f... | <p>Try This:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta na... |
Set two button below grid View <p>Actually i want to set the two button below the grid view and i try Relative Layout and other things but the problem is not solve</p>
<p>XML code:</p>
<pre><code> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xml... | <p>try to this hope this can help you..</p>
<pre><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:id... |
Application design is not display properly in simulator after updating xcode 8 <p>I have updated xcode 8 and then tested application in <strong>iphone 6 (ios 10) simulator</strong>.
Application desiging is not showing properly as it should be.
In xcode 8, storyboard designing is not proper.
Storyboard showing designs p... | <p>from storyboard, Select your view controller and set proper device from View As button. If your storyboard is designed using previous version of Xcode, try selecting iPhone SE from "View As" as shown in below image.</p>
<p><a href="https://i.stack.imgur.com/IZ2Rz.png" rel="nofollow"><img src="https://i.stack.imgur.... |
Get location of text in textview on the screen <p>I make an app that allow user to read in English and in my language.
But the text is long, maybe 100 lines for each file.<br>
so when the user scroll down maybe to line 20(like reading in English), the when user switch to my language, it is on line 15 or 16.
so how can... | <p>Easiest way is to get it using <code>View.getLocationOnScreen();</code> OR <code>getLocationInWindow()</code>;</p>
<p>And if you want position relative to root Layout then <a href="http://stackoverflow.com/a/3621042/3496570">See</a></p>
|
Python and Pip not in sync <p>I am working on a remote linux server with python 2.7.6 pre-installed. I want to <strong>upgrade to python 2.7.12</strong> (because I am not able to install some libraries on the 2.7.6 due to some <strong>ssl error</strong> shown below).</p>
<p>I downloaded and compiled from source and in... | <p>Upgrade (and automatically reinstall) pip this way: </p>
<pre><code>/path/to/python2.7.12 -m pip install pip --upgrade
</code></pre>
<p>The <code>-m</code> flag loads the corresponding module, and in the case of pip will execute <code>pip</code> (thanks to <a href="https://docs.python.org/3/library/__main__.html" ... |
Check the username and password using .NET Webservice (SOAP) <p>I want to consume a SOAP Webservice in android, created in .NET framework and using it want to check the username and password.</p>
<p>How to check the username and password entered by user with the data which is stored on Server using webservice?</p>
| <p>Use <strong>okHttp</strong> library for android.This library will provide you all the HTTP methods to consume Webservice.</p>
|
Datetime VB net to SQL table <p>I have this:</p>
<pre><code> Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Dim con As New SqlConnection
Dim myCommand As New SqlCommand
Try
Dim a As String
con.ConnectionString = "Data Source=SVNAV;Initial Catalog=NAV_Vermo... | <p>In the <code>Else</code> part you leave VB variable <code>dlaser</code> uninitialized, which means it has value <code>0001-01-01 00:00:00</code>. But that variable is always used for parameter <code>@EndDateLaser</code> to set column [EndDateLASER].</p>
<p>Column [EndDateLASER] has SQL type <code>datetime</code>, b... |
Adding 0 (Zero) as Key in array doesn't work but when i change it to 1 it works <p>I'm still confused why when i use 0 as key in array it does not work but when i changed it to 1 it works normally. Can someone explain me why this is happening.
Thanks in advance.</p>
<h1>$myArray = {1,2,3,4}</h1>
<h1>Using foreach loo... | <p>check this,</p>
<pre><code><?php
$o = array(1,2,3,4);
$bind = array();
foreach($o as $key=>$value){
$bind[] = $key.":".$value;
}
echo implode( ',', $bind );
?>
Output: 0:1,1:2,2:3,3:4
</code></pre>
|
SQL Server 2008 Stored Procedure execution issue <p>I will try to explain the problem in details. I wrote a SP and executed it successfully. Here it is:</p>
<pre><code>SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[InvoiceReference]
@StartDate DateTime = NULL,
@EndDate DateTime = NULL,
@Doc... | <p>You have to set default collation before comparing result OR before IN Statement.</p>
<p>try your where condition as below:</p>
<pre><code>and ((@Partners is null) or (p.Name COLLATE DATABASE_DEFAULT in (select * from dbo.fnSplitString(@Partners, ','))))
</code></pre>
<p><strong>OR</strong></p>
<pre><code>Set da... |
UPDATE with SELECT with a reference to the updated table <p>I have a script:<br/></p>
<pre><code>UPDATE a
SET fieldX =
(SELECT F_Aggregate(x.fieldy)
FROM table_B
INNER JOIN ....
INNER JOIN ....
INNER JOIN ....
....
INNER JOIN table_C on .....
WHERE table_C.fieldY = table_A.fieldY)
FROM table_A a;
</c... | <p>Move the calculation in other <code>Data Source</code> - it could be CTE, table variable or temporary table, etc. Then join the updated table with it:</p>
<pre><code>WITH DataSource (fieldY, result) AS
(
SELECT table_C.fieldY
,dbo.F_Aggregate(x.fieldy) as result
FROM table_B
INNER JOIN ....
... |
"eurekaHealthIndicator" issue with netflix eureka client <p>Trying to write Eureka Client With Spring Cloud Netflix v1.2.0.Release
but facing the below mentioned issue. PFB code and configurations.</p>
<p>EurekaClient.java</p>
<pre><code>import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import ... | <p>The problem seems to be that you are naming your client <strong><em>EurekaClient</em></strong>, There is already a bean with that name. Rename that class to something else and it should work</p>
|
Spark - PySpark sql error <p>I have a simple pyspark code but i can't run it. I try to run it on Ubuntu system and I use PyCharm IDE. I would like to connect to Oracle XE Database and I want to print my test table. </p>
<p>Here comes my spark python code: </p>
<pre><code>from pyspark import SparkContext
from pyspark.... | <p>Change to <code>dbtable</code> from <code>table</code> like this,</p>
<pre><code>demoDf = sqlContext.read.format("jdbc").options(
url="jdbc:oracle:thin:@10.10.10.10:1521:XE",
driver="oracle.jdbc.driver.OracleDriver",
dbtable="tst_table",
user="xxx",
password="xxx").load()
</code></pre>
|
Working with dbms_lob.copy and error ORA-06502: <p>I am bit lost with working with <code>dbms_lob.copy</code></p>
<pre><code>CREATE OR REPLACE PROCEDURE Ex_PRC IS
dest_lob CLOB;
src_lob CLOB;
BEGIN
SELECT F_CLOB INTO dest_lob
FROM EX_EMPLOYEE
WHERE id = 1;
dbms_lob.copy (dest_lob, src_lob, 30, 1, 1);
COMM... | <pre><code>set serveroutput on
create or replace procedure test_clob (p_clob_res out clob) is
cursor c_tabs is
select ename from emp;
v_clob clob;
amt integer := 0;
begin
dbms_lob.createtemporary(v_clob,true,dbms_lob.session);
for r_tabs in c_tabs
loop
dbms_lob.writeappend(v_clob,length(r_tabs.ename)... |
How to convert intArray to ArrayList<Int> in Kotlin? <p>From</p>
<pre><code>val array = intArrayOf(5, 3, 0, 2, 4, 1, 0, 5, 2, 3, 1, 4)
</code></pre>
<p>I need to convert to <code>ArrayList<Int></code></p>
<p>I have tried <code>array.toTypedArray()</code></p>
<p>But it converted to <code>Array<Int></code... | <p>You can use <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/to-collection.html"><code>toCollection</code></a> function and specify <code>ArrayList</code> as a mutable collection to fill:</p>
<pre><code>val arrayList = intArrayOf(1, 2, 5).toCollection(ArrayList())
</code></pre>
|
How do I upgrade React from 0.13 to 15.0.1? <p>Please tell me step by step process of upgrading React from version .13 to 15.0.1 .</p>
| <p>Update react version in package.json <br>
Delete node_modules folder<br>
Run npm install<br></p>
<p>install process will fail if there is any version mismatch among other dependencies in package file, console will show the expected compatible version number. Update those and run npm install again.</p>
<p>Once inst... |
How to unset chrome.windows.onRemoved.addListener? <p>I have the following code in my Chrome extension to detect when windows are closed:</p>
<pre><code> closeListener = chrome.windows.onRemoved.addListener(function(closed_window_id){
// something
}
</code></pre>
<p>How do I unset this such that the an... | <p>After taking a look at your code, I see your problem. The function you put into the <code>addListener</code> is anonymous and needs to be set to a variable or become a named function.</p>
<pre><code>function newListener() {
alert();
}
//This will add the listener
chrome.windows.onRemoved.addListener(newListener... |
Scriptella data copy error on mysql <p>I am using <a href="https://scriptella.org/" rel="nofollow">Scriptella</a> to copy data from one table to another table(different database) on Mysql. For source, I have used table <a href="https://dev.mysql.com/doc/sakila/en/sakila-structure-tables-film.html" rel="nofollow">film<... | <p>The exception you receive is</p>
<pre><code>Driver exception: java.sql.SQLException: Cannot convert value '2006' from column 4 to TIMESTAMP.
</code></pre>
<p>It seems that the particular DB line contains value 2006 in a column where a TIMESTAMP type is expected, the format of which for MySQL seems to be</p>
<pre>... |
PHP LDAP number of locked out users <p>I am working on a script that can get the number of locked out users from Active directory. Not disabled, just current number of locked out users. Is this possible? I havent worked with fetching data from AD before so I'm asking you guys before I try.</p>
| <p>Try searching for <code>(|(!(gosaVacationStop=*))(!(gosaVacationStop=0)))</code>.</p>
<p>That should fetch all users that have the attribute <code>lockoutTime</code> set and where it is not 0.</p>
<pre><code>$result = ldap_search($con, '(&(samaccountname=*)(|(!(gosaVacationStop=*))(!(gosaVacationStop=0))))', '... |
How to make an iPhone app uncloseable? <p>I would like to hand out iPhones as navigation/information devices to users at an event but users should only be able to see and use the event app and not close it or tamper with phone settings etc.</p>
<p>Is it possible to make an iPhone app not closable by the user and put i... | <p>Yes its possible by using guid access in your iphone,</p>
<p>Here is image how to set it.</p>
<p><a href="https://i.stack.imgur.com/aLKRp.png" rel="nofollow"><img src="https://i.stack.imgur.com/aLKRp.png" alt="enter image description here"></a></p>
<p>So without your permission user cannot close apps.</p>
|
How Spring Batch Restart logic works on hadoop job? <p>Suppose i have 10 records and some of them are corrupted records so how spring will handle restart.</p>
<p>Example suppose record no. 3& 7 are corrupt and they go to different reducer then how spring will handle the restart
1.how it will maintain the queue t... | <p>SpringBatch will do exactly what you tell SpringBatch to do.</p>
<p>Restart for SpringBatch means run the same job that failed with the same set of input parameters. However, the new instance (execution) of this job will be created.</p>
<p>The job will run on the <strong>same data set</strong> that the failed inst... |
Uploading file in Cakephp not adding file name in mysql database table <p>Please help me. Thanks in advance. I am new to Cakephp.
I am using cakephp2.8.5 version. I was trying to upload a file from HTML form, i can able to store the file in the targeted folder but not able to store the file name in the mysql database ... | <p>You didn't add image name in your <strong>$this->request->data</strong> array if your image field name is <strong>image_name</strong>. Then add this line </p>
<pre><code> $this->request->data['User']['image_name'] = $this->data['Document']['submittedfile']['name']
</code></pre>
<p>After </p>
<pr... |
Detect whether iPad supports sim card programatically <p>Currently, I have an app that shows the 3G data / Wifi used by the user since the last reboot.
What I want to do is, if the app is running on an iPad which doesnât support SIM card, I want to hide certain statistics shown to the user.</p>
<p>Is it somehow poss... | <p>As far as I know, you cannot detect if the SIM card is installed. You can only determine if a WWAN connection is available using <a href="https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html" rel="nofollow">Reachability</a> (<a class='doc-link' href="http://stackoverflow.com/do... |
Restart Revmob Session - If no connection and then got connected <p>I have an adobe AIR AS3 application for both Android and iOS. I have implemented all the necessary code with the help of revmob's great technical support team. My problem now is if the user originally was not connected to a wifi or cellular network, th... | <p>You can see how to create a <strong>ConnectionChecker</strong> class to check for a internet connection in this <a href="http://stackoverflow.com/a/13569775/5128351">link </a>. After creating a <strong>ConnectionChecker</strong> instance, you can call it and call the startSession method when connection is successfu... |
Is it Pythonic to passed in arguments in a function that will be used by a function inside it? <p>Is there a better way to do this? Like I'm passing in arguments to <code>func</code> that will be used in <code>inside_func</code> function? </p>
<pre><code>def inside_func(arg1,arg2):
print arg1, arg2
return
de... | <p>Of course it is.</p>
<p>Your outer function provides a service, and to do its job it may need inputs to work with. <em>How it uses those inputs</em> is up to the function. If it needs another function to do their job and they pass in the arguments verbatim, is an implementation detail.</p>
<p>You are doing nothing... |
Django - What is the best way to have multi level status before login <p>I have one scenario, there is a user registration and it should have multiple status(may be is_active - but this is boolean by default)</p>
<ol>
<li>List item Code - 0 -> Pending for Email Confirmation</li>
<li>List item Code - 1 -> Account Activ... | <p>You should create custom <code>User</code> or custom <code>Profile</code>(i believe that it's better with custom <code>Profile</code>, to avoid messing with django <code>User</code>):</p>
<pre><code>from itertools import compress
class CustomProfile(Profile):
is_confirmed = models.BooleanField(default=False)
... |
How to make communication between UWP Client and Java Server using WebSocket? <p>I need to send text,primitive data types and object between a UWP client and JAVA server using WebSocket, however I don't know how to code.</p>
<p>I don't understand if there is any difference between these two languages that make coding ... | <p>Your Java code creates a plain TCP/IP socket, not a [websocket][1], which is a higher level protocol on top of TCP/IP.</p>
<p>If you want websockets you need to either implement websockets for yourself (don't do that if you are not very experienced at network programming) or use a Java library that provides websock... |
Get an exception with Invalid reference from Solr DocumentExpressionDictionaryFactory <p>I am using solr 6.2. I am trying to configure multiple suggester definition in Solr search component and got error information like:</p>
<pre><code>java.lang.IllegalArgumentException: Invalid reference 'softId_suggest'
at org.apac... | <p>In your description, you say that you configured softId_suggest in <strong>solrconfig.xml</strong>. But the fields are configured in <strong>managed-schema</strong> file. So, either that's the problem or you need to correct the question.</p>
<p>If it is defined correctly, make sure you've reloaded the core, rerun t... |
yii2, how can I create table in database based on imported excel or csv file <p>I want to import excel or csv file into not existent table. Most of the extensions for yii2 imports files into existing table with known column names and attributes.</p>
| <p>It is not clear the excect difficulty which you met.</p>
<p>If you want to extract the list of columns of your excel document, you can use PhpExcel library like <a href="http://stackoverflow.com/a/5578240/6222876">here</a>. You can add it into your project with <code>composer</code> as:</p>
<pre><code>php composer... |
Unable to locate an element error is coming when i am running the below piece of code <pre><code>public class TestWebtable {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.espncricinfo.com/indian-premier-league-2016/engine/match/981019.html")... | <p>Try this</p>
<pre><code>driver.get("http://www.espncricinfo.com/indian-premier-league-2016/engine/match/981019.html");
int i = 2;
int rowNum = 0;
while (true) {
try {
driver.findElement(
By.xpath(".//*[@id='full-scorecard']/div[2]/div/table[1]/tbody/tr[" + i + "... |
Regex password validation add underscore like special symbol <p>Password must contains :
1 Upper letter
1 lower letter
1 digit
1 special symbol
Minimum 8 symbols</p>
<p>Here it is my regex:</p>
<pre><code>^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@_$%^&*-]).{8,}$
</code></pre>
<p>But when i try to validate... | <p>No matter if you are using regular expressions or other means to validate those strings - but please: don't push everything into one piece of code or regex. </p>
<p>You want to create code that is easy to read and maintain; and a single regex containing so much "coded" knowledge wont help with that. I have more tha... |
Different marker colors for start and end points in pyplot <p>I am trying to plot lines on a plot between two point tuples. I have following arrays:</p>
<pre><code>start_points = [(54.6, 35.2), (55.5, 32.7), (66.5, 23.7), (75.5, 47.8), (89.3, 19.7)]
end_points = [(38.9, 44.3), (46.7, 52.2), (72.0, 1.4), (62.3, 18.9), ... | <p>The trick is to first plot the line (<code>plt.plot</code>) and then plot the markers using a scatter plot (<code>plt.scatter</code>).</p>
<pre><code>import numpy as np
from matplotlib import pyplot as plt
start_points = [(54.6, 35.2), (55.5, 32.7), (66.5, 23.7), (75.5, 47.8), (89.3, 19.7)]
end_points = [(38.9, 44... |
C# find cost, calculate the cost of item and include 10% GST <p>I am studying C# and have been asked to create a grocery program. I am stuck and can't seem to find anything on the net to help me. I have created a grocery item class with properties containing Name and Price. I have also created a subclass of purchased... | <p>You can try this,</p>
<pre><code>using System;
using System.Collections.Generic;
namespace Groceries
{
public class Program
{
public static void Main(string[] args)
{
FreshGrocery freshGrocery = new FreshGrocery();
freshGrocery.Name = "Fresh grocery";
fre... |
How to delete some rows which keys has the same prefix from a table in SQLite android? <p>simple table with </p>
<p><code>CREATE TABLE IF NOT EXISTS tb (id TEXT NOT NULL, json TEXT NOT NULL,PRIMARY KEY(id))</code></p>
<p>insert 4 rows into the table, looks like:
<code>
akey1, avalue1
akey2, avalue2
bkey1, bvalue1
bke... | <p>The problem must be you missing single qoutation around like statement and it may work if you add single qoutations around your like condition. Like so:</p>
<pre><code>database.delete(tableName," id like '?';", new String[]{"akey%"});
</code></pre>
<p>but anyway The "?" Placeholder is a little buggy some times.</p... |
mousedown and move cross dom element, keep cursor is crosshair <p>When mousedown and mouse move from outside to inside, the cursor become like text, how to keep cursor is crosshair?<br>
I tried use <code>:active</code> but not work ..</p>
<p><a href="https://jsfiddle.net/xu9tmmfr/" rel="nofollow">https://jsfiddle.net/... | <p>This one is bit hacky but should work .Prevent default action (which is to change cursor) upon mousedown on the container</p>
<pre><code>$('.a').mousedown(function (e) {
e.preventDefault();
});
</code></pre>
<p><a href="https://jsfiddle.net/g7nw10dk/" rel="nofollow">https://jsfiddle.net/g7nw10dk/</a></p>
|
Jquery Number counting slowdown animation when target reach <pre><code>$(this).prop('Counter', 0).animate({
Counter: 123456789
}, {
duration: 2000,
easing: 'easeOutBack',
step: functio... | <p>You can make a variable for speed and incrase this with step. In your exemple is:</p>
<pre><code>var speed = 2000;
$(this).prop('Counter', 0).animate({
Counter: 123456789
}, {
duration: speed,
easing: 'easeOutBack',
step: function (now) {
$(this).html(parseFloat(now).... |
SonarQube Analysis Task Error After File Move <p>We have been using SonarQube analysis on a C# project as part of a TFS 2015/15 RC2 vNext build for ages which has been working fine.</p>
<p>A few days a go I refactored several aspects of code, this consisted of moving files into new folders within the same project, as ... | <p>You face <a href="https://jira.sonarsource.com/browse/SONAR-8013" rel="nofollow">https://jira.sonarsource.com/browse/SONAR-8013</a>. It is fixed in version 6.1.</p>
|
I have requirment like <p>I have requirment like In which I have to create</p>
| <p>Have a look at <a href="http://www.wiris.com/editor/docs/javaswing" rel="nofollow">WIRIS</a>. You can integrate it in your Swing application (using Java/Swing API) or web application (using JavaScript API).</p>
<p>How to use:</p>
<ol>
<li>Create an instance of the editor and use the toolbar to enter the formula.</... |
log4j2 queue/topic configuration by spring <p>Are there any way to configure log4j2 to read Appender attributes from for example a spring bean? I am curious especially in JmsAppender to dynamically set it's target destination based on a parameter read from database and not from JNDI context.</p>
<p>BR
Zoltán</p>
| <p>Your best chance is to extend the JMSAppender and override the append methods in the logger. A good example is <a href="https://github.com/danveloper/real-time-logging/blob/master/enhanced-log4j-jms-appender/src/main/java/com/danveloper/log4j/jms/EnhancedJMSAppender.java" rel="nofollow">here</a></p>
<p>This case , ... |
How to change the value of an input inside of a frame with VBScript <p>I want to make a script which will open IE and automatically fill in inputs in a form on an external website. The inputs I want filled-in are placed inside of a frame. So the <code>getElementByID</code> won't work here.</p>
<p>I've made my own test... | <p>First get the frame named "form" from the page. Since it has only name, we can use the <a href="https://msdn.microsoft.com/en-us/library/ms536438(v=vs.85).aspx" rel="nofollow">getElementsByName</a> method and get the first element of the returned collection:</p>
<pre><code>set frame = IE.document.getElementsByName(... |
How can you build RealmSwift for Swift 2.3 from sources using Xcode 8 IDE? <p>I see <a href="http://stackoverflow.com/questions/38888454/how-to-build-realm-using-swift-2-3">here</a> that it is possible to build RealmSwift for swift 2.3 from the command-line.<br>I have RealmSwift as a dependent project within my workspa... | <p>To my knowledge, it's not possible to override an Xcode subproject's <code>SWIFT_VERSION</code> within the IDE. You can specify <code>SWIFT_VERSION</code> when invoking <code>xcodebuild</code>, which should also propagate to Xcode subprojects, but I don't know of any way to do that from the Xcode GUI.</p>
<p>I'd re... |
How to have two series in one chart in stimulsoft? <p><a href="https://i.stack.imgur.com/cfXeH.png" rel="nofollow"><img src="https://i.stack.imgur.com/cfXeH.png" alt="enter image description here"></a></p>
<p>I want to have a scatter diagram and its regression line simultaneously in one chart. How it is possible in st... | <p>You could add a Scatter Line to the Scatter chart.</p>
|
Spring Mqtt integration: outbound topic issue <p>Hi I'm trying to use spring integration to receive MQTT messages, process them and publish to another topic.</p>
<p>Here is the integration.xml:</p>
<pre><code> <int-mqtt:outbound-channel-adapter id="mqtt-publish"
client-id="spring-foo-1"
client-factory="c... | <p>That's correct because the <code>AbstractMqttMessageHandler</code> takes a look first of all into <code>headers</code>:</p>
<pre><code>String topic = (String) message.getHeaders().get(MqttHeaders.TOPIC);
Object mqttMessage = this.converter.fromMessage(message, Object.class);
if (topic == null && thi... |
Sequence Recognition using fsm in python <p>What is the best way to detect a sequence of characters in python?</p>
<p>I'm trying to use transitions package by Tal yarkoni for creating fsm's based on input sequences. Then i want to use the created fsms for new sequence recognition.
I'm storing the created fsm in a dic... | <p>There is no concept of end state, but you can define a state 'end' on each fsm and check for it (see 'checking state' in the git readme), or you could add a 'on enter' reference on the 'end' state and that function will be called when the 'end' state is entered.</p>
<p>Haven't seen transitions before, looks very ni... |
i want to save data using following c# code but its not working <p>i want to upload two pic and one file and other data using asp.net with following c#.but it giving error of Uploadresumepic.SaveAs(path1);</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
us... | <p>just change the code to <br></p>
<pre><code>path1 = Server.MapPath("~/profile_pic/" + f1);
</code></pre>
|
How to display image which is in binary form in SQL database? <p>I am using this code but image is not displaying full. This code is displaying one forth part of image rather full image. </p>
<pre><code><?php
echo '<img src="data:'.$image_mime_type.';base64,'.base64_encode($rs["Pic"]).'" alt="My image alt" />... | <p>Try this,</p>
<pre><code>$path = $rs["Pic"];
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
//echo $base64;
echo '<img src="'.$base64.'" alt="My image alt" />';
</code></pre>
|
Swap the label text of two buttons in Swift <p>I have 2 button like picture below, their text label are: "Input location...". Now i want to click on the swap button on the right, so the text label of these button will swap. It's look like you have 2 location and you want to swap it. Please any one can point me how to d... | <p>On click just set their text to each other. </p>
<pre><code>var tempString = secondButton.titleLabel.text
secondButton.setTitle(firstButton.titleLabel.text, forState: UIControlState.Normal)
firstButton.setTitle(tempString, forState: UIControlState.Normal)
</code></pre>
|
Swift 3 conversion - function in capture list <p>I am trying to convert a project from Swift 2.3 to Swift 3.
Code before the convertor was: </p>
<p>Code in Swift 2.3</p>
<pre><code>..., handler: { [performSegueWithIdentifier] _ in
performSegueWithIdentifier("Help Segue", sender: nil)
}
</code></pre>
<p>After con... | <p>The error:
'Expression type 'Void' ...' is related to second line: </p>
<p><code>performSegue(withIdenfifier: "Help Segue", sender: nil)</code></p>
<p>So, all will become: </p>
<pre><code>handler: { [performSegue] _ in
performSegue("Help Segue", nil)
})
</code></pre>
|
Detect the number of physical objects in an image (Image processing) <p>I am developing a Ruby on Rails application where I want to detect the number of physical objects (bottles and food packets) in an image.</p>
<p>I just explored Google Vision API (<a href="https://cloud.google.com/vision/" rel="nofollow">https://c... | <p>I've made a simple command line program that detects faces and replaces them with emojis using OpenCV through JRuby. It's an absolute pain to set up, but once it is done it is a beauty to write in. I also made a small script to create OpenCV JRuby projects that can be executed with the required command line argument... |
No respond from getSelectedItem Spinner <p>I have a Spinner with list of category, which get the data from JSON. I want to make, when an item other than <em>All Category</em> get selected, another spinner of subcategory become visible, and get loaded with data from JSON according to its category.</p>
<p>Previously I m... | <p>change your code to</p>
<pre><code>categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// On selecting a spinner item
categoryString = parent.getItemAtPosition(position).toString(... |
Cannot initialize an uninitialized variable inside a class method <p>I have just started practicing OO programming using PHP. Recently I have encountered a problem.<br>
I am trying to declare a variable inside a class but leaving it uninitialized. Later inside a method of the class when i try to initialize the variable... | <p>In function call $a does not exist. Only $this->a (without $ before the a), which is the property of your "sam" object, and $b, which is an input parameter.
Plus when you set the property, you must not use $a. Use $this->a.
If you would have a variable which contains a property name of the class, you should use $thi... |
How do I split a list containing data frames into the individual data frames? <p>I have 6 lists (<code>l1</code>,<code>l2</code>,<code>l3</code>,<code>l4</code>,<code>l5</code>,<code>l6</code>) in total and in each list, I have 12 dataframes (<code>df1</code>,<code>df2</code>,<code>df3</code>,...,<code>df10</code>,<cod... | <p>You use assign locally. So inside the function, you create the <code>data.frame</code>s <code>df1</code> and <code>df2</code>. You can assign these to the global environment instead: </p>
<pre><code>split_df<-function(list){
for (i in 1:length(list)){
assign(paste0("df",i), list[[i]], envir = .GlobalEnv)
... |
Upload data and file with ng-file-upload <p>I am new to angular. I have searched a lot but didn't find a way to grab the data send through <strong>Upload.upload()</strong> of ng-file-upload. Though my file is uploaded into the destination folder using muter</p>
<p>Here is my controlled function which is called on uplo... | <p>You are receiving <code>multipart/form-data</code> from ngf. </p>
<p>I don't know which server you are using, but I think you should check <code>req.form</code> rather than <code>req.data</code> or something. </p>
<p>Alternatively, you can use some external middleware, like <a href="https://github.com/expressjs/bo... |
android listview with button does not work <p>I created a listview adapter which a row contains a button. It works when i clicked on the button , but not when i click on the row
This is my main activity</p>
<pre><code>public class MainActivity extends AppCompatActivity {
.
.
.
ListView lvProducts = (ListView) findV... | <p>In your custom layout file set</p>
<pre><code>android:focusable="false"
android:focusableInTouchMode="false"
</code></pre>
<p>for your button.</p>
|
Prompt the user for an index - 2D array - output the array element given by the index - java <p>I'm very new to Java and have no idea what I'm doing. How can I prompt the user for an index for a 2D array in the format 'ab' (the value of a is row number and the value of b is column number) and output the array element g... | <p>There are a number of ways to do this. I would do:</p>
<pre><code> if (sIndex.length() == 2) {
int selectedRow = Character.getNumericValue(sIndex.charAt(0));
int selectedColumn = Character.getNumericValue(sIndex.charAt(1));
// do your stuff
}
</code></pre>
<p>You ... |
Execute a method inside Eventhandler with delay and ignore th next eventhandler during this interval <p>I have a textbox filter which is binded to the following event handler</p>
<pre><code> SimpleFilterTextBox.TextChanged += OnFilterTextBoxTextChangedHandler;
private void OnFilterTextBoxTextChangedHandler(object oS... | <p>Use <code>async</code> and <code>CancellationToken</code>.</p>
<pre><code>private void OnFilterTextBoxTextChangedHandler(object oSender, TextChangedEventArgs oArgs)
{
//Other operations
_oCollectionView.Filter = new Predicate<object>(DoFilter);
}
private CancellationTokenSource filterToken;
private as... |
JTextfield only accept numbers between 0-255 <p>for a little test application I need a TextField which only accepts numbers. In addition the user should only be able to enter numbers from 0-255. So far i found this:</p>
<pre><code>import javax.swing.JTextField;
import javax.swing.text.AttributeSet;
import javax.swing.... | <p>you can implement those two checks as follows:</p>
<pre><code> if(str.length()>3) {
return;
}
int inputNum = Integer.parseInt(str);
if(inputNum<0 || inputNum>255) {
return;
}
</code></pre>
<p>Add these checks before the last if block an... |
Get back Access Token of Twitch API with node js <p>I am developping a google chrome extension in which I need to authenticate the user on Twitch. According to <a href="https://github.com/justintv/Twitch-API/blob/master/authentication.md" rel="nofollow">https://github.com/justintv/Twitch-API/blob/master/authentication.... | <p>There is already an explanation in the documentation just below the line that you 've posted:</p>
<blockquote>
<p>Note that the access token is in the URL fragment, not the query
string, so it won't show up in HTTP requests to your server. URL
fragments can be accessed from JavaScript with document.location.h... |
Initialize a struct in C using {} <p>In the marked line I get an error <code>Error - expected expression</code></p>
<pre><code>#include <stdlib.h>
struct list_head {
struct list_head *next, *prev;
};
struct program_struct {
const char *name;
struct list_head node;
};
typedef struct program_struct p... | <p>Initialization is allowed only when you define a variable. So, you can't use initializers in assignment.
You can instead use C99's <a href="https://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Compound-Literals.html" rel="nofollow">compound literals</a>:</p>
<pre><code>p->blocked_list.node = (struct list_head) {&(p-... |
How to create angular2 jwt token in angular2 <p>I need to create a jwt in angular2. How do I do that?
I am using this for an api service.</p>
<pre><code> jwt_token = ?
</code></pre>
<p>I can create in python with no issue. </p>
| <p><strong>Normally tokens are generated on the server-side !!
If you are creating them on client side, its easy to see your password!!</strong></p>
<p>Anyway, to answer your question:</p>
<p>Best way is to use an existing library, like this one: <a href="https://www.npmjs.com/package/jsonwebtoken" rel="nofollow">htt... |
Calling a Java 8 function only once when iterating a function list <p>Is there an elegant way to store the return value of the <code>apply()</code> method so it won't have to be invoked more than once? Because the only way I could think of is to create a local map variable that will store the function-"return value" pa... | <p>Try this.</p>
<pre><code> private String evaluate(String code) {
return evaluators.stream()
.map(f -> f.apply(code))
.filter(s -> s != null)
.findFirst().get();
}
</code></pre>
|
Unable to create post on my Google plus activity <p>How to sent <code>CURLOPT_POSTFIELDS</code> values for google plus..add post.</p>
<p>I'm able to get ..authentication token on google plus..but when I add post on google plus.. then I am getting that error </p>
<pre><code>{
"error":{
"errors":[
... | <p>There are two possible causes for this problem:</p>
<ol>
<li>Your question says you are trying to post to <a href="https://plus.google.com/u/0/" rel="nofollow">Google+</a>. There is no way to post to Google+ the social media site the <a href="https://developers.google.com/+/web/api/rest/" rel="nofollow">Google+ AP... |
Matplotlib : single line chart with different markers <p>I have a list for markers on my time series depicting a trade. First index in each each list of the bigger list is the index where i want my marker on the line chart. Now I want a different marker for buy and sell</p>
<pre><code>[[109, 'sell'],
[122, 'buy'],
[... | <p>Create two new arrays, one buy-array and one sell-array and plot them individually, with different markers. To create the two arrays you can use list-comprehension</p>
<pre><code>buy = [x[0] for x in your_array if x[1]=='buy']
sell = [x[0] for x in your_array if x[1]=='sell']
</code></pre>
|
Find the last visited URL in javascript with history <p>I know about <code>document.referer</code> and this is not what I'm looking for.
It could probably be a solution but I want to retrieve it in local without using server.</p>
<h2>Steps :</h2>
<ul>
<li><p>I'm pushing a new state in the current url of my page with ... | <p>One way of doing it would be to put the value in a parameter of the next page address, like so:</p>
<pre><code>http://server.com/next-page-address/whatever.html?prevData=RequiredStateData
</code></pre>
<p>Note that using this approach, you might be exposed to users changing <code>RequiredStateData</code> in a mali... |
JOptionPane.showinputdialog To only Input Letters or Numbers and multiple choice <p>Hello i'm new to java and i would like to ask some question regarding JOptionPane.showinput so that it will only accept letters/numbers only and if they enter an incorrect one it will result to an error and need to retype again (searche... | <p>for getting a valid string that contains only alphabets and numbers then regex are a great help <strong>^[a-zA-Z0-9]*$</strong> it allows only alphabets and numbers only and the following code will ask repeatedly until a valid input is given</p>
<pre><code>String input;
String string = "";
... |
Displaying progress in one line? <p>Is it possible to display progress on one line instead of having the for-loop printing out a bunch of lines for every action?</p>
<p>Like, for example. Instead of this:</p>
<pre><code>Progress: 0%
Progress: 15%
Progress: 50%
Progress: 100%
</code></pre>
<p>It does all that in one ... | <p>Use</p>
<pre><code>printf ("\r progress =%d", progress)
</code></pre>
|
jQuery function into ajax <p>I'm using jQuery for a while but it is the first time I need to create my own function. (I'm using noConflict)</p>
<p>I have a code who work like this :</p>
<pre><code>jQuery(function()
{
jQuery("#tabs-3").dynatree({
checkbox: true,
onActivate: function... | <p>That's because when you do jQuery.fn.extend, it extends your selector.</p>
<p>For example:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id = "tabs-3">&... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.