INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Persisting the font settings for gitk
You may change the font settings of a gitk window by making changes in Edit->Preferences. But these settings are reflected only for that session of gitk.
How can I persist the font settings for all further sessions? | You should see, when you quit gitk, a setting file created/updated in:
%HOMEPATH%\.config/git/gitk
It will include a line like:
set mainfont {{Calibri Light} 9}
Those settings will persists across sessions. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "git, gitk"
} |
connect prestodb through sqlalchemy
I'd like to connect to prestodb with SQLalchemy interface. I'm running `prestodb==0.7.0` and `SQLalchemy== 1.4.20` and SQLalchemy doesn't seem to have prestodb baked in:
NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:presto
Not much luck with registering the `prestodb` either:
from sqlalchemy.dialects import registry
import prestodb
from prestodb.dbapi import Connection
registry.register('presto', 'prestodb.dbapi', 'Connection')
from sqlalchemy.engine import create_engine
port = 8889
user = os.environ["USER"]
engine = create_engine(f'presto://{user}@presto:{port}/hive',
connect_args={'protocol': 'https', 'requests_kwargs': {'verify': False}})
db = engine.raw_connection()
# AttributeError: type object 'Connection' has no attribute 'get_dialect_cls'
Any ideas? | If you have a look at the Dialects docs you will see that `Presto` is a external dialect and needs to be installed separately. The Presto dialect is supported through PiHyve and can be installed using `pip install 'pyhive[presto]'`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "sqlalchemy, presto"
} |
Как вычисляется "ожидаемое значение" в протоколе PPP CHAP?
Есть RFC 1994 с описанием протокола CHAP, где утверждается про вычисление "ожидаемого значения" на авторизующем сервере на основе данных из запроса пользователя. Но в данном RFC нет описания про способ вычисления оного.
Отсюда вопрос: для протокола CHAP используются один или несколько способов вычисления "ожидаемого значения", если один, то какой именно? | Там есть описание алгоритма
> The Response Value is the one-way hash calculated over a stream of
> octets consisting of the Identifier, followed by (concatenated with) the "secret", followed by (concatenated with) the Challenge Value. The length of the Response Value depends upon the hash algorithm used (16 octets for MD5).
**Response Value** \- это результат вычисления хэш-функции над массивом байт состоящим из **идентификатора** , **секрета** и **запроса** ( **Challenge** ). Длина значения ответа зависит от алгоритма хэш-функции (16 байт для MD5). | stackexchange-ru_stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "алгоритм, сеть, авторизация, шифрование"
} |
Is it better to purchase 1password from agilebits website or the app store?
Is it better value to purchase 1password from the < website or the app store?
They cost different amounts, does the app store version include all future versions of 1password?
Which is the best option for consumers based on the license terms of the Mac App store versus a third party license where you buy an app directly from the vendor?
(I have checked the agilebits.com website, but cannot find this information) | There are benefits to both sides:
* The Mac App Store's 1Password has iCloud syncing whereas the AgileBits store distribution method can't include iCloud syncing since an app must be distributed through the Mac App Store to use such Apple services.
* The AgileBits store's 1Password is updated more frequently since the updates don't have to go through Apple's approval system. This also means you can get beta updates that aren't on the Mac App Store due to Apple's guidelines on beta distribution. | stackexchange-apple | {
"answer_score": 6,
"question_score": 5,
"tags": "mac appstore, license, password"
} |
Can multiple download locations be defined in the SRC_URI for a BB recipe?
What I'm trying to do is define a secondary location for a file ( or repo (git://) in the SRC_URI if the first one happens to fail.
Something like:
SRC_URI = " \
\
or
SRC_URI = "git://site1/myrepo.git \
git://site2/myrepo.git
Where if the first one fails, it will try the second option and not just download them both over each other.
I know there are pre-mirrors, local cache, and mirrors, but I really just want to specify multiple locations in the BB recipe.
This seems like something that should be supported, but I cannot find it. | That is not supported. The developers designed the mirroring scheme for that use case. In your example, the fetcher will try to download _both_ files. Sorry, but that's the way it works today. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "yocto, bitbake, openembedded"
} |
printing an array with a for-loop
I've build an array with 10 plurals of 7 and am now trying to print it in reversed order with a for loop. but my program seems to be ignoring this code. I've no issues printing it in regular order with a for or a for each loop. What is wrong in this piece of code?
int[] numbers = new int[10];
for (int i = 0; i < numbers.length; i++) {
numbers[i] = (int) (Math.random() * 10) * 7;
}
for (int i = numbers.length; i == 0; i--) {
System.out.println(numbers[i]);
}
System.out.println("---");
for (int i = 0; i < numbers.length; i++) {
System.out.println(numbers[i]);
} | An array of size N in java has its indexes ranging from 0 to **N-1**. So in fact `numbers.length` is out of bounds - the last element in `numbers` is with index `numbers.length - 1`. Also not your condition should be `i >= 0` instead of `i==0`, otherwise your cycle will never be executed for an array of size greater than 1. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "java, arrays, for loop, printing"
} |
Persistent login data after refreshing page in React
I have created a `login page` in React which takes user data and opens a `User Page` with the user's name. When I refresh this page again, it loses user data. I am storing user data in redux store.
If I want to make it persistent what should I do? Should I use local storage or create a Mysql DB to store data? Which one is better for a large application? | It looks like a backend job to me ... Your persistence should probably be on the express side of your application.
If you really want to do it with React only check this : <
There are a lot of resources on the Web about sessions :
* <
* <
* ... | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, html, mysql, reactjs"
} |
does openfire interfere with mysql or phpmyadmin?
I have installed php, mysql, phpmyadmin on windows server 2008 and everything is working fine. Now, I installed Openfire and i connected it to mysql database. the problem that i am having now is when every i run openfire i can't connect to database or login phpmyadmin. It seems like openfire is interfering with mysql ports! I am using port 3306 for mysql. I belive openfire is using 9090 and 9191.
so when I have open fireopen my php scripts will not be able to connect to the database and also i won't be able to log in to phpmyadmin. But when i close openfire then everything works fine again.
Can any one help me with betting both to work next to each other eith no issue please?
Thanks | I found the issue. the problem was that a min connection in openfire was set to 100 and Mysql max connection was also set to 100. So I have increased the max connection allowed and that fixed the issue. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "mysql, phpmyadmin, openfire"
} |
How to get multiple instances of mongodb-compass to run side-by-side
I am using Ubuntu 18.04, and mongodb 4.0.3 community, and mongodb-compass 1.15.4 - trying to have two instances of mongodb-compass running side-by-side. When I double-click my launcher icon it opens the first instance of mongodb-compass. When I double-click my launcher the second time it sets focus on the current running instance of mongodb-compass but does not open a second instance.
I have tried to invoke using the command line and again the focus is set to the current running instance.
How do I start another instance of mongodb-compass to run side-by-side with the first instance? | In Mongo Compass, click the "Connect" menu and select "Connect To". It will open another instance for you. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 1,
"tags": "mongodb, mongodb compass"
} |
how to print two messages in single dialogue box using python?
D= dict[a= 2, b=4, c=1, d=3]
I am using the above dictionary after sorting (ascending order) and displaying the sorted value along with the lowest value.
Desired output in the dialogue box
c=1
a=2
d=3
b=4
c lowest value is 1
I am trying the following code:
D dict[a= 2, b=4, c=1, d=3]
f= sorted(D.items(), key=operator.itemgetter(1))
g= f[0]
f= [str(x) for x in f]
g= [str(x) for x in g]
msg= '\n'.join(f) + 'lowest value is\n'.join(g)
dlg= wx.MessageDialog(self,msg,"lowest value",wx.OK)
dlg.showModal()
dlg.Destroy()
using this we are getting:
(c=1)
(a=2)
(d=3)
(b=4)c
lowest value is 1
we do not want 'c' after b=4 instead we want 'c' in the next line as in desired output. please help... | Insert extra newline characters:
msg = '\n'.join(f) + '\n\n' + ' lowest value is '.join(g) + '\n'
although the last line would be more logically built as:
msg = '\n'.join(f) + '\n\n%s lowest value is %s\n' % tuple(g)
And how about your dictionary definition?
D dict[a= 2, b=4, c=1, d=3]
was meant as
D = {'a': 2, 'b':4, 'c':1, 'd':3}
? | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "python, messagebox"
} |
What do you call a person who eats products to test their quality?
Is there a word for it? There's the term food taster, but it seems it's used for people who test food for poison. I am talking more about people who taste food for big food companies, like a candy factory or a refrigerated meal factory. | In the U.S., we often call such a person a "taste tester". From vocabulary.com:
> someone who samples food or drink for its quality
From Wikipedia:
> taste tests are sometimes used as a tool by companies to develop their brand or new products | stackexchange-ell | {
"answer_score": 4,
"question_score": 0,
"tags": "word request"
} |
Compose URL for webView
I have a webView in xamarin called Browser and I should give it a URL.
string ciao = "pizza";
Browser.Source = "www." + pizza + ".it";
I have this code, how can I compose the URL? | Use the `Uri` class.
string ciao = "pizza";
string it = "it";
Browser.Source = new Uri (string.Format (" | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "url, xamarin"
} |
Difference between "duly admitted" and "graduated"
I got my degree but it is stated that "duly admitted" but I am wondering if it is correct or not? Of course it is from university, so it might be correct, but I am just curious.
EDIT:
> This is to certify that
>
> Mr. Xyz
>
> After fulfilling the requirements has been duly admitted to the degree
>
> BS Mechatronics Engineering | This conforms most closely to this definition from dictionary.com
> to permit to exercise a certain function or privilege:
> _admitted to the bar_.
In this case, the graduate gets the privileges afforded to those who have attained the specified degree.
You can think of this as being admitted to a figurative "club" of people with that degree. | stackexchange-english | {
"answer_score": 1,
"question_score": 0,
"tags": "grammar"
} |
How to find the fundamental set of solutions of a second order ODE with constant coefficients, when given the solution form.
Q: By looking for solutions to $$y''' − y'' = 0$$ in the form $y = e^{rx}$, find a fundamental set of solutions to the above equation.
> A: {$e^0$, $xe^0$, $e^x$} forms the fundamental set of solutions
What is the full methodology which gains you this answer? | You can substitute _y=e rx_ in the equation: _y'''- y''= 0_. This gives the following:
_(e rx)''' - (erx)'' = 0_
The derivatives of an exponential function is this exponential function times the constant term in the exponent:
_(e rx)' = rerx_
Thus the above equation is equal to:
_r 3erx \- r2erx = 0_
_(r 3 \- r2)erx = 0_
_r 2(r - 1)erx = 0_
This means that _r=1_ or _r=0_ are solutions to the equation: _y'''- y''= 0_ | stackexchange-math | {
"answer_score": 0,
"question_score": 1,
"tags": "ordinary differential equations"
} |
how to change default website loading page in vs2017?
I recently installed VS2017 and when I run the site, the following page is displayed after I F5 to load the site and displays until the actual webpage displays:
<
I don't remember the behavior in the previous version of Visual Studio but I think that the default page was just white. Do you know if there's a way to change the default page loading display to a blank page or something else? | This is a new feature of VS 2017 that enables JavaScript debugging in Chrome inside VS. To turn it off:
> Go to Tools -> Options -> Debugging -> General and turn off the setting Enable JavaScript Debugging for ASP.NET (Chrome and IE). | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, .net, visual studio"
} |
SQL query two tables
I have the following two tables...
Messages
ID Title Body
1 T1 B1
4 T2 B2
5 T3 B3
6 T4 B4
8 T5 B5
.
MessagesRead
UserName ID
tom 1
tom 4
tom 8
dick 5
dick 6
dick 8
harry 4
harry 5
harry 6
I need to design a query that returns only the rows when the IDs don't match for a given person. For example...
Running this for 'tom' will return rows from 'Messages' with IDs 5 & 6\. For 'dick', 1 & 4\. And for 'harry', 1 & 8.
Hope this makes sense! | You can use following query:
SELECT ID
FROM Messages
WHERE ID NOT IN (
SELECT ID
FROM MessagesRead
WHERE UserName = 'your_input_name'); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "sql"
} |
Matplotllib plot scatter with circle sizes proportional from distance to mean
I would like to plot a scatter of values distances from mean in a scatter plot.
Here is my code for this:
import numpy as np
import matplotlib.pyplot as plt
x=[5,6,2,6,9]
y=[2,4,5,1,10]
x_mean=np.mean(x)
y_mean=np.mean(y)
x_dist_mean=x-x_mean
y_dist_mean=y-y_mean
my labels=['horse', 'cat' , 'dog', 'fish', 'ape']
plt.scatter(x_dist_mean, y_dist_mean ,alpha=0.5 )
plt.show()
However, I would like to have the dots in the scatter proportional in size for the distance from mean, so a large distance would give a big circle and a small distance would give a small circle. In addition I would also like to color the circles with the label names in my_labels.
Could someone help me with this? | Just pass in the `s` parameter for the sizes of the dots and later annotate the dots. You can play with the annotate function a lot more. (I just placed the labels to start at the center of the dot, but you can make it look different...)
import numpy as np
import matplotlib.pyplot as plt
x=[5,6,2,6,9]
y=[2,4,5,1,10]
x_mean = np.mean(x)
y_mean = np.mean(y)
x_dist_mean = x - x_mean
y_dist_mean = y - y_mean
size = np.abs(x_dist_mean * y_dist_mean) * 100
labels=['horse', 'cat' , 'dog', 'fish', 'ape']
plt.scatter(x_dist_mean, y_dist_mean, s=size, alpha=0.5, label=labels)
for label, x, y in zip(labels, x_dist_mean, y_dist_mean):
plt.annotate(label, xy = (x, y)) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "python, matplotlib, scatter plot"
} |
Remove list elements at given indices
I have a list which contains some items of type string.
List<string> lstOriginal;
I have another list which contains idices which should be removed from first list.
List<int> lstIndices;
I'd tried to do the job with **RemoveAt()** method ,
foreach(int indice in lstIndices)
{
lstOriginal.RemoveAt(indice);
}
but it crashes and said me that **"index is Out of Range."** | You need to sort the indexes that you would like to return from largest to smallest in order to avoid removing something at the wrong index.
foreach(int indice in lstIndices.OrderByDescending(v => v))
{
lstOriginal.RemoveAt(indice);
}
Here is why: let's say have a list of five items, and you'd like to remove items at indexes `2` and `4`. If you remove the item at `2` first, the item that was at index `4` would be at index `3`, and index `4` would no longer be in the list at all (causing your exception). If you go backwards, all indexes would be there up to the moment when you're ready to remove the corresponding item. | stackexchange-stackoverflow | {
"answer_score": 45,
"question_score": 17,
"tags": "c#, list"
} |
Can't import packages in VSCode Java project
I cannot import packages in my Java classes in VSCode. I type out the statement, `import db.engine.*;` (in the 'GlobalSetters' class), and try to "Run Code" in the GlobalSetters class. An error is then returned in the console:
`GlobalSetter.java:3: error: package db.engine does not exist`
`import db.engine.*;`
The issue started in another project, then I copied all classes to a test project to try and figure the issue out. I've installed the 'Extension Pack for Java' extension and I am trying to run the code with the 'Code Runner' extension.
I've been at this for a while now and there aren't any issues being identified in the import statement itself. Any ideas as to why it continually returns this error?
$. And that I'm being asked what the probability of having $\frac{M}{F} \geq 1.1 $ is for this. But I'm not sure how to go about that, of if that's the correct approach to solve this problem. | Using the normal approximation, $\hat{p} \sim N(p=.2, \frac{p(1-p)}{n}=.005)$ and assuming independence between $\hat{p}_{m}$ and $\hat{p}_{f}$, then $$\hat{p}_m - \hat{p}_r \sim N(0, .005 + .005=.10^2)$$ Using R as a calculator:
> pnorm(.10, 0, .10, lower.tail = F)
[1] 0.1586553 | stackexchange-stats | {
"answer_score": 2,
"question_score": 1,
"tags": "probability, distributions, normal distribution, frequency"
} |
On topology of p-adic numbers.
This may be a stupid question.But I am stuck with it.Is Q_p(the p-adic) connected under the usual topology?I was confounded with this problem while trying to construct a counter-example related to my master's thesis. | Any non-empty open can be written as a disjoint union of opens ; for example $\mathbb{Z}_p=\cup(a+p\mathbb{Z}_p)$ where $a$ runs through $\\{0...(p-1)\\}$. Those spaces are said totally disconnected. | stackexchange-mathoverflow_net_7z | {
"answer_score": 1,
"question_score": 0,
"tags": "nt.number theory"
} |
Space or tabs as separator in CSV
I usually put "sep=," or "sep=;" as first line on my csv files so i can easily open them with excel. But is there a way to use this with space and tab separated files? | `"sep=/t"` for tab delimited
`"sep= "` for space delimited, should work | stackexchange-superuser | {
"answer_score": 9,
"question_score": 6,
"tags": "microsoft excel, csv"
} |
Load another form in Visual foxpro
Visual foxpro 9
I have Form1, contain button btnFind; and Form2, now I want to when button btnFind is clicked, Form2 is showing up, how can I do that? | in the click of the button on the first form, just call the second with...
Do form Form2
Now, if you wanted to pass a parameter to the second form, you wound need to add a "parameter" statement to the load event of the second form and then...
do form Form2 with SomeParameterValue | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "forms, visual foxpro"
} |
How to convert Nonetype to integer?
This value exists in the list.
list = ['4', '4', '4', '1,119', '1,119', '1,119']
i try convert Nonetype to int.
list = ['4', '4', '4', '1,119', '1,119', '1,119']
for i in list :
a = [int(x.replace(',', '')) for x in list]
print(set(list))
`TypeError: 'NoneType' object is not iterable`
**i want output**
list = [4,1119] | lst = ['4', '1,119']
print ([int(x.replace(',', '')) for x in lst]) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -2,
"tags": "python"
} |
is it possible to add two developers to the development of an app?
I am just starting to work with XCode and I am kind of lost. I am working on an iOS app and I want to add a friend who will help me to develop the app.
How can we both work on the app? is there any way to achieve this? If I add him on my account as a team member, will he be able to see the source code?
Thank you for your help. | To work together on any development project, you preferably need a version control system like GIT or SVN. Apple supports this with Xcode Server. If you're not working on the app at the same time, I imagine that DropBox or any other file sharing system would work as well.
Being on the same Apple Developer team would hardly mean _anything_ in this matter at all. Note that you need to apply as a company to the Apple Developer Program in order to have more team members. The only direct benefit during development is that you can use the same certificates for distributing your app. The package you upload to iTunes Connect for distribution via the App Store is a binary, a compiled version of the app from which it is _not possible_ to extract the source code. | stackexchange-apple | {
"answer_score": 1,
"question_score": 2,
"tags": "ios, xcode"
} |
Is it wrong to have a "loading" spinner wheel in bottom right corner?
I had reported a bug, where the user was able to click a delete action multiple times, i.e. Deleting something multiple times which would result in an error.
I disabled the button upon action, and put a spinner wheel.
Today I was told that this is completely "not normal" and to "stop doing weird things"
What do you think? What are better, more standard options?
 it's not a common place for a user to look to receive feedback, and 2) the Cancel button is presumably still active (the user might want to click on it to try to cancel the action - not sure if that's desirable.)
