INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Whether Geth is safe to install?
I'm using Windows OS and is my private computer.
**Norton Internet Security** says :
> Firewall rules were automatically created for geth and Intrusion Prevention is monitoring network traffic.
Can someone tell me whether **Geth** is safe to install especially on a private computer.?
|
Geth, like any other Ethereum client, needs to use your network to connect with peers and share details about the latest block, pending transactions, etc...
It makes sense that Geth would adjust your firewall settings to make sure that it has outward network access, and this alone should not leave you concerned about malicious activity.
Additionally, the second part of your error message:
> Intrusion Prevention is monitoring network traffic.
This is a feature of Norton Internet Security that continues to monitor the network traffic of this connection to catch and detect any attack patterns which could exploit your system. This is in itself not an error, but simply telling you that your anti-virus software is continuing to do its job on this opened connection.
Assuming you downloaded Geth from an official source, you should feel safe to install it.
|
stackexchange-ethereum
|
{
"answer_score": 3,
"question_score": 1,
"tags": "go ethereum, security, user safety"
}
|
How do I get the name of a Ruby class?
How can I get the class name from an ActiveRecord object?
I have:
result = User.find(1)
I tried:
result.class
# => User(id: integer, name: string ...)
result.to_s
# => #<User:0x3d07cdc>"
I need only the class name, in a string (`User` in this case). Is there a method for that?
I know this is pretty basic, but I searched both Rails' and Ruby's docs, and I couldn't find it.
|
You want to call .name on the object's class:
result.class.name
|
stackexchange-stackoverflow
|
{
"answer_score": 808,
"question_score": 429,
"tags": "ruby on rails, ruby, rails activerecord"
}
|
create matrix from coordinate (x, y) ruby
I can get positions of a Matrix with this code:
rows = 2
columns = 2
Matrix.build(rows, columns).to_a
[[0, 0], [0, 1], [1, 0], [1, 1]]
this code is building a matrix from 0,0.
I would like build a matrix from 0,1
 do |k|
