qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
8,928,533 | Why in jQuery `core.js` isn't `extend` defined as like this:
```
jQuery.extend = jQuery.fn.extend = function() {
...
}
```
and not as a prototype like:
```
jQuery.prototype.extend = jQuery.fn.prototype.extend = function() {
...
}
```
Presumably with the former, objects created from jQuery will not have th... | 2012/01/19 | [
"https://Stackoverflow.com/questions/8928533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/415600/"
] | Because `jQuery.fn === jQuery.prototype`
It is defined on the prototype. jQuery just decided it would be "cute" to alias the prototype to `.fn`
Which is why
```
$().extend({
"lulz": "baz"
}, {
"more-lulz": "no wai"
})["more-lulz"] === "no wai"; // true
``` | Well, because `fn` is nothing than a shortcut to the `prototype` property :
```
console.log($.prototype === $.fn);
```
Maybe John Resig got bored of typing `prototype` for every method and set up a nice alias `fn` (which is indeed shorter and in my opinion more suggestive). |
77,946 | For Barcelona, Google Maps has driving, public transport and walking directions. However, the button for cycling directions is grayed out. Is this feature only available in certain places? | 2015/05/11 | [
"https://webapps.stackexchange.com/questions/77946",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/-1/"
] | It is likely that the area does not support this method of navigation in Google Maps.
Looking at the location you mention Google Maps is reporting that "Cycling is not available".
You could try out [OpenCycleMaps](http://www.opencyclemap.org/) powered by [OpenStreetMaps](https://www.openstreetmap.org/) | Try this - looks like is built on Google anyhow,
<http://com-shi-va.lameva.barcelona.cat/en/bicycle> |
173,264 | Are there Virtual Machine Servers that you can install Virtual Machines on and then the clients can just fire up the OS (Windows, Mac, Linux) through the web browser?
That would be very efficient. | 2010/08/22 | [
"https://serverfault.com/questions/173264",
"https://serverfault.com",
"https://serverfault.com/users/39101/"
] | VMware's ESX pretty much does this by default although this feature has now been removed from ESXi and will not be available in future releases after V4.1 once the ESXi variant becomes the only one that VMware will update in future. Web based access to a remote guest console is trivially easy to provide for ESX but as ... | VirtualBox can be scripted, so it would be possible to include a web front-end command interface.
Microsoft's Virtual Server 2005 was ran exclusively from a web front-end, bit it has largely been supplanted by Hyper-V.
Hyper-V is scriptable via Powershell, I believe, so a web front-end would be possible but I think i... |
3,799,810 | I have an instance on my stage that I dragged from my library at design time. This instance links to a custom class who's constructor takes an argument.
```
package
{
import flash.display.MovieClip;
import flash.media.Sound;
public class PianoKey extends MovieClip
{
var note:Sound;
pu... | 2010/09/26 | [
"https://Stackoverflow.com/questions/3799810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46914/"
] | Why not just use VIM?
You know exactly what it can do and how it can be extended, and it appears to be what you want anyway.
You will not be satisfied by any emulation as it will fall short, and with your current mindset you will not like having to learn a new editor. It is, however, what I will recommend you to do. ... | I've been using the viplugin for eclipse (http://www.viplugin.com/viplugin/)
It's quite good, fights a little bit with refactoring, but most of the main editing commands work. I still have to use vim for complex regex work, but I only have to do that about twice a year.
Unfortunately it's commercial (€15) and develop... |
1,358,694 | How to remove a blank page that gets added automatically after \part{} or \chapter{} in a book document class?
I need to add some short text describing the \part. Adding some text after the part command results in at least 3 pages with an empty page between the part heading and the text:
1. Part xx
2. (empty)
3. some... | 2009/08/31 | [
"https://Stackoverflow.com/questions/1358694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025531/"
] | A solution that works:
Wrap the part of the document that needs this modified behavior with the code provided below. In my case the portion to wrap is a \part{} and some text following it.
```
\makeatletter\@openrightfalse
\part{Whatever}
Some text
\chapter{Foo}
\@openrighttrue\makeatother
```
The wrapped portio... | I believe that in the book class all \part and \chapter are set to start on a recto page.
from book.cls:
```
\newcommand\part{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{plain}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vfil
\... |
17,406 | I want to convert `.txt` files to `.pdf`. I'm using this:
```
ls | while read ONELINE; do convert -density 400 "$ONELINE" "$(echo "$ONELINE" | sed 's/.txt/.pdf/g')"; done
```
But this produces one "error" -- if there's a very long line in the text file, it doesn't get wrapped.
### Input text
![Screenshot of the i... | 2011/07/26 | [
"https://unix.stackexchange.com/questions/17406",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/6960/"
] | You can print text to a PostScript file using Vim and then convert it to a PDF, as long as Vim was compiled with the `+postscript` feature.
For this you use the `:hardcopy > {filename}` command. For example you can open `example.txt` and execute
```
:hardcopy > example.ps
```
which will produce a file `example.ps` ... | I am adding this `a2ps` as another alternative. `a2ps` produces postscript file, then could be converted into pdf using `ps2pdf`. Both `a2ps` and `ps2pdf` should be in the major Linux distros repository.
```
a2ps input.txt -o output.ps
ps2pdf output.ps output.pdf
``` |
39,654,620 | By default IDE genarate a apk like `app-debug.apk` or `app-release.apk` file but I need to generate specific name of the **Apk** of the App.
For Example:
My application name is **iPlanter** so i need to generate **`iPlanter-debug.apk`** or **`iPlanter-release.apk`** instead of `app-debug.apk` or `app-release.apk` resp... | 2016/09/23 | [
"https://Stackoverflow.com/questions/39654620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5315735/"
] | This will help you. This code will create app name like iPlanter-release.apk or iPlanter-debug.apk
```
buildTypes {
applicationVariants.all { variant ->
variant.outputs.each { output ->
project.ext { appName = 'iPlanter' }
def newName = output.outputFile.name
newName = newName.replace("a... | Try this code:
```
defaultConfig{
applicationVariants.all { variant ->
changeAPKName(variant, defaultConfig)
}
}
def changeAPKName(variant, defaultConfig) {
variant.outputs.each { output ->
if (output.zipAlign) {
def file = output.outputFile
output... |
21,696,293 | As soon as the page load, href link should get trigger(Manual click should not happen).Plz help
```
<a href="www.google.com" id="info">Information</a>
<script>
$(document).ready(function(){
$("#info").click(function(){
});
$(window).load(function(){
$("#info").trigger("click");
});
});
</script>
``` | 2014/02/11 | [
"https://Stackoverflow.com/questions/21696293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2721624/"
] | Use this
```
<script>
$(document).ready(function(){
$("#info").on("click",function(){
var url = $(this).attr('href');
$(location).attr('href',url);
});
$("#info").trigger("click");
});
</script>
```
Jsffidle demo <http://jsfiddle.net/waseemmachloy/tBGX3/2/> | Simply
```
$(function(){
$("#info")[0].click();
});
``` |
1,258,335 | I m using Zend\_Log to create and Log messages.
It works well for storing Log messages in to a stream (a new defined file name), well i want to store these messages in to Buffer array.
For this i visit :
<http://framework.zend.com/wiki/display/ZFPROP/Zend_Log+Rewrite#Zend_LogRewrite-1.Overview>
but fail to get their p... | 2009/08/11 | [
"https://Stackoverflow.com/questions/1258335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Here's a shot at it. With this method, you don't need to write any global utility functions. You can use the Zend\_Log interface for all your method calls.
In your bootstrap, initialize your logger. Make sure to include the file and line event types in your formatter. Then, create the Logger with a custom writer, whic... | You're gonna have to write your own writer for this functionality I think. You can use debug\_backtrace to see where the $logger->info() for the line and file info.
<http://de2.php.net/manual/en/function.debug-backtrace.php> |
325,296 | I would wager there must be a term of art describing what a fish does as it breathes, normally, underwater. Any thoughts? | 2016/05/12 | [
"https://english.stackexchange.com/questions/325296",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/174975/"
] | This punishment, while potentially useful, is burdened with an overly restrictive [precondition](http://www.oxforddictionaries.com/us/definition/american_english/precondition) for activation. It means
>
> A condition that must be fulfilled before other things can happen or be done.
>
>
>
Also, you may consider [... | In safety, there are regulatory limits for exposures to various hazards, such as noise and ionizing radiation. In many cases, there are also **action levels**, which are typically some percentage, e.g., 10% or 50%, of the regulatory limits. When an exposure reaches an action level, that triggers an investigation or int... |
4,571,155 | How do i manually initiate values in array on heap?
If the array is local variable (in stack), it can be done very elegant and easy way, like this:
```
int myArray[3] = {1,2,3};
```
Unfortunately, following code
```
int * myArray = new int[3];
myArray = {1,2,3};
```
outputs an error by compiling
```
error: expec... | 2010/12/31 | [
"https://Stackoverflow.com/questions/4571155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335717/"
] | This is interesting: [Pushing an array into a vector](https://stackoverflow.com/questions/4541556/pushing-an-array-into-a-vector/4541707#4541707)
However, if that doesn't do it for you try the following:
```
#include <algorithm>
...
const int length = 32;
int stack_array[length] = { 0 ,32, 54, ... }
int* array = ne... | `{1,2,3}` is a very limited syntax, specific to POD structure initialization (apparently C-style array was considered one too). The only thing you can do is like `int x[] = {1,2,3};` or `int x[3] = {1,2,3};`, but you can't do neither `int x[3]; x={1,2,3};` nor use `{1,2,3}` in any other place.
If you are doing C++, it... |
12,393,428 | I am a relatively new web apps programmer.
I have done differents web apps when HTML 5 were becoming (let's say) the new HTML standard.
So I want to know whether it is a good idea to migrate some of those apps to HTML 5.
By the way, I never have used HTML 5 in any web application.
What things do I have to keep in m... | 2012/09/12 | [
"https://Stackoverflow.com/questions/12393428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1464529/"
] | After much experience running unit tests across multiple environments I recommend not referencing `nunit.framework` that comes with MonoDevelop (or Xamarin Studio). If you only ever run your tests within that IDE it is fine. However, if you run your tests from a command line, a different environment or on a build box t... | I had a similar problem.
I removed explicit reference (.dll) and I installed NUnit by Nuget package.
Works for me. |
38,770,799 | i had write a html file which will request some information from user and send it to another php file. The php file will establish the connection to database and insert the value to database.
My database name = testdb
table name = table1
I had do some testing on both file by calling an alert message, the alert ... | 2016/08/04 | [
"https://Stackoverflow.com/questions/38770799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5157127/"
] | First, your `if` statement is missing a closing `}`.
Second, your SQL query is not inserting the variables you've set above. You've got variables like `$num1`, but then you are inserting the value just `'num'` in your SQL insert. You have to change `'num1', 'num2'...` to `'$num1', '$num2'...`
Third, please do some re... | As you clearly mentioned in your question,
>
> " I had do some testing on both file by calling an alert message, the
> alert messages was able to display in the html file, **it's seen like the
> request from the html file cant send to the php file ,so the code for inserting data to database can't execute** ~@Heart... |
6,895 | I'm thinking of writing a novel where my character narrates flashbacks through the hardest times of his life written in past tense, leading up to the present tense. I was considering switching to present tense only directly before and throughout the climax of the book so that the reader can understand the character's a... | 2012/12/25 | [
"https://writers.stackexchange.com/questions/6895",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/4518/"
] | I think that beginning with a series of flashbacks might be difficult for the reader to follow if there was no sense of what they are moving towards. This might not be exactly what you are doing, but in any case my advice would be to consider an *[in medias res](http://en.wikipedia.org/wiki/In_medias_res)* structure. I... | One can debate the validity of the flashback technique, as Lauren Ipsum and Tylerharms do in the comments on another answer. Like many techniques, it can be done well and it can be done lamely.
(Oh, how I hate movies that start out with a character brooding over the scene of the disaster -- whether it's the end of hi... |
2,272,996 | What is the easiest way to simulate a database table with an index in a key value store? The key value store has NO ranged queries and NO ordered keys.
The things I want to simulate (in order of priority):
1. Create tables
2. Add columns
3. Create indexes
4. Query based on primary key
5. Query based on arbitrary colu... | 2010/02/16 | [
"https://Stackoverflow.com/questions/2272996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/190822/"
] | Use a hashtable or dictionary. If you want unique key values you could use a GUID or hashcode. | The key-value store should support ordering the keys and ranged access to the keys.
Then you should create two dictionaries:
```
id -> payload
```
and
```
col1, id -> NULL
```
, where `payload` should contain all the data the database table would contain, and the keys of the second dictionary should contain the ... |
26,322,873 | ternery search tree requires O(log(n)+k) comparisons where n is number of strings and k is the length of the string to be searched and binary search tree requires log(n) comparisons then why is TST faster than BST ? | 2014/10/12 | [
"https://Stackoverflow.com/questions/26322873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2745366/"
] | ```
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*(\W|_)).{5,}$
```
You can use the above regex with lookahead and you can *easily* append any other criteria if required in
future. You're basically checking if each of your criteria is present by lookaheads.
```
if(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*(\W|_)).{5,}$/.test(pwd)... | Below regular expression should work for you...
```
var pattern = /^(?=.{5,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\W])/
```
**HTML Code**
```
<input type="text" id="pass" />
<input type="button" id="btnpass" value="Test" />
```
**jQuery code**
```
var pattern = /^(?=.{5,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*... |
548,408 | >
> How can I configure `biber`/`biblatex` so that `{\"u}` is printed as `{\"u}` in the `bbl` file, not as `ü`?
>
>
>
I uses `biblatex`+`biber`. Because they're stuck in the past, arXiv require a `bbl` file of version `2.8`. I have an old version of `biber`, namely `2.7`, which outputs a `bbl` files with version `... | 2020/06/08 | [
"https://tex.stackexchange.com/questions/548408",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/81928/"
] | It's difficult to fit such big objects in a table without making line breaks.
Here's my suggestion: the laws' names on a line by themselves, in italic type; then the mathematical law and its description.
Some spacing between rows will help in dividing the four parts. With `tabularx` the second column takes all the sp... | Another solution only for fun!
```
\documentclass[12pt]{article}
\usepackage{amsmath,palatino}
\usepackage{longtable,array}
\renewcommand\arraystretch{2.5}
\begin{document}
\begin{longtable}{|m{0.3\linewidth}|>{\centering$\displaystyle}m{0.3\linewidth}<{$}|m{0.4\linewidth}|}\hline
Gauss' law
& \vec{\nabla... |
1,522,444 | I've been trying to redirect System.out PrintStream to a JTextPane. This works fine, except for the encoding of special locale characters. I found a lot of documentation about it (see for ex. [mindprod encoding page](http://mindprod.com/jgloss/encoding.html)), but I'm still fighting with it. Similar questions were post... | 2009/10/05 | [
"https://Stackoverflow.com/questions/1522444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Try this code:
```
public class MyOutputStream extends OutputStream {
private PipedOutputStream out = new PipedOutputStream();
private Reader reader;
public MyOutputStream() throws IOException {
PipedInputStream in = new PipedInputStream(out);
reader = new InputStreamReader(in, "UTF-8");
}
public void write... | As you rightfully assume the problem is most likely in:
```
String s = Character.toString((char)i);
```
since you encode with UTF-8, characters may be encoded with more than 1 byte and thus adding each byte you read as a character won't work.
To make it work you can try writing all bytes into a ByteBuffer and using... |
36,846 | If the stock market crashes 20%, do bonds suffer or is there little to no correlation between the two markets? | 2014/09/10 | [
"https://money.stackexchange.com/questions/36846",
"https://money.stackexchange.com",
"https://money.stackexchange.com/users/2239/"
] | It depends. Very generally when yields go up stocks go down and when yields go down stocks go up (as has been happening lately).
If we look at the yield of the 10 year bond it reflects future expectations for interest rates. If the rate today is very low but expectations are that the short term rates will go up that w... | It depends on **why** the stocks crashed. If this happened because interest rates shot up, bonds will suffer also.
On the other hand, stocks could be crashing because economic growth (and hence earnings) are disappointing. This pulls **down** interest rates and lifts bonds. |
45,333,609 | I'm inserting data into the influxDb using batch points via Java API (used http API under the hood) after some time the exception is raised.
```
java.lang.RuntimeException: {"error":"partial write: max-values-per-tag limit exceeded (100010/100000):
```
According to the Influx docs - [docs](https://www.influxdata.co... | 2017/07/26 | [
"https://Stackoverflow.com/questions/45333609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/359376/"
] | They are using in memory index for "tags", the more different tags values you have (the higher aardinality of the data) the more memory influx requires.
<https://github.com/influxdata/influxdb/issues/7151> | InfluxDB may require high amounts of memory for high cardinality data (~10KB of memory per time series) and memory requirements may grow exponentially with the number of unique time series. See [these official docs](https://docs.influxdata.com/influxdb/v1.7/guides/hardware_sizing/#when-do-i-need-more-ram) for details.
... |
1,969,620 | I'm looking at some 3rd party code and am unsure exactly what one line is doing. I can't post the exact code but it's along the lines of:
```
bool function(float x)
{
float f = doCalculation(x);
return x > 0 ? f : std::numeric_limits<float>::infinity();
}
```
This obviously throws a warning from the compiler about c... | 2009/12/28 | [
"https://Stackoverflow.com/questions/1969620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/197229/"
] | I think it is a mistake. That function should return a float. This seem logical to me.
The conversion float to bool is the same as float != 0. However, strict comparing two floating points is not always as you'd expect, due to precision. | I think it would be better to use **isnan()**.
isnan() returns true if f is not-a-number. But it will return true for e.g. 0.0 ...
```
#include <cmath>
bool function(float x)
{
float f = doCalculation(x);
return isnan(f) ? false : true;
}
```
as mentioned that will not catch the case where f is 0.0 - or ver... |
21,174,359 | I'm trying to add fields dynamically to a web page so that a user can enter in additional amenities to a form. By clicking on the add amenity button I can add the fields just fine. However I cannot manage to get the values out of the input fields dynamically. The objective is to display what they type after they leave ... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21174359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3192152/"
] | I've just made this ugly example. And it worked, it retrieves all messages including those that have been seen.
```
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getDefaultInstance(props, null);
try {
Store store = App.session.getStore("ima... | ```
import java.util.*;
import javax.mail.*;
public class ReadingEmail {
public static void main(String[] args) {
Properties props = new Properties();
props.setProperty("mail.store.protocol", "imaps");
try {
Session session = Session.getInstance(props, null);
Store store = session.g... |
3,369,107 | I am currently reading Folland's Real Analysis. On page 145 of his book, he claims the following:
>
> **Claim**: If $X$ is a noncompact, locally compact Hausdorff space, then the closure of the image of the embedding $e:X\hookrightarrow I^\mathcal F$ associated to $\mathcal F=C\_c(X)\cap C(X,I)$ is the one-point comp... | 2019/09/25 | [
"https://math.stackexchange.com/questions/3369107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/544921/"
] | Your proof is correct, although you should explicitly define $\hat X$ is and restate lemma 1 as
>
> Lemma 1: Let $X$ be a completely regular space, and let $Y$ be a compact
> Hausdorff space. Suppose that $\mathcal{F}\subset C(X,I)$ separates
> points and closed sets. Then any $\phi\in C(X,Y)$ such that the collect... | Simply use the fact mentioned in the preceding sentence (on p.145): Y consists of e(X) together with the single point of $I^{\mathcal{F}}$ all of whose coordinates are zero.
To prove the aforementioned fact, just observe that if $y \in Y \setminus e(X)$, then $y \notin K$ for all compact subsets $K \subseteq e(X)$. |
32,640,250 | I'm having an issue where my gameObject barely jumps at all. I think it has something to do with `moveDirection` because the jumping works when I comment out `p.velocity = moveDirection`.
Any suggestions on how to fix this?
```
using UnityEngine;
using System.Collections;
public class Controller : MonoBehaviour
{... | 2015/09/17 | [
"https://Stackoverflow.com/questions/32640250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5348182/"
] | You would just have to use the **createdRow**
```
$('#data-table').DataTable( {
createdRow: function( row, data, dataIndex ) {
// Set the data-status attribute, and add a class
$( row ).find('td:eq(0)')
.attr('data-status', data.status ? 'locked' : 'unlocked')
.addClass('ass... | **To set the Id attribute on the row `<tr>` use:**
```
//....
rowId: "ShipmentId",
columns: [...],
//....
```
**To set a class name on the `<tr>` use this calback**
```
createdRow: function (row, data, dataIndex) {
$(row).addClass('some-class-name');
},
```
ref: <https://datatables.net/reference/option/creat... |
39,387,688 | i want to remove all unselected option of Particular select box by j-query and java script simple code
example : if i select test- 1 option of first select box, than all unselected option remove of first select box , and this condition apply on all select box
```html
<script src="https://ajax.googleapis.com/ajax/lib... | 2016/09/08 | [
"https://Stackoverflow.com/questions/39387688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5935830/"
] | Try something like this :
```js
$(function() {
$('.mymultiSelect').on('change', function() {
$(this).find('option').not(':selected').remove();
});
});
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select class="mymultiSelect">
<option value="0">-s... | Im not quite sure I understand correctly.
My code uses the value that is selected and removes it from all the other selects. I hope this works for you.
```js
$(function() {
$('.mymultiSelect').on('change', function() {
$('.mymultiSelect').not($(this)).find('option[value="'+$(this).val()+'"]').remove();
});... |
42,227,537 | I am reading a book on compiler design and implementation. In the part about storage management the author writes a function to allocate memory. He wants the function to be suitably aligned for any type. He claims that the size of the union below is the minimum alignment on the host machine. I don't quite understand wh... | 2017/02/14 | [
"https://Stackoverflow.com/questions/42227537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/904194/"
] | The alignment of a union is chosen to be the same as the alignment of the member with the greatest alignment requirements. Its size chosen to be as big as the biggest member, plus some additional padding at the end to ensure that the alignment doesn't break when it is laid out sequentially in an array.
So in that sens... | Consider a machine that, due to memory bus limitations, can read 16-bit values only from even addresses.
A 16-bit value on such a machine would have an "alignment requirement" of 2.
Do **not** rely on `union` trickery. Since C11, there are:
* [`max_align_t`](http://en.cppreference.com/w/c/types/max_align_t) which is... |
57,432 | I am replacing the toilet in my house, and after removing the old toilet, I can see that the flange is not bolted to the floor. Also, it sits up off the finished floor about a quarter inch. Do I need to add any supports underneath to fill the gap, and do I need to drill holes and bolt it down to the subfloor before ins... | 2015/01/08 | [
"https://diy.stackexchange.com/questions/57432",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/31453/"
] | We would usually screw it down during the rough in. Having said that I personally see nothing wrong with cementing it to the exit pipe below. Although not my first choice I have seen installs last many many years without screwing in the flange. For example for basement bathrooms I would just attach the flange via cemen... | If your pipe is already installed with a flange and studs, it's probably attached correctly. A sub floor was probably installed during the last remodeling. You just need to check for rot around the pipe flange. |
39,786,337 | I wish to convert a JS object into x-www-form-urlencoded. How can I achieve this in angular 2?
```
export class Compentency {
competencies : number[];
}
postData() {
let array = [1, 2, 3];
this.comp.competencies = array;
let headers = new Headers({ 'Content-Type': 'application/x-www-form-ur... | 2016/09/30 | [
"https://Stackoverflow.com/questions/39786337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6897022/"
] | ```js
let o = { a:1, b:'2', c:true };
let s = new URLSearchParams(Object.entries(o)).toString();
console.log(s);
``` | Assume have an object named postdata as below:
```js
const postdata = {
'a':1,
'b':2,
'c':3
};
```
and, you want convert it into x-www-form-urlencoded format, like: `a=1&b=2&c=3`
with [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams) it's very easy to do it.
... |
9,725,103 | I have a nested inner class that extends AsyncTask to run a db query in the background. In the post execute method I am calling a parent's method to update the view something like this
```
private class QueryRunner extends AsyncTask<Void,Void,Cursor> {
@Override
protected Cursor doInBackground(Void... voids)
{
... | 2012/03/15 | [
"https://Stackoverflow.com/questions/9725103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54321/"
] | Is "another\_value" supposed to represent a magic number or another vaiable? First things first, you should assign all primitives an initial value when they are defined. Don't use magic numbers, used #define ANOTHER\_VALUE 0, if this is the case.
>
> When I remove it from the C file and put it under the private varia... | Is `table` supposed to be shared between all instances of `test`, or do you want one instance per class instance (and zero instances when there are no instances). The semantics you have to begin with result in one instance shared between all instances of `test`. To get this with a member variable, it is necessary to de... |
12,373,064 | Sorry I know this is a generic question, I'll try to provide as much detail as possible
I am running Bitnami Rubystack (3.2.7) on Amazon EC2 Medium instance. and some aspects of Rails are extremely slow, here are some of them:
* when logging in (I am using devise gem), if you provide an invalid password, it would tak... | 2012/09/11 | [
"https://Stackoverflow.com/questions/12373064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would suggest you to compile a Ruby 1.9.3-p194 with falcon patch, it increases ruby and rails speed dramatically.
[falcon patch in rvm](https://github.com/wayneeseguin/rvm/blob/master/patches/ruby/1.9.3/p194/falcon.diff)
You download ruby src and apply this patch if you do not want to use RVM.
It might also be a DN... | Just put gem [rails tweak](https://github.com/wavii/rails-dev-tweaks) in your gem file and after that run
```
bundle install
```
I think it will solve your problem.
Thanks |
36,516,614 | Does anyone know a way to simulate a NOR-gate in JavaScript?
<https://en.wikipedia.org/wiki/NOR_gate>
From what I have seen so far the language has only AND and OR. | 2016/04/09 | [
"https://Stackoverflow.com/questions/36516614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6085786/"
] | Always you could negate the logic or making something like this:
```
if(!(true || true))
```
this way you always going to obtain the or result negated, which really have a NOR-gate behavior. | Here's the bitwise version:
```
~(a | b)
``` |
2,921,237 | I'm looking for a package / module / function etc. that is approximately the Python equivalent of Arc90's readability.js
<http://lab.arc90.com/experiments/readability>
<http://lab.arc90.com/experiments/readability/js/readability.js>
so that I can give it some input.html and the result is cleaned up version of that h... | 2010/05/27 | [
"https://Stackoverflow.com/questions/2921237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/236007/"
] | Please try my fork <https://github.com/buriy/python-readability> which is fast and has all features of latest javascript version. | I have done some research on this in the past and ended up implementing [this approach [pdf]](http://www.psl.cs.columbia.edu/crunch/WWWJ.pdf) in Python. The final version I implemented also did some cleanup prior to applying the algorithm, like removing head/script/iframe elements, hidden elements, etc., but this was t... |
23,796,894 | ```
<form method="post" action="">
<input type=text name="nm" />
</form>
```
request.getParameter("nm");
I can get the parameter named nm, but I can't confirm it's confirm method ,post or get?? | 2014/05/22 | [
"https://Stackoverflow.com/questions/23796894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3663191/"
] | I would follow nmenego's advice, but keep in mind that the values you get from text fields are inherently strings (not numbers). Javascript lets you play fast and loose with this, but this results in less than ideal results:
Consider:
<http://jsfiddle.net/eFkze/>
```
alert("10" > "9")
```
So... you'll want to colle... | Below code will first check if both the inputs are entered and if both the inputs are numbers and then proceed with the calculation. isNaN function is used to check for numbers.
**HTML CODE**
```
<input type="text" id="inputfield1" />
<input type="text" id="inputfield2" />
<button onclick="compare()">Compare</button>... |
31,000,636 | I have a form which has 10 checkboxes. By default angular js triggers on individual checkbox. I want to grab all selected check box values on submit action only. Here is my code...
```
<form name="thisform" novalidate data-ng-submit="booking()">
<div ng-repeat="item in items" class="standard" flex="50">
<l... | 2015/06/23 | [
"https://Stackoverflow.com/questions/31000636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4846792/"
] | ```
<div ng-repeat="item in items">
<input type="checkbox" ng-model="item.SELECTED" ng-true-value="Y" ng-false-value="N"/>
</div>
<input type="submit" name="submit" value="submit" ng-click="check(items)"/>
$scope.check= function(data) {
var arr = [];
for(var i in data){
if(data[i].SELECTED=='Y'){
... | Can I suggest reading the answer I posted yesterday to a similar StackOverflow question..
[AngularJS with checkboxes](https://stackoverflow.com/questions/30976425/how-to-filter-through-a-table-using-ng-repeat-checkboxes-with-angularjs/30977408#30977408)
This displayed a few checkboxes, then bound them to an array, so... |
3,223,935 | I'm using Eclipse along with plugin m2eclipse to build and manage my project. In POM, I have included entry for servlet-api:
```
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
```
Scope is provided, n... | 2010/07/11 | [
"https://Stackoverflow.com/questions/3223935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/270315/"
] | This
>
> \WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
>
>
>
is simply a warning from the app server that it is ignoring one of your included JARs and will not load it. It can be safely ignored.
Sounds like the issue is with ... | Install the plugin which named "**Maven Integration for WTP**", it can completely sovled this problem.
Repository URL: **<http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/>** |
59,129,171 | For example, there is a sample flutter code. This code is not properly formatted.
```
import 'package:flutter/material.dart';
void main() => runApp(SampleApp());
class SampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Sa... | 2019/12/01 | [
"https://Stackoverflow.com/questions/59129171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5829191/"
] | Go to **Settings -> Languages & Frameworks -> Flutter** and check **Format code on save**.
---
You can also use Reformat code [shortcut](https://developer.android.com/studio/intro/keyboard-shortcuts) manually:
Windows/Linux: `Ctrl` + `Alt` + `L`
Mac: `Command` + `Option` + `L` | As @janstol said, there is a shortcut to auto reformat code. However, I had the same problem but I could not solve it because my command was not established, so I'll leave the route to get there in case someone needs it.
Open **Setting > Preferences > Keymap** and search for the one that says "**Reformat code with 'da... |
4,378,972 | In Visual Studio there is a command to remove unused using statements
```
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
```
Is there a pe... | 2010/12/07 | [
"https://Stackoverflow.com/questions/4378972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/322518/"
] | No. Namespaces are used to resolve class names at compile time. After compilation, your assembly only contains fully qualified class names like `System.Collections.Generic.List<int> myList = new System.Collections.Generic.List<int>()`, all the usings are gone. | I always thought they were removed away by the compiler. |
4,340,292 | If I have
```
char input[50] = "xFFFF";
int a;
```
How can I store the numerical value of input in a?
the language is C. | 2010/12/02 | [
"https://Stackoverflow.com/questions/4340292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/386020/"
] | One way to do it might be:
```
if (sscanf(input, "x%x", &a) == 0) {
/* matching failed */
}
```
If your input uses a real hex specifier (like "0xFFFF") you can just use %i:
```
if (sscanf(input, "%i", &a) == 0) {
/* matching failed */
}
``` | See [C++ convert hex string to signed integer](https://stackoverflow.com/questions/1070497/c-convert-hex-string-to-signed-integer) and if you're in a pure C environment, make sure to scroll down. |
33,122,986 | I struggled for hours to find out how to make a javascript function to copy the current URL into a new alert window.
For example, when a user click "Share this page", then a new alert window appears with the URL selected in an input text box:
[](https... | 2015/10/14 | [
"https://Stackoverflow.com/questions/33122986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5025969/"
] | As simple as this:
```js
prompt('Please copy the following URL:', window.location);
``` | For a better user experience you may consider allowing access to the clipboard with [clipboard.js](http://zenorocha.github.io/clipboard.js/). |
9,676,740 | Currently using Flexslider and would like to be able to hide the navigation arrows which presently appear on right and left side of the image but than have them appear when the user hovers over the image. I remember it being addressed on the old site - muffin one, but cannot find it on woothemes.
Does anyone have an id... | 2012/03/13 | [
"https://Stackoverflow.com/questions/9676740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932795/"
] | You can modify the arrows in the css. If you want the arrows to always be visible you want to change the opacity. It's currently set to 0 which makes it non-visible until hover (the hover opacity is set to 1 which is completely visible). So you want to just make it visible like so:
```
.flex-direction-nav a {opacity: ... | You can probably accomplish this via jQuery. In my case I am using FlexSlider for Drupal so I cannot promise that you will have the same CSS selectors, but I hope this code could provide a general idea :)
```
$(document).ready(function(){$("div.flexslider").hover(function() {
$("a.prev").sh... |
22,017,631 | I use the Kendo UI grid in ajax mode and have a ClientFooterTemplate with a sum of the total for a column. This all works well, but if I create/update or remove a record the ClientFooterTemplate is not updated and the sum value stays the same.
How can I update the ClientFooterTemplate so that the sum value is up to d... | 2014/02/25 | [
"https://Stackoverflow.com/questions/22017631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2600162/"
] | you need to update the `datasource` and fetch again if you using aggregates sum in you gird footer the following JavaScript will update your footer sum every time you create/update any row.
```
.DataSource(dataSource => dataSource
.Ajax()
.Aggregates(aggregates =>
{
aggregates.Add(p => p.WorkOrderDetailsQuan... | If you don't want to reload your data, you can always do something like this (a little hacky...):
First, use a different function for the Save event vs. the SaveChanges event, e.g.:
```
.Events(events => {
events.Save("Save");
events.SaveChanges("SaveChanges");
events.Remove("Remove")
})
```
Second, def... |
8,910,697 | I have many classes with static final fields which are used as default values or config. What is best approach to create global config file? Should I move these fields to single static class, use properties file or what?
Edit: I need to use this values both in java classes and xhtml pages. Values dosen't depend on env... | 2012/01/18 | [
"https://Stackoverflow.com/questions/8910697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/878418/"
] | The answer depends...
* Put stuff in properties files if the values change depending on runtime environment (eg database connection settings, foreign server IPs), or that will likely change often/soon
* Prefer using `enum` to `static final` constants where possible (avoid "stringly typed" code)
* Find an existing libr... | Both the approches are fine:
1. Have a static class with required `final` fields.
2. Have a singelton but save it from multiple threads appropriately.
3. if possible use `enum` over static fields. This way you can group related fields together.
If these are application level values, i'll prefer `static` class over si... |
36,477,390 | I'm working on a PDF Signer/Validator and don't know how I should handle pdf files with multiple signatures and dss dictionaries.
Here is the scenario: A pdf file is signed twice, and after the second signature, a DSS dictionary is added with the CRLs, CERTs and OCSPs of both signatures:
```
[ Signature 1 ]
[ Signatu... | 2016/04/07 | [
"https://Stackoverflow.com/questions/36477390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4979817/"
] | Andrea Valle, from Adobe, clarified this for me by e-mail:
>
> This has been discussed within ESI for some time, and finally the team decided to clarify this in EN 319 142-1.
>
>
> See section 5.4.1 on page 11 of version 1.1.0:
>
>
> The life-time of the protection can be further extended beyond the life-time of ... | As there's only a single DSS entry in the Catalog dictionary you need to update the existing DSS dicionary (resp. the VRI dictionary and the other values). |
985,460 | I am running a IP PBX system with trixbox, what i'm trying to do is connect PSTN lines with IAX2 using X100P analogue card.
The problem is i cannot call any outgoing routes. (already tried AsteriskNOW and elastix)
The problem as i've learned is "low IRQ"(Interrupt Request), if that is the case how do i increase it? o... | 2015/10/12 | [
"https://superuser.com/questions/985460",
"https://superuser.com",
"https://superuser.com/users/493478/"
] | Try this script. You might need to edit the drive letters though
```
setlocal EnableDelayedExpansion
@echo off
Q:
cd "Estimating\Estimating Files"
FOR /D /R %%G IN ("*Drawings*") DO (
FOR /F "tokens=4,5 delims=\" %%H IN ("%%G") DO (
set temp=%%H
set num=!temp:~4,2!
set temp=%%I
set alpha=!temp:~5!
MKDIR "Q:\E27XXX\0XX... | Here is the final code I used to copy the folders to the new directory.
Thanks to @ElektroStudios for their help.
```
@Echo OFF
Set "sourceDir=%CD%"
Set "targetDir=S:\E30xxx"
Set "findPattern=2 - Drawings"
For /F "Tokens=6,7,8,9 Delims=\" %%a In (
'Dir /B /S /A:D "%sourceDir%\*%findPattern%"'
) Do (
Call Se... |
2,324 | It seems to me that the first AGIs ought to be able to perform the same sort and variety of tasks as people, with the most computationally strenuous tasks taking an amount of time compared to how long a person would take. If this is the case, and people have yet to develop basic AGI (meaning it's a difficult task), sho... | 2016/11/13 | [
"https://ai.stackexchange.com/questions/2324",
"https://ai.stackexchange.com",
"https://ai.stackexchange.com/users/3604/"
] | There are basically two worries:
If we create an AGI that is a slightly better AGI-programmer than its creators, it might be able to improve its own source code to become even more intelligent. Which would enable it to improve its source code even more etc. Such a selfimproving seed AI might very quickly become superi... | To avoid a repetitive answer that has been already spoken about such as absurdly high iterative ability or it being able to create another AGI system and multiplying or anything sci-fi like - there is one line of thought I feel people do not speak enough about.
Our human senses are extremely limited i.e. we can see o... |
102,930 | It is common the use of [asterisk](https://en.wikipedia.org/wiki/Asterisk) (\*) to indicate required elements. I understand [the use of explicit text is better than relying on symbols](https://ux.stackexchange.com/questions/90685/using-asterisk-vs-required). So writing "required" or "optional" is more understandable th... | 2016/12/26 | [
"https://ux.stackexchange.com/questions/102930",
"https://ux.stackexchange.com",
"https://ux.stackexchange.com/users/32130/"
] | This is what I would do in order to specify when a field is required or optional
[](https://i.stack.imgur.com/UZrf3.jpg)
The last field is the active one, I added it in order to show that we still have the label when the field is active. | For simplicity, it feels natural to show which are required before an error message has to tell a user what's required. Anything else that's left as an option doesn't need an optional message by the nature of a required element.
If no special required element existed, then everything can be perceived as an option unle... |
57,842,810 | I have an Ajax call which returns a JSON response and i'm loading the response using an array
```
var results = {
"appointmentrequired": {"name": "Appointment Required?"},
};
success: function(data) {
$.each(results, function(key, value) {
// show results from `data` here
});
}
```
But I'm not ... | 2019/09/08 | [
"https://Stackoverflow.com/questions/57842810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4838253/"
] | If you `console.log()` both `key` and `value` you should be able to see what's being provided to the function arguments.
As such, either `data[key].name` or `value.name` is what you need.
```js
// mock AJAX response data
var data = {
"appointmentrequired": {
"name": "Appointment Required?"
},
};
// in... | `$.each` run on arrays
You want to explore `let keysArr = Object.keys(data)` |
18,262,053 | I'm struggling with how to do the query for this. I have three tables...ingredients, recipes, and stores. I'm trying to build a query that will tell me what recipes I can make from the ingredients available at a store. My tables are:
```
mysql> SELECT * FROM ingredients;
+---------+
| id |
+-----... | 2013/08/15 | [
"https://Stackoverflow.com/questions/18262053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1106281/"
] | try this:
```
SELECT r.name FROM recipes r
GROUP BY r.name
HAVING COUNT(*) = (SELECT COUNT(*)
FROM recipes r2 INNER JOIN stores s
ON r2.ingredient = s.ingredient AND s.name = 'wal-mart'
WHERE r.name = r2.name)
```
[fiddle demo](http://sqlfiddle.com/#!2/3c763/9) | (Remodelled the data a bit to use only numerical keys)
```
CREATE TABLE IF NOT EXISTS ingredients (
ing_id INTEGER NOT NULL PRIMARY KEY
, ing_name varchar(32) NOT NULL
) ;
INSERT INTO ingredients (ing_id, ing_name) VALUES
(1, 'apple' ),
(2, 'beef' ),
(3, 'cheese' ),
(4, 'chicken' ),
(5, 'eggs' ),
(6, 'flour' ),
(... |
71,414,890 | I have some info in JSON form fetched from my API, now I want to console.log a specific object from it, I have tried a few ways, but I get either undefined or the whole JSON text printed out
The code I have right now:
```
const api_url = 'http://127.0.0.1:8000/main/';
async function getapi(url) {
const response = a... | 2022/03/09 | [
"https://Stackoverflow.com/questions/71414890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18165364/"
] | You can use `itertools.dropwhile`
```
from itertools import dropwhile
from collections import Counter
data = [0.0,0.0,2.0,3.0,0.0,2.0]
print(sum(1 for _ in dropwhile(lambda x: x == 0, data))) # 4
print(Counter(dropwhile(lambda x: x == 0, data))) # Counter({2.0: 2, 3.0: 1, 0.0: 1})
``` | You can simply wrap your counter code in a conditional, with something like this:
```
x=[0.0,0.0,2.0,3.0,0.0,2.0]
start_counting = False
item_count = 0
for i in x:
if i != 0.0:
start_counting = True
if start_counting:
item_count += 1
```
`item_count` will now have the amount of items in the ... |
15,743,550 | I'm trying to implement a very simple SSDP functionality into my android app taken [from here](https://code.google.com/p/android-dlna/source/browse/trunk/src/org/ray/?r=2#ray/upnp/ssdp).
My application sends some UDP packets containing a relevant M-SEARCH message to the broadcasting address without any issue. The prob... | 2013/04/01 | [
"https://Stackoverflow.com/questions/15743550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1455529/"
] | Weird. I fixed the issue but I'm genuinely not sure what made it work.
Here are some changes that I made:
Instead of assigning a fixed port, I made it dynamically allocate an available port.
```
public class SSDPSocket {
SocketAddress mSSDPMulticastGroup;
MulticastSocket mSSDPSocket;
InetAddress broadcas... | On possible answer is that you may have an "old" device. Apparently multicast (from Java) is broken before Android 2.3.7
Reference: <https://stackoverflow.com/a/9836464/139985>
Another possibility is that it is a device-specific problem; e.g. like this: <https://stackoverflow.com/a/3714848/139985>. (I'm not saying it... |
38,023,521 | I have a function in c++ who returns a list of complex:
```
#include <complex>
std::list< std::complex<double> > func(...);
```
what should i do in the '\*.i' file ?
Thank you every body.
=================
Following are details:
the function i would like to use in python in x.h:
```
std::list<std::complex<doubl... | 2016/06/24 | [
"https://Stackoverflow.com/questions/38023521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6459155/"
] | This works:
```
%include <std_list.i>
%include <std_complex.i>
%template(ComplexList) std::list<std::complex<double> >;
... (your includes / function declarations)
```
I think your version (3) should actually also work. Strange that it doesn't. Maybe a SWIG bug. | To be more concise you can use the whole namespace:
```
%include <std_list.i>
%include <std_complex.i>
using namespace std;
%template(ComplexList) list<complex<double> >;
```
But the initially suggested versions of including SWIG `%template` into the `std` namespace is not a good idea. |
2,926,843 | I wonder if Nihbernate closes db connection supplied as a parameter to `OpenSession` method.
Example
```
using(var session = sessionFactory.OpenSession(connection))
{
}
```
I want the connection to be disposed with the session.
Best regards,
Alexey Zakharov | 2010/05/28 | [
"https://Stackoverflow.com/questions/2926843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/161287/"
] | I just used route globbing to achieve this:
```
map.connect "/*other", :controller => "pages", :action => "index"
```
Note that this route should be at the end of routes.rb so that all other routes are matched before it. | You can use the following ways to handle errors in a common place. Place this code in you ApplicationController
```
def rescue_404
@message = "Page not Found"
render :template => "shared/error", :layout => "standard", :status => "404"
end
def rescue_action_in_public(exception)
case exception
... |
38,236,723 | I am using XCode 8 and testing with iOS 10.2 Beta.
I have added the Photos, PhotosUI and MobileCoreServices frameworks to project.
Very simple code:
```
#import <Photos/Photos.h>
#import <PhotosUI/PhotosUI.h>
#import <MobileCoreServices/MobileCoreServices.h>
@interface ViewController : UIViewController <UIImagePic... | 2016/07/07 | [
"https://Stackoverflow.com/questions/38236723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1634905/"
] | in iOS 10 you need to add the key mentioned in below image if you are using camera or photo gallery in your app
[](https://i.stack.imgur.com/nw6ms.png) | In iOS 10, Apple has changed how you can access any user private data types.
You need to add the **Privacy - Photo Library Usage Description** key to your app’s `Info.plist` and their usage information.
For more information please find the below GIF.
[](https://i.stack.imgu... |
258,602 | I tend to see these words a lot in Discrete Mathematics. I assumed these were just simple words until I bumped into a question.
Is the following proposition **Satisfiable?** Is it **Valid**?
$(P \rightarrow Q) \Leftrightarrow (Q \rightarrow R ) $
Then I searched in the net but in vain. So I'm asking here. What d... | 2012/12/14 | [
"https://math.stackexchange.com/questions/258602",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/49700/"
] | A formula is valid if it is true for all values of its terms. Satisfiability refers to the existence of a combination of values to make the expression true. So in short, a proposition is satisfiable if there is at least one `true` result in its truth table, valid if all values it returns in the truth table are `true`. | * **Valid**: always true regardless of the values of its variables, e.g., `P OR NOT(P).`.
Slightly more formally: *A valid formula is one which is always true, no matter what truth values its variables may have.*
* **Satisfiable**: Can be solved, i.e., `true` and `false` values can be assigned to its variables, in a ... |
78,712 | It appears to be quite difficult to define agency in a metaphysical sense in a deterministic world. All handling I have seen suggests agents "choose" between paths, and thus require the system to be non-deterministic.
Are there any philosophical approaches which support the reduction of a non-deterministic system into... | 2021/01/24 | [
"https://philosophy.stackexchange.com/questions/78712",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/8007/"
] | >
> All handling I have seen suggests agents "choose" between paths, and thus require the system to be non-deterministic.
>
>
>
I don't believe that choice (or agency) requires non-determinism. Even if it is predetermined that I will choose A rather than B, the fact remains that at some point I do choose A rather ... | There is no concept of agency in a deterministic world.
Agency is the capability to initiate actions. Determinism does not include any such capability.
A non-deterministic system can be reduced to a deterministic system only by removing all things not possible in determinism. I have no idea how that could be done. |
1,379,213 | I just updated to 21.10. I was used to and loved using [Tilda](https://github.com/lanoxx/tilda) with F1 to drop it down and up. This does not seem to work on 21.10 easily. I couldn't deactivate the F1 help function, i.e. whenever I press F1, depending on the active window, the help window appears. Also other Fx keys do... | 2021/12/04 | [
"https://askubuntu.com/questions/1379213",
"https://askubuntu.com",
"https://askubuntu.com/users/1549234/"
] | Ubuntu 20.04 and later has the python3.9 package in its default repositories. It can be installed alongside the default python3.8 package with `sudo apt update && sudo apt install python3.9` Installing the python3.9 package from the default Ubuntu repositories simplifies package management.
If you are using Ubuntu 20.... | If you're asking about installing a version of python that's available system wide as a non-root user, I haven't found a good way to do this. However, there is no problem with having multiple versions of python available on your system at the same time. Download the appropriate .tgz file from the python website. Then (... |
2,182,744 | I am using VS 2008(Professional edition) with SP1.I am new to ADO.NET DataServices.I am watching Mike Taulty videos.
He used [DataWebKey] attribute to specifty the key field and he referred the namespace
Microsoft.Data.Web. To follow that example I am trying to refer the same assembly,but it is not found in my system... | 2010/02/02 | [
"https://Stackoverflow.com/questions/2182744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264175/"
] | [`echo`](http://de.php.net/manual/en/function.echo.php) is not a function, but a language statement. It cannot be redefined. If you are looking to prettify your output markup, have look at [Tidy](http://de3.php.net/manual/en/class.tidy.php).
---
What you *could* do, is use your IDE's search/replace method and replace... | You have various possibilities to output HTML.
You can use the [heredoc](http://php.net/manual/en/language.types.string.php) syntax:
```
$html = <<<EOF
<h1>Rar<h1>
<span>Rar</span>
<p>Rar</p>
EOF
echo $hml;
```
Or (what is way better in my opinion), **separate HTML from PHP**. E.g. put all the PHP logic in the top ... |
26,338,107 | Can you mix user input data with fixed data in a prepared statement security wise or does each query condition have to have a placeholder?
For example:
```
$code = htmlspecialchars($_GET['code']); // USER INPUT DATA
$status = 'A'; // FIXED
$stmt = $connect->prepare("SELECT s_id FROM events WHERE s_code = ? AND s_sta... | 2014/10/13 | [
"https://Stackoverflow.com/questions/26338107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1826238/"
] | Here is my countdown timer:
***QuestionCountdownTimer***
```
public class QuestionCountdownTimer extends CountDownTimer {
private TextView remainingTimeDisplay;
private Context context;
public QuestionCountdownTimer(Context context,long millisInFuture, long countDownInterval,TextView remainingTimeDisplay) {
sup... | You should use handler
```
private Handler tickResponseHandler = new Handler() {
public void handleMessage(Message msg) {
int time = msg.what;
//make toast or do what you want
}
}
```
and pass it to MyCountDownTimer constructor
```
private Handler handler;
public MyCountDownTimer(long start... |
48,572,428 | I am working on an Excel workbook that has one initial sheet. This first sheet is a form that asks the users how many items in their project they have. The macro then generates a sheet for each item in their project.
Each generated sheet has buttons that perform specific functions, and these buttons have click events ... | 2018/02/01 | [
"https://Stackoverflow.com/questions/48572428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2796352/"
] | You could create a sheet named "Template" (potentially hidden) that would contain all the code and buttons and then use something like this:
```
Sheets("Template").Copy After:=Sheets(Sheets.count)
```
At this point, the Activesheet will be the newly copied sheet, so you can define a variable to refer to it and make ... | As @cyboashu said, just copy the sheet and it will copy all formulas and formatting over. At that point, any additional changes that are needed can still be made to the individual sheets. They are not linked copies.
Here's a quick and dirty macro to copy worksheet(1) to the end of the workbook and rename. If you need ... |
60,240 | In the following context is the word 'would' correct at all or do we have to use 'will'?
>
> Some countries grow hashish, and sometimes they **would** smuggle it to other countries.
>
>
> Some countries grow hashish, and sometimes they **will** smuggle it to other countries.
>
>
>
What is the difference between... | 2012/03/06 | [
"https://english.stackexchange.com/questions/60240",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/17953/"
] | *Would* makes it sound past tense. Also, "*they*" doesn't sound right, because countries don't smuggle, people do.
I prefer either:
>
> Some countries grow hashish; sometimes it gets smuggled it to other
> countries.
>
>
>
or:
>
> Some countries grew hashish; sometimes it would be smuggled it to
> other cou... | *Would* is the past tense: 'People grew hashish, and sometimes they would smuggle it across the border' (habitually: if you mean specific instances 'sometimes they smuggled it'). It can be used even if hashish is still being grown ('Hashish has been grown in the region for centuries, and sometimes people would smuggle ... |
680,138 | What is a good way for an ActiveX control to detect that its container (or container's container) is Internet Explorer?
Currently, I am doing this by calling the control's IOleClientSite::GetContainer method and checking whether the container implements the IHtmlDocument2 interface, but now, I would like to check all ... | 2009/03/25 | [
"https://Stackoverflow.com/questions/680138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13316/"
] | in the FragmentShader, you can write:
```
uniform sampler2D A;
vec3 result = vec3(texture(A, TexCoord).r);
```
in the cpp file,you can write:
```
glTexImage2D(
GL_TEXTURE_2D, 0, GL_RED,
dicomImage->GetColumns(), dicomImage->GetRows(),
0, GL_RED, GL_UNSIGNED_BYTE, pixelArrayPtr);
``` | You would use `GL_LUMINANCE` format in old versions of openGL, but now in modern 3.0+ OpenGL versions `GL_LUMINANCE` is deprecated, so new way of doing it is to use `GL_RED` format, but that would result in a red texture, so to get around this you should create a costum shader as above answers have shown, in that shade... |
265,482 | Imagine I want to make a laser of electrons like a laser of light. Is that possible, or does the Pauli exclusion principle prohibit that? | 2016/06/30 | [
"https://physics.stackexchange.com/questions/265482",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/103999/"
] | This is almost a duplicate then of *[Pauli exclusion principle in an electron beam](https://physics.stackexchange.com/questions/176481/pauli-exclusion-principle-in-electron-beam)*. Almost because it asks about cathode ray beams. The answer there is yes; the Pauli exclusion principle plays a role similar to the neutron ... | Lasers operate via the stimulated emission of light. This is a phenomenon that applies to bosons, since the stimulated photon is in the same state as the photon that stimulates it.
The same thing cannot happen in fermions; instead there is an analogous process called stimulated absorption which means that the intensit... |
820,526 | Does anyone know where I can find an implimentation that wraps a `std::map` and makes it thread safe? When I say thread safe I mean that it offers only serial access to the map, one thread at a time. Optimally, this map should use only the standard-library and / or boost constructs. | 2009/05/04 | [
"https://Stackoverflow.com/questions/820526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25882/"
] | Does not meet the criteria that you have specified, but you could have a look at the [TBB](http://www.threadingbuildingblocks.org/) containers. There is so called `concurrent_hash_map` which allows multiple threads to access concurrently the data in the map. There are some details, but everything is nicely documented a... | You might look at [Thread Safe Template Library](http://freshmeat.net/projects/tstl/) |
439,688 | I have a log file, each line in the log is prepend with a date, like so:
`2012-03-06 11:34:48,657 blah blah blah...`
How do I `grep` this file and get only the lines from 8am to 11pm only?
My intention is I want to count the number of errors happening within 8am to 11pm. | 2012/06/21 | [
"https://superuser.com/questions/439688",
"https://superuser.com",
"https://superuser.com/users/34680/"
] | ```
egrep '^[^ ]+ (0[89]|1[0-9]|2[012]):'
```
Detailed explanation can be found in various [regex](http://en.wikipedia.org/wiki/Regular_expression) (regular expression) tutorials; `egrep` uses "POSIX extended" syntax (`man 7 regex`).
* The first `^` means "start of the line".
* `[^ ]+` just matches the date field, r... | There's actually a much easier way to do this.
Download/Documentation: [autodrgrep.kl.sh](http://www.kinglazy.com/grep-date-range-in-log-files-awk-sed-linux-unix.htm)
**Command:**
```
./autodrgrep.kl.sh notchef /tmp/client.log '2016-05-08_08:00:00,2016-05-08_23:00:00' 'INFO' 'a2ensite' 5 10 -show
```
... |
166,641 | Introduction:
-------------
The best options for the glass of your house will:
1. Let through as little heat as possible in both directions (insulation-value `Ug`).
(2. Let through as much sunbeams as possible from the outside to the inside.)
(3. Let through as much light as possible from the outside to the i... | 2018/06/11 | [
"https://codegolf.stackexchange.com/questions/166641",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/52210/"
] | JavaScript (ES6), ~~111~~ 109 bytes
===================================
```javascript
s=>'_FQLKIe%f:}'.charCodeAt((g=c=>~-s.split(c).length)(/\W/)+3*g` `+6*g`r`+8*g`f`)*5%117/(g`g`?8:g`|`?6:4)*.3
```
[Try it online!](https://tio.run/##XZJRT4MwFIXf9yvui2k7XAsDNsSwxRiXLC4hPvmgRiaj3XQZpiVG4/SvI5QWjX1p8nFyzrmXPq/f1iqXu9... | Excel & CSV, 194 bytes
======================
```
,"=HLOOKUP(SUBSTITUTE(SUBSTITUTE(A1,""g"",),""/"",""|""),2:3,2,)*IF(CODE(A1)=47,1.5,1)*IF(RIGHT(A1,1)=""g"",0.75,1)"
|,||,| |,|+|,|++|,|+++|,|r,||r,|f,||f
5.8,2.7,1.85,1.45,1.2,0.7,3.4,2.1,2.8,2
```
Input entered before the first `,`n and saved as `CSV`.
When opened ... |
308,158 | In C++, it is possible to write an overriding for a base class's method even if the visibility declaration of the two don't match.
What are the possible design considerations under the decision of not considering the visibility in the overriding rule?
Consider this piece of code as an example:
```
class A{
public... | 2016/01/23 | [
"https://softwareengineering.stackexchange.com/questions/308158",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/181877/"
] | >
> The above compiles in clang, and running it prints B::f, showing that
> it is possible to call a private function of B from outside the class,
> thus breaking encapsulation.
>
>
>
The encapsulation isn't broken. It's B that's semi-broken. B publicly inherits from A. A's public interface *is* B's public inter... | It's absolutely intentional. Changing the visibility must (at most) change whether your code compiles or doesn't compile. It must never, ever change what the code does. If B::f() were public, then you would expect B::f() to be called. The fact that you made b::f() private cannot change this, according to the rule above... |
8,750 | It's being rather a tough choice on selecting projects. (Different case from what I had posted before.) Now in the scenario if there is Project A and B. Only one project can be executed and that has to be chosen. Both are given the same resources, costing/budgeting. Project A would generate revenue of 100$, and senior ... | 2013/02/21 | [
"https://pm.stackexchange.com/questions/8750",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/5633/"
] | TL; DR
------
Project selection is the job of the project sponsor, product manager, or steering committee. It is *not* the job of the project manager. *Very Bad Things™* (mostly for you) will often result from this.
Why You Shouldn't Do What You're Doing
--------------------------------------
Part of the problem her... | I haven't attended this course, but I'll cite it because it seems relevant
[How to Prioritize Projects When Each One is Critical](http://www.pduotd.com/2013/03/01/how-to-prioritize-projects-when-each-one-is-critical-10/).
I have no affiliation with the vendor - I just hoped it might help the OP (and provide some PDU's... |
1,065 | I just got finished a few weeks ago setting up my `torrc` to require connections to U.S. ExitNodes. I just used Vidalia to get into the "Tor Configuration File", and edited that. Worked great. Now I've downloaded the new Tor bundle (3.5) and, whoah, Vidalia is gone, and my ExitNodes are no longer constrained in the sam... | 2013/12/20 | [
"https://tor.stackexchange.com/questions/1065",
"https://tor.stackexchange.com",
"https://tor.stackexchange.com/users/618/"
] | Tor Browser Bundle uses the `Data/Tor/torrc` file inside its own directory.
From [Tor Project FAQ](https://www.torproject.org/docs/faq.html.en#torrc):
>
> If you installed Tor Browser Bundle, look for `Data/Tor/torrc` inside
> your Tor Browser Bundle directory.
>
>
> Core Tor puts the torrc file in `/usr/local/et... | Tor browser now uses `./Data/Tor/torrc-defaults`. In `./Data/Tor/torrc`, there's the warning:
>
> This file was generated by Tor; if you edit it, comments will not be preserved
>
> The old torrc file was renamed to torrc.orig.1 or similar, and Tor will ignore it
>
>
>
This is somewhat confusing, because in th... |
10,653,604 | I have an object called "message"
"message" holds an anonymous object (as a string):
```
{"action":"wakeup","hello":"testing123"}
// this is what I get when I output "message" with alert()
```
How do I address/get the content of "hello" from that? | 2012/05/18 | [
"https://Stackoverflow.com/questions/10653604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1284740/"
] | I think this is a JSON object so you should use the eval function to convert it to json and you can use it as a property of variable that will contain the result of convertion | Since your using JSON and jQuery I'll assume that you're getting the data from an AJAX call. You could use the `$.getJSON()` method which will give a nice fully formed Javascript object.
If that's not correct you should be calling `eval()` on the message string to create a Javascript object. |
27,454,350 | I'm trying to compress pdf files using ghostscript like this:
```
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -sOutputfile=output.pdf input.pdf
```
I've done this successfully in the past, but for some reason now it won't work. I get the following error:
```
GPL Ghostscrip... | 2014/12/13 | [
"https://Stackoverflow.com/questions/27454350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570251/"
] | This worked for me...
```
gs \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/printer \
-dNOPAUSE \
-dQUIET \
-dBATCH \
-sOutputFile=output.pdf \
input.pdf
```
**Edited by -kp-**
To spell it out explicitly (and to re-iterate what KenS wrote in his comment):
1. `-SOutputFile=... | It could be that you have simply mixed up your input and output filenames. I have done that before and got the same message. It's easy to do, since the output file command comes before the input file. |
30,070,233 | I have a text like this:
```
my text has $1 per Lap to someone.
```
Could anyone tell me how to pick the `per` part from it. I know how to pick the `$` amount. It's like this:
```
new Regex(@"\$\d+(?:\.\d+)?").Match(s.Comment1).Groups[0].ToString()
```
Any help would be highly appreciated. | 2015/05/06 | [
"https://Stackoverflow.com/questions/30070233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1077309/"
] | In case you have multiple substrings you need inside a larger string, you can use capturing groups.
To obtain the `per` part, use the following regex and grab the `Groups[2].Value`:
```
var str = "my text has $1 per Lap to someone. ";
var per_str = new Regex(@"(\$\d+(?:\.\d+)?)\s*(\p{L}+)").Match(str).Groups[2].Value... | ```
(?<=\$\d+(?:\.\d+)?\s+)\S+
```
This should do it for you. |
8,014 | According to [this answer,](https://stackoverflow.com/a/664779/5394409) the stack grows downward. It's in §4.4 of the cited document:
>
> As another example, the DEC PDP11 range has a hardware
> stack which grows with decreasing store addresses.
>
>
>
Now, but the way this works is by the pre-decrement and post-... | 2018/10/20 | [
"https://retrocomputing.stackexchange.com/questions/8014",
"https://retrocomputing.stackexchange.com",
"https://retrocomputing.stackexchange.com/users/576/"
] | The PDP-11 was especially designed to allow code to be written in either of the three common addressing schemes:
* Zero Address (Stack)
* On Address (Acumulator)
* Two Address
There's a quite nice paper Gordon Bell (et. al) wrote [describing the PDP-11 architecture](https://gordonbell.azurewebsites.net/CGB%20Files/Ne... | Doesn't it really depend on how you draw your memory.
```
________ ________
FFFF| | 0000| |
| map 1 |down | map 2 | ^
| | v | |up
0000|________| FFFF|________|
```
If it is a decreasing address, then in map1, it grows downward... |
22,513,289 | I have a csv file which contains millions of rows. Now few of the rows contains more data then column data type can accommodate. For e.g. csv file has only two rows as shown below please not ^\_ is delimiter
```
A^_B^_C
AA^_BB^_CC
```
Now assume each line can accomodate only one character so line 1 row 1 is correct ... | 2014/03/19 | [
"https://Stackoverflow.com/questions/22513289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/449355/"
] | ```
awk -F'\\^_' -v OFS=':' '
{
for (i=1;i<=NF;i++) {
if (length($i) > max) {
max = length($i)
lineNr = NR
line = $0
fldNr = i
fld = $i
}
}
}
END {
print lineNr, line
print fldNr, fld
}
' file
``` | Here's an answer that requires defining the column lengths in a single line file using the same delimiter as the data ( assuming different columns can have different acceptable lengths ):
```
1^_1^_1
```
Using that file (which I called `clengths`) and using `split()` in an lazy way to get indexed elements:
```
awk ... |
58,786,375 | I'm a beginner for programming still a student. I tried to create a .txt file in C to write data, save it and after to read what I have written. And I did, it running smoothly in integer format, but when I tried to use characters (sentences), when I use spaces in my input eg:- Hi, My Name is Dilan.... It's only print H... | 2019/11/10 | [
"https://Stackoverflow.com/questions/58786375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12349956/"
] | Try to use `fgets(txt, 400, stdin)`
instead of `scanf("%s", &txt)` | What are you tiping in console or something else input stream is saved in a buffer("string") in operation system, your C program acces this buffer, so when you call scanf it read from that buffer, your problem is because you use %s data specificator, which read a string while the character readed is different of blank ... |
33,798,600 | I have a mobile application which needs to display images which will be sent to it via REST API. How do I tranfser images ove the API? I am developing a ASP.net Web API using C#.
I tried converting image to base64 then send it though API to the mobile device, but this seems to take a lot of time as I have to send larg... | 2015/11/19 | [
"https://Stackoverflow.com/questions/33798600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1650891/"
] | If you want to sent the images alongside other data in one request using base64 is the best way.
You could think of using gzip to compress the image data to reduce the size. An other way would be to send the images in a reduced size to your android client alonside with a URL to a fully sized image. This enables you t... | If you want to send image or a file through REST Api then it should be implement through Multipart request.
Please refer [here](http://www.jayway.com/2011/09/15/multipart-form-data-file-uploading-made-simple-with-rest-assured/) how it make your work easy.
You can also use [Retrofit](http://square.github.io/retrofit/) ... |
118,973 | I'm currently preparing to leave my company and writing extended documentation on the system for an eventual successor. An important note: I was the sole developer on the whole project for the last three years and did everything from planning, testing, distribution, etc. by myself. So nobody else has any idea what and ... | 2018/09/10 | [
"https://workplace.stackexchange.com/questions/118973",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/76538/"
] | In a situation like yours, a good starting point is to present the current use of Git as the rule.
Add simple instructions like
* Where do I get the current code? **Check out the Git repository XYZ**.
* How do I make modifications to the code? Use development environment ABC, modify code and **commit changes to Git ... | On some days you made changes, which look good first (they compile) but terrible later on.
When you notice such mistakes, you can roll out the better-working old code in an instant, or invest work hours into finding and undoing your changes -> while others have to work with software which doesn't work as intended. Both... |
5,333,871 | I am doing a build on a 32bit SLES10 machine. Using GCC 3.4.2
Here is a sample error
```
`.L8245' referenced in section `.rodata' of CMakeFiles/myproj.dir/c++/util/MyObj.o: defined in discarded section
`.gnu.linkonce.t._ZN5boost9re_detail9reg_grep2INS0_21grep_search_predicateIPKcSaIcEEES4_cNS_12regex_traitsIcEES5_S5... | 2011/03/17 | [
"https://Stackoverflow.com/questions/5333871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64758/"
] | This is typically due to 2 different .cpp's being compiled with different compiler switches - but also using the same templates. The generated template instantiations may differ in what they define/reference, and if the instantiation that is selected doesn't define/refer to the exact same symbols as the ones that got d... | This may be due to using a newer version of binutils. binutils version 2.15 treated this as a non-fatal error, but later versions of binutils changed and so the link started failing. See <https://bugzilla.redhat.com/show_bug.cgi?id=191618> for a similar report.
In my case, I was able to get things to link once more by... |
14,897,826 | How can u get my webworks app to pop open the blackberry 10 share panel?
Ex: open a website in the browser, click the overflow button and then click share
Thank you! | 2013/02/15 | [
"https://Stackoverflow.com/questions/14897826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/997410/"
] | You'll want to look at the invokeTargetPicker API.
Essentially, you create a request
```
var request = {
action: 'bb.action.SHARE',
// for a file
uri: 'file://' + path,
// for text you'd use 'data'
data: 'I am awesome',
target_type: ["APPLICATION", "VIEWER", "CARD"]
};
```
Then you call the API
```
... | This should be an option that appears on any link, image or Text: "Share". Is the item not present in the Cross Cut menu shown? |
40,289,427 | I want to create a linked list with classes. I have two classes, one LinkedList and another LinkedNode. My problem is that my function InsertAtEnd always delete the current node. So when I want to print my linked list, I can't see anything.
I know thanks to debugger that in the function InsertAtEnd, we don't enter in t... | 2016/10/27 | [
"https://Stackoverflow.com/questions/40289427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7037642/"
] | `tmp` is the last Node, so if you don't want to delete it you shouldn't write value `data` in it. You should link it with the new Node, which you named `node`.
Instead of
```
tmp->setData(data);
tmp->setNext(nullptr);
```
You should write
```
tmp->setNext(node)
``` | At the end of the loop, the `tmp` is the last node in the current list. As you want to add the new `node` after the last node, you need to
```
tmp->setNext(node);
```
to append it (and not set the data as the data are already set to the new `node`).
Also note that you actually do not need to iterate through the ent... |
23,570,273 | When you click on the initial link to go to my website and go on the web page with the accordion the accordion appears and hides at 1500 as requested. However when i click on the headings to bring the text up nothing appears. The heading just highlights. There are no errors and the console log states "ready to do some ... | 2014/05/09 | [
"https://Stackoverflow.com/questions/23570273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3616649/"
] | You need to use [**`.change()`**](http://api.jquery.com/change/).
```
$('.section .container-items input').change( function(){
$(this).parent().removeClass('red').siblings().addClass('red');
});
```
[**Example Here**](http://jsfiddle.net/UDZaN/) | `[**Fiddle Demo**](http://jsfiddle.net/cse_tushar/dJgKE/)`
```
var chck = $('.section .container-items input');//cache selector
chck.change(function () { //change event
chck.filter(':not(:checked)').parent().addClass('red'); //add red to class red to parent if not checked
chck.filter(':checked').parent().remov... |
29,696,717 | `undefined method 'each' for nil:NilClass`
OK so, I know that there is hundreds questions that are talking about that.
I know what this error message means, and I know how to deal with that.
My question is : Is there a way to force the nil class to return an empty array?
My second question : Would it be safe ?
... | 2015/04/17 | [
"https://Stackoverflow.com/questions/29696717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4328084/"
] | 1) Of course, you could patch *nil* (there is always only one *nil* object in Ruby thread, so you could patch it, and not NilClass):
```
def nil.each
puts 'Hey'
end
nil.each #outputs 'hey'
```
2) But you should **never** do things like that, because it could break a lot of things inside a lot of libraries and eve... | If you are using something like `@products`..try ternary operator
```
@products = @products.present? ? @products : []
```
Yes it's safe if you handle it properly using empty and check the relevant values that you need before you proceed ahead or save them |
49,522,326 | I want to send a json with Ajax to the Spring MVC controller but I can not get anything, I do not know what I'm failing
Javascript:
```
var search = {
"pName" : "bhanu",
"lName" :"prasad"
}
var enviar=JSON.stringify(search);
$.ajax({
type: "POST",
contentType : 'application/json... | 2018/03/27 | [
"https://Stackoverflow.com/questions/49522326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9387062/"
] | I think you made things complicated,in fact,if you have a ***Search*** object defined,you can past the data directly to the Controller method,and **SpringMVC** will form an instance of the search object for you,try as below:
```
var search = {
pName : "bhanu",
lName :"prasad"
};
$.ajax({
type: "POST",
... | ```
var fullName = $("#fullName").val();
var location = $("#location").val();
var capacity = $("#capacity").val();
var guarantee = $("#guarantee").val();
var status = $("#status").val();
var data = {
name : fullName,
capacity : capacity,
guarantee : guarantee,
location : location,
status : status
}
... |
3,394,580 | In shell scripting how to find factorial of a number? | 2010/08/03 | [
"https://Stackoverflow.com/questions/3394580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/409345/"
] | 10! in bash:
```
f=1; for k in {1..10}; do f=$[$k * $f] ; done; echo $f
```
or here in a step by step fashion:
```
$ t=$(echo {1..10})
$ echo $t
1 2 3 4 5 6 7 8 9 10
$ t=${t// /*}
$ echo $t
1*2*3*4*5*6*7*8*9*10
$ echo $[$t]
3628800
``` | You have to use loop, see this link: <http://ubuntuforums.org/showthread.php?t=1349272> |
2,588,502 | This is my pom file:
```
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sia.g7</groupId>
<artifactId>sia</ar... | 2010/04/06 | [
"https://Stackoverflow.com/questions/2588502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/119895/"
] | You should remove the `<scope>system</scope>` clauses from those dependencies.
When the scope is set to system that means the artifact is ALWAYS available, so jar-with-dependencies does not include it. | Unpack your jar and add it to src/main/resources. |
473,932 | In a dark room there are two people and a very faint candle. Then the candle emits one photon. Is it true that only one person can see the photon? Why? And are there any experiments?
Edit 2019/4/23:
Thanks a lot. I was originally asking about quantum mechanical things. Because I believe such an experiment will turn t... | 2019/04/20 | [
"https://physics.stackexchange.com/questions/473932",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/226304/"
] | Seeing = detecting photons that happen to interact with your retina.
You can't see photons when they are just travelling nearby. Take lasers for example. When someone is using laser pointer, the only reason you see the beam is that photons collide with dust and air particles and therefore their direction is changed. ... | Two people cannot see the same photon. Only one person can see a specific photon.
To see a photon, it must be absorbed by a molecule in the retina [1]. The photon then no longer exists, so it is not available to be seen by another person.
[1] [Mammalia retinas can respond to single photons](http://webhome.phy.duke.ed... |
127,325 | I have recently noticed wmpnetwk.exe using a more than usual amount of processor cycles.
I'm on Windows 7 Home Premium on a Netbook.
I'm guessing it's a feature of Windows Media player that recently got turned on, possibly because of a Windows update or accidental key combination.
I don't usually use Media player th... | 2010/04/04 | [
"https://superuser.com/questions/127325",
"https://superuser.com",
"https://superuser.com/users/7891/"
] | Solution
========
You can use the `taskkill` command.
**Note**: The command is not available in Windows XP Home/Starter Edition.
Examples
--------
```
taskkill /IM app.exe
taskkill /IM app*.exe
```
Further reading
---------------
* [Taskkill](http://technet.microsoft.com/en-us/library/bb491009.aspx) | With PowerShell, you can use `Stop-Process` supplying either an id or name |
19,906,078 | ```
public class TestReturn {
int i = 0;
public static void main(String[] args) {
TestReturn t = new TestReturn();
System.out.println(t.test());
System.out.println(t.i);
}
private int test() {
return i++;
}
}
```
output
```
0
1
```
My question is,
1. Si... | 2013/11/11 | [
"https://Stackoverflow.com/questions/19906078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4332075/"
] | It's not the return that's the problem here, it's your usage of the post-increment operator.
What happens with "return i++;" is that the value of i is returned, then the value is incremented. That's why you get 0 and 1 as the values. | If u wanna return `1`, give `return ++i;`
`return i++;` will first return `i`, then increment it;
`i++` can be imagined as another function like (the syntax not applicable to java tough)-
```
preIncrementFunction(int &i){
int j = *i;
*i = *i+1;
return j;
}
```
so, the value getting printed is the un-incr... |
27,126,658 | Which between of the practises is better, style wise?
using the keyword "this" or choosing a different parameter name for the parameter of the constructor?
case1:
```
public class Student {
//variables
private String name;
//constructor
public Student(String name) {
this.name = name;
}
}
```
or cas... | 2014/11/25 | [
"https://Stackoverflow.com/questions/27126658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1205944/"
] | There is no "standard" way of doing this. And you'll find people are split between different "schools of thinking" in regards to readability of code.
My advice would be to go with whichever is most used in your organization, or which you consider to be more readable.
I, for one, prefer to use different names for the ... | I prefer the first one. It can always be used without thinking of new names such as aName. Moreover, this is how, for instance, eclipse generates setters. |
67,811,950 | I'm trying to make a code for finding siRNAs. For now I've made a code that's just finding all possible siRNAs combinations. I also need to find the best ones, which must contain from 30% to 50% of the GC or CG nucleotides.
This program is searching for the 21 nucleotides length sequences with content of CG or GC from... | 2021/06/02 | [
"https://Stackoverflow.com/questions/67811950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13772234/"
] | I tried to figure out what this code does, but I couldn't)) Have you written in another language before? Just specify the input data and the output you want to receive.
Returns **true** if fits the condition (30%-50%). Then you can add it to the list or whatever.
```
def foo(seq: str) -> bool:
"""searching for th... | ```
DNA_seq = input("")
RNA_seq = DNA_seq.replace("T", "U")
N = RNA_seq
iRNA = (N.translate(str.maketrans({"A": "U", "G": "C", "U": "A", "C": "G"})))
iRNA_str = iRNA
K = 4
iRNA_comb = [iRNA[i: j] for i in range(len(iRNA_str)) for j in range(i + 1, len(iRNA_str) + 1) if len(iRNA_str[i:j]) == K]
print("All iRNA comb... |
19,611,603 | So, I've been trying to create a users' activity page for a practice project, that shows all their activity and their friends' activity on a page. I've got this working, but can't order it by date due to the query being nested. The problem is that I have to first get the user's friends', which is in one table then I ha... | 2013/10/26 | [
"https://Stackoverflow.com/questions/19611603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2310431/"
] | [](https://i.stack.imgur.com/GLkW3.gif)
This method does not require subclassing anything. You just add a `UILongPressGestureRecognizer` to the view and set the `minimumPressDuration` to zero. Then you check the state when the gesture events are calle... | Thanks to [Holly's answer](https://stackoverflow.com/a/19612446/1121497) I built a `ButtonView` convenience class.
Edit: As this [answer](https://stackoverflow.com/a/31829331/1121497) says, `UILongPressGestureRecognizer` reacts quite faster so I updated my class.
Usage:
```
let btn = ButtonView()
btn.onNormal = { bt... |
42,261,577 | After I have disabled any button by clicking on it, the button looks like it's disabled but accepts more clicks. I have noted that there is no `<form>` in the page, but adding a `<form>` does not seem to matter.
<https://jsfiddle.net/3y1dn29v/>
Why?
```js
function tally(card, suit) {
cards += card;
suits += s... | 2017/02/15 | [
"https://Stackoverflow.com/questions/42261577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1293245/"
] | You need to set the disabled attribute to true
```
function disableButton(button) {
document.getElementById(button).setAttribute("class", "button disabled");
var x = document.getElementById(button).getAttribute("class");
alert(x);
document.getElementById(button).disabled = true;
}
``` | add `pointer-events: none;` to your `.disabled` CSS |
15,830,411 | I have a table with 105 columns and around 300 rows in Sheet 1. I need in Sheet 2 a reduced version of the same table, filtered by some column values (not the first column).
I've looked at Pivot Tables but it seems that I can not get the same tabular structure. I have tried with Advanced Filter and I get an error:
> ... | 2013/04/05 | [
"https://Stackoverflow.com/questions/15830411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1693172/"
] | Microsoft's PowerQuery addin supports this. One of its many sources can be Excel Data-From Table. | You can use the [add-in for table-valued functions](http://finaquant.com/products/excel-add-in-for-table-valued-functions) I developed to make any operations (including filtering, partitioning, aggregation, distribution etc.) on data tables in Excel.
Each table (ListObject in Excel) is an input or output parameter fo... |
73,377,829 | How do I solve this?
Warning message:
package ‘dplyr’ was built under R version 4.2.1 | 2022/08/16 | [
"https://Stackoverflow.com/questions/73377829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19749572/"
] | This warning appears when you load a package that was built under a version of R different to the one you are running.
You have several options:
* Update R to the latest version
* build/compile dplyr with your current version of A
* ignore the warning
If the difference between your R version and the R version where ... | I think you are trying to install the dplyr package in R4.2.1 and facing this issue.
So you can try this,
In RStudio,
Click on Tools -> install packages.. -> Under packages section type dplyr -> install. |
34,760,765 | I tried to load a large audio dataset and implement audio.spectrogram.
I got this error:
```
$ Torch: not enough memory: you tried to allocate 0GB. Buy new RAM! at /home/XXXX/torch/pkg/torch/lib/TH/THGeneral.c:222
stack traceback:
[C]: at 0xb732c560
[C]: in function '__add'
/home/XXXX/torch/install/share/lua/5.1/audi... | 2016/01/13 | [
"https://Stackoverflow.com/questions/34760765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5118777/"
] | **No**, Torch does not have a memory limit but it requires that certain conditions are met when allocating memory.
If you take a look at [`THGeneral.c`](https://github.com/torch/torch7/blob/3864f3782a74715e35d98176f9014a74524a868a/lib/TH/THGeneral.c#L226-L273) (where the error comes from), you'll see that this error i... | You may have created a CNN model using PyTorch which runs on CUDA automatically if your system has a GPU. **Restart** the system, the memory will be cleared automatically. |
1,952,505 | i needed help refactoring the following class,
Following is a class Operation with variety of Operations in switch :
i want to avoid the switch statement.I read few articles on using polymorphism and state pattern .but when i refactor the classes i dont get access to many variables,properties
Im confused on whethe... | 2009/12/23 | [
"https://Stackoverflow.com/questions/1952505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158297/"
] | In C# you can use functions for the strategy, and using an extension method as the function gives you the ability to add operations as and when required:
```
public enum OperationStatus
{
Success, NotStarted, Error, Fail, InProcess, Free
}
public class Operation
{
// raise this event when operation completes
... | I'd like you to check if this switch case is likely to be spawn at multiple places. If it is just isolated to one place, you may choose to live with this. (The alternatives are more complex).
However if you do need to make the change,
Visit the following link - <http://refactoring.com/catalog/index.html>
Search ... |
8,587,330 | This is the overview of my problem:
I am adding (and confirm they are added) about 1400 relationships loaded from a soap service into CoreDat. After I close the app and open it again some of the relationships are lost; I only see around 800 of them (although it varies). Also, I am not getting any errors.
And now, mor... | 2011/12/21 | [
"https://Stackoverflow.com/questions/8587330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/458365/"
] | ```
NSMutableSet *userServices = self.user.services;
...
[userServices addObject:service];
```
Can't do that. `self.user.services` does not return a mutable set. That's what that `addServicesObject` method is for. Change the second line to:
```
[self.user addServicesObject:service];
```
F... | I had the same issue the relationship to another entity lost every time I restart the app. I searched for hours. In the end I found the issue.
I declared my relationship as **`Transient`**, this caused the issue.
 |
19,357,667 | I have something like this:
```
public function options()
{
$out = '';
$docs = $this->getAll();;
foreach($docs as $key => $doc) {
$out .= ',{"label" : "' . $doc['name'] . '", "value" : "' . $doc['id'] .'"}';
}
return $out;
}
```
It gives me a list... | 2013/10/14 | [
"https://Stackoverflow.com/questions/19357667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2463411/"
] | test $out to see if it has any length, if so add the comma and the line, otherwise just set it to be the line:
```
$out="";
foreach($docs as $key=>$doc){
if(strlen($out)){
$out.=',{"label" : "' . $doc['name'] . '", "value" : "' . $doc['id'] .'"}';
}else{
$out='{"label" : "' . $doc['name'] . '",... | I'd suggest using an [array](http://php.net/manual/en/language.types.array.php) instead to hold the individual values, and using [join](http://uk1.php.net/manual/en/function.join.php) to concatenate them together.
```
public function options()
{
$docs = $this->getAll();
// Create an empty array
$items =... |
16,383 | ***Background:*** I & the wife are looking to buy a house priced at $250k via an FHA loan.
One of the requirements for the loan is that we have a 2 year continuous employment.
I have a 1 year gap in income(i.e. I **was employed but not paid** because I wasn't working on any project)
Anyways, after that 1 year gap, as ... | 2012/08/09 | [
"https://money.stackexchange.com/questions/16383",
"https://money.stackexchange.com",
"https://money.stackexchange.com/users/3282/"
] | Do you need to put down 25% on a conventional loan? Conventional loans can be done with 5%, 10%, or 20% down (if you're willing to pay PMI for the <20% down scenario).
If you don't like FHA's terms, don't do an FHA loan.. | These are your options:
* Wait until you have two years of continuous employment.
* Get a family member to gift you enough of a down payment to exceed 20%. You need $50,000 to reach the 20% level. Due to gift tax rules that will mean that the money will have to come from multiple people, or the donor will have to file... |
25,833,956 | Should not be needed create an instance of a class to access a public constant. I recently started working in Swift, so I must be missing something here.
In this simple example:
```
public class MyConstants{
public let constX=1;
}
public class Consumer{
func foo(){
var x = MyConstants.constX;// Com... | 2014/09/14 | [
"https://Stackoverflow.com/questions/25833956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2700303/"
] | Use `struct` with `static` types.`struct`are more appropriate as in `enum` you can only bind one type of associative values but you can contain the "Type Property of any type" in both.
```
public struct MyConstants{
static let constX=1;
}
public class Consumer{
func foo(){
var x = MyConstants.constX;
... | If you want a constant, you can also "fake" the as-yet-unsupported class variable with a class computed property, which does currently work:
```
public class MyConstants{
public class var constX: Int { return 1 };
}
public class Consumer{
func foo(){
var x = MyConstants.constX; // Now works fine.
}... |
42,132,789 | ```
[
{
"Book ID": "1",
"Book Name": "UNIX **<script type='text/javascript'>alert('test')</script>**",
"Category": "Computers",
"Price": "113"
},
{
"Book ID": "2",
"Book Name": "Book two",
"Category": "Programming",
"Price": "562"
}
]
```... | 2017/02/09 | [
"https://Stackoverflow.com/questions/42132789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2118565/"
] | The point of an `std::map` is to provide an efficient **key to value** mapping. What you need is an additional **value to key** mapping - that can be achieved in multiple ways:
* Have with an extra `std::map` that goes from `Position` to `std::vector<ID>`.
* Use some sort of *spatial partitioning* data structure *(e.... | You need to provide a reverse mapping. There are a number of ways to do this, including `multimap`, but a simple approach if your mapping isn't modified after creation is to iterate over the map and build up the reverse mapping. In the reverse mapping, you map value -> list of keys.
The code below uses `std::unordered... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.