INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
How to go to last change not made on the current screen?
I love `g;`, but often I find myself repeatedly doing `g;` until the screen changes. The reason for this is that I am often editing in two different places in the file. If I think ahead, I should set marks at the two places, but I usually forget to do this. Also, I don't know how many edits I made at the current "screen" so I can't just do `ng;` for some n. An alternative workflow would be to split the screen and edit in two places that way, but I just haven't gotten used to that workflow and even in that case, I think I would still find this functionality useful. Finally, I often use `''` but it often doesn't do what I want since I commonly search different parts of the file and I really want to jump to the last part of the file (that's not on the current screen) where I made a change.
How can I make a command that will essentially repeat `g;` until the screen changes? | Seems pretty straightforward
nnoremap <expr>g; DeltaChange()
func! DeltaChange() abort
let ch = getchangelist()
let delta = 1
let top = line('w0')
let bot = line('w$')
while delta <= ch[1]
let lnum = ch[0][ch[1] - delta].lnum
if lnum < top || lnum > bot
return delta..'g;'
endif
let delta += 1
endw
return ''
endf | stackexchange-vi | {
"answer_score": 4,
"question_score": 4,
"tags": "cursor movement"
} |
If $a^2 + b^2 +c^2 =4$ and $a^3 + b^3 + c^3 = 8$ then find $a^4+b^4+c^4$
This is a popular question, but I can find $a^4+b^4+c^4$ if I know $a+b+c, a^2+b^2+c^2, a^3 +b^3 +c^3$ or in special case $a+b+c=0$ we only need a more condition like $a+b+c$. I have tried in many times and can't find out the way to archive it. | Well, it sounds logical that we need three equations, because three variables and stuff. This is **wrong** , though. Sometimes one equation can give us two variables, like $x^2+y^2=0\Rightarrow x=0,\;y=0$ (if we stay in $\mathbb R$, that is; but if we don't, then the original question can't be answered either). Same thing here.
Obviously†, $a^3+b^3+c^3\leqslant(a^2+b^2+c^2)^{3/2}$, and the equality is only possible when two of the variables are $0$. So $(0,0,2)$ and its permutations are indeed the only real solutions, from where you can easily find the answer.
So it goes.
* * *
† $$(a^2+b^2+c^2)^3\geqslant \overbrace{a^6+b^6+c^6+\underbrace{a^4b^2+a^2b^4}_\text{apply AM-GM}+\underbrace{b^4c^2+b^2c^4}_\text{here too}+\underbrace{a^4c^2+a^2c^4}_\text{and here}}^\text{skipped quite a lot of terms, all of them quadratic}\geqslant \\\\\geqslant a^6+b^6+c^6+2a^3b^3+2b^3c^3+2a^3c^3=(a^3+b^3+c^3)^2,\text{ hence}\\\ a^3+b^3+c^3\leqslant (a^2+b^2+c^2)^{3/2}=4^{3/2}=8$$ | stackexchange-math | {
"answer_score": 4,
"question_score": 2,
"tags": "algebra precalculus, symmetric polynomials"
} |
get next auto increment value from an empty table
I've got a table named 'messages'
I flooded it with approx 150 tables I'm not sure about the count. The 'id' field is 'primary' and 'auto_increment'.
by mistake i deleted all the records in the table (NOTE: I did not truncate the table so the count would not be reset) and I lost the count of the number of records.
Is there a possibility that I can get the next count of 'id' field? This is causing problems for me while trying to insert a new message using ajax message. | If you did **not** truncate the table then you can use
select auto_increment
from information_schema.TABLES
where TABLE_NAME ='messages' and TABLE_SCHEMA='database_name'
to get the next auto-increment value.
## SQLFiddle demo | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "mysql"
} |
How to make Puppet fix SELinux types for home directories?
We are using pam_mkhomedir.so to automatically create the home directories of users logging in with SSH. There is a bug in pam_mkhomedir that sets the SELinux contexts to home_root_t instead of user_home_dir_t. The solution is using pam_oddjob_mkhomedir, which we've implemented.
We however still have many home directories with invalid SELinux contexts.
drwxr-xr-x. jdoe users unconfined_u:object_r:home_root_t:s0 jdoe
How can we design a Puppet module that would correct SELinux contexts on all user home directories?
I was thinking about a solution like this:
file { '/home/*':
ensure => "directory",
seltype => "user_home_dir_t"
}
Unfortunately the wildcard doesn't work. | Maybe this would be helpful? <
Recurselimit seems to work for /home/user1, but also sets /home to user_home_dir_t.
file { '/home/':
ensure => "directory",
recurse => true,
recurselimit => 1,
seltype => "user_home_dir_t"
}
You could set up a custom fact that returns all home directories in an array (too many users could be a problem here):
$fact_home_dirs = ['/home/user1', '/home/user2']
file { $fact_home_dirs:
ensure => "directory",
seltype => "user_home_dir_t"
}
Perhaps the best option in this case would be to run restorecon since you seem to have implemented a solution for newly created directories. | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 2,
"tags": "puppet, rhel6, selinux"
} |
How to get log information in android
How to get log information to remote server while app running on device. Like how we get in log of java file using log4j? | for getting crash reports of app use following link
< | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "android, logging"
} |
Is OpenLDAP a viable alternative to Windows LDAP?
Just a simple question; this question is not meant to attack Windows or start a flame war in anyway. I want a viable solution to the way authentication is done in Windows DC environment (LDAP) on *nix. I just want to know if OpenLDAP can be that solution? | Microsoft Active Directory is (mainly) just an LDAP server, some pre-cooked schemas and some tools for interacting with it and Kerberos. OpenLDAP is pretty much a drop-in replacement for the former.
While you could design your own AD compatible schemas (or if you already have an AD schema, just import it into openLDAP) and write your own tools for managing the datasets there are solutions runing on top of openLDAP available, e.g. GoSA, freeIPA see the samba wiki for more stuff
Not sure where Samba 4 has got to (its expected to add drop-in replacement functnioality for MSAD). | stackexchange-serverfault | {
"answer_score": 6,
"question_score": 6,
"tags": "linux, ldap, openldap"
} |
Effective speed of original COSMAC VIP CHIP-8 interpreter
The original CHIP-8 interpreter ran on RCA 1802-based kit computers and home computers, most notably on the COSMAC VIP. Some of the CHIP-8 opcodes are complicated and involve many memory round-trips, for example the drawing instructions, or the ones that store register values in RAM. However, many of them are straightforward register-to-register operations which can be implemented fairly uniformly in a bytecode interpreter: just fetch the bytes, switch on the relevant parts of it to jump to the right operation, then do the operation.
For this second kind of "regular", "atomic" operations, I think it should be meaningful to assign a single number to the effective interpretation rate, i.e. on average restricted to these operations, how many CHIP-8 bytecode instructions could the original interpreter run per second on the COSMAC VIP? | This is the best reference I know of concerning timing in the CHIP-8 interpreter for COSMAC VIP: Chip 8 Instruction Scheduling and Frequency
To understand the reasons for the timings here, you'll need to look at a disassembly of the interpreter. Sadly, the website mentioned in the link above (Laurence Scotford's blog) is down, but some of the pages (but not all) are available at the Internet Archive's WayBackMachine.
One reason is of course that the CHIP-8 registers aren't really registers, but just memory locations. So each time the interpreter looks up a register, it needs to add the register number as an offset to the memory location of register V0. In addition, instructions in the `$8XYN` range are decoded and dispatched to the 1802 CPU's ALU, which is why they have uniform timing. Perhaps those would make for an OK baseline? | stackexchange-retrocomputing | {
"answer_score": 3,
"question_score": 3,
"tags": "emulation, chip 8, rca 1802"
} |
SQL IF THEN for concatenating fields
I have two columns that are `min_price` and `min_price`. Most of the time, the `min_price` and `max_price` is the same. Instead of two separate fields for the price, I would like just one "price" field. If the min_price and the max_price are the same I want to display that price. If the `min_price` and `max_price` are different, then I would like to show a concatenated string that is (`min_price` "-" `max_price`). This is just for a table grid, so data types are not important.
Would I use an `IF THEN` statement in my select?
select (lots of other stuff), min_price, min_price, (lots more stuff)
Not sure where to go from here. I am using MySQL 5. | Here you go:
select if(min_price=max_price,min_price,concat(min_price,' - ',max_price)) as price
from your_table; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "sql, mysql"
} |
post values in smarty - CS-cart
I was handed a cs-cart project and i've been having some minor issues, I think i'm missing something.
given this (self explanatory) code :
{if $smarty.get.mypin ==""}
OK
{assign var="my_pin_q" value=$smarty.post.mypin}
{else}
NOT OK
{assign var="my_pin_q" value=$smarty.get.mypin}
{/if}
So i'm checking if a get paramter exists, if it does i'm saving it to a local varaible, else i'm saving the .post variable(instead of of the get).
This is followed by :
<input type="hidden" name="mypin" value = "{$my_pin_q}">
(inside a form ofcourse)
the issue at hand is that for some reason `.post.mypin` is always empty, even though it's passed correctly through the form.(I checked the POST request).
Is this normal? Does smarty store the request variables somewhere else? | You should not use comparison `$smarty.get.mypin ==""`. You should use `isset` instead. Below code should work for you (notice changed blocks inside if and else):
{if isset($smarty.get.mypin)}
{assign var="my_pin_q" value=$smarty.get.mypin}
{else}
{assign var="my_pin_q" value=$smarty.post.mypin}
{/if}
Value of PIN: {$my_pin_q} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, smarty, cs cart"
} |
WPF properties not working correctly in windows 8
I am having an issue with the BorderThickness or BorderBrush property in Windows 8.
In win7, the code below correctly outlines editControl in a 5px thick read outline, however it does not work in windows 8. I am wondering if there is something deprecated or unsupported in windows 8 now? I cannot find any notion of that on the microsoft documentation.
editControl.BorderThickness = new Thickness(5);
editControl.BorderBrush = Brushes.Red;
Anyone able to help? | I found a workaround using using Adorners.
private class ErrorHighlightAdorner : Adorner
{
public ErrorHighlightAdorner(UIElement adornedElement)
: base(adornedElement)
{
}
protected override void OnRender(DrawingContext drawingContext)
{
Rect sourceRect = new Rect();
FrameworkElement fe = AdornedElement as FrameworkElement;
if (fe != null)
{
sourceRect = new Rect(fe.RenderSize);
}
else
{
sourceRect = new Rect(AdornedElement.DesiredSize);
}
Pen renderPen = new Pen(new SolidColorBrush(Colors.Red), 2.0);
drawingContext.DrawRectangle(null, renderPen, sourceRect);
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, wpf, windows"
} |
React router dom type error / FC{} | ReactNode is not assignable to type ReactNode
I'm new to typescript. I'm working on a project and using `react-router-dom`, and whenever I'm trying to create the elements in the App.tsx I get an error.
This is the code:
<Route path="landing-page" element={landingPage} />
Here is the error:
> Type 'FC<{}> | ReactNode' is not assignable to type 'ReactNode'. Type 'FC<{}>' is not assignable to type 'ReactNode'.ts(2322) components.d.ts(52, 5): The expected type comes from property 'element' which is declared here on type 'IntrinsicAttributes & (PathRouteProps | LayoutRouteProps | IndexRouteProps)'
For my components at first I gave them a type of `React.FC` but when I got this error I tried to change it to `React.ReactNode | React.FC` but still nothing is rendering on the page. Does anyone have an idea? | The `Route` component's `element` prop takes _**only**_ a `React.ReactNode` type. In other words, it takes JSX.
Route
>
> declare function Route(
> props: RouteProps
> ): React.ReactElement | null;
>
> interface RouteProps {
> caseSensitive?: boolean;
> children?: React.ReactNode;
> element?: React.ReactNode | null; <-- ReactNode or null
> index?: boolean;
> path?: string;
> }
>
Pass the `LandingPage` component as JSX instead of as a reference to a React component.
<Route path="landing-page" element={<LandingPage />} /> | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "reactjs, typescript, react router dom"
} |
Weird thing - -25 reputation from not mine post
I have on my profile on StackOverflow (in Reputation section) this:
Oct 8
-25 12:08 removed I need to create a GUI that will launch external applications using Visual Studio 2010
As for me this is weird, because:
1. I haven't used Windows for ~6 months
2. Even when I used Windows, I used VS 2008 only (I installed VS 2010, but I hated it)
3. I wasn't even using internet this day, had really important task to do.
So my question is, what is that? | This question was deleted. The reputation you gained from posting an answer is reversed since the question was deleted.
<
So it's not really negative reputation (in the same sense as downvotes), it's just StackOverflow reclaiming points awarded for a question deemed inappropriate. | stackexchange-meta | {
"answer_score": 15,
"question_score": 2,
"tags": "support, reputation"
} |
HTML5: Inverse text-color on canvas
I want to draw text on a canvas in the inverse color of the background (to make sure the text is readible no matter the background color). I believe in oldskool bitblt-ing, this was an XOR operation.
How to do this? | I've removed my old answer, as it did not solve the question. As of recently, there are new `globalCompositeOperation`s that do all kinds of great things. I've created an example that shows how to obtain inverted text. In case that link breaks, the method is essentially this:
ctx.globalCompositeOperation = "difference";
ctx.fillStyle = "white";
//draw inverted things here
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 6,
"tags": "html, canvas"
} |
Variance of geometric mean of two uniform random variables
Suppose $Y_1, Y_2$ are from a random sample of the uniform distribution on $[0, 1]$. How do I compute the variance of the geometric mean of two points in the interval $[0, 1]$?
I know the geometric mean is $X=(Y_1 Y_2)^{1/2}$. I can't compute the variance since I'm not sure how to find the expected value of a radical. | **Hint** : This is one of those instances where it helps to understand **linearity of expectation** and the product structure that occurs due to **independence**.
Recall that for an arbitrary random variable $X$ with finite second moment, $$\newcommand{\E}{\mathbb E} \mathrm{Var}(X) = \E X^2 - (\E X)^2 \>. $$
In particular, $$ \mathrm{Var}(\sqrt{Y_1 Y_2}) = \E Y_1 Y_2 - (\E\sqrt{Y_1 Y_2})^2 = (\E Y_1)(\E Y_2) - (\E \sqrt{Y_1})^2(\E \sqrt{Y_2})^2 \>, $$ by independence of $Y_1$ and $Y_2$. (Why?)
**Now, can you do the rest?** | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "probability"
} |
Symfony2 - Error when trying to get post count for a specific year
I am trying to create a query to find all posts within the year 2014.
I have the following but the error appears:
[Syntax Error] line 0, col 88: Error: Expected end of string, got '00'
What's wrong with my query?
public function getPostCountByYear()
{
$query = $this
->createQueryBuilder('post')
->where('created >= 2014-01-01 00:00:00 AND created < 2015-01-01 00:00:00');
$query->select('COUNT(post)');
$year = $query
->getQuery()
->getSingleScalarResult();
return $year;
} | Try this.
public function getPostCountByYear()
{
$query = $this
->createQueryBuilder('post')
->where('post.created >= :begin')
->andWhere('post.created < :end')
->setParameter('begin', new \DateTime('2014-01-01 00:00:00'))
->setParameter('end', new \DateTime('2015-01-01 00:00:00'));
$query->select('COUNT(post.created)');
$year = $query
->getQuery()
->getSingleScalarResult();
return $year;
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "symfony, doctrine orm, count"
} |
How to make the output of server headers more readable?
Given the following php5 code that output a gigantuous amount of _difficult to read_ code:
<?=var_dump($_SERVER);?>
<?=print_r($GLOBALS); ?>
Question: how to make the output more human-readable? e.g. houw to but every "item" on a new line? | On your development environment, you should install the **Xdebug** extension.
Amongst other useful features _(such as a debugger !)_ , it'll get you nicer `var_dump()` :
* colors
* formating
For example, here's a screenshot of the beggining of the output I get for `var_dump($_SERVER);` :
 | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "php, arrays, readability"
} |
How can I trigger('click') on page load with this specific code
How can I make this happen, on page load?
<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $text_write; ?></a>
Thanks. | $(window).load(function ()
{
$('a[href="#tab-review"]').click();
});
RTFM.
* * *
> Hm, any idea how to put this between I need this to be executed with IF...?
<script>
function clickTheLink()
{
$('a[href="#tab-review"]').click();
}
<?php
if ($something) {
echo '$(window).load(clickTheLink);';
}
?>
</script> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "javascript, jquery"
} |
Delete session in laravel
I am using a session_variable as the user_id to get information about the user by querying with the help of the variable. Whenever my user logs in with correct credentials, I create a session variable using:
\Session::put('user_id', $user_id);
And now I have a condition when the user logs out from the website,so how do I remove the session variable from the session using laravel. I tried something like : `session()->forget('some_data');` which didn't seem to work for me so what should I do to remove all the session variable I have in the webpage? | You can try with this
Session::flush(); // removes all session data
Session::forget('user_id') // Removes a specific variable | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "laravel, session, laravel 5, session variables"
} |
How to I configure Eclipse PDT 2.1 to display PHP CLI output in the console?
Starting with a recent version of Eclipse PDT, the standard out and standard error from executed PHP CLI code doesn't appear in the console anymore. (It still shows up in the Debug-perspective in the Debug Output-view).
How can I change this back so that PHP CLI output arrives in the console again? | Wait for the bug to get fixed. :( <
If you find another solution, let me know please! | stackexchange-superuser | {
"answer_score": 2,
"question_score": 1,
"tags": "eclipse, stdout, php cli, stderr"
} |
Homotopy type of certain maps on complex grassmanian
$G(k,n)$ is the complex grassmanian which is homeomorphic to the space of projections in $M_{n}(\mathbb{C})$ with trace $k$. So we can Identify $G(k,n)$ with $$\\{A\in M_{n}(\mathbb{C})\mid A=A^{*}=A^{2},\;\;trac(A)=k\\}$$
With this matrix interpretation, we define two maps from $G(k,n)$ to $G(2k,2n)$. Our quesion is that :
> Are these maps homotpic maps?:
The maps are $f(X)=X\otimes I_{2}$ and $g(X)=I_{2}\otimes X$ | Let $U$ be the matrix which sends $e_i$ to $e_{2i}$ and $e_{i+n}$ to $e_{2i+1}$ for $0\leq i<n$. Then $f(X)=Ug(X)U^{-1}$. You can join $U$ to $I$ by a path in $U(n)$, and this gives a homotopy between $f$ and $g$. | stackexchange-mathoverflow_net_7z | {
"answer_score": 7,
"question_score": 1,
"tags": "at.algebraic topology, matrices, grassmannians"
} |
Valid regular expression for validation oracle Number
How can i write valid regular expression for Oracle's **Number(2,2)** , Also digits after decimal should be either, 1 or 2 but not more than 2,also it can be optional. The numer should never start with [1-9] but can start with 0.
Valid Number are -:
0
0.00
0.12
0.14
Invalid are
0.
1
1.00
2.00
0.000 | The regular expresion you want is:
^0(\.[\d]{n,m}[1-9])*$
Let m and n be 2 non negative integers,and be n+1 the minimum acceptable decimals and m+1 the maximun acceptable decimals. This prevents 0.000..0 btw. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, java, javascript, jquery, oracle"
} |
Squaring 4-momentum gives wrong result
I‘m doing an exercise where a particle $A$ with mass $m_A$ decays into two particles $B$ and $C$ with mass $m_B$ and $m_C$. The goal is to calculate the absolute value of the momentum of the particles $B$ and $C$. In the solution they start with ($E$ is the energy) $$(m_Ac,0,0,0)=(E_B/c,0,0,p)+ (E_B/c,0,0,-p)$$ and when the square it they get: $$m_A^2c^2=m_B^2c^2+ m_C^2c^2+2(E_BE_C/c^2+|p|^2)$$ But if I calculate the square I get at the end $-|p|^2 $ and not $|p|^2$ because of the minkowski metric. So where is my mistake? | With $E_B = \sqrt{p^2+m_B^2}$ and $E_C = \sqrt{p^2+m_C^2}$:
$$\begin{align}\begin{pmatrix}\sqrt{p^2+m_B^2} + \sqrt{p^2+m_C^2}\\\ 0 \\\ 0 \\\ 0\end{pmatrix}^2 &= \left(\sqrt{p^2+m_B^2} + \sqrt{p^2+m_C^2}\right)^2\\\ &=m^2_B + m^2_C + 2p^2 + 2 \underbrace{\sqrt{p^2+m_B^2}}_{E_B}\underbrace{\sqrt{p^2+m_C^2}}_{E_C} \end{align}$$
So
$$ \begin{align} \sqrt{p^2+m_B^2}\sqrt{p^2+m_C^2} &= \frac{m_A^2 - 2p^2 - m^2_B - m^2_C}{2}\\\ (p^2+m_B^2)(p^2+m_C^2) &=\frac{\left(m_A^2 - 2p^2 - m^2_B - m^2_C \right)^2}{4}\\\ \end{align} $$
From there it follows that
$$p=\frac{\sqrt{m_A^4 - 2 m_A^2 m_B^2 + m_B^4 - 2 m_A^2 m_C^2 - 2 m_B^2 m_C^2 + m_C^4}}{2 m_A}$$
This can be simplifed by using the Källén function
$$\lambda(a,b,c) = a^2+b^2+c^2-2(ab+bc+ca)$$
Then
$$p = \frac{\sqrt{\lambda(m_A^2, m_B^2, m_C^2)}}{2m_A}$$ | stackexchange-physics | {
"answer_score": 1,
"question_score": 0,
"tags": "special relativity, energy, momentum"
} |
Submit / Reset Buttons - Order in the Form
When it comes to putting the **submit and reset buttons** on your forms, **what order do you use?**
[SUBMIT] [RESET]
or
[RESET] [SUBMIT]
This issue has come up countless times at work...
So, in your opinion, which is the most usable for online users?
I personally favor the latter, but some people tend to think otherwise. | In addition to the suggestions given already, I would like to add that the submit button should be an actual button where as reset or cancel just a link making it different from the submit button hence highlighting the fact that they are functionally different and keeping it simple. Last thing you want is to make your users think. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 3,
"tags": "forms, user interface, usability"
} |
How to parse multipe json value in java
I've below json value in my StringBuilder variable, I want to parse all **id** key value and store it again in StringBuilder.
{"status":"success","id":"1"}
{"status":"success","id":"2"}
{"status":"success","id":"3"}
{"status":"success","id":"4"}
{"status":"success","id":"5"}
{"status":"success","id":"6"}
Expected output: 1 2 3 4 5 6
How can I parse these value in java?
I tried below option but it doesn't help:
StringBuilder str = new StringBuilder();
str.append(jsonStringValue);
JSONObject jObj = new JSONObject(str);
jObj.getString("id");
**Using JSONTokener**
JSONTokener t = new JSONTokener(str.toString());
while (t.more()) {
JSONObject o2 = (JSONObject) t.nextValue();
System.out.println(o2.getString("id"));
}
But I'm getting below error message: org.json.JSONException: Missing value at character 128 | If you're using org.json, You can use JSONTokener.
Here's example shows how it works.
public static void main(String args[]) throws JSONException {
String str1 = "{\"strValue\":\"string\"}\n{\"intValue\":1}";
JSONTokener t = new JSONTokener(str1);
JSONObject o1 = (JSONObject) t.nextValue();
JSONObject o2 = (JSONObject) t.nextValue();
System.out.println(o1.getString("strValue"));
System.out.println(o2.getLong("intValue"));
System.out.println(t.more()); // Check if there's more token. can be used to process with loop.
}
Or if you can change input string, you can put those object into Json array.
[
{"status":"success","id":"1"},
{"status":"success","id":"2"},
{"status":"success","id":"3"},
{"status":"success","id":"4"},
{"status":"success","id":"5"},
{"status":"success","id":"6"}
]
In that case you can use org.json.JSONArray to handle it. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, json, parsing, stringbuilder"
} |
Matrix with rank 3 does not exist in this $p(x)$
> Given: Characteristic polynomial is $p(x) = x^7 - x^5 + x^3$ .
Prove that there isn't a matrix A that $ \rho(A) = 3 $
I tried to play with $p(x) = x^3(x^4 - x^2 +1)$ But I'm still not sure how to continue with that. Any ideas? | The characteristic polynomial shows that there are 4 distinct imaginary eigenvalues and 3 times eigenvalue 0.
Therefore the matrix $A$ has rank of at least 4. | stackexchange-math | {
"answer_score": 2,
"question_score": -1,
"tags": "linear algebra, polynomials"
} |
Why do clang++ and gcc/g++ produce differently linked executables
When compiling and linking with g++ and clang++ there is an expectation that the resulting executable will be linked equal with respect to their linkage.
However in certain cases it appears that clang++ executables are linked to more libraries than g++ despite the same arguments passed in.
This can cause functional differences especially with respect to dynamically linked libraries that have automatic execution on load and unload.
Why does this happen? | It turns out gcc has a feature enabled by default in ubuntu `--as-needed` which causes gcc to effectively ignore any library for which none of it's symbols are referenced in the chain of linked items
This can be disabled in gcc with `--no-as-needed` flag. Or alternatively you can issue `-Wl,--as-needed` as the first option to clang++ to behave the way gcc does. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 4,
"tags": "c++, gcc, linker, clang"
} |
How to add MDCTabBar in the custom view?
I'm using Material Design library in iOS, I'm trying to add **MDCTabBar** in the custom view below the navigation bar but it doesn't work. Code is like
let tabBar = MDCTabBar(frame: self.mainTabBar.bounds)
tabBar.items = [
UITabBarItem(title: "TAB 1", image: nil, tag: 0),
UITabBarItem(title: "TAB 2", image: nil, tag: 1),
]
tabBar.tintColor = UIColor.white
tabBar.barTintColor = UIColor.theme
tabBar.alignment = .justified
tabBar.itemAppearance = .titles
tabBar.autoresizingMask = [.flexibleWidth, .flexibleTopMargin]
tabBar.displaysUppercaseTitles = true
tabBar.sizeToFit()
self.mainTabBar.addSubview(tabBar)
Here `mainTabBar` is my custom view and it is exactly below the navigation bar. Please help to solve this.
Thanks in advance! | let tabBar = MDCTabBar(frame: self.mainTabBar.bounds)
tabBar.delegate = self
tabBar.items = [
UITabBarItem(title: "Tab 1", image: nil, tag: 0),
UITabBarItem(title: "Tab 2", image: nil, tag: 1),
]
tabBar.tintColor = UIColor.white
tabBar.barTintColor = UIColor.theme
tabBar.alignment = .justified
tabBar.itemAppearance = .titles
tabBar.autoresizingMask = [.flexibleWidth, .flexibleTopMargin]
tabBar.displaysUppercaseTitles = true
tabBar.sizeToFit()
self.mainTabBar.addSubview(tabBar)
Here `mainTabBar` is my customview which is exactly below the NavigationBar. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "ios, material design, material components, material components ios"
} |
Programaticly Move Mouse in VMWare C#
I'm writing a toy application that plays with the mouse cursor, and I'm trying to move it programmticly. Using either `Cursor.Position = ...` or Win32 interop calls work fine on a normal machine, but I'm having difficulties getting it to work under VMWare.
Does anyone have any suggestions?
### EDIT
To clarify:
I've got a small windows forms application I've made running inside the VM, it has one button on it, when clicked it is supposed to move the mouse cursor inside the VM. I've used both the Cursor.Position method and the approach that **Wolf5** has suggested. | I have resolved the issue.
In a desperate attempt to try _anything_ i finally gave up and un-installed the mouse driver from the VM. After a reboot, my toy application works.
The device was listed as a VMWare Pointing device, after the reboot it's coming up as an "unknown device", but the mouse still works. Albeit I a little on the nippy side. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "c#, mouse, vmware"
} |
Set log level in environment variable for certain class in Spring
In order to change log level, how env variable should be named for camel-cased class name?
For example I have `my.package.MyClass`:
`export LOGGING_LEVEL_MY_PACKAGE=DEBUG` works for the whole package well;
`export LOGGING_LEVEL_MY_PACKAGE_MYCLASS=DEBUG` does no effect
`export LOGGING_LEVEL_MY_PACKAGE_MY_CLASS=DEBUG` does no effect | Kudos to @sp00m!
`export SPRING_APPLICATION_JSON='{"logging.level.my.package.MyClass": "DEBUG"}'` solved the problem. Reference to the Spring documentation | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "spring, spring boot"
} |
Logging in from /review redirects to /community (and a 404)
I just tried to log in from review (after recovering from a battery-loss incident) using one of the review log-in links.
> !login
I was able to log in but was re-directed to the 404 because /review has been replaced with /community.
> !community 404
### Steps to reproduce:
1. Log out/open an "incognito" window.
2. Navigate to stackoverflow.com/review
3. Log in.
I'm using Chrome 24.0.1312.57 m on Windows 7, if it's relevant and was logging in using my Google account.
P.S. Is /community something? Was it ever? | If I recall correctly, that path is some ancient pre-release route for the new(-ish) review queues. Looks like it just never got updated in that code path.
The next build will fix it. | stackexchange-meta | {
"answer_score": 4,
"question_score": 5,
"tags": "bug, status completed, review, login, redirection"
} |
Why is exciton diffusion a problem in organic photovoltaics and not in inorganic photovoltaics?
On page 2 of this paper: "When the incident photon hits electrons at the ground state, inorganic semiconductors generate free carriers. However, in organic semiconductors, excited electrons slightly relax and then form an exciton, a bounded electron and hole pair."
Why is this only applicable to organic semiconductors? | For most semiconductor, e.g. GaAs, a exciton has binding energy about 6 meV ($0.006 eV$) and with a binding length about $200 \dot{A}$. That is a very loosely binded state, can be broken into free electron and hole, easier to propagate out of the surface region.
On the contrary, an organic exciton is usually located within the molecule and has a binding energy in order of 1 eV. These make the exciton hard to break, and slow in propagate out of the surface region. | stackexchange-physics | {
"answer_score": 4,
"question_score": 2,
"tags": "condensed matter, solid state physics, semiconductor physics, solar cells"
} |
Bash for loop with unique var names issue
I am using a bash for loop to cycle through a directory and print the file size. My issue though is that I need to assign a unique variable to each of the values so that they can be used later but the array is inputting all the data as one element in the array. I have tried both a double for loop and a if statement with a nested for loop but did not get the right results. Question: How can I fix the below code to match my needs or is there a better method?
declare -a byte
for b in /home/usr/frames/*
do
byte+=$(wc -c < $b)
done
declare -p byte | A variation on OPs original code and jetchisel's answer:
unset byte
declare -A byte # -A == associative array
for b in /home/usr/frames/*
do
byte[$(basename "${b}")]=$(wc -c < "${b}")
done
declare -p byte
* * *
Using some `*.txt` files on my host:
$ pwd
/c/temp/cygwin
$ wc -c *.txt
22 file.txt
405 somefile.txt
214 test.txt
With the modified `for` clause:
unset byte
declare -A byte
for b in /c/temp/cygwin/*.txt
do
byte[$(basename "${b}")]=$(wc -c < "${b}")
done
declare -p byte
Generates:
declare -A byte=([somefile.txt]="405" [test.txt]="214" [file.txt]="22" ) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "bash, for loop, variables"
} |
MySQL-python is not installing in windows 8
While trying to install mysql db for django(1.8.x) using command prompt it shows this error:
error: command 'C:\Users\anonymous\AppData\Local\Programs\Common\Micro osoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2
Maybe this error is too straightforward but I can't figure out that.
Python version is 2.7.3 | The MySQL-python driver needs the binding for MySQL in order to compile, build and install.
On Linux and other systems; it is easy to get a build environment going because these operating systems provide packages to setup a development environment that include all the required libraries to compile and build software.
To install the driver you would have to install the Python source code, and the developer libraries for the MySQL client. On Linux and other systems this is a straightforward process - but on Windows is requires a lot more setup than what is typically done on developer machines.
Therefore, most projects provide a pre-built installed for Windows or a wheel that can be installed without compiling things.
For MySQL-python, the Windows installer is available at the downloads page. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "python, mysql, django"
} |
Convert a string to number with +
Here's an easy one for you true believers: You can use + to convert a string to a number,
var thing = "12"
alert(thing);
alert(typeof thing); // string
thing = +thing;
alert(typeof thing); // number
if (thing == 112) alert("!"); // number
Can someone explain:
1. What is the name of this process?
2. How does + convert a string to a number? | Javascript uses a dynamic type system. For me it's a 'cast' operation.
The operator + could be a String operator ('a' + 'b') or an Number operator (1+2). It could be used also between Strings and numbers (remembering that 0 + '12' = 12 and '0'+'12' = '012')
By default, i think that the JS interpreter considered +thing as 0 + things so it casts this variable to a number | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "javascript"
} |
Image Showing through Spry Menu Bar after hover over
I have the menu working correct on IE with z-indexs but can't get the same results with chrome and firefox. If you go to www.rsd17.org/test/test/untitled1.shtml and on the top spry menu bar hover over students. Then mouse down to any of the items you will see the corner of the picture go through the menu. This is not the case in IE. Anyone know which element I need to change in my css to correct this issue? Let me know if you guys need to see my CSS to help out.
Thanks | fixed the issue by adding in relative position to the menu and submenu, and made the whole bar position absolute. Not sure if this is the correct way to do this, but this is how I fixed my issue. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "css, google chrome, firefox, spry"
} |
Linux terminal emulator with terminal autocomplete?
I've moved from OSX back to Linux and am mostly happy. One of the main things I miss is iTerm2, especially its terminal based autocompletion feature (tmux integration would also be nice).
I've looked around but couldn't find an equivalent in Linux, any pointers?
(p.s.: I know of shell based autocompletion and I know of editor/IDE autocompletion; I use both, but I also want terminal based autocompletion. That's how I roll.) | The closest thing I've seen to iTerm2 is Final Term. However, it's currently in development with the disclaimer
> Final Term is in heavy development and neither stable nor feature complete!
Some of the features it boasts are
* Semantic text menus
* Start command completion
* GUI terminal controls
A list of available/planned features is available here | stackexchange-superuser | {
"answer_score": 2,
"question_score": 0,
"tags": "linux, terminal, autocomplete"
} |
Should I seal sandstone? Based in UK
Deciding between porcelain 18mm and sandstone 24mm both grey. The porcelain cost about 1/3 more however if i have to seal the sandstone the cost isnt that different and over time probably works out more. But i have read conflicting literature saying it doesn't need to be sealed!
Extract from here <
_Do I need to seal sandstone patio slabs? Short answer, no! Leading paving manufacturers Marshalls and Stonemarket don’t recommend coatings and sealants for their sandstone paving. Knowing this will save you time and money! Quality Indian sandstone does not need sealing, so you won't need to seal even the cheapest Marshalls Indian Sandstone Paving._ | It is a personal preference to seal or not to seal. I have sand stone night stands. When we purchased I sealed incase I knock a cup of coffee over or spill something that would stain the surface I don’t want it looking bad. Yes things have spilled and they still look good. Another possible reason for sealing outside work is if it freezes hard. At my current location I won’t use a concrete finishing method I used in the San Francisco Bay Area , it worked great and looked cool there but the occasional hard freeze here would cause the surface to fracture, I believe the same may be true for sand stone but am not sure so if I used sand stone outside I would want to water seal it to prevent freezing damage. But as I said it is personal preference since sand stone is soft as an outside wear surface you may need to seal more often. | stackexchange-diy | {
"answer_score": 1,
"question_score": 0,
"tags": "outdoor, patio, stone, porcelain"
} |
Is the Cauchy sequence of natural numbers countable?
Consider the set consisting of all Cauchy sequences $a_n$ with $a_n \in \mathbb{N}$ for all $n$. Is the set countable?
My idea:
It is straight forward to prove that any such cauchy sequence conatining only natural number can have only finite number of distinct terms i.e. Cauchy sequence consisting entirely of natural numbers, then all of the entries beyond some index are the same natural number.
Now if your consider all the sequences that end with $1$, it is clear that cardinality of this will be more than the cardinality of power set of natural numbers. Over all I can conclude that such a set has to be uncountable.
Can some one please validate the proof especially the second part where I try to prove the cardinality? | The first part of your analysis is fine, but the second is wrong. Consider the set of sequences that are eventually $1$. Let $S_n$ be the set of these sequences that are $1$ for all but at most the first $n$ terms. There is an easy bijection between $S_n$ and $\Bbb N^n$: just throw away all of the ones after the $n$-th term. But $\Bbb N^n$ is countable for each $n\in\Bbb Z^+$, so each $S_n$ is countable, and therefore $\bigcup_{n\in\Bbb Z^+}S_n$, being the union of countably many countable sets, is also countable.
Now do this for each natural number, not just $1$; there are only countably many of them, so you still end up with only countably many Cauchy sequences. | stackexchange-math | {
"answer_score": 5,
"question_score": 2,
"tags": "real analysis, elementary set theory, metric spaces, cauchy sequences"
} |
Why are mined blocks not always full
Why do mined blocks tend to vary so much in size. If the miner's objective is to maximize their revenue from transaction fees they should add transactions starting with the one with the largest fee, working down to the one with the lowest until the pool of waiting transactions is empty. | If you look at recent blocks on < (as of today, Aug 15 2020), nearly all blocks are very close to 4000 kWU. The variation is due to availability of sufficiently small transactions to fill up the last part, and differences in selection algorithms.
Occasionally, an empty block appears instead. These happen as a result of pools learning about a new block faster than they can construct a new template on top, and inform all their hashers. Instead, the instantly tell everyone to start working on an empty block (which is definitely valid), and only when a new full block template is constructed do they inform the hashers of it. This is exacerbated by validationless mining, where the pool may learn about the new block hash tip, before actually having even seen the new block.
So, as far as I can see, in recent times with sufficient pressure for demand, effectively all blocks are full, except for empty ones occasionally. | stackexchange-bitcoin | {
"answer_score": 5,
"question_score": 2,
"tags": "transaction fees, block, miner configuration"
} |
Increasing the JVM heap memory using Xmx doesn't work
I'm developping a javafx application which has much ui interfaces, and while opening many windows, the **jvm** start consumming much memory ( **going up tp 350mb** ).
When it arrives to **360mb** , the programs starts **lagging** and end up by being **crashed** (nothing works, screen blocks ...) and the console show a `OutOfMemoryException` with `Java Heap Space error`
I've **6gb** of memory in my computer, and tried to start the `.jar` file using `-Xmx` param, but still the operating system doesn't allow the **jvm** to consume more memory.
Is there anything else i should specify so that the jvm may be able to get as much memory as it needs ? | You might want to ensure that you're using:
java -Xmx1024m -jar YourApplication.jar
and not:
java -jar YourApplication.jar -Xmx1024m
Anything after the .jar is considered as argument passed to your executable Jar. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "java, javafx, memory, java 8, heap memory"
} |
create custom permission level in SharePoint Site programatically in JSOM or CSOM
I want to create my custom permission level programmatically name "Only Doc Edit" and want to choose only selected value for them viz. Edit Item, view Item etc.. Is it Possible? If yes, How can I achieve this? | **Yes,** we can do it using JSOm as well. Please visit the below ref:
< | stackexchange-sharepoint | {
"answer_score": 3,
"question_score": 9,
"tags": "sharepoint online, csom, jsom, custom permission level"
} |
Живые обои фоном для приложения, как?
Как сделать живые обои, фоном для своего приложения? вдобавок пока что, я видел их только в расширение apk, как быть? | Живые обои основываются `Surface` и рисуются внутри `SurfaceHolder`, вы можете на задний план приложения добавить такой вью и рисовать в нем все что угодно. | stackexchange-ru_stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "android, livewallpaper"
} |
Show that $f$ is summable on $A$ and $\lim_{n\rightarrow \infty} \int_A f_n dm=\int_A f dm$
Show that if $f_n$ is summable on a bounded measurable set $A$ for $n=1,2,\ldots$ and if $f_n$ converges uniformly to $f$ on $A$ then $f$ is summable on $A$ and $\lim_{n\rightarrow \infty} \int_A f_n dm=\int_A f dm$.
Proof: It is enough to show that $\lim_{n\rightarrow \infty} \int_A (f_n-f) dm=0$. We have
$$\Bigg| \int_A(f_n-f)dm\Bigg| \le \int_A|f_n-f|dm\le m(A)\sup_{x\in A} |f_n(x)-f(x)|$$
but $\sup_{x\in A} |f_n(x)-f(x)|$ goes to $0$ as $n\rightarrow\infty$ so
$$\Bigg| \int_A(f_n-f)dm\Bigg| \rightarrow 0 \mbox{.}$$
Is this proof correct? I think I have not proved that $f$ is summable. How can I do it? | The proof that $\lim_{n\rightarrow \infty} \int_A f_n dm=\int_A f dm$ is correct. For the other part, take $n_0$ such that $\sup_{x\in A}|f_{n_0}(x)-f(x)|\leqslant 1$; then $$\int_A|f(x)|\mathrm dm(x)\leqslant \int_A\left(\left|f(x)-f_{n_0}(x)\right|\right)\mathrm dm+\int_A\left|f_{n_0}(x)\right|\mathrm dm(x).$$ Now I this you can finish the proof. | stackexchange-math | {
"answer_score": 1,
"question_score": 3,
"tags": "calculus, measure theory, lebesgue integral, lebesgue measure"
} |
Import images from kitematic to boot2docker
I am on OS X.
I have been using kitematic for some time now, but today I wanted to switch to boot2docker, as I sometimes find kitematic very abstract to the user.
The problem I am facing is, is there a way to use all the images that I built in kitematic, in boot2docker. It took me considerable time to build 2 of them, and I certainly don't want to build them again.
I think one way would be to first push the image to docker hub using kitematic, and then pull it in boot2docker. But, that would consume a lot of data, as the image is pretty large.
The images are right now stored somewhere on my mac, so there must be some way to directly use them in boot2docker, right? | Use `docker save` to save the image to a tar file and `docker load` to load it back in your other vm. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "docker, boot2docker"
} |
Template module names based on position
For instance, if I have a position called 'position-1' and I've multiple modules in position-1. How can I get all module names based on position (in this case 'position-1')? Is it even possible? If so, how? | If you mean programatically, JModuleHelper should return the info you need.
$modules = JModuleHelper::getModules('position-1');
print_r($modules); | stackexchange-joomla | {
"answer_score": 5,
"question_score": 3,
"tags": "module, templates, positions"
} |
Does the Hom-functor $H( _, A)$ take limits to colimits?
Let _Ab_ be the category of abelian groups, and $A$ a finitely generated abelian group. One can deduce the two Hom-functors $Hom(A,\:\\_ \;): Ab \to Ab$ and $Hom(\:\\_ \;,A): Ab^{op} \to Ab$, both of which are covariant. My question is: Do both functors preserve colimits ?
I believe it is true for the first case, however, all my attempts to prove it for the second case fail. Can anybody give me a clue ? | First, by universal property of the limit and colimit both functors preserve limits.
Now let $A=\mathbb{Z}$ and define $B$ as the coequalizer $$ B= \text{coeq}(0,\cdot 2)$$ where $0,\cdot 2\colon \mathbb{Z}\to \mathbb{Z}.$ So in $Ab$, $B\cong \mathbb{Z}/ 2 \mathbb{Z}$ and in $Ab^{op}$, $\color{red}{B}\cong \mathbb{Z}$.
Now $$ \text{Hom}(\color{red}{B},\mathbb{Z})= \text{Hom}(\mathbb{Z},\mathbb{Z}) \ne \text{coeq}(0,\cdot 2) $$ and $$ \text{Hom}(\mathbb{Z}/2\mathbb{Z},B) \cong B \ne \text{coeq}(\text{Hom}(\mathbb{Z}/2\mathbb{Z},\mathbb{Z})\rightrightarrows \text{Hom}(\mathbb{Z}/2\mathbb{Z},\mathbb{Z}) ) \cong 0. $$
This shows that both functors do not preserve colimits. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "category theory"
} |
Can tcp_wrappers be bypassed?
I utilize TCP wrappers to secure services running on my machine. Things like webmail, cpanel, whostmgrd, and so on. I use the hosts.allow/hosts.deny files to facilitate this.
Is it possible for an intruder to bypass tcp_wrappers in order to gain access to my services? | There wouldn't be much value to it if it could be bypassed, now, would it?
There are a number of scenarios in which TCP wrappers might be made ineffective, though. Misconfiguration is almost certainly the most likely -- a mistaken netmask, misspelling of a service name, and so on. You might also be running a service which doesn't support TCP wrappers, which is more common than you might think, and not realise it (configure it in `hosts.deny`, but nothing ever happens). Then there's bugs, which these days I'd consider "unlikely", but you should never discount them completely. | stackexchange-serverfault | {
"answer_score": 2,
"question_score": 0,
"tags": "security"
} |
FQL get friends not authorized my app
How can I get friend list who have not authorized my application yet? I want to send invites to them.
Thanks. | I think I got the answer. Here is the query:
SELECT uid, name, pic_square FROM user WHERE is_app_user=0 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "facebook graph api, facebook fql"
} |
Can patents on computer file formats be obtained?
**Preface**
When talking about file formats (= data formats intended for files), it is easy to confuse the data format and the algorithm used to produce or decode this format. This is mostly due to the fact that for many data formats, there is only one (known) algorithm to produce this data format in a way that makes sense. For this reason, very often the algorithm and the data format are - informally - known under one and the same name. A very good example is MP3, which is both, a certain class of algorithms for encoding/decoding audio data and a file format for storing, besides other information, the data encoded using an MP3-encoding algorithm.
Certainly, it is not impossible to obtain a patent for an algorithm. However, my question concerns the file (data) formats.
**Question**
Is it possible to obtain a patent on a file format, or a data format in general? | In the past, patents have issued that cover data compression and encryption mechanisms that are part of a file format (see MPEG-LA < and also reference the $100 million jpg patent <
However, the Supreme Court has been very actively revisiting what satisfies the requirements for patentable subject matter (i.e. 101 eligibility) and nobody really knows how far they will eventually go with regard to things like software-implemented compression.
File formats are also very likely to be considered essential patents with regard to a standard set by a standards organization, and members of that organization may face additional issues when trying to enforce or license the patent. See < | stackexchange-patents | {
"answer_score": 3,
"question_score": 7,
"tags": "software, computer, file format, data format"
} |
Efficient way to work with JSON Webservices?
What are efficient ways to work with `RESTful JSON` webservices?
Best would be for me if I could work with `POJOs` that are auto-filled somehow after calling a webservice that responds with `JSON` data string.
The webservice does not provide any schema data like WSDL or XSD. I know `Jackson` library can transform json strings into pojos. But therefore the pojos have to exist before.
So, how could I best auto-generate them, preferably using Jackson annotations.
Or otherwise, could you recommend different frameworks? | One way i can think of is to call the restful web service(jax-rs) and use the accept application/xml http header flag, this will return you an xml representation. Then use xjc and jaxb to create a schema and jaxb pojos from the xml, you can then use the same jaxb objects with the accept application/json http header and it should be auto converted into the jaxb java object from the json response. But then again you could have just created a pojo yourself and annotated it with jaxb annotations in the first place. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, json, web services"
} |
What is the default location for rsync uploads?
I uploaded a local text file omitting the remote location and can't find the file (Ubuntu 16.04).
rsync -chavzP dump.sql user@ip-address
It's not in my home directory or anywhere else that I can tell:
find / -name dump.sql -print
I can re-upload with a remote location, but would like to at least find and remove that 6GB dump that I'm not using. | You miss `:` after `user@ip-address`. Without that you will create `user@ip-address` file in the directory where you ran rsync. | stackexchange-askubuntu | {
"answer_score": 12,
"question_score": 5,
"tags": "command line, rsync"
} |
Passing datatable to a stored procedure
I have a datatable created in C#.
using (DataTable dt = new DataTable())
{
dt.Columns.Add("MetricId", typeof(int));
dt.Columns.Add("Descr", typeof(string));
dt.Columns.Add("EntryDE", typeof(int));
foreach (DataGridViewRow row in dgv.Rows)
{
dt.Rows.Add(row.Cells[1].Value, row.Cells[2].Value, row.Cells[0].Value);
}
// TODO: pass dt
}
And I have a stored procedure
CREATE PROCEDURE [dbo].[Admin_Fill]
-- Add the parameters for the stored procedure here
@MetricId INT,
@Descr VARCHAR(100),
@EntryDE VARCHAR(20)
What I want is to pass the datatable to this stored procedure, how? | You can use a Table Valued Parameter as of SQL Server 2008 / .NET 3.5....
Check out the guide on MSDN
Also, as there other options available, I have a comparisonof 3 approaches of passing multiple values (single field) to a sproc (TVP vs XML vs CSV) | stackexchange-stackoverflow | {
"answer_score": 17,
"question_score": 17,
"tags": "c#, .net, sql, sql server 2008"
} |
PowerBI subscription notifications for the latest changes
I was wondering if it is possible to notify / send an email to the PowerBI report subscribers whenever there is a new change to the data in the report?
I saw that the only current options are for periodic notifications (hourly, daily, etc.) and after refreshing, but they are not that helpful. The problem is that there might not be updates once the data refreshes and this notification would be useless. I am interested in sending notifications once new data comes in.
Has anyone had this problem and found a solution or a work-around?
Best regards, Denis | Work-around solution (which is not that elegant).
I created a measure that computes the desired number and displayed it in a card. I pinned this card in PowerBI Service (after publishing the report) as a scoreboard / goal. Then I have set an alarm with a specific threshold which triggers an email notification once this threshold is exceeded.
I created a flow in Power Automate which checks if the threshold has been exceeded and automatically send a PDF to the users.
I could have stopped at the goal alarm notification but this would mean that the users have to set their own alarm individually & manually. By creating the Automate flow, I only have to add their email to the list and they would be notified whenever the threshold is exceeded. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "email, notifications, powerbi, updates, subscription"
} |
Trying to split server response for blackberry app
I am getting the response from the web service as follows:
response = (SoapPrimitive) envelope.getResponse();
String result = response.toString();
The "result" is a long string that consist "CredentialAccepted < / > FirstName < / > LastName < / > Picture". I need to split this result at the tags < / >. I tried the following but BlackBerry does not support. Any help?
List<String> list_result = Arrays.asList(result.split("</>")); | Something like that:
public static String[] split(String original, String separator) {
Vector nodes = new Vector();
String trimmed = original.trim();
int start = 0;
int end;
while ((end = trimmed.indexOf(separator, start)) != -1) {
nodes.addElement(trimmed.substring(start, end));
start = end + separator.length();
}
if (start < trimmed.length()) {
nodes.addElement(trimmed.substring(start));
}
String[] result = new String[nodes.size()];
nodes.copyInto(result);
return result;
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "blackberry"
} |
Слово "кромешный"
Часто в поговорках употребляется слово "кромешный": "кромешный ад", "кромешная тьма". Что означает это слово? | Старославянское слово "кромешный" происходит от слова "край". Раньше считалось, что Солнце освещает только определенный "небесный купол", за пределами которого находится непроглядная тьма. То есть, "кромешный" — означает "находящийся за краем, где всегда темно". | stackexchange-rus | {
"answer_score": 0,
"question_score": 1,
"tags": "фразеология"
} |
time data does not match format '%y-%m-%d'
.date()`
when I run above code, I get below error
.date() | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "python, pandas, datetime"
} |
What network elements does the 'last mile' comprise?
From the Wikipedia entry, I take the 'last mile' of networks to means the point at which network capacity is split from the 'trunk' and provided to individual users. So in my mind this could mean:
1. The link between a wireless receiving device and a wireless emitter (i.e a wifi or mobile connection)
2. The feed from utility poles to a user's home network
3. Are there other examples?
More specifically, are there any components of a network considered to be 'last mile' that handle connectivity for more than a single user?
Also, aside from home-devices such as routers, what network infrastructure elements could be included within a network's 'last mile'? | In general, the so-called "last mile" is a shorthand for the segment at which the network goes from being "very shared" to "hardly shared". It's of course specially an issue where the clients are sparse geographically.
For example, at some kind of distribution point, perhaps a telephone exchange, to each building: the network goes from "thin and shared" such as a fibre, to "bushy and unshared", perhaps copper to each building.
Inside the building under the client control is not generally discussed as part of the issue of the last mile. | stackexchange-networkengineering | {
"answer_score": 4,
"question_score": 1,
"tags": "networking"
} |
How to project specific elements in an embedded schema in Mongoose
I have a schema:
trip : {
source,
destination,
startTime,
endTime
}
and this schema is part of another Schema
tripSchema : {
userId ,
driverId,
trips : [trip]
}
Now I specifically want only source and destination from trip Schema in mongoose. How do I achieve that? | You do this by giving
var projection = {
'trips.startTime' : false,
'trips.endTime' :false,
};
and then
CollectionName.find({query}, projection, function(err, result){
});
Hope this helps someone | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "mongodb, mongoose"
} |
IIS/SQL Server showing RAM is 100% utilized but Processes add up to less than 15% usage
I have a Windows Server 2008 system running IIS 7 and SQL Server 2008 R2 with 64gb of RAM which is showing 100% of the available physical RAM being used at all times.
However, when you look at the memory usage via Task Manager and Process Explorer, all the processes (from all users) add up to less than 6gb of total RAM usage.
I'm trying to figure out what is using the remaining 58gb of RAM and I'm having trouble figuring it out.
Can anybody shed some light on this?
Thanks in advance. | Found the answer over here: <
On the same page, there is a link to a blog post with an even great explanation: < | stackexchange-serverfault | {
"answer_score": 2,
"question_score": 1,
"tags": "windows server 2008, iis 7, sql server 2008"
} |
How to rename a user in MongoDB?
There is a user in database, this user should be renamed. How to rename the user? The MongoDB user management reference has method db.updateUser but I don't see how to set a new name for the user. **How to update the username?** ty
db.updateUser(
"<username>",
{
customData : { <any information> },
roles : [
{ role: "<role>", db: "<database>" } | "<role>",
...
],
pwd: "<cleartext password>"
},
writeConcern: { <write concern> }
) | Did you try to update the user?
db.system.users.update({"user":"oldname"}, {$set:{"user":"newname"}})
This command requires `root` access to admin database. | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 7,
"tags": "mongodb, rename, user management"
} |
Tool to copy file from given 'x' (starting) offset to given 'y' (ending) offset
Is there any tool to copy a file from the given starting offset to the given (end) offset. I also want to confirm that the tool has copies specified bytes rightly by running md5sum. Some thing like this
1) Copy source file starting from 100 byte till 250th byte
$cp /path/to/source/file /path/to/dest/file -s 100 -e 250
2) Create md5sum of the source file starting from 100byte till 250th byte
$md5sum /path/of/src/file -s 100 -e 250
xxxxxx-xxxxx-xxxxx-xxxx-xx
3) Confirm that destination file created from step 1 is right by comparing the md5sum generated from step 2.
$md5sum /path/of/dest/file
xxxxxx-xxxxx-xxxxx-xxxx-xx
I know md5sum doesn't have the option of -s and -e but I would like to confirm by some tool given the source file and the destination file. Thanks in advance | For 1) you can use `dd`:
# dd if=/path/to/source/file of=/path/to/destination/file bs=1 skip=100 count=250
For 2) I'm not really sure if that's achievable with standard tools.
[edit]
Aha, found a way:
For 2)
# dd if=/path/to/source/file bs=1 skip=100 count=250 | md5sum
And for 3)
md5sum /path/to/destination/file | stackexchange-stackoverflow | {
"answer_score": 16,
"question_score": 8,
"tags": "linux, unix"
} |
Embedding of separable $C^*$-algebra
Let $A$ be a separable $C^*$-algebra. Can $A$ embedded into a separable, simple $C^*$-algebra? | In B. Blackadar, Weak expectations and nuclear C -algebras. Indiana Univ. Math. J. 27 (1978), 1021-1026. Blackadar shows that every separable subalgebra of a simple $C^*$-algebra is contained is a simple separable $C^*$-subalgebra of $A$. In particular, every separable $C^*$-algebra can be embedded into a simple separable $C^*$-algebra (since it can be embedded into the Calking algebra). | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "functional analysis, operator theory, operator algebras, c star algebras"
} |
How to use symbolizer in openlayers3
How to use symbolizer in openlyers3? I need to display my line with double dashed.
We have option in 2 like symbolizer : {strokeDashstyle:"dash"}
Please help me.. | You can specify a **lineDash** option under ol.style.Stroke See:
<
(you'll need to untick stable at the top right)
E.g.
stroke: new ol.style.Stroke({
color: 'blue',
lineDash: [4],
width: 3
})
Take a look at the triangular polygon in blue at <
The lineDash type is an array describing the dash pattern. | stackexchange-gis | {
"answer_score": 4,
"question_score": 2,
"tags": "style, openlayers"
} |
Filtering nested data in Angular 2
I have a many to many relationship between Books and Categories and I want to filter the books by category. What I am missing here ? because it returns unfiltered books.
ngOnInit(): void {
this.bookService.getBooks()
.subscribe(
books => {
this.filteredBooks = books.filter(
book => book.categories.filter(cat => cat.categoryId === this.route.snapshot.params['categoryId']));
this.route.params.subscribe(params => {
this.categoryId = params['categoryId'];
this.updateList();
});
});
}
updateList() {
if (this.categoryId > 0) {
this.books = this.filteredBooks;
}
}
Thanks a lot ! | Try by using `find` in the second search
this.filteredBooks = books.filter(
book => book.categories.find(
cat => cat.categoryId === this.route.snapshot.params['categoryId']
) != undefined); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "angular, typescript, filter"
} |
Words to Disambiguate Alphabet Letters from Others
Dictating e-mail/website addresses each one letter by one **on a phone call** is always challenging for me. I found that listeners often misspell certain letters like B/D/V because the pronunciation is distorted.
With a list of 26 words that represent each alphabet letter, if any, communications are going to be easier:
> I: R-A-N-D-O-M-A-L-P-H-B-E-T.
>
> Listener: (Simultaneously) R-A-N-D-O-M-A-L-P-H... wait. _D or B_?
>
> I: It's B. _B of 'black'_.
'Black' is a quick example of my own but seems good enough because 'black' is simple, easy, and there's no word such as "vlack", "dlack", "glack", etc.
I'd love the list of words like 'black' if there is already one in common use. | What you are describing is called a _phonetic alphabet_.
There are a number of common phonetic alphabets used in the English language.
One of the most popular ones is the International Civil Aviation Organization (ICAO) alphabet, commonly called the NATO phonetic alphabet. See < for a complete reference. | stackexchange-ell | {
"answer_score": 17,
"question_score": 9,
"tags": "word choice, spelling"
} |
The leaves of my aloe plant are growing stacked. Is that okay?
So I have had this aloe plant for three years and she has been doing fairly well, producing plenty of pups (the ones in the pot have grown since I separated 7 from her 4 months ago) but I have noticed that her leaves are growing on top of each other instead of fanning out. Should I be worried or is there something that I can do to help her? Thanks in advance! 
In the offline section of the docs, it says in the offline.iplot section:
> "To embed an image of the chart, use `plotly.image.ishow`."
which requires online authentication. | The answer is to create an account and use `plotly.image.ishow`, given it doesn't save the picture on their servers. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, ipython, jupyter, plotly"
} |
R - Can I have a matrix with different number of columns for rows?
This might be a stupid question. I have some 'NA' in a matrix, I need to put this matrix into jags model, but I want to remove those NA. Can I remove only NA but keep the rest of the data?
My data looked like the picture below. Can I have rows with different column numbers?
 format('eot'), url('GraublauWeb.woff') format('woff'), url('GraublauWeb.ttf') format('truetype');
}
And ran it through yui-compressor
@font-face{font-family:'Graublau Web';src:url('GraublauWeb.eot?') format('eot'),url('GraublauWeb.woff') format('woff'),url('GraublauWeb.ttf') format('truetype')}
It appears that the minimized css will work just fine in this case.
Edit: It doesn't appear that you should be worried about base64 encoded data in font face src urls either. I ran the css from this example page < through yui-compressor, pasted it back into the file and opened it in my browser without any problems. | stackexchange-webmasters | {
"answer_score": 1,
"question_score": 0,
"tags": "css3"
} |
Laravel pagination with relations
Being new to this framework faced a problem that the resultset is not paginated with the use of standart `->paginate()` method if I want to get the result with relations. What is the best approach to achieve the desired ?
Here is my method :
public function findAll($perPage = 15, $order = 'ASC', $orderBy = 'id')
{
$users = User::orderBy($orderBy, $order)->with('permissions','companies')->paginate($perPage);
$users = $users->toArray();
return $users['data'];
} | There's actually no need to convert the result object into array, so in your example you can actually do something like this in the function:
$users = User::orderBy($orderBy, $order)->with('permissions','companies')->paginate($perPage);
return $users;
Then to access the values in your view:
foreach ($users as $user){
echo $user->name;
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "php, laravel, laravel 4"
} |
How do you restric maximum length of elements in language of context free grammar
How does one restrict the maximum length of elements in a context free grammar.... How would you structure rules to say only allow for elements of language to be of length seven and less. | With this you can even express it as a REGEX/FSA. All you need to do is essentially the same thing as you would in those machines, which is to make `n` amount of nodes which in your case 7. Basically it looks like this.
R -> <1><2>...<7>
<1> -> elements. | e
<2> -> elements. | e
..
<7> -> elements. | e | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "context free grammar, context sensitive grammar"
} |
vb.net creating data table?
I'm using vb.net / winforms. How can I convert 10 lines with three columns into a DataSet/DataTable?
Lines are something like this:
Item-1, $100, 44
Item-2, $42, 3
etc | Dim Table1 As DataTable
Table1 = New DataTable("TableName")
Dim column1 As DataColumn = New DataColumn("Column1")
column1.DataType = System.Type.GetType("System.String")
Dim column2 As DataColumn = New DataColumn("Column2")
column2.DataType = System.Type.GetType("System.Int32")
Dim column3 As DataColumn = New DataColumn("Column2")
column3.DataType = System.Type.GetType("System.Int32")
Table1.Columns.Add(column1)
Table1.Columns.Add(column2)
Table1.Columns.Add(column3)
Dim Row1 As DataRow
Row1 = Table1.NewRow()
Row1.Items("Column1") = "Item1"
Row1.Items("Column2") = 44
Row1.Items("Column3") = 99
Table1.Rows.Add(Row1)
' Repeat for other rows | stackexchange-stackoverflow | {
"answer_score": 25,
"question_score": 14,
"tags": "vb.net, datatable"
} |
is it possible to feed highlighted text as input to grep
I use grep to find unique (marker) text among a large number of files.
grep MarkerText -r -C 30 -h ~/helpfiles/*
Is it possible to feed a highlighted text as input to my grep command so that the highlighted text replaces MarkerText in this command? I am hoping to avoid having to copy and paste all the time. | Yes, sure - there is `PRIMARY` selection in X11.
> PRIMARY selection, is used when the user selects some data. X Window: Clipboard
You can use either `xsel` or `xclip` cli tools:
## TL;DR
1. Select some text
2a. `grep "$(xsel)" -r -C 30 -h ~/helpfiles/*`
OR
2b. `grep "$(xclip -o)" -r -C 30 -h ~/helpfiles/*`
## Precondition
* `xsel` or `xclip` package installed: `apt get install xsel` or `apt get install xclip`
* `X` server is running (i.e. you use X server, not text-mode without X server): `xset q > /dev/null && echo "X is running" || echo "start X server"`
## Explanation
Both `xsel` and `xclip` are clipboard management tools. Commands `xsel` and `xclip -o` print to `STDOUT` contents of `PRIMARY` selection. More info you can find here: 'xclip' vs. 'xsel'
Use double quotes around `$()`. This allows to highlight more than 1 word. | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 1,
"tags": "grep, clipboard"
} |
How to raise error if cap deploy was not invoked using bundle exec
I just encountered a subtle issue with capistrano deployment gem dependencies and I would like to enforce how capistrano is invoked.
How can I detect that capistrano was invoked using 'bundle exec' like this:
bundle exec cap app deploy
And not like this:
cap app deploy
I would like to raise an error in the latter case by detecting the method of invocation at the top of my deploy.rb file. | It appears that Bundler sets the $BUNDLE_BIN_PATH and $BUNDLE_GEMFILE environment variables when running executables. For example, do this:
env >/tmp/1
bundler exec env >/tmp/2
diff -u /tmp/[12]
You'll see the differences in the environment.
So then in your deployment script, you can do something like this:
abort "You must run this using 'bundle exec ...'" unless ENV['BUNDLE_BIN_PATH'] || ENV['BUNDLE_GEMFILE']
Hope this helps. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 2,
"tags": "ruby on rails, capistrano, bundler"
} |
Mathematics and logs
For this indirect utility function:
v(y) = ln(1/3 y) + 2 ln (2/3 y) = 3 ln(y) + ln (4/27)
How did they simplify to 3 ln(y) + ln (4/27)?
Im a bit confused, if there is a site helping with this review it would be helpful. Thanks | $$\ln\left(\frac 13 y\right) = \ln\frac 13 + \ln y$$ $$2 \ln\left(\frac 23 y\right) = 2 \ln\frac 23 + 2 \ln y$$ $$\ln\frac 13 + 2 \ln\frac 23 = \ln\frac 13 + \ln\left(\left(\frac 23\right)^2\right) = \ln\left(\frac 13 \cdot \left(\frac 23\right)^2\right)$$
Put these facts together with $v(y) = \ln\left(\frac 13 y\right) + 2 \ln\left(\frac 23 y\right).$ | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "algebra precalculus"
} |
Are $\Bbb Q[x]/<x^2-1>$ and $\Bbb Q[x]$ isomorphic to any subring of $\Bbb R$?
Are $\Bbb Q[x]/<x^2-1>$ and $\Bbb Q[x]$ isomorphic to any subring of $\Bbb R$?
We know that $x^2-1$ is not irreducible so the quotient ring $\Bbb Q[x]/<x^2-1>$ is not a field. But I am wondering whether it is possible to identify that by some subring of $\Bbb R.$ What is confusing about this is that we are like adjoining a square root of $1$ but we know that the square root of $1$ already exists in the field of $\Bbb Q.$ Also, how about $\Bbb Q[x]$? Is $\Bbb R$ an extension of $\Bbb Q[x]?$ | First of all, $\Bbb Q[x] \cong \Bbb Q[\pi]$ (since $\pi$ is transcendental) and $\Bbb Q[\pi]$ is a subring of $\Bbb R$. So $\Bbb Q[x]$ is isomorphic to a subring of $\Bbb R$.
As for $\Bbb Q[x] / (x^2 - 1)$. Since $\Bbb R$ is zero divisor free, any subring of $\Bbb R$ will also be zero divisor free. But $\Bbb Q[x] / (x^2 - 1)$ isn't (since $(x-1)(x+1) = 0$), so is can't be isomorphic to any subring of $\Bbb R$. | stackexchange-math | {
"answer_score": 2,
"question_score": 3,
"tags": "ring theory, field theory, extension field"
} |
Nginx root to one file in a directory and deny all the others
I have **one** app folder with **many dev files** , among them there is an **index.html** file.
I would like nginx to serve this index.html **only** :
domain.com/ -> app/index.html
and `deny all` the other files/subfolders.
Here is what I have right now, but it works only for **domain.com/index.html** :
server {
listen 80;
server_name domain.com;
root /home/app;
location / {
deny all;
location ~ \.(html)$ {
allow all;
}
}
}
Any ideas? Thanks. | There are many ways to structure this, but an exact match location is useful to extract a single URI. I use an empty directory (`/var/empty`) if the default is to deny access:
root /var/empty;
location = / {
root /home/app;
rewrite ^ /index.html break;
}
See this document for details. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "nginx"
} |
Writing json from two lists in Python
I am new to Python. I have two lists. One is key list and another list is value list.
title = ["Code","Title","Value",....] value = [["100","abcd",100",...],["101","efgh",200",...],...] data={} data.setdefault("data",[]).append({"code": sp[0],"val": sp[2]})
this code gives me the following result.
{'data': [{'code': '100', 'val': '100'},{'code': '101', 'val': '200'}]}
But I want the result as the below,
{ "100": { "Title": "abcd", "Value": "100", ............, ............}, "101": { "Title": "efgh", "Value": "200", ............, ............} }
i.e., The first column of the value list should be the key of every Json array list and other items of the lists should be generated as key and value pair. How can I generate the Json array using Python code referring that two lists. | As it is not mentioned that about the size of list ,the below could would do the job.I am using python3.x
title = ["Code","Title","Value"]
value = [["100","abcd","100"],["101","efgh","200"]]
dic1={}
for i in range(len(title)-1):
for j in range(len(title)-1):
dic1.setdefault(value[i][0],{}).update({title[j+1]:value[i][j+1]})
Output is
{'101': {'Title': 'efgh', 'Value': '200'}, '100': {'Title': 'abcd', 'Value': '100'}}
I hope it is helpful! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, json"
} |
Where to allocate one time use class?
Lets consider the following code:
void main(int argc, char* argv[])
{
Foo foo;
//at this point I don't need foo any more
//a lot of stuff here
}
If I only need `foo` only for short amount of time,isn't it would be better to allocate it on a heap and delete before executing rest of the code? | No, it's better to write an _inner scope_.
int main()
{
{
Foo foo;
// use foo
}
// more code
}
But doing this should be a hint that it might be better to put foo in a completely separate function.
There's no reason to use heap allocation here though. That solution would be worse than the problem. | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 0,
"tags": "c++, memory management"
} |
Condition on convergent filter bases imply a function is continuous
I'm trying to understand an implication in a theorem. Suppose you're given topological spaces $(X,\mathcal{T})$ and $(Y,\mathcal{U})$ and $f\colon X\to Y$. Then if for every convergent filter base $\mathcal{F}\to x$ in $X$, $f[[\mathcal{F}]]\to f(x)$ in $Y$, then $f$ is continuous.
$f[[\mathcal{F}]]$ is the set of all direct images of $f$ on the sets $A$ in $\mathcal{F}$. The proof says take any $U\in\mathcal{U}$ and $x\in f^{-1}(U)$. The filter $\mathcal{F}$ of all neighborhoods of $x$ converges to $x$, so $f[[\mathcal{F}]]\to f(x)$. For some neighborhood $V$ of $x$, $f[V]\subset U$, so $V\subset f^{-1}(U)$, and $f^{-1}(U)\in\mathcal{T}$.
I don't understand the last part. Why would $V\subset f^{-1}(U)$ imply that $f^{-1}(U)$ is an open set in $X$? | In general it does not true that $V\subseteq f^{-1}(U)$ implies that if $V$ is open then $f^{-1}(U)$ is open.
However, recall that a set $U$ is open if and only if for every $x\in U$ there is an open $V\subseteq U$ such that $x\in V$.
In the proof given in your question, we take an arbitrary $x\in f^{-1}(U)$. For every such $x$ set an open $V_x$ which is a subset of $f^{-1}(U)$ given by the proof.
Now we have that $V_x\subseteq f^{-1}(U)$ and therefore $\bigcup \\{V_x\mid x\in f^{-1}(U)\\}\subseteq f^{-1}(U)$. As well for every $x\in f^{-1}(U)$ we that $x\in V_x$, so the inclusion is actually equality.
Therefore $f^{-1}(U)$ is exactly the union of all these open sets, and thus open. | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "general topology, continuity, filters"
} |
How to see a json object's format?
I'm using Django as back-end,in my view.py I return a json object as
return HttpResponse(json.dumps(result))
and in my front-end, in a javascript file I received with
jsonResult = JSON.parse(result);
it is successful cause I can see the variable "jsonResult" if I use the console to check it, just as:
console.log(jsonResult);
**The problem** is that I want to see its **format** , as something like this:
{
"tags":{
"tag":[
{
"time":"67",
"comment":"test 2",
"id":"18",
"owner":"xiaoli",
},
{
"time":"30",
"comment":"",
"id":"28",
"owner":"xiaoli",
}
]
}
}
How can I do this? Or if I can generate a json file? Thanks. | The result of your HTTP request is a string. So you do :
jsonResult = JSON.parse(result);
to parse this string (result) in an object (jsonResult).
So if you want to see this json as a string, you just have to :
console.log(result);
Or add it to an element | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, json"
} |
Delete all Rows that couldn't find a JOIN?
I have this query:
SELECT Auctions.ID
FROM Auctions
INNER JOIN Products ON Auctions.ProductID = Products.ID
Now as far as i know if i have an auction:
ID | ProductID
1 | 12
And the ProductID 12 is not on the Products table, so the row wont be selected.
If i am right, i want to delete all the rows that didn't found the Product ID on the Products table. (the products that couldn't find a JOIN)
How can i do that? | DELETE Auctions WHERE ProductId NOT IN(SELECT ProductId FROM Products)
Of course, after you do this, do yourself a favor and create a Relationship from `Auctions.ProductId` to `Products.ProductId` if you don't want to do this again. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "sql, sql server, select, inner join"
} |
$f : \mathbb{C} -> \mathbb{C} f(z) = x^2 + axy + by^2$
Find $a,b$ from $\mathbb{C}$ such that $f : \mathbb{C} \to \mathbb{C},\ f(z) = x^2 + axy + by^2$ for every $z = x + iy$ from $\mathbb{C}$ is holomorphic on $\mathbb{C}$
I've tried to derivate $f$ with respect to $z$ conjugate using $\frac{1}{2}(f_x' + f_y') = 0$ but i get $x = y = 0$ after solving the system | Let $a=\mathrm{Re}\,a+i\,\mathrm{Im}\,a$ and $b=\mathrm{Re}\,b+i\,\mathrm{Im}\,b$, so $$u(x,y)=\mathrm{Re}\,f(z)=x^2+\mathrm{Re}\,a\,xy+\mathrm{Re}\,b\,y^2,$$ $$v(x,y)=\mathrm{Im}\,f(z)= \mathrm{Im}\,a\,xy+\mathrm{Im}\,b\,y^2.$$ Let $f$ be entire function. Then Cauchy - Riemann equations hold on $\mathbb{R}^2$:
$u_x=v_y$ and $u_y=-v_x$ for all $x,\,y$
giving you: $$2x+\mathrm{Re}\,a\,y=\mathrm{Im}\,a\,x+2\mathrm{Im}\,b\,y,$$ $$\mathrm{Re}\,a\,x+2\mathrm{Re}\,b\,y=-\mathrm{Im}\,a\,y.$$ So $$\mathrm{Im}\,a=2,~\mathrm{Re}\,a=2\mathrm{Im}\,b,~\mathrm{Re}\,a=0,~2\mathrm{Re}\,b=-\mathrm{Im}\,a$$ i.e. $a=2i,\,b=-1$ and $f(z)=z^2$ (which is clearly entire function). | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "complex analysis"
} |
How to use mysqli without implementing the prepared statement?
<?php
...........
$connection = mysqli_connect('......com', 'login', 'password',
'dbname');
if (!$connection) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo "Connection Successful";
// creating a query
mysqli_query($connection, "INSERT INTO `users` (`userid`,`firstname`, `lastname`, `username`, `email`,
`password`) VALUES (NULL, $firstname, $lastname, $username,$email,$password);");
mysqli_close($connection);
// printing to the screen
echo "Welcome $lastname . You have successfully logged in!";
?>
The connection is OK, but the values do not get inserted. How can I improve my code? I do not understand why the values donot get inserted into the database. I have checked the variables, they are fine. | try this "INSERT INTO `users` (`userid`,`firstname`, `lastname`, `username`, `email`,
`password`) VALUES (NULL, '$firstname', '$lastname', '$username','$email','$password');" | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "php, mysqli"
} |
angularjs passing in css file to header in IE
I am currently trying to pass a css file to a iframe. I got the css to work correctly in Chrome but not in IE. When trying to add it to the header, it translate the value directly and not the angular text. It changes the {{}} into the url without converting it.
Example:
<head>
<link href="{{css}}" rel="stylesheet" type="text/css">
</head>
In Chrome comes out as
> <
In IE
> /%7B%7Bcss%7D%7D
Is there a way to convert it in angular to embed the css correctly. | Pankaj Parkar put me on the right track with this one. The href needed to be handled as angular ng-href to smooth out the special characters.
Here is the correct answer:
<link ng-href="{{css}}" rel="stylesheet" type="text/css"> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "html, css, angularjs"
} |
Have a Javascript which works in Chrome and Firefox but not IE
I've created a simple javascript to select all check boxes. It works in two browsers but not one. Can anyone help me with this script to make it compatible with IE8 or above.
<script language="JavaScript">
function toggle(source) {
checkboxes = document.getElementsByName('marked[]');
for(var i in checkboxes)
checkboxes[i].checked = source.checked;
}
</script>
<p>
<input type="checkbox" onClick="toggle(this)" /> Select All
</p>
Thanks,
Jonah | Try plain loop:
for (var i = 0; i <checkboxes.length; i++) {
checkboxes[i].checked = source.checked;
}
The `getElementsByName` returns HTMLCollection which is not plain array, and probably treated differently in each browser. Most likely Firefox and Chrome returns the indices when using the `for(var i in checkboxes)` loop while IE returns the items themselves - plain loop should solve this, as the basic syntax is the same for all browsers. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 0,
"tags": "javascript"
} |
Opening a .zbd file
I have a .zbd file from my military service with sensitive information on it from 2004.
I have downloaded the ZoomBrowser from Canon, it does not recognize it as a file.
I downloaded the Zebedee Secure Tunnel, but that just creates a tunnel, and is not a file viewer.
I have downloaded a number of free file viewers, but none seem to open this file.
Any assistance you could give is immensely appreciated. | < says File Type 2 EPSQ Database
with description:
Encrypted file format used by the U.S. military and Department of Defense for Electronic Personal Security Questionnaire (EPSQ) documents; most often used for the Standard Form (SF) 86 Questionnaire, which is used by military personnel, government employees, and government contractors to apply for a Security Clearance.
That seems like what you're looking for.
According to this site and several like it there's a Windows program "DoD EPSQ" that can read this.
According to < that software can be downloaded from < but that website no longer exists.
Another person had a similar question here: < but not sure if the linked dropbox file is correct (or safe). Good luck. | stackexchange-retrocomputing | {
"answer_score": 4,
"question_score": 1,
"tags": "file format"
} |
Reset Input and Textarea fields without form.reset
For a few reasons, I can't have a `<form>` tag on the page, but I do have `<form>` elements like `<input>`, `<textarea>`, and `<button>`. I have a reset button and I need to reset everything inside the input and textareas when I click the button. There's also quite a few input boxes.
Additionally, there is a php script that fills in `<span>` tags with requested information that I would also like to make blank again when pressing the button.
Some example code below
HTML
<button id="reset" onclick="resetFields()">Reset Fields</button>
<input id="myID" type="text">
<input id="myID2" type="text">
<span id="mySpan">Some text here</span>
<span id="mySpan2">Some text here</span> | I think that is what you want:
function resetFields(){
var inputArray = document.querySelectorAll('input');
inputArray.forEach(function (input){
input.value = "";
});
var textAreaArray = document.querySelectorAll('textArea');
textAreaArray.forEach(function (textArea){
textArea.innerHTML = "";
});
var spanArray = document.querySelectorAll('span');
spanArray.forEach(function (span){
span.innerHTML = "";
});
} | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "javascript, html, button, reset"
} |
Ruby on Rails queue question
I have been trying to figure out a solution but nothing has really presented itself to work. I am building a system that sends out emails (among other things), and I have been trying to figure out a way to have the queuing of messages work. I would like to provide the user a (somewhat) accurate count of the messages sent so far. I was thinking of having the user facing page, and then another page that would start the sending process and continually output (no like a refresh, just kind of a real-time output) and then parse that and make the information more user-friendly. I'm open to any suggestions on how I could do this, and thanks for any ideas ahead of time! | See this question about message queues in rails.
Essentially, choose a messaging queue and interogate it for the status once in a while with a jquery ajax timer or something. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, message queue"
} |
Solving a Diffrential Equation by Taking Derivative
Taking a derivative of a differential equation and solving it is one approach to solving a differential equation. However, for some reason I can't get this method to work in cases where there is an interaction term.
Let's consider the differential equation:
$$y'+yx=0$$
Derived with respect to x we have:
$$y''+y'x+x'y = 0$$
$$\rightarrow y'' +y'x+y=0$$
If the differential equation is solved the answer is different for the equations above. Is there something that I am missing when taking the derivative of the equation? | if the D.E is $y'+xy=0$, the solution is $$y=c_1e^{\frac{-x^2}{2}}$$
if the D.E is $y''+xy'+y=0$, the solution is $$y=c_1e^{\frac{-x^2}{2}}+\sqrt{\frac{\pi}{2}}c_2e^{\frac{-x^2}{2}}erfi(\frac{x}{\sqrt{2}})$$ so that $erfi(x)$=imaginary error function
to find the $c_2$ $$y'=-c_1xe^{\frac{-x^2}{2}}-x\sqrt{\frac{\pi}{2}}c_2e^{\frac{-x^2}{2}}erfi(\frac{x}{\sqrt{2}})+\sqrt{\frac{\pi}{2}}c_2e^{\frac{-x^2}{2}}\sqrt{\frac{2}{\pi}}e^{\frac{x^2}{2}}$$ $$y'=-c_1xe^{\frac{-x^2}{2}}-x\sqrt{\frac{\pi}{2}}c_2e^{\frac{-x^2}{2}}erfi(\frac{x}{\sqrt{2}})+c_2$$ substitute it in $y'+xy=0$, to get $$c_2=0$$ so the solution will stay without any change | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "ordinary differential equations, multivariable calculus"
} |
android - is it possible to update the Android Dev Phone 2 sold by google to 2.1 OS?
If I have a Android Dev Phone 2 phone that comes with 1.6, can I upgrade it to Android 2.1 ?
Thanks | No. The latest supported version is 1.6. If they will release an update I think you will find it here:
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "android, version"
} |
VisualStudio 2010 freezes anytime I delete a file
Anytime I delete a file in VisualStudio, the entire thing freezes and needs to be ended from TaskManager. I was hoping someone could help me troubleshoot this (or at least point me in the right direction to ask this question)
Facts:
* I am using Visual Studio 2010 Premium
* I have Windows XP
* I have no VS addins
* Moving a file, or Cut/Pasting it works fine. It's only when I delete that I freeze
* The file actually gets deleted, but my UI freezes and when I end program and restart it, the reference is still there and needs to be removed
* I can create a blank project, add a file, and delete the file to get it to crash on me
* CPU usage hangs at around 3-5% in Task Manager until I end the program | The company uses Symantec Endpoint Protection v11, [...]
I don't know this antivirus software very well, but you could always try to temporarily disable it. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 5,
"tags": "visual studio, freeze"
} |
Newly signed assembly not found (stopping deployment)
Quite an urgent one this - my solution wouldn't build because a referenced assembly (another project) needed signing with a strong name key. I signed it and it's now "system cannot find the file specified" when trying to deploy!? I've checked windows\assembly and it's not in there.
NOTE: This is when I attempt to deploy a dependent project/feature to SharePoint. It builds fine, but fails on 'Activate Features'. | Sorted it now; I'll post the answer just in case anybody else comes up against the same problem.
For the wsp I'm deploying to also deploy the project dependency - it needs to be included in the project manifest. You get to this by double clicking on Package (in the primary project being deployed) > Advanced tab at the bottom > and then adding the assembly from project output. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, deployment, sharepoint 2010, .net assembly, strongname"
} |
Was there a Taboo trace charm associated with the name "Tom Riddle", or just with the name "Voldemort"?
Wizards refered to him as "He Who Must Not Be Named" long before the Taboo charm was placed on the word "Voldemort" in the Deathly Hallows.
According to _Wikipedia_
> "Throughout the series, Rowling establishes that Voldemort is so feared in the wizarding world that it is considered dangerous even to speak his name. Most characters in the novels refer to him as "You-Know-Who" or "He-Who-Must-Not-Be-Named" rather than say his name aloud. In Harry Potter and the Deathly Hallows, a Taboo is placed upon the name, such that Voldemort or his followers may trace anyone who utters it. By this means, his followers eventually find and capture Harry, Ron, and Hermione."
Was there a Taboo trace charm associated with the name _Tom Riddle_? | I don't think it's answered in canon, but I would be surprised if Tom Riddle had been part of the taboo. Voldemort had shown many times that he does not want his Tom Riddle heritage to be known about. Putting his real name at the same level as "Voldemort" would effectively be acknowledging his history that he spent a long time concealing. | stackexchange-scifi | {
"answer_score": 19,
"question_score": 6,
"tags": "harry potter, voldemort"
} |
Can any one tell me how the conduit.com works?
Can any one tell me how the conduit.com works??
Hi i want to make something like conduit.com...how this website works.means how they generate an executable in runtime.i want to make in C# and Asp.net..
Please help
thank you
* * *
What i am asking is that how it generates installation files dynamically... | "how it generates installation files dynamically"
Probably using something like nullsoft NSIS - <
They'd make a generic install script, and replace a few files as per the customised toolbar, and then re-run the NSIS compiler and send you its output.
-edit- Another option is InnoSetup - < \- I've used it before and it's quite good. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, toolbar"
} |
Reference generated primary key in SQL script
I'm trying to create a bunch of entries in a database with a single script and the problem I'm encountering is how to reference the generated primary key of the previous entry I created.
For example if I created a customer, then tried to create an order for that customer, how do I get the primary key generated for the customer?
I'm using SQLServer. | Like so:
DECLARE @customerid int;
INSERT INTO customers(name) VALUES('Spencer');
SET @customerid = @@IDENTITY;
**EDIT:**
Apparently it needs to be SCOPE_IDENTITY() in order to function as expected with triggers.
DECLARE @customerid int;
INSERT INTO customers(name) VALUES('Spencer');
SET @customerid = SCOPE_IDENTITY(); | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "sql, sql server, primary key"
} |
jQuery fadeIn() and fadeOUt() without delay
Please see the attached JSFiddle.
Div1 (red) fades out to show div2 (blue). It all works fine. But there is a small time in between div1 fading out and div2 fading in when its all white. I understand it is because of the fade in code being inside the fadeOut completion.
Is there a way I can start the fadeout half way through the fade in. I have to do it with images, kinda mimic a slider.
I have tried using z-index on two images and using a delay on the fadeIn, but that doesnt seem to work well. Its stacks the images one below the other. Not sure if I can use z-index with images
Any help is appreciated.
<
$('#div1').fadeIn();
setTimeout(function(){
$('#div1').fadeToggle(600,function() {
$('#div2').fadeToggle(600);
});
},4000); | Here's one way to do what you're after. Fade out the first div and then after a short delay, fade in the second. Position them so that they sit on top of each other by using abolsute positioning:
$('#div1').fadeIn();
setTimeout(function () {
$('#div1').fadeOut(600)
setTimeout(function () {
$('#div2').fadeToggle(600);
}, 300);
}, 4000);
**jsFiddle example** | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "jquery, html, css, slideshow"
} |
Understanding short hand for loops in c++
I am very new to C++. I am trying to figure out this sample short hand for loop from my book, it is very long and ugly and was wondering if this can be re written in a cleaner way. Ignore the functions in there like before() and others, they are part of a linked list program I am working on. I just do not understand from my book how to re write the loop in a more "traditional" way. Thanks in advance!
fooExample(string str){
string s = toLower(str);
for(books->setEnd();!books->atStart() && (toLower(books->getInfo().getAuthor()).search(s)==string::npos);books->before());
} | The form for for-loops in C++ looks like this:
for(initialisation; condition; incrementation)
{
//code
}
So you could do something like
for(unsigned int i = 0; i < 10; ++i)
{
std::cout << "i = " << i << std::endl;
}
The principle in your code is the same; there is an initialisation, a condition, and not really an "incrementation", but something that happens every iteration of the loop(I guess it goes to the previous book). | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "c++, for loop, shorthand"
} |
Write Query in CDBCriteria in Yii with Where and Group By clause
I have this query, I want to do this query using CDbCriteria. Model is `Clog`
SELECT c.id, c.answer, c.number
FROM `Clog`as c
WHERE c.company_id =20
AND date(c.answer) = '2016-04-02'
GROUP BY c.calls_id
HAVING count(c.id) <2
This is what i have tried so far.. is it a proper way to use WHERE, GROUPBY, HAVING COUNT.. in CDbCriteria.. This is my search function in a model `Calls`
$criteria = new CDbCriteria();
$criteria->select = 'c.id, c.answer, c.number';
$criteria->addCondition(' c.company_id='.$this->companyId);
$criteria->addBetweenCondition(' c.answer', ''.$this->start_date.'', ''.$this->end_date.'');
$criteria->group = 'c.calls_id';
$criteria->limit < 2;
Any suggestions, how to achieve this in Search function of model, because i want to show the result in CGridView... | The field you group by "c.calls_id" should exist in your select statement
$criteria->select = 'c.id, c.answer, c.number, c.calls_id';
The proper statement for "having" is, for example:
$criteria->having = "count(c.id) < 2"; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, mysql, yii"
} |
Difference in type conversion between C and C++?
The last example in this tutorial regarding Implicit type conversion states that `std::cout << 5u - 10;` will produce `4294967291` rather than `-5` due to type conversion. I tried this in both C and C++. The result in C++ was as promised, however when using C (`printf("%d\n", 5u - 10);`) the result was `-5`. What happened? | In the C example there is no type conversion whatsoever. C just evaluates the expression `5u - 10` and pushes the result onto the stack. Then printf sees a type character and interprets the value on the stack as such when printing it. The type character is `d` (`%d`) meaning "decimal integer" and hence the position on the stack is retrieved as an int and is printed as (signed) decimal.
Would the type character be for example `ld` (`%ld`), the position on the stack would be retrieved as a long, even if only an int was pushed, and that would be printed as a (signed) decimal number. Again, there is no type conversion whatsoever (there will just be a nonsense number printed). | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -4,
"tags": "c++, c, type conversion"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.