INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Norm of an Ideal.
Let Let $K = \mathbb{Q}(\sqrt{5})$ and $\alpha = \frac{1+\sqrt{5}}{2}.$ How do we describe the ideal $I$ for ring of integers $\mathcal{O}_K$, given by $I = \\{ (2+\alpha) a + (1+ 3 \alpha) b : a, b \in \mathbb{Z}\\}$ and how do we calculate norm of $I.$
I tried writing $I = \\{ (2a+b) + (a+ 3b)\alpha : a, b \in \mathbb{Z}\\}.$ Now in ring $\mathcal{O}_K/I$ we have $I = 0.$ So $(2a+b) + (a+ 3b)\alpha = 0$ and since $1,\alpha$ are linearly independent we have $2a+b = 0$ and $a+ 3b=0.$ Which gives $a=b=0.$ I dont know what to interpret from this or even I am doing right or wrong. Help please. | A useful fact here is that $\mathcal O_K$ is a PID. This means that $I$ can be written in terms of one generator.
As you've written it, $I$ consists of integer combinations of $2+\alpha$ and $1+3\alpha$, so as an ideal, it is generated by these elements. Denote this fact using the notation $$I = \langle 2+\alpha, 1+3\alpha\rangle.$$
Observe that $$\alpha^2-\alpha -1 = 0$$ and that $$\alpha(2+\alpha) =2\alpha + \alpha^2 = 2\alpha + (\alpha + 1) = 1+3\alpha.$$
So $I = \langle 2+\alpha\rangle$, and hence the norm of the ideal $I$ will just be the $N_{K/\mathbb Q}(2+\alpha)$. | stackexchange-math | {
"answer_score": 6,
"question_score": 3,
"tags": "algebraic number theory"
} |
Why does boost::filesystem::path::string() return by value on Windows and by reference on POSIX?
From boost/filesystem/path.hpp:
# ifdef BOOST_WINDOWS_API
const std::string string() const
{
[...]
}
# else // BOOST_POSIX_API
// string_type is std::string, so there is no conversion
const std::string& string() const { return m_pathname; }
[...]
# endif
For wstring() it is exactly the other way around - returning by reference on Windows and by value on POSIX. Is there an interesting reason for that? | On Windows, `path` stores a `wstring`, since the only way to handle Unicode-encoded paths in Windows is with UTF-16. On other platforms, the filesystems handle Unicode via UTF-8 (or close enough), so on those platforms, `path` stores a `string`.
So on non-Windows platforms, `path::string` will return a const-reference to the actual internal data structure. On Windows, it has to generate a `std::string`, so it returns it by copy.
Note that the File System TS bound for C++17 does not do this. There, `path::string` will always return a copy. If you want the natively stored string type, you must use `path::native`, whose type will be platform-dependent. | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 7,
"tags": "c++, boost, boost filesystem"
} |
Copy formatted tabbed table trimmed in Excel
I have a text editor logbook and need to copy the contents into an Excel sheet.
Logbook content:
01.01.2000
----------
Entry One.\t\t\t\t\t8 Hours
Entry Two.\t\t\t\t\t20 Minutes
If I paste this into Excel, the content `8 Hours` is miles away from the `Entry One.` Cell. How can I correctly copy this content so that I have only two cells by each other?
Excel goal example:
|01.01.2000| |
|----------| |
|Entry One.|8 Hours |
|Entry Two.|20 Minutes| | When you paste, excel converts unquoted tabs into column breaks and unquoted line breaks into row breaks. This is why if you directly paste in content where a quote immediately follows (a) a line break, (b) a tab, or (c) the beginning of the file, your spreadsheet may not behave as expected.
To solve this, you'll want to replace all the extra tabs with a single tab. To do this, go into Replace (`Ctrl`+`H` on Windows). Type in `\t{2,}`† in the _Find_ box and `\t` in the Replace box. Make sure _Search Mode_ is set to _Regular expression_ and press `Replace All`.
* * *
† `\t+` would work as well, but it'd be slower on very large files that actually have single spaces. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "microsoft excel, copy paste"
} |
capybara visit doesn't work
describe Inventory::Export do
describe "export page" do
it "check to show export page" do
user = FactoryGirl.build(:admin)
activity_type = FactoryGirl.create(:activity_type)
visit "/users/sign_in"
fill_in "user_Login", :with => user.Login
fill_in "user_password", :with => user.password
click_button "user_submit"
visit "/admin/inventory/exports"
save_and_open_page
end
end
end
The code at
visit "/admin/inventory/exports"
doesn't affect to result of
save_and_open_page
And I get the page which redirected after authorization | try
visit admin_inventory_exports_path
check your routes for actual path with `rake routes`. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "ruby on rails 3, rspec, capybara"
} |
Access website localstorage data from a Chrome Packaged App
I'm building a packaged app that's meant to interact with a website I wrote to get its localStorage data and send it to other devices using bluetooth. This seems like it would be easy with an extension, however with an extension I would not have access to chrome's bluetooth API. I'm not sure this is even possible, but if it is, how would I go about accessing and communicating with the website using the packaged app? | The answer is that you can't. The two local storage repositories are distinct ("sandboxed"), and one can't access the other.
If this website wants to make data available to any other website, or to a Chrome App, it should put it someplace on the server, accessible via a URL, and then the Chrome App can easily access it. But, there's no way to effect such sharing with the data on the client.
Two Chrome Apps can share data locally, because they can access the local file system. However, web apps (HTML/JavaScript loaded from a server) can't access the local file system, only a sandboxed file system. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "google chrome, google chrome extension, bluetooth, local storage, google chrome app"
} |
Want to put a 4.6 directory in Core Project
I have one of my first .net core projects and need to include a subdirectory off my website with NopCommerce with is .net 4.6.
How can I put this in say a shopping directory off the main directory?
I'm using the non-source version of nop commerce so I can't just import a new project into my existing project. | Until `NetStandard2.0` comes out (Later this year) and you use it's compatibility shims you can't.
If you can't wait for `NetStandard2.0` you will need to make this NopCommerce section of your site a entirely different project, you then need to deploy it as a child application under your site. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": ".net, asp.net core, asp.net core mvc, .net core, nopcommerce"
} |
Laplace Transform of a Fourier Series
If I have a Fourier series, how can its Laplace transform be determined?
Is it correct to determine the Laplace transform of each single term, or should I proceed in some other way? | The Laplace transform is a linear integral operator, so the identity $$ \left(\mathcal{L}\sum_{n\geq 1} f_n(x)\right)(s) = \sum_{n\geq 1}\left(\mathcal{L} f_n\right)(s) $$ holds if the hypothesis of the dominated convergence theorem are met. If $f_n(x)=a_n \sin(nx)$ then $\left(\mathcal{L} f_n\right)(s)=a_n\cdot\frac{n}{n^2+s^2}$ is bounded by $\min\left(\frac{|a_n|}{n},\frac{|a_n|}{2s}\right)$ in absolute value for any $s>0$. In particular $\\{a_n\\}_{n\geq 1}\in \ell^1\cup \ell^2$ is sufficient to ensure that the above identity holds.
For instance, we are allowed to state $$\mathcal{L}(|\sin x|)(s) = \frac{2}{\pi s}-\frac{4}{\pi}\sum_{n\geq 1}\frac{s}{(4n^2-1)(4n^2+s^2)}=\frac{\coth\frac{\pi s}{2}}{1+s^2}. $$ | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "fourier series, laplace transform"
} |
The person who requests something is called...?
Let's say that I have a collection of books, and someone requests one of them. How would that person would be called, in one word?
The only thing I have been able to come up is "pretender", but does not sound right, for some reason. | Yet another option would be _**applicant**_.
> **noun**
>
> 1. a person who applies for or requests something; a candidate:
> _an applicant for a position._
>
Reference:
< | stackexchange-english | {
"answer_score": 2,
"question_score": 1,
"tags": "single word requests"
} |
Ruby on Rails: Class.where(...) but return just 1 record?
I got a table named users, and I'm doing
array = User.where("username=?", username)
to get the user for a specific username.
My minor gripe is that this returns an array, and I have to do `array[0]` but there should always be just 1 user returned.
Is there anyway, syntactically to specify that I expect just 1 record, and it shouldn't be an array returned, just the user? | You can limit it to one result:
User.where("username = ?", username).first
However, you might just want to use the dynamic `find_by_` method:
User.find_by_username(username) | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 1,
"tags": "ruby on rails"
} |
Is there a way to use JMS in a JUnit test?
I want to run a JUnit test with usage of JMS. Is it possible to have a JUnit test use JMS outside of an Application Server like JBoss or a CDI container? | Provided that sending and consuming the message is completely decoupled from JMS, you could mock it.
For example: You can have a class that implements an interface like "IMyClassSender". In real code (non junit), all this class does is submit the message to JMS. In junit, implement IMyClassSender with a class that takes the input and instead if submitting to JMS, it passes it to your consumer class.
Alternatively, if you are using active mq: < | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "java, junit, jboss, jms, cdi"
} |
When hovering one DOM element display another
With CSS/LESS, is it possible somehow to display (it's default is "display: none;") `sidebar-submenus`, when hovering `sidebar-category`?
I have this HTML:
<div id="sidebar">
<div id="sidebar-wrapper">
<div id="sidebar-categories">
<div id="menuDashboard" class="sidebar-category sidebar-category-top active">
<i class="fa fa-tachometer"></i>
</div>
</div>
<div id="sidebar-submenus">
</div>
</div>
</div>
I have this LESS:
body {
&.sidebar-collapsed {
#sidebar-submenus {
display: none;
}
#sidebar-categories:hover {
/*#Display sidebar-submenus with block somehow..? */
}
}
} | Try:
#sidebar-categories:hover {
+ #sidebar-submenus { display:block; }
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "javascript, html, css, less"
} |
Add Checkbox Column into GridControlEx
What I want to do is to add a column that filled by checkboxes and placed on the left side of the grid. The grid rows is binding from a query. I have this code:
string query = "SELECT TransID, Company, Period, EmpID, Employee FROM Trx"
DataTable tblClaim;
tblClaim = DB.sql.Select(query);
tblClaim.Columns.Add("Process", typeof(bool)); //I want this column placed on the left side of the grid
gcxClaim.ExGridControl.DataSource = tblClaim;
What I get from that code is, the checkbox is disabled and the column is placed on the right side. While I tried to place `tblClaim.Columns.Add("Process", typeof(bool));` before `tblClaim = DB.sql.Select(query);`, it got error. How can I do that? Thanks. | It works by below code:
string query = "SELECT CAST(1 AS BIT) AS Process, TransID, Company, Period, EmpID, Employee FROM Trx"
tblClaim = DB.sql.Select(query);
gcxClaim.ExGridControl.DataSource = tblClaim;
gcxClaim.ExGridView.OptionsBehavior.Editable = true;
for (int i = 0; i < tblClaim.Columns.Count; i++)
{
gcxClaim.ExGridView.Columns[i].OptionsColumn.AllowEdit = false;
}
gcxClaim.ExGridView.Columns["Process"].OptionsColumn.AllowEdit = true; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, checkbox, grid"
} |
MySQL percona 5.6 to MySQL 5.5 replication
Scenario 1 I am having a MySQL DB on 5.5 which is compliance, So need to upgrade it to MySQL 5.6. while doing this we see that 5.6 is running slow, were as it runs perfectly on 5.5 backup.
Scenario 2 We have installed 5.6 percona MySQL on one system & just want to know if we can replicate on MySQL 5.5 using MySQL replication.
Please advice what issue will be faced in this 2 scenario. any suggestion is acceptable. | It isn't clear what you're asking in scenario 1.
As for scenario 2, you can have a slave that's a higher version than the master, but not vice-versa. From the documentation:
> MySQL supports replication from one release series to the next higher release series. For example, you can replicate from a master running MySQL 5.5 to a slave running MySQL 5.6, from a master running MySQL 5.6 to a slave running MySQL 5.7, and so on. | stackexchange-dba | {
"answer_score": 0,
"question_score": 0,
"tags": "mysql, replication, mysql 5.5, upgrade, percona server"
} |
How can I get OS X to challenge me for password after sleep?
I'm running version 10.6.8. Where do I go to enable password challenge after sleep? | Go to System Preferences > Security and check "Require password"
* There are several selectable time delays if immediate locking isn't what you prefer.
!enter image description here | stackexchange-apple | {
"answer_score": 8,
"question_score": 1,
"tags": "security, sleep wake"
} |
AES encrypt secret key with plaintext
We need to be able to retrieve password. Hashing is one-way, we can't do that.
So we ended up using AES.
We want to know if the following schema is safe or not. I am only familiar with modulo PK encryption scheme, but I can't figure out the safeness here:
1. p = encrypt(password, newIV, newSecret)
2. s = encrypt(newSecret, newIV, password)
We basically encryp the newSecret with user password. So whenever retrieval is needed, user must supply the password and we then decrypt it and pass it to the user.
Is there any `undo` modulo thing like we would find in RSA-kind encryption/decryption scheme? | Since you only need one account to be able to access the credentials for a second legacy system, I would recommend that you use a chain. The user password for your system should not be reversible and the encrypted credentials should not be available without the user's password. You can store the encrypted credentials with a symmetric record key that can be protected by both the user's password for your system and, if necessary, an administrative private key to allow account recovery. This would probably be the best you can do since it would not allow the user's legacy account to be decrypted without the user's password.
(Basically just treat the legacy credentials as secured data. There should be no difference.) | stackexchange-security | {
"answer_score": 3,
"question_score": 1,
"tags": "encryption, aes"
} |
Smart way to search a word in a list
I want to make a python program that is able to search through a list of words in a smart way.
Let's say that I have a list like this:
ex_list=["Red Apples", "Green Apples", "Bananas", "Yoghurt", "ApplePie", "Milk", "Pineapple"]
And the word I want to search is:
search_word = "Apple"
The way I want the program to work is so that it returns "Red Apples", "Green Apples", "ApplePie" and "Pineapple". (Since, they all contain apple)
How do I achieve that?
I basically want it to return everything that has "a", then "p", then "p", "l", and "e". I don´t care what is in front(like greenapple) or in the back(like applePie). | One-liner with filter:
list(filter(lambda x: search_word.lower() in x.lower(), ex_list))
Or with list comprehension:
[x for x in ex_list if search_word.lower() in x.lower()]
Just filter your list by condition that `ex_list` element contains `search_word` (case insensitive).
Result:
['Red Apples', 'Green Apples', 'ApplePie', 'Pineapple'] | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "python, string, list"
} |
How to call code behind function from label.text in asp.net
I am trying to call a function defined in code behind from Label.Text but it's not working. Here is the code... code in .aspx file
<asp:Label runat="server" Text='<%# GetPagingCaptionString() %>' ID="pagenumberLabel"></asp:Label>
code block from code behind
public string GetPagingCaptionString()
{
int currentPageNumber = Convert.ToInt32(txtHidden.Value);
int searchOrderIndex;
if (int.TryParse(Convert.ToString(Session["searchOrderIndex"]), out searchOrderIndex))
{
return string.Format("{0} to {1} orders out of {2}", (currentPageNumber * 20) + 1,
(currentPageNumber + 1) + 20, GetItemsCount(searchOrderIndex.ToString()));
}
return String.Empty;
}
Can anyone tell me what's wrong here. | Unless you're using a template based control (such as `<asp:Repeater>` or `<asp:GridView>`) then you can't use inline code-blocks such as you have within a server-side control.
In other words, you can't have `<%=%>` blocks within the attributes of server-side controls (such as `<asp:Label>`). The code will not be run and you will find the code is actually sent as part of the rendered HTML. The exception is for databinding controls where `<%#%>` code-blocks _are_ allowed.
You're better off in this situation setting the `.Text` property in the code-behind itself.
For instance in your page-load function....
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
pagenumberLabel.Text = GetPagingCaptionString();
}
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "c#, asp.net, eval, code behind"
} |
How to cache Windows docker images on Linux?
What is the best way to cache Windows container images on a Linux system? Setting up a registry mirror won't work because pulling a Windows image from Linux gets me a
`no matching manifest for linux/amd64 in the manifest list entries`
One option would be setting up the registry mirror in a Windows inside a Virtual Machine, but I hope there are better solutions. | The image architecture that Docker attempts to pull is determined by the client, not by the server. You can run your registry server under Linux and perform you `docker push/pull` from Windows. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "docker, docker registry, docker for windows, windows container, container image"
} |
Font Awesome Icons not displaying
There are lots of threads about this, I know. I spend the last 2 days trying all the solutions in the other questions but still can't fix it.
As you can see here: < font awesome icons aren't showing up. They should show up on the left and bottom on the facebook and twitter social share button. | Why the `-ism` at the end? For instance, on the Facebook icon, the class should just be `fa fa-ism fa-facebook` and it'll work just fine. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "css, font awesome"
} |
What are the high pranic foods according to Yogic culture?
In the following video Sadhguru says Ash Gourd known as Kooshmanda. He says that is a high pranic food. That is why it is also used in sacrifices where they break it by throwing it to ground.
<
What are the other high pranic foods according to yogic culture or ancient Hindu scriptires? Is this somehow related to breaking of coconuts?
Please note: High pranic food should not be confused with Sattvik food. As it may or may bktbe same. If it is same plase give reference for the same. | I have the answer to your question. Some high positive Pranic foods are ALL fresh fruits and vegetables (expect onions and garlic of course), along with nuts, dairy products(except eggs). A very important part of the Pranic diet is herbal teas. Along with sweet spices such as cinnamon, cardamon, mint, basil, turmeric, ginger, cumin, and fennel seeds. And finally we some plant based oils such as sesame, sunflower, and olive oil. I hope this answers your question. | stackexchange-hinduism | {
"answer_score": 0,
"question_score": 1,
"tags": "yoga, food, yogi, sadhguru jaggi vasudev, prana"
} |
Have a popupmenu appear on a popupmenu on right-click
I have a wx Popupmenu appear when I left-click on a toolbar `LabelTool`. I already have a binding to have a handler run when I left click an item in the menu, but I want another popup menu to appear when I right click an item in the original popup menu. I've already tried binding it to `wx.EVT_RIGHT_DOWN` but it doesn't do it. Whenever I try right clicking on a menu object, it seems it still calls the `wx.EVT_MENU`, which calls the same handler as a left-click would. How would I implement this? | As far as I can tell, that is not supported. Besides, no user is going to expect that they need to right click on a context menu anyway. You should rethink your design so it's more intuitive. Perhaps by using a sub-menu instead of a secondary popup menu | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "python, wxpython, right click, wxwidgets, popupmenu"
} |
Which process knows what applications are open?
I'm trying to find the process that takes care of what applications are open. For example, an app I closed stills shows as open in Dock and Force Quit, so I want to kill/restart that process (which takes care of what processes are open). Logging out would solve it too, but I can't right now. Restarting Dock does not work.
For example, I'm 100% sure I have killed Safari, using kill -9, but it still shows up in the Dock and in Force Quit. The process is definitely killed, but the Dock and Force Quit haven't got that, because the process that lists which applications are open have frozen. I want to know the name of that process. | The process which keeps track of all processes is `launchd` (PID 1) which is the first process launched when the OS starts. There is no standard way of killing it (technically speaking sending the `TERM` or `KILL` signal will not kill it), if you could it would immediately lead to a reboot.
If Finder still shows an application running despite it being killed, you can also try `killall Finder` in Terminal to restart Finder without reboot. | stackexchange-apple | {
"answer_score": 1,
"question_score": 2,
"tags": "macos"
} |
Can I farm underground in Minicraft?
I'm not sure if it cares that there's no sunlight or not; I haven't actually tried yet though because I never seem to have any seeds to spare. | According to this reddit post, it is possible.
This is the image that was posted as proof. !enter image description here | stackexchange-gaming | {
"answer_score": 4,
"question_score": 4,
"tags": "minicraft"
} |
Pandas get rows by its values from dataframes
I have a reference dataframe:
ex:
time latitude longtitude pm2.5
0 . 0 0 0
1 . 0 5 1
......
And I have a query with
ex:
time latitude longtitude
0 . 1 3
1 . 0 5
.......
I want to get the pm2.5 which matches the rows in query.
I have used the iteration of rows but it seems very slow.
predications_phy = []
for index, row in X_test.iterrows():
Y = phyDf[(phyDf["time"] == row["time"]) & (phyDf["latitude"] == row["latitude"]) & (phyDf["longtitude"] == row["longtitude"])]
predications_phy.append(Y)
What is the efficient and correct way to get the rows? | Given reference dataframe `df1` and query dataframe `df2`, you can perform a left merge to extract your result:
res = df2.merge(df1, how='left')
print(res)
# time latitude longtitude pm2.5
# 0 0 1 3 NaN
# 1 1 0 5 1.0
Loops are highly discouraged unless your operation cannot be vectorised. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "python, python 3.x, pandas, scikit learn"
} |
Escape react-router scope
I am using react-router in my application. I have a facebook link . But clicking on it, will append the link to my localhost as localhost:3000/www.facebook.com. How do I make it such that it goes out of react-router's scope? | > Please specify the HTTP or HTTPS protocol with www
Please use like below if you are getting the URL from context or state:
<a href={this.context.myurl} target="_top">Facebook</a>
<a href={this.state.myurl} target="_top">Facebook</a>
use `target="_blank"` in case you want to open it in a new tab.
Example:
<a href=" | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "reactjs, react router"
} |
Split a string using regular expressions in PHP
I have this problem in out project
$line = substr($line,8);
$LIT_YARN = '".*"';
$VAR_NAME = '[A-Za-z][a-zA-Z0-9]*';
$TEMP2 = "/($LIT_YARN|$VAR_NAME)/";
$line = trim($line);
preg_match_all($TEMP2,$line,$params);
var_dump($params[0]);
the simple input is
" "askdj" "asjdk" "asdasndw" "
the complicated input is
" "asd" Y "asd" X "
variables can also be inputted
simple input resulted to a single string
params[0] => "askdj" "asjdk" "asdasndw"
I was expecting like this
params[0] => "askdj"
params[1] => "asjdk"
params[2] => "asdasndw"
complicated input should result to
params[0] => "asd"
params[1] => 'Y'
params[2] => "asd"
params[3] => 'X'
including the X and Y which are variables
how should i do the trick? | This should do the trick:
`preg_match_all('/"([A-Za-z0-9]+)"/', '" "askdj" "asjdk" "asdasndw" "', $Matches))`
You want to match a quote, then at least one alphanumeric character, then an ending quote. Put the alphanumeric characters in parentheses to capture the output and put it in `$Matches`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "php, regex, string"
} |
Why is Float::INFINITY == Float::INFINITY in Ruby?
In mathematics 2 infinities are not equal, nor greater than or less then. So what gives?
In irb, Float::INFINITY == Float::INFINITY (tested in ruby 1.9.3) | In more technical terms, it all comes down to the IEEE 754 standard for floating-point arithmetics.
> The IEEE 754 standard does implicitly define Infinity == Infinity to be true. The relevant part of the standard is section 5.7: "Four mutually exclusive relations are possible [between two IEEE 754 values]: less than, equal, greater than, and unordered. The last case arises when at least one operand is NaN."
>
> Between any pair of floating point values exactly one of these four relations is true. Therefore, since Infinity is not NaN, Infinity is not unordered with respect to itself. Having one of (Infinity < Infinity) and (Infinity > Infinity) be true wouldn't be consistent, so (Infinity == Infinity).
This was taken from < | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 6,
"tags": "ruby, math"
} |
htaccess rewrite rule for javascript file with multiple periods
I'm looking for a rewrite rule that will handle a request such as
js/mysite/jquery.somelibrary.js or
js/mysite/jquery.validate.js or
js/mysite/somejsfile.js
What I have written so far handles the last case `RewriteRule ^js/([a-z_]+)/([^\/.]+)\.js$ /site_specific_js.php?site=$1&file=$2 [QSA,L]`
but on the first two, all that gets rewritten for the file is **jquery** and everything else gets ignored
Any help is appreciated. | All things is on te dot `([^\/.]+)`, just remove it
RewriteRule ^js/([a-z_]+)/([^\/]+)\.js$ /site_specific_js.php?site=$1&file=$2 [QSA,L]
or as in the $1
RewriteRule ^js/([a-z_]+)/([a-z0-9\.]+)\.js$ /site_specific_js.php?site=$1&file=$2 [NC,QSA,L] | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "jquery, regex"
} |
Why aren't my CTreeCtrl checkboxes checking?
I've got a MFC CTreeCtrl stuck in a dialog with the TVS_CHECKBOXES style turned on. I get checkboxes next to all my tree items fine. In OnInitDialog I set the checked state of some of the items using CTreeCtrl::SetCheck but none of the items in the tree are checked when the tree is displayed. SetCheck is returning TRUE. Checking items with the mouse works fine. Anyone encounter this before? | Figured out what the problems was. I was setting the TVS_CHECKBOXES style in the visual studio resource editor. Apparently this causes the problem I was having with the initial checks. Instead you have to do
m_nodeTree.ModifyStyle (TVS_CHECKBOXES, 0);
m_nodeTree.ModifyStyle (0, TVS_CHECKBOXES);
before filling the tree in OnInitDialog. Once I did this everything worked fine. | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 5,
"tags": "c++, windows, mfc"
} |
What is this form of mass conservation equation?
I found the following equation of conservation of mass (continuity) in "Computational Fluid Dynamics Vol.III" by Hoffmann:
$$ \frac{\partial \rho}{\partial t} + \frac{\partial}{\partial x}(\rho u)+ \frac{\partial}{\partial y}(\rho v) + \frac{\alpha}{y}(\rho v) = 0$$
The author refers to Vol. II of the book for the origin of this equation, however, I don't have it.
So, has any one encountered this form of continuity equation? (regarding the $\frac{\alpha}{y}$ part of course) and what do those terms mean?. | The only thing I can think of is that this is done in cylindrical coordinates: $$\partial_t \rho + \partial_x \rho u_x + \frac{1}{r}\partial_r r \rho u_r=0$$ Using the product rule the last term can be written as: $$\frac{1}{r}\partial_r r \rho u_r=\partial_r \rho u_r + \frac{1}{r}\rho u_r$$
Update: The reference in vol. ii indicates that my feeling about this was correct. That term is introduced to allow planar flow for $\alpha=0$ (so normal continuity in Cartesian coordinates) and axisymmetric flow for $\alpha=1$ (hence the cylindrical coordinates). Some textbooks sacrifice clarity for brevity. | stackexchange-physics | {
"answer_score": 4,
"question_score": 2,
"tags": "fluid dynamics, navier stokes"
} |
Hiding Text in Word (particularly tables)
I've been working on a document that has a number of hidden sections that can be made visible using check boxes (and VBA). Most of this works fine including hiding Tables, Pictures, Formatting and Text using Range.Font.Hidden = True.
My problem lies with leaving a table hidden, saving the document and then re-opening the document.
The document saves and closes fine, but when reopening the Document the text for the table stays hidden but the table gridlines and spacing are displayed, giving the look of a strange but empty table.
Does anyone know of a way to avoid this problem or have any advice? | After trying a number of different things and even though I have other sections that contain tables that work fine, I have ended up converting the tables back to text which makes them work fine.
It is annoying that I can't seem to find the issue, but the information works out ok just as normal text. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "vba, ms word, visibility"
} |
About Manipulate : How to make this work properly?
Manipulate[
Plot[PDF[NormalDistribution[mu, sigma], x], {x, -4*sigma, 4*sigma}],
{mu, -10, 10}, {sigma, 0, 10}
]
I got the following error:
!enter image description here | For the code to work without error messages, `signa` needs an initial value, for instance:
Manipulate[Plot[PDF[NormalDistribution[mu, sigma], x], {x, -4*sigma,
4*sigma}], {mu, -10, 10}, {{sigma, .5}, 0, 10}]
Alternatively, just tolerate the initial error messages, and move the `sigma` slider to obtain the desired results. | stackexchange-mathematica | {
"answer_score": 2,
"question_score": 0,
"tags": "manipulate, dynamic"
} |
Prove $x \cap x ^ \perp =\left\{0\right\} $
I'm learning about Hilbert Spaces and one of the definitions says that $ H=Y\oplus Y^{\perp}$. I'm not having problem with the proof of uniqueness. I'm trying to prove $Y \cap Y ^ \perp =\left\\{0\right\\} $ where $Y \subset H $ and $Y$ is closed.
My approach is the following:
$x \in Y \cap Y ^ \perp \implies x \in Y$ and $ x \in Y ^ \perp $
and since $Y ^ \perp=\left\\{x\in H: x\perp Y\right\\} $
Therefore $x\perp x \implies x = \left\\{0\right\\} $
Is my proof right or is there something I'm clearly missing? | $x\in Y\cap Y^{\perp}$ implies $<x,x>=0$ implies $x=0$ | stackexchange-math | {
"answer_score": 3,
"question_score": 0,
"tags": "hilbert spaces, orthogonality"
} |
Need help obtaining the thesis of Zygmunt Janiszewski from 1911
I am trying to obtain a PDF of the thesis of Zygmunt Janiszewski, which is titled "Sur les continus irréductibles entre deux points".
I have learned that this is also contained in a later publication "Oeuvres choisies".
Please help me see this very influential paper! | There is one Polish publication of Zygmunt Janiszewski available online, from which one learns that the paper in question was also printed in Journal de l'École Polytechnique in 1912, and this is available online too. And indeed, your paper starts on page 79 there. In case you can't get this pdf, I can post it somewhere. | stackexchange-mathoverflow_net_7z | {
"answer_score": 8,
"question_score": 3,
"tags": "reference request"
} |
How to automatically graph the output of a shell function
I do a lot of video editing and processing, and spend a lot of time looking at the output of command line programs like ffmpeg. Ffmpeg produces a regular output of the form
frame=1234 fps=80 q=-1.0 size= 23456kB time=1234 bitrate=280.0kbits/s
frame=1237 fps=80 q=-1.0 size= 23678kB time=1258 bitrate=280.0kbits/s
...
my question is, is there a command line program that could automatically graph the output of this (preferably live)? so you could write
ffmpeg -i inputfile.avi -lotsofoptions -outputfile.avi > graphprogramorsomething
and it would produce a nice chart showing how the fps and things varied throughout the whole process.
Not really a mission critical request but would make the wait much nicer... | I don't know about the generation being done "automatically", but you can certainly automate it.
Gnuplot might be your best bet.
Here's a brief tutorial.
Here's another method to extract some data from ffmpeg: <
xgraph and ploticus might also be of use. | stackexchange-askubuntu | {
"answer_score": 2,
"question_score": 4,
"tags": "command line, bash, graphics, ffmpeg"
} |
Disable Backlight Timeout in BlackBerry devices
I'm trying to disable the Backlight Timeout function on BlackBerry device - where the screen automatically dims after a period of inactivity.
The only thing I can do at this moment is go to: **Options** -> **Display** -> **Screen Components** -> **Backlight Timeout**
and change the time there. The default is 10 seconds and the maximum is 2 minutes.
Does anyone know how to completely disable this Backlight Timeout function with Java code? | I've found the answer. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, blackberry"
} |
More than one Remote Desktop Session on Windows Server
I have a Windows Server 2012 setup and I access it using Remote Desktop Connection.
If I'm connected and someone else connects, I get booted off. Is there a way for me to still stay connected and when someone else connects, they get there own "session" and I stay on? | By default, Remote Desktop for Administration allows two Remote Desktop Services sessions.
Looks like there is a limit set for this in your case[ [check if there are limits for a number of sessions]](
If your server is in a domain, then the limit could be applied via GPO. If **Limit number of connections** policy is enabled then the default restriction would be 1 session.
},ylabel=Amplitude]
\addplot[no markers,smooth,samples=201,domain=0:2.5]
{exp(-9*(x-1.25)*(x-1.25))*cos((x-1.25)*1440)};
\end{axis}\\[5mm]
\begin{axis}[xmin=-10,xmax=10,ymin=0,ymax=1,
xtick={-10,-5,0,5,10},
xlabel={Frequency (MHz)},ylabel=Spectral amplitude]
\addplot[no markers,smooth,samples=201,domain=-10:10]
{0.2*exp(-(x-5)*(x-5))+0.2*exp(-(x+5)*(x+5))};
\end{axis}\\
};
\end{tikzpicture}
\end{document}