Consider changing the buttons to "Delete" and "Cancel" to make it really clear to the user what they're going to do. "Cancel" should close the window (the user really should never see a spinner). When "Delete" is clicked, both buttons should become disabled; a spinner is OK if the deletion only lasts a couple of seconds (for longer deletions, use a progress bar). Position the spinner either in the middle of the screen, or on the "Delete" button itself. | stackexchange-ux | {
"answer_score": 0,
"question_score": 0,
"tags": "interaction design"
} |
How could i parse this xml string with Simple Xml
<?xml version="1.0" encoding="UTF-8"?>
<form>
<field name=”name”>VALUE</field>
<field name=”lastname”>VALUE</field>
<field name=”country”>VALUE</field>
<field name=”usstate”>VALUE</field>
<field name=”email”>VALUE</field>
<field name=”password”>VALUE</field>
<field name=”type”>VALUE</field>
<field name=”iscustomer”>1|0</field>
<field name=”newsletter”>1|0</field>
<field name=”privacy”>1|0</field>
<field name="udid">VALUE</field>
<field name="hash">VALUE</field>
</form> | Why negative votes? This is a legitimate question, isn't it!? I've seen stupider.
You want: simplexml_load_string
$xmlString = ' your xml ';
$xml = simplexml_load_string($xmlString);
// jimy's code here | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "php, xml, simplexml"
} |
Solving for the radius given a circumscribed triangle
Given an equilateral triangle with it's center indicated by the $\bullet$, I can drop a perpendicular bisector $y$. How can I show the segment connecting the top of y to the bottom right corner bisects the $60^{\circ}$ angle?
The problem I am actually trying to solve has a circumscribed equilateral triangle and I am trying to solve for the radius (the aforementioned segment).
!Triangle | Assuming the known variable to be the side of the triangle, I am proceeding with my answer.
Let the side of the triangle be 'a'.
1) In an equilateral triangle the median, perpendicular bisector, altitude, angular bisector are the same straight line. Hence the line joining the right most corner and passing through the dot(top of Y) is the angular bisector for that angle. Hence the angle is $30$ degrees.
2)So now you can easily solve for the cir-cum radius, which is the line joining the right most end to the dot(top of Y). You can also find the In-radius which the segment 'y'. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "geometry"
} |
How to get hive instance details from Beeline using Zookeeper
I am using a ZK string and connecting to the Hive instances. There are 6 hive instances mentioned in the ZK string all with port 2181. 3 of them are running in http mode and 3 in binary. I want to check to which hive instance my Beeline is connected to and what mode I am using.
I can get the details of the transport mode which the instance uses ( _set hive.server2.transport.mode_ ).
I just wanted to know to which instance I am connected to as well. Is there any way I can get the details of the instance to which I am connected to ?
Thanks,
AKS | set hive.server2.thrift.bind.host | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "hive, apache zookeeper, beeline"
} |
A problem about prime subring
This is a problem from gtm 167 _Field and Galois Theory_.
> Let R be a commutative ring with identity.The prime subring of R is the intersection of all subrings of R.Show that this intersection is a subring of R that is contained inside all subrings of R.Moreover,show that the prime subring of R is equal to $\\{n\cdot1:n\in\mathbb{Z}\\}$,where 1 is the multiplicative identity of R
The first part of this problem is easy.What puzzled me is the second part.I think under this definition, the prime subring of R should be $0$.Even if we only consider the inersection of non-zero subring of R,I think the outcome won't be $\\{n\cdot1:n\in\mathbb{Z}\\}$.Since $\\{2n\cdot1:n\in\mathbb{Z}\\}$ is also a subring of R.This is a controdiction.I want to know where I was wrong | This definition of “prime subring” is inconsistent with the definition of subring that does not require shared unity.
It could simply be a mistake, yes, or maybe there is more to the context than you are letting on. From scanning a copy it seems there are some small mistakes in the book of this sort.
I can’t actually locate an explicit definition of “subring” in the book... did you? If not, I would not get hung up on this and I would advise using the stronger definition.
By the way, the author _does_ explicitly say all rings in the book should have identity, and that would make subring a necessarily have identity, eliminating one of your examples. | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "abstract algebra, ring theory, field theory"
} |
Function without return doesn't work
I have a macro that calls a function:
Function escreve_mapa(Row As Integer, LastColumn As Integer, equipamentos As interger, Abrangencia As String, medias)
Dim cell As Range
Dim colunas As Range
Dim i As Integer
Sheets("Mapa de sinais (tabela)").Select
Cells(Row, "A").Value = Abrangencia
Cells(Row, "B").Value = equipamentos
Set cell = Range("C" & Row)
Set colunas = Range(cell, cell.Offset(0, LastColumn - 3))
i = 0
For Each cell In colunas
If medias(i, 1) > 0 Then
cell.Value = Round(medias(i, 0) / medias(i, 1), 2)
End If
i = i + 1
Next cell
End Function
But when it gets to this function it returns the error User-defined type not defined
Any idea why? | You've got a typo in your functions (although as it doesn't return anything it could be a sub) arguments.
`equipamentos As interger` should be `equipamentos As Integer` | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "vba, excel"
} |
How to restore database using old full backup and current log file
What is happened? My client has lost the hard disk. He has to restore database.
* He has the full backup of database 15 days old.
* He has _ldf_ (log) file of this database.
* He has NOT _mdf_ file (it was located on that hard disk).
Does it have enough components to restore SQL Server 2008 database, if he used standard options in SQL Management Studio when he did full backup 15 days ago (still database structure has changed)? Is it possible to restore **at least** database structure (it's possible to regenerate data from other source) that is was actual on crash moment?
Finally:
1) Is it possible to restore all database (data+structure)
2) Is it possible to restore database structure
Thank you. | You can only restore the 15 days old backup and get data from that point.
It comes down to something called Log Sequence Number: Your MDF expects a certain LSN, LDF knows what the LSN is, the information is in the backup. The current LDF is a later state than the MDF you'll restore and it can't be attached or used.
In simple terms, log itself is only used to track changes for rollback. There is no meaningful data as such. You are expected to back it up regularly to preserve the LSN and change chain for recovery purposes. This is why log restores are applied one after the other using a full restore as a baseline. If your database has a SIMPLE recovery model, then the log entries are discarded anyway. | stackexchange-serverfault | {
"answer_score": 3,
"question_score": 0,
"tags": "sql server 2008, restore"
} |
How to update object list JDO
So I'm trying to update an object called Alumno, this is the class:
public class Alumno extends Persona {
private Alumno alumno;
private List<String> telefonos;
private List<Asignatura> asignaturas;
And this is class "Asignatura"
public class Asignatura {
private String alias;
private String nombre;
private Long curso;
private Profesor profesor;
private List<Alumno> alumnos;
And when I try to update an object "Alumno" I get this error:
> [ObjectDB 2.8.1] javax.jdo.JDOUserException Object 'Modelo.Asignatura.Asignatura#'PGL'' belongs to another EntityManager [Asignatura:'PGL'] (error 634)
Any idea on how to solve this? Thank you very much. | This error message indicates mixing entity objects of different `EntityManager` instances.
Every `EntityManager` instance represents a separate connection to the database with a separate and isolated "persistence context", which is the set of objects in memory that represent entity objects in the database.
If you retrieve an entity object in one `EntityManager` you are not allowed to link it to entity objects in another `EntityManager` instance (e.g. using references from another entity object of another `EntityManager`). | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "java, jdo, objectdb"
} |
Is it possible to configure Windows to always display a certain application in the foreground?
I have an application that displays a dialogue box during operation. The issue is that sometimes I'll have multiple applications open and this dialogue box will appear behind those others.
Can I administratively tell Windows to always give certain applications foreground priority? So if/when they pop-up a window, it'll always be on top? | There is no global setting for this. The applications itself must support this (set the wndTopMost flag) and must give you an option whether you want this feature or not (like Taskmgr.exe) | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "windows 7"
} |
File (FRM) not found? Cant view the tables?
I have 2 version of database backup.
Mysqldump > db_backup.sql
&
`FRM` files (tables files)
The `db_backup.sql` file is corrupted; it is 0 KB. I think I can't help with it anymore.
Now I only have the `FRM` files. After I copy all the `FRM` files to my database folder, in `phpmyadmin`, I got this message: `File not found 'users' errno2`
`Users` is one of the important tables; I can't lose it. Is there any way to repair the `FRM` files? The files are there. Why does it say "File not found"? | The `.frm` files don't contain the data; the `.ibd` files have the data, if you have `innodb_file_per_table` in the `my.cnf` file. If you don't have `innodb_file_per_table` in the `my.cnf` file, the data is in the `ibdata1` file.
The `.frm` files are the table format files. They have the information about the columns in the table. If all you have are `.frm` files, your data is gone. | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 3,
"tags": "backup, files, mysql"
} |
Presentation of abelian groups and classification.
One of my friends today asked me a question. I am unable to see a clear way to attack such a problem. Here it is:
Let $G$ be a finite abelian group with generators $a,b,c,d$ and relations : $2a = 4b+c,4c =d-2b\ \text{and}\ a+b+c+d = 0$. Now we wish to write $G$ as a product of its cyclic subgroup\classify it.
Now form the given information, I can see that $G$ can be finitely presented. And after solving the equations, I was able to reduce the relations and obtain the following: $G = \langle a,b,c,d \ |\ 17b =11 a, 17c = -10a, 17d =-18a \rangle.$
Now how do I proceed from here, I thought of calculating the order but I don't know how to do so for a given presentation. In particular, is there some algorithm\formula to calculate\classify finitely presented abelian groups?
Maybe it can be done by using techniques for finitely generated abelian groups (invariant forms etc??) Please provide hints. Thank you. | Let $g=2a-3b$. Let $H$ be the subgroup of $G$ generated by $g$. Then from $11a-17b=0$, $$ 6g=12a-18b=a-b\in H,$$ hence $a=3(a-b)-g=5g\in H$, $b=a-(a-b)=5g-6g=-g\in H$, as well as $c=2a-4b=14g\in H$, and $d=2b+4c=54g\in H$. In other words $G=H$ is cyclic. The last relation tells us that $$ 0=a+b+c+d=5g-g+14g+54g=72g.$$ We verify that we obtain a homomorphism $G\to\Bbb Z/72\Bbb Z$ by sending $$a\mapsto 5,\quad b\mapsto -1,\quad c\mapsto 14,\quad d\mapsto 54.$$ | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "abstract algebra, group theory, abelian groups, group presentation"
} |
How to list items in Orchard container?
In my Orchard site, there is a content type named Product. It has the parts Container and Routable. Products can contain a content type named ProductFeature.
I have overrode the view Content-Product.cshtml to modify the html when browsing to the Route url. **Within this view, how can I get a list of all ProductFeature's the Product contains?**
This post shows how to do this for a blog Widget. <
I'm having a hard time finding how to do this in the Product's content view. The code from the above example throws a null exception error, so the model structure must be different. I I tried looking at the model using Shape Tracing or debugging in Visual Studio, but couldn't find the contained items.
Any help would be appreciated. | If you make sure your placement.info includes the container part, then your list of features should already being displayed. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "orchardcms"
} |
Is it possible to have 2 functions in 1 cell with a seperator?
I am having trouble figuring out how to use fit 2 =SUM formulas into 1 cell with a seperator('/' or '|')
Formula 1: =SUM(Sheet2!E28) - 1 Formula 2: =SUM(Sheet3!C19) - 2
The result would be something like 1/2 or 1|2, is this possible? | There are multiple ways to do that. One of simple way is to use concatenation operator `&`. Try-
=SUM(Sheet2!E28)-1 & "|" & SUM(Sheet3!C19)-2
Another way is to use `TEXTJOIN()`.
=TEXTJOIN("|",TRUE,SUM(Sheet2!E28)-1,SUM(Sheet3!C19)-2) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "excel, excel formula"
} |
How to reset/restart Cinnamon if the panels become invisible
This question is a port of this one applied to a similar but distinct issue:
## Problem:
The Cinnamon panel (my system: Linux Mint 19.1) became "invisible", that is, it still responded to mouse-clicks but became completely transparent.
## Cause:
Having plugged in an external HDMI monitor and having switched to tty1 with CTRL+ALT+F1 and back to tty7 with CTRL+ALT+F7 (where Cinnamon runs) in order to have the external monitor recognized by the system. | This answer is a port of this one applied to a similar but distinct issue:
To restart the Cinnamon Panel
1. type `ALT+F2` to open the command box
2. and then type `r` and enter. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "linux mint, cinnamon"
} |
c: fscanf trouble including newline character
I'm reading this text from a file:
file1: file2,file3,file4
file10: testfile.h
file1: file9
and splitting it
while(fscanf(fp,"%[^:]: %s",map[i].name, map[i].filesNeeded) == 2)
{
printf("%s %s",map[i].name, map[i].filesNeeded);
i++;
}
The problem is that the second and third variables are saved with leading newline characters:
Details:{name = "\\nfile10", '\\000' <repeats 56 times>, filesNeeded = "testfile.h", '\\000' <repeat
How can i save it without the leading newline characters? | add space for `" %[^:]: %s "`
while(fscanf(fp," %[^:]: %s ",map[i].name, map[i].filesNeeded) == 2)
the space in the scanf absorbs the space characters, tabulation characters, new line characters | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "c"
} |
Get all Objects one by one but in a random way
Here is the code from an other post :
from random import randint
count = article.objects.all().count()
random_index = randint(0, count - 1)
all_articles_query = article.objects.all()
article = all_articles_query[random_index]
but now i would like to remove article from the list all_articles_query, and multiple time. I would like to sort a list of article then a random article and each time i sort a random article to move it from the list of article.
I would like to get all article one by one but in a random way.
Regards | I think you can try like this using random.randrange:
import random
article_list = list(article.objects.all()) # evaluating queryset before everything
while article_list:
sample = article_list.pop(random.randrange(len(article_list)))
print(sample) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "python, django, django queryset"
} |
Why is my httpsession expiring?
I'm pretty new to JSF and I ran into an interesting problem. I have a web application, with a session timeout specified and even if I make actions, the session expires. As far as I know, every new request restarts the timeout counter, well it is not happening. Also, during development I noticed, that after timeout (redirected to the login page), if I reload the page, the session is still valid. Same session Id, counter still going... I have no idea what is wrong, I am using Glassfish and PrimeFaces.
I googled a lot, even tried to catch the ViewExpiredException, but with no luck. The redirection is done using the
<meta http-equiv="refresh" content="#{session.maxInactiveInterval};url=login.jsf?reason=expired>
method. Maybe I am missing something obvious in the web.xml, I am out of ideas.
Please give me some advice on this, thank you very much! | The approach you are using is not the best fit for implementing session timeout, The reason is meta tag will refresh the page on a specific interval, and in your case it redirects to another url on refresh,
i.e., if value of `session.maxInactiveInterval` is `5`, the page will be refreshed in 5 seconds and redirects to `login.jsf?reason=expired`, regardless of the actions you make. only page refresh will reset the counter.
Learn more about meta tags here
If you want to implement idle monitor, i suggest you to have a look at `<p:idleMonitor>` at Primefaces showcase - IdleMonitor | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "jsf, primefaces, glassfish, httpsession"
} |
Occultations of Triton
I've been listening to an episode of the "NASA in Silicon Valley" podcast about the SOFIA mission.
One of the techniques they use at SOFIA is stellar occultations to study different objects.
My impression was that the _occultations by Pluto happen much more often than by Triton_. Is this true and why is that? | Pluto is actually smaller in diameter than Triton, and is also farther away, meaning that Triton covers roughly 1.4x (according to WA) the angle that Pluto does, making occultation that much more probable apriori, ignoring their actual orbits.
In addition to the above, New Horizons recently observed Pluto's atmosphere with far more detail than what we can do from here on Earth, so it makes sense to measure a different target. | stackexchange-astronomy | {
"answer_score": 4,
"question_score": 7,
"tags": "observational astronomy, telescope, occultation, triton, sofia"
} |
several methods to same instance - DRY
Sorry if this is too simple. I'm looking for a way to make my `ruby` code dry : I want to call a number of methods on the same instance variable `@var = Model.new(param)` :
@var.method1
@var.method2
@var.method3
...
Is it possible to use the `send` method to write one line of code ? Btw, is it possible to call a block on `Model.new` to produce some more concise code ? | If you build `method1`, `method2`, etc. such that they return the instance itself using `self`, you can build a chainable interface. For example:
class Foo
def method1
# do something
self
end
def method2
# do something
self
end
def method3
# do something
self
end
# more methods...
end
@var = Foo.new
@var.method1.method2.method3
# or if this gets too long
@var.method1
.method2
.method3 | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "ruby on rails, ruby, dry"
} |
VS2019 WinForms no events showing up in Diagnostics Tool
I've tried to create simple application using WinForms. Using a Designer i added couple buttons textfield etc. No C# code modificiations only drag and drop to Layout. However when running the app no Events are shown on button click or any other action. I'm using VS2019 Professional(Edu licence) Is there a way to fix it?

