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 |
|---|---|---|---|---|---|
39,400,439 | I have a green navigation bar and a green table view header that together look like this:
[](https://i.stack.imgur.com/BTalO.png)
But when the user scrolls the table view down it appears like this:
[
bgView.backgroundColor = UIColor.green
bgView.autoresizingMask = .flexibleWidth
tableView.addSubview(bgView)
``` |
10,927,550 | I've made a simple calendar where you can select year and month through a dropdown list.
```
<form name=calenderselect method='post' action='calendar.php'>
<select name='month' id='month'>
<option>January</option>
<option>Februari</option>
<option>March</option>
....
</select>
<input type='submit' name='submit' valu... | 2012/06/07 | [
"https://Stackoverflow.com/questions/10927550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1399283/"
] | here you are: `<select name='month' id='month' onclick="this.form.submit()">`
but i guess you really want to submit the form by `onchange` event. | Add a javascript event on your select :
```
<select name="month" id="month" onChange="yourjsfunction()">
``` |
4,285,214 | I am fitting a model to factor data and predicting. If the `newdata` in `predict.lm()` contains a single factor level that is unknown to the model, *all* of `predict.lm()` fails and returns an error.
Is there a good way to have `predict.lm()` return a prediction for those factor levels the model knows and NA for unkno... | 2010/11/26 | [
"https://Stackoverflow.com/questions/4285214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/452096/"
] | You have to remove the extra levels before any calculation, like:
```
> id <- which(!(foo.new$predictor %in% levels(foo$predictor)))
> foo.new$predictor[id] <- NA
> predict(model,newdata=foo.new)
1 2 3 4
-0.1676941 -0.6454521 0.4524391 NA
```
This is a more general way ... | A quick-and-dirty solution for split testing, is to recode rare values as "other". Here is an implementation:
```
rare_to_other <- function(x, fault_factor = 1e6) {
# dirty dealing with rare levels:
# recode small cells as "other" before splitting to train/test,
# assuring that lopsided split occurs with prob < ... |
51,707,790 | Im learning how to program and I would like to toggle between hiding and showing an element with JavaScript. The script is shown below. It works but instead of showing the solution once the program runs, I would like to have it hidden so that the user can click and see the solution. I would like to have it the other wa... | 2018/08/06 | [
"https://Stackoverflow.com/questions/51707790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10170226/"
] | You can use the hidden attribute/property on the element to toggle the visibility instead.
You should also remove any spaces you have in `id=""` to be able to properly get the element by id
```js
function SolutionFunction() {
var x = document.getElementById("solution");
x.hidden = !x.hidden
}
```
```css
#solu... | Stop the spaces!
```
function SolutionFunction() {
var x = document.getElementById("solution");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
#solution {
width: 100%;
padding: 50px 0;
text-align: center;
background-color: lightblue;
margin... |
60,588,727 | I am trying to code the implementation of the Cube, Stack example given in this [Coursera course example of Towers of Hanoi](https://www.coursera.org/lecture/cs-fundamentals-1/4-2-tower-of-hanoi-introduction-aLUTd) to learn more C++.
In `stack.h` I have to implement:
```
class Stack {
public:
void push_back(const Cu... | 2020/03/08 | [
"https://Stackoverflow.com/questions/60588727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7093241/"
] | Based on the function signature, you have to implement, you really can't. Typically, you'd guard this sort of thing with an assertion. In some situations you might use the [NullObject pattern](https://en.wikipedia.org/wiki/Null_object_pattern), or you could return a junk object. In newer C++ versions, you can also use ... | As [pyj](https://stackoverflow.com/users/1265214/pyj) noted, since c++17 there is a new mechanism to do so (adopting boost::optional idea). This is the *std::optional* container. When using *std::optional*, you tell the user of this function, that he might get an **empty response**, and therefore, he must check whether... |
56,004,908 | Assume there are numerical variables: a, b, c, d, e..., and I want to compare a and b first, pseudo code:
```
if a > b:
if a > b+c:
if a > b+c+d:
...
else:
...
else:
...
else:
...
```
go forward one by one, I don't want such ma... | 2019/05/06 | [
"https://Stackoverflow.com/questions/56004908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8294738/"
] | If you make a list out of those variables, you can compare `a` to the cumulative sum of that list, and find the first index where it's `False`:
```
import numpy as np
b=1
c=2
d=7
e=10
a=8
x = [b,c,d,e]
np.argmin(np.greater(a,np.cumsum(x)))
```
Try it out! | A pseudo code to do this using a list. Please note that this is just a pseudo-code. You will have to modify it appropriately to suit your needs.
In the below solution, we try to add all parameters into a list. Since list is ordered. We can pick up the parameters in order to compare their sum with `a`.
```
a = 1000
b ... |
69,887,097 | I am using datetime-local input type in HTML, but I don't want to use the "T" on the output. I want to only get the date and time with a space between.
```
<input type="datetime-local" id="date" name="date">
```
The output is:
```
2021-11-08T16:34
```
What i want is:
```
2021-11-08 16:34
```
What do i need to ... | 2021/11/08 | [
"https://Stackoverflow.com/questions/69887097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17338283/"
] | You can define 2 capture groups and check them
```
df = pd.DataFrame(
{'txt': ['firstname lastname (1937-2015)', 'firstname lastname (1780-1820)',
'firstname lastname (1945-?)', 'firstname lastname (1980-2022)']})
df[['birth', 'death']] = df['txt'].str.extract(r'(\d+)-(\d+|\?)').replace({'?': None}).... | A generic regex solution to extract the second year (from 1800 to 2099) in Pandas using `Series.str.extract` you can leverage
```py
import pandas as pd
df = pd.DataFrame({'col':['firstname lastname (1937-2015)']})
yr = r'(?:1[89][0-9]{2}|20[01][0-9]|202[01])'
df['second_year'] = df['col'].str.extract(fr'(?s)(?<!\d){yr... |
7,823 | In the comment to [this great post](http://www.owenpellegrin.com/blog/testing/how-do-you-solve-multiple-asserts/), Roy Osherove mentioned the [OAPT](http://rauchy.net/oapt/) project that is designed to run each assert in a single test.
The following is written on the project's home page:
>
> **Proper unit tests sho... | 2010/09/28 | [
"https://softwareengineering.stackexchange.com/questions/7823",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/1716/"
] | The goal of the unit test is to give you as much information as possible about what is failing but also to help accurately pinpoint the most fundamental problems first. When you know logically that one assertion will fail given that another assertion fails or in other words there is a dependency relationship between th... | Yes, it is ok to have multiple assertions *as long as* a failing test gives you enough information to be able to diagnose the failure. This is going to depend on what you're testing and what the failure modes are.
>
> Proper unit tests should fail for exactly one reason, that’s why you should be using one assert per ... |
31,127,797 | I have two class like this:
```
class one
{
public $var1 = 'anythig';
}
class two
{
public $var2 = 'anythig';
}
```
I want to know when I create a object instance of these classes what happens? My point is about the values stored in the memory. In reality I have some big class, and my resources are limited.... | 2015/06/30 | [
"https://Stackoverflow.com/questions/31127797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The `videoUrl` parameter did not point to the right file.
Use this approach when referencing videos locally:
```
let filename = "yourvideo.mp4"
let allDirs = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let documentsDir = allDirs[0] as! NSString
let filePath = documen... | The NSURL can mean two different things :
1. The absolute file path that you mentioned i.e. starting with file://
2. The URL that you get from ALAsset. You can get it using :
NSURL \*asseturl = [asset valueForProperty:ALAssetPropertyAssetURL];
where "asset" is of type ALAsset
This URL can then be used to get AVAsse... |
51,815,123 | I have a model called `ImportTemp` which is used for store imported XLSX file to database. I'm using ActiveStorage for storing the files.
this is the model code:
```
class ImportTemp < ApplicationRecord
belongs_to :user
has_one_attached :file
has_one_attached :log_result
end
```
this is my import controller c... | 2018/08/13 | [
"https://Stackoverflow.com/questions/51815123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8252171/"
] | I ended up using `Tempfile` as suggested by George Claghorn. I don't know if this is the best solution or best practices, but it works for me now. I'm going to use this solution while waiting Rails 6 stable to come out with `ActiveStorage::Blob#open` feature.
```rb
def perform(file_id)
import = ImportTemp.find(fi... | The answer now seems to be (unless I am missing something):
```
Creek::Book.new file.service_url, check_file_extension: false, remote: true
``` |
64,614,976 | I'm trying to add a delay in one of my loops but I get unexpected results. I've looked at many similar questions but since I'm trying to learn javascript I want to know why this isn't working and how I can get it to work.
If you look at the script below, shouldn't it go like this:
1. cars[1]
2. sleep(); (wait 3 sec t... | 2020/10/30 | [
"https://Stackoverflow.com/questions/64614976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9370976/"
] | The `setTimeout()` function doesn't block. It calls the function passed to it after the time out. You can just tell it to call `main`.
```
function main() {
var cars = ["Saab", "Volvo", "BMW"];
if (nr !== qty) {
console.log(cars[nr]);
nr++;
sleep(3, main);
}
}
function sleep(timeou... | [setTimeout](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals) does not interrupt the main thread. Instead, it registers your callback function and continues executing upcoming lines.
To get your desired output, we need to have callbacks here and there. This is something ca... |
39,409,341 | The following is my controller file:
```
class BiodataController < ApplicationController
def store
@user=params[:username]
@age=params[:age]
@gender=params[:gender]
@mstatus=params[:mstatus]
@language=params[:language]
@email=params[:email]
@mobile=params[:mobile]
if params[:username... | 2016/09/09 | [
"https://Stackoverflow.com/questions/39409341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5063789/"
] | For today's TypeScript and Angular 5, avoiding `WARNING in Circular dependency detected` when importing the global injector, first declare a helper, e.g. `app-injector.ts`:
```js
import {Injector} from '@angular/core';
/**
* Allows for retrieving singletons using `AppInjector.get(MyService)` (whereas
* `ReflectiveI... | I've managed to do it using manual boostrapping. Don't use "`bootstrap: [AppComponent]`" declaration in `@NgModule`, use `ngDoBootstrap` method instead:
```
export class AppModule {
constructor(private injector: Injector) {
}
ngDoBootstrap(applicationRef: ApplicationRef) {
ServiceLocator.injector ... |
7,606,633 | Please see this line of code. This is an invocation of a stored procedure, which returns an `ObjectResult<long?>`. In order to extract the long values I added the Select:
```
dbContext.FindCoursesWithKeywords(keywords).Select(l => l.Value);
```
Based on intellisense this Select returns `IEnumerable<long>`.
I'm not ... | 2011/09/30 | [
"https://Stackoverflow.com/questions/7606633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/124132/"
] | Working on an `IEnumerable<T>` means that all further operations will happen in C# code, i.e. linq-to-objects. It does not mean that the query has already executed.
Once you degrade to linq-to-objects all data left at this point needs to be fetched from the database and sent to .net. This can degrade performance drast... | IEnumerable will not hydrate until materialized. If calling a stored procedure I would think that there is no further filter required, I mean you send parameters to a stored procedure to produce the desired subset of data returned. IEnumerable tied to a stored procedure is fine. However if you are fetching the entire c... |
62,134,143 | When its RDBMS, I used Liquibase to deploy the changes in the target database. That has support for multi-tenancy & roll back to different versions.
In Mongo, I tried to find the equivalent library and found the below.
1. <https://github.com/mongobee/mongobee> - Requires java skillset. Last update was 2 Years ago.
2.... | 2020/06/01 | [
"https://Stackoverflow.com/questions/62134143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1154991/"
] | If you are using Java, a very good option(I'd say probably the best) is [Mongock](https://www.mongock.io/).
It provides everything you need and there are very good features in the road map.
To get started(if using Spring 5 and spring data 3), you just need :
1. Add Mongock to your pom
```xml
<dependencyManagement>
... | I'm not familiar with Liquibase and I'm not sure what you mean by "Must be able to extract the changes before execution", but here is another useful MongoDB-specific option that is similar to node-migrate:
<https://www.npmjs.com/package/migrate-mongo>
Also, an article explaining the how / why to use it:
<https://mediu... |
58,231,977 | I am having more than 30000 jobs and executions in my rundeck. Is there any API or CLI so that we can schedule to clean periodically. Because of too many jobs and executions rundeck throws `java.lang.OutOfMemoryError: GC Overhead Limit` and the services gets stops.
Also if there are more number. The UI takes long time... | 2019/10/04 | [
"https://Stackoverflow.com/questions/58231977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6112907/"
] | Using RD CLI you have [this](https://gist.github.com/shamil/1f6524f06210252c7d13d0deb169bdc2) good option. So, if you're using Rundeck 3.1 or above, you can go to Project Settings > Edit Configuration > Execution History Clean (tab) and click on "Enable" checkbox (then you can define the parameters in the same page).
... | if your project is only one, you don't have to run the above script.
Go to Projects, Click on `recent` or `failed` or `running` tab and do a `bulk delete` |
6,437 | I feel like something is wrong with the *", notably" part*, but I can't explain why! Is the following sentence grammatically correct?
>
> Employees give relatively low scores across a variety of characteristics, notably the quality of the Marketing department's decisions, compensation, and having sufficient people re... | 2010/12/08 | [
"https://english.stackexchange.com/questions/6437",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2591/"
] | The only thing I would change in the original sentence is the order or wording of the comma-separated list itself; when I first read it, I thought the Marketing Department was at fault for all three issues. If the items are supposed to be in that particular order as the top 3 results, some extra specifiers might be hel... | Punctuation dictates the flow of your sentence, therefore if you feel that the person reading it should take a short breath at that point, then so be it. If it's really bothering you, take the sentence apart and try to reword it differently.
Personally I find it fits perfectly, both reading it in my head and reading a... |
21,180,931 | So I have this code:
```
import sys ## The 'sys' module lets us read command line arguments
words1 = open(sys.argv[2],'r') ##sys.argv[2] is your dictionary text file
words = str((words1.read()))
def main():
# Get the dictionary to search
if (len(sys.argv) != 3) :
print("Proper format: python f... | 2014/01/17 | [
"https://Stackoverflow.com/questions/21180931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3188565/"
] | Your words is an instance of `str`. You should use `split` to iterate over words:
```
for word in words.split():
print(word)
``` | A `for`-loop takes one element at a time from the "sequence" you pass it. You have read the contents of your file into a single string, so python treats it as a sequence of letters. What you need is to convert it into a list yourself: Split it into a list of strings that are as large as you like:
```
lines = words.spl... |
15,092,173 | I have a report with a typical date column. I want the user to select a start date from @prompt. Then I want the end date to be 3 months less than the user selected start date.
Example:
```
SELECT Date,Y,Z
FROM TABLE
WHERE Table.Date >= @prompt('Enter value(s) for Acct Open Dt','D',Object',Mono,Free,Persistent,,Use... | 2013/02/26 | [
"https://Stackoverflow.com/questions/15092173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1123492/"
] | C++ gives you many tools:
* `string` is a class managing the lifetime of character strings.
* `getline` puts a line from a stream (up to the next newline) into a `string`.
* `istringstream` makes an `istream` out of a `string`
* `istream_iterator` iterates over an `istream`, extracting the given type, breaking on whit... | Put
`sum=0;` // at the top
ps
```
while(cin.peek()!='\n'){
}
``` |
19,963,209 | Thank you in advance for helping out!!!
I have an mySQL statement that works locally:
```
mysql -u root -ppassword -e 'SELECT "Column 1 text" as "Column 1 Heading", table1.* FROM table1;' dataBase1
```
If I try and run it with SSH, it errors out. I don't know how to get the quote in the SQL statement through SSH. ... | 2013/11/13 | [
"https://Stackoverflow.com/questions/19963209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1171852/"
] | Try this:
```
> ethn[ethn < 0.3] <- NA
> ethn
caucasian asian latino
1 NA 1.000 1.000
2 0.723 0.622 0.748
3 NA NA 1.000
4 NA 0.316 NA
5 0.799 0.680 0.737
6 1.000 1.000 1.000
7 1.000 1.000 1.000
``` | The`.default` method for the `is.na<-` function succeeds with data.frames:
```
> is.na(ethn) <- ethn <0.3
> ethn
caucasian asian latino
1 NA 1.000 1.000
2 0.723 0.622 0.748
3 NA NA 1.000
4 NA 0.316 NA
5 0.799 0.680 0.737
6 1.000 1.000 1.000
7 1.000 1.000 1.000
```
... |
3,535,078 | Hi I just installed Tomcat and and am trying to get it up and running however whenever I try to navigate to manager/html it gives me this error "The requested resource (/manager/html) is not available".
The homepage, /docs, /examples all work fine and my logs show nothing. How do I fix this? I'm using Tomcat 6.0.20 a... | 2010/08/20 | [
"https://Stackoverflow.com/questions/3535078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426792/"
] | You have to check if you have the folder with name `manager` inside the folder `webapps` in your tomcat.
```
Rubens-MacBook-Pro:tomcat rfanjul$ ls -la webapps/
total 16
drwxr-xr-x 8 rfanjul staff 272 21 May 12:20 .
drwxr-xr-x 14 rfanjul staff 476 21 May 12:22 ..
-rw-r--r--@ 1 rfanjul staff 6148 21 May 12:2... | I had the situatuion when tomcat manager did not start. I had this exception in my logs/manager.DDD-MM-YY.log:
```
org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter CSRF
java.lang.ClassNotFoundException: org.apache.catalina.filters.CsrfPreventionFilter
at java.net.URLClassL... |
5,583,469 | I'm making a little "you give me your email, I'll give you an AWESOME song" page for a mate's band. I'm trying to get the simple javascript form (email) validation to work when submitting from with in the jQuery Facebox plugin. I've found out that you need to bind the JS validation function *after* the Facebox has open... | 2011/04/07 | [
"https://Stackoverflow.com/questions/5583469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/609907/"
] | John Q mentioned that facebox creates a copy of the elements, so to refer to any element in the window, I gave everything a class instead of an id then referred to it thus:
```
$($('.email')[1])
```
Then, unfortunately, I had to roll my own validation because any plugin still didn't work. Here's one example:
```
if... | From what I understand of Facebox, the contents of the modal window are always stored in the page but just hidden (by display: none) until required. Therefore you should not need to bind the validation after the facebox has loaded as the elements are in the DOM straight from page load.
With that in mind, try the foll... |
23,696,556 | I've been looking around at other questions but to no avail did I find a solution. I feel like I might not be putting the svg file in the correct location for the css/html to access it
Currently, I have this in a .svg file right next to my HTML file.
```
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
<filter ... | 2014/05/16 | [
"https://Stackoverflow.com/questions/23696556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2423436/"
] | If your SVG is not in the HTML file, then you cannot just use `url(#blur)`. You would need to use something like `url(my_svg_file.svg#blur)`.
But if I remember correctly, those sort of external file references don't work properly in all browsers anyway. So you should move the contents of the SVG into the HTML file and... | Not sure what you are trying to do but .blur{} refers to the class blur, not the id blur as used in the filter. For adding CSS to the filter try #blur{} instead. |
31,593 | I'm trying to write a function in Workbench which will generate a Fibonacci sequence starting with `F0 = 0` and `F1 = 1`. So far I have this written
```
fibonacciSequence[n_] :=
Module[{fPrev = 0, fNext = 1, i = 0},
While[i++ < n, {fPrev, fNext} = {fNext, fPrev + fNext}];
fNext]
```
How do I modify the function to... | 2013/09/03 | [
"https://mathematica.stackexchange.com/questions/31593",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/9350/"
] | This is probably defeating your professor's unspoken desire, but no one explicitly said you required a recursion. It may or may not entertain you to know Binet's formula. Without checking, I would guess that this approach is similar to how the built in function computes Fibonacci numbers. It is clearly computationally ... | For giggles, here is a contour integral method (based on Cauchy's formula) for computing the Fibonacci numbers:
```
Table[Round[Re[NIntegrate[1/((1 - z - z^2) z^n),
{z, 1/2, I/2, -1/2, -I/2, 1/2}]/(2 π I)]],
{n, 10}]
{1, 1, 2, 3, 5, 8, 13, 21, 34, 55}
``` |
46,918,397 | With dplyr starting version 0.7 the methods ending with underscore such as summarize\_ group\_by\_ are deprecated since we are supposed to use quosures.
See:
<https://cran.r-project.org/web/packages/dplyr/vignettes/programming.html>
I am trying to implement the following example using quo and !!
Working example:
`... | 2017/10/24 | [
"https://Stackoverflow.com/questions/46918397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2664205/"
] | From `dplyr` 1.0.0 you can use `across` :
```
library(dplyr)
cols2group <- c("x","y")
col2summarize <- "z"
df %>%
group_by(across(all_of(cols2group))) %>%
summarise(across(all_of(col2summarize), min)) %>%
ungroup
# x y z
# <chr> <dbl> <int>
#1 a 1 1
#2 a 2 3
#3 b 2... | Another option is to use non-standard evaluation (NSE), and have R interpret the string as quoted names of objects:
```
cols2group <- c("x","y")
col2summarize <- "z"
df %>%
group_by(!!rlang::sym(cols2group)) %>%
summarize(min(!!rlang::sym(col2summarize)))
```
The `rlang::sym()` function takes the strings and... |
24,782,721 | I'm currently developing an iOS app using swift and Xcode 6 (Beta 3).
Everything went fine so far but now as my project grows, Xcode suddenly began indexing and it does that again and again, making Xcode nearly unusable.
I have searched the web for similar problems and tried the solutions but none of them did help.
E... | 2014/07/16 | [
"https://Stackoverflow.com/questions/24782721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3845091/"
] | Solved it: I deleted the most recently added files from the project and the problem disappeared. Then I started to add back the files, one by one until the problem reappeared. So I found the file causing the problem. Then I deleted the most recently added code from that file and again, the problem disappeared.
That wa... | I had that problem when I was at the swift crunch in krakow a couple weeks ago. We had the code on github, experienced that indexing problem on a macbook, we tried pulling the repo on 2 other macbooks, same result.
It's clearly a bug, I don't know what is causing it, we tried whatever we could think of (clean, clean ... |
38,462,558 | I want to use the strings listed in List\_ and pass them in my function lambda so that each iteration names changes for load or temp....ie. lambda x: x.**load**.reset\_index().T
```
List_ = {'load','Temp','Hum','Hum'}
list__ = []
for names in List_:
test = df.apply(lambda x: x.names.reset_index().T)
list__.a... | 2016/07/19 | [
"https://Stackoverflow.com/questions/38462558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6311384/"
] | The List Objects operation appears to be eventually-consistent, even for new objects. According to a support forum post from an AWS employee ChrisP@AWS:
>
> Read-after-write consistency is only valid for GETS of new objects - LISTS might not contain the new objects until the change is fully propagated.
>
>
> — <htt... | The preceding answer of @Michael had been accurate before latest announcement from AWS.
**AWS has recently announced that both read after write operation and list operation is now strongly consistent.**
Snippet from AWS:"After a successful write of a new object, or an overwrite or delete of an existing object, any su... |
13,319,660 | Okay I tested the following with the tabbed application template on Xcode 4.5/iOS 6.
1. Created a tabbed application.
2. Created a UIButton subclass called SampleButton and implemented
the following mothods:
```
- (void)touchesBegan:(NSSet *)touches
withEvent:(UIEvent *)event
{
[super touchesBegan:touc... | 2012/11/10 | [
"https://Stackoverflow.com/questions/13319660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/480641/"
] | I worked around this by setting targets for the actions instead of using the touch methods:
```
[self addTarget:self action:@selector(handleKeyPressed) forControlEvents:UIControlEventTouchDown];
[self addTarget:self action:@selector(handleKeyReleased) forControlEvents:UIControlEventTouchUpInside];
[self addTarget:self... | Subclassing the button seems like the hard way to do this. Just tell the audio player to stop playing in the viewDidDisappear:animated: method, as R.A. suggested. |
816,656 | I assume that the iPhone Wi-Fi hardware is able to switch between channels, since my WLAN router shows me channel 1 to 13. So that WLAN spectrum must be devided up into those, I think. I would like to observe the signal strength from a specific channel within my app. Is there a way to get this data? | 2009/05/03 | [
"https://Stackoverflow.com/questions/816656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62553/"
] | There are four [transaction isolation levels](http://www.mssqlcity.com/Articles/General/TIL.htm) in SQL Server:
1. READ UNCOMMITTED
2. READ COMMITTED
3. REPEATABLE READ
4. SERIALIZABLE
For the tables it's applied to, NOLOCK is the equivalent of "read uncommitted". That means you can see rows from transactions that mi... | You should use nolock when it is ok to read dirty data. A large transaction that may make a number of changes to the database may still be in progress, using nolock will just return the data it has set so far. Should that transaction then rollback the data you are looking at could be wrong. Therefore, you should only u... |
43,995,458 | I want to create a shortcode to display the date by increasing 2 days from the current date. For example, if today is 16 may, I want to show 18 may by shortcode.
Please help me with this. | 2017/05/16 | [
"https://Stackoverflow.com/questions/43995458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7392810/"
] | If the value length is fixed this will helps you
```
DECLARE @String VARCHAR(200)
SET @String = '9744123453544'
SELECT STUFF(@String, 5, LEN(@String) - 8, REPLICATE('X', LEN(@String) - 8)) AS HideValue
```
OutPut
```
HideValue
---------
9744XXXXX3544
``` | If you are on SQL Server 2016+ try using dynamic data masking feature. (<https://learn.microsoft.com/en-us/sql/relational-databases/security/dynamic-data-masking>). |
60,469,977 | Made a ror api with auth and JWT to feed a react app. In dev environment (localhost) everything was working fine. Once I deployed to heroku I started to have that error. I deployed following heroku's rails docs: <https://devcenter.heroku.com/articles/getting-started-with-rails5>
When I try to "signup" or "signing" the... | 2020/02/29 | [
"https://Stackoverflow.com/questions/60469977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11326537/"
] | Judging by the stack trace, the error happens in `app/lib/json_web_token.rb#9`. I suspect that the error happens in:
```
HMAC_SECRET = Rails.application.secrets.secret_key_base
```
then raises a type error in:
```
JWT.encode(payload, HMAC_SECRET)
```
Is it possible that your version of rails uses a new way for fe... | Use instead
```
HMAC_SECRET = Rails.application.secret_key_base
```
<https://github.com/heartcombo/devise/issues/4864> |
7,510,422 | In an application a String is a often used data type. What we know, is that the mutation of a String uses lots of memory. So what we can do is to use a StringBuilder/StringBuffer.
But at what point should we change to StringBuilder?
And what should we do, when we have to split it or to remplace characters in there... | 2011/09/22 | [
"https://Stackoverflow.com/questions/7510422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/917672/"
] | >
> What we know, is that the mutation of a String uses lots of memory.
>
>
>
That is incorrect. Strings **cannot** be mutated. They are immutable.
What you are actually talking about is building a String from other strings. That can use a lot more memory than is necessary, but it depends *how* you build the stri... | Both a `String` and a `StringBuilder` use about the same amount of memory. Why do you think it is “much”?
If you have *measured* (for example with `jmap -histo:live`) that the classes `[C` and `java.lang.String` take up most of the memory in the heap, only then should you think further in this direction.
Maybe there ... |
31,238 | What is the reason that a likelihood function is not a pdf (probability density function)? | 2012/06/27 | [
"https://stats.stackexchange.com/questions/31238",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/12223/"
] | We'll start with two definitions:
* A [probability density function (pdf)](http://en.wikipedia.org/wiki/Probability_density_function) is a non-negative function that integrates to $1$.
* The likelihood is defined as the joint density of the observed data as a function of the parameter. But, as pointed out by the refe... | I'm not a statistician, but my understanding is that while the likelihood function itself is not a PDF with respect to the parameter(s), it is directly related to that PDF by Bayes Rule. The likelihood function, P(X|theta), and posterior distribution, f(theta|X), are tightly linked; not "a completely different thing" a... |
16,154,566 | I have an MVC4 site using Castle Windsor that I want to add some WebAPI calls to, so I start digging around a little bit on the interwebs.
Now I don't know the ins and outs of IoC; I followed a tutorial for how to set up Castle Windsor on my project, injecting the `IUnitOfWorkFactory` and the `IApplicationService` as ... | 2013/04/22 | [
"https://Stackoverflow.com/questions/16154566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/610217/"
] | The following sample project gave me the answer I was looking for. It uses Castle Windsor for dependency injection. I was able to use MVC Controllers alongside Web API controllers on the same Application.
[mirajavora / WebAPISample](https://github.com/mirajavora/WebAPISample)
---
Here's the post detailing it:
[Gett... | First as Iko stated you need to create a class that implements `IHttpControllerActivator`.
Then in `ContainerBootstrapper` in `Bootstrap()` add the following Replace the default with the one implemented:
```
//This will help in creating Web api with Dependency injection
GlobalConfiguration.Configuration.Services.Re... |
70,699,982 | I have the following array of objects; however this could be any unknown key/value and be infinitely nested, for now this is a testing sample:
```
[
{
"reference_id": "R123",
"customer": "Person 1",
"customer_email": "person1@email.com",
"location": "UK",
"bookings": [
{
"product": ... | 2022/01/13 | [
"https://Stackoverflow.com/questions/70699982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6496374/"
] | I'm not quite sure if this is what you're looking for. It makes the assumption that my guess in the comments was correct:
>
> Do I have this right? You have one (presumably dynamic) condition that says that an object either has a `provider` property with value `"Customer 1"` or has a (recursively) descendant object t... | This solution is not as beautifully elegant as an accepted answer, but why not show my efforts. Perhaps someone will find this way more understandable.
```js
const selected = [{term: 'Company 1', column: 'provider'}, {term: 'Person 1', column: 'customer'}]
const input = [{reference_id: "R123", customer: "Person 1", cu... |
44,432,951 | I have this API that I'm currently using to output a short URL or URL generator. Is there a way to pass the output to an `on-click` function.
The first script shows the API running
```
var base_url = window.location.origin,
hash_bang = "/#/sign-up?referral=",
login = "login",
api... | 2017/06/08 | [
"https://Stackoverflow.com/questions/44432951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2500177/"
] | There is no need to, you can simply wrap
```
$('#twitter').on('click', function() {
get_short_url(login, api_key, function(short_url) {
win = ...
win.focus();
});
});
``` | I'm no pro at js, but this seems fairly simple. I have not tested this.
```
var base_url = window.location.origin,
hash_bang = "/#/sign-up?referral=",
login = "login",
api_key = "api_key";
function get_short_url() {
var value = ('#input-refcode').val();
var result = '';
... |
1,563,313 | I have a windows service and I'd like my application to be able to call some methods on that service.
I've read that this is possible via exposing the required methods with WCF.
Can someone give me a pointer on how to achieve this? I understand web services and calling them, but WCF and windows services are less my f... | 2009/10/13 | [
"https://Stackoverflow.com/questions/1563313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64519/"
] | Have a look at this: <http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx> | If you are looking for the productName+version that marketing uses, it's in the registry:
HKEY\_LOCAL\_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Product Name
Looking at my computer, it says "Windows 8.1 Pro". |
56,199,965 | I'm doing a HTML form, it's meant to create step to pass on a game and I want to be able to enter a number and when for example I enter 5 it instantly show me 5 form to fill and create new step but when I try it doesn't appear how can I do please?
```php
<h3>Insertion des étape :</h3>
<form action="InsertionEtape.php... | 2019/05/18 | [
"https://Stackoverflow.com/questions/56199965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11359851/"
] | Right so it sounds like you want this form to update on page. For this you'll need to use JavaScript. PHP runs server side only, you want this to update on the client side.
Here is a quick example to get you on the right path. I am using jQuery which is a popular Javascript library.
```js
var $group = $('form .group'... | okey I changed to this but an error appeared,
```php
<form action="InsertionEtape.php" method="post">
<input type="number" name="quantity" min="1" max="5">
<br>
<?php for ($i=0; $i < $_GET['quantity']; $i++) {
echo "<h5>Nom de l'étape</h5>";
echo "<input type=\"text\" name=\"NomEtape_".$i."\... |
52,537 | I'm trying to get through a proof of Gauss' that certain primes can be written as the sum of two squares. An assumption is that
>
> the order of $\mathbb{Z}[i]/(a+bi)$ is $a^2+b^2$.
>
>
>
I get that $(a+bi)(a-bi)=a^2+b^2$, so this places a bound on the order of integers with no imaginary part. But since $b$ isn'... | 2011/07/20 | [
"https://math.stackexchange.com/questions/52537",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/2549/"
] | Expanding on Qiaochu's comment, but trying to leave you some room to think:
$\mathbb{Z}[i]$ is a *square [lattice](http://en.wikipedia.org/wiki/Lattice_%28group%29)* in the complex plane, and the ideal $(a+bi)$ is a square sublattice. (Why?) The index of $(a+bi)$ in $\mathbb{Z}[i]$ is the number of elements of $\mathb... | *Hint:* The Gaussian integers are a Euclidean domain with respect to the norm. Hence given $z\in \mathbb Z[i]$ there are $q$ and $r$ in $\mathbb Z[i]$ such that $z=q(a+bi)+r$, with $r=0$ or $N(r)<N(a+bi)$. |
5,117,538 | I have Magento set up to not display VAT on checkout, but it is still adding at the total. It doesn't add it up to the total - which IS correct.
For example if I have an item that costs £5 - with 20% VAT it is £6 and this is set to show in the catalogue prices - which it does. Now on checkout this item would display ... | 2011/02/25 | [
"https://Stackoverflow.com/questions/5117538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/616562/"
] | To hide the tax comment out in /app/code/local/Mage/Sales/Model/Quote/Address/Total/Tax.php at the end of the file:
```
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$applied = $address->getAppliedTaxes();
$store = $address->getQuote()->getStore();
$amount = $address->get... | In the end the only way i solved this was by removing the tax out of magento and check the box that says the prices that we submit contain tax. Not ideal. |
60,533,617 | I'm trying to integrate keycloak with a spring boot app and i have a few issues with it.I'm trying to define some endpoints that should be excluded from keycloak validation and let everyone make requests to those endpoints but it's not working.
Here is my config:
```
keycloak.realm=spring-security-quickstart
keycloak... | 2020/03/04 | [
"https://Stackoverflow.com/questions/60533617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8747553/"
] | Found the problem. While the app was running with no other issues than the one stated, when I went to replicate the problem on StackBlitz, the code there gave me an error, telling me that I needed to add the `CrudListComponent` on my @NgModule declaration, so all I had to do was to add the component there, rebuild the ... | This issue is present in the angular 9. I was using **angular(9.0.1)** version so upgraded to **~10.0.9** and now it's working. |
15,330 | You have been chosen to participate in a selection process for a secret underground group. To make sure you're worthy, they test you with a series of devious puzzles. However, one in particular has you stumped...
The challenge you receive is as follows:
>
> People aren't very good at observing things. We hope you ar... | 2015/05/22 | [
"https://puzzling.stackexchange.com/questions/15330",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/7308/"
] | Not done yet, I think, but:
>
> Using the fill option in paint, this came out:
>
> 
>
> Keep looking!
>
>
>
Also:
>
> The displayed and actual link are different. Following the displayed link shows:
>
> 
>
> Again, filli... | The solution is
>
> 404
>
>
>
How it's hidden...
>
> The linked image is described as [http://i.stack.imgur.com/XKGpe.png](https://i.stack.imgur.com/XKGpe.png)
> but actually points to [http://i.stack.imgur.com/X2plV.png/](https://i.stack.imgur.com/X2plV.png/).
> The image actually linked to contains very f... |
256,141 | I am lost I just can't seem to get my head around backtracking/recursion approaches. I understand how simple recursion problems like factorials work I can even trace those by hand. But when it comes to backtracking problems I am so lost. I keep trying. its been 5 hours I have been reading various approaches on forums a... | 2014/09/12 | [
"https://softwareengineering.stackexchange.com/questions/256141",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/132623/"
] | You want to enumerate recursively the set of sublists of `1 :: 2 :: 3 :: 4 :: []` which sums to `5`. (The `::` is the OCaml notation for the list construction.) The recursive step in list processing is splitting the list in its head `1` and its tail `2 :: 3 :: 4 :: []` — can we describe our set in these terms?
There i... | I'm assuming for the purpose of this exercise that you don't want any repeats. For example, the combinations for [1..4] are
```
[[1],[1,2],[1,2,3],[1,2,3,4],[1,2,4],[1,3],[1,3,4],
[1,4],[2],[2,3],[2,3,4],[2,4],[3],[3,4],[4]]
```
If not, the process is really the same for all recursive functions: figure out your bas... |
26,251 | Numbers 25:9 (NKJV)
>
> 9 And those who died in the plague were twenty-four thousand.
>
>
>
1 Corinthians 10:8 (NKJV)
>
> 8 Nor let us commit sexual immorality, as some of them did, and in one day twenty-three thousand fell;
>
>
>
Assuming Paul was referencing to the incident of Baal of peor where Israel c... | 2016/12/18 | [
"https://hermeneutics.stackexchange.com/questions/26251",
"https://hermeneutics.stackexchange.com",
"https://hermeneutics.stackexchange.com/users/16527/"
] | The 23,000 refers to the worship of the gods of Moab and the sexual immorality between some Israelite men and the the daughters of Moab. This is known as the rebellion of Baal of Peor at which 24,000 died by the plague ([Numbers 25:9](https://www.biblegateway.com/passage/?search=Numbers%2025%3A9&version=ESV)).
As noted... | They probably cannot easily be reconciled, but one must ask whether the point of Paul's teaching is to firmly establish exactly how many perished in the plague of old, or is rather that Christians should avoid sexual immorality.
According to the apparatus of the Nestle-Aland Greek English New Testament (11th ed.), cer... |
60,275,044 | I have two dates like 2020-12-31 and 2020-12-01 in string format yyyy-mm-dd while check the month it should return true.
Suppose I compare 2020-11-31 and 2020-12-31 it should return false.
If there is a difference in only month and year, it should return true.
For example today Feb 18, 2020, Suppose I choose Feb ... | 2020/02/18 | [
"https://Stackoverflow.com/questions/60275044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4117259/"
] | You can go with the following code:
```
const date1 = new Date('2020-12-01');
const date2 = new Date('2020-12-31');
// if you want to return true or false based on either date or month or year difference then use the following code.
const diffTime = Math.abs(date2 - date1);
const diffDays = Math.ceil(diffTime / (100... | Shorted, faster, and simpler solution is:
```js
"2020-11-31".substr(5, 2) === "2020-12-31".substr(5, 2)
``` |
3,165,409 | 
Hello, I am confused as to how they got 5y in this problem when they multiplied dx/dy by dy/dt in the fourth line.
I am also confused as to what dx/dt and dx/dy and dy/dt mean. | 2019/03/28 | [
"https://math.stackexchange.com/questions/3165409",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/649779/"
] | You have:
$|z^2-1|=|z|^2+1$.
Squaring both sides:
$|z^2-1|^2=(|z|^2+1)^2$.
Since:$|a-b|^2=|a|^2+|b|^2-a\bar b-\bar a b$
Now You have:
$|z|^4+1-z^2-\bar z^2=|z|^4+2|z|^2+1$
Rearranging and cancelling terms:
$2|z|^2+z^2+\bar z^2=0$
Now, $|z|^2=z\bar z$
So, you get $(z+\bar z)^2=0$
i.e., $z+\bar z=0$ z is th... | Note that for $u,v \in \mathbb{C}$ you have
* $|u+v| \leq |u| + |v|$ and equality holds if and only if $\operatorname{Re}(u\bar v)=|u||v|$.
Applying this to the given equation you get
$$|z^2 + (-1)| = |z|^2 +1 \Leftrightarrow \operatorname{Re}(z^2\cdot (-1)) = |z|^2 \Leftrightarrow \boxed{\operatorname{Re}(z^2) = -|... |
38,991,478 | I have two Python lists with the same number of elements. The elements of the first list are unique, the ones in the second list - not necessarily so. For instance
```
list1 = ['e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7']
list2 = ['h1', 'h2', 'h1', 'h3', 'h1', 'h2', 'h4']
```
I want to remove all the "first encountered... | 2016/08/17 | [
"https://Stackoverflow.com/questions/38991478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6597296/"
] | Just use a `set` object to lookup if the current value is already seen, like this
```
>>> list1 = ['e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7']
>>> list2 = ['h1', 'h2', 'h1', 'h3', 'h1', 'h2', 'h4']
>>>
>>> def filterer(l1, l2):
... r1 = []
... r2 = []
... seen = set()
... for e1, e2 in zip(l1, l2):
... ... | Use a set to keep track of values you've already encountered:
```
seen= set()
index= 0
while index < len(list1):
i1, i2= list1[index], list2[index]
if i2 in seen:
index+= 1
else:
seen.add(i2)
del list1[index]
del list2[index]
``` |
9,027,046 | So I clicked on my storyboard in Xcode today and all of my controllers were squashed. I dragged out an empty ViewController on the left for comparison. Has anyone else encountered this?  | 2012/01/26 | [
"https://Stackoverflow.com/questions/9027046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152845/"
] | This is a bit fragile since it relies on understanding the internals of `argparse.ArgumentParser`, but in lieu of rewriting `argparse.ArgumentParser.parse_known_args`, here's what I use:
```
class OrderedNamespace(argparse.Namespace):
def __init__(self, **kwargs):
self.__dict__["_arg_order"] = []
s... | There is module especially made to handle this :
<https://github.com/claylabs/ordered-keyword-args>
without using orderedkwargs module
----------------------------------
```
def multiple_kwarguments(first , **lotsofothers):
print first
for i,other in lotsofothers:
print other
return True
mult... |
10,139,779 | I have my .htaccess file redirecting all URLs to index.php?url=$1 as shown below:
```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L]
```
But when the url is authenticate?code=blahblahblah the code= part is not pulled in, therefore me... | 2012/04/13 | [
"https://Stackoverflow.com/questions/10139779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/715474/"
] | You need the [`[QSA]`](http://www.google.com/search?q=apache+rewriterule+%5BQSA%5D) flag then. | use `RewriteRule ^(.*)$ index.php?url=$1&%{QUERY_STRING} [L]` instead |
655,641 | Sometimes, an alt-code that I find on the internet does not work on my PC, for example Pi alt code (`Alt`+`227`) throws Ń isntead of π.
So I need to use the character in clipboard (or in a file or wherever) and conver it to Alt-code compatible with my system. Is this possible? | 2013/10/07 | [
"https://superuser.com/questions/655641",
"https://superuser.com",
"https://superuser.com/users/194976/"
] | You can start "Character map", choose your font, search you character and at the bottom (in the status bar) is the Alt code you need.
(In Windows 7 you can press `Start` and begin type `Character map` en choose it at the top.)
The fact that you get a different character with `Alt` + `227` is probably that you're usi... | For Windows, one way to enter codes is by referring to code page
437:
<https://en.wikipedia.org/wiki/Code_page_437>
For anything on that list, you just enter Alt followed by the
decimal code. For example for this character:
```
☺ U+263A
```
According to the chart is decimal `1`. So you will just enter
`Alt + 1`. A... |
294,504 | In the beginning of my presentation, I would like to show the following. On the first slide, I would like to show a table of contents with sections only. That is, the subsections should be invisible, but they should be THERE. Then, on the following slides, the subsections shall sucessively be blended in.
Using the op... | 2016/02/17 | [
"https://tex.stackexchange.com/questions/294504",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/96089/"
] | Since `\big` is the minimum requested size anyway, it's better to use a simpler approach:
```
\documentclass{article}
\usepackage{amsmath,mleftright}
\usepackage{xparse}
\NewDocumentCommand{\evalat}{sO{\big}mm}{%
\IfBooleanTF{#1}
{\mleft. #3 \mright|_{#4}}
{#3#2|_{#4}}%
}
\begin{document}
\begin{align}
& \e... | While trying to adapt [Bernard’s answer](https://tex.stackexchange.com/a/294543/69818) to a similar question ([Vertical bar for “evaluated at”](https://tex.stackexchange.com/q/376541/69818)), I noticed that it is defective in that it smashes the height of the “evaluated” subformula, as it can clearly be seen in this mo... |
54,116,784 | I have a JTable application. I need to change the cell values and save the data, but only cells with index smaller than or equal to 4 are within the array bounds.
```
package fi.allu.neliojuuri;
import com.sun.glass.events.KeyEvent;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing... | 2019/01/09 | [
"https://Stackoverflow.com/questions/54116784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5964318/"
] | You could slice the array and omit the last element.
```js
var array = [1, 2, 3],
item;
for (item of array.slice(0, -1)) {
console.log(item)
}
``` | If you want to change your loop behavior based the specific index, then it's probably a good idea to use an explicit index in your for-loop.
If you simply want to skip out on the last element, you can do something like
```
for (item of array.slice(0, -1)) {
//do something for every element except last
}
``` |
8,863,103 | A few days ago I've asked a question concerning how to detect an end of input file of N(N is unknown) lines.
```
StringBuilder input = new StringBuilder();
int endOfFile = 0
while ((endOfFile = Console.Read()) != -1) {
input.Append(((char)endOfFile).ToString());
input.Append(Console.ReadLine());
}
```
I've ... | 2012/01/14 | [
"https://Stackoverflow.com/questions/8863103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/824431/"
] | This could help in looping through the file and check for end of file.
```
using (StreamReader sr = new StreamReader(@"test.txt"))
{
string line;
while ( (line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
```
**UPDATE**
Here is a link from msdn [ReadLine method](... | Are you planning on using the shell to redirect standard input to your input file?
Why not use something like TextReader.Read() or TextReader.ReadLine()? <http://msdn.microsoft.com/en-us/library/system.io.textreader.aspx> |
34,487,991 | I want to know why this error comes when try to upload file with real device using Marshmallow. Can you please explain the solution for this.
>
> 12-28 10:39:32.606: E/3(17552): Excption : java.io.FileNotFoundException: /storage/emulated/0/WoodenstreetD.doc: open failed: ENOENT (No such file or directory)
>
>
>
I... | 2015/12/28 | [
"https://Stackoverflow.com/questions/34487991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This error comes due to wrong path. The path your getting from onActivityResult is not correct. Use this to get path of selected file.
```
public static String getRealPathFromUri(Context ctx, Uri uri) {
String[] filePathColumn = { MediaStore.Files.FileColumns.DATA };
Cursor cursor = ctx.getContentResolver().q... | i worte this and it'll work for me.
```
public static java.io.File convertUriTFile(Activity activity, Uri uri) {
InputStream inputStream = null;
java.io.File file = null;
try {
inputStream = activity.getContentResolver().openInputStream(uri);
} catch (FileNotFoundException ... |
29,678,424 | I would like to show one progress bar the resets when its finished. Here is the code. When you run it you can see it makes a new line every time .
```
import time
import sys
toolbar_width = 40
numbers = [1,2,4,5,6,7,8,9,10]
for number in numbers:
for i in xrange(toolbar_width):
time.sleep(0.1) # d... | 2015/04/16 | [
"https://Stackoverflow.com/questions/29678424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4624573/"
] | Print a carriage return when you are done:
```
import time
import sys
toolbar_width = 40
numbers = [1,2,4,5,6,7,8,9,10]
for number in numbers:
#print number
for i in xrange(toolbar_width):
time.sleep(0.1) # do real work here
# update the bar
sys.stdout.write("-"... | ```
sys.stdout.write("\r" + " " * toolbar_width + "\r")
```
instead of
```
sys.stdout.write("\n")
```
Explain:
* `\r` -- return at the beginning of line
* `" " * toolbar_width` -- fill the line with space of the size toolbar\_width
* `\r` -- return again at the beginning of line |
41,708,152 | I am trying to use `removeEventListener` but in line with `event.target.removeEventListener('click', myName, false);` is mistake. I tried different ways but none works.
```
document.querySelector('#imagesContainer').addEventListener('click', function myName (event) {
var images = this.formData.getAll('images[]')... | 2017/01/17 | [
"https://Stackoverflow.com/questions/41708152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4418289/"
] | You would need to first shift by the required number of bits then perform a bitwise OR of the new data.
```
int a = 0;
a = a << 3;
a = a | 0x5;
a = a << 3;
a = a | 0x3;
printf("a=%x\n", a);
```
( Used separate assignments and operators instead of compound operators to make it clearer to beginners. )
Result:
```
a=... | >
> Is there a way for me to say left shift 101 into the variable
>
>
>
No. You need to left shift first, then add (or OR) the new value.
```
int eax = 0;
eax <<= 3;
eax |= 5;
``` |
59,942,915 | I want to display an Image or Text in Center like `No Record Found` all details are fetched from API. In Native Android `setEmptyView()` for this condition but no idea how can I do this in flutter. Non-stop progress Dialog is running but the text is not displayed. I added code with my JSON response
```
List<NewAddress... | 2020/01/28 | [
"https://Stackoverflow.com/questions/59942915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12094392/"
] | You have to use different `widget` for this. You can use something like this to display empty image when there is no data.
```
@override
Widget build(BuildContext context) {
if (array.isEmpty()) {
return Widget(child: Thing(this.name));
} else {
return Widget(child: WithoutT... | In your case, the best solution will be the use of [**FutureBuilder**](https://api.flutter.dev/flutter/widgets/FutureBuilder/FutureBuilder.html) .
The [FutureBuilder class](https://api.flutter.dev/flutter/widgets/FutureBuilder-class.html)
[An article that can help you](https://medium.com/nonstopio/flutter-future-buil... |
62,010,915 | When nav component switches to a fragment, I get this "Views added to a FragmentContainerView must be associated with a Fragment" crash. What causes this? | 2020/05/25 | [
"https://Stackoverflow.com/questions/62010915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/251120/"
] | I didn't see this mentioned anywhere and it took a while to figure out but in this case, I was trying to set up a old legacy fragment while migrating to the nav arch component.
The reason was in the frag's `onCreateView`, the inflate looked like:
```kotlin
layoutView = inflater.inflate( R.layout.home, container, fals... | Just replace your **onViewCreated** method.
```
class MyFragment : Fragment() {
override fun onCreateView( inflater: LayoutInflater,container: ViewGroup?, savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_post,container,false)
}
}
``` |
3,580,839 | >
> Why does $\left(1+{\frac{1}{\sqrt{n}}}\right)^\sqrt{n}$ also converge to $e$?
>
>
>
I mean, if we use, instead of $\sqrt{n}$, something like $2n$ or $n^2$, we could argue that these sequences are SUBsequences of $(1+1/n)^n$. I need a proper definition or explanation why these sequences are related to the "ori... | 2020/03/14 | [
"https://math.stackexchange.com/questions/3580839",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/740715/"
] | You can always make a substitution. For your first example, set $y=\sqrt n.$ Then as $n\to+\infty,$ we have that $\sqrt n\to+\infty,$ so that $y\to+\infty$ too. Then we have that $$\left(1+\frac{1}{\sqrt n}\right)^{\sqrt n}=\left(1+\frac1y\right)^y\to e.$$
You can then see that this also works for any function $f(n)$ ... | Note that
$$ \lim\_{n\to\infty}\left(1+\frac1{n}\right)^{n+1}=\lim\_{n\to\infty}\left(1+\frac1{n}\right)^{n}\cdot \lim\_{n\to\infty}\left(1+\frac1{n}\right)=e.$$
Likewise,
$$ \lim\_{n\to\infty}\left(1+\frac1{n+1}\right)^{n}=e.$$
Let $a\_n$ be a sequence of reals with $a\_n\to\infty$. Then wlog. $a\_n\ge 1$ for all $n... |
1,595,785 | Is there a way that I can pass in a reference to an object, manipulate it inside my method which directly changes the referenced object?
For instance I want to pass a dropdownlist into my method, manipulate it and be done. This method is going to take in any dropdownlist:
```
public static void MyMethod(Dropdownlist ... | 2009/10/20 | [
"https://Stackoverflow.com/questions/1595785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/93468/"
] | Yes (but more like Javadoc) - [look at JSDoc](http://jsdoc.sourceforge.net/)
Basically you use Javadoc-like special syntax in your comments e.g. `@param` like in the following example and then parser will generate good looking HTML output for you
```
/**
* Shape is an abstract base class. It is defined simply
* to hav... | I haven't personally used it, but [jsdoc-toolkit](http://code.google.com/p/jsdoc-toolkit/) seems to be what you're after. |
5,261,748 | I've tried some dropdown menus, but they drop behind other frames. | 2011/03/10 | [
"https://Stackoverflow.com/questions/5261748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/521180/"
] | Can you give each cell a unique id? Then you can just do:
```
var cell_ids = ['id-cell-1', 'id-cell-2',...];
var cellcontents = [];
while (i < 10) {
cellcontents.push($("#" + cell_ids[i]).html());
i--;
}
``` | an array?
this is just semi psuedo code but:
```
var i;
var innerString[];
while (i < 10) {
innerString[i] = (innerHTML of elementID);
i++;
}
``` |
35,945,855 | I am trying to get a value from the table.
```
cursor=db.rawQuery("select value from '" + tableName + "' where key= '" + name + "' ",null);
if (cursor.getCount()>0){
if (cursor.moveToFirst()){
String value= cursor.getString(cursor.getColumnIndex("value"));
return value;
... | 2016/03/11 | [
"https://Stackoverflow.com/questions/35945855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3695849/"
] | Table and column names in SQL are case sensitive. Since your column is named "VALUE", you need to getColumnIndex("VALUE") | The Table you created must have a column with name \_id. it won't work until you add column with column index "\_id".
if you do not have any column with column index "\_id". Explicitly uninstall your app from settings->app manager. and re-run you app after adding required column. |
25,387,114 | I am new to Android application development and Java programming, currently, I'm working on a project to retrieve from my database the status of a service. However, the application will stop working whenever I tried to submit my tracking ID.
MainActivity.java
```
package com.example.trackstatus;
import com.example.t... | 2014/08/19 | [
"https://Stackoverflow.com/questions/25387114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3956889/"
] | According to your LogCat message:
```
Caused by: java.lang.NullPointerException at com.example.trackstatus.ViewTrackingStatusActivity.onCreate(ViewTrackingStatusActivity.java:55)
```
You are missing :
```
setContentView(R.layout.your_layout);
```
where your EditText `trackingNumberText` must be declared.
thats t... | The error is in `Line55`
`String trackingno = trackingNumberText.getText().toString();`
`trackingNumberText` is **NULL**
instead try to do NULL check
```
String trackingno = "";
if(trackingNumberText.getText().length() > 0)
{
trackingno = trackingNumberText.getText().toString();
} else {
Toast.makeText(ge... |
25,594,535 | I have accidentally deleted App.xaml and App.xaml.cs from project solution. Now when I try to compile my program I get this error:
Error 1 Program 'xxx\WpfApplication1\obj\Release\Pacman Reloaded.exe' does not contain a static 'Main' method suitable for an entry point xxx\WpfApplication1\WpfApplication1\CSC WpfApplica... | 2014/08/31 | [
"https://Stackoverflow.com/questions/25594535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2267956/"
] | It is not enough to create a new class. You need a pair of xaml and xaml.cs files properly setup to work together. Create a new window called App. That will give you the files. Then modify them both to turn the window into an application:
App.xaml needs to look like this:
```
<Application x:Class="WpfApplication3.App... | you can find the deleted App.xaml in your recycle bin. Search it there then put it in your desktop then right click on your project/Solution in visual studio hover on add choose existing item, locate the App.xaml then click add. |
12,199 | As a kid I watched a movie that was my dads. All I remember from it was there was some kind of (potentially reluctant) hero / anti hero. He's trying to shoot an (Asian?) guy who could dodge the bullets. This guy ends up training him up (perhaps) and then this hero / anti hero has the same ability. Ability in the ninja ... | 2013/06/26 | [
"https://movies.stackexchange.com/questions/12199",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/3441/"
] | Is it [Remo Williams: The Adventure Begins](http://www.imdb.com/title/tt0089901/),
>
> where An officially "dead" cop is trained to become an extraordinarily
> unique assassin in service of the US president.
>
>
>
Given answer by reading [this](http://answers.yahoo.com/question/index?qid=20090325075903AATi5nT) ... | This sounds like "[Remo Williams: The Adventure Begins](http://www.youtube.com/watch?v=C_lKShbp3nw)." The cheesy dodging of bullets is a component of the fictional martial art Shinanju. |
41,029,712 | I am trying to find a file ("Vodoo.txt") on my D:\ drive using static recursion in JAVA. I was wondering if you might be able to help me find out what I am doing wrong.
My goal is to search through all of my folders until I find "Vodoo.txt" and print out the path to that file.
>
> My Code:
>
>
>
```
import java.... | 2016/12/08 | [
"https://Stackoverflow.com/questions/41029712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6906088/"
] | Using the lag function is the best approach to this.
```
SELECT [Year], [Item], [Qty], [Amount],
[Qty] - LAG([Qty]) OVER (PARTITION BY [Item] ORDER BY [Year]) [QtyDiff],
[Amount] - LAG([Amount]) OVER (PARTITION BY [Item] ORDER BY [Year]) [AmountDiff]
FROM [ItemTable] it
order BY [Year] DESC, [Item];
``... | Here is the required query:
```
SET @YEAR1 = '2014';
SET @YEAR2 = '2015';
SELECT
Item,
if(count(*)>1,sum(if(Year=@YEAR2,Qty,-Qty)),NULL) as 'Qty Diff',
if(count(*)>1,sum(if(Year=@YEAR2,Amount,-Amount)),NULL) as 'Amount Diff'
FROM
table
WHERE
Year IN ... |
188,855 | I have a `2D platformer` and if my player dies, he goes back to the start, but I want there to be checkpoints.
My current Respawn script:
```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Respawn : MonoBehaviour
{
public GameObject PlayerPrefab;
public Tran... | 2021/02/04 | [
"https://gamedev.stackexchange.com/questions/188855",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/146741/"
] | I would recommend you to structure your project a bit differently. Instead of having the `Respawn` script on the player (I assume it's on the player) detect and handle all the interactions with different objects in the world, you should make those objects themselves responsible for detecting the player and triggering a... | You clearly know how to move the player to a spawn point when hitting a trap.
You can use the same logic to move the spawn point to a checkpoint when hitting the checkpoint. |
26,276,700 | I have the following 4 tables: MainTable, Warehouse,Customer and Company.
The schema of these tables:
```
create table MainTable(ID int, Warehouse_id int, Customer_ID int)
create table Warehouse (Warehouse_id int, company_id int)
create table Customer (Customer_ID int, Company_ID int)
create table company (Company_id... | 2014/10/09 | [
"https://Stackoverflow.com/questions/26276700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3569267/"
] | You can use [UNION](http://msdn.microsoft.com/en-us/library/ms180026.aspx):
```
SELECT CO.Country_ID, CO.Zone_ID
FROM MainTable MT
INNER JOIN Warehouse W ON MT.Warehouse_ID=W.Warehouse_ID
INNER JOIN Company CO on W.Company_ID=CO.Company_ID
WHERE MT.Warehouse_ID IS NOT NULL
UNION
SELECT CO.Country_ID, CO.Zone_I... | You can't do that. **What would you expect the output to be** with this kind of conditional joins ?
Have you tried using outer joins ?
```
select ISNULL(C1.Country_ID,C2.Country_ID) as Country_ID,ISNULL(C1.Zone_ID,C2.Zone_ID) as Zone_ID
from MainTable MT
left outer join Warehouse W on MT.Warehouse_ID=W.Warehous... |
50,278,840 | In the Main function of this script I have two if statements, each having two conditions that should be met before running. In the first if statement both conditions are met but the code is not running. Below is the code and the output. Any insight would be valuable!
```
$port= new-object system.io.ports.serialport co... | 2018/05/10 | [
"https://Stackoverflow.com/questions/50278840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9772404/"
] | Here's the stored procedure method. In SSMS, run this one time
```
CREATE PROCEDURE dbo.UpdateAndGetLegal
AS
UPDATE Legal
SET Category = CASE WHEN DATEDIFF(MONTH, GETDATE(), [End date]) > 9 THEN 'Blue'
WHEN DATEDIFF(MONTH, GETDATE(), [End date]) < 9
... | I'm taking a bit of a guess here, but it's based on something that feels off.
Every time you run your SELECT to get some data
```
Select
classification,
datediff(month, GETDATE(), [End date]),
Category
from
Legal
```
You first run an UPDATE...
```
Update Legal
Set Category = Case
... |
10,842,571 | I have to implement [Battleship game](http://en.wikipedia.org/wiki/Battleship_%28game%29) in C++. It would be *Human* vs *Computer* game.
Everything is quite straight forward except positioning computer's ships on start of the game. Computer's ships' positions should be random. But how should I (optimally) choose cell... | 2012/05/31 | [
"https://Stackoverflow.com/questions/10842571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1321680/"
] | Use a linked list, where each node is a link to a square on the board. You can then a) generate a random node and b) as you place ships remove nodes from the list. You can remove extra nodes from around the placed ship to make give that ship some room (don't want your ships to touch ;) | If it's computer vs. computers, you just have to make sure you place the ships randomly across the board such that none of the ships are adjacent to each other.
However, since you're playing a human you can get a little more creative. It's like the game rock-paper-scissors where you can gain an edge by exploiting huma... |
34,420,590 | I have some trouble with validation in Laravel 5.2
When i try validate request in controller like this
```
$this->validate($request, [
'title' => 'required',
'content.*.rate' => 'required',
]);
```
Validator catch error, but don't store them to session, so when i'm try to ... | 2015/12/22 | [
"https://Stackoverflow.com/questions/34420590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/467310/"
] | ```
// Replace
Route::group(['middleware' => ['web']], function () {
// Add your routes here
});
// with
Route::group(['middlewareGroups' => ['web']], function () {
// Add your routes here
});
``` | ```
// Controller
$this->validateWith([
'title' => 'required',
'content.*.rate' => 'required',
]);
// Blade Template
@if ($errors->has('title'))
<span class="error">
<strong>{{ $errors->first('title') }}</strong>
</span>
@endif
@if ($errors->has('anotherfied'))
<span class="error">
... |
60,899,696 | I have a scenario where I want to cache a JSON response and use it further.
I have total two requests out of which one I want to cache and use the response in another request, however the other request should not be cached. As of now what I have tried cache's all the requests.
Here is what I have tried :
```
import re... | 2020/03/28 | [
"https://Stackoverflow.com/questions/60899696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12967623/"
] | There is a feature in `requests_cache` to temporarily disable the cache feature. This is the method `.disabled()`. In the following snippet I use the `with` keyword to create the temporary scope in which the requests are not cached.
```
import requests
import requests_cache
requests_cache.install_cache('test_cache', ... | Option 1: CachedSession
=======================
Alternatively, you can use [requests\_cache.CachedSession](https://requests-cache.readthedocs.io/en/stable/user_guide/general.html) to cache requests instead of `install_cache()`, and a regular [requests.Session](https://docs.python-requests.org/en/latest/user/advanced/#... |
21,091,188 | How to remove the `type` from the JSON output that I have. I have a class/bean that contains output of a REST service.I'm using `jersey-media-moxy` to do the conversion.
The service
```
@Resource
public interface MyBeanResource
{
@GET
@Path("/example")
@Produces( MediaType.APPLICATION_JSON )
public Be... | 2014/01/13 | [
"https://Stackoverflow.com/questions/21091188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/461499/"
] | MOXy will add a type indicator to differentiate between the different subtypes. This however will only happen if MOXy is aware of the subtypes (it isn't by default).
Demo Code
---------
**Demo**
Below is the equivalent code that Jersey will call on MOXy.
```
import org.eclipse.persistence.jaxb.rs.MOXyJsonProvider;
... | I used a Jersey specific Jackson package in a slightly different case, it worked. Detailed configuration is described in [Jersy document](https://jersey.java.net/documentation/latest/media.html#json.jackson). In my case, I used a generic type field in an @XmlRootElement class. MOXy added a type in the JSON output. I ca... |
6,300,332 | I have a current Android app that uses i18n via resources. res/values-es/strings.xml and so on. When I test it on a device with the language set to Espanol it pulls the correct resources, from the values-es file, but the accent characters are way out of whack.
For example, I want to use the lowercase o with an accent... | 2011/06/09 | [
"https://Stackoverflow.com/questions/6300332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/252676/"
] | I finally solved this one. I was using a font and calling setTypeface earlier in the code. The font I'm using must not have the special characters needed for the other languages. I need to check to make sure my user's are using a locale that my font supports before setting the font.
I should have realized this and che... | This is strange as it should not cause a problem. Maybe you should try to embed string into CDATA section, like this:
```
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="label_app_version"><![CDATA[Versión]]></string>
</resources>
``` |
3,302 | What is a good way of learning how to season food correctly? Are there some foods which are particularly bland until seasoned correctly that can be used to 'educate' your palate as to what is correctly seasoned? | 2010/07/26 | [
"https://cooking.stackexchange.com/questions/3302",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/210/"
] | My best recommendation is to taste as you go. Taste the initial product...raw vegetable, ingredient from the can, bottle, etc. and then continue to taste and sample a dish throughout the cooking process to see how flavors develop/diminish and enhance one another through the cooking process.
Learning to season food is ... | Definitely taste as you go and season gradually and regularly. Good chefs might taste their dish thirty times before it gets to the plate. Proper seasoning is not a formula, it's heat-seeking missile that constantly adjusts to hit its target. Or an impressionist painter who builds a base of color and then dabs on highl... |
9,529,504 | I try to connect to Facebook throught Facebook API, I follow this example: <https://github.com/facebook/facebook-android-sdk/tree/master/examples/simple>
Everything is ok, but when I try to edit some code, I mean I want to display the dialog post message after the login is successful like this:
```
public void onAut... | 2012/03/02 | [
"https://Stackoverflow.com/questions/9529504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/917206/"
] | After execute the thread, add these two line of code, and that will solve the issue.
```
Looper.loop();
Looper.myLooper().quit();
``` | Another developer use case: If the `WindowManager` or `getWindow()` is being called on `onCreate()` or `onStart()` or `onResume()`, a `BadTokenException` is thrown. You will need to wait until the view is prepared and attached.
Moving the code to `onAttachedToWindow()` solves it. It may not be a permanent solution, bu... |
30,836,183 | I'm working on an application that requires the use of getting dates for national holidays.
Below, I was able to get Memorial Day:
```swift
// Set the components for Memorial Day (last Monday of May)
let memorialDayComps = NSDateComponents()
memorialDayComps.weekday = 2
memorialDayComps.month = 5
memorialDayComps.y... | 2015/06/15 | [
"https://Stackoverflow.com/questions/30836183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3720634/"
] | I was able to find a [gist](https://gist.github.com/duedal/2eabcede718c69670102) on GitHub that has a solution that was accurate for calculating and returning an `NSDate` for Easter.
The code below is what the gist contains:
```swift
// Easter calculation in swift after Anonymous Gregorian algorithm
// Also known as... | Here is a Swift 5 implementation of [*O'Beirne*'s algorithm](https://books.google.be/books?id=zfzhCoOHurwC&num=15&pg=PA828) with inline documentation.
The code is more compact than the implementations in the other provided answers because it makes use of Integer arithmetic and thus removes the need to explicitly round... |
39,606,379 | I have two yii2 projects based on kartik practical A and B. Both using johnitvn/ajaxcrudmodal. It looks like single page crud with ajax modal for create and update.
I use kartik select2 in \_form.php.
However, in the project that based on practical A it can work carefully. But in the project that use practical B, it ... | 2016/09/21 | [
"https://Stackoverflow.com/questions/39606379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2264589/"
] | This isn't something you're going to fix yourself.
The problem that you're facing is that you need compiler assistance. In the "real" Visual Studio, that's provided by Intellisense. This includes a C++ compiler (surprisingly enough, not Microsoft's own but EDG's). Since it's a compiler, it's smart enough to figure out... | It works in my VS2008, while you must include the corresponding header file firstly. |
4,056,614 | I've read about how a hard job in programming is writing code "at the right level of abstraction". Although abstraction is generally hiding details behind a layer, is writing something at the right level of abstraction basically getting the methodss to implement decision correct? For example, if I am going to write a c... | 2010/10/29 | [
"https://Stackoverflow.com/questions/4056614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | I don't think that's it.
To me, abstraction is synonymous with generalization. The more abstract something is, the more the author is trying to think about a problem in such a way that it's easier to extend and apply to new problems.
In general, greater abstraction requires more effort to develop and to understand. I... | I think one dangerous aspect of abstraction is its ability to erase or hide the reality or the design it represents. You should always maintain a reasonable distance between what you represent and the representation. By "reasonable" I mean easily understandable by an external developer how hasn't been coding on this sp... |
21,457,906 | 
We have tabbar and a more view controller (bacuse too many icons for the tabbar) with icon and text. The icon (png) image color is black but on the device or simulator it's always gray. I would like to know how to change the icon color or transparency of the icon. Idea why? | 2014/01/30 | [
"https://Stackoverflow.com/questions/21457906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/777612/"
] | `default=randomword()` is wrong. Since the function has called so become a constant, it is not a function any more. Pass a callable function if you want to get different values every execution:
```
import random, string
from sqlalchemy import create_engine, Column, String
from sqlalchemy.ext.declarative import declara... | default=randomword will solve the issue.
Not useful for you case, but there is another default called 'server\_default' which sits at the DB. So, even if you are manually inserting rows, 'server\_default' gets applied. |
35,914,161 | I am attempting to set a certificate in my CloudFrontDistribution using Cloud Formation.
My certificate has been issued via Certificate Manager. It has been approved, and I have validated that the certificate works by manual configuration directly through the CloudFront console.
Within my CloudFormation template, I... | 2016/03/10 | [
"https://Stackoverflow.com/questions/35914161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14971/"
] | Cloudformation added this property but it is not documented. You can use like this easily:
```
"ViewerCertificate": {
"SslSupportMethod": "sni-only",
"AcmCertificateArn": "CERTIFICATE_ARN"
}
```
Be aware that the certificate must be created in us-east-1 region, if not it won't be accepted. | Took a few days but found the answer with some help from AWS support.
The information for:
```
"ViewerCertificate" : {
"IamCertificateId" : "********",
"SslSupportMethod": "sni-only"
}
```
is found using the CLI "aws iam list-server-certificates":
```
{
"ServerCertificateId": "ASCAXXXXXXXXXXXXXX",
"Se... |
3,622,180 | As an example, in $\mathbb{R^3}$, the canonical basis is:\begin{align}
B &= \left(\begin{bmatrix}
1 \\
0 \\
0
\end{bmatrix},\begin{bmatrix}
0 \\
1 \\
0
\end{bmatrix}, \begin{bmatrix}
0 \\
0 \\
1
\end{bmatrix}\right)
\end{align}
So it is a set of 3 vectors.
There are also different bases in $\mathbb{R^3... | 2020/04/12 | [
"https://math.stackexchange.com/questions/3622180",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/248360/"
] | The vector $(1,1,1)$ clearly doesn’t span all of $\mathbb R^3$ since you can only generate vectors of the form $(a,a,a)$ from it: remember that when you multiply a vector by a scalar, you multiply all of the components by the same value.
You do ask an important question earlier, though: does every basis of $\mathbb R... | No, it cannot reproduce.
The dimension of a vector space is an invariant in the sense that each basis of an $n$-dimensional vector space consists of $n$ elements.
Your vector $A$ is a linear combination of the canonical basis $B=\{e\_1,e\_2,e\_3\}$:
$A = e\_1 + e\_2 + e\_3$, but not every vector in ${\Bbb R}^3$ is a ... |
64,200,443 | Cant Really bend my mind around this problem I'm having:
say I have 2 arrays
```py
A = [2, 7, 4, 3, 9, 4, 2, 6]
B = [1, 1, 1, 4, 4, 7, 7, 7]
```
what I'm trying to do is that if a value is repeated in array B (like how 1 is repeated 3 times), those corresponding values in array A are added up to be appended to ano... | 2020/10/04 | [
"https://Stackoverflow.com/questions/64200443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14055214/"
] | Here is a solution without pandas, using only `itertools` `groupby`:
```
from itertools import groupby
C = [sum( a for a,_ in g) for _,g in groupby(zip(A,B),key = lambda x: x[1])]
```
yields:
```
[13, 12, 12]
``` | I would use pandas for this
Say you put those arrays in a DataFrame. This does the job:
```
df = pd.DataFrame(
{
'A': [2, 7, 4, 3, 9, 4, 2, 6],
'B': [1, 1, 1, 4, 4, 7, 7, 7]
}
)
df.groupby('B').sum()
``` |
26,899,973 | I'm in the process of experimenting with transitioning an existing web app from knockout to react js.
As it stands the application establishes a websocket connection to the server and receives update asynchronously (there can be many clients which can affect each others state, think chat room for example).
My Questio... | 2014/11/13 | [
"https://Stackoverflow.com/questions/26899973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2778940/"
] | With React, unidirectional flows are often the best way to do it. To achieve this, we should use an event emitter.
Your get JSON from the server using websockets, SSE, or polling (it doesn't matter). They should be in an envelope format. This would be an example for a chat application.
```js
{
"type": "new-message"... | >
> if I were do the rendering server side, how could changes be pushed down to each client?
>
>
>
Well, you just said it, via Sockets.
However, this is not really "optimal". You wouldn't want to push markup down the line every time. I suggest you push a template down to the client if they don't have it, or just ... |
6,972,650 | I have a problem with the gloss effect in app icon at iOS 5 beta 5, in iOS 4 it's show the effect not gloss, but iOS5 shows the gloss effect. I put the option `Icon already includes gloss effects = YES`, but simply does not work, and it appears that the application Google+ also has the same problem | 2011/08/07 | [
"https://Stackoverflow.com/questions/6972650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/881095/"
] | First Settings in a your project info-list set key **Icon already inculdes gloss effects** to YES Boolean value like below screen shot:

after try project Target settings tick the **checkbox** in the **summary** tap in the **App Icons** section
lik... | There are 2 keys in the Info.plist governing this.
xCode generated the following code for you, but it doesn't offer a GUI for changing this:
Open your Info.plist file (Right Click > Open As > Source Code).
```
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles... |
31,698,756 | I just added the new TabLayout component to my app. As you may know there are two different modes for tabs `app:tabMode="scrollable"` and `app:tabMode="fixed"`.
When I use `app:tabMode="fixed"` I get following result:
[](https://i.stack.imgur.com/1y... | 2015/07/29 | [
"https://Stackoverflow.com/questions/31698756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2642024/"
] | Here's a quick hack, a lot shorter than using `setCustomView()`: use the `android:theme` attribute on your `TabLayout`:
```
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TabLayout_Them... | With this code you are able to remove the default padding. For me it worked to make slightly longer texts within one line
```
<android.support.design.widget.TabLayout
app:tabPaddingStart="-1dp"
app:tabPaddingEnd="-1dp"
```
From here:
<http://panavtec.me/playing-with-the-new-support-tablayout> |
15,564,902 | I am trying to simulate a live data stream, to test a program that is constantly filtering and computing data points. Mainly I need to make sure that it will meet timing.
Every 50 milliseconds there will be a new data point that will need to be computed on.
So I would like to create a java clock that is independent... | 2013/03/22 | [
"https://Stackoverflow.com/questions/15564902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742197/"
] | Not transparent, but still [lazy fetching](http://springinpractice.com/2011/12/28/initializing-lazy-loaded-collections-with-spring-data-neo4j/).
```
template.fetch(person.getDirectReports());
``` | Some updates based on the current neo4j reference - <http://docs.spring.io/spring-data/neo4j/docs/current/reference/html/>
@Fetch is a Obsolete annotation
neo4jTemplate.fetch() is not available, you should specify the depth - <http://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#_api_changes> |
4,885,337 | How would I extract Active Directory info (Username, first name, surname) and populate an SQL table with the results?
Many thanks
Scott | 2011/02/03 | [
"https://Stackoverflow.com/questions/4885337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/601388/"
] | If you just need it in SQL, I'm using the code below
```
INSERT...
SELECT A.SAMAccountName, A.Mail, A.displayName FROM
(SELECT * FROM OpenQuery(ADSI, 'SELECT title, displayName, sAMAccountName, givenName, telephoneNumber, facsimileTelephoneNumber, sn, userAccountControl,mail
FROM ''LDAP://domain.ro/DC=doma... | There are different ways to do that. I use PHP to get data out of our Active Directory.Take a look at the chapter "[Lightweight Directory Access Protocol](http://www.php.net/manual/en/book.ldap.php)" in the PHP Documentation. It's also easy to populate a database using PHP, e.g. [MySQL](http://www.php.net/manual/en/boo... |
62,473,510 | Here is my SQL request for a PostgreSQL datatable
```
select main_bundle_statuses.status from (
select main_bundle.status,
row_number() over
(partition by main_bundle.client_id order by main_bundle.created desc)
as rnum
from bundle main_bundle
join config_dependence cd on cd.main_config_id = ma... | 2020/06/19 | [
"https://Stackoverflow.com/questions/62473510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12898912/"
] | The problem is the lack of precision in pi. The result of the expression in your code is just 12.56. To get to 12.57, increase the precision.
```
from math import pi
R=2
Z=2*pi*R
print(round(Z, 2))
``` | You could use [`math.pi`](https://www.w3schools.com/python/ref_math_pi.asp) instead of `3.14` to be more precise, and then round it to two decimals, since with `math.pi` `Z=12.566370614359172`:
```
import math
R=2
Z= 2*math.pi*R
print(round(Z, 2))
>>>12.57
``` |
49,724,516 | I have an NSCollectionView and I would like to hide the horizontal scroll indicators.
I've tried
```
collectionView.enclosingScrollView?.verticalScroller?.isHidden = true
```
But it is not working.
Thank you in advance. | 2018/04/09 | [
"https://Stackoverflow.com/questions/49724516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3019776/"
] | **hidden** didn't work for me too.
The only way I found to hack this, is by changing inset:
(**scrollViewCollectionView** is of type **NSScrollView**, this example is while creating **NSCollectionView** programmatically)
```
scrollViewCollectionView.documentView?.enclosingScrollView?.scrollerInsets = NSEdgeInsets.in... | I got same problem and just solve it. You can write your own custom `NSScrollView` and override 2 stored property: `hasHorizontalScroller`, `horizontalScroller`, and 1 function `scrollWheel(with:)`. Here's my code:
```
class MyScrollView: NSScrollView {
override var hasHorizontalScroller: Bool {
get {
... |
36,650,319 | I'm trying to make the user be able to remove his upvote by re-clicking on the upvote button
Here's my controller
```
def upvote
if current_user.voted_up_on? @post
@post = Post.find(params[:id])
@currentUserLikes = PublicActivity::Activity.where(trackable_id: @post.id, owner_id: current_user.i... | 2016/04/15 | [
"https://Stackoverflow.com/questions/36650319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5738789/"
] | Consider of using dictionary mapping:
```
dmap = {
'As': parse_as,
'Between': parse_between,
'During': parse_during
}
```
Then you only need to use it like this:
```
dmap = {
'As': parse_as,
'Between': parse_between,
'During': parse_during
}
for l in f.readline():
s = l.split(' ')
p... | Why not use a regular expression?
```
import re
# open file
with open('datafile.txt') as f:
for line in f:
ts_vals = re.findall(r'(\d+:\d\d:\d\d)', line)
# process ts1 and ts2
```
Thus `ts_vals` will be a list with either one or two elements for the examples provided. |
43,534,240 | I have an AJAX request call (with JQuery) to my django view. It sends to view this kind of data:
```
{"cityId": 1, "products_with_priority": [{"id": 1, "priority": 1}, {"id": 2, "priority": 2}, {"id": 3, "priority": 3}, {"id": 4, "priority": 4}, {"id": 5, "priority": 5}]}
```
In my django view, I'm trying to get thi... | 2017/04/21 | [
"https://Stackoverflow.com/questions/43534240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3003432/"
] | Ensure your dataType is `json`, and stringify your array:
```
dataType: 'json',
data: {'cityId': 1, 'products_with_priority': JSON.stringify([{"id": 1, "priority": 1}, {"id": 2, "priority": 2}, {"id": 3, "priority": 3}, {"id": 4, "priority": 4}, {"id": 5, "priority": 5}])}
```
Then use the (standard Python library) ... | In AJAX request, make sure you include the header:
```
content-type: application/json
```
Then if you are using Python 3 as I do, in Django View:
```
def my_view(request):
received_json = json.loads(request.read().decode('utf-8'))
products_priority = received_json['products_with_priority']
``` |
16,874,983 | API Console data seems to be corrupted for my account. I cannot recreate the Client ID for package **com.clc.mmm.free** and my production key.
The error I am getting is "This client ID is globally unique and is already in use", **although no Client ID exist for this package in any of my active or deleted API Console p... | 2013/06/01 | [
"https://Stackoverflow.com/questions/16874983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1004296/"
] | Since the key names you'll get from your CCTV system are not in quotes, the string is not a valid JSON string. You won't be able to parse it with `json_decode` without performing some ugly string modification.
When searching for an alternative, I found this answer: <https://stackoverflow.com/a/6250894/1560865>
The an... | Use [`json_decode()`](http://www.php.net/manual/function.json-decode.php) with something like this:
```
<?php
$encdata = getTheData(); // your method to get the string
$data = json_decode($encdata);
foreach($data => $row)
{
// access the row members like this:
// $row->alarmimage
// $row->timestamp
... |
66,147,707 | I'm a student learning C and I was puttering around with arrays of strings and malloc().
I have the following code that is supposed to load an array of strings (statically created) with dynamically created strings (please forgive / correct me if my terminology does not align with the code I have).
The problem is, onc... | 2021/02/11 | [
"https://Stackoverflow.com/questions/66147707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8163401/"
] | `ram[i] = "aaaa";` reassigns the pointers at `a[i]` to point to static memory, discarding the result of `malloc`. Later on you pass those pointers to `free`, which fails because they were not the result of an `*alloc` function.
Use [`strcpy`](https://linux.die.net/man/3/strcpy) to instead copy the string from static m... | C's syntax strongly suggests that `"aaaa"` is a "string". People even talk of this syntax that way: they call it "strings". But `"aaaa"` is nothing such. It's the unfortunately named string literal, which is *not* a string - neither in C nor in C++. A `char *` is not a string either - it's a pointer-typed value. It's u... |
47,345,474 | Using C++11 or C++14:
I have a:
```
constexpr double [2][3][4] = some value;
```
I want `constexpr int [2][3][4]` from this.
(Actually I will want `constexpr my_type [2][3][4]`, but that should be trivially solvable once int works.)
The only solution I came up with was a container class with `operator[]` overload... | 2017/11/17 | [
"https://Stackoverflow.com/questions/47345474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832745/"
] | If you accept a `constexpr std::array<std::array<int, 4U>, 3U>, 2U>`, well... using ~~SFINAE~~ tag-dispatching, `std::rank`, `decltype()`, `auto` as return type and `std::index_sequence` (so a C++14 solution) you can ping-pong play with a `getArray()` and his helper `getArrayH()` functions as follows
**NOTE**: answer ... | Unfortunately, [`std::array::operator[]` is not constexpr before C++17](http://en.cppreference.com/w/cpp/container/array/operator_at). Hence you probably need to come up with your own boilerplate.
Here is an example in C++17. If you export the "indices trick" into a separate function (instead of lambda) and implement ... |
3,650,995 | I'm starting to design an application, that will, in part, run through a directory of files and compare their extensions to their file headers.
Does anyone have any advice as to the best way to approach this? I know I could simply have a lookup table that will contain the file's header signature. e.g., `JPEG: \xFF\xD8... | 2010/09/06 | [
"https://Stackoverflow.com/questions/3650995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/180449/"
] | I'm afraid it'll have to be more complicated than that. Not every file type has a header at all, and some (such as RAR) have their characteristic data structures at the end rather than at the beginning.
You may want to take a look at the Unix `file` command, which does the same job:
* <http://linux.die.net/man/1/file... | You can know the file type of file reading the header using apache tika.
Following code need apache tika jar.
```
InputStream is = MainApp.class.getResourceAsStream("/NetFx20SP1_x64.txt");
BufferedInputStream bis = new BufferedInputStream(is);
AutoDetectParser parser = new AutoDetectParser();
Detector detector = p... |
8,603,944 | I'm getting a text from server side and I want to show one word for each button click. Here is my approach:
```
$(document).ready(function()
{
$.ajax(
{
type: "GET",
dataType: 'json',
url: "request.php",
... | 2011/12/22 | [
"https://Stackoverflow.com/questions/8603944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/784266/"
] | There two problems with your code;
You're using `.append()` to append `span` elements to `#container` but it returns `#container` jQuery object. So everytime you append a `span` element you call `.hide()` for `#container`. As you can see I changed it a little. You have to create `span` element, hide it and then append... | Declare two vars:
```
var arr = [];
var inc = 0;
```
After the ajax call, store the words to an array:
```
for (i = 0; i < 10; ++i)
arr.push(words[i]);
}
```
then:
```
$("#button").click(function(){
while (inc < arr.length) {
$("#container").html("<span>"+... |
531,685 | I have a MacPorts installed ProFTPD daemon installed. It worked like a charm for a year. Now it does not work at all anymore. All I get is
### Connection refused
```
ftp localhost
Trying ::1...
ftp: Can't connect to `::1': Connection refused
Trying 127.0.0.1...
ftp: Can't connect to `127.0.0.1': Connection refused
Tr... | 2013/08/17 | [
"https://serverfault.com/questions/531685",
"https://serverfault.com",
"https://serverfault.com/users/101547/"
] | If you're talking about backing up the vhd of the virtual machine, you can:
* Create periodic blob **snapshots** (since the vhd is stored in a Windows Azure Storage blob). Initially snapshots don't really take up any space since they're effectively an index of storage pages. Over time, if these pages change, *then* th... | This is a nice tutorial complementing David's answer: [Create Backups of Virtual Machines in Windows Azure by using PowerShell](http://blogs.technet.com/b/heyscriptingguy/archive/2014/01/24/create-backups-of-virtual-machines-in-windows-azure-by-using-powershell.aspx)
You can backup *AzureOSDisk* and *AzureDataDisk* in... |
37,276,732 | `calling button.selected = true` does not fills the entire button frame with tint color.
>
> Expected result
>
>
>
The button should be filled entirely with the tint color in selected state.
>
> Actual result
>
>
>
The tint color only filled the the area around the text in button.
[. |
8,807 | On earth, we use a simple but effective coordinate system which determines position unambiguously on the surface (GPS achieving accuracy within 1 meter, which speaking as an engineer, is a remarkable feat in of itself).
For example, Greenwich, England is located at coordinates 51.4800° N, 0.0000°. This disregards til... | 2015/01/16 | [
"https://worldbuilding.stackexchange.com/questions/8807",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/557/"
] | >
> Suppose you were given orders to explore an unknown planet's volcano, how would they deliver the coordinates?
>
>
>
"They" would need to give you two things: the coordinates of the planet itself, needed for the interplanetary travel, and the coordinates of the volcano on the planet.
These are two different co... | The co-ordinate system you choose would depend on the location you want to specify.
If you want to specify the position of a star within the Milky Way, one option might be to use a polar co-ordinate system centered on the galactic center of mass. Inspired by the terrestrial longitude/latitude co-ordinate system, we w... |
6,686,290 | I'm looking for a way to serve a "Maintenance Mode" website from Amazon S3 or Azure Blob storage while I'm updating my website to a new version. I'd like to just flip DNS over to point to maint.mydomain.com (which would be a static site & return 503 http status). Is this possible to do with either of these, or would I ... | 2011/07/13 | [
"https://Stackoverflow.com/questions/6686290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/226060/"
] | It seems like you can also make amazon s3 to return 404s for your website during maintenance by specifying incorrect path to the index file and providing correct path for the error page which will be always returned when you hit any url at the endpoint (including root). | You're approaching this wrong.
You should run multiple instances, a staging and a production. Both staging and production are "production" code, but staging is used to actually deploy your changes. Once your staging is up and running you flip the staging and production instances (in Azure this is called a VIP swap). ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.