input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Find element by id in tree data structure <p>Tree sample: </p>
<pre><code> root
/ | \
1 2 4
/ /|\
3 5 6 7
/ \
13 14
</code></pre>
<p>I have one function, that search element in tree recursively. For example i want to find element #6</p>
<pre><... | <p>The truth is indeed in the middle: when you do not return the value of the recursive call, you lose the information you gathered. When on the other hand you return the value of the recursive call it will not work because you will then <em>always</em> return in the first iteration of your <code>foreach</code> loop.</... |
Get vine image with cURL <p>Im trying to get vine image using cURL but its returning empty.</p>
<p>I want to extract the image from vine meta tags</p>
<pre><code><meta property="twitter:image:src" content="https://v.cdn.vine.co/r/thumbs/C40D8A18E21388329752896937984_58406422053.35.0.D4119957-7F82-4C6F-94EC-4732C58... | <p>The Answer is already posted here:<a href="http://stackoverflow.com/questions/14549745/how-to-get-vine-video-url">How to get Vine video url</a></p>
<p>You've even copied an answer. Just replace <code>twitter:player:stream.</code> with <code>twitter:image:src</code>.</p>
<p><strong>My bad, didn't read Image</strong... |
Split the contents of Combobox <p>I have a combobox the allow for multiple entries that are delimited with comas.</p>
<p>Trying to split those values into an array. Using the following:</p>
<pre><code>Dim LogArray As String
If AreaCB.Value <> "No Changes Needed" Then
LogArray = Split(Me.Bay1CB.Value, ","... | <p>I find it simpler to use a Variant:</p>
<pre><code>Dim LogArray As Variant
If AreaCB.Value <> "No Changes Needed" Then
LogArray = Split(Me!Bay1CB.Value, ",")
End If
</code></pre>
|
Transitions browser issue Css3 <p>I have searched and I am unable to locate a solution. I have a section with an id called <strong>#games</strong> and i have the following link setup.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre... | <p>I think your <code>transition</code> statement is missing the <code>fade</code> parameter - try:</p>
<pre><code>transition: opacity .5s ease-in-out;
</code></pre>
|
same class looks different on different pages <p>I'm trying to figure out what's wrong with my responsive website.</p>
<p>On a desktop it looks fine, but when you view the mobile version, the class ".game-box" looks fine on the main page, but on other pages the text inside that class looks tiny.</p>
<p>I coded the st... | <p>I changed the font size to 2em in this media query and it seems to look better.</p>
<pre><code>@media screen and (max-device-width: 720px)
.game-box, .game-box--right {
margin: 20px;
width: calc(100% - 4 * 10px);
font-size: 2em;
}
</code></pre>
|
Maximum cost from a set of labels 1-n each with a weight vi <p>I'm trying to solve a problem wherein I have a set of items with labels l1,l2,l3,....ln each of which is associated with a weight vi.
n is "EVEN".</p>
<p>There are 2 people each of which will take turns to pick one item at a time. You can only pick an ite... | <p>This can be solved by <a href="https://en.wikipedia.org/wiki/Dynamic_programming" rel="nofollow">dynamic programming</a>.</p>
<p>Say you create an <em>n X n</em> matrix, <em>P</em>, indicating the largest possible payoff for you. Specifically, <em>P<sub>i, j</sub></em> indicates the largest payoff available to you ... |
Not a valid parameter definition for Swagger query? <pre><code># GET verb version of the "GetClientsForGadget" method from the original ASMX Service
/clients/ProspectClient/roleandcstbased/{OrgNmFilter}/{SortNm}?{UserName}:
get:
tags:
- Client
summary: Merging of GetClientsforGadget and GetCl... | <p>Realized the issue was in path. The path does not need to include the query parameter.</p>
<pre><code>/clients/ProspectClient/roleandcstbased/{OrgNmFilter}/{SortNm}?{UserName}:
/clients/ProspectClient/roleandcstbased/{OrgNmFilter}/{SortNm}:
</code></pre>
<p>It only needs the query to be defined in parameters. Oth... |
org.apache.spark.sql.AnalysisException: cannot resolve given input column <p>I have a Spark program that's reading from CSV files and loading them into Dataframes. Once loaded, I'm manipulating them using SparkSQL.</p>
<p>When running my Spark job, it fails and gives me the following exception:</p>
<p>org.apache.spar... | <p>In Spark 2.0 in built CSV support has been added , try like below.</p>
<pre><code>spark.read.format("csv").option("header","false").load("../path_to_file/file.csv")
spark.read.option("header", "false").csv("../path_to_file/file.csv")
</code></pre>
|
Java generic class Autodialer and interface Callable <p>my task is to write the first line of several classes (the code itself I cannot change) which I have seemed to master, except for one compilation problem: </p>
<p>Exception in thread "main" java.lang.Error: Unresolved compilation problems: T cannot be resolved... | <p>try this </p>
<pre><code> class AutoDialer<T>
</code></pre>
<p>Generic type should be defined for the whole class first</p>
<p>you have the same problem in Node class</p>
<p>and in your test methods you need to specify the type as these methods are static and you cant pass type to them even if you ... |
How can one create a custom listing page displaying products for a specific brand in BigCommerce? <p>We are trying to set up a custom brand landing page at <a href="https://www.brace-mart.com/test-drive-medical" rel="nofollow">https://www.brace-mart.com/test-drive-medical</a> to meet that brand's requirements. We woul... | <p>According to Danielle Mead, "You'd have to make the brand a category and then you could apply a custom page template to it. You can't apply custom templates to brands." David Inman also contributed, "We do this all the time. Just redirect the Brand URL to your Category and apply the custom template to that."</p>
<... |
Is send_resp() and put_resp_content_type() the canonical way to send a string as XML in Phoenix? <p>In Phoenix, what's the canonical way of sending a string as an XML response? </p>
<p>I have the following code which works fine, but it seems like I should use render or similar? </p>
<pre><code>conn
|> put_resp_con... | <p>In Phoenix there isn't directly support to xml so you need to fall back to what <a href="https://github.com/elixir-lang/plug" rel="nofollow">plug</a> expose. As you can see in the hello world example in <a href="https://github.com/elixir-lang/plug/blob/2df667389dbaebb0e2102343c8d7a6ed4de6e280/README.md#hello-world" ... |
How to vertical align an anchor inside li? <p>I want to create a menu with a 'button' (anchor) in the last <code><li></code>.</p>
<p>So far so good, but when I want to create the button, I can't get it to vertical center it.</p>
<p>Here is <a href="https://jsfiddle.net/wksfdszu/" rel="nofollow">a live demo</a>.... | <p>Add <code>vertical-align: middle</code> to <code>.vertical</code>.</p>
<p>code updated <a href="https://jsfiddle.net/wksfdszu/1/" rel="nofollow">https://jsfiddle.net/wksfdszu/1/</a></p>
|
A list of anonymous types with inheritance <p>Let's say I have the following classes</p>
<pre><code>public class Dog{}
public class Bulldog : Dog{}
public class Pitbull : Dog{}
</code></pre>
<p>I am trying to create a list like this</p>
<pre><code>var dogs2 = new[]
{
new { X = new Bulldog(), Y = 10},
new { X =... | <p>You can explicitly cast X to a type of <code>Dog</code>:</p>
<pre><code>var dogs2 = new[]
{
new { X = (Dog)new Bulldog(), Y = 10},
new { X = (Dog)new Pitbull(), Y = 20}
}.ToList();
</code></pre>
|
VSCode Format Inserts Spaces and Breaks Angular HTML on some files <p>For a small subset of HTML Files in my Angular/MEAN Stack app, invoking the Auto Formatter breaks the angular code in a number of very strange ways. The problems boil down into the following major issues:</p>
<ol>
<li><p>Spaces inserted at the end o... | <h1>Investigation</h1>
<p>per the suggestion by <a href="http://stackoverflow.com/users/2371073/joaozito-polo">Joaozito</a> I tried reinstalling VSCode, wiping ~/Library, and restarting. No Luck.</p>
<p>I then started at the top of the file and identified where the problems started ... Sure enough, I had an extra <co... |
How to read from a stream first N digits as an integer? <p>From a stream and an integer <code>N</code>, I have to get the integer represented by the <code>N</code> first digit-characters of the stream.</p>
<p>Here are some examples:</p>
<pre><code>/*------------------------------------------------*/
/* N | Stream... | <p>There is no built-in way to do this in C++. However you can 'read' exactly N characters, then turn them into integers.</p>
<pre><code>char number[N];
stream.read(number,N);
return atoi(number); // or stringstream ss; ss << number; ss >> ret; return ret;
</code></pre>
|
Set value in Bitfield variable <p>I'm using the Bitfield structure bellow to store the board state of a chess game, it's a 32 bit integer. The fields I'm encoding/decoding are:</p>
<ul>
<li><p>epSquare (0 from 63)</p></li>
<li><p>half moves count (0 to 100)</p></li>
<li><p>current player (0 or 1)</p></li>
<li><p>4 cas... | <p>Well, firstly, your <code>#setEPSquare()</code> function is not correct. When I show you the code below, you might understand why, but I will explain as well:</p>
<pre><code>public static int setHalfMoves(int s, int e){
return (
//mask for e to only the correct bits
(e & 0x7f)
... |
TypeScript compiler ignores declaration file in tsconfig.json <p>I'm currently trying to set up a development environment for a typescript REST consumer and am encountering the following problem: the compiler seems to mind references to Typings when they're placed in the .ts source files, however completely ignores the... | <p>The problem was caused by two things:</p>
<p><strong>First</strong>, if you're using gulp-typescript to compile your code first and then bundle it only with browserify (without using tsify), you have several options on how to configure the compiler. If you choose to configure it with tsconfig.json, you first need t... |
rewrite url with virtual host <p>I have very limited experience with system administration and I'm currently trying to re-route/write (which ever is the appropriate term) sub-domains to top level domains. For example, I have a domain called bar.com, and I've created a number of sub-domains such as foo.bar.com. I'd like... | <p>It sounds like you're looking for a way to redirect within the virtual host.</p>
<p>If that's the case then, you should be able to use mod_rewrite within your virtual host to accomplish this.</p>
<pre><code>RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo\.bar\.com$ [NC]
RewriteRule ^(.*) http://foo.com/ [L,R]
</cod... |
Does Swift have quadratic string concatenation when using var? <p><a href="https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html">In the Swift Language Reference, under String Mutability</a> it says:</p>
<blockquote>
<p>You indicate whether a ... | <p>Appending to a collection like this (while <code>String</code> is not itself a collection, you're essentially appending to its <code>characters</code> view with that code) is linear, not quadratic. A string in Swift has an internal buffer whose size is doubled whenever it fills up, which means you will see fewer and... |
Dynamic allocation with charactere array <p>I try to add a string dynamically allocate an element but there is a thing in my function "ajouter_element" "add_element" it's in the malloc but i don't know how it does work</p>
<pre><code>void ajouter_element(liste* liste, chaine val){
element* listeCourante;
elem... | <p>A bit of guesswork since some info is missing:</p>
<p><code>chaine</code> is very likely to be a typedef on a <code>char *</code> (see main program where <code>value</code> is allocated)</p>
<p>When you do this:</p>
<pre><code>listeCourante = (element*)malloc(sizeof(element)); // on alloue de la place dans cette ... |
How to get the highest range from low value minus high value within an array of numbers? <h1>Idea</h1>
<p>So we have a sales person who comes to a shop that has an array of numbers of products with different prices.</p>
<pre><code>vector<int> prices{28, 18, 20, 26, 24, 12};
</code></pre>
<h1>Problem</h1>
<p>W... | <p>You have to store current minimum and current maximum profit:</p>
<pre><code>auto min = v.begin();
auto max_profit = 0;
for (auto it = v.begin(); it != v.end(); ++it) {
if (*it < *min) {
it = min;
}
max_profit = std::max(max_profit, *it - *min);
}
</code></pre>
<p>so for <code>{65, 50, 100, ... |
Having trouble pushing a specific key into an array <p>So I just learned how to create a function for a for loop.
Here's what we have:</p>
<pre><code>function each(array, func) {
for (var i = 0; i <array.length; i++) {
func(array[i]);
}
}
</code></pre>
<p>Now I'm trying to take an already made func... | <p>You should do this:</p>
<pre><code>function ages(people) {
var acc = [];
each(people, function(person) {
acc.push(person.age);
});
return acc;
}
</code></pre>
<p>By the way, javascript has a native <code>forEach</code> function that does what your <code>each</code> function does, and is pro... |
How to show a div With Css and JavaScript <p>I wanted to show a div if a particular var is equal to 1.
But my code is not working.</p>
<pre><code><div id="bip" style="display: none;" >My Content Goes Here </div>
</code></pre>
<p>HERE IS MY JS CODE</p>
<pre><code>var msg=::msg_id::
if(msg==1)document.get... | <p>It might not seem obvious, but to apply new styles to elements, you have to do it when the DOM is ready. So:</p>
<p><strong>HTML</strong></p>
<pre><code><div id="bip" style="display: none;">My Content Goes Here</div>
</code></pre>
<p><strong>Javascript</strong></p>
<pre><code><script type="text/ja... |
How to create a plugin in ES6 (no build system) <p>I'm trying to move one of my Aurelia custom elements to its own Git repo so that I can <code>npm install</code> it and use it in more than one project.</p>
<p>My hope was to simply commit the one JS file the element consists of (it uses an <code>@inlineView</code>) (a... | <p>Your plugin can be ES2015, for the most part. The main exception is that you cannot use the <code>import</code> module syntax, as that is not supported by any browser yet. This also means that the <code>export class</code> syntax that your plugin uses is not supported. </p>
<p>So, at the very least, you'll need to ... |
R tm package (version) <p>I am starting a project of text mining using R and almost every resource I've found needs package <code>tm</code>, problem is, this package won't load because it imports package <code>slam</code> which is unavailable for R version 3.3.0.</p>
<ul>
<li><p>Does anyone know a good package for tex... | <p>I simply updated to 3.3.1. This worked for me when I ran into the same thing last week on an OSX system running 3.3.1. I used the method found here to save my packages, but to my delight I did not have to restore them (maybe bc it's only a minor version?): <a href="https://www.datascienceriot.com/how-to-upgrade-r-... |
How can I echo "pass" or "fail" after a bash, curl, grep sequence? <p>I'm big fan of elegant one-liners. I am trying to write a one-line test that outputs "pass" or "fail" after doing an http request and a search. I've tried something like this:</p>
<pre><code>curl "http://haystack.io" | sed 's/.*?needle.*/PASS/' || e... | <p>If you're just looking for the needle, you can use <code>grep -q</code> to get an exit code:</p>
<pre><code>if curl "http://haystack.io" | grep -q needle
then
echo "PASS"
else
echo "FAIL"
fi
</code></pre>
<hr>
<p>The problem with your approach:</p>
<pre><code>curl "http://haystack.io" | sed 's/.*?needle.*/PA... |
Canvas Image to Email Form in New Window <p>I am trying to have the user save a portion of an image.<br>
I can save it to the server now and it all works but on the same page.<br>
I need to be able to break this off into two separate pages.<br></p>
<p>This is where I am pulling the image data and sending from.<br>
Ope... | <p>Here is what I would do. Save the image to a hidden form field, submitting the form via POST to your server. In your PHP file, save the image to a unique location using PHP's uniqid function. Then respond with the confirmation page that contains an <code><img></code> tag to the image they just uploaded.</p>
<... |
Python string have not control characters <p>i have proxy string:</p>
<pre><code>proxy = '127.0.0.1:8080'
</code></pre>
<p>i need check is it real string:</p>
<pre><code>def is_proxy(proxy):
return not any(c.isalpha() for c in proxy)
</code></pre>
<p>to skip string like:</p>
<pre><code>fail_proxy = 'This is pr... | <p>Try the following specific approach using <code>re</code> module(regexp):</p>
<pre><code>import re
def is_proxy(proxy):
return re.fullmatch('^\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}:\d{1,5}$', proxy) is not None
proxy1 = '127.0.0.1:8080'
proxy2 = '127.0.0.1:8080\r'
print(is_proxy(proxy1)) # True
print(is_proxy(p... |
Autofac applying generic decorator on closed types unable to get working <p>Using Autofac 3.5 and MediatR, I am trying to apply a decorator to a closed type that implements a specific interface. I have the following handler type:</p>
<pre><code>class ABCQueryHandler: IRequestHandler<GetBankStatementLinesQuery, Bank... | <p>You are passing on the open-generic type to the <code>KeyedService</code>. You should instead pass on the closed-generic type as follows:</p>
<pre><code>builder
.RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
.As(type => type.GetInterfaces()
.Where(t => t.IsClosedTypeOf(typeof(IRequest... |
Text compressor doesn't compress the intended way <p>For a school assignment I have to write a python program to compress a text and write a new file with the compressed text, conserving the original. For example, the text "heeeeeeellllooo" to "he7l4o3". So each character that is iterated subsequently has to be replace... | <p>Here's a correct solution:</p>
<pre><code>inp = open("hello.txt", "r")
out = open("compr.txt", "w")
kar=inp.read(1)
prevkar=''
def iterations(a,b):
re = 1
while a==b:
re+=1
b = a
a = inp.read(1)
out.write(str(re))
return a
def no_iteration(a):
out.write(a)
return
... |
Binding WPF not executed immediately <p>I would like to update busy indicator on the beginning of the function.
The binding executed only when function is done.</p>
<pre><code>private async void DoJob()
{
await Task.Run(() => SetBusyIndicatorState(true));
var res = await ( LongFunction());
...
awa... | <p>Mark your method async and await for the execution complete.</p>
<pre><code> SetBusyIndicatorState(true);
Task.Run(() =>
{
//implement
}).ContinueWith(completedtaskresult=>
{
SetBusyIndicatorState(false)
}, TaskScheduler.FromCurrentSynchronizationContext());
</code></pre>
|
NgModule vs Component <p>So I'm learning angular2 now and reading ngbook2 about the modules.
Modules contain components, but also can import different modules with their public components.</p>
<p>And the question is: What is the scope of the module component (in this meaning scope as parts of an application, not the r... | <p>A common way is to see a module as a distinct feature implementation, that can consist of zero or more services, components, directives, and pipes and import modules that are used to implement that feature.</p>
<p>A module can define what of its content it exports to be made available for importers.</p>
<p>An appl... |
Indentation error basic program <p>Hello I am beginner to python and am trying to learn, this is what i keep hitting when i execute the below code, where is the mistake</p>
<pre><code>#!/usr/bin/python
def main():
num1=input("Enter the 1st #\t\t")
print "First # is\t:", num1
print
num2=input("Enter the 2nd #\t\t")
pr... | <p>You should indent your main function with spaces or tabs. (4 spaces is recommanded)</p>
<p>Like this:</p>
<pre><code>def main()
num=input()
# rest of your main code
main()
</code></pre>
<p>I saw you allready did this for if/else, you should also do it for functions. </p>
<p>I recommand you take a beginn... |
How to fetch next 10 SQS messages after fetching first 10 SQS msges at any point in time <p>I am trying to develop a UI for QA team where they can check queue messages without login to AWS.</p>
<p>To make this UI less expensive I am showing only first ten Queue messages, now what if QA person want to fetch more record... | <p>Sounds like you may want to temporarily write your SQS messages to a database at the same time and have the QA team view messages in the database instead. SQS has no concept of paging or 'next 10' - when you read messages from the queue you are supposed to process and delete them - and then ask for more. Browsing da... |
C# convert string to hex offset <p>Ok, so lets say I have a text box and someone writes "0x02009000", how can I convert that string to a hex offset and use it for a binary writer? I haven't seen any other questions answer this.</p>
| <pre><code>// Remove the "0x" from the string (it's not supported)
string hexVal = hexTextBox.Text.Substring(2);
// Parse into int
int offset = int.parse(hexVal, System.Globalization.NumberStyles.HexNumber);
// Use in BinaryWriter
binaryWriter.Write(someByteArray, offset, someLength);
</code></pre>
|
How can I generate all unique combinations of multiple array's with optionals? <p>I would like to combine all values in multiple array's to create unique combinations. There is one catch: some array's can be optional.</p>
<p>For example: I'm configuring a PC and I've got the choice between:</p>
<ul>
<li>5 types of ch... | <p>It seems that answer is much more simple than understanding the problem.
You need no change in procedure - just include 'null' as possible value in optional arrays. It would mean that part wasn't included.</p>
<p>This way there will be arrays with null values returned, but their indexes will represent source. Takin... |
Same Image, but different base64 <p>I used the following function to create a base64 encoded string of my Gravatar image (<a href="https://www.gravatar.com/avatar/cd5415f97afbe0177ba35ae31fbfd0db">https://www.gravatar.com/avatar/cd5415f97afbe0177ba35ae31fbfd0db</a>):</p>
<pre><code>final BASE64Encoder encoder = new BA... | <p>Converting both images back to .jpg, and using <a href="http://regex.info/exif.cgi" rel="nofollow">http://regex.info/exif.cgi</a>, the following header comments appear:</p>
<p>One:</p>
<blockquote>
<p>CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 90</p>
</blockquote>
<p>Other:</p>
<blockquote>
<p>CRE... |
AWS/Apple Push certificate -- error setting private key <p>I'm attempting to follow <a href="http://docs.aws.amazon.com/sns/latest/dg/mobile-push-apns.html#verify-cert-private-key-apns" rel="nofollow">these</a> instructions to set up my S3 API to send push notifications to my iOS app.</p>
<p>I'm making a mess of the c... | <p>Don't use Apple's instructions to generate the CSR.</p>
<ol>
<li><p>Generate key:</p>
<pre><code>openssl genrsa -out $app.key 2048
</code></pre></li>
<li><p>Generate CSR:</p>
<pre><code>openssl req -new -key $app.key -out $app.csr
</code></pre>
<p>And enter the relevant data.</p></li>
<li><p>Upload CSR to Apple.... |
Log4j2 getting logging event <p>I am trying to migrate a small test case (which make sure our logging is working as expected) from log4j-1.6 to log4j- 2.6. What we are doing is passing a map and logging it under Debug level and verifying whether loggingEvent is Debug or not and asserting for expected rendered message. ... | <p>After a long research,I solved my problem like this. Added a customized appender in tst and property file in src lik</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<Configuration package="log4j.test" status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
&... |
Emacs program to collapse Json to single line <p>I'm dealing with a file that has a list of single line json strings. To edit an individual json object, I found this tool: <a href="https://github.com/gongo/json-reformat" rel="nofollow">https://github.com/gongo/json-reformat</a>. Now, I'm looking for the reverse operati... | <p>Doesn't look like <code>json-reformat</code> comes with anything for that. </p>
<p>Here's an interactive function that can do this:</p>
<pre><code>(defun json-to-single-line (beg end)
"Collapse prettified json in region between BEG and END to a single line"
(interactive "r")
(if (use-region-p)
(save-ex... |
Select all buttons except one with jQuery <p>I have this code :</p>
<pre><code><div id="filters" class="button-group">
<button class="button is-checked" data-filter="*">Tous</button>
<button class="button" data-filter=".image">Photos</button>
<button class="button" data-fil... | <p>Your selector should look like this </p>
<pre><code>$('#filters button').not('#sort')
</code></pre>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$... |
Does printf() allocate memory in C? <p>This simple method just creates an array of dynamic size n and initializes it with values 0 ... n-1. It contains a mistake, malloc() allocates just n instead of sizeof(int) * n bytes:</p>
<pre><code>int *make_array(size_t n) {
int *result = malloc(n);
for (int i = 0; i &... | <p>Whether <code>printf()</code> allocates any memory in the course of performing its work is unspecified. It would not be surprising if any given implementation did so, but there is no reason to assume that it does. Moreover, if one implementation does, that says nothing about whether a different implementation does... |
Error while querying for a column in database using spring <p>I am trying to query an entire column data for eg:</p>
<pre><code>SELECT USER_USERNAME FROM xxxx WHERE USER_USERNAME=?
</code></pre>
<p>I'm getting error </p>
<pre><code>org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expec... | <p>In JdbcTemplate , queryForInt, queryForLong, <strong>queryForObject</strong> all such methods expects that executed query <strong>will</strong> return <strong>one and only one row</strong>.
If you get no rows that will result in EmptyResultDataAccessException. </p>
<p>From the <a href="http://docs.spring.io/spring... |
Memory leak when using angular's $compile with a new scope <p>I want to dynamically create angular components using javascript, and then have angular compile them using <code>$compile</code> with a newly created scope. Then when I have no longer use for that component, I want to destroy the component and the new scope.... | <p>It will start deallocating if you put array to scope and de-allocate it</p>
<pre><code>$scope.array.length = 0;
</code></pre>
<p>to the destcructor. But... nice to know. I'll have to watch closely memory consumption. Seems that scope is retained. Cause I am only de-allocating inner variables.</p>
|
pyqt: How to quit a thread properly <p>I wrote an pyqt gui and used threading to run code which needs a long time to be executed, but I want to have the choice to stop the execution safely. I dont want to use the get_thread.terminate() method. I want to stop the code by a special function (maybe <strong>del</strong>())... | <p>This is impossible to do unless <code>prog.run(self)</code> would periodically inspect a value of a flag to break out of its loop. Once you implement it, <code>__del__(self)</code> on the thread should set the flag and only then <code>wait</code>.</p>
|
Restrict Secure Gateway Network Security to API Connect in Bluemix <p>I have setup the Secure Gateway to connect to my on premises DataPower and have exposed a local SOAP service. In the destination I have enabled User Authentication for mutual auth, and this is working well. In order to access the SOAP service the cli... | <p>This is not possible due to the nature of cloud-based solutions. IP addresses may change at any time, thus breaking the linkage.</p>
<p>Mutual TLS is an excellent solution and should provide robust security as long as your private keys are carefully protected.</p>
|
cross compiling util-linux for ARM, libtool/ld is not taking libs from LDFLAGS path <pre><code>OS_COMP_DIR="/home/dev_team/prebuilt"
export CROSS_COMPILE="arm-linux-gnueabi"
export CPPFLAGS=" -I$OS_COMP_DIR/usr/include "
export LDFLAGS=" -L$OS_COMP_DIR/usr/lib/"
export AR="/usr/bin/arm-linux-gnueabi-gcc-ar-4.9"... | <p>You have specify <code>LDFLAGS</code> right in configure command line : </p>
<p><code>./configure --build=i686-pc-linux-gnu --target=${CROSS_COMPILE} --host=${CROSS_COMPILE} LDFLAGS=-L/home/dev_team/prebuilt/usr/lib/ make V=1</code> </p>
<p>Or you may add to your env: </p>
<pre><code>export LD_LIBRARY_PATH=" -... |
String or object compairson in Python 3.52 <p>I am working on the exorcism.io clock exercise and I can not figure out why this test is failing. The results look identical and even have the same type.</p>
<p>Here is my code:</p>
<pre><code>class Clock:
def __init__(self, h, m):
self.h = h
self.m = ... | <p>A custom class without an <a href="https://docs.python.org/3/reference/datamodel.html#object.__eq__" rel="nofollow"><code>__eq__</code> method</a> defaults to testing for <em>identity</em>. That is to say, two references to an instance of such a class are only equal if the reference they exact same object.</p>
<p>Y... |
Displaying 2 records in a column using php <p>So I have a code</p>
<pre><code><?php
$showorder = "SELECT order_number FROM orders WHERE customer_number=522";
$orderesult = mysqli_query($con, $showorder);
$ord = mysqli_fetch_array($orderesult);
?>
</code></pre>
<p>in my database customer number 522 has 2 order n... | <p>You just need to use <code>while()</code> here for getting all records, something like:</p>
<pre><code>while($ord = mysqli_fetch_array($orderesult)){
//echo all value here
}
</code></pre>
<p>Also note that, if you want to print <code>$ord["order_date"]</code> than you must need to select column also in your que... |
How to find the location of maximum and minimum value of a 2d array <p>I don't know if i am being clear with this but I already have the minimum and the maximum printing out right, but I can't seem to figure out how to say the exact row and column they are in.
this is what i have so far; </p>
<pre><code>double max = ... | <p>See the below modification. I added variables to track the indices of the min and max. At the end of your loop you can simply print out <code>maxIndex1</code>, <code>maxIndex2</code>, <code>minIndex1</code>, and <code>minIndex2</code>.</p>
<pre><code>double max = m[0][0];
double min = m[0][0];
//declare variables... |
Azure AD admin consent from the Azure portal <p>I have registered few apps in Azure AD and these apps require admin consent. Can the tenant admin instead of opening each app and then providing consent, can he just select the apps in the azure portal and provide his consent?</p>
| <p>The consent framework is used to make it easy to develop multi-tenant Web and Native client applications that need to access Web APIs secured by an Azure AD tenant, different from the one where the client application is registered.</p>
<p>Based on the test, if you were developing single-tenant apps, there is not ne... |
Populating an element with dynamic html <p>So I am building a song queue which automatically updates it's contents on a function call. This function call creates an ajax request to a php script which returns json data for songs in the queue (image url, song title, song author). I am then wanting to dynamically populate... | <p>A jQuery solution:</p>
<pre><code><ul id="container" />
</code></pre>
<p>and Javascript:</p>
<pre><code>// Assuming the data comes in like this:
/*
[
{url: 'http://www.example/com', title: 'Title Goes Here', author: 'Author here'},
{url: ...
]
*/
$.getJSON('url.php', function(data) {
$('#contain... |
Editr.js light theme <p>I am trying to figure out how to implement the <a href="https://github.com/Idered/Editr.js/blob/master/README.md" rel="nofollow">editr.js</a> light theme</p>
<p>It says it to do it via JS, </p>
<p>Not overly sure what it means in the documentation when it says </p>
<blockquote>
<p>ACE Edito... | <p>On this line, add "editr--light" to the list of classes:</p>
<pre><code><div class="editr" data-item="PROJECT-NAME" data-files-html="index-1.html;index-2.html" data-files-css="!normalize.css;style.css" data-files-js="!jquery.js;script.js"></div>
</code></pre>
<p>EG:</p>
<pre><code><div class="editr... |
Getting Nested Data From JSON Object in Angular 2 <p>Hello I am building something similar to a music player app. I have a service set up grabbing the data from a JSON file that I have in a fixture. I can grab all top level data with *ngFor but once I start to ask for something like songs.parts.name this shows up undef... | <p>You could make use of <a href="https://angular.io/docs/ts/latest/guide/template-syntax.html#!#safe-navigation-operator" rel="nofollow">Safe-Navigation-Operator</a></p>
<p>Looks like you might of had it or been close to having it, shouldn't it be somehting like</p>
<pre><code><section class="songs container">... |
Do we need to specify python interpreter externally if python script contains #!/usr/bin/python3? <p>I am trying to invoke python script from C application using <code>system()</code> call</p>
<p>The python script has <code>#!/usr/bin/python3</code> on the first line.</p>
<p>If I do <code>system(python_script)</code>... | <p>Make sure you have executable permission for <code>python_script</code>.
You can make <code>python_script</code> executable by </p>
<p><code>chmod +x python_script</code></p>
<p>Also check if you are giving correct path for <code>python_script</code></p>
|
How to unit test express route with passport authenticate <p>How can one unit test an express router that is dependent on passport authentication to call the helper methods?</p>
<p>I'm new to express unit testing and I've seen a lot of code that actually hits the server to call the method. But would that not make it a... | <p>Check this repository, it has all You want: <a href="https://github.com/num8er/alttab-nodejs-challenge" rel="nofollow">https://github.com/num8er/alttab-nodejs-challenge</a></p>
<p>Also a look at example and implement it as You wish:</p>
<p>1) server.js :</p>
<pre><code>var
http = require('http'),
app = requi... |
Saving a UIAlertControllers UITextField text as core data <p>I have created a UIAlertController with three buttons and a UITextField. I would like to be able to save user input in a UITableView row cell in another ViewController.</p>
<p>I have tried to save the UiTextField Text in an array to no avail. </p>
<p>How ca... | <p>Usually you don't save strings directly to Core Data. It is meant to store enteties, which may have strings as their properties though.</p>
<p>If you push view controller with UITableView from your current view controller and you don't really need to persist your data, you can save every string user enters into you... |
Passing a value into List then outputting it in a method <p>I have created a couple of methods outputing values (all of them are void) e.g.</p>
<pre><code>static void GetStudentDetails()
{
Console.WriteLine("Please enter your name:");
string Name = Console.ReadLine();
// (Optional) listOfVariables.Add(Name);
... | <p>You can do something like this:</p>
<pre><code> static void ShowSummary()
{
foreach(var name in listOfVariables )
Console.WriteLine("Your name is " + name);
}
</code></pre>
<p>The <code>GetStudentDetails</code> function would be like:</p>
<pre><code>static void GetStud... |
Loading Bootstrap modal after delay not working <p>I'm working on a cratejoy site, and my client needs a modal to popup after a set amount of time. I added the modal and when I use this it works fine:</p>
<pre><code>$('#myModal').modal('show');
</code></pre>
<p>But when I try to use either of these answers from <a hr... | <p>You have multiple versions of jQuery being loaded</p>
<p>Apart from the obvious version with it's own script tag your main.js file also includes it.</p>
<p>Since it loads after bootstrap.js it overwrites the whole jQuery object and removes reference to bootstrap in original version. That is why you get the error s... |
Ember log every click <p>I would like to log every click (whether that is through transitions, views, auto generations, ect ...) in some datastore for later analysis.</p>
<p>I realize this is probably a deal breaker for using ember as there are a lot of these activities that do not depend on a server side api call, so... | <p>Install <a href="https://github.com/poteto/ember-metrics" rel="nofollow">ember-metric</a> and write a simple adapter for it so that it sends the data to your storage. Notice how it instructs you to extend the router, so that tracking is done automatically after every transition - you can do the same without using em... |
SQL flattening tables of translations <p>I have a table of products, and a separate table which lists various translations for those products. The basic setup looks something like this:</p>
<pre><code>dbo.Products
ProductID | Description
1 | An amazing product
2 | An even more amazing product
3 ... | <p>It seems like you need to return description for English from your products table. Use conditional sum aggregation:</p>
<pre><code>SELECT
p.ProductID,
MAX(CASE WHEN pt.Language = 'EN-US' THEN COALESCE(pt.Description, p.Description) END) AS ENUS_Description,
MAX(CASE WHEN pt.Language = 'FR-CA' THEN pt.Descript... |
Unable to install jdk-8u101-windows-x64 in system <p>After uninstalled the java in my computer, i have downloaded latest version jdk-8u101-windows-x64.exe and tried to install it. but unfortunately at end of installation i got the error code as,</p>
<p><a href="http://i.stack.imgur.com/IycSh.png" rel="nofollow">Error ... | <p>From Oracle <strong>site</strong>,</p>
<p>This is a <strong>known</strong> issue.</p>
<blockquote>
<p>Error 1603: Java Update did not complete.</p>
<p>WORKAROUND This is a known issue, and we are still investigating the
root cause. Meanwhile you can try the following to install Java.</p>
</blockquote>
<p... |
Greensock (GSAP) is much less smooth/more jerky compared to css animations in this simple example. Is there a way to improve it? <p>I'm new to gsap so if I'm doing something horribly wrong then please correct me, but this is a pretty simple example. I'm just trying to compare performance of css animations to gsap anima... | <p>This is a more of an apples-to-apples comparison (kinda): <a href="http://codepen.io/anon/pen/BLJGwK?editors=0110" rel="nofollow">http://codepen.io/anon/pen/BLJGwK?editors=0110</a></p>
<p>On my system, I couldn't notice <strong>any</strong> difference in terms of smoothness, but I realize results may vary by system... |
Is it valid to use the #define preprocessor directive inside an #if in C# <p>Could I use <code>#define</code> <a href="https://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx" rel="nofollow">preprocessor directive</a> inside <code>#if</code> and <code>#endif</code>, in C# ?</p>
<p>e.g.</p>
<pre><code>#if !SILVERLIGHT ... | <p>Yes. Looking at the <a href="https://www.microsoft.com/en-us/download/confirmation.aspx?id=7029" rel="nofollow">C# specification</a> a particular example of this usage is given in section <strong>2.5.3 Declaration directives</strong> and deemed as valid:</p>
<pre><code>#define Enterprise
#if Professional || Enterpr... |
Animate a button along a circular path in Xamarin Forms <p>I am trying to make a button move on to a Xamarin Forms page along a circular path. The button should start in the lower left of the screen then progress up the screen moving to the right, then the left in a circular motion, as if tracing a half circle on the l... | <p>The simplest solution would be to use 2 Rotation animations.
The first drawing the path, the second keeping the object leveled.</p>
<p>As both animation needs different <code>AnchorX</code> and <code>AnchorY</code>, you'll have to wrap you object in a ContentView and have the "path" animation on that one.</p>
<blo... |
Get wordpress parent template name <p>I need to get the pages parent template name. I know I can use get_page_template() for the current page, but there doesn't seem to be a way to get the parents one.</p>
<p>Is it also possible to get just the templates name instead of the path to it?</p>
| <pre><code>You can try this for get parent page template name
/********** GET PAGES BY PARAMS ************/
/*-- Get root parent of a page --*/
function get_root_page($page_id)
{
global $wpdb;
$parent = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE post_type='page' AND ID = '$page_id'");
... |
How to modify source code of app after Building? xCode-Sparkle <p>I'm doing a Mac agent that needs to use two variables, those two variables need to be set every time a user downloads the agent,my first attempt was to modify the <code>Info.plist</code> file and do the signing for Sparkle, but after that I realized that... | <p>If you mean that every user downloading should get a unique bundle (bundle whose Info.plist has been modified) to download, i.e. that you intend to compute a new DSA signature again for every single download (that's how your question can be understood), what you intend to do isn't very HTTP caching friendly (your se... |
I need to pull a first name from a full name during an append <p>So I've got a bunch of excel spreadsheets with different column headers and different formatting. I need all of them imported into an Access DB that I've been working with.</p>
<p>So I've essentially imported them all as separate tables and then consolid... | <p>Maybe an easy fix is to just import it as normal... then do an UPDATE to get the first name from the already existing Full Name column. The append or INSERT statement should have worked so something is going on to create the additional records. But if you are not into figuring out why these additional records are be... |
GKE Ingress Basic Authentication (ingress.kubernetes.io/auth-type) <p>I'm trying to get a GKE ingress to require basic auth like this <a href="https://github.com/kubernetes/contrib/blob/45bdc249bc27bdf427498b42859e1a98d634bff0/ingress/controllers/nginx/examples/auth/README.md" rel="nofollow">example from github.</a></p... | <p>The example you linked to is for nginx ingress controller. GKE uses <a href="https://github.com/kubernetes/contrib/tree/master/ingress/controllers/gce" rel="nofollow">GLBC</a>, which doesn't support auth.</p>
<p>You can <a href="https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx#deployment"... |
Can not install relational algebra interpreter writen in Java <p>RA is a simple relational algebra interpreter written in Java.
RA is packaged with SQLiteJDBC, so one can use RA as a standalone relational-algebra database system.<br>
I downloaded the zip file and extracted the contents in a folder. According to the ins... | <p>Make sure you have installed JAVA on your machine. If you have, check if path to your <code>JAVA_HOME</code> it is present in <code>%PATH%</code>.
You can see PATH variable by</p>
<p><code>echo %PATH%</code></p>
|
Hive: struct as a key in map type when creating table <p>I'm trying to create a table in Hive created from a spark job with the following data format:</p>
<pre><code>{'Group1': {[start=0, end=20]: 'Data goes here'}}
</code></pre>
<p>The spark dataframe schema for this is:</p>
<pre><code>MapType(StringType(),
... | <p>In Hive the key for a Map column must be a primitive (i.e. not a Struct).</p>
<p><a href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-ComplexTypes" rel="nofollow">https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-ComplexTypes</a><... |
How to disable vertical / horizontal mouse movement in pygame? <p>I want to prevent an object from moving vertically on the surface when moving the mouse around while horizontal movements will still be allowed. </p>
<p>How do I do that?</p>
<p>I have managed to let the object move around freely using:</p>
<pre><code... | <p>I don't remember much of Pygame, so I might be missing something, but it looks kinda obvious:</p>
<pre><code>if event.type == pygame.MOUSEMOTION:
x = event.pos[0]
</code></pre>
|
EXP() in BigQuery returns floating-point error <p>I have the following query:</p>
<pre><code>SELECT EXP(col) FROM `project.dataset.tablename`;
</code></pre>
<p>Where <code>col</code> is <code>FLOAT</code>. However, I get this error: <code>Error: Floating point error in function: EXP</code>.</p>
<p>I've tried <code>E... | <p>Probably you are working with numbers larger than 709.7827.</p>
<p>Weird number, but even in Fortran docs:</p>
<blockquote>
<p>EXP(X)</p>
<p>Exponential.</p>
<p>X must be less than or equal to 709.7827.</p>
<p><a href="http://sc.tamu.edu/IBM.Tutorial/docs/Compilers/xlf_8.1/html/lr277.HTM" rel="nof... |
Google scatter chart legend - remove line through dot <p>This is what the legend looks like:</p>
<p><a href="http://i.stack.imgur.com/XTXLB.png" rel="nofollow"><img src="http://i.stack.imgur.com/XTXLB.png" alt="enter image description here"></a></p>
<p>I want the last 3 series to show up as points, and I want the lin... | <p>you want to use something like this</p>
<pre><code>+ scale_colour_manual(values = c("purple", "green", "blue", "yellow", "magenta"),
guide = guide_legend(override.aes = list(
linetype = c("solid", "solid",rep("blank", 3)),
shape = c(NA,NA, rep(16, 3)))))
... |
Writing results of database query to text file with PHP <p>I have some code that I've written to pull attachments in my posts table of my wordpress site. </p>
<p>The first function pulls down the results, but I cannot get it to write to a text file. </p>
<p>Creation of the file is fine, and I get no errors. And the c... | <p>Your function appears to be retrieving the query AFTER attempting to write to the file.</p>
<p>As it looks like you are planning to retrieve the data, write it to a file, and then return the data for further use in your application, I would suggest something like below.</p>
<pre><code>function getPostsToMove($base... |
Convert html file containing mathjax to pdf using reportlab django <p>I would like to know how is it possible to convert an HTML file containing some Mathjax to pdf (in order to print it). I tried to make it work like this : </p>
<p>VIEWS.PY
from easy_pdf.views import PDFTemplateView</p>
<p>class HelloPDFView(PDFTemp... | <p>I finally found a solution : use pdfcrowd </p>
<p>1°. Subscribe here : pdfcrowd.com
2°. they provide you a username and API key (first 100 tokens are free)
3°. run : pip install pdfcrowd
4°. </p>
<pre><code>import pdfcrowd
def generate_pdf_view(request):
path_to_html_file = os.path.join(settings.PROJECT_RO... |
lodash findindex push to an array <p>I am using <code>_.findIndex</code> which returns me an array, which needs to be pushed to array. How can I do this?</p>
<pre><code> $scope.filtersRequested[_.findIndex( $scope.filtersRequested, {
'codeColumnName': $scope.refData[idx].codeColumnName
... | <p>If I understand correctly, you'd like to set filterCondition on a specific value. Since you use lodash, you'd better use _.set which is safe (i.e. does not fail if the first arg is undefined) and _.find (to get access to the relevant request). Hence, I'd suggest you do:</p>
<pre><code>_.set(
_.find( $scope.filters... |
GPUImage Lookup Filter - creating a color depth greater than 512² colors <p>GPUImage's LookupFilter uses an RGB pixel map that's 512x512. When the filter executes, it creates a comparison between a modified version of this image with the original, and extrapolates an image filter.</p>
<p><a href="http://i.stack.imgur... | <p>I'm not quite sure what problem you are actually having. When you say you want "4x the color depth" what do you actually mean. Color depth normally means the number of bits per color channel (or per pixel), which is totally independent of the resolution of the image.</p>
<p>In terms of lookup table accuracy (which ... |
SimpleBlobDetector not recognizing the more obvious circles <p>I am using SimpleBlobDetector with the parameters specified below:</p>
<pre><code># Parameters
params = cv2.SimpleBlobDetector_Params()
params.filterByArea = True
params.minArea = 1500
params.filterByCircularity = True
params.minCircularity = 0.5
params.fi... | <p>If you add</p>
<p>params.maxArea = 10000</p>
<p>you get this image:</p>
<p><a href="http://i.stack.imgur.com/nz9cy.png" rel="nofollow"><img src="http://i.stack.imgur.com/nz9cy.png" alt="not too big to fail"></a></p>
<p>so I assume there's a default maximum, and you're exceeding it.</p>
|
Getline equivalent for class and int, and also 'no viable overloaded =' error <pre><code>class Book{
public:
string _title;
string _author;
string _publisher;
Date _published;
float _price;
string _isbn;
int _page;
int _copies;
Book(void);
Book(string, string, string, Date, float, string, int, int);
};
Book::Book(vo... | <p>One cannot simply <code>std::getline</code> into an <code>int</code>. Seriously. It's harder than walking into Mordor.</p>
<p>A few ways to do this.</p>
<p>One is to intermix <code>std::getline</code> and use of the <code>>></code> operator. But </p>
<pre><code>myFile >> price;
getline(myFile,isbn);
<... |
How would i make the computer assign a name to the automaticly that can be recalled later in python <p>My objective is to make the computer assign a name to the user file automatically but that can also be recalled later.</p>
<pre><code>import random
r = random.choice()#i want this too be a random name that the comput... | <p>If you're just trying to generate a random name, use a list and random.choice. Here is an example. <code>print(random.choice(["Hello","World","!"]))</code>, this will give you a random string from the list either 'Hello', 'World', or '!'. If you want more help on the random module I suggest looking at the docs, <a h... |
Angular 2: Calling a child component <p>I've updated my ionic app from beta 11 to rc0. So it means I've switched from angular2 rc4 to angular2 stable.</p>
<p>I am trying to use a custom component that I'm calling from <em>home-page.html</em></p>
<pre><code><slider-component [title]="sliderTitle[0]" [songs]="recent... | <p>You should implement <code>OnInit</code> and access your data bound properties (title, songs etc.) in <code>ngOnInit()</code> method. As per the life cycle they are not initialized at the time of constructor execution. </p>
|
Codeigniter null values ajax request <p>, i'm triying to get some values from database on an ajax request in codeigniter...but json object returns null ([]) when I put console.log...I need help pls !!</p>
<p>JAVASCRIPT</p>
<pre><code>function list_president() {
var section = "1";
$.post(baseurl + 'vot... | <p>You aren't sending key/value pair to server...just a value.</p>
<p>So there is no <code>$_POST['section']</code> which is basically what <code>$this->input->post('section');</code> is</p>
<p>Try changing</p>
<pre><code> var section = "1";
</code></pre>
<p>To</p>
<pre><code> var section = {section: "1"};
... |
App Transport Security blocking with "Allow Arbitrary Loads = YES" <p>I'm trying to access my Python CGI script running on an instance in Amazon EC2 though a POST request but even though I have changed my Info.plist file to allow arbitrary loads it shows:</p>
<p><img src="http://i.stack.imgur.com/I9NLs.png" alt="error... | <p><strong>Make sure you have the right Info.plist file</strong></p>
<p>First, make sure that the Info.plist that you put those settings in is the one your project is using. You can verify this by going into your project settings and searching for Info.plist. Make sure that the Info.plist file where you set those val... |
How can I add fractional times in R? <p>I have large number of dates in this format:</p>
<pre><code>dt = as.POSIXct("2004-04-02 12:45:00 UTC")
</code></pre>
<p>And I have to add/subtract numbers that may not always be whole numbers.I am using lubridate library.</p>
<p>Example:</p>
<pre><code> dt - days(2)
[1] "2004... | <p>The error is occurring with <code>days(1.5)</code>, which doesn't allow fractional periods. You could do:</p>
<pre><code>dt - days(1) - hours(12)
</code></pre>
<p>or</p>
<pre><code>dt - 1.5*24*3600
</code></pre>
<p>or there's probably a base date function that guys like @DirkEddelbuettel know about that would wo... |
How to implicitly set UITextView contentSize? (Swift 3/xCode8) <p>I have a need to set the contentSize of a non-scrolling UITextView exactly to it's superview's frame. I need to do this for the purpose of getting the range of characters that fit, and while I know there's better methods for doing this, or even better vi... | <p>You can do so using <code>.bounds</code>:</p>
<pre><code>textView?.bounds = superView.bounds
</code></pre>
<p>That should set all the properties you want to be the same as the super view.</p>
|
Inner content composite component <p>I have my composite component <code><my:panel/></code> :</p>
<pre><code><composite:interface>
<composite:attribute name="header" />
<composite:attribute name="content" />
</composite:interface>
<composite:implementation>
<div class="pan... | <p>Try <code><composite:insertChildren/></code>?</p>
<pre><code><composite:interface>
<composite:attribute name="header" />
<composite:attribute name="content" />
</composite:interface>
<composite:implementation>
<div class="panel panel-default">
<div class="pane... |
ASPNET MVC 4: User.IsInRole() always returns false <p>I can not get User.IsInRole() work. </p>
<pre><code> [HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid && WebSecurity.Login(model.UserName... | <p>You are using SimpleMembershipProvider, not Asp.Net Identity framework. <code>User.IsInRole()</code> works well with Identity, but I'm not sure if it will work with SimpleMembershipProvider. </p>
<p>I'm afraid you'll have to stick with the method that work for you: <code>Roles.IsUserInRole</code>. Unless you fancy ... |
Use result of select column subquery in the where clause of the outer query? <p>I've got a table <code>User</code> and <code>Company</code>. The User records are a child of the Company records i.e. the User table has a column <code>parent_company_id</code> indicating which company the user is a part of.</p>
<p>I want ... | <p>There are many ways to do this. But one is to use <code>cross apply</code>:</p>
<pre><code>select c.name, j.james_count
from company c cross apply
(select count(*) as james_count
from [user] u
where first_name = 'James' and u.parent_company_id = company_id
) j
where james_count > 0;
</co... |
Set cookie with button in Cakephp <p>I feel like this should be a very common thing but I can't find any info on it. I'm trying to set a cookie in CakePhp 3 from a button in a view. (The idea is that you click that to agree to terms and then the banner asking you to agree will no longer appear once the cookie is set)</... | <blockquote>
<p>But I can't figure out how to call this action from the button in the view.</p>
</blockquote>
<p>Use AJAX or create a link to that action and redirect back from there to where you came from.</p>
|
Error: d3.v4.min.js:3 Error: <rect> attribute width: Expected length, "NaN" <p>I've seen this question a few times and it usually gets resolved by fixing a typo, but I don't think I've got any typos as I only encounter errors when I load data as a csv. Script has no problems loading the same data as json.</p>
<p><div ... | <p>Remove the spaces in your CSV:</p>
<pre><code>"name","age"
"george",50
"carla",29
"bobby",18
</code></pre>
<p><code>d3.csv</code> is based on RFC 4180, which says:</p>
<blockquote>
<p>Spaces are considered part of a field and should not be ignored.</p>
</blockquote>
<p>Working plunkr: <a href="https://plnkr.co... |
Using switch statements for a playing cards program (Java) <p>I have my program figured out so far, it's just that I'm not understanding these instructions I was given (or at least understanding how to do them). </p>
<p>When I type 10, it prints out "10 of", but when I try to type <code>10S</code> for 10 of Spades, it... | <p>Your problem starts at <code>card.substring(0);</code>, which equals <code>card</code> because the substring from the start of the String. Maybe you wanted <code>card.charAt(0);</code>? But that is also wrong because <code>"10S"</code> will have three characters, two for the face value. </p>
<p>You'll need to handl... |
Python Repeat List to Max Number of Elements <p>What is the most efficient method to repeat a list up to a max element length?</p>
<p>To take this:</p>
<pre><code>list = ['one', 'two', 'three']
max_length = 7
</code></pre>
<p>And produce this:</p>
<pre><code>final_list = ['one', 'two', 'three', 'one', 'two', 'three... | <p>I'd probably use <code>iterools.cycle</code> and <code>itertools.islice</code>:</p>
<pre><code>>>> from itertools import cycle, islice
>>> lst = [1, 2, 3]
>>> list(islice(cycle(lst), 7))
[1, 2, 3, 1, 2, 3, 1]
</code></pre>
|
Keeping image aspect ratio in flex box <p>So I want to have text next to the image, and both centered. Flexbox seems like it could work well for this but the image keeps getting squished. Any ideas of how I can keep the image in its original aspect ratio?</p>
<p><div class="snippet" data-lang="js" data-hide="false" da... | <p>You will need to put the image into another container so that its intrinsic dimensions will not be affected.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.container ... |
D3 filtering root data from flare.csv for treemap <p>I have the following csv-formatted data saved into a variable called <code>csvData</code> and I'm trying to only show certain parts of it. The variable is formatted like so ...</p>
<pre><code>var csvData = 'id,value
flare,
flare.analytics,
flare.analytics.cluster,
f... | <p>Instead of <code>root.leaves()</code> you should use:</p>
<pre><code>root.children.find( e => e.id === "flare.analytics").leaves()
</code></pre>
<p>Or</p>
<pre><code>root.children.find( function(e) { return e.id === "flare.analytics";}).leaves()
</code></pre>
<p>That is, find the "analytics" child from root a... |
How to find the number of duplicate documents in solr based on a indexed field <p>I have few near duplicate documents stored in solr. Schema has a autogenerated uuid as the unique key so duplicates can get into the index. I need to get the counts of duplicated documents based on field/fields in the schema.</p>
<p>I am... | <p>jason facet query can be used to find out unique values as explained in this blog
<a href="http://yonik.com/solr-count-distinct/" rel="nofollow">http://yonik.com/solr-count-distinct/</a></p>
<p>or it can be done using collapse filter and finding the difference
q=*:*&fq={!collapse=true field=idfield} - get the n... |
Is there a way for SSRS to remember my parameters when switching between Design and Preview mode? <p>When designing a report in SSRS, I put in my parameters and run the report.
If I see that there is a change in the Design that I need to make, I then have to flick back to the Design tab and make the change.</p>
<p>Onc... | <p>There is no way for SSRS to remember the parameters when flicking between the design/preview tabs - however you could select default values for the parameters so that when you flick to the preview page, the values will automatically appear in the preview tab.</p>
<p>To do this, right click the parameter > Go to "De... |
grails 3 spring security - authentication does not working <p>I tried to update simple project from grails 2.4.2 to 3.2.0 and seems everything works except spring security.</p>
<p>The problem is that /login/auth page always redirects to /login/auth?login_error=1 even if corrected user from BootStrap.groovy trying to l... | <p>Problem was in custom login and logout gsp. New version has no compatibility, need to re-create it.
Deleting login.gsp/logout.gsp solved the issue.</p>
|
Java programming design <p>You have been asked to build a system for entering and displaying the alergies that patients may have.
The allergy will have its own set of symptoms reactions.
The allergy will also have a spectrum of severity which the clinician should be aware of, and allergies can be reported by the patie... | <p>If an <code>Allergy</code> is meant to have a "set" of symptoms, then you want some sort of <code>Symptom</code> array in your <code>Allergy</code> class. Also just to make sure that variable names are linked to their classes (so you know what you're editing), the <code>name</code> in <code>Allergy</code> should be ... |
join (wordpress) meta table with missing rows <p>using wordpress user meta, wp_usermeta. (Note there is a umeta_id unique Id in the table I'm not showing here.) I'm trying to select two values in one query so I don't have to do two separate queries. The ext_id will always exist. I want to insert the img_url if it doesn... | <p>Ahhh.. I no longer have WP installed to test it out but I suspect this query would work:</p>
<pre><code>SELECT m1.user_id
, m1.ext_id
, m2.meta_value AS img_url
FROM wp_usermeta m1
LEFT JOIN wp_usermeta m2 ON m1.user_id=m2.user_id AND m2.meta_key='img_url'
WHERE m1.meta_key='ext_id'
</code></pre>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.