INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Lunch meat is slimy on outside?
Sometimes when I buy lunch meat cuts, from the supermarket, they quickly get slimy on the outside. Regardless of the date which is indicated by the sticker.
I perform taste, smell, and visual checks for discoloration, but the cuts of meat seem to pass all those criteria.
Is this a sign that it's about to expire? Also, why does it get slimy?
FYI: This happens on Dietz BBQ chicken, and this other chicken cut I get from Costco.
|
The rate of slime of a piece of food has to do with amount of surface area it has. At each point a food's surface is an entry point for bacteria. Since there is always bacteria on any cutting utensil or machine every cut piece of meat has been seeded with a bacteria culture. Although it might not kill you or make you visibly sick, the slime is coming from microbes which will stress your immune system that might be fighting other things instead. Unless it's Nato beans or oysters slime on food is no good. If the cold cuts are sliming quickly it might be because the grocer is not cleaning the machine properly or somebody's refrigeration is not cold enough, 5 to 10 degree f too warm.
|
stackexchange-cooking
|
{
"answer_score": 10,
"question_score": 14,
"tags": "food safety, chicken, sandwich"
}
|
Components: What is the purpose of the option_on and option_off fields in models > forms > viewname.xml?
In a Joomla 3.x component, a parameter that's frequently listed in the MODELS > FORMS > VIEWNAME.XML file is `option_on` or `option_off`.
For example;
<field
name="something_amazing"
type="editor"
label="COM_YOURNAME_FORM_LBL_VIEWNAME_SOMETHING_AMAZING"
description="COM_YOURNAME_FORM_DESC_VIEWNAME_SOMETHING_AMAZING"
menu_published="0"
filter="safehtml"
option_on="Yes"
option_off="Yes"
/>
Many of the available parameters are listed on the official documentation, but no matter where I look, I can't seem to find an explanation of these particular fields.
What are they for, and can you give an example of when you might use them?
Thanks in advance!
|
These options are generated (only) by extensions created with component-creator.com.
|
stackexchange-joomla
|
{
"answer_score": 2,
"question_score": 6,
"tags": "joomla 3.x, component, xml, component params"
}
|
Point actions to the same view
I have a controller with the following actions...
public ActionResult YellowList()
public ActionResult RedList()
public ActionResult BlueList()
All these actions populate the same viewModel (ListViewModel).
How do I get them all to point to the same view (aspx)?
Thanks,
ETFairfax.
|
In your action use this overload of the view method:
public ActionResult YellowList()
{
ListViewModel model = GetSomeModel();
return View("viewName", model);
}
public ActionResult RedList()
{
ListViewModel model = GetSomeModel();
return View("viewName", model);
}
public ActionResult BlueList()
{
ListViewModel model = GetSomeModel();
return View("viewName", model);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "asp.net, asp.net mvc"
}
|
Accessing variable passed to callback
Can anyone explain why the following won't work? The setTimeout callback in watchLog() will output undefined.
function initWatchers() {
if (config.watchLogs.length >= 1) {
config.watchLogs.forEach(function(path) {
watchLog(path);
});
}
}
function watchLog(path) {
setTimeout(function(path) {
console.log(path)
}, 1000);
}
|
Because `setTimeout`, when calling the callback function, does not pass any parameter into the function. So the parameter `path` in `function (path)` doesn't get any value and is `undefined`. Further, it shadows the `path` variable in the outer scope, replacing it (with `undefined`). You actually want this:
function watchLog(path) {
setTimeout(function () {
// no shadowing arg ^^
console.log(path)
}, 1000);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "javascript, asynchronous, callback"
}
|
New PayPal API - how to set up live application? Not Sandbox
It has been some time since I last set up PayPal payments on a website.
After I opened the new PayPal API and honestly, I am a little bit confused. At the moment, there is each new website considered by PayPal support?
On the following page, < I found **Test credentials** , but I want to set up **Live credentials**.
In the block with **Live credentials** , it is written:
Live credentials (currently for U.S. businesses)
We'll email you when your live credentials are ready.
How much it usually takes? And also, what everything is needed for being approved? Is there any way to make it faster or the only thing I can do is to wait?
Thanks
|
The first part of your question about new websites is unclear. But I would guess that the Classic APIs might be a better choice for your use-case, as the new RESTful API is still in a beta stage with limited features.
I see this is tagged as paypal-adaptive-payments. Adaptive Payments is its own separate API and you can read information on going live with it here: <
For the second part of your question, I am not sure how long it takes but my best guess from similar processes is two business days (Monday-Friday)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "paypal, paypal adaptive payments"
}
|
I've written a jQuery plugin - how do I get it to run automatically?
As the title suggests I've written my jQuery plugin.
It adds visual feedback for password constraints to a password field.
At the moment, I have to manually call it
$("#password").addPasswordConstraints();
How can I make the plugin run simply by being included?
//plugin version 0.2
(function($) {
$.fn.addPasswordConstraints = function() {
//plugin code goes here.
});
return this;
};
}(jQuery));
|
If you're looking to run it on page load for all password inputs, this should work.
(function($) {
$.fn.addPasswordConstraints = function() {
//plugin code goes here.
});
return this;
};
// On document ready apply it to every password field.
$(document).ready(function (){
$('input[type="password"]').addPasswordConstraints();
});
}(jQuery));
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "jquery"
}
|
Does creating webjobs are available on trail Azure subscription?
I need to create a WebJob through the Azure Portal. However, I'm not seeing an option to do so in the Portal through my trial subscription. Can you tell me how to set up a WebJob in the Portal using my trial subscription?
|
There's not an option to create an Azure WebJob as a separate resource. Instead, you want to create a Web App. A Web App can host a web application, but it can also host continuous and triggered WebJobs.
To provision a new Web App, click the New button in the upper left-hand corner of the portal. Choose "Web + Mobile", then choose "Web App".
After you create a WebJob project in Visual Studio, you can right click the project file and choose "Publish as Azure Webjob..."
If you browse to your Web App's management blade, you'll see a menu item called "WebJobs". This will list all WebJobs that are running on that WebApp.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "azure webjobs"
}
|
C++ NCurses how to get current cursor position?
How do I get the current position of the cursor in terminal with NCurses using C++? I searched around a bit and saw "getxy(int x, int y)". I tried that and got the error "'getxy' was not declared in this scope".
|
You might have forgotten some `#include <ncurses.h>` and the macro is spelled getyx
Don't forget to compile with `g++ -Wall -g` and to link with `-lncurses`
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 4,
"tags": "c++, linux, ncurses, cursor position"
}
|
Check file name and filter it based on the date
I have many files one of my scripts generate daily. The file name structure resembles:
capacity_data_2012-12-02.txt , capacity_data_2012-12-03.txt and so on...
I want to create a script which would check for the last month of data. For example today is capacity_data_2012-12-28.txt. I'd create a list of the files for the last 30 days. Any files more than 30 days old (not in my list) would then be moved to another directory.
Any direction would be helpful.
|
If you want to move files older than 30 days, or more precisely, files which as not been written in the last 30 days:
find . -maxdepth 1 -type f -name "capacity_data_???-??-??.txt" -mtime +30 -exec echo mv {} another_directory/ \;
(Remove the `echo` when you are happy with the output.)
If you want to list the files of the last 30 days:
awk 'BEGIN{now_n = systime() - 30 * 24 * 60 * 60;
for(n = 30; n >= 0; n--) {
print "capacity_data_" strftime("%Y-%m-%d", now_n) ".txt"
now_n += 24* 60 * 60;
}}'
And if you want to loop on those files:
files=$(awk 'BEGIN{now_n = systime() - 30 * 24 * 60 * 60;
for(n = 30; n >= 0; n--) {
print "capacity_data_" strftime("%Y-%m-%d", now_n) ".txt"
now_n += 24* 60 * 60;
}}')
for file in $files; do
echo $file
done
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linux, shell script, perl"
}
|
Python 3 sort a dict by its values
The only methods I found work for python2 or return only list of tuples.
Is it possible to sort dictionary, e.g. `{"aa": 3, "bb": 4, "cc": 2, "dd": 1}`, by its values?
Order of sorted dictionary I want to achieve is from largest to smallest. I want results to look like this:
bb 4
aa 3
cc 2
dd 1
And after sorting I want to store it into a text file.
|
`itemgetter` (see other answers) is (as I know) more efficient for large dictionaries but for the common case, I believe that `d.get` wins. And it does not require an extra `import`.
>>> d = {"aa": 3, "bb": 4, "cc": 2, "dd": 1}
>>> for k in sorted(d, key=d.get, reverse=True):
... k, d[k]
...
('bb', 4)
('aa', 3)
('cc', 2)
('dd', 1)
Note that alternatively you can set `d.__getitem__` as `key` function which may provide a small performance boost over `d.get`.
|
stackexchange-stackoverflow
|
{
"answer_score": 126,
"question_score": 91,
"tags": "python, python 3.x, sorting, dictionary"
}
|
Radioactive isotopes differential equationa
I am having a hard time finding the correct differential equation to my problem. The problem is :
There's 2 isotopes: A and B. A is is transforming into B to a rate proportional to its quantity and B is decreasing to a rate proportional to its quantity.
I need to find an equation that gives the quantity of the B isotope at time t.
I've found the the equation of the lost of A over time, but I don't know how to integrate it to the differential equation of B.
The quantity of A isotope that has turned into B over time is y(t) = yi*e^(kt)
**edit** B is not a fixed quantity. It's the lost quantity of A so the lost rate of B is proportional to the quantity B at the time which is equals to the lost quantity of A - minus the quantity of B that has been lost over time.
Thanks for the help
|
Let $A(t)$ be the amount of substance A at time $t$, and let $B(t)$ be the amount of substance B at time $t$.
For suitable decay constants $a$ and $b$, we have $$A'(t)=-aA(t),$$ and $$B'(t)=-A'(t)-bB(t)=aA(t)-bB(t).$$ The second equation comes from the fact that B atoms are "born" (through decay) at rate $aA(t)$, and die at rate $bB(t)$.
How we handle these is a matter of taste. If it is familiar, we can express the system in matrix notation. The more straightforward approach is to solve the first equation explicitly for $A(t)$, and substitute in the second equation. We obtain a fairly simple but non-homogeneous linear equation.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "ordinary differential equations"
}
|
Fazendo com que um input só apareça quando um option(select) for escolhido
Tenho um formulário de cadastro, com um selected, mas uma das opções desse selected quando selecionada deveria aparecer um input. Exemplo:
<select>
<option>value1</option>
<option>value2</option>
</select>
<input type="text" style="display:none" />
quando fosse escolhida a opção 2. aparecesse o input(display:block)
Alguém sabe como fazer isso? obrigado
|
Primeiro, dê um `id` ao seu `select` para que possamos trabalhar com ele no javascript.
Depois, você pode colocar seu `input` dentro de uma `div` e exibi-la ou oculta-la de acordo com o option selecionado.
$(document).ready(function() {
$('#inputOculto').hide();
$('#mySelect').change(function() {
if ($('#mySelect').val() == 'value2') {
$('#inputOculto').show();
} else {
$('#inputOculto').hide();
}
});
});
<script src="
<select id="mySelect">
<option>value1</option>
<option>value2</option>
</select>
<div id="inputOculto">
<input type="text" />
</div>
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 5,
"question_score": 2,
"tags": "javascript, jquery, html"
}
|
Can't update Nginx to version higher than 1.12.2 in ubuntu 16.04
I have been trying to update Nginx to it's latest version in my ubuntu server.
So, I tried with this command:
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
But the result showing that **Nginx is already in the newest version (1.12.2-0+xenial0)**
 Thanks!
