qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
22,615,976 | I have the following angular service.
```
angular.module('myApp')
.service('StatusService', function StatusService() {
var statusService= {
show: 'off',
on: function() {
this.show = 'on';
},
off: function() {
this.show = 'off';
}
};
return st... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22615976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1323435/"
] | I think this will be faster. It's set-based and doesn't use a cursor.
```
DECLARE @return VARCHAR(255) = ''
SELECT @return = @return + CAST(quote_ln_no AS VARCHAR) + ','
FROM dbo.quote_line_bom
WHERE quote_no = @quote_no AND component_mat_no = @mat_no
AND quote_ln_no IS NOT NULL
GROUP BY quote_ln_no
ORDER BY quote_ln... | You can just use `COALESCE` instead of a cursor:
```
declare @return varchar (255) = ''
select
@return = coalesce(@return + ' ', '') + quote_ln_no
FROM dbo.quote_line_bom
WHERE quote_no = @quote_no AND component_mat_no = @mat_no
ORDER BY quote_ln_no
```
You can join to it however you need to, I just used cross appl... |
4,192,227 | I am asking a very basic question which confused me recently.
I want to write a Scala For expression to do something like the following:
```
for (i <- expr1) {
if (i.method) {
for (j <- i) {
if (j.method) {
doSomething()
} else {
doSomethingElseA()
}
}
} else {
doSome... | 2010/11/16 | [
"https://Stackoverflow.com/questions/4192227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241824/"
] | The part
```
for (j <- i) {
if (j.method) {
doSomething(j)
} else {
doSomethingElse(j)
}
}
```
can be rewritten as
```
for(j <- i; e = Either.cond(j.method, j, j)) {
e.fold(doSomething _, doSomethingElse _)
}
```
(of course you can use a yield instead if your do.. methods return somethin... | The conditions specified in a Scala for operation act to filter the elements from the generators. Elements not satisfying the conditions are discarded and are not presented to the yield / code block.
What this means is that if you want to perform alternate operations based on a conditional expression, the test needs t... |
12,373,148 | I am considering to use an enum with a static initializer like this:
```
public enum MyEnum{
...
private static HashMap<X, Y> features;
static {
features.put(X, new (Y));
}
...
}
```
Is the HashMap going to be reinitialized every time I need a value from it? | 2012/09/11 | [
"https://Stackoverflow.com/questions/12373148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/990616/"
] | No, static block will be executed only once while class initialization. It won't execute on each call to retrieve. | No, just once.
BTW: [Guava ImmutableMap](http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/collect/ImmutableMap.html) can help:
```
private static Map<X, Y> features = ImmutableMap.of(X1, Y1, X2, Y2...));
```
Benefit:
* No need static block
* One line code
* ImmutableMap means safer, if you ... |
31,870 | Let's face it: You are *The ultimate God*
You created the universe, including its physical laws. You created the stars and alligned them in specific order. You created the solar system where the planets are in order as you wish.
You brought life to one (or more) planet(s) in that solar system and did fiddle with evol... | 2015/12/20 | [
"https://worldbuilding.stackexchange.com/questions/31870",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/2071/"
] | **Note: Many theologians, priests, rabbis, imams, and believers in God can argue that your situation mirrors life right now. I feel the Worldbuilding Stack Exchange is not the place for this religious discussion. This answer will attempt to answer your question and nothing more; rephrasing this question and posting on ... | This is perhaps less of an answer, and more, some thoughts to consider when attempting as you propose.
The main difference between you, the World Builder, and any traditional idea of a god is the reason you are making the world and its peoples.
A deity in your world would likely have in-world reasons to do what they ... |
1,351 | I'm trying to translate a poem from English to German, and the missing line is:
>
> I've heard some talk, they say you think I'm fine.
>
>
>
I've rendered *They say you think I'm fine* as *Man sagt du liebst auch mich.*
But I need something for *I've heard some talk*.
Could I use a construction using the word ... | 2011/06/13 | [
"https://german.stackexchange.com/questions/1351",
"https://german.stackexchange.com",
"https://german.stackexchange.com/users/343/"
] | My proposal:
>
> Es gibt Gerüchte, ...
>
>
>
or
>
> Ich hab davon gehört, ...
>
>
>
An elegant translation for "they say" is "es heißt":
>
> Es heißt, du glaubst es gehe mir gut.
>
>
> | >
> Es heißt,..
>
>
>
I consider a good approach
There is also
>
> Man munkelt...
>
>
>
and also one might use
>
> Sie sagen...
>
>
>
for *I've heard some talk, they say..* which implicates the speaker heard it by someone, somehow. `Sie` does not need to be determined more closely. |
52,901,324 | New to code coverage, would like to have some insights...
```
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Person other = (Person) obj;
if (... | 2018/10/20 | [
"https://Stackoverflow.com/questions/52901324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8383210/"
] | To have this class 100% tested you should create a test for every `if` and `?:` operator. Every part of the code should be tested. For instance, the first `if (this == obj)`, you should have a test where you do
```
@Test
public void testEqualsSameObj() {
MyClass sut = new MyClass(); // sut == system under test
... | The equals could have 0% coverage because you might have not included the lombok.config file with with generated annotations as true.
Set,
config.stopBubbling = true;
lombok.addLombokGeneratedAnnotation = true
in lombok.config file |
55,269,186 | I am trying to make a function that takes an equation as input and evaluate it based on the operations, the rule is that I should have the operators(\*,+,-,%,^) **between** correct mathematical expressions, examples:
```
Input: 6**8
Result: Not correct
```
**Reason:** \* has another \* next to it instead of a digit... | 2019/03/20 | [
"https://Stackoverflow.com/questions/55269186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11234125/"
] | As mentioned in comments, this is called `parsing` and requires a grammar.
See an example with [**`parsimonious`**](https://github.com/erikrose/parsimonious), a `PEG` parser:
```
from parsimonious.grammar import Grammar
from parsimonious.nodes import NodeVisitor
from parsimonious.exceptions import ParseError
gramm... | Important to first mention that `**` stands for exponentiation, i.e `6**8`: 6 to the power of 8.
The logic behind your algorithm is wrong because in your code the response depends only on whether the last digit/sign satisfies your conditions. This is because once the loop is complete, your boolean `correctsigns` defau... |
61,898,211 | I have a following testNg xml file.
Can someone please advice how to create this dynamically using java.
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test">
<groups>
<run>
<include name="PrometheusHome" />
... | 2020/05/19 | [
"https://Stackoverflow.com/questions/61898211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4284762/"
] | Adjusted core from [here:](https://seleniumtips2017.wordpress.com/2017/12/30/generating-dynamic-testng-xml-programmatically/)
```
public class DynamicTestNG {
public void runTestNGTest(Map<String,String> testngParams)
{ //Create an instance on TestNG
TestNG myTestNG = new TestNG();
//Create an inst... | [TestNG Official Documentation on Programattic Execution](https://testng.org/doc/documentation-main.html#running-testng-programmatically)
If you are looking to run your tests programmatically, it's best to read an existing testng XML file, do some runtime modifications and run it programmatically. **This would basicall... |
62,136 | Is either of the following correct?
>
> X is known difficult to implement.
>
> X is known to be difficult to implement.
>
>
> | 2012/03/24 | [
"https://english.stackexchange.com/questions/62136",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/19332/"
] | The only one of your choices that is a complete sentence is this:
>
> X is known to be difficult to implement.
>
>
>
And there are verbs which fit the other structure, such as *find*, with which the *to be* is unnecessary:
>
> X has been found [to be] difficult to implement.
>
>
>
*Know* with that usage, wh... | The first expression is possible with *difficult to implement* as an adjective, that is, a noun follows it:
>
> X is **a** known *difficult to implement* plan.
>
>
>
Note, however, the added article **a**. It is also better to hyphenate the phrase (difficult-to-implement) or find a one-word substitute, except wh... |
17,599,266 | I'm trying to count the rows with a datetime less that 10 minutes ago but the current time its being compared to seems to be 1 hour ahead so Imm getting 0 results, if I go into my table and put some fields forward an hour then I get results.
Getting results:
```
$stmt = $db->query('SELECT check_log FROM members WHERE... | 2013/07/11 | [
"https://Stackoverflow.com/questions/17599266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2558771/"
] | PHP and MySQL don't agree on the current timezone.
Pass the desired time in as a literal from PHP to SQL instead of using `NOW()`. | Always store date times in php's timezone.
One function you can particularly make use of is [strtotime](http://php.net/strtotime).
```
$now = strtotime("now"); // current timestamp
$hour_later = strtotime("+1 hour"); // hour later
$now = date("Y-m-d H:i:s", $now);
$hour_later = date("Y-m-d H:i:s", $hour_later);
``` |
23,845,935 | All,
I have a map with categories and subcategories as lists like this:
```
Map<String,List<String>> cat = new HashMap<String,List<String>>();
List<String> fruit = new ArrayList<String>();
fruit.add("Apple");
fruit.add("Pear");
fruit.add("Banana");
cat.put("Fruits", fruit);
List<String>... | 2014/05/24 | [
"https://Stackoverflow.com/questions/23845935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3671825/"
] | Iterate thought all the keys and check in the value if found then break the loop.
```
for (String key : cat.keySet()) {
if (cat.get(key).contains("Carrot")) {
System.out.println(key + " contains Carrot");
break;
}
}
``` | You have to search for the value in the entire map:
```
for (Entry<String, List<String>> entry : cat.entrySet()) {
for (String s : entry.getValue()) {
if (s.equals("Carrot"))
System.out.println(entry.getKey());
}
}
``` |
3,654,278 | Clearly for the **Pair Axiom** for any $x,y$ there esist a set $X$ such that $X=\{x,y\}$ and so for any $x$ there exist a set $X$ such that $X=\{x,x\}$. Unfortunately how prove that $\{x,x\}=\{x\}$? Indeed clearly if $\{x\}$ is a set the statement is trivially true, but unfortunately I don't know if $\{x\}$ is a set: a... | 2020/05/01 | [
"https://math.stackexchange.com/questions/3654278",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/736008/"
] | What does $X = \{x\}$ mean? It means that (1) $x$ is an element of $X$, and every element of $X$ is equal to $x$.
By the Pair axiom, there exists a set $\{x,x\}$. What does this mean? It means that (2) $x$ is an element of $X$, $x$ is an element of $X$, and every element of $X$ is equal to $x$ or equal to $x$.
But ... | I presume your version of axiomatic set theory defines sets implicitly as the objects produced by applying the axioms. So...
* The empty set, $\varnothing$, is a set by the empty set axiom.
* The powerset of $\varnothing$, which is $\{\varnothing\}$ establishes the existence of a one element set.
* For the $x$ in your... |
69,611,827 | I used Cloud Foundry a lot previously, when an app is bind with a service, all the service connection info will be injected into app's environment variables. In Kubernetes world, I think this is same for normal service.
For me, I try to use headless service to describe an external PostgreSQL using below service yaml.
... | 2021/10/18 | [
"https://Stackoverflow.com/questions/69611827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4821961/"
] | The problem was with "**cert-manager-cainjector**" pod status which was "**CrashLoopBackOff**" due to FailedMount as **secret** was not found for mounting. I have created that secret and after that it start working fine. | if you are using webhook, check if you have injected the ca, if not you could do it using:
```
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
...
annotations:
cert-manager.io/inject-ca-from: "<namespace>/<certificate_name>"
``` |
42,352,427 | I found [**this**](http://codepen.io/ccrch/pen/yyaraz) codepen showcasing a zoom and pan effect for images. As far as I can tell, the code works by assigning a background-image to each div based on its `data-image` attribute. Is there any way that I can do this on a direct `img` tag instead of a div with a background-i... | 2017/02/20 | [
"https://Stackoverflow.com/questions/42352427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Take a look at the [CodePen](http://codepen.io/anon/pen/ygddoj) now.
Think i got it to look kinda like you want it
```
<div class="tiles">
<div data-scale="1.1" class="product-single__photos tile" id="ProductPhoto">
<img class="photo" src="//cdn.shopify.com/s/files/1/1698/6183/products/bluza_dama_... | You can play with the margin to adjust the image position
```css
div{
width:100%;
height:200px;
overflow:hidden;
}
img{
width:100%;
margin:0%;
transition:0.5s;
}
img:hover{
width:120%;
margin:-10;
}
```
```html
<div>
<img src="https://cdn.pixabay.com/photo/2015/07/06/13/58/arlberg-pass... |
42,659,113 | I would like to generate equations symbolically, then sub in values with types from libraries like [`uncertainties`](https://pythonhosted.org/uncertainties/) (but could be any library with custom types) however it seems that using `.evalf(subs={...})` method fails with a rather odd error message:
```
>>> from uncertai... | 2017/03/07 | [
"https://Stackoverflow.com/questions/42659113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5827215/"
] | maybe you want more, but you can just create ordinary functions from sympy expressions and then use uncertainties
```
from uncertainties import ufloat
from sympy.abc import x
from sympy.utilities.lambdify import lambdify
expr = x**2
f = lambdify(x, expr)
f(ufloat(5,1))
Out[5]: 25.0+/-10.0
``` | My current solution is just using a loose call to `eval` which does not seem like a good idea, especially since Sympy [is fine with `Basic.__str__` method being monkey patched.](http://docs.sympy.org/dev/modules/printing.html#sympy.printing.printer.Printer)
```
import math, operator
eval_globals = {"Mod":operator.mod}... |
10,621,582 | I use a jQuery animation in my page which adds some CSS properties and I don't understand why the `margin: auto` doesn't work.
The HTML code (with style properties added by jQuery) :
```
<body style="overflow: hidden;">
<div id="tuto_wamp" style="width: 7680px; height: 923px; ">
<!-- Step 1 -->
<d... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10621582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857728/"
] | it won't work because you've set the width of `.content_tuto` to `100%;` | I have created a fiddle and added a border to visualise and solve
<http://jsfiddle.net/meetravi/Y42Pf/>
You could also have a good read of center a div in css from here
<http://stever.ca/web-design/centering-a-div-in-ie8-using-marginauto/>
Hope it helps. |
25,855,428 | Currently, when you set up tabs in Bootstrap 3, the tabs are not responsive.
This:

Turns into this:

**CSS. Fixing how it looks is easy, just removing the float, etc. at the max-... | 2014/09/15 | [
"https://Stackoverflow.com/questions/25855428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1004312/"
] | Slack has a cool way of making tabs small viewport friendly on some of their admin pages. I made something similar using bootstrap. It's kind of a tabs → dropdown.
**Demo: <http://jsbin.com/nowuyi/1>**
Here's what it looks like on a big viewport:
[](https://i.stack.imgur... | I prefer a css only scheme based on horizontal scroll, like tabs on android. This's my solution, just wrap with a class nav-tabs-responsive:
```
<div class="nav-tabs-responsive">
<ul class="nav nav-tabs" role="tablist">
<li>...</li>
</ul>
</div>
```
And two css lines:
```
.nav-tabs { min-width: 600px; }
.na... |
2,625,869 | I have a segmentation fault in the code below, but after I changed it to pointer to pointer, it is fine. What is the reason?
```
void memory(int * p, int size) {
try {
p = (int *) malloc(size*sizeof(int));
} catch(exception& e) {
cout << e.what() << endl;
}
}
```
It does not work in the m... | 2010/04/12 | [
"https://Stackoverflow.com/questions/2625869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233254/"
] | Regarding,
```
memory(p, 10); // Get the address of the pointer
```
This just sends the *p* value, not the address of the p. It sends (\*p). if the address of p is 123 and its value is 50, it sends 50 to the function.
And at the memory function it makes a new pointer with new address like 124 and it contains 50; an... | I corrected the code... read the comments and all will be clear...
```
#include <iostream>
#include <conio.h>
#include <exception>
using namespace std;
void memory(int* p, int size) { // Pointer to pointer` not needed
try {
p = new int[size];
} catch(bad_alloc &e) {
cout<<e.what()<<endl;
... |
126,613 | Challenge
=========
Given an integer `n` (where `4<=n<=10**6`) as input create an ASCII art "prison door"\* measuring `n-1` characters wide and `n` characters high, using the symbols from the example below.
---
Example
-------
```
╔╦╗
╠╬╣
╠╬╣
╚╩╝
```
The characters used are as follows:
```
┌───────────────┬─────... | 2017/06/15 | [
"https://codegolf.stackexchange.com/questions/126613",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/58974/"
] | [Stax](https://github.com/tomtheisen/stax), 23 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
=================================================================================================================================
```
÷ÅoB↔╒╢Fm|╦a⌐á5µ┐»♫÷d╕Ñ
```
[Run and debug it](https:... | Mathematica, 106 bytes
======================
```
(T[a_,b_,c_]:=a<>Table[b,#-3]<>c;w=Column;w[{T["╔","╦","╗"],w@Table[T["╠","╬","╣"],#-2],T["╚","╩","╝"]}])&
``` |
309,682 | I'm writing a HTML form that's divided in fieldsets, and I need to get the form fields from a specific fiedset in a function.
Currently it's like this:
```
function conta(Fieldset){
var Inputs = Fieldset.getElementsByTagName("input");
var Selects = Fieldset.getElementsByTagName("select");
/* Doin... | 2008/11/21 | [
"https://Stackoverflow.com/questions/309682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9835/"
] | @Ryan is on the right track if you want to use jQuery (and I would), but I'd suggest something more along the lines of:
```
$('fieldset#fieldset1 > input[type=text]').each( function() {
... do something for text inputs }
);
$('fieldset#fieldset1 > input[type=radio]').each( function() {
... do something f... | Haven't tested this and don't know how it would work, but you could use JQuery here to select all the elements into a JQuery object
```
//$("input select textarea").each(function() {
$(":input").each(function() { //even better
// do stuff here
});
```
this would at least cleanup the code, although you would stil... |
21,934,275 | I've a problem when access to value for `aaData` in "fnFooterCallback".
This is the output of log:
>
> aaData: [object Object],[object Object],[object Object],[object Object]
>
>
>
Really, I've 4 rows to show in datatable, but I can't access these values to show totals in dataset.
I try to use this:
```
"fnDr... | 2014/02/21 | [
"https://Stackoverflow.com/questions/21934275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3036384/"
] | You could draw that as a filled UIBezierPath (which is a UIKit wrapper on a CGPath).
You'd open a path, draw a sequence of straight lines and cubic or quadratic bezier curves, then close the path. Then you'd draw it as a filled path.
Once you have the path created, you could draw it with a single call. | A couple of alternatives, as Duncan seems to have answered this.
One option would be to dynamically scale a high resolution image.
There is one caveat with this approach: you should not scale anything below 1/2 of the original size, otherwise the interpolation tends to glitch.
So you would need to store image at say... |
292,101 | I just learned something interesting. The add method for the javascript select object in IE 6 takes only one parameter. It throws an error when you pass it two parameters which I believe is the [standard](http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html.html), even as [documented](http://msdn.microsoft... | 2008/11/15 | [
"https://Stackoverflow.com/questions/292101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25191/"
] | You shouldn't be using the Select.add method, as it's broken in IE, and there are better ways to add options dynamically (see <http://msdn.microsoft.com/en-us/library/ms535921(VS.85).aspx>)
I have had the same problem, and have found that the best way is to use the Node.insertBefore method. This has the advantage of w... | I did some research myself using all permutations and combinations of creating an option object and I hope this is the best possible way by which we can add options to select in a browser neutral way:
```
function populateSelectField()
{
document.frmMain.fldSelect.options.length = 0;
document.frmMain.fldSelec... |
62,762,083 | I am using ChromeDriver and I would like it to click every button on the page that contains a specific class name.
```cs
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
ChromeDriverService chromeDriverService = ChromeDriverService.CreateDefaultService();
chromeDriverService.HideCommandPromptWindow = true;
Chrome... | 2020/07/06 | [
"https://Stackoverflow.com/questions/62762083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11229214/"
] | Try with `FindElements` instead of `FindElement`
```cs
IList<IWebElement> list= driver.FindELements(By.ClassName("some-class-name");
foreach (IWebElement element in list)
{
element.Click();
}
``` | ```cs
List<WebElement> elementName = driver.findElementsBy.ClassName("some-class-name"));
```
This will return a list of `WebElements` which you can iterate over in a foreach statement, performing `.click()` on each. |
28,640,275 | This must be a silly question but with my logic i can't understand why it doesn't exit.
This is my loop:
```
Random _random = new Random();
int num;
char let;
string TempName = "~";
string sTempPath;
do
{
while (TempName.Length < 12)
{
num = _random.Next(0, 26);
let = (char)('a' + num);
... | 2015/02/20 | [
"https://Stackoverflow.com/questions/28640275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4496821/"
] | Currently your loop runs *as long as* `File` doesn't exist. If you wanna stop when the file doesn't exist then change your condition to `File.Exists` by removing negation operator (!). | Your condition is incorrect.
`while(File.Exists(sTempPath))` |
200,686 | I'm investigating options for a small corporate virtualisation setup. We specialise in scientific computing and would like to consolidate our resources. We are keen on KVM, since it looks like it performs well with multiple vCPU per VM.
I'm confused by the RedHat KVM offering. We don't want to virtualise everyone's ex... | 2010/11/11 | [
"https://serverfault.com/questions/200686",
"https://serverfault.com",
"https://serverfault.com/users/43873/"
] | Certainly. [LTSP](http://www.ltsp.org/) can be served from a virtual machine running on top of RHEL, and then you can have the virtual desktops connect via XDMCP to another virtual machine running on the server that does the actual hard work. | Your environment seems to be a good match for NX/NoMachine - See here: <http://www.nomachine.com/> |
437,108 | I have just started studying rotational kinematics. | 2018/10/27 | [
"https://physics.stackexchange.com/questions/437108",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/210963/"
] | when electrical current flows through a circuit component (easy example: a resistor), the resistor dissipates power; as it does, the voltage decreases steadily from the high-voltage side to the low-voltage side. this decrease in voltage is called the voltage drop.
In the case of a resistor of resistance R with a volt... | Voltage is a term which is sometimes confusing because people use it different ways in different contexts. Technically, voltage is the *difference* in electrical potential between two points. Electric potential is a physics concept which describes how much potential energy will be added or removed from a system if a un... |
69,497,078 | I want to check if the current `id` equals last `id` +1, (this should work for any number of similar dicts added in the list)
### Code
```sh
listing = [
{
'id': 1,
'stuff': "othervalues"
},
{
'id': 2,
'stuff': "othervalues"
},
{
'id': 3,
'stuff': "ot... | 2021/10/08 | [
"https://Stackoverflow.com/questions/69497078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17107125/"
] | To check if all the `id`s are in a sequence we can use [`enumerate`](https://docs.python.org/3/library/functions.html#enumerate) here.
```
def is_sequential(listing):
start = listing[0]['id']
for idx, item in enumerate(listing, start):
if item['id'] != idx:
return False
return True
``` | When you do `for item in some_list`, `item` is *the actual item* in that list. You can't get the previous item by `item[-1]`.
So in your case, `item` is a dictionary that has the keys `'id'` and `'stuff'`. Obviously, no key called `-1`, so you get a `KeyError`.
You can iterate over two slices of the list after using ... |
2,386,718 | Ok, I'm trying to use the FaceBox() plugin for jQuery along with the jQuery UI datepicker().
I've got it to bind to the lightbox'd inputs on the first appearance of the lightbox, but it's not working afterwards.
I'm doing the following:
````
$(function() {
$('.jQueryCalendar').live('click', function () {
... | 2010/03/05 | [
"https://Stackoverflow.com/questions/2386718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/70847/"
] | Try this and see what happens:
```
$(function() {
$('.jQueryCalendar').live('click', function () {
$(this).datepicker('destroy').datepicker({showOn: 'both'}).focus();
});
});
```
If you're using jQuery UI 1.7.2 with jquery 1.4, some effects destroy widgets, it fading, etc may be causing datepick... | its possible that the datepicker is behind the box...
i had also the same problem a time ago.
put this in a css file, and that did the trick for me.
```
#ui-datepicker-div
{
z-index:9999999;
}
``` |
320,666 | Every time I try to kill the x-server,
```
sudo service lightdm stop
```
so that I can install the latest Nvidia drivers, I get an error message.
```
stop: Unknown instance:
```
What am I doing wrong? | 2013/07/16 | [
"https://askubuntu.com/questions/320666",
"https://askubuntu.com",
"https://askubuntu.com/users/101532/"
] | 1. Use `ctrl`+`alt`+`F1` to switch to terminal,
2. login
3. run `sudo service lightdm stop`, lightdm and xserver should be stopped now (check with `ctrl`+`alt`+`F7`, which is your current xorg session, it should not show any desktop now)
4. do your things
5. run `sudo service lightdm start` to start lightdm and xorg ag... | Ok had the GTX 970 installation Problem under Ubuntu 14.04 too.
Sometime i was able to start Ubuntu with the standart drivers and sometime not.
However, this should hopefully fix the Problem:
After switching from IGP (I7 4770 with HD4600) to GTX970 in Biosi got an error
with some Xorg Gui.
However you can not install... |
26,466,334 | I am trying to get a list of users from the database that have ALL the tags in a criteria.
The User entity has a many-to-many association to a Tag entity.
The or version where just one of the tags have to match is working using the following code
```
$tagIds = array(29,30);
$this->createQueryBuilder('u')
->selec... | 2014/10/20 | [
"https://Stackoverflow.com/questions/26466334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374914/"
] | After `cin>>t`, there is a newline remaining in the stream, then the newline will be assigned to `s`, so `cout<<s` seems to print nothing(Actually, it prints a newline).
add `cin.ignore(100, '\n');` before first `getline` to ingore the newline. | The newline from `cin >> t;` after pressing enter is still in std::cin when `getline(cin,s)` is called, resulting in s being empty. The string you enter is actually being stored in p. Try using a different capture method or flushing the cin buffer before using it again. |
38,588 | Would the above mentioned microphone work with a laptop,to create audio for dubbing and podcasts?if not,then what do you guys suggest? | 2016/03/21 | [
"https://sound.stackexchange.com/questions/38588",
"https://sound.stackexchange.com",
"https://sound.stackexchange.com/users/-1/"
] | You would create stems Dialogue, Ambience, Foley, SFX for the entire length of the film | You simply bounce it down to either a stereo file or If it's surround you need to run it through a surround sound encoder so the resulting wav will know its multiple panned channels. You only need to do stems if it's required for being redubbed in a foriegn language. |
66,418,092 | I'm learning javascript and AngularJS. I made this little code for something (we made it in AngularJS format), and we need to make this same logic but using only javascript.
The color of a botton changes to other when it's available or unavailable.
Can someone help me with this and tell me the logic?
```
$scope.save... | 2021/03/01 | [
"https://Stackoverflow.com/questions/66418092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15305215/"
] | It is not Angular but jQuery apart from the $scope which I guess is part of some Angular scope
A plain JS version could be
```
const saveButton = () => {
const cl = document.getElementById("saveButtonPics").classList;
cl.remove("attachment-space-available")
cl.add("attachment-boton-guardado");
};
```
If you ... | In angularjs we need change model to change view
```
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<button ng-click="saveButton()" ng-class="savebtnclass">Save Pics</button>
</div>
<script>
var a... |
63,942,280 | I'm fetching data out of a mapping API (which returns JSON) and luckily for me as a JSON noob, the object I've been wanting to manipulate in the past has been named with a shortcut.
However, today I want to get data from an object which is named with a randomly generated number, which I won't know the name of when I f... | 2020/09/17 | [
"https://Stackoverflow.com/questions/63942280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8805457/"
] | This should do it:
```
Object.values(data.areas)
.filter(a=>a.type_name=="Scottish Parliament constituency")
.map (a=>a.name)
```
```js
const data={
"wgs84_lat": 55.861509653107056,
"coordsyst": "G",
"shortcuts": {
"WMC": 14425,
"ward": 151284,
"council": 2579
},
"wg... | In Addition to above [comment](https://stackoverflow.com/a/63942457/10102695), You can use "find" if you want to return once the first match occur!
```
const element = Object.keys(x.areas).find(item => x.areas[item].type_name === "Scottish Parliament constituency");
const obj = x.areas[element]; //Complete Object on ... |
45,176,273 | I need to run command line from a c# program. I want to set the directory of the command line window. To do so, I am using the following code:
```cs
Process.Start("cmd", @"cd C:\Users\user1\Desktop");
```
When I run the c# program, a command line window is opened, but the directory is not set to C:\Users\user1\Deskt... | 2017/07/18 | [
"https://Stackoverflow.com/questions/45176273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8260918/"
] | To set the working directory, you can also do it using the [ProcessStartInfo](https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo(v=vs.110).aspx) like this:
```
using System;
using System.Diagnostics;
namespace so45176273
{
internal class Program
{
private static void Main(str... | I believe this is the answer you are looking for.
```
Process.Start("cmd", @"/c cd C:\Users\user1\Desktop");
``` |
13,620,267 | I'm playing with the add-member cmdlet and found the following three piece of code does not give me the same result. Any anyone explain why? Thanks.
```
################################################################
$hash = @{"a" = "aa"; "b" = "bb"}
$result = new-object psobject
$result | Add-Member $hash
$result
... | 2012/11/29 | [
"https://Stackoverflow.com/questions/13620267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/170931/"
] | 1st one works because $result psobject creation is performed before the Add-Member. The second 2 do not work because $result is null. Code below ensures the order of statement evaluation.
```
################################################################
$hash = @{"a" = "aa"; "b" = "bb"}
($result = new-object psobj... | $hash is probably binding to the wrong parameter. The correct way would be to decide on the member type (NoteProperty in this example), a Name and value:
```
$result | Add-Member -MemberType NoteProperty -Name MyHash -Value $hash
```
If you assign the result to a variable add the -PassThru switch:
```
$result = new... |
3,265 | So I flagged [this question](https://aviation.stackexchange.com/questions/38709/why-dont-pilots-or-passengers-for-that-matter-yet-seem-to-really-like-auto) as being opinion based and the flag got declined, yet the question is currently [on hold] for being opinion based.
Has something gone wrong with the system?
Decl... | 2017/06/09 | [
"https://aviation.meta.stackexchange.com/questions/3265",
"https://aviation.meta.stackexchange.com",
"https://aviation.meta.stackexchange.com/users/15982/"
] | Based on [the link to a meta.SO post](https://meta.stackoverflow.com/a/284872/6650102) given by Aurora0001 in the comments, and the fact that [the review](https://aviation.stackexchange.com/review/close/23980) shows that nobody in the queue agreed with you, the system has "declined" automatically this flag.
The questi... | Four possible reasons.
1. Declined by mistake. It happens.
2. A mod has a vendetta against you. It also happens. Often.
3. Some mods think flagging for close reasons should not be done and blanket decline. This is wrong.
But from the looks of it,
4. it timed out, because the question was closed by user votes, makin... |
374,886 | I'm trying to setup Spring using Hibernate and JPA, but when trying to persist an object, nothing seems to be added to the database.
Am using the following:
```
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="url" value="${jdbc.url}"/>
<property name="driverClassName" va... | 2008/12/17 | [
"https://Stackoverflow.com/questions/374886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32713/"
] | I actually came across another way that this can happen.
In an injected EntityManager, no updates will ever occur if you have persistence.xml specified like this:
`<persistence-unit name="primary" transaction-type="RESOURCE_LOCAL">`
You need to remove the transaction-type attribute and just use the default which is... | Probably you're keeping the transaction active and it is not calling "commit" until other methods running supporting the active transaction end (all "voting" for commit and none for rollback.)
If you're sure that the entity you're going to persist is ok you could probably do this:
```
@TransactionManagement(Transacti... |
30,252,911 | The following `select` query is to search a keyword 'law' from multiple tables `tbl_books`, `tbl_author` and `tbl_books_subject`
```
SELECT *
FROM tbl_books p, tbl_books_author d, tbl_books_subject m
WHERE p.title = 'law'
OR d.author = 'law'
OR m.subject = 'law'
LIMIT 0,30
```
This query is giving error. Pleas... | 2015/05/15 | [
"https://Stackoverflow.com/questions/30252911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4902657/"
] | You need three separate SELECTs (and probably a wildcard search):
```
SELECT *
FROM tbl_books
WHERE title LIKE '%law%'
LIMIT 0,30
SELECT *
FROM tbl_books_author
WHERE title LIKE '%law%'
LIMIT 0,30
SELECT *
FROM tbl_books_subject
WHERE title LIKE '%law%'
LIMIT 0,30
```
If you return compatible results you might UN... | You can achieve that in single query but you need to have some foreign key in other tables. Here check the code below.
```
SELECT b.*, ba.*, bs.* FROM tbl_books as b
FULL OUTER JOIN tbl_books_author as ba ON ba.book_id=b.id
FULL OUTER JOIN tbl_books_subject as bs ON bs.book_id=b.id
WHERE b.title LIKE 'law' OR ... |
19,962,809 | I need help please - here's a little history..
I have a google schedule - <https://docs.google.com/spreadsheet/ccc?key=0ArmKEmhue9OgdEFwMHBldFpGenNVdzJUQThCQU9Qcmc&usp=sharing>
Within that schedule there are numerous sheets but the ones that I was hoping to get help with is the Form Responses 1 and PROJECTS sheet
I ... | 2013/11/13 | [
"https://Stackoverflow.com/questions/19962809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2540437/"
] | Don't use inline JS to do that. Instead use event delegation:
```
$(document).on('click', '.closeAlerts', function(){
$(this).parent().remove();
});
``` | You can set `this` as parameter in function
```
<div class="closeAlerts" onclick="closeAlert(this)">Dismiss</div>
```
And `this` will be your `div` object.
But I'm not reccomend you to use embedded javascript code in html elements. Try to separate js code from html. |
16,195 | In [a review of an entry level DSLR](http://www.dpreview.com/reviews/nikond3100/page19.asp), I found this:
>
> [this] is an excellent DSLR but make clear that a DSLR is no longer the only way to gain large sensor image quality at this price [around $500]
>
>
>
What are the alternatives the reviewer is alluding to... | 2011/10/05 | [
"https://photo.stackexchange.com/questions/16195",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/534/"
] | To specifically answer your question "What are the alternatives the reviewer is alluding to?"
If you go to [this](http://www.dpreview.com/reviews/nikond3100/page16.asp "Page 16 - compared to (JPEG)") page of the review, you will see that dpreview have compared the image quality with the following non-dslr cameras:
* ... | what it means is that something has a product to sell that's priced like a DSLR but isn't a DSLR, and is trying to convince people to look for his product rather than a DSLR who are susceptible to "new and improved" as the main reason to buy something different from the established standard. |
60,406,254 | ```cpp
#include <iostream>
struct A{
A(int){
}
};
struct B{
B() = default;
B(A){
}
B(B const&){}
B(B&&){}
};
int main(){
B b({0});
}
```
For the given codes, the candidate functions are:
```
#1 B::B(A)
#2 B::B(const B&)
#3 B::B(B&&)
```
According to the standard, for #1, the object... | 2020/02/26 | [
"https://Stackoverflow.com/questions/60406254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11796722/"
] | pass argument to withInput() $request->all() like this
```
return Redirect::back()->withErrors($Validator)->withInput($request->all());
``` | use **Validator** to handle errors - check this - [LINK](https://laravel.com/docs/6.x/validation)
```
use Validator;
$validator = Validator::make($request->all(),[
'username' => 'required|unique:userlists,username|max:20',
'email' => 'required|email|unique:userlists,email|max:20',
'... |
37,195 | I remember reading somewhere that to evacuate a person is a medical procedure, and not something to be done during an earthquake. (I thought it was in Fowler, but I just looked and couldn't see it). The point is that it is the *building* that is being evacuated, not the people. "Evacuate" comes from the Latin word for ... | 2011/08/08 | [
"https://english.stackexchange.com/questions/37195",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/879/"
] | I'd say that you are [rescuing](http://dictionary.reference.com/browse/rescue) them, or helping them [exit](http://dictionary.reference.com/browse/exit) the building. | As others have noted, it is completely correct to say, "You evacuated me from the building." I just checked two dictionaries and both list "to withdraw inhabitants from a threatened area" (with slightly different wording) as one of the definitions.
So when the questioner says that this usage is incorrect and the perso... |
147,621 | I want to get the output
[](https://i.stack.imgur.com/ZZNWK.png)
from the code
```
Do[
Print[
Flatten[Table[j + k + s + l, {j, -1, 1}, {k, -2, 1}]]],
{s, -1, 1}, {l, -2, 1}]
``` | 2017/06/05 | [
"https://mathematica.stackexchange.com/questions/147621",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/49153/"
] | Don't use `Do` and `Print`; use `Table` with `Flatten` or maybe `ArrayReshape`.
```
m =
Flatten[
Table[
Flatten[Table[j + k + s + l, {j, -1, 1}, {k, -2, 1}]],
{s, -1, 1}, {l, -2, 1}],
1]
m // MatrixForm
```
[](https://i.stack.imgur.com/PA31M.png)
... | Equivalent output:
```
Array[Plus, {3, 4, 3, 4}, {-1, -2, -1, -2}] ~Flatten~ {{3, 2}, {1, 4}}
```
Or for the particular case illustrated:
```
Array[Plus, {3, 4, 3, 4}] ~Flatten~ {{3, 2}, {1, 4}} - 10
```
$\left(
\begin{array}{cccccccccccc}
-6 & -5 & -4 & -3 & -5 & -4 & -3 & -2 & -4 & -3 & -2 & -1 \\
-5 & -4 & -... |
48,872,361 | I'm using Sonatype Nexus as a Docker Registry and after a while, it got really big (new image with every CI build and some old projects).
I tried using "Purge unused docker manifests and images" task, but it doesn't seem to do anything. | 2018/02/19 | [
"https://Stackoverflow.com/questions/48872361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6657236/"
] | You will need to setup Cleanup Policy.
[](https://i.stack.imgur.com/1VKYh.png) | Create a cleaning policy (for example: 15 days after modification)
- Caveat: `docker push` of the same hash is *not* modification
For each your registry (Nexus calls it "repository of type Docker"):
* Setup the cleaning policy of your choice
* The cleanup task
+ Create
+ Run until finish
+ Check the nexus3.log fi... |
56,764,028 | would like to identify the number of firms that start and end each month. The goal is to say by column how much firms start and end.
My data looks like this, with many more rows and columns.
```
Firm Return_1990_01 Return_1990_02 Return_1990_03 Return_1990_04 Return_1990_05
#1 fg23 NaN NaN ... | 2019/06/26 | [
"https://Stackoverflow.com/questions/56764028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3962801/"
] | Another way to represent this with column names using `tidyverse`. We `gather` the data into long format and select only first and last value for each row. Create a new column (`temp`) which holds `"Start"` and `"End"` for each group and `spread` it to wide format.
```
library(dplyr)
library(tidyr)
df %>%
mutate(r... | With `tidyverse`, we can do this without any reshaping with `pmap`. Find the `names` of the elements that are not NaN with `which`, get the `first` and `last` column names
```
library(tidyverse)
df %>%
transmute(Firm, start_end = pmap(.[-1], ~
which(!is.nan(c(...))) %>%
names %>%
range %>%
... |
15,967,652 | I have an apache httpd server, say **server1\* (publicly exposed) that is acting as load balancer for some jboss servers(behind firewall) using mod\_cluster. Now I want to install my static content (images/css/htmls) and probably some cg-scripts on a couple of apache servers, say \*\*server2** and **server3** (behind f... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15967652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2273375/"
] | Well, you just add a ProxyPass setting. mod\_cluster is compatible with ProxyPass, so you can use both.
For instance, if I would like gif images to be served by httpd, not by AS7, I can add:
```
ProxyPassMatch ^(/.*\.gif)$ !
```
Furthermore, if you set
```
CreateBalancers 1
```
mod\_cluster won't create proxi... | I had the same issue where in we were using Apache HTTP server for static content and JBOSS AS 7 server for dynamic contents (the JSF web app).
So adding the below property at the end of Load modules tells
```
CreateBalancers 0
```
Tells to **"0: Create in all VirtualHosts defined in httpd."**
More at: <http:/... |
8,500,309 | How to add a div after all dd tags through jquery ?
```
$(document).ready(function(){
$('dd').xyz('<div class="clear"></div>'); // what will be this xyz function
});
```
I have the following HTML structure -
```
<dl>
<dt>A</dt>
<dd>AA</dd>
<dt>B</dt>
<dd>BB</dd>
</dl>
``` | 2011/12/14 | [
"https://Stackoverflow.com/questions/8500309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1078254/"
] | It should be like - `$('<div class="clear" />').insertAfter('dd');` | ```
$(document).ready(function(){
$('dd').after('<div class="clear"></div>');
});
```
Here is example, I've created jsfiddle <http://jsfiddle.net/VWYf4/> |
27,855 | I am reading up on the `Carhart Four-Factor` model.
Let's say there a regression of stock returns on alpha, `RM-RF`, `SMB` (small minus big stocks returns), `HML` (high minus low value stock returns) and `UMD` (up minus down trend stocks).
Let's say my portfolio consists of mostly high value stocks (Apple, Google),... | 2016/06/29 | [
"https://quant.stackexchange.com/questions/27855",
"https://quant.stackexchange.com",
"https://quant.stackexchange.com/users/22366/"
] | Factor models tell you how the returns of your portfolio are related to the returns of the models' factors. In this case, after controlling for the relation with the size, momentum, and market factors, your portfolio is positively related to the value factor. We often say it *loads on* the value factor (meaning it is e... | your modeling was similar to the original paper? in this case a negative momentum coeficient is telling you that for this timeframe the winners of the last period are not the winners in this period. |
13,899,746 | I have the following command:
```
find . -type d -mtime 0 -exec mv {} /path/to/target-dir \;
```
This will move the directory founded to another directory. How can I use `xargs` instead of `exec` to do the same thing. | 2012/12/16 | [
"https://Stackoverflow.com/questions/13899746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1203997/"
] | If you've got GNU [`mv`](http://www.gnu.org/software/coreutils/manual/html_node/mv-invocation.html) (and `find` and `xargs`), you can use the `-t` option to `mv` (and `-print0` for `find` and `-0` for `xargs`):
```
find . -type d -mtime -0 -print0 | xargs -0 mv -t /path/to/target-dir
```
---
Note that modern versio... | With [BSD xargs](http://www.unix.com/man-page/freebsd/1/xargs/) (for **OS X** and FreeBSD), you can use `-J` which was built for this:
```
find . -name some_pattern -print0 | xargs -0 -J % mv % target_location
```
That would move anything matching `some_pattern` in `.` to `target_location`
With [GNU xargs](http://w... |
2,792,932 | I've got some settings saved in my Settings.bundle, and I try to use them in `application:didFinishLaunchingWithOptions`, but on a first run on the simulator accessing objects by key always returns `nil` (or 0 in the case of ints). Once I go to the settings screen and then exit, they work fine for every run thereafter.... | 2010/05/08 | [
"https://Stackoverflow.com/questions/2792932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | If I got your question right, in your app delegate's - (void)applicationDidFinishLaunching:(UIApplication \*)application, set the default values for your settings by calling
registerDefaults:dictionaryWithYourDefaultValues
on [NSUserDefaults standardUserDefaults]
```
- (void)applicationDidFinishLaunching:(UIApplicatio... | >
> Isn't the point of using default
> values in the Settings.bundle to be
> able to use them without requiring the
> user to enter them first?
>
>
>
No. The point of the settings bundle is to give the user a place to edit all 3rd Party app settings in a convenient place. Whether or not this centralization is r... |
456,221 | [](https://i.stack.imgur.com/2AL7i.jpg)
So I have a bunch of these FFC connectors shown here, and a lot of the middle pins are actually ground pins (highlighted in green). I have a multi-layer board, so I want to route all these grounds to an internal... | 2019/09/05 | [
"https://electronics.stackexchange.com/questions/456221",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/230289/"
] | Take a look at a randomly chosen old op-amp, for example the [TL081](http://www.ti.com/lit/ds/symlink/tl082.pdf). The single-amp version will often have two pins named "offset null" or similar.
This is because they have a fairly large offset voltage that can cause problems if you want to amplify DC levels, and the off... | It means adjusting the op amp input offset voltage error towards zero with components external to the op amp, such as trimmer potentiometer or resistors connected to op amp adjustment pins. |
5,701,281 | is there any way to route a ServiceMix message by operation specified in that message?
I've tried googling it but was unable to find any way to complete this simple task, maybe I am doing it wrong in first place?
I've got an adapter that dispatches 2 types of messages. 2 other adapters have to catch them and give a r... | 2011/04/18 | [
"https://Stackoverflow.com/questions/5701281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43677/"
] | awk can take a regular expression as field separator, so use either parenthesis as the field separator and just emit the 2nd field:
```
awk -F'[()]' '{print $2}' filename
``` | You can remove everything from beginning of line until the first `(` and from (including) the last `)` till the end of line with `sed`:
```
sed -r 's/^[^(]*\(.*)\)[^)]*$/\1/'
``` |
3,160,866 | Given $A,B \in P(N)$ We mark $\overline{\sim}$ as
$$A\overline{\sim} B = \{x+y : \langle x,y\rangle\in A\times B\}$$
Now, order R will be as following
$ARB$ iff $\exists M\in P(N)$ so $A\overline{\sim} M=B$.
The question is
R is reflexive? symmetric? anti-symmetric? transitive?
I think R is partial order, i.e reflexi... | 2019/03/24 | [
"https://math.stackexchange.com/questions/3160866",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/536356/"
] | You got off to a great start with your transitivity proof!
Note that $M=T\overline{\sim} S.$ Having chosen $q\in A\overline{\sim}M,$ we know that $q=a+m$ for some $a\in A$ and some $m\in M.$ Since $M=T\overline{\sim} S,$ then $m=t+s$ for some $t\in T$ and some $s\in S,$ whence $$q=a+(t+s)=(a+t)+s.$$ Since $a\in A$ and... | The usual notation for $\overline{\sim}$ is +.
Show + is associative and communitive.
Clearly, A + {0} = A, so ARA.
Assume ARB, BRC. Thus exists K,L with A + K = B, B + L = C.
As A + (K + L) = (A + K) + L = B + L = C, ARC. |
67,831,594 | I showed data using below angular functions
```
availableLockers = [
{
"lockerCode": "L01",
"allocStatus": "alloc"
},
{
"lockerCode": "L02",
"allocStatus": "un-alloc"
},
{
"lockerCode": "L03",
"allocStatus": "un-alloc"
},
{
"lockerCode": "L04",
... | 2021/06/04 | [
"https://Stackoverflow.com/questions/67831594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14753393/"
] | It's better to create a dictionary for the count of each `allocStatus` using [reduce](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
**and then use it where ever you want with O(1) time complexity**
```js
availableLockers = [
{
lockerCode: "L01",
allocStatus: "al... | **In Html File**
```
<div *ngFor="let locker of availableLockers; let i=index;">
{{locker.lockerCode}}
</div>
<div>{{alloc}}</div>
<div>{{unAlloc}}</div>
<div>{{tempAlloc}}</div>
```
**In TS file**
```
alloc:number = 0;
unAlloc:number = 0;
tempAlloc:number = 0;
ngOnInit(){
availableLockers.fo... |
2,843,455 | Is there a way to resolve mathematical expressions in strings in javascript? For example, suppose I want to produce the string "Tom has 2 apples, Lucy has 3 apples. Together they have 5 apples" but I want to be able to substitute in the variables. I can do this with a string replacement:
```
string = "Tom has X apples... | 2010/05/16 | [
"https://Stackoverflow.com/questions/2843455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/104421/"
] | The only way I can think of to achieve this would be a templating engine such as [jTemplates](http://jtemplates.tpython.com/). Also see the answers to [this](https://stackoverflow.com/questions/552934/what-javascript-templating-engine-do-you-recommend) SO question. | In ES6 you can now use [template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings):
var X = 2, Y = 3;
string = `Tom has ${X} apples, Lucy has ${Y} apples. Together they have ${X+Y} apples`; |
5,262,159 | How would I go about using an `IF` statement to determine if more than one parameter has a value then do some work, if only one parameter has a value then do other work. Is this possible with the SQL if? I am just trying to determine if one parameter has a value or if multiple parameters has value, because if so then I... | 2011/03/10 | [
"https://Stackoverflow.com/questions/5262159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/595208/"
] | In SQL to check if a parameter has a value, you should compare the value to NULL.
Here's a slightly over-engineered example:
```
Declare @Param1 int
Declare @param2 int = 3
IF (@Param1 is null AND @param2 is null)
BEGIN
PRINT 'Both params are null'
END
ELSE
BEGIN
IF (@Param1 is null)
PRINT 'param1 i... | You can check the parameter values for NULL values. But it seems like to me at first blush you should check the parameters BEFORE going to the SQL...
Once you know what you need to do then call that SQL or Stored Procedure.
If you do it that way you can simplify your SQL because you only pass the parameters you reall... |
86,743 | I am involved with the development of innovative software. The development is innovative since we don't know how to develop it and what algorithm should we use to implement and nobody else did it before. The process consists of several stages of studying books/papers, suggesting algorithms, writing prototypes and compa... | 2011/06/24 | [
"https://softwareengineering.stackexchange.com/questions/86743",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/28844/"
] | >
> Is there any project management software for these types of projects?
>
>
>
No.
There's no "project" until you have a firmly-defined goal.
Exploration and Research aren't really amenable to project management. It's exploration of the unknown.
If you don't know where you're going, you can't manage the proce... | "The best agile technique" is a contradiction. The [Agile Manifesto](http://agilemanifesto.org/) clearly says "Individuals and interactions over processes and tools", so if you're going to be agile in any real sense you need to pick processes and tools based on the individuals that will be using them. |
11,151,228 | I really like Python because I can use its shell to explore things.
Is it possible to do the same while developing a django app?
I mean, is it possible to do:
```
def process_request(request):
...
if(request.FILES != none):
__builtins__.debug_request = request
showPythonShell();
...
```
... | 2012/06/22 | [
"https://Stackoverflow.com/questions/11151228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/269334/"
] | Usage of selenium-webdriver behind proxy has browser related specific. In short, you need to find a way of passing proxy settings to the browser instance created by webdriver.
Below is a code that works with Firefox.
```
#Firefox keeps proxy settings in profile.
profile = Selenium::WebDriver::Firefox::Profile.new
pr... | ```
require 'rubygems'
require 'selenium-webdriver'
ENV['NO_PROXY']="127.0.0.1"
driver = Selenium::WebDriver.for :firefox
driver.get "http://google.com"
``` |
2,822,616 | We are given angles A and B (70 and 60 respectively). Also AΓ=ΒΔ. Ζ and E are midpoints of AB and ΓΔ respectively.
I also drew some bigger circles with radius AH and ΒΘ, trying to see some pattern but with no luck. Geogebra shows that the required angle is 95 degrees but I don't have any clue on how to prove it :(
Ob... | 2018/06/17 | [
"https://math.stackexchange.com/questions/2822616",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/330814/"
] | Let us shift this problem to the Coordinate Plane with $A$ at the origin, $AB$ on the $X$ axis, and $AB=2\alpha$. Thus $A\equiv(0,0)$ and $B\equiv(2\alpha,0)$. Also $A\Gamma=B\Delta=r$. Lastly let $\theta=\angle EZB$
$$$$
The equation of $A\Gamma$ is $y=x\tan70^{\circ}$ and the equation of $B\Delta$ is $y=x\tan120^{\ci... | Alt. hint: define a complex plane with $\,Z=0, B=1, A=-1, A\Gamma=B\Delta=\lambda \in \mathbb{R}^+\,$.
Let $\,\alpha=70^\circ=\frac{7 \pi}{18}\,$, $\,\beta=60^\circ=\frac{\pi}{3}\,$, then $\,\Gamma = -1 + \lambda e^{i\alpha}\,$ and $\,\Delta = 1 + \lambda e^{i(\pi - \beta)}\,$.
The midpoint of $\Gamma\Delta$ is $\re... |
5,197,274 | I have three domain objects:
Child, Classroom and ChildClassroom. Here are lists of each:
```
var childrens = new List<Child>() {
new Child() { ChildId = 1, FirstName = "Chris" },
new Child() { ChildId = 2, FirstName = "Jenny" },
new Child() { ChildId = 3, FirstName = "Dave" },
};
var classrooms = new L... | 2011/03/04 | [
"https://Stackoverflow.com/questions/5197274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/86259/"
] | ```
var kidsInClass = (
from kid in childrens
from c in classrooms
select new {
ChildID = kid.ChildId,
classrooms = (
from cc in childclassrooms
select new {
ClassroomID = c.ClassroomId,
Occupied = cc.ChildId == kid.ChildId
... | You could do this:
```
var childClassroomRelationships = (
from child in children
select {
childid = child.ChildId,
classrooms = (
from classroom in classrooms
select new {
classroomId = classroom.ClassroomId,
occupied = childclassrooms.An... |
49,131,536 | I have `click` event with jquery and i want to know how is selector clicked...
```
$('#parent').on('click','#child',function(){
//....
});
<div id="parent">
<div id="child">
</div>
</div>
```
**$(this)** is `#parent` or `#child` ? | 2018/03/06 | [
"https://Stackoverflow.com/questions/49131536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3162975/"
] | The context `this` is related to the event target. In your case is `#child`.
Further, you don't need event delegation when the `id` is available, so bind that event as follow:
```
$('#child').on('click',function(){
//....
});
``` | This is called `Event delegation` which allows us to attach a single event listener, to a parent element, that will fire for all descendants matching a selector, whether those descendants exist now or are added in the future.
So, `$(this)` here is always referring to the clicked child element to a parent element, whic... |
8,410,749 | Basically this following code will check whether two different binary trees have the same members of integer. The way that I'm supposed to do it is to store the integer from tree to array and then compare the array.
Here is the code that put the integers to array
```
private static int toarray (btNode t, int[] a, int... | 2011/12/07 | [
"https://Stackoverflow.com/questions/8410749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1084925/"
] | Hi you can use the recursion for comparing two binaryTrees the concept may like follow
```
int compareTree(tree1, tree2) {
//if both are empty the return true
if (tree1==NULL && tree2==NULL) return(true);
// if both non-empty then compare them
else if (tree1!=NULL && tree2!=NULL) {
return
//compare values an... | Try using `Arrays.deepEquals(a1, a2)` for the array comparison. It should work.
You will however need to create an Integer array instead of int since this function works on Object[]. |
2,286,245 | >
> Suppost that $a,b,c,d$ are real numbers such that $$a^2+b^2=1$$ $$c^2+d^2=1$$ $$ac+bd=0$$
>
>
>
I've to show that $$a^2+c^2=1$$ $$b^2+d^2=1$$ $$ab+cd=0$$
Basically,I've no any idea or tactics to tackle this problem. Any methods? Thanks in advance.
EDITED.
The given hint in the books is $S:=(a^2+c^2-1)^2+(b^... | 2017/05/18 | [
"https://math.stackexchange.com/questions/2286245",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/221836/"
] | What if $b=0?$
Else $abcd\ne0,$
we have $\dfrac ab=-\dfrac dc=k$(say)
$\implies a=bk,d=-ck$
$$1=a^2+b^2=b^2(1+k^2)\implies b^2=?,a^2=(bk)^2=?$$
$$1=c^2+d^2=c^2(1+k^2)\implies c^2=?,d^2=(-ck)^2=?$$ | Just a very basic brute force method,
$a^2 + b^2 = 1$ - (1)
$c^2 + d^2 = 1$ -(2)
$ac+bd=0$
On multiplying the two we get, $a^2c^2+b^2d^2+a^2d^2+b^2c^2=1$
Whereas $a^2c^2+b^2d^2+2abcd=0$ {squaring both sides $ac + bd = 0$}
Thus we get $-2abcd+a^2d^2+b^2c^2=1 \Rightarrow (ad-bc)^2=1 \Rightarrow ad-bc=\pm1$
Adding ... |
49,611,196 | I have copied some item manually from web pasted into txt and then stored it into database.Now what I missed is invisible characters.
when I'm retrieving first characters of each word using different values in substr($word,0,x) it shows presence of invisible characters.
php code-
```
public function getPrefixAttrib... | 2018/04/02 | [
"https://Stackoverflow.com/questions/49611196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7701774/"
] | I suspect it's an issue of interpolation. You can kill two birds with one stone by using *prepared statements*. By using *prepared statements*
1. your data won't be corrupted or need to be manually handled by you,
2. your application will not be subject to security issues a la [SQL injection](https://stackoverflow.com... | Try <http://php.net/manual/en/function.nl2br.php>
Example,
```
$conteudo = nl2br($conteudo);
```
Then store into database. |
9,049,790 | *(Using iOS 5 and Xcode 4.2.)*
I've followed the instructions here: <http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW15> and used the [MKCircle](http://developer.apple.com/library/ios/#documentat... | 2012/01/29 | [
"https://Stackoverflow.com/questions/9049790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404409/"
] | I had the same task and here is how I solve it:
**NOTE: this code will only work starting from iOS7**
Add an overlay to the map, somewhere in your view controller:
```
MyMapOverlay *overlay = [[MyMapOverlay alloc] initWithCoordinate:coordinate];
[self.mapView addOverlay:overlay level:MKOverlayLevelAboveLabels];
```... | Here a Swift version. Thanks Valerii.
<https://github.com/dariopellegrini/MKInvertedCircle> |
49,498,922 | I've been trying to create a bunch of test users for my test application that will be mocking a case when user signed up to Facebook using his phone number (not his email).
Turns out that the tool to create test users (`App -> roles -> test users`) allows to create only users who have email and there's no way (AFAIK)... | 2018/03/26 | [
"https://Stackoverflow.com/questions/49498922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809230/"
] | Unfortunately, there is no way to add testers with their phones. You can add your testers by their fbids or usernames.
 | As others say there is no way to have test user without email address.
What you can do however is to create test user and when logging into your app deny access to email. It will have nearly same effect as logging in with user that has phone number instead of email. You can do it in edit section while logging in(as sh... |
20,530,388 | I have a really big problem with UIScrollView. To make sure it wasn't my actual project, I created a NEW project, iPhone only, for iOS 6 and 7. I **disabled autolayout**.
1. I created a Tab Bar project
2. I created a view controller,
embedded it in a navigation controller and connected it as Tab bar
item #0
3. I put a... | 2013/12/11 | [
"https://Stackoverflow.com/questions/20530388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1318432/"
] | I had the same issue until I realized I hadn't set the UIScrollView delegate. Also, if you're using auto layout, you need to wait for the layout to be applied to the UIScrollView. This means you should set the Content Size in "viewDidLayoutSubviews". | Use this code. ScrollView setContentSize should be called async in main thread.
Swift:
```
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
DispatchQueue.main.async {
var contentRect = CGRect.zero
for view in self.scrollView.subviews {
contentRect = contentRec... |
3,761,237 | Ok so i have a variable $phone which contains the string (407)888-9999 and I have this code
```
if($phone != ''){ $phone = "<span id='telephone'>{$phone}</span>";}
return $phone;
```
This works fine but now the client wants to have a some padding in between the area code and the next three numbers. So i need the co... | 2010/09/21 | [
"https://Stackoverflow.com/questions/3761237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223367/"
] | You can do:
```
$input = "(407)888-9999";
$area_code = '';
$ph_num = $input;
if(strpos($input,')') !== false) { // if area-code is present.
list($area_code,$ph_num) = explode(')',$input);
$area_code .= ')';
}
``` | Iff the phone number is always in the same format, you can split it with:
```
list($area,$phone1,$phone2) = sscanf($phone,'(%d)%d-%d');
```
or
```
sscanf($phone,'(%d)%d-%d',$area,$phone1,$phone2)
``` |
46,727 | I've started working on a script that turns sections with headings into a tabbed interface.
The repo is at <https://github.com/derekjohnson/tabs> and a demo at <http://derekjohnson.github.io/tabs/>
It works in IE8 up, although I haven't fully tested it on all the devices I have access to.
I'm particularly interested... | 2014/04/09 | [
"https://codereview.stackexchange.com/questions/46727",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/30509/"
] | You don't actually need the `self` variable in most of your code (the constructor doesn't use it at all). You can just use `this` directly in most cases.
The only exception is in the `session.requestServer` callback, where you do need a way to reference the object context - and there it's perfectly fine to use `self`.... | Or if you want to avoid classical style but still use prototypes for performance or manageability...
```
var Child = {
// defaults values for inherited properties
id: 0,
firstname = "",
moneyCurrent = 0,
moneyDue = 0,
missionsPlay = 0,
missionsWait = 0,
missionsStop = 0,
missions = [],
// factory ... |
15,153,943 | My goal is to only display contacts with phone number to user and let user select few contacts which I want to store locally.
I have used various options in place of ContactsContract.Contacts.CONTENT\_URI in below method. But I am getting lot many of the contacts (many are junk with only email ids) displayed.
```
... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15153943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/344535/"
] | ```
*-> Add a permission to read contacts data to your application manifest.
<uses-permission android:name="android.permission.READ_CONTACTS"/>
-> Use Intent.ACTION_PICK in your Activity
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
... | Use this:
```
Intent intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts/people"));
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(intent, 1);
``` |
78,949 | When my students ask questions and participate in discussion, class is more thoughtful, more fun, and more effective. I encourage their participation by checking in with them regularly, and making sure that they have time to speak and that they get a respectful hearing. Still, perhaps half of them never say a word. It ... | 2016/10/28 | [
"https://academia.stackexchange.com/questions/78949",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/14140/"
] | You want to grade people, in part, on their participation. If a person isn't speaking in class, whether it's because they're shy or because they have nothing to say, they're not participating.
If part of the assessment of a class involves an oral presentation, and a student refuses to present because they're shy then ... | What you can do is tell those students that notoriously always answer (in my experience there always are some) to give some others a chance as well. If the few that always contribute also have the best contributions, you should tell them to just wait a little bit for the others to speak up and still hear them out after... |
7,813 | There are a number of new developers and testers in our team. When the testers are testing the new features the developers built, they are finding a number of issues, which is not strictly in the scope of the feature. As a result the developers tend to deny responsibility and the bugs are going to the production bug tr... | 2014/02/19 | [
"https://sqa.stackexchange.com/questions/7813",
"https://sqa.stackexchange.com",
"https://sqa.stackexchange.com/users/7025/"
] | The first thing you want to do here is perform some bug triage. Problems your team finds during feature testing will be one of:
* something introduced by the changes
* something that was there before and doesn't have much if any impact on the changes
* something that was there before and has a major negative impact on... | If the test team is finding *that* many then it is possible their focus is not entirely on the new functionality. A common strategy is to focus the test team on the new functionality and look at reporting only issues which arise from interactions between old functionality and new functionality, or issues which will imp... |
31,258,598 | I am supposed to write a program with check buttons that allow the user to select any or all of these services. When the user clicks a button the total charges should be displayed. I already have the first portion done and finished but I need help with the second part. I can't find a calculation that works when the use... | 2015/07/07 | [
"https://Stackoverflow.com/questions/31258598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5009501/"
] | ```
import os
os.path.basename(os.path.dirname(os.path.realpath(__file__)))
```
Broken down:
```
currentFile = __file__ # May be 'my_script', or './my_script' or
# '/home/user/test/my_script.py' depending on exactly how
# the script was run/loaded.
realPath = os.path.... | Just write
```
import os
import os.path
print( os.path.basename(os.getcwd()) )
```
Hope this helps... |
36,986,192 | For my work I have done some tests for time chart.
I have come to something that surprised me and need help understanding it.
I used few data structures as queue and wanted to know how deleting is fast according to number of items. And arraylist with 10 items, deleting from front and not set initial capacity is much s... | 2016/05/02 | [
"https://Stackoverflow.com/questions/36986192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2558231/"
] | Read this article about [Avoiding Benchmarking Pitfalls on the JVM](http://www.oracle.com/technetwork/articles/java/architect-benchmarking-2266277.html). It explains the impact of the Hotspot VM on the test results. If you don't take care about it, your measurement isn't right. As you have found out with your own test.... | I too was able to replicate it by creating the code below. However, I noticed that whatever is run first (the set capacity vs non-set capacity) is the one that will take the longest. I assume this is some kind of optimization, maybe the JVM, or some kind of Caching?
```
public class Test {
public static void main(Str... |
73,784 | I'm working on getting my first server up and running and my dad is trying to convince me that Gentoo is the way to go. Is it worth the compile? I was just planning on using Ubuntu. | 2009/10/12 | [
"https://serverfault.com/questions/73784",
"https://serverfault.com",
"https://serverfault.com/users/22778/"
] | The answer really depends on your objective.
gentoo is not worth the effort if you want to get a server up quickly and easily or think that you will get noticeably better performance. Other distributions (ubuntu, RHEL, CentOS) are easier to set up and operate. I do not believe the typical user will notice much of a pe... | I would suggest Ubuntu for now for it's simplicity... however in the future I **fully recommend** trying Gentoo out just for the experience you'll receive in installing, configuring, troubleshooting linux. It's a great OS and you'll learn a ton. |
207,240 | I need to draw this kind of simple sequency diagram, but I'm not very good with Ti*k*Z:

```
\begin{figure}[!ht]
\begin{center}
\begin{tikzpicture}[node distance=2cm,auto,>=stealth']
\node[] (server) {server};
\node[left = of server] (client) {client};
\node[b... | 2014/10/15 | [
"https://tex.stackexchange.com/questions/207240",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/64319/"
] | Next time please provide a [minimal working example (MWE)](http://goo.gl/dtPzv). This should be the starting point.
```
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (0,1);
\coordinate (c) at (1,0);
\coordinate... | ```
\documentclass{article}
\usepackage{pgf-umlsd}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{figure}
\centering
\scalebox{1}
{ \begin{sequencediagram}
\newthread{A}{\shortstack{Cliente\\ \\\begin{tikzpicture}
\node [copy shadow,fill=gray!20,draw=black,thick ,align=center]... |
328,749 | I'm working on a Spring-based REST api that has v1 and v2 variants:
```
/api/v1/dates
/api/v2/dates
```
Correspondingly, there are v1 and v2 packages in the code base:
```
com.company.api.v1
com.company.api.v2
```
Is it a good practice to postfix class names with version number like below:
* DatesControllerV1.ja... | 2016/08/19 | [
"https://softwareengineering.stackexchange.com/questions/328749",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/76266/"
] | I must admit, my heart contracted in stress when I read "...there are v1 and v2 packages in the code base..." Typically, versioned APIs are, well, *versions* of your code, and don't live side-by-side in your codebase.
How I've done it before is forking the repo. V1 sticks around for bug fixes until we can get everyone... | I guess it depends on "Do you see them as two versions of essentially same concept OR do you see them as two different concepts"?
If you see two different concepts, it would definitely be better to name them separately (such as SavingsAccount versus CheckingAccount).
---
I hated the versions. But, in reality, I had ... |
621,042 | I have a TP4056 module (datasheet: <https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/TP4056.pdf>). It charges a 18650 cell.
According to the datasheet :
(Pin6): Open Drain Charge Status Output When the battery Charge Termination, the
pin is pulled low by an internal switch, otherwise STDBY pin is in high i... | 2022/05/25 | [
"https://electronics.stackexchange.com/questions/621042",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/294744/"
] | Meters were invented two decades later (Oerstead's compass.)
So, how did Volta discover that something was going on here? Wet fingers! With hands well soaked in water (or seawater, or vinegar,) touching a ~10V battery produces a detectable shock-feeling.
In figure one, the "measurement instrument" is Volta himself, d... | Holding the structure of heavy metal disks was done possibly by wooden poles.
The A stood for Ag = Silver, and Z for Zn = Zinc. He focused only on this galvanic electro-potential of bimetals and completely ignored the massive electrochemical energy of an insulated acid or alkaline cell. I guess coal wasn't clean enoug... |
36,308,224 | I have a requirement, where I need to delete thousands of files efficiently. At present, files are deleted in a sequential manner.
I want to speed up the deletions, by calling delete in an asynchronous manner, using std::async().
Current Flow:
1. Get the list of files
2. For each file call delete()
Desired Flow:
... | 2016/03/30 | [
"https://Stackoverflow.com/questions/36308224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2256902/"
] | You may find this doesn't actually help as much as you would like. The file system is likely to have kernel level locks (to ensure consistency), and having many threads hitting these locks it likely to cause trouble.
I suggest
1. Get the list of files.
2. Divide the list into (say) ten equal chunks (represented by i... | As a *completely* different approach, have you considered moving everything into a database? Deleting thousands of persistent things quickly is just the sort of stuff databases are good at. |
6,735,549 | I've got a FrameLayout with TextView children and I'd like to change the position of the TextViews at runtime (in onSensorChanged(), so several time per seconds). There is no setPosition(...), so how can I do that?
Thanks | 2011/07/18 | [
"https://Stackoverflow.com/questions/6735549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/326849/"
] | I would suggest you two ways, and none of them is text-indent(which is obsolete method).
First way is to remove text, and instead it ad a title to your anchor, like this:
```
<a href="index.php" id="logo" title"My Website"></a>
```
Second way, is to add an image in this anchor tag:
```
<a href="index.php" id="logo"... | Here is a trick that I use a lot. It shouldn't heart seo at all
```
<a href=""> </a> - now is visible but without showing any chars.
``` |
48,712,194 | How to get **only** the returned value from a function, in the below example, I want to get only `foorbar` and not `this is a test` in the bash shell.
```
$ cat foo.py
print "this is a test"
def bar():
return "foobar"
$ output=$(python -c 'import foo;print foo.bar()')
$ echo $output
this is a test foobar
``` | 2018/02/09 | [
"https://Stackoverflow.com/questions/48712194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2748513/"
] | I'd recommend if you require for whatever reason the `print "this is a test"` section, you check if the file is being run itself, such as by checking the `__name__` property as follows:
**foo.py:**
```
def bar():
return "foobar"
if __name__ == "__main__":
print("this is a test")
```
This should mean that t... | If you want to keep the module as-is and get what you want, you need to suppress the module level string being printed by temporarily redirecting the STDOUT to someplace else (e.g. `None`, `/dev/null` or any other file descriptor as a dumping zone), and duplicate again to the original STDOUT once the `import` is done.
... |
25,125,560 | When I scroll to the bottom of the child `div`, the `body` element starts scrolling.
How can I prevent this? I only want the `body` to scroll when the cursor is over it.
Example: [JsFiddle](http://jsfiddle.net/5mmay/) | 2014/08/04 | [
"https://Stackoverflow.com/questions/25125560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3675747/"
] | By adding some javascript of course!
**[FIDDLE](http://jsfiddle.net/5mmay/1/)**
```
$( '.area' ).on( 'mousewheel', function ( e ) {
var event = e.originalEvent,
d = event.wheelDelta || -event.detail;
this.scrollTop += ( d < 0 ? 1 : -1 ) * 30;
e.preventDefault();
});
``` | Use this plugin <http://mohammadyounes.github.io/jquery-scrollLock/>
It fully addresses the issue of locking mouse wheel scroll inside a given container, preventing it from propagating to parent element.
It does not change wheel scrolling speed, user experience will not be affected. and you get the same behavior rega... |
11,495,851 | I get tired of the dotted box that appears when you click a tags...so that I started replacing them with p tags...and adding an event listener for click events.
I can't help but notice that other popular sites don't do this ( for example when you click Post Your Question on SO the annoying dotted box appears )
Is the... | 2012/07/15 | [
"https://Stackoverflow.com/questions/11495851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | No, this is **not** okay.
Anchor tags are needed for browsers that don't support your styling, and I'm just talking about old versions of IE. Remember that screen readers, text-only users, and browser plugins all expect to find your anchor tags.
As Dash has pointed out, bots such as search engine crawlers also need y... | I disagree with the other two commenters a little. While it is true that it will break screen readers and not be backward compatible in general.....
IF you have a specific use case where you don't care about any of the above, well...it is your project. :)
And you COULD also mostly achieve this and keep the anchor tag... |
2,523,391 | Is there an open source project that can serve as a good example on how to use the [maven site plugin](http://maven.apache.org/plugins/maven-site-plugin/) to generate reports? I would prefer it to
* consist of many modules, possibly hierarchically structured
* use as many plugins as possible (surefire, jxr, pmd, findb... | 2010/03/26 | [
"https://Stackoverflow.com/questions/2523391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21499/"
] | I don't think there is such a project, if there is I want to know it as well. In order to find things in maven you have to know what you're looking for(which is not exactly the same with what you want to accomplish).
If its any help I'm building 13 module project with MAVEN, use cobertura maven plugin, surefire, java... | You can use [Violations Maven Plugin](https://github.com/tomasbjerre/violations-maven-plugin) to aggregate Findbugs (and many other static code analysis) reports.
It needs to run after the analysis. It will parse their report-files and present them in one unified report. It can, optionally, fail the build depending on... |
2,552,453 | Is there a way to give CSS syntax highlighting to any `<textarea>` using any bookmarklets or favlets? I work on a CMS where I write and manage CSS in a plain `<textarea>` like Notepad. Is there a boomarklet to enable CSS syntax highlight in specific `<textarea>` temporarily?
Should work in IE. | 2010/03/31 | [
"https://Stackoverflow.com/questions/2552453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/84201/"
] | If you know how to write a bookmarklet, you may be able to adapt [Code Mirror](http://marijn.haverbeke.nl/codemirror/). | I don't know about mookmarklets or Favlets, but you could write a userscript to do that.
Not sure if IE supports anything like that, but Firefox, Chrome and Opera all support userscripts. (Use [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/748) for Firefox)
For example, I wrote [this script](http://atl... |
1,660,856 | The rules for promotion is "when operands are of different types, automatic binary numeric promotion occurs with the smaller operand type being converted to the larger". But the operands are of same type for example,
```
byte=byte+byte // Compile time error... found int..
```
So why is it so? | 2009/11/02 | [
"https://Stackoverflow.com/questions/1660856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/167114/"
] | To understand this you should refer the 2 things:
Implicit Casting:
byte (8 bit) -> short (16 bit) -> int (32 bit) -> float (32 bit) -> double (64 bit)
char (16 bit) -> int (32 bit)
Arithmetic Operator Rules
1. Operator Precedence Rule : This rule states that Group of (\*,/, %) will be evaluated first. Then Group o... | From [this SO question](https://stackoverflow.com/q/13100019/1686291), and above answers due to `+` arithmetic operator, both operands are converted to type `int`.
```
byte b1 = 1;
byte b2 = 2;
byte b3 = b1 + b2; // compile time error
```
In above code, value of `b1` and `b2` will be resolved at runtime, so compiler... |
41,357,643 | I am creating a form where user can select a country from a drop-down list, then based on selected country, all related states filled in a multi-select list-box. Now a user can select multiple states and based on selected states another multi-select list-box (assigned for cities) should be filled accordingly. How can a... | 2016/12/28 | [
"https://Stackoverflow.com/questions/41357643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6869675/"
] | I solved by doing this:
```
$scope.changeStudentStatus = function(){
if($scope.ctrl.newStudentStatus)
{
//some logic
}
};
``` | Change
```
ng-change="changeStudentStatus();"
```
to
```
ng-change="ctrl.changeStudentStatus();"
```
The difference is that in your code, you call a method that is called `changeStudentStatus()`. This method isn't available on the controller.
I assumed that you alliased your controller as `ctrl` since your othe... |
73,120 | I am a newbie in comics. Although I'm well aware with all the DC characters and have seen all the movies, I think it's time for me start diving into comics as they're the real deal and I've always wanted to read comics. I like the Batman (who doesn't!) and the Flash (because he's cool). Superman is pretty cool as well.... | 2014/11/20 | [
"https://scifi.stackexchange.com/questions/73120",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/36290/"
] | I've found that there are two big dampers on reading comic books **cost** and **finding complete stories**.
When I started reading DC comics I went to a used bookstore and looked for consecutive issues of individual titles. I wound up with a 5 issues of Teen Titans from 1995 and the first 3 issues of Young Justice for... | The latest issue of Batgirl is a good jumping-on point, and Gotham Academy just started up. You might also want to check out older books like Batman Year One, The Dark Knight Returns, The Killing Joke, etc.
Other than that, just go into your local comic shop and ask them the question. They'll be able to point you to s... |
63,687,810 | ```
var d = new Date();
var month = d.getMonth();
var monthday = d.getDate();
var hours = d.getHours();
var minute = d.getMinutes();
var date = document.getElementsByClassName("date");
date[0].innerHTML = [month + 1] + "." + monthday + " " + hours + ":" + minute;
```
This is printing the current date like this: `9.1... | 2020/09/01 | [
"https://Stackoverflow.com/questions/63687810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14128494/"
] | `Add` for every value before the string `"0"` and get with `slice(-2)` the last 2 chars.
```js
var d = new Date();
var month = d.getMonth();
var monthday = d.getDate();
var hours = d.getHours();
var minute = d.getMinutes();
var date = document.getElementsByClassName("date");
let res = '0'+[month + 1].slice(-2) + "."... | Try this
```
var d = new Date();
var month = d.getMonth();
var monthday = d.getDate();
var hours = d.getHours();
var minute = d.getMinutes();
var date = document.getElementsByClassName("date");
function pad(s) { return (s < 10) ? '0' + s : s; }
date[0].innerHTML = pad([month + 1]) + ... |
7,027,513 | Where could I find JavaSpaces tutorials?
Points of interests for me:
* What can I do with it?
* How do I use it?
* How does it work? | 2011/08/11 | [
"https://Stackoverflow.com/questions/7027513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/505714/"
] | In addition to what cs94njw mentioned, I would also recommend [JavaSpaces](http://docstore.mik.ua/orelly/java-ent/dist/appc_01.htm) as well as [The Nature Of JavaSpaces](http://www.dancres.org/cottage/javaspaces.html). | Quick google search:
<http://java.sun.com/developer/technicalArticles/tools/JavaSpaces/>
http://www.gigaspaces.com/wiki/display/XAP7/Plain+JavaSpaces+Tutorial |
33,986,143 | I have a `listView` in Activity A , which the value are returned from Activity B.When the list is clicked, it will intent to Activity B for edit.
**Activity B**
```
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.add_... | 2015/11/29 | [
"https://Stackoverflow.com/questions/33986143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5398173/"
] | **First Step:** Make your **addItemsOnSpinner** like as below:
```
public void addItemsOnSpinner(String value)
{
int position = 0;
project=(Spinner)findViewById(R.id.SpinnerProject);
List<String> list = new ArrayList<String>();
list.add(position,"TRN-XXX-XXX");
list.add("Pro-XXX... | Use `SharedPreferences`. Next time, [googling helps](https://stackoverflow.com/a/33962422/1390727).
**Get `SharedPreferences`**
```
SharedPreferences prefs = getDefaultSharedPreferences(context);
```
**Read preferences:**
```
String key = "test1_string_pref";
String default = "returned_if_not_defined";
String test... |
35,323,144 | Currently my query looks like so:
```
SELECT start_date, from_id, to_id, from_amount, to_amount
FROM sample_table
WHERE from_id = '123'
OR to_id = '123';
```
However, what I'm really aiming for is one `amount` column in my results which shows `from_amount` WHERE `from_id = 123` and `to_amount` WHERE `to_id = 123`.
... | 2016/02/10 | [
"https://Stackoverflow.com/questions/35323144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3084511/"
] | They are *some kind* of **colored margin** (used in Android Wear).
They are used to create a padding from the main content to the actual border:
There are a few examples [here](http://developer.android.com/training/wearables/ui/layouts.html).
---
This is an image with 2 insets: Circle/Squared.
[:
```
@Override
public void onApplyWindowInsets(WindowInsets insets) {
super.onApplyWindowInsets(insets);
mRound = insets.isRound();
}
```
to detect if wearable android device is round ... |
41,594,631 | I wrote a python script to output lines and cells of a csv file.
The file I read has been exported from the address-book of a shipment company utility.
It appears, that this file is somehow "corrupted". The co-workers who registered the addresses did some wrong copy-paste and inserted many quotation marks often without... | 2017/01/11 | [
"https://Stackoverflow.com/questions/41594631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5497403/"
] | Using `GNU grep` with `-P` for perl-style `regEx` match, and `-o` flag to return only the matching pattern.
```
grep -oP 'Program Version \K[^ ]*' file
1.3.1
```
To save it in a variable
```
versionNo="$(grep -oP 'Program Version \K[^ ]*' file)"
printf "%s\n" "$versionNo"
1.3.1
```
Use `perl` `regEx` itself,
```... | I guess you obtain that `Program Version 1.3.1` for example launching some kind of command. Well, try this:
```
#!/bin/bash
version=$(yourCommandWhichShowsVersion 2> /dev/null | egrep "^Program Version [0-9]" | awk '{print $3}')
```
Explanation:
* You need to launch the command which show the version
* You redirect... |
19,086,409 | Hello `sackoverflow` I'm trying to develop an application which can backup and restore contacts, my code is as follows
```
public class MainActivity extends Activity
{
Cursor cursor;
ArrayList<String> vCard ;
String vfile;
FileOutputStream mFileOutputStream = null;
Button btnRestorects = null;
Button btnBackupCts = ... | 2013/09/30 | [
"https://Stackoverflow.com/questions/19086409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2503661/"
] | Use this to restore:
```
final MimeTypeMap mime = MimeTypeMap.getSingleton();
String tmptype = mime.getMimeTypeFromExtension("vcf");
final File file = new File(Environment.getExternalStorageDirectory().toString()
+ "/contacts.vcf");
Intent i = new Intent();
i.setAction(android.content.Inten... | ```java
Intent mIntent = new Intent(Intent.ACTION_VIEW);
mIntent.setDataAndType(Uri.fromFile(new File(filePath)), MimeTypeMap.getSingleton().getMimeTypeFromExtension("vcf"));
startActivity(Intent.createChooser(mIntent, "Select App"));
``` |
1,120,132 | How can I get SMTP to work on a Windows 7 development box? I used to just be able to turn on the IIS SMTP server on Windows XP. Is SMTP not included with Windows 7? If so, what can I use instead as a free relay mechanism? | 2009/07/13 | [
"https://Stackoverflow.com/questions/1120132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/137506/"
] | According to [this post](http://thisthattechnology.blogspot.com/2009/09/smtp-service-on-windows-7.html), the issue an SMTP server was included in IIS6, but has been removed in IIS7. This [thread suggests](http://social.technet.microsoft.com/Forums/en-US/w7itproinstall/thread/7cef5da9-5b31-4b98-9bd9-9f7777dd7b37/) the [... | I use "Free SMTP Server" from Softstack.
<http://www.softstack.com/freesmtp.html>
HTH |
59,423,504 | I'm having a two columns say Value column is having records like `'abc|comp|science|raja'` and I want to split this records like `abc,comp,science,raja` and I need to compare it with another column say `CHECKER` which is having record as science
Value
=====
```
abc|comp|science|raja
```
Checkers
========
```
scien... | 2019/12/20 | [
"https://Stackoverflow.com/questions/59423504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10492921/"
] | You don't need to split the string and you don't even need a regular expression; just check whether the `checker` string (with leading a trailing delimiters) is a sub-string of `value` (with leading and trailing delimiters):
**Oracle Setup**:
```sql
CREATE TABLE your_table ( value, checker ) as
SELECT 'abc|comp|sci... | It sounds like you just want to check whether the checker is in the value, in that case you can do this:
```
with mytable as
( select 'abc|comp|science|raja' value
, 'science' as checker
from dual
union all
select 'science|abc|comp|raja'
, 'science'
from dual
union all
select 'abc|... |
197,708 | I'd like to use Rich Text Editing in place on forms in order to let admins change instructions. What are the best options for doing this?
[To be more clear - the admins are non-technical but may want to control some formatting without using markup or with as little markup as possible. What I'd like is for them to be a... | 2008/10/13 | [
"https://Stackoverflow.com/questions/197708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6805/"
] | I'm not sure if I fully understand the question, but if you just ask about which editor to use, there are many options and none of them is a matter of Rails - you can use any of them just by adding a little piece of javascript into your markup. Nice and up to date overview can be found here: [http://bulletproofbox.com/... | I know this threat is pretty old but I came across looking for a few good options the a few weeks back, so in case someone else is facing the same issue like I did I give a more resent response. So my favourite editor is [Froala](https://www.froala.com/) ([wysiwyg-editor](https://github.com/froala/wysiwyg-rails) if you... |
2,269,672 | Let $A=\{(x,y)\in\mathbb{R}^ 2|x\in\mathbb{Q}\text{ or }y=0\}$.
>
> 1. How do I show that $A$ is path connected?
> 2. How do I show that $A$ is NOT locally path connected?
>
>
>
What I thought:
1. So we need a continous map $f:[0,1]\rightarrow X$ from $(x\_1,y\_1)$ to $(x\_2,y\_2)$. I was thinking $$f(t)=t(x\_... | 2017/05/07 | [
"https://math.stackexchange.com/questions/2269672",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/427455/"
] | Use [this inequality](https://math.stackexchange.com/questions/184029/inequality-frac116abcd3-geq-abcbcdcdadab?rq=1):
$\frac{1}{16}(a+b+c+d)^3 \geq abc+bcd+cda+dab$ equivalent $\frac{1}{4}(a+b+c+d) \geq \sqrt[3]{\frac{abc+abd+acd+bcd}{4}}$ Now just prove$\sqrt{\frac{a^2+b^2+c^2+d^2}{4}}\geq \frac{1}{4}(a+b+c+d)$ equiv... | Since
$$\frac{a^2+b^2+c^2+d^2}{4}\geq\frac{ab+ac+bc+ad+bd+cd}{6}$$
it's just
$$(a-b)^2+(a-c)^2+(a-d)^2+(b-c)^2+(b-d)^2+(c-d)^2\geq0,$$ it's enough to prove that
$$\sqrt{\frac{ab+ac+bc+ad+bd+cd}{6}}\geq\sqrt[3]{\frac{abc+abd+acd+bcd}{4}},$$
which I proved here:
[How to prove this inequality $\sqrt{\frac{ab+bc+cd+da+ac+... |
18,092,354 | Is there a way to split a string without splitting escaped character? For example, I have a string and want to split by ':' and not by '\:'
```
http\://www.example.url:ftp\://www.example.url
```
The result should be the following:
```
['http\://www.example.url' , 'ftp\://www.example.url']
``` | 2013/08/06 | [
"https://Stackoverflow.com/questions/18092354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1200615/"
] | There is a much easier way using a regex with a *negative lookbehind assertion*:
```
re.split(r'(?<!\\):', str)
``` | As Ignacio says, **yes**, but not trivially in one go. The issue is that you need lookback to determine if you're at an escaped delimiter or not, and the basic `string.split` doesn't provide that functionality.
If this isn't inside a tight loop so performance isn't a significant issue, you can do it by first splitting... |
33,237,731 | ( F.Y.I. I already searched out many documents in Internet. I'm using storm-0.10.0-beta1. Configuration file of log4j2 in Storm is worker.xml )
Now, I try to use log4j2.
I'm searching out way of deleting old logs but I cannot find out.
Part of configuration is like below.
```xml
<RollingFile name="SERVICE_APPEND... | 2015/10/20 | [
"https://Stackoverflow.com/questions/33237731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2552915/"
] | Since 2.5, Log4j supports a [custom Delete action](http://logging.apache.org/log4j/2.x/manual/appenders.html#CustomDeleteOnRollover) that is executed on every rollover.
You can control which files are deleted by any combination of:
1. Name (matching a [glob](https://docs.oracle.com/javase/7/docs/api/java/nio/file/Fil... | You can find more background information in this JIRA entry for log4j:
<https://issues.apache.org/jira/browse/LOG4J2-524>
It seems to be the case that auto deleting old log files does not work when you only use a `TimeBasedTriggeringPolicy` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.