INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
MySql query execution time
I am using MySQL Workbench on Windows. How do I find out the time taken to execute a query like
Select * from employers where employerid > 200
Is there a statement I can enter that returns the execution time for this query? Thanks
|
MySQL workbench is the way to go for things like this (optimization, benchmarking of queries, etc.). You say you're not familiar with it, so I'd recommend reading a tutorial from the good folks at MySQL
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 5,
"tags": "mysql, time, mysql workbench, execution"
}
|
How we can justify UDP as connection-less and TCP as connection-oriented protocol?
How we can justify UDP as connection-less and TCP as connection-oriented because in both the protocols we use concepts of ports and sockets for the process to process communication. In what way we can say that UDP is a connection-less protocol.
|
Let say, that communication is a talk. mean, two (or more) entities came to exchange information between their.
UDP doesn't verify that the messages reached their destination, and the order of the messages is not guaranteed. so you can say that is more like as the target bombing with the messages than like communication between entities.
|
stackexchange-stackoverflow
|
{
"answer_score": -2,
"question_score": -1,
"tags": "networking"
}
|
The equivalence of numerical radius and spectral norm
Let $A$ be a $n\times n$ complex matrix. Define the numerical norm of $A$ as $$w(A)=\sup\\{|x^*Ax|;\|x\|_2=1\\}, \|x\|_2^2=\sum_{i=1}^n|x_i|^2.$$ And the spectral norm of $A$ is $$\|A\|_\infty =\sup_{\|x\|_2=1}\|Ax\|_2.$$ Then we have $$\frac12\|A\|_\infty \leq w(A)\leq \|A\|_\infty.$$
I do know how to prove $w(A)\leq \|A\|_\infty$, which is easy. However, I could not prove the left inequality, in particular, the factor $1/2$ is hard to think...
Notice that the matrix need not to be symmetric.
|
Let $A=H+S$, where $H:=(A+A^*)/2$ and $S:=(A-A^*)/2$. The hermitian and skew-hermitian parts $H$ and $S$ of $A$ are normal matrices and for normal matrices, the spectral norm coincides with the spectral radius which is equal to the numerical radius. Hence $$ \|A\|\leq\|H\|+\|S\|=w(H)+w(S). $$ We have $$ \begin{split} \|A\| &\leq w(H)+w(S)\\\ &= \frac{1}{2}\left(\sup_{\|x\|=1}|x^*(A+A^*)x|+\sup_{\|x\|=1}|x^*(A-A^*)x|\right) \\\ &\leq \frac{1}{2}\left(2\sup_{\|x\|=1}|x^*Ax|+2\sup_{\|x\|=1}|x^*Ax|\right)=2w(A). \end{split} $$
|
stackexchange-math
|
{
"answer_score": 7,
"question_score": 4,
"tags": "numerical linear algebra, matrix calculus"
}
|
What do link editor (LD) params mean?
I write NASM (netwide assembler) program and for some reasons I needed to use some functions written in C. So, I tried to link compiled C object files with compiled Assembly objects using _**ld**_ link editor. I did it by this way :
`ld -m elf_x86_64 -lc --dynamic-linker=/lib64/ld-linux-x86-64.so.2 object_files -o program`.
And it didn't want to link and work long enough until I picked up the necessary parameters. Now this works as expected with this parameter set. But I don't understand the meaning of `-lc` and `--dynamic-linker=/lib64/ld-linux-x86-64.so.2`. What do they do ?
|
1. -lc - link c standard library
2. \--dynamic-linker=/lib64/ld-linux-x86-64.so.2. - set the program loader. Linux ELF binaries have a field for this.
Afaik the latter is needed even for static binaries, anything other will confuse the loader, and it won't execute.
man ld lists its parameters.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "makefile, linker, gnu make, linker flags"
}
|
React how to prevent a parent's onclick event from firing when a child is clicked?
I have set the `onClick` prop on my div which will navigate to a new page when clicked. `svg` is absolutely positioned. How do I avoid the click event on the `svg` element?
I've already tried `stopPropagation()` but it doesn't work.
<div
className={classes.container}
onClick={() => navigate(`${props.productName}`)}
>
<img src={props.image} alt="" />
<svg></svg>
</div>
|
Well the obvious answer would be to put it outside of the `div`.
But if you really can't, you can always use CSS for this.
Try using `pointer-events`
**Example:**
HTML -
<div
className={classes.container}
onClick={() => navigate(`${props.productName}`)}
>
<img src={props.image} alt="" />
<svg className='no-events'></svg>
</div>
CSS -
.no-events {
pointer-events: none;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "javascript, reactjs"
}
|
Cálculo com virgula em PHP
Preciso multiplicar o valor recebido do formulário post Ex: $altura * $largura * 45; Até aí tudo bem, mas se o usuário digitar um valor com virgula, a soma não acontece.
Eu preciso que a soma aconteça de ambas formas, e não que me mostre o resultado com number_format() apenas.
<?php
// Exemplo com POST
$altura = $_POST['alt'];
$largura = $_POST['larg'];
$valor = "45";
$soma = $altura * $largura * $valor; // Soma: Altura * Largura * Valor.
echo $soma
?>
<?php
// Exemplo cru com vírgula
$altura = "1,20";
$largura = "0,90";
$valor = "45,00";
$soma = $altura * $largura * 45; // Soma: Altura * Largura * Valor.
echo $soma
?>
|
O separador decimal é `.`(ponto) e não `,`(virgula), para resolver isso você pode usar str_replace para trocar as ocorrências de virgulas por pontos.
Nenhuma soma é realizada :P parece que o sinal de mais foi trocado pelo de multiplicação.
$altura = "1,20";
$largura = "0,90";
$valor = "45,00";
$altura = str_replace(',', '.', $altura);
$largura = str_replace(',', '.', $largura);
$valor = str_replace(',', '.', $valor);
$multiplicao= $altura * $largura * 45; // multiplica: Altura * Largura * Valor.
echo $multiplicao;
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 6,
"question_score": 5,
"tags": "php"
}
|
Oracle - Output number of rows affected from dynamic merge statement
I have a dynamic sql in a stored procedure with a `MERGE` statement and and executing it using `EXECUTE IMMEDIATE <dynamic_sql>`. When I run the merge query through the sql worksheet, it tells me the number of rows merged. How do I retrieve the same information through a dynamic sql?
I would appreciate any efforts towards this question.
|
After running any SQL statement (static or dynamic), the `SQL%ROWCOUNT` variable will tell you how many rows were affected.
EXECUTE IMMEDIATE l_sql_stmt;
l_rows_affected := SQL%ROWCOUNT;
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sql, oracle, merge"
}
|
Database Server Disk Memory is Full
I am using SQL Server for my web application. How will I know that an insert query failed because the database server memory disk is already full
|
You can simulate this by disabling the auto-grow feature on the database (It's a checkbox in the database properties on the file tab) and filling up the database. The error will be the same.
ALTER DATABASE YourDatabase
MODIFY FILE (name='YourFile' MAXSIZE=50MB);
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sql server"
}
|
How to pass data in controller Angular JS?
I have two controllers:
<div ng-controller="Main">
<div ng-controller="Map"></div>
</div>
In controller `Main` I have variable `$scope.mapCoord;` How I can to pass this variable in controller `Map`?
|
Use a service. For example:
var app = angular.module('myApp', [])
app.service('sharedProperties', function () {
var mapCoord= 'Test';
return {
getProperty: function () {
return mapCoord;
},
setProperty: function(value) {
mapCoord= value;
}
};
});
Inside your Main controller
app.controller('Main', function($scope, sharedProperties) {
$scope.mapCoord= sharedProperties.setProperty("Main");
});
Inside your Map controller
app.controller('Map', function($scope, sharedProperties) {
$scope.mapCoord= sharedProperties.getProperty();
});
Here's a fiddle for you. JSFiddle
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "angularjs"
}
|
Environment variable only works in windows command prompt when i run it "start in %HOMEDRIVE%%HOMEPATH%"
I am trying to add the Sublime Text directory to environment variable PATH so I can start Sublime from `cmd` in Windows 7 easily. But, it is not working when I start `cmd` without doing this...
!enter image description here
Opening this shortcut makes all Sublime available in command line...
However if I start `cmd` directly it or by right clicking in a folder and try to start Sublime it says internal error !enter image description here
My path settings
!enter image description here
!enter image description here
|
You'll need to reboot the machine, or log out and back in. On at least some versions of Windows, the "Open command window here" menu option doesn't check for changes to environment variables that have been made since the user logged on.
This appears to be a bug in Windows.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "windows, sublimetext3, command prompt"
}
|
Dynamically construct variables inside the script and fetch values from source parameters
I have a txt file extract.dat which is read inside my code using source.
$ cat extract.dat
ExchgRate_prop="EDB_NAME=share_exchange SRC_WDS=wds PN=ExchgRate"
Compliance_prop="EDB_NAME=share_compliance SRC_WDS=wca PN=com"
Unitcost_prop=="EDB_NAME=share_unitcost SRC_WDS=wda PN=unit"
source ./ extract.dat
now I would have got all the varaibles inside my code. if my code takes an argument $PROJ with value as 'ExchgRate' , how can i concatenate "$PROJ""_prop" to create the variable ExchgRate_prop and then get value "EDB_NAME=share_exchange SRC_WDS=wds PN=ExchgRate"
|
You can use bash _variable indirection_. Ex. given
$ echo "$ExchgRate_prop"
EDB_NAME=share_exchange SRC_WDS=wds PN=ExchgRate
and
$ PROJ=ExchgRate
then
$ var=${PROJ}_prop
$ echo "${!var}"
EDB_NAME=share_exchange SRC_WDS=wds PN=ExchgRate
|
stackexchange-askubuntu
|
{
"answer_score": 0,
"question_score": -1,
"tags": "source"
}
|
Saving the output of a child process in a variable in the parent in NodeJS
I would like to start a child process in NodeJS and save it's output into a variable. The following code gives it to stdout:
require("child_process").execSync("echo Hello World", {"stdio": "inherit"});
I have something in mind that is similar to this code:
var test;
require("child_process").execSync("echo Hello World", {"stdio": "test"});
console.log(test);
The value of `test` was supposed to be `Hello World`.
Which does not work, since `"test"` is not a valid stdio value.
Perhaps this is possible using environment variables, however I did not find out how to modify them in the child process with the result still being visible to the parent.
|
`execSync` is a function which _returns_ the stdout of the command you pass in, so you can store its output into a variable with the following code:
var child_process = require("child_process");
var test = child_process.execSync("echo Hello World");
console.log(test);
// => "Hello World"
Be aware that this will throw an error if the exit code of the process is non-zero. Also, note that you may need to use `test.toString()` as `child_process.execSync` can return a `Buffer`.
|
stackexchange-stackoverflow
|
{
"answer_score": 20,
"question_score": 11,
"tags": "node.js, environment variables, parent child, ipc, child process"
}
|
Choosing a subject to create a site for
For 6 years I'm working as web developer and I would like to finally create my own site. I thought I have everything needed: programming and administration skills, found a good designer, own servers and understanding how to operate site. But I've missed very important (or the most important) point: how do I find a subject for my site? My hobby and my work are the same: IT, but I don't want to create just another tech blog or news aggregator, I want something different.
First I thought things like Google Trends or Google top 1000 could help, but I've got lost in thousands of options I can't see them all (I actually can, but it'll take at least a couple of month).
So my question is: how did you start? Where did you get the idea?
|
Depends on what you want to do with your site. If you want to make money online, you can find a good niche. Try to browse the affiliate networks niches (
But this may not be what you're looking for. You may as well create a blog about your life.
|
stackexchange-webmasters
|
{
"answer_score": 1,
"question_score": 1,
"tags": "marketing, best practices, recommendations, research"
}
|
sql server output parameters ado.net
cmd.Parameters.Add(New SqlParameter("LossID", SqlDbType.Int).Direction = ParameterDirection.Output)
.....
Dim LossID as integer
lossID = cmd.Parameters("@LossID").Value
When I add my output parameter to my command object, I am receiving a
> The SqlParameterCollection only accepts non-null SqlParameter type objects, not Boolean objects.
How do I correctly place my return value into the `lossID` integer? thank you very much
|
You need to separate the assignment of the Direction property from the adding of the parameter to the parameters collection.
param = New SqlParameter("LossID", SqlDbType.Int)
param.Direction = ParameterDirection.Output
cmd.Parameters.Add(param)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sql server, ado.net"
}
|
Windows API STARTUPINFO destroyed?
After creating a process and waiting for it to finish, does it's STARTUPINFO still available or is it destroyed ?
STARTUPINFO si;
bRes = CreateProcess(NULL, command, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
dwRes = WaitForSingleObject(pi.hProcess, INFINITE);
After this does the `si` gets modified/destroyed or is it left intact ?
|
Windows creates a copy of the startup info struct for the new process. That has to happen because the new process has a brand new address space and cannot see your struct.
Now, what happens to your struct? Well, the documentation has the answer. The parameter is annotated like this:
_In_ LPSTARTUPINFO lpStartupInfo
The `_In_` means that the contents of the struct are not modified by the call to `CreateProcess`. So, you can be confident that when `CreateProcess` returns, the startup info struct has not been modified.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "c, winapi, process"
}
|
Redefine jgrid navgrid add/edit button
Is there any way, in jqgrid, to redefine the function to call when the "add" button of the navgrid?
The only thing I've found is to add a new button redefining "onclickbutton" property , and I've looked at code, but I think that is impossible, isn't it?
Thanks in advance,
|
In the code which you referenced you can find the line of code. So is you defines `addfunc` option of `navGrid` you can implement your own implementation of "Add" button.
Alternatively you can just use `add: false` option of `navGrid` and then uses navButtonAdd to add your custom button which looks exactly like "Add" button.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "jqgrid"
}
|
Is Ajax with JSON or Ajax with dojo are same
I am new in Ajax . Want to use Ajax with Json . I am searching the tutorial for this and i find this.
I want to ask is i am in right direction ?
Is both things are same Ajax with Json and Ajax with dojo?
|
## Not the same
Ajax is a technology that send request and accept data asynchronously(do not need to reload page).
You can use JSON or XML to send the data or just use the string.
When you do the Ajax request, any data type(like array, object, number..) except string will lost their data type and become string, so If you want to reserve their type, you must use data transmit format like JSON and XML.
Dojo just a library which have easier method for doing Ajax. You also can use jQuery, Angular,..Whatever even JavaScript native XMLHttpRequest.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ajax, json"
}
|
Prove that $ab+bc+cd \le \frac{1}{4} $ if $a+b+c+d =1$
If $a,b,c,d$ are four nonnegative real numbers and $a+b+c+d=1$ then prove that $$ab+bc+cd \le \frac {1}{4} $$ It is the problem. I tried A.M.-G.M. Inequality, Cauchy-Swartz inequality. But I can't proceed. Somebody help me.
|
The reversed inequality with $ab+bc+cd$ is true because by AM-GM
$ab+bc+cd\leq ab+bc+cd+da=(a+c)(b+d)\leq\left(\frac{a+b+c+d}{2}\right)^2=\frac{1}{4}$.
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 4,
"tags": "algebra precalculus, inequality, a.m. g.m. inequality"
}
|
How to setup /etc/issues to show the IP address for eth0
I've got a couple of linux virtual machines with bridged interfaces, and I'd like the IP address of the machine to show up after the machine boot (in the login, where it usually shows the release and kernel).
From what I can tell the message is picked up from /etc/issues, but I'm not sure how and when to write to it.
|
It's just a text file...you write to it the same way you'd send text to a file with any other shell script. Something like this would replace /etc/issue with just your ip address:
ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -f2 -d: > /etc/issue
Obviously you can make this arbitrarily more complex, depending on what information you want in your `/etc/issue` file.
You can write to this file in your local equivalent of /etc/rc.d/rc.local (which typically executes after all the other startup scripts).
|
stackexchange-serverfault
|
{
"answer_score": 14,
"question_score": 15,
"tags": "linux, centos, virtual machines"
}
|
Союз "а" и частица "же"
Во всех ли случаях конструкцию с союзом "а" можно заменить конструкцией с частицей "же" ("Вчера было так, а сегодня всё иначе" = "Вчера было так, сегодня же всё иначе")? Или в каких-то случаях нельзя?
|
> > Во всех ли случаях конструкцию с союзом "а" можно заменить конструкцией с частицей "же" ("Вчера было так, а сегодня всё иначе" = "Вчера было так, сегодня же всё иначе")?
Здесь ЖЕ не частица, а тоже союз.
_Это был Вася Петров, а не Петя Васечкин._ Здесь на ЖЕ не заменить.
|
stackexchange-rus
|
{
"answer_score": 1,
"question_score": 0,
"tags": "синтаксис, союзы, частицы"
}
|
Calling Javascript function and django view function at the same time
I am a django beginner, I was trying to call django view function and Javascript function at the same time through submit button in django form but django view is not calling. Is there any way that I can call both functions at the same time?
|
You can add `onclick` event on your submit button, but you'll have short period beetween click on submit button and page redirect. When Django redirects you to success page you wouldn't be able to access your function anymore.
<form>
{csrf_token}
<button type="submit" onclick="yourFunction()">Button</button>
</form>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, django, django forms"
}
|
Why does "one" < 2 equal FALSE in R?
I'm reading Hadley Wickham's Advanced R section on coercion, and I can't understand the result of this comparison:
"one" < 2
# [1] FALSE
I'm assuming that R coerces 2 to a character, but I don't understand why R returns `FALSE` instead of returning an error. This is especially puzzling to me since
-1 < "one"
# TRUE
So my question is two-fold: first, why this answer, and second, is there a way of seeing how R converts the individual elements within a logical vector like these examples?
|
From `help("<")`:
> If the two arguments are atomic vectors of different types, one is coerced to the type of the other, the (decreasing) order of precedence being character, complex, numeric, integer, logical and raw.
So in this case, the numeric is of lower precedence than the character. So `2` is coerced to the character `"2"`. Comparison of strings in character vectors is lexicographic which, as I understand it, is alphabetic but locale-dependent.
|
stackexchange-stackoverflow
|
{
"answer_score": 17,
"question_score": 17,
"tags": "r, boolean, comparison, boolean logic, coercion"
}
|
Pulling information from a cell in a .csv file into a variable in Excel using vba
I'm working on a vba macro for an excel sheet and I'm not sure how to go about doing one of my functions. I have a private sub in the macro that is used to get the path of a .csv file (say C:/files/file.csv stored as variable 'csvfile').
What I need to do at this point is automatically pull information from that csv file according to a certain formula and save it as a variable:
=COUNTIFS(F2:F10000,"=medium",Z2:Z10000,"=Open")
So in summary, in a macro in spreadsheet Main.xlsx, I need to run the above formula on the file whose path is stored in variable csvfile, and save the returned number as a variable within the macro so I can make use of that number in my macro.
I'll need to do this nine times actually with the formula slightly different each time, but once I have the single variable worked out I think I'll be able to modify it to produce all the results I need.
Thanks
|
Here's an example of one way to do it:
Sub OpenAndCount()
Dim sFile As String
Dim wb As Workbook
Dim ws As Worksheet
Dim cnt As Long
Dim rng1 As Range
Dim rng2 As Range
sFile = "c:\files\file.csv"
Set wb = Workbooks.Open(sFile)
Set ws = wb.Sheets(1)
Set rng1 = ws.Range("F2:F100000")
Set rng2 = ws.Range("Z2:Z100000")
cnt = Application.WorksheetFunction.CountIfs(rng1, "=medium*", rng2, "=open")
Debug.Print cnt
wb.Close
End Sub
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "vba, excel"
}
|
Int object is not subscriptable, but it is a list
I am trying to write some code for a chess application. One line of code in a function is:
if check_mate(board, True) == True:
value = 999
the checkmate function is:
def check_mate(board, previous):
if previous != True:
prev = previous
elif previous == True:
if len(move_history_int) != 0:
prev = move_history_int[-1]
else:
prev = [0,0,0,0]
the length of move_history_int is 0, so prev becomes `[0,0,0,0]`, but later on in check_mate, it gives me the error
if prev[-1][0] == element - 1 and prev[-1][1] == z and prev[-1][2] == element - 1 and prev[-1][3] == row:
TypeError: 'int' object is not subscriptable
Doing `print(prev)` gives `[0,0,0,0]` and trying `print(type(prev))` gives list. I can't think of what is going wrong. Can anyone help?
|
if prev[-1][0] == element - 1 and prev[-1][1] == z and prev[-1][2] == element - 1 and prev[-1][3] == row:
TypeError: 'int' object is not subscriptable
This error is telling you that **previous** can't be double-subscripted. That's because you're using a one-dimensional list, as we see in:
prev = [0,0,0,0]
Because it's a one-dimensional list, calling prev[-1][0] attempts to call the first list item of the list at prev[-1]...but prev[-1] isn't itself a list, as if you do:
>>> prev = [0,0,0,0]
>>> prev[-1]
0
>>> type(prev[-1])
>>> <type 'int'>
So, to fix this, figure out what you're trying to extract from your one-dimensional list, or refactor your list to be a two-dimensional list.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "python"
}
|
Why won't my <script> tags execute the code inside of them?
I am using Notepad ++ and this keeps on happening. I have this really simple code to test if the console works or not. When ever I run the program, I get the the code written in the browser. I am currently using Google Chrome. This is my code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
document.write("Hello World!");
</script>
</body>
</html>
Thanks in advance! Sorry if I formatted the code wrong, this is all new to me!
|
If you want "Hello, World!" to be written to the console, try using `console.log`:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
console.log("Hello World!");
</script>
</body>
</html>
Using `document.write` is for writing to the actual document, not the console, and is generally considered bad practice.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "javascript, html"
}
|
Run newer version of mono without sudo
I'm on a virtual host with Debian, and it has an outdated version of mono. I do not have sudo privileges. I have compiled an updated version into my home directory with ./configure --prefix=$HOME.
How do I run my programs with the compiled version?
|
With a prefix of $HOME and assuming you have done a 'make install', add mono's bin dir to your path and test to see you are are picking up the correct/newer one:
export PATH=${HOME}/bin:${PATH}
which mono
At that point, you can:
mono yourprogram.exe
Note: Instead of using your home directory as the prefix, you might want to install to a sub-directory to keep all those mono sub-dirs separate from your other HOME directories; i.e. Use --prefix=$HOME/mono when you autogen/configure mono.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "compilation, mono, debian, virtualhost"
}
|
PostgreSQL slow query log entries contain no query details, only duration
I have a PostgreSQL RDS instance hosted in AWS. I have set the `log_min_duration_statement` setting to 1 second. When checking my log for slow queries I found the following six entries which don't contain any query/statement:
 is logged when it ends. You can use the PID or maybe the client IP and port number to pair those up to each other in the log file. I don't know if RDS provides a specific way to do that, I've always done it in 'vim' or 'less'.
