INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Full text query with a single quote
I'm having a problem when I try to do a full text search in boolean mode using a string with a single quote and an asterisk wildcard, i.e. "levi's*": it seems to search also for all words beginning with "s", like "spears", when, as far as I know, the quote should be considered part of the word while two single quotes ('') would be a word separator... but maybe I'm wrong.
Please, look at the example here: < \- the second row should't be there
how can I do what I want? | this gives you the two rows from your example:
SELECT *
FROM ft
WHERE MATCH(value) AGAINST ('"levi\'s" lacost*' IN BOOLEAN MODE)
In < at the end, it talks about exact matches in double quotes. You then just escape the single quote and you are done.
Using parentheses, you can add the asterisk:
WHERE MATCH(value) AGAINST ('(levi\'s)* lacost*' IN BOOLEAN MODE) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 7,
"tags": "mysql, full text search, match against"
} |
Match any word that starts with a character, Regex
I am writing an extension for vscode and I am using regular expressions for the grammers. I am currently trying to find every word that beings with * but if there is a solution that expands to any character feel free to suggest it.
Any suggestions so far that I have seen have not worked. I think how TextMatte processes these expressions are a bit different so I think that is why.
Example of what I want.
This is a *star word. Here is another *word with a star.
*start *word | `(?<!\b)\*[a-zA-Z0-9_]+` if you want `*first_name` to be a word
`(?<!\b)\*[a-zA-Z0-9]+` if you don't
Could also throw in other symbols
the `(?<!\b)` is a negative look ahead to avoid stuff like `not*me`
`[a-zA-Z0-9]` is a common way to select all numbers and letters `+` tells it 1 or more
<
* * *
I'm not familiar with `TextMatte` so apologies if this is unhelpful
* * *
per comments, `TextMatte` accepts the regex from json so the slashes needed to be escaped: `(?<!\\b)\\*[a-zA-Z0-9_]+` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "regex, visual studio code, textmate"
} |
SQL Server continue series of inserts from Select statements despite errors(?)
I have a large file of SQL statements that are lined up as follows:
INSERT INTO [table here]
SELECT [columns]
FROM OPENROWSET(xlsx tab 1)
INSERT INTO [table here]
SELECT [columns]
FROM OPENROWSET(xlsx tab 2)
... etc etc...
The problem is that sometimes XLSX tab #2 (or 22) does not exist and may cause an error and the entire series of statements fails.
Is there a way to get each statement to execute as though they were their own query or ignore the error and continue?
Thanks! | Error Handling in SQLServer is tricky.There some errors that abort entire batch,some which abort entire session,errors which abort session can't be caught and can't be retried from SSMS itself
In your case,if you want one insert ,not to be affected by another..Try separating them with BATCH SEPARATOR `GO`
INSERT INTO
SELECT
GO
INSERT
SELECT
GO
**Reference and further reading :**
Error and Transaction Handling in SQL Server | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "sql, sql server, ssms, sql insert, openrowset"
} |
Eclipse 4.14.0 cannot set correct execution environment for the Server Runtime Environment for Wildfly 14
I'm trying to move my projects from eclipse 4.9.0 to 4.14.0 and I am experiencing problems when creating the Server Runtime Environment for Wildfly 14.0.1. When I try to create the runtime environment, I cannot set the correct Execution environment because only JavaSE-1.8 is offered in the drop down menu. It should be possible to select JavaSE-1.11
eclipse 4.14.0
In eclipse 4.9.0 I can choose among all the java environments I have installed
eclipse 4.9.0
I cannot see what is the problem. I'm running eclipse on Win 10 64-bit and I have jdk1.8.0_92, jdk-11.0.1 and jre1.8.0_231 installed. I have also tried to install it on an fresh win 10 computer with only jdk-11.0.1 installed, but the problem remained. What am I missing here? | In JVM 9 there ware essential changes like module system. One of consequences is for instance this bug in WildFly 14. I suppose RedHat wanted to help developers and displays in the newer Eclipse plugin only Java versions under witch WildFly 14 runs flawless.
The first version of WildFly that officially works well with new module system is WildFly 15. That's why when you configure WildFly 15, also Eclipse 4.14 will show you not only Java 8, but also higher JREs if you have configured them in Eclipse, e.g. JavaSE-11 or JavaSE-13.
If you want to force WildFly 14 to run under Java 11, you can configure Java 11 to pretend to be Java 8: Windows --> Preferences --> Installed JREs --> Execution Environments --> select JavaSE-8 in the left pane and select JRE 11 in right pane. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "java, eclipse, wildfly 14"
} |
Shell Script - How to run script after mysql is ready?
I have a script (in a `.sh` file) to run once everytime i logged in. But I have to make sure that mysql service is already running before the main script in my `.sh` executed.
Here is my draft:
function check_mysql(){
// script for checking mysql
return status
}
mysqlstatus = check_mysql()
while mysqlstatus == false {
mysqlstatus = check_mysql()
}
// once mysqlstatus == true
// my main script
// my main script
// my main script
// my main script
How to write the above draft in shell script? | Finally I found the answer! :D
while !(mysqladmin ping)
do
sleep 3
echo "waiting for mysql ..."
done
echo "starting the main script"
#main script
#main script
#main script | stackexchange-askubuntu | {
"answer_score": 4,
"question_score": 5,
"tags": "command line, bash, scripts, mysql"
} |
How to add double quotes around data in tables using Calc
I am trying to load my data into a CRM, but am having a lot of trouble. The data simply wont load at the same time, but all the files work fine individually. Support advised that I make sure I'm using double quotes. This is a decent sized list and I can't go through all the tables to add double quotes. Is there an easy way to add double quotes around the data in each table? | I just needed to select "Quoted field as text" when opening the CSV. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "csv, spreadsheet, libreoffice calc, openoffice calc"
} |
When does it make sense to use drawRangeElements
I am trying to understand when it makes sense to use the `glDrawRangeElements` function.
The OpenGL wiki says:
> for optimization purposes, it is useful for implementations to know the range of indexed rendering data
So, as I interpret it, if I had one large buffer (containing say, multiple meshes' data) and I was planning to call `glDrawRangeElements` if I instead specify the minimum and maximum index values that this call will use, I could achieve a speedup.
**Is this a correct use case for`glDrawRangeElements`?**
It seems like I would almost always know the minimum and maximum index values (because I would know ahead of time what I am going to draw) so it seems like `glDrawRangeElements` should be just a drop in replacement for `glDrawElements`.
However, this answer implies that `glDrawRangeElements` might actually be slower.
So, **what are the pros and cons of using glDrawRangeElements?** | The problem `glDrawRangeElements` was invented to fix was effectively removed by the advent of vertex buffers.
What `glDrawRangeElements` allows the implementation to do is to know exactly what range of values will be used as indices for the vertex arrays. Given that knowledge, they can read that range of values into a separate buffer, and then render from that buffer. Without knowing the range of indices, that wouldn't be possible, since an index list could pick from any index.
But that's only useful if you're reading from _client memory_. Copying that range out of client memory allows you to render asynchronously. You copy out the values you know you need, issue a rendering command with that, and then return to the caller.
If you're reading from buffer objects, this isn't a useful thing to do. And since core OpenGL doesn't even allow you the option of using client memory, the `Range` commands are no longer useful. | stackexchange-computergraphics | {
"answer_score": 6,
"question_score": 6,
"tags": "opengl"
} |
number rounded down in select statement with equation SQL Server 2012
If I do
select 18000*13/100000
it returns 2
when it should return 2.34
How do I make it return the correct number?
thanks | select 18000*13/100000.0
Use a `float` either in numerator or denominator to get a float. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "sql, sql server"
} |
Confluence Wiki - Preformatted vs Paragraph?
I've been told, when editing with Confluence Wiki page, the differences between a _Preformatted_ style and a _Paragraph_ style is that
* _Preformatted_ remain it's style from the origin when it's copy and pasted and _Paragraph_ does not.
However when I test it, _Paragraph_ does the same thing. Anyone knows the differences between these two? I did some googling but doesn't seems to find an answer. | Preformatted text is exactly similar to the Monospace text in Confluence editor when you add a new text in your wiki. (You can manually add monospace text via `{{}}`). As far as I know and you can see in other Articles, Preformatted introduced after Confluence 4.x.
In the other hand, Paragraph is a normal Paragraph in the editor. I don't know where did you get that answer about their behaviour during copy paste but you can see the difference between Paragraph and Preformatted text as well as similarity between monospace and Preformatted in attached screen shot.
 then no problem.
Any ideas? | `git submodule init` or `git submodule update` are supposed to work for _all_ submodules registered in `.gitmodules`, so it doesn't make sense to execute them for each submodules.
If you had submodules within submodules, `git submodule update --recursive` would take care of _all_ submodules recursively. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 3,
"tags": "git, git submodules"
} |
Why is $0^{-\infty}$ not an indeterminate form?
Wikipedia says the expression $0^{-\infty}$ is equivalent to $1/0$. How can I prove this? | If $\lim_{x\to a}f(x)=-\infty$ and $\lim_{x\to a}g(x)=0$, then$$\lim_{x\to a}g(x)^{f(x)}=\frac1{\lim_{x\to a}g(x)^{-f(x)}}$$and $\lim_{x\to a}g(x)^{-f(x)}=0$. | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "limits"
} |
Relocate one line to find the equality
 might be down to hacking the installer rather than faults in the beta.