i, j = k.divmod(rows)
[i + ro, j + co]
end
#=> [[0, 1], [0, 2], [1, 1], [1, 2]]
See Array::new and Integer#divmod.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "arrays, ruby, matrix"
}
|
R: replace value with value from interval list
using R I calculate age based on a combination of distributions. This age is then linked to a centrain life-expectancy which is listed in a table (or whatever the most convenient way is) like this:
age exp_life
0-5 80
6-10 75.38
11-15 70.4
16-20 65.41
21-25 60.44
26-30 etc..
So for example age 7 corresponds with 75.38, how do I easily program in R to look this up?
Thanks a lot.
|
use `findInterval()` to find the `exp_life` corresponding to the `age` interval.
With a setup similar to the previous answer (but no need to create an entire lookup table -- if your age input is not an integer this won't work anyway).
df <- read.table(header=TRUE,
text="age exp_life
0-5 80
6-10 75.38
11-15 70.4
16-20 65.41
21-25 60.44
26-30 etc..",
stringsAsFactors =FALSE)
library(tidyr); library(dplyr)
df %>%
separate(age, into=c('from_age','to_age'), sep='-') %>%
mutate_each(funs(as.numeric)) %>%
arrange(from_age) -> df # in case it's not sorted
df$exp_life[findInterval(7, df$from_age)] # returns [1] 75.38
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "r"
}
|
Install packages from PYPI in Raspberry Pi
I want to install a precompiled version of OpenCV 3.4.2 in the Raspberry using the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install pip3
sudo pip3 install opencv-python
But it failed and the error message was: _"Could not find a version that satisfies the requirement opencv-python (from versions: ) No matching distribution found for opencv-python"_
Then tried the following commands but the result was the same:
sudo apt-get install python3-pip
sudo pip install opencv-python
I had not problems installing it on my PC with ubuntu 16 using the same commands. This is the page im using for reference <
I'm using Raspbian Jessie Lite, Python 3.4
|
The list of downloadable files for opencv includes binary wheels for many Python versions but for limited set of architectures: MacOSX on Intel, Linux on Intel 32 and 64 bits, Windows on Intel 32 and 64 bits. Raspberry Pi processors absent and there is no source code so `pip` cannot compile it.
The FAQ recommends to look up Pi wheels at <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "opencv, raspberry pi3, pypi"
}
|
Find the number of dimensions and a basis $W$ of a generating set of $U$
Given the system of vectors $U= \left \\{ \left ( 1, 2, 3 \right ), \left ( 0, -1, -2 \right ), \left ( 2, 3, 4 \right ), \left ( 1, 0, -1 \right ) \right \\}.$ Find the number of dimensions and a basis $W$ of a generating set of $U.$
We use the rows reduction $$\begin{pmatrix} 1 & 0 & 2 & 1\\\ 2 & -1 & 3 & 0\\\ 3 & -2 & 4 & -1 \end{pmatrix}\xrightarrow{2R_{1}- R_{2}}\begin{pmatrix} 1 & 0 & 2 & 1\\\ 0 & 1 & 1 & 2\\\ 3 & -2 & 4 & -1 \end{pmatrix}\xrightarrow{3R_{1}- 2R_{2}- R_{3}}\begin{pmatrix} 1 & 0 & 2 & 1\\\ 0 & 1 & 1 & 2\\\ 0 & 0 & 0 & 0 \end{pmatrix}$$ then $\operatorname{rank}= 2.$
I don't have a way of thinking to continue. What is the relationship between $W$ and $U,$ I need to the help ?!
**Edit**. Find the value of $k$ so that $u= \left ( 2, 3, k^{2}+ 1 \right )$ is a linear combination of $W,$ and what is $\left [ u \right ]_{W}\\!.$
|
I'll use $M$ to stand for RREF form of $W$ you calculated. The key idea is that the "relationship" between the columns of $M$ will also hold for the columns of $W$. Here it should be pretty easy to see that the first two columns of $M$ (1,0,0) and (0,1,0) form a basis for the column space of $M$. So the first two columns of $W$ will also form a basis for the column space of $W$. So the basis your looking for is just the first two columns of $W$.
Let me know if you need more details.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "linear algebra, matrices, vector spaces"
}
|
Why are the wings of many strong lines, including hydrogen lines and most metal lines, stronger in Dwarfs than in Supergiants?
What is the reason? Is it because Dwarfs have higher surface gravity (log g), in turn related to pressure, than Supergiants so there is more contribution from van der Waals and Stark broadening?
|
Collisional broadening - which includes van der Waals and Stark broadening - is more important in the higher gravity, higher pressure/density atmospheres of dwarf stars (a factor of 100-1000 higher for dwarfs vs giants of the same photospheric temperature).
These collisional effects effectively "truncate" radiative emission and absorption processes, leading to broadening of the frequency response of a line absorption cross-section. That means strong lines have appreciable opacity away from the line centres and means the lines sample a broader range of temperatures in the photosphere.
See <
|
stackexchange-astronomy
|
{
"answer_score": 6,
"question_score": 5,
"tags": "star, spectroscopy, spectra, stellar astrophysics, dwarf star"
}
|
create new column based unique values
Say I have a simple dataset of this
set.seed(123)
a <- sample(1:4, 30, replace = TRUE)
b <- sample(5:10, 30, replace = TRUE)
c <- sample(5:15, 30, replace = TRUE)
data <- data.frame(a,b,c)
Now I want to create a new column, `data$d` which will take the values of `b` when `a`=1|3 and the values of `c` when `a`=2|4
|
Like this, supposing column `a` only have values in `c(1,2,3,4)`:
data$d = ifelse(data$a==1|data$a==3, data$b, data$c)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "r, calculated columns"
}
|
Tool for drawing timing diagrams
Recently I am working with a hardware design group developing an ASIC. And I am drawing a lot of timing diagrams for which I am using Microsoft Excel, as it is easy to import into Word document. But, things are getting more and more difficult with Excel.
What can be used to draw timing diagrams? Is there any easy tool out there?
|
I have the same problem and tried the following tools:
* drawtiming
* timing (LaTeX)
* tikz-timing (LaTeX)
* Microsoft Visio
After trying all these I now ended up using Visio and pen&pencil. All other programs lacked support for adding arrows/relationships between signals easily. In Visio, such things are absolutely easy. And you can export the diagrams directly to PowerPoint or even as PDF for using them in LaTeX.
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 33,
"tags": "hardware, verilog, asic, timing diagram"
}
|
Read from url and write to Tempfile
Say I have this url: Image
And I want to write its contents to a tempfile. I am doing it like this:
url =
tmp_file = Tempfile.new(['chunky_image', '.png'])
tmp_file.binmode
open(url) do |url_file|
tmp_file.write(url_file.read)
end
But it seems tmp_file is empty. Beacuse when I do:
tmp_file.read => # ""
What am I missing?
|
Just do as
open(url) do |url_file|
tmp_file.write(url_file.read)
end
tmp_file.rewind
tmp_file.read
Look at the documentation example.
The problem in your case was that you were doing a _read_ at the current `IO` pointer in the `temp_file`, that is already at the end when you completed with _writes_. Thus you need to do a `rewind` before the `read`.
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 6,
"tags": "ruby, temporary files"
}
|
How can I switch line-wrapping on and off from within less
I know I can run `less -S` and avoid long line wrapping. But can I switch wrapping on and off from within `less`?
|
Yes. You can toggle the `chop` behavior within `less`.
`-``Shift``s` would toggle the _chop long lines_ behavior within `less`.
|
stackexchange-superuser
|
{
"answer_score": 12,
"question_score": 6,
"tags": "console, less"
}
|
PHP Time/Date Timezone Specific Stuff
I'm slightly curious as to how I can store and access 'time points' for various things while acquiring a user's timezone. It would be cool to use `time();` as the storage / database data.
For example if I make an update to a blog it would show the stamp as something like `26/01/2000 11:34` but if the user's timezone was one hour ahead of mine then it would appear as `26/01/2000 12:34`, of course determined through their settings. It would also be useful for things like countdowns for time limited features. I however do not know how to format the unix-timestamp in this way. Guidance and help would be wonderful :).
|
All of your post times and server time should be UTC to start. Retrieve your post time from the DB and utilize the DateTime and DateTimeZone classes in some way similar to below
$fromDatabase = '2008-08-03 14:52:10';
$datetime = new DateTime($fromDatabase);
$timezone = new DateTimeZone('America/Los_Angeles');
$datetime->setTimeZone($timezone);
echo $datetime->format('Y-m-d H:i:s');
Alternatively on Linux if using MySQL you can load the timezone tables and adjust the date time returned in the MySQL query. Refer to this page for how to start with this - <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "php, date, time, timezone, unix timestamp"
}
|
How to get result from string.format() with . and not with ,?
It returns me 1014,66 but i want it returning 1014.66 . Any suggestions?
double money = 1000;
double last = money * 1 * 1.04166;
String gift = String.format("%1$,.2f",last);
|
Use the version of the `String.format` method that takes a `Locale`, and specify a locale that has a dot for decimal separator instead of a comma. For example, the US locale:
String gift = String.format(Locale.US, "%1$,.2f", last);
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "java, decimal"
}
|
Como criar uma tabela dinâmica no Word via Delphi?
Tenho documentos _.doc/_.docx, que estou fazendo a substituição de TAGs, porém agora necessito fazer a criação de uma tabela dinâmica, com base em um select, nestes mesmos arquivos que estou substituindo tags. Essa tabela deve estar abaixo do texto já existente no arquivo.
Já fiz diversas pesquisas, porém não consegui obter sucesso com os exemplos, devido a não estar bem explicado. Alguém poderia dar um exemplo?
|
Existe componentes nativos para isso. Para habilitar vai em:
> Component/Install packages.../ Microsoft Office XP Sample Automation Server Wrapper Components.
Vai habilitar uma paleta chamada **Servers**. Provavelmente o que você quer é o **_TWordApplication_**.
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "delphi, tabela, word"
}
|
Integration testing Azure Service Bus with Docker
What is an appropriate way to integration test systems that use ASB? With something like Kafka and using docker-compose, I could spin up two services that will communicate asynchronously over Kafka. Is there a way to do something similar with ASB? If not, what is a common integration testing pattern?
|
The pricing model for Service Bus has 12.5 million operations per month included for free. Past that, it's less than a dollar per millions of messages sent. With these kinds of services it should be simple for you to spin up and tear down instances with absolutely zero cost to you as part of integration tests.
NUnit, for example provides the `[OneTimeSetup]` and `[OneTimeTearDown]` methods which you could use as part of an integration test suite to provision and subsequently delete a Service Bus instance.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 7,
"tags": "azure, docker compose, integration testing, azureservicebus"
}
|
How to compile jnativehook?
I can't use English well but I got problem. I'm using 'jnativehook global mouse/keyboard listener' library on my program. But when I press quit button on my program, it didn't terminated because of jnativehook's thread. So I need set setDaemon true to it's source. I found that code and changed setDaemon method parameter to 'true'. So I proceeded to build using 'ant' what it written on developer's page. I added JNITasks's jar file in the source folder. But I got this error when I build.
y = Real('y')
s = Solver()
s.add(And(x+y>1,x==0.00001,y==0.1))
print(s.check())
The returned result is `sat`, which I think is incorrect as x+y=0.10001<1\. I also print out the solver s
[And(x + y > 1, x == 1/0, y == 1/10)]
which I notice have term x==1/0 with a 0 in the denominator. I am using Python 3.9.8, z3-solver 4.8.12.0 running on macOS 10.14.6 Mojave.
I also tried the exact same example on a machine with Ubuntu 20.04, python3.8, and z3-solver 4.8.10.0. The returned result is `unsat` and there is no 0 in the denominators when the solver is printed out.
Does anyone know if I am doing anything wrong here? Thank you very much in advance.
|
I cannot replicate this with z3 4.8.14; where it prints `unsat`, like you found with 4.8.10. You should simply upgrade your version of z3.
There has been previous questions regarding this, and it appears in certain incarnations small numbers like `0.00001` weren't being correctly translated. I suspect you're suffering from the same. See here: Why is Z3 "rounding" small reals to 1.0/0.0?
Upgrading would be the best; if you can't try the recommendation there: Instead of using `0.00001`, try `Q(1, 100000)` instead.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python 3.x, macos, z3, z3py"
}
|
Free alternative to standard C# DataGrid?
The standard DataGrid is quite unresponsive when it comes to displaying large amounts of information. I tried SourceGrid and can live with the results, but see room for improvement. Can anyone think of any other free alternatives to the standard DataGrid that can handle large amounts of data? I am open to creative ideas.
|
After looking into XPTable and trying out ObjectListView, I've decided that SourceGrid is superior (speed wise) to both for large quantities of data, scrolling feels much smoother.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 6,
"tags": "c#, winforms, datagrid"
}
|
I have a list of files, how can I open and copy the contents of each file to a new one using bash?
I'm running simulations and I want to write scripts which make data evaluation much faster. I have a list of files. I used this command to generate it:
echo ( find "../../../Single conical/IV/" -name "current-tot.dat" ) > IVfilenames.dat
I want to open them one by one and copy their content into a new file (lets call it results.dat), but I don't know how to do it. Can anyone help me?
|
Take the `echo` out of your command. I don't know why you had it there in the first place.
find "../../../Single conical/IV/" -name "current-tot.dat" > IVfilenames.dat
Then `IVfilenames.dat` will be a list of files like this:
../../../Single conical/IV/Dir1/current-tot.dat
../../../Single conical/IV/Dir2/current-tot.dat
You can use the below code to compile all the `current-tot.dat` files from the list into one `results.dat` file:
while read -r filename; do
cat "$filename"
done < IVfilenames.dat > results.dat
* * *
But that said, it's easier to cut out the middleman, and not create the list of files at all:
find "../../../Single conical/IV/" -name "current-tot.dat" -exec cat -- {} + > results.dat
|
stackexchange-askubuntu
|
{
"answer_score": 4,
"question_score": 3,
"tags": "bash"
}
|
Writing Output to a File
How do I write some `Console.WriteLine()` values to a file located in `C:\`?
|
Use the `StreamWriter` class:
var outputfile = new StreamWriter("c:\\outputfile.txt");
outputfile.Writeline("some text");
outputfile.Close();
However, depending on your version of Windows, you might not have permission to write to C:\\.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "c#"
}
|
ssh one shot command gives partial results
I execute a command to grep a long log file on a remote server and the problem is whenever I ssh first and then execute the grep command remotely I get way more matches than if I do it in one shot as follows:
`ssh host 'less file | grep something'`
I was suspecting some default automatic timeout with the second version so I experimented with those options `-o ServerAliveInterval=<seconds> -o ServerAliveCountMax=<int>` but to no avail. Any idea what could be the problem?
|
The problem was related to `less`. It does not behave well outside of interactive mode. Using `cat` solved the issue.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ssh"
}
|
Openshift context path
I have deployed the war into tomcat 7 Openshift . Everything is fine and its running .Myappp Here is my mapped web application.
I am storing images in the dir webapps->docs->images But When I upload the image (with UI) it doesnt appear on site and I cant even find where images are stored (I connected using FTP -filezilla ) Where my deployed war file stored ? Do I need to make any changes in my code so to upload in proper dir of Openshift?? Thanks in advance
|
You should use your OPENSHIFT_DATA_DIR (~/app-root/data) to store uploaded images. However, using Java this presents some challenges. I would recommend that you read through this article (< it should help you with dealing with user uploaded images.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "java, tomcat, openshift, war"
}
|
SQL Reformatting my date column in Access
I have a table that has a date column. For example:
| User | Date |
| 1 | 05-16-2016 |
| 1 | 07-28-2016 |
| ....
Notice how the format of the date is month-day-year. Basically I want to reformat it so that it does: day-month-year. So the resulting table would look like:
| User | Date |
| 1 | 16-05-2016 |
| 1 | 28-07-2016 |
| ....
Thanks alot in advance!
|
So i figured it out. Basically all you do is use format like this:
FORMAT(Date, "dd-mm-yyyy")
And I created a new column for the formatted date and used that column to carry out other computations
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "sql, ms access"
}
|
Variable importance in classification
For example: I have 100 books with 1000 words each. They belong to different classes (comedy,drama,...). Each class consist of 15 different books. When I do tfidf on my data, I get the importance for every word in a book in context of all books. I see that the books belonging to the same class have similar tfidf values for each variable.
Let's say drama and comedy are pretty similar. How can I tell what words make a difference in between those two classes? What words do I have to change in book that belongs to comedy so the book now belongs to drama now?
I can check one by one; but I have 2000 books, 17500 words each; 950 classes. It would take a decade :)
|
I would definitely run pairwise tests, i.e. one for each of the 475*949 pairs of classes you have as "important variables" can differ very much from case to case. Then run some standard feature selection algorithm, such as chi-square or information gain. See < for an extensive study.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "statistics, nlp, data mining"
}
|
SQL case when error
Hello my sql query still returns else case but I am pretty sure that inner select returns 1. What`s wrong with the code?
SELECT CASE a_from
WHEN (SELECT a_from REGEXP 'something.com>$' = 1 )
THEN "S"
ELSE "T"
END AS 'HP', a_from FROM article WHERE id =4
|
I think you missed the `where` in your inner select statement.
SELECT CASE a_from
WHEN (SELECT a_from REGEXP where 'something.com>$' = 1 ) <-- Here
THEN "S"
ELSE "T"
END AS 'HP', a_from FROM article WHERE id =4
As commented by ypercube you may try like this:
SELECT CASE WHEN a_from REGEXP 'something.com>$' = 1
THEN 'S'
ELSE 'T' END AS hp, a_from
FROM article WHERE id = 4 ;
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "mysql, sql"
}
|
How to make a cell where a specific date can be entered without editing date in the formula
I came up with this formula on excel and it does the job my job on telling me how many beans I made in a specific date range:
`=SUMIFS(N10:N20,H10:H20,">=20/01/18",H10:H20,"<=02/02/18")`
But I don’t want to be editing the formula all the time as this isn’t convenient.
I tried removing the date from my formula, and typing in a cell for example `A4` to replace the date hoping the formula would recognise that in cell A4 there is a date.
But Excel didn’t detect that there is a date in cell A4.
So my question is: would it be possible to change the date through a cell, so that I don’t need to change the formula all the time. Thanks
~Neamus
|
Excel should be able to recognize the dates.
Put your `start` & end `dates` in `A4` & `A5`
Then try the below formula:
=SUMIFS(N10:N20,H10:H20,">="&A4,H10:H20,"<="&A5)
 via Lulu printing. (There is almost always 15% off at Lulu that you can find with a google search.)