But really, I just auto_explain now. I think that this is available in RDS although I've never used it there.
|
stackexchange-dba
|
{
"answer_score": 0,
"question_score": 0,
"tags": "postgresql, amazon rds, aws, slow log, troubleshooting"
}
|
android:pathPattern has no effect on intent-filter behavior
I'd like to make my filter to pass only `*.pls` files. According the developer docs: < it should be working (I think) but it's not. Instead of the expected behavior (passing `.pls` files only) all file types are being passed.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.pls" />
</intent-filter>
|
If you re-read the docs you'll notice this line relating to the `android:path`, `android:pathPrefix`, and `android:pathPattern`
> These attributes are meaningful only if the scheme and host attributes are also specified for the filter.
You are missing the `android:host` atttribute. Add
<data android:host="*" />
to your intent-filter as the docs specify
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, intentfilter"
}
|
Using large arrays, I get "Access violation writing location" in a different place every time
For some reason (I guess the malloc) my code doesn't work after a random iteration.
Basically I'm supposed to read code from a file and put it in an array of vertexes. A vertex looks like this: `v -0.11459 0.100413 0.298243`.
* num_of_vertexes=2108.
* Visual Studio 2019.
Vertex* vertexes = (Vertex*)malloc(sizeof(Vertex*)*num_of_vertexes);
for (int i = 0;i < num_of_vertexes;i++) {
vertexes[i].x = 0; //Crashes here at a random i>900
vertexes[i].y = 0;
vertexes[i].z = 0;
}
typedef struct {
float x; // Coordinates of Vertex
float y;
float z;
} Vertex;
|
Your size calculation is wrong - you're multiplying the number of elements in the array by the size of a `Vertex*` (a Vertex pointer) instead of the size of a `Vertex`:
Vertex* vertexes = (Vertex*) malloc(sizeof(Vertex) * num_of_vertexes);
/* Here -----------------------------------------^ */
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "c"
}
|
How to solve this exponential equation with the given n
How to solve this exponential equation:
n*2^n=2^37
n=32
Is my answer correct ?
n*2^n=2^37=>
2^37=2^5*2^32=>
32*2^32=>
n=32
|
No its not. You have minor mistake.
$2^{37} = 2^5 \cdot 2^{32}$
Not $2^5 + 2^{32}.$
> Solution -
$n × 2^n = 2^{37}$
$n × 2^n = 2^5 × 2^{32}$
$n × 2^n = 32 × 2^{32}$
So n = 32.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "exponential function"
}
|
Typo3 - Fluid - Content Header output
I have an issue with Typo3 Extension tx_News.
I should Display the tt_content Header in the General fluid template. I tried to found any Solutions by search in Google, unfortunately I don't found any solution.
I tried to get the Output by: \- {contentObject.header} \- {contentObj.header} \- {tt_content.header} \- {data-header}
Unfortunately I don't found the correct solution and would appreciate if anybody can help me
|
The news extension adds the content object data in the variable `contentObjectData`, so you can use `{contentObjectData.header}` to get the tt_content header value in your news templates.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "php, typo3, tx news"
}
|
Connect automatically after database finished recovery
I have an asp.net website which is connected to a database which recovers every 5 minutes because it's a snapshot of the production database. When I log in to the site and the db is under recovery it returns a database related error. It does not return the same error every time.
What I want is that every time the db recovers and a user logs in, it will return a custom error page in the front end while in the back end, if the connection was lost due to recovery it will automatically connect once the database is done in recovery. Any idea ? Thanks.
|
You can use EF `Connection Resiliency` feature. Connection Resiliency refers to the ability for EF to automatically retry any commands that fail due to these connection breaks.
Connection retry is taken care of by an implementation of the `IDbExecutionStrategy` interface. Implementations of the `IDbExecutionStrategy` will be responsible for accepting an operation and, if an exception occurs, determining if a retry is appropriate and retrying if it is.
Here some useful samples:
Implementing Connection Resiliency with Entity Framework 6
Connection Resiliency in Entity Framework 6.0 above
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, sql server, asp.net mvc, entity framework"
}
|
Хеш ветки или хеш коммита
Столкнулся с задачей вывода текущей версии приложения, расположенного в репозитории git. Совпадает ли хеш ветки master с хешем последнего коммита в эту ветку? Это одно и тоже или нет?
|
> Совпадает ли хеш ветки master с хешем последнего коммита в эту ветку? Это одно и тоже или нет?
«хэша ветки» не существует в природе. ветка (branch) в программе _git_ — это плавающий указатель на (один) коммит.
собственно «содержимым» ветки и является хэш коммита, последнего в последовательности коммитов, связанных друг с другом благодаря тому, что каждый коммит (кроме самого первого) содержит хэш «родительского» коммита (а некоторые коммиты, т.н. «коммиты слияния», имеют и более одного «предка»).
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "java, git, gitlab"
}
|
How to authenticate user with form authentication in Windows Desktop Application
I have done some work in Asp.NET, and i am quite used with user authentication using FormAuthentication
Now I am working on a desktop application and i want to have something like above in windows form application, I want to create and authenticate users by using the application database or xml whatever it is like i have done it in Asp.NET. So far did not any way to achieve this like i want to.
Any help would be great!
|
A Windows desktop application is nothing like an ASP.NET web application.
You cannot call the different forms separately.
(well you can hack the application, but if you do that, you can just as well remove any password protection)
Hence forms authentication does not make any sense.
You can create a login window as startup window, and check username and password against the database.
And that's about it.
It's a Windows application, you don't need membership provider, forms cookie ticket, etc. because unlike HTTP, Windows desktop applications are not stateless.
PS: If you do a WinForms application, make the login via ActiveDirectory authentication.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, winforms, forms authentication"
}
|
Evaluate $\int_{\pi/6}^{\pi/2} (\frac{1}{2} \tan\frac{x}{2}+\frac{1}{4} \tan\frac{x}{4}+ \cdots+\frac{1}{2^n} \tan\frac{x}{2^n}+\cdots) dx$
$$f(x)=\frac{1}{2} \tan\frac{x}{2}+\frac{1}{4} \tan\frac{x}{4}+....+\frac{1}{2^n} \tan\frac{x}{2^n}+...$$
Check the function $f(x)$ is continuous on $[\frac{\pi}{6},\frac{\pi}{2}]$ and evaluate $\displaystyle\int_{\pi/6}^{\pi/2} f(x)$.
|
$$\sum_{k=1}^{n}\dfrac{1}{2^k}\tan{\dfrac{x}{2^k}}=-\left(\sum_{k=1}^{n}\ln{\left|\cos{\dfrac{x}{2^k}}\right|}\right)'=-\left(\ln{\left|\dfrac{\sin{x}}{2^n\sin{(x/2^n)}}\right|}\right)'=\dfrac{1}{2^n}\cot{\dfrac{x}{2^n}}-\cot{x}$$ so $$\sum_{k=1}^{+\infty}\dfrac{1}{2^k}\tan{\dfrac{x}{2^k}}=\dfrac{1}{x}-\cot{x}$$ then it is easy
$-\displaystyle\int_{\pi/6}^{\pi/2}\dfrac{1}{x}- \cot(x) = \left(\ln{x}-\log(\sin(x))\right)_{\pi/6}^{\pi/2} =\ln{3}-\log(2)$
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 1,
"tags": "calculus, integration"
}
|
ReferenceError: $ is not defined in Angular JS
Hi i am getting 'ReferenceError: $ is not defined' in my code. This is my sample code
$rootScope.$on('$stateChangeStart', function (event, next, current) {
// redirect to login page if not logged in and trying to access a restricted page
var restrictedPage = $.inArray($state.current.name, ['login']) === -1;
var loggedIn = $rootScope.globals.currentUser;
if (restrictedPage && !loggedIn) {
$state.go('login');
}
});
This code am writing inside run();
|
Add jquery file in your project. `$` means jQuery.
<script src="
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "jquery, angularjs"
}
|
Derivative of a Position Eigenket
I was flicking through Zettili's book on quantum mechanics and came across a 'derivation' of the momentum operator in the position representation on page 126. The author derived that $\langle\vec{r}|\hat{\vec{P}}|\psi\rangle = -i\hbar\vec{\nabla}\langle\vec{r}|\psi\rangle$ (I've omitted the full derivation). However, from this relationship he concluded that $\hat{\vec{P}} = -i\hbar\vec{\nabla}$. I'm sure this is very basic but why can you immediately conclude this? Surely this assumes that $\langle\vec{r}|(-i\hbar\vec{\nabla})|\psi\rangle = -i\hbar\vec{\nabla}\langle\vec{r}|\psi\rangle$. I'm not sure why this is necessarily true.
|
$-i\hbar\vec{\nabla}|\psi\rangle$ is not a valid notation. The nabla operator is defined in three-dimensional Euclidean space, not the in the Hilbert space of quantum states.
When the author says $\hat{\boldsymbol{P}}=-i\hbar\vec{\nabla}$ he does not mean the momentum operator defined in the state space, but the space of wavefunctions. Then $\hat{\boldsymbol{P}}\psi(\boldsymbol{r})=-i\hbar\vec{\nabla}\psi(\boldsymbol{r})$.
|
stackexchange-physics
|
{
"answer_score": 3,
"question_score": 3,
"tags": "quantum mechanics, momentum, operators"
}
|
How to open a pointer with fopen?
Usually we open file in this way
FILE *student_file;
student_file = fopen("five_students", "rb");
Now I have a function with an image pointer as argument. I want to open the image file and read the content inside. I tried to open it as following, but it doesn't work. How can I fix it?
void read_metadata(FILE *image, int *pixel_array_offset, int *width, int *height) {
FILE* img = fopen(*image, "rb");
}
|
If you already have the parameter `image` opened when you call `read_metadata` (i.e. if an earlier call to `fopen` succeeded in the calling code), you don't need to call `fopen` on it again. It is already open. Also, that code shouldn't even be compiling, since `fopen` takes a `char *` string as its first argument, not a `FILE`.
Just use the file I/O functions on `image` right off the bat (`fread`, `fgets`, `fscanf`, etc.).
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c, fopen"
}
|
How to auto adjust text field width
I'm trying to expand I just can't make it work... any solution?
< here`
< `another sample too...`
|
Since you mentioned in your comment that the element you're working with has the !important attribute, my recommendation would be to use the built in javascript method setProperty instead of jquery. It allows you to easily add !important to your new css property value:
$(document).ready( function() {
$("#btn").click(function(){
document.getElementById('lbl').style.setProperty('width', '300px', 'important');
});
});
I've also updated the jsfiddle so you can see it work: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -4,
"tags": "javascript"
}
|
Can Spider-Man get drunk?
Captain America is shown to not be able to get drunk.
With Spider-Man's body operating at even higher levels than Cap, has he ever been shown to be drunk?
|
## Yes, Peter Parker/Spider-Man has been drunk in the comics, and it got in the way of his ~~vigilanteing~~ heroing.
This happened back in Web of Spider-Man #38(1988).
Peter is at a party and gets drunk, and ends up running off to fight the Hobgoblin.
After he almosts gets some innocents hurt, he pretty much swears off drinking.
. Some high rep users do a lot of voting and no reviewing. Others do a lot of reviewing and no voting. Some do both and some do neither. And this goes on at lower rep levels as well. As well as asking and/or answering.
What would be the message you would send to other users that don't seem to interact with the community in the same way you do? I don't see this as much of a _real issue_.
|
stackexchange-meta
|
{
"answer_score": 3,
"question_score": -4,
"tags": "discussion, questions, up votes"
}
|
Check Ubuntu for Installation Issues/Errors
I upgraded from Ubuntu 12.10 to 13.04. I have got an error massage before the upgrade was finished and now i have the feeling that Ubuntu 13.04 was not installed correctly. How can i check/scan the OS for errors ? I dual boot with Windows 7.
|
To be honest I'm not aware of any utility to scan for installation errors, but if you are experiencing some weird behaviour from the OS, you could try to reinstall the `ubuntu-desktop` metapackage, it should reinstall everything that may be lost/damaged during the upgrade.
I'm using Kubuntu, and sometimes when I get problems in updating the files of the KDE environment, reinstalling `kubuntu-desktop` (which, as you can guess, is the equivalent to `ubuntu-desktop` for Kubuntu) solves anything.
Anyway, from a more general point of view, I found that when making major version upgrades, it is better to use a LiveCD, rather than using the built-in upgrade options, it causes far less problems; if you have your /home folder on a separate partition, you won't lose any data, and you simply have to reinstall some software.
You can also check this and this.
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ubuntu, installation, upgrade, ubuntu 13.04"
}
|
Error when Restoring a backup
Why I always got this Error when Restoring a backup
"Exclusive access could not be obtained because the database is in use"
I try this but did'nt work:
use Master
ALTER DATABASE yourdatabasename SET MULTI_USER WITH ROLLBACK IMMEDIATE;
I always have to close the ssms and open it again to restore backup. How I will avoid this error especially when I will use the backup/restore in my c# application? Do I have to change some properties of my database? I need this issue to resolve to avoid encountering it with the application which I am developing.
|
Check if you have any query tab connected to this specific database. If yes, you may choose another database from the dropdown instead of closing it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "c#, winforms, sql server 2008, backup, restore"
}
|
Shimano GRX 2x11 brake rotor compatibility
I am looking for possible disc rotors for the GRX 2x11 that comes with the GRX BR-RX810 brakes but can just find one recommendation which are the Shimano Ultegra SM-RT800 Center Lock Ice-Tech, that I find very ugly. Even on the Shimano page I cannot find anything else. Are there any other rotors that are compatible with the GRX BR-RX810 and GRX2x11?
|
If you want to stick with Shimano, the line-up charts for the GRX groups suggest an SM-RT64, SM-RT70 and RT-MT800 for use with RX400 and RX600 and RX810 groups respectively. None of those discs have the 'bladed' look of the SM-RT800 rotor.
|
stackexchange-bicycles
|
{
"answer_score": 4,
"question_score": 3,
"tags": "shimano, disc brake, gravel"
}
|
What's the difference between Class Library and .NET Core Class Library templates?
I'm creating a new ASP.NET Core 1.0 application targeting the full .NET Framework 4.6.1.
Because I'll be running this app on Azure, I don't want to target the new .NET Core framework. I don't need to worry about running it on other platforms.
I now need to add a couple of class library projects to my solution to handle some back end functions. Which class library should I choose?
 template and target `netstandard1.3` or higher in your library.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "c#, .net, asp.net core, .net core, asp.net core 1.0"
}
|
I can't see the hdri background in my final render and render view in the viewport
i'm pretty new to blender and I have a problem. Every time I import an HDRI image, the lightning changes, but not in the right way. the background color changes but the background itself doesn't change, I'm using cycles. I impoort my HDRI images by setting the base color of the world to image texture, I don't know if there is another way and if I should use it that way. The answer is probably very simple but I just can't seem to find a solution to it. Thanks in advance!
Someone asked for the node setup of the world so here it is: <
 transaction is based on the assumption that the child actually spends the output created by the first transaction.
In your case, your second transaction does not actually spend the output of the first transaction - this allows it to be confirmed without any relation to the previous one.
That said, your fee is not so low that it will never confirm - transactions with that feerate are cleared out every day or two, usually. You will likely be fine if you just wait.
If you are in a hurry, you can use your wallet to make another transaction spending the unconfirmed output - note that this is not an option if the address you sent the coins to belongs to an exchange or hosted wallet where you cannot control which outputs/keys are used for a new transaction.
|
stackexchange-bitcoin
|
{
"answer_score": 0,
"question_score": 1,
"tags": "blockchain, child pays for parent"
}
|
How can I run mongod in the background on unix (mac osx)?
I would like to run mongod in the background as an always present sort of thing. What would be the best way to do this? Kind of like the way I can run MySQL on startup and it's just always there running in the background. Maybe it's just some bash scripts, but it would be nice to hear if there is a better way. If it is just bash - what would that look like? Thanks.
|
The MongoDB daemon (mongod) has a command-line option to run the server in the background...
--fork
This command-line option requires that you also specify a file to log messages to (since it can not use the current console). An example of this command looks like:
mongod --fork --logpath /var/log/mongod.log
You could put this into an /etc/init.d/mongod bash script file. And then to have the service run at startup, create the standard symbolic links (S## & K##) inside of /etc/rc#.d/. Here is a tutorial that explains this process in more detail. Scroll down to the section titled "Init Script Activation". This also has the added benefit of being able to execute commands like...
service mongod status
service mongod start
service mongod stop
|
stackexchange-serverfault
|
{
"answer_score": 93,
"question_score": 60,
"tags": "mac osx, unix, background process, mongodb"
}
|
Watchkit App: slider background color
I am surprised no one asked already this question, maybe I am just thinking something wrong. But here it is: I am trying to use WKInterfaceSlider to show some progress. The background of my app is black and I really need the background of the slider to match. It looks really bad with that dark grey default background. Isn't there really anyway to set it to replace it or simply set it to nothing?
I would accept also a no answer, but I would really like to understand why this choice in the APIs.
|
It seems you are unable to set the background color of the WKInterfaceSlider. You could always do a feature request.
I think the reason behind this is that the user should be familiar with the interface elements regardless of which app he/she uses.
Tips: You could make your own Slider via a WKInterfacePicker. Where you define the slider as an image sequence. Highly customisable and you could slide it via the digital crown. Check out this piece of code: Trying to get button to spin in WatchKit
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ios, watchkit, apple watch"
}
|
Create index and merge two dataframes side by side after transpose
I have two tables
NumberofTracks NumberofAlbums
0 200 12
and
Genres Metal Rock
count 12 17
The second table is the result of a transposed group by aggregation
I need to join both tables to have something like
Metal Rock NumberofTracks NumberofAlbums
count 12 17 200 12
here is the table I performed the aggregated transpose on as well as the code that I used
Genres Songs
Metal Nothing Else Matters
Metal Paranoid
Metal Paranoid
Rock I Can't Drive 55
Rock Carry On Wayward Son
Metal Walk
group=df.groupby('Genres').agg(count=('Songs','count'))
transpose=group.T
|
Assuming `df1` is the name of the first table and `transpose` is the name of the transposed table, you can use:
transpose.join(df1.set_index(transpose.index))
# Result:
Metal Rock NumberofTracks NumberofAlbums
count 4 2 200 12
Here, we make use of `.set_index()` to set the index of `df1` to the same index of dataframe `transpose`. Thus, enabling them to `.join()` together because of having same index.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, pandas, join, merge, pandas groupby"
}
|
DS-160 - I was asked more questions than my mom, is that normal?
My mom and I are planning to visit the US soon for a short period of time, I had 1 more section than she did, is that normal?
This is the section I am talking about: DS-160 Form Guide: Additional Work/Education/Training Information.
|
It appears that this section is required of only some applicants, depending on their occupation or nationality:
> Please note that this page will be displayed if the Additional Work/Education/Training page is not required (this page is required for nationals of certain countries as discussed below).
And
> Present and Past Work/Education/Training Information
>
> This page is displayed for all applicants with varying amount of information required depending on the Primary Occupation chosen.
Source: <
|
stackexchange-travel
|
{
"answer_score": 4,
"question_score": 4,
"tags": "visas, usa"
}
|
Open a pair of tabbed terminal windows with titles
I am constantly opening up a pair of terminal windows which I like to have on separate tabs that I then use to SSH to the same pair of servers. I then set the titles of each tab to be that of the server I am connecting to. This is something I do manually every day and would love to be able to automate it.
So I tried the following:
gnome-terminal --tab
gnome-terminal --tab
gnome-terminal -t hello
gnome-terminal -t=hello
gnome-terminal -t="hello"
gnome-terminal --title="hello"
gnome-terminal --title=hello
gnome-terminal --title='hello'
gnome-terminal --tab --title='hello'
None of these options were able to open a new terminal window in a tab or with the title set to "hello". I haven't even tried to tackle the problem of ssh-ing to the servers yet. What am I doing wrong?
|
Try this:
gnome-terminal --tab -t "watch" -e "watch ps -ef" --tab -t "top" -e "top"
It seems that gnome-terminal ignores `--tab` if there is only one in the command line. You have to provide at least two `--tab` to have some effect.
The command to execute is given by `-e` or `--command`. I used `watch` and `top` in my example because they run indefinitely so the tabs will stay open. Once the command is done executing the tabs will close themselves. Read this answer for how to prevent the tabs from closing once the command is done executing.
|
stackexchange-askubuntu
|
{
"answer_score": 3,
"question_score": 4,
"tags": "command line, ssh, gnome terminal"
}
|
How do I get to the "Personnel Facilities" waypoint in Priority: Mars?
In the second mission of the game, Priority: Mars, you fight your way inside a building and go up a large elevator. Once you take the elevator all the way up, you find yourself in an area that kind of looks like a big garage. Some enemies attack you from the walkways above and, once you defeat them, a waypoint appears to "Personnel Facilities." Shepard makes a comment about figuring out a way up there, and then that's where I get stuck.
I found a button that raises one of the large yellow vehicles but then I run around all over the floor of area and can't find a ladder or any other way of reaching the walkways above. The only thing I can find is an elevator the enemies have conveniently sabotaged.
So, with all that said, **how do you get from the floor of the "garage" to the "Personnel Facilities" waypoint above?**
!enter image description here
|
When you have lifted up "one of the large, yellow... things..." you can scale the boxes to the left of it and jump on top of it to reach the top floor of the room. Here is a video of Ronan Forman doing it
|
stackexchange-gaming
|
{
"answer_score": 4,
"question_score": 2,
"tags": "mass effect 3"
}
|
How to access parameters that were passed to next page
As part of my requirement i constructed the href link with a variable associated with it as follows
<h5><a href=" ', $NAME, '</a></h5>
Upon click, page is being redirected correctly to single.php and even $ID value can be seen on the browser.
But I dont know how to extract ID parameter in single.php
Can any body please tell me how can i access $ID value in single.php page
|
<h5><a href=" ', $NAME, '</a></h5>
<?php echo $_REQUEST['id']; ?>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, php, html, css, e commerce"
}
|
Where to get a climate database for all places of the world?
I want to show some climate graphs and historical weather data for specific places around the world.
My current database has city names, countries, longitude, latitude possible to query a search in a climate database. There are a lot of weather api's but I search for static climate information, can't find anything on the internet. Database doesn't have to be updated, I don't expect the climate too change so fast.
XML, json even api is fine. Hope anyone can help me with this.
Format with max / min temperature per month, maybe average rainfall and sun hours would be great.
|
NOAA keeps global climate data, Did you look at:
There seems to be an API:
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "weather"
}
|
java: Splitting arithmetic expresssion into tokens
How do you separate an arithmetic expression with space, example i have this expression 22+(33*1) i want to split them with space between operators in the same string (returning a String) like 22 + ( 33 * 1 ) by the way im using StringTokenizer
|
Your rule is simpler then you think. Probably correct java:
expr = expr.replaceAll('+', ' + ')
.replaceAll('-', ' - ')
.replaceAll(')', ' ) ')
//etc
.replaceAll(' ', ' '); //remove any double spaces added.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, string, stringtokenizer"
}
|
css: Attach a div to a Centered div
I have a centered div and was wondering how can i attach a div on its right, there is a title DIV on top, then the yellow centered DIV and this SOCIAL SHARING DIV I'd like to attach on the right.
Thank you!!!
!image of my divs
|
Add it inside the yellow div, and position it as follows:
#yellowdiv { position: relative; }
#sidebar { position: absolute; left: 790px; top: 10px; }
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "html, css, css float"
}
|
Then minimum value of $\frac{\sec^4 \alpha}{\tan^2 \beta}+\frac{\sec^4 \beta}{\tan^2 \alpha}$
> If $\displaystyle \alpha, \beta \in \left(0,\frac{\pi}{2}\right),$ Then minimum value of $$\frac{\sec^4 \alpha}{\tan^2 \beta}+\frac{\sec^4 \beta}{\tan^2 \alpha}$$
$\bf{My\; Try::}$ I have tried it using Cauchy-Schwarz Inequality
$$K=\frac{\sec^4 \alpha}{\tan^2 \beta}+\frac{\sec^4 \beta}{\tan^2 \alpha}\geq \frac{(\sec^2 \alpha+\sec^2 \beta)^2}{\tan^2 \alpha+\tan^2 \beta} = \frac{(2+\tan^2 \alpha+\tan^2 \beta)^2}{\tan^2 \alpha+\tan^2 \beta}$$
So $$K\geq \frac{4+(\tan^2 \alpha+\tan^2 \beta)^2+4\cdot (\tan^2 \alpha+\tan^2 \beta)}{\tan^2 \alpha+\tan^2 \beta} $$
$$K\geq 4+(\tan^2 \alpha+\tan^2 \beta)+\frac{4}{\tan^2 \alpha+\tan^2 \beta}\geq 4+4 = 8$$
My question is can we solve it some simple way, If yes Then plz explain me, Thanks
|
Let $a = \frac{\sec^2\alpha}{\tan \beta}$ and $b = \frac{\sec^2\beta}{\tan\alpha}$. Then we have: $$a^2 + b^2\geq 2ab = \frac{2\sec^2\alpha\sec^2\beta}{\tan \beta\tan\alpha} = \frac{2}{\sin\alpha\cos\alpha\sin\beta\cos\beta} = \frac{8}{\sin(2\alpha)\sin(2\beta)}\geq 8.$$
Both equality happens when $\alpha = \beta = \pi/4.$
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 2,
"tags": "inequality"
}
|
Numpy array indexing with a List: difference between arr[:][li] and arr[:,li]
What is the explanation of the following behavior:
import numpy as np
arr = np.zeros((3, 3))
li = [1,2]
print('output1:', arr[:, li].shape)
print('output2:', arr[:][li].shape)
>>output1: (3, 2)
>>output2: (2, 3)
I would expect output2 to be equal to output1.
|
Let's use a different array where it's easier to see the difference:
>>> arr = np.arange(9).reshape(3, 3)
>>> arr
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
The first case `arr[:, li]` will select all elements from the first dimension (in this case all the rows), then index the array with `[1, 2]`, which means just leaving out the first column:
array([[1, 2],
[4, 5],
[7, 8]])
Hence, the shape of this is (3, 2).
The other case `arr[:]` will copy the original array, so it doesn't change the shape, therefore it's equvivalent to `arr[li]`, hence the output shape is `(2, 3)`. In general you should avoid double indexing an array, because that might create views twice, which is inefficient.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, arrays, numpy, indexing"
}
|
Aliasing a java package name in clojure
Given a java package x.y.z, can I alias x.y.z to a shorter name, so that i can then refer to java classes inside the package as my-alias.MyJavaClass.
If that isn't possible, I could just `import` all classes into my namespace, but I don't want to specify the names of each class manually, and the clojure API docs doesn't seem clear on whether it's possible to `import` all classes in a package automatically.
|
There isn't any functionality for this (yet). Java packages are in a different namespace than Clojure's, so the usual alias tricks won't work.
What you can do is import each class, which lets you avoid the full package+class name:
(import [java.io File Writer Reader])
(new File "/")
; #<File />
Rich provides his reasons for not supporting `(import [java.io.*])` here.
|
stackexchange-stackoverflow
|
{
"answer_score": 12,
"question_score": 10,
"tags": "clojure"
}
|
msys2 create a sym link into windows folder location
I have just started to use msys2. I wanted to make a sym link to a folder on my d:. I can access it like this:
`cd /d/mytestfolder/`
I tried:
* When I do `ln -s /d/mytestfolder/ testfolder` \- this seems to be working, but takes a long time, then I realized it just makes a copy and not a link at all :(
* I also tried `cmd /c mklink /c/mytestfolder` (found that somewhere on the web)... no joy
* I even tried (in windows explorer) making a windows short cut. I can see that file, but it does not work with `cd`.
So how can I make a link/shortcut to to my folder?
|
Same as Use mklink in msys
reminding that mklink is a windows command, so it does not understand `/c/mytestfolder` but `c:\mytestfolder` must be used
cmd /c 'mklink link c:\mytestfolder'
|
stackexchange-superuser
|
{
"answer_score": 5,
"question_score": 4,
"tags": "linux, windows, cygwin, msys"
}
|
Вызов метода скрипта, лежащего на другом объекте
Выполняю реализацию панели умений и появилась проблема с использованием умения находящегося в ячейке. Суть: есть 5 ячеек, в которых мы можем менять местами наши умения. Нужно понимать, какое умение находится в ячейке и при нажатии на бинд(кнопка использования спелла) ячейки, вызывалось умение, которое лежит в ячейке.
Есть база данных на сцене, в которой лежат префабы наших умений. По сути это один измененный префаб, в котором меняется [название], [id], [описание], [cooldown], [и сам компонент скрипта с реализацией умения]. **Проблема** заключается в вызове скрипта с реализацией способности, который висит на объекте базы данных, к которому мы обращаемся. Не могу найти способ вызова функций из этого скрипта. Думаю можно создавать одинаковые названия скриптов и методов и при нажатии на клавишу мы обращаемся к объекту бд по id и через GetComponent().UseSkill() вызвать метод, но мне этот метод не очень нравится.
|
В общем нашел я решение для проблемы. На скринах мой пример решения проблемы. Я просто решил переопределить метод `Use()` в дочерних классах, которые отвечают за реализацию своего умения. Сначала добавил поле `bool IsUsable`, чтобы проверять, можно ли использовать умение, но как оказалось методы переопределяются не во всех дочерних классах, а только на том, на котором лежит `override`-метод. Не знаю насколько этот метод может существовать, но если вам нужно что-то рабочее, то вот.
> На префабе вашего умения должен висеть **ТОЛЬКО** скрипт с реализацией умения(в примере Spell1 или Spell2) без скрипта `Skill`, Иначе работать не будет!!!
 and the plugin is responsible to acessing his serial port, parallel port, etc, and sending client's information to the cloud for processing.
|
I do know, that the opposite is possible: Write a Winforms app, that only contains a browser and have it communicate with the serial port in the background - this is how I access a ticket printer in a ticket sales app.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, plugins, web, cloud"
}
|
Exploring feasible points in a linearly defined space
What is the quickest way to find a point inside a linear feasible space? (Defined by the intersection of several hyperplanes and halfspaces). I want to be able to choose an initial point in the original convex space, discover a certain neighborhood around it (not convex but can be written as the union of some convex spaces defined by by the intersection of several halfspaces) using a procedure that depends on the point I have, and then I need to choose another point in the original space but not in the neighborhood already explored. I need to keep doing that until the space is exhausted (It should be exhausted eventually). Basically, I have a convex space $S$, I need loop until $S=\phi$ while doing the following: Choose $x\in S$, Find $N$ around $x$, and then $S \leftarrow S - N$ Any help is appreciated.
|
Finding a single feasible point is traditionally done by phase 1 of the simplex algorithm.
<
This means that you can do it by calling any routine for linear programming, just by putting the objective function to zero.
Covering the feasible domain by balls of fixed radius $r$ whose midpoints are feasible is much harder, though, as exccluding a ball constitutes a nonconvex domain. There are algorithms for enumerating all vertices of a bounded polyhedron given by equations and inequalities (their number typically grows exponentially with the dimension, though). After having all vertices, the feasible set consists just of their convex combinations, so this can be used to samle inside. But unless the polyhedron is a simplex, different convex combinations may give the same point, so one would need to add a reject facility when generating a minimal covering.
|
stackexchange-scicomp
|
{
"answer_score": 4,
"question_score": 2,
"tags": "linear algebra, linear programming"
}
|
how to detect all symbol on mathematical operators on php using regex?
how to detect all symbol on mathematical operators on php using regex?
example :
$operators = [">0",">=1","==12","<9","<=1","!=4"];
$results = array();
foreach ($operators as $key => $value){
detect $value using regex, if include symbol of maths operators {
array_push($results, $value);
// just push $value with format of symbol of maths operators, example : ">" // remove 0 on my string
}
}
from my array i want to collect just math operators, my expected results:
$results = [">",">=","==","<","<=","!="];
how to do that? thank you advanced
|
You can simply use `array_map` along with `preg_replace` like as
$operators = [">0", ">=1", "==12", "<9", "<=1", "!=4"];
print_r(array_map(function($v) {
return preg_replace('/[^\D]/', '', $v);
}, $operators));
**Output:**
Array
(
[0] => >
[1] => >=
[2] => ==
[3] => <
[4] => <=
[5] => !=
)
**Demo**
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -3,
"tags": "php, regex, string, operators"
}
|
platform-tools\aapt.exe directory missing in android SDK
I'm trying to get 'hello world' working on the Android SDK with Eclipse. I'm following this tutorial step by step:
<
but i'm returned the error "Error executing aapt. Please check aapt is present at C:\android-sdk-windows\platform-tools\aapt.exe"
For some reason, the "platform-tools" folder does not exist under my installation. In its place I find "platforms" and "tools". Presumably, my SDK version is different to that used in the tutorial.
I can't work out what i need to change or update. Can someone please point me in the correct direction?
Thank you
|
*What version of the SDK are you running? (1.5_r2 or something?)*
I would suggest updating your SDK and be done with it ;) You can do so trough the "Android SDK and AVD Manager".
Eclipse:
`menu->window->"Android SDK and AVD Manager"`
You might also want to change this setting:
`menu->window->preferences->install/update->(expand)->automatic updates`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 5,
"tags": "android, eclipse, sdk"
}
|
Передача кука и сессии на другой домен
Подскажите, как, один раз авторизовавшись, авторизоваться на разных доменах?
|
Ну что же. Можно намутить как вариант, конечно, такое - входите на один сайт. На нем стоит внизу счетчик от других сайтов (счетчик или картинка - все равно). Адрес ее делается следующим образом - ` мд5`, от пароля получая данное, скрипт делает проверку (на одном из сайтов, на котором надо авторизоваться) и дальше можете бегать между ними.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "авторизация, сессия, cookie, php"
}
|
Given that $f(x)=(2x+1)^3$, find $\int (\lim_{h \to 0} \frac{f(x+h)-f(x)}{8h})\,dx$
I thought this was as simple as: $$ \int \left (\lim_{h \to 0} \frac{f(x+h)-f(x)}{8h}\right)\,dx = \frac{1}{8}\int f'(x)\, dx=\frac{f(x)}{8} + C $$
But the answer is supposed to be:
$$ \left (\frac{2x+1}{2} \right )^2 + C $$
How?
|
For a continuously differentiable function $f$, we have
$$\int f'(x)dx = f(x) + C$$ i.e., you need to write the constant. The indefinite integral is _always_ a family of functions, not just a single function. So the correct answer would be $$\frac{f(x)}{8} + C.$$
The answer to the question **you** wrote is certainly not $$\left (\frac{2x+1}{2} \right )^2 + C$$
Unless you made some typo (highly likely, and I advise you to double check), the answer provided is wrong.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 1,
"tags": "calculus, limits, derivatives"
}
|
I want to parse xml comming from http server using blackberry
I want to parse xml which coming from http server using black berry
|
You can use KXML framework and parse the incoming data from server. For more information see this wiki link.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "blackberry, xmlpullparser"
}
|
When to use Unconfined in Kotlin
When would I choose to use Dispatchers.Unconfined? Is when it doesn't really matter where the coroutine should run? So you let the coroutine to choose the thread pool as it better suits?
And how does it differ from Dispatchers.Default? Is it that when running the Default dispatcher is always within a specific thread pool defined as the default one?
|
> The unconfined dispatcher is appropriate for coroutines which neither consume CPU time nor update any shared data (like UI) confined to a specific thread.
So, I'd use it in non-IO, UI or computation heavy situations basically :D. I think the nunmber of use-cases for this is pretty low, but I'd think of an operation which isn't heavy, but still for some reason you'd like it to run on a different thread.
Here's a link for how it actually works.
`Dispatchers.Default` is really different, and it's mostly used for heavy CPU operations. This is because, it actually dispatches works to a thread pool with a number of threads equal to the number of CPU cores, and it's at least 2. This way developers can leverage the full capacity of the cpu when doing heavy computational work.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 5,
"tags": "kotlin coroutines"
}
|
XQuery Full Text Search: Text Near Element?
I am using the eXist implementation of Lucene. Is there a query that would allow me to find, for instance, all occurrences of `<span>A</span> B` in a document? I.e., all `B`s that occur within 1 word of `<span>A</span>`, but aren’t wrapped in their own elements?
|
This XPath should do the trick:
//span[. = 'A'][following-sibling::node()[1] = ' B']
This doesn't make use of eXist's Lucene-based full text index, but you haven't said if you've applied an index to the span element here. If there's another aspect to the challenge, please let me know.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "lucene, full text search, xquery, exist db"
}
|
Getting Webview URL from textField in Swift
I have a picker view that populates a `textField` with a `URL` from an array. I would like the user to select an option from the picker view which then opens up the `webView` with the supplied address in the `textField`. Is that possible?
Is there a more efficient or easier way to do this?
**The only code I have is for the PickerView populating the `textField`.
|
You have code for the UIPickerview selection that fills the textField value.
So now once user select the value from UIPickerView first fill the textfield and navigate it to webviewController that contains the String varialbe for URL.
Pass the selected value as String while navigation like push the view controlller.
and follow the link for the load URL in webview:
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "swift, web, view, uiwebview"
}
|
Change background color of NSButton
I have an NSButton in a mac application whose colour I'd like to change programatically but nothing I tried seems to work. I tried to create an output on the NSButtonCell and set the background color there but that didn't work either. Any code snippets would be helpful.
|
The standard Aqua (pill-shaped) buttons are drawn by the system. They don't have a background color as such. In fact, they are composed of images that Cocoa stitches together to make a coherent button image. So Cocoa can't recolor the images to your liking. Only the default button (the one with Return set as its key equivalent) will have a blue pulsing background.
What it sounds like you want to do will involve subclassing `NSButtonCell` and doing your own drawing. If you wanted to recolor the button images to get the effect you want, you can use the excellent Theme Park utility to extract copies of Apple's button images and use those. I'll admit to having done this myself in order to "steal" certain interface elements that aren't otherwise accessible, such as the scrollers from iTunes.
|
stackexchange-stackoverflow
|
{
"answer_score": 15,
"question_score": 33,
"tags": "objective c, cocoa, macos, user interface"
}
|
get value of current scroll position by js
I need if user scrolled to `<a id="stass">` this script runs
<script>
if(current id is stass){
var stassik = 1231;
}
</script>
The part with `if(current id is stass)` it s where I need to get info about current anchor. I mean, if user scrolled to this anchor, the var `stassik ` will become `1231`
|
Try using IntersectionObserver API to achieve this. For more details: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, html"
}
|
#define directive clarification
Sorry if this is a a bad question but . . .
I want to create a shortcut to my UIColor that looks like this
[UIColor colorWithRed:(88.0f/255.0f) green:(201.0f/255.0f) blue:(234.0f/255.0f) alpha:1]
Can I use a #define for that somehow so that I can just type in some shortcut? I've tried but I think my notation may be off . . .
If a #define is only for constants or for some reason doesn't apply in this situation, are there any other ways to shortcut that method?
Thanks!
|
#define is just a glorified text replacement system. If you define something like this:
#define key value
then the preprocessor will replace every occurrence of `key`with `value` even before the compiler can do anything. So it doesn't really matter what you define. You can use anything as your value, so you could do something like
#define kMyColor [UIColor colorWithRed:(88.0f/255.0f) green:(201.0f/255.0f) blue:(234.0f/255.0f) alpha:1]
But in this case you probably should use a static constant variable:
static const UIColor *myColor = [UIColor colorWithRed:(88.0f/255.0f) green:(201.0f/255.0f) blue:(234.0f/255.0f) alpha:1];
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "objective c, ios, cocoa touch"
}
|
Susy gem: How to find out which version of Susy is installed?
Does any one know how can I found which version of **Susy** is installed on my windows system?
For example you can write in the command line compass -v to find out which version of Compass is installed on your machine. But susy -v doesnt work.
Is there any command to find out which version of Susy is installed?
Thanks
|
Ok, I found a way.
gem list
shows all installed gems including Susy. :-)
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 3,
"tags": "susy compass, susy"
}
|
How to get open files of a subprocess?
How to get open files of a subprocess?
i opened a subprocess which generate files, i want get file descritor of these files to do fsync on them
so if i have code like this:
p = subprocess.Popen([
'some_program'
])
the process p generate some files i can get the process id of the subprocess using:
p.pid
but how can i get fd of these files to call flush and fsync() on them?
actually i find a utility called "lsof" (list open files) but it is not installed or supported on my system, so i did not do further investigations on it, as i really need a standard way
thanks
|
Each process has its own table of file descriptors. If you know that a child process has a certain file open with FD 8 (which is easy enough, just take a listing of `/proc/<pid>/fd`), when you do `fsync(8)` you are sync'ing a file of _your_ process, not the child's.
The same applies to all functions that use file descriptors: `fread`, `fwrite`, `dup`, `close`...
To get the effect of `fsync`, you might call `sync` instead.
What you could do instead is implement some kind of an RPC mechanism. For example you could add a signal handler that makes the child run `fsync` on all open FDs when it receives SIGUSR1.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, linux, posix, fsync"
}
|
CSS text-indent combined with white-space
I have the following style already: `white-space: pre-wrap;`
This allows newlines to be treated as newlines (and spaces don't get collapsed) for the element.
Now I want to apply `text-indent: -40px; padding-left: 40px;` in an attempt to produce something like this:
This is a long line of text (or at least, just pretend it is) so it
will indent when it wraps.
Further lines of text appear as normal, but again if they exceed the
maximum width then they wrap and indent.
Unfortunately, it's not doing quite what I intended:
This is a long line of text (or at least, just pretend it is) so it
will indent when it wraps.
Further lines of text appear as normal, but again if they
exceed the maximum width then they wrap and indent.
Is there a way in CSS to indent wrapped lines, but counting newlines as a new first line?
|
No, because `text-indent` relates to the first line of an element, and newlines generated by line wrapping do not create elements. So instead of just newlines in HTML source, you need to use some content markup.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "css, text indent"
}
|
Word for destroying someone's heart physically
For example, _decapitate_ means to cut off someone's head.
Is there a word that means to rip out someone's heart or destroy a heart?
|
Perhaps there is no really appropriate single word commonly accepted for what you seek, and you should simply use the phrases 'heart removal' or 'heart extraction', which are the terms used on Wikipedia's page on human sacrifice in Maya culture. However, there are terms used in medicine that may be of interest to you.
Mosby's Medical Dictionary lists 'cardiectomy' to mean 'removal of the heart' or 'removal of the cardiac portion of the stomach'. The Miller-Keane Encyclopedia and Dictionary of Medicine, Nursing, and Allied Health lists 'cardiocentesis' as 'surgical puncture or incision of the heart'.
|
stackexchange-english
|
{
"answer_score": 15,
"question_score": 21,
"tags": "single word requests"
}
|
specifically add javascript to class but not to another
How would you specifically add some javascript to one class, but definitely not to another class.
My simple javascript is below:
<script type='text/javascript'>
$(document).ready( function(){
$('.slider').foggy();
});
</script>
I want to apply the 'foggy()' to the class **.slide**
But I definitely don't want to apply it to apply it to the class **.slide.swiper-slide-visible.swiper-slide-active**
|
You can simply do this with `:not(selector)`
$('.slider:not(selectorClassToExclude)').foggy();
Like you don't want to add foggy() to **.slide.swiper-slide-visible.swiper-slide-active** code would be:
$('.slider:not(.swiper-slide-visible)').foggy();
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "javascript, jquery, class, document ready"
}
|
How to get cookies while browing from the android mobile programmatically?
I want to get the browser cookies from the android application programmatically.
I got a link for one application (`.apk`) through one customer(i.e. website). The link will redirect me to the server(i.e., the data base of the owner of `.apk` file). Then the owner will check whether the customer is registered. If registered, It'll allow me to download the `.apk` file and the server will also send the Customer Id to the cookies. I want to get the Customer Id from the mobile browser cookies using program.
|
You could do some kind of xss. Depending on your website configuration if you set your cookies for all subdomains you could add a new subdomain let's call it xss.example.com where you read the cookies and put them in GET args pointing back to an URL which is caught by your app.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -4,
"tags": "android, cookies"
}
|
Rounded borders on a JPanel
What I've got here is a JPanel with a rounded border that is set up as such:
panel.setBorder(new LineBorder(PanelColor, 5, true));
The problem is, in each of the corners there are 2 diagonal opaque lines going from the outer corner to the inner corner that is the length of the border. Whatever is behind the border shows through. Is there any way to get rid of these lines and make the entire border one solid color? Thanks!
I'd attach a picture but I don't have enough rep to do so :P
|
Maybe here is a way to paint RoundedLineBorder; please be careful with constants for nice output to the GUI.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "java, swing, user interface, awt, border"
}
|
Information from a characteristic polynomial
 I know that since the highest multiplicity is 4, that the largest possible dimension is 4.
(IV) I believe that there are 3 distinct eigenvalues, but because of the multiplicities, there are exactly 7 eigenvalues?
I don't know how to tell if it's invertible, or the size of the matrix from the information given.
|
(I): $A$ can't be invertible because $0$ is an eigenvalue.
(II): $A$ must be $7 \times 7$ because its characteristic polynomial has degree $7$.
(III): Your answer is correct
(IV): I don't think that they mean to count eigenvalues up to multiplicity. Yes, $A$ has exactly $3$ distinct eigenvalues.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "linear algebra"
}
|
What is the source code of find element in selenium-java?
This maybe a fairly simple question,but I'm having hard time finding it out.I'm trying to understand what is the source code of the find elements function in selenium-java? I looked at the source code,I only found the webdriver interface that has unimplemented function? If it is an interface it should be implemented by some class,Isn't it? but I could not find any class that implements webdriver interface.
What am I missing here?
|
You are probably looking at the `WebDriver` interface alone. But, the main point of interest should be the `RemoteWebDriver` class which implements `WebDriver`.
Note that browser-specific `WebDriver` implementations are then based on the `RemoteWebDriver`. For instance, see the `ChromeDriver`.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 2,
"tags": "java, selenium, selenium webdriver"
}
|
C# late bound non exist property
how check is property exist? like
if propertyName in obj
{
}
because there is some moments when obj doesn't have such property
|
Another approach using reflection is:
PropertyInfo info = obj.GetType().GetProperty("PropertyNameToFind");
if (info != null)
{
// Property exists in this type...
}
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "c#, .net"
}
|
preg replace multiple results
I'm currently writing a function in PHP to translate BBCodes for a forum engine. Now I wanted to add a `[code]`-tag and I created the following function:
$txt = preg_replace('#\code\\[(.*)\[/code\]#isU', "<div class=\"bb_uncode\">$1[$2</div>", $txt);
(Side note: `[` equals [)
This works very well if there's only one `[` inside the [code]-tags, but it ignores every further one.
Is there a possiblity to apply this search pattern on every other brackets, too?
|
Do this with `preg_replace_callback()`:
$txt = preg_replace_callback('#\code\\[/code\]#isU', function($match) {
return "<div class=\"bb_uncode\">" .
str_replace('[', '[', $match[1]) .
"</div>");
}, $txt);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "php, preg replace, bbcode"
}
|
Align some text between two html.actionlinks
I have been trying to place a "|" between two actionlinks but it just goes out of the place.Is there a way I can align them just like in plain html page.
@Html.ActionLink(....)
|
@Html.ActionLink(....)
but doesnt align properly.Am i missing some simple rule?
I am new to MVC
|
Use the `span` tag like this:
@Html.ActionLink(....)
<span> | </span>
@Html.ActionLink(....)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "html, asp.net mvc, html.actionlink"
}
|
Ray Tracing Sphere Shadows On Triangles
I have two light sources, three spheres and two triangles. Spheres placed on two triangles. I alrady did intersectSphere and computeColorSphere functions. I somehow started implementing intersectTriangle and computeColorTriangle functions. How should it be different from Sphere functions ? and how can i implement shadows of spheres on triangles plane ?; but you need to check if there is no obstacle to the light sources by casting secondary rays from the hit point to the sources. If you find an obstacle, just ignore the contribution for this source.
Very similarly, you can implement reflections by casting a secondary ray in the reflected direction (incidence angle = reflection angle) and seeing if you hit another surface.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c, graphics, raytracing"
}
|
Sending javascript variable on res.render - express
I'm trying to build a small app to call from a `config.js` file containing JSON and write that data to a page based on the `name` key within the JSON.
app.get('/:verb', function(req, res) {
if(!!req.param.verb) {
config.data.forEach(function(o) {
var verbName = o.name,
description = o.description;
});
};
res.render('verb', {title: verbName, subtitle: description});
});
What I'm trying to do is use the `verbName` and `description` javascript variables as Jade variable in the `res.render` structure. As it stands this code will fail due to `verbName` and `description` not being strings.
Is it possible to include variables this way?
PS - been in express 1 week and Jade 2 days, so all ideas/solutions would be appreciated.
|
You are declaring your variables in the wrong scope. You are also overwriting them on each of the forEach loop executions
app.get('/:verb', function(req, res) {
var verbName,
description;
if(!!req.param.verb) {
config.data.forEach(function(o) {
verbName = o.name,
description = o.description;
});
};
res.render('verb', {title: verbName, subtitle: description});
});
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "javascript, json, node.js, express, pug"
}
|
I want to learn how images are composed
I really want to learn how an image is composed (i.e. array of bits, or however, how is the color composed for each pixel, etc). Can you point me in the right direction? I'm not really sure what to search for.
Thanks a lot in advance.
So what I want to do is to be able to modify the picture pragmatically, i.e. change to black and white, scale it, crop it, etc, and for this I would really like to learn how the image is composed instead of just finding these algorithms online.
|
You don't always need to know low level mathematical details(matrixes,quantisation,fourier transform etc.) of graphic formats to manipulate images. For all the things you want to do you may use proper libraries. For example in PHP libraries used freuqently to manipulate images are:
* GD - <
* ImageMagick - <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "image, image processing"
}
|
How do I sell uniques that I don't need
I'm a casual gamer mostly playing self-found in Standard. From time to time, I find some uniques that I don't need (some latest catch were Thousand Ribbons or Perandus Blazon). I don't want to vendor them, as they only yield me a couple of shards. Linking them to /trade 1 doesn't help, as /trade 1 is generally overwhelmed with massive and better offers.
How could I sell those uniques to other players? Or, better, how do I find players in need of those uniques?
I'm only playing 1-2 hours a day, irregularly.
EDIT: For anyone reading this question later than March 2016, Premium stash tabs are more convenient than Procurement. Premium stash tabs are paid, using Procurement is still free.
|
Use Procurement and set up a shop. It's never too early to do that.
People buy this sort of uniques by looking for the cheapest online seller on poe.trade. If you appear online on poe.trade (Procurement has a feature to do that automatically for you as long as the program is open), and have one of the lowest prices listed there, they will contact you. Bingo.
You will occasionally sell items for less than their value. It's perfectly normal; forget it, go on, and learn.
|
stackexchange-gaming
|
{
"answer_score": 1,
"question_score": 4,
"tags": "path of exile"
}
|
onclick location href not working with php variable
I have a button with a link that involves a PHP variable, but when the button is clicked, nothing happens and I am not brought to a new page according to the link. I tested the link with a `<a>` tag instead of a `<button>` tag, and the link works. I am new to PHP so any suggestions are appreciated.
Here is the code:
<?php
echo
'<button type="button" class="btn btn-secondary" id="btn" style="margin-left:0%;color:gray" onclick="location.href="' . $child_page . '"">
KEEP READING <span class="glyphicon glyphicon-chevron-right" style="color:gray"></span>
</button>';
echo '<a href="' . $child_page . '">Link </a>';
?>
The variable can look like: `/n/2/ar/` and will apply like this: `www.example.com/n/2/ar/`. Please note that the inline CSS is only for testing purposes.
|
There is a problem with the quotes..Nothing else Use this:
echo
'<button type="button" class="btn btn-secondary" id="btn" style="margin-left:0%;color:gray" onclick=location.href="'.$child_page.'">
KEEP READING <span class="glyphicon glyphicon-chevron-right" style="color:gray"></span>
</button>';
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "javascript, php, html, css"
}
|
how to compile Marble (KDE) on macOS? No pre built package available
Marble is an Open Source alternative to Apple Maps / Google Earth:
> Versatile, yet easy to use. Use Marble similar to a desktop globe; pan around and measure distances. At closer scale it becomes a world atlas, while OpenStreetMap takes you to street level. Search for places of interest, view Wikipedia articles, create routes by drag and drop and so much more.
From marble.kde.org deep link `
> Mac OS X Desktop
>
> The Mac OS X installer is outdated. We recommend compiling the latest stable version yourself.
Homebrew
> brew cask search Marble
==> Exact Match
marble
> brew cask info marble
marble: 1.5.0
Not installed
From:
==> Name
Marble
==> Artifacts
Marble.app (app)
there is no guide how to compile on macOS from source.
|
There is a pre-built application for Marble. You can install it with :
brew cask install marble
It will install it as a standard application on :
/Applications/Marble.app
|
stackexchange-apple
|
{
"answer_score": 2,
"question_score": 2,
"tags": "terminal, command line, install, homebrew, open source"
}
|
How to make VS Unit Test show the Error Message from exceptions other than UnitTestAssertException?
I'm using VS Unit Testing Framework and Moq.
When a Moq verification fails, I'll get a Moq.MockException. In the Test Results window, instead of showing the helpful message inside the exception, it just says "Test method XXX threw exception: ..."
Is there a way to tell the VS Unit Test framework always display the message of exceptions of a given type (like Moq.MockException)?
|
The short answer is: No. You have to open the _Test Details_ window for that in MSTest (btw. that's one of many reasons why I think MSTest is not the best choice for doing Test-driven development...).
Anyway, there are two possible ways to achieve this (at least that I know of):
1. Use ReSharper to run your tests.
2. Use the free Gallio automation platform to run your tests.
HTH!
Thomas
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "unit testing, exception, moq, assert, vs unit testing framework"
}
|
Example of $g:\mathbb{R}^2 \to \mathbb{R}$ s.t. $E[g(Z)\mid M=\mu]=0, \forall \mu \in C$ where $Z$ is Gaussian and $C$ is an ellipse.
Let $Z \in \mathbb{R}^2$ be an i.i.d. Gaussian vector with mean $M$ where $P_{Z|M}$ is it's distribution.
**Question:** I am looking for an non-trivla example of function $g: \mathbb{R}^2 \to \mathbb{R}$ such that \begin{align} E[g(Z)\mid M=\mu]=0, \forall \mu \in C \end{align} where $C=\\{\mu: \frac{\mu_1^2}{r_1^2}+\frac{\mu_2^2}{r_2^2}=1 \\}$. That is, $C$ is an ellipse.
**Some Thoughts** : I was able to find an example of $g$ when $r_1=r_2=r$ that is when $C$ is a circle. For example, let \begin{align} g(x)= \|x\|^2 -(2-r^2) \end{align} Then, \begin{align} E[g(Z)|M=\mu]&= E[\|Z\|^2 \mid M=\mu]-(2-r^2)\\\ &=\operatorname{Var}[Z \mid M=\mu]+ \|\mu\|^2-(2-r^2)\\\ &=2 +r -(2-r)=0 \end{align}
However, I was not able to find an example of such a function if $C$ is an ellipse but not a circle.
|
**Hint**
If $\ f(x)=\frac{x_1^2}{r_1^2}+\frac{x_2^2}{r_2^2}\ $, what is $\ E\big[f(x)\,\big|\,M=\mu\big]\ $ for $\ \mu\in C\ $?
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "probability theory, expected value, gaussian integral"
}
|
2 PPPOE on different computer
I have an ISP which provides "WAN Miniport (PPPOE)" connection type. It means they gave me the username and password so that I can log into in. They have registered my MAC address on their website. I can add 3 MAC address so other computers at home can also log into in using username password. Now the question is, Once I'm log into my PC using username and password, I cannot login into another PC. If I log out from my PC I will able to login into other PC. Is there any trick or way to bypass it ? I mean if I try to login into another pc then My connection will be closed and his/her connection will be started.
My connection type description :
, or just "PPPoE".)
If your modem cannot do that, buy a router which can & connect it to the modem – again, many home "wireless routers" support PPPoE for their WAN connection. _(Double-NAT will not be an issue here.)_
(Windows itself also has "Internet connection sharing", but it needs a PC that's always on, with a wired Ethernet connection, and ideally with _two_ Ethernet connections – one to the modem, one to other computers.)
|
stackexchange-superuser
|
{
"answer_score": 0,
"question_score": 1,
"tags": "networking, router, adsl, dsl, pppoe"
}
|
Broken oh-my-posh on Windows Terminal
I'm using Windows Terminal (Preview) with oh-my-posh. But when I start my terminal up, the screen is broken as hell.  in Windows Terminal. The way I'm reading it, I may have run into it with some glyphs in WSL2 with the Fish shell.
If that is what you are seeing, the Oh My Posh FAQ recommends a workaround of adding an invisible spacing character at the end of each segment. For example:
{
"type": "executiontime",
/* other attributes here */
"properties": {
"always_enabled": true,
"prefix": "\ufbab",
"postfix": "\u2800" // invisible spacing character
}
}
I believe you'll need to do this for each element of your prompt.
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 1,
"tags": "windows terminal"
}
|
How to stop using Protobuf-Net inheritance and use inherited classes directly?
I have an inherited settings classes inherited from a base class which I would like to (de)serialise separately (example)
[ProtoContract]
[ProtoInclude(1, typeof(GlobalSettings))]
[ProtoInclude(2, typeof(UserSettings))]
public class BaseSettings
{
}
[ProtoContract]
public class GlobalSettings: BaseSettings
{
[ProtoMember(1)]
public string TempPath { get; set; }
}
[ProtoContract]
public class UserSettings: BaseSettings
{
[ProtoMember(1)]
public int UILanguage { get; set; }
}
Only issue is I cannot afford losing the configuration, can it be done in a way that if UserSettings are no longer inherited from BaseSettings and moved to another assembly to be used independently, (de)serialisation still will be possible (with some sort of conversion or without) without access to GlobalSettings class?
|
The inheritance is a fundamental part of the serialization model, _especially_ if you ever talk in terms of `Deserialize<BaseSettings>`. If you **only ever** do things like `Deserialize<GlobalSettings>` or `Deserialize<UserSettings>`, then you might be able to remove the `[ProtoInclude]`s, but then the issue becomes announcing the members of `BaseSettings` into the sub-types. There are ways to do that.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, inheritance, serialization, deserialization, protobuf net"
}
|
How does Path app know my phone number in the registration process
I started using Path, and noticed that in the registration process, they identified both my phone number and my email.
As far as I know, there is no way to programmatically get those values (without being rejected by apple), so how does path do it?
|
_Moving my comments into an answer :)_
As I've stated above, this is a duplicate of How does Square's CardCase app automatically populate the user's details from the address book?
Because Path asks beforehand for the first and last name it's easy to search for the contact in the address book. Of course one has to handle the case when a) no contact or b) multiple contacts are found. In both this cases I'd probably go with standard input fields, because for the "no contact found" case you need those anyway.
How common it is to have a contact with it's own name I don't know, but according to the Fact that Path and other apps are doing it the same way I suppose it's worth taking the risk :) AFAIK MacOS X automatically creates a contact with my name in the Address Book, but really can't recall if iOS has the same behavior.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "ios, iphone, email, phone number"
}
|
Undeclared JavaScript variable in functions overriding over uses
I have two function examples as follows
function call1() {
variable = "test string";
}
function call2() {
variable = responseFromAJAX();
document.title = variable;
setTimeout(function() { call2(o); }, 1000 );
}
If there anyway that the undeclared variable "variable" can be overridden by either function? even when "variable" is not declared out the scope of the functions?
Many thanks
|
> If there anyway that the undeclared variable "variable" can be overridden by either function?
Yes. Unless you're in strict mode, assigning to an undeclared variable creates a global variable implicitly (I call it _The Horror of Implicit Globals_). So either function can write to it. Fortunately, strict mode put a stop to implicit globals.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "javascript, function, variables, scope, undeclared identifier"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.