{
}
AND in Form1.Designer.cs
this.MultiplyButton.Click += new System.EventHandler(this.button7_Click); | According to this post Events not collected in diagnostic tools, it's only collected in the Enterprise edition.
!enter image description here | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "c#, visual studio, winforms"
} |
Why my Xcode 4.6 localize file only can choose English?
I can choose only Englist for localizing file in my Xcode 4.6.
Is this a bug of Xcode 4.6?
How to localize my file now?
Special thanks!
!enter image description here | Before localize a file you have to add the language to the application, see image below:
!enter image description here | stackexchange-stackoverflow | {
"answer_score": 19,
"question_score": 9,
"tags": "iphone, ios, xcode"
} |
Are there any comics where Superman is influenced by several types of Kryptonite in the same time?
I've seen and know some types of Kryptonite and know what its effects are, but is there something canon (or even non-canon) that shows what effects can happen when various **different types** of Kryptonite influence Superman at the same time? | **Yes, there are several times when Superman is exposed to multiple kinds of Kryptonite:**
_Red and Green Kryptonite dust_ seems to rob him of his powers permanently (Superman #152)
!enter image description here
A ray comprising Red and Green Kryptonite causes him to develop a third eye in Action Comics #275
!enter image description here
Red and Gold Kryptonite gives Superman 'super-amnesia' in Superman #178
!enter image description here
* * *
There are also two " _imaginary stories_ " involving mixed kryptonite sources.
In Superman #192, Superman is subjected to an alloy of Gold, Red and Green Kryptonite. The effects are that he has amnesia **_and_** loses his powers.
!enter image description here
In Superman #162, Superman exposes himself to the rays of Red, Gold, Green and Blue Kyrptonite. The effect is to literally split himself into two identical (and hyper intelligent) Supermen.
!enter image description here | stackexchange-scifi | {
"answer_score": 5,
"question_score": 8,
"tags": "dc, superman"
} |
Reading Excel File as an Array in Python via Pandas
So basically I want to capture sheet as array.
Excel data[][]: A / B / C // D / E / F // G / H / Z //
I want from code to return -----> **data[0][0]=A , data[2][1]=F** and etc. Can you help me to achieve this via pandas in python. | So I achieved to solve this with numpy arrays , thanks to everyone. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "python, pandas"
} |
Most efficient method of generating a random number with a fixed number of bits set
I need to generate a random number, but it needs to be selected from the set of binary numbers with equal numbers of set bits. E.g. choose a random byte value with exactly 2 bits set...
00000000 - no
00000001 - no
00000010 - no
00000011 - YES
00000100 - no
00000101 - YES
00000110 - YES
...
=> Set of possible numbers 3, 5, 6...
Note that this is a simplified set of numbers. Think more along the lines of 'Choose a random 64-bit number with exactly 40 bits set'. Each number from the set must be equally likely to arise. | Do a random selection from the set of all bit positions, then set those bits.
Example in Python:
def random_bits(word_size, bit_count):
number = 0
for bit in random.sample(range(word_size), bit_count):
number |= 1 << bit
return number
Results of running the above 10 times:
0xb1f69da5cb867efbL
0xfceff3c3e16ea92dL
0xecaea89655befe77L
0xbf7d57a9b62f338bL
0x8cd1fee76f2c69f7L
0x8563bfc6d9df32dfL
0xdf0cdaebf0177e5fL
0xf7ab75fe3e2d11c7L
0x97f9f1cbb1f9e2f8L
0x7f7f075de5b73362L | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 10,
"tags": "algorithm, optimization, language agnostic, random, bit manipulation"
} |
Calculating partial derivative
How can I calculate the following derivative? \begin{align} \frac{\partial\int_{0}^{x_1}f(x_2,y)dy}{\partial x_2} \end{align} | By the Leibniz Rule, $$\ \ \ \frac{\partial \int_{0}^{x_{1}}f(x_{2},y)dy}{\partial x_{2}}=\int_{0}^{x_{1}}{ \frac{\partial f(x_{2},y)}{\partial x_{2}} dy}$$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "integration, derivatives"
} |
DirectoryInfo, FileInfo and very long path
I try to work with DirectoryInfo, FileInfo with very long path.
* I try use \\\?\c:\long path (i got illegal caracter with fileInfo and DirectoryInfo)
* I try use file://c:/long path (i got uri not supported)
Can i use ~ in a path or something else.
I read this post but i would like to use another way that call a API. Is it any other solutions ?
There is an article from microsoft for use \\\? in file path link text.aspx)
The question is how can i work with very long path, and DirectoryInfo, and FileInfo for path who are more longer that 256 char | Looking at the Long Paths in .NET blog post series, it looks like going to the Win32 API through P/Invoke is the only solution at the moment, other than restructuring your directories so that you don't hit the limit. | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 12,
"tags": "c#, .net, fileinfo, directoryinfo, pathtoolongexception"
} |
PhantomJS + CasperJS from Ruby - Reuse Code?
I am calling CasperJS from the backend of my Ruby on Rails application using `Open3.popen3` to make a command line call. The filename (in my case CoffeeScript) is the first argument followed by options.
Many of my coffee files do similar tasks. I see examples of of how to reuse code with modules, but I think that's a NodeJS only thing.
Any suggestions how I might reuse common code in my situation? I'm really getting horribly un-DRY.
**UPDATE:**
hexid's answer is correct. What I was missing when I tried it before is that you need the rooted file path, not relative the current file path:
my_module = require('/rooted/path/to/the/file.coffee') | PhantomJS has support for CommonJS' require.
You won't, however, be able to require NodeJS modules because PhantomJS doesn't run on NodeJS, but instead on a version of Webkit that is included in QT. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ruby, phantomjs, casperjs"
} |
Is there a way to check for Nameservers using Linux?
If a domain name has not been registered, but the nameservers have been setup, is there a way I can check using the commandline on linux if the nameservers exist without having the domain name registered? | dig @ns1.example.com www.example.com
Will send a query directly to `ns1.example.com` for the name `www.example.com`, without doing recursive lookup from the root nameservers. | stackexchange-serverfault | {
"answer_score": 5,
"question_score": 1,
"tags": "linux, nameserver"
} |
High-precision clock in Python
Is there a way to measure time with high-precision in Python --- more precise than one second? I doubt that there is a cross-platform way of doing that; I'm interesting in high precision time on Unix, particularly Solaris running on a Sun SPARC machine.
timeit seems to be capable of high-precision time measurement, but rather than measure how long a code snippet takes, I'd like to directly access the time values. | The standard `time.time()` function provides sub-second precision, though that precision varies by platform. For Linux and Mac precision is `+-` 1 microsecond or 0.001 milliseconds. Python on Windows uses `+-` 16 milliseconds precision due to clock implementation problems due to process interrupts. The `timeit` module can provide higher resolution if you're measuring execution time.
>>> import time
>>> time.time() #return seconds from epoch
1261367718.971009
Python 3.7 introduces new functions to the `time` module that provide higher resolution:
>>> import time
>>> time.time_ns()
1530228533161016309
>>> time.time_ns() / (10 ** 9) # convert to floating-point seconds
1530228544.0792289 | stackexchange-stackoverflow | {
"answer_score": 102,
"question_score": 82,
"tags": "python, time"
} |
Абракадабра при отправке писем из FireFox (PHP)
Кодировка `windows-1251`.
На сайте есть блок отправки "жалобы". Функция для отправки - `mail(PHP)` , язык - `рус/укр`.
Когда письмо отправляется из `Chrome/IE`, письмо приходит с нормальным отображаемым текстом, но вот когда из `FireFox` \- абракадабра на `укр/рус`, а на латинице - норма.
Пробовал перекодировать файл в разные кодировки, устанавливал header - результата нет. | Вы отправляете скрипту header, а кроме попробуйте установить header для функции mail. Вот, например, так:
public function sendMail($to, $subject, $message, $html = true) {
$headers = 'From: YOU EMAIL <[email protected]>' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=YOU_CHARSET"' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
} | stackexchange-ru_stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, сервер, браузер"
} |
Win7: Taskbar programs look like they're being hovered over when they're not
Windows 7 Ultimate x64 keeps thinking I'm still hovering over a taskbar program even though I'm no longer hovering over it, resulting in the hover colour and tooltip being displayed when it shouldn't.
In this screenshot, Chrome is my active window, yet iTunes remains lit up because I just hovered over it for a second, even though I've since moved the cursor and clicked on my Chrome window. This is unhelpful and distracting.
!Chrome is the active window, yet iTunes retains its hover colour
This bug is temporarily resolved by logging out, but it comes back after a while, not sure what causes it. This has happened to me on and off over several months. Few days ago I did a format and clean install, ran Windows Update completely, yet this is happening again.
Any ideas? | Not sure about an official cause or fix, but the act of simply installing 7 Taskbar Tweaker seems to have solved it. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 2,
"tags": "windows 7, taskbar"
} |
Form next to P tag
I want to archieve the following: I have a text wrapped in a p-tag and a submit-button together with a hidden input-field wrapped in a form-tag. I want the text in the `<p>` tag and the button to **appear in the same line** , how can I do this (with css)?
<p>This is a example message text.</p><form method="POST"></input><input type="hidden" name="delete_message_id" value=" 1 "></input><input type="submit" value="delete"></input></form>
Since I want the hidden input field to be sent along with the submit event, I can not just leave away the wrapping form-tag. | Both `<p>` and `<form>` elements are displayed as block elements by default.
Change the 'display' CSS property to have them display inline:
p, form{
display: inline-block;
}
Also, `<input>` tags are self-closing; you don't include `</input>`. (Even you did, you have a further invalid `</input>` tag right after opening your `<form>`).
**JSFiddle** | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "css"
} |
How to specify a gcc path in pip command?
I am trying to install cupy 5.0.0. cupy5.0.0 needs gcc version not more than 7. My deafault gcc is gcc-9. I cannot use conda environment. Also i dont have sudo permission to change /usr/bin/gcc to point to gcc-7. Is there any way to pass gcc path to pip command? | You can use `CXX`, `CC` and `LD` environment variables to specify executable names or full paths to C++ and C compilers, and the linker.
Specify the variables only for one command:
CXX=g++-7 CC=gcc-7 LD=g++-7 pip install ...
Alternatively:
export CXX=g++-7
export CC=gcc-7
export LD=g++-7
pip install ...
You can also pass extra compiler and linker options in `CXXFLAGS`, `CFLAGS`, `LDFLAGS`. Preprocessor options (e.g. include directories) go in `CPPFLAGS`. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "gcc, pip, g++, cupy"
} |
Facing error while loading data from Excel Sheet to DataTable
using (OleDbConnection connection = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathOnly + ";Extended Properties=\"Text;HDR=" + header + ";IMEX=1;Readonly=1;Extended Properties=Excel 8.0;\""))
{
using (OleDbCommand command = new OleDbCommand(sql, connection))
{
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
{
dataTable = new DataTable();
adapter.Fill(dataTable);
}
}
}
The above is the code I am using and getting the below **error** :
> Cannot update. Database or object is read-only.
Have someone faced the same issue? | your connection string contains "Readonly=1;". try changing "Readonly=0;". And try to remove "imex=1". So your code should be someting like that:
using (OleDbConnection connection = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathOnly + ";Extended Properties=\"Text;HDR=" + header + ";Readonly=0;Extended Properties=Excel 8.0;\""))
{
using (OleDbCommand command = new OleDbCommand(sql, connection))
{
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
{
dataTable = new DataTable();
adapter.Fill(dataTable);
}
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "c#, excel, oledb"
} |
Package Connected App
My app uses the Salesforce API and a managed package. Inside of the package, I have a connected app using OAuth and the Rest API. When the package has been installed, are users redirected to the call back URL? I need the package to be installed and users to pair our app with Salesforce. Many apps I viewed have no packages. Users just install the app through their website. Should this be the approach that I take?
 go into HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\ in the regedit
2) right click on Windows then New->Key
3) name the key "Test Drivers"
4) click on new key Test drivers and set "Value data" into "use at own risk"
Am I correct? Would be also nice if you could tell me if it can be done from the command line (it's easier). Thank you in advance. | No, the correct thing to do is to right click on `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows` and select New => Key and name it `Test Drivers - use at own risk`
To add it from the Command Line, you have to:
Paste this into a file and name it `import.reg`
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Test Drivers - use at own risk]
"1"="1"
"1"=-
Then, simply save and run. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "windows, windows 8.1, drivers, windows registry"
} |
Activation Energy in Acid/Base reactions
For simple acid/base reactions - i.e. those involving inorganic compounds - does activation energy ever play in reactions?
Or can we ignore kinetics entirely and just consider thermodynamic factors such as conjugate stability?
I'd be very interested if there were some book or article examining inorganic molecules' acid-base behavior from a kinetic standpoint. | Proton transfer, especially in aqueous media, has an activation barrier that is easily surmounted at room temperature or higher. Such reactions are said to be diffusion controlled (the reaction happens at the rate of proton diffusion through the media) or spontaneous. In such cases thermodynamics will control the process. That said, I'm sure there are cases where the base the proton is transferring to, is, for example, surrounded by bulky ligands substantially increasing the activation energy for the process. | stackexchange-chemistry | {
"answer_score": 3,
"question_score": 1,
"tags": "acid base, thermodynamics, kinetics"
} |
Why "puts" output is indented in Ruby?
Given the following Ruby program:
def getch
begin
system("stty raw -echo")
ch = STDIN.getc
puts "[#{ch}]"
ch
ensure
system("stty -raw echo")
end
end
print "Press a key: "
getch
puts "Have a nice day!"
and the following run:
$ ruby a.rb
Press a key: [t]
Have a nice day!
Why "Have a nice day!" is indented? Why the output is not like that:
$ ruby a.rb
Press a key: [t]
Have a nice day!
? | Ok, adding `opost` should fix it. Change you third line to look like this:
system("stty raw opost -echo")
I hope this is the answer you are looking for. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "ruby, puts"
} |
Best 2D game developing enviroment for iOS
First english isn't my primary language then I assume that I will have some grammatical mistakes.
I want to develop a 2D game for iOS.
What will be the best developing environment for iOS?
Will this developing environment require a legal OS system, or will I be able to develop in windows(without virtual machine)?
Which skill will it require in order to learn using those development environment and language and they includes have a basic physical system or will I have to program and design by myself some physical system ?
I would glad for some answers:) | Use xcode for development.
for 2d game you can use ios 7 SpriteKit, or for example Cocos2D(open source) + Box2D
cocos2d site <
or Sparrow < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ios, iphone, objective c"
} |
How to use ViewBag in a using statement?
I am trying to use the ViewBag to display the action for a form in a partial page.
I have tried the following:
@using(Html.BeginForm(ViewBag.Action, "Person", FormMethod.Post)
@using(Html.BeginForm((ViewBag.Action), "Person", FormMethod.Post)
@using(Html.BeginForm(@(ViewBag.Action), "Person", FormMethod.Post)
@using(Html.BeginForm({ViewBag.Action}, "Person", FormMethod.Post)
But none of those work. What is the correct syntax? | Try
@using(Html.BeginForm((string)ViewBag.Action, "Person", FormMethod.Post) | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 2,
"tags": "asp.net mvc, asp.net mvc 3, razor"
} |
Let the EditText can input zero when zero is the first number
Now,my EditText only can input number.But I want to ban inputing zero when the zero is the first number. How can I do? | This should help you:
yourTextEdit.addTextChangedListener(new TextWatcher(){
public void onTextChanged(CharSequence s, int start, int before, int count)
{
if (yourTextEdit.getText().matches("^0") )
{
// Not allowed
yourTextEdit.setText("");
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void afterTextChanged(Editable s){}
}); | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 5,
"tags": "android, android edittext"
} |
How to repair chipped tile edges on an external facing corner?
I've got these problems in an apartment that has been rented out.
No tile trim was ever used and it shows!
. and glue that on in the same way. | stackexchange-diy | {
"answer_score": 1,
"question_score": 0,
"tags": "tiling"
} |
GUI要素とキャラクターの位置が重なった時にGUI要素の色を半透明に切り替えるには?
GUIGUI
UnityUIuGUI | UnityWebPlayer
<
UI
RectTransformUtility.WorldToScreenPoint()
UICanvas Hierarchy
public Canvas canvas;
//UI
Vector2 GetUIScreenPos (RectTransform rt) {
return RectTransformUtility.WorldToScreenPoint(canvas.worldCamera,rt.position);
}
UI Canvas Public Canvas.worldCamera Canvas WorldToScreenPoint()
UI

Camera.main
Public Transfomr player;
void Update() {
var playerScreenPos = Camera.main.WorldToScreenPoint(player.position);
}
playerScreenPos UIUI | stackexchange-ja_stackoverflow | {
"answer_score": 9,
"question_score": 7,
"tags": "unity3d, ugui"
} |
Access App_Data in WCF service
How to access App_Data folder in WCF service?
I have placed a xslt file and I am not able to find the path. | You need to use HostingEnvironment.ApplicationPhysicalPath:
string myXsltFilename = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "App_Data", "my.xslt"); | stackexchange-stackoverflow | {
"answer_score": 29,
"question_score": 15,
"tags": ".net, wcf"
} |
Remove curved corners with CSS
I am looking to remove the curved corners from the listings on this site using CSS.
_<
I've tried various things but cant get it to work.
Would anybody have any ideas?
thanks | ### CSS
/* remove radius from container and its border */
.content-box {
border-radius: 0px;
}
/* remove radius from the image itself */
.job_listing-entry-header.listing-cover.has-image {
border-radius: 0px;
}
/* remove radius from the background of the image*/
/*its needed because the images are semi transparent*/
.job_listing-entry-header.listing-cover.has-image:after {
border-radius: 0px;
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -2,
"tags": "css"
} |
MATLAB Error Message (function definitions)
I am getting the following error when I type in CalculateIntegral(2,5) into the MATLAB Command Window:
??? Error: File: CalculateIntegral.m Line: 2 Column: 1 Function definitions are not permitted at the prompt or in scripts.
I am not sure how to resolve this error. Thanks.
clear all;
function g = CalculateIntegral(s,N)
a=0;
b=1;
h=(b-a)/N;
x = 0:h:1;
g = ff(x).*exp(-s*x);
% compute the exact answer of the integral
exact_answer=antiderivative(b,s)-antiderivative(a,s);
% compute the composite trapezoid sum
If=0;
for i=1:(N-1)
If=If+g(i)*h;
end;
If=If+g(1)*h/2+g(N)*h/2;
If; | You can't have a `clear all` before your function definition (and you don't need one). Just remove that first line to make your code work. MATLAB functions need to be by themselves in their own file, named like the function (`CalculateIntegral.m` in your case). | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -5,
"tags": "matlab"
} |
Swtich project teams in TFS 2017 portal
I have got TFS 2017 on prem and have created an additional team with it's own area. I have then added a new user story for both of these areas/teams.
I am a member of both of the areas, but can't see a way to switch between the two teams.
When looking at the backlog I can only see one of the user stories. How can I then switch to the other team and see other stories associated with that area?
In addition, I can't see a way of seeing what teams I belong to in a project without going into the settings.
Thanks | I was thinking along the lines of a new user coming along to view the project teams and so the teams wouldn't be in the Recent list. I found the list is at the Team Project list, it just needs to be expanded:
{
while(a <=b){
a+= 1;
return a;
}
return b;
}
so i was expecting it to return the new value over and over but it didnt, once i executed the code and saw for myself that, i realised it had something to do with pass by value or by reference which is something i dont really understand! can someone explain? | because the return instruction exits the code hence the methods done its job it doenst need to iterate again once it reaches the return instruction, i however would have done it if the return instruction wasnt reached. | stackexchange-stackoverflow | {
"answer_score": -2,
"question_score": -5,
"tags": "java, pass by reference, pass by value"
} |
How to make the Android Project of my Xamarin app start with MainApplication.cs instead of MainActivity.cs
I am working on a `Xamarin.Forms` application that has `Xamarin.Android` and `Xamarin.ios` projects. I need to use the `CurrentActivityPlugin` for Android.
I need to perform some functionality when the Android app starts, hence I want to my app to begin with a `MainApplicaiton` instead of a `MainActivity` as shown in the docs here.
And ideas on how I can refactor the Android Project to begin with a `MainApplication` instead of `MainActivity`? | In your AssemblyInfo.cs remove this:
#if DEBUG
[assembly: Application(Debuggable=true)]
#else
[assembly: Application(Debuggable = false)]
#endif
Then add it to your MainApplication like this:
#if DEBUG
[Application(Debuggable = true)]
#else
[Application(Debuggable = false)]
#endif
public class MainApplication : global::Android.App.Application
{
public MainApplication(IntPtr handle, JniHandleOwnership transer): base(handle,
transer)
{
}
public override void OnCreate()
{
base.OnCreate();
CrossCurrentActivity.Current.Init(this);
//A great place to initialize Xamarin.Insights and Dependency Services! Add
some function that you want.
}
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "xamarin, xamarin.forms, xamarin.android"
} |
How to set name of text input in HTML form to be variable
I am trying to create text input in my HTML form but want that input to have name value set by variable:
#! c:\Python24\python
print "Content-Type: text/html\n"
import cgi,cgitb
cgitb.enable()
name1 = "kuba"
val1 = 150
name2 = "pipi"
val2 = 300
print("<form action='python2.py' method='GET'>")
print("<input type='text' name='name1'>")
print("<input type=submit value='name2'>")
I would like to have my text to have name "kuba" and not "name1"
Can someone give me a hint? Thank you, Jakub | You could use `.format()` in your string like this, say `name1` is your variable that you want in your second print method. Then you would do:
#! c:\Python24\python
print "Content-Type: text/html\n"
import cgi,cgitb
cgitb.enable()
name1 = "kuba"
val1 = 150
name2 = "pipi"
val2 = 300
print("<form action='python2.py' method='GET'>")
print("<input type='text' name='{0}'>".format(name1))
print("<input type=submit value='name2'>")
Hence the second `print()` would output `<input type='text' name='kuba'>` . As requested by OP, for python 2.4
print("<input type='text' name='%s'>"%name1)
Similarly you could use other concatination option like `+` as pointed by @Rafalsonn in the comment. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, html, cgi"
} |
Flutter : File google-services.json is missing. The Google Services Plugin cannot function without it
I have already attached the google-services.json file from my firebase after connecting my flutter app and followed all the steps but I am still receiving this error. I looked for other answers on the net but none of them helped. I tried opening the app in chrome but then I recieved this error "Error: Assertion failed: D:\…\src\firebase_core_web.dart:273 options != null "FirebaseOptions cannot be null when creating the default app."
Are these connected? What can I do to solve these?
 async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
// Replace with actual values
options: FirebaseOptions(
apiKey: "XXX",
appId: "XXX",
messagingSenderId: "XXX",
projectId: "XXX",
),
);
runApp(MyApp());
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "firebase, flutter, dart, google cloud firestore, flutter layout"
} |
Populating a div with JSON data using jQuery
let's say that I have grid table which should be populated with data on user click. Request should be sent over ajax and returned data over json. I want to use asp.net mvc3 and jQuery.
My question is how to populate div id with returned json data, how can I recognize targed div and populate with data in that div using jQuery? | So far as div is considered, you can give it an id and later you will be able to access the element using GetElementbyId javascript function.
For the table elements, You have multiple choices.
1. Do not code a static table. instead, add elements to dom using jquery or javascript. This way, you will be able to iterate through xml and add relevant rows and columns dynamically.
2. Code the table in html statically, assign it an id and then access all the cells using next sibling, previous sibling etc relations between cells,
and lastly
1. instead of xml, fetch xhtml from ajax request. This way, you will be able to put the html directly into the div. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "c#, jquery, json, asp.net mvc 3"
} |
Determinants of symmetric tridiagonal matrix after removing first row and column
The symmetric traditional matrix $A$ and its determinant is given.
$$ A = \begin{bmatrix} a_1&b_1&0&0&0&0& \cdots &0\\\ b_1&a_2&b_2&0&0&0&\cdots&0\\\ 0&b_2&a_3&b_3&0&0&\cdots&0\\\ 0&0&b_3&a_4&b_4&0&\cdots&0\\\ 0&0&0&b_4&a_5&b_5&\cdots&0\\\ 0&0&0&\ddots&\ddots&\ddots&\ddots&\vdots\\\ 0&0&0&0&0&b_{n-2}&a_{n-1}&b_{n-1}\\\ 0&0&0&0&0&0&b_{n-1}&a_n\\\ \end{bmatrix} $$
What is the determinant of matrix $B$ which exactly $A$ after removing first row and column?
$$ B = \begin{bmatrix} a_2&b_2&0&0&0&\cdots&0\\\ b_2&a_3&b_3&0&0&\cdots&0\\\ 0&b_3&a_4&b_4&0&\cdots&0\\\ 0&0&b_4&a_5&b_5&\cdots&0\\\ 0&0&\ddots&\ddots&\ddots&\ddots&\vdots\\\ 0&0&0&0&b_{n-2}&a_{n-1}&b_{n-1}\\\ 0&0&0&0&0&b_{n-1}&a_n\\\ \end{bmatrix} $$
Is there any known way to calculate this from $A$? | I think we can only find by Laplace expansion:
$$det A=a_1\cdot detB-b_1\cdot detB'$$
and
$$det B'=b_1\cdot detC-b_2\cdot detC'$$
and so on, but it seems not possible to simplify further. | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "linear algebra, matrices"
} |
Add seconds into timestamp
I want to add seconds into the given timestamp.
**Example** :
Given time:
Declare
t1 timestamp = '1900-01-01 02:00:00';
Now I want to add some `20 seconds` into the given time.
In SQL Server I have used `DATEADD`. But I searched and come to know that there is no such function provided by PostgreSQL.
What will be the solution? | Just add the 20 seconds:
t1 := t1 + interval '20' second;
* * *
The assignment operator in PL/pgSQL is `:=`. The `=` is only there for backward compatibility. Don't use it. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 2,
"tags": "postgresql, postgresql 9.3"
} |
Can an abstract class have only method signatures without implementation like interfaces?
Like Interfaces, can an abstract class have only method signatures without implementation? If yes:
1. How do abstract classes differ from interfaces?
2. How can another class, which has an abstract class as its base class, implement the body of the base class methods? | An abstract class can contain implementations, but it doesn't have to. This is one thing that makes it different from interfaces.
abstract class classA
{
abstract public void MethodA();
public void MethodB()
{
Console.WriteLine("This is MethodB inside ClassA");
}
}
class classB : classA
{
public override void MethodA()
{
Console.WriteLine("This is MethodA inside class B");
}
}
If you implement a method in the abstract base class and want to be able to override it later, you need to declare the method as virtual.
virtual protected void MethodC(){
//this can be overridden
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -3,
"tags": "c#, java, .net, oop"
} |
why does the python version change when i run it from different locations?
When i run the python compiler from ...Anaconda2>python i get python version 2.7.11. But when i run the python compiler from ...Anaconda2/Lib>python i get python version 3.5.1.
Not sure whats happening:
C:\Anaconda2>python
Python 2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: and
>>> exit()
C:\Anaconda2>cd lib
C:\Anaconda2\Lib>python
Python 3.5.1 |Anaconda 2.5.0 (64-bit)| (default, Jan 29 2016, 15:01:46) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information. | When you type `python` in cmd Windows at first search for `python.exe` in current directory. If you stay in `C:\Anaconda2` it run python2 from Anaconda2 installation. When you execute `python` from `C:\Anaconda2\lib` Windows could not find it in the current folder, looks into `PATH` environment variable and found another `python` from another Anaconda installation. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "python, anaconda"
} |
Ignore optparse if value is given
I would like to have the ability to pass an argument w/o having to specify an option for optparse. If I do pass an option, it has to be a known option or else the script will fail.
Rsync the following file to destination
myscript.py filename
Rsync the following folder to destination (all this is figured out in function I create).
myscript.py -f foldername
The reason is, I have an array (or dict) that ties with the "foldername." If no options are passed, the argument given in the CLI is a file that's in the working folder where the user calls the script. Passing `-f` means to upload a folder whose value is stored in a dict (user can be in any directory, this folder's path is known ahead of time).
Am I better off adding options for both options? `-f` for file and `-v` for folder aka version? | I am always a fan of being explicit, but you can short circuit optparse.
# args[0] is always the executable's name
if len(args) > 1:
parser.parse_args(args, options)
else:
#open file | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "python"
} |
Count unique dates from a multidimensional list
I am querying a database for Leads. Leads have a "lead generated date" and a possible "closed" date.
What I would like to do is get a month by month total for leads generated/leads closed per month in the format [MM/YYYY, leads generated, leads closed] for Google Visualization API.
I have my query logic set and currently have a a result similar to:
[
["09/2011","09/2011"],
["09/2011","10/2011"],
["10/2011","12/2011"],
...
]
I am stuck trying to come up with an efficient way parse this and get the result of:
[
["09/2011", 2, 1],
["10/2011", 1, 1],
["12/2011", 0, 1]
]
Any help would be appreciated! | It's not that beautiful, but this should work:
from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)
data = [["09/2011","09/2011"],["09/2011","10/2011"],["10/2011","12/2011"]]
for d in data:
d1[d[0]] += 1
d2[d[1]] += 1
out = []
for key in set(d1.keys()) | set(d2.keys()):
out.append([key, d1.get(key, 0), d2.get(key, 0)]) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python 2.7, django 1.4"
} |
Inclusion of orthogonal complements: if $U_1\subset\ U_2$, then $U_2^\bot\subset\ U_1^\bot$
> Show if $U_1\subset\ U_2$, then $U_2^\bot\subset\ U_1^\bot$
I'm thinking using contradiction. $\exists v\in U_2^\bot$ s.t. $v\notin U_1^\bot$ $\Rightarrow$ $\exists u\in U_1$ s.t. $u\notin U_2$
Let $v\in U_2^\bot$ and $v\notin U_1^\bot$, then $\exists u_2\in U_2$ s.t. $\lt v,u_2\gt =0$ and $\forall u_1 \in U_1, \lt v,u_1\gt \neq 0$
This implies, $\forall u_1 \in U_1, u_1\neq u_2$. Hence, $U_1\not\subset U_2$
I feel like this should be really easy with direct proof, but I keep getting $U_1^\bot = U_2^\bot$. What am I doing wrong?
Any hint will be helpful. Thank you! | You're right that there's no need to use contradiction here (although what you were trying is really contraposition.) Here's the direct proof, where by $v\perp u$ I mean $\langle v,u\rangle=0$.
Assume $U_1\subset U_2$ and $v\in U^\perp_2$. Then $v\perp u$ for all $u\in U_2$. If $u'\in U_1,$ then in particular $u'\in U_2$ and $v\perp u'.$ Thus $v\perp u'$ for all $u'\in U_1,$ so $v\in U^\perp_1,$ and we've shown $v\in U^\perp_2\Rightarrow v\in U^\perp_1$, i.e. $U_2^\perp\subset U_1^\perp$. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "linear algebra"
} |
Select inputs with jquery
How can I select input fields with names like `name="myinput[something][etc]"` ?
`$('input[name=myinput[something][etc]')` doesnt seem to work... | $('input[name="myinput[something][etc]"]'); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "jquery, jquery selectors"
} |
How do I reshape a non-quadratic matrix?
I have a column vector `A` with dimensions (35064x1) that I want to reshape into a matrix with 720 lines and as many columns as it needs.
In MATLAB, it'd be something like this:
B = reshape(A,720,[])
in which `B` is my new matrix.
However, if I divide 35604 by 720, there'll be a remainder.
Ideally, MATLAB would go about filling every column with 720 values until the last column, which wouldn't have 720 values; rather, 504 values (48x720+504 = 35064).
Is there any function, as `reshape`, that would perform this task?
Since I am not good at coding, I'd resort to built-in functions first before going into programming. | `reshape` preserves the number of elements but you achieve the same in two steps
b=zeros(720*ceil(35604/720),1); b(1:35604)=a;
reshape(b,720,[]) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "matlab, matrix, reshape"
} |
How to creat a sleep loop in Ruby?
I'm new to Ruby and I'm trying to make a Loop that will count to 12 but every count it will sleep for 5 seconds, I made it on python like that :
import time
start=0
end=12
while start<end:
start=start+1
time.sleep(5)
How can I create a Loop like that in Ruby ? | This would do it, **sleep** act as wait,
for i in 0..12
p i
sleep(5)
end | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -3,
"tags": "ruby, loops, sleep"
} |
Create auto-generate long filed (identifier/unique key) in Solr cluser of Watson retrieve and rank service
I want to have auto-generate Long unique key in Solr cluster. I'm using IBM Watson Retrieve and Rank service and I tried the standard ways of Solr to have auto-generate mechanism (generate UUID, etc), but it's not working for Retrieve and Rank clusters. Maybe IBM is using old version of Solr or it's customized by IBM.
Who had a such a situation and how he/she fixed it?
Then you in advance. | Add the following code in your solrconfig.xml configuration file:
<updateRequestProcessorChain>
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
I'm using IBM Watson Retrieve and Rank too and it worked for me. I created my collection after adding this configuration. If you already have a collection, check this link to update an existing configuration. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "solr, ibm watson, retrieve and rank"
} |
send php value to another file in extjs
I need to pass a value of a php variable to another file using extjs4 I have this at the top of my page:
$userid = $_POST['userid'];
This is my extjs code
echo("
{
title: 'Users',
xtype: 'gridpanel',
autoScroll: true,
layout: 'fit',
store: {
storeId: 'test',
fields: [
{name: 'ID', type: 'string'},
{name: 'Name', type: 'string'},
{name: 'Admin', type: 'string'}
],
proxy: {
type: 'ajax',
url : 'GetScripts/getUsers.php',
reader: 'json'
},
autoLoad: true
},
i need to pass $userid to getUsers.php. Can I get some help on this one? | In your proxy you can specify URL parameters like so:
echo("
{
title: 'Users',
xtype: 'gridpanel',
autoScroll: true,
layout: 'fit',
store: {
storeId: 'test',
fields: [
{name: 'ID', type: 'string'},
{name: 'Name', type: 'string'},
{name: 'Admin', type: 'string'}
],
proxy: {
type: 'ajax',
url : 'GetScripts/getUsers.php',
reader: 'json',
extraParams: {
userid: " . $userid . "
}
},
autoLoad: true
},
Additionally, when you load your store you can pass parameters as well
store.load({
params : {
userid : whateverUserId
}
}); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, extjs4"
} |
What is the best way to scale a numerical dataset
I have a dataset with differents attributes which don't have the same range on their values which is a problem when we need to compute distance beetween objects. After some research i found that i can do the regularisation job with this formula : (value-min)/(max-min) where min and max are respectively the minimum and maximum value in the domain of val attribute. The question is that one, does it exist other ways ?
Thank you for your help. | There is pretty much mess in terminology in your question :). **Data Regularization)** is used for model selection, it is not about data processing. Here it is described in more friendly manner.
What you mean is **Feature Scaling**. It can be done in **several** ways including **Rescaling** , the method you described. You may also use Standardization (normalization) and Scaling to unit length.
These answers may be helpful:
* Normalization vs Scaling
* Normalization vs Standardization | stackexchange-datascience | {
"answer_score": 3,
"question_score": 2,
"tags": "data mining, dataset, beginner, feature scaling"
} |
AngularJS - Default value when var is undefined
I'm trying this:
$scope.items = {
current: item.number || 1
};
And i'm getting: `Error: item.number is undefined`
How to set the `current` to `1` when `item.number`is undefined? | This errors because item itself is undefined. Try:
current: item && item.number ? item.number : 1
If it's possible for item.number to be 0, change this to:
current: item && item.number !== undefined ? item.number : 1
0 is falsey so would be overwritten by 1 in the first case. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "javascript, angularjs"
} |
How do I make a MySQL statement from ID to ID
Example I have 500 users and every 50 users manage by one moderator.
Let's say `moderator_id = 1` can edit/manage user from `user_id` 1 until 50. What is the statement should I use?
SELECT * FROM users
WHERE
user_id `what should i use here?`
AND
moderator_id = '1';
Let me know.. | Use the `BETWEEN` operator, like this:
SELECT *
FROM users
WHERE user_id BETWEEN 1 AND 50
AND moderator_id = '1'; | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "mysql, sql"
} |
The letter 'C' is missing from GNOME
Well this is an odd issue that I've come across. I've just recently installed the GNOME shell and it's been having an issue with displaying an upper case C.
!Where's the C gone in Chrome?
This also happens with notifications: !No C in Caps
The lower case c works absolutely fine. What could be the issue? !The main menu works fine | Restarting the GNOME shell solved the problem. Press Alt+F2, type `r` in the box that shows up, and press enter. | stackexchange-askubuntu | {
"answer_score": 0,
"question_score": 2,
"tags": "14.04, gnome, session"
} |
Future of the "fun" tag
I suggest we get rid of the fun tag. The questions are mostly wikis, closed or both and I think it matches all criterion for a meta tag. | .each(function(){
var $this = $(this);
$this.children('a').attr('title', $this.find('.tooltip span').text())
})
Demo: Fiddle | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "jquery"
} |
Calling -init multiple times in Objective-C
What happens when you call -init multiple times on one object, are there some hidden side effects? Can you assume that no additional memory is allocated? Would anything go against such an idea? | Calling `-init` multiple times is undefined, unsupported, and **will** lead to bugs, crashes, and other unexpected behavior.
Many classes -- `NSString`, `NSArray`, and `NSDictionary`, for example -- don't actually allocate _anything_ when the `+alloc` method is called. It isn't until one of the various `-init*` methods are called that the object has enough context to figure out the most efficient means of doing whatever you ask. | stackexchange-stackoverflow | {
"answer_score": 31,
"question_score": 7,
"tags": "objective c, cocoa"
} |
Getting the mapping for a permutation in MATLAB
Say I have two arrays where one is a permutation of the other:
A = [2 1 5 3 7]
B = [7 2 1 3 5]
with no repetitions in either array.
How can I obtain the permutation mapping between both?
E.g. `A->B` should be:
[2, 3, 5, 4, 1]
which means:
A(1) -> B(2)
A(2) -> B(3)
A(3) -> B(5)
A(4) -> B(4)
A(5) -> B(1)
## Update:
Is there a **fast** vectorized solution that does not use `ismember` ? In my experience, `ismember` tends to be slow for very large arrays. | How about this:
[i a] = sort(A);
[i b] = sort(B);
mapping = b(a) | stackexchange-stackoverflow | {
"answer_score": 19,
"question_score": 8,
"tags": "matlab"
} |
Javascript is there a way to get the null or undefined in string format?
I can test null or undefined with ?? operator :
let test = undefined;
let result = test ?? "null or undefined"
But can I actually get "null" if it is null or "undefined" if it is undefined using ?? somehow ? | Just cast to string?
const test = undefined;
const result = test ?? String(test);
console.log(result); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "javascript"
} |
How to send arguments when requesting form
During user registration I'm calling some custom function :
def user_created(sender, user, request, **kwargs):
form = ExtendedRegistrationForm(validateemail=True, request.POST, request.FILES)
When requesting a form I need to give additional bool argument validateemail. This though give me error :
`Exception Type: SyntaxError at / Exception Value: ('non-keyword arg after keyword arg', ('/home/myapp/regbackend.py', 59, None, 'form = ExtendedRegistrationForm(dontvalidateemail=True, request.POST, request.FILES)\n'))`
What am I doing wrong ? Also if I'd like to use this argument in my form, do I need to add a custom init method? Like :
def __init__(self, *args, **kwargs):
try:
validate = args['validate']
except:
pass
if not validate:
validate = False
super(ExtendedRegistrationForm, self).__init__(*args, **kwargs) | Keyword arguments have to go after position arguments. Try:
form = ExtendedRegistrationForm(request.POST, request.FILES, validateemail=True) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "django, django forms, validation"
} |
platform.js from polymers template binding
In the platform.js from polymer is a template binding described.
Then is my understanding that the platform.js contains polyfills for later implemented browser features.
Is the template bind a feature that will later supported by browsers? | There has been talks of taking `Node.bind()` through the standards process, but there's currently no movement on that front. This is why all the template/data binding stuff is part of Polymer core and not the platform.js polyfill/prollyfill layer. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "polymer"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.