If you want to download once for multiple installs then download the installer. The web installer optimises the current install at the cost of every install having to download. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "visual studio, visual studio 2012"
} |
Is it more performant to use Raphael.transformPath or Element.transform() with Raphael.js?
I'm working on an SVG-based web app that has a number of SVG elements that need to be moved around the SVG canvas. When transforming SVG elements, is it faster from a performance perspective to use Raphael.JS's `Raphael.transformPath` or `Element.transform`? | Without a doubt, `Element.transform` is hundreds of times faster than `Raphael.transformPath`. I believe that this is because `Raphael.transformPath` does string operations that can take quite a bit of time, especially with longer, more complex paths. `Element.transform` merely applies an attribute to the corresponding SVG element and lets the browser do the heavy lifting. A jsPerf is available here: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, svg, raphael"
} |
Can something worse than a temporary ban happen when I get too many rejected edits?
If I try to edit multiple questions, and they all get rejected, could I potentially get a worse punishment than a temporary ban? | In theory something worse can happen.
If you continue to get yourself into an automatic ban, the users and or moderators might start to notice.
When there is evidence that you don't improve or ignore advice presented to you by the system, you could risk a suspension handed out by a mod. Those start with days but can increase in length up to a year and if you persist on doing this network-wide be extended by community managers to 99999 days.
It would be a novum if you get a ~ 273 year suspension from just lousy edits. | stackexchange-meta_stackoverflow | {
"answer_score": 39,
"question_score": 24,
"tags": "discussion, suggested edits, rejected edits"
} |
Excel - Blanks show up as zeros in Index/small code
I'm having trouble figuring this out, I've inserted an `IF` statement into my code but my fields are still showing 0's where there are blanks in my table. Any help would be appreciated!
=IFERROR(INDEX('Error'!$A$2:$I$5000,SMALL(IF('Error'!$E$2:$E$5000="","",IF(OR('Error'!$E$2:$E$5000="does
not match",'Error'!$A$2:$I$5000="not on the
Route"),ROW('Error'!$A$2:$A$5000))),ROW(2:2))-1,1),"")
Edited to include expected results and table | If the purpose of your function is to determine if at least one cell in your range is empty, you can use the COUNTBLANK() function like this :
=IF(COUNTBLANK('Error'!$E$2:$E$5000) > 0, "at least one is empty", "no empty cell") | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "excel"
} |
Is element in array js
Following an old question, I still have a problem:
a = ["apple", "banana", "orange", "apple"];
a.indexOf("apple") = 0
What is the easiest way to find BOTH indexes of "apple" element in array? I want to delete them both at once - is it possible? | That's the task for filter method:
var noApples = a.filter(function(el) { return el != "apple"; }) | stackexchange-stackoverflow | {
"answer_score": 15,
"question_score": 11,
"tags": "javascript, jquery"
} |
Page down in terminal
How can I "page down" in the terminal? | In addition to VxJasonxV’s answer (which is correct), if you want to modify your terminal behavior so using _up_ or _down_ does a pageup/pagedown in vim (and others), you can go to:
Terminal -> Preferences -> Click on the Settings Toolbar, then the Keyboard Tab.
Add a new keys like this: (showing one example below)
* Page Up: \0335~
* Page Down: \033[6~
* Home: \033[4~
* End: \033[1~
Here’s an example with the “Cursor up”:
![alt text
Now you can press Up/Down and it will do the pageup/down. I suggest you add a modifier (like Control). Sadly, you can’t use the “Fn” key as a modifier.
**Note** : By default, Control + Cursor Left is delete until the end of the line and control+cursor right is insert (in vim at least), so you can use another modifier if you don’t want to change those. | stackexchange-apple | {
"answer_score": 11,
"question_score": 12,
"tags": "terminal"
} |
How can I compare the date from text file to today's date
<?php
$myFile = strtolower('date.txt');
$lines = file($myFile);
$expire_date = $lines[0];
$date = strtotime($expire_date);
//$date->format("y,m,d");
$now = new DateTime();
$now->format("y,m,d");
if($now < $date) {
echo 'Have not reached date yet.';
}else{
echo 'Date in file is old';
}
?>
Content of my date.txt file -
2018,2,18 (this is line 1)
Test (This is line 2 in my file)
I want to compare 2018,2,18, line 1 in the file, with the current date. Code keeps saying that the date is old when it's clearly in the future. Is it because line 1, although will return the date, is actually an array or not a date? | Your `strtotime($expire_date)` is returning `FALSE`. I have replaced comma with dash in your date string. Also consider I'm using `time()` function which returns current Unix timestamp. I have considered the date in your file is UTC date.
$myFile = strtolower('date.txt');
$lines = file($myFile);
$date = $lines[0];
$date = str_replace(',', '-', $date);
$date = strtotime($date);
if(time() < $date) {
echo 'Have not reached date yet.';
}else{
echo 'Date in file is old';
}
Or you can also create your date from the format in file:
$myFile = strtolower('date.txt');
$lines = file($myFile);
$date = $lines[0];
$date = date_create_from_format('Y,m,d', $date);
$date = date_format($date, 'Y-m-d');
$date = strtotime($date);
if(time() < $date) {
echo 'Have not reached date yet.';
}else{
echo 'Date in file is old';
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, date, comparison"
} |
Deduce type from (member) function
Is there a simple way to deduce the "type" of a member function? I would like to deduce the type of the following (member) function:
struct Sample {
void func(int x) { ... }
};
void func(int x) { ... }
To the following type (to be used in `std::function`):
void(int)
I'm looking for a solution that does support a variable count (not varargs!) of arguments...
**EDIT - Example:**
I'm looking for an expression similar to `decltype` \- let's call it `functiontype` \- that has the following semantics:
functiontype(Sample::func) <=> functiontype(::func) <=> void(int)
`functiontype(expr)` should evaluate to a type that is compatible with `std::function`. | Does this help?
#include <type_traits>
#include <functional>
using namespace std;
struct A
{
void f(double) { }
};
void f(double) { }
template<typename T>
struct function_type { };
template<typename T, typename R, typename... Args>
struct function_type<R (T::*)(Args...)>
{
typedef function<R(Args...)> type;
};
template<typename R, typename... Args>
struct function_type<R(*)(Args...)>
{
typedef function<R(Args...)> type;
};
int main()
{
static_assert(
is_same<
function_type<decltype(&A::f)>::type,
function<void(double)>
>::value,
"Error"
);
static_assert(
is_same<
function_type<decltype(&f)>::type,
function<void(double)>
>::value,
"Error"
);
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "c++, c++11, template meta programming"
} |
Oracle takes more time to export csv
Oracle takes more time to export csv,i have tried with UTL_FILE & spool both takes more time,if there are any other way in coding for fastest export? | Just thought I'd do a quick test. Used UTL_FILE to export 4 columns (comma separated) from a table of approx 1.3Million records. This is the code;
DECLARE
fl_output UTL_FILE.FILE_TYPE;
s_output_line VARCHAR2(2000);
CURSOR lcur_test IS
SELECT col_a||','||col_b||','||col_c||','||col_d AS line_out
FROM insurance_policy;
BEGIN
fl_output := utl_file.fopen('OUT_DIR','test_file.csv','w');
FOR lrec_test IN lcur_test
LOOP
UTL_FILE.PUT_LINE(fl_output, lrec_test.line_out);
END LOOP;
UTL_FILE.FCLOSE(fl_output);
END;
Very simple and produces a file with all the records in 25seconds. The DB is Oracle 11g (not Enterprise) on Windows and is by no means fast. I suspect that you may well have a query that is les that optimal and that is where the time is going OR you have something very wrong wit your disks. | stackexchange-dba | {
"answer_score": 0,
"question_score": -2,
"tags": "oracle"
} |
исключить папку из индекса git
Не работает правило, по исключению папки в файле _.gitignore_ , который лежит в папке с проектом.
**правило:**

{
let rightBtn = UIBarButtonItem.init(title: "Right", style: .Plain, target: UIBarButtonItem.self, action:#selector(UIBarButtonItem.self.newMenuTapped(_:)))
cName.navigationItem.rightBarButtonItem = rightBtn
}
}
extension UIBarButtonItem
{
func newMenuTapped(sender: UIBarButtonItem)
{
print("Tapped")
}
}
Crashes with this error:
> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: unrecognized selector sent to class 0x14c830
Can someone guide be as to what I am doing wrong? Thanks. | Create an extension for `UIViewController` like this:
extension UIViewController {
func addButton() {
let button = UIBarButtonItem(title: "Right", style: .Plain, target: self, action: #selector(self.rightButtonPressed(_:)))
self.navigationItem.setRightBarButtonItem(button, animated: false)
}
func rightButtonPressed(sender: UIBarButtonItem) {
print("tapped")
}
}
And call `self.addButton()` in all view controllers where you want to implement the button. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "ios, swift, swift2"
} |
Obtaining a number of (x, y) points that correspond to specific values of concentration that are chosen at random
I need to generate a matrix of points given that they meet the condition that at these (x,y) points concentration is greater than 10. Note that I first run a code that gives me concentration at each location c(x,y,t), and now from the results of the first run I need Matlab to "randomly" pick (x,y) points with the above condition. Also, note the dimensions of the results from the first Matlab run (which the random sampling should be based on): concentration changes with location and time and is 52x61x61, x is 1x61, y is 1x52, and time is 1x61.
For example, for a randomly chosen concentration with a value of 50, what is x and y at which this value is observed? I need to do this for 12 different points; 12 different values of c(x,y,t).
I hope my question makes sense. Thanks. | Well, since you have the coordinates and the moments `x`, `y`, `t` and the function for concentration `c` the plan is:
* calculate the concentration in all points;
* find where are high concentration points;
* calculate the indices of those high concentration points;
* use the indices in the coordinates and moments to get the positions.
The code should look like:
%// Dimensions:
%// 1st --> y
%// 2nd --> x
%// 3rd --> t
conc = c(x,y,t);
high = (conc > 50);
indx = find(high);
%// Here's the trick: convert back to subscripts the linear indices
%// of the random 12 positions/moments where the concentration was high.
select = randi(numel(indx), 1, 12);
[yk,xk,tk] = ind2sub(size(high), indx(select));
%// Aggregate the results as (x,y,t) 3x12 numeric array
result = [x(xk); y(yk); t(tk)]; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "matlab, random, 3d, conditional statements, sample"
} |
Como mudar o encode no Java?
Estou consumindo a API do IBGE para pegar os municípios por estado. Quando imprimo os municípios os acentos ficam errados. O que eu posso fazer para arrumar isso? Abaixo o código que pega o nome dos municípios.
JSONArray jsonarray = new JSONArray(jsonString);
List municipios = new ArrayList();
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject jsonobject = jsonarray.getJSONObject(i);
municipios.add(jsonobject.getString("nome").);
} | Acredito que você pode fazer isso na hora de adicionar o texto à lista:
JSONArray jsonarray = new JSONArray(jsonString);
List municipios = new ArrayList();
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject jsonobject = jsonarray.getJSONObject(i);
municipios.add(new String(jsonobject.getString("nome").getBytes(), "UTF-8"));
}
Pegando os _bytes_ da palavra e criando uma _string_ em formato `UTF-8`, os acentos e caracteres serão exibidos. | stackexchange-pt_stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "java"
} |
Stopping bubbling event in Firefox
I'm trying to handle touch/mouse events. So, I created this code:
myObject.addEventListener("touchstart", function(e){
e.stopPropagation();
e.preventDefault();
console.log("Touched");
mouseTouchDown(e);
});
myObject.addEventListener("mousedown", function(e){
console.log("Clicked");
mouseTouchDown(e);
});
function mouseTouchDown(e){
console.log("Some function.");};
I want to stop bubbling of touch event, so click won't be fired afterwards. It works on Chrome, but on Firefox I get in console:
Touched
Clicked
How can I stop mouse click firing after touch event?
I tried returning false, but it doesn't work. | Have u attached both events with same element?
If that is the case the error is not because of bubbling happening.while mouse click several events will happen like `mousedown`, `touchstart` ..etc.so if you want to avoid mouse click event occuring add `preventDefault()` in the mouse down.This will disable default mouse click event happening on that element. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, firefox, events, touch, preventdefault"
} |
Mocha и Sinon. Как сделать идемпотентные тесты, без памяти состояния?
Имею папку `tests`, в которой лежит чуть более 10 файлов с тестами.
Запускаю файлы по отдельности - **все работает.**
Когда запускаю как `mocha *` или `mocha file1.js file2.js` получаю ошибку.
**Ошибка связана с тем** , что у меня один экземпляр `сервиса для базы данных`, на который я ставлю `заглушки`.
Пример:
File1:
sinon.stub(database.__proto__, "findAll").returns(1);
File2:
sinon.stub(database.__proto__, "findAll").returns(2);
Как сделать их идемпотентными? Убрать эту "память" между тестами. | Решил используя флаг `mocha` \--parallel | stackexchange-ru_stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, юнит тесты, mocha"
} |
count occurances of each word in apache spark
val sc = new SparkContext("local[4]", "wc")
val lines: RDD[String] = sc.textFile("/tmp/inputs/*")
val errors = lines.filter(line => line.contains("ERROR"))
// Count all the errors
println(errors.count())
the above snippet would count the number of lines that contain the word ERROR. Is there a simplified function similar to "contains" that would return me the number of occurrences of the word instead?
say the file is in terms of Gigs and i would want to parallalize the effort using spark clusters. | Just count the instances per line and sum those together:
val errorCount = lines.map{line => line.split("[\\p{Punct}\\p{Space}]").filter(_ == "ERROR").size}.reduce(_ + _) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "scala, apache spark"
} |
Regular Expression to remove everything but characters and numbers between Square brackets
I used
value.replaceAll("^\\w", "");
it works fine if in the following case
[a+b+c1 &$&$/]+(1+b&+c&)
produces:
[abc1]+(1+b&+c&)
but in case of following string it only removes the square brackets within square brackets in the first run
[a+b+c1 &$&$/[]]+(1+b&+c&)
produces:
[a+b+c1 &$&$/]+(1+b&+c&) | _Translating my comments into an answer_
You can use this simple parsing in Java for your replacement:
String s = "[a+b+c1 &$&$/[]]+(1+b&+c&)";
int d=0;
StringBuilder sb = new StringBuilder();
for (char ch: s.toCharArray()) {
if (ch == ']')
d--;
if (d==0 || Character.isAlphabetic(ch) || Character.isDigit(ch))
sb.append(ch);
if (ch == '[')
d++;
}
System.out.println(sb);
//=> [abc1]+(1+b&+c&) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 6,
"tags": "java, regex, parsing"
} |
Cannot redirect to new url using .htaccess
I have a html web page and on the logo of the site, I wrote my logo URL as
`example.com` and I now want to redirect all requests made to `example.com` to go to `
This is my `.htaccess` so far:
ErrorDocument 404
Redirect /index.html
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*)$ [R=301,L]
`example.com` is not being redirected to ` | You need to use the following in your `.htaccess`:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ [L,R=301]
Make sure you clear your cache before testing this. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "php, html, apache, .htaccess"
} |
how to refer another view from the current one?
I'm struggling with a very basic feature. I want to refer another view from the current view to load the content from that view by applying very basic ajax. here is the code:
<div>
<ul id="biographies">
<li> <a href="Ajax">Ajax</a></li>
<li> <a href="Index">Index</a> </li>
</ul>
<div id="biography">
The ajax content will appear here...
</div>
<script type="text/javascript">
$("#biography").load('Ajax.cshtml');
</script>
</div>
Both the page is in the same directory that is: views/home
* Question 1: how to pass the parameter for load event?
* Question 2: how to link to other pages using the anchor tag?
Thanks. | Use the `Url.Action` helper method:
$("#biography").load('@Url.Action("Ajax")');
Similarly, you can use `Html.ActionLink` to get an `a` tag for actions or routes:
@Html.ActionLink("Go to Index", "Index")
@Html.ActionLink("Go to Home:Index", "Index", "About")
The output will be like `<a href='/About/Index'>Go to Home:Index</a>`.
Remember, with MVC the idea is that URLs point to resources and routes, not to specific files. It's best to use these helper methods (rather than writing out hard-coded URLs) as they specify the route precisely. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "c#, jquery, asp.net mvc, hyperlink"
} |
How to remove or hide port no from url?
I have created a web application using **blazor** asp net core and publish as a folder profile, it is working fine on < but i want to remove/hide the port no from url. i am not using IIS express. | If you are using Visual Studio you can go to the menu option "Project => YourApp's Properties" and you'll find the url addresses of your app in the "Debug" tab.
Try tweaking them, but you'll have to be sure to adjust the NAT inside your intranet for it to work as you want. If you pretend to run the app just on a single PC I'm not sure you can get rid of the port number at all... | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "asp.net core, url, port, blazor, blazor server side"
} |
Do two Eladrin both wearing a Circlet of Revelation auto-save on Charm effects?
Eladrin have a +5 racial bonus to saving throws against charm effects.
The Circlet of Revelation head slot item grants the following:
> **Property** : While you have an eladrin ally within 10 squares of you, you gain a +5 item bonus to saving throws against charm effects.
Normally item bonuses and racial bonuses stack, but from a "I-think-too-much" standpoint it seems to not make sense in this case. The circlet lets you pick up the other racial traits of your party members. I wouldn't think you'd gain the racial benefit of your same race twice.
**Do two Eladrin both wearing a Circlet of Revelation get +10 to saving throws against charm effects?** | Yes they do. Even though they are allowing others to use their racial bonuses, it is still classified as an _Item_ bonus and therefore it stacks with the _Racial_ bonus. It does indeed allow you to use your racial bonus twice. | stackexchange-rpg | {
"answer_score": 15,
"question_score": 12,
"tags": "dnd 4e"
} |
Decomposition of local martingales
From Kal97, pg. 446:
> **Theorem 23.14** Any semimartingale $X$ has an a.s. unique decomposition $X=X_0 + X^c + X^d$ where $X^c$ is a continuous local martingale with $X_0^c=0$ and $X^d$ is a purely discontinuous semimartingale.
**Q:** Is it true that if $X$ is a local martingale then **both** $X^c$ and $X^d$ are local martingales? If not, does anyone have a counterexample?
My intuition tells me it is true. But I have a very weak handle on this material and cannot find any theorems/corollaries/remarks/etc. in Kal97 or Pro05 that definitively say whether this is the case or not. | Yes; write $X^d = X - X^c - X_0$. Any sum (or difference, or linear combination) of local martingales is again a local martingale. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "stochastic processes, martingales"
} |
Is it possible to extract tiles layer as raster in QGIS?
Let's say I have a shapefile that contains multiple polygons and I open it on QGIS:
 in QGIS? | You can export OSM XYT Tiles background map as raster file: right click on the OpenStreetMap layer and select `Export / Save as...` to save a copy of the background tiled map as raster file. Be sure to define the extent and resolution of the raster.
