INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Regular expression to find last dot in request URI
I am trying to write a regular expression for apache virtual host configuration that will map request if URI doesn't have certain extensions. Below expression I have written.
^\/bookdata\/.+\.(?!jpg|mp3|mp4|zip|doc|pdf|xls|xlsx).*$
Below URI is not matching to this expression which is perfectly fine.
/bookdata/rw0/media/Q2e_00_RW_U08_Q_Classroom.mp3?fd=1
My problem with below URI which is matching with this expression due to two dots.
/bookdata/rw0/media/ELM2_U02_Track06_Chart2.8.mp3?fd=1
Any small help will be appreciated.
|
Put the neg. lookahead right at the start, like so
^(?!.*\.(?:jpg|mp3|mp4|zip|doc|pdf|xls|xlsx))\/bookdata\/.+$
See **a demo on regex101.com**.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "regex, apache"
}
|
Do I need to manually declare >= and <= operators?
If I already have **operator >** and **operator <** defined (and **operator ==** ), do I need to define **operator >=** and **operator <=**, or will the compiler declare them for me if I intentionally don't declare them?
Also, if I have **operator ==** defined, will the compiler declare **operator !=** for me?
|
No, the Compiler won't declare/define any of the operators you did not define manually. However, Boost.Operators might be to your liking - it does exactly what you want the compiler to do.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 6,
"tags": "c++, operators, operator overloading"
}
|
prove $G=HN$, if $N \lhd G$ with prime index, and $H$ is not contained in $N$
Let $G$ be a group with the following properties
* G has a normal subgroup $N$ with $[G;N]=p$ where $p$ is a prime number;
* G has a subgroup $H$ such that $H$ is not contained in $N$
Prove
$$G=HN$$
* * *
attempt1
$\frac{|G|}{|N|} =p$ is a quotient group so $n=p|N|$
**Theorem 8.7** hungerford $p$ is prime every group of order $p$ is cylcic and isomorphic to $Z_p$
call that $<g_p> =\frac{G}{N} \cong Z_p$
$$\frac{G}{N}=\\{g_p, \dots , g_p^p\\} $$
and
$$ \frac{G}{N} = g_1 N \cup \dots \cup g_p N= \cup ^{p}_{i=1} (g_p)^i N$$
**lead 2**
$K \not \geq H $ so $[G:HN]<p$ and it divides $p$ so $$ \frac{|G|}{|HN|}=1$$ and the order of $|G|=|HN| $
that means that $HN=G$ since they have the same number of elements
* * *
**need $HN$ to be normal?? anything wrong/corrections??**
|
First, observe that $HN$ is a subgroup because $N$ is normal, and $HN$ properly contains $N$. Now use the fact that $$p = [G:N] = [G:HN][HN:N]$$ Since $[HN:N] > 1$ and $p$ is prime, this forces $[HN:N] = p$ and $[G:HN] = 1$. The latter equality implies that $G = HN$.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "abstract algebra, group theory"
}
|
Why does this program segfault
Upon compiling and running this small program to reverse a string, I get a Segmentation Fault before any output occurs. Forgive me if this is an obvious question, I'm still very new to C.
#include <stdio.h>
int reverse(char string[], int length);
int main() {
char string[] = "reversed";
printf("String at start of main = %s", string);
reverse(string, sizeof(string));
printf("%s\n", string);
return 0;
}
// Reverse string
int reverse(char string[], int length) {
int i;
char reversed[] = {};
int temp;
for(i = 0; i < length; ++i) {
temp = string[i];
reversed[length - i] = temp;
}
return 0;
}
|
Because of this:
First you create an array with zero elements:
char reversed[] = {};
And later you attempt to write to that array beyond its bounds:
reversed[length - i] = temp;
**Update:**
The above means that you need to allocate memory whose size is only known at runtime (it's `length`). The usual C-style way of doing this is... by pushing the burden of memory allocation to your caller:
int reverse(const char* string, char* destination, int length);
This function would write to a buffer provided by the caller, who now also must ensure that:
1. The buffer is large enough
2. The memory for buffer gets freed when it should be
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "c, string, segmentation fault, reverse"
}
|
black litterman for rebalancing
I've noticed in my backtests that "shrinking" the expected returns vector towards zero tends to improve the performance. This has led me to investigate shrinkage methods for the forecasts/expected return vector vs the traditional "shrinkage" as applied to the risk/covariance matrix estimation.
One structured way to do this is the Bayesian approach - which seems to lead to Black Litterman. There is some advice on shrinking the expected returns vector here
What methods do you use to improve expected return estimates when constructing a portfolio in a mean-variance framework?
but I'm wondering if people tend to perform Black Litterman in an online sense as in portfolio rebalancing.
E.g. this would mean using your previous weights/portfolio positions as your prior and updating your prior with your new expected return forecasts at the next time step.
Is this a common approach/use case of Black Litterman?
|
There are some technical problems with using your previous weights as priors (that is, they are point measures), but yes, the Black-Litterman framework is suitable for this. You can essentially include any view point you have on the market within the model and let it affect your position size. This also includes views on transaction costs (based on such measures as market impact, average volume, position size etc.).
If you work with a simple diagonal model (ignoring covariance), I have found it effective to shrink the weight toward the previous periods value.
Regarding the point measure issue, it is a reasonable modelling assumption to assume a normal distribution with mean equal your previous weight (or the market capitalized weight) and a sufficiently small variance. This makes the model analytically tractable.
|
stackexchange-quant
|
{
"answer_score": 4,
"question_score": 3,
"tags": "optimization, portfolio optimization, black litterman, rebalancing"
}
|
Split first element of object in html
in my car object i have a value car.photos it's look like this:
car.photos :
15214615_01_hd.jpg|15214615_02_hd.jpg|15214615_03_hd.jpg|15214615_04_hd.jpg|15214615_05_hd.jpg|15214615_06_hd.jpg|
My question is: Is it possible in my html with the ng-src display the first element of my `car.photos`?
**_my html:_**
<tr ng-repeat="car in $data">
<td><img class="img-rounded resize" ng-src="../photos/15214615_01_hd.jpg"></td>
...
</tr>
|
you can call it as `getSrc()`
<img class="img-rounded resize" ng-src="{{ getSrc(car.photos) }}">
in controller,
$scope.getSrc = function (photos) {
return photos.split("|")[0];
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "angularjs, split"
}
|
insert value of one col to another on inserting
i want to insert value of one col to another on inserting new row in sql.
how do i? there is any way to do this by default value(constraint)?
|
You have to use a trigger to achieve this.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql server 2008, insert, default value, constraints"
}
|
Determining dimension given a parameter $a$
If I have a homgenous matrix with one of the entries being $a$ and I need to determine which values of $a$ will give the matrix a space of solutions that has dimension $1$ (or dimension 2), how would I go about doing that?
For example ( just making this up from the top of my head):
$\begin{pmatrix} 1 &2&3&0\\\4&5&6&0\\\3&2&a&0 \end{pmatrix}$
I know I have to bring the matrix to RREF first, and I know which $a$ to choose to get infinitely many solutions or no solutions, but I'm not sure if there's a relation with dimension. Also my knowledge on linear algebra is just from an intro course on it.
|
Recall that the rank and the nullity of a matrix add up to the number of columns of the matrix (rank-nullity theorem). The nullity the dimension of the solution space. So, you can control the nullity by changing $a$ to adjust the rank of the matrix.
The rank of the matrix in your case is at most 3, since it is 3x4. The first two rows are linearly independent, so the rank is at least 2. This means that $a$ controls whether the rank of the matrix is 2 or 3, and therefore if the nullity is 2 or 1. If you choose $a$ such that its row is linearly independent of the above rows, the nullity will be 1. If it is linearly-dependent, the nullity will be 2.
Note however, that it is not guaranteed that you can choose $a$ to specify the dimension you want, because this is also controlled by the other numbers in the row.
For example, you can clearly see here that the rank will always be 3:
$ \begin{pmatrix} 0 & 0 & 1 \\\ 0 & 1 & 0 \\\ 1 & 0 & a \end{pmatrix} $
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "linear algebra"
}
|
Is this chipped tire bad enough to replace?
I probably chipped my tire by hitting the curb when parallel parking, the tire only has about 6000 miles on it, but does it look bad enough that I should replace it?
here is the image: ![
|
That is a scuff at worst. As long as there's no leakage, deformity, cords showing, or bubbling of the rubber, there shouldn't be an issue with it. I would ride on it without too much worry. Just keep an eye on it for the above.
|
stackexchange-mechanics
|
{
"answer_score": 3,
"question_score": 1,
"tags": "tires, sidewall damage"
}
|
Creating a new collection from results of a mongodb query
I'm trying to create a new collection using the results of a mongodb query. For example,
db.coll.find({name:'abcd'})
will return a subset of the collection. Now, I want to insert this result into a new collection. How can I do this?
|
You can't do this directly with `find`, but you can use an `$out` pipeline stage of `aggregate` to do it:
db.coll.aggregate([
{$match: {name: 'abcd'}},
{$out: 'newcoll'}
])
Note that `$out` support was added in MongoDB 2.6.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 4,
"tags": "mongodb, nosql"
}
|
How to get real time data from ardunio board using NodeJS and send to my remote server without the wifi module?
As the question, How to get real time data from ardunio board using NodeJS and send to my remote server without the wifi module.how to do this without any hardware.
|
It is pretty easy to send data with the help of NodeJS. Here i attach the code.
var request = require('request');
var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
var serialPort = new SerialPort("COM5", {
baudrate: 9600,
parser: serialport.parsers.readline("\n")
});
serialPort.on("open", function () {
console.log('open');
serialPort.on('data', function(data) {
console.log(data);
});
});
serialPort.on('data', sendSerialData);
function sendSerialData(data) {
request({
uri: "
method: "GET",
timeout: 10000,
followRedirect: true,
maxRedirects: 10
}, function(error, response, body) {
console.log(body);
});
}
|
stackexchange-arduino
|
{
"answer_score": 0,
"question_score": -2,
"tags": "arduino uno"
}
|
How can I get sender ID using Discord.py?
I'm trying to create a logger bot which will log everything said in a server. I need the sender ID to @mention the user who said something so that it can be traced to the original author. How can I get the user's ID?
|
If you want the command author's id, you would want to do something like this:
@bot.command(name="id")
async def _id(ctx):
author = ctx.message.author
await ctx.send('Your ID is: ' + str(author.id))
you get the ID with .id if you would like to get a mentioned users id, just add a .id to the end of a discord.Member variable.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, discord, discord.py"
}
|
SharePoint Web Error
Assembly generation failed -- Referenced assembly 'ClockControlWebPart' does not have a strong name
I can't understand this error....
|
Most lilkey assembly you are building is strongly named and as result it can't reference assemblies that are not strongly named.
Note that each error C# compiler produces have code in the beginning (like CS1234). Searching on for this code will likely give you article on MSDN with explanation of the error and most common cases when it happens.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, .net, sharepoint 2007, web parts"
}
|
Live render of text in a textarea
I would like to make a textarea and a div near it similar to what you use in the "ask question" page here in stackoverflow. You type a text in the textarea and the text is rendered live under the textarea. I'd like to make this to convert "live" some codes like "a024" typed in the textarea to symbols in the div. Do I need to use javascript to get this feature? Thanks.
|
Yes. That was called DHTML for Dynamic HTML at the beginning of JavaScript. You will have to use Javascript to create this behavior.
You can get the value of an element with something like:
var source = document.getElementById("sourceTextarea").value;
and set text in a destination element with something like:
document.getElementById("destinationDiv").innerText = "some text";
In your HTML you will have to use :
<textarea id="sourceTextarea"></textarea><div id="destinationDiv"></div>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "javascript, html, textarea"
}
|
How would I graph this implicit function in geogebra?
I am trying to graph the below equation in geogebra.
\begin{equation} x\cos { (xy) } = 4 -y \end{equation}
I was able to get wolframalpha to graph it but I am unsure on how to in geogebra. I am assuming I should be using an implict type function. Anyone one know how I can do this?
<
|
Write the equation in standard form ($f(x,y)=0$) and use the `ImplicitCurve` command:
;
String sitetoblock = "\n 127.0.0.1
sw.Write(sitetoblock);
sw.Close();
MessageBox.Show(listView1.SelectedItems[0].Text " blocked");
|
It's not the right way to block a website, but here is the way to 'unblock' a site that is 'blocked' by your code is simply :
1. read the host file
2. find the site url by regex
3. delete the line
4. save the file.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 1,
"tags": "c#, file io, hosts"
}
|
Selecting multiple hit-scoped custom dimensions with bigquery
I'm trying to get a list of customers who made at least one purchase on a given day. The bigquery below works when just selecting date and customer_id. However, city always returns null, though I know the data exists.
Do I need to use a different approach when selecting multiple hit-scoped custom dimensions?
SELECT date
,CASE WHEN hits.customdimensions.index = 5
THEN hits.customdimensions.value END as customer_id
,CASE WHEN hits.customdimensions.index = 50
THEN hits.customdimensions.value END as city
FROM (TABLE_DATE_RANGE([16475821.ga_sessions_],
TIMESTAMP('2016-09-01'), TIMESTAMP('2016-09-07'))
GROUP BY 1, 2, 3
HAVING sum(case when hits.eventInfo.eventAction = 'purchase' then 1 end) > 0
and customer_id is not null
|
Don't have any data to test again, but visually assessing - below should work for you
SELECT
date,
MAX(CASE WHEN hits.customdimensions.index = 5
THEN hits.customdimensions.value END) WITHIN RECORD AS customer_id
MAX(CASE WHEN hits.customdimensions.index = 50
THEN hits.customdimensions.value END) WITHIN RECORD AS city
SUM(CASE WHEN hits.eventInfo.eventAction = 'purchase'
THEN 1 END) WITHIN RECORD AS purchases_count
FROM (TABLE_DATE_RANGE([16475821.ga_sessions_],
TIMESTAMP('2016-09-01'), TIMESTAMP('2016-09-07')))
HAVING purchases_count > 0
AND NOT customer_id IS NULL
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "google bigquery"
}
|
Is longer text (eg. article content) or shorter text (eg. article title) better for classification?
I'm currently doing a project to collect and classify news articles, and I'm only interested in a small subset (for example sports-related news) of all the articles collected.
I'm new to Machine Learning and Text Classification. Should I classify the articles based on their titles or actual contents? A human being can usually tell with fair amount of confidence if the news article is relevant by just looking at the title. Hence I'm wondering if titles, instead of content, would give similar or better accuracy in automatic text classification?
The reason for this problem is that overall performance will improve a lot if the program analyses titles first when it finds a link, instead of retrieving every page from the urls and then analyses the contents.
|
The title is unlikely to provide enough information to classify an article. You can however analyse the title and, if your confident enough that you've got an accurate classification, you can classify it, otherwise look at the content.
Take something like `Manchester in trouble`. If you don't know that `Manchester` is a sports team, the article could be economic or political or probably one of few other categories too. I suspect a lot of titles can only easily be classified by people because they're familiar with the Proper Nouns relating to that category, and it could be difficult to get proper training data to train an agent to do this well.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "machine learning"
}
|
Asp.Net MVC on Subdomain, standard MVC app gives 404's
I am trying to deploy my MVC app on a subdomain, unfortunately I get 404 errors.
I tried to find out if it's MVC itself that can't handle being hosted on a subdomain.
I uploaded the standard bare MVC webapp that you get when you start a new project. The index page loads, but all the other pages that require actual routing based on the url do all give 404's.
What do I need to change to be able to use MVC on a subdomain.
(it's all setup on a IIS 7.5 server as a seperate website)
|
I had this problem with a shared hosting provider. I had to get them to change the Application Pool to "Integrated Mode" instead of "Classic" mode in iis7 for it to work. Not sure why, haven't really looked into IIS7 that much
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "asp.net mvc, subdomain, http status code 404"
}
|
What is the best way to manual install an Azure VM Extension?
I need to install a modified azure linux vm extension. Unfortunately the documentation doesn't mention an easy way to install them.
Powershell, Azure CLI or Azure Portal would work.
|
You could use PowerShell, Azure CLI or Azure Portal to configure VM Extension’s parameters. However, the VM Extension is installed by waagent, so you could find install logs in `/var/log/waagent.log`. If waagent does not install in your VM, you could not install VM Extension.
More information please refer to this article.
|
stackexchange-serverfault
|
{
"answer_score": 1,
"question_score": 0,
"tags": "azure"
}
|
Swift dynamic cast failed - Error when trying to run unit tests
Xcode Version 6.1.1 (6A2008a)
Error: libswiftCore.dylib`swift_dynamicCastClassUnconditional and Swift dynamic cast failed
I am trying to test and I am coming across this error that I am unsure about how to fix. Can someone please shed some light on this?
Error happens:
The error happens with this cast:
var delegate = UIApplication.sharedApplication().delegate as AppDelegate
After reading this post: I deleted the AppDelegate.swift from the test target but then I get an error when building as the compiler complains about not knowing about "AppDelegate" in the cast. I am confused?!
|
Ok so after a lot of messing about here is what solved the issue:
1. I removed all the test target membership from the files in the main (non-test) part of my application, including the AppDelegate.
!enter image description here
2. I changed all the classes (in the main part of the application) that I needed to access (from the Test part of the application) to be public and also set these class's required methods to be public as well).
3. I imported the main project into each appropriate test classes with an `#import AppName` statement
Hope that saves some other people some time.. :)
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 5,
"tags": "objective c, swift"
}
|
Sqllite :Selecting records between 2 dates including intervening rows
I have some data in a sqllite db table (mytable ) of the form:
id column1 date
111 280 2014-02-01
112 281 invalid invalid invalid
113 282 invalid invalid invalid
114 275 2014-02-01
......................
338 273 2014-02-28
I want to select all the records in February. There are some intervening records that are invalid and don't have a date. I tried:
SELECT * FROM mytable WHERE date BETWEEN '2014-02-01' AND '2014-03-01'
but this skips the intervening records
I want to select these as well, so that I end up with all the records between id 111-338
All the columns except for id are in text format.
How can I do this?
|
Don't have sqlite right now but this should give you a start:
select max(id) as max_id, min(id) as min_id
from mytable
where date BETWEEN '2014-02-01' AND '2014-03-01'
then
select *
from mytable where id >= min_id and id <= max_id
I think this would make it in just one query:
select mytable.*
from (select max(id) as max_id, min(id) as min_id
from mytable
where date BETWEEN '2014-02-01' AND '2014-03-01'
) as internal, mytable
where mytable.id >= internal.min_id and mytable.id <= internal.max_id
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "sql, sqlite"
}
|
Cannot create git repository using Xcode 9
I have created a project that I would like to push to my GitHub account. Unfortunately, I did not create a GitHub repository when creating the project. When I attempt to create a repository using Xcode by following the path of Source Control -> Create Git Repository, Xcode displays a popup stating that "all projects are already under source control." This is not the case and the project is not in my GitHub account. Here is a screen cap of the error. What am I missing?
 and "M" (for Modified) and "A" (for Added)
