INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
TV videos shown in middle school about reading books, woman book destroyer and a face that hypnotizes kids
When I was in the 7-8th grade (1994), there were class videos we had to watch about this or that. One show in particular had a cliffhanger ending, and I never got to find out what happened.
There were at least two kids. They find a lady who is destroying books aka "I am the book destroyer". The episode in question, had a man whose eyes were closed, then he opens them, hypnotizing one of the kids. It was a live action series, and was as cheesy as it gets...
The video style was similar to a music video called "Ghost of a Chance", where a house trapped a pizza guy who had fractions pop up at points in the song being played about his chances of escaping that particular trap or room (ended with something like 15/16 chance of escape and he picks the one wrong door). | This is Episode 9 of Season 2 of _Read All About It)_ (1979-1981).
> The Book Destroyer traps Lynne and Alex in her mine and says they must help her erase all villains from books.
Found with search terms of _educational videos "book destroyer"_ | stackexchange-scifi | {
"answer_score": 7,
"question_score": 6,
"tags": "story identification, tv"
} |
How to read line by line multiple files
let's say I have an undertermined number of files
in `/mnt/traitement` and I want to read line by line every file in this folder how do I do it, I know that to read files line by line you need to do this code
while read line
do
#stuff
done < file
but I don't know how to target multiple files. | It should be sufficient to wrap the while loop into a for loop:
for i in file1 file2 file3; do
while IFS= read -r line
do
#stuff
done < "$i"
done
If you care only about the text itself, you can just `cat file1 file2 file3 | while IFS= read -r line`, but beware of non-newline terminated files, as `cat` will splice last item of that file with first line of new one.
Also, since you mentioned particular directory, you can use glob with the for loop as in `for i in /mnt/traitement/*`. Like so
for i in /mnt/traitement/* ; do
if ! [ -f "$i" ]; then
continue
fi
while IFS= read -r line
do
#stuff
done < "$i"
done | stackexchange-askubuntu | {
"answer_score": 7,
"question_score": 3,
"tags": "command line, scripts"
} |
Dilation of an operator
Let $T\in B(\mathcal{H})$. Based on < dilation of the operator $T$ is an operator on a larger Hilbert space $K$, whose restriction to $\mathcal{H}$ composed with the orthogonal projection $P$ onto $\mathcal{H}$ is $T$.
I have several questions about this definition. Is there another version of this definition? Is the operator $P$ always projection? I mean could one find a larger Hilbert space $K$ and operators $V, U$ on $K$, when $U$ is not an orthogonal projection, such that $UV|_{\mathcal{H}}= T$? | Your candidate for a definition is exactly the same definition of dilation you quoted. If $UV|_H=T$, then since $PT=T$ you have $PUV|_H=T$, and so $UV$ is a dilation of $T$ in the sense of your first paragraph.
A "dilation" has to be a "dilation". The spirit is that you have $T$ (typically, $T$ is a contraction), and you get a dilation $$\tilde T=\begin{bmatrix} T&A\\\ B& C\end{bmatrix}$$ that is better behaved, say $\tilde T$ is a unitary, or a projection. | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "functional analysis, operator theory"
} |
proof that $\frac{a_{4n}-a_2}{a_{2n+1}}$ : integer
I would appreciate if somebody could help me with the following problem:
Q: How to proof?
If $\\{a_n\\}$ satisfy $a_{1}=a$, $a_2=b$, $a_{n+2}=a_{n+1}+a_{n}$($a,b$: positive integers)
then proof that $\frac{a_{4n}-a_2}{a_{2n+1}}$ : integer
I try start by mathematical induction but...., find $f(n)=\frac{a_{4n}-a_2}{a_{2n+1}}$ $f(1)=1$, $f(2)=4$, $f(3)=11$, $f(4)=29$,... | It is easy to prove by induction that $a_n=aF_{n-2}+bF_{n-1}$, where $F_k$ is Fibonacci numbers. I want to prove that $\frac{a_{4n}-a_2}{a_{2n+1}}=F_{2n-2}+F_{2n}$. Therefore, we must prove that $$aF_{4n-2}+bF_{4n-1}-b=(aF_{2n-1}+bF_{2n})(F_{2n-2}+F_{2n})$$ Therefore, we need prove that $F_{4n-2}=F_{2n-1}(F_{2n-2}+F_{2n})$ and $F_{4n-1}-1=F_{2n}(F_{2n-2}+F_{2n})$.These two equalities are easily proved by well-known formulas from Wikipedia. | stackexchange-math | {
"answer_score": 3,
"question_score": 4,
"tags": "sequences and series"
} |
Pixel size when changing from geographic to projected coordinate system?
I have a large raster dataset spanning ~5 degrees of latitude N-S. I know the geographic projection has a spatial resolution of 0.00025 degrees, meaning that the dimensions of each pixel in meters varies depending on latitude.
I have counted the number of pixels in the raster representing different land cover classes. How would I go about converting these pixel counts to area in m2 if the pixel dimensions are variable?
Would simply converting to a projected coordinate system (ie in ArcGIS) standardize the pixel dimensions so that I can multiply pixel counts by a constant area? | Yes, if you project it from a geographic to a projected coordinate system each pixel will have the same area and you can multiply by pixel count to get total area. How accurate that total is will depend on the coordinate system you choose. | stackexchange-gis | {
"answer_score": 3,
"question_score": 3,
"tags": "coordinate system"
} |
How to find corresponding revision of an exported folder with Git
How can I find the corresponding revision of an exported source folder with Git? | I would use `git-bisect` and a custom script that diffs your export and the checkout as a _callback_. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "git, version control, tortoisegit"
} |
How to consume a VSTS artifact DLL from another pipeline in my VSTS MSTest pipeline
I am trying to use a DLL artifact from a developers build pipeline in my VSTS MSTest build pipeline. I need to reference this DLL but I get an error - Error CS0246: The type or namespace name 'Adv' could not be found (are you missing a using directive or an assembly reference?)
I am able to download the DLL's/Artifacts successfully to the agent using Download Build Artifacts option in my pipeline.
How can I get my build in the VSTS pipepline to use the downloaded DLL artifacts on the agent and get rid of this error? | I found out you need to use the copy files option to get the DLL's where you want them. I first tried \bin\debug but the problem there was the build creates these areas automatically and it overwrote my file copy. I noticed in the build log it was considering looking here for the DLL's - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0.
I updated the copy files to copy there and the solution builds just fine now. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "dll injection, azure artifacts"
} |
Swing Component Event Handlers
I have a menu class called Menu wich defines a JFrame, this class instantiates two JPanel objects which contain text fields and buttons. There is a private inner class inside each JPanel extending class which handles the events triggered by pressing the buttons.
I want to know if there is a way for the Menu class to detect the triggered events from the buttons inside the JPanels.
Could you add a listener to a JPanel in the Menu class and do something like this? :
if(event.getSource() == panel.getButton1()){
//do button1 code
} | JPanels and in fact all Swing components have property change support, and so you could easily add a PropertyChangeListener to any Component and listen for state changes. Just be sure that in the code whose state is changing to call `firePropertyChange(...)` after the state changes. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "java, swing, user interface, awt"
} |
Quit makefile if version is to old
I have a makefile using the .ONESHELL command. This feature is supported beginning from version 3.82 of Make.
Is there a way to check and exit if the Make version is to old ? | ifeq ($(filter oneshell,$(.FEATURES)),)
$(error Your version of make does not support .ONESHELL)
endif | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "makefile, gnu make"
} |
WebGL: How to Use Integer Attributes in GLSL
Is it possible to use integer attributes in WebGL vertex shaders? My vertex data contains integers and I want to define the vertex attributes like this:
attribute vec3 POSITION;
attribute int INDEX[8];
attribute float WEIGHT[8];
If this is possible, how would I pass the mixed vertex data to the shader from js using gl.bufferData?
If this is not possible, what is the best way to achieve the same results (pass indices from CPU to shader and use them as integers in the shader)? | WebGL does not support integer attributes. With some exceptions listed in the spec (< WebGL uses mostly the same GLSL feature set as OpenGL ES 2.0.
The spec document for the OpenGL ES Shading Language 1.00 (which is the GLSL version used for ES 2.0)says on page 30, in section "4.3.3 Attribute":
> The attribute qualifier can be used only with the data types float, vec2, vec3, vec4, mat2, mat3, and mat4. Attribute variables cannot be declared as arrays or structures.
The best you can do is probably to simply use floats that do not have a fractional part. The range of values that can be represented exactly will be more limited than an integer using the same storage space. For example a 16-bit float (half float) has 11 bits of precision, and can exactly represent integers from 0 to 2048. | stackexchange-stackoverflow | {
"answer_score": 18,
"question_score": 14,
"tags": "glsl, webgl"
} |
How to show all the midpoints on my bisection code?
I have a code for finding the bisection (and it finally works!), but I need to include 3 more things:
* output- Root History a vector containing the sequence of midpoints obtained by the algorithm
* output- the absolute value of the function
* f(x) at r, i.e., fRoot = f(r) input- max iterations
function [R, E] = myBisection(f, a, b, tol)
m = (a + b)/2;
R = m;
E = abs(f(m));
while E(end) > tol
if sign(f(a)) == sign(f(m))
a = m;
else
b = m;
end
m = (a + b)/2;
R = [R, m];
E = [E, abs(f(m))];
end
how do I do this? thanks!! | I have corrected indents an you can see that you've left out `end` from the end of the function. (it is optional but best not to leave those things out so you know you did not mean to write couple lines to the end but you forgot it.)
`R` and `E` should be returned now, if you call myBisection apropriately, that is
[R, E] = myBisection(f, a, b, tol);
If you just call
myBisection(f, a, b, tol)
it will only return `R`.
To add a limit on the number of iterations, you change `while`'s condition like so:
iter=0;
while (E(end) > tol) && (iter<max_iter)
iter = iter+1;
% ...
end
or it is better to do it in a for loop, with an `if` plus `break`:
for iter=1:max_iter
if(E(end) <= tol), break, end;
% ...
end | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "matlab, bisection"
} |
iTunes App Store: Does a major version upgrade = longer approval queue time?
I'm wondering if anyone has insight into this... when releasing an update of an iPhone application, should I expect the approval process to take longer if I submit something that's declared as a major version update (as compared to a minor version)?
Last time around (about the time the big Facebook-update was released) our wait time for a minor version review was 21 days (16 working days). | The App store is notoriously secretive, so any answers you get here will be anecdotal. I have found (after over 50 releases for different apps) that not much you can do will help estimate how long an approval will take. I have released a bug-fix update with 1 change that took 6 weeks. I have released major app updates that took 1 week.
That said, I think you can help minimize your waiting time by:
1) Providing good release notes to tell the reviewer (and the customer) what has changed.
2) Making sure you dot your i's and cross your t's. Dont expect to get away with any thing, even if you already have in a previous version | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "iphone, app store, appstore approval"
} |
Rails 3/Devise - Change Error Message for Password Reset
I am working with a Rails 3 App and am needing to adjust the error message on the password resent view. If a user types in an email address and submits it, currently, the app will display this error message:
Email not found
I am needing to change this error message to this:
We don't have an account with that e-mail address. Maybe you used another address?
I know that you can adjust this in the Devise YML file, but am not sure how to do this... any suggestions?
**Working Code**
class PasswordsController < Devise::PasswordsController
def create
user = User.find_by_email(params[:user][:email])
if user.nil?
flash.now[:notice] = "We don't have an account with that e-mail address. Maybe you used another address?"
end
super
end
end | You could try using a before_filter that checks if the email exists in the datbase and if not the it redirects you to the password reset form with a flash notice | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "ruby on rails 3, devise"
} |
MFP development server displays 2 of everything
Hi I am trying to set up MFP 7.1 development server on my local. I installed eclipse and MF studio. Everything went fine. i could even create a HelloWorld MFPF project. But i noticed 2 of everything under Mobile First Developement Server [ worklight] [Started, Synchronized] in the 'Server" tab . I see 2 AnalysticsServices, 2 AnalyticalUI, 2 WorklightConsole and 2 WorklightServices. Anything wrong with my setup? How can fix it?screenshot of the workspace | Please search first: IBM MobileFirst 7.1 - Local server duplicating resources
This is a known APAR: PI50480 ALL MOBILEFIRST SERVER .WAR FILES IN MOBILEFIRST STUDIO APPEAR TWICE
The development team is working on fixing it. That said, this duplication has no effect on your project. You can ignore it. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "ibm mobilefirst, mobilefirst studio"
} |
Setting integers inside array to a fixed length
I´m trying to generate an array with integers of a fixed length of 6, so that e.g. 1234 is displayed as `001234` and 12345 as `012345`. I can get it to work for an integer using:
x = 12345
x = '{0:06d}'.format(x)
print(x)
>>> 012345
I tried the same method for an array, but it doesn`t seem to work, so how can I convert this method to array entries?
dummy_array = np.array([1234, 653932, 21394, 99999, 1289])
for i in range(len(dummy_array)
dummy_array[i] = '{0:06d}'.format(dummy[i])
print(dummy_array[2]) #test
>>>21394
Do I need convert the array entries to strings first? | If you set:
dummy_array = np.array([1234, 653932, 21394, 99999, 1289],dtype=object)
it allows the numpy array to contain integers and strings simultaneously, which was your problem. With this simple dtype argument your code will work. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "python, arrays"
} |
Laravel, redirect unregistered user to login route with parameter
Im using the Laravel base Authentication, when unregistered user attempt to access a link, for example: <
It is redirect to < because the user is not registered yet.
My question is: how do i get the url parameter email of the original link (< of the user tried access in my login page?
Obs: im using Laravel 5.7 | In your controller simply try like that:
$email = request()->input('email'); // null if not set
// do your things
// then redirect
< | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, laravel, laravel 5"
} |
Colocar um valor dentro da do 'val' do jquery
Qual a forma correta de montar essa linha?
$("#rastreo").val('BR'<?php echo date("hYmdi"); ?>json[0].estado);
O ID rastreo é um campo input. | Lembre-se de que para concatenar strings com `js` usa-se o caractere '+'. Então seu código original ficaria:
$("#rastreo").val('BR'+<?php echo date("hYmdi"); ?>+json[0].estado);
Uma forma alternativa pode ser:
$('#rastreo').attr('value', 'BR'+<?php echo date("hYmdi"); ?>+json[0].estado); | stackexchange-pt_stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "javascript, jquery"
} |
Width limit on D3 force layout centers
I'm just starting out with D3 and I currently have a force layout with 5 different centers and my nodes gravitating around each one based on a data property. Ideally, each of the five groups has equal number of nodes so that they appear as roughly uniform-width columns — similar to the orange group in this example < (if you let it run for a while).
Some of my groups have many nodes and some have none, however, which is resulting in some clusters being much wider than others. Is it possible to set a max-width beyond which no node will drift left or right of its center while still letting nodes drift more freely above and below center?
Or could I fake it by placing columns of invisible nodes between each of groups to suitably repulse them?
Any help is much appreciated! | After much tinkering I've found that by multiplying the alpha by different numbers you can control the left/right and top/bottom pull independently.
Following this example ( set the setBubbleLocation function to something like this
bubble.y = bubble.y + (center.y - bubble.y) * (0.115) * alpha*.5; //smaller alpha = looser
bubble.x = bubble.x + (center.x - bubble.x) * (0.115) * alpha*3; //bigger alpha = tighter | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "d3.js, force layout"
} |
Does operator precedence explain the difference in these expressions involving multiplication of a numeric with a negated logical?
I have three expressions, each involving multiplication with a logical or its negation. These logicals and their negation represent indicator variables, so that the expressions are conditionally evaluated:
-2*3*!T + 5*7*T
5*7*T + -2*3*!T
(-2*3*!T) + 5*7*T
I expect the above to produce the same result. However:
> -2*3*!T + 5*7*T
[1] 0 # unexpected!
> 5*7*T + -2*3*!T
[1] 35
> (-2*3*!T) + 5*7*T
[1] 35
I am sure this has something to do with operator precedence and type coercion, but I can't work out how it makes sense to even evaluate `!T` after the `*`. | You're exactly right that this is about operator precedence. As `?base::Syntax` (which you link above) states, `!` has lower precedence than all of the arithmetic operators, so the first expression is equivalent to
(-2*3)*!(T + 5*7*T)
(because the expression containing `!` has to be evaluated before the final multiplication can be done) or
-6*!(36) # T coerced to 1 in numeric operations
or
-6*FALSE # non-zero numbers coerced to TRUE in logical operations
or
-6*0 # FALSE coerced to 0 in numeric operations | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "r, logical operators, operator precedence, not operator"
} |
Adding constraints to an abstract type
I have this type that I have created :
`create type baseType as Object(...) NOT Instantiable not Final`
and I'd like to add constraints to some fields. The problem is that this type in `not instantiable` and therefore, I can't add a constraint to its fields. So then, when I create my inheriting types
create type childType1 under baseType (...)
create type childType2 under baseType (...)
I'll have to add constraints to all the children tables. Is this the correct way to go? I thought there would be a way to add the constraints on the common fields only in the parent type. Is there a way of doing that? | You can't add constraints to object types at all - constraints are on a table. If the object is not instantiable, you can't have a table based on it, ergo no constraints on it.
I guess the answer would be to make the object type Instantiable. Then you can create a table based on it with constraints. Of course, these constraints won't be "inherited" by the child types.
All that said, however, I personally avoid Oracle object types when I can. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "sql, oracle, constraints, object oriented database"
} |
How to include files in gcc search path?
I am installing pylibrabbitmq on ubuntu. But `amqp.h` is not in search path. It is in
'`/tmp/src/rabbit/rabbitmq-c/librabbitmq`'.
How can I add this location to gcc search path? | run
sudo gcc whatever.c -I/dir/*
where ampq.h should be in the folder * | stackexchange-stackoverflow | {
"answer_score": -1,
"question_score": 0,
"tags": "python, ubuntu"
} |
Why in a DFA the empty string distinguishes any accept state from any reject state?
Often I read this sentence about DFA:
> The empty string $\epsilon$ distinguishes any accept state from any reject state.
Here the source: <
I don't understand the above statement, since by definition a DFA can't have $\epsilon$ transitions. Please can you explain me better? Many thanks! | That claim has nothing to do with $\epsilon$-transitions. What is says intuitively is that even before you read any input letter, you can tell an accepting state from a non-accepting state.
In minimizing DFAs, we look for _indistinguishable_ states. Two states are indistinguishable if the same language is accepted starting from both. To compute the indistinguishable pairs, we define $k$-indistinguishable states; that is, those states from which the words of length up to $k$ accepted from the two states are exactly the same. As a special case, two states are $0$-indistinguishable if and only if they are either both accepting or both rejecting. This is what those lecture notes presumably talk about. | stackexchange-math | {
"answer_score": 3,
"question_score": 0,
"tags": "computer science, automata"
} |
Calculation Within mySQL With a Count
I need to make a mySQL query to calculate some values.
essentially I want to select a single column from a table, I want to count how many of each values there are and then give that to the user.
So:
SELECT numeric_values FROM answerTable
IF numeric_values == '1.00' THEN new_variable1 ++
IF numeric_values == '2.00' THEN new_variable2 ++
IF numeric_values == '3.00' THEN new_variable3 ++
IF numeric_values == '4.00' THEN new_variable4 ++
RETURN new_variable1 ++
RETURN new_variable2 ++
RETURN THEN new_variable3 ++
RETURN THEN new_variable4 ++
;
I really havent got a clue where to start looking or if these types of operators are even available in mySQL? | SELECT numeric_values,COUNT(numeric_values)as name FROM answerTable
GROUP BY numeric_values | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "mysql, sql"
} |
Can you spot people in BF3 when you are in a vehicle?
Say you are flying a heli, can you use the same spot key/button to spot people on the ground? Do you have to have them in your sights? | Yes, you can. The same principle applies as when you are on foot, in that you need to be looking in their direction and not have them in your peripheral vision. The same applies to all vehicles. | stackexchange-gaming | {
"answer_score": 6,
"question_score": 4,
"tags": "battlefield 3"
} |
What's the name of this insect?
Here's a picture:
 API.
In the documentations I see that there is an Enumeration called PushpinOffset but I just cannot find how and where to apply it. I had a look on the Pushpin as well as the Map instance and I couldn't find it any properties where I should add this enum.
This is most likely a rather trivial issue but I would be grateful if someone could show me how to use PushpinOffset enumerations using C#/Bing Maps Store API.
Thank you | Use the MapLayer.SetPositionAnchor method instead to offset the position of your pushpin. For example:
MapLayer.SetPositionAnchor(pin, new Point(10,10)) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, windows runtime, windows store apps, bing maps"
} |
Return a http response before actual function is completed
I have a form on my site that uploads a file. Currently i upload the file to amazon S3 before sending a response back to the user. Is there a way in Django to send a "Success" response to the user immediately after the file is saved on my local server, but before I i start saving it to s3? | You should use a distributed task queue.
Since you are using AWS already, you might want to consider their alternative: Amazon SQS. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "django"
} |
Azure Webjobs app.config Release Transformations
I have a webjob and a webapp (both separate projects), I would like to build one artifact for all environments and do the transformations during the release step rather than build, as that way I have to create an artifact per environment. So I am creating two separate artifacts (one for webapp and one for webjob) per environment and applying the xml transforms during publish to the app service, now everything works fine, except that the transformed file for the webjob is placed in the root directory of the webapp, which is not what I intend to do. I would like the file to be placed as `app_data\jobs\continous\myjob\myjob.exe.config`
I've seen the slow cheeta and CTT transforms, but those are out of the scope of this question as they do transform only on build.
$
This additionally selects the selected number of beginning characters of a paragraph, but does not exclude them.
^^.*{1}$ | Depending on the type of regex you're using, you could use \K to reset the match after the first character, for example:
^.\K.*$
If you can't use \K, you should be able to use a negative look-ahead to ignore the first character of the string:
(?!^.).*$
`(?!something)` is a negative look-ahead which ensures that whatever follows that matches what's in the parentheses is NOT included in the match. `^.` is the character immediately following the start of the string. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "regex, select, paragraph, negative lookbehind"
} |
Calculate quintiles/deciles from an array of numbers
Given the following array:
[13, 468, 3, 6, 220, 762, 97, 16, 522, 69, 119, 2895, 1255, 49, 19, 261, 9, 140, 55, 20, 6, 22, 6, 17, 115]
I need to calculate the value that is at the 20th, 40th, 60th, and 80th percentile. The steps would be to order the array from low to high, count the total number of values, determine what value is at the 20th percentile, etc. (for example, if there are 10 numbers in order from low to high, the 2nd value would be the 20th percentile).
This is stored in a variable and I know I can sort the numbers like this: `ticks6.sort();`
and get the number of values in the array with this:
`var newticks=ticks6.length;`
I have no idea how to do the next part though where I figure out the percentiles, but looking for a solution in jquery or javascript. | Use like this:
var arr = [13, 468, 3, 6, 220, 762, 97, 16, 522, 69, 119, 2895, 1255, 49, 19, 261, 9, 140, 55, 20, 6, 22, 6, 17, 115];
arr.sort();
var len = arr.length;
var per20 = Math.floor(len*.2) - 1;
console.log(arr[per20]);
//similarly
var per40 = Math.floor(len*.4) - 1;
console.log(arr[per40]); | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 2,
"tags": "javascript, jquery, arrays"
} |
PHP basename( __DIR__ ) is returning _DIR_ on some servers
I'm hoping someone here knows the answer to this. I wrote a script that uses
`basename( __DIR__ )`
then uses an if file exist function.
On my server this works fine, however on other sever it actually returns the word `_DIR_` instead of the file path.
Did this change with a version of PHP or is there some other setting that makes it so this doesn’t work?
Lastly is there a better way to get the path of the file? Here is the whole line I’m using:
`define('NIFTY_CONSTANT', trailingslashit (WP_PLUGIN_DIR . '/'. basename( __DIR__ ) ). '/lib/mdetect.php' );`
(yes I know it's a WordPress function but this is not a WordPress question it's a PHP one) | `__DIR__` is introduced in PHP 5.3 . Double check your PHP version .
Reference: < | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 5,
"tags": "php, filepath, dir"
} |
Own Exception Class with Toast Nofitfication
Hy!
I want to make my own Exception Class, but my problem is that i don'T know how to access the Context to show a Toast for the user.
My Code:
public class NFFException extends Exception{
private static final long serialVersionUID = 1L;
public NFFException(String msg) {
Toast.makeText(???, msg, 300);
}
} | Since context is not static, so you can not use it in Exception class. One thing you can do, in any activity class, make a static field
static Context context;
initialize it in onCreate() method,
and then use this context variable in your above code | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "android"
} |
Second order partial derivative 9
I am following a work where the authors start a production function and get this first order partial derivative (with respect to $ k $):
$$ f'(k)=\frac{a(1+bk)}{k^{1-a}(1+abk)^{a}} $$
And by deriving it again obtain the following second order partial derivative:
$$ f''(k)=a(a-1)k^{a-2}(1+abk)^{-a-1} $$
I managed to get the first one but not the second one. Is there someone who can help me with this? Thank u so much and Happy Christmas!! :) | I think that this is a good problem for logarithmic differentiation.
Consider $$y=\frac{a(1+bk)}{k^{1-a}(1+abk)^{a}}$$ $$\log(y)=\log(a)+\log(1+bk)-(1-a)\log(k)-a\log(1+abk)$$ Differentiate both sides $$\frac{y'}y=\frac {b}{1+bk}-\frac{1-a}k-\frac{a^2b}{1+abk}=\frac{a-1}{k (1+b k) (1+a b k)}$$ Now $$y'=y \times \frac{y'}y=\frac{a(1+bk)}{k^{1-a}(1+abk)^{a}}\times \frac{a-1}{k (1+b k) (1+a b k)}$$
Just simplify.
# Merry Xmas | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "calculus, derivatives, partial derivative"
} |
Figure 2 in the Verifiable Computation - Pinocchio
I am reading the Pinocchio paper (verifiable computation): <
The paper is rather hard for me. For the Figure 2, I guess $v_1(x)$ should be $(r_6-r_5)^{-1}*(x-r_5)$, and the rest can be found similarly. Is this right? If yes, then how do we determine $r_5$ and $r_6$ when we generate the keys (evaluation and verification). Since we will have to calculate $v_k(s)$ etc.
Thanks for help me to understand it! | Yes, this is correct. The $r_i$ are arbitrary elements of the base field, their values are unimportant as long as they are all distinct. | stackexchange-crypto | {
"answer_score": 1,
"question_score": 1,
"tags": "zero knowledge proofs, verifiability"
} |
Geckodriver for Solaris OS
We are using selenium python to automate web application. To launch firefox browser, we need to download geckodriver and place it in /usr/bin. but, we found that linux version geckodriver is not compatible with Solaris os. whenever I am running selenium python to run code on solaris v5.11 , we got an error like "Bad System call(core dumped)"
solaris 11.4 python 2.7.14 selenium 3.141.0 geckodriver 0.24.0
please help to resolve the issue | Solaris & Linux use very different system calls, and binaries must be compiled specifically for each one - you cannot copy them across from one system to the other - so you will need to either compile geckodriver yourself or find a version already compiled for Solaris, not Linux. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, selenium, solaris, selenium firefoxdriver"
} |
Trajectory of $X_1(t) = (2\cos^2 x, \cos t \sin t)\;\; (0\le t \le \pi)$
I need to draw trajectory of $X_1(t) = (2\cos^2 t, \cos t \sin t)\;\; (0\le t \le \pi)$
If one let $2\cos^2 x = x, \cos t \sin t =y$ then
$dx/dt = -4\cos t\sin t =-4y$ and one could derive x = -4yt+C.
However, with this approach doesn't make the t disappear so that one could get the pure relation of x and y.
any hint/adice ? | We don't have to differentiate.
$x=2\cos^2t$ and $y=\cos t\sin t$.
\begin{align} y^2&=\cos^2t\sin^2t\\\ &=\cos^2t(1-\cos^2t)\\\ &=\frac{x}{2}\left(1-\frac{x}{2}\right) \end{align} | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "parametric"
} |
Azure 2.6 SDK - Microsoft.WindowsAzure.targets not found on TFS Online
According to < and <
the tfs online build services should be updated. I just upgraded projects to 2.6 and checked them in to get the following:
The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Windows Azure Tools\2.6\Microsoft.WindowsAzure.targets" was not found.
Have something changed with 2.6 or is it because my build service not yet has been updated? | The VSO Host Build Controller has now been updated with Azure SDK 2.6.
You can see all the supported software here. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "azure, tfs"
} |
DOM code for select tag
Here is the fiddle
<
I want, if you select a no. then according to that number the rows comes up!
var number_opt = document.getElementById("opt_select");
var opt;
for (var i = 1; i <= number_opt.value; i += 1) {
opt = '"#opt_row_' + i + '"';
$(opt).show(100);
}
Will this work! I know it's stupid! | yes you can...using `change()` event.
try this
$(function () {
$("#opt_row_1,#opt_row_2,#opt_row_3").hide(0); //<--using multiselector
$("#opt_select").change(function () {
var $val = this.value;
$('#opt_row_' + $val).show(100);
});
});
**update**
if you want to hide other rows before displaying the selected rows then
$(function () {
$("#opt_row_1,#opt_row_2,#opt_row_3").hide(0);
$("#opt_select").change(function () {
$("#opt_row_1,#opt_row_2,#opt_row_3").hide(0);
var $val = this.value;
$('#opt_row_' + $val).show(100);
});
});
**hide other rows and display the selected rows :** updated fiddle
**simple fiddle displaying just the selected rows** : fiddle here | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, dom, html select"
} |
(scheme) how can I use a procedure in a control structure?
I have a procedure like
(lambda (r) (change table r))
I want to use that in an if structure. My main goal is apply a procedure to list elements which satisfy another procedure. I can't use filter because I want to see also unchanged element of list | (define (map-if mapper pred lst)
(map (lambda (x)
(if (pred x)
(mapper x)
x))
lst)) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "if statement, scheme, procedure"
} |
How to get the opposite value of a bool variable in C++
To me, a bool variable indicates either **true** or **false**.
Some bool variable was defined and initialized to a value unknown to us. I just want to get the opposite value of it. How should I do it in C++? | Just use the `!` operator:
bool x = // something
bool y = !x; // Get the opposite. | stackexchange-stackoverflow | {
"answer_score": 28,
"question_score": 6,
"tags": "c++, variables, boolean"
} |
File Sharing With Ext4 Partition
I tried googling this problem but I haven't received a definitive answer.
This is my situation, I have a 3TB external hard drive connected to my server via esata. I plan on sharing this drive over a network using samba. The hard drive is formatted in ext4 but I need a windows machine to be able to read and write to it over the network to access files, make backups and general storage.
I chose ext4 because I heard ntfs-3g has a ton of latency when accessing drives and I like how I can move files while I'm using them.
Is this possible or will I have to install some program to at least read the drive? | It is certainly possible. To my knowledge, Samba doesn't care what file system you're using, just so long as you can read it and mount it. If you setup a Samba share that points to a directory on your esata drive, windows machines will be able to view it without ever having to know that it's formatted ext4.
edit: To provide more information, modifying your `/etc/samba/smb.conf` is how you would go about creating a share for your esata drive.
As an example, here is a relevant entry in my smb.conf:
[raid]
comment = 4TB Raid5
path = /mnt/raid
public = yes
writable = yes
create mask = 0777
directory mask = 0777
force user = nobody
force group = nogroup
That will create a share named _raid_ that points to the directory _/mnt/raid_. It doesn't require a username/password, and it's writable.
After making those changes, use `sudo service smbd restart` to restart the samba server. | stackexchange-askubuntu | {
"answer_score": 6,
"question_score": 2,
"tags": "windows, samba, ext4"
} |
Javascript: if 'abstract' is a reserved word why I am still able to use it as an identifier?
I am reading a book about JavaScript where I read about reserved words, I tried all the reserved words to us as an identifier but no one is allowed except 'abstract', I am still able to use 'abstract' as an identifier even it is a reserved word! I tried Internet Explorer, Chrome, Firefox and it is working as an identifier, why is it still allowed as an identifier even it is a reserved word? Thanks
function myFunction(a, b) {
abstract = a+b;
alert("Sum = "+abstract);
}
<!DOCTYPE html>
<html>
<head>
<title>TestScript</title>
</head>
<body>
<button onclick="myFunction(20, 5)">Try it</button>
</body>
</html> | There are tons of "future" reserved words which aren't actually reserved, because the don't yet do anything. Many of them will never do anything.
For example, `synchronized` is also a reserved word, but `var synchronized = true` probably works in most browsers. Same for `native`, `boolean`, `transient` etc.
var native, boolean, float, await, synchronized;
native = boolean = float = await = synchronized = "blah";
document.write(native, boolean, float, await, synchronized); // blahblahblahblahblah | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "javascript, identifier, reserved words"
} |
Exiting the airport on a connection flight
I am citizen of USA. I will be flying from South Korea back to USA. There is an 8 hour stop in Taiwan for a connecting flight. Am I allowed to exit the Taiwan airport on this stop to meet up with some friends for a meal? If so, are there any complications I should expect to encounter, such as immigration and luggage check? | As a US citizen you do not require a visa to enter Taiwan.
I have done exactly what you're planning multiple times (most recently last year) and had no issues passing through immigration in either direction. If the immigration staff ask, just explain to them that you are in transit, and show them your connecting boarding pass.
Presuming you are on a single booking, your bags will be checked all the way through, and you will not need to collect them in Taiwan, even though you are entering the country. | stackexchange-travel | {
"answer_score": 6,
"question_score": 4,
"tags": "transit, airports, us citizens, connecting flights, taiwan"
} |
Implication and entailment
I have several questions about entailment and implication.
1) Let $A = \\{p_1, ..., p_n \\}$ be some set of logical statements and $q$ some logical statement. Is it right that "$A \models q$" is a correct logical statement, i.e. it may be true, or false and we may always define its logical meaning?
2) What if $A = \varnothing$?
3) Is it right that $(A \models p) \equiv ((p_1 \land ... \land p_n) \rightarrow q)$ ?
4) How should i treat the following situation: $\\{ q, q->p \\} \models p \rightarrow r$. Is it a correct entailment? I'm confused because there is $r$ on the right and there is no $r$ on the left.
Thanks in advance.
EDIT
Sorry for my English. I suppose "logical proposition" is a more correct term then "logical statement". | * If $q$ is a "logical statement" (assuming you mean is logically valid), then we have $\vDash q$, and so a fortiori $A \vDash q$. (If $q$ is true on _all_ interpretations, it is true in particular on all intepretations which make the members of $A$ true.)
* If $q$ is a "logical statement", then we have $\emptyset \vDash q$. (For $\emptyset \vDash q$ says that $q$ is true on those interpretations which make any $p$ true if $p$ is a member of $\emptyset$ -- which are, vacuously, _all_ interpretations).
* Not quite. You mean $(A \models q)$ iff $\models ((p_1 \land ... \land p_n) \rightarrow q)$ or $(A \models q) \Leftrightarrow\ \models ((p_1 \land ... \land p_n) \rightarrow q)$ [You want metalinguistic claims on both sides of the equivalence.]
* Finally $\\{ q, q->p \\} \models p \rightarrow r$ is plainly not correct. Suppose $p$ and $q$ are true, and $r$ false. | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "logic"
} |
How does the ellipsis $x^2+2y^2=2$ gets represented to $x=\sqrt{2}\cos\theta; y= \sin(\theta)$ in polar coordinates?
Just like the title says, How does the ellipsis with equation $$x^2+2y^2=2$$ becomes represented as $$x=\sqrt{2}\cos\theta; y= \sin(\theta)$$ in polar coordinates?
can someone help me to understand the translation between cartesian to polar here?
This is for evaluating a double integral, btw. But I can't understand on my own how to get that transformation. | The idea of the transformation here is based on polar coordinates but actually is called a parametrisation (as stated in the comments). Precisely, you wish to find values of $x$ and $y$ such that the above equation is true. In your case, plugging in $x=\sqrt{2}\cos\theta$ and $y=\sin\theta$ yields $$(\sqrt{2}\cos\theta)^2+2\sin^2\theta=2\cos^2\theta+2\sin^2\theta=2,$$ since $\cos^2\theta+\sin^2\theta=1$. Then, instead of evaluating a double integral over $x$ and $y$, you just use your transformation and evaluate it over $r$ and $\theta$, of course without forgetting the Jacobian. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "integration, polar coordinates"
} |
Сервант как остекленная секция стенки
Подскажите, пожалуйста, можно ли назвать одну из секций стенки сервантом (или буфетом): речь идет об остекленной секции, хранящей в данном случае посуду вместе с различными сувенирами. Определяется ли сервант содержанием или техническим исполнением? Может ли он быть составной частью?
 секцию шкафа можно назвать _буфетом_. Как разновидность буфета это "буфет с нишей". _Сервантом_ называют другую, низкую разновидность буфета: < Тип конструкции, подобной застеклённому верхнему шкафчику буфета, иногда называют "витриной"; в современной торговле мебелью встречаются и отдельные предметы под названием "шкаф-витрина". | stackexchange-rus | {
"answer_score": 1,
"question_score": 0,
"tags": "значение"
} |
fibroblast cells and fibers
I am interested in fibroblast cells in human arteries. Here are the things that I am not clear at the moment and I could not find any answer from the literature:
1. What are the dimensions of these fibroblast cells? How big are they in terms of diameter and thickness? How big are they if they are comparing with the collagen fibers in the artery?
2. I think they have to attach themselves to the fibers in order to proliferate or differentiate. However, I do not know, do one fibroblast cell attach itself to one fiber and then "crawl" to another? Or do they "sit" on a network of fibers?
I will appreciate your help on this and will be even more grateful if you could provide me with some literature that I could find the answer to these questions. | Regarding dimensions:
!Cultured fibroblasts
As per this image the length and breadth seems to be ~30-50 μm (area should be roughly around 900 μm²). The third dimension (thickness) as per this article can be assumed to be around 3-7 μm.
Regarding cell attachment:
Cells attach to extracellular matrix via integrins, which attach to ECM proteins like collagen and fibronectin. The matrix is a net of fibres and the cell is not specifically attached to a single fibre but rather "sits"(as you said) on the matrix [see the below image]. A single cell also simultaneously interacts with two different types of ECM proteins such as fibronectin and collagen.
!ECM
During migration they move along the matrix using lammelipodia (actin filament polymerization in the direction of motion).
Fibroblast express ICAM1/VCAM1 (Inter/Vascular Cell Adhesion Molecules) under certain conditions such as inflammation and bind to T-cells and endothelial cells. | stackexchange-biology | {
"answer_score": 2,
"question_score": 2,
"tags": "human biology, cell biology, physiology, cell culture, cardiology"
} |
How to open a whole Rails app in Notepad++
I'm using Notepad++ on a Windows machine. On my Mac, I can open the whole Rails app in the text editor and then just click on files in the editor. however, in windows notepad++ it seems to require me to open each file individually.
Alternatively, is there a command I can use from the command line? | Try to create a project and add your source files.
1. You can go to Notepad++ "View -> Project -> Project Panel 1" (for example)
2. In the panel Right Click the Workspace Icon, Select "Add New Project"
3. Once the project is created right click it and select "Add Files From Directory".
It's not a top gun feature, but it surely makes the job. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "ruby on rails, windows"
} |
Multi continents shown when at max zoom in leaflet - data only shown on center continent
New user to Leaflet here and I've developed a mapping application that pulls geoJSON from an Oracle db. This all works but if I zoom Leaflet all the way out where it shows multiple copies of the continent my data only shows if I zoom into the center continent. My questions are is this normal? How to you prevent the user from panning to another continent while continuing to move in an east or west direction? | You can set a `minZoom` property to avoid this.
Something like:
var map = L.map('map', {
center: [51.505, -0.09],
minZoom: 4,
zoom: 13
});
Docs Reference
**EDIT:** Maybe I misunderstand your question.
To restrict the map view to the given bounds you use:
map.setMaxBounds(LatLngBounds);
setMaxBounds Reference
**_More specifically:_**
map.setMaxBounds(L.latLngBounds(
L.latLng(85, -180),
L.latLng(-85, 180)
)); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "leaflet"
} |
What are the security implications of a user account with no password on linux?
It is possible to log in to an account without a password from a virtual terminal when the password is empty. On my system(Arch Linux), logging in with `su` and an empty password simply gives a wrong password notification.
Can a program log in "directly"(without using `su`) with empty password?
Note that this is a "default" Linux installation, without `sudo`,`sshd` or anything of the type. This also does not take into someone malicious physically logging in from the keyboard, since physical access is total compromise anyway. | > What are the security implications of a user account with no password on linux?
That will make brute force attacks very efficient as they generally start with testing an empty password. The implications depend on how the system is configured. Some systems and services might not allow login using a passwordless account (e.g. pam_unix **nullok** option), or restrict such logins to some devices (e.g. see pam_unix **nullok_secure** option and /etc/securetty).
> Can a program log in "directly"(without using su) with empty password?
A suid program can do it. A regular program might depending on the OS and on whether it is called from a login shell or not. | stackexchange-unix | {
"answer_score": 0,
"question_score": -1,
"tags": "linux, security, password"
} |
SQL database structure for week schedule
I've been looking for an answer for the following question, but I didn't find anything on it.
I would like to make a SQL database where I can store data per day (Mon-Sun), per hour (every 15 minutes). It's sort of an overview from Monday to Sunday only from the previous week, where I can add data per 15mins.
If handling a lot of data (read several 100k rows). Would it be better to make tables per day and then have columns per 15 minutes? | You can just have a table that takes the data at the 15 minute interval with a timestamp.
So only 3 columns (user, data, timestamp). The timestamp could be in seconds/milliseconds/nano what ever format you want.
Once displaying the data you can compute what week its in on the "fly". | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "mysql, sql, calendar"
} |
How can I login to a website with username and password using curl?
I want to update the IP Address from my DynDNS via curl. For that i need to ping a website with my username and my password. Here a screenshot from the login screen. How can i pass my credentials to this via curl?
Best greetings, DasMoorhuhn :) | I found it...
curl -s --user USER:PASSWORD URL | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "curl"
} |
Let $f(x)=x^5+a_1x^4+a_2x^3+a_3x^2$ be a polynomial function. If $f(1)<0$ and $f(-1)>0$. Then
> Let $f(x)=x^5+a_1x^4+a_2x^3+a_3x^2$ be a polynomial function. If $f(1)<0$ and $f(-1)>0$. Then
>
> 1. $f$ has at least $3$ real zeroes
> 2. $f$ has at most $3$ real zeroes
> 3. $f$ has at most $1$ real zero
> 4. All zeroes are real
>
**My attempt:-**
From the given condition. we get
1. $f(-1)>0 \implies a_1-a_2+a_3>1$
2. $f(1)<0 \implies a_1+a_2+a_3<-1$
3. By intermediate theorem, $f$ has at least a zero in $[-1,1]$ $f(0)=0\implies 0$ is a zero of $f(x).$
How do I draw conclusion from this? | We know that $$\lim_{x\to\infty}f(x)=\infty$$
and
$$\lim_{x\to-\infty}f(x)=-\infty$$
Therefore there are constants $C_-,C_+$ with $C_-<-1$, $C_+>1$ and so that $F(C_-)<0$, $F(C_+)>0$.
Apply intermediate value theorem on $[-C_-,-1]$, $[-1,1]$, $[1,C_+]$ to get at least 3 real zeroes. | stackexchange-math | {
"answer_score": 3,
"question_score": 1,
"tags": "real analysis, polynomials, continuity, roots"
} |
PyCharm Code Completion on function parameters
I have written a function in python that expects a parameter (message) of a special class "Message" from a library. Unfortunately i dont get recommendations for autocompletion when i write message. and press strg + space in the function's body because PyCharm doesnt know its an object of the class Message. Is there anyway to fix this? | try using type definition <
something like this
class Message:
pass
def foo(message: Message):
print(message) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "python, autocomplete, pycharm"
} |
Qt: У меня вопрос по поводу QStackedWidget И Qt Designer
Используя Qt Designer я добавил в окно QStackedWidget и две страницы. Как я должен сделать так чтобы добавить в эти страницы кнопки и прочие виджеты? (Просто я только начал использовать этот Дизайнер). Если вам не полностью понятно то что я хочу сказать, я могу дополнить текст деталями. | Приведу минимальный пример:
class Foo : public QWidget
{
Q_OBJECT
public:
Foo(QWidget* parent = 0) : QWidget(parent),
stw_(new QStackedWidget(this))
{
QVBoxLayout* lo = new QVBoxLayout();
QPushButton* btn = new QPushButton(this);
lo->addWidget(stw_);
lo->addWidget(btn);
this->setLayout(lo);
connect(btn, SIGNAL(clicked()), this, SLOT(slotChangePage()));
addPages();
}
private slots:
void slotChangePage()
{
int index = stw_->currentIndex() + 1;
if (index >= stw_->count()) {
index = 0;
}
stw_->setCurrentIndex(index);
}
private:
void addPages()
{
// Здесь разместить код вставки страниц в QStackedWidget,
// например, используя QStackedWidget::addWidget(QWidget*)
}
private:
QStackedWidget* stw_;
}; | stackexchange-ru_stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c++, qt"
} |
$E(X\mid X+Y)$, where $X$ and $Y$ are independent $U(0,1)$.
Given that $X,Y\sim U(0,1)$ calculate:
(1) $E(X\mid X+Y)$
I am stuck at this point:
$$E(X\mid X+Y)=\int_0^1 xf_{X\mid X+Y}(x\mid x+Y) \, dx=\int_0^1 xf_{X, Y}(x, Y) \, dx$$ | We know $(X,X+Y)\sim U(D)$ (i.e., a uniform distribution over $D$), where $D$ is the shaded area as below:
$. | stackexchange-math | {
"answer_score": 2,
"question_score": 3,
"tags": "probability, functions, expectation, convolution"
} |
Prevent a node module from being recreated or overwritten?
Is there any way in node.js by which I can prevent a module to never be updated or overwritten? | You need to write it as exact version on dependencies property, for example:
"dependencies": {
"async": "1.3", // exact version this never will be changed/overwritten/updated/etc...
"body-parser": "~1.5.2", // This could be updated to version reasonably close to 1.5.2
"bower": "^1.3.8", // This could be updated to version compatible with 1.3.8
}
Please look at here for the complete list of options. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "node.js, node modules"
} |
How to add time pattern in the log when using java logger
We use java.util.logging, and we use java.util.logging.FileHandler to config the rotated logs.
We want to add timestamp into log file name pattern to make it looks like:
logFile_2011-08-25_14_*02*_38_PDT.0.log
logFile_2011-08-25_14_*12*_38_PDT.1.log
logFile_2011-08-25_14_*22*_38_PDT.2.log
logFile_2011-08-25_14_*32*_38_PDT.3.log
Be aware of the different timestamp in the log file name.
We are now using the pattern = "logfile_XXXXXX.%g"
How is the pattern looks like to make the timestamp decided at runtime? | No, java.util.logging no! Check out LogBack instead! It's a successor of log4j and of course implements sfl4j.
Back to your question, I'm not an expert of Java Logging but I believe you cannot do this through configuration. There might be other ways though.. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, logging"
} |
How to determine which function is the "higher" one of two from equations?
I'm wondering how I can determine from the equations of two functions without graphing which function will be the "upper" function when calculating the area between the two. For example, the equations:
$$f(x) = x^2$$ $$g(x) = 1 - x^2$$
Graphing it is is obvious $g(x)$ is the "higher" of the two; meaning the area between the curves would be calculated as $\int_a^b(1-x^2) - \int_a^b x^2$. The graph is shown below:-g(x)| dx$, which ensures you are taking the positive area in each of these intervals. Note that this is not necessarily the same as $|\int (f(x)-g(x)) dx|$! | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "calculus, integration, definite integrals, graphing functions, area"
} |
Beta decay breaks conservation of momentum?
Just considering the decay of a free neutron, the change in rest mass, .732-ish MeV, leaves as kinetic energy of the electron and neutrino. Doesnt this break conservation of momentum since the neutron has no momentum? What am I missing, is there really a mass-energy-momentum conservation and momentum conservation on its own doesnt exist for beta decay?
In math, before = after, is
pn = pe + pp + pv
Or
E + p = sum of E + sum of p
Or something else? | **Edit** after the question was edited to include the proton in the decay products
Momentum is a vector quantity and the four vector algebra has to be used when discussing decays and conservation laws at particle level. The equation for the momentum is
$P_xn=p_xp+p_xν+p_xe$
$P_yn=p_yp+p_yν+p_ye$
$P_zn=p_zp+p_zν+p_ze$
If in the center of mass of the neutron, when P is equal to zero, conservation requires for the sum to be zero.
and for energy
En=Ep+Eν+Ee
Where E is the total energy in the system, all to be computed with the four vector algebra representing the particles . The "length" of the four vector is the invariant mass of the particle it represents. | stackexchange-physics | {
"answer_score": 1,
"question_score": 1,
"tags": "energy, particle physics, momentum, radiation"
} |
Good idea to have an index on datetime column?
Assuming something like so:
`select * from table where DatePart(YEAR, dateColumn) = 2012`
Reasonable to have an index on dateColumn?
Edit*
For **SQLServer** | Adding an index is definitely a good idea for this. However, DATEPART(YEAR, datecolumn) = 2012 isnt' sargable so it will still do a scan of the index.
If you want it to use the index then you will need to do:
WHERE dateColumn >= '1/1/2012' AND dateColumn < '1/1/2013'
Please note the placement of the >= and the < signs to get the correct bounding box. | stackexchange-dba | {
"answer_score": 4,
"question_score": 2,
"tags": "sql server, index"
} |
Confusing choices for what the limits at infinity for a rational function
I was given a question in our discussion that states that:
> Let $$f(x) = \frac{(x^3+2)}{x}$$ What is the limit of $f(x)$ as $x$ approaches infinity? The choices were:
> A. It is a relative extremum of $f$.
> B. It is a point of inflection of $f$.
> C. It is a horizontal asymptote of $f$.
> D. It is a vertical asymptote of $f$.
Obviously, D isn't correct.
For A, B, and C, we need a certain value for it to be true, right? Is there something wrong with the question or I'm missing something? | I don't think it is any of the choices, because I graphed it on Desmos, and there is a vertical asymptote at zero, but it just blows up at both ends of the graph. can be evaluated as: $$ EX=\int_0^\infty[1-F(x)]dx-\int_{-\infty}^0F(x)dx $$ I can't convince myself why the integral bounds change the way they do, once Fubini's theorem is used to swap the order of integration.
Here's the start of his solution: $$ \begin{align*} \int_0^\infty[1-F(x)]dx&=\int_0^\infty\int_x^\infty dF(y)dx\\\ &=\int_0^\infty\int_0^ydxdF(y) \end{align*} $$ This might be a basic calc misunderstanding, but hopefully someone could clarify. | If you consider a plane and label the horizontal axis with $x$ and the vertical axis with $y$, then draw the region consisting of points $(x,y)$ satisfying $y \ge x \ge 0$. It is a cone ("infinite triangle") in the first quadrant. By cutting this region into vertical strips or horizontal strips respectively, you can write this set as $$\\{(x,y) : y \in [x, \infty)\\} \cap \\{(x,y) : x \in [0,\infty)\\}$$ or $$\\{(x,y) : x \in [0,y]\\} \cap \\{(x,y) : y \in [0,\infty)\\}$$ which gives the two different integral bounds. | stackexchange-math | {
"answer_score": 3,
"question_score": 3,
"tags": "integration, probability theory, improper integrals, expected value"
} |
Set style for a div using angular Scope value
I have a horizontal div to show the percent of some activity. I have one outer div with `width=100%` and one inner div. I have to fill the inner div with background color based on percentage value obtained from the controller, but my problem is that percentage value is in `$scope` variable percentage.
My code is below:
<div class="outerDiv">
<div class="innerDiv" style="'width':{{percentage}}"></div>
`{{percentage}}` is my scope value. But the above code is not working fine so my need is that, I have to set style for div using scope value.plz help | You can use `ng-style="{'width' : width}`
In your controller:
$scope.width = '50%'; | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "javascript, html, css, angularjs"
} |
What determines cache speed?
I have a program that reads from a file and performs operations on it (count frequencies of words)....I have 4 different file sizes, i get cache speed on all but the largest. Why does the largest file only run at disk speed no matter how many times i run it? Does too much ram usage restrict the cache from running? The large file is 27 gb. Running on windows. This is file caching, not CPU caching | Cache == memory. Run out of memory, you run out of cache. If you have a file that is greater than the size of the cache, and you're streaming through it, it's as if you had pretty much no cache at all. Cache only helps when you read the data again, it has no effect on the first time.
When the file is greater than the memory, then there is never any of the original file left in memory when you try to re-use it, thus the cache has pretty much no value in that case. The other dark side is that when you do that, you may well lose the cache on all of the other small files that the system accesses often and are no longer cached. So it may take a bit longer for things to reload and get back up to speed. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "file, caching, disk"
} |
Is there a direct, fast way to "map" list<VectorXd> to MatrixXd?
I am looking for a direct, fast method to convert a `list<VectorXd>` to `MatrixXd`. How can I do that?
Map<Eigen::MatrixXd> listV(list<VectorXd>)
Doesn't compile.
I am also thinking about iterating over the `list<VectorXd>` and fill in the `MatrixXd` necessarily, but that could be slow and unnecessary.
Although I agree that this answer is helpful to me in resolving my question, but I don't agree that the parent question is a duplicate for this one. The way to access `list` and `vector` can be different, so the question should remain open because _the answer is different._ | No that's not possible because the elements of the std::list are not sequentially stored in memory. So you'll have to process it one column at once, using Map on the std::vector. So only one loop over the elements of the std::list. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c++, height, eigen"
} |
Redirect after X seconds AngularJS
I already saw this thread but it uses `ui-router` and I'm only using the `$routeProvider` of AngularJS. The code in the thread is:
.controller('SeeYouSoonCtrl', ['$scope', '$state', '$timeout',
function($scope, $state, $timeout) {
$timeout(function() {
$state.go('AnotherState');
}, 3000);
}])
How can I use it with my `routeProvider` since I am not using `ui-router`? Thank you in advance. | You need to use `$location` service
$location.path('/anotherURL'); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "javascript, angularjs"
} |
Match multiple regular expressions from a single file using awk
I'm trying to parse a HTML file using shell scripting.
There are 4 different regular expressions that i need to catch: `name=` , `age=` , `class=` , `marks=`.
Using
grep "name=\|age=\|class=\|marks=" student.txt
I'm able to get the required lines, but along with these matching lines I also need to print the second line from each match which contains the score.
Referring to the question: Print Matching line and nth line from the matched line.
I modified the code to:
awk '/name=\|age=\|class=\|marks=/{nr[NR]; nr[NR+2]}; NR in nr' student.txt
But this does not seem to work. How do I search for multiple regular expressions in the same `awk` command? | Try with:
awk '/foo/||/bar/' Input.txt | stackexchange-unix | {
"answer_score": 9,
"question_score": 6,
"tags": "shell script, awk, regular expression"
} |
Can't run play app on os x lion
I created an alias like this `alias play=/Users/bobdylan/Documents/play/play`
After creating a new app and trying to run it with `play run` I keep getting this:
Debugger failed to attach: handshake failed - received >GET / HTTP/1.1< - excepted >JDWP-Handshake<
Debugger failed to attach: handshake failed - received >GET / HTTP/1.1< - excepted >JDWP-Handshake<
Any idea what could be wrong? | That shouldn't prevent your application from starting, only the debugger from being acceessible. It should also show an exception stacktrace which may help us to point the issue (if it's showing in your case please attach it).
To solve the issue, can you check:
1. Ports you are using for Play (maybe you have some other server blocking those ports)
2. The hostname of your computer (you may have localhost pointing somewhere in your host file or some configuration that makes Play fail) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "java, playframework"
} |
How does the structure key= min work in sorted method?
My problem is basically that both of this peaces of code work proparly, however, the second solution with **key = min** doesn't make sence to me. How does python go through this code? Why does it ignore sorting the letters and goes straight to sorting by digits? I can't understand the underlying logics of this code.
My code:
def order(sentence):
return ' '.join(sorted(sentence.split(), key=lambda s: int("".join(filter(str.isdigit, s)))))
print(order("is2 Thi1s T4est 3a"))
Second solution
def order(sentence):
return ' '.join(sorted(sentence.split(), key=min))
print(order("is2 Thi1s T4est 3a"))
The answer is correct in both cases:
Thi1s is2 3a T4est | This works because numbers come before letters in the Unicode encoding system, and given that sorted sorts lexicographically, the list will be sorted according to the smaller value in the table in each string. You can see this with:
s = "is2 Thi1s T4est 3a"
[min(i) for i in s.split()]
# ['2', '1', '4', '3']
* * *
You can check that indeed the Unicode value for the numbers are smaller by using `ord`, which will return the position in the table for each value:
s = "is2 Thi1s T4est 3a"
for i in s.split():
for j in i:
print(f'{j} -> {ord(j)}')
print()
i -> 105
s -> 115
2 -> 50
T -> 84
h -> 104
i -> 105
1 -> 49
s -> 115
T -> 84
4 -> 52
e -> 101
s -> 115
t -> 116
3 -> 51
a -> 97 | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "python, sorting, key"
} |
Applescript, show all files with tag
I am trying to build an applescript which will open show all files tagged with the school class I am currently in, based on current time. For instance, if the time is 10 AM on a Tuesday, it will show all my files tagged with Chemistry. Now, I have made the AppleScript to get the correct name of the class.
Now I need to tell Finder to open the files with the correct tags. How would I do this?
Basicaly, something like this:
set tagged to "Tag:Chemistry"
tell application "Finder"
reveal tagged
activate
end tell
Ofcourse, tagged here would be dynamically assigned. | You can use the **GUI Scripting** to click on left-pane in the finder window.
Because this script use `GUI Scripting` to control the user-interface, you must add the applet to an approval list, displayed in the Security & Privacy system preference pane.
set tagName to "Chemistry" -- the full tag's name
my showFinderWindow(tagName)
on showFinderWindow(thisTag)
tell application "Finder" to if not (exists Finder window 1) then make new Finder window
tell application "System Events"
tell process "Finder"
repeat with i in windows
tell outline 1 of scroll area 1 of splitter group 1 of i to if exists then
tell (first row whose value of its static text 1 is thisTag) to if exists then perform action "AXOpen" of static text 1
exit repeat
end if
end repeat
end tell
end tell
end showFinderWindow | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "applescript"
} |
Import .txt file to matlab, anything works
I have a problem importing data to matlab workspace. My file is a .txt file with 8 columns and a lot of rows (I cannot count them). The first 5 columns are numbers, but the 3 last are paths (letters), each path indicates the position of an image that correspond to the first 5 datas. I want to save the whole file into a matrix, I have tried load (but it doesn't work when I mixed characters), textscan (but it gives me just a row vector), impordata (but only write the first column data), fscan.... I think I have tried every command, and still doesn't work.
I want to specify that the text I have is another variable I want to save to work with it in a future, is not a headline.
Can any one help me?
Thanks in advance. | You should store your data into a cell, not a matrix, textscan should work without any problems
fileID = fopen('file.txt');
C = textscan(fileID,'%f %f %f %f %f %s %s %s');
fclose(fileID);
If you have a particular delimiter between your column you can specify this delimiter:
C = textscan(fileID,'%f %f %f %f %f %s %s %s','Delimiter','|') | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "matlab"
} |
How can I read just articles (with included images) online?
I would like to read just the contents of an article (text plus images) on a website (any modern news/blog website) spanned over the entire width of my browser window.
I have installed browser addons such as `Clearly` for Google Chrome or `Reader` for Mozilla Firefox but I'm unsatisfied with their results (article does not span the entire width, loading is slow, images not always showing up or displayed too small or wrongly positioned).
Are there any other/online ways to achieve similar result? | Try Google Mobilizer
As the Google Mobilizer service works by taking a querystring as an input, it can be adapted to work like a search provider in Chrome & Opera, to simplify its use. The string to use for configuring it is - **`
If you assign a letter like M to this app, you can type M in the Chrome address bar/omnibox & then the type the URL you would like to see via Google Mobilizer.
Change the value for **noimg** in the querystring to 0 to view images in the article. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "browser, accessibility"
} |
UITextView scroll
This is a real n00b question but i am very new at this and have been looking for an answer and also read the reference as i am trying to work with UITextView.
I want to add quite a lot of text into a view and i want it to be scrollable.
I have created the UITextView in IB, added text via "self.myTextView.text = @"...", which works. However i am not able to scroll down and see all text. I see only the amount of text that fits in the view i have.
I wonder if someone nice could help me and give an example/hint how to get the UITextView scrollable.
Thank you. | If it's static text and you'd like some formatting, I recommend using a UIWebView. You can give it a variety of files types, and edit the file easily. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "objective c, uitextview"
} |
How to test if a variable is primitive in PHP
What would be the best (most efficient, easiest to understand in the code, etc) way to check whether a variable is of primitive type in PHP?
Should I go the "positive" (e.g. `is_string() || is_int()...)` way, or vice versa `!is_array() && __is_object()..` or maybe some even fancier way? | You are looking for is_scalar(). | stackexchange-stackoverflow | {
"answer_score": 28,
"question_score": 13,
"tags": "php, primitive types"
} |
SuperClass and SonClass
I have a SuperClass Employee and a Subclass Manager extends Employee with tribute Name.
Now I want to use instanceof while I go over an array of Employee
Example:
while (employee[i]!=null){
if (employee[i] instanceof Manager)
here is my problem"!!
I want to sysout a Manager atribute "Name":
sysout("Name: "+employee[i].name)
but it says create name in Employee.. why if it extends employee and already used instanceof...I tried Casting like this (Manager)employee[i].name but it doesn't do anything. | The cast needs to be applied to the value on which you are accessing the field.
((Manager)employee[i]).name
You were using it like
(Manager)employee[i].name
which attempted to apply the cast to the value returned by accessing the field `name`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -5,
"tags": "java"
} |
cmd.ExecuteNonQuery() is not allowed
In my webmethod, i am updating the database. but while debugging the cursor escapes on cmd.ExecuteNonQuery(). my code is,
If tbl = "All" Then
cmd = New SqlCommand("update setbool set pos_val='False',valid_rp='False',Pos_save='False'", conn)
cmd.ExecuteNonQuery()
Return Nothing
Else
cmd = New SqlCommand("update setbool set " & tbl & "='True'", conn)
cmd.ExecuteNonQuery()
Return Nothing
End If
Any suggestion? | I found my own solution.
instead of
cmd = New SqlCommand("update setbool set pos_val='False',valid_rp='False',Pos_save='False'", conn)
cmd.ExecuteNonQuery()
Return Nothing
i changed
Using cmd1 As New SqlCommand("update setbool set pos_val='False',valid_rp='False',Pos_save='False'")
cmd1.CommandType = CommandType.Text
cmd1.Connection = conn
conn.Open()
cmd1.ExecuteNonQuery()
conn.Close()
End Using
Return Nothing | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "vb.net, webmethod, executenonquery"
} |
Finding the absolute minimum of a piecewise function on an interval.
I am doing some review questions for an upcoming final and stumbled upon the following:
> $ f(x) = \left\\{ \begin{array}{lr} 1 \ : if \ x = 0\\\ x^\sqrt{x} \ : if \ 0 < x \le 2 \end{array} \right. $
>
> Find the absolute minimum value of $f(x)$ on $[0,2]$
>
> (A) $e^{-1/e}$
>
> (B) $e^{-2/e}$
>
> (C) $e^{-1/2e}$
>
> (D) $e^{-2\sqrt{e}}$
>
> (E) $e^{-\sqrt{e}}$
So far, I know I need to use Rolle's Therom to try to find a value c in $[0,2]$ that is the absolute minimum but I don't know how to utilize it since this is a piecewise function. Any hints or help is greatly appreciated! Cheers! | Find the critical numbers of $f(x)$ in $0<x<2$. Compare the value of $f$ there with the value of $f$ at the endpoints, $x=0$ and $x=2$. The smallest of these numbers is the absolute min. This is due to the Extreme Value Theorem for continuous functions on a closed interval.
The critical number is at $x=1/e^2$ and $f(0)=1$, $f(2)=2^\sqrt{2}\approx 2.67$, $f(1/e^2)=e^{-2/e}\approx 0.48$. Thus, the absolute min is $e^{-2/e}$.
Here's a graph:
!enter image description here | stackexchange-math | {
"answer_score": 0,
"question_score": 1,
"tags": "algebra precalculus"
} |
How is there no murder trial in Southpaw?
In the movie Southpaw, how is there no trial for the murder of Maureen? Given the presence of only a handful of people in the event and the bullet fragment/shell (and possible surveillance cameras), it would have been easy to investigate the murder and locate the killer. Why is the murder simply ignored, given it was a high profile killing? | In this deleted scene Billy Hope (Jake Gyllenhaal) talks to two police officers who are assigned to the case, they outline a few problems with evidence, meaning that they cannot find out who the killer is.
* As of the time they are working on the case (two weeks have passed) there is no video evidence of the shooting on cell phones or CCTV cameras
* There have been no eye witnesses to the shooting, including Billy himself who didn't see it, although claims Miguel Escobar's brother Hector was the one who did it.
* They say "No one is talking" and that they "Don't want to be involved"
For a trial to take place, the officers would have to gather evidence on one of the individuals and charge them. Because they have none, a trial would be out of the question. This explains why Miguel Escobar and his companions do not face any repercussions. | stackexchange-movies | {
"answer_score": 5,
"question_score": 7,
"tags": "plot explanation, southpaw"
} |
Feed me: set entrytype dynamically
Can someone confirm that when importing entries with Feed-Me, the entrytype can NOT be set dynamically based on a field of the feed? | i don't think it is possible via GUI but you can do this via feed me events and a simple plugin.
because entrytype's fieldlayout and field mappings are different, in my solution, you should edit feed and update fieldmapping for each entry type, change the if condition of the code and run the feed again.
Event::on(Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function (FeedProcessEvent $event) {
$entryTypeId=$event->feedData['entrytype'];
if ($entryTypeId==1){
$event->element->typeId=1;
}
//maybe, if field mapping for entrytype1 and entrytype2 are same
elseif ($entryTypeId==2){
$event->element->typeId=2;
}
else {
//skip saving element for other entry types because they have different field mapping.
$event->isValid=false;
}
});
* about event->isValid | stackexchange-craftcms | {
"answer_score": 1,
"question_score": 1,
"tags": "craft3, plugin feedme, import"
} |
How to clear Exchange mail queues using PowerShell
I needed to clear a bunch of messages out of the mail queue this morning, and thought it would be super nice to be able to query the queue(s) using Powershell. Any scripts out there?
Note: this is for SBS 2003, so no Exchange 2007 - but as an upgrade is near, a 2007-only answer will be just fine... | I don't know of a PowerShell script that will do it for Exchange 2003 (there may be one, just can't find it), with Exchange 2007 its very easy.
There is a script here that will clear the entire queue for you, using vbscript. Are you looking to do that, or to remove particular emails? | stackexchange-serverfault | {
"answer_score": 2,
"question_score": 1,
"tags": "exchange, exchange 2003, powershell"
} |
Cube root of $-2+i$
**Edit:**
My question comes from finding the solutions of this equation using Cardano's method(because our teacher said :D ):
$$x^3-6x+4=0$$
And finally I got:
$$x=(\sqrt[3]{2})\sqrt[3]{-2+\sqrt{-1}}+(\sqrt[3]2)\sqrt[3]{-2-\sqrt{-1}}$$
**I want to denest and find the cube roots of this two radicals.**
According to this links answers:
First link
Second link
Third link
I tried to find this using **norm** (actually for dinest):
$$\sqrt[3]{-2+i}$$
So the **problem's norm is $5$** and I must find a root with **norm = $\sqrt[3]{5}$** .
And I found this :
$$(\sqrt{\sqrt[3]{5}-1}+i)$$
But:
$$(\sqrt{\sqrt[3]{5}-1}+i)^3\neq {-2+i}$$
Anybody can tell me whats my wrong?
And how to correct that? | Applying Cardano's method to $x^3- 6x+4 =0$ I get:
set $x=u+v$, then
$$x^3 = u^3 + v^3 +3uv(u+v)$$
$$-6x = -6(u+v)$$
so in order to cancel the last terms we set $uv=2$.
So the equation transforms into
$$u^3 + v^3 + 4 = 0; uv=2 $$
Using $v = \frac{2}{u}$ we get
$$u^3 + \frac{8}{u^3} + 4 =0$$
and we set $t = u^3$ and multiply both sides by $t$ to get
$$t^2 + 4t + 8 = 0 \to (t+2)^2 + 4 =0$$
And so $$t+2 = 2i \to t = 2i-2 \text{ or } t+2 = -2i \to t = -2i -2$$
This doesn't seem to lead to your solution?
**Added** $x=2$ is a solution (the only rational roots are integer divisors of $4$), and the equation factorises to $$(x-2)(x^2 +2x-2)=0$$ | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "polynomials, problem solving, cubics, nested radicals"
} |
MYSQL query using OR and AND on same sentence
I need help writing a query that will validate a first expression and than, if its true, will validate the following expression. Something like:
SELECT
name
FROM
names
WHERE
(tag_id = 1 OR tag_id = 2) AND (tag_id = 3 OR tag_id = 4)
Tried to use subqueries with if's and exists, but no success.
Any help? Thanks, | Reading between the lines a bit, perhaps something like this:
SELECT n1.name
FROM names n1
INNER JOIN names n2
ON n1.name = n2.name
WHERE (n1.tag_id = 1 OR n1.tag_id = 2)
AND (n2.tag_id = 3 OR n2.tag_id = 4) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "mysql, subquery, case, exists"
} |
SQLCommand ExecuteNonQuery Maximum CommandText Length?
I've searched around the internet and everything seems to be about individual fields or doing one insert. I have a migration tool that is migrating from an old legacy database (superbase) to our SQL server DB (2008). Currently I'm reading 20,000 records from the old database and generating one big `SQLCommand.CommandText` string with 20,000 insert statements delimited by a semicolon. **This works fine**. But can I do 25k? 30k? I tried not having any limit at all, but when I tried to run `ExecuteNonQuery` with a `CommandText` containing over 4 million INSERT statements, it said something about being too long. I don't recall the exact error message, sorry. I can't find any documentation on the exact limitations. It's important for me to find out because the more inserts I can fire at a time, the faster the whole process. Any advice / links / documentation would be greatly appreciated, thanks! | It depends on the SQL Server version.
<
For SQL Server 2012, the batch size or SQL Statement (String) = 65,536 * Network packet size.
Network Packet Size is the size of the tabular data stream (TDS) packets used to communicate between applications and the relational Database Engine. The default packet size is 4 KB, and is controlled by the network packet size configuration option.
In short, 64K x 4K = 256 MB. Again, this assumes you are using default packet sizes. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 9,
"tags": "c#, sql, sql server, database, sqlcommand"
} |
I can't access the admin UI in KeystoneJS
I just installed the Keystone yeoman generator and ran the yo keystone command. I went through and entered the email, password, and all the other fields in the set up.
I can run the Keystone App just fine, but when I go to sign in to the admin UI it won't accept my credentials. On the welcome page it tells me that email and password to sign in with so I know I'm using the correct credentials. I checked the User.js model and everything looked fine. I'm new to Keystone and have no idea what the problem could be. I looked through the Keystone docs and for answers elsewhere but have found nothing. | I confirmed this to be a bug in Keystone. I submitted a pull request (#1326) to address this issue just a few minutes ago.
~~I will update my answer as soon as it's merged.~~ It was just merged! :-) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "authentication, keystonejs"
} |
YouTube API - Option for "Authorized redirect URIs" not showing on credentials page
I am creating an internal project application with the YouTube Data v3 API. Following the tutorial given in this post, I am trying to add "< as a link under "Authorized redirect URIs" when editing the client_id and client_secret entry.
When I go into the console and edit the credentials, I cannot find this option anywhere. See the screenshot below to see what I see when I edit the Oauth 2.0 Client IDs.
Does anyone have an idea about why I cannot see this option or where I have to go in order to find it?
Screenshot of what I see | I found out why. It's because I had set my credentials to "Other (Windows)". When I created new credentials with "Web server" selected instead, the option started showing. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "youtube api, youtube data api"
} |
Accessing the name a function generated in a while loop. (Python)
Below is a superhero name generator. I want to be able to add the name chosen to where it says go out and save the world. does anyone know how I can do this?
def superhero_name_generator():
print("Welcome to the superhero name generator:\nTo choose your name follow the instructions below")
first_part = input("Please enter the name of the city you grew up in. ")
second_part = input("Please enter the name of your pet or your favorite mythical creature (Ie. Dragon). ")
superhero_name = first_part + second_part
print("your superhero name is {}".format(superhero_name))
end = '-'
while end != 0:
superhero_name_generator()
print("If you want to generate another name please press 1 to quit press 0")
end = int(input())
else:
print("Go out and save the world") | You'll have to return the value from the function. I also simplified your loop a little bit by making it an infinite one we `break` out of.
def superhero_name_generator():
print("Welcome to the superhero name generator:\nTo choose your name follow the instructions below")
first_part = input("Please enter the name of the city you grew up in. ")
second_part = input("Please enter the name of your pet or your favorite mythical creature (Ie. Dragon). ")
superhero_name = first_part + second_part
print("your superhero name is {}".format(superhero_name))
return superhero_name
while True:
name = superhero_name_generator()
print("If you want to generate another name please press 1 to quit press 0")
if int(input()) == 0:
break
print("Go out and save the world,", name) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "python, function, while loop"
} |
Add padding/margin to ng-options - Angularjs
I have this code :
<select style="font-size:0.9em;" ng-model="course" ng-options="c.Id as c.Name for c in model.courses">
<option value="">--select--</option>
I need to add padding/margin for each of the options.
Is there a straight way of doing this ? | You can't do this because the select list is rendered by browser/os.
But you can use some third party plugin like Select2 (angularjs directive) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "css, angularjs"
} |
What does "on the fly" mean in the streaming technology field?
"on the fly" appears in many articles on streaming technology, and some tutorials about streaming engine like Wowza and Unified Streaming. But I don't understand the word, what does it exactly mean? | "On the fly" related to streaming usually refers to processing of live streams and delivery of modified result with low latency (almost in real time).
This can include encoding with different codecs, bitrate (transcoding), packetising streams (for delivery as HLS, MPEG-DASH and similar formats available over HTTP). | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "video streaming"
} |
Rails: How to cache a field of a has_many relationship in an array
Here is what I'm doing right now:
m = Merchant.find(1)
ebay_item_id_array = []
active_items = m.active_items
active_items.each { |item|
# Fill the array containing what items are already in the DB based on ebay item id
ebay_item_id_array.push(item.external_product_id)
}
The goal here is so that when I ping eBay's API for the latest products, I can check if I already have that ebay item id in my database. Thus, it would be skipped. The problem is that when the DB gets big, this operation above is not very efficient. How can I cache the external_product_field into an array that I can bring up without looping across all my active records? | You should consider polling the eBay API for products added after the last update of your database that would be less computationally expensive. You can do this by using itemFilters
See the documentation for more info: < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, arrays, caching"
} |
How to implement a stack exchange style voting for mobile?
I have a client who wants me to improve the usability of their current iOS app.. they have a voting mechanism that looks like this:
!enter image description here
i figured that this was bad usability b/c it didn't add up the votes to a final number (like how it's done on stack exchange).. and so I created a design that's very similar to the stack exchange voting style:
!enter image description here
he said that he hated my design! he said he didn't like my idea of a vote up vote down.. he couldn't think of another way though..
so any suggestions here folks? any sample implementations of this idea on some famous android or iphone apps? | this is one of my attempts so far.. basically the item that's voted for comes in the center.. i guess this has better affordance than the previous one.
!enter image description here
**update:** I convinced my client to go with this one.. I will have to animate into the screen though. | stackexchange-ux | {
"answer_score": 0,
"question_score": 0,
"tags": "gui design"
} |
NODE.JS - Cannot find module '@hapi/boom'
I've been asked to create a super simple chatbot. I'm not a developer and I've never used node.js before. I found this simple demo on GitHub. I first ran `npm install rcs-maap-bot` as the main page says, pasted the code, ran it and I get this error. Online research said to move its missing `index.js` so I moved copied it a directory back and now I get this error: <
I wasn't able to resolve it.
Does anyone know what's going on? Huge thanks ahead. | You need `Maap`, provided that you have it on node_modules, replacing
const Maap = require('../')
wit this line should work:
const Maap = require('rcs-maap-bot') | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, java, node.js, nodejs server"
} |
SLD filter for GetMap, which ignores records in a layer of GeoServer 2.20.4
This below section in SLD worked ok in 2.10 Geoserver, where it did not include any records from that layer.
<Filter>
<Or />
</Filter>
However, This does not work in GetMap of GeoServer 2.20. It shows the "Rendering process failed" error.
Does anyone know what to pass in this filter node so that, the layer features are ignored in the final print? I have tried an empty filter node, does not work and loads all features from the layer.
<Filter>
</Filter> | I'm not sure I've ever tried to exclude a whole layer but I would expect something like:
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Literal>1</ogc:Literal>
<ogc:Literal>0</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
would work. | stackexchange-gis | {
"answer_score": 1,
"question_score": 0,
"tags": "geoserver, sld, filter, getmap"
} |
How to print with page numbers in @media print?
I have been seeking this answer for a while now and wasn't able to find anything that could work properly. I had these two ideas that kind of look like weren't working at all for quite sometime:
1. A method using `@page` with `bottom-right`. Link
2. A method using fixed footer. (Said to work in Firefox) Link
Is there any other way? | After a while doing some research I think I got something cooking here which still needs some testing in different browsers, and maybe some perfectioning. For now, I've tested and seems to be working fine in Chrome.
Basically, blending in a little of both techniques I was able to create this idea that replicates (on load) a `h3` for each `p` in the work (just so it runs enough for each page). They have `position: absolute` and each one subtracts `100vh` so they go to the bottom of the other page.
Here it is: JSFiddle - Without Page Total
## EDIT
Here's a new version capable of showing the **page total** : JSFiddle - With Page Total
Hope this has some use! | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "jquery, html, css, printing, pagination"
} |
sailspostgresql Error while using sails lift command?
While running $ sails lift command , I am getting this error.
info: Starting app...
error: Trying to use unknown adapter, "sailspostgresql", in model `adminintro`.
error: Are you sure that adapter is installed in this Sails app?
error: If you wrote a custom adapter with identity="sailspostgresql", it should be in this app's adapters directory.
error: Otherwise, if you're trying to use an adapter named `sailspostgresql`, please run `npm install sails-sails[email protected]`
Please help me out guys ... | Got the answer ... It was unicode mistake . I have copy n pasted the code for local.js from one of my coworker's pdf file. So when I pasted that code in my local.js "-" was replaced with some unicode < .. and that was causing this issue.. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "postgresql, sails.js, sails postgresql"
} |
How to extract a certain paragraph from a file use regex in python?
My question is to extract a certain paragraph (e.g., usually a middle paragraph) from a file through the regex in Python.
An example file is as follows:
poem = """The time will come
when, with elation,
you will greet yourself arriving
at your own door, in your own mirror,
and each will smile at the other's welcome,
and say, sit here. Eat.
You will love again the stranger who was your self.
Give wine. Give bread. Give back your heart
to itself, to the stranger who has loved you
all your life, whom you ignored
for another, who knows you by heart.
Take down the love letters from the bookshelf,
the photographs, the desperate notes,
peel your own image from the mirror.
Sit. Feast on your life."""
How to extract the second paragraph (which means "all you life ... the bookshelf,") of this poem use regex in python? | Use group capturing and try this out:
import re
pattern=r'^(all.*bookshelf[,\s])'
second=re.search(pattern,poem,re.MULTILINE | re.DOTALL)
print(second.group(0)) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, regex, extract, paragraph"
} |
Which are the prevention activities that QA executes?
Most of my tester friends say that one important part of quality assurance position is "prevention". I´ve read a lot in the university about costs of quality and cost of poor quality and prevention but in my daily work I´ve never seen this activity performed by QA teams. I mean, there are a lot of tools and practices for development which help us to avoid some kind of problems as code reviews, static and dynamic code analysis, unit testing, and others but which are the most important "prevention" activities that QA guys should execute? | "More than the act of testing, the act of designing tests is one of the best bug preventers known. The thinking that must be done to create a useful test can discover and eliminate bugs before they are coded..." - Boris Beizer, Software Testing Techniques 2nd ed.
D. Gelperin and B. Hetzel also first suggested the idea of "Test, then code" in 1987.
The concept of TDD is the reintroduction of these basic tenets that are intended to prevent bugs from getting into code. I would say that ATDD is a bug preventative approach which some testers participate in.
In my team, we also perform code reviews prior to check-ins which are one bug prevention activity.
Some other things that testers (and others on the team) can do to help prevent bugs might include:
* Specification reviews
* Dev design reviews
* Scenario planning
* Design/architectural modeling | stackexchange-sqa | {
"answer_score": 6,
"question_score": 4,
"tags": "techniques"
} |
Plot dash lines on plot (specifying coordinates)
I'd like to get the plot in the following figure (without grid):
};
\end{axis}
\end{tikzpicture}
Thank you very much for your time. | You mean something like the following?
% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.11,
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=8,
ymin=0, ymax=8,
xlabel={$x$},
ylabel={$y$},
axis lines=center,
xtick={1,2},
ytick={1,2},
]
\addplot [color=red,mark=*] coordinates {(2,2)};
\draw [dashed,help lines] (0,2) -| (2,0);
\end{axis}
\end{tikzpicture}
\end{document}

* Highest rated episodes (English)
They now link to a similar search from the **TV** menu. | stackexchange-webapps | {
"answer_score": 3,
"question_score": 5,
"tags": "imdb"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.