To get the extent of a layer, simply click `Calculate from Layer...` in the `Extent` section of the dialog window (see dialog window on the right in the screenshot, in dem middle). If you only want to keep those pixels that intersect the polygons, use `Menu Processing / Toolbox / Clip raster by mask layer` (see documentation).
However, you don't write why you need to do so, what you ultimately want to do with this raster. Maybe there are better ways to achieve that.
_OSM XYZ Tiles map (brighter, in the background), and exported raster file (darker, in the middle):_  | These things are called passenger information displays (or display systems) in most English speaking countries, including Australia (where Hurlstone Park is), Britain and the USA, where they have been used in new subway and main line rolling stock (equipment in USA) since the 1990s. The actual piece of technology in the picture is called a "dot matrix display". A lot of such systems don't use displays like in the picture, they have LCD screens (like a flat screen TV or monitor) and people just call those 'screens' or maybe "information screens". They are found in trains and buses, at stations, bus stops, airports, etc.
Passenger Information system | stackexchange-ell | {
"answer_score": 5,
"question_score": 0,
"tags": "phrase request, colloquial language"
} |
How to match line start and ending with specific text
I'm having a hard time with this regex. I'm trying to match the amount in the line starting with "`Zahlbetrag`" which ends with "`CHF`".
The text to search is:
Zwischentotal 0,00 13,24 906,79 CHF
Zahlbetrag 0,00 13,25 906,80 CHF
My regex so far:
(?<=Zahlbetrag)(?:.*?)((\d+,\d{2})(?=([\s]*)CHF))
The result of this is currently (tested with <
Match 1: 0,00 13,25 906,80
Group 1: 906,80
Group 2: 906,80
Group 3:
But I need the first match to be:
Match 1: 906,80
It should only include the last number, not the full line. Does anyone know how this can be accomplished? | You can use
Zahlbetrag.*?\K\d+,\d{2}(?=\s*CHF)
See the regex demo. _Details_ :
* `Zahlbetrag` \- a literal string
* `.*?` \- zero or more chars other than line break chars, as few as possible
* `\K` \- omit the text matched so far
* `\d+` \- one or more digits
* `,` \- a comma
* `\d{2}` \- two digits
* `(?=\s*CHF)` \- a positive lookahead that matches a location immediately followed with zero or more whitespaces and then `CHF`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "regex, pcre"
} |
Why b=b+1 when b is a byte won't compile but b+=1 compiles
This is my code:
class Example{
public static void main(String args[]){
byte b=10;
//b=b+1; //Illegal
b+=1; //Legal
System.out.println(b);
}
}
I want to know why I'm getting a compilation error if I use `b=b+1`, but on the other hand `b+=1` compiles properly while they seem to do the same thing. | This is an interesting question. See JLS 15.26.2. Compound Assignment Operators:
> A compound assignment expression of the form `E1 op= E2` is equivalent to `E1 = (T) ((E1) op (E2))`, where `T` is the type of `E1`, except that `E1` is evaluated only once.
So when you are writing `b+=1;`, you are actually casting the result into a `byte`, which is the similar expressing as `(byte)(b+1)` and compiler will know what you are talking about. In contrast, when you use `b=b+1` you are adding two different types and therefore you'll get an `Incompatible Types Exception`. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 5,
"tags": "java"
} |
right floated span does not appear to be in parent div
I'm trying to float a span right in my message bar. For some reason on in my webpage the right floated span appears below the div visually. In JS fiddle it looks ok. What could be pushing it down?
Example: <
Html:
<div class="msg">
Some thext here
<span class="goright">Close</span>
</div>
Css:
.msg {
background-color: green;
}
.goright {
float:right;
} | I believe this is an issue only in IE7 and below where the content itself is pushing the floated element down. In modern browsers it should not be pushed down. But to fix the issue, putting the floated span before the content should work.
<div class="msg">
<span class="goright">Close</span>
Some thext here
</div> | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "css"
} |
System.NullReferenceException When checking if != null
I'm using an ASHX handler, i want the handler to check if Session != null.
if (context.Session["Username"] != null)
And i get this error pointing this line:
> System.NullReferenceException: Object reference not set to an instance of an object.
What's the problem? | if (context.Session["Username"] != null)
Does your handler implement `IRequiresSessionState`? Otherwise Session might not be available.
From MSDN:
> Specifies that the target HTTP handler requires read and write access to session-state values. This is a marker interface and has no methods. | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 2,
"tags": "c#, null, handler, ashx, argumentnullexception"
} |
Regular Expression on XSD schema not validating string
I am trying to validate a string such as "1.9.29". Something like a version number in a software. The expression below wont work:
<xs:attribute name="version" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-999]\.[0-999]\.[0-999]"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
I also tried `\d{1,3}\.\d{1,3}\.\d{1,3}\` with no luck. | Try:
<xs:pattern value="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"/>
`[0-999]` matches any one character in the following set: `0-9`, `9`, `9`. In other words, this is the same as doing `[0-9]`.
Note: You should also be able to replace `[0-9]` with `\d`..I believe the reason it didn't work in your second try was because of the trailing `\`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "regex, xsd validation"
} |
DropBox finder button
Does anyone know how the DropBox app is able to add a toolbar button to the Finder window? I'm asking because I'd like to do this in some of my apps.
**Edit:** The dropbox toolbar button is more then a droplet or an app, it gets added to the Finders toolbar buttons list and acts exactly like the other toolbar items. It fades when Finder is inactive(on Snow Leopard) and it has a dropdown menu.
!enter image description here | These are called "Droplets;" Amp Up Productivity With OS X Finder Droplets is a pretty good introduction. You may also be able to find some projects on GitHub; jiho/gitx-here is one I found during a cursory search.
[Edit]
I was incorrect! As you pointed out, this is not a Droplet. Judging by some of their bug reports, this is a Finder plugin. There is a surprisingly sparse amount of information on this topic, especially in Snow Leopard. This SO answer may be of interest to you. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "cocoa, macos"
} |
How to conduct mesh analysis on a current source in series with a resistance?
How can I do a mesh analysis of the following kind of circuit? I'd normally put up Kirchoff's voltage laws for each of the two loops. If the current source wasn't in series with a resistance, I'd write down the voltage law for the complete sling (R 3-4-6-9-8) and the relation between the partial circuits, but in this case, I don't know how to handle the current source.
!enter image description here
How can I conduct a mesh analysis? | Write down Kirchoff's voltage law for the combined loop. That is, disregard the current source and any elements in series with it, since they're not part of the loop.
The relation between the two partial currents is then:
$$I_d - I_u = I_2$$
where \$I_d\$ is the clockwise current in the lower mesh, and \$I_u\$ is the clockwise current in the upper mesh. | stackexchange-electronics | {
"answer_score": 3,
"question_score": 3,
"tags": "dc, current source, analysis"
} |
Prove that there is no function $f$ such that $\int_{0}^{\pi} |f(x)-\sin x|^2dx \le \frac34$ and $\int_{0}^{\pi} |f(x)-\cos x|^2 dx \le \frac34$
> Prove that there does not exist a continuous function $f:[0,\pi] \to \mathbb{R}$ such that $$\int_{0}^{\pi} |f(x)-\sin x|^2 \mathrm{d}x \le \frac34 \\\ \text{and} \\\ \int_{0}^{\pi} |f(x)-\cos x|^2 \mathrm{d}x \le \frac34$$
I thought of some inequalities like cauchy-schwarz and AM-GM , but it didn't help. Also, since there is no condition on $f(x)$ , it could be positive or negative, so that makes it a bit challenging.
Thank you for helping! | Assume such a function exists. We have $$ |\cos x - \sin x| \le |f(x)-\cos x| + |f(x) - \sin x| $$ by the triangle inequality. Hence, $$ \begin{align*} |\cos x - \sin x|^2 \le |f(x)-\cos x| ^2 + |f(x) - \sin x|^2 + 2|f(x)-\cos x||f(x) - \sin x| \end{align*} $$ Integrating from $0$ to $\pi$ and applying the Cauchy-Schwarz inequality we get $\pi \le 3$, a contradiction. | stackexchange-math | {
"answer_score": 12,
"question_score": 4,
"tags": "calculus, integration, inequality, definite integrals, cauchy schwarz inequality"
} |
Ruby * operator before array
> **Possible Duplicate:**
> Understanding ruby splat in ranges and arrays
could anyone tell me what the * does in the following piece of code?
line = "name=yabbi;language=ruby;"
Hash[*line.split(/=|;/)]
Thanks. | `*` is the splat operator. It is used to split an array into a list of arguments.
`line.split(/=|;/)` returns an array. To create a Hash, each element of the array must be passed as an individual parameter. | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 11,
"tags": "ruby, hash"
} |
Optimization in maple
I optimized a function and I want to use the value.
The answer I got is [4.77011197468878567, [alpha = 1.43792823465135400]] and I want to use the alpha for plotting but I don't know how to extract it. | ans := Optimization:-Minimize(...);
ans := [4.77011197468878567, [alpha = 1.43792823465135400]];
ans[2];
[alpha = 1.43792823465135400]
You can utilize that with the `eval` command, to evaluate-at-a-point (ie, substitute, mathematically).
eval(alpha, ans[2]);
1.43792823465135400
expr := cos(alpha^2*x);
2
expr := cos(alpha x)
eval(expr, ans[2]);
cos(2.067637609 x) | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "maple"
} |
decoupling of network and link layer addresses
can you pls help me understand what the instructor is trying to convey in the following slide.
from what I understand:- network address and link address are independent in the protocol layers but when it comes to the assignment of these addresses they are in some sense dependent in a way that for each link-layer address we need to have a network-layer address.
 uses the link layer (MAC) to deliver packets inside a local subnet. For IPv4, ARP is used to translate the local destination IP to the destination MAC address. The IP packet is encapsulated by a link-layer frame (usually Ethernet) and transported across the link-layer network.
The question _which IP address belongs to MAC address xyz_ doesn't usually need an answer.
You only need a network-layer address if you use a protocol that requires those. Alternatively, you could use a protocol without network-layer addressing (like NETBIOS) but that is confined to a local segment and not routable in general. | stackexchange-networkengineering | {
"answer_score": 1,
"question_score": 0,
"tags": "mac address, ip address, gateway"
} |
Android - not all logs appear in a logcat output
I am using windows cmd terminal to output logs of my application using following command:
adb.exe logcat | find "%part_of_my_apps_name%"
however, not all logs appear in the output. Only messages like this one:
I/AppService(10597): Received start id 1: Intent { cmp=package_name/.AppService(has extras) }
And in my `AppService` I have the following code:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "Received start id " + startId + ": " + intent);
Log.i(TAG, "Test");
So what am I doing wrong?
**UPD** : I asked a bit wrong question. I actually used part of my app's name, not package, so it MUST appear in the log output. | I used a part of app's name, however, because `"find"` is basically `case sensitive` it did show me only that particular output ( name appeared in package name ) , so I came up with the following command:
adb.exe logcat -v time | find "%part_of_my_apps_name%" /I | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "android, debugging, android logcat"
} |
Invocation Error in Xaml Page in Xamarin
Here's my question in xamarin forums but until now, I got no answer yet
| I fixed the answer. Please see the link and I put the answer there. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -4,
"tags": "xaml, xamarin, xamarin.forms"
} |
Arrays misbehaving
Here's the code:
# a = Array.new(3, Array.new(3))
a = [[nil,nil,nil],[nil,nil,nil]]
a[0][0] = 1
a.each {|line| p line}
With the output:
[1, nil, nil]
[nil, nil, nil]
but using the commented line:
[1, nil, nil]
[1, nil, nil]
[1, nil, nil]
So why is that? | The commented line is assigning three of the _same reference_ to the array, so a change to one array will propagate across the other references to it.
As for the 2 arrays vs 3, that's simply a matter of the first line specifying 3 as its first parameter and only specifying 2 array literals in the second line.
To create the nested arrays without having any shared references:
a = Array.new(3) {Array.new(3)}
When passed a block (`{...}` or `do ... end`), Array.new will call the block to obtain the value of each element of the array. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 0,
"tags": "ruby, arrays"
} |
Collect files from all subdirectories
I have a directory with about 5,000 subdirectories in it.
Each subdirectory contains one file each.
I'd like to collect those files and put them in the same folder somewhere.
Is there a way to do that by Mac OSX terminal command? Or should I write a, say, python script to do that? | Something like,
find . -type f -exec echo mv {} /path/to/dst/dir/ \;
You'll have to tweak this according to your circumstances, of course. See `man find` for details. Remove the `echo` when you're ready to run for real (preferably after taking a backup). | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "terminal, subdirectory"
} |
div following floating left element does not keep on its right
Please take a look at this page: clicking on the orange cart badge always added contents on its right (since badge is `float: left`).
Now I messed with something and added content ends up **under** the badge at the end of the animation and I can't figure why!
I'm using Firebug too but it's about an hour I'm diggin in it with no results. | The issue is with the `h2` tag. Headers are block-level elements that do not float by default. You would have to add `display-inline` explicitly to that header. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "jquery, css"
} |
How can display json data two models in Rails index page?
in controller
class V1::ItemsController < ApplicationController
def index
images = Image.all
render json: {status: 'SUCCESS', message:'Loaded images',
data:images},status: :ok
items = Item.all
render json: {status: 'SUCCESS', message:'Loaded items',
data:items},status: :ok
end
end
in model
item.rb
has_many :images, dependent: :destroy
image.rb
belongs_to :item
when i am going to render json data i am getting error like this
Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".
pls need help......... | You have defined `ItemsController` to provide both `images` & `items` which is not proper, so it will be more relevant if you do it using association but will need changes at view side.
It will be real good format if you pass your data in following format,
def index
data = { images: Image.all.as_json, items: Item.all.as_json }
render json: { status: 'SUCCESS', message: 'Loaded images & items', data: data, status: :ok }
end
**update:** For show action, you can pass it as,
data = { image: @image.attributes, item: @item.attributes }
@image & @item are objects here | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ruby on rails, ruby"
} |
How do I edit Infopath webparts in SharePoint 2010?
I have full control on a SharePoint 2010 site with an Infopath Web part on it.
I want to edit its content but the relevant ribbons would not show up from the top.
Please help.
Screenshot below: ");
If this in-clause can hold multiple values how can I do it. Sometimes I know the list of parameters beforehand or sometimes I don't know beforehand. How to handle this case? | What I do is to add a "?" for each possible value.
var stmt = String.format("select * from test where field in (%s)",
values.stream()
.map(v -> "?")
.collect(Collectors.joining(", ")));
Alternative using `StringBuilder` (which was the original answer 10+ years ago)
List values = ...
StringBuilder builder = new StringBuilder();
for( int i = 0 ; i < values.size(); i++ ) {
builder.append("?,");
}
String placeHolders = builder.deleteCharAt( builder.length() -1 ).toString();
String stmt = "select * from test where field in ("+ placeHolders + ")";
PreparedStatement pstmt = ...
And then happily set the params
int index = 1;
for( Object o : values ) {
pstmt.setObject( index++, o ); // or whatever it applies
} | stackexchange-stackoverflow | {
"answer_score": 148,
"question_score": 136,
"tags": "java, jdbc, prepared statement, in clause"
} |
how to get html text before its load on page using jquery
I want to alert text before its load on page.
var jaw='<div id="text">hii</div>';
alert($('#text').text())
$('body').append(jaw) | var $jaw = $('<div id="testing">this is stuff <div id="text">hii</div></div>');
alert($jaw.find('#text').html());
$jaw.appendTo(document.body);
You already have a string literal, though, so given the code you have above you could simply do `alert(text)`.
Note that `html()` will return inner html. `text()` will return inner text. If you want outerHTML search for outerHTML solutions for jQuery. That's another topic.
EDIT: Added JSFiddle - < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "jquery"
} |
how to make the second gui wait until the first one finishes?
I have two consecutive guis in one function. how can I make the second one waits until I push the exit button on the first one. I searched in the internet and everyone says use uiwait, but where should I use it? I should menstion that the first gui contains 3 buttons that one of the is supposed to be programmed to quit the gui.
thanks in advance | `uiwait` should be used in the first GUI, just before launching the second.
E.g.: `uiwait( launch_second_gui );` | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "matlab, user interface, matlab guide"
} |
Running Gradle on Ubuntu 13.10
I am having a problem running gradle on ubuntu 13.10, which I am assuming is the root of the issue.
I installed `gradle` using the below command
sudo apt-get install gradle
I am getting an error when running the command `gradle -version`:
gradle -version
/usr/lib/jvm/default-java/bin/java: symbol lookup error: /usr/lib/jni/libnative-platform-curses.so: undefined symbol: tgetent
I am using java version:
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4ubuntu3)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
I'm not sure what else to do. I tried different versions of java, but to no avail. | I was able to fix the above problem with advice from Vidya, manually adding gradle into the system allow gradle to correctly work. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 15,
"tags": "java, ubuntu, gradle"
} |
Brave Browser: Disable Restore Pages on crash
When Brave crashes and then asks me to restore pages
.css("position", "fixed");`
var $rows = $('.col-md-3');
$('.form-control').keyup(function() {
var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*$',
reg = RegExp(val, 'i'),
text;
$rows.show().filter(function() {
text = $(this).text().replace(/\s+/g, ' ');
return !reg.test(text); //sprawdzamy czy wiersz pasuje doelementu szukanego, jeśli nie to chowamy ten wiersz
}).css("display", "none"); | Instead of returning the result of the test directly, use it in an `if()` that does what you want, then returns the result.
$rows.show().filter(function() {
text = $(this).text().replace(/\s+/g, ' ');
if (!reg.test(text)) {
$otherDiv.css("color", "red");
return true;
}
}).hide();
I also recommend using `.hide()` and `.show()` rather than `.css()`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "javascript, jquery"
} |
Stack Overflow for Teams for Students?
So, I saw this post about Stack Overflow for Teams becoming free for teams of up to 50 people, and a thought struck me after I took at look at the Stack Overflow for Teams page: there doesn't seem to be any sort of student discount for SO for Teams. While smaller classes with 50 or fewer students can use the existing free option, classes with more students than that (like many university Computer Science classes) can't.
As a result, I think it might be a good idea for Stack Exchange corporate to consider implementing a free or discounted version of SO for Teams for students/educational institutions, since students trained in how to use SO for Teams at university are probably a lot more likely to carry on using it in their professional life afterwards. | We do offer non-profit organizations (who meet requirements) access to our Free plan for more than 50 users. Educational institutions who have a need should reach out to discuss pricing options for our paid plans directly. We can be reached at our support portal. | stackexchange-meta_stackoverflow | {
"answer_score": 11,
"question_score": 22,
"tags": "feature request, status completed, stack overflow for teams"
} |
Question about Tangent Planes:
So the surface $S$ is given to be $z=x\sin(x+y)$ and the point $(2,-2,0)$ is given. When solving for a tangent plane, I got the equation:
$z = 2(x-2) + 2(y+2)$
So the vector-function of a space curve is $r(t) = <a(t),b(t),c(t)>$ on the surface $S$. And it is supposed that $c(t) = a(t)\sin(a(t)+b(t))$ for all real numbers of $t$. $r(0)$ is said to equal $<2,-2,0>$.
How can I prove that $r'(0)$ is PARALLEL to the tangent plane equation found above?
Also, is the tangent line to $C$ at $r(0)$ on the tangent plane? Can this be inferred from some general fact about space curves, tangent lines, and tangent planes? | Start with the equation:
$$ c = a \sin(a+b) $$
Everything ($c$, $a$, and $b$) are functions of $t$, but I will just write $a$ instead of $a(t)$, etc...
Now take the $t$-derivative of both sides of the equation (using product and chain rules):
$$ c' = a' \sin(a+b) + a\cos(a+b) \cdot (a'+b') $$
Now we plug in $t=0$, remembering that $a(0) = 2$ and $b(0) = -2$:
$$ c'(0) = 2a'(0) + 2b'(0) $$
The derivative $r'(0)$ is the vector $(a'(0), \, b'(0), \, c'(0))$. By the above equation, $r'(0)$ satisfies the tangent plane equation: $$ z = 2(x-2) + 2(y+2) = 2x + 2y $$ | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "multivariable calculus, vector spaces, vectors, plane curves, tangent line"
} |
Copy content://mms-sms/conversations to SD card
I would like to copy the entire contents of the mms-sms database to the SD card, but I can't find a way of doing so. I'd preferably also like to avoid iterating through the entire database (a few calls to the database querying excluded from this exception).
I have already added the R/W External Storage permissions and the R/W SMS permissions.
Can this be done without rooting and copying mmssms.db?
* * *
Extra Details: I'm using API level 21 (Lollipop 5.0+) and I'd also need a way of restoring the copy from the SD card to the database. | This question is very API Level dependent since Android opened up in Level 19.
`Telephony.Sms` and `Telephony.Mms` have `Inbox` and `Outbox` classes that contain all the SMS and MMS messages on the device | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "android"
} |
Find files in subdirectories and copy them to another directory with the same subdirectories?
This question is very similar to this one except that I want to maintain the file's original subdirectories.
For example if I had
/temp/a/a.txt
/temp/a/a.jpg
/temp/a/b.txt
/temp/b/c.txt
/temp/d/d.txt
/temp/d/d.jpg
/temp/d/e.txt
/temp/f.txt
I'd want to copy all the text files to /temp2 so that the directory structure would look like:
/temp2/a/a.txt
/temp2/a/a.jpg
/temp2/a/b.txt
/temp2/b/c.txt
/temp2/d/d.txt
/temp2/d/d.jpg
/temp2/d/e.txt
/temp2/f.txt
Thanks for your help!! | If you want to replicate the whole directory structure, then simply do `cp -a /temp /temp2` if `/temp2` doesn't exist yet, or `cd /temp; cp -a . /temp2` if the target directory already exists. (`-a` is a Linux-specific options to `cp`; on other systems you can use `cp -Rp` for a recursive copy preserving permissions.)
If you want to copy only certain files based on their names, use rsync. It has sophisticated include-exclude rules; I wrote a tutorial for these rules in response to a question asking how to do this at Unix Stack Exchange.
If you want to match files through other criteria such as the date, the simplest way is to combine `rsync` with zsh's pattern matching rules, as in Marcel Stimberg's answer to the above-mentioned question. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 1,
"tags": "linux, command line, bash, cp"
} |
Given ring $F[X]/(X^2)$ why is the ideal (X) the unique maximal ideal of the ring
Given ring $F[X]/(X^2)$ I'm trying to understand why the ideal (X) is the unique maximal ideal of the ring. I have figured out that an element in the ring is either in the ideal (X) or is a unit, but not sure if this helps. | Your observation directly implies the claim:
Let $R$ be a ring and let $I$ be a proper ideal of $R$ such that every non-unit is contained in $I$. Then $I$ is a maximal ideal, and it is the unique one.
_Proof._ If $J$ is some ideal, then either $J=R$, or $J$ consists of non-units. Thus, $J \subseteq I$. Thus, if $I \subseteq J$, we get $I=J$, which shows that $I$ is maximal. And if $J$ is maximal, we get $J=I$, so that $I$ is the unique maximal ideal. $\checkmark$
Alternatively, you can use the fact that $R/I^n$ has a unique prime ideal (and therefore a unique maximal ideal) if $I$ is some maximal ideal of a commutative ring $R$. Apply this to $R=F[X]$ and $I=(X)$. | stackexchange-math | {
"answer_score": 1,
"question_score": 4,
"tags": "linear algebra, abstract algebra, ring theory, ideals"
} |
file_get_contents Connection Timed Out for some contents
i'm developing a site in which user can upload pictures.
Once users insert the url ( only remote ) of image, i call a ajax to a php that take url and store it to the server.
The problem is the file_get_contents:
For some images it gives me Connection Timed Out, for other no.
Some images that gives me that error are:
* <
* <
I simple try to fetch content in this way:
$img = "
$inbuf = file_get_contents($img);
var_dump($inbuf);
What could be the problem? Do i have to change some configurations of my server? | try to use cURL , it gives you more options and control than file_get_contents as the following :
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$raw=curl_exec($ch);
curl_close ($ch);
$fp = fopen($save_to,'x');
fwrite($fp, $raw);
fclose($fp); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, file get contents, connection timeout"
} |
How to create a generic date formatter in java for Solr?
I've a requirement where date can be passed in the following formats before indexing them to Solr. Here are the examples of dates being passed
String dateStr = "2012-05-23T00:00:00-0400";
String dateStr1 = "May 24, 2012 04:57:40 GMT";
String dateStr2 = "2011-06-21";
The standard Solr format is **"yyyy-MM-dd'T'HH:mm:ss'Z'"**.
I've tried SimpleDateFormat but is not able to write a generic program to support various formats. It ends up throwing parse exceptions.
I also tried joda time, but not been succeful so far in UTC conversion.
public static String toUtcDate(final String iso8601) {
DateTime dt = ISO_PARSE_FORMAT.parseDateTime(iso8601);
DateTime utcDt = dt.withZone(ZONE_UTC);
return utcDt.toString(ISO_PRINT_FORMAT);
}
Is there a standard library to achieve this ?
Any pointers will be appreciated.
Thanks | I just try the various formats until I get a hit:
public static String toUtcDate(String dateStr) {
SimpleDateFormat out = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// Add other parsing formats to try as you like:
String[] dateFormats = {"yyyy-MM-dd", "MMM dd, yyyy hh:mm:ss Z"};
for (String dateFormat : dateFormats) {
try {
return out.format(new SimpleDateFormat(dateFormat).parse(dateStr));
} catch (ParseException ignore) { }
}
throw new IllegalArgumentException("Invalid date: " + dateStr);
}
I'm not aware of a library that does this. | stackexchange-stackoverflow | {
"answer_score": 15,
"question_score": 7,
"tags": "java, date, solr, date format"
} |
R Integer Key, Value map
How do you make a simple integer map in R from key to value.
I want to interact with it this way:
id_map[245]
>> 3
id_map[123]
>> 4
Thanks | `environment`s are the closest thing to a hashtable in R. Unfortunately, they only support `character` keys.
ht <- new.env()
assign(as.character(245), 3, ht)
get(as.character(245), ht)
`environment`s are hashed, and will be more efficient than using a vector. Unlike other R objects, `environment`s pass by reference when supplied as the argument of a function.
You can easily use this to implement something that feels natural.
new.hashtable <- function() {
e <- new.env()
list(set = function(key, value) assign(as.character(key), value, e),
get = function(key) get(as.character(key), e),
rm = function(key) rm(as.character(key), e))
}
ht <- new.hashtable()
ht$set(245, 3)
ht$get(245)
# [1] 3 | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 3,
"tags": "r, dictionary, hashmap, key value"
} |
How can I launch an email from a website?
I am developing a seat plan website. When a desk is clicked I get the info of the person sitting at the desk fine (name,phone,email). Now I want to have a email button beside the persons email address (similar to what lync 2011 had if anyone has seen it). On click off the button I would like to launch a new email in outlook and have the persons email address in the To field.
My solution is being developed in Visual Studio 2010, and uses C#, ASP, XML and Javascript/JQuery/JSON.
Does anyone have any advice on how to achieve this - any links or sample source would be great. | `mailto:[email protected]`
Put that in a link. and viola you are good ^_^
Example:
<a href="mailto:[email protected]">Email Harry</a>
See example here with a button (as described in comments below): < | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "javascript, asp.net, email, outlook"
} |
Prime Knots and Prime Numbers
I have heard that prime knots and prime numbers are somehow related. I can see the obvious relationship, that they are both defined similarly, but is there anything beyond this? | This is probably a comment about composition. As is well known, every integer can be decomposed into its prime factorization. So, $12 = 2\times 2 \times 3$. In the same way, every knot can be decomposed into the simplest pieces that cannot be further decomposed. We call these pieces prime knots. The knots which can be decomposed we call composite knots and the operation to put them together is called the connected sum or knot sum. See these links for images that will probably help.
The point here is that you can often get away with only looking at prime knots because every composite knot can be broken down. Otherwise, I don't know of how you would "relate" prime knots and numbers. | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "number theory, prime numbers, knot theory"
} |
Reading variable number of lines from file
How do I read multiple lines (in Java) from an input file (say, helloworld.in)?
The input file does not have a fixed number of lines, it can have anywhere from 3 to 99999 lines. | Use a java.util.Scanner:
Scanner scanner = new Scanner(new File("helloworld.in"));
while (scanner.hasNext()) {
String line = scanner.nextLine();
// Do something
}
With a scanner, you can also read specific types, eg scanner.nextInt() etc | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "java, input"
} |
When i pressed Enter in keyboard it submits the form without going through the javascript?
When i Pressed Enter/Return in Keyboard it submits the form without going through my javascript function in the Submit button of the Form.
I'm thinking of manipulating the keyboard command when pressed but i think that would take time.
so, is there any short way of doing so? like an event in the form/button?
Any Answer will help. Thank you.
PS: sorry for bad explanation. | Assuming "your JavaScript function" is assigned to the submit button's `click` handler, it's obvious why it didn't work: you didn't click the submit button. The code to handle a form submission should go onto the form's `submit` handler. It will trigger from both submit buttons and Enter key.
One more critical piece of info: your handler has to return `false`, or call `preventDefault` on the event; if you don't, the form will still submit after your code exits. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "php, javascript, jquery, html, css"
} |
Add values to a vector to make a consecutive vector in R
I have several vectors that look like this:
v1 <- c(1,2,4)
v2 <- c(3,5,8)
v3 <- c(4)
This is just a small sample of them. I'm trying to figure out a way to add values to each of them to make them all consecutive vectors. So that at the end, they look like this:
v1 <- c(1,2,3,4)
v2 <- c(1,2,3,4,5,6,7,8)
v3 <- c(1,2,3,4)
So "3" is added to the first vector, "1","2","4","6","7" is added to the second and so forth. I have several hundred vectors that look like this so I'm trying to figure out a solution that would scale/be automated. | You can use `seq` and `max`
seq(max(v1))
For multiple vectors, we can loop
lapply(mget(paste0('v',1:3)), function(x) seq(max(x)))
#$v1
#[1] 1 2 3 4
#$v2
#[1] 1 2 3 4 5 6 7 8
#$v3
#[1] 1 2 3 4 | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "r, rstudio"
} |
how to retrieve target security group for a SharePoint list item?
I am developing a web part in C# which is reading the contents of a SharePoint list. I can retrieve the values in all the fields I need, except the Target Audience field (which uses AD security groups). I have tried various ways to access this e.g.
string myItem = Convert.ToString(ListItem.properties["Audience"])
but all I get is null returned. I can see that a target group has been stored in the fueield for thwe item when I edit the item in SharePoint.
How can I retrieve the contents of this field using code? | Try not using the `Properties` of the `ListItem`, but the fields themselves.
In the "Target Audience" field you have some GUIDs stored as strings, these you need to retrieve like so:
//use the FieldId enumeration for system fields
string audienceID = item[FieldId.AudienceTargeting] as string;
string newID = audienceID.Remove(36); //retrieve just the first guid
Guid audienceGuid = new Guid(newID);
AudienceManager audienceManager= new AudienceManager(SPContext.Current.Site);
Audience audience = audienceManager.GetAudience(guid);
afterwards you might want to look at `audience.GetMembership()`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, sharepoint, target audience"
} |
Linking on a Redmine Wiki
I'm writing a wiki on Redmine for the program my company just developed. I've been reading Redmine Wiki formatting pages but I simply can't find how to link to headers on a page that hold spaces.
For example:
This works [[Setup#Oracle|Oracle Setup]]
This does not work [[Setup#Oracle DB|Oracle DB Setup]]
The second I have a header with a space, hyphen, underscore... ANYTHING more than one word, Redmine is unable to link.
Any ideas how to link correctly? | Hyphens worked for me using the textile formatting.
[[Wiki#Test-link-target|a link]]
If you open the wiki page you should see a little paragraph symbol next to each header that appears when you hover your mouse there. That should give you the (semi-)permalink you can use. You can always look at the wiki pages source for the link names.
One problem I remember when working on the Markdown filter was that each text formatter would create it's table of contents separately. So the anchor links for textile might be different than the ones for plain text or Markdown. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "hyperlink, wiki, redmine"
} |
Insert values in MySQL with PHP using combobox
So, I want to insert values into MySQL, but with a combobox. I've already tried some code, but it isn't working. To insert the normal data I have the following code:
<input name="password" type="text" placeholder="Password"
value="<?php echo !empty($password) ? $password : ''; ?>">
I'd like to create a "`user_type`" field (like `adm`, `developer`, `normal_user`), but as a `ComboBox`.
DB name: `bsh` Table name: `customers`
I have not clue how to make it, how can I do it please? | <select name="user_type">
<option value="admin" <?php echo !empty($user_type) && $user_type == 'admin' ? 'selected' : ''; ?> >Admin</option>
<option value="developer" <?php echo !empty($user_type) && $user_type == 'developer' ? 'selected' : ''; ?>>
Developer
</option>
<option value="normal_user" <?php echo !empty($user_type) && $user_type == 'normal_user' ? 'selected' : ''; ?>>
Normal User
</option>
</select>
When you submit form you will get user_type value with nam $_POST['user_type']. May be it could be helpfull to you | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "php, mysql, database, combobox"
} |
Create pull request from specific commit via VS team services
I am trying to create a pull request from specific commit. Is it possible?
**Detail:**
There is commit c1, c2, c3 in branch b1, and commit c3 is also in branch b2. Create a pull request to merge commit c2 into branch b2.
My failed attempts:
* Create a new branch from specific commit, couldn't find any VS team services API for this.
* Create a tag on specific commit, don't know how to, only found get tag api.
* Build a temporary branch b3 from b2, cherry-pick commit c2 to b3 and create pull request from b3 to b2. I don't see any way to pick a existing commit to a branch from official document. | Since the REST Api doesn't have any features to perform merges nor conflict resolution, anything that has to do with merges, rebases, cherry-picks etc needs to be performed locally before pushing the commit data back to VSTS.
The simplest solution would be to perform a clone of the target repo and then to perform the changes before pushing them back.
Depending on what you're trying to accomplish, a shallow clone may suffice, though if you want to cherry pick old commits, that may not work for you. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "git, rest, azure devops, tfs sdk"
} |
How to extract a few levels from a large statistical result in R?
I am not sure if I have used the correct words in the question title, so please let me explain. Lets say, I have a dataset with three factors: species, life, and exposure and one response variable: mean_v. In total there are 108 levels. When I apply 3-way ANOVA followed by Tukey's post-hoc test, it generates a very large number of statistical comparisons.
life <- rep(c("5d", "15d", "45d"), 2, each = 18)
species <- rep(c("SP1", "SP2"), each = 54)
exposure <- rep(c("c1", "c2", "c3"), 6, each = 6)
mean_v <- runif(108, 4, 80)
data1 <- data.frame(species, life, exposure, mean_v)
model1 <- aov(mean_v~species*life*exposure, data1)
tukey <- TukeyHSD(model1)
tukey
However, I am only interested in few, for example comparison between SP2:5d:c3 - SP1:5d:c3. Is there a way to extract specific comparisons from the whole analysis? Thanks in advance | You have to select `species:life:exposure` list inside `tukey` and after that select only the comparison needed, like this:
tukey$`species:life:exposure`[rownames(tukey$`species:life:exposure`)=="SP2:5d:c3-SP1:5d:c3",]
diff lwr upr p adj
-2.123986 -47.461693 43.213722 1.000000 | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "r, extract"
} |
How to get character's position in alphabet in C language?
Is there a quick way to retrieve given character's position in the english alphabet in C?
Something like:
int position = get_position('g'); | int position = 'g' - 'a' + 1;
In C, `char` values are convertible to `int` values and take on their ASCII values. In this case, `'a'` is the same as 97 and `'g'` is 103. Since the alphabet is contiguous within the ASCII character set, subtracting `'a'` from your value gives its relative position. Add 1 if you consider `'a'` to be the first (instead of zeroth) position. | stackexchange-stackoverflow | {
"answer_score": 39,
"question_score": 12,
"tags": "c, char, ascii"
} |
Find triggers of a form in oracle
How can I get the body of triggers in Oracle 10g forms?
I used `ALL_TRIGGERS` but it showed me triggers saved in tables, not in forms. | You can find oracle forms in the .fmb files. You can open .fmb files with a text editor. See How to Open FMB Files for more information. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "sql, database, oracle, forms, triggers"
} |
Which Eclipse distribution to download
I am newbie to Java. I need to build a Windows Desktop Application and use Java bean component and use Eclipse IDE. I searched the web but it is too many information and I am not completely sure how to do it. I understand I need the JDK and JRE before launching Eclipse.
When I opened the Oracle website,there are so many options and I don't know which one I need. For JDK, the website has `Java Platform(JDK)7u51`,`JDK 7u51 & NetBeans 7.4` and `JDK 7Dos`.
Also Eclipse download page suggests a lot of options.
Do I need `Eclipse Standard 4.3.1`and package solutions, `Eclipse IDE for Java Developers`?
Hope someone show me the name of the package and program I need to download.
Thanks. | For Windows Apps:
* Java Platform(JDK)7u51
* Eclipse IDE for Java Developers
If you plan on building Web Applications:
* Java Platform(JDK)7u51
* Eclipse IDE for Java EE Developers | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, eclipse"
} |
Reopen SASS Mixins
Is there a way to redefine SASS mixins. I want to override SASS mixins for site specific styling needs. Is there a way to do it ? | My quick bit of testing seems to show that you can override mixins without a second thought. You can't reopen them to the extent that would allow you to override only certain attributes, but you can easily replace them entirely.
### sample.sass:
=test
color: red
font-weight: bold
=test
color: blue
p
+test
### sample.css:
p {
color: blue; }
Note that this test was performed using Haml/Sass 3.0.2 (Classy Cassidy), so this may not hold true for earlier versions, if you were getting an error before. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "ruby on rails, haml, sass"
} |
RSpec returns all objects to be 'nil'
I am new to Rspec. I am writing a test case to cover some action in a model. Here is my rspec code
test_cover_image_spec.rb
require 'spec_helper'
describe Issue do
before :each do
@issue = Issue.joins(:multimedia).uniq.first
binding.pry
end
describe '#release_cover_image' do
context 'While making an issue open' do
it 'should make issue cover in S3 accessible' do
put :update, :id => @issue.id, :issue => @issue.attributes = {:open => '1'}
end
end
end
end
@issue always returns nil. In my debugger also, Issue.all returns an empty array. | Tests usually run in isolation. That means each test needs to set up the objects before running. After the test run common test configurations delete all created data from the test database. That means you need to create your test data before you can use it.
For example like this:
require 'spec_helper'
describe Issue do
# pass all attributes to create a valid issue
let(:issue) { Issue.create(title: 'Foo Bar') }
describe '#release_cover_image' do
context 'While making an issue open' do
it 'should make issue cover in S3 accessible' do
put :update, id: issue.id, issue: { open: '1' }
expect(issue.reload.open).to eq('1')
end
end
end
end | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, ruby, unit testing, rspec"
} |
Prove that $1+x\log(x+\sqrt{1+x^2})>\sqrt{1+x^2}$ for all $x\in\mathbb{R}$
I tried to approach this problem the most obvious way. I called to life $f(x) =1+x\log(x+\sqrt{1+x^2})-\sqrt{1+x^2}$ and I wanted to show that f(x) in the limit in $-\infty$ is positive (but it diverges to $\infty$ what may be a problem already, is it?) and it is increasing function. I found out that $f'(x)=\log(x+\sqrt{1+x^2})$ so f'(x) is well defined everywhere since $x+\sqrt{1+x^2}$ is always positive but for $x<0$ we have $f'(x)<0$ so my idea of a proof collapses. Does anyone have any hints how to solve this problem? | You can show your inequality (except for $x= 0$) using hyperbolic functions when you recognize that
* $\ln{(x + \sqrt{1+x^2})} = \sinh^{-1}x$
So, set
* $x = \sinh y$ and note that
* $\sqrt{1+\sinh^2y}= \cosh y$
Now, your inequality turns into $$1 + y\sinh y \gt \cosh y \Longleftrightarrow y\sinh y > \cosh y - 1$$ Now, use the series expansions
* $\sinh y = \sum_{n=0}^\infty \frac{y^{2n+1}}{(2n+1)!}$
* $\cosh y = \sum_{n=0}^\infty \frac{y^{2n}}{(2n)!}$
A short calculation shows $$y\sinh y = \sum_{n=\color{blue}{1}}^\infty \frac{y^{2n}}{(2n-1)!} \gt \sum_{n=\color{blue}{1}}^\infty \frac{y^{2n}}{(2n)!} = \cosh y - 1 \mbox{ for all } y \color{blue}{\neq} 0$$ | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "calculus, real analysis, analysis"
} |
Sensible use of SQL Server 2008 FileStream?
I have an ASP.NET MVC application and I want to embed on each page some help content. This will be HTML pages that will be loaded into a dialog or new browser page (to be decided). Obviously I could store this in a max text field in the DB, but I also think I could store it in a FileStream. This sounds appealing to me as it would allow my devs to edit the HTML without requiring a special tool that can access the DB content.
Assuming this HTML is not going to be massive, is this a sensible use of a Filestream or should I simply use a regular text column? | This is not how Filestream works - you cannot modify the files without going through the database. That would be equivalent to editing .mdf files - effectively corrupting the database.
Also keep in mind that unless your HTML files are at least 500 KiB in size (unlikely for HTML files), you may achieve better performance storing them inside the database (e.g. in nvarchar(max) columns). | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "sql server 2008, filestream"
} |
Only last element of dictionary is adding into Core Data
I have a dictionary and I am trying to load all of its data into Core Data.
However, it is inserting only the last element into Core Data.
NSArray *NameArray = [resultsDictionary objectForKey:@"Sections"];
for (NSDictionary *Dictionary in NameArray) {
[section setValue:[Dictionary objectForKey:@"Name"] forKey:@"name"];
} | You override the value for "name" key in every iteration. Thats why only last one gets saved. You should insert a new object or update existing one for every dictionary item.
NSArray *NameArray = [resultsDictionary objectForKey:@"Sections"];
for (NSDictionary *Dictionary in NameArray) {
Section *newSection = <#create new object or fetch existing one#>
[newSection setValue:[Dictionary objectForKey:@"Name"] forKey:@"name"];
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "objective c, core data, nsdictionary"
} |
Can't reach out to nth child img inside div
I have this fiddle, I want to display only first photo on default and hide the rest, and change photo with each mousescroll. var i is determined by mousescroll, if i < 1 or i > 5, I want the operation to break because there is no nth child bigger than 5 or smaller than 1.
**Please provide fiddle in your answers. Thank you.**
**<
$(window).scroll(function(event){
var i = 0;
var st = $(this).scrollTop();
if (st > 0)
{
var i += 1;
if (i > 5)
{
return;
}
$("img").hide();
$("img:nth-child(" + i + ")").show();
}
else
{
var i -= 1;
if (i < 0)
{
return;
}
$("img").hide();
$("img:nth-child(" + i + ")").show();
}
}); | Are you looking for something like this?
**<
var i = 1;
$(document).bind('mousewheel', function (e) {
if (e.originalEvent.wheelDelta < 0) { // scroll down
if (i + 1 <= 5)
i++;
else
return;
} else {
if (i - 1 >= 1)
i--;
else
return;
}
//console.log(i);
$("img").hide();
$("img:nth-child(" + i + ")").show();
}); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, jquery"
} |
send email with pdf attachment using logic app : PDF is not getting opened. It got corrupted
['attachments']?['ContentBytes'] and ContentBytes => base64(triggerBody()['attachments']?['ContentBytes'])
['attachments']?['ContentBytes']) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "base64, http post, azure logic apps, memorystream, tobase64string"
} |
executing php code on server from React native
I'm trying to make a call for a php code on server from react native, and return a value and display it. The idea that I have an image I want to process it on server save it then return results and the resulted image(I already have a php code on server that run a C# code and give back the results) then showing them on the mobile app . any idea? | Do you have a REST API to provide this image?
If you do I use Axios to make http requests.
If you don't, i think fetch has the ability to communicate with a server via TCP.
I suggest you create an API endpoint to provide your image. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -3,
"tags": "c#, php, react native, client server"
} |
Can i host a website with a Minecraft Server?
I want to know if i could do that.
I tried searching up on google but nothing came up.
I wanted to know if there was any spigot plugin that i could use.
Thanks | You cannot host a website from a Minecraft server itself, but you can easily host a website at the same IP address and on the same server/machine as the Minecraft server using software like **Nginx** or **Apache**. | stackexchange-gaming | {
"answer_score": 2,
"question_score": -3,
"tags": "minecraft java edition server"
} |
Export Exchange calendar using EWS API
I am new to EWS managed API. I was wondering if there is any way to export an exchange calendar using EWS API to an ics file. I searched and found ways to create and retrieve calendar items but couldn't find a way to export a calendar. Any help is greatly appreciated | Take a look at < There's a section of that article that talks about exporting to iCal format (which is the format .ics files use). | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "exchangewebservices"
} |
IOS: fill a popover with a tableview
How can I create a popover and fill it with a tableview? I have a button on a toolbar in bottom of my view, and when i push this button I want to show this popover | Create pushviewcontroller and in the pushviewcontroller you have to give the tableview. like this.
UIViewController *myPopOver = [[UIViewController alloc] initWithNibName:@"MyPopOverView" bundle:nil];
//(asper your requirement take thiscontroller as tableview)
popoverController = [[[UIPopoverController alloc] initWithContentViewController:myPopOver] retain]; | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "xcode, ios, uitableview, uipopovercontroller"
} |
Как можно остановить такой таймер
вот код таймера, его нужно остановить, и после возобновить
new java.util.Timer().schedule(new TimerTask(){
@Override
public void run() {
}
},1000*2,1000*2); | Timer t = new Timer();
TimerTask tt = new TimerTask() {
@Override public void run() {
// some code
};
}
t.schedule(tt,1000*2,1000*2);
Остановка:
tt.cancel();
t.cancel(); | stackexchange-ru_stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "java"
} |
pgAdmin is consuming too much ram in Server
I am a developer yesterday I have noticed something odd with my server as pgAdmin is taking 11.2g of Ram I got Nagios alert for that is it normal Please help.
 {
var processed = 0;
for (var c = 1; c < 10; c++) {
workflow.removeZSet(c, function() {
processed++;
if (processed === 9) {
return fn(null, "finished removing");
}
});
}
}
workflow.removeZSet = function(precision, fn) {
rc.zrem("userloc:" + precision, function() {
return fn(null, 'done');
});
});
}
Does anyone have a suggestion how to accomplish this without triggering the warning?
I have some ideas like using the async library to run them all in parallel but this is a fairly common thing I do throughout this code base so interested in feedback on the best way. | The error is because you have define a function within your for loop.
You could try something like this, defining the function outside of the loop:
workflow.removeZSets = function(fn) {
var processed = 0;
function removeZ(c) {
workflow.removeZSet(c, function(err) {
processed++;
if (processed === 9) {
return fn(null, "finished removing");
}
});
}
for (var c = 1; c < 10; c++) {
removeZ(c);
}
}
Using a library like async to do the looping would help clean up your code, it would allow you to avoid checking if all the items have processed (processed ===9) because it is handled by async. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "node.js, asynchronous, redis"
} |
Python: How to connect to a server database?
Which modules would you recommand for connecting a SQL database on the server and how to install and use them?
I'm developing with Python and PyQt5 an application which needs results from a server database. | I suppose it depends on what database you're looking to use. If you're using mysql you might want to check out < . I have been using it and seems to be working out quite nicely. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "python, sql, database, client"
} |
How to make my trigger available in classpath (h2 database)
when I invoke query:
st.execute("create trigger myTrigger after insert on NEWPOPULATION for each row call "\NewPopulationTrigger\" ");
The console write: `Class NewPopulationTrigger not found`
How to should I follow the sentence "The trigger class must be available in the classpath of the database engine" \- how can I implement it?
My research: The example of my issue /
adding classpath in scala | The package must be given on the left of the class name.
In the H2 example. The package is `org.h2.samples` and the class is `TriggerSample`
CREATE TRIGGER INV_INS AFTER INSERT ON INVOICE
FOR EACH ROW CALL "org.h2.samples.TriggerSample"
The clean way in your case is to ask the full name in java:
st.execute("create trigger myTrigger after insert on NEWPOPULATION for each row call \""+NewPopulationTrigger.class.getName()+"\""); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, eclipse, triggers, h2"
} |
How can i fill an Experience Manager footprint dropdown from a Category / Keyword list in the Tridion CM?
I hope someone can point me in the right direction; I'm creating a footprint that has a dropdown. The dropdown values are added by hand. And the footprint works as expected.
Now comes the question: in the SiteEditModel config I want to replace the static entry's by a more dynamic approach by getting the values from a category / keywords list from the Tridion Content Manager.
Has anyone done this? Can someone point me in the right direction?
I was thinking of copying the FootprintDropDown to change and extend it. But it's kinda hard to see what possibilities I have to access the Content Manager. And it seems to be different then creating a GUI extension. | Sounds like you want to create your own editor for the footprint. The possibility was taken into account when we designed footprints and the approach is documented on the following page:
Creating a custom Footprint field with a custom input control (login required) | stackexchange-tridion | {
"answer_score": 3,
"question_score": 3,
"tags": "2013, experience manager"
} |
Python source file organization
I'm starting a new Python project, and want to follow standard conventions as closely as possible. I've read that import statements should come first, for example. But I haven't found any conventions for things like putting all function definitions before or after all class definitions. Are there any conventions for things like this? Or does everyone typically just organize things like function and class definitions in whatever order seems to make sense? | No, there's no convention for organization of functions and classes. However, there are some basic guidelines that will make your source flow better and make more sense to readers:
* Document. Whatever you do, make sure that the uses (and in some cases, implementation) of classes and functions is described in plain english)
* Group together things that are alike. Two functions that perform similar functions? Put them together.
* Use common sense. If a class extends another, the base class should come first. If a function takes an instance of a class you defined, make sure the class definition comes first.
For examples on how this is done, look no further than the Python standard library. The source files from some of the modules should give you an idea how source is organized in Python. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 6,
"tags": "python, conventions"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.