|
stackexchange-judaism
|
{
"answer_score": 3,
"question_score": 5,
"tags": "product recommendation, jewish books, mussar ethics"
}
|
How to write (10) in excel using jsp
I am doing some stuff with Excel with JSP.
Question is :
How to write excel that will print "(10)" in excel sheet. If you write (10) in excel it will convert to -10. I don't want to convert value to -10.
Make sure i am not using any API for writing in excel i just simply change the header type to excel. and using tab i am writing or responding with excel sheet.
|
Either precede it with a ' (as in `'(10)` or change the formatting of the cells to `text` _before_ setting the value
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "excel, jsp, numbers"
}
|
Execute a script as another user
I have 6 scripts that I execute with PHP, unfortunately, I have to execute it as my default user. I tried to execute it with PHP only but it doesn't work.
Do you know how to do this without a big security breach ?
Thank you :)
|
You can use php as a command line utility by typing `php /path/to/script.php`
The PHP script will be excecuted by the user you are logged in to.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "php, linux, permissions"
}
|
Ways to access Apple Pay
What are the possible ways to access Apple Pay as quickly and easily as possible on an iPhone SE in a shop? I am using iOS 12.
|
Some ways are:
**From the lock screen** \- Go to Settings -> Wallet & Apple Pay and enable Double-Click Home Button. Now when you double-click on the lock screen your cards will appear. Then select your card and use Touch ID or hold it next to the reader. One of the quickest and easiest ways.
**Siri** \- You can access Apple Pay by saying "Apple Pay" to Siri.
**Wallet App** \- Go to the wallet.app, click on your card at the top. Then when you rest your finger on the home button, it will authenticate it and search for a nearby reader.
**Holding it near the reader** \- When you hold your iPhone near a card reader it will automatically bring up your list of cards.
You might also want to check out Apple Pay.
|
stackexchange-apple
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iphone, apple pay"
}
|
Excel: Standard deviation, ignoring #NA and blanks in the range
I want to calculate the standard deviation with STDDEV.P for a range, but I want to ignore #NA and blank cells.
#NA and blanks should NOT be included in the calculation as 0.
I've reached this solution for ignoring #NA:
=STDEV.P(IF(NOT(ISERROR(Trade!AI5:AI154));Trade!AI5:AI154))
How do I ignore blank cells as well?
|
I reached a conclusion myself, using ISNUMBER():
=STDEV.P(IF(ISNUMBER(Trade!AI5:AI154);Trade!AI5:AI154))
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "excel, excel formula, standard deviation"
}
|
Optimized version of sieving for primes
I was reading a piece of code that was an optimized version of Eratosthenis sieve for primes but I don't understand the logic and can't find online the formalized definition of it.
Basically for input `n` to generate all primes up to and including `n`, it considers as the max number of iterations to the process:
int size = Math.floor(0.5 * (n - 3)) + 1
and iteratively goes for `i = 0; i < size; ++i` considering that if `i` is prime then `(i * 2) + 3` is also prime and then marking as not prime all j `for j = ((i * i)* 2) + 6 * i + 3; j < size; j +=(i * 2 + 3)`
Can someone explain what is the logic behind this?
|
This is just a standard sieve, optimized slightly for space but not for speed. Instead of an array with an entry for each positive integer, it uses an array with only entries for the odd numbers from 3 onwards. So entry $i$ in the array (with $0$-based indexing) represents the integer $2i+3$.
Note that contrary to what you said, it does not matter whether or not the index $i$ is prime, it only matters whether the number it represents, $2i+3$, is prime.
Anyway, the algorithm removes multiples of all numbers up to $n$. That is to say, the corresponding index $i$ is such that $2i+3\le n$. This leads to the expression you ask about.
That is actually not an optimized bound. Every composite number $\le n$ will actually have a factor that is $\le\sqrt{n}$, so really they could have lowered that bound significantly.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "prime numbers, sieve theory"
}
|
Auto formatting code in vim when saving .cpp file
I have read this How can I autoformat/indent C code in vim? about how to format C/C++ code, but I want to autoformat the code when I'm saving the file, like how vim-go calls `gofmt` when saving Golang code.
How can I configure my vimrc? I'm using clang-format, and have installed vim-clang-format with spf13vim using Vundle.
|
Found it.
> * `g:clang_format#detect_style_file`
>
>
> When this variable's value is `1`, vim-clang-format automatically detects the style file like `.clang-format` or `_clang-format` and applies the style to formatting.
So this code should be in the `.vimrc`:
let g:clang_format#auto_format=1
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c++, vim"
}
|
Recovering lost folder name:
Can I recover a folder name accidentally lost in renaming?
I've just done a complete installation, formatting everything, from 12.04 LTS to 14.04 LTS.
The plan was to slot my Mozilla profile from my backed up copy into the new version, simply renaming the old one, to replace the new .default folder which came with the installation so that Firefox would find my slotted in folder instead. It worked fine on Thunderbird, but on Firefox I somehow accidentally deleted the name of the .default folder I need to replace. This means I don't know what to call the one I'm slotting in. Is there a way, please, of recovering the name I deleted?
I'm on Ubuntu 14.04 LTS, Processor AMD Athlon(tm) 64 X2 Dual Core Processor 5200+ × 2 ,Memory 2.0 GiB, OS type 32 bit, Disk 155.3 GB.
|
I'd say you don't need to, if you're going to replace that profile.
The file `.mozilla/firefox/profiles.ini` contains the path of the default profile:
$ ls .mozilla/firefox/
Crash Reports profiles.ini wng922jv.default
$ cat .mozilla/firefox/profiles.ini
[General]
StartWithLastProfile=1
[Profile0]
Name=default
IsRelative=1
Path=wng922jv.default
So you can either extract the name from the `Path` field above, or, replace it with the path of your profile.
|
stackexchange-askubuntu
|
{
"answer_score": 1,
"question_score": 1,
"tags": "firefox, data recovery, rename"
}
|
Maintain last modified date for a file between server and local machine
I am making FileSync kind of service between the server where my website is hosted and my local machine (windows app). From my machine I want to download a file only if it is modified at server.
After investigating on how to do that I came to know that I can compare "Last date modified" of that file on server to what it is on my local machine. Lets say I have this file:
!enter image description here
I am downloading this file via stream to my local machine via C# windows app. When the file is downloaded on my machine its "date modified" gets changed. I have two questions here:
How to preserve Last Date modified what was on server?
How should I consider the timezones difference of my machine and
server machine?
|
You can reset the date by using the the `.LastWriteTime` property of an `FileInfo` instance. I would suggest getting the original date from your file on the server, downloading it and afterwards setting the date of your written file with some code like this:
DateTime originalServerFileTime = ...;
FileInfo fi = new FileInfo(@"YourFile.txt");
fi.LastWriteTime = originalServerFileTime;
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "c#"
}
|
What language technique is 'She is pure guts and steel'?
I am doing an English assignment where I have to identify the language techniques used in a feature article.
I am confused as to what technique is used in "She is pure guts and steel."
I first thought it is an idiom or a phrase but I'm not sure if that's correct
|
It's a _sentence_ , not a phrase, but I don't think that is the answer your teacher is looking for.
"Guts" -- which literally means "intestines" but is used to mean courage -- is an idiom, as you suspected, or more exactly a _figure of speech_.
"Pure guts" is _hyperbole_ , an exaggeration for rhetorical effect.
"Steel" is a _metaphor_ ("the use of a word or phrase to refer to something that it is not, invoking a direct similarity between the word or phrase used and the thing described").
Perhaps the technique referred to is one of these.
|
stackexchange-english
|
{
"answer_score": 2,
"question_score": 0,
"tags": "literary techniques"
}
|
Programatically import custom fields using wp all import
I have a csv with a lot of custom fields that I need to import. It would take too much time to manually set up the fields using the interface and it also is not very client friendly to ask them to make sure the values match up. Many of the values must also be mapped from the csv to a different value in the custom field in WordPress.
|
WP All Import has a lot of undocumented features in the various hooks, actions and filters implemented in the code. The easiest way to do such a mapping is to add a filter to the `pmxi_options_options` and add custom rules. These rules will show up under the Custom Fields accordion during the import configuration step.
<?php
add_filter( 'pmxi_options_options', function( $options ) {
// Match the desired custom post type
if ( $options['custom_type'] != 'product' ) {
return $options;
}
// Configure the custom fields
$options['custom_name']['custom_field_name'] = '_custom_field_name';
$options['custom_value']['custom_field_name'] = '{csv_column[1]}';
$options['custom_mapping_rules']['custom_field_name'] = json_encode( [
'value_from_csv' => 'value_to_custom_field',
'en' => 'English',
] );
return $options;
} );
 when I need to prove something in the exercises.
