INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Avoiding forum style usage and promoting SE style Q and A
There is a question on the parent site that has become like a forum (follow-up questions and responses posted as answers). The question is complicated because the person asking included several issues together, which txwikinger pointed out in a comment. It does appear to be on-topic, but I'm not sure it is helping anyone in its present state.
Is there anything that can be done to steer that question in a more Stack Exchange Q&A direction? | In general, users need to be encouraged to **edit their existing question** (or answer) rather than adding more answers or more questions.
edit, edit, _edit!_
... should be your first impulse, not clicking "new question", or "new answer" | stackexchange-meta_askubuntu | {
"answer_score": 5,
"question_score": 4,
"tags": "support, answer format, moderation"
} |
List folder permission doesn't show subfolders
I have situation described below.
Z:\SHARE (shared | Everyone Read\Change) Authenticated users group has NTFS permission "List folder contents"
Z:\SHARE\Foo Only john.doe has permission to enter that directory
Z:\SHARE\Bar Only alan.smith has permission to enter that directory
The problem is when Joe or Alan enter the share they see only that folder to which they have permission to enter.
Shouldn't they see both folders, cause of Authenticated users permission? | The reason of that problem was Access-based enumeration. It is enabled so users can see only folders which they have direct access to. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "windows, permissions, ntfs, network shares, shared folders"
} |
Move unique values across different dimensions
I have a requirement where I want to convert a 2D matrix to 3D by separating 3 unique values across 3 dimensions. For Example: convert
A = [1 2 3 3
1 1 2 1
3 2 2 3
1 3 3 2]
to
A = [[1 0 0 0
1 1 0 1
0 0 0 0
1 0 0 0]
[0 1 0 0
0 0 1 0
0 1 1 0
0 0 0 1]
[0 0 1 1
0 0 0 0
1 0 0 1
0 1 1 0]]
Pardon me if the syntax of matrix representation is not correct. | Use `broadcasting` with `outer-equality` for a vectorized solution -
# Input array
In [8]: A
Out[8]:
array([[1, 2, 3, 3],
[1, 1, 2, 1],
[3, 2, 2, 3],
[1, 3, 3, 2]])
In [11]: np.equal.outer(np.unique(A),A).view('i1')
Out[11]:
array([[[1, 0, 0, 0],
[1, 1, 0, 1],
[0, 0, 0, 0],
[1, 0, 0, 0]],
[[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 1, 1, 0],
[0, 0, 0, 1]],
[[0, 0, 1, 1],
[0, 0, 0, 0],
[1, 0, 0, 1],
[0, 1, 1, 0]]], dtype=int8)
To use the explicit `dimension-extension` \+ `comparison`, it would be :
(A == np.unique(A)[:,None,None]).view('i1') | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, python 3.x, list, numpy"
} |
reference in Montgomery/ Zippin
In a paper, the authors use the reference [M–Z, Theorem in 4.13] where [M-Z] denote the book D. Montgomery and L. Zippin, Topological Transformation Groups. Interscience Publishers, New York–London, 1955.
Unfortunately, I have no access to the edition of 1955 of this book. I would be very grateful if you would help me to know the theorem. | The part 4.13 has 3 pages, here are the scans: 188, 189, 190. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "reference request, lie groups, locally compact groups"
} |
Show only rows that contains specific value in specific row
I need to sort all the rows only to show the rows that contain same `Session["ID"]` in the `userId` column.
This is my code
public void GetAllUsers()
{
Response.Write("<table border='1' class='tables'> <tr>");
Response.Write("<td align='center'>שם המשימה</td>");
Response.Write("<td align='center'>פירוט המשימה</td>");
Response.Write("<td align='center'>מועד אחרון</td>");
foreach (DataRow row in ds.Tables[0].Rows)
{
Response.Write("<tr>");
Response.Write("<td align='center'>" + row["title"].ToString() + "</td> ");
Response.Write("<td align='center'>" + row["description"].ToString() + "</td> ");
Response.Write("<td align='center'>" + row["isDone"].ToString() + "</td> ");
Response.Write("</tr>");
}
Response.Write("</table>");
} | Do you mean this:
foreach (DataRow row in ds.Tables[0].Rows)
{
if (row["userid"].ToString() == Session["ID"].ToString())
{
Response.Write("<tr>");
Response.Write("<td align='center'>" + row["title"].ToString() + "</td> ");
Response.Write("<td align='center'>" + row["description"].ToString() + "</td> ");
Response.Write("<td align='center'>" + row["isDone"].ToString() + "</td> ");
Response.Write("</tr>");
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "c#, html, sql, asp.net, datatable"
} |
Where can I find the Adobe Flash Player changelog or full release history?
I'm familiar with the Flash Player archives at Adobe, but I'd like to see the changelog for every minor public release of the Flash Player. I've been searching with Google and on Adobe's site and still haven't found it. We know the side-effects of the most recent releases VERY WELL, we just can't find a changelog that documents what Adobe has changed that has broken many of our web applications. Does anyone know where this changelog/release history documentation lives? | You can check their website: < | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "security, flash, flash player"
} |
An exercise about compactness
> Let $X$ be the set of all bounded sequences of complex numbers. That is, $\left\\{x_{n}\right\\} \in X$ $\iff$ sup $\left\\{\left|x_{n}\right|: n \geq 1\right\\}<\infty .$ If $x=\left\\{x_{n}\right\\}$ and $y=\left\\{y_{n}\right\\},$ define $d(x, y)=\sup \left\\{\left|x_{n}-y_{n}\right|: n \geq 1\right\\} .$ Show that for each $x$ in $X$ and $\epsilon>0, \bar{B}(x ; \epsilon)$ is not totally bounded although it is complete. (Hint: you might have an easier time of it if you first show that you can assume $x=(0,0, \ldots$.)
I don't have any way to start. | **Hint:** First consider the case $x = (0, 0, \ldots)$. Define a sequence $(y_n)_{n \in \mathbb{N}}$ in $\bar{B}(x; \varepsilon)$ by
$$y_n(m) = \begin{cases} \varepsilon, & \text{if m = n} \\\ 0, & \text{otherwise}. \end{cases}$$
Now consider $d(y_n, y_m)$ for $n \neq m$ and conclude that $(y_n)_{n \in \mathbb{N}}$ cannot have a convergent subsequence. | stackexchange-math | {
"answer_score": 1,
"question_score": -3,
"tags": "general topology, complex analysis"
} |
In Vim, how to match pattern only if it occurs once?
I have the following text :
Line 1 : orange blackberry orange coconut
Line 2 : orange
Line 3 : blackberry coconut blackberry
Line 4 : pear orange apricot
I want to find the lines where "orange" occurs only once, i.e. lines 2 and 4 (for "blackberry", it would be line 1 only).
I tried a negative lookahead construct (orange NOT FOLLOWED BY orange) but failed miserably…
/orange\(.*orange\)\@!
gave me line 2 and 4 but also, as I should have foreseen, the second instance of orange in line 1.
How should I proceed ?
Thanks in advance | You may use
/\(orange.*\)\@<!orange\(.*orange\)\@!
where
* `\(orange.*\)\@<!` \- a negative "lookbehind" that makes sure there is no `orange` anywhere before the current position on the line
* `orange` \- an `orange` substring
* `\(.*orange\)\@!` \- a negative "lookahead" that makes sure there is no `orange` anywhere after the current position on the line.
Very magic mode notation:
/\v(orange.*)@<!orange(.*orange)@! | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 6,
"tags": "regex, vim"
} |
What is the difference between a node and a vertex?
What is the difference (if any) between a node and a vertex? I can't find the answer after looking at countless sites! Even my book doesn't specify it so I am kind of lost!
_It is worth mentioning that I am looking for the difference besides the fact that it is called a 'vertex' when used in a graph and a 'node' when used in a tree._ | There are no differences between the words **Node** and **Vertex**. Even in some books that explain graph theory and graph algorithms they name it as:
> _Vertex denoted by v, and sometimes it's called nodes also_
There are no major nor minor differences between them.
This is mentioned in the book: Data structure and Algorithms with Object Oriented Design Patterns in C#, Bruno R, Preiss. | stackexchange-stackoverflow | {
"answer_score": 60,
"question_score": 53,
"tags": "graph, tree, nodes, vertex"
} |
Scala sum aggregation issue
here is my code which prints toString method of InternalSum and i want actual numeric sum to be print on screen but it's not giving me any further method to retrieve the sum
val sumSalary = client.execute {
search("myindex") aggregations sumAgg("sum_salary_aggregation", "salary")size 0
}
sumSalary.map(f => println(f.original.getAggregations.get("sum_salary_aggregation")))
output : org.elasticsearch.search.aggregations.metrics.sum.InternalSum@2bef9178 | It seems like to you need to call `.value()` on the result.
Specifically:
sumSalary.foreach(f => println(f.aggregations.sumResult("sum_salary_aggregation").value())) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "scala, elasticsearch"
} |
How to implement a jQuery slide/bounce animation?
Basically I would like to have a DIV slide out and do a slight bounce where it goes past it's final size and then returns. Not sure how to explain it so please see my attempt at a diagram below:
---------------------> //Slides out
<---- //Then "bounces" back to it's final size
I have the first part down using the toggle animation:
$("#second").animate({ width: 'toggle' }, 85);
I thought I could get the bounce effect by doing:
$("#second").animate({ width: 'toggle' }, 85).animate({ width: 'toggle' }, 75);
But it disappears. After reading over the animate/toggle documentation I guess this makes sense, but I'm still not sure how to get the desired functionality. Any suggestions?
Bonus points if you can make it so the content of the sliding div is cut off rather than being pushed to the next line. | I was able to implement it this way:
$("#second").animate({ width: 'toggle' }, 250).animate({ width: '-=10' },185);
Seemed like the most straight forward way. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "jquery, jquery animate"
} |
General method for unpacking and combining nested tuples
I've generated the cartesian product of three dicts thus:
import itertools
combined = list(itertools.product(foo, bar, baz))
So my list now looks like:
[(('text a', 'value a'), ('text b', 'value b'), ('text c', 'value c')), … ]
What I want to do is unpack this list such that I end up with a list of lists containing the flattened nested tuples' text and values:
[['text a text b text c', 'value a value b value c'], … ]
Is there an efficient general method for doing this?
Follow-up (having seen Dan D.'s answer):
What if my tuples looked like
(('text a', float a), ('text b', float b), ('text c', float c ))
and I wanted to add the floats instead of concatenating the values? | You don't have to cram everything on one line:
def combine(items):
for tuples in items:
text, numbers = zip(*tuples)
yield ' '.join(text), sum(numbers)
print list(combine(product( ... ))) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "python"
} |
Requirements for implementing _rvs in subclass of scipy.stats.rv_continuous?
I'd like to implement a particular distribution in terms of the `scipy.stats.rv_continuous` class, and I'd like to provide my own implementation of `_rvs` but I don't understand what arguments come into it (it's just `*args` in the function declaration).
In particular, I don't see how the `size` parameter feeds into the call to `_rvs` via the `rv_generic.rvs` function call (line 665 in online source).
My distribution does not have any parameters (other than `loc` and `scale`), so if `_rvs` just needs to return 1 random value, I could do that with an empty argument list, but it seems like it needs to return a (flat) array of random values, how do I obtain the number of elements to return? | The `scipy.stats.rv_continuous` class is a subclass of `rv_generic`. The latter defines a `rv_generic.rvs` function that calls `self._rvs` after having set its `self._size` variable to either `None`, or a specific number. This is done by reading the keyword arguments stored in `**kwds` and checking for a `size` parameter.
Usually, when `self._size` is `None`, distributions return a scalar and otherwise return an array of length `self._size`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, statistics, scipy"
} |
Mysql Search for Domain Names
I have a table full of domain names. I'd like to do a search that returns some kind of relevancy results on it. My problem, is that if I do a search for "cool" I want it to return "cooldomain.com", which a fulltext search, unless I'm doing it wrong, will not.
Are there any fulltext options I'm unaware of that will accomplish this? If not, how would I go about doing it? | I'd use LIKE here, fulltext search is for matching against full words or expressions, query expansion, etc. And I think the `*` operator can only be used as a suffix when using MATCH, so you'll miss imcool.com...
I think you'll have to gather more information to make a relevancy sorting.
**Edit:** If you want to use an index, you can also store the words of the domain in another column, and use the power of fulltext search on this one... | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "mysql, search, full text search, domain name"
} |
iPhone - At user event create objects in the view
I am new to iPhone programming, so I think part of the problem is that I don't know what I really want to google to find my answer. I am looking for a method that allows a user to draw a line on the screen. There is no guarantee that it will be straight, it can be curved or whatever. I was thinking that I could create some small square image, and then as they draw, place them into a NSset. But I am not really sure how to communicate each new object up to the view. Up to this point, I've just been messing around with objects I put on the view and then assign movement to those, this is my first jump into on-the-fly object creation.
It might be that I just need to jump into a class/object type or even a tutorial, any guidance would be great.
Thanks! | Are you asking how to create a 'paint' type application? There's an apple example for that:
<
This question is relevant, but might be too complex when you're just starting out:
Improving Finger Painting Performance
If you're a bit more specific about what problem your app is to solve you might get some more specific answers. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "iphone"
} |
FileStream not closing file
I have the following code:
using (MemoryStream str = new MemoryStream())
{
Program.api.GetDocument(result, str);
using (FileStream fileStream = File.Create(filePath))
{
str.WriteTo(fileStream);
}
}
Whenever a file is written, it is always locked afterwards - attempting to delete it or modify it causes Windows to tell me the file is in use, even after closing my application. Am I missing something? | Your problem is most likely caused by Windows Search Indexing which is a part of Windows Search. If you attempt to access the file immediately (or very shortly) after modifying it, you may run into the sort of issues you are seeing. The best way around this is to add retry logic to the file operation you are performing, which waits some small period of times and re-attempts the file op.
If you would like to confirm that the problem is cause by Windows File Search Indexing, you can disable it for the file type and/or location where you are writing your file to see if that makes the problem go away. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 9,
"tags": "c#, filestream, memorystream"
} |
Extract List from Lists and Print each List with a new format - Python 3.6
I have a list in the following format, including the extra square brackets on the ends:
[[[['10.0.0.0-E', '10.0.0.0-B'], ['172.0.0.0-E', '172.0.0.0-B'], ['12.0.0.0-E', '12.0.0.0-B']]]]
I would like to take this list and print out the following:
10.0.0.0-E - 10.0.0.0-B
172.0.0.0-E - 172.0.0.0-B
12.0.0.0-E - 12.0.0.0-B
Are the extra brackets screwing me up?
I've tried this..
newList = []
for item in result:
newList.append(item[0].split(","))
print(newList) | Your list is a list inside a list inside a list, which explains the extra brackets.
This works:
result = [[[['10.0.0.0-E', '10.0.0.0-B'], ['172.0.0.0-E', '172.0.0.0-B'], ['12.0.0.0-E', '12.0.0.0-B']]]]
for item in result[0][0]:
print(f'{item[0]} - {item[1]}')
`result[0][0]` selects the first element of `result`, a list, and then selects its first element, another list - the for loop then assigns each element of that list to `item` one at a time.
`print(f'{item[0]} - {item[1]}')` takes that item and prints a formatted string like you need:
10.0.0.0-E - 10.0.0.0-B
172.0.0.0-E - 172.0.0.0-B
12.0.0.0-E - 12.0.0.0-B | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, python 3.6"
} |
PHP/Laravel get last word in a a class name: App\Models\Example\Class; and lowercase it: class
Anyone see a simpler/cleaner way of going about this? I have polymorphic types that are stored as a full class name and I need to access the last word in the class and lowercase it to locate a config file:
Examle: `$this->ant_type = App\Models\AntTypes\Request`
$antTypeArray = explode('\\', $this->ant_type);
$workflow = strtolower(array_values(array_slice($antTypeArray, -1))[0]);
It certainly works fine, just curious if there's an even simpler way to go about it. I'm using Laravel 5.7. | I think you can do this with PHPs `ReflectionClass`.
$workflow = strtolower((new \ReflectionClass($this->ant_type))->getShortName()); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "php, laravel, laravel 5, php 7, laravel 5.7"
} |
How many ways can a person select $3$ out of $10$ math questions while selecting at least one of four geometry questions?
A person needs to select 3 out of 10 math questions and will have to select at least one geometry question out of 4 available, in how many different ways can he select his questions?
I tried: There are 4 ways to choose the required geometry problem, and ${9\choose 2}$ to select the other 2, so my answer is $4 {9\choose 2} = 144$, but my textbook says the answer should be $100$, what am I missing? Thanks! | The short answer is you're over counting. The long answer is:
You want to choose at least one geometry problem. There are two main approaches, one shorter than the other. Starting with the longer approach first:
The number of ways of choosing at least 3 geometry problems = number of ways of selecting exactly 1 + number of ways of selecting exactly 2 + number of ways of selecting exactly 3
So its: $$\sum_{i=1}^3 \binom{4}{i}\binom{6}{3-i} = 100$$
The shorter way is: Consider all the ways of selecting 3 problems, and from that, subtract the number of ways of selecting no geometry problems (because you always select at least 1): $$\binom{10}{3} - \binom{6}{3} = 100$$
Note that in your working, you're over counting (for example note that picking one geometry problem is a subset of picking two geometry problems). I'd suggest looking into the principle of inclusion and exclusion if you want to follow your line of reasoning. | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "combinatorics, discrete mathematics"
} |
Why is the use of cin, cout or %I64d preferred over %lld specifier in C++?
Why do many of the online judges advise _" do not use the `%lld` specifier to read or write 64-bit integers in С++"_?
Is it preferred to use the `cin`, `cout` streams or the `%I64d` specifier? | I believe the answer is related to `%lld` means `long long decimal`, which isn't guaranteed to be 64-bit. It could be, for example 128 bit on some systems. (Although if the variable is `long long` rather than, say, `uint64_t`, then I expect `%lld` is the right thing to use - or it would go wrong the other way around)
Unfortunately, the design of `printf` and `scanf` and their siblings is such that the compiler implementation and the format must match.
Obviously, `cout` and `cin` are safe in the sense that the compiler will chose the right output and input translation in itself.
It may also have something to do with what compiler(s) the "online judges" use - I think Microsoft compilers at some point supported 64-bit integers, but not `long long`, and thus didn't have `%lld`, but did have `%l64d`. | stackexchange-stackoverflow | {
"answer_score": 16,
"question_score": 23,
"tags": "c++, 64 bit, iostream, format specifiers, long long"
} |
Android studio- Can't run library project?
I am trying to run a project that is android-library plugin in Gradle and I get this error in run configurations: "The module cannot be Android library". The project is running as regular Android plugin. Is there any way to run android library in Android studio? | You cannot run an Android library project using any tool. An Android library project is a library, not an app. You cannot generate an APK from an Android library project. Instead, you attach an Android library project to another app.
You can read more about library projects in the developer documentation. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "android, android studio, android library, run configuration"
} |
R shiny display formula
I want to display correctly formula in Shiny title, like in Latex:
X_n=X_{n-1}-\varepsilon_n
shinyUI(pageWithSidebar(
headerPanel("Display formula in heading X_n=X_{n-1}-\varesilon"),
sidebarPanel( ),
mainPanel( )
)) | You can use `withMathJax`
require(shiny)
runApp(
list(ui = pageWithSidebar(
headerPanel(withMathJax("$$\\text{Display formula in heading }X_n=X_{n-1}-\\varepsilon$$")),
sidebarPanel( ),
mainPanel( )
),
server= function(input, output, session){
}
)
)
!MathJax example | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 7,
"tags": "r, formula, shiny"
} |
AWStats: page views by country (locale)
I know there is a way to see who (who meaning which countries, not specific IP addresses) views your website, and how many pages they view under "Locales"; however, I am trying to understand who views a specific page on my website and how often they view it. Is there a way to see page views by country? | I recommend using Google analytics. You can define custom reports like this:
* Metrics: Pageviews, any other metric that you are cerious about :P
* Dimension: Page
And then apply. Then add a secondary dimension "Country". You will be able to see how many times a page is viewed in each locacle. | stackexchange-webmasters | {
"answer_score": 1,
"question_score": 2,
"tags": "page views, awstats"
} |
Can I bin data in SQLite?
I have a lot of rows with dates in some SQLite database. I'd like to get some aggregated statistics for weeks or some other periods.
Is it possible to bin data in SQLite (i.e. get some number which corresponds to the number of the period - e.g. week)? | To create a column of unique week identifiers use strftime('%Y%W', date_column). More info here.
For your purposes I believe a "SELECT ... GROUP BY strftime('%Y%W', date_column)" should work. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "sqlite"
} |
Assign an object in a select in angularjs
I modified the original plunker of
original documentacion ng-options
I am trying to assign in the "bogus" button the black object.
It is the same object but is not selected in the drop down with ng-model binding
{name:'black', shade:'dark'}
you can see in
plunker forked
Why the double binding is not working??? | It's because it's not the same object, try using a filter to get your black item as in this plunker
$filter('filter')($scope.colors, {name : 'black'});
If you use a console.log of the $filter black item you'll see there is a $$hashKey: "object:3" value added to the item, that's why it doesn't take it as the same object. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "angularjs, angularjs ng options"
} |
Objective C - how to get current time in ISO 8601 format?
How would I get the current time in ISO 8601 format? It should look something like 2011-11-16T22:06Z | use a simple NSDateFormatter call for that -- "yyyy-MM-dd'T'HH:mmZ" or some such. (Don't forget to set Locale to avoid the AM/PM mess.) | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 4,
"tags": "objective c, date"
} |
ExpectedError: Error: Max connection attempts reached
 and also 4 types of data related to this tags table like(articles,resources,jobs,...).