By default Xcode creates a local git repository for new project unless you uncheck that option
Check this out
> Xcode will automatically add it under source control.
You just need to define a remote. Right click on the repository (from the git pane) and tap on "Add existing remote.."
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "ios, xcode, git, github"
}
|
SQL SERVER 1 to many - groupby query
I have 2 tables Categories & Subcategories
i need to create a query to display Category name and under each all subcategories (ID + Name)
Something like that:
Category1
Sub101
sub102
sub103
Category2
sub201
sub202
Category3
sub301
sub302
I know that I can count subcats for each cat, but i need to display their names as well.
I tried this query:
select distinct CatID, COUNT(SubcategoryID)
from Subcategory
group by CatId
another query :
select distinct CatName, SubcategoryName , COUNT(SubcategoryName)
from Categories, Subcategory
group by CatName,SubcategoryName
I need to bind this later to a dropdownlist in asp.net
any ideas?
Thank you!
|
Something like this?
select distinct CatID, 0 as Header, CatName
from Categories
UNION
select distinct CatID, 1, SubcategoryName
from Subcategory
Order by CatId, Header, CatName
This uses the CatId to group all the categories and sub categories together. Then the 1\0 to ensure the Category sorts to the top and finally the CatName\SubcategoryName is sorted Alphabetically.
There may be a problem with selecting distinct from subcategories if they are reused, but we can cross that bridge if we come to it.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sql server"
}
|
Outpuf PDF as a stream for calling process
I'm using jasperstarter (a java program, open source) to generate reports that I define in iReports. This runs in windows and I need the output PDF generated to be directly read by the calling process which is a C# program.
Jasperstarter has lots of options like viewing the PDF generated directly, or generating the PDF as a file, sending it to printer, but no option to stream the result PDF to the calling process.
Is this possible at all, even if I have to change jasperstarter's open source code? How? Is this possible in some other way that doesn't imply changing the jasperstarter's code? How?
|
Actually the answer was quite easy. I've downloaded jasperstarter and was able to use JasperExportManager.exportReportToPdfStream method which already existed on jasper's library to export the pdf to "System.out" stream. Together with adding a new option to run this process, this makes jasperstarter to be able to allow for redirection of the PDF's result (pipe '|' and redirect can be used directly on the program).
I tried contact with jasperstarter's project owner to see if I can get this change commited on the master branch.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, c#, pdf, stream, jasperstarter"
}
|
Is the set of undecidable problems decidable?
I would like to know if the set of undecidable problems (within ZFC or other standard system of axioms) is decidable (in the same sense of decidable). Thanks in advance, and I apologize if the question is too basic.
|
No, in fact the situation is even worse than that. The set $T$ of all (Gödel codes for) sentences that are provable from ZFC is computably enumerable; the set $F$ of all sentences that refutable from ZFC is also computably enumerable. These two sets $T$ and $F$ form an _inseparable pair_ : $T \cap F = \varnothing$ but there is no computable set $C$ such that $T \subseteq C$ and $F \cap C = \varnothing$.
In other words, there is no finite algorithm that can reliably tell whether a sentence is "not provable" or "not refutable." This is much weaker than asking for an algorithm to tell us whether a sentence is independent or not (in which case we could determine whether it is provable or refutable by waiting until it enters $T$ or $F$).
This remains true if ZFC is replaced by PA and some still weaker theories.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 13,
"question_score": 9,
"tags": "lo.logic, model theory"
}
|
Angular 8 with Storybook 6
Getting the below error while installing and starting a storybook.
ERROR in /Users/username/angular-storybook/src/stories/Button.stories.ts
ERROR in /Users/username/angular-storybook/src/stories/Button.stories.ts(2,29):
TS2307: Cannot find module '@storybook/angular/types-6-0'.
ng version
Angular CLI: 8.3.29
Node: 12.16.2
OS: darwin x64
Angular: 8.2.14
Dev dependency
"@compodoc/compodoc": "^1.1.11",
"@storybook/addon-actions": "^6.0.12",
"@storybook/addon-essentials": "^6.0.12",
"@storybook/addon-links": "^6.0.12",
"@storybook/angular": "^6.0.12"
|
As a workaround, I have updated the imports from Button, Header, Page{.stories}:
From --->
import { Story, Meta } from '@storybook/angular/types-6-0';
To ---->
import { Story, Meta } from '@storybook/angular';
This works fine. But not sure why the boilerplate code has the issue. :( This works fine with version 6.0.12.
Updates: With newer version of the storybook(>6.2.*), Explicitly declare in typings.d.ts inside the .storybook directory. (mentioned by @Mr.7)
declare module '@storybook/angular'
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 6,
"tags": "angular, angular8, storybook, angular storybook"
}
|
only last line gets saved in text file in c++
my code only saves the last line for eg if i enter 1 abc then press enter and then type 2 def then only 2 def is saved in txt file. here is my code :-
int main()
{
ofstream rankings;
rankings.open("rankings.txt");
cout << "Enter rank of the Student <space> followed by Name\n"
"Press Ctrl+Z to quit"<< endl;
int rank;
string name;
while (cin >> rank >> name);
{
rankings << rank << ' ' << name << endl;
}
rankings.close();
return 0;
}
|
You have a superfluous semicolon after your `while` loop:
while (cin >> rank >> name);
// ^
This will just open a new block in the code afterwards, and leave you with the least values input.
To fix change your loop to
while (cin >> rank >> name) {
rankings << rank << ' ' << name << endl;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "c++, file io"
}
|
Using <script> tag within editable email notification dialog in Jenkins
I am writing this simple html in the editable email notification dialog box:
<!DOCTYPE html>
<html>
<body>
<p id="demo"> </p>
<script type="text/javascript">
document.getElementById("demo").innerHTML = "this is from JS";
</script>
</body>
</html>
However I am unable to see the string " this is from JS" in the generated email. Not sure what am I doing wrong ? Any pointers?
|
You have your JS, but it seems that you never call it. Try running in a load or ready function.
<script type="text/javascript">
window.onload = function() {
document.getElementById("demo").innerHTML = "this is from JS";
};
$( document ).ready(function() {
document.getElementById("demo").innerHTML = "this is from JS";
});
</script>
I think this is what you are trying to do.
UPDATE:
Alright, I found another function that will work for you. here is the the FIDDLE.
<body>
<p id="demo"></p>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("demo").innerHTML = "this is from JS";
});
</script>
</body>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, html, jenkins"
}
|
PHP - merge two arrays similar to array_combine, but with duplicate keys
I have two arrays:
$arrKeys = array('str', 'str', 'otherStr');
$arrVals = array('1.22', '1.99', '5.17');
I would like to merge them into something like this
$arrResult = array(
array('str' => 1.22),
array('str' => 1.99),
array('otherStr' => 5.17)
);
The keys are non-unique, otherwise I'd use `array_combine`. That would give a bit different output, but it would suit me as well.
Can this be done in an elegant way using PHP 5.2.x, without `foreach`/`for` loops, preferably using PHP's built-in functions?
|
You can use `array_map`:
$arrKeys = array('str', 'str', 'otherStr');
$arrVals = array('1.22', '1.99', '5.17');
function foo($key, $val) {
return array($key=>$val);
}
$arrResult = array_map('foo', $arrKeys, $arrVals);
print_r($arrResult);
Array
(
[0] => Array
(
[str] => 1.22
)
[1] => Array
(
[str] => 1.99
)
[2] => Array
(
[otherStr] => 5.17
)
)
BTW, if you upgrade to PHP 5.3 you can do this using an anonymous function, which is a bit more elegant:
array_map(function($key, $val) {return array($key=>$val);}, $arrKeys, $arrVals);
|
stackexchange-stackoverflow
|
{
"answer_score": 15,
"question_score": 3,
"tags": "php, arrays"
}
|
How to split cell text into multiline in table?
I'm writing a paper using the ACM double column template, and I have a table which I want to fit to just one column, and in order to do so, I want to split the text inside the cells to multiple lines. I have the following code segment:
\documentclass{paper}
\begin{document}
\begin{table}[thb]
\centering
\begin{tabular}{|l|c|l|} \hline
\textbf{Col1} & \textbf{Col2} & \textbf{Col3} \\ \hline
This is a \\very long line \\of text & Short text & Another long \\line of text \\ \hline
$\pi$ & 1 in 5& Common in math\\
\hline\end{tabular}
\end{table}
\end{document}
But, what it gives me an output which is not quite right, as can be seen below.
, using:
Collections.unmodifiableList(yourArrayList)
This returns an unmodifiable view of the list.
_Note that this doesn't mean the items themselves cannot be modified._
Other alternatives could be:
* Converting the list to an array (with `toArray(T[] a)`, and passing that to `Arrays.asList()`, which would also send back an unmodifiable list.
* If using some other libraries in your code, like Guava, you could invoke `ImmutableList.copyOf()` or other variations.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, arraylist"
}
|
CGRect Assistant?
This is a little vague, but i'll try to be specific.
How do you use CGRect and CGRectMake? Is there an assistant or something which you can use to find points quickly? I've looked in Interface Builder, but it seems to me that there is no quick way of finding the points to use in CGRect. If anyone could point me in the right direction, it would be great.
|
If you're trying to recreate an interface in code that's in interface builder, you need to look at the Size Inspector:
First, select an element in interface builder:
!enter image description here
Now look at the Size Inspector in the right-side panel:
!enter image description here
The X, Y, Width and Height variables give you enough information to create a `CGRect` with the same size as the element:
CGRect editFrame = CGRectMake(233.0, 6.0, 67, 32);
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 0,
"tags": "objective c, ios, cocoa, interface builder, cgrect"
}
|
CSS convention for rgb colors
Is there any convention for `css` rgb color values? I mean- sholud the values be separated with spaces or should they not?
For example- should it look like this:
.some_element_class {
color: rgb(100,100,100);
}
Or like this?:
.some_element_class {
color: rgb(100, 100, 100);
}
|
As the W3 org, it can be used with and without spaces.
My advice is for you to use the one you like better and follow that in all your projects. If you get to work for a company follow their code formatting.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "html, css, colors, sass, rgb"
}
|
Why am I getting 'Braintree/BTUICTAControl.h' file not found error on Braintree manual integration?
I get the following build error after implementing step number four "Add the Braintree SDK code to project" from the Manual Integration Without CocoaPods guide.
> braintree_ios/Braintree/UI/Braintree-Payments-UI.h:3:9: 'Braintree/BTUICTAControl.h' file not found
## Tested in
* New Objective-C iOS app project.
* In Xcode 6.1 (6A1042b) and 6.3 (6D543q)
How can I fix this build error?
|
I work on the Braintree iOS SDK.
I believe using the name `Braintree` instead of `Braintree SDK` for the framework target name will resolve this particular issue. I recently updated the manual docs accordingly.
We recommend that you integrate using CocoaPods if at all possible, as it handles all this complexity for you.
Note also that I've responded on the issue you posted on GitHub. Let's resolve this there. Thanks!
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "ios, xcode, braintree"
}
|
Search not working?
When I load < (or any other search query) I get a **Your search returned no matches.** response.
|
Should be working now. Upgrading our search clusters today, and so things might be a bit off here an there.
|
stackexchange-meta_mathoverflow_net_7z
|
{
"answer_score": 5,
"question_score": 4,
"tags": "bug, status completed"
}
|
Записать картинки на сервер url
Здравствуйте. у каждого пользователя есть аватар. я уже сделал выбор аватара из галереи и также можно сделать фото. Потом мне нужно чтоб пользователь видел не только свой аватар, но и всех остальных. То есть я думаю, после выбора аватара, нужно сохранить этот файл на сервер, чтоб другие могли скачать по url этот файл. Как скачать по url я знаю, а как записать на сервер картинки?
|
1. Отправить post-запросом и обработать на сервере.
2. По ftp
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "url, android, изображения"
}
|
Print all elements in a comma separated String
I have a simple string that is generated dynamically as such:
String values = "one, two, three...last"
How to i print all items in string values?
|
It's simple. You can try like below:-
for (x in "one, two, three...last".split(", ")) {
println(x)
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "android, string, kotlin"
}
|
What are these mounts for on inside edge of carbon fiber fork?
I just got a new Tommaso Sterrata.
I commute during the winter so I'm looking to put fenders on. I know I can get fenders that clip onto the fork instead of being mounted, but while inspecting the fork, I found these two screws on the inside edge of the fork.
What are they for? What are they supposed to do, and what _can I do_ with them. Would it be feasible to mount the fender stays on them?
 from coders on VisualStudio project?