Looking at a different analysis book, the same theorems have (of course) different identifiers.
So except the theorems that have widely known names, it is hard to crossreference them. For example if I want to prove a theorem using other theorems, how could I refer to them without explicitly mention them?
Is there an attempt to create a unified index of theorems, so you can refer to them on the internet? Is there even already such an index? (A proof of a theorem then could use references to this index, so a traversable graph of theorems and how they relate to each other could be built and you could have statistics on theorem usage etc.)
|
One problem with this program is the fact that different books (and textbooks, especially) use slightly different definitions, so two theorem statements in two different books can be (1) identical in wording but yet (2) asserting different things. More subtly, a text book might make a global assumption throughout, in effect tacitly adding the list of hypotheses in each theorem in the book. That way, apparently different theorems are actually identical.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "proof writing"
}
|
Please help translate regular expression to StringExpression
I am familiar with regular expressions in other languages (e.g., Perl, Python, ViM), but the Mathematica `StringExpression` is baffling me.
I'd like to match strings that look like this:
1001.200nc
12345.220nc
987654.215nc
The regular expression I'd use in Python/Perl would look like this: `[0-9]+\.2[0-9]{2}nc`. What is the equivalent in Mathematica `StringExpression`?
Related: Can I use a `RegularExpression` wherever a `StringExpression` is expected?
|
For me (that is very personal indeed), StringExpressions in Mathematica are much more transparant than regular expressions. Here are two StringExpressions for your strings:
p1 = NumberString ~~ ".2" ~~ DigitCharacter ~~ DigitCharacter ~~ "nc";
p2 = NumberString ~~"." ~~ (x : NumberString /; 200 <= ToExpression[x] < 300) ~~ "nc";
teststrings = {"1001.200nc", "12345.220nc", "987654.215nc"};
StringMatchQ[teststrings, p1]
StringMatchQ[teststrings, p2]
(* {True, True, True}
{True, True, True} *)
|
stackexchange-mathematica
|
{
"answer_score": 6,
"question_score": 3,
"tags": "string manipulation, regular expressions"
}
|
How far can a 2.4 GHz, 1 watt signal go in a rural area?
What's the approximate range achievable by a 2.4 GHz signal of 1 watt in semi-urban areas? I can see 2 km from our rooftop. Will a 2.4 GHz signal go that far, i.e. if I send WiFi signals from our rooftop is it possible to catch them on my phone 2 km away?
|
This is a strange sort of question, as in reality the signal will go infinitely far (effectively) however you are really asking at what distance might a receiver be able to pick up the signal.
In testing a 2.4GHz signal with a 100mW omni antenna, the furthest distance I could receive a signal with less than 5% retries (802.11b kit) was 2 miles with a 100mW 3dB receiver. I could manage over 5 miles with a directional 10dB antenna, but had some trouble aiming it accurately.
Your phone is going to have challenges at that range, but if you have a specific location, you could use a directional antenna on your rooftop aimed at that location. Even a basic Huber Suhner running at 1W could make that work.
(disclaimer - I used to test 2.4GHz radio kit from Symbol, Telxon, Motorola and Cisco. I can't post the data tables, but more than happy to give indications of what might work)
|
stackexchange-ham
|
{
"answer_score": 10,
"question_score": 8,
"tags": "propagation, wifi, line of sight"
}
|
How Do I get Packets from Locally hosted website on remote computer with pyshark
I am trying to get packets from a website hosted locally on remote computer(Test purpose) using pyshark.
Here is my code:
import pyshark
def print_live_dns():
capture = pyshark.LiveCapture("wlan0")
for packet in capture:
# print(packet)
with open('packets.txt', 'a') as f:
f.write(str(packet))
if "DNS" in packet and not packet.dns.flags_response.int_value:
print(packet.dns.qry_name)
if __name__ == "__main__":
print_live_dns()
With this code I only get packets from the internet. which is not what I need. How do I achieve this? using either `pyshark, scapy, nmap ` etc
|
You can use set intersection
>>> from functools import reduce
>>>
>>> my_list = [[2,3,5,6,7,8,9], [2,4,78,23,13,7], [3,2,5,98,23,1,34]]
>>> list(reduce(lambda x, y: set(x).intersection(set(y)), my_list))
[2]
>>>
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": -2,
"tags": "python, scapy, pyshark"
}
|
QList inside function template
I am trying to create a function template containing a `QList` iterator :
template <typename T> void funcTemplate()
{
QList<T>::ConstIterator it;
}
I get:
> In function 'void funcTemplate()': error: expected ';' before 'it'
I tried lots of things but I can't make it compile. It is really strange because I can create a QList without problems:
template <typename T> void funcTemplate()
{
QList<T> list;
}
Does anybody has an idea?
Thanks!
|
It should be
template <typename T> void funcTemplate()
{
typename QList<T>::ConstIterator it;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c++, qt, templates, compilation"
}
|
typecasting char pointer to float in C
I have a flat file with the ff data:
date;quantity;price;item
I want create a data record using the following struct:
typedef struct {
char * date, * item;
int quantity;
float price, total;
} expense_record;
I created the following initializing method:
expense_record initialize(char * date, int quantity, char *price, char *item) {
expense_record e;
e.date = date;
e.quantity = quantity;
e.item = item;
/* set price */
return e;
}
My question is how to set the price as `float` (as required by the struct) from the `char *price`. The closest I got, i.e. without generating a compiler error was
e.price = *(float *)price
but this results in segmentation faults.
Thanks!
|
You are looking for the ~~`strtod`~~ `strtof` library function (include `<stdlib.h>`). Relatedly, if the calling code uses anything other than `strtoul` to convert `quantity` from text to an `int`, that is probably a bug (the only exception I can think of would be, if for some reason `quantity` can be negative, then you would want `strtol` instead).
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "c, parsing, casting"
}
|
Grails: Dynamically inject service in domain class
I need to inject a service based on domain property, so far I came up with the following:
ApplicationHolder.application.getServiceClass("package.${property}Service").clazz
but loading it this way doesn't inject it's dependent services. Am I doing it wrong?
|
New instances will bypass Spring's dependency management; you need to get the configured singleton bean from the application context. Use this instead:
def service = ApplicationHolder.application.getMainContext().getBean("${property}Service")
That assumes that 'property' is the partial bean name for a service, i.e. for FooBarService, the property would have to be 'fooBar'. If it's 'FooBar' then you can use GrailsNameUtils.getPropertyName() to fix it:
import grails.util.GrailsNameUtils
String beanName = GrailsNameUtils.getPropertyName(property) + 'Service'
def service = ApplicationHolder.application.getMainContext().getBean(beanName)
|
stackexchange-stackoverflow
|
{
"answer_score": 15,
"question_score": 5,
"tags": "grails, groovy, dependency injection, service"
}
|
git push -f leave unwanted log in bitbucket
I did a commit, pushed it, but later realised I made some mistake on the code, I do `git reset HEAD~`, and recommit and `push -f`, I found there's an extra log in my PR. How do I get rid of that?
|
I would assume here that the problem is that you actually made a _new_ commit on top of your branch, instead of amending the commit you wanted to rework. So here is what you probably should have done:
# make changes
git commit --amend
git push --force origin master
This should still leave you adding one new commit to the remote. However, in general force pushing a branch is bad news in Git, especially when other users might be sharing your branch, and might have already pulled it at some point. In this case, a much safer approach is to just make a new commit and push that. Or, you could use `git revert` to undo a commit, if you wanted to do that.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "git, bitbucket"
}
|
Find string and replace another line in linux
I have an xml file which looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Station name="XxXx" >
<Inverter name="0701">
<String name="07.01.01-1">
<Converter sku="31570014-0900 A" sn="2116K000551" mac="548280000227" ts="01"/>
</String>
<String name="07.01.01-2">
<Converter sku="31570014-0900 A" sn="1716K000232" mac="4482800000E8" ts="02"/>
</String>
I need a script (or better one linux command) that can find in this file a String with name="07.01.01-1" for example, and change in the _next_ line sn="2116K000551" to sn="11111111", and delete everything till the end of the line (means mac="xxx" ts="xx"), except closing tag "/>", and save this file. I'm trying to do it with sed, but not successfully for now. Is there a one linux command that can do it? I would very much appreciate any suggestions.
|
The right way with **`xmlstarlet`** tool:
xmlstarlet ed -u '//String[contains(@name, "07.01.01-1") and ./Converter/@sn = "2116K000551"]
/Converter/@sn' -v 11111111 \
-d '//String[contains(@name,"07.01.01-1")]
/Converter/@*[name()="mac" or name()="ts"]' file.xml
The output:
<?xml version="1.0" encoding="utf-8"?>
<Station name="XxXx">
<Inverter name="0701">
<String name="07.01.01-1">
<Converter sku="31570014-0900 A" sn="11111111"/>
</String>
<String name="07.01.01-2">
<Converter sku="31570014-0900 A" sn="1716K000232" mac="4482800000E8" ts="02"/>
</String>
</Inverter>
</Station>
* * *
To modify the file in-place - add `-L` option: `xmlstarlet ed -L -u ....`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "linux, string, sed, replace"
}
|
Is $(∃x,∃y,¬P(x, y))$ true or is $ (∀x,∀y,¬P(x, y))$ true when $P(x, y) : x^2 > y^2$?
I'm taking a discrete structures class and I positively don't understand a thing. I have to verify if this statement is true and prove it. I never know where to start.
Considering $P(x,y): x^2 > y^2,$ is the conjunction of $∃x∃y¬P(x, y)$ and $∀x∀y¬P(x, y)$ true?
My understanding is; $∃x∃y¬P(x, y)$: There exists an x and a y for which P isn't true? Is it what the negation symbol does here?
And then; $∀x∀y¬P(x, y):$ For every x and y, P isn't true?
I really don't get it.
|
It is not the case that $$\forall x\forall y, \lnot P(x, y)$$
Take $x = 2, y = 1$. Then there exist, x, y, such that $P(x, y)$ is true since $2^2 \gt 1^2$. Hence, it is not true that $\forall x, \forall y, \lnot P(x, y)$.
And we can surely suppose $x = 1, y=2$, so that $\exists x \exists y \lnot P(x, y)$ because $\lnot(1^2\gt 2^2)$
The conjunction of each claim amounts to evaluating $F\land T$, which is always false.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "discrete mathematics, logic"
}
|
Seeking common interface for ST_Geometry SDO_Geomtry
I've worked a fair bit with Oracle Spatial and I've had some requests to transition to PostgreSQL Spatial.
Is there a common interface for SDO_Geometry and ST_Geometry? I'm working in Java with EclipseLink ORM.
|
GeoTools < provides PostGIS and OracleSpatial datastores which will abstract away the differences.
|
stackexchange-gis
|
{
"answer_score": 2,
"question_score": 3,
"tags": "postgis, java, oracle spatial"
}
|
Sorting generic set in swift
What is the correct way to sort a generic typed Set in swift?
class CustomSet<T: Hashable>: NSObject {
var items: Set<T>
init(_ items: [T]) {
self.items = Set(items)
}
var toSortedArray: [T] {
//Error: Binary operator '<' cannot be applied to two 'T' operands
return items.sort{ (a: T, b: T) -> Bool in return a < b}
}
}
Xcode Version 7.1 beta (7B60), this is a wrapper around swifts `Set` type.
`items.sort{$0 < $1}` doesn't work
`Cannot invoke 'sort' with an argument list of type '((_, _) -> _)'`.
But works in `xcrun swift`
1> let s = Set([4,2,3,4,6])
s: Set<Int> = {
[0] = 6
[1] = 2
[2] = 4
[3] = 3
}
2> s.sort{$0 < $1}
$R0: [Int] = 4 values {
[0] = 2
[1] = 3
[2] = 4
[3] = 6
}
|
You need to constrain your generic placeholder to conform to Comparable (as well as Hashable, which you are already doing). Otherwise, as the error message says, we cannot guarantee that `<` is applicable.
class CustomSet<T: Hashable where T:Comparable>: NSObject {
Your `xcrun` example works because Int _does_ conform to Comparable.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "swift, sorting, generics, set"
}
|
CV and/or resume for PhD Student with industry experience?
I spent 10+ years in industry before going back to grad school to pursue a PhD, and therefore I have extensive industry experience, as well as ongoing academic work. Is there a good way to represent this on my CV? Does anyone know a good CV format or template that would allow me to show this?
|
I would say there are a couple ways to attack this. You could list academic experience as a separate section to industry experience, this would show that you consider them very separate.
You could also make a section titled " (Relevant) Experience" and list everything you have in chronological order. This would give the impression to whoever is reading it that you consider all of your experience relevant in the position that you are applying to.
In either case, make sure you highlight the relevant portions of your background to the position you are applying.
|
stackexchange-academia
|
{
"answer_score": 1,
"question_score": 3,
"tags": "cv"
}
|
Inject User-defined HTML Into Directive's Template
I am trying to populate the contents of a with HTML supplied by the user. Specifically:
app.directive("myTable", function() {
return {
restrict: 'E',
scope: {
rows: '@'
},
template:
'<table>' +
'<tbody>' +
'<tr ng-repeat="row in rows">' +
'<td>{{row.html}}</td>' +
'</tr>' +
'</tbody>' +
'</table>'
};
});
However, {{row.html}} is inserted as text. Thank you
|
Use ngBindHtml to evaluate the expression:
<td ng-bind-html="row.html"></td>
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "angularjs, angularjs directive"
}
|
How to proceed to the next video in youtube playlist using python selenium
I tried using this code:
elem = driver.find_element_by_class_name("ytp-next-button ytp-button")
elem.click()
but without mouse on the video there is no toolBar. what can I do?
|
You are unable to click on that button not because you need to put cursor on it, but because of wrong locator: to use `find_element_by_class_name()` name should not contain spaces... But there is a space in your case. So you should use `find_element_by_xpath()` instead. Try following code:
elem = driver.find_element_by_xpath('//*[@class="ytp-next-button ytp-button"]')
elem.click()
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "python, selenium, selenium webdriver, youtube, youtube api"
}
|
Not enough rep for chat?
> **Possible Duplicate:**
> How long does it take for chat profiles to update?
I am on this question: Selecting option in select field does not trigger ajax script in Google Chrome
And I would like to continue in chat and I get this message:
!enter image description here
But the OP has 21 rep! he should be able to chat!
Now the OP clicked the link and it worked for him, but why did it not work for me?
|
My money's on caching. Chat rep is updated once an hour, if I recall.
That user only hit 21 rep 25 minutes ago, so it may be another half hour or so before chat recognizes it.
|
stackexchange-meta
|
{
"answer_score": 8,
"question_score": 3,
"tags": "bug, comments, chat"
}
|
Simple concatenated json line breaker in Splunk
I know this is probably simple, but for some reason I am able to get a line breaker working in Splunk. I am fetching a data source from AWS S3, and multiple events in JSON format are concatenated. e.g.
{"key":"value", {"composite":"result"}}{"something":"else"}
So LINE_BREAKER should match on `}{` with the left brace included.
I have `SHOULD_LINEMERGE=false` and then `LINE_BREAKER=(\{.+\})\{` but i loose the closing bracket. The `}{` don't have any characters between them (not even a newline), what is the best way to split these?
|
The `LINE_BREAKER` attribute requires a capture group, but discards the text that matches the capture group. The solution is to be more creative with the regex.
LINE_BREAKER=\}()\{
Empty capture groups are allowed.
Your comments confuse matters. Are events separated by `}{` or by `{"key"`? The value of `LINE_BREAKER` should be set to whatever separates events. Once you've established that then you can address the `TRUNCATE` setting.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "line breaks, splunk"
}
|
Magento - get rule from coupon code
I have to retrieve the rule associated to a coupon code in order to display in quote the discount percentage of that rule. the simplest way is to calculate directly from quote amounts, but i want to retrieve directly the rule and then get the discount percentage from it.
this is what i tried:
$rule = Mage::getModel('salesrule/coupon');
$rule->load($couponCode);
by this way i still havent retrieved rules attributes. any help?
thanks.
|
To load a coupon by code, pass `'code'` as 2nd param to `load()`. Then you can get the proper rule instance by using the `rule_id` value of your coupon instance:
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
var_dump($oRule->getData());
|
stackexchange-stackoverflow
|
{
"answer_score": 31,
"question_score": 11,
"tags": "magento, magento 1.4, magento 1.5, magento 1.6"
}
|
Is this idea for rain harvesting suitable for crop irrigation
I am thinking of attaching what is a akin to an "inverted umbrella" to some trees - i.e. underneath the tree canopy, so that I can harvest rain from underneath the tree.
Please note, this is not EXACTLY what I'm doing - so go along with the analogy. I don't want people asking me WHY I am doing this etc.
So, going on with the analogy of the "inverted umbrella" under the tree canopy, to collect rain, I am aware that there will be debris/detritus consisting of (but not limited to):
* Bird (and other fauna) excreta
* Dead leaves, twigs etc.
My question is this:
Can such collected water be used to irrigate vegetables (especially salads) - that are often eaten raw?
If the answer is a resounding "No" \- then, please indicate what the potential dangers are - and how these may be mitigated against.
|
Yes. Plants get their water from the soil, and soil is made of detritus consisting of organic mater of animal and plant origin similar to what you expect to fall into the rain collection devices. Any such in the water will help the plants rather than harm them.
If you actually hung up umbrellas you may well get man made chemicals in the water, in particular water proofing substances can be quite harmful. This is probably what you should be considering most.
|
stackexchange-sustainability
|
{
"answer_score": 2,
"question_score": 3,
"tags": "water, rain harvesting"
}
|
Trouble updating Eclipse plugins
I just installed some extra repos and now I'm trying to Check for Updates but I keep getting an error that I can't seem to get past and can find nothing about it in the google.
Cannot complete the install because one or more required items could not be found.
Software being installed: EGit Mylyn 1.3.0.201202151440-r (org.eclipse.egit.mylyn.feature.group 1.3.0.201202151440-r)
Missing requirement: EGit Mylyn 1.3.0.201202151440-r (org.eclipse.egit.mylyn.feature.group 1.3.0.201202151440-r) requires 'org.eclipse.mylyn.team_feature.feature.group 3.5.0' but it could not be found
I'm at a bit of a loss here. Anyone know how to fix this?
|
You are missing a Mylyn feature. Make sure you have the Mylyn update site in your list of software update sites and you should be good.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "eclipse, eclipse plugin, mylyn"
}
|
Ocean modifier color and foam
I'd like to know how to do two things with materials related to the Ocean Modifier:
1) Change the color depending on the depth of the water, and
2) Create some believable foam.
Both of these features should change as the ocean modifier plays back.
The attached image shows what I mean pretty well, methinks—you can see how the water changes to a darker blue where the water is a bit deeper, a lighter blue where it's shallower, and blends to a white where the foam should be. I also believe that this image was made with Blender's ocean modifier [EDIT apparently it's not, but the point still remains]. I'd like this to be possible regardless of lighting conditions.
Does anybody know how to create these effects with materials that use the ocean modifier?
.
**Foam.**
First of all you will need to choose **Foam Data Layer Name**. I used... 'foam' and use it in **Attribute** node. I've also added a **Math** node with **Power** to fine tune mix between water and foam shader.
**Mix.**
You can now mix shaders by 'foam' factor and use any other shader for materials. I've used simple **Glossy** for water and **Diffuse** for foam.
**Nodes and Ocean setup.**
 = \frac{-x}{2\alpha}\cos(\alpha x)$
I know it won't use the transformation $P(D^2:\mapsto -\alpha^2)$, since it will put a zero in the denominator, and that it should involve the integral $\frac{1}{D}$, but that's as far as I can get.
|
Writing a differential operator $D$ in a denominator is somewhat irregular, I would say. Multiplying both sides with $D^2 + \alpha^2$ yields the equation \begin{equation} (D^2 + \alpha^2)\left(\frac{-x}{2\alpha} \cos(\alpha x)\right) = \sin (\alpha x). \tag{1} \end{equation} You can easily prove the validity of $(1)$ by calculating the result of the application of the operator $(D^2 + \alpha^2)$ on the function $\frac{-x}{2\alpha} \cos(\alpha x)$.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ordinary differential equations"
}
|
Change the size of a web page
Actually I have done my webpage with a 800x600 monitor. All things are well, but I encountered a problem when i explore the page with bigger screens.
And there are the problem with larger screens.
enter image description here
|
That is normal behavior for most CSS frameworks. If font sizes and element widths, etc. are specified in pixels: 400 pixels fills up half an 800px screen but only a fraction of a 1900px screen.
That works quite well because for phones vs tablets vs desktop monitors, the highers screen resolution balances out the size of the screen, so "readable" size text will be the same number of pixels. The difference is you can fit MORE elements on a bigger screen. See responsive CSS: <
If you really want your content to fill up the same amount of screen, regardless of screen size, you can define all you CSS width and height and font-size attributes as percentages of viewport size, see <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "html, resize"
}
|
$\mathbb{C}^\times$ mod roots of unity isomorphic to $\mathbb{C}^\times$
> Let $H = \langle i \rangle =\\{ i, -1, -i, 1 \\}\le \mathbb{C}^\times$. Then is $\mathbb{C}^\times/H$ isomorphic to $\mathbb{C}^\times$?
I don't think there exists an isomorphism $\varphi : \mathbb{C}^\times \to \mathbb{C}^\times/H$ because for any $z = re^{i\theta} \in \mathbb{C}^\times$, we can consider $z' = re^{i(\theta+\pi/2)}$ which gives $zH = z'H$. So this makes me think an isomorphism property can be broken somehow but I can't seem to make it work out. Or perhaps the quotient group is isomorphic to the multiplicative group of complex numbers.
|
Let $n$ be any positive integer, and $\mu_n$ the group of complex $n$-th roots of unity. The map $\Bbb C^\times\to\Bbb C^\times$ given by $z\mapsto z^n$ is a surjective group homomorphism with kernel $\mu_n$. By the First Isomorphism Theorem, $\Bbb C^\times\cong\Bbb C^\times/\mu_n$.
This is the $n=4$ case.
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 2,
"tags": "abstract algebra"
}
|
Bland Altman plot interpretation
Dear all and good day,
Could please someone help me clarify what does it mean for the lower limit of the BA plot to be positive.
In most of the BA plots I saw, the limit ranges from -ve to -ve number but mine both upper and lower limits are +ve (1.2 to 3.8).
Thanks
|
Quoting from the Cross Validated info page on the Bland-Altman (or Tukey mean-difference) plot:
> The Bland-Altman plot consists in plotting the difference between the two assays against the mean of the two assays on each sample.
If the lower limit of the plot is greater than 0, then one of your assays is always providing larger values than the other.
|
stackexchange-stats
|
{
"answer_score": 0,
"question_score": 0,
"tags": "bland altman plot"
}
|
Bike Rack design
 {;}; //How can i get at this point rule2 or rule3 text?
