INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Accept either type
In Visual Basic 2010, I would like a function that accepts 2 possible types.
So for example, something like this:
Public Function test(ByVal value As Int32 Or Int64) As String
I know that I can just use this:
Public Function test(ByVal value) As String
And it will accept either type. But I am just wondering if it is possible.
|
Sure, method overloading is possible in VB.NET. Just give both methods the same name but different argument lists:
Public Function test(ByVal value As Int32) As String
Return test(CLng(value))
End If
Public Function test(ByVal value As Int64) As String
' Do something useful
End If
All the first function does is to convert the argument to an Int64 (`Long` in VB.NET) and call the second function. You can replace `CLng` with `Convert.ToInt64`, if you prefer the CLI terminology.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "vb.net, visual studio 2010"
}
|
At what point does scalability become an issue for a Rails application deployed on Heroku?
Ruby on Rails has largely been faulted for it's lack of scalability options, and the alternative is generally to migrate to some form of a Java webapp or something similar. But all of the concerns seem to be very arbitrary at best, in a way.
Are there any concrete numbers for when a certain application needs to be rewritten in a different language? Heroku provides various scaling options with the numbers of dynos available to the app, but at what point will diminishing returns, if any, be evident? Or at what point will the cost of having so many dynos outweigh the costs of simply writing a new app?
How many active concurrent users can I expect to be able to support without suffering performance issues on the basic free hosting plan at Heroku?
|
The "Rails doesn't scale" myth simply won't die ...
Quoting Twitter's lead architect:
> The performance boosts associated with a “faster” language would give us a 10-20% improvement, but thanks to architectural changes that Ruby and Rails happily accommodated, Twitter is 10000% faster.
I can't give you a fixed number, but it is almost absolutly guaranteed that you run into database or architectural bottlenecks long long before Ruby or Rails are starting to become bottlenecks.
Teflon Ted has created a nice collection of blog posts regarding this topic.
|
stackexchange-stackoverflow
|
{
"answer_score": 20,
"question_score": 11,
"tags": "ruby on rails, heroku, scalability"
}
|
filtered results with s3cmd get
I'm using cmd tool for AWS S3 called s3cmd. I'm trying 'get' set of folders filtered by front part of name directory name like '/192.168.*/'. Basically I have S3 bucket with a lot of directories and I just need couple of them that start with particular string. Here is what I have so far. Will be grateful for any kind of help :) Thank you!
s3cmd get --recursive --include '192.168*' s3://mys3bucket/logfiles/
Code above pulls down all the directories from /logfiles/. :(
|
s3cmd get --recursive s3://mys3bucket/logfiles/192.168
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "regex, amazon s3, get, s3cmd, buckets"
}
|
representing total partial participation in sql / mysql from er diagrams
In an ER diagram, you can represent participation by normal line / thick line from an entity to a relationship.
*How do you represent participation when you make an SQL table?
*can you have strong entities that require total participation in a relationship?
*Can an entity (or table, once it's been converted to sql table) be in total participation to multiple relationships? Again how would that be represented when you start making tables in MYSQL?
Apologies for noob questions. I am only student.
|
For example if you have this two tables:
_SUPPLIER( **CodS** , NameS, DeptS);_
_PRODUCT( **CodP** , **CodS** , NameP, Qta);_
Where the bold words rappresented the primary keys on the tables, you connected this tables through attribute **CodS** in _PRODUCT_.
Example for creating table:
CREATE TABLE SUPPLIER (
CodS INT NOT NULL,
NameS VARCHAR(20) NOT NULL,
DeptS VARCHAR(20) NOT NULL,
PRIMARY KEY(CodS) );
CREATE TABLE PRODUCT (
CodS INT NOT NULL,
CodP INT NOT NULL,
NameP VARCHAR(20) NOT NULL,
Qta INT,
PRIMARY KEY(CodS, CodP) );
I hope I've been useful
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "mysql, sql, entity relationship, partial, diagrams"
}
|
Distributed "Spring Integration" contexts
Hi The spring control bus resides in one context (or am i wrong ?) A spring integration context would expose and consume services using channels and adaptors. So in a distributed environment what is the best practise to take advantage of integration of "spring integration". In the sense that there are several peer nodes running each within their own context what is the suggested methodology of passing messages ? (jms ; then with which open source provider). In short how to leverage spring-integration as an Enterprise service bus and what are the best practises surrounding them.
Thanks in advance
|
Depends on the requirements, but you can use any transport mechanism you like. If the bus can be small you might like to work with http adapters or even lower like tcp or udp. If you need to scale you might best look into the RabbitMQ integration through spring-amqp.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "esb, spring integration"
}
|
AngularJS $http.post() to another port at the same machine
I have an AngularJS app hosted in nginx server at localhost and Rest service hosted in Weblogic at localhost:7001.
I'm trying to do this post inside of Angular part:
$http.post('localhost:7001/testApp/user/login', { username: username, password: password })
.success(function (response) {
callback(response);
});
And this is the error I'm getting:
XMLHttpRequest cannot load localhost:7001/testApp/user/login. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
|
You should specify the protocol scheme (`http`, `https`, ...) in the URL:
$http.post(' { username: username, password: password })
.success(function (response) {
callback(response);
});
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 4,
"tags": "angularjs, rest, http, post, nginx"
}
|
Entity Framework 6. Извлечение связанныx данных
привет есть запрос на выборку
var t = context.Group.Include(g => g.Items);
и все работает но необходимо еще в Items включить другие данные из другой таблицы
типа такова
var t = context.Group.Include(g => g.Items.Include(o => o.Data));
|
Установи package: <
Затем используй:
var t = context.Group.Include(g => g.Items).ThenInclude(o => o.Data);
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": -4,
"tags": "c#, entity framework, linq"
}
|
Sorting a dictionary by values
Consider a dictionary 'a' if:
a = {6:32 , 1:15 , 3:45 , 2:12 , 5:46, 4:99}
I want to sort this dict by values with respect to its keys, such as this:
a = {2:12 , 1:15 , 6:32 , 3:45 , 5:46 , 4:99}
I wanted to know if it's possible without importing any modules.
Thanks
|
A dictionary has no sort order. But you can sort the keys and retrieve them in order. For example:
for k in sorted(a, key=lambda k: a[k]):
print k, a[k]
The "key" `lambda` function specifies by which value to sort. In the example it sorts by the key's value in the dictionary.
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 0,
"tags": "python, dictionary"
}
|
Using the printlist/1 predicate in Prolog to sum up all numbers in a list
I am trying to use the `printlist/1` predicate to sum up all the numbers in a list but kind of got stuck.... tried to come up with the code for this but I keep getting `false`.
Here is what I've come up with:
printlist([]).
printlist([H|T], Totalsum) :-
print (H+Totalsum),
nl,
printlist(T, Totalsum).
I know it's wrong and it's probably the last part. Any help is appreciated!
I query it this way:
?- printlist([1,2,3]).
false.
|
As Paulo already said, you are defining two predicates here, which is incorrect.
Here is the solution:
printlist([], 0).
printlist([H|T], Sum) :-
printlist(T, Subsum),
Sum is Subsum + H.
Sample query:
?- printlist([1,2,3,5], L).
L = 11.
@ Paulo requested), a tail recursive version:
printlist(L, Sum) :-
sumac(L, 0, Sum).
sumac([], Acc, Acc).
sumac([H|T], Acc, Sum) :-
Nacc is Acc + H,
sumac(T, Nacc, Sum).
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "list, prolog"
}
|
How to out put a nest block in cms?
like this
<block class="Magefan\Blog\Block\Post\PostList\Item" name="blog.posts.list.item" template="post/list/item.phtml">
<block class="Magefan\Blog\Block\Post\Info" name="blog.post.info" template="post/info.phtml" />
<action method="setPostInfoBlockName">
<argument name="name" xsi:type="string">blog.post.info</argument>
</action>
</block>
|
Create a layout file in this path:
Magefan/Blog/view/base/layout/magefan_blog_cms_postlist.xml
And like any other layout define all your blocks and nested blocks (as you have posted in your question).
> Note: your template files should be in view/base
And then in CMS page or block use it like:
{{layout handle="magefan_blog_cms_postlist"}}
There is no way to define nested blocks in CMS directly. You need to use your custom layout and layout handle.
|
stackexchange-magento
|
{
"answer_score": 2,
"question_score": 2,
"tags": "magento2, blocks, cms"
}
|
Combine and Redirecting stderr and stdin - Difference in Methods BASH
What is the real difference of the **new** and the **old** methods of how we combine and redirect stderr and stdin?
For example:
* "The Old Way": `2>&1`
* "The New Way": `&>`
Down to the core are there any differences in these implementations? Are their any advantages to either?
|
The difference is that the "new way" is a bashism. It's not POSIX.
My advice is avoid bashisms & write POSIX shell as best as you can. And least then you stand a chance of it working on other (faster) shell implementations.
* Related tool checkbashisms
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "bash, shell"
}
|
sql left join returns
I am trying to run a left join on 2 tables. I do not have a group by and the only where condition i have is on the second table. But, the returned rows are less than the first table. isn't the left join suppose to bring all the data from the first table? Here is my SQL:
select *
from tbl_a A left join tbl_b B
ON
A.Cnumber=B.Cnumber
and A.CDNUmber=B.CDNumber
and abs(A.duration - B.Duration)<2
and substr(A.text,1,3)||substr(A.text,5,8)||substr(A.text,9,2)=substr(B.text,1,8)
where B.fixed = 'b580'
There are 140,000 records in table A but the result returned is less than 100,000 records. What is the problem and how can I solve it?
|
As soon as you put a condition in the `WHERE` clause that references the right table and doesn't accommodate the `NULL`s that will be produced when the join is unsuccessful, you've transformed it (effectively) back into an `INNER JOIN`.
Try:
where B.fixed = 'b580' OR B.fixed IS NULL
Or add this condition to the `ON` clause for the `JOIN`.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "sql, left join, conditional statements, records"
}
|
Is there an easy way to abort with status code 429?
Trying to abort from a "before_request" handler (in Flask) with that code gives the following error: `LookupError: no exception for 429`. Is there a way to fix this?
Here's the code that triggers the error:
key = "ip:{}:account-requests".format(request.remote_addr)
# Determine how many requests have been made in the past day
# by this API.
requests_made = r.get(key) or 0
if requests_made >= max_requests:
abort(429) #HTTP Too Many Requests
|
you can do like this in Flask
if requests_made >= max_requests:
return '429 error', 429
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "python, flask"
}
|
Dynamic(ExpandoObject) vs static type(Model) in asp.net mvc
## Dynamic vs static type in asp.net mvc
Is car better than motorcycle? It all depends on the scenario you are using it. Without knowing the scenario it is not possible to make that determination!
Is Dynamic typing better than static typing for certain problems/situations.
In this case
I need to show the view when OnException() method of BaseController is called. This is one time thing and i show the error page once instead of yellow screen of death.
Suppose i need to show ErrorMessage and Stacktrace on the view. As this is one time thing is it not better to use dynamic than create a error model for this.
dynamic obj = new ExpandoObject();
obj.ErrorMessage = "message";
obj.StackTrace = "bla bla bal";
return to view.
What is the best practice. Thanks for the reply.
|
"Is Dynamic typing better than static typing for certain problems/situations."
Of course.
"Suppose i need to show ErrorMessage and Stacktrace on the view. As this is one time thing is it not better to use dynamic than create a error model for this."
In this case you usually have a view model that can carry the errors with it. Sometimes I use a base view model class with:
public class ViewModelBase
{
public string ErrorMessage { get; set; }
}
Most often I'll put the errors in TempData:
TempData["Errors"] = "";
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "asp.net mvc, c# 4.0, dynamic, expandoobject"
}
|
Instagram URL is converted into oEmbed
I have 8 Instagram URLs in this post out of which 3 are not converted into embed/iframes.
I'm using Gutenberg's Instagram embed blog to add the URL's.<
I see the block code in the classic editor which is same as other instagram blocks which render properly but for < it just returns URL.
<!-- wp:core-embed/instagram {"url":" -->
<figure class="wp-block-embed-instagram wp-block-embed is-type-rich is-provider-instagram">
<div class="wp-block-embed__wrapper">
</div>
</figure>
<!-- /wp:core-embed/instagram -->
I tried using shortcode also it's the same result only the below 3 Instagram posts don't render.
`[embed]
I need help debugging this weired issue
* <
* <
* <
|
Figured it out.
Embed shortcode stores the oemebd data as post meta using md5 hash.
wp-includes/class-wp-embed.php
// Check for a cached result (stored in the post meta)
$key_suffix = md5( $url . serialize( $attr ) );
$cachekey = '_oembed_' . $key_suffix;
$cachekey_time = '_oembed_time_' . $key_suffix;
And has a cache mechanism to fetch new data only after a day.
I deleted the post meta and then it started working.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "shortcode, embed, oembed, block editor"
}
|
Eclipse: is there a shortcut for changing the order of methods in a class?
In Eclipse, is there a shortcut for moving a certain method up or down the method list in a class, without having to cut and paste it manually?
|
Window-->Show View->Outline
In `Outline` view change the order of methods with drag and drop
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "java, eclipse, ide"
}
|
When and why were answer acceptance percentages removed?
I just noticed on Stack Overflow that the acceptance percentage is missing on questions and peoples' profiles? Why was this removed?
|
Only users who have asked at least 4 non-wiki questions that are open, older than 3 days, and have at least one answers have their Accept Rate displayed.
|
stackexchange-meta
|
{
"answer_score": 7,
"question_score": 1,
"tags": "support, profile page, accept rate"
}
|
Validating emails in file with batch
I have a file with emails and I need to validate them.
The sequence is:
1. First name.
2. Dot.
3. Last name.
4. Number (optional - for same names).
5. static string domain(@utp.ac.pa).
I wrote this:
egrep -E [a-z]\.+[a-z][0-9]*@["utp.ac.pa"] test.txt
It should match this email: "[email protected]"
But it is also matching:
* [email protected]
* [email protected]
Although they don't follow the sequence. What am I doing wrong?
|
Your regex doesn't even match the first email. If I understand your requirements correctly, this should work:
[A-Za-z]+\.[A-Za-z]+[0-9]*@utp\.ac\.pa
* Note that to match a dot, it needs to be escaped (i.e., `\.`) because `.` matches any character.
* You can get rid of `A-Z` if you don't want to match upper-case letters.
Try it online.
Let me know if this isn't what you want.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "regex, bash"
}
|
Adding dynamic text to ArcGIS map documents
I've been making some map layouts and just noticed this command:
< dyn type="document" property="name"/>.mxd
It make possible to change automatically my current file name: <
I want to ask how does it works and how do I find some other commands that makes things like these quick and easy?
|
This is called 'dynamic text' and is used with ArcMap Layouts:
> Dynamic text is text placed on a map layout that changes dynamically based on the current properties of the map document, data frame, and Data Driven Pages. Dynamic text works through the use of tags, like HTML. Here is an example of a dynamic text tag for the title of a map document:
<dyn type="document" property="title"/>
|
stackexchange-gis
|
{
"answer_score": 2,
"question_score": 2,
"tags": "arcgis desktop, arcgis 10.2, command line"
}
|
Format Painter in Microsoft Office
I know I can google it quite easily but hey, I have never asked any question @ SU, so here is one.
What is the shortcut key for Format Painter in Microsoft Office things e.g., Microsoft Word?
|
The answer is to use `Ctrl`+`Shift`+`C` to Copy Format and `Ctrl`+`Shift`+`V` to Paste Format.
|
stackexchange-superuser
|
{
"answer_score": 12,
"question_score": 8,
"tags": "keyboard shortcuts, microsoft word"
}
|
Should a view be dependent on its controller? (ASP.NET MVC)
Have a question about the design/usage of asp.net mvc here.
In the html helper class, you can get to the current controller by Html.ViewContext.Controller. Moreover, you can get to the request, route collection and much more from the html helper class.
Doesn't this go against the rule of MVC? Doesn't this opens up a ways for developer to do heavy controller dependent code in views?
If not, what's the best practice use case for current viewcontext and controller from the html helper class?
Thanks in advance.
|
Use a strong typed ViewModel, so your view is only dependant of it and not of the controller who generates it
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 4,
"tags": "asp.net mvc, view, controller"
}
|
Getting WiFi Direct IP address of my device
I am trying to get the ip address of my device but all in vain and no success. I've tried
public String getP2PIpAddr() {
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_P2P_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ip = wifiInfo.getIpAddress();
String ipString = String.format(
"%d.%d.%d.%d",
(ip & 0xff),
(ip >> 8 & 0xff),
(ip >> 16 & 0xff),
(ip >> 24 & 0xff));
return ipString;
}
but its giving me 0.0.0.0 and no other method is working too..Help !!
|
send out the peer's local ip address (starting with 192.168.x.x) to the group owner. After this "handshake", which doesn't really take time, it's all good to go. Did not find any other way to get the peer's ip addresses, the only information provided by GroupListener/PeerListener/... is the mac address.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 9,
"tags": "java, android, ip, wifi direct"
}
|
Merging DB Content From 2 DBs, Need To Avoid Non-Exact String Likenesses
Maybe I am day-dreaming but I am about to merge the contents of two large tables which represent two companies versions of the same data. I'd like to avoid duplicates (entries with the "title" field from DB 1 being _almost_ the same as the "title" from DB 2. Are there any methods in php or mysql do do close string matches and return a relevance factor? Or any good php classes anyone knows of to check for likeness?
|
Try the levenstein function in PHP.
In MySQL you will have to write stored procedure for that.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "php, mysql, database, sql like"
}
|
Deleted question showing in the review queue
I was going through the "First Posts" review queue and stumbled upon this:
> <
However, when I clicked the link to view the question itself, I discovered that it was a deleted question. Not only was it deleted, but the deletion had taken place **over 10 days ago**.
I assume this is a bug. There is no need for us to review questions that have already been deleted.
|
Were you looking at the recently reviewed?
> **Review audit passed 54 mins ago:**
> Adaephon reviewed this 54 mins ago: Reviewed
It was an audit post. They're commonly already nuked.
|
stackexchange-meta_askubuntu
|
{
"answer_score": 4,
"question_score": 1,
"tags": "bug, status bydesign, deleted questions, review queue"
}
|
Programmers that need a lot of "outside help" - is this bad?
Is it kind of tacky or poor practice when programmers use an unusual amount of libraries/frameworks to accomplish certain tasks? I'm working with someone on a relatively simple programming project involving geolocation queries. The guy seems like an amateur to me. For the server software, this guy used Python, Django, and a bunch of other crazy libraries ("PostGIS + gdal, geoip, and a few other spatial libraries" he writes) to create it. He wrote the entire program in one method (in views.py, nonetheless _facepalm_ ), and it's almost unreadable.
Is this bad? Is this really tacky and amateurish? Am I the only minimalist out there these days?
|
Writing an entire program in one method is probably bad. That being said, utilizing tools that already exist can definitely help speed up development times. I hope I misinterpreted your wording as it seems to imply that Python or Django should be looked down upon as outside help. Both are extremely useful tools for developers. I think we can agree that for most cases, a developer who implements a linked list to use instead of using a provided standard is a bad idea. This can apply to more complex things as well, like TCP sockets, and maybe even GeoIP.
Agreed, sometimes when people incorporate external modules/libraries in a product things can get messy, especially when there are multiple modules and you start getting into dependency nightmares. These need to be managed appropriately, and yes, sometimes it is better to code things yourself. I wouldn't judge a developer on _if_ they use "outside help", as much as _how_ they use outside help and integrate it with the rest of the system.
|
stackexchange-softwareengineering
|
{
"answer_score": 11,
"question_score": 7,
"tags": "python, frameworks, libraries"
}
|
Image resize for printing
Can I resize an image with 21cm x 42cm and 1200 DPIs to 24cm x 48cm and 400 DPIs without quality loss?
The reason being is that my scanner max size is 21cm x 42cm and 1200 DPIs. And I need to make an artwork with 24cm x 48cm (bigger than the scanner size).
Thks in advance.
|
Yes.
!enter image description here
Actually, you end up with a tad bit over 1000ppi.
!enter image description here
Just be certain to **uncheck** "Resample" in the Image Size dialog of Photoshop. Assuming you're using Photoshop.
|
stackexchange-graphicdesign
|
{
"answer_score": 0,
"question_score": 0,
"tags": "adobe photoshop, print design, resize, dpi"
}
|
How to convert a string to a numeric in autohotkey?
`FormatTime, CurrentMinute , , m` assigns the current minute to variable `%CurrentMinute%`, and its value is a string, not a numeric. I wanna do some calculations on the value of `%CurrentMinute%`, so how could I convert it to numeric?
Thanks for any help in advance!
|
AutoHotkey automatically converts numbers and strings as needed.
FormatTime, CurrentMinute,, m
NextMinute := CurrentMinute + 1
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 3,
"tags": "string, format, converters, numeric, autohotkey"
}
|
CRLB to find UMVUE
In what situation can one obtain an estimator that reaches the Cramer-Rao lower bound, i.e. an efficient estimator?
I know the rules for finding UMVUEs, and I know they are efficient if they reach CRLB. But how can I use the Cramer-Rao result directly to find UMVUEs?
Thanks.
|
CRLB is proved using the Cauchy-Schwarz inequality. Equality holds in C.S. inequality whenever the two vectors are linearly dependent. The vectors in this case are: $\frac{\partial\log f(x;\theta)}{\partial^T\theta}$ and $\hat{\theta}-\theta$, So $\frac{\partial\log f(x;\theta)}{\partial^T\theta}=C(\theta)(\hat{\theta}-\theta)$. Where $C(\theta)$ is a matrix (if $\theta$ is a scalar then $C(\theta)$ is also scalar. On this case when the equality holds, the bound is reached by $\hat{\theta}$. By differentiating the above equation with respect to $\theta$ and applying the Expectation operator to both sides you will see that $C(\theta)=I(\theta)$, where $I(\theta)$ stands for the Fisher Information Matrix. So, the condition for efficiency is $\frac{\partial\log f(x;\theta)}{\partial^T\theta}=I(\theta)(\phi(x)-\theta)$. The derivative of the log-likelihood function takes the above form iff the efficient estimator is given by $\phi(x)$.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 0,
"tags": "statistics, statistical inference, parameter estimation"
}
|
Jacobi determinant for high-dimensional sphere inversion
I need to find the Jacobi determinant for the unit sphere inversion in $\mathbb{R}^n$, i.e. the map given by $f(x) = \frac x {|x|^2}$ for $x\in \mathbb{R}^n$. The main problem is to figure out the determinant of the following matrix (when $\xi = f(x)$): $$\frac 1 {|\xi|^{4n}}\left[\begin{array}{cccc} |\xi|^2 - 2\xi_1^2 & -2\xi_1\xi_2 &\ldots& -2\xi_1\xi_n\\\ -2\xi_2\xi_1 & |\xi|^2 - 2\xi_2^2 & \ldots& -2\xi_2\xi_n\\\ \vdots & \vdots & \vdots & \vdots \\\ -2\xi_n\xi_1 & \ldots & -2\xi_n\xi_{n-1} & |\xi|^2 - 2\xi_n^2 \end{array}\right]$$ Direct computation for low dimensions suggests that the result is $-\frac 1 {|\xi|^{2n}}$, but the recursive formula for n-th dimension seems terribly complicated, and involves all smaller dimensions. Is there a relatively simple way to solve this problem?
|
First, the Jacobian is equal to $-1$ on the unit sphere. Indeed, consider an orthonormal basis at a point of the unit sphere where one of basis vectors is normal to the sphere. Under inversion, the normal flips its sign while the rest remain as they were: hence, the Jacobian matrix has eigenvalues $-1,1,1,\dots,1$.
Now take any $x_0$ with $|x_0|=r>0$. Observe that for all $x$,
$$ f(x) = r^{-1}f(r^{-1} x) $$ Taking the Jacobian on both sides yields $$ J_f(x) = r^{-n}J_f(r^{-1} x)r^{-n} = -r^{-2n} $$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "geometry, multivariable calculus, differential geometry, determinant"
}
|
Can ReportViewer render a hyperlink with a relative path?
I have created a local report on a datasource that has a field named "RelativePath". When my WinForms app renders the report, it exports files to the location specified in the RelativePath field. In the report builder, I set Navigation|Hyperlink action|Jump to URL to "=Fields!RelativePath.Value" and set the report's EnableHyperlink property to true. Whenever my app renders the report, however, the hyperlink is not active. If I hardcode the Jump to URL to an absolute path, however, it works just fine. Does the ReportViewer not render a hyperlink with a relative path?
|
I have been struggling with the same problem after which i came to the conclusion that the reportviewer does not support hyperlinks with the relative path. To solve this problem is by adding a custom code that retrieves the relative path then concantenate with the field values that you may wish to be part of the URL - atleast that works for me.
Shaddie
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": ".net, winforms, reportviewer, hyperlink"
}
|
initialize an array with dummy values
while ($row = mysql_fetch_object($result)) {
$data[] = $row;
echo "<div id='captionbox' style='width: 110px;float:left;color:#FFF;text-align:center;'>";
echo "<a href='#' class='thumb'><img class='thumb-img' value = ".$row->aid." onclick='getVote(".$row->aid.", \"".$row->atitle."\")' src='images/roadies/th".$row->aid.".jpg' /> </a>";
echo "<input type = hidden name = aid id = rd".$row->aid." value = ".$row->aid.">".$row->atitle."</input>";
echo "</div>";
}
$jsfriend = json_encode($data);
In the above PHP code, I am adding the mysql rows into an array $data. then i am making a JSON object from that array. before I come into the while loop I want to create the array $data and initialize the $data[0] pointer with dummy values as I do not want to use the [0] pointer values. can this be done?
I hope I am making sense.
|
Something like this?
$data=array("dummyfirst");
while(....
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php"
}
|
Where should my duplicate check be for Azure Table Storage models?
I have an Azure table datastore and here's my model for one class:
public class Product : TableServiceEntity
{
[Required(ErrorMessage="Title required")]
[DisplayName("Title")]
public string Title { get; set; }
}
There is more to this but the most important thing is PartitionKey, RowKey (hidden here) and Title.
What I want to do is to ensure that no record is saved that has the same title as another. I currently use a service layer for everything to do with the model.
Should my check there's no record already with the same title be part of this service layer or should it somehow be in the model itself?
|
Azure storage can only enforce uniqueness based upon partition key and row key. Any other uniqueness needs to be enforced by your own logic.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "asp.net mvc, asp.net mvc 3, azure"
}
|
I am taking CCD images through my telescope and am wondering what can I do analytically with those images?
This weekend I'll be taking around 50 CCD images with my Celestron CPC 8in. telescope and would like to use python to analyzie the images. Does anyone have any experience doing this?
|
Check out the python wrapper for OpenCV: < This should provide all the power you need to do any image processing tasks you require. And there are some great tutorials to help you get started.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, ccd"
}
|
What's this book about?
<
My Rabbinic Hebrew is very poor and my wife was asking for a book on Niddah and other womanly things so i was looking for a book according to the Egyptian tradition. Does this book cover such things?
|
The book you linked to is about **the laws of a rebellious wife**. The book was authored in Egypt and printed in Jerusalem.
|
stackexchange-judaism
|
{
"answer_score": 1,
"question_score": 1,
"tags": "jewish books"
}
|
copy specific files from a container using wildcard filename in ADF pipeline
I'm trying to copy specific files from a container in a Storage Account using an ADF pipeline. lets say the container has the following files
* aa_aaa_01_yyyymmdd.csv
* aa_abb_01_yyyymmdd.csv
* aa_aaa_02_yyyymmdd.csv
* aa_aaa_03_yyyymmdd.csv
* aa_abb_02_yyyymmdd.csv
* ab_abc_01_yyyymmdd.csv
My pipeline has to copy all the files beginning with ' **aa_aaa_** '. I tried using the * wildcard at the time of creating the source dataset - like "aa_aaa_*.csv" but didn't work; the validation fails.
please help. Thanks
|
You can use prefix option like below in copy activity , I upgraded to ICS in December but I think it has problem because it restarts itself very often and I don't know what have caused this behavior.
Anyone have similar problem?
Thanks
|
Yes many people experienced problems. Have a look at:
where a Google employee is asking for information on the problems people are having and asking them to submit bug reports. Here's the generic bug report link for Nexus S with ICS:
|
stackexchange-android
|
{
"answer_score": 2,
"question_score": 1,
"tags": "updates, samsung nexus s, 4.0 ice cream sandwich"
}
|
Trying to Upgrade froM MVC3 to MVC4, all ok bar one component which is still referencing 3.0.0.0
I have upgraded my MVC3 application using the Nuget UpgradeFromMvc3ToMvc4 which has worked fine, except for one component. I did uninstall the V3 of this "MvcSiteMapProvider" component before upgrading, and then installed "MvcSiteMap Core V4" after the MVC4 upgrade.
Ther error I get is:
Error 41 Assembly 'MvcSiteMapProvider, Version=4.6.18.0,
Culture=neutral, PublicKeyToken=1923abe4657913cc' uses 'System.Web.Mvc,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which
has a higher version than referenced assembly 'System.Web.Mvc,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
d:\..\MvcSiteMapProvider.MVC4.Core.4.6.18\lib\net45
\MvcSiteMapProvider.dll
There is no reference to 3.0.0.0 in my solution. I have done a "find" in "all files". So am confused.
Any help appreciated. Thanks.
|
Drop refference to `System.Web.MVC` and readd it. Sometimes this just happends.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "asp.net mvc, asp.net mvc 3, asp.net mvc 4, mvcsitemapprovider"
}
|
How do I pass a variable to a ajax success function as it was at the time of the ajax call?
So this is my ajax call (pretty much standard jQuery but using the couchdb jquery library, < ):
var stuff = "some stuff";
$.couch.db("test_db").create({
success: enyo.bind(this, function (data) {
console.log(stuff);
})
});
stuff = "a change in stuff";
And I'd like the output of console.log to be "some stuff" rather then "a change in stuff".
The more methods to do this the better, cause I think some methods might need me to not use "enyo.bind" ( < ), but perhaps I can accomplish the same thing a little differently with those methods.
|
You can use a function for it.
var create = function (stuff) {
$.couch.db("test_db").create({
success: enyo.bind(this, function (data) {
console.log(stuff);
})
});
};
create(stuff);
Or, its equivalent as an anonymous function.
!function(stuff) {
$.couch.db("test_db").create({
success: enyo.bind(this, function (data) {
console.log(stuff);
})
});
}(stuff);
See What does the exclamation mark do before the function?
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "jquery, ajax, variables, scope"
}
|
Building Dependencies problem in Core-Plot integration?
I'm trying to integrate core-plot. I followed all the steps in "Read Me" doc in core-plot. But i get a following error.
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=i386, VALID_ARCHS=armv6 armv7).
I'm using IPhone simulator-4.1. x-code-3.2 Can any one help me?
|
Somehow I figured it out. I changed to "All Configurations" in the project settings. Previously I was using Debug-device setting. For integration of Core-Plot Library , use 'All-Configurations' and set the your base sdks and additional sdk. Make sure your header search path is pointing core-plot framework(/**-recursive format). make changes both in Project build settings and Target build settings. I changed from device to simulator. And Used appropriate additional libraries. I used LLVM GCC 4.2 compiler.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iphone, core plot"
}
|
What are some must-know trig identities?
I'm having a hard time with trigonometry. Not in the sense that I can't solve problems, but that I don't understand what I'm using. I see a trig identity and just sort of accept that it works without necessarily seeing how it was derived. But most of the time when I see the equivalence I have no idea how they got there.
Are there a few "core" identities from which the rest can be derived? Or am I barking up the wrong tree and just need to suck it up and memorize?
|
Learn and remember the basic geometric definition of trigonometric functions, notably
* $\cos x$ and $\sin x$ are the coordinates of the point M on the trigonometric circle
* $\tan x$ is the y coordinate of the intersection between the vertical line from (1,0) and the line OM
* ...
and so on.
 {
for (int i = 0; i < nItems; i++) {
if (!strcmp(items[i].key, key)) { return &items[i]; }
}
return NULL;
}
From main function, I want to retrieve my struct value as following:
struct item search_items = findItem(&key) ; // I have problem with this line
char* itemValue;
if (search_items != NULL)
{
itemValue = search_items->value;
}
How can I retrieve the structure and save it to be used in the `main` function?
|
If you are returning pointer from function, then you have to read it as pointer. Notice `struct item* search_items` part on my code and on your (I added pointer `*`)
struct item* search_items = findItem(&key) ; // i have problem with this line
char* itemValue;
if ( search_items != NULL)
{
itemValue = search_items->value;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "c, pointers, struct"
}
|
Xcode 6 flushing NSUserDefaults
my application stores some state information inside NSUserDefaults. When using Build & Run with the newest version of Xcode 6 (the GM), all the defaults are flushed upon install. In addition, values entered in my Settings.bundle are removed (which is another sign of the user defaults being flushed). Any suggestions on how to fix that?
|
As it appears I was a little mislead. I checked for some files being present in the apps document directory on startup. If they were not, I removed stuff from the NSUserDefaults. Apple seems to have updated the Xcode Build&Run implementation leading to a new app file path (the identifier inside the path changes) each time Build&Run is executed. When simply restarting the app in a normal way without Build&Run (so as a normal user would do), everything is working fine and the path stays the same.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ios, objective c, xcode, settings, nsuserdefaults"
}
|
Determining the length of an expl3 sequence
Is there a function/command/macro that gives the _length_ of an expl3 sequence? I know that you can do something like the code below but I thought that there would be a more direct way of doing this since you can pop items from either end of the sequence and, internally, the sequence probably does know its own length.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\seq_new:N \l_tmp_seq
\seq_set_from_clist:Nn \l_tmp_seq {1,2,3,4,5,6}
\int_new:N \l_my_int
\int_set:Nn \l_my_int {0}
\seq_map_inline:Nn \l_tmp_seq {% loop through the sequence and count its length
\int_incr:N \l_my_int
}
\NewDocumentCommand\SequenceLength{}{
The~sequence~has~length~\int_use:N \l_my_int
}
\ExplSyntaxOff
\begin{document}
\SequenceLength
\end{document}
As you might expect, this prints:
.
|
stackexchange-tex
|
{
"answer_score": 8,
"question_score": 5,
"tags": "expl3"
}
|
Find string with special char using regex
I need to scroll a List and removing all strings that contains some special char. Using RegEx I'm able to remove all string that start with these special chars but, how can I find if this special char is in the middle of the string?
For instance:
Pattern.matches("[()<>/;\\*%$].*", "(123)")
returns true and I can remove this string
but it doesn't works with this kind of string: 12(3).
Is it correct to use \\* to find the occurrence of "*" char into the string?
Thanks for the help! Andrea
|
You are yet another victim of Java's ill-named `.matches()` which tries and match the _whole_ input and contradicts the very definition of regex matching.
What you want is matching one character among `()<>/;\\*%$`. With Java, you need to create a `Pattern`, a `Matcher` from this `Pattern` and use `.find()` on this matcher:
final Pattern p = pattern.compile("[()<>/;\\*%$]");
final Matcher m = p.matcher(yourinput);
if (m.find()) // match, proceed
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "java, regex"
}
|
Delete / change values in a column based on values in a different column in R
It seems I cannot get to the bottom of one issue and I haven't found a satisfactory answer anywhere.
So, here is my problem. I have a data frame with multiple columns and I want to change the values in one column if the value matches a string in another column.
For example:
id Var1 Var2 .................Var10
1 A 1
2 A 1
3 D
R
F .
.
1000 A 1
What I want to achieve ultimately is to change values in Column 10 to another value of my choice if values in Column 1 match a declared value. As an example, if value in column 1 is "A", then change value in Column 10 to NA.
I have tried to use this code, but failed:
if(df$Var1 = "A"){df$Var10 <- "NA"}
Thank you very much for your help!
|
df$Var10[df$Var1=="A"] <- "NA"
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "r"
}
|
Multiple boost trails possible?
On RocketLeagueValues I read for the Tachyon, Season 2 Champion or other rocket trails:
> It depends on your Battle-Car how many boost trails your car has
Does that mean that there are cars that can have 2 or more boost trails assigned at the same time? How would I assign that then?
|
No, they mean how many trails come out the back of the car.
For instance, notice that when the Gizmo boosts there's only one smoke trail behind it, but when the Merc boosts there's two (stacked vertically on top each other)
|
stackexchange-gaming
|
{
"answer_score": 5,
"question_score": 3,
"tags": "rocket league"
}
|
Is is possible to run multiple apps in one VM instance?
Do I have to make another VM instance to run another app? Or can I run multiple apps in one instance?
|
Straight forward answer - YES
VMs behave similar to what a regular physical machine would. In any machine you can run multiple apps , just that they would need to run on different ports. So, you can run multiple services / applications in a single VM but they would need to run on different ports.
The other things you might have to consider is like the capacity of the VM. Running multiple services in parallel will only lead to more consumption of the RAM and CPU and might lead to exhaustion of the complete capacity.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -2,
"tags": "google cloud platform, google compute engine"
}
|
Can anyone tell me how to trigger a function when the mouse is pressed and continues untill it is released in p5.js
I was trying to add an image using p5 and ml5 In my website where user can train there own image and get the predicted output over webcam I tried implementing it by using
var addImage;
var mobilenet;
mobilenet = ml5.featureExtractor('MobileNet', modelReady);
classifier = mobilenet.classification(video,videoReady);
addImage = createButton('Insert');
addImage.mousePressed(function (){
classifier.addImage('Insert');
});
but for every image, I need to press the mouse button to insert I just want to make it something like this
**On mousePress()
function to add multiple image;
On mouseRelease()
stop;**
|
From this reference, this should work;
var addImage;
var mobilenet;
var drawImageInterval = null;
mobilenet = ml5.featureExtractor('MobileNet', modelReady);
classifier = mobilenet.classification(video,videoReady);
addImage = createButton('Insert');
addImage.mousePressed(function (){
if(mouseIsPressed && !drawImageInterval){
drawImageInterval = setInterval(function(){
classifier.addImage('Insert');
}, 1000);
} else {
clearInterval(drawImageInterval);
drawImageInterval = null;
}
});
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, machine learning, p5.js, web site project, mobilenet"
}
|
Limit of $-itc\sqrt{n}+n\log(1-\frac{it}{c\sqrt{n}})$
For $c>0, t\in \mathbb{R}$ why $$ -itc\sqrt{n}+nc\sum_{k\geq 0}\frac{1}{k+1}\bigl(\frac{it}{\sqrt{n}}\bigr)^{k+1}\stackrel{n\rightarrow \infty}\longrightarrow \frac{-ct^2}{2}?$$ Just because it isn't very clear, the summation was $$\log(1-\frac{it}{\sqrt{n}})$$ where $\log$ is the complex logarithm.
I only see it converging to $-\infty$.
|
What I have written at first was wrong. That was causing me the problem. Gary's remark helped. Solution: Separate the first 2 terms of the sum and simplify. What you get is $-itc\sqrt{n}+itc\sqrt{n}+\frac{(it)^2c}{2}$ \+ something converging to 0.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sequences and series, complex analysis"
}
|
Reciprocal of Holder's inequality
Does anyone know how to do this exercise? I couldn't do it.
Let $(X,S,\mu)$ be a $\sigma$ -finite measure space and $g\in M(X,S)$ such that $gs\in\mathcal{L}_1$ for any simple function $s\in\mathcal{L}_p$, $p\in(1,\infty)$. Suppose there is $A\geq0$ such that $\left|\int gs\,d\mu\right|\leq A||s||_p$ for all $s$. Show that $g\in\mathcal{L}_p$ with $\frac1p+\frac1q=1$ and $||g||_q\leq A$.
|
Define $T$ on the space $M$ simple functions in $L^{p}$ by $Ts=\int gs d \mu$. It is a bounded linear functional on $M$ with norm at most $A$. Since $M$ is dense in $L^{p}$ it extends uniquely to a bounded linear functional on $L^{p}$ with the same norm. Since the dual of $L^{p}$ is $L^{q}$ there exists $h \in L^{q}$ such that $\int s gd \mu=Ts=\int hs d\mu$ for all simple functions $s$ and $\|h\|_q=\|T\|\leq A$ . For any set $E$ of finite measure this gives $\int_E g d\mu= \int_E h d\mu$. Can you use sigma finiteness now to prove that $g=h$ a.e..?
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "functional analysis, measure theory, lebesgue integral, holder inequality"
}
|
Need HELP in storing the state of the track being played for Alexa Skill
Hey I am developing an Alexa skill which i will be publishing at a later point in which based on the track the user requires Alexa would play that specific track with the help of our api which returns the track url . I was able to implement this . I wanted to know how should i be saving the state of the track the user is playing so that the user can resume at a later point . Since this is a skill that will be published i needed to figure how out how to be able to store the point at which the user pauses so that he can continue later . So basically we need to be able to maintain seperate channels for every user that logs in .
|
If you review this code, < you will see in constants.js is the listing of audio tracks so modeling your skill it would be a list of x number of your tracks. the mechanism that is storing the enqueue for each user is AWS dynamo db which when a skill user enables your skill records them as ID and then tracks the constants.js track and placement on the track. This also allows the user to pause, play previous, play next.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "node.js, alexa, alexa skills kit, alexa skill, alexa app"
}
|
iOS開発 のmediapicker(_ didPickMediaItems) を使用してアルバム情報を取得する方法
music player
mediapicker(_ didPickMediaItems)
mediaItemCollection
skipToNextItem()
mediapicker(_,didPickMediaItems)
|
MPMediaPickerController **** UI
`allowsPickingMultipleItems` `false` `didPickMediaItems` MPMediaItemCollection **1**
mediaItemCollection 1
MPMediaItem `albumPersistentID` MPMediaQuery ****
****
MPMediaQuery.albums() MPMediaItemPropertyAlbumPersistentID MPMediaPropertyPredicate
) Using Filters to Create Specialized Queries
|
stackexchange-ja_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "swift, ios, xcode, swift4"
}
|
Creating centerline of polygon using PostGIS?
I am aware of Finding centrelines from polygons in QGIS? but I am looking for another Open Source GIS way to do this.
Is there a possibility to create centerlines in PostGIS?
I have this shapefile (see below) which contains different zones. I need a centerline in each zone - it may not be one line, it can be more (for example in brown zone).
In ArcGIS I can separate each zone as a new shapefile and then use ET Geowizard to create that lines.
.
I want the color-distribution to span the whole x-range.
Any ideas how to do this?
!enter image description here
|
pretty easy if you're using matplotlib & seaborn:
import matplotlib.pyplot as plt
import seaborn as sns
x = range(10)
y = range(10)
plt.bar(x,y,color= sns.color_palette("BuGn_r", len(x)))
plt.show()
just pass the length of the x-array as the 2nd parameter of color_palette()
!enter image description here
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, matplotlib, seaborn"
}
|
Does not contain a definition for 'NewRow' and no extension method 'NewRow' accepting a first argument of type 'Systems.Windows.Forms.DataGridView
private void Agregar()
{
var rowsChecked = this.DataKitchenArea.AsEnumerable().Where(r => Convert.ToBoolean(r["Sel"]));
foreach (DataRow rowOrigen in rowsChecked)
{
DataRow rowDestino = this.dataGridView1.NewRow();
rowDestino["Sel"] = false;
rowDestino["Id"] = rowOrigen["Id"];
rowDestino["Nombre"] = rowOrigen["Nombre"];
this.dataGridView1.Rows.Add(rowDestino);
}
this.dataGridView1.DataSource = dataGridView1;
}
La función principal del boton es que agregue a otro grid los filas del checkbox seleccionados
Mi pregunta es que reemplaza el NewRow o que hay que agregarle.
|
El `NewRow()` es un metodo de `DataTable` no del `DataGridView`, por lo que deberias usar
private void Agregar()
{
var dt = (DataTable)dataGridView1.DataSource;
var rowsChecked = DataKitchenArea.AsEnumerable().Where(r => Convert.ToBoolean(r["Sel"]));
foreach (DataRow rowOrigen in rowsChecked)
{
DataRow rowDestino = dt.NewRow();
rowDestino["Sel"] = false;
rowDestino["Id"] = rowOrigen["Id"];
rowDestino["Nombre"] = rowOrigen["Nombre"];
dt.Rows.Add(rowDestino);
}
dataGridView1.DataSource = dt;
}
Si el `dataGridView1` no tiene un DataSource entonces el DataTable deberias crearle la estructura de columnas
|
stackexchange-es_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#"
}
|
Generate exponential random values in a given range
Need to generate random values that follow an exponential distribution on an interval [a, b]. I tried using explained here Trucated distribution, but did not succeed
|
This case has a simple solution because the cumulative distribution function for a truncated exponential variable and its inverse are easy to compute:
$$ F(x) = \frac{1}{e^{-\lambda a}-e^{-\lambda b}}\left[e^{-\lambda a}-e^{-\lambda x}\right] $$
so for a random variable, $u$ uniformly distributed over $[0,1]$, $ x=F^{-1}(u) $ follows the desired distribution. So (1) generate $u$ and (2), let
$$ x=-\frac{1}{\lambda} \log\left(e^{-\lambda a}-u\left[e^{-\lambda a} - e^{-\lambda b}\right]\right)$$ and you have it.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "probability distributions, random variables"
}
|
.htaccess How to create a RedirectPermanent by triming a char?
My goal is to create a permanent redirect
<
to <
(removing the last '-' char (if present) from category
regards
|
You can use this rule in your root .htaccess:
RedirectMatch 301 ^/(.*?)-/(.*)$ /$1/$2
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "regex, apache, .htaccess, redirect"
}
|
It's easy to set a breakpoint when debugging VBA, but how about a "startpoint" or a "skippoint"?
I'm debugging a subroutine in my VBA code. I want to ignore the first half and just run the second half. So, is there a way to set a 'startpoint'?
Also, is there an easy way to ignore a specific line of code other than commenting?
If not, I'll just continue commenting out all the code I don't want run. The problem with this, of course, is that I have to remember to uncomment the critical code before I send it on to Production.
|
Why not just put the breakpoint at the begining of the the second half of the subroutine? Also, I believe clicking the "run" button (green right-pointing arrow) should run and then stop the app at the next breakpoint, thus saving you from stepping through the code between breakpoints. There's also a "Run-to-cursor" feature (Ctrl-F8) which I've never used, but it's worth a try (I suspect it executes up to wherever you place the cursor). ;)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "ms access, vba"
}
|
Where is the entity ID stored?
I have an installation which I am trying to upgrade from Drupal 6 without much success. I have decided to manually port the database over.
I realized that in a fresh installation of Drupal 7, node has entity ID = 1 whereas in another installation, node has entity ID = 2.
Where is the table storing this data located?
|
Check for `hook_entity_info` and `entity_extract_ids`. The former specified a base table and the id key, the latter allows to extract the ID from the entity.
|
stackexchange-drupal
|
{
"answer_score": 3,
"question_score": 1,
"tags": "7, entities"
}
|
Sharp Lower Bound for Entrywise 1-norm of a Real Semi-Orthogonal Matrix
Let $A$ be a real-valued $m\times n$ ($m>n>1$) matrix such that $A^TA=I$, what is the sharp lower bound for $\|A\|_1=\|\operatorname{vec}(A)\|_1=\sum|A_{i,j}|$?
Since one can show the submultiplicativity of $\|\cdot\|_1$, we have $$\|I\|_1=\|A^TA\|_1\leq\|A^T\|_1\|A\|_1=\|A\|_1^2,$$ which implies $\|A\|_1\geq\sqrt{n}$. However, I am not sure if the equality here is actually attainable, especially for real $A$... I suspect instead $\min\|A\|_1=n$.
|
The property $A^TA=I$ means that $A$ is an isometry in the $2$-norm: $\|Ax\|_2 =\|x\|_2$ for all $x\in\mathbb{R}^n$. In particular, $\|Ae_k\|_2=1$ for the standard basis vectors $e_1,\dots, e_n$. It follows that $$ \|A\|_1 = \sum_{k=1}^n \|Ae_k\|_1 \ge \sum_{k=1}^n \|Ae_k\|_2 \ge n $$ as you expected.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "inequality, normed spaces, orthogonal matrices, upper lower bounds"
}
|
What effects does Orisa's Fortify resist?
Jeff Kaplan mentioned that Orisa's Fortify ability will resist some crowd control effects, such as Pharah's concussive blast. The gameplay video for Orisa on playoverwatch.com also shows her resisting a Reinhardt Earthshatter.
So, what other effects does it resist? Does it stop things like Roadhog's hook, or stop her from getting affected by Zarya's ultimate?
|
As per this Reddit post, Orisa's Fortify resists the following effects:
* McCree's Flashbang
* Pharah's Concussive Blast
* Junkrat's Concussion Mine
* Junkrat's Steel Trap
* Mei's Endothermic Blaster
* Mei's Blizzard
* D.Va's Boost
* Orisa's Halt!
* Reinhardt's Charge
* Reinhardt's Earthshatter
* Roadhog's Hook
* Ana's Sleep Dart
* Lucio's Soundwave
After additional testing, Fortify also resists the following crowd control effects:
* Soldier: 76's Helix Rockets (they have a very small knockback effect)
* Roadhog's Whole Hog
* Winston's Primal Rage
* Zarya's Particle Cannon alternate fire
* Zarya's Graviton Surge
* Symmetra's Sentry Turrets
* Bastion's Configuration: Tank
|
stackexchange-gaming
|
{
"answer_score": 6,
"question_score": 7,
"tags": "overwatch"
}
|
Difference in casting in the following 2 methods
> **Possible Duplicate:**
> casting vs using the 'as' keyword in the CLR
hi,
can somebody please tell me what is the difference between the following two statements, because both of them give me the same results. Also i want to know which is better.
Label lblSome = e.Item.FindControl("lblMyLable") as Label;
&&
Label lblSome = (Label)e.Item.FindControl("lblMyLable");
thank you so much.
|
`as` checks if it can cast it, if it can't, it sets lblSome to null. Normal casting, `(Label)`, doesn't do that check for you, just gives you an `InvalidCastException` instead. However, `as` doesn't work with non-nullable structs.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, casting"
}
|
Rails + Capybara: Selecting select option using HTML class?
My select looks like this:
<select id="product_products_colors_attributes_0_variants_attributes_1401459162565_size_id" class="size_select" name="product[products_colors_attributes][0][variants_attributes][1401459162565][size_id]">
<option value="1">XS</option>
<option value="2">S</option>
<option value="3">M</option>
<option value="4">L</option>
<option value="5">XL</option>
<option value="6">One Size</option>
</select>
The thing is that the `1401459162565` part is random (comes from the nested_form gem). How would I select `M` from this select dropdown using the class (or ID or any way that works with the random number)?
|
I'm fairly new to Capybara, but as I understand it, you can select for embedded elements (by class) like this:
within('.select_box') do
click_on "Option"
end
There is also the select method:
select('Option', :from => 'Select Box')
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails"
}
|
Add a vector of days and hours to plot in R
I would like to add concise date and time info to my plot in R.
I am adding this plot to a research paper and when it's shrunk to fit the template it loses some of it's info.
My actual datetime range is 20/07/2017 18:15 - 23/07/2017 21:15
I'd like to abbreviate the date to days such as Thur 18:15 and Sun 21:15 with 5 days and times in between.
I can create the correct range in POSIXLT format but it's too big for my needs.
my.date <- seq(as.POSIXlt(strptime('20/07/2017 18:15',"%d/%m/%Y %H:%M"),tz="GMT"), as.POSIXlt(strptime('23/07/2017 21:15',"%d/%m/%Y %H:%M"),tz="GMT"),length.out = 7)
Is there a better way to achieve this datetime rage?
|
The key for this problem is convert the POSIX object into an character string with the desired format. The format function is used here: `format(my.date, "%a %H:%M")`
Here is a simple example:
my.date <- seq(strptime('20/07/2017 18:15',"%d/%m/%Y %H:%M"),
strptime('23/07/2017 21:15',"%d/%m/%Y %H:%M"), length.out = 7)
#x axis labels in the desired format
labels<-format(my.date, "%a %H:%M")
#simple example with base graphics
y<-2:8
plot(my.date,y, axes=FALSE)
#draw x and y axis
axis(1, at=my.date, labels=labels)
axis(2, at=y)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "r, datetime, plot, posixlt"
}
|
Insert link with yii framework
I'm developing a web app with yii framework in php.
In html code i have something like this:
<a href="search.php" class="btn_buscar">
<h3>Search</h3>
<div class="icon_menu">
</div>
</a>
¿ How can I do that with CHtml::link in yii framework?
Thank you :)
|
This should work:
echo CHtml::link('<h3>Search</h3><div class="icon_menu"></div>','search.php',array('class'=>'btn_buscar'));
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "php, yii, hyperlink"
}
|
Poisson Process Probability of a machine failing before other
> Machine $1$ is working now. Machine $2$ will be switched on at time $t$. Suppose that machine $1$ fails at rate $λ_1$ and $2$ at rate $λ_2$with an exponential waiting time. What is the probability that machine $2$ fails first?
**I thought:**
It should be $P(X_2+t<X_1)$ or $P(X_2<X_1|X_2=t)$ but I don't know how to go about calculating it.
Can someone give me a hint?
|
Let $X_i$ be the failure time of machine $i$. By lack of memory we have \begin{align} \mathbb P(X_2+t<X_1) &= \mathbb P(X_1>X_2+t\mid X_1>t)\mathbb P(X_1>t)\\\ &= \mathbb P(X_1>X_2)\mathbb P(X_1>t)\\\ &= \left(\frac{\lambda_2}{\lambda_1+\lambda_2}\right) e^{-\lambda_1 t}. \end{align}
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "probability, poisson distribution, poisson process"
}
|
SharePoint 2013 Web Parts and Apps
Does SharePoint 2013 support Web Parts or only new Apps?
|
In addition to traditional web parts still being supported (in either full-trust or sandboxed solutions) as Simon mentions, you can develop new **app parts** in an app for SharePoint 2013.
An app part is like a web part, and in fact is also made available to users in a host web's web part gallery. Users add app parts to pages the same way they would add web parts. One fundamental difference between an app part and a web part is that an app part uses an IFRAME to load the app part's content.
App parts, like web parts, can also have custom properties that users can set. More information about this, and app part development in general, may be found here.
|
stackexchange-sharepoint
|
{
"answer_score": 9,
"question_score": 4,
"tags": "web part, 2013, app"
}
|
Not able to set a view on clearcase getting i/p o/p error
Everything was working fine except the storage which was almost full 97% approx and after some time i started getting below errors.
When i tried to vi/ or ls the file i am getting the below errors.
ls: cannot open directory .: Input/output error
I tried to set a new view which is giving me the below error.
cleartool: Warning: Unable to preserve working dir "/vob/*" from old view in new view: Input/output error.
cleartool: Warning: Setting current working directory to "/".
|
Thanks @VonC for your valuable inputs but the issue was due to space crunch on the vob server no sooner the space issue was resolved the `input output error` I was getting got resolved.
Thanks
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "clearcase"
}
|
Bounds of Sparse Matrix Multiplication
Does anyone know a good reference for bounds on sparse matrix multiplication? I'm interested in bounds of the number of scalar products required and bounds of the sparsity of the product.
I know that the upper bound of the sparsity of the product $C = AB$ would be $nnz(A)\cdot nnz(B)$, lower bound being zero (if matrix $A$ only has elements in columns, corresponding to rows where $B$ does not have elements), but I suspect that it is not a very tight bound.
|
The bound $nnz(AB)=nnz(A)nnz(B)$ is tight: Take $$ A = \pmatrix{1 & 0 & \dots & 0 \\\ \vdots & \vdots & & \vdots \\\1 & 0 & \dots & 0 }\in \mathbb R^{m_a,n_a}, \quad B = \pmatrix{ 1 & \dots & 1 \\\0 & \dots & 0 \\\\\vdots & &\vdots \\\0 & \dots & 0 \\\\}\in \mathbb R^{m_b,n_b}. $$ Then $AB$ is a full matrix with all entries equal to one, $nnz(AB) = m_an_b=nnz(A)nnz(B)$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "matrices, computational complexity"
}
|
Ace HTML Editor - Making resource internal
I've implemented the Ace Editor using the recommended CDN I've seen in their official documentation and it works great.
<script src=" type="text/javascript" charset="utf-8"></script>
However, being an external resource, it requires internet, which the user may not always benefit of, as in my case, the application could run on the internal server of an embedded device.
Simply copying the code from the cdn link into a JavaScript plugin starts the editor without any features.
Is there any way to manage this library using bower or npm ?
|
You need to include mode, theme, and worker files in addition to ace.js, copy the whole < or use `npm install ace-builds`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "npm, bower, ace editor, html editor, cloud9"
}
|
Jquery regex range not working for password
I'm trying to pass minimum range for a password that should not be less than 3 letters, but every time my text/password gets executed.
**Below is my code:**
$.formUtils.addValidator({
name: "userpassword",
validatorFunction: function(a) {
return !!a.match((/^\s*[A-Za-z0-9@_\./\-]{5,}+\s*$/))
},
errorMessage: "Please enter a valid Password for user (Special characters are not allowed apart from At sign (@),Underscore(_), Hyphen(-) and Period(.)) <br> Minimum length for password is 5",
errorMessageKey: "badname"
})
|
JS regex does not support possessive quantifiers.
You may fix the pattern by removing the `+` after the limiting quantifier:
a.match((/^\s*[A-Za-z0-9@_.\/-]{5,}\s*$/)
Note that a `/` is better escaped (even though in most browsers it will work well if you keep it unescaped inside a character class), `.` does not have to be escaped inside a character class and `-` at the end of the character class does not have to be escaped.
Also, you may shorten the regex by replacing `A-Za-z0-9_` with `\w`:
a.match((/^\s*[\w@.\/-]{5,}\s*$/)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "jquery, regex"
}
|
Pisano period generator behaves incorrectly for 3-digit periods
I have a C++ code which is supposed to return the Pisano period value for any value m. The code works correctly when the period is 2-digited, but generates incorrect values for 3-digited periods. Eg:- Period(24) = 24 which is correctly generated Period(25) = 1243 (which is INCORRECT , it should be = 100)
#include <iostream>
using namespace std;
int main()
{
long long m;
cin >> m;
long period = 1;
long prev1 = 0;
long cur1 = 1;
long long prev2 = 0;
long long cur2 = 1;
while (1)
{
long long tmp = prev2;
prev2 = cur2;
cur2 = tmp + prev2;
period = period + 1;
if (((cur2 % m) == prev1) && (((cur2 + prev2) % m) == cur1))
{
break;
}
}
cout << period;
}
|
When you compute the next fibonacci number, you do :
long long tmp = prev2;
prev2 = cur2;
cur2 = tmp + prev2;
period = period + 1;
There's nothing in there to prevent overflow. Even `long long` eventually overflow. You should try keeping only the modulo part of `prev2` and `cur2` to avoid the overflow.
I don't have quite enough number theory knowledge to guarantee you it will work, but it looks plausible.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c++"
}
|
Cell Contains String in another Worksheet Return True
I am trying to figure out how to return true in column B if any of the text in column A is present in worksheet2(Themes by Subcategory)column D and return nothing if it is not present. I tried this so far `=IF(ISNUMBER(VLOOKUP(A2,Sheet2!$D$2:$D$65535,1,FALSE)), "", "True")` and don't know what' to do next.
* If "New Variables Needed" column A (for example: $data.tv.model) is present in "Themes by Subcategory" column D, then I want to return "True" in column B
<
|
How about this?
=if(isnumber(MATCH("*"&A3&"*",'Themes by subcategory'!D:D,0)),true,false)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "excel, excel formula"
}
|
How can i change a specific label's text with a foreach loop
I tried this before:
string st = "Unit";
foreach (Label lb in tabControl1.Items)
{
if (st.IndexOf(lb.Name) != -1)
lb.Content = "Some text";
}
Didn't work... Thank you for helping EDIT: I did used .text instead of .content sorry.
|
Edit:
use this method instead:
var control = this.FindName("button1");
but if you still want to serach every single item
* every TabeControl has TabeItems every TabeItem has a layout container
* (Grid for example) the container has Children property which is a
* collection of UIElements
* you can cast every child to a control and then do whatever you want
var container = ((tabControl1.Items[0] as TabItem).Content as Panel);
foreach(Control control in container) { // do what you want }
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, wpf"
}
|
How to get a object from array for a particular value
In swift i am using this code to get particular object for a particular value
if let layer = self.layers.first(where: {$0.id == id}) { }
I want to use this same in objective-c. How should i get a object from array of objects for particular value
|
You can use `NSPredicate` in `Objective-C` to filter an array.
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"id == %@", id];
id layer = [[self.layers filteredArrayUsingPredicate:predicate] firstObject]
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "ios, objective c, arrays"
}
|
Excel table using Powershell
I have an excel file with 2 tables on the first sheet. Can I pull Excel tables using Powershell. Currently using Powershell v3 with Excel 2007.
I'm aiming to convert those table to CSV file separately for other purpose.
The table should be reference by tables name as the table would not be located on fixed cell with fixed ranges. Is it possible to do this using Powershell?
|
I searched the MSDN entry for Excel automation and could not find a way to reference tables by name. Does that mean it's not there and I missed it? No, but it means that it's not obvious, and quite likely means that it is not there at all.
Next, can this be done another way? Probably, yes. I'm not half bad at performing some digital voodoo with Excel and PowerShell, so I would say that while you can not reference the table by name you can probably find the table by other means if you really wanted to pursue automating this task. Once you get the spreadsheet in your hands take a look at it and see if there's something you could search for with the table, and try and work another way at it, and if you run into roadblocks come on back and we'll see if we can assist you with tackling them. But for now, I'm sorry, but it does not look like you can reference a table by name from Excel's com object.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "excel, powershell, export to csv"
}
|
How to filter out special characters created by an array when filling out name portion of an email in php
I have built an email app (?) and I want special characters (eg. !@£$%^) to be filtered out, when a user submits the form.
Here's what I've done so far:
<?php
$name = $_POST['name'];
$to = "[email protected]";
$subject = "Test";
$message = $name;
$invalid= array("@","!","#");
if (($_POST['name'])!== $invalid[0]){
mail($to, $subject, $message);
echo 'Message sent';
} else {
echo 'Invalid character entered';
}
?>
As you can see, I created an array to do this, but I am limited to filter out only one special character (i.e. the @ character). Any way in which I can choose all the characters from an array to be filtered out?
|
You can just use a regular expression to character match.
if (!preg_match('/[!@£$%^]/', $name)) {
mail($to, $subject, $message);
echo 'Message sent';
} else {
echo 'Invalid character entered';
}
Here it's checking for the characters `!@£$%^` you specifically mentioned in your question, but _" I want special characters to be filtered out"_ is a bit vague, and I suspect you mean to include a few more characters in this. If you can be more specific about which characters you want to allow, we can refine the regex.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, html"
}
|
Laravel collection filtering to avoid null records
is there an inbuilt way to loop through collections and return only the objects that are meeting a specific condition?
like skip all records that has `$user->role === null`
|
You actually don't even need the `->filter` method if you're using `Eloquent`. If `role` is a relationship of your `User` model, you can simply call:
$users = User::has("role")->get();
This will automatically return only Users that have a `role`, or where `$user->role` is not null.
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 8,
"tags": "php, laravel, eloquent"
}
|
How to use filter, group by and agg function together in Python
I have a dataframe below:
A B C
0 asia 1000 ab
1 africa 2000 ab
2 asia 4000 bc
3 asia 6000 cd
4 USA 200 ab
I'd like to filter for column A = asia and sum column B group by column C. I am trying to use:
agg = df[df['A'] = 'asia'].groupby('C')[['B']].sum()
But it only returns one row with column B and sum amount of column C. I'd like to return the whole dataframe. How can I achieve that?
|
Try this:
df1 = df[df['A'] == 'asia'].groupby(['A', 'C'], as_index=False).sum()
print(df1)
A C B
0 asia ab 1000
1 asia bc 4000
2 asia cd 6000
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, python 3.x, pandas"
}
|
Set is reverse sorted by default for a list having negative integer
n = int(input())
arr = list(map(int, input().split()))
s = set(arr)
print(s)
print(list(s)[len(s) - 2])
**Input** :
4
57 57 -57 57
**Output** :
{57, -57}
57
I am trying to find the second largest number in the given list. In the above code the set is reverse sorted which should not be the case. Why is this happening ?
|
A `set` doesn't have a defined order of any kind. You need to convert the set to a `list` then explicitly sort it. `sorted` will produce a list automatically.
print(sorted(s)[-2] if len(s) >= 2 else None)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python 3.x"
}
|
How to to set width automatically?
I need to create a wrapper(container) with (from 2 to 4 div inside) like:
<div class="wrapper">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
my problem is that I CAN'T set the width for the inner divs, because they must have an equals width, so if my wrapper is 300px and I only have two inner divs (150px once) etc etc.
But I can't set the width into .css file, because as i told there can be from 2 to 4 divs.
The question is: is it possible to autosize the inner divs (to get the entire wrapper's width) or not?
Thanks!
|
You can use `display:table` property for this:
.wrapper{
width:300px;
border:2px solid green;
display:table;
}
.wrapper > div{
display:table-cell;
border:1px solid red;
height:50px;
}
Check this <
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "html, css"
}
|
A sweet little riddle
Here's a short little riddle.
You hang it on your tree.
You can stir it in your tea.
If you hap keep it handy,
You can give it to your dame.
Oh, it's a little ___________
Hint:
> Two words fill the blank ending in a rhyme. Happy Holidays, everyone!
|
Just a guess but I think it might be
> Candy Cane
Because
> It is an item often associated with Christmas and used in all the ways described in the poem.
|
stackexchange-puzzling
|
{
"answer_score": 5,
"question_score": 5,
"tags": "riddle, word, rhyme, poetry"
}
|
Wordpress child theme template not working with external jquery/javascript functions
I have created a template in my wordpress child theme and included a link to Bootstrap v3.0.3 .js file which is also hosted on my site.
the popup modal is working fine, however the jquery tabs are not.
They will display (using bootstrap.css) however, when navigating through the tabs they are not changing
i have pasted the full code from the page here: <
|
Can you try loading files like this?
function theme_enqueue_styles() {
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array($parent_style));
}
add_action('wp_enqueue_scripts', 'theme_enqueue_styles');
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/vanja-script.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
Place these inside your functions.php in the Appearance section. Here is the screenshot: < Then just place the files into the appropriate folders.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, css, wordpress"
}
|
Programmatically created WooCommerce order - set customer based on email instead of user ID
Im creating a WooCommerce order programmatically trough a form and I link the order trough the user id:
$order->set_customer_id( $user_id );
I retrieve the customer information via mail instead of ID:
$user = get_user_by( 'email', $email );
Is it possible to link the order to an existing customer via the existing email instead of the user id? Something like this:
$order->set_customer_id( $email );
Is this possible?
|
Function get_user_by() returns WP_User object, so you only need to take the ID from the object and substitute it into the function set_customer_id() from $order:
// $user - it is WP_User object
$user = get_user_by( 'email', $email );
$order->set_customer_id( $user->ID );
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "php, wordpress, woocommerce"
}
|
How can mod_rewrite choose the correct RewriteCond in an ElseIf logic in order to decide whether to add WWW or not?
I'm looking for the following logic:
1. If the Host has only 1 dot, add www (e.g. example.com will turn to www.example.com)
2. **Else** , **if** the Host starts with www, remove it (e.g. www.dummy.example.com will turn to dummy.example.com)
I'd like to keep it general, no `example.com` inside the code.
Here's what I have so far with what I need commented out:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ [L,R=301]
# ElseIf
# RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ [R=301,QSA,NC,L]
|
Have it like this:
RewriteEngine On
# check for single dot
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^ [L,R=301,NE]
# ElseIf check for www and 2 or more dots
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.[^.]+\..+)$ [NC]
RewriteRule ^ [R=301,NE,L]
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": ".htaccess, mod rewrite"
}
|
Condition on $\beta$
> Let $f(x)$ be a function such that $\lim_{x \to \infty}f(x)=1$ and $\lim_{x \to \infty}f'(x)=\beta$. Then **(1)** $\beta > 1$, **(2)** $\beta$ must be $0$, **(3)** $\beta$ need not be $0$ but $|\beta| < 1$, **(4)** $\beta < -1$.
How I proceed: Take $f(x)=\frac{1}{x}$ then $f'(x)=-\frac{1}{x^2}$. Here $\beta=0$.So, **(1)** and **(4)** is not true.I am stuck between **(2)** and **(3)**. Please help.
|
Firstly, to satisfy the condition $\lim_{x\to\infty}f(x)=1$, your choice of $f$ could be corrected as $f(x)=\frac{1}{x}+1$.
Secondly, by mean value theorem, for every $x$, there exists $c_x\in [x,x+1]$, such that $f'(c_x)=f(x+1)-f(x)$. Then $$\beta=\lim_{x\to\infty}f(c_x)=\lim_{x\to\infty}(f(x+1)-f(x))=0.$$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "real analysis, limits"
}
|
How to make certain javascript files render from php using htaccess
So I haven't quite figured out the proper structure to use within my .htaccess file for what I am looking to achieve.
What I would like to have happen is any javascript files that are called from a folder (and only that folder) are generated by a php file. I'm not looking to have a .php extension or create multiple files for this.
An example is
Would then be sent to something like:
Not looking to use a $_GET method on the php either. Basically the php file detects the file name and then does what it is supposed to do from there.
What would be the best way to set this up within an .htaccess file?
Thanks!
|
Inside `loads/.htaccess` you can use this rule:
RewriteEngine On
RewriteBase /loads/
RewriteRule ^[\w-]+\.js$ js.php [L,NC]
Inside your `js.php` you need to use `$_SERVER["REQUEST_URI"]` to get original JS filename and serve the content.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 6,
"tags": "javascript, php, .htaccess"
}
|
Can I override individual maven plugin settings in settings.xml (or elsewhere)?
My team uses a plugin that generates javadocs that adds about 20 - 30 seconds to our build time. I don't ever use these javadocs, so I would like to eliminate them from my build.
Changing the POMs is not possible for various reasons, so I can't add a profile to conditionally use those (even if they default to true!).
My read of the docs suggests that this is not possible in settings.xml since it's a truncated version of and doesn't contain .
How can I override plugin settings locally?
|
Skip it using a system property:
mvn -Dmaven.javadoc.skip=true clean install
You can change some behavior using system properties, e.g. the value of the configuration settings `skipTests` is bound to the user property `skipTests`, so when you invoke Maven with `-DskipTests=true`, it will implicitly set this value.
However, that works only if a) your POMs rely on properties to make configurations, b) your POMs do so far not set these configuration settings explicitly and c) it is not some special value that cannot be set via properties, e.g. config settings that accept multiple values such as some "includes/excludes" settings.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "maven, pom.xml"
}
|
How to move (and overwrite) all files from one directory to another?
I know of the `mv` command to move a file from one place to another, but how do I move all files from one directory into another (that has a bunch of other files), overwriting if the file already exists?
|
It's just `mv srcdir/* targetdir/`.
If there are too many files in `srcdir` you might want to try something like the following approach:
cd srcdir
find -exec mv {} targetdir/ +
In contrast to `\;` the final `+` collects arguments in an `xargs` like manner instead of executing `mv` once for every file.
|
stackexchange-stackoverflow
|
{
"answer_score": 24,
"question_score": 67,
"tags": "linux, unix"
}
|
How to find out which rails version an existing rails application is built on?
In general, the question I have is the question in the title:
How do I find out which rails version an existing rails application is built on?
More specifically for my purposes, I would like to know how to find out in the case when there is no gemfile (I'm relatively new to rails and used to seeing the rails version in the gemfile with all the rails 3 apps, but am not sure for older versions.)
|
`rake gems` will print out what gems, dependencies, and versions are installed, frozen, etc.
If you are using bundler than you can use `bundle show` to list all the gems that your app is using.
|
stackexchange-stackoverflow
|
{
"answer_score": 27,
"question_score": 43,
"tags": "ruby on rails"
}
|
Devolver el total de montos por mes en un procedimiento almacenado en SQL Server
Debo crear un procedimiento almacenado que se ejecute automáticamente al momento que yo haga registros de una tabla, esta tabla contiene las siguientes columnas.

AS
BEGIN
SELECT MES, MONTODEBITOFLOAT FROM PRUEBAOPEX
END
De momento tengo así mi estructura. No tengo claro cuantas variables debería crear, si una por mes. O si debo utilizar más parámetros.
De antemano muchas gracias.
|
La solución pasa por una consulta que sume el monto y agrupe ese valor por el mes. El procedimiento no requiere de parámetros::
CREATE PROCEDURE SP_GRAFICOLINEAL
AS
BEGIN
SELECT MES, SUM(MONTODEBITOFLOAT) AS MONTO
FROM PRUEBAOPEX
GROUP BY MES
END
|
stackexchange-es_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql server, stored procedure"
}
|
Wicket - passing control between modal window and form
I'd like to have a modal window that gets displayed when the user submits a form. Inside the modal window is a second form that the user has to fill in and submit. If the second form has no errors, then the original form should get submitted, too. If the second form has error, the original form should not get submitted.
Can I achieve this in Wicket in a relatively clean way? Our current solution uses Javascript, but it feels very hacky and the code is very hard to comprehend.
|
The event bus in Wicket 1.5 seems to be the right solution.
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "wicket"
}
|
What files does affect apt-get purge¿?
I want to know before doing `apt-get purge <packet>` what files thats gonna have effect on. The reverse thing would be, what packet do I have to do purge if I want to remove that file (`apt-file search <file>`), but my question is the first one. Hope I made myself clear, thank you in advance
|
The command `apt-get purge` is mostly identical to `apt-get remove`, but `purge` also deletes any configuration files. Often you will want to keep those as they can hold local changes that will be lost permanently if you delete them.
You can use `apt-file list <package_name>` to list out what files belong to a specific package. These files are the ones that will be deleted by `apt-get purge`. You can also use `dpkg-query -L <package_name>`
|
stackexchange-unix
|
{
"answer_score": 1,
"question_score": 1,
"tags": "files, apt"
}
|
How to check how many participants are connected to my chat room using socket IO
Here is an excerpt of the code I am using to make a connection to my chat room...
io.on('connection', function(socket) {
var col = db.collection('messages');
sendStatus = function(s){
socket.emit('status', s);
};
//emit all messages
col.find().limit(100).sort({_id:1}).toArray(function(err, res){
if(err) throw err;
socket.emit('output', res);
});
socket.on('input', function(data) {
...
... etc
What code can I implement to check how many users or participants are connected to my chat room.
I heard of a method `clients()` but I'm not sure if that's what I need to use or how to use it.
|
In the latest version of socket.io, you can see how many sockets are in a given chat room with this:
io.sockets.adapter.rooms["testRoom"].length
Where `testRoom`is whatever the name of your chat room is (whatever you used `.join()` with.
* * *
io.sockets.adapter.rooms["testRoom"]
is an Object where each property name except `.length` is the socket.id of the socket that is in the chat room.
* * *
FYI, the code you show in your question doesn't appear to have anything to do with socket.io chat rooms so that has me a bit perplexed.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, node.js, socket.io"
}
|
How to force terminating a cloud function?
I unfortunately ran to an infinite loop of cloud function ,It's being executing since yesterday without stopping ,please don't tell me how to avoid this problem because I'm fully aware of this but I ran to this issue by mistake ,I just want to know why firebase team did not yet develop a way allowing developers to force terminating such functions.
|
You can stop a function from executing by undeploying it. Comment it out of your index.js and run `firebase deploy` again.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 3,
"tags": "google cloud functions"
}
|
"branch is up-to-date with origin" but actually not
Is the message a bit mis-leading?
When checkout a branch (eg., `b535`), git does it and says **"Your branch is up-to-date with 'origin/b535'."** That sounds like what I have in my local branch `b535` is up-to-date.
$ git checkout b535
Previous HEAD position was 8aa0145... master - resyns
Switched to branch 'b535'
Your branch is up-to-date with 'origin/b535'.
**But actually it's not**. When doing a `git pull`, it found updates from remote and updating local branch.
$ git pull origin b535
remote: Counting objects: 39, done.
remote: Compressing objects: 100% (39/39), done.
remote: Total 39 (delta 31), reused 0 (delta 0)
Unpacking objects: 100% (39/39), done.
...
|
Well, your branch is up to date with the last _known_ position of origin/b535. If you want `git status` to give you more accurate info without having to do a `git pull`, do a `git fetch` instead. This will update origin/b535, without changing your local b535.
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 5,
"tags": "git"
}
|
How can I apply error reporting in Magento 2?
I googled out how to apply error reporting in Magento 2, but I didn't find any solution yet. It will be useful if there is any link.
|
> By default Error reporting are possible in frontend using developer mode.
Run command,
Using Developer mode, you can directly check error in frontend browser if any error are occur,
php bin/magento deploy:mode:set developer
Changes in file,
Go To **pub** folder of root and rename at below path,
pub/erros/local.xml.sample to local.xml
Now go to `app/bootstrap.php` file,
Remove # from initial,
**#ini_set('display_errors', 1);**
to
**ini_set('display_errors', 1);**
|
stackexchange-magento
|
{
"answer_score": 5,
"question_score": 3,
"tags": "magento2, error log"
}
|
How can I draw a commutative diagram without the arrows overlapping?
I am trying to draw a commutative diagram as follows.
\usepackage{tikz-cd}
\usepackage{newtxmath}
\begin{document}
\[
\begin{tikzcd}
& P \arrow[d, "\pi_i" near start] &\\
& P_i \arrow[u, "\iota_i" near start] \arrow[d, "\phi" near start] & \\
M \arrow[r, "\psi"]&N \arrow[r] & 0
\end{tikzcd}
\]
\end{document}
The problem is that the parallel arrows overlap causing the diagram to look bad.
 and the database driver were wrapped in NetBeans modules. After that everything started working.
I guess Maven/NetBeans is misleading on that aspect since the modules compile if you have appropriate dependencies.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "maven, persistence, netbeans platform"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.