INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Missing GAE's application to an existing Google API project
The problem is the following:
> I have a Google API project which appears in Google API console and Google Cloud console but not in App Engine's applications.
How can I add an App Engine's application to an existing Google API project?
Thanks in advance! | It shouldn't appear in the list of your GAE's apps, because it isn't a GAE app - it is just an API project.
You need to create a new GAE app, and you can do that from here:
<
You can now use your GAE app with your API project, but I don't know of a way to actually associate your new GAE project with an existing API project. They can be used together and technically associated, but the Cloud Console won't show them as associated.
If you didn't already have an API project then you could create your GAE app first and then create your API project from within your GAE app and then they would be fully associated. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "google app engine"
} |
FileHelpers nested quotes and commas - parsing error
I'm trying to parse a CSV file from hell, using the fantastic FileHelpers library.
It's failing to handle a row of the form:
"TOYS R"" US"," INC.""",fld2,fld3,"<numberThousands>","<numberThousands>","<numberThousands>",fld7,
FileHelper is very good at handling number fields in 'thousands' format (using a custom formatter), even when wrapped in quotes, trailing commas etc, however it's causing issues with the first field.
"TOYS R"" US"," INC.""",fld2,...
This field includes both nested quotes and nested commas. FileHelper doesn't know how to handle this and is splitting it into two separate fields, which subsequently causes an exception to be thrown.
Are there any recommended ways to handle this? | First, you need to make all of your fields optionally quoted.
[DelimitedRecord(",")]
public class contactTemplate
{
[FieldQuoted('"', QuoteMode.OptionalForBoth)]
public string CompanyName;
[FieldQuoted('"', QuoteMode.OptionalForBoth)]
public string fld2;
// etc...
}
Then you need replace the escaped delimiters with something else (e.g., a single quote) in a `BeforeReadRecord` event.
var engine = new FileHelperEngine<MyFileHelpersSpec>();
engine.BeforeReadRecord += (sender, args) =>
args.RecordLine = args.RecordLine.Replace(@"""", "'"); | stackexchange-stackoverflow | {
"answer_score": 13,
"question_score": 4,
"tags": "c#, parsing, csv, filehelpers"
} |
If $ n^2+2 $ and $ n^2-2 $ are prime numbers, then $n$ is divisible by $3$.
If $n>1$ ($n \in \Bbb N$) and,if $ n^2+2 $ and $ n^2-2 $ are prime numbers, prove that $n$ is divisible by $3$.
I have been trying to solve this with no success. | Note that 3 must divide exactly one of $\\{a-2,a,a+2\\}$ for any integer $a$. [In fact 3 must divide exactly one of $\\{a-1,a,a+1\\}$. Furthermore 3 must divide exactly one of $\\{a-k,a,a+k\\}$ for any integer $a$ and any integer $k$ relatively prime to 3.]
So setting $a=n^2$, it follows that 3 must divide exactly one of $\\{n^2-2,n^2,n^2+2\\}$.
But $n^2-2$ and $n^2+2$ are prime, so which of $\\{n^2-2,n^2,n^2+2\\}$ does 3 divide again? And then after that...
> And if 3 divides $n^2$, then does 3 also divide $n$? | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "number theory, elementary number theory"
} |
Is Ubuntu 10.04 suitable for working on for web development
Im just wondering what everyone's experiences are with the latest Ubuntu 10.04 version? Is it stable enough for a working environment?
I require it for web development, so using VMs, IDEs, connecting to VPNs, SSH to servers, etc. Im currently using 9.04 and found 9.10 unstable and problematic at times (such as problems connecting to VPN)
Any input would be appreciated, thanks! | Yes we are using it right now on many machines, since it has the "LTS" designation it is slated for more attention than other releases as they'll maintain "Long Term Support" for it.
Go for it! | stackexchange-superuser | {
"answer_score": 1,
"question_score": 3,
"tags": "linux, ubuntu, web development"
} |
Launch ASP Development Server Manually?
There has to be a way to do this, I was googling information but I can't seem to get it to work. The sites I checked out said to do something along the lines of
**`start /B %WINDIR%\Microsoft.NET\Framework\v2.0.50727\webdev.webserver.exe /path:"D:\MyFolder" /vpath:/HelloWorldWebSite`**
In a batch file. However, none of my framework folders (im developing in 3.5) have this **`webdev.webserver.exe`** file.
Any suggestions?
UPDATE: Thanks to Casper over on this post, I found where the file resides. | C:\Program Files\Common Files\microsoft shared\DevServer\9.0
got it here on my pc
used task manager to track it | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 5,
"tags": "asp.net, webdev.webserver"
} |
Visual Studio 2015 does not remember undocked windows position between debug and coding views
An issue started happening with VS2015. All was working fine for a while and then it suddenly stopped remembering the position of my undocked tools windows when the "view" switches between debug and coding.
All my undocked windows get repositioned in the middle of the main visual studio monitor.
Even rearranging the toolboxes, doing Window > Save window Layout, and then trying to apply that layout screws up.
Maybe relevant info : \- multiproject C# solution. \- multiple monitors (3) \- windows 7 pro
Anybody has a fix for that? | Ok, turns out it was an issue with my triple monitor setup. (I use a Matrox TripleHead2Go display port.)
The issue was that the Matrox PowerDesk / Desktop Management settings where screwing around with Visual Studio's window layout settings.
All I had to do was uncheck the "Center Dialog Boxes and message boxes" settings :
; do rm $a_file; done;
But this script doesn't incorporate spaces. How would I fix that? | How about using the `find` command's built-in `-delete` action? that should be whitespace safe
find . ! -name '*-out*' -type f -delete
Otherwise, you could do a null-terminated while loop - make sure you quote the filename variable as well
while read -rd $'\0' f; do rm "$f"; done < <(find . ! -name '*-out*' -type f -print0) | stackexchange-askubuntu | {
"answer_score": 2,
"question_score": 0,
"tags": "delete"
} |
Change the next N characters in VIM
Say I have the following line:
|add_test() (| == cursor position)
And want to replace the 'add' with a 'del'.
del|_test()
I can either press X three times and then press i to insert and type del. What I want is something like 3c or 3r to overwrite just 3 characters. Both of these don't do what I want, 3c overwrites 3 characters with the same character, 3r does several other things.
Is there an easy way to do this without manually Xing and inserting the text? | `3s`, "substitute 3 characters" is the same as `c3l`. `3cl` and `c3l` should be the same, I don't know why you'd see the same character repeated. I'm also a fan of using `t`, e.g. `ct_` as another poster mentioned, then I don't have to count characters and can just type "del".
I struggled with the "replace a couple of characters" for a few days too; 'r' was great for single characters, `R` was great for a string of matching length, but I wanted something like the OP is asking for. So, I typed `:help x` and read for a while, it turns out that the description of `s` and `S` are just a couple of pages down from `x`.
In other words, `:help` is your friend. Read and learn. | stackexchange-stackoverflow | {
"answer_score": 114,
"question_score": 72,
"tags": "vim, character"
} |
{% if session['username'] =='' %} doesn't display the login button
I want to display the login button if the username is empty.
But it doesn't display the login button instead the part within the else statement is rendered but the username is blank. I tried with double quotes as well and it is the same. Can anyone see what is wrong?
{% if session['username'] =='' %}
<button>
<fb:login-button scope="public_profile,email" onlogin="sendTokenToServer();">
<a href='javascript:sendTokenToServer()'>Login with Facebook</a>
</fb:login-button>
</button>
<!--END FACEBOOK SIGN IN -->
{% endif %}
{% else %}
<a href="{{url_for('fbdisconnect')}}">Welcome {{session['username']}} <br>Logout</a>
{% endif %} | I think this is what you are looking for:
{% if 'username' not in session %} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "python, html, flask, jinja2"
} |
Unable to access website admin page - 500 error - how to change landing page
Help is required to solve a problem created by a stupid mistake.
Our website is hosted by Godaddy and created with Wordpress. It had been set up and running smoothly for long.
Recently We wanted to keep the website down for some time as we wanted to modify some contents. So with a "brilliant-idea-moment", using wp-admin login, in the dashboard, the landing page name was changed from "mydomain.com" to "mydomain.com/404".
Now we are not able to access the wp-admin login page at all to revert back, as it keeps redirecting it to "mydomain.com/404/wp-admin", a page which does not exist so giving a 500 error message.
Is there anyway, we could change the landing page back to original, through hosting admin or cPanel by editing any specific file?
Your assistance would be highly helpful. | Connect to you Cpanel through godaddy and search for `PHPMyadmin`. The interface that allow you to manage your database.
Then search for a table called `wp_options` then in this table you should be able to find the url of the site in two places ( **siteurl** , **home** ) and you should be able to change it back to the domain name.
After this you will be able to access the admin again, then you should go to the permalinks settings and hit save (without doing any changes). This will correct your url rewriting. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 1,
"tags": "login, 500 internal error"
} |
Compile Laravel blade component from string
I have a pagebuilder where i store {variable} in the database. When loaded on the frontend i want the variable to be translated to blade components.
$replacers = [
'x-system-counters' => '<x-system-counters :data="$gloabal_variable"></x-system-counters>',
'x-system-status' => '<x-system-status :data="$gloabal_variable"></x-system-status>',
];
$page = \App\Page::first();
$text = $page->content;
foreach ($replacers as $key => $value) {
$text = str_replace('{'.$key.'}', $value, $text);
}
//Bladefile
{!! $text !!}
Any idea of how to solve this? I have tried the `Blade::compileString($text)` with no luck.
Thanks | After some digging, this was actually very easy. Laravel always delivers
$replacers = [
'x-system-status' => view('compontents.system-status', $data)->toHtml(),
];
$page = \App\Page::first();
$text = $page->content;
foreach ($replacers as $key => $value) {
$text = str_replace('{'.$key.'}', $value, $text);
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "laravel"
} |
Android Studio: How do I remove the phone border frame on layout previews?
When previewing a layout, such as activity_main.xml on the design view, how do I remove the frame of the phone on my previews? I know this question may have been answered before, but I can't find the solution anywhere.

Is there an equivilent of vb.nets StringValue.ToString("0000") so that it returns the string as four numbers. I'm trying to work it on :
public static String getNextID(int stationID, String tablename) {
String rtnID;
rtnID = Integer.toString(stationID) + "-" + getNextID(tablename);
return rtnID;
}
So that the value of rtnID is 4 characters long and it's added 0's in the right place if needed
Tom
Edit: heres what I now have that isn't working:
public static String getNextID(int stationID, String tablename) {
String rtnID;
NumberFormat formatter = new DecimalFormat("0000");
String s = formatter.format(String.valueOf(stationID));
rtnID = s + "-" + getNextID(tablename);
return rtnID;
}
With this error: < | You can use this:
NumberFormat formatter = new DecimalFormat("0000");
String s = formatter.format(stationID); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "java, android, string"
} |
select a string from sql server with slash it include a backslash
I have a data in my sql server like this
<
my query is like this :
select mag_link from [_DB].[dbo].[magazine_details]
then when i put to json i've got
http:\/\/172.16.11.29:7777\/Lesson1Makeview.pdf
there's a \ in the link i've got.
how will i remove it?
im using c# | That is an entirely valid representation in JSON; it is _unnecessary_ to escape `/` as `\/`, but it is _valid_ to do so.
If you don't want to perform an _unnecessary_ escape, then: use a tool that doesn't do that. JSON.NET does not add this, for example:
var obj = new Foo { url = " };
var json = JsonConvert.SerializeObject(obj);
Which results in the string:
{"url":"
However, both the json above and the json below will deserialize to mean the same thing
{"url":"http:\/\/foo.com"} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "c#, json, wcf"
} |
MySQL: Getting a return code when calling a stored procedure within another stored procedure?
You have 2 MySQL stored procedures, both that select return codes at the end. You need to call 1 stored procedure within another, and get its return code. Is this possible?
Proc1:
CREATE PROCEDURE (IN...)
BEGIN
DECLARE ret_code
...UPDATE SOMETHING....
SELECT ret_code as return_code from dual;
END
Proc2:
CREATE PROCEDURE (IN...)
BEGIN
DECLARE returnVal
if(conditional true)
..Update something else..
Set returnVal = x;
else
call proc1(var1,...)
Set returnVal = (ret_code obtained from proc1)
end if
select returnVal;
END
When calling proc1 within proc2, how can I get that ret_code that's selected at the end of proc1 within proc2? | You should either use `CREATE FUNCTION` instead of `CREATE PROCEDURE`:
CREATE FUNCTION (...) RETURNS ...datatype...
BEGIN
DECLARE ret_code
...UPDATE SOMETHING....
RETURN ret_code;
END
CREATE FUNCTION (...) RETURNS ...datatype...
BEGIN
DECLARE returnVal
if(conditional true)
..Update something else..
Set returnVal = x;
else
Set returnVal = proc1(var1,...)
end if
RETURN returnVal;
END
or else specify an `OUT` parameter to the procedure, and use that:
CREATE PROCEDURE (OUT ret_code ...datatype..., IN...)
BEGIN
...UPDATE SOMETHING....
Set ret_code = return_code;
END
CREATE PROCEDURE (OUT returnVal ...datatype..., IN...)
BEGIN
if(conditional true)
..Update something else..
SET returnVal = x;
else
call proc1(returnVal, var1,...)
end if
END | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "mysql, sql, stored procedures"
} |
makeglossaries hangs waiting for input on mac
I'm very new to Latex so apologies if this is a newbie question. However I have looked around online and can't find an answer.
I'm trying to compile my file in TeXShop (on mac) using the following but I'm not sure how to go about it (using the 'Typeset' button alone is not sufficient). Please can someone help me out?
(pdf)latex
makeglossaries
(pdf)latex
(pdf)latex
When I tried compiling the document with the script provided it got stuck. Here is a screenshot of what I see:
!enter image description here | You create a file with
#!/bin/sh
bfname=$(dirname "$1")/"`basename "$1" .tex`"
pdflatex --shell-escape "$1"
makeindex -s "$bfname".ist -t "$bfname".glg -o "$bfname".gls "$bfname".glo
pdflatex --shell-escape "$1"
pdflatex --shell-escape "$1"
You save this file with a name like `glossaries.engine` inside
`/Users/yourusername/Library/TeXShop/Engines`
You need also to make excutable the script :
Go to the terminal : `cd ~/Library/TeXShop/Engines` and then `chmod u+x glossaries.engine` use the name of your engine.
Then you can compile with the engine glossaries . Before to click on the compilation button, you need to chice the engine inside the list near the button "typeset", I suppose because in french, i have a "composition" button. | stackexchange-tex | {
"answer_score": 7,
"question_score": 5,
"tags": "compiling, glossaries, texshop"
} |
Create new table procedure
I'm trying to create a procedure which adds / removes a table to the database. I'm working in SQL Server. The query works (it succeeds) but the table isn't added to the database.
I did refreshed...
ALTER procedure [dbo].[upgrade_1]
as
begin
create table awards (
ID int NOT NULL IDENTITY,
name nvarchar(256) DEFAULT 'award',
description nvarchar(256)
PRIMARY KEY (ID)
)
/*update goto_vs
set current_version = 1*/
end | The script you have in the question will only modify the PROCEDURE. The procedure needs to be executed for it to perform the required task e.g. create the table
Execute the procedure with this statement
EXEC upgrade_1
That should create the table | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "sql server 2008"
} |
Which gears combinations shouldn't be used?
Is there any general rule or recommendation to avoid usage of certain gears combinations (for 2xN and 3xN gears systems)? Do they differ for mtb and road bikes? I know that it's recommended not to use biggest front chainring with big chainrings on cassette (and opposite) because parts will wear faster and I will loose a bit of pedaling efficiency, but I'm not sure, if I should avoid 2 or 3, or even more biggest (smallest in opposite case) chainrings on cassette. | This is an old chestnut from the days of 5 speed freewheels and chainrings without shifting ramps. With modern hyperglide cogs and the relatively slinky thin modern chains, cross chaining is simply no longer an issue. While there are very few studies on this, the one I've seen suggests that there is no loss in mechanical efficiency for cross chaining at the angles typical of most bikes.
In general for a given gear ratio, big/big is more mechanically efficient than small/small. So the only science out there suggests that cross chaining on the big chainwheel is actually more efficient.
<
Use the gears you like, check your chain wear and replace your chain often and the expensive bits of your drive train will last a long time. | stackexchange-bicycles | {
"answer_score": 7,
"question_score": 6,
"tags": "gears"
} |
Position an element at top right of a <span> in IE
I am having trouble positioning a (div) element at the top right of a span. It works in FF3, but not in IE7:
<html>
<head>
<style>
body
{
font-size: 24px;
}
.tag
{
padding: 3px;
background-color: lightblue;
position: relative;
}
.x
{
position: absolute;
top: 0px;
right: 0px;
width: 10px;
height: 10px;
background-color: orange;
}
</style>
</head>
<body>
text <span class="tag">tag<div class="x"></div></span> text
</body>
</html>
In FF3, a 10x10 orange box is rendered at the top right corner of the light blue box. I am having trouble getting this to work in IE7. Thanks! | First, get a proper doctype for your page so that it's not rendered in quirks mode.
W3C: Recommended list of DTDs
Second, make sure that the code is valid. You can not put a block element (div) inside an inline element (span).
W3C markup validation | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "html, css"
} |
RVM problems installing ruby 2
I did `rvm get stable`
Then I tried to install ruby 2.0.0
$ **rvm install 2.0.0**
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-2.0.0-p0.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing requirements for smf, might require sudo password.
Installing SM Framework.
Error running 'requirements_smf_install_sm',
please read /usr/local/rvm/log/ruby-2.0.0-p0/smf_install.log
$ **cat /usr/local/rvm/log/ruby-2.0.0-p0/smf_install.log**
[2013-03-28 20:58:11] requirements_smf_install_sm
SMF Framework support is only intended for RailsInstaller, please use Homebrew integration instead.
The error log is not very helpful. I am on Mac OS X Mountain Lion. Any help? | Try running
brew update
If you don't have brew installed there is a good guide here to doing the whole installation process, you can ignore the 1.9.3 stuff and replace it with 2.0.0
< | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 5,
"tags": "ruby on rails, ruby, rvm"
} |
Delete partial duplicates from a MySQL table
I have a table that looks like this
Id FirstName
5 Adam
6 Bob
8 Bob
5 Carl
5 Dewie
8 Ernest
When two rows have the same Id, I'd like to keep only one of them. On this example, I would obtain
Id FirstName
5 Adam
6 Bob
8 Bob
Is there concise command to that? I was thinking of
SELECT * FROM Persons HAVING(COUNT(Id)=1)
or
SELECT DISTINCT(Id), FirstName FROM Persons
but my syntax isn't correct. | Hope you are looking for this::
SELECT * from Persons GROUP BY Id | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "mysql, sql"
} |
How to transform German umlauts when creating slugs?
First of all, I want to thank you for creating Craft. It's really one of the best content management systems I have ever worked with.
I encountered an issue while working on a multilingual site: German Umlauts are not automatically transliterated ( **Ä -> Ae** ) for slugs. In other parts of Craft (e.g. field handles) Umlauts _are_ transliterated automatically.
Personally, I would prefer if this behavior could be controlled by a config variable (e.g. `slugExpandUmlauts`). | Try enabling the config setting `limitAutoSlugsToAscii`, that should do what you want. | stackexchange-craftcms | {
"answer_score": 4,
"question_score": 4,
"tags": "localization, slug"
} |
Finding nth term when recurrence relation is given
$$a_k = \left\\{ \begin{array}{lr} 2a_{k-1} - a_{k-2} &: if \space k > 2 \\\ 3 & :if\space k =2 \\\ 2 & :if \space k =1 \end{array} \right.$$
It's easy to see that the nth term is n+1 based on the pattern but how do I actually show it? Is there a general way to solve these recurrence problems?
The only way I can think of is $a_k - a_{k-1}=a_{k-1}-a_{k-2}$ implies arithmetic progression, so based on that n+1 | The more general approach would be to write a characteristic equation
$$x^k=2x^{k-1}-x^{k-2}$$
and simplify this to $$x^2=2x-1$$ which has the double solution $x=1$.
It there had been two distinct solutions $\beta$ and $\gamma$ then a general solution to the recurrence would be $a_k= A\beta^k+B\gamma^k$ and you would find $A$ and $B$ by looking at the initial terms. But if there a double solution $\beta$ to the characteristic equation then a general solution to the recurrence would be $a_k= A\beta^k+Bk\beta^k$. With longer linear recurrences, there may be more roots, and a similar approach works.
Here we are in the latter situation and $\beta=1$, so the solution is of the form $a_k=A+Bk$, and the initial terms $a_1=2, a_2=3$ tell us $A=1, B=1$ and thus $$a_k=1+k.$$ | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "sequences and series, recurrence relations, alternative proof"
} |
Implement a Facebook login without breaking the privacy
Like everybody knows Facebook ignores the privacy compleatly.
So I would like to allow users to login via Facebook without breaking their privacy or non Facebook users. Curriently I'm using the modules `Fbconnect`, `OpenID Selector`, `OpenID Selector for Drupal login` and `OpenID Selector for Facebook Connect`.
I want to allow the users to log in like in stack exchange. This works almost so like expected except the Facebook stuff. The plugin adds to everypage a stupid link to Facebook. So Facebook can spy my users. How can I avoid that?
Is it possible that I download the ` script and put it on my space? Or maybe to proxy the access and cache the file. Does anyone know if some of my ideas are forbidden by Facebook? | I can suggest you a module called Janrain engage drupal.org/project/rpx , this does not add links, it helps you during the registration to collect the user data as well. Have a look to it. | stackexchange-drupal | {
"answer_score": 1,
"question_score": 1,
"tags": "7, users, social network"
} |
How to programmatically show master view controller on splitViewController when in Portrait orientation?
I have a UISplitViewController where I need to show the master view controller in both landscape and portrait, currently the user has to either swipe or press a bar button item to show the master view controller but I need it to be visible on page load.
Any Ideas? | Set the split view controllers preferredDisplayMode property to UISplitViewControllerDisplayModeSideBySide | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "objective c, ios7, uiviewcontroller, uisplitviewcontroller, uipopovercontroller"
} |
Python Win32 and excel
I am using WIN32com to use excel. I need to make sure that excel opens up new instances everytime. So if I run this and already have excel open I need it to open a new excel, and with in the script I need it to open a 2nd excel window for file 2 . This is what I am using: I can get it to open but not in new instances.
import win32com.client
import os
x1 = win32com.client.Dispatch("Excel.Application")
wb1= x1.workbooks.Open("X:\File1.xlsx")
wb2 = x1.workbooks.Open("X:\File2.xlsm")
x1.close("X:\File1.xlsx") | You can use DispatchEx to create a new instance of the application.
x1 = win32com.client.DispatchEx("Excel.Application")
x2 = win32com.client.DispatchEx("Excel.Application")
wb1 = x1.Workbooks.Open(.....
wb2 = x2.Workbooks.Open(.....
Roger | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "python, excel, win32com"
} |
XML / XSL Use maths functions like cosine() or sine()
I have got a XML file. I'm trying to do a pie chart thanks to a XSL file, however I need use maths functions in my program but I don't know how to do it. In order to visualize the result I want to use a browser like Firefox or Internet Explorer. Excuse me if I have made mistakes.
Help me please ! | Browsers only support XSLT 1.0 and there are no trigonometric functions in XSLT 1.0. I believe your options are limited to these two:
1. Transform your XML to HTML and use HTML/Javascript to draw the chart **after** the transformation;
2. Use the Taylor power series to simulate trigonometric functions such as sine and cosine.
\--
_(Or do the transformation in another tool before passing the result to a browser.)_ | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -4,
"tags": "xml, xslt, math, pie chart, xls"
} |
Binary list from indices of ascending integer list
I have an ascending list of integers `e` that starts from 0 and I would like to have a binary list `b` whose `i`-th element is 1 if and only if `i` belongs to `e`.
For example, if `e=[0,1,3,6]`, then this binary list should be `[1,1,0,1,0,0,1]`, where the first 1 is because 0 is in `e`, the second 1 is because 1 is in `e`, the third 0 is because 2 is not in `e`, and so on.
You can find my code for that below.
**My question is:** is there something built-in in python for that? If not, is my approach the most efficient?
def list2bin(e):
b=[1]
j=1
for i in range(1, e[-1]+1):
if i==e[j]:
b.append(1)
j+=1
else:
b.append(0)
return(b) | This can be done with a list comprehension, and in case `e` is huge then better convert it to a `set` first:
>>> e = [0, 1, 3, 6]
>>> [int(i in e) for i in xrange(0, e[-1]+1)]
[1, 1, 0, 1, 0, 0, 1]
The `in` operator returns True/False if an item is found in the list, you can convert that bool to an integer using `int`. Note that for lists the `in` is `O(N)` operation, so if `e` is large then converting it to a set will provide you much more efficiency. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 1,
"tags": "python, list, binary"
} |
Is Late 2016 MacBook Pro 13" Capable of 3440 x 1440 @ 100 Hz?
I have a Late 2016 MacBook Pro 13" laptop and I am considering buying the Samsung CF791 34" monitor, capable of 3440 x 1440 @ 100 Hz resolution. I realize I may need to buy an adapter, such as the USB-C to DisplayPort Adapter Cable from StarTech, but I'm concerned I won't be able to get 100 Hz from this cable and/or the built-in video card won't support that resolution and refresh rate.
If I buy this monitor and cable, will I be able to use the Mac at 3440 x 1440 @ 100 Hz resolution? | The Startech adapter didn't work for me with the Samsung CF791 (the monitor was not getting any signal and I had to return the cable). I did however get 3440x1440 @ 100 Hz using the Anker USB-C to HDMI adapter. You can see it here: 
df.head()
for i in df.columns:
print(df.loc[:, i].is_unique)
Using `[x.is_unique for x in df.loc[:, i] for i in df.columns]` does not work | Use `Series.is_unique` with one `for`:
out = [df[i].is_unique for i in df.columns]
Alternative solution (I prefer first for more clear iterate by columns):
out = [df[i].is_unique for i in df] | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "pandas, list comprehension"
} |
Zshell aliases like !gst inside vim?
Is there a way to run my zshell aliases inside vim, with the output going to a new split?
I'm using oh-my-zsh's git aliases like `gst`, and I am unable to do `:!gst` inside vim.
Thanks | Try
:set shell=zsh\ -l
And put the alias setting to `~/.zshenv`
Here is the similar question terminal vim not loading .zshrc. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 11,
"tags": "bash, vim, zsh, aliases"
} |
variable inside pattern
var seperator = ',', group = 'red, blue';
//group.search(seperator/g) - g is not defined
group.search(/seperator/g) // looks for "seperator"
group.search('/' + seperator + '/g') // doesn't seem to find my "seperator"
And with that I'm out of ideas... How do I get my `seperator` within expression?
Thanks in advance! | You need to create new regexp Object
var test = new RegExp(seperator, 'g');
group.search(test) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "javascript, regex, dynamic"
} |
\today month as text
I have this code:
\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage[ddmmyyyy]{datetime}
\renewcommand{\dateseparator}{.}
\begin{document}
\today
\end{document}
Prints:
!enter image description here
How can I make it print this:
07 May, 2013 | From the `datetime` manual, you have two solutions:
* either use the predefined `shortdate` format, which will print "07th may, 2013";
* or define a new date format to get rid of the ordinal as well.
\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage[nodayofweek]{datetime}
\newdateformat{mydate}{\twodigit{\THEDAY}{ }\shortmonthname[\THEMONTH], \THEYEAR}
\begin{document}
\shortdate
\today
\mydate
\today
\end{document}
!enter image description here | stackexchange-tex | {
"answer_score": 31,
"question_score": 34,
"tags": "datetime"
} |
Get the highest index with a defined value in an array in python
what could be a nice one-liner to get the highest index in a python array whose value is defined (i.e. not None):
f( [None, 1, 5, None, 3, None, None] )
would return:4 (as the "last" defined element is 4. (with value 3))
Sure a search loop would make the job, but it feels non optimal... | Loop over the reversed of the list and return the first valid item's index:
In [70]: next((len(l) - i for i, j in enumerate(l[::-1], 1) if j is not None), 'NOT FOUND')
Out[70]: 4
Note that since you are looping over the reversed array the correct index would be `len(l) - i` (if we consider the first index as 1).
If you are looking for a functional and/or more optimized approach you can use `numpy` and it's `where` function:
In [1]: import numpy as np
In [2]: lst = [None, 1, 5, None, 3, None, None]
In [4]: np.where(lst)[0][-1]
Out[4]: 4 | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "python, arrays"
} |
Diff-in-Diff with multiple treatment groups
I have monthly panel data and I want to estimate the effects of two different treatments that occur in different time periods. The treatment groups are not the same. An individual can belong one, both or neither of the treatment groups. If one belongs to the first treatment group it is likely that one also belongs to the second group. Both treatments are permanent. What kind of difference in differences specification should I use?
I have been thinking the following kind of equation, but I don't know if it makes sense.
$Y_{it}=B0*\text{Treated1}_i + B0'*\text{Treated2}_i + B1*\text{Treated1}_i*Post1_t + B2*\text{Treated2}_i*\text{Post2}_t + \text{VectorOfTimeDummys}_t + B3'*\text{VectorOfControlVariables}_{it} + \text{ErrorTerm}_{it}$ | Yes it make sense. You should include also an intercept term (unless you have good reason to not do so) which is excluded from your formula.
Individuals who do not belong to treatment group 1 or 2 will form the reference (or control) group.
If a large group of individuals belong to both groups, it might be difficult to separate $B1$ and $B2$ (imperfect multicollinearity issue) and you might have no choice but to stick with only one treatment indicator for both of them. | stackexchange-stats | {
"answer_score": 0,
"question_score": 3,
"tags": "econometrics, panel data, difference in difference, treatment effect"
} |
Как можно проверить наличие драйвера в системе?
Например, нужно проверить есть ли у пользователя JET 4.0 или ACE 12.0 в системе. | Вообще-то это OLE DB провайдеры и их поиск осуществляется с помощью `OleDbEnumerator`.
using System.Data.OleDb;
. . .
OleDbEnumerator enumerator = new OleDbEnumerator();
DataRow[] foundRows = enumerator.GetElements().Select("SOURCES_DESCRIPTION = 'описание провайдера'");
if (foundRows.Length > 0)
{
/*OLE DB провайдер установлен! Всё в порядке!*/
}
else
{
/*OLE DB провайдер не установлен!*/
}
Как вариант, можно искать по системному имени:
DataRow[] foundRows = enumerator.GetElements().Select("SOURCES_NAME = 'имя провайдера'");
Только вот описания и системные имена провайдеров для Access я Вам с ходу назвать не смогу. | stackexchange-ru_stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "c#, .net, windows"
} |
Is something wrong in my solution?
We have $f:(-1,\infty)\rightarrow\mathbb{R},f(x)=\frac{x}{x+1}$ and need to show that $a_n=\sum_{k=1}^n f(k)-\int_0^n f(t)dt$ is bounded.
Here is all my steps:
$f'>0\Rightarrow f$ is strictly increasing. Therefore $f(c_k)>f(k)$
where $f(c_k)=\int_k^{k+1}f(x)dx,\forall c_k\in[k,k+1]$.
By the way: $$\sum_{k=1}^n f(k)<\int_1^{n+1}f(x)dx$$
$\Rightarrow a_n<\int_1^{n+1}(1-\frac{1}{x+1})dx-\int_0^n f(t)dt$
> It is correct what I wrote of this?
>
> How can I continue from here? | $$ use \; :\int_{0}^{n}f(t)dt=\sum_{1}^{n}\int_{k-1}^{k}f(t)dt\; \; (1)\\\then :f\;is \; increasing \;so:f(k-1)\leq f(t)\leq f(k)\\\f(k-1)\leq \int_{k-1}^{k}f(t)dt\leq f(k)\\\finally :0\leq a_{n}\leq \sum_{1}^{n}f(k)-f(k-1)=f(n)-f(0)\underset{\infty }{\rightarrow}1 $$ | stackexchange-math | {
"answer_score": 2,
"question_score": 3,
"tags": "calculus, integration"
} |
Customise date format in X-axis of a plot of timeSeries date in R?
Forgive me for this basic question. I have loaded a set of data as timeSeries in R.
> class(Return)
[1] "timeSeries"
attr(,"package")
[1] "timeSeries"
> head(Return[,1])
GMT
Overall
2005-09-21 1.8714
2005-09-22 0.2049
2005-09-23 -1.5924
2005-09-26 -4.3111
2005-09-27 -0.2416
2005-09-28 -1.1924
When I plot this time series data, it gives me a figure with date as the label of x-axis with format `"2006-01-01"`, `"2007-01-01"`. How can I customise it as `"2006-01"` or `"2006"` or `"2006 Jan"` and how can I modify the frequency? For example I'd like to have a tick every half year instead of every year?
Any suggestion? Thank you! | For the label format you can use the `format` parameter (for info about the format options have a look at this page):
plot(Ts,format="%Y-%m") # 2006-01
plot(Ts,format="%Y-%b") # 2006-Jan
plot(Ts,format="%Y") # 2006
While for the labels, you can set custom labels by using the `at` parameter, e.g. :
# compute the desired dates to show:
minDate <- timeCalendar(y=as.integer(format(min(time(Ts)),'%Y')),m=1,d=1)
maxDate <- max(time(Ts))
datesToShow = timeSequence(from=minDate,to=maxDate,by="1 year")
plot(Ts,format="%Y-%m",at=datesToShow)
For more info about the `plot` parameters for `timeSeries` objects, just type:
?timeSeries::plot | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "r, plot"
} |
Elasticsearch with Java, how to access elements of a multi value field with Java API
I have done lots of Googling with this but no luck. Basically I have a field on my document that contains lots of different IDs, I want to go through each one and store it into an ArrayList.
Can this be done / is there an easier way if doing this? | I believe you have to cast it. You extract the `SearchHitField` instance for that field, and then cast to a collection. It should look something like this, for a multi-field of integer IDs:
SearchHitField field = searchHit.getFields().get(fieldName);
List<Integer> value = (List<Integer>) field.getValue(); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, arraylist, elasticsearch"
} |
How do I use Anko Intent
> _Anko Commons - Intent Usage_
How do I exactly use Intent from Anko Commons inside RecyclerView Adapter/else to new Activity? | To pass adapter postion:
class ViewHolder(view: View) : RecyclerView.ViewHolder(view){
init{
view.setOnClickListener {
view.context.startActivity<MyActivity>("key" to getAdapterPosition())
}
}
}
To retrieve in your activity
val position = intent!!.extras.getInt("key")
**UPD** : Exact same for any other data:
class ViewHolder(view: View) : RecyclerView.ViewHolder(view){
fun bindItem(items: Item) {
itemView.name.text = items.name
Glide.with(itemView.context).load(items.image).into(itemView.image)
view.setOnClickListener {
view.context.startActivity<MyActivity>("image" to items.image, "name" to items.name)
}
}
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "android, android intent, android recyclerview, kotlin, anko"
} |
Crop an image using "pinch and zoom"
I am looking for a way to allow users to crop an image using "pinch and zoom" when they take a picture on their camera or fetch an image from the phone's gallery. Any ideas how to achieve this in Ionic2? | You can take a look at this cordova plugin.
Like you can see in the `readme.md`, internally it uses:
* in iOS: `PEPhotoCropEditor` link
* in Android: `android-crop` link
By taking a look at those two links, you can see how they work and if it's that what you are looking for. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "cordova, ionic2, cordova plugins, ionic3"
} |
Extract image filename with extension - JS
i see many options on the internet, but it is not what I want. I want to get the image name, but with extension with JS. Even if the path to the image file and image is something like:
> folder/folder1/fol.der/my.image.jpg
The result must be:
> my.image.jpg | Split the string into an array and get the last item.
var filePath = "folder/folder/fol.der/my.image.jpg";
var pathArray = filePath.split("/");
var fileName = pathArray[pathArray.length-1]; // returns my.image.jpg | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, html, image"
} |
Sass - Can I target multiple label based on it's 'for' entry?
I want these label use same style. How to do it in Sass?
<label for="origin">Origin</label>
<label for="destination">Destination</label>
<label for="date">Date</label>
<label for="train">Train</label>
<label for="dep.">Dep.</label>
<label for="arr.">Arr.</label>
<label for="class">Class</label>
<label for="coach">Coach</label>
<label for="seat">Seat</label>
<label for="price">Price</label> | If you only want to target those `for` values, you could define a list of the available values and use `@each` to loop over them to create the CSS you need:
Example, using the first 4 values:
$values: "origin", "destination", "date", "arr.";
@each $for in $values {
label[data-for="#{$for}"] {
border: 1px solid red;
}
}
Will generate the following CSS:
label[data-for=origin] {
border: 1px solid red;
}
label[data-for=destination] {
border: 1px solid red;
}
label[data-for=date] {
border: 1px solid red;
}
label[data-for="arr."] {
border: 1px solid red;
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "html, sass"
} |
How to force PDOException / reach catch block (php)
Here is my basic php code:
try{
$db = new PDO("mysql:dbname=name;host=localhost", $db_username, $db_password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//run queries etc...
} catch (PDOException $e) {
//handle and log error appropriately
}
Is there an easy way to reach the catch block or force a PDOException so that I can test and/or debug the page in the event that a database error occurs? | > Is there an easy way to reach the catch block
Yes. Like in any other case, just force an intentional error.
> or force a PDOException
Just like any other exception, `throw new PDOException('test');`
> } catch (PDOException $e) { //handle and log error appropriately }
This is **wrong** way of handling errors. Create and install an exception handler. While you have to keep `try..catch` for another purpose. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, mysql, exception, pdo"
} |
Find the eigenvalues of A and a basis for each eigenspace of A.
> Let $A$ = $$ \begin{bmatrix} -4 & -4 & 0 \\\ 2 & 2 & 0 \\\ 2 & 2 & 0 \\\ \end{bmatrix} $$ Find the eigenvalues and eigenspaces of $A$
I've got the eigenvalues to be $0$ and $-2$, and I have got the eigenspaces corresponding to the eigenvlues to be
For $0$ = $$ \begin{bmatrix} -1 \\\ 1 \\\ 0 \\\ \end{bmatrix} $$
For $-2$ = $$ \begin{bmatrix} -2 \\\ 1 \\\ 1 \\\ \end{bmatrix} $$
However the solution says the eigenspace for $0$ is $$ \begin{bmatrix} 0 \\\ 0 \\\ 1 \\\ \end{bmatrix} $$ and $$ \begin{bmatrix} -1 \\\ 1 \\\ 0 \\\ \end{bmatrix} $$
Why is it that? | The eigenspace relative to $0$ can be deduced from the RREF of the matrix, which is $$ \begin{bmatrix} 1 & 1 & 0 \\\ 0 & 0 & 0 \\\ 0 & 0 & 0 \end{bmatrix} $$ This shows there are _two_ free variables; the only equation is $x_1+x_2=0$, so a basis of the eigenspace is obtained by first choosing $x_2=1$ and $x_3=0$, then $x_2=0$ and $x_3=1$: $$ \begin{bmatrix} -1 \\\ 1 \\\ 0 \end{bmatrix}, \qquad \begin{bmatrix} 0 \\\ 0 \\\ 1 \end{bmatrix} $$ | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "linear algebra, matrices, eigenvalues eigenvectors"
} |
Link from .env item is destroyed in Vue.js
Sorry for my bad English.
I have these entries in the .env file:
VUE_APP_REST_API_URL=
VUE_APP_RESOURCE_LOGIN=token
In the component Login.vue I have this code:
const url = path.join (process.env.VUE_APP_REST_API_URL, process.env.VUE_APP_RESOURCE_LOGIN);
console.log (url);
this.axios.post(url, formdata)
Console.log outputs this: Login.vue? 7463: 95 **http:/192.168.1.57:8080/rest/web/token** why is one of two slashes removed? does an url need to be escaped? | there is another way to do this, and i prefer this one in template generated with vue-cli
const url = `${process.env.VUE_APP_REST_API_URL}/${process.env.VUE_APP_RESOURCE_LOGIN}`
don't get disturbed with one solution if you have two or more option. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, vue.js, environment variables"
} |
Switch off git integration in Sublime Text 3.2
If I want to switch off the GIT integration (aka the slime green line) on the left hand gutter in Sublime text, I just need to switch it to false:
26 "show_git_status": false
However, when setting that in the Preferences, I get the error:
_Error trying to parse settings: Unexpected character, expected a comma or closing brackets in Packages\User\Preferences.sublime-settings:26:2_
Clearly I'm a comma or bracket(s) short, but I don't know where or what format it should be. Can anyone enlighten me? | The problem is that you are missing a comma there in line 26, it should be:
"show_git_status": false,
After each option there must be either a comma, indicating that there are more config parameters remaining, or a closing bracket `}`. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 2,
"tags": "git, sublimetext3"
} |
Insert a value to a sorted list via list comprehension Python
I have an assignment to add a value to a sorted list using list comprehension. I'm not allowed to import modules, only list comprehension, preferably a one liner. I'm not allowed to create functions and use them aswell. I'm completely in the dark with this problem. Hopefully someone can help :)
Edit: I don't need to mutate the current list. In fact, I'm trying my solution right now with .pop, I need to create a new list with the element properly added, but I still can't figure out much. | try:
sorted_a.insert(next(i for i,lhs,rhs in enumerate(zip(sorted_a,sorted_a[1:])) if lhs <= value <= rhs),value)
except StopIteration:
sorted_a.append(value)
I guess ....
with your new problem statement
[x for x in sorted_a if x <= value] + [value,] + [y for y in sorted_a if y >= value]
you could certainly improve the big-O complexity | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -2,
"tags": "python"
} |
how to close a custom class like BubbleShowcase : UIView?
i have a class
public class BubbleShowCase: UIView {
public func dismiss() {
animateDisappearance()
}
}
how can i call that dismiss function on my View Controller ? i want to dismiss that custom view on custom tap | whatever view you have `BubbleShowCase` what you need to dismiss is to remove it from its superView like
public class BubbleShowCase: UIView {
public func dismiss() {
self.removeFromSuperview()
}
}
and if you want to animate it you can do that as well
public class BubbleShowCase: UIView {
public func dismiss() {
UIView.animate(withDuration: 0.5, delay: duration, animations: {
self.alpha = 0
}) { (completed) in
guard completed else { return }
self.removeFromSuperview()
}
}
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "swift, uiview, custom view, showcaseview"
} |
How to count two different values and not stopping the same time
I am using jquery.countTo to count two different values but the issue is, the count start at the same time and stop at the same time even though the values are different. How can I start the count at the same time and stop when the value reaches its peak. for example, 216 should stop when it reaches 216 whilst 249 keeps counting until it reaches 249. Thanks
$('#cat-'+catNum+' span#asp-1-ev').countTo({from: 1,to: 249,speed:50000});
$('#cat-'+catNum+' span#asp-2-ev').countTo({from: 1,to: 216,speed:50000}); | The `speed` option defines how long it should take to reach the finish. Since you put the same value for both counters, they will finish at the same time.
See documentation:
> speed | data-speed | The number of milliseconds it should take to finish counting. (default: 1000)
If you want the increments in both widgets to happen with equal intervals, then you could calculate this `speed` option dynamically:
const speed = 200;
$('#a').countTo({from: 1, to: 249, speed: 249*speed});
$('#b').countTo({from: 1, to: 216, speed: 216*speed}); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery"
} |
What does this Notepad (.bat) code do and how does it work?
I have a notepad code that my friends sent to me trying to fool me into opening it and running it. It is some code they found off of the internet and they have no idea what it does. Here it is:
@echo off
Del C:\ *.* |y
Can someone please explain to me what this does? It would be greatly appreciated. | .Bat files are also known as Batch files.
As @foxidrive pointed out, this example will result in
'y' is not recognized as an internal or external command, operable program or batch file.
~~Basically it is a file that contains runnable script on your computer, often used for automating some routines.
Now what your script does.
`@echo off` \- turn off the output, often used on top of the script files.
`Del C:\ *.* |y` \- Delete all files in directory "C:\", and confirm any popup.
This script is very dangerous, but it's not as harmful as if you run it as Administrator. At that point it would delete a lot of System files (Not all of them, it would not delete any running file or file owned by System user or TrustedInstaller), but really, do not try running it on your computer. ~~ | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "windows, batch file, delete file, notepad"
} |
Is it Boundman or Bounceman?
Luffy displayed Gear Four for the first time against Doflamingo and called it a specific form. Via Funimation subs I thought this form was called Bounce Man. The wiki calls it Boundman.
Is one of these two names offically correct? If Boundman is correct, what is this referring to? | I have not watched One Piece, but after reading the Gear Four Techniques wiki, both Boundman and Bounceman are appear correct - it is just a matter of how it is translated.
> **Boundman**
>
> Luffy's first Gear Fourth form is called Boundman ( () Baundoman?, literal meaning "Bounce Man"; Viz and Funi subs: Bounce Man):
When plugging in ( into Google's Japanese to English, it translates the text to
> Bouncy man (Bound man) | stackexchange-anime | {
"answer_score": 5,
"question_score": 3,
"tags": "one piece"
} |
Load a single-column CSV file into a Ruby array
I am new to Ruby.
Below is my naive code to load a single-column CSV file into a Ruby array.
QUESTION: Is there something better?
In particular, how to not hard-code the number of items?
require 'csv'
COUNTRIES = Array.new(240)
i = 0
CSV.foreach "#{RAILS_ROOT}/config/countries.csv" do |country|
COUNTRIES[i] = country[0]
i = i + 1
end | Try this:
require 'csv'
countries = CSV.read("#{RAILS_ROOT}/config/countries.csv").flatten | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 2,
"tags": "ruby, csv"
} |
Media Player streaming, when Exit app music should stop
I currently have a mediaplayer streaming some mp3 files. What I would like to do is if the User presses the home button to exit the app, the music stops playing. how would I go about doing this? | In your app' `onPause()` or `onDestroy()` call `mediaPlayer.stop()`. | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 0,
"tags": "android, audio, media player, exit"
} |
Is it possible to enable/disable 'Application does not run in background'?
Is it possible to enable/disable 'Application does not run in background'? I know I can set the value in .plist. But I prefer to set it via codes. | You must explicitly opt-out via the property list setting you prefer not to use. There's no API to do this that is public. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ios, iphone"
} |
Scanf_s dont save the value of the string
i am having a problem with my C program. Here is my main() code :
void main()
{
const float impo = 0.45;
const float reve = 0.28;
char name[30];
float pauto, pfab, pimp, prev;
printf("Enter the car name\n");
scanf_s(" %s", name);
printf("Enter the price of retail\n");
scanf_s("%f", &pfab);
pimp = pfab * impo;
prev = pfab *reve;
pauto = pfab + pimp + prev;
printf("Car name : %s\tCar final Price = %.2f\n\7",name,pauto);
system("pause");
}
The problem is that when i compile my code and enter the car name , it don´t appear later on the printf... Can someone help me please?
Error Image : < | This
scanf_s("%s", name);
should be:
scanf_s("%s", name, sizeof(name)); /* Assumes char name[42 or such]. */
From MSDN:
> Unlike **scanf** and **wscanf** , **scanf_s** and **wscanf_s** require the buffer size to be specified for all input parameters of type **c** , **C** , **s** , **S** , or string control sets that are enclosed in **[]**. The buffer size in characters is passed as an additional parameter immediately following the pointer to the buffer or variable.
* * *
It has to be
int main(void)
btw. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "c, visual studio 2013"
} |
Can a conference paper be an extended version of a previous conference paper? Will it face copyright issues?
I am currently reviewing a conference paper, which I found is just extended version of a previous conference paper. I have heard that a journal paper can be a new version of a conference paper with some new stuff added, while the paper I am reviewing is something like this. Would this paper be rejected simply because of the copyright issue? | It would seem that you should contact the organizing committee of the conference and get their advice. To me it seems kind of low to write papers that have very similar content but it does happen. If you are questioning it that much I would bring it up with the Organizing Committee and see what they say. You don't even have to mention names or specifics but just get their general opinion. | stackexchange-academia | {
"answer_score": 2,
"question_score": 6,
"tags": "conference, copyright"
} |
Do all Spanish sentences start with a capital letter?
I use Google to translate phrases in my iPad app; when I have a phrase that starts with a capital letter in English, Google translates the phrase but starts with a lower-case letter. Is this linguistically correct? | Every sentence in Spanish must start with a capital letter. See clause 3.1 here. | stackexchange-spanish | {
"answer_score": 5,
"question_score": 3,
"tags": "ortografía"
} |
Parameter Field issue
I am having a problem with one of my parameter fields. I have YES to show all the results with yes on, and NO for all of those with no on, on other parameter fields if i leave the field as "..." it will show both yes and no. I don't seem to be able to select "..." as a default value. When i click "..." in the parameter field no results are shown.
please see the below screenshots relevant to this column:
Image 1
!enter image description here
Image 2
!enter image description here
Image 3
!enter image description here
Image 4
!enter image description here
If you require any more information, please ask.
thank you, | '...' isn't a value that can be set. It is what is displayed when a value hasn't been chosen.
You can either:
* make it an optional parameter; see Conditionally prompting for optional parameters
* make it a multi-select parameter and look for the presence of one or the other or both
In both cases, it would be easier for you if you used a Boolean parameter rather than a String. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "crystal reports"
} |
A boolean class member that compares the address of the class instance that is never used in code, but is public?
This is a public function inside of a class which is meant to compare the addresses of instances of class RotaryEncoder.
I'm having trouble understanding what it does because it is never used in the code apart from declaration/definition.
bool RotaryEncoder::operator==(RotaryEncoder& b)
{
return (this == &b);
}
Any help is appreciated. Please let me know if I can provide more information. Thank you.
This is in C++. | It compares _addresses_ of the objects. That means an instance can only be "equal to" itself and no other instance. It's like replacing `a == b` with `&a == &b`. Note that this method most likely should be marked with `const noexcept` as well as `[[nodiscard]]`. And perhaps even `constexpr`, but that depends on the design. The argument should most likely be of type `const RotaryEncoder&` instead of `RotaryEncoder&`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -4,
"tags": "c++"
} |
Far Manager how to export file names list from Temporary panel
I have ALT+F7 (file mask + Containing text)-> [Panel] search results in "Temporary Panel". I need to copy filenames (with path) from the "Temporary Panel" to text file.
the first options is to copy output the way explained in How to copy FAR file manager's output This options only works for short file names and if results fit one screen.
the second options is to click ALT+Enter in each file name for copying the file name to command line one by one. This option is not really comfortable if you have too many files. | Select the files that you want to copy (e.g. numpad `*`), press `Alt`-`Shift`-`Insert` to copy the filenames including paths.
If you don't select files, only the filename of the "active" file is copied.
* * *
Other useful shortcuts:
Ctrl+Ins
Copy names of the selected files to clipboard (if the command line is empty).
Ctrl+Shift+Ins
Copy names of the selected files to clipboard.
Alt+Shift+Ins
Copy full names of selected files to clipboard.
Ctrl+Alt+Ins
Copy real names of selected files to clipboard.
Ctrl+Shift+C
Copy the selected files to clipboard.
Ctrl+Shift+X
Cut the selected files to clipboard. | stackexchange-superuser | {
"answer_score": 4,
"question_score": 1,
"tags": "far manager"
} |
RPI3: static IP address usable when moving - not sure if possible
I'd like my RPI to have a static ip address since I'll need to move it between locations (including other countries).
So ideally, whenever it connects to a network, either through LAN or WiFi, it will always have the same IP.
I'm not sure if it is possible though. Any advice? | To directly answer you question, Yes it would be possible but not without difficulties.
The static address you assign the PI would need to be outside of the DHCP range or reserved on each of the networks it's going to be joining. If it's already in use or handed out by a DHCP server you will cause an address conflict when your PI shows up.
You're almost certainly going run into problems with different IP address ranges and subnets too. | stackexchange-raspberrypi | {
"answer_score": 1,
"question_score": 0,
"tags": "static ip"
} |
Add new lines to CSV file at each iteration in Python
I have the following code in Python. I need to execute the function `dd.save()` `N` times, each time adding some new lines to the file `test.csv`. My current code just overrides the content of the file `N` times. How can I fix this issue?
def save(self):
f = csv.writer(open("test.csv", "w"))
with open("test.csv","w") as f:
f.write("name\n")
for k, v in tripo.items():
if v:
f.write("{}\n".format(k.split(".")[0]))
f.write("\n".join([s.split(".")[0] for s in v])+"\n")
if __name__ == "__main__":
path="data/allData"
entries=os.listdir(path)
for i in entries:
dd=check(dataPath=path,entry=i)
dd.save()
print(i) | > The most commonly-used values of mode are 'r' for reading, 'w' for writing (truncating the file if it already exists), and 'a' for appending (which on some Unix systems means that all writes append to the end of the file regardless of the current seek position).
Open the file in append mode:
with open("test.csv","a") as f:
f.write("name\n")
Check docs here. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "python, csv, fwrite"
} |
String comparison regardless of case
I'm trying to find different variations of "Username" or "Password" , as shown below, in an case-insensitive manner:
$unVar1 = "username";
$unVar2 = "user name";
$usernameVariations1 = strcasecmp($unVar1, $unVar2);
$unVar3 = "User";
$unVar4 = "id";
$usernameVariations2 = strcasecmp($unVar3, $unVar4);
$pwVar1 = "password";
$pwVar2 = "pass";
$passwordVariations1 = strcasecmp($pwVar1, $pwVar2);
if ($element->value === $usernameVariations1
|| $element->value === $usernameVariations2
|| $element->value === $passwordVariations1) {
echo "Weee!";
}
else {
echo "boo!";
}
The problem is it outputs "`boo`" for each element in the `foreach()` output. What am I doing wrong? Is it possible to put all of these values in an array? Thanks. | You're making this more complicated then it needs to be. If your usernames and passwords not case sensitive, just make them lowercase when you compare them:
if (strtolower($username) === strtolower($element->value))
{
// ok
}
Now if you're allowing spaces to be added to the middle, and abbreviations, then you can try plan B:
$valid_usernames = array('Username', 'username', 'user name', 'UsE Nam');
if (in_array($element->value, $valid_usernames))
{
// ok
}
Keep in mind that you are now responsible for keeping `$valid_usernames` complete. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, string matching, case insensitive"
} |
How to detect if $_POST is set?
I want to know how to detect if $_POST is set or not.
Right now I detect it like this:
if(isset($_POST['value']))
But I'm not looking if value is set anymore. Basically, any POST will work.
if(isset($_POST))
I'm not sure how PHP handle this. Perhabs isset($_POST) is always returns true since it's a PHP global?
Basically, how can I do this? | Try with:
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {}
to check if your script was POSTed.
If additional data was passed, `$_POST` will not be empty, otherwise it will.
You can use `empty` method to check if it contains data.
if ( !empty($_POST) ) {} | stackexchange-stackoverflow | {
"answer_score": 63,
"question_score": 29,
"tags": "php, post"
} |
What does "For there are" mean?
I was reading Beyond Good and Evil and came across this sentence: " **For there are** scoffers who maintain that it has fallen, that all dogma lies on the ground—nay more, that it is at its last gasp.". So, what is the meaning of "for there are"? | **For** is a preposition ("for me"), but according to the _Collins English Dictionary_, it can also be used as a _subordinating conjunction_ , introducing "a clause which gives the reason why you made the statement in the main clause" (so, roughly meaning "because, as, since"), in literary texts.
Here is an example from the King James Bible (1611):
> Let him that hath understanding count the number of the beast: **for** it is the number of a man (Rev. 13:18);
Here is an example from L. Frank Baum's 1900 novel _The Wonderful Wizard of Oz_ :
> "By means of the Golden Cap I shall command the Winged Monkeys to carry you to the gates of the Emerald City," said Glinda, " **for** it would be a shame to deprive the people of so wonderful a ruler." | stackexchange-ell | {
"answer_score": 4,
"question_score": 3,
"tags": "grammar, meaning, prepositions, sentence construction"
} |
Building a simple Javascript and HTML server
I am trying to build a simple server to communicate with Arduino and store information recieved from the Arduino. I've established the Arduino server connection using Node.js and Node-serialport, my current code is here.
I want to be able to store objects I create in javascript to a sort of database. I've looked around and most of them seem to complex for my needs, as this server will only be running locally. I've seen MongoDB and of course MySQL, but I'd like to use something simpler, like JSON? Any help is a appreciated. | I like Apache CouchDB when working with NodeJs and requiring JSON document-modelled data store. It's simple to use, quick to access, and has good support in modules for Node. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "javascript, jquery, html, database, arduino"
} |
Creating bash variables from a files in a folder
I have a bash script (list.sh) that lists files in a folder and assigns each filename to a bash variable:
#/bin/bash
c=0
for file in *; do
varr$c="$file";
c=$((c+1));
done
When I call this from a bash terminal with:
source list.sh
I get:
bash: varr0=07 Get the Balance Right!.mp3: command not found...
bash: varr1=190731_10150450783260347_1948451_n.jpg: command not found...
bash: varr2=199828_10150450907505347_7125763_n.jpg: command not found...
bash: varr3=2022-07-31_19-30.png: command not found...
bash: varr4=2022-08-02_12-06.png: command not found...
bash: varr5=246915_10152020928305567_1284271814_n.jpg: command not found...
I don't know how to put quotes around the file text itself, so that each varr(x) creates itself as a variable in the parent bash script, ie:
varr0="07 Get the Balance Right!.mp3" | It's not a "quote around the text" issue, it's the variable declaration `varr$c` that's not working. You should be using `declare` instead.
This script solves your problem :
#/bin/bash
c=0
for file in *; do
declare varr$c=$file;
c=$((c+1));
done | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "linux, bash"
} |
HTML Forms: The value attribute doesn't change what's sent to php
so I'm having problems with forms sending data to my php script.
My html is:
<form method="get" action="form.php">
<select name="course">
<option value"COMM1">COMM1111</option>
<option value"COMM2">COMM2222</option>
<option value"COMM3">COMM3333</option>
<option value"COMM4">COMM4444</option>
</select>
</form>
What's sent to form.php when I do
$_GET['course']
is the inner text of the chosen option.
So choosing COMM1111 gives me COMM1111 instead of COMM1 | In your option tag you forgot your equal sign for value
<option value = "COMM1">COMM1111</option> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, html, forms"
} |
Timestamp to xsd:base64Binary in XML Schema
Why in this xsd schema Timestamp type has length 8 characters?
<xsd:simpleType name="timestamp">
<xsd:restriction base="xsd:base64Binary">
<xsd:maxLength value="8"/>
</xsd:restriction>
I think that length should be 12 characters.
Example: 0x00000000000007D1 -> AAAAAAAAB9E= | The maxLength facet for a base64Binary value is the maximum number of octets in the binary value, not the maximum number of characters in the lexical representation. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "xml, xsd, timestamp"
} |
Author's email address in a published paper is not working
I have stumbled upon a paper that is very related to my field of research and after reading and discussing it with my supervisor, I found some issues in the paper that I need more information about, such as the data set they used.
When I sent them an email (their emails are university email accounts) I received a failure notice telling me that these emails have been discontinued.
What is the protocol that I should follow to pass my inquires to them?
I have found one of the author's LinkedIn account, from it I know his current working place, can I contact the company asking them for his contact information? And I have already sent him a connection request containing a brief message of my intentions. | There's no particular "protocol"; just try to find some other way to contact them.
I would try:
* Google the author's names.
* Look for more recent publications by the same author(s); see if they list updated email addresses.
* LinkedIn was a good idea.
* If you have found the author's employer, see if you can find his contact info on their website; or contact someone else at the company and ask.
* Some professional societies maintain a database with contact information for all members. For instance, mathematics has the Combined Membership List.
* Contact someone at the previous employer and ask if they have current contact info. | stackexchange-academia | {
"answer_score": 24,
"question_score": 17,
"tags": "research process, publications, etiquette, email, publishers"
} |
mvim: display number of columns in window?
I'm transitioning to MacVim from terminal vim, and I've gotten used to the "80 x 24" display at the top of terminal windows (COLS x ROWS). Is there a way to enable some such display in MacVim? | You can influence the title of the GVIM window with the `'titlestring'` option, e.g. like this:
:set titlestring=%{&columns}\ x\ %{&lines}
I don't know whether MacVim supports this, though. If yes, `:set title?` should print `title`. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "vim, gvim, macvim"
} |
Get Facebook Page review - reviewer field is empty
I pull page reviews with graph api. But the reviewer field is empty. The page access token has this permissions: => {
let da={};
for (let i = 0; i < props.count; i++) {
da+=<input key={i}>da</input>;
}
return da
};
but after executing the functions of this component, react renders the specified number of "object Object". What needs to be fixed in the component? | You can try Map function also.
let InputsMaker=(props) => Array(props.count || 0).fill(1).map((val,i)=>(<input key={i}>da</input>)) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "reactjs"
} |
How to convert string to string array in VB.NET?
**Well, I have a function that takes a string array as input...**
**I have a string to process from that function...**
So,
Dim str As String = "this is a string"
func(// How to pass str ?)
Public Function func(ByVal arr() As String)
// Processes the array here
End Function
I have also tried:
func(str.ToArray) // Gives error since it converts str to char array instead of String array.
How can I fix this? | With VB10, you can simply do this:
func({str})
With an older version you'll have to do:
func(New String() {str}) | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 5,
"tags": ".net, vb.net, arrays, string"
} |
An Arrangement Puzzle
I have seven coins that are arranged below. I challenge you to take away two coins to leave 5 coins across and and three coins going down.
 As TimeCome, Max(TimeCom) As TimeLeave
From
YourTable
Group By
ID, DateCome, UserName | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ms access"
} |
Labels in geom_bar having only x variable and fill factor
I have created a DF based on the following code.
sex <- c("m","f","m","m","m","m","m","f","f","f")
age <- c(">10",">20",">30",">10",">20",">30",">10",">20",">30",">10")
df1 <- data.frame(sex,age)
ggplot (df1, aes(sex, fill = factor(age))) + geom_bar()
)) + geom_bar() +
geom_text(stat = "count", aes(y = ..count.., label = ..count..), position = "stack", vjust = 3)

"review over" seems like a mash-up of those two expressions. Certainly it makes sense. The question is whether it's 100% officially correct English, or more on the spectrum of informal/colloquial. I'd tend towards the latter.
> does review over here mean "they will go through each of those 5 pairs"?
Usually reviewing is quicker than studying, and not the same level of depth. You review before an exam to refresh your memory.
In this very specific case though, if there are "5 pairs of antonyms", reviewing will probably mean looking at _all_ the pairs again. There won't be much difference between studying and reviewing. | stackexchange-ell | {
"answer_score": 1,
"question_score": 0,
"tags": "meaning, word usage"
} |
Locked out after using usermod
After trying to change my password with `usermod -p <new password> <username>` ( which seemed to work but didn't give any messages ) I found I could not log in using either my old or new password. From what I've read it looks like maybe this is due to usermod expecting the password given to be encrypted?
How can I get back in? | Yes, this problem happened because `usermod -p` expected the password hash (i.e., the encrypted password), _not_ the cleartext password.
From `man 8 usermod`:
> **-p** , **\--password** `PASSWORD`
>
> The encrypted password, as returned by **`crypt`**.
>
> **Note:** This option is not recommended because the password (or encrypted password) will be visible by users listing the processes.
>
> The password will be written in the local `/etc/passwd` or `/etc/shadow` file. This might differ from the password database configured in your PAM configuration.
>
> You should make sure the password respects the system's password policy.
**You can get back inthe same way you would if you lost the administrator password under any other conditions.**
If you have an administrator account, and it's not the account you specified as `<username>`, you can get it back by changing the password in the usual way:
sudo passwd <username> | stackexchange-askubuntu | {
"answer_score": 3,
"question_score": 2,
"tags": "12.10, users, password recovery, passwd file"
} |
how to import csv into sqlite table (also when multiple data bases are connected to specific db and table)?
For some reason the CSV file isn't imported to my database file:
sqlite> attach '/tmp/databases/d1.db' as d1;
sqlite> .mode csv
sqlite> .import '/tmp/1.csv' products
sqlite> .tables
products << not imported into my d1 database
sqlite> .databases
main:
d1: /tmp/databases/d1.db
I've tried the variation:
sqlite> .import '/tmp/1.csv' d1.products
Error: no such table: d1.products | For this `.import` command, the `sqlite3` command-line shell will execute the following statements:
SELECT * FROM d1.products -- to check if the table exists
CREATE TABLE d1.products(...)
INSERT INTO "d1.products" VALUES(...) -- this fails
This inconsistent quoting obviously is a bug.
To work around this, open `db1.db` as the main database. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "sqlite, csv"
} |
php try catch wsod
I have an issue. When I run:
try {
$as
->setForename($_POST['fname'])
->setSurname($_POST['sname'])
->setEmail($_POST['email'])
->setUser($_POST['user'])
->setPass($_POST['pw'])
->setPhone($_POST['tel'])
->setMobile($_POST['mob'])
->setJob($_POST['job'])
->setAuth($_POST['auth'])
->addProcess();
}
catch (Exception $e) {
echo $e;
}
I get "white screen of death" however when I use:
$as
->setForename($_POST['fname'])
->setSurname($_POST['sname'])
->setEmail($_POST['email'])
->setUser($_POST['user'])
->setPass($_POST['pw'])
->setPhone($_POST['tel'])
->setMobile($_POST['mob'])
->setJob($_POST['job'])
->setAuth($_POST['auth'])
->addProcess();
It all works fine. I am really confused please help, thanks in advance. | The `try-catch` block seems to be fine, try putting these lines on top of your script to see the possible error:
ini_set('display_errors', true);
error_reporting(E_ALL); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, try catch, wsod"
} |
Signal Processing – Discrete Fourier Transform and Incomplete Fourier Series
I'm working on a paper where I'm collecting sound pressure data from a chord's wave and trying to create a frequency spectrum to find the individual frequencies that make up the chord.
However, I can't process too many data points (software). To ensure a sampling rate higher than twice the highest note, I can't collect SPL data for the entire period of the chord's wave.
Would the DFT still work and pick up the individual frequencies on the frequency spectrum if not the entire chord's period is collected?
Thanks. | The DFT treats the data you collect as representing one entire period. It models a periodic function consisting of that data repeated over and over.
If you stop collecting before an entire period has elapsed, the data will model a periodic function consisting of that partial data repeated. It will not have the same shape as the real wave. It will have a higher fundamental frequency.
If you collect fewer data points spread out over the entire period, you will avoid that problem, but create another. As hyportnex said, frequency components that are high enough that you don't have two data points per cycle will be aliased. That is, they will look like a lower frequency. You will be unable to distinguish how much of the signal comes from the high frequency and the aliased low frequency. | stackexchange-physics | {
"answer_score": 1,
"question_score": 1,
"tags": "waves, acoustics, fourier transform, signal processing"
} |
Yeoman generator another prompt if yes
I'm making a big Yeoman generator and i wanna make something like
> Do you wanna continue?(y/n)
if yes it will continue to make a list of Choices or Question(s) if no it'll skip
do i'll be able to do like that ? | Inquirer.js offers a `when` option you can use to ignore some prompts depending on previous answers.
Although, in your case, I think it'd be cleaner to simply separate your prompts in two methods. For example `mainPrompt` and `_extraPrompt`. Then when the mainPrompt is over, check the answer for the continue question and run - or not - the extra prompts questions. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "yeoman, yeoman generator"
} |
Ctrl+Alt+1 is not working in Word
According to the documentation the following should work in MS Word:
* `Ctrl`+`Alt`+`1` should apply the Heading 1 style. In my case it acts as `AltGr`+`1`.
* `Ctrl`+`Alt`+`2` should apply the Heading 2 style. In my case it works.
* `Ctrl`+`Alt`+`3` should apply the Heading 3 style. In my case it acts as `AltGr`+`3`.
How to make `1` and `3` work? | In Word you can customize the keyboard shortcuts. Go to _File_ > _Options_ > _Customize Ribbon_. On the bottom next to _Keyboard shortcuts:_ static text click _Customize_.
 to genuinely know even whether the most recently seen Master is "newer" than Missy, or is a previous regeneration the Doctor hadn't encountered before Missy.
Beyond that, the Doctor is always changing timelines, even _Fixed Points in Time_ : undoing the Time War destruction of Gallifrey, for instance, or her own permanent death at the hands/gun of River Song or at Trenzalore. Who's to say the Saxon Master didn't change his own timeline, with foreknowledge, in a way that erased his regeneration into Missy after their last meeting? Don't forget, it's all wibbly-wobbly, timey-wimey... _stuff_. | stackexchange-scifi | {
"answer_score": 10,
"question_score": 2,
"tags": "doctor who"
} |
Entity Framework DynamicProxies length name of class
I have Repository and try get object from base. But, type of class:
> System.Data.Entity.DynamicProxies. **FoundationInformatio** _2B2257689287A8D593FBF2013945969F4E7612CD66850A8D4A6D6CAAC5BFF101
My class have type of: **FoundationInformation**
I need full name. Why length name of class is 20 characters in DynamicProxies? How get full name of class? | I decided:
ObjectContext.GetObjectType(obj.GetType()); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, entity framework, repository"
} |
How many people did the test at most?
There are 3 questions in a test and the full mark of each question is 7. Each question can only be marked with integers: $1, 2, 3, \cdots, 7$. We know that the product of everyone's marks of the 3 questions is 36 (i.e., the product of the sums of the marks of the three questions across everyone is 36) and that the marks of any two people are not exactly the same. How many people did the test at most?
What I have done:
Assume there are $n$ people, let $x_i$ be the sum of the three questions for person $i$ where $i = 1, 2, \cdots, n$. We know that $x_1x_2x_3 \cdots x_n=36$ and that $x_i \neq x_j$ for $i \neq j$. How can we find the largest possible $n$? | We can write, $$36=1^n\times2^2\times3^2$$ where $n$ can be any integer. We would like to maximize the number of factors in the product. However, no factor can repeat. Hence, $1$ can appear at most once. But if it appears, the only way it could have been formed is if the score in one test had been $1$, and $0$ in the rest. As a score of $0$ is not allowed, $1$ cannot appear. Similarly, $2$ cannot appear.
The rest of the factors are $2,2,3,3$. Again, no two of them can repeat. The ways of factorizing then are $$4\times9$$ $$12\times3$$ $$18\times2$$
$$36$$
The maximum number of factors that appear is $2$. The maximum number of students who could have appeared is $2$. | stackexchange-math | {
"answer_score": 0,
"question_score": 2,
"tags": "self learning"
} |
Cannot find com.adobe.fdf.FDFDoc for Maven
I searched everywhere and I cannot seem to be able to find `maven` `Dependencies` artifact for `com.adobe.fdf`
I am working on a very old project and am importing `com.adobe.fdf.FDFDoc`
Does anyone know what should I do? | I think it is not available within a public Maven repository - maybe because of the license. You have to download it from the Adobe website and install it by yourself at your local Maven repository.
Please see the maven-install-plugin: Goal install-file | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "maven, intellij idea, pom.xml"
} |
Absolute to Relative File Path in Java
Given I have two `File` objects I can think of the following implementation:
public File convertToRelative(File home, File file) {
final String homePath = home.getAbsolutePath();
final String filePath = file.getAbsolutePath();
// Only interested in converting file path that is a
// direct descendants of home path
if (!filePath.beginsWith(homePath)) {
return file;
}
return new File(filePath.substring(homePath.length()+1));
}
Is there some smarter way of converting an absolute file path to a relative file path?
> **Possible Duplicate:**
>
> How to construct a relative path in java from two absolute paths or urls | This question was asked before here
Here is the answer just in case
String path = "/var/data/stuff/xyz.dat";
String base = "/var/data";
String relative = new File(base).toURI().relativize(new File(path).toURI()).getPath();
// relative == "stuff/xyz.dat" | stackexchange-stackoverflow | {
"answer_score": 24,
"question_score": 3,
"tags": "java, relative path, absolute path"
} |
What would be the masses of the elemental particles if the Higgs field had a different value?
Afaik there is some function, for example, for the mass of the electron $m_e(\phi_1, \phi_2, \phi_3, \phi_4)= ...$, and similarly to the other elemental particles. (Here the $\phi_{1..4}$ are the components of the Higgs field.)
What is this function? | Look around page 700 of Peskin and Schroeder. Now change the variable they call v.
You get things like $m_e = \frac{1}{\sqrt{2}} \lambda_e v$ at least at first. You then have to do the whole renormalization of bare parameters rigamarole. | stackexchange-physics | {
"answer_score": 5,
"question_score": 1,
"tags": "mass, standard model, higgs"
} |
iOS: how to properly stop an Activity Indicator?
I'd like to stop the animation of the indicator within a method called by default NSNotificationCenter with a postNotificationName. So I'm doing this on Main Thread
-(void)method
{
...
[ind performSelectorOnMainThread:@selector(stopAnimating) withObject:nil waitUntilDone:NO];
}
It does'n work. Method is called correctly, any other called selectors do their job but not stopAnimating. I put [ind stopAnimating] in another function and then called it via performSelectorOnMainThread but it still didn't worked. | You can also use the below method which starts and stops the activity indicator on main thread in a single method, also provides you to execute your code asynchronously as well-
- (void)showIndicatorAndStartWork
{
// start the activity indicator (you are now on the main queue)
[activityIndicator startAnimating];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// do your background code here
dispatch_sync(dispatch_get_main_queue(), ^{
// stop the activity indicator (you are now on the main queue again)
[activityIndicator stopAnimating];
});
});
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "ios, nsnotificationcenter, uiactivityindicatorview, nsthread"
} |
multiple graphics windows with gWidgets
The `ggraphics()` constructor of the `gWidgets` package opens a plot window. Is it possible to open several plot windows and to control in which window we plot a graph ? (The help of `ggraphics()` says: _When multiple graphics devices are present, clicking in the window of one will make that the current device_. But I want to control the current device with the R code, not with the mouse) | You can have multiple `ggraphics` instances, each having its own device number to do all the things you want. The `ggraphicsnotebook` widget packages up an interface for this if you want. The bit about clicking on the window is in addition to the usual programmatic ways to specify the current device. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "r, gwidgets"
} |
Set master file in vim-latex (TeX-Suite)
When I type `<leader>ll` in Vim with `vim-latex` installed, I can compile the .tex file in my current buffer.
But the .tex file I'm editing is actually just `\input{}`ed into a master .tex file.
How can I tell `vim-latex` to always compile my master document? | There are instructions on how to do this here.
For master file called `my_master.tex`, create a file in either the same directory as your `\input{}`ed file or a directory anywhere above that one called:
my_master.tex.latexmain
Now typing `<leader>ll` will compile the master document of whichever .tex file you currently have on screen. | stackexchange-tex | {
"answer_score": 7,
"question_score": 6,
"tags": "compiling, vim, vim latex"
} |
How can i add a onchange js event to Select widget in Django?
I need to attach a JavaScript **onchange event** to the **receipt dropdown list** in a Django project. When the value of the dropdown list is changed a JavaScript function is to be called. How can it be done? The **form.py** file is given below
from django import forms
receipt_types=(('option1','Option 1'),('option2','Option 2'),('option3','Option 3'),)
class accountsInForm(forms.Form):
receipt=forms.CharField(max_length=100, widget=forms.Select(choices=reciept_types)) | Change the code as follows :
` reciept=forms.ChoiceField(reciept_types, widget = forms.Select(attrs = {'onchange' : "myFunction();"}))`
In case you want to have access to the input value in your JavaScript code, which is very common:
{'onchange' : "myFunction(this.value);"}
And the JS:
myFunction(value) {
console.log(value)
} | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 5,
"tags": "javascript, python, django, django forms"
} |
How to call method inside the same class in ReactJS?
I want to call the method inside the same class. For example, when I click a button, it will trigger the method `handleLoginBtnClicked()`. I expect it will call the method `checkInputValidation()` in the same class. What is the proper way to do this?
export default class LoginCard extends React.Component {
//If I click a button, this method will be called.
handleLoginBtnClicked() {
this.checkInputValidation();
}
checkInputValidation() {
alert("clicked");
}
...
...
...
render() {
...
<LoginBtn onClick={this.handleLoginBtnClicked}/>
...
}
}
Error Message:
Uncaught TypeError: this.checkInputValidation is not a function | You will need to bind those functions to the context of the component. Inside `constructor` you will need to do this:
export default class LoginCard extends React.Component {
constructor(props) {
super(props);
this.handleLoginBtnClicked = this.handleLoginBtnClicked.bind(this);
this.checkInputValidation = this.checkInputValidation.bind(this);
}
//This is the method handleLoginBtnClicked
handleLoginBtnClicked() {
...
}
//This is the method checkInputValidation
checkInputValidation() {
...
}
...
..
.
} | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 8,
"tags": "javascript, reactjs, method call"
} |
Apply conditional formatting based on range of cells in another tab
I have a sheet with a calendar with dates in row 3 and weekday names in row 4. In another tab of the sheet called 'Festivos' I have in column A a series of dates. What I would like is that these dates appear in the calendar highlighted in a different colour, and if possible that the whole column is highlighted according to a conditional formatting. I have tried with the 'match' function and with 'Indirect' but I have not achieved much.
thanks in advance
,B$3)>=1 | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "google sheets"
} |
Find the area of a spherical triangle made by the points $(0, 0, 1)$, $(0, 1, 0)$ and $(\frac{1}{\sqrt{2}}, 0, \frac{1}{\sqrt{2}})$.
> Calculate the area of the spherical triangle defined by the points $(0, 0, 1)$, $(0, 1, 0)$ and $(\dfrac{1}{\sqrt{2}}, 0, \dfrac{1}{\sqrt{2}})$.
I have come up with this:
From the spherical Gauss-Bonnet Formula, where $T$ is a triangle with interior angles $\alpha, \beta, \gamma$. Then the area of the triangle $T$ is $\alpha + \beta + \gamma - \pi$.
How do I work out the interior angles in order to use this formula?
Any help appreciated. | $A(0, 0, 1)$, $B(0, 1, 0)$ and $C(\dfrac{1}{\sqrt{2}}, 0, \dfrac{1}{\sqrt{2}})$ with $|A|=|B|=|C|=1$ these point lie on unit sphere. These points specify three plane $x=0$, $y=0$ and $x=z$ then the angle between them are $\dfrac{\pi}{2}$, $\dfrac{\pi}{2}$ and $\dfrac{\pi}{4}$, since their normal vectors are $\vec{i}$, $\vec{j}$ and $\vec{i}-\vec{k}$, respectively (by $\cos\theta=\dfrac{u.v}{|u||v|}=u.v$).
At last $\sigma=\dfrac{\pi}{4}+\dfrac{\pi}{2}+\dfrac{\pi}{2}-\pi=\dfrac{\pi}{4}$. | stackexchange-math | {
"answer_score": 4,
"question_score": 5,
"tags": "spherical coordinates, spherical geometry"
} |
What is the proper replacement igniter for my York furnace?
I replaced one of these before on another unit but the part number was printed on the igniter.
This one is not so, being ignorant to HVAC I just want to make sure I get the appropriate part.
York Stellar Model: M3UF044SA
I pulled the igniter and it looks just like this one but there is no model number on it so I just want to be sure.
Are most of these universal?
$, with $S$ a finite set?
Thank so much! | A $k$-algebra $A$ is finteley generated if there exists a finite set $S$ (possibly empty) such that $A=k[S]=\\{ P(s_1,\ldots,s_n) \mid n\geq 0, P\in k[X_1,\ldots,X_n],s_1,\ldots,s_n\in S\\}$. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "abstract algebra, vector spaces, modules"
} |
Subsets and Splits