|
Answer: there is no way to do this.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "google maps, google maps api 3, google maps markers"
}
|
Antiderivative of $\cos(x)\ln(1+\cos(x))$
I'm trying to find the antiderivative of $A(x)=\cos(x)\log(1+\cos(x))$
By using integration by parts I get :
$$\int A(x)\, dx = \sin(x)\ln(1+\cos(x))+\int \frac{\sin^2(x)}{1+\cos(x)} \\\ =\sin(x)\ln(1+\cos(x))+\sin(x)\int \frac{\sin(x)}{1+\cos(x)}\\\ =\sin(x) \ln(1+\cos(x))+\sin(x)(-\ln(1+\cos x))=0$$
However using formal calculator I find the antiderivative is $x+\sin(x)\ln(\cos(x)+1)-\sin(x)$. I do not see where is my mistake I applied $\int u'v \,dx=uv-\int uv'$ with $u'=\cos(x)$ and $v=\ln(1+\cos(x))$
Thank you
|
On the second line, you cannot pull the $\sin(x)$ in front of the integral. You should use $$ \sin^2(x)=1-\cos^2(x)=(1+\cos(x))(1-\cos(x)). $$
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 4,
"tags": "indefinite integrals"
}
|
Insert data in local system but not inserted in live in codeigniter
In my codeigniter application data is inserted to database in my local system but on live data is not inserted into database and no error is occurred, how to debug?
|
I cross the post data limit due to data is not inserted,I change it and it's working now.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "php, codeigniter"
}
|
set new value for "ft_min_word_len " FULLTEXT in mysql
I changed to `"ft_min_word_len" = 4` by `my-innodb-heavy-4G.ini` located in my system path `"C:\Program Files\MySQL\MySQL Server 5.1"` , but when i run
SHOW VARIABLES LIKE 'ft_min_word_len'
I got still result `value= 4`. I did not find this variable in `my.ini` file. So i have also create a my logic. I copied to `ft_min_word_len` variable and place in `my.ini` file and now my result show `value=3`.
But it is not working for three character search. I've restarted server.
How can i achieve to be able to search three character value also.
|
You should change this system parameter, restart server and then rebuild ALL FULLTEXT indexes.
REPAIR TABLE <TableName> QUICK;
* Change the full text index minimum word length with MySQL
|
stackexchange-stackoverflow
|
{
"answer_score": 24,
"question_score": 15,
"tags": "mysql, full text search, database administration, fulltext index"
}
|
Sentences in newer Cobol versions
Cobol sections and paragraphs are subdivided into sentences. In older Cobol versions (without explicit scope delimiters e. g. `END-IF`) defining multiple sentences per section/paragraph was required to limit the scope of conditional statements (e. g. `IF`).
Are there any use-cases where defining multiple sentences is required in newer Cobol versions? Or are sentences just there for historical reason?
|
As Bill Woodger says, sentences only exist now for backwards compatibility.
There is now only one place where multiple sentences must be used: in `DECLARATIVES`, where the `USE` statement must be in its own sentence.
DECLARATIVES.
a-file-error SECTION.
USE ON a-file.
DISPLAY "Oops"
.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "cobol"
}
|
Java get Session Cookies
Getting header fields from a URLConnection doesn't get session cookies for me.
When I use `CookieManager` I can get session cookies from a URL:
CookieManager manager = new CookieManager();
manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(manager);
URLConnection con = url.openConnection();
con.getContent();
CookieStore cookieJar = manager.getCookieStore();
List<HttpCookie> cookies = cookieJar.getCookies();
This is fine, but I need to send a POST request. So I am writing to the URLConnection's output stream. My question is how to get the session cookies after sending the POST request.
|
Try using the same CookieManager object with your first and subsequent requests using URLConnection.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, session, cookies, session cookies"
}
|
In PHP, how can I compare three queries to select corresponding rows?
I have three individual queries that are used to select users dependent on the variables. Each user has a unique user ID which is on each table effected by the queries. Is there a way, with PHP, that I can only select the users that return for all three queries?
|
Yes, do an inner join on all three tables using the common field.
Ex:
Select cola, colb
From tablea join tableb
On a.commoncolumn=b.commoncolumn
Join tablec on a.commoncolumn=c.commoncolumn
Where ...
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, sql"
}
|
Gas mixture algorithm
I have a pool of ten different gas mixtures. Each gas mixture is made of nitrogen, oxygen and carbon dioxide in different percentages.
The goal is to mix and match sets of gasses to to get a requested percentage output.
Lets say we want 33-33-33 out. Whats the best methodology to select the best subset of gases and mixing proportions to get an optimal output?
|
Just solve 3 equations with 3 unknowns.
if mixture 1 has a1 fraction of chemical a (and similarly with other chemicals/mixtures), and you need xa : xb : xc mixture, where xa+xb+xc=1, this will be:
a1 * x1 + a2 * x2 + a3 * x3 = xa
b1 * x1 + b2 * x2 + b3 * x3 = xb
c1 * x1 + c2 * x2 + c3 * x3 = xc
Solve for x1, x2, x3. If you get negative numbers (or no solutions), this means that it's impossible to get the wanted mixture.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "algorithm"
}
|
How to prevent someone misusing routing systems?
I'm using a routing system. You can use the url to do some quick updates etc, without having to create a page for it. I believe this to be very effective. Though, how can I prevent a user misusing it?
This line updates a users account:
Class: User
Method: update
Set permissions => 1
Where id is 29
It works very nice, but any user could be able to type this in his URL if he knew in what way the system works.
Are there any ways to prevent misuses like this one?
Thanks!
|
You should implement User Authentication, then check if user is logged in and if he has required permissions. I don't see any other way to do it simpler.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "php, oop, routes, misuse"
}
|
form :remote => true, not working in IE?
- form_for(@post, :remote => true, :id => 'post_form') do |f|
Works as expected in FF and Chrome, but IE just processes the submit action normally, without any ajax request.
Not really seeing any info on this on the rest of the internet so I imagine I've done something wrong somehow. Ive used both the default rails.js, and the jquery version from the github page
|
Well, I don't know why the default rails version doesn't work for me here on IE, but I wrote this as a workaround:
if ($.browser.msie) {
var form = $('form#new_post');
form.find('input#post_submit').bind('click', function(){
var data = form.serializeArray();
$.ajax({url: '/posts', type: 'POST', data: data});
return false
});
}
And now it's working correctly. Shouldn't something like this be included in rails.js if this is in fact a problem with Rails, and not something that I've somehow done?
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "ruby on rails 3"
}
|
Selecting options from Auto Complete Dropdown using selenium web driver in python
I have to select options from a drop down on a page. I tried the below code but it is showing a syntax error. Can somebody help me with this?
web_element x = driver.find_element_by_xpath('//*[@id="txtSearchPhone"]')
Select sel = new Select(x)
sel.select_by_value("Iphone")
I tries Web_element, WebElement too. But this is showing syntax error for the very first line.
web_element x = driver.find_element_by_xpath('//*[@id="txtSearchPhone"]')
^
SyntaxError: invalid syntax
|
You can use the following code block to select the option `Apple iPhone 6 128GB` from the suggestions:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome(executable_path= r"C:\\Utility\\BrowserDrivers\\chromedriver.exe")
driver.maximize_window()
driver.get('
driver.find_element_by_xpath("//input[@id='txtSearchPhone']").send_keys("Apple iPhone 6 128GB")
WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, "//li[@class='ui-menu-item']/a[contains(@id, 'ui-id-')][text()='Apple iPhone 6 128GB']")))
driver.find_element_by_xpath("//li[@class='ui-menu-item']/a[contains(@id, 'ui-id-')][text()='Apple iPhone 6 128GB']").click()
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, selenium, drop down menu, autocomplete"
}
|
Delete Object from CoreData (error)
I'd like to delete an object from core data. I tried this code but it's not working. What's wrong? I'm working with Swift and Xcode 6.1.1.
Code:
let managedObjectContext = (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext
var daten = [TaskModel]() //CoreData Entity
managedObjectContext!.deleteObject(daten[indexPath.row])
appDelegate.saveContext()
let fetchRequest = NSFetchRequest(entityName: "TaskModel")
daten = managedObjectContext!.executeFetchRequest(fetchRequest, error: nil) as [TaskModel]
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Right)
|
`daten` is an empty array.
Therefore, `daten[x]` will crash.
In your case, `x` is `indexPath.row`, but it will crash with any value.
If you try to access an element of an empty array by index, you will get the above error.
To get an object from your fetched results controller and delete it,
let task = self.fetchedResultsController.objectAtIndexPath(indexPath) as TaskModel
self.fetchedResultsController.managedObjectContext.deleteObject(task)
self.fetchedResultsController.managedObjectContext.save(nil)
The standard implementation of the fetched results controller from the Xcode template will take care of updating your table view automatically, you even get animation for free.
If you are **not** using a `NSFetchedResultsController`, stop here and refactor.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "ios, swift, core data"
}
|
Открыть таблицу из текстового файла с форматированием
Есть файл .txt, внутри которого находится таблица в том виде, в котором надо отобразить в Экселе. При использовании функции `xlsfile.Workbooks.Open(edit1.Text);` \- где `edit1.Text` \- путь и имя текстового файла, возникает проблема с форматированием - строки не разделяются на столбцы. Вот как задать форматирование, как при открытии таблицы в Экселе( сначала, чтоб столбцы были фиксированной ширины, потом чтоб определенный столбец имел определенный формат данных)
|
Все сделать можно, но описывать много и долго. скачай книгу **Разработка приложений Microsoft Office в Delphi** и почитай там все описано.
Программирование документов и приложений MS Office в Delphi
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "delphi, excel"
}
|
How to add DataGridViewLinkColumn property to dynamically generated columns in DataGridView?
**Developing In:** `c# winforms` without any Database Connections
**Description:** In my DataGridView, columns were dynamically generated.At some point some of the columns need to be DataGridViewLinkColumn property. I was tried in many ways but didn't achive this.
I hope someone from here would help me :)
Thanks In Advance.
|
You will need to switch off `AutoGenerateColumns`, then generate each column yourself.
Setup the normal columns as type `DataGridViewTextBoxColumn`, then for the columns which need to be Linked columns set them up as type `DataGridViewLinkColumn`.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "c#, winforms, datagridview"
}
|
What doctypes are available in Yesod Hamlet?
In Hamlet, `$doctype 5` generates `<!DOCTYPE html>`. The Yesod book says that "We have support for a number of different versions of a `doctype`", but does not document these. What other doctypes are supported and what is the syntax?
|
You can see the list in the source code:
<
The theory behind this was that people were going to ask for all the additional doctypes that they needed, and once we had a comprehensive list, we'd put it in the docs. It seems that no one cared about anything but the HTML 5 doctype.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "doctype, yesod, hamlet"
}
|
On limits related to $\frac1{\ln n}\sum\limits_{r=1}^{n^4}\frac1r$ when $n\to\infty$
> $$L=\lim_{n\to\infty}\frac1{\ln n}\sum_{r=1}^{n^4}\frac1r,\qquad M=\lim_{n\to\infty}\left\lfloor\frac1{\ln n}\sum_{r=1}^{n^4}\frac1r\right\rfloor$$
* * *
I know that $$\lim_{n\to\infty}\frac1n\sum_{r=1}^{n^4}\frac nr=\int_{\lim\limits_{n\to\infty}1/n}^{\lim\limits_{n\to\infty}n^4/n}\frac{dx}x=\ln 4-\color{red}{\ln 0}\to-\infty$$
I suspect the limits to both doesn't exist.
|
This exercise is meant to help you discover/apply the properties of the partial sums of the harmonic series), known as the harmonic numbers $$H_n=\sum_{k=1}^n\frac1k.$$ For example, for every $n\geqslant2$, $$\log n\lt H_n\lt1+\log n.$$ This suffices to answer your question. Do you see why?
Note that, if $\lfloor\ \rfloor$ in the formula for $M$ stands for the integer part, the bounds above yield $$M=4.$$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sequences and series, harmonic numbers"
}
|
n is of the form 3(mod 4), prove n cannot be sum of two squares.
I have looked across old past papers whilst revising and have stumbled across a question I have not seen before,
**Let $n$ be a positive integer of the form $3(\textrm{mod} \; 4)$, show that n cannot be written as the sum of two squares.**
I began by writing $$n=p_1^{a_1} {p_2^{a_2}} \cdot\cdot \cdot {p_k^{a_k}}.$$ Where $p$ is a prime number then I wrote $n=3+4t$, but I am not sure where to go from here, all help would be appreciated.
|
There's no reason to think in terms of prime factorization. If $m^2+n^2\equiv3\pmod 4$, then $m$ and $n$ can't be both even nor can they be both odd. Therefore, you can assume withou loss of generality that $m$ is odd and $n$ is even. If $m=2a+1$ and $n=2b$, with $a,b\in\mathbb Z$, then$$m^2+n^2=4(a^2+a+b^2)+1\not\equiv3\pmod4.$$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 3,
"tags": "elementary number theory, prime numbers, modular arithmetic"
}
|
ARM __clear_cache equivalent for iOS devices
I'm porting a library to the iPhone which makes a call to `__clear_cache`. A little research digs up this nice explanation of what it does.
The article lists the library functions for Linux, Windows and even Android. I don't suppose there is an equivalent for iOS devices? Or some other workaround I can implement?
|
As iOS is a *NIX-based platform, and you can compile code with apple's version of GCC (LLVM-GCC 4.2), you should just be able to make a function call to `__clear_cache()`, like this:
extern void __clear_cache(char *beg, char *end);
__clear_cache(beg, end);
Note that this will NOT work with `Apple LLVM Compiler 3.1`, only with GCC for some odd reason.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "ios, arm"
}
|
Mongoose is undefined when using import syntax and not when using require
So I have my module written as such
import mongoose from 'mongoose';
export class MyModule {
constructor(){
//do
}
create(str){
mongoose.connect(str); //cannot find property 'connect' of undefined
}
}
When using the import syntax, I get the `cannot find property 'connect' of undefined` error; it works as intended when using require.
Weirdly enough, importing individual properties via import syntax works as intended,
import { connect } from 'mongoose'
but I need access to the entire ORM for some other reasons.
Why is it like so? Am I doing something wrong? To be fair, I don't have much experience in ES6 module system, TypeScript and Node.js so I might be missing something here.
* * *
I'm running this on Node.js with NestJS, on a typescript file.
|
> There are total 2 syntex we can use here.
# ES15 (NodeJS)
const mongoose = require('mongoose');
then use **mongoose.connect**
# ES16 (import/export)
import * as mongoose from `mongoose`;
then use **mongoose.connect**
### or
import {connect} from `mongoose`;
then use **connect** directly
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "javascript, typescript, mongoose, ecmascript 6, nestjs"
}
|
Tension on a string
A string is attached at both extremities and put under tension $T_0$ at rest. We know that if we pull the string upwards from the middle, the tension will increase. But why is it that, admittedly, $$T\cos(\alpha) = T_0$$ or $$T = \frac{T_0}{\cos(\alpha)}~ ?$$
I understand the trigonometry, but Why is the new tension directly proportional to $\frac{1}{\cos(\alpha)}$ ? Is it that obvious ? I would have imagined something involving the length change and the material properties like elasticity ...
!enter image description here
|
The equation you quote is an approximation that is only valid if the horizontal force on the string remains the same. In practice that is not the case - and your concern is valid.
The increase in length $\Delta \ell =\ell(\frac{1}{\cos\theta}-1)$; how much additional force that generates depends on the unstretched length of the string (or equivalently on its elastic coefficient) since $\Delta T = k(\ell - \ell_0)$ where $\ell_0$ is the unstretched length.
It follows that while $\Delta T = k \Delta \ell$ the original tension is not $k\ell$ so the equality is not exact. But for small displacements it is usually good enough.
When I have a chance I will add some diagrams.
|
stackexchange-physics
|
{
"answer_score": 4,
"question_score": 0,
"tags": "homework and exercises, newtonian mechanics, forces, vectors, string"
}
|
Increase column length of Acumatica field to nvarchar(max)
I want to increase the column length of a standard Acumatica field from nvchar(1000) to nvarchar(max), but not sure about how to do this. I tried to use the column length increase but it does not allow entering MAX. I tried the below, but it resulted in ntext rather than nvarchar(max).
<Column TableName="SMEmail" ColumnName="MailBcc" ColumnType="string" AllowNull="True" DecimalPrecision="0" DecimalLength="0" IsUnicode="True" />
ntext, text, and image data types will be removed in a future version of SQL Server, therefore it's best not to use these.
The other option I am thinking is to use a DDL script to Alter the column, but I would have preferred to do it using standard Acumatica functionality instead. Is there a way to do it without executing an Alter script?
|
The Customization Project Editor tool engine won't allow you to set 'MAX'. The maximum value allowed in the Customization Project Editor tool engine is '4000'. So you could use this '4000' value instead.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "acumatica"
}
|
How to convert Iterator to scalaz stream?
Suppose I've got an `Iterator[A]`. I would like to convert it to `Process[Nothing, A]` of scalaz stream.
import scalaz.stream._
def fooA: Process[Nothing, A] = ???
How would you implement `foo` ?
|
I think that you can do it using `unfold`:
import scalaz.stream._
def fooA: Process[Nothing, A] = Process.unfold(it) { it =>
if (it.hasNext) Some((it.next, it))
else None
}
Example:
scala> foo(List(1,2,3,4,5).iterator).toList
res0: List[Int] = List(1,2,3,4,5)
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 7,
"tags": "scala, scalaz stream"
}
|
width not picked up by cgrect()
i wanted to ask why doesnt my layer.frame = cgrect() doest not pick up the width (350) which i have set in the viewDidLayoutSubviews even though it does get printed in the console. but the width remains the same(390) as i have set in the storyboard.
override func viewDidLayoutSubviews() {
width = masjidName.frame.width
print(width)
}
override func viewDidLoad() {
super.viewDidLoad()
viewDidLayoutSubviews()
let bottomLine1 = CALayer()
bottomLine1.frame = CGRect(x: 0.0, y: masjidName.frame.height - 1, width: width, height: 1)
bottomLine1.backgroundColor = UIColor.black.cgColor
let bottomLine2 = CALayer()
bottomLine2.frame = CGRect(x: 0.0, y: masjidName.frame.height - 1, width: width, height: 1)
bottomLine2.backgroundColor = UIColor.black.cgColor
}
|
I got it to work by moving what I had In viewdidload into viewdidappear. As it takes a while for widths to update and viewdidload is called before it.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "ios, swift, autolayout"
}
|
How can I access a specific character in an <int,string> map?
I have a map in C++ and I want to access only a specific character in the string. I have a loop that looks something like this.
map<int, std::string> line;
for (int j = position; j < position+WIDTH; j++)
{
// get the next number
int number = convertToInt(line[j][position]); // <---Need only 1 char
std::cout << "Number :: " << number << std::endl;
}
position++;
|
Your code works fine because
line[j] //retrun string
[position] //retrun a specific character in place of position of the line[j]
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "c++, string, hashmap, character"
}
|
Mapping to Dictionary with iBATIS
Given a simple statement, such as:
<statement id="SelectProducts" resultMap="???">
SELECT * FROM Products
</statement>
Is it possible to get a list of dictionary objects where the keys are the column names? ie.
var list = Mapper.QueryForList<IDictionary<string,string>>("SelectProducts", null);
IDictionary<string, string> dict = list[0];
// dict["id"] == "1"
// dict["name"] == "Some Product Name"
// dict["price"] == "$9.99"
// etc.
I'd like to generalize the result of a query to handle any number of columns/column names without mapping to specific properties on some class.
I realize the example here would fail since a result set may have duplicate (or null) column names. I've thought about a result class that holds an indexed list of key-value pairs. The key thing here is retaining the column information somewhere.
|
You can do this by setting the class attribute to HashTable in the resultMap configuration. More details available here.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": ".net, ibatis, datamapper"
}
|
GPGPU, OpenCL, CUDA, ATI Stream
Please tell me what technologies GPGPU exist already and which hardwares vendor's implement GPGPU?
I've been reading articles on various sites from morning and I've become confused.
|
`AMD-ATI` allows you to harness the power of GPU using a language based on `Brook+`. And `nVidia` provides `CUDA`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "cuda, gpgpu, nvidia, ati"
}
|
SwiftUI: How can I increase the area in which a button can be triggered?
How can I increase the area in which a button can be triggered without changing the UI?
This is my code
struct ContentView: View {
var body: some View {
NavigationView {
Text("Text")
.navigationBarTitle(Text("Title"))
.navigationBarItems(
leading:
Button(action: { print("add") }) {
Image(systemName: SFSymbolName.plus)
.font(.system(size: 18))
}
)
}
}
}
|
For this particular situation, You can add padding to all edges excluding the leading edge **to the`label` of the button**:
Button(action: { print("add") }) {
Text("+")
.padding(EdgeInsets(top: 20, leading: 0, bottom: 20, trailing: 50))
}
.background(Color.red) // This is just for seeing the hit area. You should get rid of it
**Note that** The maximum tappable area should be inside the rectangle above the title:

<xsl:variable name="empid_field">
<xsl:for-each select="$fields">
<xsl:if test="internalName='EMP_ID'">
<xsl:value-of select="position()"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
|
Ok got something ...
Created a comma separated string and picked the part before the delimiter.
<xsl:variable name="empid_fields" >
<xsl:for-each select="$fields">
<xsl:if test="internalName='EMP_ID'">
<xsl:value-of select="position()" />
<xsl:text >, </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="empid_field" >
<xsl:value-of select="substring-before($empid_fields, ', ')" />
</xsl:variable>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "xslt"
}
|
Why is there a negative voltage?
=0\iff\\\ 0=\cos^2\theta k_1+\sin^2 \theta k_2\iff\\\ \sin^2 \theta=\dfrac{-k_1}{k_2-k_1};\cos^2\theta=\dfrac{k_2}{k_2-k_1}.$$
To get bissection, I thought that I should obtain $\sin^2 \theta=\cos^2\theta$. I cannot finish.
Many thanks in advance.
|
**HINT** : Solve your equation
$$0 = k_1\cos^2\theta + k_2\sin^2\theta$$ for $\theta$.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 4,
"tags": "differential geometry, conic sections, surfaces, vector fields, curvature"
}
|
Formatação django template numero decimal
Estou tendo problemas na exibição dos resultados de um calculo. Eu tenho um campo DecimalField e quero retornar ele formatado dessa maneira:
1.000.000,00
Se eu mando exibir normalmente sem tags, fica assim:
1000000,00
Se eu adiciono `{{value|floatformat:2}}` fica igual:
1000000,00
Se eu faço o load do humanize e adiciono um intcomma (`{{value|floatformat:2|intcomma}}` fica assim:
1,000,000,00
Eu não estou sabendo resolver esse problema. Meu `settings.py` está dessa forma:
LANGUAGE_CODE = 'pt-BR'
TIME_ZONE = 'America/Sao_Paulo'
USE_I18N = True
USE_L10N = True
USE_TZ = True
|
Adicione em settings (considerando as suas outras configurações, não há necessidade do humanize):
THOUSAND_SEPARATOR='.',
USE_THOUSAND_SEPARATOR=True
Na template:
{% load l10n %}
...
{{valor | floatformat:2}}
Exemplo de uma saída em que pego o valor digitado e multiplico por 2:
 "duration" property or "year" (and
* eventually) "month" properties.
*
* @return array Array containing start date and end date DateTime objects.
*/
public function parseTimeArgs($args)
{
$now = new DateTime();
if(isset($args->duration) && $duration = new DateInterval($args->duration))
return array((clone $now)->sub($duration), $now);
}
|
No, this is not possible. You could use a "factory" method instead:
public function parseTimeArgs($args)
{
$now = new DateTime();
if(isset($args->duration) && $duration = new DateInterval($args->duration))
return array($this->clone($now)->sub($duration), $now);
}
public function clone($object)
{
return clone $object;
}
Side note: Using the `new` operator is currently not possible this way either. In the upcoming PHP 5.4 release this will be possible for `new` as follows:
$a = (new a())->doStuff()->foMoreStuff();
Clone however is not supported here.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "php, object, clone, chaining"
}
|
Probability that the first number is strictly greater than the second
_This is a nice problem on Probability. I request you all to please help me with the same._
_Problem -_
A number consists of three distinct digits chosen at random from $1, 2, 3, 4, 5, 6, 7, 8$ and $9$ and then arranged in descending order. A second number is constructed in the same way except that the digit 9 is not be used. What is the probability that the first number is strictly greater than the second number?
|
HINT: The first number is guaranteed larger if $9$ is one of the three digits chosen (because the sorting will put it first, i.e. in the hundreds place). So you can just condition on this event.
* What is the prob that $9$ is one of the three digits chosen?
* Conditioned on $9$ being not chosen, what is the prob that the first number is strictly greater than the second?
* Apply the law of total probability.
Can you finish from here?
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 2,
"tags": "probability"
}
|
JS countdown doesn't work
This code is supposed to show a seconds countdown on an HTML page. But it does not work at all. What could be wrong? I kinda copied the code from a website, and just added few details.
function timer() {
var now = new Date().getFullYear;
var newdate = new Date("March, 19, 2014");
var SecCount = (newdate - now) / 1000;
SecCount = Math.round(SecCount);
if (SecCount === 1) {document.getElementById("days").innerHTML= "يوم واحد"; }
else if (SecCount === 2) {document.getElementById("days").innerHTML= "يومان"; }
else if (SecCount > 2 && SecCount < 10) {document.getElementById("days").innerHTML = (SecCount + " أيام"); }
else {document.getElementById("seconds").innerHTML = (SecCount + " يوم"); }
setTimeout(timer,1000);
}
|
assuming you want the full date that is now for the variable 'now', you should use `Date.now`. getFullYear will only return 2014 which will give you unexpected results. **this solution is only if you want a count down till March 19 2014.**
// var now = new Date().getFullYear
var now = Date.now();
the variable day count isn't in the form of days, it should be this instead
// convert the seconds into days
var DayCount = Math.round(SecCount / (3600 * 24));
did you call the function to start the timeout loop ?
timer();
**jsfiddle**
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -3,
"tags": "javascript"
}
|
Lost changes in TFS
On Commit found many conflicts in files after taking latest, so I remove mapping thinking remap somewhere else and paste my old local changes in latest version of TFS but remove mapping remove all files with my latest changes. I have remapping my code somewhere but please help me that how I can find my old changes
|
I haven't resolved for conflict, but just remove mapping and bind again for somewhere else, but after remapping binding again to my original first path no loss I found there, all checked out files were remain same...
might be helpful for others
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "tfs, visual studio 2013"
}
|
I signed an offer. Can I change my mind?
I signed an offer letter for a job that will start later this year. Now I changed my mind, and I want to accept another job. My question is: **can I refuse a job after I signed an offer letter without any legal consequence?**
I read the offer I signed and I can't find anywhere any sentence that suggest that it is a binding contract, so I think that there are no problems. However, I'm wondering: is there any legal binding implied in the offer letter?
The job is in California.
|
If you're going to immediately quit anyway, I'm sure they would prefer that you contact them now and apologise, before they waste more money on you.
That's probably about as much damage control as you can hope to achieve.
|
stackexchange-workplace
|
{
"answer_score": 4,
"question_score": 0,
"tags": "job offer, united states, contracts, california"
}
|
Can I upload 13TB(folders and files) to OneDrive or SharePoint and do collaborate work with that files?
I need to upload all folders since my company PC to SharePoint for collaboration work with that, but I don't know if it is possible because if I synchronize with OneDrive the space is limited.
|
**Sharepoint limit**
Max storage per site (site collection) is 25 TB. In a SharePoint Online subscription you will get 1 TB plus 10 GB per license purchased space by default.You could split the data between various Sitecollections. It is normal for an organization to have 100's-1000's of site collections. If you wish to add additional space to the 1TB you need to purchase more storage which is available on the on the Site Collections page inside SharePoint admin or on the subscriptions page inside Office 365 Admin.
**Onedrive limit:**
You get 5 GB of free storage when you sign up for OneDrive.Microsoft 365 subscribers can buy up to 2 TB of OneDrive storage.
So onedrive can't store 13TB files, sharepoint can.
Reference: <
<
* * *
If the answer is helpful, please click "√" on the left panel of the answer and kindly upvote it.
|
stackexchange-sharepoint
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sharepoint online, document, file, onedrive, limitations"
}
|
Displaying a quote from the first post using Jekyll
I'm trying to set up Jekyll so that a quote from the first post in the list of posts is displayed in a sidebar, but I can't quite work out how to do it. I have the quote text defined as a `quote` variable within the YML Front Matter in each post's Markdown.
This is the relevant extract from my **default.html** :
<div id="content">
{{ content }}
</div>
<div id="sidebar">
<blockquote>{{ page.quote }}</blockquote>
</div>
And this is my **index.html** :
---
layout: default
quote: ** Can a variable referencing the first post go here? **
---
{% for post in site.posts limit:10 %}
<h2>{{ post.title }}</h2>
<div class="post">
{{ post.content }}
</div>
{% endfor %}
|
After much experimentation, I was able to solve the problem using this Liquid snippet within **default.html** :
<div id="sidebar">
<blockquote>
{% if page.quote %}
{{ page.quote }}
{% else %}
{{ site.posts.first.quote }}
{% endif %}
</blockquote>
</div>
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "liquid, jekyll"
}
|
Sent two models to a view with Sequelize
I tried to send two models to a view with Sequelize but I don't know how to proceed.
My code below doesn't work.
Post.findAll().success( function(posts) {
Creation.findAll().success( function(creations) {
res.render('admin_index', {
creations: creations,
posts: posts
});
});
});
Anthony
|
Actually you arent returning any posts in your callback and that's why posts is undefined.
So that you cant access it in yoru res.render context.
Check this part of your callback
Creation.findAll().success( function(creations) {
// The other stuff
});
Here you are only returning creations instead you should write a query that returns both creations and posts. Or do multiple queries in a callback chain something like these.
RandomQuery.findAll().success( function(creations,posts) {
// The other stuff
});
Or chain the callbacks inside each other
Creation.findAll().success( function(creations) {
Post.findAll().success(function(posts){
res.render('admin_index', {
creations: creations,
posts: posts
});
});
});
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "node.js, express, sequelize.js"
}
|
How do I install the ubuntu-restricted-extras package?
I would like to install the restricted extras package, which I didn't select during the install. How can I do that?
* * *
> ubuntu-restricted-extras is a meta-package that installs:
>
> * Support for MP3 and unencrypted DVD playback
> * Microsoft TrueType core fonts
> * Flash plugin
> * codecs for common audio and video files
>
|
First, be warned that it might not be legal in some countries, because of software patents.
With that being said, here is how to install it, click here:
ubuntu-restricted-extras 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"
else
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"comgooglemaps://"]];
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 0,
"tags": "ios, xcode, url, google maps mobile"
}
|
How to switch C++ array elements positions based on specified conditions?
I'm having a little problem with getting my head around this homework task. The task says:
"Write a function called **MoveSmallest** that moves all the minimal integer elements at the start of the array. All the remaining items must stay at their places. (the array and its size are parameters)
_Example:_ the array: 2, 3, 5, 1, 2, 3, 6, 4, 2, 1, 1 changes into 1, 1, 1, 2, 3, 5, 2, 3, 6, 4, 2
void MoveSmallest(int A[],int n)
{
int Min;
for(int i=0;i<n;i++)
{
if(i==0)
{
Min=A[i];
}
else if(A[i]<=Min)
{
Min=A[i];
}
}
So far I've only figured to check which one is the smallest element of the array. I don't have any ideas what to do next.
|
Once you have found the minimum value, all there is left to do is moving things around in order to have the minimum values at the beginning of the array.
You can do this by permuting the values until you have arrived to the "left" of the array (i.e index 0).
void MoveSmallest(int A[],int n)
{
int Min;
for(int i=0;i<n;i++)
{
if(i==0)
{
Min=A[i];
}
else if(A[i]<=Min)
{
Min=A[i];
}
}
for(int i = 0; i < n; i++)
{
if(A[i] == Min)
{
for(int j = i; j > 0; j--)
{
int tmp = A[j];
A[j] = A[j-1];
A[j-1] = tmp;
}
}
}
}
You could also use `std::swap` to do the permutation, instead of the temporary variable `tmp`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "c++, arrays, function"
}
|
What is a good Google Fonts serif typeface for a content website?
the authors on my website insist we use serif typeface as it identifies our purpose. I've tried two fonts, Playfair Display and Sanchez, but both have visual problems.
I need a very simple, highly readable, and soft on the eyes serif typeface that can be linked from Google Fonts.
This is the website with Sanchez right now, and as you can see, it's not particularly easy on the eyes.
* * *
.
The software architect / designer would create technical UML diagrams (component diagrams, deployment diagram, ...).
Most UML diagram types can be used in creating functional models as well as in creating technical models. For example, the classes in a class diagram can represent business entities, but also classes in an OO programming language, or tables in a database.
For more information, see Which UML models should we make?
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "uml, software design"
}
|
Does Control+C delete the files that you were downloading and installing?
If you are installing a package in the terminal and you use Control+C to stop it, does it also undo all the changes and remove the files that it downloaded?
|
Hitting `Ctrl-C` (or whatever the current `intr` character is in the output of `stty -a`) in a terminal, if `isig` appears in the output of `stty -a` causes the kernel to send a `SIGINT` signal to every process in the _foreground process group of the terminal_ , that is the shell job running in foreground if you're running an interactive shell in that terminal.
By default, that signal causes the process to die straight away (without flushing buffers or any cleanup action). However, applications are free to intercept or ignore that signal and perform whatever action they deem necessary before exiting.
A package manager would typically do so, as it would try and avoid to leave the package system in an inconsistent state. However, all package managers would behave differently, so you'd need to specify which you're using.
|
stackexchange-unix
|
{
"answer_score": 3,
"question_score": 0,
"tags": "package management, signals"
}
|
Cross-Platform C++ Dynamic Library Plugin Loader
I was just wondering what my options were for cross-platform implementations for the dynamic loading of plugins using shared libraries. So far the only one that I have found is:
* <
And I was just wondering if I had other options? Essentially, I want to be able to put plugins in shared object files, and load them at runtime and I wanted to do it in a cross-platform C++ way.
**Edit** : I found this Dr Dobbs Post from 2007; surely somebody has come up with something more since then.
|
You could look into Boost Extension, though it has not yet been accepted into Boost.
> The Boost.Extension library has been developed to ease the development of plugins and similar extensions to software using shared libraries. Classes, functions and data can be made available from shared libraries and loaded by the application.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 9,
"tags": "c++, plugins, cross platform, shared libraries"
}
|
Changing the editor in Joomla deleted my javascript, unsaved...Any way to recover?
I used No editor option and joomla and wrote javascript. The code was working perfect. To add other articles I changed editor to TinyMCE, added a table. ...All my javascript is gone, even after I revert back to No editor. Anyway, I can get previous version of article with javascript. Has about 2 days of coding and unfortunately, stupid enough, I don't have back up
|
No way (unfortunately) to get what was saved before and overwritten afterwards.
Two solutions (if it was made after at least one day):
A. Maybe your server was set to backup the database? If so, you could recover it via the backups.
B. If the site was indexed by Google (and public), try to view a cached version of that page (if accessible and indexed).
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, joomla, editor"
}
|
How to evaluate $ \int_c (\sin z)/ z^6$?
Evaluate: $$ \int_c {\sin z\over z^6} \, dz$$ Where, $c$ is a circle of radius $2, |z| = 2$. Don't understand why ${\pi i \over 5!} $ (Answer from book). $$ {\sin z \over z^6} = {1 \over z^6}\left [ z-\frac{z^3}{6}+\frac{z^5}{120}-\frac{z^7}{5040}+\frac{z^9}{362880}-\frac{z^{11}}{39916800}+O(z)^{12} \right ]$$
What happens to $ \int_c {1 \over z^5}\,dz$ and $- {1\over 3!} \int_c {1 \over z^3} \, dz $?
|
Hint: for a function $\,f(z)\,$ holomorphic within the domain inclosed by a closed smooth path $\,\gamma\,$, we have $$f^{(n)}(a)=\frac{n!}{2\pi i}\oint_{\gamma}\frac{f(z)}{(z-a)^{n+1}}dz$$
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 3,
"tags": "complex analysis, integration"
}
|
save multiple chkdsk logs to single file
I am creating a batch file to run `chkdsk` on every drive and log the output to a single file.
I am able to run a `chkdsk` and log it to a file with:
chkdsk a: > %userprofile%\desktop\test.log
However I am struggling to work out how to then run a new `chkdsk` and log that output to the same file.
|
### How do I run a new `chkdsk` and log that output to the same file.
You need to use a different redirection operator.
The `>>` operator will append to a file.
Example:
chkdsk a: > %userprofile%\desktop\test.log
chkdsk b: >> %userprofile%\desktop\test.log
> **Redirection**
>
>
> command > filename Redirect command output to a file
> command >> filename APPEND into a file
>
Source Command Redirection, Pipes - Windows CMD - SS64.com
* * *
### Further Reading
* An A-Z Index of the Windows CMD command line | SS64.com
* Windows CMD Commands (categorized) - Windows CMD - SS64.com
* Command Redirection, Pipes - Windows CMD - SS64.com
|
stackexchange-superuser
|
{
"answer_score": 0,
"question_score": 1,
"tags": "batch, cmd.exe, chkdsk"
}
|
sql query confusion with count
im trying to fgure out this query from a sql book im reading.
6. Find the name of the most popular course based on the number of the times the course was offered.
i have the query up to were it lists the courses and counts how many times each has been offered, now my question is how do satisfy the question above lol. how can i get just the course that was offered the most ? (ie. the databases course)
my query is
SELECT
count(s.course_id) AS Times_Offered,
c.title
FROM
sections s
INNER JOIN courses c ON c.id = s.course_id
GROUP BY c.title
ORDER BY Times_Offered DESC;
my query shows up as
times_offered title
3 Databases
3 Calculus 1
2 Compilers
2 Elocution
2 Acting
1 Topology
|
If you want to count them and then show the one with the highest number only, try this:
SELECT COUNT(s.course_id)
AS Times_Offered, c.title FROM sections s
INNER JOIN courses c ON c.id=s.course_id
GROUP BY c.title
ORDER BY Times_Offered DESC
LIMIT 1
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "mysql, postgresql"
}
|
Monotonic functions that converges to 0 when $x \rightarrow +\infty$
If $g(x)$ monotonically tends to $0$ as $x \rightarrow +\infty$, does there exist an $\alpha \gt 0$ such that $\lim_{x \rightarrow +\infty}x^\alpha g(x)=0$?
|
No, not in the general case.
Counter-example :
For $x>e^1$, consider : $$f(x)=\frac{1}{\ln(x)}$$
No $\alpha$ can work.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "calculus, limits"
}
|
React router dom not working after deployment
I'm using the react router dom for my frontend routing, but whenever I refresh the page or access any URL which isn't the root or '/' the server responds with a 404, before I ran npm build the router worked just fine even if I refreshed the page.
|
Please check React Router BrowserRouter leads to "404 Not Found - nginx " error when going to subpage directly without through a home-page click
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "reactjs, rxjs, react router, http status code 404, react router dom"
}
|
Overwrite attributes from DOT file in commandline with graphviz
I have graphviz installed on a linux VM. I am automatically converting .apt into .dot files using APT. I draw these with graphviz and the dot command. But it keeps showing the xlabels, which are set automatically by APT. Is there a way to surpress these xlabels, so they dont show ?
-Gforcelabels=false didn't work and i could not change the labels with -Exlabel
|
**dot -Nxlabel= "" -Exlabel="" -T...** should(?) work, but it does not! I consider this a bug, not a feature.
This does work:
gvpr -c 'E{$.xlabel=""}N{$.xlabel=""}' file.dot |dot -Tsvg >file.svg
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "graphviz, dot"
}
|
how to make a Yad split window, upper split = text and lower split = progress bar?
I can't work out how to make a Yad split window, upper split = text and lower split = progress bar? My attempt below failed.
id=$(echo $[($RANDOM % ($[10000 - 32000] + 1)) + 10000] )
Settings=$(cat ~/tmp/YadWindow4SelectedSettings.txt)
{
echo 25
echo "#25%"
echo 50
echo "#50%"
echo 75
echo "#75%"
echo 100
echo "#100%"
} |
yad --plug=$id --tabnum=1 --progress --auto-close --auto-kill --center --width=700 --image=$ICON --image-on-top --title="Loading..." --percentage=0 &> res1 &
yad --plug=$id --tabnum=2 --text="$Settings" &> res2 &
yad --length=800 --width=800 --center --paned --key=$id --splitter="200"
|
I've been helped elsewhere with advice on an alternative method for the same result. Using this I wrote the following, which seems to work sufficiently for me:
Settings=$(cat ~/tmp/YadWindow4SelectedSettings.txt)
{
echo 25
echo "#25%"
sleep 2
echo 50
echo "#50%"
sleep 2
echo 75
echo "#75%"
sleep 2
echo 100
echo "#100%"
} |
yad --progress --enable-log --log-on-top --log-expanded --auto-close --auto-kill --center --width=700 --image=$ICON --image-on-top --title="Loading..." --text="$Settings" --percentage=0
|
stackexchange-unix
|
{
"answer_score": 0,
"question_score": 0,
"tags": "gui, yad"
}
|
ES6 way to define state in React
I'd like to use state this way:
class Checkout extends Component {
state = {
ingredients: null,
totalPrice: 0
};
But I'm getting error saying `Unexpected token =`, I know this can be fixed with **babel-plugin-transform-class-properties** , unfortunately it's not working in my case.
Here is my **package.json**
"babel": {
"presets": [
"env",
"react-app"
],
"plugins": ["transform-class-properties"]
},
"eslintConfig": {
"extends": "react-app"
},
"devDependencies": {
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "^1.7.0",
"eslint": "^4.19.1",
"eslint-plugin-react": "^7.1.0"
}
Any idea what else can be wrong here?
|
Problem was related to `Eslint`. When I installed `babel-eslint` and add parcer option to `.eslintrc`, this error gone.
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "javascript, reactjs, ecmascript 6, babeljs"
}
|
About uploading app to Play Store
I have two questions about uploading app to play store. First of all I want to upload two versions of my app, the first one is free with adds and the second one is paid without any adds, but is the same app in both cases.
What should I do to upload both apps? I had thought about changing the package name but the problem I think I will have is that if the user downloads the free version and then pays for the premium he will have both applications in his smartphone, the premium won't override the free one.
And this question is more about your experience uploading apps. I have mine in english, spanish and french. I had thought in uploading the app in every country but in the videos I have seen everyone chooses a few countries to upload their own apps. What do you recommend me to do?
Thank you in advance.
|
There are a few ways you can handle it, though I have to say I'm not sure you should.
My suggestion is to upload your free version first, and later when you have enough users implement in app billing instead. I know it's not directly answering your question, but I think it's a better approach that will save you a lot of time, and also be a better experience to the users.
Regarding countries, you don't need to upload it to each country, that's automatic (unless you indicate otherwise), and you actually can't upload or create a specific store listing by country, at least as far as I know.
**You do need** to create a store listing to the languages you want, otherwise they'll get the default language and in some cases see automatic translated listing, which is quite bad in my opinion.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android, file upload, google play"
}
|
Reference request: additive basis of coordinate ring of Grassmannians
Let $\tilde{Gr}(k,n)$ be the affine cone of the Grassmannian $Gr(k,n)$. I think that the following set $S$ is an additive basis of $\mathbb{C}[\tilde{Gr}(k,n)]$: \begin{align} S = \\{e_T: T \text{ is a rectangular semi-standard Young tableau with $k$ rows}\\}, \end{align} where $e_T = P_{T_1} \cdots P_{T_n}$, where $T_i$'s are columns of $T$ and $P_{T_i}$ is the Plücker with indices from the entries of $T_i$. Are there some references about this? Thank you very much.
|
The result you mention is very classical, but it also fits within the more general and conceptual framework of Standard Monomial Theory: <
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 5,
"question_score": 4,
"tags": "ag.algebraic geometry"
}
|
Given an Android phone, how can I find out what custom and stock ROMs are compatible?
I've recently started trying to dabble in custom ROMs, or even just trying to boost an old phone with a newer version of Android, but there doesn't seem to be a conclusive place online to find out what ROMs are supported by what phones (and how to root any given phone), what ROMs are available out there in the world in general, it all seems a bit... messy!
So here's my example for my question: I have an Obi S453, how can I find out what ROMs I might be able to install?
|
This site offers a fairly comprehensive coverage to the questions asked by you:
* Where can I find stock or custom ROMs for my Android device?
* How do I root my Android device?
* How do I update Android on my device?
Coming to your device in particular, it appears there is lack of developer support to create custom ROMs as a quick search (not comprehensive ) did not provide any evidence. Even the OEM, it looks like has not come out with any plans to update to Lollipop, whereas most popular phones have the next version Marshmallow rolled out or in the process of rolling out.
Possible reasons for lack of developer support, in general, could be (i am not a developer, so guessing):
* Chipset being not developer friendly
* Not a popular phone compared to low cost "budget phones"
* Kernel and chip set information not "open source"
* Difficulty in porting custom ROM from another ROM
* OEM not coming up with a improved versions of phone
|
stackexchange-android
|
{
"answer_score": 2,
"question_score": 0,
"tags": "custom roms, rom"
}
|
$f$ and the domain are convex but not constant, $\hat{x} \in X$ is the maximizer, then it is possible that $\hat{x}$ is not an extreme point
Assume $f$ is convex but not constant with the domain $X$ is also convex set, let $\hat{x} \in X$ is the maximizer, then it is not necessary that $\hat{x}$ is an extreme point.
I cannot see this is true, intuitively, if $\hat{x}$ is a maximizer then it should be an extreme point. Could anyone give me an example? Thank you very much.
|
**Hint:**
$f$ can be constant on a line on the boundary, like $$ f(x,y) = |x| $$ for $(x,y)\in [-1, 1]^2$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "convex analysis"
}
|
Creating a light that follows the player
How do I create a point light that follows the player character when they walk around? The light should shine on the player and not on a fixed point.
|
The simplest way to do this, is to make the light a child of the character. Position the light where you want it to be in relation to the player, then in the Hierarchy view, drag the light so that it becomes a child of the player.
!enter image description here
Now when the player is moved, all of its children are moved as well (including the light).
* * *
Another option is to use one of the built in scripts called "Smooth Follow". On your light object, in the Inspector, click on the Add Component button.
!enter image description here
Find the "Smooth Follow" script and add it to the light.
Then set the player as the follow target:
!enter image description here
Do that by dragging the player object from the Hierarchy view and dropping it on the Target (Empty) variable.
Now the light object will follow the player with a little bit of smoothing.
|
stackexchange-gamedev
|
{
"answer_score": 5,
"question_score": 2,
"tags": "unity, lighting"
}
|
Unicode equivalent in javascript
Builtin function for Javascript equivalent for this code? i tried using CryptoJS but the bytes are not matching. Any builtin method available
byte[] tempBytes = (new UnicodeEncoding()).GetBytes("TestWord");
I have used CryptoJS but still it doesn't provide same bytes
<script src="
<script src="
<script src="
<script src="
<script>
var words=CryptoJS.enc.Utf16.parse('TestWord');
console.log(words);
</script>
|
I have used CryptoJS before CryptoJS `CryptoJS.enc.Utf16.parse('TestWord');` returns object which has an array of words. If you convert the words to byte using
`CryptoJS.util.wordsToBytes(words.words)` it will return the same bytes
i have made JSFiddle Here working as well Link here
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "javascript, c#, .net, arrays, html"
}
|
Difference between keeping jar files in WAR and Tomcat lib folder
I have web application. I want Eclipse BIRT reports in that application. Tomcat is not even started by memory error if i add BIRT jar files into Tomcat lib.
If build WAR with that jars only application runs
What is the difference and what is the problem behind this?
|
Jars in Tomcat/libs are visible to all WAR files.
Generally there is no need to place JARs in Tomcat/libs. Only time one would do this is when your WAR file is very big (say 50 MB+) and bulk of it is third-party JARs. In such cases, you can move all the JARs that are not part of your source code like Spring, Hibernate, etc. and move them to Tomcat/Lib and deploy a much light-weight WARs. This may be needed only for Staging/Test/Production systems.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "java, tomcat7, birt"
}
|
Quadratic Forms
When defining a quadratic form why is it that we place $\frac{1}{2}$ in front? That is, why do we use $f(x) = \frac{1}{2}(x^T Qx) - b^T x$? Is this simply a convention that comes from the one-dimensional case where we would have $f^\prime(x) = Qx - b$?
|
This way $Q$ is the Hessian matrix of second partials. Also, it allows $Q$ to have all integer entries in some special cases of interest, such as $$ f(x,y,z) = x^2 + y^2 + z^2 + y z + z x + x y. $$
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 1,
"tags": "linear algebra, quadratic forms"
}
|
Am I going to do any damage by swapping cassettes frequently?
I've got a separate wheelset for cylocross riding and road riding. Would it be detrimental to the life of my cassette or hubs If I swapped the cassette between my road and off-road wheelset frequently?
|
The main hazard is that, with so much swapping, you will sooner or later cross-thread the cassette and ruin both cassette and hub. There will also be additional wear on the threaded surfaces and on the spline, where you wrench it on and off. The spline may eventually become too worn to allow removal.
So a lot depends on the care you use -- if you get too casual in doing the swap you're apt to muck it up.
|
stackexchange-bicycles
|
{
"answer_score": 5,
"question_score": 4,
"tags": "wheels, hub, cassette"
}
|
Configuring systemd to allow daemon to set RT priority
I have a daemon that calls pthread_setschedparam() to set the thread priority. On a system using systemd (OpenSuse 12.1), this fails, because sched_setscheduler() returns EPERM.
From what I understand systemd doesn't use the permissions set in /etc/security/limits.conf any more where I used to be able to allow this.
How can I allow a deamon to change RT priorities when using systemd ?
|
Read systemd.exec(5), then experiment with `LimitRTPRIO` and `LimitRTTIME` or `CPUSchedulingPolicy`, `CPUSchedulingPriority`, `CPUSchedulingResetOnFork` in daemon service file.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 2,
"tags": "priority, threads, systemd"
}
|
Computing the efficiency in percentage between two times in Excel
I got in Excel two cells of type "hh:mm:ss" and I need to find how fast was the first column from the second column in percentage. Is there any simple way to find that ? Thanks!
|
I think you need to have a some sort of baseline to which to compare the time difference. For example, "how fast" is 100% efficient?
The formula is straight-forward:
(t2 - t1) / baseline
where, (t2-t1) is in the same units as baseline.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "excel, formula, calculated columns"
}
|
Is there a way in vim to make :W to do the same thing as :w?
The same goes for :q and :Q. I almost always don't let up on shift quick enough and seeing that :Q and :W aren't used anyway I thought it would be nice to just have them do the same as their lower-case counterparts.
|
The hack is via a `:cmap` or `:cabb`, but these have side effects (i.e. other instances will be inadvertently converted, too).
The cmdalias plugin does this better.
But I think for your use case it's best to define your own uppercase command-variants. The main challenge is to support all the options that the original one has:
command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args>
command! -bang Q quit<bang>
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 20,
"tags": "vim"
}
|
How can you create a unique key for two interchangable integers?
I am trying to write a simple caching mechanism for Euclid's method of finding the GCD of two numbers:
gcd(a,0) = a
gcd(a,b) = gcd(b, a % b)
Note that `gcd(a,b) == gcd(b,a)`.
For the cache, I need to find a key for a given `(a,b)` or `(b,a)`, with `0 < a < 20` and `0 < b < 20`.
Of course, I could use `key = a*20 + b`, or `key = a + b*20`, but those are asymmetric - the key for `(1,5)` is different than for `(5,1)`.
How could I implement this?
|
First, sort the numbers.
key = a > b ? b*20 + a : a*20 + b;
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 2,
"tags": "math, hash, greatest common divisor"
}
|
Is it suitable to use 'etc.' in an academic paper?
I'm writing one of my first academic papers and I'm not sure whether _etc._ is too informal. Should I use _et cetera_ instead?
|
_**etc._** is not informal. In fact it is better than its expansion, which sounds rather awkward. It is perfectly ok to use _etc._ in an academic paper.
Just note, however, that both of them are very sparingly and carefully used in serious writing. Try to list fully or describe the list instead.
|
stackexchange-english
|
{
"answer_score": 9,
"question_score": 11,
"tags": "abbreviations, formality"
}
|
Store HighRes photos in Database or as File?
I run a site which has a couple of million photos and gets over 1000 photos uploaded each day. Up to now, we haven't kept the original file that was uploaded to conserve on space. However, we are getting to a point that we are starting to see a need to have high-res original versions. I was wondering if its better to store these in the filesystem as an actual file or if its better to store them in a database (ie: mysql). The highres images would be rarely referenced but may be used when someone decides to download it or we decide to use it for rare processes like making a new set of thumbnails sizes/etc.
|
Yep, as everyone has noted, store the large images in a filesystem (and possibly thumbnails as well). You can hash or UUID them or something to get a reasonable location/unique name, then you can store this (as well as the matching thumbnail or other resolutions if required) location in the database. Then the DB does the search/match/join work for you, and the filesystem does what it's good at: storing files.
|
stackexchange-softwareengineering
|
{
"answer_score": 2,
"question_score": 1,
"tags": "mysql, storage, image manipulation"
}
|
Filtered response does not show total records in response of REST APIs in Magento 2
I am using **GET V1/products** endpoint to fetch product list. I want to fetch sku and name only.
**response**
{
"items": [
{
"sku": "5245",
"name": "Test Product"
},
{
"sku": "product 1",
"name": "product 1"
},
{
"sku": "product 2",
"name": "product 2"
},
]
}
I am not getting total number of records in this response. I checked it on devdocs as well. It also has same type of response, please find link below.
Magento filtered response
Please help if anyone already faced this and solved it.
|
Ok I found the solution, I checked some core files of catalog module and I can see that search criteria and total records are not in items index so I just need to update my request like below.
I hope it'll help others, Happy Coding :)
|
stackexchange-magento
|
{
"answer_score": 8,
"question_score": 4,
"tags": "magento2, rest api, search criteria"
}
|
Conditionally Apply Gradle Plugin
As the title suggests I want to apply a plugin in my `build.gradle` iff a certain properties file exists in the project folder. The following attempt
buildscript {
File c = file('crashlytics.properties')
ext {
crashlytics = c.exists();
}
}
if (crashlytics) {
apply plugin: 'io.fabric'
}
//...
results in the following error message
No such property: verboseGradlePlugin for class: java.lang.Boolean
Is there a way to achieve what I want?
|
You can try:
if (project.file('crashlytics.properties').exists()) {
apply plugin: 'io.fabric'
}
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 5,
"tags": "android, groovy, gradle"
}
|
access fortran module data from c using gfortran and gcc
I'm trying to access module variables in a fortran code, calling it from C. I already call a subroutine, but cannot call the variables.
module myModule
use iso_c_binding
implicit none
real(C_FLOAT) aa(3)
contains
subroutine fortranFunction() bind(C)
print *,"hello world from Fortran 90"
aa(1)=1.0;
aa(2)=2.0;
aa(3)=3.0;
end subroutine
end module
and the C code is
#include "stdio.h"
extern void fortranfunction();
extern float mymodule_aa_[3];
int main()
{
printf("hello world from C\n");
fortranfunction();
printf("%f %f %f \n",aa[0],aa[1],aa[2]);
return 0;
}
I'm compiling via
gcc -c ccode.c
gfortran -c fortrancode.f90
gcc fortrancode.o ccode.o -lgfortran -o myprogram
to which the gcc responds with undefined reference to `aa'
|
Using objdump to look at the symbols, we see
0000000000000000 g O .bss 000000000000000c __mymodule_MOD_aa
You need to add `bind(C)` to your aa variable
module myModule
use iso_c_binding
implicit none
real(C_FLOAT), bind(C) :: aa(3)
contains
subroutine fortranFunction() bind(C)
print *,"hello world from Fortran 90"
aa(1)=1.0;
aa(2)=2.0;
aa(3)=3.0;
end subroutine
end module
now `$ objdump -t fortrancode.o` says
000000000000000c O *COM* 0000000000000004 aa
and
#include "stdio.h"
extern void fortranfunction();
extern float aa[3];
int main()
{
printf("hello world from C\n");
fortranfunction();
printf("%f %f %f \n",aa[0],aa[1],aa[2]);
return 0;
}
and
$ ./myprogram
hello world from C
hello world from Fortran 90
1.000000 2.000000 3.000000
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "c, fortran, fortran iso c binding"
}
|
Automatic compaction in CouchDB 2.2
I have read the following article, because couchdb was busy almost all the space of my hard drive at an impressive speed.
Thanks to this article I have managed to reduce the size of my database from 19 GB to 19 MB.
But I would like the "compaction" to be done automatically, without me having to worry, so I followed the steps of that article, however, there is no way to verify that the configuration is working properly.
**How can I determine if it is working correctly?**
|
You are facing a CouchDB 2.2 bug. You can check it here.
It is planned to be fixed in the next release 2.3
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "couchdb, couchdb futon, couchdb 2.0"
}
|
Matching optional groups
With the following code:
Pattern pattern = Pattern.compile("((foo) (bar)?)|((foo) (baz)?)");
Matcher matcher = pattern.matcher("foo baz");
if(matcher.find()){
for(int i=1; i<=matcher.groupCount(); i++){
System.out.println(matcher.group(i));
}
}
The result is:
foo
foo
null
null
null
null
Whereas I was hoping for:
null
null
null
foo baz
foo
baz
How to match the second item?
I want to match the full "foo baz" if possible, else match "foo"
|
Your regular expression is behaving as expected: Your input `"foo baz"` matches `((foo) (bar)?)`—at least, the `"foo "` part does. In general, regular expressions prefer the _longest_ pattern (greedy) defined _first_ (left to right), and `"foo "` matches that better than `"foo baz"`.
If you want to ensure that the entire expression is matched, you'll need `^` and `$`:
Pattern pattern = Pattern.compile("^((foo) (bar)?)$|^((foo) (baz)?)$");
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "java, regex"
}
|
How to integrate Alfresco with my website such that both share same login page?
Currently i am working on an ERP system such that it contain 2 module. First module is on php and mysql and second module is Alfresco. I just want to have a common login page for both module.
|
What you are asking for is called Single Sign-On. To implement this, you'll start with an LDAP directory of some sort (OpenLDAP, for example) and use that to manage your users and their login credentials. Then, you'll implement a Single Sign-On provider to handle authentication. A common one is called CAS. Finally, you'll configure your PHP app and Alfresco to use the login page provided by CAS. CAS will be responsible for authenticating users and providing/validating authentication tokens for the apps participating in Single Sign-On.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -3,
"tags": "php, mysql, alfresco, alfresco share"
}
|
Urn problem with two ways of expectation computation
Let $X$ denote the number of white balls selected when $k$ balls are chosen randomly from an urn containing $n$ white balls and $m$ blacks.
For $i1....k; j1....n$,
$$\begin{align*} X_i&\begin{cases} 1,&\text{if }i\text{-th ball selected is white}\\\ 0,&\text{otherwise} \end{cases}\\\ Y_j&\begin{cases} 1,&\text{if white ball }j\text{ is selected}\\\ 0,&\text{otherwise} \end{cases} \end{align*}$$
Compute $E[X]$ in two ways by expressing $X$ first as a function of the $X_i$s and then of the $Y_j$s.
Sorry for the poor codes
|
We can use the reasoning behind linearity of expectation and indicator random variables.
Let $X$ be the number of white balls from our k draws. $$X = X_1 + X_2 + X3 ... + X_k$$ where $X_i = 1$ if the $i^{\text {th}}$ ball selected is white and $X_i = 0$ if black. $$E[X] = \sum_{i} E[X_i]= \sum_{i} P(X_i = 1)$$ $$P(X_i = 1) = \frac{n}{n + m}$$ $$E[X] = \sum_{i}P(X_i = 1) = \sum_{i = 1}^{k}{\frac{n}{n + m}}\\\= \frac{kn}{n + m}$$
And I think a very similar reasoning can be used for the second part of your problem.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "probability, polya urn model"
}
|
Evaluating Double integrals
$$\iint_R e^{x+y} \, dx \, dy$$ where $R$ is the domain lying between two squares of sides 2 and 4 with centre at origin and sides are parallel to the co-ordinate axes. I can't understand the limits..please help me
|
Draw a picture and consider $y$ between $-1$ and $1$, between $1$ and $2$ and between $-2$ and $-1$. Write down the range of values of $x$ in each case.
The integral is $(\int_{-2}^{-1} \int_{-2}^{2} +\int_{1}^{2} \int_{-2}^{2}+\int_{-1}^{1} \int_{-1}^{1} ) e^{x+y} dx dy$
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "calculus, integration"
}
|
Replace one square bracket and new line in all files using Shell script
I know many similar questions exist, but I couldn't figure this particular pattern out and hence posting here (after spending lot of time and giving up). Please help :)
There's a string that I need to match and replace in all files in a given directory.
What it looks:
tag:
["
What it should be converted to:
tag: "
I need to match the patterns: **tag \n [** and **" ]** and replace them from all files.
This is what I tried but it didn't work:
find . -type f -name "*.md" -print0 | xargs -0 sed -i '' -e 's/tag: \\n \[\"/tag: /g'
find . -type f -name "*.md" -print0 | xargs -0 sed -i '' -e 's/\"\]/\"/g'
|
sed -e '/^tag: $/!b' -e '$b' -e 'N;s/\n *\["/"/;s/"]/"/' file
Tip: don't use `-i` until edits are correct.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "sed"
}
|
Formula to calculate the sum of the series
> **Possible Duplicate:**
> Counting subsets containing three consecutive elements (previously Summation over large values of nCr)
Suppose there are n houses and I want to calculate the number of ways of selecting any number of houses given a condition that I have to select atleast three consecutive houses. for eg.if the total number of houses is 4,so the no of ways to do the job will be 3. No of houses(n)=4 no of ways = {1,2,3},{2,3,4},{1,2,3,4}
(note:I am can only select in increasing order of the number,so {1,3,2},etc are invalid)
I was able to find that total no of ways to do the above job follows a series
**Sum=1+2+5+12+28+...(n-2) terms**
so when n=4,then no of ways = 1+2=3 .When n=5,then no of ways=1+2+5=8 and so on.
Now,i am looking for the formula in terms of n to calculate the sum of this series.
|
Let $f(n)$ denote the number of subsets of $\\{1, \ldots,n\\}$ that _avoid_ three consecutive numbers. Then what you are looking for is simply $2^n-f(n)$.
Clearly, $f(0)=1$, $f(1)=2$, $f(2)=4$. For $n\ge3$, such an avoiding set is either
* in fact a subset of $\\{1,\ldots,n-1\\}$
* of the form $A\cup \\{n\\}$ where $A\subseteq \\{1,\ldots,n-2\\}$
* of the form $A\cup \\{n-1, n\\}$ where $A\subseteq \\{1,\ldots,n-3\\}$
We conclude $f(n) = f(n-1) + f(n-2)+f(n-3)$ for $n\ge3$. These are the tribonacci numbers, see < for some formulas to compute them and more information.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 2,
"tags": "sequences and series"
}
|
Canonical sheaf of product of two smooth projective curves
Let $C_1, C_2$ be two smooth projective curves of genus atleast $2$. Let $X:=C_1 \times C_2$. If $P_1, P_2$ are denoted as the first and second projections, then it is known that the canonical bundle relation is given as follows : $K_X := P_1^*(K_{C_1}) \otimes P_2^*(K_{C_2})$.
From this relation is it elementary to see that $h^1(K_X)=h^1(\mathcal O_X) >0$?
Any hint or explaination is appreciated.
|
If you know the Kunneth formula (ref Stacks or MO), yes! The Kunneth formula says that for quasi-compact schemes $X$ and $Y$ over a field $k$ with affine diagonal (separated implies affine diagonal, for instance) and for $\mathcal{F}$ a quasi-coherent $\mathcal{O}_X$-module, $\mathcal{G}$ a quasi-coherent $\mathcal{O}_Y$-module, we have a canonical isomorphism $$H^n(X\times_{\operatorname{Spec} k} Y, p_1^*\mathcal{F}\otimes_{X\times_{\operatorname{Spec} k} Y} p_2^*\mathcal{G}) \cong \bigoplus_{p+q=n} H^p(X,\mathcal{F})\otimes_k H^q(Y,\mathcal{G}).$$
This gives us that $H^1(X,K_X) \cong H^1(C_1,K_{C_1}) \otimes_k H^0(C_2,K_{C_2}) \oplus H^0(C_1,K_{C_1}) \otimes_k H^1(C_2,K_{C_2})$ in our case. As $H^1(C_i,K_{C_i})\cong k$ by Serre duality and $h^0(C_i,K_{C_i}) = g$ by Riemann-Roch, we have that $h^1(K_X)>0$. Noting that $h^1(K_X)=h^1(\mathcal{O}_X)$ and this is calculated by the same expression by Serre duality, we're done.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 3,
"tags": "algebraic geometry"
}
|
Can we interpolate between a logarithm and a constant function with bounded derivative?
I have the following problem. Let $r_0>0$.
Does there exist a family of **smooth** real-valued functions $\phi_{r_0}:[0,1] \to \mathbb{R}^+$ (parametrized by $r_0$), satisfying
$$ \phi_{r_0}(r) = \begin{cases} \log {r} & \text{if $r \ge r_0$} \\\ ? & \text{if } r^*\le r<r_0 \\\ \text{const} & \text{if } 0<r\le r^*, \end{cases} $$
where $r^*$ is a parameter which depends (in any way you want to) on $r_0$, such that
$$ \lim_{r_0 \to 0}\int_{0}^{r_0} \big(\phi_{r_0}'(r)\cdot r\big)^2 d r =0$$
The constant value $\phi_{r_0}(r)$ takes at $r \le r^*$ may also depend on $r_0$.
The $\phi_{r_0}$ do not need to change continuously with $r_0$. (In fact I will be satisfied with constructing a sequence $\phi_{r(n)}$ which corresponds to $r_0=r(n)$ which tends to zero when $n \to \infty$).
|
Let $\psi$ a $C^\infty$ function whole value is $0$ for $x<0$ and $1$ for $x\ \ge 1$. Such function can be constructed using the standard $C^\infty$ function :
$$f(x) = \begin{cases} e^{-\frac 1 x } & \text{ if } x>0 \\\ 0 & \text{ otherwise} \end{cases}$$
And by defining $\psi(x) = \frac{f(x)}{f(x)+f(1-x)}$.
Thus the following does what is required, with $C$ some constant :
$$\phi_{r_0}(r) = C\psi\left( \frac {r}{r^*-r_0} - \frac{r_0}{r^*-r_0} \right) + \log r \psi\left( \frac {r}{r_0-r^*} - \frac{r^*}{r_0-r^*} \right).$$
Indeed we only have $C^\infty$ functions involved and I let you verify that the equality on each interval and the condition over the integral are verified for $r^* = r_0/2$ for example.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "real analysis, approximation, interpolation"
}
|
How to use CURL over SSH and get the file as well as the return value?
I want to load a file from a clients webserver. This webserver is running local only. To get there I have to use ssh. I need the content as well as the return value (e.g. SSH connection broke, webserver down).
What do I have to change? My first try:
#!/bin/bash
RETURN=0
CONTENT=""
sshpass -p xxxxxx ssh [email protected] "curl -X POST -H 'Content-Type: application/json' > $CONTENT | bash; RETURN=$?"
|
If you want to get the exit code of `curl` and the return value of `curl`:
#!/bin/bash
CONTENT=$(sshpass -p xxxxxx ssh [email protected] "curl -X POST -H 'Content-Type: application/json'")
RETURN=$?
echo "$RETURN, $CONTENT"
In your script you set the variables on the server you ssh'ed into.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "bash, curl, ssh"
}
|
Mercurial creating extra files after cloning a repo
I am working on an Android App and the APK file is located in the _out_ folder. I am also using Mercurial as version control system and cloned the repo, the clone was successful but Mercurial created two APK files one inside the _bin_ directory and another in the root directory of the project.
Why Mercurial created these extra two APK files and how to get rid of them?
|
1. You **have** these two files in repo, clone just show it to you
2. You _didn't see only_ these files in original Working Copy, because (not discovered yet) local settings for original workspace **now** ignore these files (after they was commited to repo - see `hg log FILENAME`), but adding to ignore-list doesn't mean "automatically forget and remove from repo"
> how to get rid of them?
* In cloned repo-root create .hgignore, add global pattern for all and any (?) *.apk-file
* `hg forget` both APK (or Forget from CMenu of THG)
* commit changes
* remove files from WorkingCopy
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "android, version control, mercurial"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.