INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
style issues in display in IE8 vs IE9
I have a lot of issues right now for display in IE8, the pages are appropriately styled in IE9, I am attaching a sample screenshot of the page difference. I have used a css-html based template skin called theme forest constellation admin template and I am not sure of its support for IE8
anyways I am using all kinds of styles some of which are ul, li elements, margins, auto width, display: block, inline, float: left... etc
I want to know how can I start fixing the display in IE8, do I have to fix each style manually or is there a list of know differences I can refer to between IE8 & 9 and then see if I have used any of those to fix. The below diagram shows the difference, issues are
1) the grey bar below the date input
2) the chart div boxes in IE8 are shifted down to and little part of it is outside the box
!display difference between IE8 and IE9
Thanks in Advance | My suggestion would be to address IE8 compatibility issues as you discover them and whenever possible use libraries and frameworks that gauruntee IE8 support if this is a priority.
As far as general references for IE CSS/HTML bugs: < And for a list of CSS compatibility by browser: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "internet explorer 8, styles"
} |
Custom links in Wordpress navigation
I have a Wordpress site utilizing Bootstrap 3 framework for the navigation. I have the Wordpress enabled navigation contain all my links.
HTML
<div class="collapse navbar-collapse navbar-right">
<?php /* Primary navigation */
wp_nav_menu( array(
'menu' => 'top_menu',
'depth' => 2,
'container' => false,
'menu_class' => 'nav navbar-nav',
//Process nav menu using our custom nav walker
'walker' => new wp_bootstrap_navwalker())
);
?>
I want to change the css on one specific button in the navigation. I think this has to be done through the admin side. Possibly through the Title Attribute' tab, not sure how to do it | On the Menus page in the admin area, at the top right of the screen click "Screen Options" and check the box called "CSS Classes".
You can now go to your menu item and give it a class, which you can now target using CSS. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery, html, css, wordpress, twitter bootstrap"
} |
Discrete-time Fourier transform of $a^{|n|} u[n]$
I have a problem calculating the DTFT of this pair: . The documentation on the site is fairly decent <
Also, I faced several problems while trying to build a WAR and get it deploy successfully on tomcat. I found this discussion on the forum to be extremely useful. The OP on this even posted a working POM
< | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 2,
"tags": "java, maven 2, gwt"
} |
Is there a way to do this? - Batch file
I am trying to make a game in batch but..
:start
set q1=b
set q2=c
set number=1
set q%number%=c
if q%number%==c goto ok
:nope
echo nope
pause
goto start
:ok
echo ok
pause
goto start
output -->
C:\Users\Thomas\Desktop\snake>set q1=b
C:\Users\Thomas\Desktop\snake>set q2=c
C:\Users\Thomas\Desktop\snake>set number=1
C:\Users\Thomas\Desktop\snake>set q1=c
C:\Users\Thomas\Desktop\snake>if q1 == c goto ok
C:\Users\Thomas\Desktop\snake>echo nope
nope
C:\Users\Thomas\Desktop\snake>pause
Press any key to continue . . .
I am trying to have the var %q1%==c and not q1==c on this way.
if anyone understands me,
THNX | Maybe you need something like this:
@echo off
set number=1
set q1=Hello
Setlocal EnableDelayedExpansion
echo !q%number%!
if !q%number%!==Hello echo World | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "batch file"
} |
Finding/Calculating Thermal Conductivity of Magnesite
Our research group is having a very difficult time locating anything about the thermal conductivity of $\ce{MgCO3}$. It is a pretty commonly mineral, so we were pretty surprised by this. Is any way to derive thermal conductivity from other properties of magnesium carbonate? (Magnesite) | In the dissertation of K. Kratz (2006) the following values of thermal diffusivity along the crystallographic axes of magnesite are listed:
$D_{[001]} = 6.55 ~\mathrm{mm^2\,s^{-1}}$,
$D_{[100]} = 2.38 ~\mathrm{mm^2\,s^{-1}}$,
$D_{[010]} = 2.38 ~\mathrm{mm^2\,s^{-1}}$.
Ch. Clauser and E. Huenges, Thermal Conductivity of Rocks and Minerals lists the following values for the thermal conductivity of magnesite in the temperature range from 25-100°C:
$\lambda_{\perp} = 7.32 \pm 0.57 ~\mathrm{W m^{-1} K^{-1}}$
$\lambda_{\mid} = 7.86 \pm 0.17 ~\mathrm{W m^{-1} K^{-1}}$ | stackexchange-chemistry | {
"answer_score": 1,
"question_score": 1,
"tags": "thermodynamics, minerals"
} |
rails not starting with the right version
This must be a simple question, but I could not find the answer by browsing this forum.
When I check rails version, it shows version 3.2.8
[email protected] [~/rails_apps]# rails -v
Rails 3.2.8
[email protected] [~/rails_apps]#
But when I start the server, it runs version 2.3.11
[email protected] [~/rails_apps/myapp]# script/server -p12011
=> Booting Mongrel
=> Rails 2.3.11 application starting on
/home3/user/rails_apps/myapp/config/environment.rb:45: warning: already initialized constant RAILS_ENV
NOTE: SourceIndex.new(hash) is deprecated; From /usr/lib64/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/vendor_gem_source_index.rb:100:in `new'.
=> Call with -d to detach
=> Ctrl-C to shutdown server
What am I doing wrong? | If you application is a 2.x rails application, you need to complete some changes before upgrade to 3.x
You may have a look to railscast <
On the other hand, you may want to upgrade your ruby to 1.9 using rvm rails 3.x work better with ruby 1.9 | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, version"
} |
Let H and K be subgroups of a group G. Prove that gH ∩gK is a coset of H ∩K in G.
Let H and K be subgroups of a group G. Prove that gH ∩ gK is a coset of H ∩ K in G.
so I believe you start with:
NTW: gH and gK $\subset$ of g(H∩K)
if x$\in$ gH and gK, then x=gh and x=gk
since gh=gk
$\Rightarrow$ h=k then h$\epsilon$ H and K
x=gn $\in$ g (H $\cap$ K)
next NTS g(H $\cap$ K) $\subset$ gH and gK
x $\in$ g(H $\cap$ K), then x=gw for some w $\epsilon$ (H $\cap$ K)
then x = gw $\in$ gH
x = gw $\in$ gK
x $\in$ gH and gK
am I doing this right?? | Hint: If $\phi: X \rightarrow Y$ is an injective function between sets, then $\phi(A \cap B) = \phi(A) \cap \phi(B)$ for any subsets $A, B \subseteq X$. | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "abstract algebra"
} |
Multivariable Limit with exponent
I need help solving this multivariable limit. I tried using $x=r\cos\theta$ and $y=r\sin\theta$ but that gets me nowhere, can anyone help?
${\lim_{(x,y)\to(0,0)}(1+x^2y^2)^\frac{1}{x^2+y^2}}$ | With $x=\dfrac1s$ and $y=\dfrac1t$ $${\lim_{(x,y)\to(0,0)}(1+x^2y^2)^\frac{1}{x^2+y^2}}=\lim_{(s,t)\to(\infty,\infty)}\left(1+\frac{1}{(st)^2}\right)^{(st)^2\frac{1}{s^2+t^2}}=e^0=1$$ | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "calculus, limits"
} |
cs-cart admin user login always act as vendor profile Issue
I face one issue and not found any solution through cs-cart community That is - When I login to admin area from my admin URL like < and enter correct authentication infromation and click on login then I always act as Vendor not like admin it means that my after login screen is same as vendor screen and cant access any admin features.
After login my URL is same as admin URL but I act as vendor instead of admin. I double check my database user settings and all are correct also. My admin `user_type` is also 'A' and its enabled also.
I cant trace any issue from my server file side.
Is it is SSL issue?
Thanks for contribution | Please check if you have any vendor selected already, on top left, right side of the admin logo, you should have All vendors ;)
!enter image description here | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "cs cart"
} |
Razor and Javascript code together
I am newcomer in asp.net mvc. How can i write javascript code in razor?
@foreach (var player in ViewBag.Players)
{
<script>
[email protected];
</script>
} | Put the razor variable within single quote-
team.member='@player.Name'; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, razor"
} |
How do I make .remove() work consistently?
I am working on some Python homework and somehow the .remove() function does not work properly and I can't explain why.
Input:
['', '', 'Age,Gender,Weight (kg),Height (cm)', '28,Female,58,168', '33,Male,,188', '', '', '', '', '21, Male, 95, 198']
My code:
for l in first:
if str(l) == "":
first.remove(l)
print(first)
Output:
['Age,Gender,Weight (kg),Height (cm)', '28,Female,58,168', '33,Male,,188', '', '', '', '21, Male, 95, 198']
As you can see, the empty strings in the front get removed as intended but the ones later on don't. How do I properly clean the list by using "basic" Python syntax? | The best solution is by doing a list comprehension:
li = ['', '', 'Age,Gender,Weight (kg),Height (cm)', '28,Female,58,168', '33,Male,,188', '', '', '', '', '21, Male, 95, 198']
li = [s for s in li if s != ""]
print(li) # ['Age,Gender,Weight (kg),Height (cm)', '28,Female,58,168', '33,Male,,188', '21, Male, 95, 198']
As @ShadowRanger noted, you can also more simply write it this way:
li = [s for s in li if s]
since `""` evaluates to `False`. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -1,
"tags": "python, python 3.x, list"
} |
Default SIGINT in Node.js?
I tried searching the Node.js source code, but I could not find it. By default, where would I find the Node.js code that handles SIGINT (`Ctrl`+`C`) by default in the following example:
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello Http');
});
server.listen(5001); | Node's default SIGINT handler is in node.cc, but it doesn't do much. It calls signalExit, which does
uv_tty_reset_mode();
_exit(1);
You can add your own handler in node.js with
process.on('SIGINT', function () {
// handle
}); | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 0,
"tags": "node.js, sigint"
} |
How do I find out which command name is bound to a particular key sequence in VSCode and vice-versa?
Are there commands equivalent to Emacs' `C-h k` and `C-h w`?
If not, is there at least a big file containing **all** keybindings I can search through?
Edit: the "vice-versa" is trivial if you know the command name. Just type it in the command prompt and it shows the associated keybinding. I'm more interested in the former. | Open the keyboard shortcuts editor (cmd+k cmd+s), and you can search for keybindings to see what they're bound to. e.g. search `cmd+s` and "Save" will be returned.
You can also click the keybindings.json link on that page to see all the keybindings in json form. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "visual studio code"
} |
using elasticsearchoperations vs elasticsearchtemplate whats the difference?
I am trying to figure out why I have to set my bean name to `elasticsearchTemplate`. Without it, my application crashes. I have the code below to configure my Rest client. The issue is if I don't add the `elasticsearchTemplate` as the bean name, it fails and says it cannot find `elasticsearchTemplate`. Any idea on why it does this and also what is the difference of using `elasticsearchoperations` vs `elasticsearchtemplate`?
Using Spring-Data-Elasticsearch Version 3.2
Using Java High-Level Rest Client Version 6.8.0
Works
@Bean("elasticsearchtemplate")
public ElasticsearchOperations elasticsearchTemplate() throws Exception {
return new ElasticsearchTemplate(client());
}
Doesn't Work
public ElasticsearchOperations elasticsearchTemplate() throws Exception {
return new ElasticsearchTemplate(client());
} | Maybe because the startup configuration (application.properties) is missing the configuration related to elasticsearch. You need to define some elastic search properties in your `application.properties` file such as **cluster-nodes** , **cluster-names** which are used by ElasticsearchTemplate and ElasticsearchRepository to connect to the Elasticsearch engine. as follows | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, spring, elasticsearch, elasticsearch rest client"
} |
how to load javascript dynamically
I try to load some js files dynamically,for example:
function openInforWindow(){
//check if the InforWinow.js has been loaded or not
if(window.InforWindow){
//do the right thing
}
else {
loadJs('xxxxxx/InforWindow.js');
// do the right thing
//but here ,the infowindow is not definded yet.
}
}
function loadJs(filename){
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref)
}
How to make sure that the vars or functions in the js which is dynamically loaded can be add to the javascript execute environment so I can use them ? | adding a script element isn't a blocking operation, this means that your loadJs method returns immediately when your external script isn't even loaded (nor interpreted). You have to wait for it to load.
function openInforWindow(){
//check if the InforWinow.js has been loaded or not
if(window.InforWindow){
//do the right thing
}
else {
var loadHandler = function() {
//do stuff with inforWindow
};
loadJs('xxxxxx/InforWindow.js', loadHandler);
}
}
function loadJs(filename, handler){
var fileref=document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", "js");
fileref.onreadystatechange = function () {
if (this.readyState == 'complete')handler();
};
fileref.onload = handler;
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref);
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript"
} |
Stacking arrays in numpy
I have two arrays:
A = np.array([1, 2, 3])
B = np.array([2, 3, 4])
C = np.stack((A, B), axis=0)
print C.shape
(2, 3)
Shouldn't the shape be `(6,)` ? | Using the `np.stack()` function you can specify which `axis` would you like to be considered the index axis. So as you can see you will never get a shape of `6`, only `(2,3)` or `(3,2)` for this example depending on what axis you chose.
See below:
A = np.array([1, 2, 3])
B = np.array([2, 3, 4])
arrays = [A, B]
With this code:
print(np.stack(arrays, axis=0))
you get this output:
[[1 2 3]
[2 3 4]]
with this code:
print(np.stack(arrays, axis=1))
you get this output:
[[1 2]
[2 3]
[3 4]] | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "python, numpy, stack"
} |
MATLAB: how to reuse plot options?
I have the following plot:
patch('Vertices',rocket_point_cloud,'Faces',rocket_faces,...
'FaceColor','red','EdgeColor','none',...
'BackFaceLighting','reverselit',...
'SpecularStrength',1,'DiffuseStrength',1)
I would like to reuse the plot options, i.e. reuse:
'FaceColor','red','EdgeColor','none',...
'BackFaceLighting','reverselit',...
'SpecularStrength',1,'DiffuseStrength',1
Is it somehow possible to store the above in a variable, e.g. `my_options` and later on do:
patch('Vertices',other_cloud,'Faces',other_faces,my_options)
Thanks for your help! | Sure. Just define your options in a cell array,
my_options = {'FaceColor','red','EdgeColor','none',...
'BackFaceLighting','reverselit',...
'SpecularStrength',1,'DiffuseStrength',1};
and then expand that cell array into a comma-separated list via curly-brace indexing:
patch('Vertices', rocket_point_cloud, 'Faces', rocket_faces, my_options{:}) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "matlab, plot"
} |
What's causing "Unable to retrieve native address from ByteBuffer object"?
As a very novice Java programmer, I probably should not mess with that kind of things. Unfortunately, I'm using a library which have a method that accepts a `ByteBuffer` object and throws when I try to use it:
Exception in thread "main" java.lang.NullPointerException: Unable to retrieve native address from ByteBuffer object
Is it because I'm using a non-direct buffer?
edit: There's not a lot of my code there. The library I'm using is jNetPcap, and I'm trying to dump a packet to file. My code takes an existing packet, and extract a ByteBuffer out of it:
byte[] bytes = m_packet.getByteArray(0, m_packet.size());
ByteBuffer buffer = ByteBuffer.wrap(bytes);
Then it calls on of the dump methods of jNetPcap that takes a ByteBuffer. | Many JNI calls expect a direct ByteBuffer. Even the standard libraries in Oracle Java 6.0 expect this and if you provide them with a heap ByteBuffer they copy your data to/from a direct one for you. In your case, you have a byte[] which can be copied to a direct ByteBuffer. note: creating a direct ByteBuffer is expensive and you should cache/recycle them if you can.
// the true size is always a multiple of a page anyway.
static final ByteBuffer buffer = ByteBuffer.allocateDirect(4096);
// synchronize the buffer if you need to, or use a ThreadLocal buffer as a simple cache.
byte[] bytes = m_packet.getByteArray(0, m_packet.size());
buffer.clear();
buffer.put(bytes);
buffer.flip(); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "java, java native interface, bytebuffer"
} |
Computing the Initial Velocity of an orbiting body
I'm working on a simulation program that replicates the movement of planets around a large celestial body (the sun). This is a three dimensional simulation that uses vectors. At present, I'm struggling to work out how to calculate the correct initial velocity vector so that the planet will enter into a stable orbit around the sun.
!Diagram of problem
I've attempted to take the vector cross product of `v1` and `v0` but to no avail. I also attempted to calculate..
$T_0 = v_1 - v_0$
$T_1 = v_0 - v_1$
$NV = T_0 * T_1$
Where `NV` is the new velocity and `*` is the cross product function. This resulted in a _zero vector_ because $T_0$ is parallel to $T_1$ so I find myself somewhat stuck. Does anyone know how to compute the correct vector? | The planet will follow an elliptical path and as an ellipse is a 2D figure it can only be traced to a plane and from two points infinite planes can pass, so you need to decide first which plane you want which is the missing information, because of which you are not able to do so. If finally you form a plane $\vec r.\vec N=p$ then the direction of the velocity vector of the planet is given by $\pm\vec N \times(\vec v_1-\vec v_0)$ the sign depending upon in which sense you want your planet to move clockwise or anti clockwise. On a paralle note the magnitude of velocity should be: $$\frac{GMm}{|\vec v_1-\vec v_0|^2}=\frac{m|\vec v|^2}{|\vec v_1-\vec v_0|}\implies |\vec v|=\sqrt{\frac{GM}{|\vec v_1-\vec v_0|}}$$ where $G$ is the universal gravitation constant and M and m the mass of sun and the planet respectively.You must play with values so that it looks very real Great help here | stackexchange-physics | {
"answer_score": 1,
"question_score": 1,
"tags": "homework and exercises, kinematics, vectors, simulations"
} |
Mysql Triggers Insert and Delete in one?
I need to create an insert and delete trigger, both will do the same thing.
Can I create this in one trigger?
Or do I need two separate ones?
I've had a look around and all seem to have one for delete and another for insert. | MySql does not allow for multiple events on the same trigger.
One option is to put your code in a procedure, and have each trigger call the same procedure - pass as much info of the old/new row to the proc as required. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "sql, mysql, triggers"
} |
Python matching dashes using Regular Expressions
I am currently new to Regular Expressions and would appreciate if someone can guide me through this.
import re
some = "I cannot take this B01234-56-K-9870 to the house of cards"
I have the above string and trying to extract the string with dashes (B01234-56-K-9870) using python regular expression. I have following code so far:
regex = r'\w+-\w+-\w+-\w+'
match = re.search(regex, some)
print(match.group()) #returns B01234-56-K-9870
Is there any simpler way to extract the dash pattern using regular expression? For now, I do not care about the order or anything. I just wanted it to extract string with dashes. | Try the following regex (as shortened by The fourth bird),
\w+-\S+
Original regex: `(?=\w+-)\S+`
* * *
## Explanation:
* `\w+-` matches 1 or more words followed by a `-`
* `\S+` matches non-space characters
Regex demo! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, regex"
} |
Antimatter: weak and strong forces
Antimatter is known to have equal mass to matter and opposite charge sign. Positron has the same mass as electron and opposite sign of charge, anti-proton has the same mass as proton and opposite sign of charge.
However, in other interactions is matter and antimatter equal? In weak and strong interactions. | An anti-particle is a particle with all quantum numbers reversed. This includes electric, weak, and strong charges (if the particle has them), but also others like the lepton number, spin, and more. The only particle properties that are not reversed are energy and momentum. So when a particle and anti-particle meet and anniholate, all quantum numbers zero out, but the total energy and momentum conserve (as two parts of the 4-momentum). This way all conservation laws are obeyed. While charges and quantum numbers can be positive or negative, energy is always positive for both a particle and its anti-particle. | stackexchange-physics | {
"answer_score": 1,
"question_score": 3,
"tags": "antimatter, weak interaction, strong force"
} |
Displaying Images from a folder in PHP
I am currently creating an e-commerce website where I retrieve the vehicle details from the database and search for its image in a folder. I used the code below for searching the folder for the image, but it only show the name of the JPG file and not the image of it. Could anyone help to to determine how I could display the image of the vehicle
$imageName=$_POST['car'];
if ($handle = opendir('Images/$imageName')) {
$dir_array = array();
while (false !== ($file = readdir($handle))) {
if($file!="." && $file!=".."){
$dir_array[] = $file;
}
}
echo $dir_array[rand(0,count($dir_array)-1)];
closedir($handle);
} | You have to put html tags around the result. Try:
`echo "<img src='PATH_TO_IMAGE/".$dir_array[rand(0,count($dir_array)-1)]."'>";`
where PATH_TO_IMAGE is the relative/absolute url address to your images folder
Ex
`echo "<img src='/images/".$dir_array[rand(0,count($dir_array)-1)]."'>";` | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "php, image, directory"
} |
How to make eclipse not auto-indent a block of code
I like Eclipse's auto-indent function, but sometimes I've got some indentation I don't want it to correct, like
audioBuffer1[j] = (short) (VOLUME_REDUCER * ( inputBuffer[i]
+ ALPHA * inputBuffer[i - echo1a]
+ ALPHA * inputBuffer[i + echo1a]
- ALPHA * inputBuffer[i - echo1b]
- ALPHA * inputBuffer[i + echo1b]
));
which gets corrected to something horrible. Is there a way of making the auto-indent function skip over some bits of code, using an `@annotation` or something? | You can put // at the end of the lines you don't want it to wrap.
audioBuffer1[j] = (short) (VOLUME_REDUCER * ( inputBuffer[i] //
+ ALPHA * inputBuffer[i - echo1a] //
+ ALPHA * inputBuffer[i + echo1a] //
- ALPHA * inputBuffer[i - echo1b] //
- ALPHA * inputBuffer[i + echo1b] //
)); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "eclipse, indentation, auto indent"
} |
Get a sharable link in python for drive files
I am trying to get a sharable link so that a sign in is not required when downloading a google drive file. I can get this link from google drive UI but I want to get it from my python code. Can anyone please help me | Your question is a little too broad, therefore my answer will help you in a general way. Using the Try this API in the Files: get endpoint and specifying in the **_fields_** request parameter `webViewLink` you will obtain a link, which you can use, but noticed this will only work if the user, who is requesting the file, has already at minimum read permissions to that file.
Translating the previous API call to Python code, it will look like this:
# Don't forget to build your Drive service instance
sharable_link = service.files()\
.get(fileId="your-file-id", fields="webViewLink")\
.execute()
print(sharable_link.get("webViewLink")) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -3,
"tags": "google drive api"
} |
Estimation of $\int \limits_{0}^{\infty}e^{-ax}\frac{1}{x}dx.$
I want to find an estimation for the integral $$\int \limits_{0}^{\infty}e^{-ax}\frac{1}{x}dx.$$ So, I change the variable $u=e^{-ax}$ and I get $$\int \limits_{0}^{e^{-a}}-\frac{1}{\ln u}du.$$ Since $u\in (0,e^{-ax})$ , then $0<\ln(u+1)<\ln(e^{-ax}+1)$. Thus, $$\int \limits_{0}^{e^{-a}}-\frac{1}{\ln (u+1)}du<\int \limits_{0}^{e^{-a}}-\frac{1}{\ln u}du.$$ And it does not make sense to achieve any estimation. Could you please give me a clue? How to find an upper bound for this case? | Assume $a>0$, otherwise the integral diverges at the upper bound. Under this assumption $\exp(-a x)$ is strictly decreasing for $x>0$. Choose two quantities $x_\ast >\epsilon>0$. Then $$ \int_\epsilon^\infty \mathrm{e}^{-a x} \frac{\mathrm{d}x}{x} =\int_\epsilon^{x_\ast} \mathrm{e}^{-a x} \frac{\mathrm{d}x}{x} + \int_{x_\ast}^\infty \mathrm{e}^{-a x} \frac{\mathrm{d}x}{x} > \int_\epsilon^{x_\ast} \mathrm{e}^{-a x_\ast} \frac{\mathrm{d}x}{x} + \int_{x_\ast}^\infty \mathrm{e}^{-a x} \frac{\mathrm{d}x}{x} = \\\ \mathrm{e}^{-a x_\ast} \ln \frac{x_\ast}{\epsilon} + \int_{x_\ast}^\infty \mathrm{e}^{-a x} \frac{\mathrm{d}x}{x} $$ The lower bound grows boundlessly as $\epsilon$ becomes smaller. Thus the integral diverges at the lower integration limit. | stackexchange-math | {
"answer_score": 4,
"question_score": 3,
"tags": "real analysis, analysis"
} |
Using while / do-while loops for array element setting
I'm having some trouble understanding how to use a while loop to get the same results as this for loop:
for (int i=0; i<N; i++){
int datum[i] = 0;
}
Basically, to set all the elements in the array datum[N] to 0. Does the following code make sense in that regard, or am I missing something? thanks
int i = 0;
while (i < N){
datum[i] = 0;
i++;
} | These two code examples produce the same results.
int i = 0;
while (i < N)
{
datum[i] = 0;
i++;
}
* * *
for (int i=0; i<N; i++)
{
datum[i] = 0; // remove int because you will be redclaring datum
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "c++, loops, for loop, while loop, do while"
} |
Is there a way of lazy initializing a static sub-object of a class?
Is there a way of initializing a static class member after main() has started ? | One way to do that is to replace the static member data which static member function.
Say you've this class:
class A
{
static B static_b; //static member data
};
//.cpp
B A::static_b; //definition (required)
So instead of that you can define your class as:
class A
{
static B static_b() //static member function!
{
static B b;
return b;
}
};
Note that it is not thread-safe, but you can make it thread-safe as well. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "c++, static members, lazy initialization"
} |
Not able to collapse the first row in datagrid in Silverlight
I am using a Silverlight datagrid control which should appear 'collapsed' by default. I found the sample code in msdn. But it shows error message that "Specified argument was out of the range of valid values. Parameter name: index. " . Below is my code.
private void CollapseGrid()
{
PagedCollectionView pcv = MyGrid.ItemsSource as PagedCollectionView;
try
{
foreach (CollectionViewGroup group in pcv.Groups)
{
MyGrid.CollapseRowGroup(group, true);
MyGrid.ScrollIntoView(group, null);
}
}
catch (Exception ex)
{
// Could not collapse group.
MessageBox.Show(ex.Message);
}
}
What am I doing wrong? | I got the issue fixed. I am populating the datagrid through an asynchronous call. So there is no way to check whether this call is completed or not. My collapse method will be called before completion of populating data in datagrid. So found a solution from one of the sites. Below is the solution.
void myDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
myDataGrid.LoadingRow -= new EventHandler<DataGridRowEventArgs>(myDataGrid_LoadingRow);
this.Dispatcher.BeginInvoke(delegate
{
PagedCollectionView pcv = (PagedCollectionView)myDataGrid.ItemsSource;
foreach (CollectionViewGroup groupname in pcv.Groups)
{
myDataGrid.CollapseRowGroup(groupname, true);
}
});
}
In the datagrid part of xaml, we need to add this event.
<sdk:DataGrid LoadingRow = "myDataGrid_LoadingRow" ItemsSource="{Binding MyBindingSource}"> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "silverlight, datagrid"
} |
jQuery event only every time interval
$(document).ready(function() {
$('#domain').change(function() {
//
});
});
The code inside the change function will basically send ajax request to run a PHP script. The #domain is a text input field. So basically what I want to do is to send ajax requests as user types in some text inside the text field (for example search suggestions).
However, I would like to set a time interval in order to lessen the load of PHP server. Because if jQuery sends AJAX request every time user adds another letter to the text field it would consume lots of bandwidth.
So I would like to set let's say 2 seconds as an interval. The AJAX request will be fired every time the user types a letter but with maximum frequency of 2 seconds.
How can I do that? | What you really want to do is check how long since the last change event so you keep track of the number of milliseconds between events rather than make a call every 2 seconds.
$(document).ready(function() {
var lastreq = 0; //0 means there were never any requests sent
$('#domain').change(function() {
var d = new Date();
var currenttime = d.getTime(); //get the time of this change event
var interval = currenttime - lastreq; //how many milliseconds since the last request
if(interval >= 2000){ //more than 2 seconds
lastreq = currenttime; //set lastreq for next change event
//perform AJAX call
}
});
}); | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 4,
"tags": "javascript, jquery"
} |
Backup Windows 8.1 partition to new hard disk using Linux
I want to reinstall Windows 8.1 on my machine, but keep the current Windows installation running for a short period of time on another machine, e.g. to access Chrome passwords or missing files easily. Usually we've done that by purchasing a new (faster) SSD and installing on that one, but now I want to install on the same (already fast) SSD and have the backup on an old spare hard-disk.
Is it possible to backup the Windows NTFS partition(s) using Linux to another hard disk, so it remains bootable? If so, what are the required steps? | Though there are numerous free Linux imaging utilities, such as Clonezilla that @LMFAO_A_JOKE suggests, all must be run on an _unmounted_ partition, AFAIK. You might prefer to image Windows using Macrium Reflect free or an alternative, since they use Windows' Shadow Copy. You can also make a recovery disk using Linux or WinPE with these utilities.
Clonezilla and alternative applications I've seen all require booting from other media (e.g. USB drive or CD) to image the primary disk. This is about the only are where I find Linux less convenient than Windows. BTW, if someone knows of a (free) Linux program that can do so, please comment here! | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "linux, partitioning"
} |
Given an integral equation, integrate the function.
$$f(x)=x+\int_0^1t(x+t)f(t){\rm d}t$$ Then what is $$\eta=\int_0^1f(x){\rm d}x$$ Ok you can write: $$\eta=\int_0^1\left(x+\int_0^1t(x+t)f(t)dt\right){\rm d}x=\frac12+\int_0^1\int_0^1t(x+t)f(t){\rm d}t{\rm d}x$$ How to eliminate f? | Reverse the order of integration.
$$\begin{align}\int_0^1 dx \, f(x) &= \frac12 + \int_0^1 dx \ \int_0^1 dt \, t(x+t) f(t)\\\ &= \frac12 + \int_0^1 dx \ \int_0^1 dt \, x(t+x) f(x) \\\ &= \frac12 + \int_0^1 dx \, x f(x) \left (\frac12+x \right )\\\ &= \frac12 + \frac12 \int_0^1 dx \, x f(x) + \int_0^1 dx \, x^2 f(x) \end{align}$$
Note, however, that
$$f(x) = x+ x \int_0^1 dt \, t f(t) + \int_0^1 dt \, t^2 f(t) $$
so that
$$\int_0^1 dx \, f(x) = f \left ( \frac12 \right ) $$
Now, note that
$$f(x) = A x + B$$
where
$$A = 1+ \int_0^1 dt \, t f(t)$$ $$B = \int_0^1 dt \, t^2 f(t)$$
Then
$$f(x) = x + \int_0^1 dt \, x (x+t) (A t+B) = x + x \left ( \frac13 A + \frac12 B\right ) + \frac14 A + \frac13 B $$
or,
$$A x+B = \left ( 1+\frac13 A + \frac12 B \right ) x + \frac14 A + \frac13 B $$
so that
$$\frac{2}{3} A - \frac12 B = 1$$ $$\frac14 A - \frac{2}{3} B = 0$$
Then $A=\frac{48}{23}$ and $B = \frac{18}{23}$ and the integral is $f(1/2) = \frac{42}{23}$. | stackexchange-math | {
"answer_score": 7,
"question_score": 3,
"tags": "integration"
} |
jquery dialog() - catch only div very next to the opener
I'm trying to set up multiple dialogs in the same page, trying to open only the one next to the opener es.
<ul>
<li class="dialog">
<a class="opener" href="#">1</a>
<div class="modal" title="Title for 1">Content for 1</div>
</li>
<li class="dialog">
<a class="opener" href="#">2</a>
<div class="modal" title="Title for 2">Content for 2</div>
</li>
</ul>
and jquery:
$(".modal").dialog({
autoOpen: false,
zIndex: 3999,
modal: true
});
$('.opener').click(function() {
$(this).next().dialog('open');
});
but $(this).next().dialog('open'); always gives me undefinded! where do I fail? :( thanks :) | You need to keep a reference to the dialog, like this:
$(".opener").each(function() {
$.data(this, 'dialog', $(this).next());
}).click(function() {
$.data(this, 'dialog').dialog('open');
});
$(".modal").dialog({
autoOpen: false,
zIndex: 3999,
modal: true
});
You can test it out here. The reason you do this is because when you call `.dialog()`, it moves the newly wrapped element to the end of the body, just before `</body>`....so it's no longer the next element. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "jquery, dialog"
} |
Implement one-to-many, parent-child relationship between two or more models in Entity Framework CF 5
Suppose I have a model like the following:
public class A{
public int ID { get; set;}
[Required]
public string Name { get; set;}
}
And I have another model like the following:
public class B{
public int ID { get; set;}
[Required]
public string Name { get; set;}
[Required]
public int AId { get; set;}
public string Type { get; set;}
[Required]
public int SlNo { get; set;}
}
Basically, I want to have a **One-to-many, Parent-Child** relationship between `A` and `B`, so that `AId` will act like a foreign key to `A`, and the same value of `AId` may be present in multiple instances of `B`.
How to achieve this in Entity Framework CF 5, ASP.NET MVC 4? | Inside of class B, just add a navigation property to class A. Then the code-first conventions will be able to infer the relationship. This ought to do it:
public class A{
public int ID { get; set;}
[Required]
public string Name { get; set;}
public virtual ICollection<B> Bs {get; set;}
}
public class B{
public int ID { get; set;}
[Required]
public string Name { get; set;}
[Required]
public int AId { get; set;}
public string Type { get; set;}
[Required]
public int SlNo { get; set;}
public virtual A A { get; set; }
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "asp.net mvc, entity framework"
} |
Is this sentence correct "The reason is actually because of another issue #176"?
I found an issue of a software, and finally I found the root cause if another issue, so I tell others:
> The reason is actually because of another issue #176
But I'm not sure if that's a valid or native English expression. | You could say it that way. For the software implementation profession, better wording would be ...
> The cause is actually due to another issue (#176). | stackexchange-ell | {
"answer_score": 2,
"question_score": 0,
"tags": "word choice"
} |
Microsoft Access Query
I have a query that has a amount of transaction column (dollar amount) and a payment type column (cash, check, CC). Is there a way to query all amount of transactions that are paid with cash and get a total, paid with credit card and get a total, paid with a check and get a total? | select payment_type, sum(transaction_amount)
from yourtable
group by payment_type
That'll return a row for each payment type, along with the total amount paid via that type. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "ms access"
} |
Is there a way to make a function do something different the second time a number appears?
Im trying to make a small program about the method in which the amount of money awarded to players at the end of a game is decided. So far I have used a RNG to simulate what happens in a round of the game but have gotten stuck. I want to find out how to design my code in order for it to do something different the second time the same number is generated from the RNG.
while (active==1)
{
random=rand()%11+1;
if (random==11)
{
bomb=1;
}
}
Thanks for any responses :) | Keep a map of (number, count) pairs:
std::unordered_map<int, std::size_t> number_frequencies;
while (active) {
int number = random_number();
++number_frequencies[number];
if (number_frequencies[number] == 2) {
// do something
} else {
// do something else
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c++, random"
} |
Where do I put my c wire the un used or c wire for me is blue but where do I connect it to?
I’m not really sure where to tie this blue wire into for my thermostat (< image description here!enter image description here!enter image description here!enter image description here | ## Include it in the nut with the red and grey wires in it
Given that the wiring diagram for your furnace says that the grey wire going into the thermostat wiring compartment is your C wire, we can connect the blue wire to the thermostat into the existing junction there to make it a C wire for your thermostat's use. This is further substantiated by the fact the yellow wire in your thermostat cable goes off into the white wire in the compressor cable, which leaves the red wire in the compressor cable to return 24V control power back to the transformer, which implies that the red wire must be connected to the furnace's C wire. | stackexchange-diy | {
"answer_score": 0,
"question_score": 1,
"tags": "thermostat c wire"
} |
Separating mysql fetch array results
i have a mysql table the contains an index id, a data entry and 10 other columns called peso1, peso2, peso3...peso10. im trying to get the last 7 peso1 values for a specific id. like:
$sql = mysql_query("SELECT * FROM table WHERE id='$id_a' ORDER BY data DESC LIMIT 0, 7");
when i try to fetch those values with mysql_fetch_array, i get all values together.
example:
while($line = mysql_fetch_array($sql)) {
echo $line['peso1'];
}
i get all peso1 values from all 7 days together. How can i get it separated? | They will appear all together because you are not separating them as you loop through them.
for example, insert a line break and you will see them on separate lines
while($line = mysql_fetch_array($sql)) {
echo $line['peso1'] ."<br />";
}
You could key it as an array like so
$myArray = array();
$i = 1;
while($line = mysql_fetch_array($sql)) {
$myArray['day'.$i] = $line['peso1'];
$i++;
}
Example use
$myArray['day1'] // returns day one value
$myArray['day2'] // returns day two value | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, mysql, arrays"
} |
Using Windows.Networking.Sockets in Xamarin for Windows Phone
I use `System.Net.Sockets` for `TCP/IP Client` in my cross-platform application. I have SharedProject where I have class responsible for connecting/receiving data. I can run app in `Android`, but I see that the `System.Net.Sockets` is not avaiable in `Windows Phone 8.1`. I read that to work with `Windows Phone` i can use `Windows.Networking.Sockets`, but when I add u`sing Windows.Networking.Sockets` in my class in `Shared Project` I get error:
> The type or namespace name 'Windows' could not be found
My question is how can I use `System.Net.Sockets` or `Windows.Networking.Sockets` with `Windows Phone 8.1` ? | Ok I resolved my problem by enter to Shared Class Library, next I double click on .NET and from left side I select Windows and click button 'Add to References in Selected Project in Solution Explorer' which is near search bar. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "sockets, xamarin, windows phone 8.1, cross platform, tcpclient"
} |
How to select the average of my "Value" column over an hour using the "Timestamp" column in my table
My table is called bluescope_data
I have three columns in this table, including “Timestamp”, “Value”, “lastchanged” as illustrated in the image below. The data is being displayed on a connecting dashboard. I want to only display the average of the “Value” column over each hour as depicted in the image below.
,
avg(Value)
FROM bluescopegas_data
WHERE $__timeFilter(Timestamp)
GROUP BY 1 | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "mysql, grafana"
} |
showing a function has exactly one root using Numerical Analysis Methods
Im trying out the Banach Caccioppoli Contradiction Principle but having a few problems..
f(x) = exp(x/2) - 25x^2 How would i show that this function f has exactly one root x^ in (-Infinity,0) ?
Some explanation would be much appeciated!
Many thanks | Let $f(x)=e^{\frac{x}{2}}-25x^2 \,.$
Then $f(0)=1, f(-1)<0$ and $f$ is continuous. IVT tells us there is at least a root.
Now, $f'(x)>0$ on $(0,\infty)$ which means that the function is strictly increasing. Thus it cannot have more than one root... | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "numerical methods"
} |
display blank select if model isn't associated with another model
I'm wondering - i have two models,`Device has many Phones` and vice versa. in the form for Phone I've got a select for a Device. I can't allow blank values to be inserted into this select, but somehow i need to display no value if no Device is associated.I can't figure out how to use javascript
= f.input :device_ids, include_blank: false, label: false, as: :select, collection: current_user.devices, input_html: {id: "phone_number_#{phone_number.id}_device_ids", disabled: (true if phone_number.multiring)}
How can i solve this problem? | Solved this issue - added inline javascript(haml)
= f.input :device_ids, include_blank: false, label: false, as: :select, collection: current_user.devices, input_html: {id: "phone_number_#{phone_number.id}_device_ids", disabled: (true if phone_number.multiring)}
- unless phone_number.devices.first
:javascript
$("#phone_number_#{phone_number.id}_device_ids").prop('selectedIndex', -1) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, select, ruby on rails 3.2, simple form"
} |
Setting CATALINA_HOME by another batch file parameter?
* I have two batch files. first.bat and test.bat
first.bat:
@echo off
SET START="C:\Users\Neonous\Desktop\test.bat"
call %START% "C:\Program Files\Apache\Tomcat_6"
test.bat:
@echo off
set "%CATALINA_HOME%=%~1"
echo %CATALINA_HOME%
actually what am trying is, just want to set CATALINA_HOME value for that session(not permanently), by calling test.bat with one parameter, inside first.bat file. Error: the syntax of the command is incorrect
how to get this? | try this:
first.bat
@echo off
call "C:\Users\Neonous\Desktop\test.bat" "C:\Program Files\Apache\Tomcat_6"
test.bat
@echo off
set "CATALINA_HOME=%~1"
echo %CATALINA_HOME% | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "windows, variables, syntax, batch file, command"
} |
What is the format of the django config file for manage.py?
I'm hooking up selenose (selenium) tests and using liveserver in the process. It appears that I automatically start running into problems with ports being used so want to configure liveserver to use more that one port. I see how to do that via the command line (--liveserver=localhost:8100-8110) but would like to use a config file.
I have one I'm using for nose already and thought I might be able to reuse it but can't find anything to support that belief and my test runs say it won't work. I was expecting to be able to add something like the following:
[???] liveserver=localhost:8100-8110
but replace the '???' with an actual header. | for some reason django uses an environment variable for this. you can set it in your settings if you want
import os
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = 'localhost:8000-9000' | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "django, selenium, configuration, manage.py"
} |
Knockout.js change dropdown possible values based on another dropdown
I have the following problem in Knockout.JS:
Let's suppose that I have an observable array of objects, rendered with the help of a template. Each one of them has two observable properties A and B. Both of these properties take their values from dropdowns (select/options binding).
My problem is that when the selected value of A changes for one object I also want to change the available (and selected) values of B for that specific object. I can't seem to find how this is done using knockout.
I could solve the problem using Javascript or Jquery to assign handlers to the onchange event of dropdown A and change the dropdown options of B manually - however I really don't want to pollute my design with that :(
So please answer me using only knockout's tools...
Thanks ! | Take a look at the "Cart editor example" over at the Knockoutjs website. It includes an example of populating one combo box based on a parent combo box.
<
Maybe this helps? | stackexchange-stackoverflow | {
"answer_score": 16,
"question_score": 10,
"tags": "javascript, drop down menu, knockout.js"
} |
Can scala's parser combinators parse binary files?
Can the built-in scala parser combinators parse binary (not text) files? | It can parse anything, that's why `type Elem` is abstract on `Parsers`. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 6,
"tags": "parsing, scala, binary"
} |
How are sensors used in Android games?
How do people create games which make the object move when we turn or rotate our phone in different directions (accelerating a car, for example)? Do they use readings from the accelerometer and gyroscope or do they use OpenGL in Android? | They are likely using the accelerometer, because it is widely available on a large variety of devices.
You might want to take a look at this tutorial: <
And here's a demo of the accelerometer feature from Google: < | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "android, opengl es, gyroscope, game development"
} |
Ruby: Embedded Ruby Array of hashes to JSON
I am trying to convert the Ruby array of hashes to a JSON and return it.
What I've tried so far:
hash ={}
user.attributes.each_pair do |key, value|
if(key == 'auth_id')
hash[key] = value
elsif (key == 'useractivity')
# How do I get to the Key's array of useractivities from here?
# {useractivities : [{id:,:name},{:id,:name}]}
end
end
return hash.to_json
Thanks! | You can do:
hash ={}
user.attributes.each_pair do |key, value|
if(key == 'auth_id')
hash[key] = value
elsif (key == 'useractivity')
value.each {|inner_hash| do_something_on_inner_hash}
# How do I get to the Key's array of useractivities from here?
# {useractivities : [{id:,:name},{:id,:name}]}
end
end
return hash.to_json | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ruby, json"
} |
How to write to a .csv file without "import csv"
For an assignment I have to write some data to a `.csv` file. I have an implementation that works using Python's `csv` module, but apparently I am not supposed to use any imported libraries...
So, my question is how I could go about doing so? I am no expert when it comes to these things, so I am finding it difficult to find a solution online; everywhere I look `import csv` is being used. | Since `csv` stands for **comma-separated values** , you can create a file with the regular I/O built-in function that ends with `.csv` like:
f = open("demofile.csv", "w")
And then write to it:
f.write("1, 2, 3 ,4, 5\n 6, 7, 8, 9, 10")
Where each cell is _separated_ by _comma_ , and each row is separated by `\n`.
The result will look like this in `MS Excel`:
 alongside Webform module (7.x-4.16) on Drupal 7.22. When I add Date column to Webform report then save it and view ,Report crashes with message ..website is currently unable to handle this request.HTTP ERROR 500. no matter what format(yyyy/mm/dd..) I enter in date field or leave it empty same happens, If I create report in View by adding all fields including Date fields it works. Also in Webform-Results -Table it works. Any suggestions.. Also can we in drupal 7 enter date and time both in same textbox so it lands in db in one field or it must be separated as I see drupal has it as separate types?
 also result(report) based on query can be shown in drupal interface, just needs some more css adjustment in table header/table data widths for columns
Nikola | stackexchange-drupal | {
"answer_score": 0,
"question_score": 0,
"tags": "entities, webforms"
} |
Exploit Time Machine sparsebundle file
I use time machine with a non HFS+ network drive to backup my data thank to the following command:
_defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1_
Everything was working until the day I format my mac and try to restore with my time machine backup : the migration assistant cannot see my network drive!
Is there a way to recover my data from the MYMACHINENAME.sparsebundle file? | I'll bet it's just that Migration Assistant doesn't know about TMShowUnsupportedNetworkVolumes. Try putting your sparsebundle on a supported network volume and see if Migration Assistant sees it then.
Even if that isn't an option or doesn't work, realize that a sparsebundle is just a sophisticated form of a disk image. You can work with it like you'd work with any .dmg. You could use Disk Utility to restore it to a USB or FireWire drive, and it would _probably_ act as if it had always been a local (directly connected) Time Machine backup drive. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "time machine"
} |
When positive score vs negative score results zero it is not showing on profile's summary
I noted it today, I don't know if it was already this way, but my last reputation was 5 downvotes and 2 upvotes in one question I asked resulting with no changes in the score.
I think it should show a mini-box with a number zero instead of hiding the mini-box. It just seems weird to me :/
.
With you in the next build (rev: rev 2016.7.13.3757, meta rev: rev 2016.7.13.4740). | stackexchange-meta_stackoverflow | {
"answer_score": 3,
"question_score": 7,
"tags": "bug, status completed, reputation, profile page"
} |
How do I create a "netlink" between kernel and userspace?
I want to use netlink to communicate between an application and kernel space. My Linux kernel version is 2.6.28, and the following is my wrong code:
nf_sock=netlink_kernel_create(NL_PROTO,0,nl_user_skb,THIS_MODULE);
The abbreviated error message is:
error: too few arguments to function 'netlink_kernel_create'
In the file `<linux/netlink.h>`, the function `netlink_kernel_create()` is defined as
extern struct sock *netlink_kernel_create(struct net *net,int unit,unsigned int groups,void (*input)(struct sk_buff *skb),struct mutex *cb_mutex,struct module *module)
I don't understand what to use for the first argument, `net`. Can someone explain what I should use here? | A `struct net` contains information about the network namespace, a set of network resources available to processes. Note that there could be multiple network namespaces (i.e. multiple instances of the networking stack), but most drivers use the init_net namespace.
Your call should probably look something like the following
nf_sock = netlink_kernel_create(&init_net,
NETLINK_USERSOCK,
0,
nl_rcv_func,
NULL,
THIS_MODULE);
where `nl_rcv_func` is a function taking `struct sk_buff *skb` as the only argument and processes the received netlink message. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 4,
"tags": "c, linux, linux kernel, device driver, netlink"
} |
How to say "oink!" in Mandarin in a family situation?
This may not be on-topic for the next 4383 days, but hopefully today someone will help me out.
Last year was the year of the dog, and a common way to write (in English) the Chinese version of what dogs say is _wang! wang!_.
Today is the first day of the year of the pig. How would I write in English and say what pigs say in Chinese?
I'm looking for something that could be polite and humorous in a family situation and generally recognized in Mandarin, if such a thing exists. | Well, the porcine vocabulary comprises at least 3 sounds. How one may represent them is a matter of choice. To date, no exhaustive linguistic studies, to my knowledge, exist. 'oink' is phonetically interesting, because the sound is produced by inhaling. To mimic the grunt adequately, one should also inhale.
grunt:
squeal:
oink(somewhere between grunt and squeal): ,
| stackexchange-chinese | {
"answer_score": 3,
"question_score": 2,
"tags": "vocabulary, pronunciation, word requests"
} |
iBooks opening a PDF - "Popovers cannot be presented from a view which does not have a window"
I'm an Objective-C noob trying to open a PDF file in the iBooks library in my app.
I use the following code - it appears to create the open dialog, but I get an error - "Popovers cannot be presented from a view which does not have a window." I'm not sure how to correct this...what am I doing wrong here?
- (void) showOptionsMenu
{
NSURL *fileURL = [NSURL fileURLWithPath:@"ibooks://test.pdf"];
docController = [self setupControllerWithURL:fileURL usingDelegate:self];
bool didShow = [docController presentOptionsMenuFromBarButtonItem:self.toolbarItems[0] animated:YES];
if(!didShow)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Sorry, app not found" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
} | Wound up fixing the problem by declaring a property for my UIDocumentInteractionController. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ios, objective c, ipad"
} |
Dropping lots of columns from a pandas dataframe
Say I have a data frame with 100+ columns, how would I go about dropping, say, the last 15 columns?
Is there a better way than typing: `df.drop([column1,column2,...,column15])`? I have to input the names of all of the columns here. Is there not a way I can sort of slice, like something like `[column1 : column15]`? | If you know the indexes of the columns you want to drop you could use
df.drop(df.columns[15:30], axis=1)
As mentioned in the comment by @fillbranden I should have shown you how to delete the last 15 columns with:
df.drop(df.columns[-15:], axis=1) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "python, pandas"
} |
JavaScript bytecode compiler?
For a project I'm tangentially working on, I need a way to compile JavaScript into some intermediate language or bytecode so that I can single-step through it. I know that many of the JavaScript engines in modern browsers do something like this, but they don't make the resulting bytecode accessible. Is there a good off-the-shelf tool for this sort of JavaScript compilation? | Not exactly sure of your needs, however maybe Rhino could work for you.
> The JavaScript compiler translates JavaScript source into Java class files. The resulting Java class files can then be loaded and executed at another time, providing a convenient method for transfering JavaScript, and for avoiding translation cost.
More about the compile function is located here. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 4,
"tags": "javascript, compiler construction, bytecode"
} |
Changing \parts in exam document class
I am using \parts in the document class exam. I have noticed that it will always start the lettering with "a". Is there a way to change this in latex? I have already tried using the following:
\setcounter{part}{2}
I was wondering if there is any way that I could start lettering with "b" or "c". | You had the right idea, but the counter you want to change is `partno` not `part`.
Code:
\documentclass{exam}
\begin{document}
\begin{questions}
\question
What if there were no air?
\begin{parts}
\setcounter{partno}{1}
\part[5]
Describe the effect on the balloon industry.
\part[5]
Describe the effect on the aircraft industry.
\end{parts}
\end{questions}
\end{document}
Yields:
$ in non-smooth case
Let $(X,L,\omega)$ be a projective variety with polarization $L$. then we can write
$$\dim H^0(X,L^k)=a_0k^n+a_1k^{n-1}+...$$
If $X$ is smooth then $a_0=Vol(X)$ and we can compute $a_i$.
If $X$ is non-smooth then how can we compute $a_i$? | Sometimes one can at least compute $\chi(\mathcal{O}_X(X, \, L^k))$.
The formula that one expects will be of the form "ordinary Riemann-Roch formula plus correction terms depending on the singularities of $X$". This is of course a bit vague, nevertheless the correction terms can be explicitly computed in some particular cases.
For instance, surfaces with rational double points and threefolds with canonical singularities are treated in detail in [M. Reid, _Young person guide to canonical singularities_ ], Chapter III "Contribution of $\mathbb{Q}$-divisors to RR". In particular, the correction terms are expressed in terms of Dedekind sums. | stackexchange-mathoverflow_net_7z | {
"answer_score": 2,
"question_score": 3,
"tags": "ag.algebraic geometry, dg.differential geometry, sg.symplectic geometry"
} |
Python - Openpyxl - Add formula to column and repeat formula to last row of data
Trying to do the following: In column G add the following formula: `"=ACOS(COS(RADIANS(90-D2)) *COS(RADIANS(90-D3)) +SIN(RADIANS(90-D2)) *SIN(RADIANS(90-D3)) *COS(RADIANS(E2-E3))) *6371"`
Repeat this formula in column G up to the last row with data in columns D and E. I want the cells in the formula to update as formula goes down the rows (i.e. D2 becomes D3...)
Tried the following without success. This will copy the formula in all the rows for column G with data in columns D and E but I am missing the part to update the D and E cells in the formula for each row. My script is incomplete and don't know how to fix it.
for row_num in range(3, max_row+1):
sheet['G{}'.format(row_num)] = '=ACOS(COS(RADIANS(90-D2)) *COS(RADIANS(90-D3)) +SIN(RADIANS(90-D2)) *SIN(RADIANS(90-D3)) *COS(RADIANS(E2-E3))) *6371'.format(row_num)``` | I am new with Python but I just figured it out. The following works.
`for row_num in range(3, max_row+1): sheet['G{}'.format(row_num)] = '=ACOS(COS(RADIANS(90-D{})) *COS(RADIANS(90-D{})) +SIN(RADIANS(90-D{})) *SIN(RADIANS(90-D{})) *COS(RADIANS(E{}-E{}))) *6371'.format(row_num-1, row_num, row_num-1, row_num, row_num-1, row_num) ` | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "python, excel, formula, openpyxl"
} |
Java: 'Invalid line number' when setting boolean grid to all true
I'm trying to set the below Grid to all true, but I get the error
> "2685 is not a valid line number in java.util.Arrays"
public class Grid {
static boolean[][] gridCon;
boolean white = true;
boolean black = false;
private static int Height;
private static int Width;
public Grid(int height, int width) {
Height = height;
Width = width;
Arrays.fill(gridCon, true);
}
}
How do I fix this? | Arrays.fill does not work with 2-dimentional arrays, try this
gridCon = new boolean[Height][Width];
for(boolean [] e : gridCon) {
Arrays.fill(e, true);
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "java, grid, boolean"
} |
Azure function doesn't timeouts earlier than set value
I have seen that Azure Functions increased timeout to 10 minutes while default is still 5 minutes.
My `host.json` is
{
"queues": {
"maxPollingInterval": 2000,
"visibilityTimeout": "00:00:30",
"batchSize": 16,
"maxDequeueCount": 3,
"newBatchThreshold": 8,
"functionTimeout": "00:10:00"
}
}
I can see the timeout value as 10 minutes in portal as well, although it didn't pick it up from the host.json I have in my local Visual Studio so I set it manually in the portal.
However, any job that passes 5 minutes is timing out. I couldn't seem to find any information around is apart from that it should work. | `functionTimeout` property should be on top level, not under `queues`:
{
"queues": {
"maxPollingInterval": 2000,
"visibilityTimeout": "00:00:30",
"batchSize": 16,
"maxDequeueCount": 3,
"newBatchThreshold": 8
},
"functionTimeout": "00:10:00"
} | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "azure, timeout, azure functions"
} |
Highlight lines with mouseclick/arrowkeys
A while back I asked a question on how to Highlight lines of text on mouseover. However, as I used this for a while I noticed a few flaws with this system. One them was that users lose track of where they were after switching to a new tab/moving the mouse to do something else.
That's why I want to do the same thing, except with mouseclicks, or even better, the arrow keys on the keyboard.
I have no idea if this is possible as I have no experience with jQuery. If anyone knows a script like this or if anyone could write me one that would be great!
Many thanks in advance! | Here is this jquert part
$(document).ready(function() {
$(".textWrapper").click(function(e) {
var relativePos = e.pageY - this.offsetTop;
var textRow = (Math.ceil(relativePos / 18) * 18) - 18;
$(".highlight", this).css("top", textRow + "px");
$(".highlight", this).show();
});
});
And the js fiddle of course <
For the arrow keys it is a bit trickier cause i need a way to figure out the number of lines in the paragraph | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, jquery, html, css, highlight"
} |
Do transations guarantee atomic execution of statements (in a programing sense)?
I have a database with tables: `users` and `relations` (between users). I want to add a relation between users only if both users exist. But between checking users and adding relationship one user might delete his account and in this case I want the second operation to fail. It wouldn't be a problem if both operations did execute atomicly (in programming sense). Do transactions guarantee that? I know that they guarantee that either all operations are executed or none with rollbacks (I recently learned that is also called atomicity), but do they also guarantee normal atomicity? And if they don't how can I solve the problem above? | Depending, whether you are using RDBMS, but Primary keys and foreign keys should resolve your problem. users (PK) -> relations (FK). Transactions will provide then, that first relation will be added, then user deletion handled.
Now the question is what do you mean by "deleting user". If you mean to actually delete row in the database - then you can "delete cascade" e.g. mysql in order to remove both relation, and user. Alternatively - if you want to prevent user from being deleted, if there are any attached relations (which is what I understand you want to happen) - your PK-FK relation will provide it for you i.e. you first would need to delete all the attached relations, in order to delete user. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "database"
} |
parsing xml with javascript WITHOUT AJAX?
I am creating a widget that will be installed across different sites. The widget will parse an XML feed into JPlayer, because the widget will be installed across different sites AJAX is not an option, is there a way to parse XML with javascript without using AJAX. I am trying to stay away from PHP as well.
here is code in Simple XML, but I want to rewrite it in javascript.
$url = '
$rss = simplexml_load_file($url);
$items = $rss->channel->item;
<?php
$i = 0;
$data = array();
foreach ($items as $item) {
$data[] = array(
'title' => (string) $item->title,
'mp3' => (string) $item->enclosure['url'],
);
if (++$i == 3) break;
}
$jsdata = json_encode($data); | The following will parse and XML string into an XML document in all major browsers, including IE 6. Once you have that, you can use the usual DOM traversal methods/properties such as `childNodes` and `getElementsByTagName()` to get the nodes you want.
var parseXml;
if (typeof window.DOMParser != "undefined") {
parseXml = function(xmlStr) {
return ( new window.DOMParser() ).parseFromString(xmlStr, "text/xml");
};
} else if (typeof window.ActiveXObject != "undefined" &&
new window.ActiveXObject("Microsoft.XMLDOM")) {
parseXml = function(xmlStr) {
var xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xmlStr);
return xmlDoc;
};
} else {
throw new Error("No XML parser found");
}
Example usage:
var xml = parseXml("<foo>Stuff</foo>");
alert(xml.documentElement.nodeName); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "javascript, ajax, xml parsing"
} |
Jquery radiobutton check and uncheck
I have a few radio buttons in a group, one of them being:
<input type='radio' id='other' name='Group'></input>
<label for='other'>Other:</label>
I would like to make it so that i get an alert when the button is checked. When the radio button becomes unchecked, after being checked, (by selecting another button) I would like to get a different alert message.
JQuery (this is not working):
$('input:radio[id="other"]').change(
function(){
if ($(this).is(':checked')) {
alert("checked");
}
if ($(this).is(':notchecked')) {
alert("notchecked");
}
}
); | You should Write the change event for the radio group, not for each button. Then look to see which radio button is checked
Here is the jsFiddle ref. < | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "jquery, radio button"
} |
Cambiar propiedad Type de input con Angular
Buenas tardes quisera que me ayuden ya que debo realizar el cambio de la propiedad de un input con Angular, he encontrado mucho con java script pero no con angular: he hecho lo siguiente:
let pass=document.getElementById('password');
con esta linea obtengo el elemento del Dom, pero al querer cambiarle la propiedad pass.type no me sale nada y me arroja un error que no existe esa propiedad, espero me puedan ayudar. | **app.html**
<input type="password" id="pass"/>
<button (click)="cambiarTipo()">cambiar tipo</button>
**app.ts**
export class AppComponent {
cambiarTipo(){
let elemento :any = document.getElementById('pass');
elemento.type = "text";
}
}
Ejemplo stackblitz
Creo que el error que mencionas es **Property 'type' does not exist on type 'HTMLElement'.** Eso se debe a que typescript crea por defecto un objeto de tipo `HTMLElement` y ese no tiene la propiedad `type`. Si se declara como tipo `any` ya no hay problema. | stackexchange-es_stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "angular, typescript, angular7"
} |
Why and when should one call _fpreset( )?
The only documentation I can find (on MSDN or otherwise) is that a call to `_fpreset()` "resets the floating-point package." What is the "floating point package?" Does this also clear the FPU status word? I see documentation that says to call `_fpreset()` when recovering from a SIGFPE, but doesn't `_clearfp()` do this as well? Do I need to call both?
I am working on an application that unmasks some FP exceptions (using `_controlfp()`). When I want to reset the FPU to the default state (say, when calling to .NET code), should I just call `_clearfp()`, `_fpreset()`, or _both_. This is performance critical code, so I don't want to call both if I don't have to... | `_fpreset()` resets the state of the floating-point unit. It resets the FPU precision to its default **and** clears the FPU status word. The two occasitions I see to use it are when recovering from an FPE (as you said) and when getting control back from library code (e.g. a DLL that you have no control about) that has screwed the FPU in any way, like changing the precision. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 5,
"tags": "c++, visual c++, floating point"
} |
Google Transliterator (input tools) is not suggesting words as typed when used on my site
I want a transliterator (Google's) to be embedded in my site. I tried embedding it and I mostly succeeded. It is showing translations, but all of them for a word typed one letter at a time like it shows in Google input tools online like this:
!enter image description here
I need such a feature in my site, however it is only showing me at the end of the word when I hit space, not after every key press.
I tried looking at the web console (Firefox), and understood that in the code that I have is sending a request whenever we hit a space. But Google input tools online is sending request to POST a request after every key press then getting and printing data only after space. | Could you code in an event listener that pings for every keypress instead of the default space / enter key press?
Google Search API and widgets usually have an auto-suggest option, which works the same as you want this to. However, I couldn't find an exact equivalent for the transliterate API, so your only option would be code this in yourself. | stackexchange-webmasters | {
"answer_score": 1,
"question_score": 5,
"tags": "google, internationalization, google apps, translation, international"
} |
Display sorting options dropdown when using WooCommerce product category shortcode
I have a WordPress site, with WooCommerce. The WooCommerce archives pages as shop display a dropdown sorting filter like in this screenshot:
_ :
[product_category limit="90" columns="3" category="foo" paginate="true"]
or inside php code:
echo do_shortcode( '[product_category limit="90" columns="3" category="foo" paginate="true"]' );
Now you will see that the sorting options dropdown appear.
**Note:** `orderby` argument with an empty value **has no effect**. `order` argument is **`ASC` by default**. | stackexchange-wordpress | {
"answer_score": 4,
"question_score": 3,
"tags": "php, woocommerce offtopic, shortcode, sort"
} |
With setResponsePage, how can I add the page version of the page I want?
With `setReponsePage`, how can I add the page version of the page I want? So for example 3 in <
Thanks. | You need to use `#setResponsePage(Page)` instead, not `#setResponsePage(Class)`.
First you need to get a reference to the page with that id: `session.getPageManager().getPage(pageId)`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -3,
"tags": "wicket"
} |
Making responsive grid elements fit by height
I'm trying to get my head around working with responsive webdesign (by column stacking) and I'm currently using this grid for my layouts: < which I think works quite neat.
Only thing I'm running my head the wall with is to make it "smart enough" to also try and fit my columns by their height. What I have so far is this: < and what I'm looking for is this: < so that the grid is trying to fit the rows by their height aswell as the column count.
Is this possible in some way? :-) Should I by using some other grid for this or do I have to make up some hacky javascript to achieve what I want?
Thanks in advance. | Don't reinvent the wheel! David DeSandro already put out a couple jquery plugins that will do this for you. Masonry was the first one and works very well, and Isotope is the newer version that expanded on the original thinking along with additional features like sorting. Both will do a good job of creating the dynamic grid system you're hoping for. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 4,
"tags": "html, css, responsive design, grid layout"
} |
Return value inside unbuffer command
I have the following bash code to capture the result of a build while printing the output to the screen and provide parsing of the build results.
output=$(unbuffer cmake ... | tee /dev/tty)
parseErrors ${output}
parseErrors does what it sounds like. It parses the output for anything that looks like an error. I can exit there, but would rather do it after the function call. How do I get the return status from the cmake build passed to the unbuffer command? I have tried using PIPESTATUS[0], but I think that is returning the value from unbuffer itself. | Assuming you want to have access to the return code from `cmake` after the 2 lines, you can do
output=$(unbuffer cmake ... | tee /dev/tty; exit "${PIPESTATUS[0]}")
rc=$?
parseErrors ${output}
exit "$rc"
The use of PIPESTATUS has to be in the `$()` subshell. If you just want to add the return code to the output, replace the `exit` by an `echo`. | stackexchange-unix | {
"answer_score": 2,
"question_score": 2,
"tags": "bash, exit status"
} |
PHP - Extract data from string with regex
I need help to do this operation. I Have a string like this:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Formatting the report</title><meta http-equiv="refresh" content="5;url=/file/xslt/download/?fileName=somename.pdf"> </head>
I need to extract the fileName parameter. How to do this?
I thing that is possible with regex, but I do not know well this.
Thanks! | Try this..
This will capture the filename
The Pattern is given below
/fileName=(.+?)\"/
<?php
$subject = "<!doctype html> <html> <head> <meta charset="utf-8"> <title>Formatting the report</title><meta http-equiv="refresh" content="5;url=/file/xslt/download/?fileName=somename.pdf"> </head>";
$pattern = '/fileName=(.+)"/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 2);
print_r($matches);
?>
$1->Contains the file name
demo | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, regex, api, extract, nessus"
} |
Multiple Conditions for Array Formula
I'm looking to use an array formula to makes lists of students who have entered different events, but also need to split by gender.
I have the first array working where it lists the students in each event but can't seem to get the second condition to work properly.
!img
Here is my working formula for the first event lists:
`=IFERROR(INDEX($A$3:$A$502,SMALL(IF($C$3:$C$502=1,ROW($C$3:$C$502)-ROW($C$3)+1),ROWS($C$3:$C3))),"")`
Here is my non-working attempt at the second one:
`=IFERROR(INDEX($A$3:$A$502,SMALL(IF(AND($C$3:$C$15=1,$B$3:$B$15="F"),ROW($C$3:$C$15)-ROW($C$3)+1),ROWS($C$3:$C3))),"")`
What am I doing wrong? | Try,
=IFERROR(INDEX($A:$A, aggregate(15, 6, row($3:$502)/(($C$3:$C$502=1)*($B$3:$B$502="F")), row(1:1))), text(,))
I have no idea why your sample formula had the criteria ranges going down to row 15; the ranges need to be the same. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "arrays, excel, indexing, conditional statements"
} |
Simple Inequality Question
Given $a>b>0$
How can I prove that $\frac{1}{b} >\frac{1}{a}$ or in other words $b^{-1}>a^{-1}$
Thanks. | $a>b>0$ or, $a-b>0$, dividing by $ab>0$, you will get:
$$\frac{a-b}{ab}=\frac{1}{b}-\frac{1}{a}>0$$ | stackexchange-math | {
"answer_score": 3,
"question_score": 1,
"tags": "real analysis"
} |
How does the dynamic nature of Python interoperate with PyPy's ability to inline functions?
Suppose you have a function like `f` that calls a function `m.g`:
def f(x):
return m.g(x, 2*x, x+1)
and `f` gets called a lot, so PyPy JITs it and inlines `m.g` into it. What if later, due to the "dynamic" nature of Python, `m.g` gets replaced by something else: Will the old JITed version of `f` be discarded right away, or could it still be called accidentally?
Also, what if your program does these redefinitions a lot, can the discarded JITed versions cause a memory leak? | To answer your last question: "if your program does these redefinitions a lot, can the discarded JITed versions cause a memory leak?" This is a good question, and the answer might be yes in some cases. The bad case might be if `g` is a function you just created with `exec` or `eval`, so that there is an unbounded number of function objects that end up being called here. This is a problem that we thought about fixing in the past, but never got around to do it. If you are experiencing what looks like a leak and have isolated this part of the code, then I'd say chances are that it is exactly what you are fearing. In that case, I'd recommend to write a mail to [email protected] or come to #pypy on irc.freenode.net to describe your case. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "python, jit, pypy"
} |
JSF and backbone/underscore.js - double-quote escaping
I'm using backbone.js and underscore.js templates in a JSF application with Facelets.
The issue I'm having is that double-quotes in template expressions like
<script type="text/template">
{{ if (x == "foo") }}
....
</script>
are getting escaped like `"foo"`.
What's the best way to avoid this?
If I put `<![CDATA[` as the first thing in my `<script>` tag, then I also see the `CDATA` in the template output.
If I try to put the template in an external .js file, then Eclipse complains heavily because the template is not Javascript code.
I'm thinking maybe put the template in another file with a different extension other than .js? | Try wrapping your Javascript code in `f:verbatim`:
<f:verbatim>
<script type="text/template">
{{ if (x == "foo") }}
....
</script>
</f:verbatim> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "jsf, backbone.js, facelets, underscore.js"
} |
Ligatures with Libertine: issue with pdflatex (and Windows)
If you compile the piece of code given below using pdflatex, then open the resulting PDF file with your preferred viewer, copy the word "efficient" and paste it in a text editor, you will read "efcient". This does not happen with xelatex or lualatex. Is there a way to fix this issue with pdflatex?
\documentclass[fleqn,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{libertine}
%\usepackage{lmodern}
\begin{document}
efficient
\end{document} | Add
\input glyphtounicode
\pdfgentounicode=1
`glyphtounicode.tex` contains a lot of mappings like
\pdfglyphtounicode{ffi}{0066 0066 0069}
which are added to the pdf and helps the viewer to correctly interprete special chars. I didn't check which of the mappings is needed for libertine, imho it doesn't harm to simply load the whole lot.
The issue itself can be viewer dependant -- some are better in guessing than other. | stackexchange-tex | {
"answer_score": 7,
"question_score": 7,
"tags": "ligatures, libertine"
} |
How to add an onload eventListener to a popup in Opera
I'm writing an application that needs to call a function when a popup has loaded. Currently, this is what I'm using, which works in Firefox/Chrome/Safari:
var win = window.open(...);
win.addEventListener( 'load', function () {...}, true );
However, opera does not like `win.addEventListener`. I tried `win.opera.addEventListener` too, but that also didn't help. | For the record the solution which had been found previously
var openedWindow = window.open("test.html", "title");
window.setTimeout(function() {
openedWindow.addEventListener("load", function() {
console.log("received load event");
}, false);
}, 0); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "javascript, dom events, opera"
} |
AngularJS - Service talking to Controller
Angular JS has pretty cool feature of two-way binding which allows controller data to automatically get updated when view changes (or vice-versa). Today we can have controllers dependent on services. Is it possible for services to depend on controller? For e.g. if a service wants to fetch certain data from a controller on it's own will, is it possible?
Also, is it possible to extend the scope of ng-model variable to pass to the service (along with controller) as variable, which keeps in sync automatically?
Thanks. | When you assign multiple variables to the same object , each is a reference to the same object.
Following is for demonstration. This may not be preferred approach depending on use case
app.controller('MainCtrl', function($scope, MyService) {
$scope.mainModel = MyService.myObject;
})
app.controller('OtherCtrl', function($scope, MyService) {
$scope.otherModel = MyService.myObject;
})
app.factory('MyService', function() {
return {
myObject: {
name: 'test'
}
}
});
Both of the following inputs will show the same value
<div ng-controller="MainCtrl">
Name:<input ng-model="mainModel.name">
</div>
<div ng-controller="OtherCtrl">
Name:<input ng-model="otherModel.name">
</div>
`**DEMO**` | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "javascript, angularjs, frameworks"
} |
How to pass extra parameter in rails form_for
How I can get `redirect_id` from this form?
<%= form_for(@category) do |f| %>
<%= hidden_field_tag :redirect_id, :value=>5 %>
<%= f.text_field :text %>
<% end %>
In controller I can get only `category` params in my `params` array.
Maybe because I'm using only this code to filter parameters in controller.
def panel_category_params
params.require(:category).permit(:text)
end | Following should work:
<%= hidden_field_tag 'redirect_id', 5 %>
See examples of using `hidden_field_tag`. | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 6,
"tags": "ruby on rails, ruby on rails 4, ruby on rails 5, ruby on rails 6, form for"
} |
PHP Regex help, getting part of a link
I'm trying to write a regex in php that in a line like
<a href="mypage.php?(some junk)&p=12345&(other junk)" other link stuff>Text</a>
and it will only return me "p=12345", or even "12345". Note that the (some junk)& and the &(otherjunk) may or may not be present. Can I do this with one expression, or will I need more than one? I can't seem to work out how to do it in one, which is what I would like if at all possible. I'm also open to other methods of doing this, if you have a suggestion.
Thanks | Use `parse_url` and `parse_str`:
$url = 'mypage.php?(some junk)&p=12345&(other junk)';
$parsed_url = parse_url($url);
parse_str($parsed_url['query'], $parsed_str);
echo $parsed_str['p']; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "php, regex"
} |
DNAT on the POSTROUTING chain
What happens if I try to do a DNAT in the POSTROUTING chain of the NAT table in iptables?
Suppose I change the destination IP of the packet in the POSTROUTING chain to an address that should get routed via a different interface. What would happen to the packet?
1. Would the host be able to route the packet to the correct interface even after all the routing decisions have been made.
2. Or would the packet still be sent via the interface which was decided in the routing decisions before. | Both options are incorrect. The right answer is :
3. An error will occur.
Because DNAT can only be used in PREROUTING or OUTPUT chains. | stackexchange-serverfault | {
"answer_score": 2,
"question_score": 0,
"tags": "iptables, firewall"
} |
Inequality of summation of two sequences.
Consider two sequences of positive real numbers $a_1,a_2,\ldots a_n$ and $b_1,b_2,\ldots,b_n$ where n is a natural number.
Prove that $\sum_{k=1}^{n} \sqrt{a_k^2+b_k^2} \geq \sqrt{(\sum_{k=1}^{n} a_k)^2 + (\sum_{k=1}^{n} b_k)^2}$.
My solution: consider n right triangle joined at their vertices with bases $a_1,a_2,...a_n$ and heights $b_1,b_2,...b_n$(i.e. they are joined end to end, with all bases parallel to one another).
The LHS of the inequality is sum of their hypotenuse.
By triangle inequality, it's least value would be the line joining the top vertex of the highest right triangle and the bottom vertex of the lowest right triangle, and this value is the RHS.
Hence proved.
Is there any other(non geometrical) solution? | I guess it should be $\sum_{k=1}^{n} \sqrt{a_k^2+b_k^2} \geq \sqrt{(\sum_{k=1}^{n} a_k)^2 + (\sum_{k=1}^{n} b_k)^2}$. The proof by geometric is nice. Here is my another proof.
* You just need to prove for case $n=2$ then apply it one by one, for example $n=3$
$$\sum_{k=1}^{3} \sqrt{a_k^2+b_k^2} \geq \sqrt{(a_1+ a_2)^2 + (b_1+ b_2)^2}+\sqrt{a_3^2+b_3^2}\geq \sqrt{(a_1+ a_2+a_3)^2 + (b_1+ b_2+b_3)^2}$$
* For case $n=2$, just squaring both two sides gives you the below equivalent inequality
$$\sqrt{(a_1^2+b_1^2)(a_2^2+b_2^2)} \geq a_1a_2+b_1b_2$$ This is just application of Cauchy-Schwarz Inequality. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "sequences and series, algebra precalculus, inequality"
} |
When Jsoup parse Html tag that only included "0", null will be returned?
I use jsoup-1.6.0parse html tag string, that only include string content "0", but jsoup return null, I understand...
examply:
String html = "<span>0</span>";
Document doc = Jsoup.parse(html);
Elements eles = doc.getElementsByTag("span");
Element span = eles.get(0);
System.out.println(span.hasText());//false
System.out.println(span.ownText());//null, but I hope the result is "0"
It's why?
* * *
Answer:
It should be a bug, binary_runner says jsoup-1.3.3 works well, I test jsoup-1.5.2 works well too. so, I decide use jsoup-1.5.2 .
Thanks binary_runner! | This is a bug in jsoup `1.6.0` caused by an incorrect null check in the new HTML parser implementation.
I have fixed the issue and it will be available in `1.6.1`, which I'll in the next couple of days. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "java, jsoup"
} |
Liferay 6.2 bundled with jBoss connect to SQL Server 2012 with Windows Authentication
I was asked to install Liferay 6.2 bundled with jBoss to connect to SQL Server 2012. I don't understand why Liferay cannot connect to the database with the JDBC URL as follows:
jdbc:jtds:sqlserver://DBSERVER/lportaldb;instance=lportal_DSN;useNTLMv2=true;domain=GLS.com.au
where,
* DBSERVER: server name
* lportalDB is database name
* lportal_DSN is data source name that I created in Control Panel/Administrative Tools/ODBC Data Sources (64-bit) and successfully tested the connection.
I've tried adding and removing some properties; such as useNTMLv2, I also put ntlmauth.dll to C:\Windows and C\Windows\SysWOW64 but the Liferay portal is still not be able to connect to the database. Any idea on this is appreciated. | There was check to the connection, LDAP, AD, DNS to the DBSERVER by IT group that fixed this issue. Regarding to the DB, it was changed to use SQL Server Authentication. The following JDBC URL was used with user sa and password:
`jdbc:jtds:sqlserver://DBSERVER/lportaldb;instance=lportal_DSN;` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "sql server, jboss, liferay"
} |
Execute Python Script from google spreadsheet
Is it possible to run a python script from GoogleSheets(GS)? The idea is that I press a button in GS and the python script runs. I found some older posts about this, like the idea to run it from Google Cloud, but maybe there is a simpler solution in the meantime? | Your Python script will have to be run from the cloud. See URL Fetch Service. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "python, google sheets"
} |
ImportError: No module named 'tensorflow.core'
After installing tensorflow-gpu using pip3, I am getting the following error when trying to `import tensorflow as tf`
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/dlpda/.local/lib/python3.5/site-packages/tensorflow/__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/dlpda/.local/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
ImportError: No module named 'tensorflow.core'
Although I am able to import successfully in a virtualenv, but not outside.
How should I resolve this problem to be able to import tensorflow? | The problem may be with packages installation directories like some packages are installed in home and some in /usr/. I suggest you to remove all the packages in home directory by finding them in ~/.local/lib/python3.5/site-packages and reinstall then with super user privileges. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 9,
"tags": "python, python 3.x, tensorflow"
} |
Blow-ups followed by contractions
Let $S$ be a **minimal** , non-singular complex projective surface. $\widehat S$ is the surface obtained by $r$ blow-ups of $S$ at the points $x_1,\ldots,x_r\in S$. Clearly $\widehat S$ contains exactly $r$ (-1)-curves and now if we contract all these curves we obtain another minimal surface $X$ such that $K^2_X=K^2_S$. Under this hypothesis can we conclude that $S$ and $X$ are isomorphic?
I suppose that the answer is **no** , because in this way I simply find two minimal models of $\widehat S$.
What do you think? | The statement
> Clearly $\widehat S$ contains exactly $r$ (-1)-curves
is false. For example, blow up $\mathbf P^2$ in 2 points. Then the exceptional curves are (-1)-curves, but there is _another_ (-1)-curve on this surface: namely the proper transform of the line that went through the two points. If we contract just that last (-1)-curve, we get the minimal surface $\mathbf P^1 \times \mathbf P^1 \neq \mathbf P^2.$ This is the point about non-uniqueness of minimal models for Kodaira dimension $-\infty$: blowing up can create **more** (-1)-curves than just the exceptional curves.
On the other hand, if the (-1)-curves you contract are exactly the exceptional curves of the blowups, then **yes** , certainly $S$ and $X$ will be isomorphic: contracting the curves is just undoing what you did when you blew up the points. | stackexchange-math | {
"answer_score": 3,
"question_score": 3,
"tags": "algebraic geometry, surfaces, minimal surfaces, birational geometry"
} |
Casting youtube from app to PC's browser
I know it's possible to stream youtube from an app to a Smart TV. Since I have a laptop connected to my TV I'd like to do something similar. I like to cast from my Iphone's youtube app to my laptop (running WIN7 with youtube in the browser).
Is this possible? | Surf to youtube.com/tv#/ and the browser will "act" as a TV app. This way you can cast from apps to the browser. | stackexchange-superuser | {
"answer_score": 2,
"question_score": 1,
"tags": "youtube, video streaming"
} |
CI active record, escapes & order_by datetime column
I've noticed that when ordering by a datetime column in CI with active record, it's treating the column as a string, or int.
Example:
$this->db->limit(12);
$this->db->where('subscribed',1);
$this->db->join('profiles','profiles.user_id=users.id');
$this->db->where('active',1);
$this->db->select('users.thumbUpload,users.vanity_url');
$this->db->select('users.created_on as time');
$this->db->order_by('time');
$query = $this->db->get('users');
This is where users.created_on is a datetime field. Firstly, is it because active record is rendering `time` escaped, or is it something else? And if it is, can I prevent the escaping on order_by somehow?
Also, stackoverflow, please stop autocorrecting 'datetime' to 'date time'. It's annoying.
Cheers! | When you set second argument as false, function wont check and escape string. Try this
$this->db->select('users.created_on as time', FALSE);
Or for you query use
$this->db->order_by('users.created_on', 'DESC'); //or ASC
And for complex queries
$this->db->query("query"); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "sql, codeigniter, datetime, activerecord, sql order by"
} |
How do I get rid of the ^I symbols in vim?
Here is a screen shot of some code in Vim. Those `^I` symbols annoy me. If they are tabs, why doesn't Vim just display them as whitespace as expected? I have the following in my `.vimrc`:
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
!enter image description here | The
:set list
command causes `vi` or `vim` to display tab characters as `^I` and end-of-line as `$`.
Type:
:set nolist
to turn it off. (It should be off by default unless you've set in your `.vimrc`.)
< | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "vim"
} |
Tunnelling AMQP over HTTP?
Are there any standard libraries or packages (preferably python-oriented) for providing HTTP gateways to AMQP-based applications?
For e.g. I have a an application which uses AMQP for communication between hosts, and would like a migration path for situations where the network may not permit traffic other than HTTP. | AMQP is a TCP-based protocol, so if you take some TCP proxy code like this Activestate recipe for Python, and modify it to forward data over port 80, then that will probably do it.
However if you have to go througa firewall that looks at the packets and recognizes the HTTP protocol, you would need to actually tunnel TCP over HTTP like in this Activestate recipe. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "python, http, amqp"
} |
Evaluate the flux integral: $\int_S F \cdot \hat n dS$
Evaluate the flux integral:
$\int_S F \cdot \hat n dS$
where $F = <y,x,z>$, S is the surface $z = 1- x^2 - y^2$ for $0 \leq z \leq 1$ and $n$ is the upward unit normal to the surface.
Now I know what the shape looks like and so deduce that the unit normal to the surface is:
$\hat n = <2x, 2y, 1>$
And so the surface integral becomes:
$\int_S <y,x,1-x^2-y^2> \cdot <2x, 2y, 1> = \int_S (4xy + 1 - x^2 - y^2) $
However from this point I am unsure how to proceed. We havent been thought divergence theorem.
Is there a way to convert the dS to a dA? Also I am unsure how it can be dS (i.e. d(w.r.t a surface) when there is only one integral? (i.a.w my question is why is there a surface 'd' when there is only a single integral since surfaces usually require 2)?
Any help is much appreciated. Also we haven't been thought the divergence theorem. Is there another way to do this? Perhaps by changing of variables or something? | The only thing you need is to find bounds of integration over $x$ and $y$.
if $z=0\to x^2+y^2=1$ that is a disc of radius one. If $z=1\to x^2+y^2=0$ that implies $x=0=y$. So the bounds of integration over $x$ is
$$x\in [-\sqrt{1-y^2}, +\sqrt{1-y^2}]$$
After performing integration over $x$, then perform the integration over $y$ for the bounds $$y\in [-1,1]$$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "integration, vector analysis, surface integrals"
} |
Is a new build required everytime I make a change to the code?
I am working on a project that has around a hundred different files (.cpp & .h), and it requires around an hour to build the entire project on MSVC 2008, suppose that I now make a change to any one file, do I need to build the entire project once again, right from the beginning, or is there a way out ?
I know it is very very noob like, but I am wasting a lot of time, hence I was wondering | The short answer: It depends.
The long answer: It depends on your source code dependencies.
For example, if every class knows about every other class in the project, then every time you make a change to one, you probably have to recompile the other.
It also depends on linkage. If you link everything into one binary file, it's also likely to compile everything again. A better way would be to separate to different shared libraries (DLLs), or at the very least into separate object (.o) files.
But then (in the latter case) you might need to tinker with it to see that it doesn't recompile all object files when you just need to recompile one and link them all together again.
But then again, maybe the linking process takes a while too. You basically need to experiment with that.
On a final note... An **hour** for building **~100 files**? That's way, _way_ too much, unless you're running on a _really_ old machine. Or unless each file contains tens of thousands of lines. | stackexchange-softwareengineering | {
"answer_score": 7,
"question_score": 6,
"tags": "development process, visual studio, builds"
} |
websocket stomp in spring over sockjs redirects to http protocol while the origin is https in pivotal web services
I am developing a spring web chat application using stomp and `sockjs`. I uploaded the application in pivotal web services. I understand that it uses a different port i.e. 4443. Once I run the application the `websocket` losts connection to undefined
The following error comes into the console: Opening Web Socket...
WebSocket connection to
`'wss://homeworkpavilion.cfapps.io:4443/chat/193/dqu_2erz/websocket' failed: Error during WebSocket handshake: Unexpected response code: 302`
POST 500 (Internal Server Error)
POST 500 (Internal Server Error)
Whoops! Lost connection to undefined
Pls help, this stuff is reaaaalyy bugging me | There is no permission to redirect to different port. You can bypass this restriction by setting all origins to allowed when registering your stomp endpoints. I want to point out, that this is a very bad solution. You should take advantage of proxies, but I lack information here to help you with that.
Here is the code you might find useful:
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/your_endpoint").setAllowedOrigins("*").withSockJS();
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "spring, websocket, stomp, sockjs, pivotal web services"
} |
checking if a matrix is diagonally dominant in python
I know that my code is wrong because np.sum(abs(X),axis=1)) also sums the diagonal value, therefore my code will always return 'NOT diagonally dominant'. I have tried putting '-np.diag(X)' but i get an error message. Thank you in advance!
import numpy as np
A=np.array([[ 40., 7., 5.],
[ 5., 90., 7.],
[20., 7., 50.]])
def dd(X):
Sum_values_in_given_row = np.sum(abs(X),axis=1)
if np.all(((abs(np.diag(X)))) >= np.sum(abs(X),axis=1)):
print 'matrix is diagonally dominant'
else:
print 'NOT diagonally dominant'
return
dd(A) | To determine if a matrix is diagonally dominant, you have to check if the sum of the row coefficients **excluding** the diagonal coefficient is larger than the diagonal coefficient. Obviously you take the absolute values as part of the test. You are not doing this and you are including the diagonal coefficient instead. As you mentioned, you should subtract this the summation of each element with the diagonal coefficient to ensure the check is correct, but you didn't put that in your code for some reason:
def dd(X):
D = np.diag(np.abs(X)) # Find diagonal coefficients
S = np.sum(np.abs(X), axis=1) - D # Find row sum without diagonal
if np.all(D > S):
print 'matrix is diagonally dominant'
else:
print 'NOT diagonally dominant'
return
Note that the code takes advantage of broadcasting to facilitate subtracting the row sums with the corresponding diagonal coefficient. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "python, numpy, matrix, linear algebra"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.