read (*) n_particles, n_groups
read (*) (group_id(j),j=1,n_particles)
In detail, the file format is:
Bytes 1-4 -- The integer 8.
Bytes 5-8 -- The number of particles, N.
Bytes 9-12 -- The number of groups.
Bytes 13-16 -- The integer 8.
Bytes 17-20 -- The integer 4*N.
Next many bytes -- The group ID numbers for all the particles.
Last 4 bytes -- The integer 4*N.
How can I read this with Python? I tried everything but it never worked. Is there any chance I might use a f90 program in python, reading this binary file and then save the data that I need to use? | Read the binary file content like this:
with open(fileName, mode='rb') as file: # b is important -> binary
fileContent = file.read()
then "unpack" binary data using struct.unpack:
The start bytes: `struct.unpack("iiiii", fileContent[:20])`
The body: ignore the heading bytes and the trailing byte (= 24); The remaining part forms the body, to know the number of bytes in the body do an integer division by 4; The obtained quotient is multiplied by the string `'i'` to create the correct format for the unpack method:
struct.unpack("i" * ((len(fileContent) -24) // 4), fileContent[20:-4])
The end byte: `struct.unpack("i", fileContent[-4:])` | stackexchange-stackoverflow | {
"answer_score": 218,
"question_score": 157,
"tags": "python, binary, fortran"
} |
SSIS - How to execute next Task after For Loop
Im trying to execute a SQL Task after a For Loop Container completes (i.e performs its iterations) but it just wont execute. I cant for the life of me work out why it wont execute as there are no errors. Any ideas?
!SSIS Workflow !Params
The Loop executes the correct number of times but as you can see from the image, the Insert Referral Actions SQL Task does not execute.
The idea is that if the number of source records falls under a certain threshold e.g. 2000000 then just load in 1 shot otherwise loop 1000000 at a time and load. This is to get around some network and connection issues I was having.
The final task (Insert Referral Actions) executes a stored procedure that joins the staging data with a lot of related tables and populates the Fact table. It is this SQL Task that I need to share between the 2 branches.
Thanks for any help | Logical explanation of "Insert Referral action" says that it should execute when input is executed successful. In your case, one out of two input is successful. So, technically "Execute SQL" task doesn't have permission to execute because both input are not successful. Here is how you can do that click on the precedence constraint and select `logical OR` instead of `Logical AND`.

else if (isliteversion)
end if | You create separate targets. one for the lite version, one for the full version, then add compiler flags like `-DLITE` then check `#ifdef LITE` in your code. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "iphone, objective c, xcode, preprocessor directive"
} |
How to condense a struct in a class c++?
I have a `a.h` which has a class `d`. I am wondering how to make a shorthand way to use the struct 'a' inside of my class.
//a.h
class d
{
public:
struct a
{
int val;
}
};
//a.cpp
#include "a.h"
using d::a; //line with error
a methodName()
{
//does stuff
return object_of_type_a;
} | what about this one
class d
{
public:
struct a
{
int val;
};
};
typedef struct d::a da; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c++"
} |
How to convert a String Mac Address to a Byte array
I have got the String MacAddress, which i need to convert in to a byte array. Java wouldn't let me do a direct conversion throwing a numberformat exception. This is what I'm doing right now
clientMac[0] = (byte)Integer.parseInt(strCameraMacId.substring(0, 2));
I tried doing it step by step
String mc = strCameraMacId.substring(0,2);
int test = Integer.parseInt(mc);
clientMac[0] = (byte) test;
But the String mc consists of a value "08" and after doing the int to byte converion im losing the zero. the mac address im trying to convert is "08-00-23-91-06-48" and I might end up losing all the zeros. will I? and has anyone got an idea regarding how to approach this issue?
Thanks a lot | The zero is going to be implied in the byte value. Remember that 0x08 == 8. You should be able to convert your to an array of 6 bytes. Youre approach is fine, just remember that if you are going to convert this back to a string, that you need to let Java know that you want to pad each number back to 2 chars. That will put your implied zeros back in place. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "java, string, arrays, mac address"
} |
Rounding half down a decimal
Does an equivalent of Java `RoundingMode.HALF_DOWN` exist in C#?
For example, I want to round `1.265` to `1.26`, and `1.266` to `1.27`.
If not, is there a simple way to do it? | Have a look at Math.Round e.g.
double[] tests = new double[] {
1.265,
1.266,
};
var demo = tests
.Select(x => $"{x} -> {Math.Round(x, 2, MidpointRounding.AwayFromZero)}");
var report = string.Join(Environment.NewLine, demo);
Console.Write(report);
Outcome:
1.265 -> 1.26
1.266 -> 1.27 | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "c#, math, rounding"
} |
getScript Local Load Instead of Global?
From what I have read JQuery's getScript function loads the script file in a global context using a function called 'global eval'. Is there a particular setting or method to change this so it will instead load within the function I am calling it from?
If I do the following code name returns undefined as its not loading the script in the local context.
function callscript(){
var name='fred';
getScript(abc.js);
}
//abc.js:
alert(name); | I believe I have found the solution using a regular JQuery ajax call. The trick is you set the datatype to 'text' as otherwise if its script or if use getScript or the alternative .get() it will auto run the script inside and place it in the global context.
function abc(){
var msg="ciao";
$.ajax({
url: 'themes/_default/system/message.js',
success: function(data){
eval(data);
},
dataType: "text"
});
}
//message.js
(function() {
alert(msg);
})();
This alerts 'ciao' as expected :)
Before anyone says anything yes I'm using eval but its perfectly fine in this situation. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 4,
"tags": "javascript, jquery, ajax"
} |
Appium cannot search element by resource id
I have trying to create a automation script for an android application using appium. I am trying to select an element and perform a click operation using the following code.
MobileElement loginElt = (MobileElement)driver.findElementById("ca.*******.bond:id/menu_item_sign_in");
Where `ca.********.bond:id/menu_item_sign_in` is the resource id.
The problem is that appium is not able to search for the resource id although it is available via the uiautomator. | Just add `.click();`
and eliminate the app ID
driver.findElementById("menu_item_sign_in").click(); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, android, automation, appium"
} |
Aliens Attack Apartments?
Difficulty level **:** fair to middling
Pose level **:** too tempting to resist
When attempting to fill in a bureaucratic blank, a friend serendipitously snapped this cameraphone picture . . .
+2 a \,c \,k \cos \alpha -c^2=0$$ if $k=1$ there is one solution $$a=\frac{c}{2\cos\alpha}$$ if $k\ne 1\land 0\le k\le \frac{1}{\sin\alpha}$ there are two solutions $$a=\frac{c \left(k \cos \alpha \pm\sqrt{1-k^2 \sin \alpha }\right)}{k^2-1}$$ Hope this helps | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "geometry"
} |
How to customize XFCE screenshot saving file name template?
When I press `Print Scrn` in XFCE and choose to save it, the automatically generated and offered file name is like `Screenshot - 141012 - 02:21:10.png` (`Screenshot - DDMMYY - HH:mm:SS.png`).
I hate to use Windows-incompatible characters (like `:`) and sorting-unfriendly date formats in file names and moreover the name looks too long: `scrnYYYYMMDDHHmmSS.png` would be much better.
Is it possible to set-up? | Nope, it's impossible.
!enter image description here
Manually modify the source code would work for you, but you could submit a bug report for it. (e.g make this configurable through xfce4-settings) | stackexchange-unix | {
"answer_score": 4,
"question_score": 3,
"tags": "xfce, screenshot"
} |
How to get the channel of a message
I want to get the channel of a message send by an user, I have that
client.on('message', msg => {
But I don't how to get the channel, how can I do? | The `msg` object returned follows the Message format you can find in the Discord.js documentation.
Hence, you can get the channel the message was sent on by `msg.channel`, and its name `msg.channel.name`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, node.js, discord.js"
} |
interface/implementation files shows up in new windows
I`m using "All in one" layout.
When I press cmd + opt + up arrow interface/implementation files are switched in new window. How to do in current window ? | Open **Preferences** (Xcode > Preferences from the menu) and on the **General** pane, under **Editing** , check off **Open counterparts in same editor**. !Xcode Preferences | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "xcode"
} |
Read InputStream from file via URL query string
Is it possible to use the java URL.openStream() method to read the file into an input stream when the URL is a query string rather than a direct link to a file? E.g. the code I have is:
URL myURL = new URL("
InputStream is = myURL.openStream();
This works fine for a direct file link. But what if the URL was < ? Would I still be able to obtain the file stream from the server response?
Thanks! | Generally YES, it will work.
But note that `URL.openStream()` method doesn't follow redirects and not so agile with specifying some additional HTTP behaviours: request type, headers, etc.
I'd recommend to use Apache HTTP Client instead:
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpGet request = new HttpGet("
try (CloseableHttpResponse response = httpclient.execute(request)) {
final int status = response.getStatusLine().getStatusCode();
if (status == 200) {
final InputStream is = response.getEntity().getContent();
} else {
throw new IOException("Got " + status + " from server!");
}
}
finally {
request.reset();
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "java, url, networking, junit, httpconnection"
} |
octave in ubuntu: 'rm' undefined near line 1 column 1
I am running octave in ubuntu. I got the following problem while trying to delete a file:
>> ls
cos1.dat cos.dat datFile.grc top_block.py
>> rm cos1.dat
error: 'rm' undefined near line 1 column 1
However, everything is OK in windows | You can remove your file with
>> delete("cos1.dat") | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ubuntu, virtual machine, octave"
} |
$G$- space is locally compact
Suppose $X$ is a topological space ,$G$ Is a locally compact group.If the quotient space $G\backslash X$ is compact,can we deduce that $X$ is locally compact? | No. Take $X=$ any non-locally compact topological group, $G=$ the same group made discrete and acting on $X$ by left translations. | stackexchange-mathoverflow_net_7z | {
"answer_score": 4,
"question_score": -2,
"tags": "gr.group theory, gn.general topology, topological groups"
} |
Eclipse IAutoEditStrategy only called on backspace; how to have it called on all edits?
I am currently working on a custom editor plugin for Eclipse. I've overwritten getAutoEditStrategies like this:
public IAutoEditStrategy[] getAutoEditStrategies(
ISourceViewer sourceViewer, String contentType) {
return new IAutoEditStrategy[] { new KRLAutoEditStrategy() };
}
and written a minimal Strategy like this:
public class KRLAutoEditStrategy implements IAutoEditStrategy {
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
System.out.println("Called.");
}
}
Now customizeDocumentCommand is only called when I hit backspace, not for any other character. What am I missing? How else do I implement auto indention? | I've actually figured this one out myself now. My strategy was perfectly fine but it didn't work because the editor partition I wanted it to be applied to was not exposed through `getConfiguredContentTypes`.
When your coloring or indention doesn't work, make sure that you work on a partition which has the correct tokens applied to it and exposed through `getConfiguredContentTypes`! The problem became obvious when I used distinct colors for all partitions and one of them didn't get colored. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "java, eclipse, eclipse plugin"
} |
I can't vertical align a logo on Wordpress
I spend the last two days trying to vertical align a logo in a website done with wordpress.
Here's the link: www.contidosdixitais.com
Does anybody knows what am I doing wrong?
Tried with
vertical-align: middle;
margin-bottom: 0;
and more but nothing works. | If you're referring to that div up top with the 'title-area' class, try:
-webkit-transform: translateY(50%);
-ms-transform: translateY(50%);
transform: translateY(50%); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "html, wordpress, alignment, graphical logo"
} |
Can I Pass a return value of a getter method to a setter method of another object in a different class?
customer1.setExcursion1() = cust_dest.get_excursion1();
`customer1` and `cust_dest` are two different objects from two different classes.
Can I pass the return value of
cust_dest.get_excursion1();
to the
`my customer1.setExcursion1()` method? | Yes, you can - but not like that. You call the setter method, passing in the value as an argument - you're currently trying to assign a value to the method call, which makes no sense.
You want:
customer1.setExcursion1(cust_dest.get_excursion1());
(Your naming is inconsistent, by the way. It should be `getExcursion1`, at least - and ideally just `getExcursion`. What is the `1` meant to be for? Likewise `cust_dest` should be `custDest` if you're not changing the words - or ideally something rather more descriptive.) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "java"
} |
Where can I learn about holograms?
I want to learn about holograms. I have zero knowledge of how they work. How can I start? I tried using Google but I cannot decide where to and how to start. Can you suggest any good sites for this purpose? | The best place to learn about holograms and how they work depends on your background. The book, "Optical Holography" by Collier, Burkhardt and Lin is for readers with a good math background, but a diligent reader can get a huge amount of information by reading between the equations. That was my holography bible "back in the day". The book, "Holography Handbook" by Fred Untersehr, was a standard for artists and hobbyists getting into holography back in the 1970's and 1980's; it had a few unimportant technical errors. There is a hologram-making kit you can get on Amazon for something over $100, made by Liti Holo. For a similar price you can get hologram-making kits from Integraf. Note: you definitely do not need a technical background to learn about how holograms work and how they are made. You can find plenty of explanations online, both written and in video form; and probably the kit would give you at least a great intuitive grasp of the subject. | stackexchange-physics | {
"answer_score": 0,
"question_score": 0,
"tags": "resource recommendations, hologram"
} |
split dataframe when number is lower than the previous number
I have a series like this: `test = pd.Series([2.4,5.6,8.8,25.6,53.6,1.7,5.7,8.9])`
I want to split it into two series at the point where the next number is smaller than the previous one. This only happens once in any series, but it does not happen at a reliable location (could be the 7th place, 4th, etc).
The result should look like this:
test1
2.4
5.6
8.8
25.6
53.6
and
test2
1.7
5.7
8.9 | You can find the position with
pos = (test - test.shift(-1)).argmax()
Now the series until that is
>>> test[: pos + 1]
0 2.4
1 5.6
2 8.8
3 25.6
4 53.6
dtype: float64
Similarly, the remainder is
>>> test[pos + 1: ]
5 1.7
6 5.7
7 8.9
dtype: float64 | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "python, pandas, dataframe"
} |
FileConnection on Storm 9550
I'm using the following code to create a file and write data into it:
fileName = "file:///store/home/user/myapp/groups.xml";
try {
fc = (FileConnection) Connector.open(fileName, Connector.READ_WRITE);
if (!fc.exists())
fc.create();
os = fc.openDataOutputStream();
String XMLString = "blablabla";
byte[] FinalXML = XMLString.getBytes();
os.write(FinalXML);
os.close();
fc.close();
} catch (IOException e) {
Dialog.alert(e.getMessage());
}
It works good on my bb 9700 with OS6 and on 9700 simulator. But it doesn't work on 9550 device and simulator. I'm getting IOException. The message says
> File not found
Does anybody have some voodoo magic that will help me? | Looks like the folder "file:///store/home/user/myapp/" does not exist yet. Just check for its presence first, if not present - create and then go on with rest of your code.
BTW, the "file:///store/home/user/" path is valid for all mentioned devices. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "blackberry, java me, blackberry storm, connector"
} |
What is the name of those Old Timey Bikes?
The bikes with a huge front wheel and small rear, with the cranks attached directly to the front wheel... What are they called?
Additionally, it seems they need to be very tall in order for you to achieve a full pedal stroke, so how is one supposed to mount this archaic device?
!Old Timey Bike | This is a "penny-farthing" bike. You mount it by putting a foot on the step above the back wheel, you push off, then climb up it towards the pedals as it moves away. (Like this video shows.)
The front wheel was so large for a couple of reasons: Since the pedals were connected directly to the wheel, the bike could go faster if the wheel were larger; and also, a large wheel functioned as suspension.
When the safety bicycle was introduced, it had pneumatic tires and drivetrains that allowed for gearing independent of wheel size, so the penny-farthing fell into disuse. | stackexchange-bicycles | {
"answer_score": 14,
"question_score": 7,
"tags": "terminology, history, penny farthing"
} |
How can I wire my case fans to be powered by my PSU and not motherboard?
My case fans are plugged into my motherboard and I have no more slots for fans. I read from a source on yahoo answers I should wire all my case fans to a molex 4 pin adapter--and plug that directly into the power supply.
The problem is my PSU doesn't have a Molex insert or adapter. This is my power supply.
It has what looks like to be PCI-E plugs coming out of my PSU. How can I route my case fans to connect to my PSU? | Your PSU definitely has such connectors, they look like this (from wikipedia): You just have to put your fans on adapters like these are (probably come with your fans) and from there to your PSU.
!enter image description here | stackexchange-superuser | {
"answer_score": 4,
"question_score": 0,
"tags": "power supply, cable, wiring, molex"
} |
If a string is an array of char, how do you convert it into an array of interger
I kept getting an error with this loop. If there are something i missed, please help. Thank You!
int main(){
string hasil;
int cod[5];
hasil = "99999";
for(int i = 0; i < 5; i++){
cod[i] = stoi(hasil[i]);
}
for(int i = 0; i < 5; i++){
cout << cod[i] + 1;
} | `std::stoi()` takes a `std::string`, not a `char`. But `std::string` does not have a constructor that takes _only_ a single `char`, which is why your code fails to compile.
Try one of these alternatives instead:
cod[i] = stoi(string(1, hasil[i]));
cod[i] = stoi(string(&hasil[i], 1));
string s;
s = hasil[i];
cod[i] = stoi(s);
char arr[2] = {hasil[i], '\0'};
cod[i] = stoi(arr); | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": -1,
"tags": "c++"
} |
Why does Qt add 'PWD' to libraries that are NOT referenced relatively?
Whenever I add a library in the `.pro` file of a Qt project (in Qt 5.2) it adds a `$$PWD` before the path of the libraries and include path. For example
INCLUDEPATH += $$PWD/C:/opencv/opencv-msvc2013/install/include
and
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/opencv/opencv-msvc2013/install/x64/vc12/lib/
My question is
1. why does Qt start the path with the PWD (Present Working Directory) keyword if its providing an absolute path to the libraries? What logic/good programming practice is this convention following?
2. And most importantly why it does not result in an error? How does Qt know when to search relative to a working directory and when not to? (Since both cases start with the PWD keyword)
PS : I removed the `$$PWD` keywords and my code worked just fine as well. | In case both the project and the library are in the same drive, that would not happen and the relative path is generated automatically. But on Windows if you add a library which is in another drive, it would add `$$PWD` followed by an absolute path.
This sounds like a bug and it has been reported here but it's still unresolved. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 3,
"tags": "c++, qt, syntax, qt creator"
} |
What does 背着 mean in the novel 活着 (pp.10-12), e.g., ...让她背着我回家...?
I encountered thrice in quick succession in the novel (pages 10 through 12):
> **** ...
>
> ... **** ...
>
> ... **** ...
>
> ... **** ...
In each case, the (sex worker) is doing to the main character "" ("me").
None of the verb definitions of seem to fit these sentences: to be burdened, to carry on one's back, to turn one's back, to hide something from, to learn by heart, to recite from memory. Perhaps it's grammatically possible she's physically carrying him or her back (?), which seems implausible.
**Question** : What does mean above? | > ...
The first section of text already makes it clear that refers to the carrying the narrator on her back. (because she was fat enough and the narrator felt like he was riding a horse) | stackexchange-chinese | {
"answer_score": 3,
"question_score": 0,
"tags": "meaning, meaning in context"
} |
gl.glScalef() hide the gl.glDrawArrays() drawing
I have a program which draw a 3D shape according to set of `GL.GL_VERTEX_ARRAY` , finally it drawn within the `display()` method -
public void display(GLAutoDrawable drawable) {
gl.glDrawArrays(GL.GL_QUADS, 0, 24);
}
so far it work ok and I get the desired shape on the output , but if I add `gl.glScalef(20, 20, 40);` before the `gl.glDrawArrays()` the shape stop to be appear and I get blank output -
public void display(GLAutoDrawable drawable) {
gl.glScalef(20, 20, 40);
gl.glDrawArrays(GL.GL_QUADS, 0, 24);
}
How could I scale the output correctly ?
**Edit:**
Fixed by adding `gl.glLoadIdentity()` before . | It is totally unclear what the rest of your code will do, but from the shown fragments alone, one could suspect that you never reset the matrix, and the scaling accumulates over the course of several frames. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, opengl, jogl"
} |
regex not working, accepting almost all letter number combinations
Can someone tell me what i'm doing wrong? This is accepting everything as a match.
if (preg_match("/^[A-Z][a-z][a-z][0-9]|[1-9][0-9]|1[0-4][0-9]|15[0-1]:[0-9]|[1-9][0-9]|1[0-6][0-9]|17[0-6]/", $_GET['id']))
{
echo "match";
}
else
{
echo "no match";
}
i'm wanting it to only match if the 1st letter is a capital A-Z, the 2nd letter a small letter a-z, the third letter a small letter a-z, then a number between 1 and 150, a colon :, Then a number between 1 and 176. It should match Abc150:176 Zyx1:1 But not aBc151:177 | Use this:
^[A-Z][a-z]{2}(?:[1-9][0-9]?|1[0-4][0-9]|150):(?:[1-9][0-9]?|1[0-6][0-9]|17[0-6])$
See demo.
* `^` asserts that we are at the beginning of the string
* `[A-Z][a-z]{2}` matches one upper-case and two lower-case letters
* `(?:[1-9][0-9]?|1[0-4][0-9]|150)` matches a number from 1 to 150
* `:` matches a colon
* `(?:[1-9][0-9]?|1[0-6][0-9]|17[0-6])` matches a number from 1 to 176
* `$` asserts that we are at the end of the string
In php:
$regex = "~^[A-Z][a-z]{2}(?:[1-9][0-9]?|1[0-4][0-9]|150):(?:[1-9][0-9]?|1[0-6][0-9]|17[0-6])$~";
echo (preg_match($regex,$string)) ? "***Match!***" : "No match"; | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "php, regex"
} |
WiX - suppress Install and Close Buttons
I have a wix installation that currently uses the standard bootstrapper to bundle a number of MSI's together.
With the goal of automatically updating the applications, what I want is for the dialog to have the Install and Close buttons suppressed so that the install automatically starts with no user intervention.
I'm currently using the following Bootstrapper definition to suppress options button and License, but can I do what I want using one of the standard bootstrappers am I looking at having to create my own GUI?
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense">
<bal:WixStandardBootstrapperApplication SuppressOptionsUI="yes" LicenseUrl="" LogoFile="logo.png" />
</BootstrapperApplicationRef> | WixStandardBootstrapperApplication does not support that: If it's started in "full UI," it will require the user to initiate the install. You can run the bootstrapper with the /passive switch to get the behavior you want. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "visual studio 2008, wix, wix3.6, bootstrapper, burn"
} |
Why can't I use LINQ on ListView.SelectedItems?
I am trying to do use `.Select` extension method on `ListView.SelectedItems` which is `SelectedListViewItemCollection`, but `.Select` doesn't show up in intellisense.
I can use `foreach` on `SelectedListViewItemCollection`, so it must have implemented `IEnumerable`. I just checked on MSDN, and it certainly does. Then why can't the LINQ extension methods be used on it? | The reason why is that SelectedItems is typed to a collection which implements IEnumerable. The Select extension method is bound to `IEnumerable<T>`. Hence it won't work with SelectedItems.
The workaround is to use the .Cast extension method to get it to the appropriate type and it should show up
ListView.SelectedItems.Cast<SomeType>.Select(...) | stackexchange-stackoverflow | {
"answer_score": 26,
"question_score": 9,
"tags": "c#, .net, winforms, listview"
} |
Get row rank without fetching every row
I'm using this query to fetch a highscore of a certain user.
SELECT score FROM highscores WHERE user_id=?
I would like to know the how-many'th this particular highscore is compared to the other scores. So basically the row number after we DESC ordered the highscores table.
I could of course fetch all rows and look at the array key but I was wondering if there's a more performance friendly method directly via the MySQL query. The highscore table contains around 500k rows, and it seems a bit overkill (and it will take some time) to have to fetch them all first just to get the rank number of the user's score. | Some time ago I helped a friend with a similar task, and wrote an article, How to get a single player's rank based on the score.
So the idea is to run a `count(*)` query with a WHERE clause to include all players having a higher score:
SELECT count(*)+1 FROM players WHERE score > ?
or, based on the user id,
SELECT count(*)+1 FROM players WHERE score > (SELECT score FROM players WHERE id = ?)
This solution is much simpler than anything I was able to find on Stack Overflow.
It can be also refined, to take into account other fields, in case two users have the same score, such as time when the score has been updated:
SELECT count(*)+1 FROM players WHERE score > ? OR (score = ? AND score_updated < ?) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "mysql"
} |
PHP Magento - redirect and send data via post without form
I have 2 php page. I want to redirect page 1 (contains a data (ex. username)) to page 2 that only receive post data.
Here is received code in page 2 (not editable due to development):
if (!$_POST["username"]||$_POST["username"]=="Studio") $username="Studio".rand(100,999);
else $username=$_POST["username"];
I tried to use curl for my case, and not get the data I needed.
Here'e my code in page 1:
$src = "
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$src);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"username=".$title);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
$this->_redirectUrl($src); | Have you tried using CURL with POST ?
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url); //set URL
curl_setopt($ch,CURLOPT_POST, 1); // make a POST request
curl_setopt($ch,CURLOPT_POSTFIELDS, $post_vars);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
`$post_vars` can be something like `'lastname=smith&firstname=bill'` | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, magento, redirect, post"
} |
A single word for a person who suffers great loss
Can anybody give me a single word for a person who suffers great loss as in the context below. The word loser is not appropriate:
> Mike lost everything after his failed business venture.
>
> Phillip suffered great loss due to the flood. | How about "destitute"
> Phillip was left destitute as a result of the flood./ Phillip is now a destitute.
There is also "ruined"
> Philip suffered great loss due to the flood. He is now ruined.
or
"Devastated" | stackexchange-english | {
"answer_score": 4,
"question_score": 6,
"tags": "single word requests, vocabulary"
} |
Silverlight 4: Binding to a calculation of control properties
What I would like to do is pretty simple. Given textboxes for ItemPrice, Tax and Total, I need the text value for Total to be bound to ItemPrice + Tax and the Tax value to display ItemPrice * taxRate.
Could someone offer a brief explanation as to how this would be accomplished or point me to an appropriate example? I see property binding examples all over the place, but none that show binding to a calculation of the properties of two controls. | This can be done quite simply: bind the `Text` property of the `Total` box to another property on your ViewModel, all that property does is have a getter that returns the sum of _ItemPrice_ and _Tax_.
You don't need to bind the Total box to any other control. Just make sure that your ViewModel also implements `INotifyPropertyChanged`, and that you also notify that the _Total_ property has changed when _ItemPrice_ or _Tax_ have changed (so that your bound text automatically updates). | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "silverlight, binding, properties, silverlight 4.0"
} |
Can I use a fake email address for asking simple questions to experts?
I am a postdoc in math. From time to time, I have some simple questions, which I believe most graduate students know in their field. So, I email specialists to ask them. I sometimes noticed that people don't react well to my questions which means I should have known the answer.
My friend suggested me to ask such simple questions using a fake email address, which is not my original email address. Although it sounds a good idea, I don't like it. I would like to know what you advise me. | I agree with both of the provided answers so far, but I feel like they are incomplete as they avoid the core issue here.
**The problem that you are facing is not reputational blowback. It's that you are asking questions that are received poorly.** There could be many reasons the questions are received poorly: maybe you're being rude in your emails; maybe the receiver is in a bad mood; maybe there's some reason that you're asking an inappropriate person; maybe you're sending 100 emails a month to the same person. Whatever the reason that people respond poorly to your questions is, the fact that they are responding poorly is the issue that needs to be addressed. This can cause reputational blowback, but the best way to avoid reputational blowback is to not ask questions that are received poorly. Using an anonymous email address does not help with this, and will still result in irate respondants. | stackexchange-academia | {
"answer_score": 52,
"question_score": 13,
"tags": "mathematics, etiquette, email, communication, answering questions"
} |
Hide fields in new item menu
I have followed the answer described in Hide list column on new, edit item-OOTB
But what I found is when editing the column from the content type, i found the hidden menu is disabled.
**Content type description :**
** column but it is possible to hide it from SharePoint Designer. Follow below steps to hide from Designer.
1. Open site in designer
2. Click On List/Library from left side
3. Click on your list
4. Click on edit content type
5. Click multiple times (may be it is six times) on your column and then you will get your column in edit mode. Now select the option from drop-down menu. | stackexchange-sharepoint | {
"answer_score": 1,
"question_score": 2,
"tags": "2013, list, content type, list form, spfield"
} |
Visual Studio 2010 MVC Project type Disappeared
I have been working with visual studio 2010 Premium RTM for over a month. When I installed it I had a fresh install of windows. (No betas or previous versions of VS)
I have been creating new ASP.NET MVC2 C# projects since I installed it. I went to create a new mvc project today and I don't have that as an option anymore. I went in under the new project section not the new website section. I don't see it listed under C# or VB.
Is there a way to get that back without reinstalling visual studio? | I had this problem with Linq to SQL templates. Try the accepted answer on this other stack overflow question.
The solution was to run
> devenv.exe /InstallVSTemplates
to reinstall the templates. It worked for me when I had missing templates in Visual Studio 2010. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "asp.net mvc, visual studio 2010, project template"
} |
BarChart with two ChartLabels
I am creating a BarChart, where i wish to have the actual value on the top of each bar and the label of the bar on the bottom. Basically i have created the BarChart with the label in the bottom, but i cannot figure out how to add the value on the top of each bar.
values = {150445, 161419, 173986, 202405, 214516, 227004,
240700, 256377, 271309, 286944, 307016, 320545};
labels = {2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009, 2010, 2011, 2012};
Show[
BarChart[values, ChartLabels -> labels,
ChartStyle -> "Pastel", AxesLabel -> {"Year", "Diagnosis"}],
Background -> Transparent,
BaseStyle -> {12, FontFamily -> "Helvetica"},
ImageSize -> 600
]
Is there a way to view the `values`on top of each bar? | BarChart[Labeled[#, {#, #2}, {Above, Below}] & @@@ Thread[{values, Most@labels}],
ChartStyle -> "Pastel",
AxesLabel -> {"Year", "Diagnosis"}, Background -> Transparent,
BaseStyle -> {12, FontFamily -> "Helvetica"}, ImageSize -> 600]
!enter image description here | stackexchange-mathematica | {
"answer_score": 5,
"question_score": 3,
"tags": "plotting, charts"
} |
mouseover() - using addClass() with this
how can I add a class when mouse is over an element?
var row = $('<tr></tr>')
.append('<td class="list_row">'+js2txt(string)+'</td>')
.mouseover(function(){
this.addClass('list_row_mover');
});
js error:
this.addClass is not a function | In your function the scope (`this`) is the HTML element, not the jQuery object.
Here is a possible fix:
var row = $('<tr></tr>')
.append('<td class="list_row">'+js2txt(string)+'</td>')
.mouseover(function(){
$(this).addClass('list_row_mover');
}); | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "jquery"
} |
How to run a service from 9 AM to 4 PM daily?
**Question :1 =>** I want to run a service from 9 AM to 4 PM daily. I plans two method.Which one is best?
**Method 1:** Inside Service:(This service initialized at on create of activity when first time application starts)
if (9 AM <=current time<=4 PM)
{
fetch data from server.
}
**Method 2:**
In Activity oncreate use Alarm manager and start a service based on the alarm manager.Then wake up next day and start service.
Which method is best?
**Question :2 =>** How to find a service is running or not programmatically? | Write a BroadcastReciever to receive the ON_BOOT broadcast (you'll need to add appropriate permission and intent filter to your manifest). The BroadcastReceiver exists only to create a 9 am notification with the Alarm Manager. The scheduled alarm has a PendingIntent which will launch the service. Obviously, set the Alarm to repeat every 24 hours.
When launched, the service simply runs normally until 4 pm, at which point it stops itself.
The service's onStartCommand() method should return the appropriate flags to cause the system to restart it if it crashes or gets killed.
The only thing I can't figure out is how to auto-start the service the first time it's installed. Waiting for the device to be rebooted isn't very practical. When I write apps like this, they're typically combined with an Activity that has controls to start and stop the service. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 5,
"tags": "android, android service, android alarms"
} |
How to properly get little-endian integer in java
I need to get 64-bit little-endian integer as byte-array with upper 32 bits zeroed and lower 32 bits containing some integer number, let say it's 51.
Now I was doing it in this way:
byte[] header = ByteBuffer
.allocate(8)
.order(ByteOrder.LITTLE_ENDIAN)
.putInt(51)
.array();
But I'm not sure is it the right way. Am I doing it right? | What about trying the following:
private static byte[] encodeHeader(long size) {
if (size < 0 || size >= (1L << Integer.SIZE)) {
throw new IllegalArgumentException("size negative or larger than 32 bits: " + size);
}
byte[] header = ByteBuffer
.allocate(Long.BYTES)
.order(ByteOrder.LITTLE_ENDIAN)
.putInt((int) size)
.array();
return header;
}
Personally this I think it's even more clear and you can use the full 32 bits.
I'm disregarding the flags here, you could pass those separately. I've changed the answer in such a way that the position of the buffer is placed at the end of the size. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "java, integer, arrays, endianness"
} |
What is the check_union256d?
What is the `check_union256d` function?
It's placed in following code:
/* { dg-do run } */
/* { dg-require-effective-target avx } */
/* { dg-options "-O2 -mavx" } */
#include "avx-check.h"
void static
avx_test (void)
{
int i;
union256d u, s1, s2;
double e [4];
s1.x = _mm256_set_pd (2134.3343,1234.635654,453.345635,54646.464356);
s2.x = _mm256_set_pd (41124.234,2344.2354,8653.65635,856.43576);
u.x = _mm256_div_pd (s1.x, s2.x);
for (i = 0; i < 4; i++)
e[i] = s1.a[i] / s2.a[i];
if (check_union256d (u, e))
abort ();
} | It's from Intel AVX which is:
> a new 256 bit instruction set extension to SSE and is designed for applications that are Floating Point (FP) intensive. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c++, testing, gcc"
} |
Git from behind a proxy - clone works - fetch/pull does not
I am using ubuntu behind a socks5 proxy and trying to use the git protocol (as opposed to http which does work). I can get git clone working by compiling connect.c
And by adding this to my ~/.ssh/config:
ProxyCommand connect -S socks-mydomain.co.uk %h %p
I have cloned a repo and have all the code, however now I am trying to merge in the changes from another repo. I have added it as a remote and now I get an error when doing this:
git fetch upstream
github.com[0: 207.97.227.239]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)
As git clone works it seems strange that a fetch does not. Any idea why? | If adding the ProxyCommand helped for your initial clone, you cloned via ssh. For the remote you just added, you use the git protocol (i.e. a git://-url). For this protocol, git does not use ssh, but some builtin network support.
Proxy support for the git protocol can be configured with the core.gitProxy variable in the git config file or the GIT_PROXY_COMMAND environment variable. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 1,
"tags": "git"
} |
SQL statement to get a total for a given date range
I am trying to get the number of bookings and their total value by date for every day within a given date range.
## My table looks like:
BookingId (int)
BookingFare (decimal)
BookingDateTime (datetime)
I can convert BookingDateTime to a date only by using:
SELECT CONVERT(varchar(8), BookingDateTime, 112) as BookingDateOnly
FROM [TaxiBookingOnline].[dbo].[Bookings]
What I'm after is something like this:
Date Bookings Value
2013-07-10 10 256.24
2013-07-11 12 321.44
2013-07-12 14 311.53
I get the feeling I should be aliasing the table, joining it to itself and then using 'GROUP BY' but I am failing to get this to work.
Any help would be much appreciated.
Thanks. | How about
select
cast(BookingDateTime as date) [Date],
count(*) [Bookings],
sum(BookingFare) [Value]
from t
group by cast(BookingDateTime as date) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "sql, sql server, tsql"
} |
Rsync copy error
I am trying to copy a directory from a remote machine's root directory to this directory /root/data_directory_backup_from_backup02 in a local machine. I spent some time to fix this but no luck. Am I making any mistakes regarding this destination path?
/usr/bin/rsync -avz -e ssh [email protected]:/backups/ /root/data_directory_backup_from_backup02
But I get the message.Could someone please help me why is so?
`/usr/bin/rsync -avz -e ssh [email protected]:/backups/ /root/data_directory_backup_from_backup02 > /var/tmp/rsync_latest_run 2>&1`
> Unexpected local arg: /root/data_directory_backup_from_backup02 If arg is a remote file/dir, prefix it with a colon (:). rsync error: syntax or usage error (code 1) at main.c(1228) [Receiver=3.0.9] | Rsync incorporates ssh. I'm pretty sure something like:
`rsync -avz [email protected]:/backups/ /root/data_directory_backup_from_backup02`
... will work just fine. | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 0,
"tags": "rsync"
} |
A literature reference for Sobolev mappings $W^{m,p}(M,N)$ for M, N smooth Riemannian manifolds
Anyone know a respectable reliable reference for the definition of Sobolev mappings $W^{m,p}(M,N)$ for M, N smooth compact Riemannian manifolds. It suffices for m natural and $p\geq 1$ | See
1. Intrinsic weak derivatives and Sobolev spaces between manifolds by Alexandra Convent and Jean Van Schaftingen
2. Gromov's compactness theorem for pseudo holomorphic curves by Rugang Ye | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "reference request, differential geometry, sobolev spaces, compact manifolds"
} |
iOS what to do instead of polling for near real-time data?
I'm developing an iPhone (and later Android) app that has real-time features, i.e. when one user posts something others will see it (depending on where they are in the app).
When implementing this in iOS one must keep in mind that network activity takes up lots of battery power.
The iOS App Programming Guide says "Connect to external network servers only when needed, and do not poll those servers."
How then is it possible for apps to have near real-time updated information? | You should use the **Push Notification Service**
<
This way, your application acts as a listener and can react to new Notifications that carry customized Payloads of data received by a server. even when it's running on background or not running at all. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "iphone, ios"
} |
Displaying html tags as simple string
I'd like to make html no interpreted. so when i do an "ECHO" within my php page
the html balise will not be interpreted
for example :
"b chat /b" will be " b chat /b" : true
"b chat /b" will be **chat** : false | Use htmlentities()
Try this,
echo htmlentities("<b>chat</b>"); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "php, html"
} |
Determining the limit of $\sqrt{x^2+y^2} \ln(x^2+y^2)$ as $(x,y)$ approaches $(0,0)$
I want to evaluate the limit of $\sqrt{x^2+y^2}\ln(x^2+y^2)$ as $(x,y)$ approaches $(0,0)$. Using polar coordinates, $x=r \cos \theta$, $y= r \sin \theta$, I obtain $\sqrt{x^2+y^2}\ln(x^2+y^2)=2r\ln(r)$ but I can not understand why this would be more simple than the original expression, or how I can proceed with this problem. | Your approach with polar coordinates is correct. The limit $\lim_{r\to 0^+}2r\ln(r)$ is simpler than the given one because it is a one-variable limit. One way to evaluate it is to write $2r\ln(r)$ as $\frac{2\ln(r)}{1/r}$ and then apply L'Hopital. Can you take it from here? | stackexchange-math | {
"answer_score": 3,
"question_score": 3,
"tags": "limits, multivariable calculus"
} |
Adjusted Cosine Similarity With Zero Vectors
I create a recommendation engine which finds item similarities according to user ratings. I'm trying to use adjusted cosine similarity to find similarities. I follow these steps.
1. Find mean rating of an every item.
2. Subtract mean rating from each item rating.
3. Apply cosine similarity.
My problem is at the second step. If all users give same rating to an item, subtracting mean rating from each rating creates zero vector. Because this vectors are dividers in cosine similarity, this causes zero division error. So is there a solution for this? | welcome to the Data science SE community:) A couple of questions in regards to the OP.
1. In what percentage of cases is this problem of dividing by zero would occur. Could you compute the percentage of such data points in the entire dataset after step 2. Based on the percentage, you could either consider dropping those points ( of the percentage is too less), similarly think of other approaches to go about tackling the problem, which brings me to point nr.2
2. Might think of using some other similarly measure which could solve this problem < This similarity score adds a small epsilon to avoid division by zero error. | stackexchange-datascience | {
"answer_score": 0,
"question_score": 0,
"tags": "recommender system, similarity"
} |
Invalid hostname for server 1. Please review your configuration
II have a problem with phpmyadmin. I have setup apache2 in my local Ubuntu and when I'm trying localhost/phpmyadmin it goes normally to the login page and login properly but I receive a promt " Invalid hostname for server 1. Please review your configuration".
Do anyone knows how to fix this?
in the config.inc.php I have this:
$cfg['Servers'][$i]['auth_type'] = 'cookie';
instead of `= 'config';` | Change in your config
// from
$cfg['Servers'][$i]['host']='';
// to
$cfg['Servers'][$i]['host']= 'localhost';
check this article for more info: < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, ubuntu, phpmyadmin"
} |
Printing data from a loop in multiple place without running the loop again
Lets I have an array like this
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
?>
<div id="3">
<!-----result of foreach loop---->
</div>
<div id="1">
<?php
foreach ($age as $key => $value) {?>
<p><?php echo $value;?></p>
<?php
}
?>
</div>
<div id="2">
<!-----result of foreach loop---->
</div>
<?php
?>
I want to print the same result in `<div id="2">` and in `<div id="3">` , without loop through the array in , I just want to use the loop only for one time . | <?php
$pAge = "";
foreach ($age as $key => $value) {
$pAge .= "<p>" . $value . "</p>";
}
?>
<div id="3">
<?= $pAge; ?>
</div>
<div id="1">
<?= $pAge; ?>
</div> | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "php, loops"
} |
Зашить драйвера в iso Windoww XP
Прислали железо ещё и с ssd, а по устанавливается только на XP. Процессе разливки ОС XP много ошибок, по ним погуглил, пишет проблема с драйверами.
Подскажите годную програмку,что бы зашить в нее в iso драйвера. Я работаю на linux and windows. Так что если под Линукс буду даже рад)
Спасибо за помощь) | Зашить драйвера в образ XP может программа nLite.
ISO редактировать можно программой xorriso (windows/linux). | stackexchange-ru_stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "windows, администрирование, драйвер, iso образ"
} |
Displaying newline character in any JTextComponent?
How to display newline character in any `JTextComponent` (`JTextArea`, `JTextPane`)? | Guess that's what you need is <
It shows not only end of par shars but also spaces and tabs. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "java, swing, newline, jtextcomponent"
} |
JSON parse in iphone Application
I am new in iphone development. I want to use parse with Json framework in my iphone application. Can anybody provide me guideline or a good tutorial link .Thanks | If you mean this Json framework you can simply call
NSString *jsonString = // String in json format
SBJsonParser *jsonParser = [[SBJsonParser alloc] init];
NSError *error = nil;
[jsonParser objectWithString:jsonString error:&error];
Full api doc is here. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "iphone, ios, json"
} |
Selecting Principal Diagonal Elements
In the matrix shown below how can I select elements 01, 09, 17 and 25. From Egon's answer to my earlier question Select Diagonal Elements of a Matrix in MATLAB I am able to select the central value 25 using `c = (size(A)+1)/2;` but I am wondering how to select above mentioned elements in NW direction.
A = [01 02 03 04 05 06 07
08 09 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35
36 37 38 39 40 41 42
43 44 45 46 47 48 49]; | Use `diag` to get elements on the diagonal.
diagA = diag(A)
You can restrict this to the elements from the top left to the middle with
n = ceil(size(A, 1) / 2)
diagA(1:n) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "matlab, matrix, diagonal"
} |
Partial sum of geometric distribution
I am stuck with the following exercise, from _Probability_ by Grimmett and Welsh.
> If $X$ is a discrete random variable having the geometric distribution with parameter $p$, show that the probability that $X$ is greater that $k$ is $(1-p)^k$.
My idea: the required probability should be given by: $$ P=\sum_{i=k}^\infty p(1-p)^i $$ but how to sum this series? The only thing that came to my mind is: $$ P = p\sum_{i=k}^\infty (1-p)^i = p \left(\frac{1}{p}-\sum_{i=0}^{k-1}(1-p)^i\right). $$ But still I do not know how to sum the right hand side series. | $1-p<1$ then as you wrote
> $$ p \sum_{i=k}^{+\infty}\left(1-p\right)^{i}=p\frac{\left(1-p\right)^k}{1-\left(1-p\right)}=p\frac{\left(1-p\right)^{k}}{p}=\left(1-p\right)^{k} $$
Reminder : If $\left|x\right|<1$
$$ \sum_{n=p}^{+\infty}x^n=\frac{x^p}{1-x} $$ It comes from $$ \sum_{n=p}^{N}x^n=\frac{1-x^{N-p+1}}{1-x}x^p \ \text{ (Partial Sum of geometric sequences )} $$ And $$ x^{N-p+1} \underset{ N \rightarrow+\infty}{\rightarrow}0 \text{ because } \left|x\right|<1 $$ Hence the result. | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "probability"
} |
exact definition of Fiedler vector
For a given N-vertex similarity graph $ G=(V,A) $ the eigenvalues of the unrenormalized (graph) Laplacian may be denoted as
$$ 0= \mu_0 \leq \mu_1 \leq ... \leq \mu_N $$ where the corresponding eigenvectors may be written as
$$ v_0 , v_1 , ... ,v_N $$ In the case where $ 0= \mu_0 = \mu_1 < \mu_2 $ I find conflicting definitions for the Fiedler vector in the literature , namely $ v_1 $(eigenvector corresponding to the second lowest eigenvalue?) or $ v_2 $ (eigenvector corresponding to the lowest non-zero eigenvalue). Which one should one choose as Fiedler vector?
In addition things get ambiguous when the lowest non-zero eigenvalue is degenerated as well. For example assume $ N = 5 $ and $ A_{ij} = 1$ if $i \neq j $ and $0$ else. The eigenvalues of the Laplacian are (0,5,5,5,5) in this case. Which eigenvector corresponds to the Fiedler vector in this case?
A good reference would be appreciated ! | The concept of a Fiedler vector is defined for graphs that consist of one single connected component. Since the number of zero eigenvalues counts the number of connected components, the second largest eigenvalue $\nu_1$ is then always nonzero. The multiplicity $m_1$ of the second largest eigenvalue may be greater than one, in which case there is more than a single Fiedler vector.
One might ask why not extend the definition of the Fiedler vector to graphs with more than a single connected component. This is not particularly useful, as explained in this MO posting. | stackexchange-mathoverflow_net_7z | {
"answer_score": 7,
"question_score": 4,
"tags": "reference request, graph theory, eigenvalues, spectral graph theory"
} |
How to set position dynamically in mongoose push
I am trying to push some data to a nested array. My data is like:
{a:[{x:[{'y':'z'}]}]}
I am trying to push values into x array. I tried this way, it works=>
{ "$push": { "a.0.x": data}}
But, is there a way where I can pass the value `0` dynamically. I tried the following, but it doesn't work.
{ $push: { "a.$.x": {
$each: [data],
$position: 1
}}} | I didn't find a mongoose way. But, here is a way I did it by passing index to the object property.
var i = "1";
var obj = { ["prop"+i+"Name"]: "response" };
console.log(obj); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "node.js, mongodb, mongoose"
} |
Why is the OR operator used instead of AND operator in the select method?
Given a hash of family members, with keys as the title and an array of names as the values, use Ruby's built-in `select` method to gather only immediate family members' names into a new array.
# Given
family = { uncles: ["bob", "joe", "steve"],
sisters: ["jane", "jill", "beth"],
brothers: ["frank","rob","david"],
aunts: ["mary","sally","susan"]
}
The solution is:
immediate_family = family.select do |k, v|
k == :sisters || k == :brothers
end
arr = immediate_family.values.flatten
p arr
Why is `||` operator used instead of `&&` operator in the select method? When I run it with `&&`, the select method returns an empty array. | The `||` and `&&` operators mean `or` and `and` respectively in most programming languages.
The expression:
family.select do |k, v|
k == :sisters || k == :brothers
end
would translate into "select all elements of the `familiy` hash where the key is `:sisters` or `:brothers`". As @Ursus points out, in this case it doesn't make sense for `k` to be equal to `:brother` and `:sister` at the same time. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -2,
"tags": "ruby, logical operators"
} |
In Github, I want to prevent members from merging a pull request
In my workflow I have two default branches: `master` (production) and `dev` (staging). All members create their branches from the `dev` branch. However, I want require the members to do a `pull request` to merge back into the `dev` branch. Additionally, I want to prevent those members from approving the `pull request`. I want to be the only one to approve a `pull request` merge after a code review.
I've been looking at protecting branches but I'm not sure if I'm on the right track. | If you enable branch restrictions on your `master` and `dev` as mentioned < everyone who branches out from these 2 will have to create a pull request which only you can merge | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "git, github, pull request"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.