qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
159,755 | Inspired by [I'm not the language you're looking for!](https://codegolf.stackexchange.com/questions/55960/im-not-the-language-youre-looking-for)
Challenge
=========
Choose two different programming languages, and write a program that prints the following line to stdout (or equivalent):
```
This program errors out in... | 2018/03/21 | [
"https://codegolf.stackexchange.com/questions/159755",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/78410/"
] | [Octave](https://www.gnu.org/software/octave/) and MATLAB, 67 bytes
===================================================================
```matlab
v=ver;disp(['This program errors out in ' v(1).Name ' :P']);v(--pi)
```
[Try it online!](https://tio.run/##y08uSSxL/f@/zLYstcg6JbO4QCNaPSQjs1ihoCg/vSgxVyG1qCi/qFghv7REITNP... | Swift 4/JavaScript (SpiderMonkey), 105 bytes
============================================
```swift
print("This program errors out in " + ([1]==[1] ?"Swift :P":"JavaScript :P"))
var b=Int.self,a=[1]
a[2]=0
```
[Try it online! (Swift)](https://tio.run/##Ky7PTCsx@f@/oCgzr0RDKSQjs1ihoCg/vSgxVyG1qCi/qFghv7REITNPQUlBW0Ej2... |
159,755 | Inspired by [I'm not the language you're looking for!](https://codegolf.stackexchange.com/questions/55960/im-not-the-language-youre-looking-for)
Challenge
=========
Choose two different programming languages, and write a program that prints the following line to stdout (or equivalent):
```
This program errors out in... | 2018/03/21 | [
"https://codegolf.stackexchange.com/questions/159755",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/78410/"
] | C and Python, ~~126~~ 116 bytes
===============================
*-10 bytes thanks to @Bubbler!*
```
#1/*
-print("This program errors out in Python :P")
'''*/
main(c){c=puts("This program errors out in C :P")/0;}//'''
```
In Python print() is a None, so trying to get its negative doesn't make sense, so Python throws... | C and ECPP, 112 bytes
=====================
```
#ifdef ECPP
#replace "C" "ECPP"
#endif
main(){puts("This program errors out in " "C" " :P");raise(strlen("C"));}
```
* [Try it online! (C)](https://tio.run/##JcsxDsMgDADAnVdYZoGhH2jGqDtDP4Ack1pKwDJkqvp2WqnrSUe3nWhOL2XjAo81JeeN9cjEgCsCMqmi81w3Ke7MUkN86zV6wOdLOqi13fIJbNa... |
159,755 | Inspired by [I'm not the language you're looking for!](https://codegolf.stackexchange.com/questions/55960/im-not-the-language-youre-looking-for)
Challenge
=========
Choose two different programming languages, and write a program that prints the following line to stdout (or equivalent):
```
This program errors out in... | 2018/03/21 | [
"https://codegolf.stackexchange.com/questions/159755",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/78410/"
] | Java 8 & C99, 172 bytes
=======================
```
//\
interface a{static void main(String[]a){System.out.print("This program errors out in Java 8 :P");a[1]=""/*
main(n){{n=puts("This program errors out in C99 :P")/0/**/;}}
```
Based on my answer for the [*'abc' and 'cba'* challenge](https://codegolf.stackexchange.... | [Zsh](https://www.zsh.org/) `-596X` and [Zsh](https://www.zsh.org/) `-596Xr`, 44 bytes
======================================================================================
```
<<<"This program errors out in Zsh -$- :P"
/
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjZbSSrqmlWYRS7IKlpSVpuhY3dWxsbJR... |
11,533 | I have a Repository in Azure Repos which has branches as master, build, feature. Build Branch and Feature branches have their own pipelines code in the azure-pipelines.yaml in the branch itself respectively. So that they can have their dedicated pipelines
The problem is that When I commit to the Build branch or in the... | 2020/05/06 | [
"https://devops.stackexchange.com/questions/11533",
"https://devops.stackexchange.com",
"https://devops.stackexchange.com/users/19681/"
] | I personally made the unwise choice of cramming five different apps into a single database about 20 years ago. I then had to deal with the repercussions of that. The bad news is, this is really hard. The good news is, modern tools make it easiser, but not easy.
So, first, absolutely get a single source of truth. You'r... | Disclaimer: I'm not a RDBMS DBA and I have zero experience with MSSQL. Everything below is a hypothesis.
Each app should have it's own stored procedures in migrations, and shared procedures should be in their own repo with a separate migration list. This adds a necessary isolation and the ability to use benefits of co... |
36,441,858 | I made a program to draw Polygon but the Polygon is not showing up. I am trying to fix my code.
```
public static class Polygon extends JPanel {
public Polygon() {
setBackground(Color.black);
}
public void paintComponent(Graphics p)
{
super.paintComponent(p);
int[] list1 = {10... | 2016/04/06 | [
"https://Stackoverflow.com/questions/36441858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6163655/"
] | `getGraphics()` method doesn't work for you. But you can just pass your `Graphics` as parameter.
```
public static class Polygon extends JPanel {
public Polygon() {
setBackground(Color.black);
}
public void paintComponent(Graphics p)
{
... | I'm not sure why you have a static class, change that first, then try the suggestions below.
I would do everything in the paintComponent method. This code works fine for me:
```
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
public class Polygon extends JPanel {
public void paintCom... |
428,460 | В словах языко-вед, товаро-вед, мыло-вар, пиво-вар и др. "вед", "вар" - суффиксоиды. Так как мы их должны выделять: как корень или как суффикс? | 2016/11/25 | [
"https://rus.stackexchange.com/questions/428460",
"https://rus.stackexchange.com",
"https://rus.stackexchange.com/users/180208/"
] | Если в морфемном разборе в школе, то однозначно как корень, ведь это КОРНЕВАЯ морфема, если вуз - смотрите в лекции, каждый учёный считает себя правым. Одни обозначают как корень, наверху пишут "суффиксоид", другие как суффикс,третьи ставят два значка-суффикс и корень.
В любом случае при словообразовательном разборе ... | В школьном морфемном разборе мы выделим два корня и соединительную гласную.
**[Как выделять суффиксоиды?](http://human.snauka.ru/2013/07/3605)**
>
> Аффиксоиды – это корневые морфемы, выступающие в функции аффиксов. Они
> делятся на префиксоиды (*полу-*) и суффиксоиды (*-вед, -вод* и др.).
> Суффиксоиды обладают ... |
4,189,987 | **This question is a bit long due the source code, which I tried to simplify as much as possible. Please bear with me and thanks for reading along.**
I have an application with a loop that runs potentially millions of times. Instead of several thousands to millions of `malloc`/`free` calls within that loop, I would li... | 2010/11/15 | [
"https://Stackoverflow.com/questions/4189987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19410/"
] | `realloc` has to copy the contents from the old buffer to the new buffer if the resizing operation cannot be done in place. A `malloc`/`free` pair can be better than a `realloc` if you don't need to keep around the original memory.
That's why `realloc` can temporarily require more memory than a `malloc`/`free` pair. Y... | You are expecting `&(*firstString)` to be the same as `firstString`, but in fact it is taking the address of the argument to your function rather than passing through the address of the pointers in `A`. Thus every time you call you make a *copy* of NULL, realloc new memory, lose the pointer to the new memory, and repea... |
4,189,987 | **This question is a bit long due the source code, which I tried to simplify as much as possible. Please bear with me and thanks for reading along.**
I have an application with a loop that runs potentially millions of times. Instead of several thousands to millions of `malloc`/`free` calls within that loop, I would li... | 2010/11/15 | [
"https://Stackoverflow.com/questions/4189987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19410/"
] | `realloc` has to copy the contents from the old buffer to the new buffer if the resizing operation cannot be done in place. A `malloc`/`free` pair can be better than a `realloc` if you don't need to keep around the original memory.
That's why `realloc` can temporarily require more memory than a `malloc`/`free` pair. Y... | Using `realloc` when you don't want to preserve the existing contents of the memory block is a **very very bad idea**. If nothing else, you'll waste lots of time duplicating data you're about to overwrite. In practice, the way you're using it, the resized blocks will not fit in the old space, so they get located at pro... |
4,189,987 | **This question is a bit long due the source code, which I tried to simplify as much as possible. Please bear with me and thanks for reading along.**
I have an application with a loop that runs potentially millions of times. Instead of several thousands to millions of `malloc`/`free` calls within that loop, I would li... | 2010/11/15 | [
"https://Stackoverflow.com/questions/4189987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19410/"
] | Using `realloc` when you don't want to preserve the existing contents of the memory block is a **very very bad idea**. If nothing else, you'll waste lots of time duplicating data you're about to overwrite. In practice, the way you're using it, the resized blocks will not fit in the old space, so they get located at pro... | You are expecting `&(*firstString)` to be the same as `firstString`, but in fact it is taking the address of the argument to your function rather than passing through the address of the pointers in `A`. Thus every time you call you make a *copy* of NULL, realloc new memory, lose the pointer to the new memory, and repea... |
34,205,481 | I am just exploring a way in order to open the default browser from Visual Studio Code API used for developing extensions.
Following is my code :
```
var disposable = vscode.commands.registerCommand('extension.browser', () => {
// The code you place here will be executed every time your command is executed
vscode... | 2015/12/10 | [
"https://Stackoverflow.com/questions/34205481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1931605/"
] | You don't need to install an external dependency. Opening an URL can be simply done with **just** the Node.js libraries and system commands. For e.g. use the [child\_process.exec](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback) to open an URL.
Declare a function lik... | I had to use npm open url in order to open in browser.
```
var openurl = require('openurl').open;
openurl("http://google.com");
``` |
34,205,481 | I am just exploring a way in order to open the default browser from Visual Studio Code API used for developing extensions.
Following is my code :
```
var disposable = vscode.commands.registerCommand('extension.browser', () => {
// The code you place here will be executed every time your command is executed
vscode... | 2015/12/10 | [
"https://Stackoverflow.com/questions/34205481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1931605/"
] | There is no need for node or external libraries.
If you are using VS Code 1.31+, use the `vscode.env.open` function:
```
import * as vscode from 'vscode';
vscode.env.openExternal(vscode.Uri.parse('https://example.com'));
```
For older VS Code versions, use the `vscode.open` command:
```
vscode.commands.executeCo... | I had to use npm open url in order to open in browser.
```
var openurl = require('openurl').open;
openurl("http://google.com");
``` |
34,205,481 | I am just exploring a way in order to open the default browser from Visual Studio Code API used for developing extensions.
Following is my code :
```
var disposable = vscode.commands.registerCommand('extension.browser', () => {
// The code you place here will be executed every time your command is executed
vscode... | 2015/12/10 | [
"https://Stackoverflow.com/questions/34205481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1931605/"
] | There is no need for node or external libraries.
If you are using VS Code 1.31+, use the `vscode.env.open` function:
```
import * as vscode from 'vscode';
vscode.env.openExternal(vscode.Uri.parse('https://example.com'));
```
For older VS Code versions, use the `vscode.open` command:
```
vscode.commands.executeCo... | You don't need to install an external dependency. Opening an URL can be simply done with **just** the Node.js libraries and system commands. For e.g. use the [child\_process.exec](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback) to open an URL.
Declare a function lik... |
14,536,227 | In my application I need a service to be running. Under this assumption I set service as foreground service. My problem is that e.g. after 24 hours or after longer time of service disuse, service doesn't react. I can see my service in Running services but broadcast receivers of service doesn't work, scheduled timer tas... | 2013/01/26 | [
"https://Stackoverflow.com/questions/14536227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1333041/"
] | Think of a problem requiring the [Lexicographically nth substring of a given string](https://www.hackerrank.com/challenges/find-strings) : A suffix array is just what you need...and it is easy to learn the bare essentials for solving most problems involving suffix arrays..
On the other hand DP is an algorithmic tech... | honestly, for job interview, no suffix tree is needed. that's too difficult and beyond the scope. however, DP is widely used in interviews for some famous companies like google and facebook.
suffix tree has limitation for solving problems compared with DP. usually it is used to solve string related problems. but DP ca... |
45,584,185 | I have this strange behavior with Hibernate `SQLQuery.list()` method.
**Following is the description of the issue:**
I have a sql select query which retrieves only single column(group) from the database (i.e., `select group from peopleGroup where groupid = 10`)
And i'm recieving the result of the above list in List ... | 2017/08/09 | [
"https://Stackoverflow.com/questions/45584185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7456785/"
] | [Docs](http://docs.jboss.org/hibernate/orm/5.1/javadocs/org/hibernate/Query.html#list--) states:
>
> List list()
>
>
> Return the query results as a List. If the query contains multiple
> results per row, the results are returned in an instance of Object[].
>
>
>
Convert it by yourself, like so.
```
List<Obj... | you can create a object mapper like below code
```
public class QueryMapper {
private String group;
//setter and getter
}
```
And you have to change your code like below
```
SQLQuery hQuery = session.createSQLQuery("select group from peopleGroup where groupid = 10");
List<Object[]> result = (List<Object... |
45,584,185 | I have this strange behavior with Hibernate `SQLQuery.list()` method.
**Following is the description of the issue:**
I have a sql select query which retrieves only single column(group) from the database (i.e., `select group from peopleGroup where groupid = 10`)
And i'm recieving the result of the above list in List ... | 2017/08/09 | [
"https://Stackoverflow.com/questions/45584185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7456785/"
] | [Docs](http://docs.jboss.org/hibernate/orm/5.1/javadocs/org/hibernate/Query.html#list--) states:
>
> List list()
>
>
> Return the query results as a List. If the query contains multiple
> results per row, the results are returned in an instance of Object[].
>
>
>
Convert it by yourself, like so.
```
List<Obj... | All i wanted is to fix the **ClassCastException** which was caught during the assignment of result.get(0) to the container i.e., container = result.get(0);
Since the value returned by mentioned list() method contains object in case of single column in the select clause of the query and i won't be allowed to cast from... |
12,779,391 | I'm doing a program that would input the weekly pay and total hours worked in that week. And it should display the answer in hourly pay rate. But I can't display the correct "centavos/2 decimal places" formula and it doesn't want to run with float % float. Please help!
```
#include <stdio.h>
int gethourpaypes(int wee... | 2012/10/08 | [
"https://Stackoverflow.com/questions/12779391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726276/"
] | `var test = <?php echo $graph_max_max_value; ?>;` should work.
This outputs using `echo`, which you forgot, *and* adds the statement terminating semi-colon at the end. | You forgot to do anything to output the variable.
You want an `echo`, `print`, `printf`, etc.
(You also need to make sure that the data in PHP conforms to the syntax for a Number type in JavaScript.) |
12,779,391 | I'm doing a program that would input the weekly pay and total hours worked in that week. And it should display the answer in hourly pay rate. But I can't display the correct "centavos/2 decimal places" formula and it doesn't want to run with float % float. Please help!
```
#include <stdio.h>
int gethourpaypes(int wee... | 2012/10/08 | [
"https://Stackoverflow.com/questions/12779391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726276/"
] | You forgot to do anything to output the variable.
You want an `echo`, `print`, `printf`, etc.
(You also need to make sure that the data in PHP conforms to the syntax for a Number type in JavaScript.) | Try this
```
var test = <?php echo $graph_max_max_value; ?>,
```
and then
```
alert(test);
```
If you dont use echo then the value is undefined |
12,779,391 | I'm doing a program that would input the weekly pay and total hours worked in that week. And it should display the answer in hourly pay rate. But I can't display the correct "centavos/2 decimal places" formula and it doesn't want to run with float % float. Please help!
```
#include <stdio.h>
int gethourpaypes(int wee... | 2012/10/08 | [
"https://Stackoverflow.com/questions/12779391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726276/"
] | You forgot to do anything to output the variable.
You want an `echo`, `print`, `printf`, etc.
(You also need to make sure that the data in PHP conforms to the syntax for a Number type in JavaScript.) | You forgot an **echo** and you need to make sure you pass an integer value to your variable.
```
<script>
<?php $graph_max_max_value = 1024;?>
alert('<?php echo( $graph_max_max_value ); ?>');
var test = '<?php echo $graph_max_max_value;?>';
test.replace(/[^0-9]/g, '');
alert(test);
</script>
``` |
12,779,391 | I'm doing a program that would input the weekly pay and total hours worked in that week. And it should display the answer in hourly pay rate. But I can't display the correct "centavos/2 decimal places" formula and it doesn't want to run with float % float. Please help!
```
#include <stdio.h>
int gethourpaypes(int wee... | 2012/10/08 | [
"https://Stackoverflow.com/questions/12779391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726276/"
] | `var test = <?php echo $graph_max_max_value; ?>;` should work.
This outputs using `echo`, which you forgot, *and* adds the statement terminating semi-colon at the end. | Try this
```
var test = <?php echo $graph_max_max_value; ?>,
```
and then
```
alert(test);
```
If you dont use echo then the value is undefined |
12,779,391 | I'm doing a program that would input the weekly pay and total hours worked in that week. And it should display the answer in hourly pay rate. But I can't display the correct "centavos/2 decimal places" formula and it doesn't want to run with float % float. Please help!
```
#include <stdio.h>
int gethourpaypes(int wee... | 2012/10/08 | [
"https://Stackoverflow.com/questions/12779391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726276/"
] | `var test = <?php echo $graph_max_max_value; ?>;` should work.
This outputs using `echo`, which you forgot, *and* adds the statement terminating semi-colon at the end. | You forgot an **echo** and you need to make sure you pass an integer value to your variable.
```
<script>
<?php $graph_max_max_value = 1024;?>
alert('<?php echo( $graph_max_max_value ); ?>');
var test = '<?php echo $graph_max_max_value;?>';
test.replace(/[^0-9]/g, '');
alert(test);
</script>
``` |
12,779,391 | I'm doing a program that would input the weekly pay and total hours worked in that week. And it should display the answer in hourly pay rate. But I can't display the correct "centavos/2 decimal places" formula and it doesn't want to run with float % float. Please help!
```
#include <stdio.h>
int gethourpaypes(int wee... | 2012/10/08 | [
"https://Stackoverflow.com/questions/12779391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726276/"
] | Try this
```
var test = <?php echo $graph_max_max_value; ?>,
```
and then
```
alert(test);
```
If you dont use echo then the value is undefined | You forgot an **echo** and you need to make sure you pass an integer value to your variable.
```
<script>
<?php $graph_max_max_value = 1024;?>
alert('<?php echo( $graph_max_max_value ); ?>');
var test = '<?php echo $graph_max_max_value;?>';
test.replace(/[^0-9]/g, '');
alert(test);
</script>
``` |
4,191 | I don't understand the numbering system on TREK bikes.
Is it the lower the number the better, or the higher?
What is exactly is the difference? | 2011/06/11 | [
"https://bicycles.stackexchange.com/questions/4191",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/1628/"
] | This higher numbers are upgrades. [Trek website](http://www.trekbikes.com/us/en/story/fx/)
Upgrades on 7.3 FX from 7.2 FX
```
IsoZone grip and handlebar system
Bontrager Race All-Weather Hard-Case tires
Alloy FX Fork
``` | So....Not much. I'm currently working on one of these, an older 7.3, and it's equipped almost exactly as the 7.2 is now. Has the steel fork and the regular handlebar grips. Tires are Bontrager...Don't know which model.
Nice bike, I'm considering keeping it. (I refurbish bikes for re-sale) |
5,571,970 | I have a page1 and link on that page which opens up the Page2. There is a textbox on Page1 whose value needs to be passed onto the Page 2 when the user clicks on the link for Page2.
Firstly, I thought of using onTextbox changed event, but cant use that as the values in the textbox are autogenerated.
Once the Page1 is... | 2011/04/06 | [
"https://Stackoverflow.com/questions/5571970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/622096/"
] | You could use a [LinkButton](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.aspx) and handle its click event in codebind. There you can [Response.Redirect](http://msdn.microsoft.com/en-us/library/a8wa7sdt%28VS.80%29.aspx) to Page2 and append the TextBox' Text to the QueryString.
```
Dim n... | Why not use POST and Server.Transfer?
Using Server.Transfer then you can get access to all form properties from the previous page.
<http://msdn.microsoft.com/en-us/library/ms525800%28v=vs.90%29.aspx> |
5,571,970 | I have a page1 and link on that page which opens up the Page2. There is a textbox on Page1 whose value needs to be passed onto the Page 2 when the user clicks on the link for Page2.
Firstly, I thought of using onTextbox changed event, but cant use that as the values in the textbox are autogenerated.
Once the Page1 is... | 2011/04/06 | [
"https://Stackoverflow.com/questions/5571970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/622096/"
] | You could easily do that with a LinkButton. Handle the click event on the LinkButton for Page2, and then construct your Response.Redirect with the appropriate QueryString key/value pairs:
**HTML:**
```
<asp:TextBox ID="TextBox1" runat="server" />
<asp:LinkButton ID="LinkButton1" runat="server" Text="Page2" />
```
*... | Why not use POST and Server.Transfer?
Using Server.Transfer then you can get access to all form properties from the previous page.
<http://msdn.microsoft.com/en-us/library/ms525800%28v=vs.90%29.aspx> |
5,571,970 | I have a page1 and link on that page which opens up the Page2. There is a textbox on Page1 whose value needs to be passed onto the Page 2 when the user clicks on the link for Page2.
Firstly, I thought of using onTextbox changed event, but cant use that as the values in the textbox are autogenerated.
Once the Page1 is... | 2011/04/06 | [
"https://Stackoverflow.com/questions/5571970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/622096/"
] | You could easily do that with a LinkButton. Handle the click event on the LinkButton for Page2, and then construct your Response.Redirect with the appropriate QueryString key/value pairs:
**HTML:**
```
<asp:TextBox ID="TextBox1" runat="server" />
<asp:LinkButton ID="LinkButton1" runat="server" Text="Page2" />
```
*... | You could use a [LinkButton](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.aspx) and handle its click event in codebind. There you can [Response.Redirect](http://msdn.microsoft.com/en-us/library/a8wa7sdt%28VS.80%29.aspx) to Page2 and append the TextBox' Text to the QueryString.
```
Dim n... |
27,947,487 | I use numpy and have two arrays, which are read with `genfromtxt`.
They have the shape `<10000,>` according to `np.shape()`.
I want these two vectors to be in an array with the shape `<10000,2>`. For now I use:
```
x = zip(x1,x2)
```
but i am not sure if there is numpy function that does this better/more efficien... | 2015/01/14 | [
"https://Stackoverflow.com/questions/27947487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4408275/"
] | There is `numpy.column_stack`:
```
>>> a = numpy.arange(10)
>>> b = numpy.arange(1, 11)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> b
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> numpy.column_stack((a, b))
array([[ 0, 1],
[ 1, 2],
[ 2, 3],
[ 3, 4],
[ 4, 5],
[ 5, 6],
... | A simple test:
```
python -m timeit "import numpy as np; x, y = np.array([range(100000), range(100000,200000)]); zip(x,y)"
```
10 loops, best of 3: 32.2 msec per loop
```
python -m timeit "import numpy as np; x, y = np.array([range(100000), range(100000,200000)]); np.column_stack((x, y))"
```
10 loops, best of 3:... |
43,868 | About an hour or two ago I went and added a comment to the [Recalc Blog post](https://blog.stackoverflow.com/2010/03/the-great-reputation-recalc-begins/) on blog.stackoverflow.com.
The comment has still not shown up. I thought maybe it got lost in translation, so I tried to add it again. (I had saved a copy.) When I d... | 2010/03/24 | [
"https://meta.stackexchange.com/questions/43868",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/16241/"
] | Yes, they're moderated, but there's also a [spam trap](https://meta.stackexchange.com/questions/33117/are-comments-broken-on-blog-stackoverflow-com) that sometimes gets clogged or something (or maybe Jeff just has it tuned to filter out comments about people gaming the Taxonomist badge). | I just left two comments, one to the above linked post, and one to the latest podcast post. Neither comment showed up.
The last comment was on the 22nd, and things were getting a bit out of hand, so it wouldn't surprise me if they were being moderated.
I'd expect them to just close comments on that one post, though, ... |
43,868 | About an hour or two ago I went and added a comment to the [Recalc Blog post](https://blog.stackoverflow.com/2010/03/the-great-reputation-recalc-begins/) on blog.stackoverflow.com.
The comment has still not shown up. I thought maybe it got lost in translation, so I tried to add it again. (I had saved a copy.) When I d... | 2010/03/24 | [
"https://meta.stackexchange.com/questions/43868",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/16241/"
] | To answer the question, no they are not moderated ahead of time. Sometimes I moderate them after the fact if they aren't constructive or at least funny in a non-malicious way.
As to the current lack of comments, this was an error in the latest version of WP-ReCaptcha. Comments were all being held for some reason-- I t... | I just left two comments, one to the above linked post, and one to the latest podcast post. Neither comment showed up.
The last comment was on the 22nd, and things were getting a bit out of hand, so it wouldn't surprise me if they were being moderated.
I'd expect them to just close comments on that one post, though, ... |
43,868 | About an hour or two ago I went and added a comment to the [Recalc Blog post](https://blog.stackoverflow.com/2010/03/the-great-reputation-recalc-begins/) on blog.stackoverflow.com.
The comment has still not shown up. I thought maybe it got lost in translation, so I tried to add it again. (I had saved a copy.) When I d... | 2010/03/24 | [
"https://meta.stackexchange.com/questions/43868",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/16241/"
] | To answer the question, no they are not moderated ahead of time. Sometimes I moderate them after the fact if they aren't constructive or at least funny in a non-malicious way.
As to the current lack of comments, this was an error in the latest version of WP-ReCaptcha. Comments were all being held for some reason-- I t... | Yes, they're moderated, but there's also a [spam trap](https://meta.stackexchange.com/questions/33117/are-comments-broken-on-blog-stackoverflow-com) that sometimes gets clogged or something (or maybe Jeff just has it tuned to filter out comments about people gaming the Taxonomist badge). |
1,312,569 | **Edit: Update at bottom.**
Hope someone can help here as it's driving me round the bend!
Delphi 2009
I have a form with two TComboxBoxEx components on it
One I populate at runtime with the following code
```
procedure TForm1.btn1Click(Sender: TObject);
var
N: Integer;
begin
cb1.ItemsEx.Add.Caption := 'Test';
... | 2009/08/21 | [
"https://Stackoverflow.com/questions/1312569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/922/"
] | Not quite sure why your code doesn't work, but here's some that does:
```
for N := 0 to 5 do
cb1.ItemsEx.AddItem(intToStr(N), 0, 0, 0, DESIRED_INDENT_LEVEL, nil);
``` | Try setting the Indent property *before* setting Caption.
Seems to be a "known bug" in TComboBoxEx. |
44,689,029 | >
> output.txt (Original Before Script)
> Apple mobile
> Telephone
>
>
> `input.txt`
>
>
>
> ```
> Samsung Gallaxy
> Tablet
> Samsung S7 mobile
> Telephone
> Oneplus3 mobile
> Telephone
>
> ```
>
>
I use this command :
`sed -n -e '/mobile/,/Telephone/ p' input.txt > output.txt`
>
> output.txt
>
>
>
> `... | 2017/06/22 | [
"https://Stackoverflow.com/questions/44689029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8197234/"
] | `awk` would also achieve your goal,
```
$ awk '/Telephone|mobile/{print}' Input.txt >> Output.txt
$ cat Output.txt
Apple mobile
Telephone
Samsung S7 mobile
Telephone
Oneplus3 mobile
Telephone
```
Brief explanation,
* `/Telephone|mobile/`: search the lines contain `Telephone` or `mobile`, then print them. | use `grep`:
```
grep -E "(Telephone|mobile)" filename >>outputfilename
``` |
39,560,934 | I recently got a new hard drive and reinstalled Mac OS X on it. I copied my entire folder with all my Xcode projects over. However when I tried booting up one by clicking the project file, Xcode opens up with only the project file present. All of the files with actual code on them are not appearing.
I tried to add fi... | 2016/09/18 | [
"https://Stackoverflow.com/questions/39560934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6846043/"
] | So, the only way I know of to do this efficiently is to load up the project file XML in your favorite editor and go manually fixup the paths. I don't recommend this.
Unfortunately, the way to do it through the UI is for each file, you need to open the Utilities Bar on the right, select the file, then update the path v... | i had this same issue i mean you could always manually transfer code through word documents or notes, but for me i had copied the entire project folder and the document transferred just fine just make sure you transfer all of the files with it and not just the one file for the project itself |
39,560,934 | I recently got a new hard drive and reinstalled Mac OS X on it. I copied my entire folder with all my Xcode projects over. However when I tried booting up one by clicking the project file, Xcode opens up with only the project file present. All of the files with actual code on them are not appearing.
I tried to add fi... | 2016/09/18 | [
"https://Stackoverflow.com/questions/39560934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6846043/"
] | i had this same issue i mean you could always manually transfer code through word documents or notes, but for me i had copied the entire project folder and the document transferred just fine just make sure you transfer all of the files with it and not just the one file for the project itself | delete the xcode application and reinstall it from the Mac App Store. |
39,560,934 | I recently got a new hard drive and reinstalled Mac OS X on it. I copied my entire folder with all my Xcode projects over. However when I tried booting up one by clicking the project file, Xcode opens up with only the project file present. All of the files with actual code on them are not appearing.
I tried to add fi... | 2016/09/18 | [
"https://Stackoverflow.com/questions/39560934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6846043/"
] | So, the only way I know of to do this efficiently is to load up the project file XML in your favorite editor and go manually fixup the paths. I don't recommend this.
Unfortunately, the way to do it through the UI is for each file, you need to open the Utilities Bar on the right, select the file, then update the path v... | delete the xcode application and reinstall it from the Mac App Store. |
38,116,270 | I'm trying to create a method that brings in a string, looks for the first letter of the string and then replaces all occurrences of that letter with another character.
It obviously does not work to use s[letter] to the new character, since letter in this case is not an index. But what solution should be used instead?... | 2016/06/30 | [
"https://Stackoverflow.com/questions/38116270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5258049/"
] | If you don't care about the nature of the transition, the easiest way is to do `CABasicAnimation`, animating the `path` of a `CAShapeLayer` from one path to another. And to achieve a patterned path with `CAShapeLayer` is actually to have two overlapping `CAShapeLayer` objects, one with a dash pattern on top of one with... | try this code, The animation is not perfect, but you will be able to convert an image to a line this way. I have to say that Rob's solution above is far more superior and if I were give a choice, i would do it his way.
The below code is very self-explanatory, but if in case of any doubt, feel free to ask.
To make t... |
71,979,681 | I have been [reading this stackoverflow post](https://stackoverflow.com/a/21022961/11092636). And they say `tabPane.getTabs().remove(tab)` will not trigger the listener on the event closing the tab which makes sense.
Therefore, I have applied their solution to my problem (I understand the principle, but not really the... | 2022/04/23 | [
"https://Stackoverflow.com/questions/71979681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11092636/"
] | None of these approaches (in other current answers in this post, or in the original post you linked) really make sense to me. It's possible I am not understanding what you are trying to do.
If you want to respond to a tab being removed, whether it is removed by the user clicking the tab close button, or programmatical... | You might want to use `getOnCloseRequest` instead of `getOnClosed` in your method `closeTab`:
```
EventHandler<Event> handler = tab.getOnCloseRequest();
handler.handle(null);
tab.getTabPane().getTabs().remove(tab);
``` |
22,356,962 | I have
```
template <typename A,
typename B,
typename C>
class Template
{
public:
static const size_t ZONE_X = 0;
static const size_t ZONE_Y = 1;
...
}
```
What is the most elegant way I to access the static const variables from other templates that in my case are dependency injection or ... | 2014/03/12 | [
"https://Stackoverflow.com/questions/22356962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870790/"
] | You can use
```
Template<void,void,void>::ZONE_X
```
Note that, the three `void`s are needed for `Template` given its definition. Of course, you can use other types, e.g. `int` or mixed of them:
```
Template<int,int,int>::ZONE_X
```
or
```
Template<void,int,float>::ZONE_X
``` | the argument list part should be taken with to refer the static member maybe you should not defined it in a template
```
#include <iostream>
using namespace std;
template <typename A,
typename B,
typename C>
class Template
{
public:
static const size_t ZONE_X = 0;
static const size_t JO... |
54,522,877 | I just created a really basic spring boot application using spring initializer and am trying things out. I want to load a list from a yaml configuration file, but it always returns empty.
I have a custom configuration class
```
@ConfigurationProperties("example-unit")
@EnableConfigurationProperties
public class Confi... | 2019/02/04 | [
"https://Stackoverflow.com/questions/54522877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11014211/"
] | Put your list under *prefix.property*. In your case `example-unit.confi-list:`. Usually provide a setter for your property: `setConfiList(List<String> strings)`. But since you already initialized it as empty Array list this setter is obsolete says [this](https://stackoverflow.com/questions/27416327/configurationpropert... | Here is an example :
***Application.yml:***
```
example-unit: string1,string2,hello22
```
**ConfigurationUnit.class:**
```
@Component
@PropertySource(value="classpath:application.yml")
public class ConfigurationUnit {
@Value("#{'${example-unit}'.split(',')}")
private List<String> confiList;
public Li... |
54,522,877 | I just created a really basic spring boot application using spring initializer and am trying things out. I want to load a list from a yaml configuration file, but it always returns empty.
I have a custom configuration class
```
@ConfigurationProperties("example-unit")
@EnableConfigurationProperties
public class Confi... | 2019/02/04 | [
"https://Stackoverflow.com/questions/54522877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11014211/"
] | This statement is wrong `static ConfigurationUnit configurationUnit = new ConfigurationUnit();`
you should not create the object
Spring only injects the properties into the beans that are handled by application context, and spring creates beans of classes that are annotated with `@ Configuration`
**ConfigurationUni... | Put your list under *prefix.property*. In your case `example-unit.confi-list:`. Usually provide a setter for your property: `setConfiList(List<String> strings)`. But since you already initialized it as empty Array list this setter is obsolete says [this](https://stackoverflow.com/questions/27416327/configurationpropert... |
54,522,877 | I just created a really basic spring boot application using spring initializer and am trying things out. I want to load a list from a yaml configuration file, but it always returns empty.
I have a custom configuration class
```
@ConfigurationProperties("example-unit")
@EnableConfigurationProperties
public class Confi... | 2019/02/04 | [
"https://Stackoverflow.com/questions/54522877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11014211/"
] | Put your list under *prefix.property*. In your case `example-unit.confi-list:`. Usually provide a setter for your property: `setConfiList(List<String> strings)`. But since you already initialized it as empty Array list this setter is obsolete says [this](https://stackoverflow.com/questions/27416327/configurationpropert... | Here is the reference on how [Spring Bboot Configurtion Binding](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding) works.
Specifically for your question, this is an example of app that achives your goal:
* application.yml
```
example-unit:
confiList:
- string1
- string2... |
54,522,877 | I just created a really basic spring boot application using spring initializer and am trying things out. I want to load a list from a yaml configuration file, but it always returns empty.
I have a custom configuration class
```
@ConfigurationProperties("example-unit")
@EnableConfigurationProperties
public class Confi... | 2019/02/04 | [
"https://Stackoverflow.com/questions/54522877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11014211/"
] | This statement is wrong `static ConfigurationUnit configurationUnit = new ConfigurationUnit();`
you should not create the object
Spring only injects the properties into the beans that are handled by application context, and spring creates beans of classes that are annotated with `@ Configuration`
**ConfigurationUni... | Here is an example :
***Application.yml:***
```
example-unit: string1,string2,hello22
```
**ConfigurationUnit.class:**
```
@Component
@PropertySource(value="classpath:application.yml")
public class ConfigurationUnit {
@Value("#{'${example-unit}'.split(',')}")
private List<String> confiList;
public Li... |
54,522,877 | I just created a really basic spring boot application using spring initializer and am trying things out. I want to load a list from a yaml configuration file, but it always returns empty.
I have a custom configuration class
```
@ConfigurationProperties("example-unit")
@EnableConfigurationProperties
public class Confi... | 2019/02/04 | [
"https://Stackoverflow.com/questions/54522877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11014211/"
] | Here is the reference on how [Spring Bboot Configurtion Binding](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding) works.
Specifically for your question, this is an example of app that achives your goal:
* application.yml
```
example-unit:
confiList:
- string1
- string2... | Here is an example :
***Application.yml:***
```
example-unit: string1,string2,hello22
```
**ConfigurationUnit.class:**
```
@Component
@PropertySource(value="classpath:application.yml")
public class ConfigurationUnit {
@Value("#{'${example-unit}'.split(',')}")
private List<String> confiList;
public Li... |
54,522,877 | I just created a really basic spring boot application using spring initializer and am trying things out. I want to load a list from a yaml configuration file, but it always returns empty.
I have a custom configuration class
```
@ConfigurationProperties("example-unit")
@EnableConfigurationProperties
public class Confi... | 2019/02/04 | [
"https://Stackoverflow.com/questions/54522877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11014211/"
] | This statement is wrong `static ConfigurationUnit configurationUnit = new ConfigurationUnit();`
you should not create the object
Spring only injects the properties into the beans that are handled by application context, and spring creates beans of classes that are annotated with `@ Configuration`
**ConfigurationUni... | Here is the reference on how [Spring Bboot Configurtion Binding](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding) works.
Specifically for your question, this is an example of app that achives your goal:
* application.yml
```
example-unit:
confiList:
- string1
- string2... |
300,215 | I am thinking of a farming project that includes using some board like [Arduino](https://www.arduino.cc/), [Raspberry Pi](https://www.raspberrypi.org/) or [Onion Mega](https://onion.io/) (the list is not exclusive).
As the system will work with sensors and support life of its wards, their health will depend on the wor... | 2017/04/18 | [
"https://electronics.stackexchange.com/questions/300215",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/2543/"
] | You have to look for information about **RAMS** (reliability, availability, maintainability and safety) engineering.
Basic RAMS concepts and techniques
----------------------------------
* **Failure rate**: number of expected failures of a component, assembly or product per time unit.
* **MTTF (mean time to failure) ... | I'd look at dual redundancy: two boards with each one monitoring itself, the second board and common resources such as the power supply. The output have to agree to drive critical things and this can be done with simple diode-ANDing. Critical things might include enabling the power to motors or other moving things. The... |
9,751 | If we create a transaction body in the backend using cardano-cli for example, and only for signing the transaction would like to get the frontend wallet to sign it, how is this done in the best possible way ? | 2023/01/19 | [
"https://cardano.stackexchange.com/questions/9751",
"https://cardano.stackexchange.com",
"https://cardano.stackexchange.com/users/1053/"
] | Basically, there are two ways:
1. After getting the transaction in the frontend, load the CBOR to CSL (cardano-serialization-lib), and proceed from there.
The workflow would be: build the transaction with cardano-cli, sign it with some random wallet stored in backend, send the signed transaction CBOR to frontend, des... | I have a different type of example that might be helpful to anyone looking for ways to sign (and build) transactions using both a browser wallet and a server side private key. Code is here <https://github.com/lley154/helios-examples/tree/main/nft-multisig>
And video <https://youtu.be/CSd9ev_XH5w> |
58,263,320 | Is it appropriate to check user auth to server api in every activity (i assume using base activity on resume)? It is to prevent user login on multiple device with same account. Or is there better approach for this? | 2019/10/07 | [
"https://Stackoverflow.com/questions/58263320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3021153/"
] | There is several approach to handle this.
1. **Push notification** - When same user login in another device then you need to send push notification to first login device. When first login device get notification then you can put your logic there.
2. **Put Logout status on every api** - You need to check logout status ... | So I'm assuming that every successful sign-in then the server gives you back a unique auth-token which should invalidate any previously assigned token.
My approach is usually just to allow the user to continue using the app with whatever cached data that's already there until I hit a scenario that needs to do an API ... |
13,543,705 | I am trying to travel up from `$('.sent_comment_action')` to `.message_to_comment` element with the following structure:
```
<div class="replay_comment_container">
<input type="hidden" class="message_to_comment" name="message_to_comment" value="1234" />
<a class="new_comment_action" href="#">Add Comment</a>
... | 2012/11/24 | [
"https://Stackoverflow.com/questions/13543705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1424329/"
] | The input with class `message_to_comment` isn't a parent of your button.
It seems you could use
```
button.closest('replay_comment_container').find('.message_to_comment').val();
``` | How about using while loop:
```
function getValue(element)
{
var parent = element;
do
{
parent = parent.parent();
element = parent.find('.message_to_comment');
}
while (!element && parent)
return element ? element.val() : null;
}
```
you can then use:
```
var myValue = getValue(val... |
13,543,705 | I am trying to travel up from `$('.sent_comment_action')` to `.message_to_comment` element with the following structure:
```
<div class="replay_comment_container">
<input type="hidden" class="message_to_comment" name="message_to_comment" value="1234" />
<a class="new_comment_action" href="#">Add Comment</a>
... | 2012/11/24 | [
"https://Stackoverflow.com/questions/13543705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1424329/"
] | The input with class `message_to_comment` isn't a parent of your button.
It seems you could use
```
button.closest('replay_comment_container').find('.message_to_comment').val();
``` | To answer your question simply, .prev(); : For previous element is the method your looking for.
But I'd suggest this to change your code a little bit to make it easier to find elements using jQuery selectors.
```
<div class="replay_comment_container">
<a class="new_comment_action" href="#">Add Comment</a>
<div class=... |
13,543,705 | I am trying to travel up from `$('.sent_comment_action')` to `.message_to_comment` element with the following structure:
```
<div class="replay_comment_container">
<input type="hidden" class="message_to_comment" name="message_to_comment" value="1234" />
<a class="new_comment_action" href="#">Add Comment</a>
... | 2012/11/24 | [
"https://Stackoverflow.com/questions/13543705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1424329/"
] | This is what you are looking for, you want to look for an element that is not a parent of the button, it is in fact a sibling of the closest `.comment_form`
```
button.closest('.replay_comment_container').children('.message_to_comment').val();
```
You could also try
```
button.closest('.comment_form').prevAll('.mes... | How about using while loop:
```
function getValue(element)
{
var parent = element;
do
{
parent = parent.parent();
element = parent.find('.message_to_comment');
}
while (!element && parent)
return element ? element.val() : null;
}
```
you can then use:
```
var myValue = getValue(val... |
13,543,705 | I am trying to travel up from `$('.sent_comment_action')` to `.message_to_comment` element with the following structure:
```
<div class="replay_comment_container">
<input type="hidden" class="message_to_comment" name="message_to_comment" value="1234" />
<a class="new_comment_action" href="#">Add Comment</a>
... | 2012/11/24 | [
"https://Stackoverflow.com/questions/13543705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1424329/"
] | This is what you are looking for, you want to look for an element that is not a parent of the button, it is in fact a sibling of the closest `.comment_form`
```
button.closest('.replay_comment_container').children('.message_to_comment').val();
```
You could also try
```
button.closest('.comment_form').prevAll('.mes... | To answer your question simply, .prev(); : For previous element is the method your looking for.
But I'd suggest this to change your code a little bit to make it easier to find elements using jQuery selectors.
```
<div class="replay_comment_container">
<a class="new_comment_action" href="#">Add Comment</a>
<div class=... |
33,566,399 | I have been experimenting Java thread visibility problem with the popular example of sending a stop signal to the thread by means of a shared boolean and non-volatile variable and the target thread does not seem to get it) as below:
```
public class ThreadVisibilityTest {
//Shared variable to send a signal to the... | 2015/11/06 | [
"https://Stackoverflow.com/questions/33566399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2104293/"
] | >
> Is this something that happens by chance or do I miss something?
>
>
>
You missed the chapter in the Java Language Reference (JLS) that talks about the Java Memory Model. Either that, or you missed working through the *concurrency* chapter in the Java tutorial. <https://docs.oracle.com/javase/tutorial/essenti... | I think mutual exclusion also provides memory visibility as stated in Java Concurrency In Practice (By Brian Goetz) in section 3.1.3 Locking and Visibility. |
33,566,399 | I have been experimenting Java thread visibility problem with the popular example of sending a stop signal to the thread by means of a shared boolean and non-volatile variable and the target thread does not seem to get it) as below:
```
public class ThreadVisibilityTest {
//Shared variable to send a signal to the... | 2015/11/06 | [
"https://Stackoverflow.com/questions/33566399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2104293/"
] | >
> Is this something that happens by chance or do I miss something?
>
>
>
You missed the chapter in the Java Language Reference (JLS) that talks about the Java Memory Model. Either that, or you missed working through the *concurrency* chapter in the Java tutorial. <https://docs.oracle.com/javase/tutorial/essenti... | See, you are reading it in synchronized context but not writing in the synchronized context. That might cause problem. |
33,566,399 | I have been experimenting Java thread visibility problem with the popular example of sending a stop signal to the thread by means of a shared boolean and non-volatile variable and the target thread does not seem to get it) as below:
```
public class ThreadVisibilityTest {
//Shared variable to send a signal to the... | 2015/11/06 | [
"https://Stackoverflow.com/questions/33566399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2104293/"
] | >
> Is this something that happens by chance or do I miss something?
>
>
>
You missed the chapter in the Java Language Reference (JLS) that talks about the Java Memory Model. Either that, or you missed working through the *concurrency* chapter in the Java tutorial. <https://docs.oracle.com/javase/tutorial/essenti... | As other answers have already pointed out, memory visibility is established when using synchronization.
However, it would be preferable to use a volatile shared variable (unless synchronization is needed for non visibility related issues) for greater concurrency. Overuse of synchronization forces threads to constantly... |
33,566,399 | I have been experimenting Java thread visibility problem with the popular example of sending a stop signal to the thread by means of a shared boolean and non-volatile variable and the target thread does not seem to get it) as below:
```
public class ThreadVisibilityTest {
//Shared variable to send a signal to the... | 2015/11/06 | [
"https://Stackoverflow.com/questions/33566399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2104293/"
] | >
> Is this something that happens by chance or do I miss something?
>
>
>
You missed the chapter in the Java Language Reference (JLS) that talks about the Java Memory Model. Either that, or you missed working through the *concurrency* chapter in the Java tutorial. <https://docs.oracle.com/javase/tutorial/essenti... | Synchronized blocks or methods work very similarly to volatile variables regarding visibility. After the thread exits the synchronized block, it releases the monitor, which has the effect of flushing CPU registers to CPU cache - so that writes made by that thread are visible to other threads.
Before entering the synch... |
36,063,662 | I am having difficulty getting the xsl:apply-template select to pick up only the desired elements. Each of the following forms for the node element is valid.
```
<?xml version="1.0" encoding="utf-8"?>
<root>
<node>unimportant</node>
<node>
<value>unimportant</value>
<asdf>important</asdf>
</node>
<node... | 2016/03/17 | [
"https://Stackoverflow.com/questions/36063662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46462/"
] | Assuming you know which nodes your are not like to treat (`not(self::value)`).
change your
```
<xsl:apply-templates select="node()[not(self::value)]"/>
```
to
```
<xsl:apply-templates select="*[not(self::value)]"/>
```
This will ignore the wrong text() nodes | Would this work for you?
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:c... |
36,063,662 | I am having difficulty getting the xsl:apply-template select to pick up only the desired elements. Each of the following forms for the node element is valid.
```
<?xml version="1.0" encoding="utf-8"?>
<root>
<node>unimportant</node>
<node>
<value>unimportant</value>
<asdf>important</asdf>
</node>
<node... | 2016/03/17 | [
"https://Stackoverflow.com/questions/36063662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46462/"
] | Would this work for you?
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:c... | ```
//node/*[not(self::value)]
```
Alternately,
```
//node/*[local-name() != "value"]
``` |
36,063,662 | I am having difficulty getting the xsl:apply-template select to pick up only the desired elements. Each of the following forms for the node element is valid.
```
<?xml version="1.0" encoding="utf-8"?>
<root>
<node>unimportant</node>
<node>
<value>unimportant</value>
<asdf>important</asdf>
</node>
<node... | 2016/03/17 | [
"https://Stackoverflow.com/questions/36063662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46462/"
] | Assuming you know which nodes your are not like to treat (`not(self::value)`).
change your
```
<xsl:apply-templates select="node()[not(self::value)]"/>
```
to
```
<xsl:apply-templates select="*[not(self::value)]"/>
```
This will ignore the wrong text() nodes | ```
//node/*[not(self::value)]
```
Alternately,
```
//node/*[local-name() != "value"]
``` |
332,312 | Question: Talking about software development, how to provide good approaches to achieve a repository of reusable components inside a project?
Context: Working on a team of 10 coworkers may be very interesting but could be also unorganized. Duplicated services, components, in other words, shareable code. Documenting an... | 2016/09/28 | [
"https://softwareengineering.stackexchange.com/questions/332312",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/245166/"
] | The usual good practices apply.
Whether it's a future you, a team of 2, a team of 10, an overseas team or whatever, write code that is
* Modular
* Easy to read
* Well named
* Well tested
* etc.
With classes and methods that are
* Short
* Single purpose
* Unit tested
* etc.
With team members that
* Physically work... | Just one aspect I haven't seen mentioned in the related questions/answers:
Depending on the size of your project team and the amount of base coding already available, it might make sense to dedicate a certain percentage (10-20%) of your developers to writing basic/fundamental/re-use library code. Those guys should hav... |
332,312 | Question: Talking about software development, how to provide good approaches to achieve a repository of reusable components inside a project?
Context: Working on a team of 10 coworkers may be very interesting but could be also unorganized. Duplicated services, components, in other words, shareable code. Documenting an... | 2016/09/28 | [
"https://softwareengineering.stackexchange.com/questions/332312",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/245166/"
] | The usual good practices apply.
Whether it's a future you, a team of 2, a team of 10, an overseas team or whatever, write code that is
* Modular
* Easy to read
* Well named
* Well tested
* etc.
With classes and methods that are
* Short
* Single purpose
* Unit tested
* etc.
With team members that
* Physically work... | You can also use Bit:
<https://github.com/teambit/bit>
It's an open source project that enables you to turn any subset of files from your source code a reusable component and create a playlist-like collection without setting up new libraries/packages.
Components can be shared with your team and across projects (examp... |
23,208,779 | When I tried to install my app on the device, the console generates the below posted message.
In my device the developers option is enabled and I also cleaned and re-built the workspace.
please help my to solve this problem
Console Output:
```
[2014-07-26 11:30:12 - CompassTest00] ------------------------------
[2014... | 2014/04/22 | [
"https://Stackoverflow.com/questions/23208779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You need to properly declare your main activity in the `Manifest.xml` file, something like this:
```
<activity
android:name="com.example.compasstest00.AndroidSensors"
android:label="@string/title_activity_android_sensors">
<intent-filter>
<action android:name="android.intent.act... | When I first tried using my phone (device) instead of an emulator, I too experienced this type of behavior. Two things I did that fixed it were:
(1) downloaded the usb driver for my phone. for example i have a Samsung Galaxy SIII. I googled it and found its usb driver and downloaded and installed it on my laptop.
(2) I... |
10,001,064 | I'm drawing a grid of data in a UIView with `drawRect`, of which I won't know the final size when the UIView is created because the number of columns and rows is dynamic. Sure I could do the calculations before creating the UIView, but that doesn't really make sense, because I'll also be doing those calculations in the... | 2012/04/03 | [
"https://Stackoverflow.com/questions/10001064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287403/"
] | Perhaps others have another solution but I think that in your case I would override setFrame: and call setNeedsDisplay so that drawRect will be called after your frame changes. Have you tried this approach already? | * Add a method in your view that determines how large it should be, based on its data. This needs to be separate from `drawRect:`.
* In your view controller, when you're setting up the view, call that method to get that size.
* Then set your view's bounds and/or frame to that size.
* And also set the scroll view's `con... |
6,126,124 | I'm using an ExecutorService to execute some Callables, but the name of the threads are like fixed-pool-1-thread-1.
How I change the name of the threads? If it's not possible, there another way to execute Callables that I can set the name of threadS? | 2011/05/25 | [
"https://Stackoverflow.com/questions/6126124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/734984/"
] | You'll have to use an `ExecutorService` implementation that allows you to set the `ThreadFactory`[1](http://download.oracle.com/javase/1,5.0/docs/api/java/util/concurrent/ThreadFactory.html) used to create threads, for example, [`ThreadPoolExecutor`](http://download.oracle.com/javase/1,5.0/docs/api/java/util/concurrent... | Guava almost always has what you [need](http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/util/concurrent/ThreadFactoryBuilder.html#setNameFormat%28java.lang.String%29). `ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("my-sad-thread-%d").build()` and pass it off to yo... |
6,126,124 | I'm using an ExecutorService to execute some Callables, but the name of the threads are like fixed-pool-1-thread-1.
How I change the name of the threads? If it's not possible, there another way to execute Callables that I can set the name of threadS? | 2011/05/25 | [
"https://Stackoverflow.com/questions/6126124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/734984/"
] | You'll have to use an `ExecutorService` implementation that allows you to set the `ThreadFactory`[1](http://download.oracle.com/javase/1,5.0/docs/api/java/util/concurrent/ThreadFactory.html) used to create threads, for example, [`ThreadPoolExecutor`](http://download.oracle.com/javase/1,5.0/docs/api/java/util/concurrent... | A quick and dirty way;
```
public void run() {
Thread.currentThread().setName(aName);
doStuff();
}
``` |
6,126,124 | I'm using an ExecutorService to execute some Callables, but the name of the threads are like fixed-pool-1-thread-1.
How I change the name of the threads? If it's not possible, there another way to execute Callables that I can set the name of threadS? | 2011/05/25 | [
"https://Stackoverflow.com/questions/6126124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/734984/"
] | Guava almost always has what you [need](http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/util/concurrent/ThreadFactoryBuilder.html#setNameFormat%28java.lang.String%29). `ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("my-sad-thread-%d").build()` and pass it off to yo... | A quick and dirty way;
```
public void run() {
Thread.currentThread().setName(aName);
doStuff();
}
``` |
341,050 | **Background**
I saw this video on youtube where this guy adds a marker to his analog oscilloscope by sending a pulse to the z axis input:
<https://www.youtube.com/watch?v=QCFBBiIm1h0>
I want to do the same thing with my Tektronix 2213, but I want the cursors to be calibrated.
The two signals my system will deal wit... | 2017/11/21 | [
"https://electronics.stackexchange.com/questions/341050",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/107412/"
] | Sounds right to me. Measuring the A-width is something a bit extra, as the necessary timing is sort of independent of the width. Remember, you're putting up a "cursor" because you have interest in labeling some time point (which you don't need the width for) -- not some location on the screen (which you do need the wid... | Since the A signal depends on whatever the scope is measuring, its frequency may not be fixed. For example the scope may be triggered on a signal whose frequency varies, or an infrequent signal.
However its pulse length will depend on the scope sweep time, so it should be constant (until you turn the knob).
I would u... |
341,050 | **Background**
I saw this video on youtube where this guy adds a marker to his analog oscilloscope by sending a pulse to the z axis input:
<https://www.youtube.com/watch?v=QCFBBiIm1h0>
I want to do the same thing with my Tektronix 2213, but I want the cursors to be calibrated.
The two signals my system will deal wit... | 2017/11/21 | [
"https://electronics.stackexchange.com/questions/341050",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/107412/"
] | The 555 circuit was just a "mickey mouse" example of how to use Z axis input on one sweep position and will not work on all positions.
The proper way is to use the X axis linear sweep output (sawtooth ramp) and use a variable threshold and comparator to trigger to fire Z-axis input low. The trick is how to get a varia... | Since the A signal depends on whatever the scope is measuring, its frequency may not be fixed. For example the scope may be triggered on a signal whose frequency varies, or an infrequent signal.
However its pulse length will depend on the scope sweep time, so it should be constant (until you turn the knob).
I would u... |
33,205,692 | I have a javascript library that I have written that I want to be able to use similar to how bootstrap's libraries are use. That is, I want to drive them from data attributes on elements in the page.
The problem is this library needs to know of a url to a specific part of our site (server api that performs a utility f... | 2015/10/19 | [
"https://Stackoverflow.com/questions/33205692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1511092/"
] | Using a prepared statement allows you to protect from SQL Injection. Checking all your posts helps ensure that they have some value if needed.
```
<?php
if(isset($_POST['submit'])){
// Populate each variable
$cf = isset($_POST['Cus_fname'])?$_POST['Cus_fname']:"";
$cl = isset($_POST['Cus_lname'])?$_POST['C... | Check the query for your account table.
>
> mysqli\_query($con, "INSERT INTO account (Cus\_ID, Cus\_Uname, Cus\_Pword)
> VALUES ('null', '$cu', '$cp')");
>
>
>
You have placed a typo **'null'** which is a string into your Cus\_ID which i assume the datatype is INT since it is a ID. Remove the single quotes **nul... |
22,916,352 | I have a few checkboxes:
```
<input class="time" id="test_1" type="checkbox" name="test1" value=""> test1<br>
<input class="time" id="test_2" type="checkbox" name="test2" value=""> test2<br>
<input class="time" id="test_3" type="checkbox" name="test3" value=""> test3<br>
<input class="time" id="test_4" type="check... | 2014/04/07 | [
"https://Stackoverflow.com/questions/22916352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778367/"
] | You can easily fix this by using radio buttons instead of checkboxes.
```
<input class="time" id="show_15min" type="radio" name="time" value="15min"> 15min <br>
<input class="time" id="show_28min" type="radio" name="time" value="28min"> 28min <br>
<input class="time" id="show_45min" type="radio" name="time" value="45... | try this:
```
var $unique = $('input.time');
$unique.click(function() {
$unique.filter(':checked').not(this).removeAttr('checked');
});
```
**[Working Demo](http://jsfiddle.net/hsvF6/1/)** |
65,110,890 | Ok so I have some columns that i'm setting data for but the data takes a sec to get prepared so i'm running into an issue where sometimes things are ready and sometimes they're not. I'm using 2 useEffect s but I feel like i'm doing something wrong. Here is an example of what i'm talking about
So pretty much sometimes ... | 2020/12/02 | [
"https://Stackoverflow.com/questions/65110890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14749895/"
] | There are some practical advises on the link below.
[Android can't play some wav file with soundpool?](https://stackoverflow.com/questions/5068068/android-cant-play-some-wav-file-with-soundpool/5071491)
Personally, I've used Soundpool with .mp3 files with no white noise issues.
After some searching, I've found this ... | FWIW, experienced the same problem on a Xiaomi Redmi 6, and @Peppinhood's suggestion to use `.mp3` did the trick
For some reason, both `.m4a` and `.wav` produced heavily distorted sounds on that device. |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | (a − b)²
========
>
> [](https://i.stack.imgur.com/Y4n0H.png)
>
>
>
This works because:
```
(a − b)² = a * (a − b) + b * (b − a)
```
Since multiplication in ℤ₂ is conjuction (`&`), and `1 - a` is negation (`!`), the above formula is equivalent to XOR f... | you can use this :
Xor(n,x,y)=x+y - Pow(2,n+1)(floor((x+y)/Pow(2,n+1)));
when
x => number in Z collection and positive, x>=0
y => number in Z collection and positive, y>=0
n => is data bit length for example 32 or 64
pow(2,3)=> 2*2*2
floor(1.6594565)=1 or floor(4562.21)=4562 |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | Weellllllllllll........
It's not quite as simple as that.
To model a XOR (let's call it X), we start with the logic.
```
X = (A & !B) | (!A & B)
```
In math, the above can be written as:
```
X = A*(1-B) + B*(1-A)
```
But the above expression is nonlinear (due to the bilinear terms -- to preserve linearity, we a... | you can use this :
Xor(n,x,y)=x+y - Pow(2,n+1)(floor((x+y)/Pow(2,n+1)));
when
x => number in Z collection and positive, x>=0
y => number in Z collection and positive, y>=0
n => is data bit length for example 32 or 64
pow(2,3)=> 2*2*2
floor(1.6594565)=1 or floor(4562.21)=4562 |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | (a − b)²
========
>
> [](https://i.stack.imgur.com/Y4n0H.png)
>
>
>
This works because:
```
(a − b)² = a * (a − b) + b * (b − a)
```
Since multiplication in ℤ₂ is conjuction (`&`), and `1 - a` is negation (`!`), the above formula is equivalent to XOR f... | TL;DR
**XOR any numerical input**
`a + b - ab(1 + a + b - ab)`
**XOR binary input**
`a + b - 2ab` or `(a-b)²`
---
**Derivation**
**Basic Logical Operators**
`NOT` = `(1-x)`
`AND` = `x*y`
From those operators we can get...
`OR` = `(1-(1-a)(1-b))` = `a + b - ab`
*Note: If a and b are mutually exclusive then t... |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | The simplest expression I can come up with is: `a != b`.
(Previous best effort was `(a + b) == 1`) | you can use this :
Xor(n,x,y)=x+y - Pow(2,n+1)(floor((x+y)/Pow(2,n+1)));
when
x => number in Z collection and positive, x>=0
y => number in Z collection and positive, y>=0
n => is data bit length for example 32 or 64
pow(2,3)=> 2*2*2
floor(1.6594565)=1 or floor(4562.21)=4562 |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | Weellllllllllll........
It's not quite as simple as that.
To model a XOR (let's call it X), we start with the logic.
```
X = (A & !B) | (!A & B)
```
In math, the above can be written as:
```
X = A*(1-B) + B*(1-A)
```
But the above expression is nonlinear (due to the bilinear terms -- to preserve linearity, we a... | abs(A+B-1). if it doesn't do abs, then (A+B-1)\*(A+B-1) should do it. |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | In Brown, G. and Dell, R., *Formulating linear and integer linear programs: A rogues’ gallery*
the following linear programming formulation for the XOR can be found:
```
Z3 = Z1 XOR Z2
```
resolves to
```
Z3 <= Z1 + Z2
Z3 >= Z1 - Z2
Z3 >= -Z1 + Z2
Z3 <= 2 - Z1 - Z2
``` | Exclusive-OR *is* a linear function, but the [definition](http://en.wikipedia.org/wiki/Linear#Boolean_functions) of 'linear' with regards to a boolean function is not the same as with a polynomial function. You will have to look through the documentation for your `lp_solve` library to see if it is capable of handling l... |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | Can you do something like:
```
(a + b) % 2
``` | you can use this :
Xor(n,x,y)=x+y - Pow(2,n+1)(floor((x+y)/Pow(2,n+1)));
when
x => number in Z collection and positive, x>=0
y => number in Z collection and positive, y>=0
n => is data bit length for example 32 or 64
pow(2,3)=> 2*2*2
floor(1.6594565)=1 or floor(4562.21)=4562 |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | (a − b)²
========
>
> [](https://i.stack.imgur.com/Y4n0H.png)
>
>
>
This works because:
```
(a − b)² = a * (a − b) + b * (b − a)
```
Since multiplication in ℤ₂ is conjuction (`&`), and `1 - a` is negation (`!`), the above formula is equivalent to XOR f... | The simplest expression I can come up with is: `a != b`.
(Previous best effort was `(a + b) == 1`) |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | (a − b)²
========
>
> [](https://i.stack.imgur.com/Y4n0H.png)
>
>
>
This works because:
```
(a − b)² = a * (a − b) + b * (b − a)
```
Since multiplication in ℤ₂ is conjuction (`&`), and `1 - a` is negation (`!`), the above formula is equivalent to XOR f... | abs(A+B-1). if it doesn't do abs, then (A+B-1)\*(A+B-1) should do it. |
2,385,389 | How can I implement XOR using basic mathematical operators like +,-,\*,/
**Update:** Actually, I need to track change in two matrix having Boolean values. This can be done using XORing each value with corresponding value in other matrix. But, Lp\_Solve library doesn't support XOR operation. Also, it accepts only line... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2385389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286937/"
] | Can you do something like:
```
(a + b) % 2
``` | abs(A+B-1). if it doesn't do abs, then (A+B-1)\*(A+B-1) should do it. |
60,961,192 | I can't seem to figure out how to clear the input once a new form is switched. I'm able to gather the input from every form and display it at the end, but for some reason information from the first input is shown in the second and third and requires manual deletion. Any help would be appreciated. Thanks
```
import Rea... | 2020/03/31 | [
"https://Stackoverflow.com/questions/60961192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12561016/"
] | The issue is that you are passing `state.name` into your Form components, when it should be `state.Name`, see below:
```
switch (state.data) {
case 1:
return (
<div className='App-container'>
<Form
button='Next'
nextStep={nextStep}
name='Name'
state={... | I believe it's because you're not actually resetting your state when calling `nextStep()`.
You're just merging new `data` but the other values: `Name`, `Email`, `City` stay the same
Fix:
```
const nextStep = () => {
setState({
data: state.data + 1,
Name: '',
Email: '',
... |
8,038,348 | What's the right code for this case:
```
p = subprocess.Popen(["git", "log" , "-1", "--pretty=format:\'%s %n%n%b\'", hash],
stdout=subprocess.PIPE)
out, err = p.communicate()
print out
message += '\n' + out
```
I always get this error:
```
fatal: ambiguous argument '': unknown revision or path not in the workin... | 2011/11/07 | [
"https://Stackoverflow.com/questions/8038348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Since the call isn't parsed by a shell, you don't need the quotes at all:
```
p = subprocess.Popen(
["git", "log" , "-1", "--pretty=format:%s %n%n%b", hash],
stdout=subprocess.PIPE)
``` | I'm not sure whether you want to include the backslashes or not so I just put this here
```
>>> s = "--pretty=format:\'%s %n%n%b\'"
>>> print s
--pretty=format:'%s %n%n%b'
>>> s2 = "--pretty=format:'%s %n%n%b'"
>>> print s2
--pretty=format:'%s %n%n%b'
>>> s3 = "--pretty=format:\\'%s %n%n%b\\'"
>>> print s3
--pretty=fo... |
37,498,610 | I have a GridView on my page and I click on `Edit`, it displays my editable text box but when I edit the value and press `Update` it errors:
The error suggests that `GridView2.DataKeys` is `null`.
I adding some extra debugging by:
`int test = e.RowIndex`
and this gives me a value of `0`
My code is below:
Can you ... | 2016/05/28 | [
"https://Stackoverflow.com/questions/37498610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2123120/"
] | You need to set the `DataKeyNames` property on your GridView control to the relevant ID property e.g. `<asp:GridView DataKeyNames="PersonID"`...
**EDIT**
Below is a complete example which will return a valid primary key value in the `DataKeyValue` variable.You can copy this example, as is, into a new web page in your... | if yo click outside of the rows but on the data view the row index which is returned is -1. You have to check if this occurs and break out of the code if it does eg.
```
if (e.RowIndex<0&&e.RowIndex>=gridiew.Rows.Count)//have to account for the blan row
return;
``` |
68,011,523 | I am trying to get my command to run slower, if that is the correct way to say it. :(
I think I have something, but its not working
What I am looking to do is wait for 1 second before each message is sent, as I have to send the message to over 500 guilds but don't want to be rate limited.
```
let i = 0;
data.message... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68011523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9968850/"
] | What you have right now is you go through each 500 guildes at once and set delay of 1sec. After 1sec all 500 messages are sent.
What you need to do is send each message after previous message was sent.
Try this (assuming `data.message.client.guilds.cache` is an array):
```
let i = 0;
!function sendMessage ()
{
con... | You could use setTimeOut and a promise.
```js
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms))
```
then running `sleep(MS)` will wait before continuing
```js
async function run() {
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
console.log(1);
await sleep(1000)... |
68,011,523 | I am trying to get my command to run slower, if that is the correct way to say it. :(
I think I have something, but its not working
What I am looking to do is wait for 1 second before each message is sent, as I have to send the message to over 500 guilds but don't want to be rate limited.
```
let i = 0;
data.message... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68011523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9968850/"
] | What you have right now is you go through each 500 guildes at once and set delay of 1sec. After 1sec all 500 messages are sent.
What you need to do is send each message after previous message was sent.
Try this (assuming `data.message.client.guilds.cache` is an array):
```
let i = 0;
!function sendMessage ()
{
con... | So this may not be the best way, but it works.
```
let i = 0;
const guilds = [];
for (const guild of data.message.client.guilds.cache)
{
guilds.push(guild);
}
const wait = setInterval(function ()
{
const guild = guilds.shift();
i += 1;
if (guild === undefined)
{
console.log(`Done all servers... |
68,011,523 | I am trying to get my command to run slower, if that is the correct way to say it. :(
I think I have something, but its not working
What I am looking to do is wait for 1 second before each message is sent, as I have to send the message to over 500 guilds but don't want to be rate limited.
```
let i = 0;
data.message... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68011523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9968850/"
] | So this may not be the best way, but it works.
```
let i = 0;
const guilds = [];
for (const guild of data.message.client.guilds.cache)
{
guilds.push(guild);
}
const wait = setInterval(function ()
{
const guild = guilds.shift();
i += 1;
if (guild === undefined)
{
console.log(`Done all servers... | You could use setTimeOut and a promise.
```js
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms))
```
then running `sleep(MS)` will wait before continuing
```js
async function run() {
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
console.log(1);
await sleep(1000)... |
592,336 | >
> Represent the following family of curves by forming a corresponding differential equations:
>
> $$(vi) \frac {x^2}{a^2}-\frac {y^2}{b^2}=1$$
>
>
>
a and b are the parameters here.
I differentiated y, solved a and b, substituted them to get an answer which was long and wrong.
Please offer your assistance ... | 2013/12/04 | [
"https://math.stackexchange.com/questions/592336",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/50085/"
] | A possible answer is 'an irreducible unitary representation of the Poincar\'e group for which the eigenspaces of the generators of translation are finite-dimensional'. (At least, this is the space of states of a single particle of a single type).
This isn't a perfect answer, because not every QFT is relativistic (nor ... | In Dirac's Principles of Quantum Mechanics (3E), a particle at a point x is represented by a specific linear operator $\eta\_x$ applied to a ground state $|0\rangle$. Thus, if the system is in state $\eta\_x|0\rangle$, there is a particle at x; if it is in state $\eta^{-1}\_x|0\rangle$, there is an antiparticle at x; a... |
27,124,096 | I am a newbie to ng. Here, I have a scenario where I need to take the response received from success to another controller. I have tried the below code but I am not able to achieve my target.
CODE:
```
$scope.received = function(){
$http({
url : "/generic/getdata",
... | 2014/11/25 | [
"https://Stackoverflow.com/questions/27124096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4231911/"
] | If you are writing the text using canvas, then you can simply rotate the canavs and write the text and restore the canvas.
generic code
```
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end,
float x, int top, int y, int bottom, Paint paint)
{
if (start >= end)... | I think rather than rotate the text, you might put a picture of V and just when you want, replace the image in the image of V reversed. |
1,629,687 | What would you use to alter an XML-file while preserving as much as possible of layout, including indentation and comments?
My problem is that I have a couple of massive hand-edited XML-files describing a user interface, and now I need to translate several attributes to another language.
I've tried doing this using P... | 2009/10/27 | [
"https://Stackoverflow.com/questions/1629687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/84007/"
] | Any DOM manipulation module should suite your needs. Layout is just a text data, so it's represented as text nodes in DOM:
```
>>> from xml.dom.minidom import parseString
>>> dom = parseString('''\
... <message>
... <text>
... Hello!
... </text>
... </message>''')
>>> dom.childNodes[0].childNodes
[<DOM Text no... | If you use an XSLT processor such as [xt](http://www.blnz.com/xt/index.html), then you can write extension methods in Java that can perform any arbitrary transformation you need.
Having said that, I have used Python's [xml.dom.minidom](http://docs.python.org/library/xml.dom.minidom.html) module successfully for this s... |
35,258,029 | I have a wildcard text search over a collection with a million documents.
I can use my full text index directly from the MongoDB console with:
```
db.oneMillionDocumentsIndexed.find({$text: { $search: "raven" } } )
```
and this returns document after a minute-ish.
When I try the same thing in a unit test though,... | 2016/02/07 | [
"https://Stackoverflow.com/questions/35258029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/442351/"
] | Task.Result is a blocking call (in this case collection.FindAsync(filter).Result), it will wait until full result set is computed and then it will return.
you can try this code and i'm sure it will perform better (though not tested)
```
using(var cursor = await collection.Find(filter).ToCursorAsync())
{
while(awa... | Not sure what version of mongoDb driver you use but can you try this
```
while (cursor.MoveNextAsync().Result)
``` |
48,569,143 | I am working on a form that gets placed inside of a system I have no control over. One stipulation of this system is that all of the Names and IDs must match.
This poses a problem with Radios since they have to have the same name in order to function, which in turn means they have to have the same ID.
Is there syntax... | 2018/02/01 | [
"https://Stackoverflow.com/questions/48569143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5693505/"
] | The better solution is to keep parameters of event hubs in App Settings, and put the name of those settings in `function.json` without ever transforming it.
So, you should define your `function.json` as
```json
{
"bindings": [
{
"type": "eventHubTrigger",
"name": "myEventHubMessage",
"dir... | Change to use app settings which, from a `function.json` perspective would look like this:
```
{
"bindings": [
{
"type": "eventHubTrigger",
"name": "myEventHubMessage",
"direction": "in",
"path": "%MyIotHubPath%",
"connection": "MyIotHubConnection"
}
],
"disabled": false
}
... |
265,189 | So my husband is trying to find a movie he watched as a kid. He said it’s a live action movie about a family that lived on a floating island and they didn’t have powers. But they would use their ships to come help when disaster struck. Does this ring any bells? It’s not Sky High or Zoom or Up Up and Away
He thinks the... | 2022/07/07 | [
"https://scifi.stackexchange.com/questions/265189",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/153600/"
] | Sounds like [Thunderbirds (2004)](https://en.wikipedia.org/wiki/Thunderbirds_(2004_film))
>
> The Tracy family, led by former astronaut Jeff Tracy, operate International Rescue (IR), a secret organization that aids those in need during disasters using technologically advanced machines called Thunderbirds, operating o... | Is it Waterworld with Kevin Costner?
Or is it Nim's Island? |
33,782,594 | I've the below piece of code, where there is a progress bar that has to progressed.
```
public void createFiles(String srcText, String destText, JTextArea outputTextArea, JProgressBar progressBar) {
String zipFilePath = srcText;
String destDirectory = destText;
UnZip unzipper = new UnZip();
... | 2015/11/18 | [
"https://Stackoverflow.com/questions/33782594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3872094/"
] | You might just have to set the maximum correctly. E.g.:
```
progressBar.setMaximum(files.length);
```
To get only the files and not the directories in the first place do:
```
File[] files = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String name) {
return !file... | Not sure why you need this condition `(fileIntList + 1) % pBarInt == 0`
You should be setting the progress bar count as a percentage of the total files. Try using
```
progress.setValue(100);
....
int progressBarValue = count * 100/files.length;
progressBar.setValue(progressBarValue);
```
For accuracy use the correc... |
53,668,399 | I have an Apache NiFi instance that needs to log messages to a remote Graylog server. I want the outputs to nifi-app.log, nifi-bootstrap.log, and nifi-user.log to all be sent to this server, as well as their default local policy.
I'm trying to get the logs to the server over UDP, as the network configuration requires ... | 2018/12/07 | [
"https://Stackoverflow.com/questions/53668399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2836808/"
] | As far as I know, Logback does not provide an out-of-the-box UDP appender so you would need to add the necessary JARs for some UDP appender, possibly the logstash one:
<https://github.com/logstash/logstash-logback-encoder>
This might work, but adding JARs to NiFi's lib directory is a bit dangerous as they end up on t... | How about a simple solution of using LogMessage processor & make sure all the LogMessage log entries goes to a particular file (flow-events.log) & then tail on it?
```
<appender name="EVENTS_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${org.apache.nifi.bootstrap.config.log.dir}/flow-events... |
42,860,060 | I successfully installed pymongo using `pip3`
```
Aleeshas-MacBook-Air:project 2 aleesha$ sudo pip3 install pymongo
The directory '/Users/aleesha/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. ... | 2017/03/17 | [
"https://Stackoverflow.com/questions/42860060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2556478/"
] | It's a common problem that "pip" or "pip3" are not the same environment as "python" or "python3". To ensure you're installing with the same environment as you run:
```
python -m pip install pymongo
```
Or:
```
python3 -m pip install pymongo
``` | 1. python path
macOS have its own python. And sometimes we will install another python from brew or anaconda. So first you should which python is using.
```sh
which python
which python3
which pip
which pip3
```
the commands `python`, `python3`,`pip` and `pip3`, could be a path, alias or softlink.
if it's a path, yo... |
218,016 | Which one of these points is accumulation point, which not and why? I read the definition x-times but I'm quite confused :-/ I also found [this post](http://wiki.answers.com/Q/In_Calculus_what_is_an_accumulation_point) which is relevant to my question but it seems to me strange.
The problem is with natural numbers and... | 2012/10/21 | [
"https://math.stackexchange.com/questions/218016",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/28921/"
] | Here is what I would recommend.
Draw a number line. Mark the points $10, 1, .99999, 0$ on your number line. Then mark down the first, say, $20$ elements of the sequence $1/n$.
You'll even get to see visually why it's called an "accumulation point."
As for your other questions:
$\epsilon$ is real, not necessarily a ... | There are different definitions of what acumulation point for a sequence is. Maybe the most clear for this case is: It's such a point that for any neighborhood that you take with center in this point there are infinitly many points of the sequence inside this neighborhood. Let's denote circle neighborhood like this: $$... |
218,016 | Which one of these points is accumulation point, which not and why? I read the definition x-times but I'm quite confused :-/ I also found [this post](http://wiki.answers.com/Q/In_Calculus_what_is_an_accumulation_point) which is relevant to my question but it seems to me strange.
The problem is with natural numbers and... | 2012/10/21 | [
"https://math.stackexchange.com/questions/218016",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/28921/"
] | Here is what I would recommend.
Draw a number line. Mark the points $10, 1, .99999, 0$ on your number line. Then mark down the first, say, $20$ elements of the sequence $1/n$.
You'll even get to see visually why it's called an "accumulation point."
As for your other questions:
$\epsilon$ is real, not necessarily a ... | 0 is the accumulation point. By Arhimedean property, for any $\varepsilon>0$, choose $N\in \mathbb{N}$ such that $N>\frac{1}{\varepsilon}$, hence $A$-{0} intersect infinitely many points in $(-\varepsilon,\varepsilon)$ |
218,016 | Which one of these points is accumulation point, which not and why? I read the definition x-times but I'm quite confused :-/ I also found [this post](http://wiki.answers.com/Q/In_Calculus_what_is_an_accumulation_point) which is relevant to my question but it seems to me strange.
The problem is with natural numbers and... | 2012/10/21 | [
"https://math.stackexchange.com/questions/218016",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/28921/"
] | Here is what I would recommend.
Draw a number line. Mark the points $10, 1, .99999, 0$ on your number line. Then mark down the first, say, $20$ elements of the sequence $1/n$.
You'll even get to see visually why it's called an "accumulation point."
As for your other questions:
$\epsilon$ is real, not necessarily a ... | No, you are wrong with your guess. Remember that an accumulation point may not be in the set. If $A=\{1,1/2,1/3,1/4,...\}$ then $0$ (though $0\notin A)$ is an accumulation of $A$. In fact we cannot find any other accumulation point of $A$ other than $0$. |
218,016 | Which one of these points is accumulation point, which not and why? I read the definition x-times but I'm quite confused :-/ I also found [this post](http://wiki.answers.com/Q/In_Calculus_what_is_an_accumulation_point) which is relevant to my question but it seems to me strange.
The problem is with natural numbers and... | 2012/10/21 | [
"https://math.stackexchange.com/questions/218016",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/28921/"
] | There are different definitions of what acumulation point for a sequence is. Maybe the most clear for this case is: It's such a point that for any neighborhood that you take with center in this point there are infinitly many points of the sequence inside this neighborhood. Let's denote circle neighborhood like this: $$... | 0 is the accumulation point. By Arhimedean property, for any $\varepsilon>0$, choose $N\in \mathbb{N}$ such that $N>\frac{1}{\varepsilon}$, hence $A$-{0} intersect infinitely many points in $(-\varepsilon,\varepsilon)$ |
218,016 | Which one of these points is accumulation point, which not and why? I read the definition x-times but I'm quite confused :-/ I also found [this post](http://wiki.answers.com/Q/In_Calculus_what_is_an_accumulation_point) which is relevant to my question but it seems to me strange.
The problem is with natural numbers and... | 2012/10/21 | [
"https://math.stackexchange.com/questions/218016",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/28921/"
] | No, you are wrong with your guess. Remember that an accumulation point may not be in the set. If $A=\{1,1/2,1/3,1/4,...\}$ then $0$ (though $0\notin A)$ is an accumulation of $A$. In fact we cannot find any other accumulation point of $A$ other than $0$. | 0 is the accumulation point. By Arhimedean property, for any $\varepsilon>0$, choose $N\in \mathbb{N}$ such that $N>\frac{1}{\varepsilon}$, hence $A$-{0} intersect infinitely many points in $(-\varepsilon,\varepsilon)$ |
56,376,134 | I will read data from a file, I have only two number in file are(1.63 , -0.21),output :
```
{'y': array([-0.21]), 'x': array([1.63])}
```
I need the output like this:
```
position = {'x': 1.63 , 'y' : -0.21}
```
this my code:
```
import pandas as pd
import numpy as np
def read():
data = pd.read_csv('distan... | 2019/05/30 | [
"https://Stackoverflow.com/questions/56376134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11162983/"
] | Change this
`x0, y0 = np.array(data.ix[:,0]), np.array(data.ix[:,1])` to `x0, y0 = data.ix[:,0], data.ix[:,1]`
Essentially you need to remove the `np.array` wrapping which converting your float to an nd.array | by this way worked but it is long
```
import pandas as pd
import numpy as np
import csv
def read():
data_path = 'distance.csv'
with open(data_path, 'r') as f:
reader = csv.reader(f, delimiter=',')
# get all the rows as a list
data = list(reader)
# transform data into numpy arra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.