rule2: HELLO+;
rule3: WORLD*;
I want to get the rule2 or rule3 text but all i get is a `type_return` that only gives me a `start` and a `stop`.
Any ideas?
|
Try:
rule
: r=(rule2 | rule3) {String txt = $r.text;}
;
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, antlr, antlr3"
}
|
Python get valid date format from date string
Is there a way to _guess_ datetime format of a given string in python?
e.g. desired usage would be:
> guess_format('2020-02-24 07:22')
'%Y-%m-%d %H:%M'
There's dateutil project which automates datetime string conversion to valid `Datetime` objects:
> from dateutil.parser import parse
> parse('2020-02-24 07:22')
datetime.datetime(2020, 2, 24, 7, 22)
but can it produce valid formatting strings?
|
The pydateinfer package provides the possibility to infer the datetime format string of a given date string.
Example:
>>> import dateinfer
>>> dateinfer.infer(['Mon Jan 13 09:52:52 MST 2014', 'Tue Jan 21 15:30:00 EST 2014'])
'%a %b %d %H:%M:%S %Z %Y'
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 4,
"tags": "python, datetime"
}
|
ping command does not work without extension
all of a sudden my command prompt commands started giving problems. when I run ping.exe it works but when I run ping it says, 'ping' is not recognized as an internal or external command.
same behavior for ipconifg and some other commands.
|
Read PATHEXT environment variable article:
> `PathExt` environment variable returns a list of the file extensions that the operating system considers to be executable. When executing a command line that does not contain an extension, the command interpreter (`cmd.exe`) uses the value of this environment variable to determine which extensions to look for and in what order.
To restore broken variable(s), read and follow How to set the path and environment variables in Windows
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 0,
"tags": "windows, command line, ping"
}
|
QLabel setText not displaying text of QLineEdit if label size small
I have a QLabel in which I want to show text from a QLineEdit. The size of line-edit is bigger than the label so I want to show the label ending with a dotted line
ui->LE_Serverpath// contains 20 charecters
ui->LB_UsernameInfo // having size of 10 charecters
ui->LB_UsernameInfo->setText(ui->LE_Serverpath->text());
using wordwrap the line is getting cut but I need dotted lines at the end
ui->LB_UsernameInfo->setWordWrap(true);
|
You have to set an _ElideMode_ for the label, you need a `QFontMetrics` instance from label font then set text elide mode for the label. to show dots by end of line, set ElidMode to `Qt::ElideRight`, on the text copied form `QLieEdit`:
//QFontMetrics metrics(ui->LB_UsernameInfo->font()); // QLabel already has font metrics
int width = ui->LB_UsernameInfo->width() - 2;
QString text = ui->LB_UsernameInfo->fontMetrics().elidedText(ui->LE_Serverpath->text(), Qt::ElideRight, width);
ui->LB_UsernameInfo->setText(text);
ui->LB_UsernameInfo->setWordWrap(true);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "qt, qt4"
}
|
Java SQLite Foreign Keys with Hibernate
I am using Hibernate with SQLite. The challenge I am facing is enabling foreign keys. I have tried passing the PRAGMA command in the connection url with no luck.
Looking in the SQLite driver I can see that there is a constructor which takes a Properties object which sets any provided PRAGMA's. How would I be able to pass this parameter with Hibernate?
**Dependencies**
* Xerial - sqlite-jdbc-3.7.2.jar
* Hibernate-jpa-2.0-api-1.0.0.Final.jar
* Hibernate-entitymanager-4.2.2.Final.jar
* Hibernate-core-4.2.2.Final.jar
Thanks
|
I managed to get it to work by modifying the persistence.properties file. I added the following property to the persistence.properties file:
hibernate.connection.foreign_keys=true
I can see the property is being passed to the connection in the console.
HH000046: Connection properties: {user=, password=****, autocommit=true, foreign_keys=true, release_mode=auto}
org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "java, hibernate, sqlite"
}
|
Always set username and email to match external repository
One thing I hate about Git is how it handles user identity. Using name and email from config is rather annoying when I clone repository as authenticated user. Is there any command that makes project username and email match the one I clone the repository as?
Additionaly, is there any way to prevent pushing under name/email different than the ones registered for SSH key? To be honest, I don't understand the purpose of username and email for external repositories.
|
Reminders: `user.name` and `user.email` have nothing to do with authentication. Only with commit authoriship.
And Git being decentralized, those values cannot be checked against a common user referentials (AD, LDAP, ...): there are the responsability of the Git repo user.
When you are pushing, using cached credentials with https (and a credential helper) or SSH (and a public key registered on the server side), you are using an account which does not have to be related in any way with the commits you are pushing.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "git"
}
|
What does Requires capabilities : [CAPABILITY_IAM] mean and how do i activate this?
Following this tutorial on AWS instance scheduling, I was able to create a new EC2instanceScheduler cloud formation stack.
However, each time that I try to update that stack, the following error occurs:
> Requires capabilities : [CAPABILITY_IAM]
I've searched for information, but can't seem to find any clear information on what this is, what this means and how to activate this.
On this page, Amazon says the following:
> In some cases, you must explicitly acknowledge that your stack template contains certain capabilities in order for AWS CloudFormation to create the stack.
But I can't seem to understand how and where. Can someone give me clear information on this subject? What does this error mean and how do I solve this?
|
It's very easy to miss, and I've seen others missing this part too.
In step 4 (review) of the update stack, at the bottom, there is this little checkbox that has to be checked before you can update the stack.
?
I am trying to extract the id `41794` from a website. But the said number depends on the start date(today's date). See snippet below from the site,
> 'index.cfm?fuseaction=c_availabilityGrid.displayAvailabilityGrid&startDate=41794&timeSpan=ww,2&showBeds=1&showMlos=0&showprice=1'
I am interested to know how the value `41794` is obtained from today's date so that i can put that logic in my code.
Is there any function in java which takes input as date and returns the number as mentioned above?
Any help in this matter would be greatly appreciated.
|
It looks like the number of days since 1 Jan 1900, possibly with a leap year screwup or two.
Take a look at
Microsoft Excel uses a system like this. Google "Excel serial date".
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 3,
"tags": "java, date, time"
}
|
Hive queries taking so long
I have a CDP environment running Hive, for some reason some queries run pretty quickly and others are taking even more than 5 minutes to run, even a regular select current_timestamp or things like that. I see that my cluster usage is pretty low so I don't understand why this is happening.
How can I use my cluster fully? I read some posts in the cloudera website, but they are not helping a lot, after all the tuning all the things are the same.
Something to note is that I have the following message in the hive logs:
"Get Query Coordinator (AM) 350"
Then I see that the time to execute the query was pretty low.
I am using tez, any idea what can I look at?
|
Besides taking care of the overall tuning: <
Please check my answer to this same issue here Enable hive parallel processing
That post explains what you need to do to enable parallel processing.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "hive, hadoop yarn, apache tez"
}
|
Concatenating Variable Names in C?
Is it possible to concatenate variable names in C? Specifically, I have a `struct` that contains 6 similar variables in it called `class1`, `class2`, `class3`, etc.
I want to run through a for loop to assign each variable a value, but I can't see how to do it without somehow concatenating the variable name with the value of the for loop counter.
How else could I do this?
|
When you find yourself adding an integer suffix to variable names, think **_I should have used an array_**.
struct mystruct {
int class[6];
};
int main(void) {
struct mystruct s;
int i;
for (i = 0; i < 6; ++i) {
s.class[i] = 1000 + i;
}
return 0;
}
**Note:** A C++ compiler will barf at this because of `class`. You will need to figure out a different name for that field if you plan to compile this code as C++.
|
stackexchange-stackoverflow
|
{
"answer_score": 48,
"question_score": 10,
"tags": "c, variables, names"
}
|
Pentaho : Cannot view sample fusion charts
I Installed and configured fusion charts as instructed in: <
What is the expected output? Samples should appear in pentaho-solutions/bi-developers in the navigation repository
What do you see instead? For version 0.03, the samples do not appear until you copy the fusion-charts folder into pentaho-solutions/bi-developers of which after you do, the sample dashboard has chart titles only and the rest is blank. The fusion charts free samples produce this error:
> FailedError retrieving data: cdaQueryComponent failed to return data. Query ID:2 Server Version: Pentaho Platform Engine Core 3.10.0-stable.48193I tried installing version 0.03 and the operating system is a 32-bit turnkey linux vm running ubuntu 10.04
|
You can learn more about FusionCharts error messages from its documentation - <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "plugins, pentaho, fusioncharts"
}
|
AngularJS + Safari: Force page to scroll to top when pages switch
I am having an odd, safari-only scrolling behavior using AngularJS.
Whenever the user flips between pages, the pages are being changed as if they are AJAX. I understand they are in AngualrJS, but the resulting behavior is that the browser does not scroll to top when the user switches pages.
I've tried to force the browser to scroll to top whenever a new controller is being used, but it does not seem to do anything.
I'm running the following JS at the top of every controller:
`document.body.scrollTop = document.documentElement.scrollTop = 0;`
This is also a Safari-only bug, every other browser will scroll to top when the page changes. Has anyone encountered a similar issue or think of a better way to resolve it?
|
Have you tried using $anchorScroll()? it's documented here.
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 24,
"tags": "angularjs, safari"
}
|
Minimum degree of polyonial (several variables) such that it vanishes in a prescribed number of points?
I saw recently the following claim. Given any 19 points in $\mathbb{R}^3$ it is always possible to find a polynomial $p(x,y,z)$ with $\deg p \leq 3$ such that it vanishes in the previous points.
My question is why is this true (for the previous particular case) and where can I find a general version of the statement (given any $m$ points in $\mathbb{R}^n$ which is the least positive integer $d$ such that I can always find a polynomial $p$ that vanishes at the points with degree $\leq d$?).
Thank you in advance!
|
I am not sure, but this is just a guess.
Given $n$ points in $\Bbb R$, you can always find a polynomial (in one variable) of degree $n$ that vanishes at the given points. This follows from the Fundamental Theorem of Algebra.
With a polynomial of degree $n$, there are $n+1$ coefficients, and the "solution polynomial" is only defined up to a constant multiple.
The general form of a three variable polynomial is
$$a_1x^3+a_2y^3+a^3z^3+a_4x^2y+a_5x^2z+a_6y^2x+a_7y^2z+a_8z^2x+a_9z^2y+a_{10}xyz+a_{11}x^2+a_{12}y^2+a_{13}z^2+a_{14}xy+a_{15}yz+a_{16}zx+a_{17}x+a_{18}y+a_{19}z+a_{20}$$
So I would guess that, since there are $20$ coefficients, you can always make it vanish at any $19$ points.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 2,
"tags": "polynomials, interpolation"
}
|
My CSS and JS external files are not working in my project
I have a simple project with that files structure:
 {
.container .hidmeinfirefox {
overflow: hidden;
}
}
.container .hidmeinfirefox {
height: 1px;
width: 1px;
}
<
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "html, css, firefox"
}
|
Is it min-max aperture range on Nikkor Lens label?
The label says 18-200m F/3.5-5.6G Nikkor lens. Focal length and G type are clear. From the lens specs I see that min aperture is F/3.5 and max is F/22. So what does the label aperture range means?
|
It means that as you zoom the max aperture increases from f3.5 at 18mm to f5.6 at 200mm
|
stackexchange-photo
|
{
"answer_score": 4,
"question_score": 1,
"tags": "lens, nikon"
}
|
How to manage reset signal for VHDL test benches?
I have a very simple vhdl testbench that should run. My components all have a reset signal, so that registers are set to 0 and other components correctly initialized... but... if I create a common signal for resetting all component only during the first clock cycle, how can I tell to that signal to go down after the first clock cycle and never get up again????
I know it is a stupid problem but, how would you do???????? Thank you.
|
reset <= '1', '0' after 10 ns;
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "signals, reset, vhdl, object test bench"
}
|
Xubuntu 14.04 network interface preferences
When I have an ethernet cable connected and WiFi pass on available network it prefers the WiFi for internet connections. How do I make it prefer the ethernet connection?
|
Go into network manager, select "edit connections", click on the wireless network and click "edit". Click on the "general" tab and untick the option to "automatically connect to this network when available" . Do the opposite for the wired network (make sure the option to automatically connect is selected).
|
stackexchange-askubuntu
|
{
"answer_score": 1,
"question_score": 0,
"tags": "wireless, internet, ethernet"
}
|
Export a value from an API call in a Trailing Closure SwiftUI
When working with API, on this code base:
Auth.auth().signIn(withEmail: email, password: password) { (result, error) in
guard case .success (let response) = result else{return}
responseText = (response.first?.choice.first?.text ?? "")
}
How can I export `responseText` outside the API call?
I’m relatively new to SwiftUI I've been trying to bind `responseText` to a variable outside the body without success.
|
If it is in view, then it could be
@State private var responseText = "" // or optional if needed
// ...
Auth.auth().signIn(withEmail: email, password: password) { (result, error) in
guard case .success (let response) = result else{return}
DispatchQueue.main.async { // update on UI queue
self.responseText = (response.first?.choice.first?.text ?? "")
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "swift, api, swiftui"
}
|
Could not find the option translate in navigation menu of SharePoint online - Multilingual
I want enable multilingual in SharePoint online.
I have enable multiple languages in Setting -> Language Setting
 language.
But when I try to translate navigation menu. I could not able to find the translate option.
. Then go to ViewAccount -> Settings & Privacy
. All the SharePoint controls will change it to Chinese.
Then go to the Navigation menu and modify the menu items, it will modify the menu items of the Chinese page.
|
stackexchange-sharepoint
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sharepoint online, navigation, modern experience, multilingual"
}
|
Freeze on Windows Phone 8 SDK install
Then trying to install Windows Phone 8 SDK I get a freeze on startup window like this:
!enter image description here
And one of my CPU cores is loaded to 100%, the installer freezes. The install log have this content after it freezes.
Any hints? I'm running Windows 8.1 Pro x64 on Intel Core 2 Quad processor (no SLAT).
|
After some investigation (thanks goes to Sysinternals Process Explorer), I've found that hang occurs in `wpfgfx_v0300.dll` module, which is, IIRC, a part of .NET Framework 3.0. So I went to "Programs and Components", then "Turn On/Off Windows Components" and turned off `.NET Framework 3.5 (includes .NET 2.0 and 3.0)` component. Reboot and voila, installer runs perfectly!
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "windows phone 8"
}
|
Date formatting
Using the following:
var date = new Date(parseInt(jsonDate.substr(6)));
I get:
Mon Feb 22 1993 00:00:00 GMT+0000 (GMT Standard Time)
How do I format this too
22-02-1993
?
|
You use the `getFullYear`, `getMonth` (note that the values start with `0`), and `getDate` functions on the `Date` instance, then assemble a string. (Those links are to the specification, which can be hard to read; MDC does a bit better.)
Or use a library like DateJS (although it hasn't been maintained in quite some time) or as joidegn mentions, moment.js.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "javascript, jquery, json, datetime, date"
}
|
Show a counter in loading screen (that count list items), before the list is created in the next Activity
I would like to show a counter that display a `list.size()` in my loading screen (the Activity that is launched when the app is starting. The problem is that my `list` is created in the next Activity, so I have no clue on how to do that.
I know how to do it in the same Activity where my list is created but not in another.
Is there a way to link an information from an Activity to another ? or to load the 2nd activity without showing it, to create the list, count the number of items in it and show it in the 1st activity ?
Thank's for your help.
|
You could load the list in ActivityOne and display the progress in ActivityOne. Once it has been loaded you could start ActivityTwo and add your list as extra. Your List has to contain objects which implement Parcelable. Take a look at this example.
Intent intent = new Intent(getApplicationContext(), ActivityTwo.class);
intent.putParcelableArrayListExtra("someArrayList", (ArrayList<? extends Parcelable>)someArrayList);
startActivity(intent);
More Info on Parcelable
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, android, list, size, counter"
}
|
Anybody knows how to "fix" this blurry font that's only on snap-store?
The issue I'm facing is pretty much described with the title and the screenshot below.
I'm using Ubuntu 21.10, Gnome 40, Wayland display manager on a machine powered by ryzen 5 4500u with radeon graphics (incase any of that is needed to diagonise the issue).
Enlarge the image and see the difference in font readability betweeen the dash/status bar vs snap-store
 Forbidden
