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 |
|---|---|---|---|---|---|
36,403,604 | I need to delete multiple objects from google cloud storage. I have deleted one object at a time.
This is my code:
```
var gcloud = require('gcloud')({
projectId: "sampleProject1"
});
var gcs = gcloud.storage();
var myBucket = gcs.bucket('sampleBucket1');
var file = myBucket.file('1.png');
file.delete(function (e... | 2016/04/04 | [
"https://Stackoverflow.com/questions/36403604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4182755/"
] | We do have [`bucket#deleteFiles`](https://cloud.google.com/nodejs/docs/reference/storage/latest/Bucket#deleteFiles) that will handle throttling the requests for you. You can use the `prefix` option to target multiple images by a naming convention, like:
```
bucket.deleteFiles({ prefix: 'image-' }, callback);
```
If ... | ```
var gcloud = require('gcloud')({
projectId: "sampleProject1"
});
var gcs = gcloud.storage();
var myBucket = gcs.bucket('sampleBucket1');
var collection = gcs.collection("Add file for delete");
collection.insert({'1.png'},{'2.png'});
collection.delete(function (err, apiResponse) {
... |
55,625,323 | I have a code as below
```
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_wid... | 2019/04/11 | [
"https://Stackoverflow.com/questions/55625323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3286489/"
] | I manage to solve it by setting my `width="0dp"` and `android:textAlignment="viewStart"` or `android:textAlignment="viewEnd"`
```
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.an... | You can also use [SequenceLayout](https://github.com/yasharpm/SequenceLayout) to make it work.
```xml
<Sequences>
<Horizontal>
<Span id="@id/left_text" size="wrap"/>
<Span size="1w"/>
<Span id="@id/right_text" size="wrap"/>
</Horizontal>
</Sequences>
``` |
62,042,836 | I have a fairly large CSV dataset, around 13.5MB and with approximately 120,000 rows and 13 columns. The code below is the current solution that I have in place.
```
private IEnumerator readDataset()
{
starsRead = 0;
var totalLines = File.ReadLines(path).Count();
totalStars = totalLines - 1;
string f... | 2020/05/27 | [
"https://Stackoverflow.com/questions/62042836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11742478/"
] | The basic mistake you are making is doing only **1 single line per frame** so you can basically calculate how long you will take for around 60fps:
```
120,000 rows / 60fps = 2000 seconds = 33.3333 minutes
```
due to the `yield return null;` which basically says "Pause the routine, render this frame and continue in ... | 30 minutes is insanely slow!
There seems to be a few issues:
* `bufferString` never gets cleared. See below for an updated version. Clearing it down allows the code to run in <1s on my machine with a 23MB 130,000 row input file.
* `row` gets reset at the endof each loop iteration, meaning that only `datasetTable[0, c... |
30,631,286 | Android Studio is giving me a Gradle build error that looks like this:
```
Error:(3, 22) compileSdkVersion android-22 requires compiling with JDK 7
```
Now it gives me these clickable prompts:
```
Download JDK 7
Select a JDK from the File System
Open build.gradle File
```
And I have already downloaded and install... | 2015/06/03 | [
"https://Stackoverflow.com/questions/30631286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4851777/"
] | You can use `cmd` + `;` for Mac or `Ctrl` + `Alt` + `Shift` + `S` for Windows/Linux to pull up the Project Structure dialog. In there, you can set the JDK location as well as the Android SDK location.

To get your JDK location, run `/usr/libexec/java_hom... | In Android Studio 4.0.1, Help -> About shows the details of the Java version used by the studio, in my case:
```
Android Studio 4.0.1
Build #AI-193.6911.18.40.6626763, built on June 25, 2020
Runtime version: 1.8.0_242-release-1644-b01 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, Co... |
17,429,591 | I have three ViewControllers:
```
RootViewController
FirstViewController
SecondViewController
```
From the RootViewController I create a TabBarController with the other two ViewControllers. So I need to do something like:
```
FirstViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"Fir... | 2013/07/02 | [
"https://Stackoverflow.com/questions/17429591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/613265/"
] | Have your root view controller pass the value of viewController2 down to viewController1 when it creates them. Describe the properties as weak, as you want rootController to own them, not the other viewController. | This will help you. You can access secondViewController this way.
```
UITabBarController *tabController = (UITabBarController *)[self parentViewController];
[tabController.viewControllers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[SecondViewController class]]) {
... |
63,445,198 | I'm trying to create a web server that allow users to oauth their IB accounts. To obtain a request token, you first need to get a consumer key. I tried to follow their instruction, but there is no details on how to make a call to get the `consumer_key`.
What exactly should the endpoint be? Is it a `POST` or `GET` call... | 2020/08/17 | [
"https://Stackoverflow.com/questions/63445198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4168649/"
] | Even though you registered your consumer\_key in InteractiveBroker settings page, OAuth flow for the consumer\_key will not be worked because IB Web API OAuth flow is not ready to work.
Their customer service doesn't have the ability to solve the problem because the OAuth flow should be ready by the developers for IB S... | If your talking about the web trading API you have to submit several things to IB in order to get your application registered. Onboarding instructions can be found in their OAuth document at: <https://www.interactivebrokers.com/webtradingapi/oauth.pdf> |
14,840,310 | ```
def regexread():
import re
result = ''
savefileagain = open('sliceeverfile3.txt','w')
#text=open('emeverslicefile4.txt','r')
text='09,11,14,34,44,10,11, 27886637, 0\n561, Tue, 5,Feb,2013, 06,25,31,40,45,06,07, 19070109, 0\n560, Fri, 1,Feb,2013, 05,21,34,37,38,01,06, 13063500, 0\n55... | 2013/02/12 | [
"https://Stackoverflow.com/questions/14840310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1478335/"
] | This should do the trick:
```
import re
filename = 'sliceeverfile3.txt'
pattern = '\d\d,\d\d,\d\d,\d\d,\d\d,\d\d,\d\d'
new_file = []
# Make sure file gets closed after being iterated
with open(filename, 'r') as f:
# Read the file contents and generate a list with each line
lines = f.readlines()
# Iterate each... | You're sort of on the right track...
You'll iterate over the file:
[How to iterate over the file in python](https://stackoverflow.com/questions/5733419/how-to-iterate-over-the-file-in-python)
and apply the regex to each line. The link above should really answer all 3 of your questions when you realize you're trying t... |
18,516,137 | I am using `regex` to capture hashtags from a string like this:
```
var words = "#hashed words and some #more #hashed words";
var tagslistarr = words.match(/#\S+/g);
console.log(tagslistarr);
```
this will return an array like this;
```
["#hashed", "#more", "#hashed"]
```
question: how can i remove the `#` hash... | 2013/08/29 | [
"https://Stackoverflow.com/questions/18516137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1057045/"
] | Try:
```
words.match( /#\S+/g ).map( function(x) { return x.replace(/^#/,''); } );
```
A better way to do this would be zero-width assertions; unfortunately, JavaScript does not support look-behind assertions, only look-ahead. (As an aside, here is a blog post about [mimicking lookbehind assertions in JavaScript](ht... | ```
var words = "#hashed words and some #more #hashed words";
var regexp = /#(\S+)/g; // Capture the part of the match you want
var results = [];
var match;
while((match = regexp.exec(words))) // Loop through all matches
results.push(match[1]); // Add them to results array
console.log(results);
``` |
48,126,328 | Why it doesn't work? When I'm trying to call example.example() I'm getting TypeError: example.example is not a function.
```
var example = class {
constructor(){
this.example = false;
}
id(){
this.example = !this.example;
return this.example;
}
};
``` | 2018/01/06 | [
"https://Stackoverflow.com/questions/48126328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5157656/"
] | >
> When I'm trying to call example.example() I'm getting TypeError:
> example.example is not a function.
>
>
>
`example` is a reference to an anonymous class, and **its constructor can only be invoked with `new`**
You need to call it as
```
var a = new example();
a.example; //false
```
**Demo**
```js
var ex... | You have created class so you need to make an object of this.It should work by calling like this.
```js
var example = class {
constructor(){
this.example = false;
}
id(){
this.example = !this.example;
return this.example;
}
};
console.log((new example()).id());
var obj = new example();
console... |
36,919,825 | How to send a pandas dataframe to a hive table?
I know if I have a spark dataframe, I can register it to a temporary table using
```
df.registerTempTable("table_name")
sqlContext.sql("create table table_name2 as select * from table_name")
```
but when I try to use the pandas dataFrame to registerTempTable, I get t... | 2016/04/28 | [
"https://Stackoverflow.com/questions/36919825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4057016/"
] | I guess you are trying to use pandas `df` instead of [Spark's DF](https://spark.apache.org/docs/latest/api/python/pyspark.sql.html#module-pyspark.sql.functions).
Pandas DataFrame has no such method as `registerTempTable`.
you may try to create Spark DF from pandas DF.
**UPDATE:**
I've tested it under Cloudera (with... | I converted my pandas df to a temp table by
1) Converting the pandas dataframe to spark dataframe:
```
spark_df=sqlContext.createDataFrame(Pandas_df)
```
2) Make sure that the data is *migrated* properly
```
spark_df.select("*").show()
```
3) Convert the spark dataframe to a temp table for querying.
```
spark_d... |
3,274,968 | The follow http post request send data using multipart/form-data content type.
```
-----------------------------27311326571405\r\nContent-Disposition: form-data; name="list"\r\n\r\n8274184\r\n-----------------------------27311326571405\r\nContent-Disposition: form-data; name="list"\r\n\r\n8274174\r\n------------------... | 2010/07/18 | [
"https://Stackoverflow.com/questions/3274968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/290082/"
] | `---27311326571405` is called boundary and it is a random string that should never appear in the data you are sending and is used as separator between the values.
Here's an example of sending such a request to a given address:
```
class Program
{
static void Main()
{
var data = new List<KeyValuePair<s... | If you like to remove `---27311326571405` boundary value in response, please use the following code
```
var multiplarty = require('multiparty')
var util = require('util')
if ( req.method === 'POST') {
var form = new multiplarty.Form();
form.parse(req, function(err, fields, files) {
res.writeHead(200, {'content... |
15,372,940 | I was wondering how to set up my `UICollectionView` so that up to 1 cell can be selected per section. I see that there is the `allowsMultipleSelection` property for UICollectionView but I'm wondering how to prevent multiple cells from being selected in the same section.
Do I need to implement logic in the `– collectio... | 2013/03/12 | [
"https://Stackoverflow.com/questions/15372940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508642/"
] | In Swift 5.0:
```
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.allowsMultipleSelection = true
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
(collectionView.indexPathsForSelectedItems ?? [])
.filter { $0.section == indexPa... | You'll probably need to do logic in `-shouldSelect` and `-shouldDeselect`. Maybe keep **a dictionary of number of cells selected per section**?
```
NSMutableDictionary *dict;
- (BOOL)collectionView:(UICollectionView *)view shouldSelectItemAtIndexPath:(NSIndexPath *)path
{
NSInteger *section = path.section;
if... |
29,407,453 | I am currently working on a big WPF project which is already been developed and structured, furthermore it is expected to grow. However it doesn't have any of the MVVM pattern architecture components.
One of our goals now is to restructure contained UIs to support the MVVM pattern components.
Due the design of MVVM v... | 2015/04/02 | [
"https://Stackoverflow.com/questions/29407453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4188683/"
] | I don't see any problem in what you're proposing. If you follow the MVVM pattern 'correctly' then it should provide complete separation between your Views and your ViewModels. As such it might also make sense to put all of your Views in a separate project to your ViewModels. Your ViewModels *should* all function perfec... | we use prism and we have our views and viewmodel split into 5 separate projects, not to mention other projects (infrastructures, data layer etc). We use prism to manage those 5 (4 of them are prism modules - wpf class libraries) and one of them is the main wpf project which loads the others into a shell. |
231,124 | I want to build a liquor shelf similar to this:
[](https://i.stack.imgur.com/YF8Y6.jpg)
I've seen metal piping and flanges like this at my local big box store, and it usually comes in two flavors: galvanized steel or black iron pipe.
The problem wit... | 2021/07/30 | [
"https://diy.stackexchange.com/questions/231124",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/87068/"
] | What's in the photo is **painted**.
Any pipe you use will require surface preparation for paint to *last a long time* and not chip off easily.
* Galvanized pipe will require either the galvanizing to be removed chemically or by harsh mechanical removal... or you can leave galvanized stuff outdoors for a year, and it ... | As @alephzero mentioned, you can get anodized aluminum in any color. The texture looks more like bare metal than paint if that is what you want. Here is a picture of the 2020 aluminum extrusion.
[](https://i.stack.imgur.com/RD6Je.jpg) |
12,734,435 | I'm trying to get the text size on my landing page to scale linearly with the viewport size. If you look at my site at <http://alexanderwhill.com/site2/> you will see what I'm saying. I would like the font size to scale fluidly instead of overflowing. Is this even possible? | 2012/10/04 | [
"https://Stackoverflow.com/questions/12734435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1713593/"
] | While it generates HTML on the fly, it still use the same CSS as everything else. So just add on required page `<style>` tag with required css which will override default styles or prepare few css files, with css rules overriding default styles, which you will attach to your page when you need that. | One thing you could consider is having no CSS for the colorbox itself, but instead having the content of the pop up in its own page and call it via ajax. Have all the CSS for the particular pop up in its own page. I've used this method before. The only CSS you need in the colorbox file is the background colour/transpar... |
34,512,646 | I've constructed the following little program for getting phone numbers using google's place api but it's pretty slow. When I'm testing with 6 items it takes anywhere from 4.86s to 1.99s and I'm not sure why the significant change in time. I'm very new to API's so I'm not even sure what sort of things can/cannot be spe... | 2015/12/29 | [
"https://Stackoverflow.com/questions/34512646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5037442/"
] | Use sessions to enable persistent HTTP connections (so you don't have to establish a new connection every time)
Docs: [Requests Advanced Usage - Session Objects](https://requests.readthedocs.io/en/latest/user/advanced/#session-objects) | Most of the time isn't spent computing your request. The time is spent in communication with the server. That is a thing you cannot control.
However, you may be able to speed it along using parallelization. Create a separate thread for each request as a start.
```
from threading import Thread
def request_search_term... |
234,084 | I have some code that kills processes and their children/grandchildren. I want to test this code.
Currently I'm doing `$ watch date > date.txt`, which creates a process with a child.
Is there any way to create a **parent -> child -> grandchild** tree? What command can make that happen? | 2015/10/05 | [
"https://unix.stackexchange.com/questions/234084",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/137147/"
] | You can create a recursive script. eg in file `/tmp/run`
```
#!/bin/bash
depth=${1:-3}
f(){
let depth--
if [ $depth -gt 0 ]
then $0 $depth
else sleep 999
fi
}
f
```
then `chmod +x /tmp/run` and do `/tmp/run 3`. | The `ps` command on freebsd doesn't seem to be able to produce a process tree. Fortunately there is a package called `pstree` which contains a program that will do precisely that. |
6,742,938 | I have a few queues running with RabbitMQ. A few of them are of no use now, how can I delete them? Unfortunately I had not set the `auto_delete` option.
If I set it now, will it be deleted?
Is there a way to delete those queues now? | 2011/07/19 | [
"https://Stackoverflow.com/questions/6742938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/498313/"
] | Another option would be to enable the management\_plugin and connect to it over a browser. You can see all queues and information about them. It is possible and simple to delete queues from this interface. | I was struggling with finding an answer that suited my needs of manually delete a queue in rabbigmq. I therefore think it is worth mentioning in this thread that it is possible to delete a single queue without `rabbitmqadmin` using the following command:
```
rabbitmqctl delete_queue <queue_name>
``` |
125,864 | I am comparing traditional stock markets with the Forex market here.
I have noticed stock market have relatively limited leverage but have more change % as well as as volatility. On the other hand, 1% change is a big thing in forex market but they are highly leveraged.
Are their pros and cons of trading one type of i... | 2020/05/26 | [
"https://money.stackexchange.com/questions/125864",
"https://money.stackexchange.com",
"https://money.stackexchange.com/users/98607/"
] | Speaking generally:
* Lower leverage means risk is better controlled. In the simplest case, an unleveraged long stock position (no matter how volatile) cannot lose more than what you put in. Higher leverage on a less volatile asset may be calibrated so that your *expected* exposure to volatility is the same, but there... | Forex is like trading two stocks against each other in a way.
* Where stocks have a company's financial reports, forex has a country's report. But stocks can also be affected by a country's economical health (Apple for example since it is a large part of the SP500 index)
* There is a US Dollar Index (58% is EURUSD) wh... |
51,447,779 | I want to fetch json from a url <https://api.myjson.com/bins/mxcsl/> using retrofit and rxjava.
Sample json is this :
```
{
"data": [
{
"itemId": "1",
"desc": "Batcave",
"audio": "https://storage.googleapis.com/a/17.mp3"
},
{
"itemId": "2",
"desc": "Fight Club rules",
"audio": "https://storage.googleapis.... | 2018/07/20 | [
"https://Stackoverflow.com/questions/51447779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6349540/"
] | Your type
```
Observable<List<Data>> register();
```
is wrong. Because Json's first level is not Array (But object with field `data`, that is array).
You should create class for outer structure
```
public class Outer{
List<Data> data;
}
```
And specify in retrofit, as observable:
```
@GET("/bins/mxcsl/")
Ob... | The error is because Retrofit is expecting a json array to be deserialized as a List
```
public interface RequestInterface {
@GET("/bins/mxcsl/")
Observable<List<Data>> register();
}
```
But the json response is an object with a field named *data* that is an array
```
{
"data": [
{
"itemId": "1",
"... |
38,393,822 | I have a Spring MVC form for inputting a date, the input gets sent to a Controller and validated via standard Spring MVC validation.
Model:
```
public class InvoiceForm {
@Future
private LocalDate invoicedate;
}
```
Controller:
```
public String postAdd(@Valid @ModelAttribute InvoiceForm invoiceForm, Bindi... | 2016/07/15 | [
"https://Stackoverflow.com/questions/38393822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4096682/"
] | I'd agree with Miloš that using the `META-INF/validation.xml` is probably the cleanest and easiest way, but if you do really want to set it up in a Spring `@Confguration` class then it is possible and here's one way you can do it.
The beauty of Spring Boot is that does a lot of configuration on your behalf so you don'... | A custom [`LocalValidatorFactoryBean`](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.html) bean can configured with the custom mapping and then be wired as a Spring Bean, replacing the default autowired Spring Boot validator:
``... |
19,780,029 | Here is the code. 5000 bouncing spinning red squares. (16x16 png) On the pygame version I get 30 fps but 10 fps with pyglet. Isnt OpenGl supposed to be faster for this kind of thing?
pygame version:
```
import pygame, sys, random
from pygame.locals import *
import cProfile
# Set FPS
FPS = 60.0
clock = pygame.time.C... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19780029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2953823/"
] | You can find more detailed information about the Ignore() function in the [SCons man pages](http://www.scons.org/doc/production/HTML/scons-man.html). Here is the signature according to the man pages:
```
Ignore(target, dependency)
env.Ignore(target, dependency)
```
You should be able to do the following:
```
# assu... | Well, I thought of a workaround.
I made a commandline variable that I use to determine whether the build is rooted at F.
It seems like there is probably a "SCons" way to do it that I'm missing, but I think this is fine.
```
do_abc = False
for key, value in ARGLIST:
if key == "do_abc":
do_abc = bool(value)
... |
129,990 | So recently I decided to create a Star Wars D&D campaign. It starts out with the group as Mandalorian bounty hunters. However, before I make this officially start, I need to know if I can use other races for the players such as Zabraks, Trandoshans, Rodians, etc. Do Mandalorians consist of humans only or are there alie... | 2016/06/04 | [
"https://scifi.stackexchange.com/questions/129990",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/67074/"
] | Choice of race will never restrict you in any way to play through any storyline in swtor.
As for story/lore/RPG i direct you to [this wiki page.](http://swtor.wikia.com/wiki/Mandalorian)
>
> *"An **interspecies** warrior culture stretching back thousands of years, the Mandalorians live for one purpose: to challeng... | Legends:
--------
In Legends, Mandalorians used to all be aliens, comprised of the [Taung](http://starwars.wikia.com/wiki/Taung).
Many different species later went on to join them.
>
> Here's why you can't exterminate us, aruetii. We're not huddled in one place—we span the galaxy. We need no lords or leaders—so you... |
7,969,109 | As I've pointed out - [here](https://stackoverflow.com/questions/5587140/any-tutorial-on-how-to-use-clang-for-syntax-highlighting-and-code-completion/7250322#7250322) - it seems clang's libclang should be great for implementing the hard task that is C/C++ code analysis and modifications ([check out video presentation a... | 2011/11/01 | [
"https://Stackoverflow.com/questions/7969109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/544721/"
] | Google have been working on a tooling library for Clang. [In since the 3.2 release](http://llvm.org/svn/llvm-project/cfe/branches/release_32/include/clang/ASTMatchers/). It includes a ASTMatchers library so you can just build up a query and don't have to walk the AST.
There is a [great video talk](http://www.youtube.c... | Google made a Clang based refactoring tool for their C++ code base and plans to release it. I don't know the current state of the project, but you can see this demo presented on the 2011 LLVM Developers Meeting: <https://www.youtube.com/watch?v=mVbDzTM21BQ>.
Also, XCode's (4+) built-in auto-completion and refactoring ... |
45,018 | My Sony earphones are damaged, I've got other earphones (non-SONY) but are not accepted by the phone. Is there a way to make them work ?? | 2013/05/07 | [
"https://android.stackexchange.com/questions/45018",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/33574/"
] | There are different standards for headset plugs, and Sony has started using the CTIA layout for it's smartphones since 2012. I couldn't find the official documentation on the differences, but it's pretty well explained [here](http://www.martzell.de/2012/12/pin-belegung-headset-iphone-omtp-ctia.html) (In german, but the... | You can try Nokia's headphones. I think they will work with them. |
18,928,216 | It may be asked somewhere but I could not find it.
Please tell me the exact difference between:
```
ArrayList list = new ArrayList();
```
and
```
ArrayList<?> list = new ArrayList();
```
I cannot figure out what is the exact difference between these two.
Thanks... | 2013/09/21 | [
"https://Stackoverflow.com/questions/18928216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2801200/"
] | ```
ArrayList list = new ArrayList();
```
We are declaring an array list that can accept any type of objects.
For example:
```
list.add(new Dog());
list.add(new Person());
list.add("Test");
```
For `ArrayList<?> list = new ArrayList();`
We are declaring an array list using generics that can accept any object usi... | ArrayList < ? > means array list of type unknown. it is called a wildcard type.
Using the wild card, the following occurs
```
Collection<?> c = new ArrayList<String>();
c.add(new Object()); // Compile time error
```
Without the wildcard you can add whatever you like to your array |
66,866,092 | I'm exploring what's possible to do in Python and recently came across this question: after running a function, is it possible to programmatically determine whether it has referenced anything out-of-scope? For example:
```
import module1
y = 1
def foo1(x):
return y + x # yes - it has referenced 'y' which is out... | 2021/03/30 | [
"https://Stackoverflow.com/questions/66866092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9223023/"
] | You can use [`inspect.getclosurevars`](https://docs.python.org/3/library/inspect.html#inspect.getclosurevars):
>
> Get the mapping of external name references in a Python function or
> method func to their current values. A named tuple
> ClosureVars(nonlocals, globals, builtins, unbound) is returned.
> nonlocals maps... | Check the builtin [locals()](https://docs.python.org/3/library/functions.html#locals) function. This will return a dictionary of the variables in the local scope.
```python
global_var = "Hello"
def foo():
local_var = "world"
if "local_var" in locals(): print(c)
if "global_var" in locals(): print(global_var)
>>> f... |
18,072,759 | I have this nested list:
```
l = [['40', '20', '10', '30'], ['20', '20', '20', '20', '20', '30', '20'], ['30', '20', '30', '50', '10', '30', '20', '20', '20'], ['100', '100'], ['100', '100', '100', '100', '100'], ['100', '100', '100', '100']]
```
I want to convert each element in `l` to `float`. I have this code:
`... | 2013/08/06 | [
"https://Stackoverflow.com/questions/18072759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1214293/"
] | I wanted to share how the list comprehension actually works, especially for nested list comprehensions:
```
new_list= [float(x) for x in l]
```
is actually the same as:
```
new_list=[]
for x in l:
new_list.append(float(x))
```
And now for the nested list comprehension:
```
[[float(y) for y in x] for x in l]
... | In case a flattened list is needed:
```
[y for x in l for y in x]
```
In case a nested list (list in list) is needed:
```
[[float(y) for y in x] for x in l]
``` |
2,900,904 | I'm working on a Linux kernel module for a 2.6.x kernel and I need to view the assembly output, though it's currently being done as a temporary file an deleted afterwords. I'd like to have the assembly output mixed with my C source file so I can easily trace where my problem lies. This is for an ARMv6 core and apparent... | 2010/05/24 | [
"https://Stackoverflow.com/questions/2900904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/99065/"
] | Assuming gcc and the gnu assembler a more readable output than `objdump` can be had. Tell the assembler to retain its intermediate code using flags to gcc:
```
-Wa,-alh=basename.s
```
And to get `basename` to be the actual source filename you need to tell make:
```
-Wa,-alh=$<.s
```
which will leave piles of fo... | To get an assembly language listing of my Linux kernel modules, I added the assembler switches to the kernel scripts/Makefile.build.
```
#cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
cmd_cc_o_c = $(CC) $(c_flags) -c -Wa,-alh=$<.lst -o $(@D)/.tmp_$(@F) $<
``` |
2,508,073 | greetings all,
when trying to commit into tortoise svn using cruise control i am getting an exception
```
[SVN commit: warn] source control failure (GetModifications): Unable to execute file
[ c:\sand\doc\svn ]. The file may not exist or may not be executable.
```
where "c:\sand\doc" is my working directory. In thi... | 2010/03/24 | [
"https://Stackoverflow.com/questions/2508073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300529/"
] | You need to add the folder containing svn.exe to your path on the CC server, or specify a full path to the exe where you attempt the commit. | It sounds like it's trying to find the svn executable in the c:\sand\ folder, so I'm guessing that you've mixed up your configuration somewhere? |
44,374,074 | So my issue is pretty simple. I have some files that I want to be copied to the build output directory whether it is a debug build or a release publish. All of the information I can find is about the old json config approach. Anyone have an example using the csproj with dotnetcore? | 2017/06/05 | [
"https://Stackoverflow.com/questions/44374074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3887945/"
] | I had the requirement for a selection of HTML templates to be consumable both client-side and server-side (Handlebars js)
```xml
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Update="wwwroot\html-templates\**... | ```xml
<PropertyGroup>
<PostBuildEvent>xcopy "$(ProjectDir)Xml" "$(ProjectDir)$(OutDir)Xml" /S /F /I /R /Y</PostBuildEvent>
</PropertyGroup>
```
or
```xml
<PropertyGroup>
<PostBuildEvent>copy /Y "$(ProjectDir)MyXml.xml" "$(ProjectDir)$(OutDir)Xml"</PostBuildEvent>
</PropertyGroup>
``` |
32,427,921 | I have a Spring MVC application (Spring Boot v. 1.2.5) that uses JPA to interact with a popular Sql Database.
Thus, I have several entities mapping all the tables in the db. Clearly, these classes are having only getters/setters and annotations for the relations between entities.
E.g.:
```
@Entity
@Table
public cl... | 2015/09/06 | [
"https://Stackoverflow.com/questions/32427921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1983997/"
] | You should test functionality not class. If you are not sure if mapping is working correctly, then maybe testing save/load of objects of this class is suitable test for you. However, unit testing should also isolate persistence layer, so you can test your business logic instead of persistence layer. | JUnit test for JPA entity with code coverage
```
public class ArticleTest {
public Article crateTestSuite(){
return new Article ();
}
@Test
public void testGetId() {
Long id= 0;
Xyz xyz =null;
xyz = crateTestSuite();
id = xyz.getId()
}
@Test
public void setI... |
25,762 | Every letter a decimal digit, different letters for different digits:
```
BASE
+ BALL
--------
GAMES
```
Which digit does each letter represent? | 2016/01/25 | [
"https://puzzling.stackexchange.com/questions/25762",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/9404/"
] | Assuming numbers can't start with 0, `G` is 1 because two four-digit numbers can't sum to 20000 or more.
`SE`+`LL`=`ES` or `1ES`.
If it is `ES`, then `LL` must be a multiple of 9 because `SE` and `ES` are always congruent mod 9. But `LL` is a multiple of 11, so it would have to be 99, which is impossible.
So `SE`+`L... | There are in total three solutions (with unique numbers):
```
G A M E S B L
-------------
0 4 9 1 6 2 5
0 4 9 3 8 2 5
1 4 9 3 8 7 5
```
So apart from the solution in @f''s answer, we have
```
2483
+ 2455
--------
04938
```
and
```
2461
+ 2455
--------
04916
``` |
3,673,388 | I tried to prove this:
[equation](https://i.stack.imgur.com/NQvLG.png)
And I came to:
[u=1-x](https://i.stack.imgur.com/N4E6r.png)
But now if I replace u by x-1, I get the same equation that needed to be proven.
So I do not know actually what to do...
Could someone help me? | 2020/05/13 | [
"https://math.stackexchange.com/questions/3673388",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/787890/"
] | You are done with the problem and you do not have to do anything else.
Note that x or u are dummy variables and you may
simply change u to x as your last step. | The integral
$$\int\_a^b f(x) dx$$
is the area under the curve of $f(x)$ as $x$ goes from $a$ to $b$.
The integral
$$\int\_a^b f(u) du$$
is the area under the curve of $f(u)$ as $u$ goes from $a$ to $b$.
These are the same area: $x$ and $u$ are called dummy variables because it doesn't matter which letter you use... |
49,424,179 | The actual JSON,that I need to parse in swift4 is,
```
{
"class": {
"semester1": [
{
"name": "Kal"
},
{
"name": "Jack"
},
{
"name": "Igor"
}
],
"subjects": [
"... | 2018/03/22 | [
"https://Stackoverflow.com/questions/49424179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8374099/"
] | There are many issues.
You are making a common mistake by ignoring the root object partially.
Please take a look at the JSON: On the top level there are 3 keys `class`, `location` and `statusTracker`. The values for all 3 keys are dictionaries, there are no arrays.
Since `class` (lowercase) is a reserved word, I'm u... | There are a few things here causing your issue.
* You have no top level item, I added Response struct
* Location, class and statusTracker are both at the same level, not under class.
* In your class struct, your items are set as arrays but they aren't arrays
* To debug these types of issues, wrap your decode in a do c... |
36,813,780 | ```
import {Component} from 'angular2/core';
@Component({
selector: 'app',
styleUrls: ['./app.component.less'],
templateUrl: './app.component.html'
})
export class AppComponent {
name:string = 'Demo'
}
```
When using the relative path for templateUrl and styleUrls, I get: error 404, file not found:
zone.js:... | 2016/04/23 | [
"https://Stackoverflow.com/questions/36813780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5540773/"
] | The `./` (single dot) notation works for ts paths only, it doesn't work with html or css paths.
These paths are relative to index.html, so according to your file structure, this should work
```ts
@Component({
selector: 'app',
styleUrls: ['app.component.less'],
templateUrl: 'app.component.html'
})
``` | You need to try
```
@Component({
selector: 'app',
template: require('./app.component.html'),
styles: [
require('./app.component.less').toString()
or
String(require('./app.component.less'))
or
add css-to-string in your webpack conf ({test: /\.css$/, loaders: ['css-to-string', 'style', 'css... |
67,168,344 | I have a database table as below.
Id 1 and 4 are old members and their data is updated (as seen in updated date column).
Id 2 and 3 new members.
So now how we can query in SQL Server and get list of members updated/registered for a given date range?
[` would be a good fit here. If `[updated date]` is `NULL`, it will then look at `[registration date]`
```
select *
from yourtable
where coalesce([updated date],[registration date]) between '2021-01-01' and '2021-01-05'
``` | ```
select *
from your_table
where [registration date] between '20210101' and '20220101'
``` |
6,209,042 | Here is my sample code:
```
var http = require('http');
var options1 = {
host: 'www.google.com',
port: 80,
path: '/',
method: 'GET'
};
http.createServer(function (req, res) {
var start = new Date();
var myCounter = req.query['myCounter'] || 0;
... | 2011/06/01 | [
"https://Stackoverflow.com/questions/6209042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/196874/"
] | I solved the problem with
```
require('http').globalAgent.maxSockets = 100000
```
or
```
agent = new http.Agent()
agent.maxSockets = 1000000 # 1 million
http.request({agent:agent})
``` | Github issue 877 may be related:
<https://github.com/joyent/node/issues/877>
Though it's not clear to me if this is what you're hitting. The "agent: false" workaround worked for me when I hit that, as did setting a "connection: keep-alive" header with the request. |
12,040,387 | I have a JSON associate array
```
[{"Test":"5:00pm"},{"Testing2":"4:30 pm"}]
```
and I want to make it so that it becomes an array where
```
{
theatre = Test
time = 5:00pm
},
{
theatre = Testing2
time = 4:30 pm
}
```
But I can't figure out how to take a key name and make it a value...
Any help? I was loo... | 2012/08/20 | [
"https://Stackoverflow.com/questions/12040387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150062/"
] | You have an array with object values. You'd need to loop over them:
```
var oldArray = [{"Test":"5:00pm"},{"Testing2":"4:30 pm"}];
var newArray = [];
for (var i = 0; i < oldArray.length; i++) {
var keys = Object.keys(oldArray[i]);
newArray.push({
theatre: keys[0],
time: oldArray[i][keys[0]]
... | ```
var result = [];
var str = [{"Test":"5:00pm"},{"Testing2":"4:30 pm"}];
for (var i = 0; i < str.length; i++) {
var obj = {};
foreach (var key in str[i]) {
obj.theatre = key;
obj.time = str[i][key];
}
result.push(obj);
}
``` |
35,819,410 | I have a code that should do exactly this:
```
A = [2;3;4;5;6;7];
b = 2;
B(10).b = zeros(6,1);
for i = 1:10
C = A;
B(i).b = C.*(b^i);
if i>1
if B(i).b(1,1)-B(i-1).b(1,1)>50
C(7) = b;
end
end
end
```
The problem is that in every iteration C matrix is replaced with the valu... | 2016/03/05 | [
"https://Stackoverflow.com/questions/35819410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5178805/"
] | You can append b to C and overwrite the value of C with the newly created value:
```
if i>1
if B(i).b(1,1)-B(i-1).b(1,1)>50
C = [C; b];
end
end
```
This should work just fine as long as C & b are not too large. | It is not recommended to change the matrix size during execution because you loose runtime. The best solution is to estimate the size of the matrix at the very beginning.
If there is no other possibility, you can add a row by the following code:
```
A = [1 2; 3 4];
A = vertcat(A,[2 3]);
```
The same works also for... |
18,769,368 | I have a QT dialog which I need to have access to from anywhere in the program. Basically what I need to do is something like creating a static instance of it somewhere in my program, something like:
'''Note''': This is just an example of what I am trying to do, not actual code (which is too long to post here)
```
cl... | 2013/09/12 | [
"https://Stackoverflow.com/questions/18769368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514983/"
] | The short answer is there is no way to accurately do this, especially with just pure SQL.
You can find exact matches, and you can find wildcard matches using the `LIKE` operator or a (potentially huge) series of regular expressions, but you cannot find *similar* matches nor can you find potential misspellings of match... | It depends a bit on what database you use, but most have some kind of REGEXP\_INSTR or other function you can use to check for the first index of a pattern. You can then write something like this
```
SELECT SubStr(merchant, 1, REGEXP_INSTR(merchant, '[0-9]')), count('x')
FROM Expenses
GROUP BY SubStr(merchant, 1, R... |
51,153,030 | Up to now, PDFs were opened by Acrobat Reader.
When I did this...
```
Dim iProcIDPDF As Integer = System.Diagnostics.Process.Start(PATH_TO_PDF_FILE).Id
```
... all was fine, I got the process ID.
Now I let Microsoft Edge open up the PDF for me with the same code, the PDF is opened up, but I get the error "System.Nu... | 2018/07/03 | [
"https://Stackoverflow.com/questions/51153030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1390192/"
] | The `processid` of Microsoft Edge is the `processid` of the application managing Edge's tabs as each tab is a process and you won't get that value using Process.Start(). You will have to check how to get the processes from a HostedApplication as Edge is a modern app.
If Internet Explorer is the one showing the PDF you... | See the System.Diagnostics.Process.Start(String fileName) documentation for the return value:
>
> A new Process that is associated with the process resource, or null if
> no process resource is started.
>
>
>
In your case you get a null return value (and since don't test for this and reference the Id property yo... |
8,529,017 | This is probably a bad example, but I think it's quite simple.
Let's say a web search engine (e.g. [Google](http://www.google.com)) is retrieving results (links to websites) of a search performed by the user and it's supposed to order them according to a given priority of languages **and** countries at the same time. S... | 2011/12/16 | [
"https://Stackoverflow.com/questions/8529017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2612112/"
] | Assuming that the languages and countries are in their own tables and that the websites table references those two, you `order by` the two fields that hold the priority of each table..
something like
```
SELECT
wesbites.url
FROM
websites
INNER JOIN languages on websites.languageId = languages.id
I... | This is a thought experiment, so the answer is a big, "It depends." If you *really* want to complicate things, then you would also be aware of that person's geolocation (or at least geopreference for those crazy ex-pats) and language.
At any rate, you'd at least have a many-to-many relationship between language and co... |
56,976,845 | I have installed Atom editor natively on Windows 10 by downloading an running the installer. Now I start WSL Ubuntu distro and want to start Atom (atom-editor) from there with the command `atom .` or VSCode (visual-studio-code) with the command `code .`
Atom starts, but not in the directory where the command was execu... | 2019/07/10 | [
"https://Stackoverflow.com/questions/56976845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4445175/"
] | I wrote a bash script to open atom with and without files from WSL2. It can handle any number (including 0) of file arguments, on any drive. Both relative and absolute paths are supported, but it can't handle path name containing .. or ~. Pointing atom to a director also works as expected. Here's my script:
```
#!/bin... | this can be a little bit outdated but you can simply run a powershell and use:
```
wsl.exe -d Ubuntu-20.04 //In my case ubuntu
```
This should open a ubuntu session or whatever wsl you have set on your own.
A little bit nooby on this but trying to help. =) |
6,553,804 | Imagine a long rectangle (maybe with size 200x20). All sides have straight edges. In my iOS app, this is easy for me to draw:
```
CGContextFillRect(context, CGRectMake(xLoc, yLoc, 200, 20));
```
Now what if I wanted the shorter ends (on the left and right side of the rectangle) to be slightly curved, rather than str... | 2011/07/01 | [
"https://Stackoverflow.com/questions/6553804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/412082/"
] | Something like this (untested, so beware of bugs!):
```
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
CGRect rrect = CGRectMake(CGRectGetMinX(re... | You may find Jeff LaMarche's RoundedRectView class useful, whether to use instances of directly or even to see how he makes them:
<http://iphonedevelopment.blogspot.com/2008/11/creating-transparent-uiviews-rounded.html> |
19,180,578 | I am trying to learn specflow and right now.
Currently I have 2 feature files.
In the second feature file, I am reusing a step from the first feature file.
Specflow automatically recognizes the step from the first feature file and when specflow generated the steps for my second feature, it was smart and did not regen... | 2013/10/04 | [
"https://Stackoverflow.com/questions/19180578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2846391/"
] | One thing I've done is used a single, massive `partial class` split up between various \*.cs files.
This lets you keep relevant things separated in their own files, but still gives you plenty of options in re-using your fixture code.
e.g.
(Feature1Steps.cs)
```
namespace YourProject.Specs
{
[Binding] // This can... | I know you mentioned you have two feature files but you might also want to think about creating one feature file with two scenarios where the scenarios use a common step as well as two identically named steps with different implementations. (overloaded functions)
```
Ex: Login.featue file
Feature: Login
Test the... |
1,092,805 | I can't seem to understand why I cant pass any values with the following code:
```
<div class="menu">
Por favor seleccione os conteúdos:
<form name="Categorias" action="Elementos_Descritivos.php" method="post">
<?php
$Categorias = array ("Nome", "Data", "Cliente", "Observacoes");
foreach( $Categorias as $key => $v... | 2009/07/07 | [
"https://Stackoverflow.com/questions/1092805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/133641/"
] | You need to set the **name** attribute on all your inputs for a form post to work. The **ID** is not posted when a form is submitted.
```
<input id=\"$value\" name=\"$value\" .../>
```
Do the same for your submit button. It will allow you to figure out which submit button was pressed in case you have many in the sa... | As Wadih pointed out - you need to assign a name attribute to your inputs. I've rewritten your code in hopes it becomes a little more clear what is going on. I've also removed the attribute $value=\"$value\".
```
<div class="menu">
Por favor seleccione os conteúdos:
<form name="Categorias" action="Elementos_De... |
20,655,612 | I want to use Back button programmaticaly, when i pressed back button:
```
onback.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
```
i want to display previous page same as i do by Clicking ... | 2013/12/18 | [
"https://Stackoverflow.com/questions/20655612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3009341/"
] | Don't call `super`. Just do:
```
onback.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Do something
onBackPressed();
}
});
``` | Try like this ..
```
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
finish();
}
```
If U need back functionality on press of button on your UI then try like this ..
```
back.setOnClickListener(new OnClickListener() {
@Ov... |
3,391,117 | I'm currently trying to implement a LALR parser generator as described in "compilers principles techniques and tools" (also called "dragon book").
A lot already works. The parser generator is currently able to generate the full goto-graph.
```
Example Grammar:
S' --> S
S --> C C... | 2010/08/02 | [
"https://Stackoverflow.com/questions/3391117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/268127/"
] | A shift entry is attributed by the next state, but a reduce entry indicates a production.
When you shift, you push a state reference onto your stack and proceed to the next state.
When you reduce, this is for a specific production. The production was responsible for shifting n states onto your stack, where n is the n... | You need to pop the stack and and find the next state from there. |
43,090,063 | I am using Laravel 5.4 and I want to view my data in database from my view page (`listpetani.blade.php`).
Here is the code of my project:
HTML:
```
<div class="table-responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th><strong>No</strong></th>
<th>... | 2017/03/29 | [
"https://Stackoverflow.com/questions/43090063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6402527/"
] | Alternatively you can use @forelse loop inside laravel blade
```
@forelse($name as $data)
<tr>
<th>{{ $data->id}}</th>
<th>{{ $data->name}}</th>
<th>{{ $data->age}}</th>
<th>{{ $data->address}}</th>
</tr>
@empty
<tr><td colspan="4">No record found</td></tr>
@endforelse
``` | I hope you already know this, but try use Model and Controller as well,
Let the route take the request, and pass it to controller
and use Eloquent so your code can be this short:
```
$petani = PetaniModel::all();
return view('listpetani', compact('petani));
```
and instead using `foreach`, use `forelse` with `@empty... |
6,860,560 | I am going through my style sheets in an attempt to make my CSS for IE friendly and I am running into an issue with my padding-left for some reason. It is only applying the padding to the first line of text in my 'span' tag. When the text runs to the next line it goes all the way to the left inside the 'span' element.
... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6860560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/386276/"
] | IE7 does not support `display: table-cell`: <http://caniuse.com/css-table>
You'll have to find an alternative technique, if only for IE7.
Try adding `*float: left` to the `span` - it will [only apply](http://mathiasbynens.be/notes/safe-css-hacks#css-hacks) to IE7 and lower. Maybe that will be a "good enough" fix.
It... | It seems similar to the question asked here: [Why Doesn't IE7 recognize my css padding styles on anchor tags?](https://stackoverflow.com/questions/2330357/why-doesnt-ie7-recognize-my-css-padding-styles-on-anchor-tags) I'm not sure exactly why it does that, it seems to be an IE bug. I would suggest either wrapping your ... |
1,444,112 | ```
#include <cstdio>
class baseclass
{
};
class derclass : public baseclass
{
public:
derclass(char* str)
{
mystr = str;
}
char* mystr;
};
baseclass* basec;
static void dostuff()
{
basec = (baseclass*)&derclass("wtf");
}
int main()
{
dostuff();
__asm // Added this after the answer fo... | 2009/09/18 | [
"https://Stackoverflow.com/questions/1444112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175492/"
] | ```
basec = (baseclass*)&derclass("wtf");
```
Here a temporary object of `derclass` is created and destructed immediately when `;` is encountered in `dostuff()` function. Hence, your `basec` pointer points to invalid object. | It creates the temporary variable on the stack because it's a local variable to the dostuff() function. Once the dostuff function exits, the stack rolls back possibly leaving the object on the memory stack exactly as it should be. Now your pointer is pointing to a spot on the stack that hopefully won't get clobbered by... |
3,983,829 | Is there a way, short of actually checking out the parent commit, to determine a submodule's SHA-1 commit ID based on a commit ID in the parent clone? I know I can find the *currently* associated SHA-1 with `git submodule`.
Here's an example:
* I have a clone with a single submodule `foo` that has changed several ti... | 2010/10/21 | [
"https://Stackoverflow.com/questions/3983829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143397/"
] | You may use [`git-ls-tree`](http://www.kernel.org/pub/software/scm/git/docs/git-ls-tree.html) to see what the SHA-1 id of a given path was during a given commit:
```
$ git ls-tree released-1.2.3 foo
160000 commit c0f065504bb0e8cfa2b107e975bb9dc5a34b0398 foo
```
(My first thought was `git show released-1.2.3 foo`, b... | I did find one promising avenue:
```
$ git log --raw <since>..<until> --submodule -- <path/to/submodule>
```
With the --raw option, this does print out the (abbreviated) SHA-1 IDs corresponding to the submodule's associated commits. Unfortunately the output is very verbose and will take some work to process in a scr... |
39,198,561 | it is allowed to use custom exception, where the exception can be thrown like below.
```
try
{
int foo = int.Parse(token);
}
catch (FormatException ex)
{
//Assuming you added this constructor
throw new ParserException(
$"Failed to read {token} as number.",
FileName,
LineNumber,
... | 2016/08/29 | [
"https://Stackoverflow.com/questions/39198561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/833985/"
] | Issue is with group by .. remove OINV.DocTotal from group by and do sum like below
```
SELECT
OSLP.SlpName as Salesman,
sum(CAST(OINV.DocTotal as float)) as Achiev,
OINV.TaxDate
FROM OINV
INNER JOIN INV1 ON INV1.DocEntry = OINV.DocEntry
INNER JOIN OSLP ON OINV.SlpCode = OSLP.SlpCode
INNER JOIN OITM ON INV1.ItemC... | If you wanted to display sum of DocTotal against each seales man and also wanted to split it by TaxDate ,
use the following script
```
SELECT
OSLP.SlpName as Salesman,
CAST(sum(OINV.DocTotal) OVER(PArtition by OSLP.SlpName Order by OINV.TaxDate) as float) as Achiev
OINV.TaxDate
FROM OINV
INNER JOIN INV1 ON INV1.Do... |
9,375,585 | I have a string array. I need to remove some items from that array. but I don't know the index of the items that need removing.
My array is : string[] arr= {" ","a","b"," ","c"," ","d"," ","e","f"," "," "}.
I need to remove the " " items. ie after removing " " my result should be
arr={"a","b","c","d","e","f"}
how ... | 2012/02/21 | [
"https://Stackoverflow.com/questions/9375585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/799141/"
] | This will remove all entries that is null, empty, or just whitespaces:
```
arr.Where( s => !string.IsNullOrWhiteSpace(s)).ToArray();
```
If for some reason you only want to remove the entries with just one whitespace like in your example, you can modify it like this:
```
arr.Where( s => s != " ").ToArray();
``` | Using LinQ
```
using System.Linq;
string[] arr= {" ","a","b"," ","c"," ","d"," ","e","f"," "," "}.
arr.Where( x => !string.IsNullOrWhiteSpace(x)).ToArray();
```
or depending on how you are filling the array you can do it before
```
string[] arr = stringToBeSplit.Split('/', StringSplitOptions.RemoveEmptyEntries);
... |
17,740,790 | I have a meteor application that generates images. After they are generated, I want to serve them. But each time I write to the public folder, my meteor server restarts.
I searched for a solution and found several workarounds:
* Serve files outside of the project folder - At the moment I don't know how to achieve thi... | 2013/07/19 | [
"https://Stackoverflow.com/questions/17740790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2123714/"
] | It's not that easy.
* Writing to `public` is out of question, as Meteor manages this folder and thus restarts itself on every file change.
* Writing to ignored folder (starting with `.` or ending with `~`, or even outside of Meteor directory) is an option. However, you'll need to manually serve those files. A small mi... | This package may help:
CollectionFS adds simple yet robust file uploading and downloading abilities to your Meteor web app. It is a mix of Meteor.Collection and MongoDB's GridFS. CollectionFS stores files in your MongoDB database but also provides the ability to easily store files on the server filesystem or a remote ... |
39,709,500 | I have a column *acdtime* that gives me the time on a call in **seconds**. I need to transform those fields to *HH:MM* format.
My idea is first to convert the seconds to interval using 3904 as parameter:
>
> INTERVAL(0:0:0) HOUR TO second + acdtime UNITS second
>
>
>
and I get:
>
> 1:05:04
>
>
>
Then conve... | 2016/09/26 | [
"https://Stackoverflow.com/questions/39709500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5133654/"
] | The Top 250 is the answer for 50 rows per page and always show five pages, what you need to also do is in your result set for your dataset, make it always return 250 rows where whatever is under 250 has a blank row.
Here is an example:
```
Create table #mytable
(
firstname varchar(200),
lastname varchar(200)
)
i... | Applicable to Tablix report only.
This method will make 50 record per page or even you can customize 100 records to 20 records per page. (However you can make it 250 records anyway by adding blank rows)
Steps:
1. Create a group with below expression:
`=ceiling(rownumber(nothing)/50)`
2. New group with column will b... |
71,938,691 | How do I pass a missing argument to a function using `do.call`? The following does not work:
```
x <- array(1:9, c(3, 3))
do.call(`[`, list(x, , 1))
```
I expect this to do the same calculation as
```
x[,1]
``` | 2022/04/20 | [
"https://Stackoverflow.com/questions/71938691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5559163/"
] | you can use `quote(expr=)`
```r
x <- array(1:9, c(3, 3))
do.call(`[`, list(x, quote(expr=), 1))
#> [1] 1 2 3
identical(x[,1], do.call(`[`, list(x, quote(expr=), 1)))
#> [1] TRUE
```
Created on 2022-04-20 by the [reprex package](https://reprex.tidyverse.org) (v2.0.1)
`do.call(`[`, alist(x,, 1))` also works.
So do... | **Update:** Thanks to @moodymudskipper: ("`is_missing()` is always `TRUE` so you're just subsetting rows and keeping everything. We could do `do.call([, list(x, TRUE, 1))`. This solves this specific issue (perhaps better in fact), but not the general one of dealing with missing arguments.")
I meant `rlang`s `missing_a... |
1,305,584 | This is like when we say that the integer which comes just after $2$ is $3$.
Is there a real number which comes just after a particular real number?
For example: Is there a number which comes just after $0.5$?
>
> If any one didn't get me, read Asaf's answer because that explains my question better.
>
>
> | 2015/05/30 | [
"https://math.stackexchange.com/questions/1305584",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/227064/"
] | If you are talking about a rational number or a real number after $\frac{1}{2}$, it is not possible. For suppose $x$ were such a number. Then $\frac{\frac{1}{2}+x}{2}$ is a number after $\frac{1}{2}$, but closer than $x$. | Let $a$ and $b$ be positive reals, and $a \neq b$
To say that $b$ is the number just after $a$ it would mean that there is not any real number between $a$ and $b$. But there is! For example, we can average them: $$a < \frac{a+b}{2} < b$$
Well, maybe the number $\frac{a+b}{2}$ is the inmeadiate number after $a$, right... |
36,205,113 | I have functionality for all or any one of these checkboxes being checked. However, when they are all unchecked I get a SQL error saying: Incorrect Syntax near ')'. Incorrect Syntax near the keyword 'OR'.
```
string andOr = string.Format(" {0} (", whereAnd);
if ((!box1)
|| (!box2)
... | 2016/03/24 | [
"https://Stackoverflow.com/questions/36205113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3715482/"
] | You always add the ")" to the query. You need to refactor your logic to make it work as expected.
```
if (box1 || box2 || box3)
{
var op = " AND (";
if (box1)
{
sqlCommand.Append(op);
sqlCommand.Append("(h.o... | So I know this was not my best post. This was code that I didn't write that I had to figure out and then fix. I haven't done a lot with ADO.NET but none the less I was able to figure out a solution to what turned out to be a very simple problem. Here is the code that I used to do it
```
string andOr = string.Format("... |
41,557,733 | I am selecting a payment method and making an AJAX call But I am not able to print the `paymentOption` parameter
I tried storing it in a cookie
```
if(paymentOption == "default_cod"){
processOrderWithCOD();
optionPayment = Cash;
}
document.cookie = "$payment_option = $this.optionPayme... | 2017/01/09 | [
"https://Stackoverflow.com/questions/41557733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7191333/"
] | So it turns out that if the `AVMetadataCommonIdentifierDescription` item is nil or an empty string, the image gets hidden. All I had to do to fix it was set the description to " " if there's not text to show. I'm going to file a bug with apple on this because that's obviously not normal. | Not sure what was happening a few years ago around this problem, but the issue now is if you don't convert your image to a `pngData` the image won't show. In other words just sending the Artwork item a UIImage won't work. So it needs to be like this per Apple:
```
if let showImage = image, let pngData = showImage.pngD... |
174,320 | I'm creating a physics game involving rigid bodies in which players move pieces and parts to solve a puzzle/map. A hugely important aspect of the game is that when players start a simulation, it runs the same *everywhere*, regardless of their operating system, processor, etc...
There is room for a lot of complexity, a... | 2019/08/03 | [
"https://gamedev.stackexchange.com/questions/174320",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/130520/"
] | I'm not sure if this is the type of answer you're looking for, but an alternative *might* be to run the calculations on a central server. Have the clients send the configuration to your server, let it perform the simulation (or retrieve a cached one) and send back the results, which are then interpreted by the client a... | I'm going to give a counter-intuitive suggestion that, while not 100% reliable, should work fine most of the time and is very easy to implement.
**Reduce precision.**
Use a pre-determined constant time-step size, perform the physics over each time-step in standard double-precision float, but then quantise down the re... |
30,072 | The computer gave me this output in a window:
```
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_natty_main_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.
```
How can I fix this? | 2011/03/12 | [
"https://askubuntu.com/questions/30072",
"https://askubuntu.com",
"https://askubuntu.com/users/-1/"
] | I was running into a similar error:
```
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/dpkg/status
E: The package lists or status file could not be parsed or opened.
```
I followed similar suggestions to copy `status-old`.
```
$ head /var/lib/dpkg... | I had the same problem. These commands fixed it:
```
sudo mv /var/lib/dpkg/status /var/lib/dpkg/status-new
sudo mv /var/lib/dpkg/status-old /var/lib/dpkg/status
sudo apt-get update
``` |
641,326 | I read Joe Armstrong's ['Programming Erlang'](https://rads.stackoverflow.com/amzn/click/com/193435600X), and the 'n times faster in n core machine' theory. The efficient way to multicore programming in Erlang is to use lots of processes (threads).
I'm a C++ programmer, so I am curious about the difference between maki... | 2009/03/13 | [
"https://Stackoverflow.com/questions/641326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59597/"
] | Context switch is extremely expensive. There are none in Erlang.
Locks makes traditional programs start to think which thread is going to execute next. That is also extremely expensive. | Well, the nature of the language with variables that can only be set once and the fact that it's a functional language automatically makes programs with lots of parallelism be written and executed "the right way" for multicore.
I don't know much about erlang besides those two facts, so there might be something else to... |
312,772 | Recently I was working on [this](https://salesforce.stackexchange.com/questions/312629/how-to-sync-typeform-to-sfmc-data-extension-via-webhooks/312680#312680) integration and got the solution which I can implement easily, by placing the below SSJS code on a cloud page.
[ function works for both Landing Pages and Code Resources. If they are in the same Business Unit as the code employing the function.
It's just harder to find the right ID for a Code Resource, as the number shown in the ... |
74,144 | I know that air pressure and temperature are inversely proportional.
Now I saw in a book that "Atmospheric pressure decreases as we go higher and higher."
But at greater heights the temperature becomes low, and so the air pressure would be high.
But it is given atmospheric pressure decreases with altitude. I underst... | 2013/08/14 | [
"https://physics.stackexchange.com/questions/74144",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/28241/"
] | If you simply go outside and hold in your hand something of standard area, like a coin, atmospheric pressure is nothing but the weight of all the air above that coin, in a very slender cylinder, going from the coin up to outer space.
Of course, since some of the air can sneak in under it and push up, you don't feel tha... | Air pressure
It can be measured by pressure gauge.
It can be changed.
Atmospheric pressure.
It is measured by barometer.
It cannot be changed. |
5,828,568 | I want to change the position of an item in ListView dynamically.How can I do that? | 2011/04/29 | [
"https://Stackoverflow.com/questions/5828568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730545/"
] | The ListView is backed up by some data structure (e.g. a `List<String>`). So you can do
Pseudocode:
```
List<String> list = ...
ListView lv = ..
Adapter a = new Adapter(..., list);
lv.setOnClickListener(this);
onItemPressed(..., int position, ...) {
tmp = list.get(0);
list.set(0, list.get(position));
list.s... | do this for change position of listview in coding
```
ListView.setSelection(position);
``` |
12,387,691 | The system has a page where the user can search through items by specifying a start date and end date. These are plain dates (Without the time component). For the user it seems most intuitive for the end date to be inclusive (so include all items for that end date as well).
The `CreateDate` of the items however does c... | 2012/09/12 | [
"https://Stackoverflow.com/questions/12387691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264697/"
] | There should be a contract for the semantics of the service exposed by your business layer, and probably automated tests for that contract.
This contract should define how the input arguments are interpreted and validated, for example:
* What is the result if StartDate > EndDate?
* What range of dates is acceptable (... | I usually put that line of code and others like it in the business/domain layer or domain service.
Whether it is:
```
endDate.Date.AddDays(1);
```
Or:
```
endDate.Date.AddDays(3);
```
It is a business concern and should be in the business layer or in a domain service. Given an application architecture that is de... |
74,594,062 | Here's (what I think is) the correct way to layout a (reflowable) html document.
The width is capped relative to the font width, and the margin is auto calculated to be symmetric so that the content is centred.
This gives a pleasant reading experience on both ultra-wide and mobile.
```css
body {
max-width: 30em;
... | 2022/11/27 | [
"https://Stackoverflow.com/questions/74594062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11998382/"
] | If you use grid, you may make it 2 columns without gap and the first one of 0 width, or span the text throught both columns. You may then offset the numbers out of the grid.
here is a few possible ways:
* 2 columns:
```css
body {
max-width: 30em;
margin: 0 auto;
padding: 2em;
}
div {
display: grid;
grid-t... | If you assign a width to the columns through column template, the p will automatically expand and fill the grids second cell. Then add a padding to your liking. You can then justify the text as you like.
```css
div {
display:grid;
grid-template-columns: 20px 1fr;
column-gap: 10px;
}
p {
padding-right:30px;
}
``... |
8,124,739 | I'm trying to figure out how a method invocation that supplies unusable arguments throw a exception on the calling line of code - before it gets to the method line.
Below is an example
```
1. static Integer x;
2. public static void main(String args[]){
3. doStuff(x)} //null pointer exception thrown on this line
//lin... | 2011/11/14 | [
"https://Stackoverflow.com/questions/8124739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492384/"
] | `null` cannot be `autounboxed` to a valid `int`
Might be helpful to look at the actual bytecode generated.
```
public static void main(java.lang.String[]);
Code:
0: getstatic #2; //Field i:Ljava/lang/Integer;
3: invokevirtual #3; //Method java/lang/Integer.intValue:()I <--- Your error comes from t... | because your method parameter type is "int" not "Integer". so JVM want to convert the Integer Object to "int" primitive type and you object is null. so this conversion throwing the exception. |
64,891,226 | i use StarUML for 2 weeks now. I can't find the option for showing "in" in the methods parameters.
Is there any option?
I should look like this:
`-foo(in param1:String[0..3], in param2:int = 0): long`
Thank you! | 2020/11/18 | [
"https://Stackoverflow.com/questions/64891226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7175257/"
] | Universal can prerender all components of appmodule, as soon as you will go to route of that page universal will pre-render them as well, not the first page only.
If you don't find universal as perfect solution, you can use puppeteer for pre-rendering that page. please find the reference below.
<https://developers.go... | Inject `$sce` into your controller, and on the element you want to add the rendered html, simply use `ng-bind-html`
<https://docs.angularjs.org/api/ng/directive/ngBindHtml> |
3,157,454 | Essentially, the situation is as follows:
I have a class template (using one template parameter `length` of type `int`) and want to introduce a static array. This array should be of length `length` and contain the elements `1` to `length`.
The code looks as follows up to now:
```
template<int length>
class myClass{
... | 2010/07/01 | [
"https://Stackoverflow.com/questions/3157454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/255688/"
] | You can't do that with C-style arrays because they don't have value semantics.
If you use something like `std::tr1::array` however then you could easily do what you want by initialising to a function result, or by using an iterator that generates those values. | It seems tough. The closest approach that i can think of would be the following :
```
template<int length>
class myClass
{
public:
myClass()
{
static InitializeArray<length> initializeArray(&array);
}
template<int length>
class InitializeArray
{
public:
InitializeArray(int* ar... |
13,349,689 | I am building a calculator that uses two sliders like this:

I have a range of CPU and RAM data that is stored in an object like this:
```
var CloudPlans = {
small: {
id: 'small',
from: {
cpu: 1,
ram: 1
... | 2012/11/12 | [
"https://Stackoverflow.com/questions/13349689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/228521/"
] | Well, coming back to this question, I thought I'd throw in my two cents...
I would compress your data storage a bit by using an Array so there's no more need for the `min` values.
```
var CloudPlans = [
{ id: 'small',
maxcpu: 2,
maxram: 2,
price: {
linux: 3490,
w... | You can make a more general function from this:
```
function check(plan, values) {
for (var prop in values)
if (plan.from[prop] <= values[prop] && plan.to[prop] >= values[prop])
return true; // if only one property is met
return false;
}
// yet I guess this is what you want:
function check... |
10,649,151 | I am trying to update status onclick. In display function i have given like this
```
if($row['IsActive']=="1")
{
echo "<td> <a href='managecategories.php?IsActive=0&CategoryID=" .$row['CategoryID']. "'>Active</a></td>";
}
else
{
echo "<td> <a href='managecategories.php?IsActive=1&CategoryID=" .$row['CategoryID... | 2012/05/18 | [
"https://Stackoverflow.com/questions/10649151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1321271/"
] | If you are running on a distro like Ubuntu, then AppArmor is probably blocking mysqld from being able to access files in a different directory. If you check your system log files, you'll find a cryptic error message to this effect.
Solutions include:
1. Disable AppArmor (not recommended)
2. Edit the AppArmor rules (c... | Change owner of /data directory to mysqld process owner (chown owner /data ). or (chmod 777 -R /data) very unsafe. |
15,277,688 | I've migrated an existing django 1.3 to django 1.5. everything seems ok. However, I have a deprecation warning due to localflavor when i lauch `python manage.py runserver`
>
> ...\env\lib\site-packages\django\contrib\loca lflavor\_\_init\_\_.py:2:
> DeprecationWarning: django.contrib.localflavor is deprecated. Use t... | 2013/03/07 | [
"https://Stackoverflow.com/questions/15277688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117092/"
] | Update:
>
> Django now have a single localflavors package: <https://pypi.python.org/pypi/django-localflavor>
>
>
> here is the documentation: <http://django-localflavor.readthedocs.org/en/latest/>
>
>
> I let the rest of the response but it is obsolete now.
>
>
>
You have to download ALL local flavors you use... | Just dealt with the same issue. I installed the new package (example for US package):
pip install <https://github.com/django/django-localflavor-us/zipball/master>
then I commented out the old code and changed to the new package:
```
# from django.contrib.localflavor.us.us_states import STATE_CHOICES <= old
from dja... |
20,347,230 | I am using `xmlrpc/client` to work with remote xml-rpc server. I have searched a lot to find something useful, yet failed. The following code for establishing connection is correct?
```
require 'xmlrpc/client'
def init
parameters = {
host: "http://x.x.x.x",
port: "1235",
user: "x",
... | 2013/12/03 | [
"https://Stackoverflow.com/questions/20347230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2929467/"
] | You can use a generator function:
```
from math import ceil
def solve(start, end, step):
#http://stackoverflow.com/a/10986098/846892
for i in xrange(int(ceil((end-start)/step))):
yield start + step*i
print list(solve(80.0, 90.0, 0.5))
#[80.0, 80.5, 81.0, 81.5, 82.0, 82.5, 83.0, 83.5, 84.0, 84.5, 85.0, ... | Someone I respect once said:
>
> There's no point in floating point.
>
>
>
So the actual answer to your question is: You're doing it wrong :)
But as that wouldn't exactly count as an answer here on SO, here's a frange function that could work for you. It elevates everything to ints and yields the floats you want... |
8,693,024 | I wanted to know what is the pythonic function for this :
I want to remove everything before the `wa` path.
```
p = path.split('/')
counter = 0
while True:
if p[counter] == 'wa':
break
counter += 1
path = '/'+'/'.join(p[counter:])
```
For instance, I want `'/book/html/wa/foo/bar/'` to become `'/wa/... | 2012/01/01 | [
"https://Stackoverflow.com/questions/8693024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/186202/"
] | A better answer would be to use os.path.relpath:
<http://docs.python.org/3/library/os.path.html#os.path.relpath>
```
>>> import os
>>> full_path = '/book/html/wa/foo/bar/'
>>> relative_path = '/book/html'
>>> print(os.path.relpath(full_path, relative_path))
'wa/foo/bar'
``` | ```
import re
path = '/book/html/wa/foo/bar/'
m = re.match(r'.*(/wa/[a-z/]+)',path)
print m.group(1)
``` |
35,155,121 | Is there an easier and shorter way to code a way to show and hide divs without having to represent each line as a show or hide?
```html
function startOver() {
$('.box1').hide();
$('.box2').hide();
$('#box3').hide();
$('.box4').show();
$('.box5').show();
$('.box6').show();
$('.box7').show();
$(".abov... | 2016/02/02 | [
"https://Stackoverflow.com/questions/35155121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2547971/"
] | you can select more than one class using a `,`:-
```
$('.box1, .box2, #box3').hide();
$('.box4, .box5, .box6, .box7').show();
$(".aboveDiv").html("Insert Text");
``` | As others have said doing below will help you
$('.box1, .box2, #box3').hide();
$('.box4, .box5, .box6, .box7').show();
but if you have group of such elements which toggle their status then you can apply different classes to both group i.e.
'.box1, .box2, #box3' with adding class class\_a
'.box4, .box5, .box6, .box7'... |
1,528,049 | I've disabled auto-correction type for my text field,
and it does not show any other auto-correction,
but it still automatically creates a dot (.) when I press space key twice.
For example,
if I write "test" and press space key twice,
it automatically changes into "test. "
Anyone knows how to disable this feature?
... | 2009/10/06 | [
"https://Stackoverflow.com/questions/1528049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185242/"
] | I found one solution - it uses UITextFieldTextDidChangeNotification because this occurs after the auto-correction applies.
1. Set the delegate for the text field
2. Set up a notification
`- (void) viewDidLoad {
...
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textFieldDidChan... | Perhaps if you hook up a text field delegate and then implement the following method:
```
-(BOOL)shouldReplaceCharactersInRange:(NSRange)aRage withString:(NSString *)aString
```
You may be able to check aString for the autocorrected string (maybe @". ") and then just return NO. This will hopefully not allow the @" "... |
53,696,888 | My interface is freezing on pressing the button. I am using threading but I am not sure why is still hanging. Any help will be appreciated. Thanks in advance
```
class magic:
def __init__(self):
self.mainQueue=queue.Queue()
def addItem(self,q):
self.mainQueue.put(q)
def startConverting(se... | 2018/12/09 | [
"https://Stackoverflow.com/questions/53696888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7315904/"
] | There are lots of ways to go about this.
Here's one idea:
Make a lookup that maps letters to the their values. Something like:
```
import string
lookup = {s: 10**i for i,s in enumerate(string.ascii_uppercase)}
```
Lookup will be a dictionary like:
>
> {
>
> 'A': 1,
>
> 'B': 10,
>
> 'C': 100,
>
>... | Try searching the string, and every instance of that letter occurring causes you to add to total.
For instance:
```
total = 0
input_string = input()
for i in len(input_string):
if input_string[i] == "A":
total += 1
```
and then you can repeat that for the other instances of the other characters.
Hope I... |
3,889,887 | If someone could help with a jscript issue I'd be very grateful! I have two scripts for different sections of the page which I'm placing in the head, but are in conflict on the same page and just can't seem to get them to work together. Both are as follows:
```
<script type="text/javascript">
jQuery.noConflict();
fun... | 2010/10/08 | [
"https://Stackoverflow.com/questions/3889887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/470170/"
] | I know my solution is somewhat hardcore, but it works great, doesn't require any external libraries (at least not in your final code) and is extremely fast.
1) Just take an existing SVG loading library, such as for example svg-android-2 (which is a fork of svg-android mentioned in another answer, just with more featur... | [Opera Mobile](http://m.opera.com/) for Android supports svg, and [Opera Mini](http://mini.opera.com/) supports static svg content. |
112,060 | Consider a function which has only jump singularities of the form of the function itself or one of its derivatives jumping. Now let $\hat{f}(k)$ be its Fourier transform/series. We know the [decay of the magnitude](https://math.stackexchange.com/a/10854/2987) of the Fourier series/transform depend on how many times $f$... | 2012/11/11 | [
"https://mathoverflow.net/questions/112060",
"https://mathoverflow.net",
"https://mathoverflow.net/users/14414/"
] | Adding something to Igor Khavkine's good answer and examples: the question might be construed as talking about functions (additively) \_modulo\_Schwartz\_functions\_, for example. Thus, two functions with a jump discontinuity at the same finitely-many points, by the same amount, with the same left-and-right behaviors t... | The question of reconstructing piecewise-smooth (and periodic) functions from their Fourier series coefficients was considered in a series of papers by K.Eckhoff, who developed the so-called "Krylov-Gottlieb-Eckhoff method". See e.g.
* K.Eckhoff, "Accurate reconstructions of functions of finite regularity from truncat... |
46,950,160 | ```
d = {'Name1': ['Male', '18'],
'Name2': ['Male', '16'],
'Name3': ['Male', '18'],
'Name4': ['Female', '18'],
'Name5': ['Female', '18']}
```
I am trying to find a way to isolate the duplicate keys to a list if any. Like:
```
['Name1', 'Name3']
['Name4', 'Name5']
```
How can I achieve this? T... | 2017/10/26 | [
"https://Stackoverflow.com/questions/46950160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8836514/"
] | An imperative solution would be to just iterate over the dictionary and add the items into another dictionary that uses the gender-age-tuple as a key, for example:
```
# using a defaultdict, which automatically adds an empty list for missing keys when first accesses
from collections import defaultdict
by_data = defaul... | I'm guessing you meant duplicate values and not keys, in which case you could do this with pandas:
```
import pandas as pd
df = pd.DataFrame(d).T #load the data into a dataframe, and transpose it
df.index[df.duplicated(keep = False)]
```
`df.duplicated(keep = False)` gives you a series of True/False, where the valu... |
458,249 | when I type `qstat -h`, I get the following option
```
[-s {p|r|s|z|hu|ho|hs|hd|hj|ha|h|a}] show pending, running, suspended, zombie jobs,
jobs with a user/operator/system/array-dependency hold,
jobs with a start time in future or any comb... | 2012/12/14 | [
"https://serverfault.com/questions/458249",
"https://serverfault.com",
"https://serverfault.com/users/149714/"
] | [From the `man` page](http://www.linuxcertif.com/man/1/qstat/):
>
> -s {p|r|s|z|hu|ho|hs|hd|hj|ha|h|a}[+]
>
>
> Prints only jobs in the specified state, **any combination of states is possible**. -s prs corresponds to the regular qstat output without -s at all. To show recently finished jobs, use -s z. To display j... | I assume `huhohshdhjha` is the combination of the options `hu`, `ho`, `hs`, `hd`, `hj`, and `ha`, as this is a general way of combining command line options.
A random other example:
```
netstat -ntlp
```
Then one can ask likewise: "what the heck is the `ntlp` option? It's not in the manpage!" |
19,030,972 | I have written the below Java program. This program is creating three threads and started them all :
```
public class MyThread implements Runnable {
@Override
public synchronized void run() {
int count = 0;
while (true) {
System.out.println("" + Thread.current... | 2013/09/26 | [
"https://Stackoverflow.com/questions/19030972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2187257/"
] | Your `synchronized` is on an instance method. It will only be `synchronized` if you were calling the method on the same instance. You aren't doing that. You're calling the `run()` method on 3 different instances. | If you want have synchronization for all threads you need to use some static field.
It could be monitor (simple Object used with synchronization) or Lock
```
private static final Lock LOCK = new ReentrantLock();
@Override
public void run() {
try {
LOCK.lock();
// Your code
} finally {
... |
29,058,393 | I have a csv I am reading from and am making 4 lists from the first 4 columns of that csv.
```
listofcelebs = (columns['name'])
listOfImages = (columns['image'])
listOfProfessions = (columns['profession'])
listOfBestWork = (columns['bestWork'])
```
I only need to read the items from the first list to run a twitter ... | 2015/03/15 | [
"https://Stackoverflow.com/questions/29058393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4644825/"
] | Put the data in a vector of vectors, and use `std::sort`:
```
vector<vector<int> > vv;
// Put data in the vector...
vector<int> v3 = {95, 67};
vv.push_back(v3);
vector<int> v4 = {76, 25};
vv.push_back(v4);
vector<int> v1 = {95, 52};
vv.push_back(v1);
vector<int> v2 = {95, 20};
vv.push_back(v2);
vector<int> v5 = {76, 2... | 1. If you want to sort the array, taking column 1 as main index, column 2 as secondary, etc, AND GET THE FINAL RESULT.
An custom sort function will do the work.
```
struct SortAll {
bool operator() (int *item1, int *item2) {
for (int i = 0; i < COLUMN_COUNT; ++i) {
if (item1[i] < item2[i]) {
... |
475,056 | When inspecting the boards from electronics made in 1980s and earlier, one distinct feature is the extensive use of axial, electrolytic capacitors as power supply filter. Axial ceramic decoupling capacitors were used as well, to a lesser extent.
For example, this is a C64 motherboard.
[![One part of a C64 motherboa... | 2020/01/07 | [
"https://electronics.stackexchange.com/questions/475056",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/130447/"
] | PCB area.
Axials pre-dated PCBs, their construction was ideal for wiring to tag strips and valve bases, and they were adopted for PCBs because that's what was available.
Example of tag strip construction below.
(There WERE radial caps in the valve days : they were generally designed for chassis mounting via a ring... | My recollection of that era was that the **selection**, **size** and **price** of axial leaded electrolytic capacitors was not competitive, so I used radial lead caps in some cases where axial leaded would have been better (production had to lay them down and add a dab of adhesive). You could not find low-leakage caps,... |
43,485,577 | What am i doing wrong here?
Here is the code:
```
<script>
var points = 1000;
document.getElementById(pointsdisplay).innerHTML = "Points:" + points;
</script>
<p id="pointsdisplay"></p>
```
I want to display the points on the website. I really don't understand why this isn't working.
Note that I put the scri... | 2017/04/19 | [
"https://Stackoverflow.com/questions/43485577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There are two mistakes here,
1. You need to surround id with `"` (Double Quotes)
2. You should put script tag after the `dom` element is created, else it may execute before the actual `dom` is created. Even if you keep js code in a separate file, make sure you write it after your `dom`, just before the `body` tag end... | I think I see two problems here.
The first is that the document.getElementById needs to be given a String. You could use: `document.getElementById("pointsDisplay")`.
Secondly, I think you will need to put the script underneath the p. The browser will execute the script as soon as it hits the script tag. |
15,191,092 | I've been trying to make a simple program that fetches a small random number and displays it to the user in a textview. After finally getting the random number to generate (I think) the program throws a fatal exception whenever I run. No errors in code, but I'm a complete newbie and I am starting simple so that I may l... | 2013/03/03 | [
"https://Stackoverflow.com/questions/15191092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2129763/"
] | You are trying to set int value to `TextView` so you are getting this issue.
To solve this try below one option
option 1:
```
tv.setText(no+"");
```
Option2:
```
tv.setText(String.valueOf(no));
``` | This always can happen in DataBinding. Try to stay away from adding logic in your bindings, including appending an empty string. You can make your own custom adapter, and use it multiple times.
```
@BindingAdapter("numericText")
fun numericText(textView: TextView, value: Number?) {
value?.let {
textView.te... |
24,610,545 | **Scenario**:
* I am matching cases up via using the distance between two points
(using lat and long).
* Everything is done in a table.
* I get a list of 'tds' with class 'city', and make an array.
* Then I sort the array based on 'data-distance' attribute
* I then highlight the top ten, and if two 'data-distance' has... | 2014/07/07 | [
"https://Stackoverflow.com/questions/24610545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Deactivating horizontal scrolling may fix the issue. Try running the following at the gnome-terminal:
```
synclient HorizEdgeScroll=0 HorizTwoFingerScroll=0
```
Or the following in the MATLAB [console](http://in.mathworks.com/help/matlab/matlab_external/run-external-commands-scripts-and-programs.html):
```
!synclie... | GNOME 3.20 ::SYNCLIENT IS OBSOLETE,
Fixing the MEvent. CASE! error in MATLAB for xinput
The suggested solution is to run
```
!synclient HorizTwoFingerScroll=0
```
as part of your startup file to disable horizontal scrolling. This however does not work on more recent linux versions because the synaptics touchpad dri... |
740,151 | After making a few changes in my application, my textures are no longer showing. So far I've checked the following:
* The camera direction hasn't changed.
* I can see the vectors (when colored instead of textured).
Any usual suspects? | 2009/04/11 | [
"https://Stackoverflow.com/questions/740151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47775/"
] | You may want to check the following:
* `glEnable(GL_TEXTURE_2D);` presence
* `glBindTexture(GL_TEXTURE_2D,
texture[i]);` and
`glBindTexture(GL_TEXTURE_2D, 0);`
when you don't need texture anymore | A few more things to check:
* glColorMaterial(...); To make sure colors aren't overwriting the texture
* glEnable/glDisable(GL\_LIGHTING); Sometimes lighting can wash out the texture
* glDisable(GL\_BLEND); Make sure that you're not blending the texture out
* Make sure the texture coordinates are set properly. |
19,405,600 | I'm in the process of learning javascript and get confused by regular expressions (regex). It can sometimes be the syntax but mostly my understanding of regex is very poor. for instance `var pattern = /^0+$/;` just looks like crap to me.
Can this jQuery if/else statement be converted to a regex method? and if so, how/... | 2013/10/16 | [
"https://Stackoverflow.com/questions/19405600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2326886/"
] | My advice, create a simple look-up array:
```
var percents = ["100%", "50%", "32%", "25%", "20%", "16.6%", "14.25%", "12%", "11%", "10%", "8%"];
var nav = $('#nav_header a');
var navlinks = $('#nav_header').children('a').length;
navlinks == 0 ? nav.css("width", "8%") : nav.css("width", percents[navlinks - 1]);
``` | >
> var pattern = /^0+$/; just looks like crap to me.
>
>
>
Actually that is an easy one, it only matches a string if that string contains only `0`s.
>
> Can this jQuery if/else statement be converted to a regex method? and if so, how/why?
>
>
>
No it can't. Regular expressions are used to find patterns in t... |
7,563,169 | I am building a JS script which at some point is able to, on a given page, allow the user to click on any word and store this word in a variable.
I have one solution which is pretty ugly and involves class-parsing using jQuery:
I first parse the entire html, split everything on each space `" "`, and re-append everythi... | 2011/09/27 | [
"https://Stackoverflow.com/questions/7563169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/725182/"
] | The only cross-browser (IE < 8) way that I know of is wrapping in `span` elements. It's ugly but not really that slow.
This example is straight from the jQuery .css() function documentation, but with a huge block of text to pre-process:
<http://jsfiddle.net/kMvYy/>
Here's another way of doing it (given here: [jquer... | As with the [accepted answer](https://stackoverflow.com/a/9304990/712526), this solution uses `window.getSelection` to infer the cursor position within the text. It uses a regex to reliably find the word boundary, and does not restrict the [starting node](https://developer.mozilla.org/en-US/docs/Web/API/Range/startCont... |
12,793,435 | How do you ensure that you don't send out real http requests while running tests.
I'm having a hard time finding documentation for this. | 2012/10/09 | [
"https://Stackoverflow.com/questions/12793435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1042382/"
] | This is only available in Play 2.3.x, but a MockWS client is available: <https://github.com/leanovate/play-mockws>
```
val ws = MockWS {
case (GET, "http://dns/url") => Action { Ok("http response") }
}
await(ws.url("http://dns/url").get()).body == "http response"
``` | WS.url is static. So you need to use powermock to test static methods.
[See this tutorial](http://code.google.com/p/powermock/wiki/MockStatic) |
43,898,447 | I've been trying to GET a HTML file and assign it to a variable as a jQuery object. To no avail. I'm not sure if Stack Snippets allow GET requests, so here is a [JSFiddle link](https://jsfiddle.net/k3s3xz2x/) as well.
```js
var html = '<!DOCTYPE html><html lang="en"><head><title>Template</title></head><body itemsc... | 2017/05/10 | [
"https://Stackoverflow.com/questions/43898447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1150683/"
] | Set [`jQuery.ajax()`](https://meta.stackoverflow.com/questions/288902/does-stack-overflow-have-an-echo-page-to-test-ajax-requests-inside-a-code-sni/290948#290948) `processData` option to `false`. Use `DOMParser()` to parse string to an `html` `document`; `XMLSerizlizer()` to get `DOCTYPE` declaration; `document.write()... | >
> I always get the same result: an array containing the title and main element.
>
>
>
What exactly is the problem?
>
> jQuery still parses it and makes an array of the element in the head and the one element in the body. But why?
>
>
>
What are you expecting?
That seems to be the behavior of parseHtml.
H... |
18,770,100 | My app is compatible with iOS5 and iOS6.
Until now I had no problem using:
```
NSString DeviceID = [[UIDevice currentDevice] uniqueIdentifier];
```
Now with iOS7 and with uniqueIdentifier not working anymore I changed to:
```
NSString DeviceID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
```
The... | 2013/09/12 | [
"https://Stackoverflow.com/questions/18770100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2773538/"
] | The best and recommend option by Apple is:
```
NSString *adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
```
Use it for every device above 5.0.
For 5.0 you have to use uniqueIdentifier. The best to check if it's available is:
```
if (!NSClassFromString(@"ASIdentifierManager"))
``... | As hard replacement of static macro, you can try dynamic if statement to check it.
UIDevice has property named 'systemVersion' and you can check [this](https://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/systemVersion). |
11,833,905 | How do you handle a "cannot instantiate abstract class" error in C++?
I have looked at some of the similar errors here and none of them seem to be exactly the same or problem that I am having. But, then again, I will admit that there are several to go over. Here is the compile error:
![[IMG]http://i67.photobucket.com/... | 2012/08/06 | [
"https://Stackoverflow.com/questions/11833905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54760/"
] | Visual Studio's *Error List* pane only shows you the first line of the error. Invoke `View`>`Output` and I bet you'll see something like:
```
c:\path\to\your\code.cpp(42): error C2259: 'AmbientOccluder' : cannot instantiate abstract class
due to following members:
'ULONG MysteryUnimplementedMethod(... | I have answered this question here..[Covariant virtual functions return type problem](https://stackoverflow.com/questions/5076226/covariant-virtual-functions-return-type-problem/27813060#27813060)
See if it helps for some one. |
130,647 | Of these buildings, what building(s) should I save in the event of any enemy ubercharge (Medi Gun/Kritzkrieg/Quick-Fix/Vaccinator)?
1) Sentry Gun Level 1/2/3
2) Dispenser Level 1/2/3
3) Teleporter Entrance/Exit Level 1/2/3 | 2013/09/12 | [
"https://gaming.stackexchange.com/questions/130647",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/55174/"
] | I can't think of a single situation where you wouldn't want to protect your level 3 sentry. Yes, you and your nest might be doomed, but every second of invincibility spent on your nest is a second of invincibility not spent on the rest of your team. Even on offence, where your teleporter is more important than your sen... | I would recommend running away with the dispenser. While your sentry will be doomed for sure, you will be able to quickly rebuild it with the metal stored in your dispenser. As for your teleporter, you didn't just leave that lying in plain sight, right?
The important thing is, your buildings are all doomed to explode... |
45,061,615 | I have a text here in anchor tag which says add to cart but on mobile view I want to change it to fa fa-cart mobile view
```
<a class="product"><?php echo $button_add_to_cart ?></a>
```
Now this $button\_add\_to\_cart has text Add to cart and a cart(fa fa-cart).
On mobile view I want [![enter image description he... | 2017/07/12 | [
"https://Stackoverflow.com/questions/45061615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8065971/"
] | **Solution1:**
```
<a class="product desktop-screen"><?php echo $button_add_to_cart ?></a>
<a class="product mobile-screen"><?php echo $cart ?></a>
```
css:
```
desktop-screen{display:block;}
mobile-screen{display:none;}
@media only screen and (max-width: 479px) {
desktop-screen{display:none;}
mob... | I have added `span` and removed positioning on the pseudo element, also added text in the `content`. It works for me.
```css
.thumbnail a.product {
background: #00A1CB;
color: #fff;
float: right;
padding: 5px;
font-size: 13px;
text-transform: uppercase;
position: relative;
}
.thumbnail a.produ... |
562,925 | I am creating a model that utilize the output probability distribution of another model, as an input. The model outputs a probability of an event occurring per year, the distribution is a probability between (between 0 and 1) and right skewed, it is defined by Mean = 0.019, Mode = 0.009, 90% confidence interval: 5th pe... | 2022/02/03 | [
"https://stats.stackexchange.com/questions/562925",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/261092/"
] | Your understanding is only half correct. PCA (Principal Component Analysis) is a dimensionality reduction technique that finds underlying patterns in data to reduce the number of features in a dataset. It does not make predictions; rather, it generates new dimensions from existing data for further analysis or visualiza... | You're missing a step: fitting some kind of predictive model. Once you transform your PCA feature space into the original features (which need not be unique unless you use all of the PCs), you have to have some way of interpreting that.
For the MNIST digits to which you allude, that could be a convolutional neural net... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.