We want our coders to NOT use `DateTime.parse()`.
How can we block to use it?
Can we override this, to hide from them?
**EDIT1**
Actually we want to override this method, we have our own method which gets called this way: `clsStrUtils.ISOToDate()`.
**EDIT2**
We do trust our programmers, but this is a specific situation. I don't want to restrict no-one using a better way, I just want to restrict Parse(). They can still use **ParseExact()**.
|
You might be able to write a custom rule in FxCop to do this. Check out the tutorials on this site for information on how. You then might be able to run it periodically to validate that the members of the team are using the standards you put in place.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "c#, visual studio, overriding"
}
|
Even holomorphic function on the punctured disk has a primitive
Let $f$ such that $f$ is holomorphic on $\\{z|0<|z|<1\\}$, and $f$ is even.
I need to show that f has a primitive. Any ideas?
|
Write $f$ in the form of Laurent series around $0$. You get the form $f(z)=\sum_{n=-\infty}^\infty a_nz^n$. Now, if we prove that $a_{-1}=0$ then $F(z)=\sum_{n=-\infty}^{\infty}\frac{a_n}{n+1}z^{n+1}$ is a primitive function of $f$. So we just have to prove that $a_{-1}=0$ and we are done. And here we are going to use that $f$ is even. We know that $\sum_{n=-\infty}^\infty a_nz^n=f(z)=f(-z)=\sum_{n=-\infty}^\infty a_n(-z)^n$. So if we define $g(z)=f(z)-f(-z)$ then $g$ is the zero function and its Laurent expansion is $\sum_{n=-\infty}^\infty a_{2n+1}z^{2n+1}$. Because Laurent expansion is unique we conclude that $a_{2n+1}=0$ for all $n\in\mathbb{Z}$. So $a_{-1}=0$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "complex analysis, holomorphic functions"
}
|
Excel copy range to keep hidden rows
As the question states, is their anyway to copy/paste a range and copy the hidden rows too?
Currently I use
xlWB.Sheets("Template").Range(Template_RFull_Inc).Copy
With ThisWorkbook.Sheets(Test_Name).Range("A11")
Application.DisplayAlerts = False
.PasteSpecial xlPasteColumnWidths
.PasteSpecial xlPasteValues, , False, False
.PasteSpecial xlPasteFormulas, , False, False
.PasteSpecial xlPasteFormats, , False, False
.PasteSpecial xlPasteValidation
Application.CutCopyMode = False
Application.DisplayAlerts = True
End With
Is their a code like
.PasteSpecial xlHiddenRows
If this is too long winded or going to cause a headache I do have a work around
|
If you want the same lines to be hidden in the copy (Test_Name), you have to run something else after the copy. Something closed to that should work.
Dim TopRowOriginal As Long
Dim TopRowCopy As Long
TopRowOriginal = Template_RFull_Inc.Row
TopRowCopy = ThisWorkbook.Sheets(Test_Name).Range("A11").Row
Dim r As Range
For Each r In Range(Template_RFull_Inc).Rows
ThisWorkbook.Sheets(Test_Name).Rows(r.Row + TopRowCopy - 1).EntireRow.Hidden = r.EntireRow.Hidden
Next r
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "vba, excel"
}
|
Which generic fast collection (set) provides getIndexFromValue or similar?
I need a collection that is a set (no duplicate values) and provides quick insert times. I also need to be able to get the index of a value.
Pseudocode:
Set.Insert(value)
Set.GetIndex(value)
The position of the value relative to the other values doesn't matter, sorting isn't required.
Is there a C# generic collection that provides this functionality? Or is there a way to do it by combining different collection types?
|
You can use `HashSet<T>` It doesn't allow duplicates and is fast. <
If you want to get the index of a value, you could convert the `HashSet` into an array and use `Array.IndexOf(value)`; however, the `HashSet` allows you to use the value itself as an index, so you may no longer have need of that.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, collections, set"
}
|
GnuPG / OpenGPG: Recovering public key from private key
I know that the public SSH key can be recovered from the private using `ssh-keygen -y`.
How can a (deleted) public key be recovered from the private key in GPG (preferably in a way that is OpenGPG compatible)?
|
## "Recovering" Public Keys in OpenSSH
`ssh-keygen -y` does not actually _recover_ the public key, but just reads it from the private key, where it is always attached if stored in OpenSSH format.
## "Recovering" Public Keys in OpenPGP
Similar for OpenPGP: if exported in an OpenPGP-compliant way, the private key will always contain the public key - import it on a computer you own and trust, and export the public key afterwards. With GnuPG, do something like:
gpg --import [private-key-file]
gpg --export [key-id]
`gpg --export` will by default only export the public key.
## Where the Public Key Also Might be Found
If you shared the public key, chances are high you either find it on public key servers (eg., < or some friend of you has it on his computer (where he can easily `gpg --export` it).
|
stackexchange-superuser
|
{
"answer_score": 34,
"question_score": 27,
"tags": "linux, gnupg, public key, cryptography, private key"
}
|
How do I make font of a button to bold on windows 10?
Currently I'm running on windows 10 when I go to services the services button are sort of different from my friend pc font button
My pc font button:
.
You can change text scaling by changing the 'Make everything bigger' function: , your friend probably uses the default 150% (which makes it easier to read but is fuzzier).
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 0,
"tags": "windows 10, fonts"
}
|
Escribir diccionario en archivo de texto
Hola estoy intentando escribir un diccionario, con datos de nombre y de telefono, en un archivo de texto y no lo puedo lograr. Mi diccionario es del tipo: agenda={"Juan":14253 , "Mariano": 24875 , "Marcos":65232} y lo que hice fue esto:
agenda={"Juan":14253 , "Mariano": 24875 , "Marcos":65232}
agendaarchivo=open("agendaarchivo.txt", "w")
for nombre,agenda[nombre] in agenda:
agendaarchivo.write(nombre+":"+agenda[nombre]+"\n")
agendaarchivo.close()
Y me salta el siguiente error:
Traceback (most recent call last):
File "C:\Users\Usuario\Desktop\final compu\error\prue.py", line 4, in
<module>
for nombre,agenda[nombre] in agenda:
ValueError: too many values to unpack (expected 2)
|
Tu debes de iterar a traves de .`items()`, este retorna la llave y el valor.
agenda={"Juan":14253 , "Mariano": 24875 , "Marcos":65232}
with open("agendaarchivo.txt", "w") as agendaarchivo:
for nombre, valor in agenda.items():
agendaarchivo.write("%s %s\n" %(nombre, valor))
|
stackexchange-es_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, archivo, diccionarios"
}
|
itunesconnection ATS year end self classification report
I have a very, very basic app that makes a web service call from a `http` url in order to retrieve facts about a number that a user inputs into a textfield. In order to bypass ATS, I went into the `info.plist` and created an exception domain for the web service only.
Before I submit my app, I get the question:
* If you are making use of ATS or making a call to HTTPS please note that you are required to submit a year-end self classification report to the US government
Am I required to do this? What does this mean exactly? Any help would be appreciated.
|
If, as you state, you are using HTTP, which is not encrypted, there is no need for you to submit the request.
> If you are **making use of ATS** or **making a call to HTTPS** please note that you are required to submit a year-end self classification report to the US government
You are disabling ATS so that you can make an HTTP call, so you do not meet the criteria for apps that would require a self classifaction report.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "ios, app store connect, app transport security"
}
|
Using cccc with pure C?
Has anyone used cccc with pure C code?
I tried it and it seems to handle all the files as one module, which means that most of the counters are useless (e.g. there is no fan-in or fan-out since there is just one module).
Can I somehow tell it to do this comparison on a file-by-file basis (i.e. each file is one module)?
|
Seems a little bit outdated. I usually use sloccount with good results.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c, static code analysis"
}
|
Animating own low poly trees on my own terrain?
Is there any easy way to animate my own tree models? I can't use tree creator, because it's useless for me since I am using my own terrain. My tree models are low poly and I would like animate trees like here. Do I have to write a shader for this? I found this one, but I am not sure if I can use it or how to apply it to all my trees.
|
You can animate them in your 3D software (Blender?) and it's probably the easiest way to do this.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "animation, unity3d, tree, shader"
}
|
jstl c:set is not working on js code in jsp file
I have a JSON from a service. I am appending a html block by JSON value and I have to check some values for appropriate display. I am trying to set discountValue variable but it not working with js variable. How can I solve it?
if (data!="")
{
$.each(data,function(index,element){
var intDiscount=parseInt(10);
console.log("intDiscount::"+intDiscount);
var strIndex='';
strIndex+='<div class="card">';
strIndex+='<c:set var="discountValue" value="'+intDiscount+'"/>';
console.log("${discountValue}");
...
...
...
...
}
$('#visilabs-FavouriteCategoryTopSeller').append(strIndex);
Console log:
intDiscount::10
0
|
I have solved it with using if condition with js:
if(element.discount>0){
strIndex+= ' <span class="label label-danger discount">'+'% '+intDiscount+'</span>';
}
Thanks everyone
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, jsp, jstl, jstl functions"
}
|
Programatically re-order images in the ACF gallery add-on. Orderby Title, ID, etc
I have a gallery field using the advanced custom fields gallery addon.
This is how I am outputting my gallery fields/images in my theme...
<?php
$images = get_field('gallery');
if( $images ): ?>
<div id="gallery-1">
<?php foreach( $images as $image ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endforeach; ?>
</div>
<?php endif; ?>
And this is the only way in the documentation I can see how to implement it.
Does anyone now who how I can order the images by title, id or anything when they are outputted in the loop?
Many Thanks
|
You can use Php's `usort()` function with a callback. For example, if you want to sort images by ID, you could try something like this (stealing the filter that @Milo used in their answer):
<?php
function sort_callback($a,$b)
{
if ($a['id'] == $b['id']) {
return 0;
}
return ($a['id'] < $b['id']) ? -1 : 1;
}
function my_acf_load_field( $field ){
usort( $field, 'sort_callback');
return $field;
}
add_filter( 'acf_load_field-gallery', 'my_acf_load_field' );
You can adjust the `sort_callback` function to sort by whichever value in the $image array that you'd like.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 0,
"tags": "advanced custom fields"
}
|
Создание игровых юнитов
К примеру, есть класс Warrior и я хочу сделать X объектов. В какой список их лучше поместить, вектор?
|
Я бы помещал в лист, и итератором при необходимости обходил его. Смотри при добавлении в вектор нового элемента выделяется новый участок памяти в который копируются старые элементы и новый и так же с удалением, а в листе удаление и добавление происходит на порядок быстрее.
Вот даже почитать можешь на эту тему
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "java, c++, c#"
}
|
What's the best way to run .net framework apps on linux with docker
I need to develop and run a .NET Framework 4.6.2 application on Linux, on this case, .net core is not a possible solution, since it's a quite old and big application.
So, is it possible to develop the application on linux and run it with docker? I would also need to run SqlServer express on the machine.
I know I could run a VM on my computer, but I wanted, if possible, in this case, not use a virtual machine
|
Your options are:
1. Run in a Linux container using Mono
2. Migrate to .NET Core/Standard (I know you said you didn't want to do this, but it might be worth investigating; if it's not an ASP. NET web app, the effort is likely pretty low as .NET Framework 4.6.2 is compatible with .NET Standard 2.0)
3. Run as-is in a Windows container
So realistically if you need to run it in a Linux container, you need to use Mono as your runtime.
Regarding SQL Express, SQL Server does now exist for Linux, with images available at Microsoft's container registry (also linked to from Docker Hub/Store)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, .net, linux, docker"
}
|
Android SDK and AVD Manager where is Settings menu?
I am dealing with a problem discussed on many forums but they all say go to the "settings" menu on the "Android SDK and AVD Manager" screen. Yet I have installed in on multiple machines and do not see a Settings menu. Where is the menu? I have it installed on Windows XP and Vista.
Thanx Julian
|
It only appears when I run it manually.
On a Mac, it is located in:
/android/tools/android
On Ubuntu:
android-sdk-linux/tools/android
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 5,
"tags": "android, android emulator"
}
|
Heroku deployment crash rails server syntax error File.expand_path("../spring", __FILE__)
When deploying on Heroku, the server crashes with this information rails server syntax error File.expand_path("../spring", **FILE** ) though everything is working when working locally. Here is my rail file
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH=File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
Do you have any idea of the issue? Thanks
|
Found the solution after 1/2 day of struggling You need the following line at the top of the rail file: #!/usr/bin/env ruby Surprisingly, it wasn't a problem locally but when deploying on Heroku it was.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 5,
"tags": "ruby on rails, ruby, heroku, spring gem"
}
|
Selenium::WebDriver Wait (Ruby, Chrome)
I have a ruby script that opens a browser. I have it set to open Firefox first and then Chrome if FF fails for some reason - like FF gets updated and Selenium hasn't caught up yet.
The wait function/definition works fine for FF but always breaks Chrome. Here is the relevant code for the Chrome browser startup:
b = Selenium::WebDriver.for :chrome
b.driver.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT
I'm fairly new to Selenium still and I user the wait.until command after declaring something like:
wait = Selenium::WebDriver::Wait.new(:timeout => $BROWSER_EXPLICIT_WAIT)
The above lines of code work fine in Firefox. However, I'd like to run my scripts with both FF and Chrome. Is there a way to do this in Chrome and FF?
Thanks
|
See now that you provide the error it gets easier to solve.
The reason is that - you have named the selenium driver instance as `b`
but defining the implicit time as
`b.driver.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT`
ie with `b.DRIVER`, hence the error message - `undefined method 'driver' for`
change your command to
b.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "google chrome, ubuntu, selenium, webdriver"
}
|
How can the prior distribution of bayes regression be estimated by empirical bayes?
Neither in Efron's book Large-scale Inference:Empirical Bayes Methods for Estimation, Testing and Prediction nor by Internet search, did I find a prior distribution estimation method of Bayes regression from the perspective of empirical Bayes
|
Check the books
An Introduction to Bayesian Inference in Econometrics by Zellner
Bayesian Econometrics by Gary Koop
The Oxford Handbook of Bayesian Econometrics by John Geweke, Gary Koop and Hermann van Dijk
Bayes and Empirical Bayes Methods for Data Analysis by Brad Carlin and Thomas Louis
|
stackexchange-stats
|
{
"answer_score": 1,
"question_score": 0,
"tags": "regression, bayesian, linear model, prior"
}
|
Handling database connections in a standalone application
I have a standalone application (no application/web server) with various methods accessing a database via JDBC. So far, a database connection is opened (and closed) in every method. There is no need for multiple connections at the same time.
But:
* Creating a new connection every time seems a bad idea because of performance
* Alternatively, using a single connection seems a bad idea as well.
What is the way to go? Connection pooling for just one connection?
|
If you configure it right, you can gain a lot by using a connection pool, most of all the performance of individual statements - connecting to the DB might be measured in seconds.
At the same time except for the initial pool creation (you might be able to run that parallel to other initialization) you still maintain a very good relaibility - as the pool will check connections on checkout or in between and discard connections that broke down. So you're likely to survive episodes of "not-connected" or similar as well.
I share your view that using a single connection might be a bad idea - because you'd have to deal with connection loss / reconnect all over your code.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "java, jdbc"
}
|
Can SpineJS block the UI when updating?
One of the stated SpineJS goals is to make the entire UI non-blocking (i.e. display the change to the user, even though it might have not been updated successfully on the server side yet).
Can it be used in a standard "blocking" manner?
|
Yes it can. Look here under "callbacks":
<
You can basically block the UI at any point, and I do it for things that just can't be deferred to the server. Note that I don't even use the ajaxSucess() event, but just custom bindings for events. Here is an example use case in meta programming:
Bind 'clickHandlerFinish' event to clickHandlerFinishWork()
Bind 'click' event on button a to clickHandler()
User clicks on button a
clickHandler() gets fired
clickHandler disables the button and blocks the UI
clickHandler makes an AJAX call to the server to do work
(Remember UI is still blocked)
AJAX call finally returns, and fires the clickHandlerFinish() callback
clickHandlerFinish() unblocks the UI, re-enables the button, and presents the new changes
I've used this successfully on a few instances. Works great for me!
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "spine.js"
}
|
Disable generation of implicit type checking code by swig for python-C++ interface
For the following simple function:
#include <iostream>
void Echo(int no) {
std::cout << "no: " << no << std::endl;
}
I have the following swig interface file:
%module example
%{
#include "example.h"
%}
%include "example.h"
I can generate a wrapper using swig and test it as:
from example import Echo
import numpy as np
no = 2
Echo( np.int(no) ) # OK
Echo( np.int32(no) ) # Error
Echo( np.int64(no) ) # Error
swig generates type checking wrapper code which results in error in 2nd and 3rd call. This is nice but is there any way to override/disable generation of this type checking code for the type casting which are legally ok?
|
This can be controlled by passing `castmode` or `nocastmode` option to swig when generating wrappers. The default is `nocastmode`. This does not require to define any `typemaps` and is also independent of python2/python3.
**Example:** To allow the type castings in above example, one can generate the wrapper as:
swig -c++ -python -castmode example.i
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "python, c++, swig"
}
|
Indexed Search extbase htmltags in output
I am using TYPO3 7.6.11 and indexed_search 7.6.0.
I use the extbase plugin for indexed_search and in the output it escapes the HTML-Tags to mark the searchword. For example, when I search for "search" I get this output:
Test text with<strong class="tx-indexedsearch-redMarkup">search</strong> pattern.
I found this bugfix to this problem: <
But the file `PageBrowsingResultsViewHelper.php` doesn't look exactly the same, and even when I add the variable `protected $escapeOutput = false;` it doesn't change anything.
Any idea where this is come from and where I can disable the escaping?
|
It was another extension who overwrote a Partial of tx_indexedsearch that caused the problem.. -> Always check if the template you are working on is the one that gets outputted ;)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 8,
"tags": "typo3, extbase, typo3 7.6.x"
}
|
Rewriting a GET request URL in WordPress
Any help is greatly appreciated!
I have a WordPress build that accesses information on an external database which then assists in populating the page. That structure looks like this:
Ideally, I would like the result to be:
There is a catch here - < is a page which holds the API call to the external database in a WP template, so I'm also wondering if the trailing slash before the GET would make any errors. Thanks again!
|
Try using a rewrite rule:
add_action( 'init', 'so46572689_new_rule');
function so46572689_new_rule() {
add_rewrite_rule('^publication/(.*)?$','index.php?pagename=publication&pub=$matches[1]','top' );
}
Make sure to flush your permalinks after you add this by going to your WP admin, Settings > Permalinks and clicking 'Save Changes'.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "php, wordpress, permalinks"
}
|
Tracking dissemination of open access publications
I recently published a paper in an open access journal, allowing me to archive the post-print in other platforms, e.g. in my university's repository, or on ResearchGate.
I wonder however whether I _should_ attach the PDF directly on these secondary platforms, or just share a link to the journal's website, where the paper is anyway freely available.
Won't multiplying the sources of the pdf make it more difficult to reflect the actual number of views or downloads of the paper? Although citations should anyway be counted properly, I assume number of reads/downloads also might influence potential readers in finding relevant papers, and I'm not sure if e.g. ResearchGate synchronizes counting with other platforms.
|
I think this is only a concern if you believe that people choose what to read based on how "popular" it is in terms of reads on sites such as ResearchGate. I really hope that this is not the case.... so long as it's citations that you are tracking (which is itself a flawed metric, but less so, and is one that is commonly used), then it doesn't matter where the paper is hosted - what matters is keeping it as accessible as possible.
|
stackexchange-academia
|
{
"answer_score": 1,
"question_score": 6,
"tags": "publications, journals, open access"
}
|
Fixed Windows 7 with BCDBoot and MBR. I now get ACTIVATE: Error Code 0xc0004e003
I fixed the PC running Windows 7, using "bcdboot C:\Windows", and the computer software thinks I reinstalled the software? Says I have 3 days to Activate now I get Error Code 0xc0004e003. It took me a couple days to fix this mess. The software has been in this PC since 2009. Any suggestions?
Anybody have suggestions, I would appreciate the help. Is it time to leave this whole product behind? Oh, It is a Dell OEM.
|
It looks like your Windows copy is activated using MBR patch.
If it is genuine, consider flashing BIOS with correct SLIC table.
|
stackexchange-superuser
|
{
"answer_score": 0,
"question_score": 0,
"tags": "windows 7, software activation"
}
|
Add nib into UIScrollView
I am having troubles with the UIScrollView.
I have a file called: ExhibitionViewController.h / m and a nib ExhibitionView.xib in which I have placed a UIScrollView.
I have a file called ExhibitionSubViewController.h / .m and ExhibitionSubView.xib which I would like to display within that UIScrollView and I cannot seem to get it to work.
What would be the correct code to do that?
|
The iPhone programming model is "one view controller per screen", which takes some getting used to. You should load your subview with [NSBundle loadNibNamed:] and add it manually to your UIScrollView with addSubview. All of your code for managing those objects should live in ExhibitionViewController.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 4,
"tags": "iphone"
}
|
The new profile page badge UI cuts off on long tag names
If you go to my profile on SFF you'll see the following*:

|
stackexchange-meta
|
{
"answer_score": 4,
"question_score": 9,
"tags": "bug, status completed, design, badges, profile page"
}
|
Enviar variable desde el controlador a una vista
Estoy enviando una variable desde mi controlador a una vista de la siguiente manera :
> $this->load->view('pagar_en_linea', $valorPagar) en Codeigneiter;
Pero al recibirla y mandarla a imprimir me genera este error:
> Undefined variable $valorPagar
He buscando en internet y esa es la manera correcta de enviar variables
|
la solución es que desde la vista se debe enviar un array
|
stackexchange-es_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php"
}
|
how to rotate one object about another object's edge?
observe the image
;
public void storeAsset(String key, Object asset) {
assets.put(key, asset);
}
public <T> T getAsset(String key, Class<T> clazz) {
return (T) assets.get(key);
}
public void freeAsset(String key) {
assets.remove(key);
}
}
That generic getter is optional, you could also do the casts yourself, but like this it's more convenient. Of course there is error handling and everything missing, but that's how a very very basic AssetManager might work.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, android, libgdx, asset management"
}
|
How to detect browser back button click in Angular2
I want to clear **Localstorage** data on browser back button click. But how to detect **browser back button** click in **Angular2**. I am not getting any exact solution. Can anyone please tell me how to do this?
|
You can use `ngOnDestroy` method of components which is part of component life cycle.
This component is called whenever component is destroyed.
What you can do is create a service where your logic to clean localstorage will be written.
Call this service on `ngOnDestroy` method of your component.
remember to `import {OnDestroy} from '@angular/core'` and add `OnDestroy` to the implements section of your Class definition
Hope this helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "angular, browser, back button"
}
|
using Multiple using statements to dispose DataSet and DataTables
Can you please explain what is happening here?
using(DataSet ds = GetDataSet()) // will this get disposed? if yes (when?)
{
using(DataTable dt = ds.Tables[0]) /* in this line is ds available for dt? i found some issue with this kind of statement. dt gets null after this line */
{
// i know that ds is available here.
//some code
}
}
|
using(DataSet ds = GetDataSet()){
using(DataTable dt = ds.Tables[0])
// dt will be NULL if there are no tables in ds
{
// both dt & ds will be available here
}// dt will get disposed
}// ds will be disposed at this point...
The equivalent code for this is:
try{
DataSet ds = GetDataSet();
try{
DataTable dt = ds.Tables[0];
// dt will not be null if there are any tables in ds
// Both ds & dt available here...
}
finally{
dt.Dispose();
}
}
finally{
ds.Dispose();
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, dataset, disposing"
}
|
Python: How to random shuffle a list where each variable will end up in a new place
I would like to random shuffle a list so that each variable in the list when shuffled gets put in a new place in the list.
What I am currently doing:
list = ['a', 'b','c', 'd'];
random.shuffle(list)
list
['c','b','d','a']
With this method I shuffle the list but it is still possible to have a variable end up in the same place in this case 'b'.
My desired output
completely shuffled list
['c','a','d','b']
I appreciate any help. I am new to python but please let me know if any further information is needed.
|
Something like this should do what you want:
import random
import copy
def super_shuffle(lst):
new_lst = copy.copy(lst)
random.shuffle(new_lst)
for old, new in zip(lst, new_lst):
if old == new:
return super_shuffle(lst)
return new_lst
Example:
In [16]: super_shuffle(['a', 'b', 'c'])
Out[16]: ['b', 'c', 'a']
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 6,
"tags": "python, random, shuffle"
}
|
ACL based on VLAN
I am trying to learn ACL on hp 2530. When I use : **sh access-list** command the following is displayed:
ACL-NAME-STR Show detailed information for an ACL.
config Show all configured ACLs on the switch with the CLI
syntax used to create them.
ports Show ACLs applied to the specified ports.
radius Show ACLs applied via RADIUS.
resources Show ACL resource usage and availability.
vlan Show ACLs applied to the specified VLAN.
I have no idea how to configure vlan based ACL. Someone please Help.
|
First you define the rule, e.g. deny 192.168.1.1 DNS access anywhere, permit everything else: ` ip access-list extended "rulename" 10 deny udp 192.168.1.1/32 any eq 53 log 9999 permit ip any any exit`
Then you apply the rule to the VLAN 99: ` vlan 99 ip access-group "rulename"`
Edit: There's an implicit last entry `deny ip any any` that will drop all remaining traffic in the VLAN if not explicitly overridden. Since you're still familiarizing yourself with ACLs I wanted to make a point of this.
|
stackexchange-networkengineering
|
{
"answer_score": 5,
"question_score": 2,
"tags": "vlan, acl, hp"
}
|
Fixed size of div
I have added a scroll bar to my div tag. However, the size of this window dynamically grow according to the text size, and therefore the scroll bar is disabled.
<div style="overflow:scroll;width: 650px;font-size: 14px;margin-top: 50px;display:None" id="loader" class="tr-bg tr-internal-frame" onclick='$("#workNow").toggle()'></div>
I guess that i need to fix the size of the window, and then the scroll bar will be enabled. Is it right? If so, how can i do that?
|
You need to give the `div` a fixed `height`. Try this:
<div style="overflow:scroll;width: 650px; height:100px; font-size: 14px;margin-top: 50px;display:None" id="loader" class="tr-bg tr-internal-frame" onclick='$("#workNow").toggle()'></div>
Here is a Demo for the same.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "html, scroll, fixed"
}
|
Gauss sum over Legendre symbols combining residue and non-residue parts
I’m reading Davenport’s Multiplicative Number Theory and I’m currently in the second chapter, the subject of which is calculating the following sum:
$$ G= \sum_{n=1}^{q-1} \Bigr(\frac{n}{q}\Bigr )e_q(n) $$
Where $q$ is an odd prime, and $e_q(n)=e^{2\pi in/q}$. On page 13, he does the following manipulation:
$$ G=\sum_{R \text{ q.r.}} e_q(R)-\sum_{N\text{ q.n.r.}} e_q(N)=1+2\sum_{R \text{ q.r.}} e_q(R) $$
Where $r$ is a quadratic residue mod $q$ and $n$ is a quadratic non-residue mod $q$.
While I understand the first separation from one sum to two sums based on whether or not we have a quadratic residue, I cannot understand how we merge this back into one sum involving only quadratic residues, nor do I understand where the mysterious $1$ comes from.
Can anyone provide a proof of this equality?
|
In your notation, $$\sum_{R\text{ q.r.}}e_q(R)+\sum_{N\text{ q.n.r.}}e_q(N)=\sum_{n=1}^{q-1}e_q(n)=-1$$ (the last equality is "a sum of roots of unity", or "a sum of a geometric progression").
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "analytic number theory, roots of unity, quadratic residues, gauss sums"
}
|
General form of integral possibly related to arctan function?
I am dealing with an integral which has the form:
$$ I = \int_{-\gamma}^{+\gamma} \frac{\alpha}{\left(\beta^2 + \alpha^2 z^2 \right)^{\frac{n}{2}}} \,\text{d}z, $$ with real constants $\alpha$ and $\beta$, and integer $n \geq 2$.
I think I am right in saying that for $n=2$, this integral becomes
$$ I = \frac{1}{\beta}\int_{-\gamma}^{+\gamma} \text{d}\arctan \left(\frac{\alpha}{\beta}z \right). $$
But I'm wondering whether there is a general result for any $n$?
Appreciate your thoughts.
|
Let $$ z=\frac{\beta}{\alpha}\tan x $$ and then $$ I = \int_{-\gamma}^{+\gamma} \frac{\alpha}{\left(\beta^2 + \alpha^2 z^2 \right)^{\frac{n}{2}}} \,\text{d}z=\frac{2}{\beta^{n-1}}\int_0^{\arctan(\frac{\alpha\gamma}{\beta})}\cos^{n-2}xdx.\tag1 $$ Now using $\cos x=\frac12(e^{ix}+e^{-ix})$, you have $$ \int\cos^{n-2}xdx=\int\left(\frac{e^{ix}+e^{-ix}}{2}\right)^{n-2}dx=\frac{1}{2^{n-2}}\int \sum_{k=0}^{n-2}\binom{n-2}{k}e^{i(n-2k-2)x}dx=... $$ to get the closed form of (1) which is not very short.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 3,
"tags": "real analysis, calculus, integration, derivatives, trigonometric integrals"
}
|
make falling block not drop item if unable to be placed
I want to make falling block not drop item if unable to be placed. If I remember correctly there is a tag for it. I might be wrong if so tell me thx Basically some falling blocks that when summoned will not become items when not able to be placed.
|
DropItem:0
Okay I found i... extra letters
|
stackexchange-gaming
|
{
"answer_score": 1,
"question_score": -1,
"tags": "minecraft java edition, minecraft commands"
}
|
How to store sea water as a souvenir for years
I recently visited the Aral sea and filled a plastic bottle with sea water. I want to keep it as a souvenir for years to come but I don't know what would be the best container. Ideally I would seal it as I don't plan to open it ever again.
Any ideas on what would be the best containers?
|
Seal it in a glass container with opening melted shut, or at least tightly stoppered and wax covered. A Florence flask looks nice and the neck can be melted by a propane torch. You can buy flasks with stoppers, but ground-glass joints are not quite airtight unless a membrane such as PTFE (Teflon©) tape is used in the joint.
**N.B.** Leave air space in the container or thermal expansion will shatter it.
|
stackexchange-lifehacks
|
{
"answer_score": 2,
"question_score": 0,
"tags": "water, storage"
}
|
Открытие файла в той же директории где файл.go
Есть основной пакет:
package main
import "testXML/dd"
func main() {
dd.SSS()
}
Он подключается к пакету
ddfunc SSS() {
bs, err := ioutil.ReadFile("dd/ff.conf")
if err != nil {
fmt.Println("--->", err)
}
str := string(bs)
fmt.Println("::::::::::::::", str)
}
Но можно ли сделать, что бы файл читался без префикса папки, т.е. просто "ff.conf" ?
|
**ioutil.ReadFile(filename)** использует абсолютный путь. Отсюда, запуск программы даст успешное открытие и чтение файла в локальной директории при условии наличия файла с таким именем.
Ошибки могут вылезать, если использовать разные IDE типа _IntelliJ IDEA_ которая при запуске компилирует временный исполняемый файл в `/tmp/рандомныйхашпроекта`.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "файлы, golang"
}
|
Introduction to proofs with a fair amount of hand-holding?
Lately I've gotten a friend of mine interested in mathematics. He has no college-level education to speak of, but is well employed as a software engineer. So I feel he's competent to learn this stuff on his own.
He asked me recently if there was a 'mathematical' version of "The Little Schemer".
The point being, if there was an "introduction to proofs" book which took a more hand-holding approach. He's also expressed fondness for the metamath project.
However, metamath's proofs are obviously a bit _too_ low level to learn anything serious.
At one point in our conversation, I mentioned the dependently typed programming language Agda, but I felt it's not quite as helpful until he at least gets some experience with Haskell (for which the target audience of Agda is Haskell programmers, hence the similarity in syntax).
Anyone have any good suggestions on a book?
|
This isn't exactly on point, but since you mentioned the possibility that your friend might be learning Haskell, you could try "The Haskell Road to Logic, Maths, and Programming". Pretty good book, maybe a natural transition for your friend.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 3,
"tags": "reference request, soft question, proof writing"
}
|
react typescript image resizing and download
I was implement image resize and image download. But I see an error in 73line..
<
I see an reference, but I can't solve the problem...
|
To solve your issue, change the declaration of the `cardRef` to:
const cardRef = useRef<HTMLDivElement | null>(null);
You should also remove the casting (`const card = cardRef.current as any;`) and modify it as follows:
const onDownloadBtn = () => {
if(cardRef.current){
const card = cardRef.current;
domtoimage.toBlob(card).then((blob) => {
saveAs(blob, "card.png");
});
}
};
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "reactjs, typescript"
}
|
Does the set of all limit points respect closure
Does the following equation hold? $$A'=[\operatorname{cl}(A)]'$$ where $A'$ is a set of all limit points of $A$ and $\operatorname{cl}(A)$ is closure of $A$.
I am having trouble finding a counterexample
|
Since, $\bar{A}'=\left(A\cup A'\right)'=A'\cup (A')'=A'$ as $A'$ is closed.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": -1,
"tags": "real analysis"
}
|
The Uri scheme is too long – AppSettings.config
I received error here appConfig.Load(file); Do you know what should I do?
string file = File.ReadAllText(baseDirectory + "\\test.config");
XmlDocument appConfig = new XmlDocument();
appConfig.Load(file);
AppSeting config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
|
You should put the uri as the parameter to the Load() method. You're passing the content of the file instead of the uri.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "c#"
}
|
Show searched value in exception when nothing is found with First()
When doing `First()` on an `IEnumerable`, the default exception I'm getting is `Sequence contains no matching element` without the searched value. I need to show the searched `Id`, Is there a way to show the `Id` while I'm in the catch block?
public static CustomItem FirstCustom(this IEnumerable<CustomItem> source, Func<CustomItem, bool> predicate)
{
try
{
return source.First(predicate);
}
catch (Exception e)
{
throw new Exception($"I need to show the searched `Id` here. How to do this? {e.Message}");
}
}
public class CustomItem
{
public int Id { get; set; }
}
|
The simple answer: you _can't do this_. Since `predicate` can be an _arbitrary_ function, e.g.
(CustomeItem c) => 1 == 2
the `predicate` may not use any `Id` at all. If you want to search for an `Id` and show it up if it's not found:
public static CustomItem FirstCustom(this IEnumerable<CustomItem> source, int id) {
if (null == source)
throw new ArgumentNullException("source"); // validate public methods' arguments
CustomItem result = source.FirstOrDefault(item => item.Id == id);
if (null == result)
throw new ArgumentException($"Id {id} has not been found!", "id");
else
return result;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, linq"
}
|
How to exit or quit my Windows Phone 8 app programmatically?
I am developing a Windows Phone 8 application.
1. How can I exit or quit programmatically (through code) from my Windows Phone 8 app?
2. What are the various ways in which I can programmatically (through code) exit or quit from my Windows Phone 8 app?
|
In WP8 there's a new API which lets you terminate the application:
Application.Current.Terminate();
By calling the method your app will immediatelly terminate. However the `Application_Closing` event won't be called, and `IsolatedStorageSettings.ApplicationSettings` dictionary won't be automatically persisted.
So if you have data hanging around in IsolatedStorageSettings.ApplicationSettings that you don't want to lose then it's wise to save it:
IsolatedStorageSettings.ApplicationSettings.Save();
Application.Current.Terminate();
Also the method should not be misused. See < for more info for legitimate use cases.
|
stackexchange-stackoverflow
|
{
"answer_score": 33,
"question_score": 9,
"tags": "windows phone 8"
}
|
Create a measure which show your turnover per year
I just begin the SSAS multidimension and i am lost.
I want to create a measure (in SSAS multidimensional) which return the turnover per each Year.
I have 2 tables in my cube : 1 dim calendar which contains the attribute Year and 1 fact table which contains the turnover
(So my measure "turnover per year" will be the same for 01 december 2010 and for 01 June 2010).
|
If you have a Calendar hierarchy you can set to return the current year level value. For example:
(
Ancestor(
[Date].[Calandar].CurrentMember,
[Date].[Calandar].[Year]
),
[Measures].[Turnover]
)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "multidimensional array, filter, ssas, mdx"
}
|
bash commandline jslint wont scan file and wont give an error
Why wont my jslint scan a file in bash?
On a fresh install of kubuntu
I installed node
sudo apt-get install node
Then
sudo apt-get install npm
Then
sudo npm install jslint -g
All installs worked well with no errors
my issue comes when I type: I use tab to auto complete
a@a:~/Desktop$ jslint test.js
a@a:~/Desktop$
it does nothing just creates a new line why? the file clearly has errors
PS proof it all installed
a@a:~/Desktop$ nodejs -v
v0.10.25
a@a:~/Desktop$ npm -v
1.3.10
|
The issue was that I had installed node and not nodejs as they are two different thing
sudo apt-get install nodejs
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "node.js, jslint"
}
|
How to create a MySQL Database with a value of +1 if a DB with a matching name exists?
I'm working on a bash script and need a bit of help, this is what I currently have.
mysql -e "create database if not exists ${UN}_${SQLBASE}"
mysql -Be "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE ROUTINE ON \`"$UN"\\_"$SQLBASE"\`.* TO '"$UN"_"$SQLUSER"'@'localhost' IDENTIFIED BY '$SQLPASS';FLUSH PRIVILEGES"
Pretty much, I need to know how I can create a database with the name cpanel_db1, if that exists then automatically move up to the number up. ex cpanel_db2.
|
could be done something like this:
username="usernamedb"
password="passworddb"
database="cpanel_db"
databases=$(mysql -u $username -p$password -Bse 'show databases'|grep $database)
max=1
if [ -z "$databases" ];then
mysql -u $username -p$password -Bse "create database ${database}$max"
else
for cdatabase in $databases
do
cdatabasenumber=$(echo $cdatabase|awk -F"db" '{print $2}')
if [ $cdatabasenumber -gt $max ]; then
max=$cdatabasenumber
fi
done
let max++
mysql -u $username -p$password -Bse "create database ${database}$max"
fi
~ ~
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "mysql, bash, ssh, cpanel"
}
|
What is $P(\min\{X, Y\} = 1)$?
If $y=1,2,3$ and $x=0,1,2$ where $P(X=x, Y=y) = k(2x+3y)$
I need to find $P(\min\\{X, Y\\} = 1)$.
I thought I need to use that the CMF of the minimum is $1-P(X)$, and maybe to find k by doing derivative on the equation and to sum it up to 1? would love any direction on this.
|
Given that $P(X=x, Y=y) = k(2x+3y)$
$\sum_{(x,y)}P(X=x,Y=y) = k(0+3) +k(2 + 3) + k(4 +3) + k(0+6) + k(2+6) + k(4+6) + k(0+9) + k(2+9) + k(4+9) = 72k = 1$
Hence $k = \frac{1}{72}$
Now, $P(\min(X,Y)=1) = P(X=1,Y=2,3) + P(X=2, Y=1)$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "probability, probability distributions"
}
|
problems running CuCumber scripts with FireFox 8.0.1
Until FireFox 3.6 I had no problems running my cucumber scripts. The recent upgrade to 8.0.1 is giving me problems. When starting the browser a prompt is shown in the top asking me if I want to share browser statistics such as load times. I tried to disable this by adding the following to my profile in the .env
profile["toolkit.telemetry.prompted"] = "false"
The prompt is gone, however my browser stays blank. The setting in the config is changed to false but the datatype has changed from boolean to string. Is there a way to bypass this or set this thing correctly? Downgrading is only a last resort.
|
You are setting it to equal a string value, so it does make sense that the datatype might change when you do it that way.
Have you tried setting it without the quotes?
profile["toolkit.telemetry.prompted"] = false
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "firefox, cucumber, webdriver, watir, watir webdriver"
}
|
Monotouch: PopToViewController and then pushing one causes views clashing on iPod/iPhone
I need to pop 3 controllers at once so I use `PopToViewController` method from Navigation controller and then I push a new one into it. It results in a views overlapping. Both controllers, to what it had been popped and what is being pushed are `DialogViewControllers`. Besides this happens only on iPod/iPhone, on iPad it works correctly.
The code is just simple as:
NavigationController.PopToViewController(NavigationController.ViewControllers[NavigationController.ViewControllers.Count() - 1 - numberOfViews], animated);
NavigationController.PushViewController(viewController);
Any help?
|
The problem was solved by setting animated parameter to false for iPhone.
NavigationController.PopToViewController(NavigationController.ViewControllers[NavigationController.ViewControllers.Count() - 1 - numberOfViews], false);
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "iphone, ios, xamarin.ios, monotouch.dialog"
}
|
Inverse Fourier transform gives wrong results
If I have a polynomial:
$a(x)= 2 + 5x -3x^2 +x^3$
The Fourier transform for N=4 is the evaluation of this polynomial in ${\omega}^0,{\omega}^1,{\omega}^2,{\omega}^3$ with ${\omega}^h = \cos(2\pi h/4) + i\sin(2\pi h/4) $. So:
${\omega}^0 = 1$
${\omega}^1 = i$
${\omega}^2 = -1$
${\omega}^3 = -i$
I evaluated the polynomial in these 4 points, and the result is $5, 5+4i, 7, 5-4i$.
Now I want to get the inverse transform, and according to the theory it's enough that I compute again the FFT on the resulting vector, but with ${\omega}^{-h}$ instead of ${\omega}^{h}$, and then I should divide the result for N=4.
I get:
${\omega}^0 = 1$
${\omega}^{-1} = -i$
${\omega}^{-2} = -1$
${\omega}^{-3} = i$
For example if I evaluate the resulting polynomial in ${\omega}^0$ I get 22/4, but the result should be 2. Where's the mistake?
|
Sign error: $a(-1)=-7$. Then the inverse transform gives the correct result $8/4$ for the constant coefficient.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "fourier analysis, inverse"
}
|
Dirichlet series for product of Mobius and divisor function
Let $\mu$ be Mobius function, defined by $\mu(n)=\begin{cases} (-1)^{\omega(n)}, \text{ if } n \text { is square free}\\\ 0, \text{ otherwise} \end{cases}$, where $\omega(n)$ is the number of prime factors of $n$. Also, consider the $k$-th divisor function $\tau_k(n)$, defined as the number of representations of $n$ as product of $k$ integers, $\tau_k(n)=\sum_{d_1d_2\dots d_k=n}1$.
Consider the generating Dirichlet series for pointwise product $\mu(n)\tau_k(n)$, $$ D(s)=\sum_{n=1}^\infty \frac{\mu(n)\tau_k(n)}{n^s}. $$ I am interested in expressing this series in terms of Riemann zeta function $\zeta(s)=\sum_{n=1}^\infty\frac{1}{n^s}$. Using the Euler product for $D(s)$ I get \begin{align*} D(s)&=\prod_{p} \left( 1+\sum_{i=1}^\infty \frac{\mu(p^i)\tau_k(p^i)}{p^{is}} \right)\\\ &=\prod_{p} \left( 1-\frac{k}{p^s} \right ), \end{align*} but then I don't know how to connect the expression I got with $\zeta(s)$.
|
Twists by completely multiplicative functions work better $$\zeta(s)^k= \sum_{n=1}^\infty \tau_k(n) n^{-s}, \qquad \frac{\zeta(2s)}{\zeta(s)} = \sum_{n=1}^\infty s(n) n^{-s}$$ where $s(n)= \prod_{p^m \| n} (-1)^m$ is completely multiplicative so $$\frac{\zeta(2s)^k}{\zeta(s)^k} = \sum_{n=1}^\infty s(n) \tau_k(n)n^{-s}$$
* * *
Now $$ T_k(s)=\sum_{n=1}^\infty \mu(n) \tau_k(n)n^{-s}= \prod_p (1-k p^{-s})= \frac{\zeta(2s)^k}{\zeta(s)^k}\prod_p (1-k p^{-s})(1+p^{-s})^k \\\= \frac{\zeta(2s)^k}{\zeta(s)^k} U_k(s)$$ where $$U_k(s) = \prod_p(1+\sum_{l=2}^{k+1} p^{-sl} ({k \choose l}-k{k-1 \choose l})$$ is analytic for $\Re(s) > 1/2$.
* * *
As $$ \log T_k(s) = -\sum_{m=1}^\infty \log\zeta(sm)(\sum_{d | m} \mu(d)\frac{k^{m/ d}}{m/d})$$ you can find the analytic continuation of $T_k$ and its singularities and show it is has natural boundary at $\Re(s) = 0$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "number theory"
}
|
How many ways are there to place these books on the shelves?
You are given 5 books and 7 bookshelves. How many ways are there to place these books on the shelves? (The order on the shelves matters.)
I want to say $7^5$ since there are 7 possible shelves and five different options to select from books that will be placed.
Could some one explain why my answer is wrong, and what the right answer is?
|
Suppose you chose Bookshelf 1 five times. That would be just one of the possibilities you've enumerated. But there are 5! = 120 ways to arrange those 5 books on the first bookshelf.
One way to do it: Consider the different shelves as 6 "boundaries" to insert between your books. Thus there are 11 things to order, but 6 of them are equivalent. So there are $\frac{11!}{6!}$ ways.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "permutations"
}
|
Find out the number of connections to tomcat server
I have a Java/Java EE web application deployed on Tomcat Server 5.5.17. I want to know the number of clients which are connected to the server. How can we find it out?
|
Most reliable way would be to search for `ip.addr.of.srv:port` in `netstat`. Here's the Windows based example (sorry, no Linux guru here ;) )
netstat -np tcp | find "12.34.56.78:80"
Replace `12.34.56.78` by IP where Tomcat listens on and `80` by port where Tomcat listens on.
This is actually not a programming problem, hence I voted to migrate this question to serverfault.com.
|
stackexchange-stackoverflow
|
{
"answer_score": 21,
"question_score": 11,
"tags": "java, sql server, tomcat5.5"
}
|
Word: an inability to understand a spoken language
_Illiterate_ is used to describe someone who cannot read. I am looking for a word to describe someone who cannot understand a spoken language.
> David was [unable to understand French] {People are speaking french around him}
>
> Jean's friends were laughing about a joke, but David was [unable to understand French] and didn't know what they were laughing about
Not-fluent is the obvious compound, but it is rather inelegant.
|
I have two more proposals which come close to what you're looking for:
* A **monolingual** is someone who only speaks one language.
* An **anglophobe** is someone who is afraid of English. (This is a neologism)
|
stackexchange-english
|
{
"answer_score": 0,
"question_score": 4,
"tags": "single word requests"
}
|
NaN returned when attempting to parse to float
I've got the following jQuery code:
var total = parseFloat($(".hidden-total").text());
For some reason or other, total is being returned as NaN.
Could anyone suggest why?
|
what is inside of hidden-total? and how many of those are there? .text() returns the concatenated string of all of the hidden-total class and other element inside of it. so if you have more than 1 it probably won't work
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, jquery, html"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.