The big question is:- for the relation with tags what best solution for optimazaion & query speed?
1. make a table for each relation like:
* table articlesToTags(ArticleID,TagID)
* table jobsToTags(jobid,tagid)
* etc.
2. or put it all in one table like
* table tagsrelation(tagid,itemid,itemtype)
I need your help. Please provide me with articles to help me in this design
consider that in future the site can conation new section relate to tag
Thanks | I would go for the normalized version of your schema (which is the table-relation). This type of schemas are very useful for scenarios where the application might grow.
The bad thing of having all the data in just one table is that if you have a bunch of attributes for both relationships, you'll end up with a table with a lot of attributes, which when growing will be slow to query, thus becoming a performance hit of your app.
So, finally the problem is to choose simplicity and quick end against well designed code considering scalability as well.
Hope I can help | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 5,
"tags": "sql, database design"
} |
Installed ffmpeg but i'm getting a "no such file or directory" error
I have installed ffmpeg and I can run it perfectly find when using the "ffmpeg" from the command line. But I am trying to run ffmpeg from PHP and when I use the bare ffmpeg command, I get " **sh: ffmpeg: command not found** ". So instead of just the bare ffmpeg command, I used the whole folder location **/home/vibe/public_html/libraries/ffmpeg/ffmpeg** but now I get the "no such file or directory" error.
Anyone know how I can solve this? Much appreciated. | You have to adapt the configuration of your webserver... normally ffmpeg and stuff like that is installed in the same directory, for example /something/bin. So everytime you want to execute something in the shell, the OS will look into the /bin-folder. If ffmpeg is installed somewhere else (obviously it is in your case), you have to add the path to your path-variable, so the OS knows that it has to look there, too. Beside this, you should not install executables in your public_html folder! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, ffmpeg"
} |
"The name ProfileCommon does not exist in the current context"
..been browsing the net but no luck.. I need to use the ProfileCommon but I can't reference any assemblies to use it.. can someone help? | When you have an ASP.NET web site, not application project, and make use of Profile the ProfileCommon file gets autogenerated in the temporary ASP.NET files. When you're using an ASP.NET project however you'll need to create that on your own. Take a look at this sample on how to implement it on your own. The sample is for usage in an MVC application project but since that's based on ASP.NET itself the concepts remain the same. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "asp.net"
} |
All Bipartite Graphs on n number of vertices
I need to find a list of all connected bipartite graphs on 15 vertices.
< lists all graphs on 14 or fewer number of vertices.
< says there are 575 252 112 such graphs. | Try
geng -bc 15 conbip.g6.txt
with the program geng from Brendan McKay's nauty package, available from <
The list of connected bipartite graphs with n = 14 vertices is 74MB compressed and requires a few minutes to generate. The list for n = 15 may take a while to complete and the resulting file will be large. | stackexchange-math | {
"answer_score": 7,
"question_score": 2,
"tags": "graph theory"
} |
Android tethering web server
I am looking for a method to display a webpage when somebody connects to my hotspot
.Is there a way I could implement this? | Not sure what the Android access restrictions are, but assuming your app has the network read / write / bind permissions, the simplest thing to do is simple embed Jetty and get it to start a server on the specified port, example are : <
EDIT: Upon further reading of your question that's just the start, you will need to block all other network traffic until the client has accepted the captive portal above.
Hope I helped
md_5 | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "android, wifi, tethering"
} |
Lion kills application behind the scene, how to put application on a do not kill list?
I am encountering an irritating feature of Lion.
Say I spend 30 minutes in XCode, then I go to iChat to talk to my girlfriend for 5 minutes, then I switch to Safari to check StackExchange, gmail, and whatever else I might want to check.
Then I switch to Safari where I run another set of pages. For 5 or 10 seconds, the app resumes with beachball. This is annoying as hell (switch appnames around, they behave the same).
How can I prevent this from happening at all (unlikely) or at least mitigate it by making a list of apps that are not allowed to go into silently-killed mode? | You can't. Check out this thread on the Apple discussion forum. You can also read this article from TUAW. | stackexchange-apple | {
"answer_score": 4,
"question_score": 6,
"tags": "macos"
} |
Automate jitsi java application windows Desktop with pywinauto
I am using jitsi windows Desktop for test voip service product.jitsi is a java windows application I want automate jitsi for do it i use pywinauto is a python library for automate gui windows application and i use inspect.exe. but when i use inspect.exe for find Dialog and element i don’t see any thing that show buttom and any thing else. so i couldn’t automate jitsi yet and I would be thankful if you show me a possible path for automation.
);
The data is added to the form as a hidden field using this variable:
$dateserial = htmlspecialchars(serialize($dates)); | `magic_quotes_gpc` is enabled in `php.ini` on the new server and "magically" escaping quotes with a `\` which is translated into `%5C` by `urlencode`.
So turn it off. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, forms, get"
} |
Congruence through Groups
I was reading proof and have gotten stuck in a place. I needed some help understanding a statement they have made:
Let $G$ be a group of order $pqr$. Let $P,Q,R$ be Sylow subgroups of $G$ of order $p,q,r$ respectively. Let $\nu_p,\nu_q,\nu_r$ denote the number of Sylow subgroups of order $p,q,r$ respectively. Then, they have proved that at least one of $\nu_q,\nu_r$ must be $1$. I have understood this.
Let that subgroup be $X=\langle x \rangle$ and it will be normal to $G$ by Sylow's Theorem on conjugates. Let $P=\langle a \rangle$ ($P$ must be of order $p$ by Lagrange's theorem and hence cyclic. Similar reasoning for $X$.) Suppose $X$ is of order $l$.
> Let $axa^{-1}=x^i.$ Then, $x=a^pxa^{-p}=x^{i^{p}}$. Hence $i^p \equiv 1 \textrm{ mod }l$. Since, $i^{l-1}\equiv 1 \textrm{ mod }l...$.
I did not understand how they arrived at the last statement, i.e., "Since, $i^{l-1}\equiv 1 \textrm{ mod }l$. " Please help. !enter image description here! | This is a consequence of Fermat' little theorem: if the integer $a$ is not divisible by the prime $p$, $$a^{p-1}\equiv 1 \mod p.$$ Then just see that $l$ must be a prime and, by Lagrange's Theorem, $i$ does not divide $l$. | stackexchange-math | {
"answer_score": 2,
"question_score": 3,
"tags": "group theory, finite groups, sylow theory"
} |
Unable to install phpmyadmin in ubuntu 14.04
I'm following this link: click here!
I ran
sudo apt-get update && sudo apt-get install phpmyadmin
Then I restarted apache2 by using this command:
sudo service apache2 restart
Then I went to < in browser and I got this error:
Not Found
The requested URL /phpmyadmin was not found on this server.
Where did things go wrong?
P.S: This is the 3rd time that I'm trying to install `phpmyadmin`. | Look at this: <
You have to edit your conf file | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "php, ubuntu, phpmyadmin"
} |
Make walking leap character
I've got issues working with leap motion.
I want to make a walking leap character so I add a leap motions controller actor in my character viewport but when I make character move (with add movement input blueprint block) the hands don't follow the character...
Thanks in advance, | It should work if you parent the controller actor correctly. However, we are currently recommend that people use the < plugin instead. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "controller, leap motion, unreal engine4"
} |
invalid value 'edge' in 'fsantize-coverage=edge' when using LLVM LibFuzzer
< I'm doing some works with libfuzzer now but when I do with the official toy example. when i run this command:
clang++ -fsanitize=address -fsanitize-coverage=edge test-fuzzer.cc Fuzzer*.o
there is an error happening that
clang: error: invalid value 'edge' in 'fsanitize-coverage=edge'
it seems that clang supports this argument but i'm wondering how i can see what value is supported... i installed llvm 3.6 by apt-get with unbuntu14.04... | The syntax of the `fsanitize-coverage=` flag has been changed, as described in this commit message from May 2015. This bit is particularly relevant to you:
Original semantics of -fsanitize-coverage flag is preserved:
* -fsanitize-coverage=0 disables the coverage
* -fsanitize-coverage=1 is a synonym for -fsanitize-coverage=func
* -fsanitize-coverage=2 is a synonym for -fsanitize-coverage=bb
* -fsanitize-coverage=3 is a synonym for -fsanitize-coverage=edge
* -fsanitize-coverage=4 is a synonym for -fsanitize-coverage=edge,indirect-calls
So you might try `-fsanitize-coverage=3`. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "clang, llvm, fuzzing"
} |
Is LINQ a valid option?
We (my team) are about to start development of a mission critical project, one of the sub-systems of this project is a Windows service. This service will be a backbone of the entire system and has to respond as per mission critical standard.
This service will contain many lists to minimize database interaction and to gain performance, I am estimating average size of a list to be 250,00 under normal circumstances.
Is it a good idea to use LINQ to query data from these queues, or should I follow my original plan of creating indexed list?
Indexed List is a custom implementation of `Idictionary`, which will work like an index and will have many performance oriented features such as MRU, Index rebuilding, etc. | Before rolling your own solution, you might want to look at i4o, an indexed LINQ to Objects provider.
Otherwise, it sounds like applying your own indexing may well be worthwhile - but do performance tests first. "Mission critical" is often about reliability more than performance - if LINQ to Objects performs well enough, why not use it?
Even if you _do_ end up writing your own collections, you should consider making them "LINQ queryable" in some fashion (which will depend on the exact nature of the collections)... it's nice to be able to _write_ LINQ queries, even if it's not against vanilla LINQ to Objects. | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 8,
"tags": "c#, linq"
} |
Return values from a generic Option Array in Scala
I am having some difficulty making my function generic, and need some help. I have an array that takes Option's of T where T is a Fractional. In F#, there is a function "choose" which strips None's from a collection of Options. In scala, I am trying to use "flatten", but it does not work with a generic type.
my code is
var arr = Array.fill(capacity)(None :Option[T])
... and later I try to get values of the Some's :
var flat = arr.flatten
error is:
error: could not find implicit value for parameter m: scala.reflect.ClassManifest[U] val flat = arr.flatten
i am a complete scala noob, and maybe should not play with generics :) how do i make this work?
Thanks! | The problem is that you are trying to create a new generic array, and your method doesn't know how because arrays require type information. You should then add a `ClassManifest` context bound so that the array knows how to create itself:
def flatT: ClassManifest: Array[T] = bumpy.flatten
val fish = Array(Some("salmon"), None, Some("haddock"))
flat(fish) // Prints Array(salmon, haddock)
Note that if you try to pass the array in directly to the method, it will get confused trying to figure out what type it is; you need the assignment for a val to let it know that the array itself contains all the information about its type, and then `flat` should take its type from the array. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 2,
"tags": "scala, scala option"
} |
Multi level selectbox
I have a problem with building multi level select box. I have category table with structure: id, parent_id, name. If parent_id = 0 it is top level. i don't know level depth, so it could be 2,3-5 levels. How i can build it with on query "SELECT * FROM cats" Result suppose to look like
<select>
<option>cat_name</option>
<option>--cat_name_l1</option>
<option>--cat_name_l1</option>
<option>----cat_name_l2</option>
<option>----cat_name_l2</option>
<option>cat_name</option>
</select>
Can You help me? | function _buildTree($data, $idParent, $indentSymbol, $level)
{
$cat = array();
foreach($data as $row){
if($row['parent_id'] == $idParent){
if($indentSymbol AND $level > 0){
$symbols = array_fill(0, $level, $indentSymbol);
$cat[$row['id']] = implode('', $symbols) . $row['name'];
}else{
$cat[$row['id']] = $row['name'];
}
$cat = $cat + _buildTree($data, $row['id'], $indentSymbol, $level++);
}
}
return $cat;
}
$result = mysql_query("SELECT * FROM cats");
$data = array();
while($row = mysql_fetch_assoc($result)){
$data[] = $row;
}
$select = '<select>';
foreach(_buildTree($data, 0, '-', 0) as $key=>$option){
$select .= '<option value=' . $key . '>' . $option . '</option>';
}
$select .= '</select>'; | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "php, html"
} |
When a variable goes out of scope does that mean it doesn't exist?
I'm not sure I understand scope - does an out-of-scope variable (I'm using Ruby) exist in memory somewhere or does it stop existing (I know you can't access it). **Would it be inaccurate to say that an out-of-scope variable does not exist any more?**
Maybe this is a philosophical question. | If you are using managed language then you don't allocate and unallocate memory so as far as you are concerned it no longer exists.
Technically it does but GCs tend not to be deterministic so technically it's hard to say when it actually vanishes. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 4,
"tags": "ruby, variables, scope"
} |
simple_one_for_one start_child() returns already_started
I have a supervisor which should start `simple_one_for_one` workers. When I call `start_child()` for the first time, everything goes excellent. But, when I do it the second time, I get `{error,{already_started,<0.71.0>}}`. Why would `simple_one_for_one` supervisor return me a `already_started`? What am I missing?
Here is the code: supervisor, worker. | you are registering a (local) name for your gen_server. once you start one, you can not start another one with the same name.
if you use gen_server:start_link/3 instead, removing the first argument from your current gen_server:start_link/4 call, you should be able to start up more than one. | stackexchange-stackoverflow | {
"answer_score": 19,
"question_score": 9,
"tags": "erlang, erlang otp, erlang supervisor, simple one for one"
} |
Retrieving the unreadCount tag for a YouTube video
How do I get the `unreadCount` value using the YouTube client library?
I think this is a new tag in the YouTube Data API, but I can't find the API method to get it. I can only get some values through SubscriptionEntry:
SubscriptionFeed feed = service.getFeed(new URL(feedUrl), SubscriptionFeed.class);
for(SubscriptionEntry entry : feed.getEntries()) {
System.out.println("Title: " + entry.getTitle().getPlainText());
System.out.println("Feed Url: " + entry.getFeedUrl());
System.out.println("CountHint: " + entry.getCountHint());
} | What you are looking is "contentDetails.newItemCount"
You can het it via getContentDetails().getNewItemCount() | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, youtube, youtube api, google data api"
} |
Replace space with underscore in string pickle
I have data in pickle format and inside the file is dictonary with several file names in the key which are like below
Key Type Size Value
22 NN_64_100_0.txt float 1 nan
The key has several names with the spaces in-between. I want to replace that with underscore like below.
22_NN_64_100_0.txt
I tried this way like below:
with open('/data/record.pickle', 'rb') as f:
data = pickle.load(f)
{data.replace(' ', '_'): v for k, v in data.items()}
But it didn't work
Can anyone help how to make it ? | Use Regex to replace several spaces into underscores
import re
with open('/data/record.pickle', 'rb') as f:
data = pickle.load(f)
{re.sub(r' ', '_', k): v for k, v in data.items()}
Tell me if its not okay for you... | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, pandas, pickle"
} |
How to do windows API calls in Python 3.1?
Has anyone found a version of pywin32 for python 3.x? The latest available appears to be for 2.6.
Alternatively, how would I "roll my own" windows API calls in Python 3.1? | There are pywin32 available for 3.0. Python 3.1 was release two days ago, so if you need pywin32 for that you either need to wait a bit, or compile them from source.
| stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 6,
"tags": "python, winapi, python 3.x"
} |
How to convert type_info to a 'Class' type of objective-c
Say I have a C++ class:
class CppClass {
// class implementation.
}
And in Objective-C++ code I have a method:
+(id)someMethod:(Class)aClass;
Is there any way to convert `type_info` to `Class`? | No. `Class` is a type that can be used to hold a pointer to an Objective-C "class object", an Objective-C object that represents an Objective-C class at runtime. C++ classes are not Objective-C classes, and don't have an Objective-C "class object". | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "types, casting, objective c++, typeinfo"
} |
How did Newt Scamander realize "someone's" real identity?
In _Fantastic Beasts and Where to Find Them_ , Newt restrains Graves' movements with one of his friendly beasts and then proceeds to use the **Revelio** spell to... (spoiler)
> reveal Graves' true identity, who is actually Gellert Grindelwald.
My question is, **what gave him away**? How did Newt realize that man was not really Graves? I was thinking maybe the speech he gave matched...
> Grindelwald's ideas
...and also the power and skill he displayed whilst fighting the aurors. Does anyone have a better explanation for this? Also, as a curiosity, what did...
> Grindelwald
...do with the real Graves? Maybe something similar to what was done to Alastor Moody in _The Goblet of Fire_? | I think Graves said something along the lines of "for the greater good" which is the punchline and motto of you-know-who-2. The whole speech he gave was reeking of you-know-who-2's ideology
Also he attacked the ministry with quite expertise.. which ministry employee would do that?
The way he interacted with Credence and how he egged on Credence to unleash his power.
I'm sure with prior knowledge of the sort of person you-know-who-2 is.. it ticked off some alarm in Newt's head
Or he could just be absolutely lucky. | stackexchange-movies | {
"answer_score": 8,
"question_score": 12,
"tags": "plot explanation, character, fantastic beasts, fantastic beasts where to find them"
} |
Read reports Bad File Descriptor despite getc successfully using the same fd to read a char
I have this C code:
FILE * fd = fopen(filename,"rb");
printf("%c ",(char)getc(fd)); // returns expected char
unsigned char buffer[10];
printf("%d ",read(fd, &buffer, 10)); // -1
printf("%d\n",errno); // 9
`getc` returns a char from the input file, as expected. However `read` returns an error (-1) and `errno` is set to 9 (bad file descriptor). Clearly the file descriptor is OK, since `getc` manages to use it to read a char.
What is the problem here? | `fopen` and `read` are functions of different families. The families are:
* `fopen` with `fread` (and also `getc`), from the C standard library.
* `open` with `read`, from the POSIX specification.
The first family uses file pointers as `FILE*` types, while the second one uses file descriptors as `int` types. You can't mix the two families as long as you don't convert from one file descriptor type to the other. The conversion from `FILE*` to `int` is done with the POSIX function `fileno`.
In your case, use `fread` to read from the file. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "c, errno, getc"
} |
Natural transformations preserve exactness.
Is there a quick way to see that if F,G are both functors (say between abelian categories or $R-Mod$ to Ab) and $F \cong G$, then F exact implies G exact? | Note that a functor is left exact if and only if it preserves finite limits. Now, assume $F$ is left exact and let $D$ be a finite diagram. Then we have $$\operatorname{Hom}(X,\lim GD)\cong \operatorname{Hom}(X,\lim FD)\cong \operatorname{Hom}(X,F\lim D)\cong \operatorname{Hom}(X,G\lim D)$$ where all isomorphisms are due to $F\cong G$. Thus, $G$ preserves finite limits and therefore is left exact. Right exactness follows dually. | stackexchange-math | {
"answer_score": 3,
"question_score": 3,
"tags": "category theory"
} |
Select input select all options at once with JavaScript
I have this code
<!DOCTYPE html>
<html>
<body>
<select multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
</body>
</html>
I want to select all option at once with JavaScript. | Here is one way you could do it:
function selectAll()
{
options = document.getElementsByTagName("option");
for ( i=0; i<options.length; i++)
{
options[i].selected = "true";
}
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<select multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<button onClick="selectAll();">Select All</button>
</body>
</html> | stackexchange-stackoverflow | {
"answer_score": 13,
"question_score": 0,
"tags": "javascript, html"
} |
Accessing Payment service configuration from within JAVA code
At our webshop, there is a need to retrieve some payment method configuration values. On the old ES6.4 based webshop, we used to retrieve payment service configuration values like this:
Iterator<? extends PaymentInstrumentInfo> piis = order.createPaymentInstrumentInfoIterator(); /* order.getPaymentMethod(); */
PaymentInstrumentInfo pii = piis.next();
final String isCreditCard = pii.getPaymentService().getConfiguration().getString("CreditCardPayment");
String pmn = pii.getPaymentService().getID();
In IS7.9 it seems the method getPaymentService() on PaymentInstrumentInfo object is deprecated, but in javadoc there is no explanation of deprecation in comment, it is just marked as deprecated.
How should we retrieve payment method service configuration params in IS7.9? | ISH offers a `GetPaymentServiceConfigurationByID` pipelet which retrieves the `PaymentServiceConfiguration` based on the ID and Domain.
The ID and the Domain for the `PaymentServiceConfiguration` can be found in the following way:
String serviceConfigurationDomain = pii.getServiceConfigurationDomain();
String serviceConfigurationID = pii.getServiceConfigurationID();
Be aware that the `getServiceConfigurationDomain` method returns a `String` instead of a `Domain`. To fetch the actual domain from this String you could use the `GetDomainByName` pipelet. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "java, payment, intershop"
} |
How do you access custom user information added from: Configuration » People » Account settings
I'm looking to create a script that pulls some of this information, but I need to know how to call it. For example one of the 'machine names' for one field is **field_first_name** how could I call this?
At the moment I'm using:
<?php
global $user;
print $user->name;
?>
Below is what I'm looking for, pulling the custom information instead of the username.
<?php
global $user;
print $user->feild_first_name;
?> | try $account = user_load($user -> uid) after global $user and then dsm($account) or print_r($account);, global $user get only basic data of object I think | stackexchange-drupal | {
"answer_score": 1,
"question_score": 0,
"tags": "users"
} |
Variance, expectation and linearity.
How do I prove that $$\mathrm{Var}[ax]=a^2\mathrm{Var}[x]$$ Where $x$ is a real random variable and a is a real constant? Also what does it mean that the $\mathbb{E}[x]$ is linear? Would be grateful for any help. | Notation: Random variables are usually capitalized. So, we usually write $Var(X)$ instead of $Var(x)$.
$Var(aX) = \mathbb{E}((a(X-\mathbb{E}(X))^2) = \mathbb{E}(a^2X^2 - 2a^2X\mathbb{E}(X) + a^2 (\mathbb{E}(X))^2)$
Then, using linearity of expectation,
$= \mathbb{E}(a^2 X^2) + \mathbb{E}(-2a^2X\mathbb{E}(X)) + \mathbb{E}(a^2 (\mathbb{E}(X))^2)$
scaling of expectation, and that the expectation of the mean is the mean itself,
$= a^2\mathbb{E}(X^2) -2a^2(\mathbb{E}(X))^2 +a^2(\mathbb{E}(X))^2$
So,
$Var(X) = a^2 \mathbb{E}(X^2) -a^2(\mathbb{E}(X))^2 = a^2Var(X)$ | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "statistics"
} |
Removing duplicate data when renaming keys after join
My code is:
dbobj = dbobj.merge( lambda row: {'right': row['right'].coerce_to('array').map(
lambda pair: [r.expr(field[:-2]) + pair[0], pair[1]]
).coerce_to('object')}).zip()
I tried doing {'new': instead of {'right': but zip doesn't let me choose to do new instead of right.
How do I remove the original key names on the right side? I know I need to use without but not sure how to loop through just the original names. | If you want your new value for `right` to replace your old value, you can use `r.literal` for that: `.merge(lambda row: {'right': r.literal(...)})`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, rethinkdb"
} |
Is $l^{\infty}$ subpace $s(\mathbb{F})$?
Let be $s(\mathbb{F})$ a all sequence with term in $\mathbb{F}$ ($\mathbb{C}$ or $\mathbb{R}$). Denoted one element of $s(\mathbb{F})$, that $x=(x_j)$. Let be $$l^{\infty} = \\{x\in s(\mathbb{F}); \sum_{j=0}^\infty |x_j|^\infty<\infty\\}.$$
Show that $l^{\infty}$ is subpace of $s(\mathbb{F})$.
I got solved 1 and 3 conditions to $l^{\infty}$ be a subpace from $s(\mathbb{F})$. I want help with the proof of the condition 2 please.
**Conditions**
1. The zero vector, $0$, is in $W$.
2. If $u$ and $v$ are elements of $W$, then the sum $u + v$ is an element of $W$.
3. If $u$ is an element of $W$ and $c$ is a scalar from $K$, then the product $cu$ is an element of $W$. | Try the triangle inequality: if $x,y\in\ell^\infty$, $||x_j+y_j||_\infty\leq ||x_j||_\infty+||y_j||_\infty$ for all $j$; then it should be straightforward to prove that the series $\sum_{j=1}^n||x_j+y_j||_\infty$ converges. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "real analysis, functional analysis, vector spaces"
} |
People choosing numbers - uniform distribution
there's a group of 100 people. each one chose a number that distributes uniformly $Ud~(1,50)$. $X$ is all the numbers that got chosen. What is the $E(x)$?
So all I got to do is $(1+50)/2$ and to multiply it by $100$? or is there a trick? | It is correct, there is no a trick but a very important reason for that
What you are asking to calculate is
$$\mathbb{E}[\frac{1}{100}\sum_{i=1}^{100}X_i]=\frac{1}{100}\sum_{i=1}^{100}\mathbb{E}[X_1]=\frac{1+50}{2}$$ | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "probability, probability distributions"
} |
How to check if NSString returned by objectForKey is "" objective c
I'm not exactly sure how to check whether a NSString is blank or not, I've got this code...
NSString *imageName = [myItem objectForKey:@"iconName"];
if(imageName == @"")
{
}
And when I do a print on the myItem object, it comes up as..
iconName = "";
At the NSString *imageName line, I noticed in xcode in the console it says
> "variable is not NSString"
Which I don't get as iconName is saved and stored on the parse.com database as a NSString.
When I run that code though it doesn't seem to realise that imageName = ""; | You should use this code block when comparing strings:
if ([imageName isEqualToString:@""]){
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "objective c, ios"
} |
Hide product price if 0 in magento 1.7?
I'm using magento 1.7.0.2 . In my store I want to show some product which don't have price, and by default in magento they become 0.00 . There are some solution, for replacing: this
<?php echo $this->getPriceHtml($_product, true) ?>
with
<?php if($_product->price==0): ?>
<?php echo 'Free'; /?>
<?php else: ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php endif; ?>
And yes this is solve problem only if I replace in list.phtml (list and grid), but when I open product page with all details, there is still 0.00.
Thanks in advance. | I solved the problem, just need to replace this code, in path app\design\frontend\default\YOURTHEME\template\catalog\product:
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getChildHtml('extrahint') ?>
with this:
<?php if($_product->price==0): ?>
<?php echo 'Free'; ?>
<?php else: ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php endif; ?> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "magento, magento 1.7"
} |
(string)reader[0] vs Convert.ToString(reader[0])
what's better
var s = (string)reader[0]
or
var s = Convert.ToString(reader[0])
? | I'd say `reader.GetString(0)` | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 7,
"tags": "c#, ado.net, sqldatareader"
} |
Bulk delete in JPA 2.1 using the criteria API
Given the following code that deletes rows in a batch.
List<City> list = ...
int i=0;
for(City city:list)
{
if(++i%49==0)
{
entityManager.flush();
}
entityManager.remove(city);
}
The JPA 2.1 criteria API provides `CriteriaDelete` to perform a bulk delete. Accordingly, the following code executes a `DELETE FROM city WHERE id IN(...)` query.
CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder();
CriteriaDelete<City> criteriaDelete = criteriaBuilder.createCriteriaDelete(City.class);
Root<City> root = criteriaDelete.from(City.class);
criteriaDelete.where(root.in(list));
entityManager.createQuery(criteriaDelete).executeUpdate();
But this should not be equivalent of the first case. What is the equivalent of the first case? It should perform deletion in a batch. | The equivalent would be to execute a query to delete a single entity in a for loop, something like:
for(City city:list)
{
if(++i%49==0)
{
entityManager.flush();
}
CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder();
CriteriaDelete<City> criteriaDelete = criteriaBuilder.createCriteriaDelete(City.class);
Root<City> root = criteriaDelete.from(City.class);
criteriaDelete.where(root.equal(city));
entityManager.createQuery(criteriaDelete).executeUpdate();
}
Each of these 50 statements might not get put into the same batch - it depends on if your JPA provider supports batching or not. The loop seems less efficient, as you end up with X statements rather than a single `DELETE FROM city WHERE id IN(...)` you did with the original bulk delete. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "hibernate, jpa, eclipselink, criteria, jpa 2.1"
} |
Using Calculated Values in Math Functions
I need to perform a basic "X to the power of Y" calculation. The calculation builder doesn't accept the ^ character as an operator, so it seems I need to use the Math.Pow(x,y) function.
That would fine if both X and Y were static numbers, but in my case Y needs to be a value that is calculated in a field higher up in the form and is based on user input. Math.Pow() will not accept the field itself as an argument.
Is there any way to do an "X to the power of Y" calculation that uses a calculated value, either with Math.Pow or otherwise? | Turns out that along the trail of calculations I was trying to use as an argument for the Math.Pow() function, I was using the "Value" parameters from one of my "Choice" type fields.
The values I'd assigned to the choices in that field could be used in most calculations, but not in the Math.Pow() function.
So I ended up creating a new hidden "Number" type field that returns the correct value based on the choice option selected. Not super elegant, but it's working for me. | stackexchange-webapps | {
"answer_score": 0,
"question_score": -1,
"tags": "cognito forms"
} |
Shouldn't there be a reputation penalty if a question you closed ends up being voted for reopen?
I see that many questions are quickly closed on questionable reasons. In some case for just pure mistakes (e.g. marked as duplicate of a different unrelated question).
Shouldn't bad closing be penalized like asking bad questions or giving bad answers is? | # No.
Bad closures happen, there's no denying that. But _good_ closures also happen, and we don't award close voters with reputation when they get it right. Penalizing them when they get it wrong would be extreme (and it feels a bit vindictive).
Just vote to re-open and move on. | stackexchange-meta | {
"answer_score": 19,
"question_score": -18,
"tags": "discussion, reputation, vote to close, reopen closed, vote to reopen"
} |
How can I use the Exclusions option to exclude all $x$ values of the form $\pi/2 + \pi n$?
Intuitively, I'm trying to do the following:
Plot[Tan[x], {x, -4 Pi, 4 Pi}, Exclusions -> {(* x = Pi/2 + Pi n *)}]
and I want to know what I should replace the comment with to get the desired effect. | Plot[Tan[x], {x, -4 Pi, 4 Pi},
Exclusions -> {Mod[x, Pi] == Pi/2},
ExclusionsStyle -> Red]
-window_size)
{
temp_window <-main_data_vector[counter:counter+window_size]
count = count+1
}
When I run the code, the counter stops at length(main_data_vector)-window_size (expectedly). But the length of the temp_window stays 1 (should be 100) and the count goes to the end of length(main_data_vector) (should have the same value as counter). I am not familiar with rollapply (online examples only show basic functions like sum and mean for it).
Can anyone please point to what I am doing wrong here ?
Thanks. | You should add round brackets for `counter+window_size-1` and `length(main_data_vector)-window_size+1`, i.e.,
for (counter in 1:(length(main_data_vector)-window_size+1))
{
temp_window <-main_data_vector[counter:(counter+window_size-1)]
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "r, for loop, rollapply"
} |
Looking for a word to describe someone who is famous to a small group of people
I'm looking for a word to describe someone who is famous to a small group of people.
For example I play a competitive card game and there are several people who are famous within the gaming community, but outside of that community they are just your average people. Most people wouldn't recognize them as celebrities. | **Cult Hero** \- a writer, musician, artist, or other public figure who is greatly admired by a relatively small audience or is influential despite limited commercial success. OED | stackexchange-english | {
"answer_score": 38,
"question_score": 30,
"tags": "single word requests"
} |
Prove that $(X'X)^{-1}X'AX(X'X)^{-1}-(X'A^{-1}X)^{-1}$ is positive definite
How to prove if A is a positive definite matrix, then $(X'X)^{-1}X'AX(X'X)^{-1}-(X'A^{-1}X)^{-1}$ is also positive definite? Here $X'$ denotes the transpose of $X$. $A$ is square and $X$ is $n\times m$. | **Hint:** Presumably $X$ is a full-rank tall matrix ($n\ge m$). Let $X=U\pmatrix{\Sigma\\\ 0}V'$ be a singular value decomposition of $X$, where $\Sigma$ is a positive diagonal matrix. Then the statement $(X'X)^{-1}X'AX(X'X)^{-1}-(X'A^{-1}X)^{-1}\color{red}{\succeq}0$ (note: it's positive semidefinite, but _not_ necessarily positive definite; for instance, it is zero when $A=I$) can be transformed into the form of $$ \pmatrix{I&0}M^{-1}\pmatrix{I\\\ 0}\succeq\left(\pmatrix{I&0}M\pmatrix{I\\\ 0}\right)^{-1},\tag{1} $$ where $$ M=\pmatrix{\Sigma\\\ &I}UA^{-1}U'\pmatrix{\Sigma\\\ &I} $$ is positive definite. Write $M=\pmatrix{X&Y'\\\ Y&Z}$, where $X$ has the size as $\Sigma$. As $M$ is positive definite, so are $Z$, its Schur complement $X-Y'Z^{-1}Y$, and also $(X-Y'Z^{-1}Y)^{-1}$. Therefore statement $(1)$ is equivalent to $(X-Y'Z^{-1}Y)^{-1} \succeq X^{-1}$, which, by strict partial ordering of positive definte matrices, is equivalent to $X-Y'Z^{-1}Y \preceq X$. Now this is obvious. | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "linear algebra, matrices"
} |
Airflow: how to use xcom_push and xcom_pull in non-PythonOperator
I see a lot of examples on how to use `xcom_push` and `xcom_pull` with PythonOperators in Airflow.
I need to do `xcom_pull` from a _non-PythonOperator_ class and couldn't find how to do it.
Any pointer or example will be appreciated! | You can access XCom variables from within templated fields. For example, to read from XCom:
myOperator = MyOperator(
message="Operation result: {{ task_instance.xcom_pull(task_ids=['task1', 'task2'], key='result_status') }}",
...
It is also possible to not specify task to get all XCom pushes within one DagRun with the same key name
myOperator = MyOperator(
message="Warning status: {{ task_instance.xcom_pull(task_ids=None, key='warning_status') }}",
...
would return an array. | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 10,
"tags": "airflow"
} |
NodeJs: Get output of python-shell to send back to client
I am trying to create a website where a user can submit python code, it gets sent to my server to be executed and I send back the results to the client. Currently I am using a NodeJs server and need to run the python code from there. To do this, I am using Python-shell like so:
const runPy = async (code) => {
const options = {
mode: 'text',
pythonOptions: ['-u'],
scriptPath: path.join(__dirname, '../'),
args: [code],
};
const result = await PythonShell.run('script.py', options, (err, results) => {
if (err) throw err;
return results; <----- HOW DO I RETURN THIS
});
console.log(result.stdout);
return result;
};
I understand I can `console.log()` the results in the `PythonShell.run()` but is there a way to return the results from my `runPy` function to then be manipulated and sent back to the client? | It looks from the `python-shell` documentation that the `PythonShell.run` method doesn't have an async mode. So, one option is to wrap it in a promise:
const runPy = async (code) => {
const options = {
mode: 'text',
pythonOptions: ['-u'],
scriptPath: path.join(__dirname, '../'),
args: [code],
};
// wrap it in a promise, and `await` the result
const result = await new Promise((resolve, reject) => {
PythonShell.run('script.py', options, (err, results) => {
if (err) return reject(err);
return resolve(results);
});
});
console.log(result.stdout);
return result;
}; | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "python, node.js"
} |
Speed up CrashPlan by transferring backups between computers using external HD?
I've just set up CrashPlan between three computers in the family (in three different locations) so that they all backup to each other over the internet. The problem is that the backup files are huge and for the first backup (where everything needs to be transferred) it's taking far too long a time to happen. We are 10 hours in and only about 7% of the way!
I'd like to speed this up by backing up each computer locally to an external hard drive, driving to the other computers and copying this backup file onto them. The idea being that CrashPlan will then start with that backup file for comparing differences and so a full transfer of several hundred GB over the internet won't be necessary.
I thought this could be done but my Google searching is failing me miserably. Can anyone point me in the direction of some instructions on how to do this properly? | Google search didn't work, but the CrashPlan site search was quite helpful.
In short, you need to backup your computer to an external drive:
<
Then take this drive, plug it into the other computer and copy off the archive into the folder configured as the backup location for that computer. The article below shows you how to change the location for each connected computer, but you can also use that to determine what the location is:
<
Once you've done this then only diff's will be transferred between computers over the internet - which should speed things up considerably as you won't have to transfer gigabytes of content just to get started.
A little bit more information about this process can be found at:
< | stackexchange-superuser | {
"answer_score": 3,
"question_score": 4,
"tags": "windows 7, backup, internet, crashplan"
} |
Nokia Glance in Landscape mode
Is it possible to show the Nokia Glance screen in landscape mode? We are using a dock that holds the phone in landscape mode for a Lumia 925 and it is a little annoying that the clock is shown sideways.
Update: The "Black" Update by Nokia is already installed, I know the feature isn't there either.
Update 2: The feature has been suggested here, please upvote it if you want it too. | No it isn't. And as someone who has a Lumia 1520 with the Nokia Black update, that feature isn't in there either. | stackexchange-windowsphone | {
"answer_score": 1,
"question_score": 2,
"tags": "8.0, lumia, glance"
} |
How to do PHP array_intersect by keys not by values?
`$master = ['111' => 'foo', '124' => 'bar', '133' => 'baz'];`
`$check = ['111' => 14, '133' => 23 ]';`
I want to remove all keys from `$master` that do not exists in `$check`. So the result in this example should be:
`$newMaster = ['111' => 'foo', '133' => 'baz'];`
Any idea how to do this ? Thanks in advance. | Yes, simply use `array_intersect_key()`
$newMaster = array_intersect_key($master, $check); | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 5,
"tags": "php, arrays, array intersect"
} |
OMNeT++ Error in Module
I am working on a project where I need to implement a routing protocol for VANET. I am using the INET Framework to implement the modules and VEINS to connect SUMO and OMNeT++.
When I run my simulation I am getting this error:
**Error in module (inet::physicallayer::Ieee80211Radio)** ManhattanScenario.RoadSideUnit.nic.radio (id=51) **during network initialization: Module not found on path** 'radioMedium' **defined by par** 'ManhattanScenario.RoadSideUnit.nic.radio.radioMediumModule'.
Thank You in advace | You most likely forgot to place a Ieee80211ScalarRadioMedium (named radioMedium) module in the top-level network so the radios in the mobile/RSU nodes cannot find it. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "routes, protocols, omnet++, inet"
} |
How to change the active state of the button in jQuery
I'd like to be able to change the background of the button div depending on it's clicked state. So if it's been activated, and it toggles the div - it's green and if it's closed it's red.
The code I have for getting the div to be green (by adding the class ACTIVE) is:
$('#clickme').click(function() {
$('#slideContainer, #buyOffPage').animate({height: 'toggle'}, 2000);
$('#clickme').addClass('ACTIVE');
});
But I don't know how to revert the state so that when the button is clicked again, and the div slideContainer hides it applies the class (INACTIVE), and so that it is in loop, so next click ACTIVE, click after that INACTIVE so on and so forth.
I think I'm going about targeting the state of the button with classes is wrong, but don't know what else to do! | Use .toggleClass() that will add/remove automatically the class to the element:
$('#clickme').toggleClass('ACTIVE');
Note:
Inside the click handler, `this` is the clicked element, you don't need to re-query it. Just use `$(this)` to refer to the element `#clickme` | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "jquery"
} |
YouTube iFrame automatically opens YouTube app. How can I stop this?
I used the default YouTube iFrame for my website. My users have said that upon entering the web app, it redirects them to youtube. I find this annoying for me and for my users.
Is there any way I can stop this from happening?
Here is the code that is causing the YouTube app to open:
<iframe width="560" height="315" src=" frameborder="0" allowfullscreen></iframe>
The site this is on can be found here. | You can use "playsinline" parameter to play the video inline instead. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 3,
"tags": "html, youtube api"
} |
DataMapper and Codeigniter - how to fully manage a many-to-many relationship
I have the following relationship
CType has many Field
Field has many Ctype
and of course the tables used are fields, ctypes, and ctypes_fields. Normally, the ctypes_fields table should contain only ids referencing the other two tables. However, i'd like to put there a "options" field that will contain some content for the concrete instance only. I walked through all DataMapper tuts but I couldn't find relevant info on how I could extract these specific values (the ones in the relation table).
Should I create a separate model for this relation table or there is a clever way to do this? | Datamapper OverZealous Edition (DMZ) allows you to do this. It should be compatible with your existing Datamapper application. < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, codeigniter, codeigniter datamapper"
} |
OpenId access token does not work for rest api
I want to use OpenId for Salesforce authentication.
I have done the following:
* created an auth provider (like in this tutorial:
* created a Connected App (Callback URL: my .Net Core web app; Selected OAuth Scopes: all scopes)
* wrote a .Net Core web app and I use Microsoft.AspNetCore.Authentication.OpenIdConnect for OpenId
Now I test the OpenId authentication and it works. Finally I want to use the openId response access token for salesforce REST API, but it does not work. I get:
[
{
"message": "This session is not valid for use with the REST API",
"errorCode": "INVALID_SESSION_ID"
}
]
Could someone tell me how I can use the openId access token for Rest API?
Thanks, mg92 | I forgot to add the scope parameter "api" into my scope list.
Now I can do REST API calls.
services.AddAuthentication().AddOpenIdConnect(o =>
{
o.ClientId = "XYZ";
o.ClientSecret = "ABC";
o.Authority = "
o.ResponseType = OpenIdConnectResponseType.Code;
o.GetClaimsFromUserInfoEndpoint = true;
o.Scope.Add("api");
}); | stackexchange-salesforce | {
"answer_score": 0,
"question_score": 0,
"tags": "single sign on, auth provider, open id connect, session id"
} |
converting ascii to unicode example BB 10 and vise versa
can anyone help me in converting a QString into unicode from Ascii and vice versa
If possible add some code snippet.
Thanks, | QString provides the toUtf8() function that returns a const char * version of the string as QByteArray. QString also provides fromUtf8().
B.T.W. The Qt technical pages provide plenty of examples. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "qml, blackberry 10, blackberry cascades"
} |
Prothean rifle in Multiplayer
If you have the DLC 'From Ashes', is it possible to get the Prothean particle rifle in one of the multiplayer item packs or no?
In other terms, can you get this weapon in the multiplayer?
Also, if you can, is it considered a rare item or a uncommon one?) | I don't think is possible by default. However, you might be able to aquire it through a "Commendation Pack", obtainable through their weekend events (like last week's "Operation: Goliath"). Don't count on this though, they said those packs can include one of the CE/singleplayer weapons you couldn't obtain otherwise in multiplayer, but if it includes any non-human stuff... will have to wait for someone finding one and telling us I guess. | stackexchange-gaming | {
"answer_score": 1,
"question_score": 4,
"tags": "mass effect 3, mass effect 3 multiplayer"
} |
iphone - display encoded characters like å,ä,ö in UILabel
I have a list that uses UILabel for each of its rows. If I try to display special characters such as å,ä,ö, it displays them as å ä ö How do I convert them into a UTF8 encoded NSString? | The characters display correctly in a WebView because the HTML entities are correctly interpreted by it.
Maybe this handy NSString category can help you to display the text how you want in a UILabel:
<
Import both NSString+HTML.h and NSString+HTML.m files, then in your class use
#import "NSString+HTML.h"
and then you can use
NSString *decodedString = [encodedString stringByDecodingHTMLEntities];
**EDIT :**
You can also try HerbertHansen's solution on the apple dev boards which doesn't need a whole library | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "iphone, ios, nsstring, uilabel, nsstringencoding"
} |
How to find double regex substrings in string?
I want to find double substrings in a string using a regex.
Example:
line = "text 04/22/2014 text 04/22/2015 02/23/2014 more text 04/22/2014 more text 02/23/2014"
myregex= "\d\d/\d\d/\d\d\d\d"
I know how to check if the regex matches the strings:
mymatches = regex.findall(myregex, line)
len(mymatches )
this returns the length of the list of matches.
if the list is `>1` than there are doubles in the string
But what I don't know is to find the doubles of the **same** strings, in above case `04/22/2014` and `04/22/2014` and put them in a nested list.
example output: `[['04/22/2014','04/22/2014'],['02/23/2014', '02/23/2014']]`
How can I find the doubles of the same regex strings? | First, we'll find all the matches to that pattern in the line. Then we will sort them and group the identical ones together.
import re
import itertools
line = "text 04/22/2014 text 04/22/2015 02/23/2014 more text 04/22/2014 more text 02/23/2014"
pat = r'\d\d/\d\d/\d\d\d\d'
reg = re.compile(pat)
print([list(g) for k, g in itertools.groupby(sorted(reg.findall(line)))])
Output:
[['02/23/2014', '02/23/2014'], ['04/22/2014', '04/22/2014'], ['04/22/2015']]
EDIT: If you want only those strings that appear twice or more, you can do something more like
[g for g in map(lambda x: list(x[1]), itertools.groupby(sorted(reg.findall(line)))) if len(g) > 1] | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, regex, string, python 3.x, substring"
} |
File Upload in asp.net
I am using FileUpload control to facilitate Image file upload on my website. I want to restrict a user to upload only Image file. I am using
if (fupFirmLogo.PostedFile.ContentType == "image/Jpeg")
{
}
to check if the file is a image or not. I want to allow all image extensions like PNG, GiF, Jpeg, tif , BMP etc. How should I do it. | you should use regular expression to validate that is an image or not, might be the better option
some thing like:
public static bool IsValidImage(this string fileName)
{
Regex regex = new Regex(@"(.*?)\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP)$");
return regex.IsMatch(fileName);
}
Then you check:
if (fupFirmLogo.FileName.IsValidImage())
{
//Do your code
}
else
{
//Not a valid image
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "c#, .net, asp.net, file upload"
} |
URL is too long while running !!
I am creating a website using LINQ database on Visual studio 2010 i am getting this error when i make many queries from the database and to database
the page contains dropdown list that get something from the database and at the same time posts back to get queries from the database and bind it to Gridviews
after 3 queries from the database it shows this message
**"The length of the query string for this request exceeds the configured maxQueryStringLength value."**
i am using Google chrome BTW! | From <
> Please check the section in your config file: `<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />` By default, the query string lengths was constrainted to 2048 characters. To allow longer or shorter query strings, modify the maxQueryStringLength attribute, please. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -3,
"tags": "c#, linq, visual studio 2010, query string, web"
} |
sending emails in node.js / nodemailer
I tried to use nodemailer to send emails using my gmail account.
However, Google rejects my login as suspicious and thinks I am a hacker.
I tried Yahoo which does send the email.
My questions are:
>
> 1) How can I configure nodemailer to send emails thru gmail
> 2) Standard/Reliable email library in node.js community with good support that can be used in production.
> | I used emailjs, and haven't had that issue. Not sure if that's because it's email.js or because it's Google Apps vs Gmail, or maybe Google is just less suspicious with this app for some reason. Maybe useful to try to triangulate:
> **$> npm install emailjs**
emailjs = require('emailjs');
...
var server = emailjs.server.connect({
user:"[email protected]",
password:"Secret@!1",
host:"smtp.gmail.com",
ssl:true
});
server.send({
text: message
from:"Display name <[email protected]>",
to:email,
subject:"Subject"
},
function (err, message) { ... } | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "node.js, nodemailer"
} |
change attributes of css class when javascript function runs
so I have this function below...
<script>
$('.tile').on('click', function () {
$(".tile").addClass("flipOutX");
setTimeout(function(){
$(".tile-group.six").load("musability-musictherapy-company-overview.html");
}, 2000);
});
</script>
I basically want to change the css attributes of tile-group.six to have a different margin. Any ideas how I might go about this ? | $(".tile-group.six").css({margin:"0"});
This should be what you're after.
As _Phylogenesis_ pointed out in his comment on the below answer, this method can be used to change multiple CSS values at once using a comma delimiter e.g.
$(".tile-group.six").css({margin:"0", padding:"0"}); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "javascript, html, css, function"
} |
Validate HTML entities in JavaScript
I have a small JavaScript validation script that validates inputs based on Regex. I want to allow certain characters that are not exactly common (not sure if they're UTF8). For example I want to allow the following character `’`, which looks like a single quote, but isn't.
I got the HTML code for this which is `’`, but I'm not sure how to put this into the Regex.
I've tried just inputting `[’]*` but it doesn't validate. | How about
/[\u2019]/
It uses the actual character rather than the html entity. 2019 is hex for 821710
< | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "javascript, regex"
} |
Multi-class classification using LIBLINEAR
I am a beginner to SVM which i have successfully implemented one-class classification.Now i want to know about multi-class classification which am very much confused about.
I went through How to do multi class classification using Support Vector Machines (SVM) which i want the exact same output but the link does not have a specific example using windows.If anyone can help me out with an example in windows for both “ONE-AGAINST-ONE”,”ONE-AGAINST-ALL” methods of multi-class classification
Thanks | Using libLinear you will not be able to have a similar output because it cannot predict probabilities. You should use libSVM for that.
LibLinear does not support multi-class classification by default, but you can download this tool from the official site and it can do the job.
If you want multi-class probability estimate, you can take a look at this tool | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "machine learning, svm, libsvm, liblinear"
} |
How can I get the name of the currently active keymap?
I want to retrieve the name of the currently active keymap. How do I get it? `bpy.types.keymap.name` errors out. But the attribute 'name' is available in the API:

# Alternatively
print (bpy.context.preferences.keymap.active_keyconfig) | stackexchange-blender | {
"answer_score": 4,
"question_score": 2,
"tags": "python, scripting, interface, shortcut"
} |
How to convert hexBinary (MsgId) to character in esql?
I'm trying to put MQMD.MsgId to XMLNSC.MsgId field, like this:
> SET OutputRoot.XMLNSC.Root.MsgId = InputRoot.MQMD.MsgId;
But I'm getting _X'414d51204d39392e5352442e4330302e56c47bd4203b3708'_ instead of just _414d51204d39392e5352442e4330302e56c47bd4203b3708_.
Also i've tried to cast MsgId to CHARACTER, but result is the same.
How to get rid of quotes and 'X'? | You could try something like this:
DECLARE msgId CHARACTER CAST(InputRoot.MQMD.MsgId AS CHARACTER);
SET OutputRoot.XMLNSC.Root.MsgId = SUBSTRING(msgId FROM 3 FOR LENGTH(msgId) - 3); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ibm mq, messagebroker, ibm integration bus, extended sql"
} |
why page is redirected when i drop image on div
I am using `jquery 1.9`. I have problem to implement upload image using drag and drop but when I drop image in div then its going redirect and open image in browser i have implement code in jsfiddle please check and tell me whats problem why its being redirected
this is my following code
$(document).on('ready',function(){
jQuery.event.props.push('dataTransfer');
$('.dropuploader').bind('drop', function(e){
$(this).css({'box-shadow' : 'none', 'border' : '4px dashed rgba(0,0,0,0.2)'});
alert("hello there");
return false;
});
$('.dropuploader').bind('dragenter', function(e){
$(this).css({'box-shadow' : 'inset 0px 0px 20px rgba(0, 0, 0, 0.1)', 'border' : '4px dashed #bb2b2b'});
return false;
});
}); | you have missed `ondragover="return false"` use following div html
<div class="dropuploader" ondragover="return false">Upload here</div>>
instead of
<div class="dropuploader">Upload here</div> | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "jquery, html, drag and drop, ajax upload"
} |
Number of elements in a squared set
> If $S= \\{\emptyset, 5, \\{1,5\\}\\}$, how many elements does $S^2$ have?
The answer to this question was given to be $9$, as $S$ has three elements so $S^2$ will have $9$, however, for example, by the principles of a cartesian product, there will be an element in which $\emptyset$ is multiplied by $\emptyset$, which I understand just to be $\emptyset$, which would mean that there would be less than $9$ elements.
Is my understanding flawed and there are indeed $9$ elements? | The Cartesian product merely assembles the elements of two sets in order. Here's is an excerpt from Wikipedia:
> ... for sets $A$ and $B$, the Cartesian product $A \times B$ is the set of all ordered pairs $(a, b)$ where $a \in A$ and $b \in B$.
In your specific example, the product will consist of the nine pairs $(\varnothing,\varnothing),(\varnothing,5),(\varnothing,\\{1,5\\}), (5,\varnothing), (5,5), (5, \\{1,5\\}), (\\{1,5\\},\varnothing), (\\{1,5\\}, 5),$ and $(\\{1,5\\},\\{1,5\\})$.
In general, the notion of "multiplication" between set elements is ill-defined. | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "elementary set theory"
} |
Сортировка массивов по алфавиту
Как можно вывести список имен и фамилий по алфавиту? Иванов, Петров, Сидоров, к примеру, и т.д.? | sort($massive, SORT_STRING);
Или просто
sort($massive);
Если нужно сортировать ключи массива, то:
ksort($massive); | stackexchange-ru_stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "php"
} |
Kodaira's definition of a primary Hopf surface
In his paper "Complex Structures on $S^1\times S^3$", Kodaira defines the following quotient of $W=\mathbb{C}^2\setminus \lbrace(0,0)\rbrace$: $$ (z_1,z_2)\sim (pz_1+\lambda z_2^m,qz_2)\,,\quad 0<|p|\leq |q|<1\,,\quad \lambda(q^m-p)=0\,. $$ He shows that this surface is diffeomorphic to $S^3\times S^1$.
My question is about the importance of $0<|p|\leq |q|<1$ when $\lambda=0$. Clearly, for $\lambda\neq 0$, one needs a requirement like this. However, is this condition also necessary when we take $\lambda=0$? For example, when $\lambda=0$, can we define the surface for $|p|,|q|>0$ without any further conditions on $p,q$? | Suppose that $\lambda=0$. Then Kodaira considers the quotient space of $W={\mathbb C}^2 \setminus \\{(0,0)\\}$ by the (holomorphic) action of the cyclic group $\Gamma$ generated by the transformation $$ \gamma(z_1, z_2)= (p z_1, q z_2), p, q\in {\mathbb C}^\times. $$ In order for the quotient to be a complex surface, one needs the group action on $W$ to be proper. (Properness is also a sufficient condition.) This is where the conditions on $p, q$ are coming from. Up to inverting $\gamma$ (which does not change $\Gamma$), we can assume that $$ |p|\le |q|. $$ Now, it is a pleasant exercise in general topology, that the $\Gamma$-action on $W$ is not proper if $|p|<1<|q|$, or if $|p|=1<|q|$, or if $|p|<|q|=1$ or $|p|=|q|=1$ and one of $p, q$ is not a root of unity. If $p$ and $q$ are roots of unity, then the quotient space will not be compact and Kodaira aims to construct compact complex surfaces. This leaves us with: $$ |p|\le |q|<1, $$
exactly what Kodaira writes. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "complex geometry"
} |
The unequal width between axes causes non-diagonal lines
import numpy as np
import matplotlib.pyplot as plt
x=np.arange(-2,4,0.1)
y1=x
y2=-x
fig=plt.figure(figsize=(8,8))
plt.plot(x,y1)
plt.plot(x,y2)
Now I have drawn a graph of y=x and y=-x. 
... It is also removed from my cell phone correctly, because I switch my cell phone off before I remove the storage card.
Now however, when I try to mount my storage card in Ubuntu, I am told:
Unable to access "Phablet"
Error mounting /dev/sdc1 at /media/gregoryopera/Phablet: Command-line `mount -t "exfat" -o "uhelper=udisks2,nodev,nosuid,uid=1003,gid=1003,iocharset=utf8,namecase=0,errors=remount-ro,umask=0077" "/dev/sdc1" "/media/gregoryopera/Phablet"' exited with non-zero exit status 32: mount: unknown filesystem type 'exfat'
Nothing on my storage card has changed (i.e. it is the same format it has always been) and aside from the usual day-to-day updates, nothing on my computer has changed either...
Any assistance would be great. | You have to install exfat driver in LINUX to access the exFAT formatted partitions in linux
I took this from this post, please see that for more information.
In Ubuntu, you have to add a PPA and then install it. In ubuntu, open the terminal and type the following :
sudo add-apt-repository ppa:relan/exfat
sudo apt-get update
In Ubuntu, I use the following command to install it successfully.
sudo apt-get install exfat-fuse
Now you will have the exFAT driver installed in your LINUX. Reboot your system and use your exFAT drive like every other drives. | stackexchange-askubuntu | {
"answer_score": 4,
"question_score": 3,
"tags": "usb storage, micro sd, memory card"
} |
Linq Transpose List
I have list of simple objects:
var r = new List
{
new { Id = 1, Value = 2, DateTime = DateTime.Parse("10.10.2014")},
new { Id = 2, Value = 3, DateTime = DateTime.Parse("10.10.2014")},
new { Id = 3, Value = 4, DateTime = DateTime.Parse("10.10.2014")},
new { Id = 1, Value = 5, DateTime = DateTime.Parse("11.10.2014")},
new { Id = 2, Value = 6, DateTime = DateTime.Parse("11.10.2014")}
};
I want to get object like:
DateTime | 1 | 2 | 3 |
10.10.2014 | 2 | 3 | 4 |
11.10.2014 | 5 | 6 | |
Is there any nice linq query to this? Smth like pivot/unpivot in sql maybe? | You're looking for a simple `GroupBy`:
var result = r.GroupBy(x => x.DateTime)
.Select (grp => new
{
DateTime = grp.Key,
_1 = grp.Where(x => x.Id == 1).Select(x => x.Value).Cast<Int32?>().FirstOrDefault(),
_2 = grp.Where(x => x.Id == 2).Select(x => x.Value).Cast<Int32?>().FirstOrDefault(),
_3 = grp.Where(x => x.Id == 3).Select(x => x.Value).Cast<Int32?>().FirstOrDefault()
});
`result` is now:
!enter image description here | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "c#, linq"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.