I've managed to receive the `access_token`, browsing to ` works very well and the browser displays all my information.
But when I'm trying to get these information with ASP.NET (C#), I get an error:
> The remote server returned an error (403) Forbidden.
Here is the code I'm using to make an Get Request.
WebRequest request = WebRequest.Create(" + access_token);
request.Method = "GET";
WebResponse response = request.GetResponse(); //Error Here
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string result = reader.ReadToEnd();
|
I monitored the request and response in my Firefox when I directly access the URL (which works). I had to set the right content type. I added the following and everything worked.
request.UserAgent = "Foo";
request.Accept = "application/json";
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "c#, http, github, oauth, get"
}
|
Finding $\int \sec^2 x \tan x \, dx$, I get $\frac12\sec^2x+C$, but an online calculator gets $\frac12\tan^2x+C$.
I tried to find a generic antiderivative for
$$\displaystyle \int \sec^2x \tan x \mathop{dx} $$
but I think there is something wrong with my solution because it doesn't match what I got through an online calculator.
What am I doing wrong?
Below is my solution.
> We will use substitution:
>
> $$u = \sec x \qquad du = \sec x \tan x \, dx$$
>
> We substitute and apply the power rule:
>
> $$ \int (\sec x) (\sec x \tan x \, dx) = \int u \, du = \frac{1}{2} u^2 + C = \frac{\sec^2x}{2} + C$$
The solution I found with the online calculator is:
$$ \frac{\tan ^2 x}{2} + C$$
The steps in the online solution make sense also, so I'm not sure what's going on.
The one thing I have some doubts about is whether I derived the $du$ from $u = \sec x$ correctly. But it seems okay to me. I used implicit differentiation with $x$.
|
$$\frac{\sec^{2}(x)}{2} + C = \frac{1+\tan^{2}(x)}{2} + C = \frac{1}{2} + \frac{\tan^{2}(x)}{2} + C$$
$\frac{1}{2}$ is just another constant, in indefinite integral constant doesn't really matter unless you're asked for the integrand original function so you can just kind of "combine" $\frac{1}{2}$ into C, you can also differentiate the answer to know that there's nothing wrong at all with your answer
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 1,
"tags": "calculus, integration, indefinite integrals"
}
|
Generate random index from Armadillo vector
I am looking to generate a random index from a given armadillo vector (using the Rcpp interface from R). The function I am using is as follows:
#include <RcppArmadillo.h>
#include <RcppArmadilloExtensions/sample.h>
using namespace Rcpp;
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::export]]
int index_rand(arma::vec& v) {
arma::uvec indices;
for (size_t i = 0; i < v.n_elem; ++i) {
indices[i] = i;
}
arma::uvec u = RcppArmadillo::sample(indices, 1, false);
return u[0];
}
However, this code complies but crashes the R interpreter when running:
index_rand(1:10)
|
It turns out this is a tricky issue solved here. The answer is as follows for posterity.
// [[Rcpp::export]]
int index_rand(arma::vec& v) {
arma::uvec indices = arma::linspace<arma::uvec>(0, v.n_elem-1, v.n_elem);
arma::uvec u = RcppArmadillo::sample(indices, 1, false);
return (int)u[0];
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "rcpp, armadillo"
}
|
figurative adjectives with "il est [adjective]"?
Duolingo tells me that some adjectives change their meaning depending on if the adjective comes before the noun, or after the noun. When it comes before the noun, the adjective takes a more figurative meaning, and when it comes after the noun, it takes a more literal meaning.
For example, "un grand homme" means "a great man", and "un homme grand" means "a tall man".
My question: which meaning does it take when a pronoun is used and thus there is no "before the noun or after the noun" placement, as in "Il est [adjective]"? For example,
* "C'est mon ami. Il est grand."
|
This rule only applies to **attributive adjectives** (adjectifs épithètes), i.e. when they are directly attached to the noun they modify. It does not apply to predicative adjectives (adjectifs attributs du sujet) like your example ("Il" is separated of [adjective] by "est"). In this case, you extract the sense of an adjective with the use of context.
Example with "important": before = large, after = it matters
> Un document important (an important document)
>
> Un important document (a large document)
>
> La colonie de fourmis est importante pour la santé de cet écosystème (The ant colony is important for this ecosystem)
>
> La colonie de fourmis est importante et ne cesse de croître (The ant colony is large and keep increasing in size)
This page (in French) will provide numerous examples and some rules.
|
stackexchange-french
|
{
"answer_score": 5,
"question_score": 7,
"tags": "adjectifs"
}
|
Multiple colors for Vuetify v-timeline center line
I need to change the color of the center line in the v-timeline components of the Vuetify framework so that it will be a particular color up-to a certain colored dot and another color afterwards as shown here, is it possible to do so?
The color for the whole line could be changed as follows
.theme--light.v-timeline:before {
background: red;
}
|
I think only one way is setting linear-gradient. Because v-timeline divider setting up all the space. Try setting
background: linear-gradient(180deg, black 0% 50%, gray 50% 100%) !important
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "css, vue.js, vuetify.js, timeline"
}
|
KeyDown Event to next row
I created this form in VS
!enter image description here
The `NumPlace TextBox` is intalized to `1` automatically, I want when I press on the `Enter` key to increment the `NumPlace` automatically in the next row.
This is the code I wrote :
Private Sub DataGridView1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyCode = Keys.Enter Then
MsgBox("Enter key is pressed !")
End If
End Sub
But It doesn't work it only works when I'm selecting some row end press on "Enter" but when I change the value of the ComboBox or when I select the `NumPlace TextBox` and then I press on `Enter` the event doesn't work.
|
The solution is to use the event `KeyUp` instead of `KeyDown`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "vb.net, gridview, keydown"
}
|
How to delete the contents of the zip file but not the directory
I am trying to delete the contents of zip file but not the zip directory.I tried `FileUtils.cleanDirectory(deteleOldZip)`, but got an error "abc.zip is not a directory".
Is there any other way to do in a single line?
|
Since you just want an empty zip file
String name = file.getAbsolutePath();
FileUtils.deleteDirectory(file)
Then create a new empty zip directory with the file path.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "java"
}
|
Power Automate to alert if file NOT created, Condition on length of array
I'm using the below to check if a file has been created in a folder. If it hasn't been done someone's forgotten and we need an alert. Listing the folder, and the two filters give the results I'd expect. The FilterTimes uses Addhours/UTCNow(-ve) so only files newer than the threshold make it through.
However, if there are no new files, the output of the last filter is Body[] as expected, but when this get passed to the condition, I'm just getting the input of that being { "expressionResult": false}
I think I'm getting my brackets and commas wrong in the condition, or have I named the array incorrectly?
)` to the left input box of " **Condition** " but not input the string `length(body('FilterTimes'))` to the box. The string `length(body('FilterTimes'))` doesn't equal to `0`, so the result is `false`.
I do the same steps in my power automate, it works fine if I input the expression.
 - 0.25}{2x^2+x+3}\,dx$.
Then, I get:
$$0.25\int\frac{(4x+1)}{2x^2+x+3}\,dx-0.25\int\frac{1}{2x^2+x+3}\,dx.$$ The left one is pretty straight forward with $\ln|\cdot|$,
Problem: does anyone have some "technique" to solve the right integral? hints would be appreciated too.
Edit: maybe somehow: $$0.25\int\frac{1}{2(2x^2/2+x/2+3/2)}\,dx = 0.25\int\frac{1}{(x+0.25)^2 + \frac{23}{16}}\,dx$$
|
$$\int \frac { dx }{ 2x^{ 2 }+x+3 } =\int { \frac { dx }{ 2\left( { x }^{ 2 }+\frac { x }{ 2 } +\frac { 3 }{ 2 } \right) } =\frac { 1 }{ 2 } \int { \frac { dx }{ { x }^{ 2 }+\frac { x }{ 2 } +\frac { 1 }{ 16 } -\frac { 1 }{ 16 } +\frac { 3 }{ 2 } } } } =$$ $$\frac { 1 }{ 2 } \int { \frac { dx }{ { \left( x+\frac { 1 }{ 4 } \right) }^{ 2 }+\frac { 23 }{ 16 } } } =\\\ =\frac { 1 }{ 2 } \int { \frac { dx }{ \frac { 23 }{ 16 } \left[ \frac { 16 }{ 23 } { \left( x+\frac { 1 }{ 4 } \right) }^{ 2 }+1 \right] } } =\frac { 8 }{ 23 } \int { \frac { dx }{ \left[ \frac { 16 }{ 23 } { \left( x+\frac { 1 }{ 4 } \right) }^{ 2 }+1 \right] } } =\frac { 8 }{ 23 } \frac { \sqrt { 23 } }{ 4 } \int { \frac { d\left( \frac { 4 }{ \sqrt { 23 } } x+\frac { 1 }{ \sqrt { 23 } } \right) }{ { \left( \frac { 4 }{ \sqrt { 23 } } x+\frac { 1 }{ \sqrt { 23 } } \right) }^{ 2 }+1 } } =\frac { 2 }{ \sqrt { 23 } } \arctan { \left( \frac { 4x+1 }{ \sqrt { 23 } } \right) +C } $$
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 2,
"tags": "calculus, integration"
}
|
PHP script not replacing string correctly
So, my code is as follows:
$data = file_get_contents("js/plugins.js");
if (isset($_GET['resx'])) {
if (isset($_GET['resy'])) {
$data = str_replace('"Screen Width":"1366","Screen Height":"768"', '"Screen Width":"$resx","Screen Height":"$resy"', $data);
}
}
file_put_contents("js/web_settings.js", $data);
What I am trying to do is define multiple variables in the URL bar and the website will update the file as such. Apparently, it seems to be replacing the string with the variable names itself instead of replacing it with the value of those variables. (So, if resx is 1280, 1366 becomes $resx instead of 1280) Due to the way the game engine works, the quotes need to be there. How do I fix this so it replaces it with the value of those variables?
|
Replace `"` to `\"` and `'` to `"`. It will allow to use variables in the string.
$data = str_replace("\"Screen Width\":\"1366\",\"Screen Height\":\"768\"", "\"Screen Width\":\"$resx\",\"Screen Height\":\"$resy\"", $data);
Empty replace because $resx and $resy not exist:
$data = str_replace('"Screen Width":"1366","Screen Height":"768"', '"Screen Width":"'.$_GET['resx'].'","Screen Height":"'.$_GET['resy'].'"', $data);
Or make $resx = $_GET['resx']; before `replace`. If there was error output is enabled , you would immediately notice it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "php"
}
|
Count if value is not blank
I want to count all cells which are `NOT(ISBLANK())`.
I tried this:
!enter image description here
Why does this does not work?
|
That's not the right syntax for the `COUNTIF` function. For more, see the documentation.
Instead, you can use this regular formula:
=SUMPRODUCT(--NOT(ISBLANK(A:A)))
or this array formula
=SUM(--NOT(ISBLANK(A:A)))
The latter must be entered as an array formula using `Ctrl` `Shift` `Enter`.
!enter image description here
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "excel, excel formula"
}
|
How can I determine the number of times a header is processed?
For the moment, my C codebases compile relatively quickly. However, I would like to utilise an _informed_ approach to reducing the number of times a given header is re-processed.
I guess that being able to see reference counts would help me to do so. How would I do that?
|
Both CLang and GCC support the `-H` option. It will dump into the console each header file included. Then, you can easily read these lines and analyze them to detect compiler bottlenecks.
From `man gcc`:
> `-H` Print the name of each header file used, in addition to other normal activities. Each name is indented to show how deep in the `#include` stack it is.
>
> Precompiled header files are also printed, even if they are found to be invalid; an invalid precompiled header file is printed with `...x` and a valid one with `...!`.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c, header, gnu toolchain"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.