input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How to add print(.....),println(..) to String scala <pre><code>def logic(n : Int):String = {
var rows = Math.pow(2,n).toInt;
var i = 0;
var str : String = "";
for(i<-0 until rows)
{
var j = n-1 ;
for(j<-(0 to n-1).reverse)
{
str+=(print((i/(Math.pow(2,j).toInt))%2)).toS... | <p><code>print</code> and <code>println</code> doesn't return a <code>String</code>, it prints to the standard output. The <code>()</code> you are seeing in the console is scala <code>Unit</code> - which is a tuple of 0 elements, since <code>print</code> and <code>println</code> return <code>Unit</code> (which is simil... |
add unicode link in site map or farsi characters? <p>i have a shop moudle in my site that it cant be inclouded in website sitemap builder , because the sitemap builder doesnt incloude it in site map.
so im making a site map for it separately my self!
there is the main problem! links in main sitemap has perisan characte... | <p>ok as long as there are many big sites like mihandownload that has url encoded urls in site map, there is no need to change the urls into regular ones for sitemaps.
but if you want it, just use this in fire fox:
tyoe about:config
search for network.standard-url and make the scape one, false </p>
|
Could not load file or assembly 'Microsoft.ReportViewer' <p>I understand how this issue is occuring, and I'm confident it's another dll, that needs an older version of 'Microsoft.ReportViewer.WebForms', and I'm guessing the 'Microsoft.ReportViewer.Common' as well.</p>
<p>Before this is marked as a duplicate, answers t... | <p>You can't use 2 versions of the same DLL in a project. It's possible that you are referencing version A of the DLL directly in your project, but that another reference <em>itself</em> makes reference to version B of the DLL. In that case, you have no choice but to either remove the reference with the reference (nest... |
FormIt troubles <p>I have a FormIt form which forks in one website, but it doesn't work at another at all (same as all forms which I have created or copypasted from the manual). If it's on the top level, it works, if it's in the some sublevel menu it doesn't.
The only thing I have found - after I try to send email the ... | <p>Do you forget to add <code><base href="[[++site_url]]"></code> tag to head of your template?</p>
|
Mock Chef::ReservedNames::Win32::Version.new in Chef unit/rspec test? [continued] <p>Assuming, I have the following recipe:</p>
<p><strong>install_iis:</strong>
</p>
<pre><code>require 'chef/win32/version'
windows_version = Chef::ReservedNames::Win32::Version.new
node.set['iis']['components'] = [
'IIS-HttpErrors',... | <p>The <code>'6.3'</code> is just a label for the fake version object. You need to tell it how to respond to methods. In this, it's pretty easy: <code>double('fake version', :windows_server_2008? => false)</code> (or <code>true</code> if you want to pretend to be true). Normally you would do this in a <code>before</... |
Create questionnaire with multiple results based on answers <p>I want to create a questionnaire in which I will ask the user 5 questions (maybe more in the future). These questions will have always 2 options and then I would like to show the results based on the different combinations.</p>
<p>Example:</p>
<p>A A B A ... | <p>This can be done with radio buttons inside of a form. Use Javascript to get the value of the radio buttons and output the result. Here is an example of how you could do one of the questions:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-cod... |
LUA : Scene not being created. What is wrong? <p>I'm building a game where I have a start screen and clicking the start button it should take me to the FIRST level. Some stuff happens and then I will be taken to the SECOND level. </p>
<p>However I'm running into problems and can't seem to find a solution.
When I click... | <p>Well, you are adding a listener <code>scene:addEventListener( "enter", scene )</code> which should be <code>scene:addEventListener( "show", scene )</code> (Change enter to show)</p>
<p>Your listener is not even being fired, because it was not added with the correct name.</p>
<p>Composer uses the following events: ... |
Running echo command without ending ";" <p>I am freaking out because I have always known that every line in PHP should end with "<code>;</code>". My question is simple: Is it possible to run the command <code>echo</code> without ending the line with "<code>;</code>"?</p>
<p>I am sorry if this is a dumb question but I ... | <p>When this:</p>
<pre><code><?php echo "Hello" ?>
</code></pre>
<p>is executed, the script <strong>ends</strong> at the <code>?></code> or simply <em>implies</em> a <strong>semi-colon</strong>. So you don't need to put a semi-colon for that.</p>
|
Listening datagram socket with any ip and any port number android <p>Hi Am sending broadcast using DatagramSocket with specific port number. Its successfully send message. But when i listening for receive message with open ip address and any port number it throwing sockettimeoutexception. But am connected with the same... | <p>Make these changes to your code:</p>
<pre class="lang-java prettyprint-override"><code>public class PacketSender implements Runnable {
@Override
public void run() {
// ...
DatagramPacket packet = new DatagramPacket(ip,
ip.length, InetAddress.getByName("255.255.255.255"), P... |
create unique file name in sas using guids <p>I am currently trying something along those lines in SAS:</p>
<pre><code>%let PartialString = %sysfunc(uuidgen());
%let OUTFILE = /SomeFolder/FileName_%SYMGET(&PartialString.).csv;
</code></pre>
<p>The second line throws errors.</p>
| <p>You don't need %SYMGET.</p>
<pre><code>50 %let OUTFILE = /SomeFolder/FileName_&PartialString..csv;
51 %put &=outfile;
OUTFILE=/SomeFolder/FileName_077e90fb-4877-67c7-9e86-b1e2779cf868.csv
</code></pre>
|
Converting Returned PHP Data into JavaScript Object <p>I have a dataset that needs to be in the same format as a JavaScript variable like below:</p>
<pre><code>var theData = {
datasets: [
{
label: "My First dataset",
backgroundColor: "rgba(179,181,198,0.2)",
borderColor:... | <p>Let's start from the top</p>
<ul>
<li><code>theData</code> is an <code>object</code></li>
<li><code>datasets</code> is an <code>array</code> of <code>objects</code></li>
<li><code>labels</code> is an <code>array</code></li>
</ul>
<p>So let's set about building this</p>
<pre><code>$data = array();
$data['datasets'... |
getJSON allways goes to fail, MVC .NET <p>I'm trying to get a JSON from my controller in ASP.Net MVC. The <code>$.getJSON</code> always goes to the <code>fail</code> function. My controller is working right. The object arrives with the correct data, and builds the JSON ok, with no incorrect data.</p>
<pre><code>public... | <p>You have some invalid JSON getting parsed:</p>
<p>"Proyecto":"proy1","â¦2,"Rentabilidad"</p>
<p>Notice that the <code>...2</code> has a double quote before it, but no double quote after it. Also, it doesn't have a property name affiliated with it.</p>
|
displaying products from database using php <p>This is a php code for displaying 3 products (from database). It displays products in a raw, but their is a fault that the first product that should appears in the very next raw is missing.</p>
<pre><code><html>
<head>
</head>
<body>
... | <p>Assign <code>$x</code> to zero. <code>$x=0;</code> </p>
<p>Complete code:- </p>
<pre><code><html>
<head>
</head>
<body>
<?php
$connect = mysqli_connect("localhost", "root", "", "shopping") or
die("Please, check your server connection.");
$query... |
Navigation Drawer - Fragments crashing <p>My app crash everytime I click on fragment (Huawai Nexus 6P, iPhone SE...) What should go wrong? Error is pasted below the picture<a href="https://i.stack.imgur.com/tPUwh.png" rel="nofollow"><img src="https://i.stack.imgur.com/tPUwh.png" alt="enter image description here"></a><... | <p>Implement your activity to OnFragmentInteractionListener. That's why, you check your context in <code>onAttact(Context context)</code> with <code>OnFragmentInteractionListener</code> . But you send activity to <code>onAttach</code> method. </p>
|
Spark transform RDD <p>I have csv file like this on imput:</p>
<pre><code>time,col1,col2,col3
0,5,8,9
1,6,65,3
2,5,8,465,4
3,85,45,8
</code></pre>
<p>number of columns is unknown
and I expect result RDD in format:</p>
<pre><code>(constant,column,time,value)
</code></pre>
<p>that means:
((car1,col1,0,5),(c... | <p>My suggetion is to use DataFrame rather than RDD for your scenario. But I tired to give you working solution which is subjected to volume of data. </p>
<pre><code> val lines = Array("time,col1,col2,col3", "0,5,8,9", "1,6,65,3", "2,5,8,465,4")
val sc = prepareConfig()
val baseRDD = sc.par... |
Optimized way to find Padovan numbers <p>What is the most optimized way to find <a href="https://en.wikipedia.org/wiki/Padovan_sequence" rel="nofollow">Padovan number</a>?
This is what I have currently.
Even though it returns correct result, I want to know what is the quickest method possible.</p>
<pre><code> l... | <p>You are doing more work than you need by using recursion. When you calculate <code>GetPadovan(42)</code> you fire off a binary tree of recursions, which will include sub-calls like <code>GetPadovan(12)</code>. That <code>GetPadovan(12)</code> will be called many times on many branches of the recursion tree. Put i... |
How to select all dates without data using JOIN SQLs in MySQL? <p>I have 3 tables, users, sites, and site_traffic, respectively. The users table contains the name of the user and other details about the user. Each user has 1 or more sites which is stored in the sites table. Now every site has its own traffic data.</p>
... | <p>I would use an anti-join pattern.</p>
<p>First, do a cross join operation between the generated list of possible dates and all sites. That gives us rows for every site, for every day. Then go ahead and do the join to the users table.</p>
<p>The trick is the anti-join. We take that set of all sites and all days, an... |
Checkbox positioning center instead of left <p>I am creating a sign in form and I added a remember me checkbox. For some reason I cannot get the checkbox to align left. It is centering in the middle of the form. Does anyone see what I am doing wrong?</p>
<p>Also, side note...why is my submit button not the same size a... | <p>You should set the <code>width</code> to <code>auto</code> and add <code>margin-left: 0</code></p>
<pre><code>#sign-in-form input[type="checkbox"] {
padding: 7px;
text-align: left;
width: auto;
margin-left: 0;
}
</code></pre>
<p>Here is the working snippet.</p>
<p><div class="snippet" data-lang="j... |
Aurelia compose element view model, configureRouter not being called <p>I have a parent view with routing (view):</p>
<pre><code><div class="render-body ${nav.hide === true?'hide':''}">
<router-view class="router-view flex"></router-view>
<div class="right-flyout ${rightFlyout.show?'show... | <p>Custom Elements don't support child routers, only pages.</p>
<p>Also, you are misusing the <code>compose</code> element here. You have a statically determined view and viewmodel, so there is no need to use the <code>compose</code> element.</p>
|
Find missing data indices using python <p>What is the optimum way to return indices where 1-d array has missing data. The missing data is represented by zeros. The data may be genuinely zero but not missing. We only want to return indices where data is zero for more than or equal to 3 places at a time. For example for ... | <p>Keep track of the count of zeros in the current run. Then if a run finishes that has at least three zeros calculate the indexes.</p>
<pre><code>def find_dx_of_missing(a):
runsize = 3 # 3 or more, change to 4 if your need "more than 3"
zcount = 0
for i, n in enumerate(a):
if n == 0:
... |
post file from HDFS using Curl <p>How can I post a file from HDFS using Curl ?</p>
<pre><code>curl --data-binary @/user/file.txt 'http://127.0.0.1/update'
</code></pre>
<p>this works but now I have put my file in HDFS are they any way to use curl to post the file in hdfs</p>
| <p>You can use HDFS REST APIs to do this. Refer <a href="http://hadoop.apache.org/docs/r2.7.2/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Create_and_Write_to_a_File" rel="nofollow">this</a>.</p>
|
Updating specific columns not all model entities <p>Zend 1.8 Geeks!</p>
<p>I always use model_mapper to update insert and fetch data from the db by this example :</p>
<pre><code> $a=somthin;
$y=qwe;
$dataMapper = new model_mapper_data();
$dataModel = new model_data();
$dataEntity=$dataModel->A... | <p>Well all what you need is to not give the update method the model entity Since the model initialize objects for all of the columns .</p>
<p>Just give it an array of the columns names you would like to modify and Pair them to their values like below :</p>
<pre><code>Mapper->update('column_name'=>value);
</cod... |
Solving normal equation gives different coefficients from using `lm`? <p>I wanted to compute a simple regression using the <code>lm</code> and plain matrix algebra. However, my regression coefficients obtained from matrix algebra are only half of those obtained from using the <code>lm</code> and I have no clue why.</p>... | <p><code>lm</code> is not performing standardization. If you want to obtain the same result by <code>lm</code>, you need:</p>
<pre><code>X1 <- cbind(1, X) ## include intercept
solve(crossprod(X1), crossprod(X1,Y))
# [,1]
#[1,] 4.2222222
#[2,] 1.0000000
#[3,] -0.3333333
#[4,] 1.0000000
#[5,] 0.66666... |
Select2 not displayed when added dynamically for the first time <p>I am working with Jquery and I have a use case to add some elements dynamically on a button click.</p>
<p>While adding the 'select' dynamically, the select2 is not displayed when the add button is clicked for the first time, instead, a simple 'select' ... | <p>Select2 doesn't work on Dom fragment because it needs to bind on document object to work.You are creating a dynamic div <code>container</code> and populating it with more dynamic html and selects when you call <code>select2</code> on selects your dynamic div is still hasn't been yet attached to document.You need to ... |
Bootstrap modal - Prevent shift AND background scroll <p>I was having trouble to prevent background shifting when bootstrap modal opened. I added the following classes to my css:</p>
<pre><code>.modal {
overflow-y: auto !important;
}
.modal-open {
overflow: auto !important;
}
</code></pre>
<p>It worked, but now b... | <p>Solved it using the css like this:</p>
<pre><code>body.modal-open {
overflow-y: scroll !important;
margin: 0 !important;
}
.modal {
overflow: auto !important;
}
</code></pre>
|
What's best MVC to use with react? <p>Like we all know React is just a V in MVC.So If I wanna use the complete MVC with react,what is the best possible technology that I can consider?</p>
| <p>You may want to explore <a href="https://facebook.github.io/flux/docs/overview.html" rel="nofollow">Flux</a> and <a href="https://github.com/reactjs/redux" rel="nofollow">Redux</a> if you're looking for a pattern or framework to design and structure your application.</p>
|
Visual Studio 2013 Conditional Breakpoint fails to evaluate <p>Visual Studio 2013 conditional breakpoint fails to evaluate. </p>
<blockquote>
<p>The condition for a breakpoint failed to execute. .... Evaluation of native methods in this content is not supported.</p>
</blockquote>
<p>Yet the Quick Watch will evalua... | <p>Right click your project in the solution explorer and select <code>Clean</code> command then rebuild the project with break point</p>
<p>Also make sure both project and solution is in debug mode</p>
|
transfer click event from one page to another in javascript <p>I am trying to transfer click event from a page to another page using javascript. I have a div with a click event on page A and this is the div</p>
<p><strong>HTML:</strong></p>
<pre><code><div class="play">Play Sound</div>
<div class="paus... | <p>you can use socket or local storage. local storage fires an event when other tabs makes changes. check this answer <a href="http://stackoverflow.com/questions/2236828/javascript-communication-between-tabs-windows-with-same-origin/12514384#12514384">Javascript; communication between tabs/windows with same origin</a><... |
How would I go about inserting values that affect multiple tables? <p>My schema is this:</p>
<pre><code>Tables:
Titles -> ID | TitleID | TitleName | ArtistNameFull | Length
Artists-> ID | ArtistNameRoot
ArtistRelation-> ID | TitleID | ArtistID | Relationship
</code></pre>
<p>ArtistNam... | <p>PHP is much better than SQL at manipulating strings. So keep doing that. Also using the temp table is a valid method. </p>
<p>You will need to use PHP to pull all of the data from the temp table. </p>
<p>For each result parse out the artist name and insert it into artists. </p>
<p>After each insert you want to ge... |
No Module name Yum in Ansible Error on vagrant <p>I am running Ansible on Ubuntu Vagrant machine. I have written a simple playbook named examyum.yml as follows:</p>
<pre><code>---
- hosts: local
tasks:
- name: Installing packages
yum: name=httpd state=latest
sudo: yes
</code></pre>
<p>When I run </... | <blockquote>
<p>I am running Ansible on Ubuntu Vagrant machine.</p>
</blockquote>
<p>So why do you use <code>yum</code> and not <code>apt</code> module first of all?</p>
<p>If you still need <code>yum</code> module for some reason, ensure that <code>yum</code> python package is installed on the managed host.</p>
|
How to count local variable indexes in MethodVariableAccess? <p>According to [1], in a method frame, the local variable array contains a reference to the called instance, the parameters and, finally, any other variables used in the method's code. Also, <code>long</code> and <code>double</code> values occupies two local... | <p><code>MethodVariableAccess.OffsetLoading</code> accesses an offset which is not named index to distinguish exactly that. If a <code>long</code> or <code>double</code> type is contained in the array, this accounts to two slots. Byte Buddy uses this abstraction to interact with ASM where the same offset is required fo... |
Combine content from 2 files Programming In C <p>I would like to combine contents from 2 files. but i unable to do it.</p>
<p>My output seem like </p>
<pre><code>Username: admin
Password: password123
Username: admin
Password: password456
Username: admin
Password: password789
Username: admin
Password: p@ssw0rd
Use... | <p>You need to rethink your loop. I think you want something like this:</p>
<pre><code> while((fgets(user , 100 , fpUser) != NULL) &&
(fgets(pass , 100 , fpPass) != NULL))
{
printf("Username: %s", user);
printf("Password: %s\n", pass);
}
}
return 0... |
ExecuteReader requires an open and available Connection,The connection's current state is closed <blockquote>
<p>Server Error in '/' Application. ExecuteReader requires an open and
available Connection. The connection's current state is closed.
Description: An unhandled exception occurred during the execution of
... | <p>Your connection is not open. You need to call </p>
<pre><code>cmdGetStudentNo.Open();
</code></pre>
<p>before you start using it</p>
|
Anyone tried using IgniteRDD/IgniteSQL of accessing Spark datasets using Scala? <p>We have a need to share the RDDs across multiple sessions. I see option of using Java to access Ignite RDD/Ignite SQL of accessing Spark datasets. Anyone tried using IgniteRDD/IgniteSQL of accessing Spark datasets using Scala.</p>
| <p><code>IgniteRDD</code> is a Scala class and Scala is fully supported by Ignite.</p>
|
tup SQL reset error: database is locked <p>Just installed tup on ubuntu 16.04 and got the following error: </p>
<pre><code>$ tup init
.tup repository initialized.
SQL reset error: database is locked
Statement was: commit
</code></pre>
<p>Also tup upd has error as well.</p>
<pre><code>$ tup upd
.tup/shared: ... | <p>according to multiple other questions/answers on stackoverflow, you are not supposed to use sqlite3 on a network drive. So by association, you should not use tup on a network drive.</p>
|
Dynamically resize drop down width when bolded <p>I have a very simple drop down list such as this:</p>
<pre><code><select>
<option selected="selected" value="MyVeryFirstLongValue">MyFirstLongestValue</option>
<option value="MyVerySecondLongValue">MySecondLongValue</option>
</s... | <p>I can reproduce it only in chrome</p>
<p>It could be an option to have bold options also:</p>
<pre><code>select,option{
font-weight: bold;
}
</code></pre>
|
JS can't delete all images from page <p>I'm trying to delete all images from page. The page is in HTML. This is my HTML button: </p>
<pre><code><input id="clickMe" type="button" value="Delete Images" onclick="click();" />
</code></pre>
<p>And the function is:</p>
<pre><code><script type="text/javascript">... | <p>Removing a child can only be done from the parent:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function removeImages() {
var images = [].slice.call(document.getEle... |
Angular ng-pattern regex validation using scope data <p>I'm pretty new at Angular, so forgive me if I'm asking or looking at this the wrong way, but I'm trying to dynamically build a form from fields in a database. When the page loads, I'm pulling data from the database and assigning those values to the scope in the Co... | <p><code>NgPattern</code> expect it's value to be a <code>Regex</code> parseable expression.</p>
<p>According to <a href="https://docs.angularjs.org/api/ng/directive/ngPattern" rel="nofollow">angularjs ngPattern</a> docs:</p>
<blockquote>
<ul>
<li>If the expression evaluates to a RegExp object, then this is used ... |
Scrapy opening html in editor , not browser <p><a href="https://i.stack.imgur.com/LWxmP.png" rel="nofollow"><img src="https://i.stack.imgur.com/LWxmP.png" alt="enter image description here"></a></p>
<p>I am working on some code which returns an <code>HTML</code> string (<code>my_html</code>). I want to see how this lo... | <p>Look at how the <a href="https://github.com/scrapy/scrapy/blob/129421c7e31b89b9b0f9c5f7d8ae59e47df36091/scrapy/utils/response.py#L63" rel="nofollow"><code>open_in_browser()</code></a> function is defined:</p>
<pre><code>if isinstance(response, HtmlResponse):
if b'<base' not in body:
repl = '<head&... |
How to affect the change in the original input box? <p>I have made an input box and i have cloned this input box to a div,let's name them ipbox1 and ipbox2, ipbox2 is the copy of ipbox1 now what i want to do is that when
i enter/change the value in either of them, the dom.value or $("#id").val() should return the updat... | <p>If you want to be able to read the value of either of them independently, then check out this <a href="https://jsfiddle.net/s6td1bof/2/" rel="nofollow">fiddle</a> </p>
<p>If not, then I must be offtrack. Please add more details about what you need to achieve :)</p>
<p>HTML</p>
<pre><code><input type = "text" c... |
Android request often fails when app is in background <p>The request throws java.net.SocketTimeoutException: connect timed out.
I use IntentService for executing the request.
I set all the timeouts to 85 seconds. Background data is enabled on the app settings. Power saving mode is off. Data limit is off.
The request is... | <p>While I would say to try a proper Service instead of an IntentService, you can achieve this with the following code. Now the only drawback is that you will need to stop it manually with stopSelf at some part of your code.
Also, you can try setting the OkHttpClient builder retryOnConnectionFailure to true.</p>
<pre>... |
Is there an equivalent function to get index of element in an array like using index to get position within a string? <p>I was hoping the the <code>index</code> function would work since Perl makes no distinction between a number and a string of numeric characters, having used index successfully on strings, but it did ... | <p>The <a href="http://perldoc.perl.org/functions/index.html" rel="nofollow"><code>index</code> builtin</a> takes a string, a substring and an optional position as its arguments. Passing an array won't search the array.</p>
<p>If you want to check for the first occurrence of <code>$sortedSeq[$i]</code> in each element... |
Jquery Data attribute selector not working <p>I have this element </p>
<pre><code><div class="messages selected" data-conversationId=""></div>
</code></pre>
<p>The <code>data-attribute</code> <code>conversationId</code> is set dynamically like so:</p>
<pre><code>$(".messages").data("conversationId", conv... | <p>If you set your dynamic attribute via jquery's .data() you will have the above problem.</p>
<p>However, if you set the dynamic attribute via jquery's .attr() method, you won't have this problem</p>
<p>Example here: <a href="https://jsfiddle.net/6dn5wjL8/8/" rel="nofollow">https://jsfiddle.net/6dn5wjL8/8/</a></p>
... |
loop optimization in c# <p>I am working on a music player for pc using c# and all seems to go fine but, i have problem in loading all the music files from the music directory because it loads very slowly and this take time when opening the app, it could take 5 min depending on the amount of music files. I think this ha... | <p>You could try replacing your loop with a parallel foreach loop using background threads - add each item to the UI as it is processed, and let .Net determine the most efficient way to process everything. If you do it right, your UI will remain responsive, and your users will start out with "enough to look at..." He... |
UWP C# Scroll to the bottom of TextBox <p>How do you scroll to the bottom of a TextBox for a UWP app?</p>
<p>With my transition to UWP, this has been one of the questions that hasn't been straight-forward.</p>
<p>I used to be able to use this:</p>
<pre><code>textBox.SelectionStart = textBox.TextLength;
textBox.Scrol... | <p>If anyone needs to scroll to the bottom of a TextBox in UWP apps:</p>
<p><a href="https://code.msdn.microsoft.com/windowsapps/How-to-scroll-to-the-a8ea5867" rel="nofollow">https://code.msdn.microsoft.com/windowsapps/How-to-scroll-to-the-a8ea5867</a></p>
<pre><code>private void TextBox_TextChanged(object sender,... |
how to set a color for check box in angularjs with css <p>here is my code. Please find a solution for this. </p>
<pre><code> <div class="list">
<ul class="items-list">
<li ng-repeat="listService in servicesList">
<input type="checkbox" ng-model="listService.sel... | <p>ng-class is what your looking for: </p>
<pre><code> <ANY class="ng-class: expression;"> ... </ANY>
</code></pre>
<p>And the expression can be a css class</p>
|
Basic explanation needed while using while loops and arrays <pre><code>// ConsoleApplication27.cpp : Defines the entry point for the console application.
</code></pre>
<p>//</p>
<pre><code>#include "stdafx.h"
#include "stdio.h"
#include <string.h>
void main()
{
char couples[5][50] = { "John Nora", "Paul Kath... | <p>Each row of 'couples' can be treated as a string (i.e a character array) consisting of two names - one male, one female - separated by a single space character. The 'while' loop is copying the male name of the pair into the separate array 'male', one character at a time. The intended action of the 'while' loop is ... |
Is it possible to commit a file to a remote base repository using JGit <p>My requirement is that I want to programmatically commit a file to a remote base repository (that resides in a central location like <code>https//:myproject.git</code>). </p>
<p>I would like to know if it is possible to commit a file to a remote... | <p>As <a href="http://stackoverflow.com/users/147356/larsks">@larsks</a> already pointed out, you need to first create a local clone of the remote base repository. Changes can only be committed to the local copy of the base repository. Finally, by pushing to the originating repository, the local changes are made availa... |
Querying a document in Mongo using DateTime C# <p>I have a mongo document with DateTime like this: </p>
<pre><code>"_id" : "58064346e74f22124037a607",
"DateEffective" : "2016-10-18T15:44:01.083Z",
</code></pre>
<p>In my C# code I want to query my collection for any document that it's DateEffective is before today... | <p>As per your document "DateEffective" is not a date, it is string. In string key less than will not work. So change your "DateEffective" to date format</p>
<p>the document should in this format </p>
<pre><code>{
"_id" : ObjectId("58064346e74f22124037a607"),
"DateEffective" : ISODate("2016-10-18T15:44:01.083... |
Is it possible for Regex.Match() to return null? (C# .Net framework 3.5?) <p>Is it possible that regex.Match in the (much simplified) code below can ever return null? </p>
<pre><code>Regex regex = new Regex(pattern);
Match m = regex.Match(input);
</code></pre>
<p>My static analysis tool complains without a null check... | <p><a href="https://msdn.microsoft.com/en-us/library/twcw2f1c(v=vs.110).aspx" rel="nofollow">Documentation</a> is your friend here:</p>
<blockquote>
<p><em>Return Value</em></p>
<p>Type: <a href="https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.match(v=vs.110).aspx" rel="nofollow">System.... |
Using "spring-security-oauth2," can custom parameters be passed in the "Authorization Phase" of OAuth2? <p>I am implementing the <strong>Authorization Code</strong> flow + <strong>JWT</strong>.</p>
<p>I would like to know if and how it may be possible to add additional custom parameters to the <em>Authorization Phase<... | <p>My idea is add your parameter during <em>AuthorizationRequest</em> in custom <em>OAuth2RequestFactory</em> at <em>createAuthorizationRequest</em> method like <a href="http://stackoverflow.com/questions/31345466/mapping-user-roles-to-oauth2-scopes-authorities">here</a>: </p>
<pre><code>@Override
public Authorization... |
Efficient way to reverse three consecutive subranges [A,B,C] -> [C,B,A] <p>I've got an array [A,B,C] consisting of three consecutive sub-arrays A, B and C. I'd like to reverse the larger array into [C,B,A]. My current attempt involves thee calls to <code>std::rotate</code>, as shown below. I wonder if there is a more s... | <p>Reverse the whole array then reverse each subarray.</p>
<pre><code>[1,2,3|4,5,6|7,8,9]
[9,8,7|6,5,4|3,2,1]
[7,8,9|4,5,6|1,2,3]
</code></pre>
<p>This will take two linear passes and is extremely CPU cache friendly.</p>
|
Initializer for conditional binding must have Optional type, not '[String]' - Xcode 8.0 Swift 3.0 <p>I am creating a function that allows me to create a array on VC1 and then I can transfer over the array using "prepare for segue" to VC2. On VC2 I can append an item to the array in VC2 and then transfer over the array ... | <p>It's telling you that, since <code>receivedString</code> is not an optional type, the <code>if let</code> doesn't make sense. You've created it as an array of strings and that's what it's always going to be.</p>
<p>Even if the array is empty, it will still evaluate as an array.</p>
|
Javascript HTTP client library <p>Does anybody know how to create a JavaScript command line Application that consumes a public API using a HTTP client library?</p>
<p>Which JavaScript http library should I use?</p>
| <p><a href="https://www.npmjs.com/package/request" rel="nofollow">request</a> will do the job. <a href="https://www.npmjs.com/package/xhr2" rel="nofollow">xhr2</a> also provides a nice <code>XMLHttpRequest</code> emulation for Node applications.</p>
|
Flexbox not taking the full height of the wrapper <p>I have a problem with my side flexbox, which is not taking the full height of the site. </p>
<pre><code>.aside-1 {
padding: 10px;
font-size: 18px;
flex: 1;
height: 100%;
}
</code></pre>
<p>I tried to set the height to 100% but wi... | <pre><code>.aside-1 {
padding: 10px;
font-size: 18px;
flex: 1;
height: auto;
}
</code></pre>
<p>will do the tricks</p>
|
Google Maps API heatmap, object array not working <p>I am trying to create a heatmap using imported data from a csv file. My csv data seems to import fine but once I try to pass the object to an array (to be used in my heatmap) something goes wrong and my heatmap is not printed to the screen.</p>
<p>Here is what I ha... | <p>You have two issues with your code.</p>
<ol>
<li>the geocoder is asynchronous, you are calling the <code>heatmapper</code> function before the responses come back from the service and the <code>heatcorarr</code> is populated.</li>
</ol>
<pre><code>function nextAddress() {
address_index++;
if (address_index &... |
set ActiveX checkbox properties with VBA word 2010 <p>I have searched high and low for this, but no luck.</p>
<p>To create a checkbox:</p>
<pre><code>Selection.InlineShapes.AddOLEControl ClassType:="Forms.CheckBox.1"
</code></pre>
<p>However, there are several properties associated with a checkbox, and I wanted to f... | <p>For anyone with the same issue</p>
<pre><code>'to place it in the table, assuming only 1 table, and in this example the checkbox is placed in the second Row, first Column
ActiveDocument.Tables(1).Cell(2, 1).Select
Set myOB = Selection.InlineShapes.AddOLEControl(ClassType:="Forms.CheckBox.1")
With myOB.OLEFormat
.A... |
Bitmap from a whole Windows Form <p>In my Visual Studio 2015 Project I have a Form (tabPage) that is bigger as the screen, so one have to scroll. How can I draw the whole Form (not only visible area) into a bitmap?</p>
<pre><code>Bitmap bitmap = new Bitmap(tabPage1.Width, tabPage1.Height);
tabPage1.DrawToBitmap(bitmap... | <p>Looks very similar to the question asked here:</p>
<p><a href="http://stackoverflow.com/questions/6001576/saving-panel-as-jpeg-only-saving-visible-areas-c-sharp">Saving Panel as JPEG, only saving visible areas c#</a></p>
<p>Here is the accepted answer from this post:</p>
<blockquote>
<p>Try following</p>
<pre>... |
Why can't I access EOF using fseek()? <pre><code>#include <stdio.h>
int main()
{
FILE * fp = fopen("Introduce.txt","rt");
fseek(fp,0,SEEK_END);
int i = feof(fp);
printf("%d",i);
fseek(fp,1,SEEK_END);
i = feof(fp);
printf("%d",i);
fseek(fp,-1,SEEK_END);
i = feof(fp);
pri... | <p>The <code>feof()</code> function doesn't report that it is at EOF until you try to read some data and there is no data to read.</p>
<p>You can seek beyond the current EOF of a file that's open for writing (or that's open for reading and writing).</p>
<p>See <a href="http://stackoverflow.com/questions/5431941/while... |
Need Output on a Sql Queries <p>I have a Sql table:</p>
<pre><code>PLAN_CD PLAN_NM CLASS
D01501 DENTAL AA
D01501 DENTAL AB
D01501 DENTAL AC
V01501 VISION AA
V01501 VISION AB
</code></pre>
<p>Output should be:</p>
<pre><code>PLAN_CD PLAN_NM
D01501 DENTAL,AA,AB,AC
V01501 VISION,AA,AB
</code></pre>
| <p>Following 2 Questions might help you:</p>
<p><a href="http://stackoverflow.com/questions/273238/how-to-use-group-by-to-concatenate-strings-in-sql-server">How to use GROUP BY to concatenate strings in SQL Server?</a></p>
<p><a href="http://stackoverflow.com/questions/15154644/group-by-to-combine-concat-a-column">GR... |
How to override "WebKit Built in pdf" of safari 10 with adobe pdf? <p>I want to override "webkit built in pdf" of safari 10 with adobePDFViewer.plugin, so that navigator.plugins in JavaScript could detect adobePDFViewer Plugin instead of "WebKit Built in pdf"</p>
<p>here what i am getting plugin array from navigator.p... | <p>Hello Every one i found answer to this solution myself...!
As of now Safari and other latest browsers and Firefox restricts enumeration via navigator[] array of objects, which means that it does not allow plugins to content enumerating navigator.plugins[]. This change does not disable any plugins; it just hides some... |
Why does Rust need to return static sizes? <p>I thought one of the big features of Rust is being a systems language comparable to C but with a garbage collector. If this is the case, why do you need to return values of a static size (or use <code>Box</code> from what I gather)?</p>
| <blockquote>
<p>Why does Rust need to return static sizes?</p>
</blockquote>
<p>Every value in every language needs to have a static size. That's how the compiler / interpreter / runtime / virtual machine / hardware knows how to access the bits that make up the value.</p>
<p>In many languages, every value is compar... |
c++ temp object created? <p>I would like to know how this code works. </p>
<pre><code>class Room
{
int sqft;
public:
Room(int k)
{
sqft = k;
}
int add(Room r)
{
return r.sqft + sqft;
}
};
int main()
{
Room living = Room(400);
Room Kitchen = Room(250);
Room Bedroo... | <p>Yes it's true, since you declared a constructor that takes an <code>int</code> parameter, the compiler will implicitly convert an <code>int</code> to a <code>Room</code>.</p>
<p>You fix this by declaring the constructor to be explicit, then the compiler will no longer do an implicit conversion but will require you ... |
Is there a way to use itertools in python to clean up nested iterations? <p>Let's say I have the following code:</p>
<pre><code>a = [1,2,3]
b = [2,4,6]
c = [3,5,7]
for i in a:
for j in b:
for k in c:
print i * j * k
</code></pre>
<p>Is there a way I can consolidate an iterator in one line instead of maki... | <p>Use <code>itertools.product</code> within a list comprehension:</p>
<pre><code>In [1]: from itertools import product
In [5]: [i*j*k for i, j, k in product(a, b, c)]
Out[5]:
[6,
10,
14,
12,
20,
28,
18,
30,
42,
12,
20,
28,
24,
40,
56,
36,
60,
84,
18,
30,
42,
36,
60,
84,
54,
90,
126]
</code>... |
Unable to set property 'src' of undefined or null reference <p>I am trying to use a button to change a picture on my webpage. When assigning a new value to the <code>src</code> attribute I have below error</p>
<blockquote>
<p>Unable to set property 'src' of undefined or null reference</p>
</blockquote>
<p>My code i... | <p>You can fix it by not making up your own HTML tags. <code><id></code> is not a valid html tag, period. ID is an <strong>ATTRIBUTE</strong> for a tag, it is not tag itself:</p>
<pre><code><img id="navImg" ...>
</code></pre>
<p>And even if it WAS a tag, you'd be setting the <code>src</code> of the <code>... |
Spring Boot @ModelAttribute include other model using string key <p>I'm a spring newbie.</p>
<p>I have a Model like below.</p>
<pre><code>User {
@Id
@GeneratedValue
private Integer id;
}
PowerUser {
@ManyToOne
private User user;
private Integer point;
}
Controller {
registerPowerUser(@M... | <p>The problem was repository.</p>
<pre><code>public interface UserRepository extends JpaRepository<User, Integer> {
</code></pre>
<p>to</p>
<pre><code>public interface UserRepository extends JpaRepository<User, String> {
</code></pre>
<p>works well.</p>
|
imgurpython.helpers.error.ImgurClientRateLimitError: Rate-limit exceeded <p>I have the following error:</p>
<pre><code>/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropr... | <p>The rate limit refers to how frequently you're hitting the API, not how many calls you're allowed. To prevent hammering, most APIs have a rate limit (eg: 30 requests per minute, 1 every 2 seconds). Your script is making requests as quickly possible, hundreds or even thousands of times faster than the limit.</p>
<p>... |
I am unable to break a loop that repeatedly asks for user input. Anyone know how to solve this? <p>I am trying to create a loop that will ask the user for an integer and will then print "hi" an integer number of times and then ask for input again. I then want the loop to break if the user inputs "bye". </p>
<p>my code... | <p>Try</p>
<pre><code> break if gets.chomp == "bye"
</code></pre>
<p>This is so because your input would be something like <code>bye\n</code>, so your condition always false, because <code>gets</code> takes even the enter.</p>
|
VBA - Split and IsError Function <p>I'm struggling with VBA code. I'm working on a ID code generator program. One of the processes involves Split Company Names by words, and taking the first two words. Split has proved to be useful in this tasks, however, when in dealing with Company Names shorter than 2 words I've got... | <p>Arr_text will be a zero-based array - UBound(Arr_text) will give you the upper bound of that array (zero if one item, one if two items, etc)</p>
<pre><code>Public Function idcode_2(text As String) As String
Dim Arr_text As Variant, rz2
Arr_text = Split(text, " ", 3)
If UBound(Arr_text ) > 0 Then
... |
Can't execute sql file <p>I'm trying to execute the following code using isql:</p>
<pre><code>IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'SFPTB051_ABERTURARCLH'))
BEGIN
SELECT * FROM SFPTB051_ABERTURARCLH;
END
</code></pre>
<p>The way i'm doing:</p>
<pre><code>isql -i sql_scripts/tes... | <p>Usually, select statements within a block statement need to return their values. For example, you can return them into variables or return values, which are almost the same.</p>
<p>Furthermore, every statement within a block statement has to be terminated by a semi-colon (<code>;</code>).</p>
<p>Your block stateme... |
Converting a recursive method into a non-recursive method using loop in java <p>So I'm currently making a game where the instructions are to move left or right within an array using the integer stored at a marked index (circle in this case) until we can get the circle to the last index of the array. The last integer of... | <p>The most important bit: when debugging app for the slowness, you should <strong>collect some performance data first</strong> to identify where your app is spending the most of its time. Otherwise fixing performance is inefficient. You can use <code>jvisualvm</code> it's bundled with jdk.</p>
<h1>Data structures rul... |
get index in multidimensional array in javascript <p>This question is follow up for,
<a href="http://stackoverflow.com/questions/40111302/get-the-index-of-a-multidimensional-array-with-the-value-of-a-given-string-in-ja">Get the index of a multidimensional array with the value of a given string in javascript</a></p>
<p... | <p>I have to agree with @Rob M.'s comment yet still you might do as follows;</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var a1 = [["present",["John","Josh","Jay"]],[... |
SOAP to Rest Service Using Adapter <p>I have a legacy project where it has SOAP webservices exposed. Now I have a requirement to convert them to rest and use it accordingly. </p>
<p>Can I have implementation like Jersey available to consume these soap services and then publish the same as REST?</p>
| <p>This is a common problem when dealing with legacy APIs. Since REST is not a protocol by definition you can implement either:</p>
<ul>
<li><p><strong>Protocol Bridging Pattern</strong>. It is a common SOA pattern that helps you transform between different protocols by using a bridging broker as intermediary. The bro... |
How to add additional tick labels, formatted differently, in matplotlib <p>I'm having real problems plotting a 2nd line of tick labels on x-axis directly underneath the original ones. I'm using seaborn so I need to add these extra labels after the plot is rendered.</p>
<p>Below is <a href="http://content.screencast.co... | <p>One possibility would be to create a second x-axis on top of the first, and adjust the position and xtickslabels of the second x-axis. Check <a href="http://matplotlib.org/examples/axes_grid/demo_parasite_axes2.html" rel="nofollow">this example</a> in the documentation as a starting point.</p>
|
How to known the level of current page in Django-CMS <p>my page.html has this</p>
<pre><code>{% extends "base.html" %}
{% load cms_tags menu_tags %}
{% block title %}{% page_attribute "page_title" %}{% endblock title %}
{% block content %}
{% placeholder "content" %}
{% show_menu 2 0 0 100 %}
{% endblock content... | <p>I do something like this to select a relevant page title based on the ancestry of the page;</p>
<pre><code>{% if request.current_page.get_ancestors|length <= 1 %}
<h1 class="pipe-title pipe-title--inset">
{{ request.current_page.get_page_title }}
</h1>
{% else %}
{% for ance in re... |
Activity to Fragment on button click <p>I have navigation bar on my app. Using that has created fragments. I added regular activities to the app and I have found how to go from a Fragment page to an activity page with using the onclick method. </p>
<p>By the click of a button I want to go from an activity page to a fr... | <p>If you want to close the current activity to go back to your Fragment-container Activity you may call the finish() method or onBackPressed() method (in case you're not overriding it).</p>
<hr>
<p>If you want to bring a fragment to the current activity you must have a fragment container and attach it with:</p>
<pr... |
java get web content for many webpages <p>So previously I had a program that would go to a lot of websites and get part of the source code out of those websites that I wanted. However recently the websites have been updated to now load the information I want dynamically, and I no longer get it. </p>
<p>I have made ano... | <p>It seems your are trying to get the page source. There's a method for that in selenium. You may use it instead of your </p>
<pre><code>getSource("http://www.google.com");
</code></pre>
<p>Create an WebDriver instance and navigate to your url and get the page source.</p>
<p><strong>Code snippet:</strong></p>
<pre... |
Ajax not returning results <p>Alright so I have this code which basically finds the user inside the table users and displays it in alert, but it seems that I am doing something wrong. The log shows "Function is not set" and the alert itself displays that.</p>
<p>This is the HTML form I have for it</p>
<pre><code><... | <p>It sounds like you're using a version of jQuery before 1.9.0. The <code>method:</code> option didn't exist in the older versions, it was called <code>type:</code>. That's why you're seeing the parameters appended to the URL, because <code>type: "GET"</code> is the default.</p>
<p>So change</p>
<pre><code>method: "... |
Displaying component with @Input in another component's router-outlet <p>I wanted to know if you guys know a way to display components that take a @Input directive inside of a router-outlet.</p>
<p>I have several components that takes in @Inputs and I would like to display these components dynamically in one component... | <p>As this <a href="http://stackoverflow.com/a/34648272/7038491">POST</a> states it is currently not possible. </p>
<p>Here is the <a href="https://github.com/angular/angular/issues/4452" rel="nofollow">linked issue</a> on Github</p>
<blockquote>
<p>Use a shared service to communicate with components added by the r... |
How to add a new column or table to sqlite database pre-populated in the assets and using SQLiteAssetHelper <p>How can I add a new column or new table to the database that pre-populated (in the assets) using SQLiteAssetHelper.
I originally preload a simple table with 3 columns:</p>
<ul>
<li>id</li>
<li>question</li>
... | <p>Hi you can use onUpgrade </p>
<pre><code>public class OpenHelper extends SQLiteOpenHelper {
private final static int DB_VERSION = 2;
public TracksDB(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
//....
... |
python: could not convert string to float <p>im submitting this code..</p>
<pre><code>a = float(input())
b = float(input())
c = float(input())
if abs(b - c) < a < (b + c) and abs(a - c) < b < (a + c) and abs(a - b) < c < (a + b):
print("Perimetro = " + str(a + b + c))
else:
print("Area = " +... | <p>The issue is that you are entering all the three values at once. Add one value and then press enter. For example:</p>
<pre><code>>>> a = float(input())
6.0
>>> b = float(input())
4.0
>>> c = float(input())
2.0
>>> a, b, c
(6.0, 4.0, 2.0)
</code></pre>
<p>OR, get the single strin... |
How do I switch to the new color map in matplotlib 1.5? <p>I want to write a line to switch all my plots to the new color map (viridis), how do I do that?</p>
<p>There's a lot of information on the new available colors <a href="http://matplotlib.org/users/colormaps.html" rel="nofollow">http://matplotlib.org/users/colo... | <p>In matplotlib, the "styles" control much, much more than just the colormap.</p>
<p>To configure one aspect of the style on the fly, use:</p>
<pre><code>import matplotlib
matplotlib.rcParams['image.cmap'] = 'viridis'
</code></pre>
<p>In the forthcoming v2.0 release of matplotlib, viridis will be the default colorm... |
Problems with reversing line into file <p>This code does reverse and put result in file, but not fully correct.
Like, some issues with detecting line breaker or sth. Here's an example:</p>
<p>Source:</p>
<pre><code>This is a line.
This is another line.
Quick brown fox jumps over a lazy dog!
</code></pre>
<p>Result:<... | <p>A couple of comments/nitpicks, which may or may not solve your problem :)</p>
<pre><code>if (!str || !(*str))
return NULL;
</code></pre>
<p>Don't do that. Don't return NULL on empty strings, fputs() will barf. In my experience, it's better to a) assert that the str pointer is non-null, b) return the empty stri... |
How to apply a PropertyChanges on a property named "target" <p>Here's an example <code>State</code> and <code>PropertyChanges</code> from the docs:</p>
<pre><code>State {
name: "resized"; when: mouseArea.pressed
PropertyChanges { target: rect; color: "blue"; height: container.height }
}
</code></pre>
<p>The o... | <p>With a little tweak, this is no problem.
If you can't alias it at the targetobject creation yourself, do it in the states like so:</p>
<pre><code>Rectangle {
id: rect
property int target: 20
x: target
y: target
width: target
height: target
color: 'orchid'
states: State {
id:... |
If statement in foreach loop char check <p>I need to only run the foreach on iterations that find a currency symbol. Currently, I have this -</p>
<pre><code>$transferid = $key;
$donation1 = $value["news"];
$donationcomma = getStringBetween($donation1,$from,$to);
$donation = str_replace(',', '', $donationcomma);
$playe... | <p>from what i understand, you could do something like this :<br></p>
<pre><code><?php
foreach($values AS $key=>$value) {
if(preg_match('/^(\$)(.+)/', $value) == 1) {
$transferid = $key;
$donation1 = $value["news"];
$donationcomma = getStringBetween($donation1,$from,$to);
$do... |
C# naming array names on the fly <p>I am trying to create a two dimensional array of random 1 and 0. These will be used to switch on or off I/O lines on an Arduino. The number of arrays (<code>height</code>) to create will come from a textbox on the UI as will the number of items (<code>width</code>) in each array. </p... | <p>Instead of trying to dynamically create variables and then add them into the array just at the end of each outer loop iteration set the value of that array:</p>
<pre><code>int[][] array = new int[height][];
for (int i = 0; i < height; i++)
{
int[] innerArray = new int[width];
for (int j = 0; j < width... |
Profiling *every* function call? <p>You may wonder why I would want to do this. I'm trying to debug PHP performance on an embedded system. Don't have access to any kind of tools on the device.</p>
<p>I was thinking if I could just do a simple <code>microseconds</code> calculation on every call, it would work.</p>
<p>... | <p>You can use <code>declare(ticks=1000);</code> to run an callback, like: </p>
<pre><code>// you can use this:
declare(ticks=1);
// A function called on each tick event
function tick_handler()
{
debug_backtrace();//get function name
microtime();//get time
}
</code></pre>
<p><a href="http://www.php.net/decla... |
API call from post trigger of DocumentDB <p>I need to make an API call from post trigger of Azure DocumentDB.
I tried calling external APIs - but found that such calls are blocked in DocumentDB. If I host an API on Azure's same account will that API is allowed to be called from the post trigger ? If not what can be th... | <p>Server-side code runs in a sandboxed environment and cannot make external calls. You can, instead, make the same call from your client after your request is acknowledged by the service (indicating your post-trigger succeeded/failed).</p>
|
Grails error handling in controllers <p>I would like to render custom JSON error messages. I created the following controller:</p>
<pre><code>class ErrorController {
static responseFormats = ['json']
def notAuthorized() {
render([error: "You are not authorized to access ${request.getRequestURL()} on ... | <p>I think what you want is <code>request.forwardURI</code>. That should give you the request that triggered the error.</p>
|
I am getting the error "This method must return a result of type java.lang.String" and I dont understand why. <p>I dont know why I am getting this error. If anyone can explain it to me and edit my code it would be appreciated.</p>
<pre><code>public class Exam1 {
public static void main(String[] args)
{
Exam1 ... | <p>If you notice. You have a condition on your return. And because you have labeled that method to return a string it must return something. There is however an eventuality where it doesn't return a string. So you have to figure out what you want to do when your if is false.
public class Exam1 {</p>
<pre><code> p... |
Weird error using Android License server <p>So following the instruction from the official android developers website I've set up everything to create a license check, but I am having the weirdest of the errors...</p>
<p>I've created 3 activities for the 3 posible responses from the license server:</p>
<p>-Everything... | <p>I solved!!! The problem is the app needs to be published in the Play Store at least as an Alpha and then you need to add a list a Alpha-tester users (in this case myself) to the app. Is not enough to to upload the APK, you need to actually publish the app to get the license to work. I will let that code here as a ex... |
How can I compare items in two list that occur in the same position? <p>As the title says, I need to compare items in two list that occur in the same position.</p>
<pre><code>la=['a0', 'b1', 'a2', 'b3', 'a4', 'b5']
lb=['b0', 'a1', 'b2', 'a3', 'b4', 'b5']
</code></pre>
<p>Like <code>'a0'</code> and <code>'b0'</code> ... | <pre><code>i = 0
j = 0
while True:
try:
if la[i] > lb[j]:
del la[i]
j += 1
elif la[i] < lb[j]:
del lb[j]
i += 1
else:
del la[i]
del lb[j]
except IndexError:
break
</code></pre>
<p>This assumes both lis... |
How to bind a click event to a Leaflet canvas GridLayer <p>I'm trying to bind a click event to a leaflet plug-in's extension of a canvas GridLayer (using Leaflet 1.0, with <a href="https://github.com/domoritz/leaflet-maskcanvas" rel="nofollow">Leaflet.MaskCanvas</a>).</p>
<p><a href="http://leafletjs.com/reference-1.0... | <p>In Leaflet 1.0, <code>GridLayer</code>s do not handle mouse/touch/pointer events (notice their <a href="http://leafletjs.com/reference-1.0.0.html#gridlayer-event" rel="nofollow">events documentation</a> does <strong>not</strong> list pointer events, whereas some <a href="http://leafletjs.com/reference-1.0.0.html#int... |
RxJava android chaining requests <p>I am using Retrofit with RxJAva for an app that gets Rss Feeds, but the rss doesn't contain all the informations so i use jsoup to parse every item link, to retrieve the image and the article's description. now i am using it this way:</p>
<pre><code> public Observable<Rss> ... | <p>Let's see...</p>
<pre><code>public Observable<Rss> getDumpData() {
System.out.println("in the getDumpData");
if (newsAppService == null) {
System.out.println("newsAppServer is null");
}
return newsAppService.getDumpData()
.flatMap(rss -> Observable
.from(rss.channel.items)
.o... |
Minimize memory overhead in sparse matrix inverse <p>As pretense, I am continuing development in Python 2.7 from a prior question: <a href="http://stackoverflow.com/questions/40050947/determining-a-sparse-matrix-quotient">Determining a sparse matrix quotient</a> </p>
<h2>My existing code:</h2>
<pre><code>import scipy... | <p>No need to 'preallocate' <code>k</code>; this isn't a compiled language. Not that this is costing anything.</p>
<pre><code>k = sp.csr_matrix(([], ([],[])),shape=[R,R])
</code></pre>
<p>I need to double check this, but I think the <code>dot/inv</code> can be replaced by one call to <code>spsolve</code>. Remember ... |
How do I know where an email form is being delivered? <p>Is there a way to extract the email address an online form will send to?</p>
<p>This website for instance: <a href="http://www.extrememicro.net" rel="nofollow">http://www.extrememicro.net</a>
There is a "contact us" page where you fill out first name, last name,... | <p>With the <code><form action=""</code> from the source :</p>
<pre><code> <form action="/#wpcf7-f37-o1" method="post" >
</code></pre>
<p>So it's a <code>POST</code> to the page <a href="http://www.extrememicro.net/#wpcf7-f37-o1" rel="nofollow">http://www.extrememicro.net/#wpcf7-f37-o1</a></p>
|
After creating a bigger array, how do I use the new array in other functions of the same class? <p>It was asked of us to implement this class without built-in functions or Arraylist.
When needing to make the data array bigger, I created a new array and gave it a new size (which is the capacity+10). As the data array is... | <p>After this code:</p>
<pre><code>int newArray[]=new int[capacity];
copyOldtoNew(data,newArray);
</code></pre>
<p>you need this little piece of magic:</p>
<pre><code>data = newArray;
</code></pre>
<p><sub>well, I hope you understand it is not magic at all.</sub></p>
|
Post request saving only versionKey with Mongoose and Express <p>I am trying to save a number and a few string values to a MongoDB and even though the code makes perfect sense to me, returns no errors and creates an entry in the database, all I get is just a versionKey, something like this:</p>
<pre><code>{
"_id":... | <p>First question, the encoding must match what you have Express parsing (in this case it wasn't <code>multipart/form-data</code> but <code>application/json</code>, <code>'application/vnd.api+json'</code>, and <code>application/x-www-form-urlencoded</code>. Removing the encoding type you were specifying fixes that.</p... |
How can I check the color of the tab bar buttons? <p>Do you have an idea how can I change the gray color of this tab button to another color?This is basically the non-taped button, when the user taps it, it is changing to white.
<a href="https://i.stack.imgur.com/w9DTl.png" rel="nofollow"><img src="https://i.stack.imgu... | <p>You need to set <code>barTintColor</code> for the whole bar and <code>tintColor</code> for the tapped button. </p>
<pre><code>self.tabBar.barTintColor = UIColor.whiteColor()
self.tabBar.tintColor = UIColor.greenColor()
</code></pre>
<p>inside Appdelegate.swift</p>
<p>Insert code somewhere in </p>
<pre><code>fun... |
415 unsupported mediaType in POST request <p>Was reading around and a lot of the issues others were having were Spring, Gradle, or something else. It seems that Postman does not like my request that I'm giving to my <code>POST</code> method. </p>
<p>Error:</p>
<pre><code>b>description</b>
<u>Th... | <p>This is a bit of a shot in the dark, but you're POSTing a string to a method which takes ApplicationInfo, and I'm not too sure JAX-RS does object mapping on the fly like Spring can do with @RequestBody.</p>
<p>Try changing your method signature to <code>public Response createQuery(String info) throws IOException</c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.