INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Login fails under IIS localhost but works under Visual Studio Server
I get this using this URL (my website setup through IIS):
<
Cannot open database "myDB" requested by the login. The login failed. Login failed for user 'R-2C02CDE60B8C4\ASPNET'.
But when I use Visual Studios built in server: localhost:3554/Default.aspx
It works fine and does not throw any error and gets all database values correctly. Does IIS need something to be changed to make this work?
|
Sounds like you are trying to connect to the database via Windows authentication. Try creating a sql user and password for your database to connect. Then it should work using both methods.
Here is a sample connection string. (1.2.3.4 is the IP address or the name of the Sql Server)
"Data Source= **1.2.3.4** ;Initial Catalog= **YourDBName** ;Persist Security Info=False;User ID=sqluser;Password= **password** "
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql server"
}
|
C++. Error: void is not a pointer-to-object type
I have a C++ program:
struct arguments
{
int a, b, c;
arguments(): a(3), b(6), c(9) {}
};
class test_class{
public:
void *member_func(void *args){
arguments vars = (arguments *) (*args); //error: void is not a
//pointer-to-object type
std::cout << "\n" << vars.a << "\t" << vars.b << "\t" << vars.c << "\n";
}
};
On compile it throws an error:
error: ‘void*’ is not a pointer-to-object type
Can someone explain what I am doing wrong to produce this error?
|
You are dereferencing the `void *` before casting it to a concrete type. You need to do it the other way around:
arguments vars = *(arguments *) (args);
This order is important, because the compiler doesn't know how to apply `*` to `args` (which is a `void *` and can't be dereferenced). Your `(arguments *)` tells it what to do, but it's too late, because the dereference has already occurred.
|
stackexchange-stackoverflow
|
{
"answer_score": 33,
"question_score": 21,
"tags": "c++, casting, void pointers, abstract data type"
}
|
Print a timer in Python to see how long to run a script
I want to print a timer in the console to optimize my script and see how long it takes to run the script.
|
This is one of the fastest way I know:
import time
import random
then = time.time() #Time before the operations start
#DO YOUR OPERATIONS HERE
now = time.time() #Time after it finished
print("It took: ", now-then, " seconds")
**time.time()** Will give you the current time in seconds. There are other way of doing it, but this is one of the best. I have always used this and it gave me no problem at all.
|
stackexchange-blender
|
{
"answer_score": 3,
"question_score": 2,
"tags": "python"
}
|
Performance azure disks, high average queue length
I'm having a classic developer-system admin battle where I am stating that there is an IO problem on the disk of the shared sql server while the system admin tells me that the capacity hasn't been reached at all.
1 thing I was able to point out is that the avg disk queue length on the SQL server is very high. The avg queue length has an average of 5 and regularly spikes to 10 to 15. It never reaches below 2.5
The system admin tells me that's not a problem because the disk is a stripe of 6 disks and the queue length is by definition bad if it is higher then the double amount of the spindles. So his formula is 6*2=12 which is lower then the average 5.
Is his reasoning correct ? Can we just look at an azure disk as a spindle? The constant avg queue length of min 5 is not an indication?
EDIT: As it turns out, the disks were a huge bottleneck. The application runs smoothly again after moving the databases to a seperate database server.
|
_You're focusing a bit much on a single metric!_
Diagnosing a bottleneck to a single component rarely ends with one counter giving a full explanation.
There are quite a few great guides for using perfmon to diagnose performance problems on SQL Server.
And unfortunately your Admin _could_ be right, the counter you choose does indeed depend on the underlying hardware. However I can't find any documentation stating that Azure is based on a 6 disk raid. So perhaps focus on other counters?
1. Avg. Disk sec/Read
2. Avg. Disk sec/Write
3. Disk Read/sec
4. Disk Writes/sec
But as a final recommendation. If your only indication was the Avg. Disk Queue Length, your Sysadmin is probably right.
If you're sure it's a disk issue, you can always try creating storage spaces.
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 3,
"tags": "performance, hard drive, sql, azure"
}
|
Render or display only the boundary of a vector layer containing thousands of polygons
To have a cleaner map to print I want to display only the boundary of a layer composed of more than 200,000 features (all adjacent).
Is there something more straightforward than dissolving or merging all the polygons?
I'm using QGIS.
|
In QGIS use the dissolve function from menu: Vector > Geoprocessing Tools > Dissolve... This will get you a new table with only the outer perimeter geometry.
|
stackexchange-gis
|
{
"answer_score": 3,
"question_score": 4,
"tags": "qgis, vector, layers, display"
}
|
Why can HTTP handle only one pending request per socket?
Being curious, I wonder why HTTP, by design, can only handle one pending request per socket.
I understand that this limitation is because there is no 'Id' to associate a request to its response, so the only way to match a response with its request is to send the response on the same socket that sent the request. There would be no way to match a response to its request if there was more than one pending request on the socket because we may not receive the responses in the same order requests were sent.
If the protocol had been designed to have a matching 'Id' for requests and responses, there could be multiple pending requests on only one socket. This could greatly reduce the number of socket used by internet browsers and applications using web services.
Was HTTP designed like this for simplicity even if it's less efficient or am I missing something and this is the best approach?
Thanks.
|
It's basically for simplicity; various proposals have been made over the years that multiplex on the same connection (e.g. SPDY) but none have taken off yet.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "http, sockets, rest"
}
|
Linker error when inlining function
I have made a function which looks like this:
//hpp
extern std::array<CPlayer, MAX_PLAYERS> PlayerArray;
inline CPlayer& Player(int playerid);
//cpp
std::array<CPlayer, MAX_PLAYERS> PlayerArray;
inline CPlayer& Player(int playerid)
{
return PlayerArray[playerid];
}
but when doing this I get a linker error saying:
error LNK2001: unresolved external symbol "class CPlayer & __cdecl Player(int)" (?Player@@YAAAVCPlayer@@H@Z)
However when I remove the `inline` keyword, everything compiles fine.
Why does this happen?
|
The function get's inlined and effectively removed from the binary as a stand alone function.
Move the implementation to header to solve this.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c++, inline, linker errors"
}
|
How can I make Notepad++ actually start maximized?
When I start a new instance of Notepad++, its window is always slightly larger than the screen, not actually maximized. That really bothers me because I have two monitors, and the extra size spills over onto the second, an effect which looks really strange.
I looked through the settings dialogs and found nothing relevant. I found guides online that explain how to make a desktop shortcut create a maximized window, but I virtually always start Notepad++ via a context menu, so that tweak doesn't help.
I'm running the installed version of Notepad++ v6.3 on 64-bit Windows 8.1.
How can I make Notepad++ start with an actually maximized window?
|
### How can I make Notepad++ start with an actually maximized window?
You need to upgrade your version (v6.3) of Notepad++.
There was a bug (fixed in v6.4):
> Fix the bug of Window position not saved/restored properly
Source Notepad++ v6.4 new features and bug fixes
Notes:
* The latest version (as of 30 May 2016) is v6.9.2.
* The version I am running (v6.8.6) remembers the size, position and windows state (minimised/normal/maximised) it had when I closed it after a restart.
|
stackexchange-superuser
|
{
"answer_score": 10,
"question_score": 10,
"tags": "notepad++"
}
|
Netflix -- How to Stream in Different Language?
There are lots of DVDs that have foreign language audio on the disc (ie foreign films might have English audio). Is it possible to stream a movie on Instant Play with an alternate language? Or do they only support native languages?
|
I believe that they only support native languages. As far as I have been able to tell there is no alternate audio stream associated with the streaming videos.
|
stackexchange-webapps
|
{
"answer_score": 2,
"question_score": 3,
"tags": "netflix, localization"
}
|
Paypal Smart Checkout | Multiple Payment Buttons with DIFFERENT currencies
I am working on a Paypal Smart button integration. On the marketplace it is for, a buyer can put items from various sellers in his cart. So there could be 2 items of seller "A" and 5 items of seller "B". The currency used by those sellers could be totally different.
The issue I am facing: When including the JS-SDK, I have to set the currency in URL of the SDK which means: I can not change it once loaded which renders my whole cart concept useless.
Is there a way where I could have different currencies for different pay buttons?
|
While it's possible (with async loading) to make a late decision about which currency SDK to load and then render some button(s) for that particular currency, it's not possible to render buttons for multiple currencies simultaneously within the same actual page/window.
To show buttons for different currencies simultaneously on the same 'page' , each block of currency buttons would need to be its own iframe, with its own currency SDK url for that frame's same-currency buttons.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "paypal, paypal rest sdk"
}
|
Possible for ListCtrl Colspan, or similar functionality?
Is there a way to have a ListCtrl cell span several columns? Or perhaps to able to append a panel / other element to a ListCtrl item that will contain the info I need?
|
No. The ListCtrl does not support that functionality. There is a pure Python list control widget called the UltimateListCtrl that allows you add any widget to a cell, although it doesn't appear to allow cell spanning either. I would still try this widget and see if it works for you. If it does not, you may be able to patch it yourself because it's written in Python or you could do a feature request for it to be added to the UltimateListCtrl on the wxPython mailing list and see if anyone takes you up on it.
You can do spanning in a wx.Grid widget if you wanted to go that route, although it's pretty limited when it comes to embedding other widgets.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python 2.7, wxpython"
}
|
Customization of Jqgrid UI by row basis
**Hello experts**
I am using jQuery grid in my web application and it is very great to use. Now i have a special requirement for it.
> can i customize its display like i want some rows text has strike ? through on it based on some condition and others display as it is. please see the attached picture for more clarification.
For example ,
I have a three rows in one grid. grid has a **isRemoved** hidden column , which has value of true or false. now if this column has value true then whole row of the grid has strike through on it means all the text of the row has strike through on it. if this column has value false then it is displayed normally ( without strike through).
**how can i achieve this ??**
Thank You
Mihir Parekh
|
<
Check this fiddle . Now here i have Client colName(colModal:name) as hidden column and i have two rows. One has value test and other has test1. Now I'm getting my row data in loadComplete and based on the value I'm applying css class to that row.
Hope it helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "jquery, jqgrid"
}
|
Sort odd numbers in Array of even and odd numbers
I need to sort the odd numbers in the inputted array. So we do nothing with the even numbers in the array but we sort the odd numbers in ascending order
public static void main(String[] args) {
System.out.println(sortArray(new int[]{1, 5, 2, 7, 3}));
}
public static int[] sortArray(int[] array) {
List<Integer> odds = new ArrayList<>();
for (int elmnt : array) {
if (elmnt % 2 != 0) {
odds.add(elmnt);
}
}
odds.stream().sorted();
for (int i = 0; i < array.length; i++) {
if (array[i] %2 != 0){
for (int j = 0; j < odds.size(); j++) {
array[i] = odds.get(j);
}
}
}
return array;
}
in this example, the array should turn into: [1, 3, 2, 5, 7]
how can I do this?
|
Here is a nifty solution using the `Stream` API.
public static int[] sortOdds(int[] a) {
var sortedOdds = Arrays.stream(a).filter(v -> v % 2 == 1).sorted().toArray();
for (int i = 0, s = 0; i < a.length; i++) {
if (a[i] % 2 == 1) {
a[i] = sortedOdds[s];
s++;
}
}
return a; // A return here is kind of redundant but whatever.
}
However, as @Yunnosch mentioned, this really isnt a good question for stack overflow. This feels like a homework question, and if it is I doubt any professor would accept the solution above since it uses `sorted()` instead of actually implementing a sorting algorithm.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -3,
"tags": "java, arrays, sorting, integer"
}
|
Method incorrectly being run twice
Why, when I am running this code, does the question from the 2nd method repeat?
using System;
namespace mdisafmidf
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello world!");
CallMethod0();
Console.WriteLine(CallMethod0());
Console.ReadKey();
}
public static string CallMethod0()
{
string x;
Console.WriteLine("Do you agree this is a good day?");
Console.WriteLine("a)Yes b)No");
x = Console.ReadLine();
if (x == "Yes")
{
return ("Of course this is a good day");
}
else
{
return ("Oh, try and stay more positive!");
}
}
}
}
|
When you run `CallMethod0`, it returns a string. You need to store the result to a string variable, and then Console.Write the variable. Since you have the method call in there twice, it is running twice.
In other words, change it to:
public static void Main(string[] args)
{
Console.WriteLine("Hello world!");
string result = CallMethod0(); // store the result like this
Console.WriteLine(result); // print the result - don't call the method again
Console.ReadKey();
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -7,
"tags": "c#"
}
|
Accuracy increases using cross-validation and decreases without
I have a question regarding cross validation: I'm using a Naive Bayes classifier to classify blog posts by author. When I validate my dataset without k-fold cross validation I get an accuracy score of 0.6, but when I do k-fold cross validation, each fold renders a much higher accuracy (greater than 0.8).
For Example:
> (splitting manually): Validation Set Size: 1452,Training Set Size: 13063, Accuracy: 0.6033057851239669
and then
> (with k-fold): Fold 0 -> Training Set Size: 13063, Validation Set Size: 1452 Accuracy: 0.8039702233250621 (all folds are over 0.8)
etc...
Why does this happen?
|
There are a few reasons this could happen:
1. Your "manual" split is not random, and you happen to select more outliers that are hard to predict. How are you doing this split?
2. What is the `k` in k-fold CV? I'm not sure what you mean by Validation Set Size, you have a fold size in k-fold CV. There is no validation set, you run the cross validation using your entire data. Are you sure you're running k-fold cross validation correctly?
Usually, one picks `k = 10` for k-fold cross validation. If you run it correctly using your entire data, you should rely on its results instead of other results.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "machine learning, naivebayes"
}
|
Maximal dimension of subspace of matrices whose products have zero trace
In the space of all real matrices with dimension $n$, find the maximal possible dimension of a subspace $V$ such that $\forall X,Y\in V,\, \operatorname{tr}(XY)=0$.
|
If $V$ is a subspace of real matrices of size $n$ with the property that $\operatorname{tr}(XY)=0$ for all $X,Y\in V$, then $\operatorname{tr}(X^2)=0$ for all $X\in V$.
Let $W$ be a subspace of real matrices of size $n$ with the property that $\operatorname{tr}(X^2)=0$ for all $X\in W$. Then $\operatorname{tr}((X+Y)^2)=0$ for all $X,Y\in W$. But $\operatorname{tr}((X+Y)^2)=\operatorname{tr}(X^2)+\operatorname{tr}(Y^2)+2\operatorname{tr}(XY)$. It follows that $\operatorname{tr}(XY)=0$ for all $X,Y\in W$.
This shows that the problem reduces to the following: Investigations about the trace form which is already solved.
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 7,
"tags": "linear algebra, matrices"
}
|
Let $A$ be a matrix sized $p\times p$, where $2\le p$. Using recurrence relations, describe $A^k$.
Let $A$ be a matrix sized $p\times p$, Where $2\le p$. The matrix values in the main diagonal are $0$ and the rest are $1$'s.
Example for $A$ where $p=5$: $$\begin{bmatrix} 0 & 1 & 1 & 1 & 1 \\\ 1 & 0 & 1 & 1 & 1 \\\ 1 & 1 & 0 & 1 & 1 \\\ 1 & 1 & 1 & 0 & 1 \\\ 1 & 1 & 1 & 1 & 0 \\\ \end{bmatrix} $$
Using reccurences relations, describe $A^k$.
|
HINT: Calculating a few powers of such matrices quickly suggests that $A^k$ always has just two distinct entries, one appearing on the diagonal, and the other appearing off the diagonal. You might try proving this by induction: the induction step, if it works, is likely to tell you what the recurrences actually are.
Let the $(i,j)$-entry of $A^k$ be $a_{ij}^k$, and suppose that $a_{ii}^k=b_k$ for $i=1,\dots,n$ and $a_{ij}^k=c_k$ when $i\ne j$. Then
$$a_{ii}^{k+1}=\sum_{j=1}^{i-1}c_k+\sum_{j=i+1}^nc_k=(n-1)c_k\;;$$
why? This is independent of $i$, so all of the diagonal entries of $A^{k+1}$ are equal to $b_{k+1}(n-1)c_k$. See if you can finish it by dealing with the off-diagonal elements.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 5,
"tags": "matrices, recurrence relations"
}
|
Can someone explain it to me what closure is in real simple language ?
> **Possible Duplicate:**
> What are ‘closures’ in .NET?
I am currently looking at lambda expression and the word closure keeps coming. Can someone explain it to me in real simple language.
|
I'd say this is a duplicate of: What are ‘closures’ in .NET?
"In essence, a closure is a block of code which can be executed at a later time, but which maintains the environment in which it was first created - i.e. it can still use the local variables etc of the method which created it, even after that method has finished executing."
|
stackexchange-stackoverflow
|
{
"answer_score": 20,
"question_score": 11,
"tags": "c#, lambda, closures"
}
|
Replace hyphens with underscores in bash script
Trying to write a bash script and in one part of it I need to take whatever parameter was passed to it and replace the hyphens with underscores if they exist.
Tried to do the following
#!/usr/bin/env bash
string=$1
string=${string//-/_}
echo $string;
It's telling me that this line `string=${string//-/_}` fails due to "Bad substitution" but it looks like it should do it? Am I missing something?
|
There is nothing wrong with your script, and it should work in modern versions of Bash.
But just in case you can simplify that to :
#!/bin/bash
echo "$1" | tr '-' '_'
This is in case that parameter substitution does not work ( which seems to be your case ).
Regards!
|
stackexchange-stackoverflow
|
{
"answer_score": 21,
"question_score": 12,
"tags": "linux, bash"
}
|
Is there anything missing in the pipeline on Azure?
I am trying to deploy angular web app using Microsoft Azure Dev cloud services. I found that the pipeline process looks successful, but somehow after completion it shows 2 steps out of 10 in grey colour (which is very kind of confusing). As, I am very new to the Azure, I am not sure what am I doing wrong here. I have attached the herewith screenshots of the steps ?
 which creates shortcuts on the desktop and start menu. By default these are created in the current user area but I could change this to install in the all users area.
What is the correct thing to do? Is there a correct thing to do?
|
I typically agree with Brandon's comment although it depends on the environment. If you're installing within an organisation and all users within the organisation (or department, or whatever) are likely to need access to your app then you can create the shortcuts for all users. If you're creating an installer for public users then only create the shortcut for that person and provide the option for all users.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "windows, installation, shortcut"
}
|
Where is Webb Space Telescope?
In this NASA application page Where is WEBB? about the recently launched Webb space telescope the information provided tracking the cruising speed of the telescope widely changes (i.e. dropped from 0.9 mi/s to 0.55 mi/s) from hour to hour or on different days.
I thought that during its cruise the Webb telescope would maintain a constant speed.
Are these large speed variations due to course corrections or due gravitational effects or whatever other reason(s)?
|
The speed is dropping, and it will continue to drop to almost zero.
The reason being that the telescope is currently moving away from the Earth, so Earth's gravity is pulling it back, slowing it down.
Spacecraft cruising are not under engine power, so they are entirely at the mercy of gravitational forces. Instead, spacecraft do their orbital changes in small impulses, "burns", and the rest of the time, the freefall cruising, their velocity naturally increases and decreases depending on whether they are going up or down. Jumping out of a plane, you're in freefall downwards, so your velocity increases. James Webb is in freefall upwards, so its velocity is decreasing.
There are some course corrections too, but the changes you are seeing are mostly due to good old gravity.
|
stackexchange-space
|
{
"answer_score": 5,
"question_score": 0,
"tags": "rockets, nasa"
}
|
Sending HTML content in API vulnerability risk
I have a react application that builds an Editor component dynamically. One of the fields in this editor is a **content editable div** that gets from API -json response- a content to be displayed in that div with some of the text highlighted or styled with any other html tags inside.
The user can change this content and I keep sending it back to API and getting it back from API to be displayed accordingly.
But I'm concerned about security, is this a risky vulnerability? How should I act in such a case?
|
Yes, you have to concern about security. I recommend to use sanitize-html.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "reactjs, api, security"
}
|
presto sql: multiple join with `using` statement
I have multiple tables and I join them (they share the same key) like this
select *
from user_account_profile
inner join user_asset_profile
using (user_id)
left join user_trading_profile
using (user_id)
I want to know how will the key `user_id` be used?, is it equivalent to
select *
from user_account_profile t1
inner join user_asset_profile t2
on t1.user_id = t2.user_id
left join user_trading_profile t3
on t1.user_id = t3.user_id
or
select *
from user_account_profile t1
inner join user_asset_profile t2
on t1.user_id = t2.user_id
left join user_trading_profile t3
on t2.user_id = t3.user_id
or if these queries are all equivalent?
|
Your two versions are functionally equivalent (except for the obvious difference of a duplicated `user_id` column when not using `using`). The first `inner join` mandates that the two `user_id`s have the same value, so either comparison returns the same result set.
If you had a series of `left join`s then you would be requiring that the value be in the _first_ table, and the equivalent would be `t1.user_id`.
If you had `full join`s, then you would not know. The matching would be from the table that has a value on the row. If both tables have a value, the logic says that they are the same, so it doesn't make a difference.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "sql, presto"
}
|
How is the sum of two Lebesgue integrable functions?
I'm practicing for the final exam in real-analysis and I am at the chapter Measure Theory and Integration. I found this exercise, but I don't know how to solve it...Could you please help me?
Let $(X, \cal{A}, \mu)$ be a measure space and $f, g : X → \mathbb{R}$. Determine if the following implications hold in general:
(i) both functions $f$ and $g$ are integrable $⇒ f + g$ is integrable;
(ii) $f + g$ is integrable $⇒$ at least one of the functions $f$ or $g$ is integrable;
|
I assume that when you say integrable you mean that the integral of the function is finite.
I belive that for the item $(i)$ you can use the property that the integral is additive and you will get your answer.
For $(ii)$ I belive it is false because you can consider $f=-x$ and $g=x$ and you get that $f+g=0$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": -3,
"tags": "real analysis, measure theory, lebesgue integral"
}
|
What's the geometric mean for (0,1)?
Someone asked me :what's the geometric mean for (0,1)
then I wrote this:
$$\mu=\sqrt[n]{x_0x_1x_2...x_n}\\\ \\\n \to \infty \\\\\mu=\sqrt[n]{\frac{n-1}{n}.\frac{n-2}{n}...\frac{n-(n-1)}{n}}\\\ \ln \mu=\frac{1}{n} \ln(\frac{n-1}{n}.\frac{n-2}{n}...\frac{n-(n-1)}{n})=\\\ \frac{1}{n}\sum_{i=1}^{n-1}\ln \frac{n-i}{n}=\\\ \frac{1}{n}\sum_{i=1}^{n-1}\ln(1-\frac{i}{n})=\\\ \int_{0}^{1}\ln(1-x)dx=\\\\(1-x)\ln(1-x)-x=-1\\\ \to \mu=e^{-1}=\frac{1}{e}$$ Am I right ?
Is it possible to find geometric mean for [0,1]
thanks in advaced .
|
Yes, though I would say the geometric mean across the interval $(0,1]$ was $$\exp\left(\int_0^1 \log_e(x)\,dx \right) =\exp\left(\lim_{b\to 0+}\left[x\log_e(x)-x \right]_b^1 \right) = \exp\left(-1 \right) = \dfrac{1}{e}$$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "calculus, logarithms, education"
}
|
Is it "How does my soul taste?" or "How does my soul tastes"?
I'm having a debate between my friends and my English teacher, it came up during a practice conversation in class and I said that "How does my soul taste" and they proceeded to correct me by saying that it's said "How does my soul tastes" given the fact that it is referred to as "He/she/it", what is the correct way to say it?
|
In English, there can be only one conjugated verb that agrees with the subject.
1. _Did_ he really eat a dozen chocolate bars at one sitting?
2. She _has_ already done her homework.
3. We _were_ not consulted on this project.
Your friend's sentence
> *How _does_ my sole _tastes_?
would then have two conjugated verbs, which doesn't work in English. It must be:
> How does my sole taste?
I presume you are talking about a type of fish, _sole_ , rather than the _soul_.
|
stackexchange-ell
|
{
"answer_score": 0,
"question_score": -1,
"tags": "phrases"
}
|
Using an Objective-C protocol from my XPC Service in my Swift app
I have an app that is written in Swift, exclusively in Swift, never had an Obj-C class, has no Obj-C files or bridging headers.
In order to add some functionality without impacting my app's entitlements, I'm trying to add an XPC service -- I created this in Xcode, and the template for XPC services in Xcode is Obj-C only.
This is fine, I wrote my service out in Obj-C, but now when I want to call my service through `NSXPCConnection` I've gotta set up the interface to it, and to do that I need to refer, in my Swift app code, to the Obj-C protocol I wrote for my XPC target.
How do I do this? I can't just add the "Protocol.h" to my app target, it has no rule for a C header. All the other commentary I've found on this only seems to apply to linking to a protocol in a framework or a common target...
|
Okay, so I figured out a solution.
1) Deleted the boilerplate Obj-C service class and protocol files.
2) Wrote my protocol and vended object classes in swift. Made sure these could be exported to Obj-C.
3) Added the protocol.swift file to my app's target. Added `#import "Service-Swift.h"` to my service's `main.m`.
So now my XPC object is implemented in Swift, my object protocol is in swift, the only non-swift file is my XPC's main.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 4,
"tags": "objective c, xcode, swift, nsxpcconnection"
}
|
Not able to get the response from django rest api using requests.get() method
I have created a Django Rest Application and exposed one service (To get the User List)
Now when I am trying to call thru curl request, I am able to get the User List.
**curl -v -XGET -i '<
But When I try to call it from another app using requests.get() method , I am getting 504 server error:
I am trying :
header = {"Content-type":"application/json"}
response = requests.get(" headers=header)
Error:
> "response , response<504>"
|
I got the issue, It was related to proxy settings.
Actually I am using two VMs (Both have different IPs) with two different micro services (First VM has User Registration service (Add User, Delete User, Get Users) and Second VM has a service to call the User Registration service using django rest framework).
Now VMs are working in a local area network with some network permissions, So I have to set the proxy range and then I have to start the server.
I am using below command for proxy setting before running the Django server:
export no_proxy='my IP/range'
Now it works fine.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, django"
}
|
When using presentViewController:animated:completion how can you pass data to the presented View Controller
When using the presentViewController:animated:completion method how can you pass data to the presented View Controller?
|
You should expose properties in the presented view controller interface and set them from the presenting view controller.
PresentedViewController* presented = [PresentedViewController new];
presented.stringProperty = @"Hello world!"
[self presentViewController:presented animated:YES completion:^ {
presented.anotherStringProperty = @"Hello again, world!"; //Set here if you need to pass the value after presentation.
}];
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "objective c, uiviewcontroller"
}
|
Return string in Scala without condition
I have following variables and i want to print output without if else condition
val students = StudentService.findAllStudents()
val colleges = StudentService.findAllColleges()
i am able to print output in Scala using following code:
students.map(student => {
val college: Option[College] = colleges.find(college => college.collegeId == student.collegeId)
if(college.isDefined)
s"${student.firstName} ${student.lastName} (${college.get.name} ${college.get.location})"
else
s"${student.firstName} ${student.lastName}"
}).foreach(println)
is there any way to return result without using if else condition when college is define or not ?
|
You can just use `map` in combination with `getOrElse`:
students.map(student =>
colleges.find(_.collegeId == student.collegeId)
.map(college => s"${student.firstName} ${student.lastName} (${college.get.name} ${college.get.location})")
.getOrElse(s"${student.firstName} ${student.lastName}")
).foreach(println)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 4,
"tags": "scala"
}
|
How to shorten file path (get canonical path) in java?
Is there any way in java which can shorten absolute path to directory.
For example:
`./data/../system/bin/` => `./system/bin/`
|
Yes, use <
File file = new File("C:/Users/../Users");
System.out.println(file.getAbsolutePath()); // C:\Users\..\Users
System.out.println(file.getCanonicalPath()); // C:\Users
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "java, file, path"
}
|
What is a Coldfusion Session?
I've used Coldfusion sessions for quite a while, so I know how they are **used** , but now I need to know how they **work** , so that I can plan for scaling my website.
Is a Coldfusion user 'session' simply a quick method to setup 2 cookies (CFTOKEN and CFID) and an associated server side memory structure? (the SESSION scope) Does it do anything else? I'm trying to identify the overhead associated with user sessions versus other methods such as cookies.
|
Your understanding of them is basically correct. Although they are not bound to the cookies. The cookies are a recording of a token. That token can get passed in the url string if cookies are not enabled in the browser.
There are 2 main advantages I see of saving things in session instead of cookies:
1. You control the session scope. People can't edit the data in the session scope without you providing them an interface. Cookies can be modified by the client.
2. Complex data like structures, arrays, objects, network sessions (FTP, exchange) can be stored there.
Their memory overhead is "low" but that's a relative term. Use the ColdFusion Admin Server Monitor to drill into how much memory your sessions are actually using.
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 5,
"tags": "session, cookies, coldfusion"
}
|
tkinter typing on an entry box without having to click on the entry first
When i open up my tkinter program, I always have to click on the entry box before i can type, is there any way to make it so it lets me type without me having to click on the entry box? thanks.
|
Yes this is possible.
If you have your entry:
myEntry = Entry(root)
You only have to add:
myEntry.focus_set()
This will put the focus on the Entry so you can type immediately without having to click on it.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "python, tkinter"
}
|
Using references vs getChildByName()
I think of 2 approaches referring to some visual element like movieclip. So suppose i have b_mc ( name="b") lying inside a_mc on the stage : 1st approach :
var mc:MovieClip = a_mc.b_mc
2nd approach :
var mc:MovieClip = a_mc.getChildByName("b")
I generally use 1st approach. What can be good reason to go for 2nd approach. It sometimes seems useless to me, as it involves extra overhead to name the movieclips, when used dynamically.
Thanks V.
|
`a.getChildByName('b')` is slower than getting `a.b`.
If you don't need to use names it makes no sense to use it, however some programmers might make use of the name, especially when generating content dynamically rather than through the Flash IDE, in which case having this function is helpful, so that the display list doesn't have to be traversed by a custom function (which it does with internal function anyway, ergo it is slower than a.b)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "actionscript 3"
}
|
SQL Server 2008 R2 Cluster with HOSTS file entries to active node on the application servers
I questioned the decision of a colleague concerning the use of a HOSTS file entry on an application server (standard SQL database backed .NET solution), which I think would cause connections to the SQL Cluster to connect only a single node in the SQL Cluster. In other words, the by using a HOSTS file entry like this....
10.10.0.100 SQLCLUSTER
...when the IP address above is the IP address of the active node in the SQL cluster and the application connection string contains SQLCLUSTER as the data source.
Intuitively, I would think the clustering technology would fail in an Active-Passive cluster configuration when using HOSTS files as described above. I do not have in-depth knowledge of MS SQL clustering, just more traditional network load balancing. Am I correct?
|
Hosts file?!! I'm going to keep this short and sweet... you should be using **AD DNS**.
Clustering uses many facilties and one of the main requirements is an AD and DNS infrastructure. It uses this for many of its configurations and features. While in theory a hosts file _might_ work with some hackery it's not best practice nor a supported configuration.
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 2,
"tags": "sql server 2008 r2"
}
|
Breakpoints stopped working in Microsoft Visual C++
All of a sudden breakpoints in Visual C++ have stopped breaking. I'm building the project in Debug mode. During execution the breakpoints say put as red dots, not as hollow dots (which would mean that it won't break due to lack of some debugging information) but still it doesn't break.
I'm using Microsoft Visual C++ 6.0 Enterprise Edition.
Please help before I shoot myself.
|
It was problem with IE 8. It started breaking at breakpoints after I downgraded to IE 6. Cruel microsoft developers.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "c++, debugging, visual c++"
}
|
Pandas Python new column dataframe
I have problems with initializing a new column in a dataframe, called df I want to do:
df['new_column'] = 0
to have all values to zero..
But then is gives me:
> A value is trying to be set on a copy of a slice from a DataFrame. Try using `.loc[row_indexer,col_indexer] = value` instead
.. so, when I then want to work on it it **** up...
I looked up on the net but didn't really find something useful.. I am a beginner in pandas so sorry if the answer is obvious but I really don't know how to do this basic thing..
Thanks!
|
I'm guessing this is because your df is already a view on some other dataframe like:
df = DF.iloc[100:]
in this case pandas will not really copy the data but just keep a reference to the old one. In my mind this is not very transparent and I have shot myself in the foot a couple of times with that.
a work around is to enfoce a copy of the dataframe to be sure it owns its own data:
df = df.copy()
so in your case you might want to do:
df = df.copy()
df['new_column'] = 0
I hope that does the trick for you
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, dataframe"
}
|
How to create an legend for ggplot for just one series of data and then add legend for additional horizontal lines?
I'm wanting to prepare a simple plot with some points and horizontal lines with a legend. The code below generates the desired plot and a legend but the legend symbols are combinations of the shape and line, when I would just like a shape for the shape and a line for the line.
dat <- iris %>% select(Sepal.Length)
dat$Type <- "Sepal.Length"
ggplot() +
geom_point(data = dat, aes(x = as.numeric(row.names(dat)), y = Sepal.Length, colour = Type), shape = 10, size = 2) +
geom_hline(aes(yintercept = 6, colour = "Some line"), linetype = "dashed")
 +
geom_point(aes(x = as.numeric(row.names(dat)), y = Sepal.Length, shape = Type), size = 2) +
geom_hline(aes(yintercept = 6, linetype = 'Some line')) +
scale_linetype_manual(values = c('Some line' = 'dashed')) +
scale_shape_manual(values = c('Sepal.Length' = 10))
, therefore a simple solution does not work.
Has anybody tried to develop that kind of deployment of d3.js charts? Do you have an idea on where to start in order to have the most simple solution?
|
A web server definitely isn't required to use a client side JavaScript library like d3.js.
For C#, you'll need to embed a web browser control (in either WindowsForms or WPF).
You'll need to make sure that the browser is working in IE9 Standards mode as shown here.
Create your web pages as you would normally. Navigate to them using webbrowser.navigate (as just files on the file system.)
This should work.
|
stackexchange-stackoverflow
|
{
"answer_score": 16,
"question_score": 38,
"tags": "c#, .net, d3.js"
}
|
Type Ahead search using Nautilus on Ubuntu 18.04
Before upgrading to Ubuntu 18.04 LTS, I was using Ubuntu 16.04.1 LTS. When I was in the file browser, I was able to access a file just by writing some letters; it just got selected and it was super fast.
After upgrading, when I start typing a search is launched and it's a little bit slow. I prefer the old method.
I tried searching on the internet but didn't know exactly what to type on the search bar.
How can I disable this automatic search? Thank you
|
Type Ahead search was removed completely from **Nautilus** , aka **GNOME Files** , since Artful. Luckily, there is a patch on GitHub that adds this functionality back to Nautilus 3.26.3, the version installed by default in Ubuntu 18.04. Now if you want to apply the patch and build Nautilus from source, go ahead, but there is a guy that did the job for us and provided a PPA to install the patched Nautilus directly:
sudo add-apt-repository ppa:lubomir-brindza/nautilus-typeahead
Then upgrade using `sudo apt full-upgrade` and kill **Files** `nautilus -q`
Please note that this will overwrite the standard version of Nautilus 3.26 in Ubuntu 18.04 with a third-party build. If you're from the _paranoid_ type you're better off using **Nemo** or **Caja** instead.
_Source:_ [[1]](
|
stackexchange-askubuntu
|
{
"answer_score": 29,
"question_score": 23,
"tags": "files, filesystem, 18.04, search"
}
|
substring-before the last occurrence of any non-word character xslt 2.0 3.0
Similar to this question, but in XSLT 2.0 or 3.0, and I want to break on the last non-word character (like the regex \W)
Finding the last occurrence of a string xslt 1.0
The input is `REMOVE-THIS-IS-A-TEST-LINE,XXX,XXXXX`
The desired output is:
REMOVE-THIS-IS-A-TEST-LINE,XXX,
This works for one delimiter at a time, but I need to break on at least commas, spaces and dashes.
substring('REMOVE-THIS-IS-A-TEST-LINE,XXX,XXXXX',1,index-of(string-to-codepoints('REMOVE-THIS-IS-A-TEST-LINE,XXX,XXXXX'),string-to-codepoints(' '))[last()])
I am using oxygen with saxon 9.9EE and antenna house.
|
I would do
replace('REMOVE-THIS-IS-A-TEST-LINE,XXX,XXXXX', '(\W)\w*$', '$1')
However, this involves back-tracking, so it might be expensive if done on a long line. To avoid the backtracking, try
string-join(
analyze-string(
'REMOVE-THIS-IS-A-TEST-LINE,XXX,XXXXX', '\W')
/*[not(position()=last())])
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "xml, substring, xslt 2.0, xslt 3.0"
}
|
How to remove program shortcuts on the desktop in window in Windows 7
I have a bunch of "Shortcut" icons on my Windows desktop folder which don't appear as .lnk files in the powershell view of `C:/users/ME/Desktop` nor in fact do they show up at all. They do show up in the file manager, however, and right clicking the "Shortcut" and selecting Properties reveals that they refer directly to the corresponding applications in my `C:/Program Files/` directory. How can I prevent them from being displayed on the desktop (or in Windows Explorer) without uninstalling them?
!Windows Explorer view of my desktop
I tried selecting them and deleting them, but Windows prompted me for administrator permissions to delete the programs themselves, and not the shortcuts.
!Prompt to delete the programs themselves. Not the links!
|
> I tried selecting them and deleting them, but Windows prompted me for administrator permissions to delete the programs themselves, and not the shortcuts.
No, it doesn't work that way. It deletes what you select. And according to your picture you've selected shotcuts, and that's just what it'll delete.
Unless of course you got some sort of weird malware, virus or program running that deletes the shortcut and anything linked to it, but that would be a first to me.
Deleting a shortcut often puts in the full name of the program it links to, which can be confusing. Try deleting just one and see what happens to the program's folder.
> How can I prevent them from being displayed on the desktop (or in Windows Explorer) without uninstalling them?
Delete the shortcuts and untick "place shortcut on desktop" during installation (a lot of programs have this).
|
stackexchange-superuser
|
{
"answer_score": 5,
"question_score": 2,
"tags": "windows 7, desktop"
}
|
Python unicode translation leaves input unchanged
I have written a python code that is supposed to translate/transliterate Persian characters. Here is a chunk of the translation table:
dictionary = {
'\u062B': 's̱',
'\u062C': 'ǧ',
}
'\u062B' is "ث" which should be translated to "s̱"
but when I run the following:
string = ('\u062B')
print("Original string:", string)
string = ('\u062B')
print("Translated string:", string.translate(dictionary))
My original string and Translated string are the same:
Original string: ث
Translated string: ث
So the translation doesn't occur. What am I doing wrong?
|
The `str.translate` method table maps from unicode _ordinals_ (i.e. integers) to ordinals, strings, or None. Use `str.maketrans` to convert the string-to-string mapping appropriately:
>>> string
'ث'
>>> str.maketrans(dictionary)
{1579: 's̱', 1580: 'ǧ'}
>>> string.translate(str.maketrans(dictionary))
's̱'
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "python, unicode, arabic, transliteration, farsi"
}
|
How to log 4xx errors into sentry?
At the moment, server errors with statuses 5xx are logged in sentry.
How can I make errors with the 4xx status be logged as warnings?
Init sentry:
Sentry.init({
dsn: '
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
new Tracing.Integrations.Express({ app: server }),
new Tracing.Integrations.Postgres(),
new ExtraErrorDataIntegration(),
],
environment: 'ENV',
release: 'n/a',
tracesSampleRate: 1.0,
enabled: true,
});
|
**shouldHandleError** intercepts the data.
In this handler, you can change the level
server.use(Sentry.Handlers.errorHandler({
shouldHandleError(error) {
if (/^[4]/.test(error.statusCode)) {
Sentry.configureScope((scope) => {
scope.setLevel(Sentry.Severity.Warning);
});
}
return true;
},
}));
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "node.js, express, sentry"
}
|
What is a safe way to stop a running thread?
I have a thread which contains execution of an IronPython script. For some reason I may need to stop this thread at any time, including script execution. How to achieve this? The first idea is `Thread.Abort()`, but it's known to be evil...
|
Well from you question and subsequent comments I can suggest you two options, with some additional "warnings":
1. If your thread loops executing something on each iteration, you can set a volatile boolean flag such that it exits after finishing the current iteration (pseudocode because I'm not familiar with python):
while shouldExit = false
// do stuff
Then just set the flag to `true` when you want the thread to stop and it will stop the next time it checks the condition.
2. If you cannot wait for the iteration to finish and need to stop it immediately, you could go for `Thread.Abort`, but make absolutely sure that there is no way you can leave open file handles, sockets, locks or anything else like this in an inconsistent state.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 10,
"tags": "c#, multithreading, ironpython, abort"
}
|
How do I convert Collection of [UILabel] to string text to display on ViewController?
I am trying to display the same information on a collection of `[UILabel]`, but I am getting this error,
> Value of type '`[UILabel]?`' has no member 'text'
I am getting the specific error on this line in my code.
storagetypelabel.text = "\(booking.storageType.uppercased()) STORAGE"
Would love some input on how to alter the way my property.text label is typed.
Since I hooked up multiple `UILabel` to one `[UILabel]` collection, when I call the `[UILabel]` property, I should be able to display the same information for all the connected labels in the collection right?
|
`text` is a property of a single `UILabel` not an array , To set the text for all labels use
let str = "\(booking.storageType.uppercased()) STORAGE"
storagetypelabel.forEach { $0.text = str }
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ios, swift, uilabel"
}
|
Dynamic selects in LINQ
Let's say I have class PersonSummary, which combines properties (columns) from 2 database tables Person and Address (with a foreign key of Person), so a PersonSummary has a First Name, State and Zip.
The creation of PersonSummary could be in a select clause with (person, address => new PersonSummary {person, address} )
My data access layer has no knowledge of PersonSummary, so I'd like to add the select clause at a higher level, and only construct the from, where, etc. at a lower level, to select rows from Person and Address based on different criteria, for e.g. have methods like GetFemales() or GetPeopleInAState().
Any recommendations on how to do this? Should my data-access functions return Expressions and the higher level method just tacks on a Select clause to it?
Signatures/Return types most appreciated.
|
When you're using the underlying extension methods LINQ uses, you can pretty much do anything you want.
So als long as your data layer returns IQueryable information, you could say
var withSummary = db.GetFemales()
.Select( p => new PersonSummary(p, p.Address) );
If you're using LINQ to SQL or EF, all data is retrieved with a single query. If, however, your LINQ provider is less advanced, you could try
var withSummary = db.GetFemales().AsEnumerable()
.Select( p => new PersonSummary(p, p.Address) );
But that does require you to somehow preload (or lazy load) the address.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, .net, linq"
}
|
Printing type of auto variable and prototype of template function/method in GDB
For demonstration purposes I need to print the type of `auto` variables and prototypes of template functions and methods.
How can this be achieved in GDB? Or is there some better way to get this information?
|
A quick search turned up this page, that shows the `whatis` command. Seems to work for me in GDB version 7.0.1.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "c++, debugging, c++11, gdb"
}
|
SQL Server - substring from position to end of string
I have to split a string, I need take the first 25 characters and then the others, this is my code
select
SUBSTRING(field, 1, 25),
SUBSTRING(field, 26, (LEN(field)-25))
from table
but I'm getting this for the second substring:
> Invalid length parameter passed to the left or substring function
What's wrong in that?
|
You can use `stuff()`:
select left(field, 25),
stuff(field, 1, 25, '')
The problem is that `substring()` doesn't accept a negative length, which your code calculates.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "sql, sql server, substring"
}
|
sectioning in org-mode to beamer does not work
I am trying to subdivide my presentation further into section and according to the org docs, setting
#+BEAMER_FRAME_LEVEL: 2
should allow for top-level headlines to be interpreted as sections, whereas not the second level headlines, i.e. ** are defining individual pages. However, in my minimal example below, setting the value from 1 to 2 does not make any difference. What am I missing here?
#+TITLE: Abandon all hope
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
#+BEAMER_FRAME_LEVEL: 2
* First page
** Stuff
larifari
** second stuff
larifari
* Second page
** fdjsfsd
larfdfj
** fjs
iiinfdnf
|
(If I understand well,) the correct way to do this is to replace `#+BEAMER_FRAME_LEVEL: 2` by `H:2` in the global options:
#+TITLE: Abandon all hope
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
#+options: H:2
* First page
** Stuff
larifari
** second stuff
larifari
* Second page
** fdjsfsd
larfdfj
** fjs
iiinfdnf
See for example here: < or directly in the current Org manual:
> Org headlines become Beamer frames when the heading level in Org is equal to org-beamer-frame-level or ‘H’ value in a ‘OPTIONS’ line
|
stackexchange-emacs
|
{
"answer_score": 4,
"question_score": 2,
"tags": "org mode, beamer"
}
|
How to have an icon next to text on an icon
I am trying to have a button with an icon and text. The icon on the left and text on the right. The following code gives me a button with an icon on top and text on the bottom.
<button class="btn-simple2" >
<a href="<%= Url.Action("Confirmation","Dashboard", new { id = Model.Data.Id })%>" rel="external" target="_blank" class="ui-icon ui-icon-print">
</a>Print Confirmation
</button>
How can I make them next to each other?? I have looked through the questions this site and that is how I got this far. Please help!
|
try, do some thing like that:
css:
.btn-simple2 {
padding-left: 24px;
background: url(../path/to/image) 0px 0px no-repeat;
}
html:
<a class="btn-simple2"
href="<%= Url.Action("Confirmation","Dashboard", new { id = Model.Data.Id })%>">
Print Confirmation
</a>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "c#, asp.net mvc 2"
}
|
How to retrieve a lost text after your browser didn't submit the text
Sometimes, I type in some text and submit, then it's not submitted for some reason or another, and when I go back, the text is lost. Is there a way to retreive this lost text?
is there a "re-type what I type in the last hour?" program?
|
For Firefox, there is an add-on named "Lazarus" which gives you exactly what you want: <
This is from the description of the add-on:
> Never lose anything you type into a web form again! Lazarus securely auto-saves all forms as you type, so after a crash, server timeout, or whatever, you can go back to the form, right click, "recover form", and breathe a sigh of relief.
|
stackexchange-superuser
|
{
"answer_score": 5,
"question_score": 2,
"tags": "forum"
}
|
Student and Subjects in a query
Can anyone help me how to possibly do this query:
I have 2 tables namely Students and Subjects, and what I want to do is get all the students with more than one subjects in the Subject table. Also I want to show the count of subjects that each student has.
Thanks you!
|
use `join` between Students and Subjects tables ,and for count `aggregate` function , below query can be your solution
select st.id,st.name,count(sb.subjectid) as numberofTakenSubject
from Students st inner join Subjects sb
on st.id=sb.student_id
group by st.id,st.name
having count(*)>1
BTW your question should be more clear and specific like Students and Subject tables structure and sample data
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "sql"
}
|
ActiveAndroid set instance id
Is it possible to set ID of certain record? I'm importing multi table database into my application database, that is mapped to ActiveAndroid model. I get it over http in json. It would save a lot of work to preserver those server-side ids on records to have same relations id<>id as on the server.
I planned on deserialisating json to objects using gson and then to save them using activeandroid .save()
Or what is the simplest way to accomplish something like that. Get rid of the the json and do some SQL import?
|
Not possible. Importing data is to be done by calling SQL inserts directly.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "android, json, orm, activeandroid"
}
|
How determinate if Json that I receive is blank
I have a function that receive a JObject, and in one case the Json that I receive are this:
{}
and I was trying to manage with this:
public void GetSomeJson(JObject request)
{
if (request==JObject.Parse("{}"))
throw new ArgumentNullException("The request are null");
//more stuff
}
In this way doesn't work, and jump the condition, any idea to recognize the Json received is null or blank?
|
`JObject` is a container for properties and implements `IDictionary<string, JToken>` to access them, so this would test if an object has zero properties:
if (request.Count == 0) { /* The object is empty */ }
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c#, json, null"
}
|
Problems with tokenize
I have
def testStr = 'a:*b*c*d'
I want to get
tokens[0]=='a'
tokens[1]=='b*c*d'
I try
def tokens = testStr.tokenize(':*')
but get
tokens[0]=='a'
tokens[1]=='b'
tokens[2]=='c'
tokens[3]=='d'
How can I do this thing
|
`tokenize` takes a list of possible tokens, so it's splitting on both `:` and `*`
You probably want `split` which takes a regular expression to split on (and returns a `String[]`):
def testStr = 'a:*b*c*d'
def tokens = testStr.split( /:\*/ )
assert tokens[ 0 ] == 'a'
assert tokens[ 1 ] == 'b*c*d'
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "string, groovy"
}
|
Gerrit to add notes to Mantis bug
I would like to have an easy way to add gerrit codes changes with bug reference to the relevant mantis bug.
I have seen some nice example here
But the use an old php scripts that's not part of mantis anymore and seems to be replaced by the source-intergration plugin that you need to configure for every single project you have. I am looking at adding this for lot's of projects. I rather just copy a hook script in the hook folder for all projects.
Versions:
* Gerrit 2.7
* MantisBT 1.2.15
|
No ready solution so I created my own plugin extending the source-integration plugin. Let's see if my boss allows me to contribute this as part of the source-integration plugin.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "gerrit, mantis"
}
|
Dropwizard banner.txt is not used
Does anyone knows how to use banner.txt in Dropwizard 0.7.1 with eclipse?
From <
> Just add a banner.txt class to src/main/resources and it’ll print it out when your application starts:
But this does not work for me. The banner.txt is there and also one in bin folder. I found no similar problem (stackoverflow,google).
Does the file need special encoding? Is it enabled (by default) to search for banner.txt in this directory? I'm using ant+ivy instead of maven!
|
I just found out, that eclipse needs the resource dir as source folder on build path:
go to project properties -> Java Build Path -> Add Folder -> go to 'src/main/resources' and activate resources -> OK
Now it works.
For the ant script use this before building the jar (change ant vars if needed):
<copy todir="${bin}" flatten="true">
<fileset dir="${src}" casesensitive="yes">
<include name="**/banner.txt"/>
</fileset>
</copy>
'flatten' attribute:
> Ignore the directory structure of the source files, and copy all files into the directory specified by the todir attribute (quote:<
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "eclipse, banner, dropwizard"
}
|
In Android, what function will be called when my application is killed by other app
I want to do something when my application destory.But now, user may be use some other app to kill my app, at that time, i dont know what function will be called.I read the document and try a lot...but the onTerminate() can't do on android decive.
so how can i detect my application is killed? there are some functions will be called when app be killed? or some BroadcastReceiver will be send?
|
Depending on how the app is destroyed, the Android system **might** call `onDestroy()`. However, this is not guaranteed. For example, if the user uses the standard App Management utility to "Force Close" your app, `onDestroy()` will not be called.
If you want to save the state of your app, you need to do so during normal operation. If you need to store data temporarily, you can override `onSaveInstanceState()`. If you need to store data more permanently, you can use either `SharedPreferences`, a SQLite database, or a file. See the Android Developer docs for more details.
I also suggest that you read the Android Developer docs about the Activity life cycle.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android"
}
|
Prove that roots are real
I am stuck with this equation, I need to prove the roots are real when $a, b, c \in R$
The equation is $$(a+b-c)x^2+ 2(a+b)x + (a+b+c) = 0$$
If someone could tell me the right way to go about this, so I can attempt it.
Thank you
EDIT: I have made an error in the question. I have now corrected it.
|
We look at the discriminant of the the polynomial, which for a quadratic $ax^2 +bx +c$ is $b^2 -4ac$, plugging the values in for our polynomial gives $$\Delta = 4(a+b)^2-4(a+b-c)(a+b+c)\\\ = 4[(a+b)^2 - (a+b)^2+c^2]\\\ = 4c^2$$
Since the square of a real number is positive, we know that the roots must be real, by looking at the quadratic forumla and seeing that the solutions are $$\frac{-b\pm\sqrt\Delta}{2a}$$
And the square root of a positive real number is real. We used the discriminant because it makes computation so much easier, than if we were doing everything that we did in the first step underneath the radical, and it would be rather ugly. Inspection shows that if $\Delta > 0$, there are two distinct real roots, if $\Delta < 0$, there are two complex roots, which are conjugate, and if $\Delta = 0$ then you have a real double root.
|
stackexchange-math
|
{
"answer_score": 5,
"question_score": 4,
"tags": "algebra precalculus"
}
|
Is there a way for having the same string readable and editable from C and Objective-C?
I have the following problem: an iOS app written with Objective-C (as usual) which uses parts of code written with C. The C code is the core of the application, the code written with Objective-C uses the job done by C and coordinates the whole application.
For doing its job, the C code reads something from a preferences file, whose name is cabled in a C file. Is it possible (in the C code) to read the name of the file at run-time rather then at compile-time? The idea is to modify a string with Objective-C and let the C code to read that string.
|
Assuming your `.c` file looks something like this:
#include <stdbool.h>
static const char *_prefsFilename = "userprefs.css";
bool readPrefs() {
FILE *fp = fopen(_prefsFilename, "r");
....
}
Then you simply need to add a function to allow `_prefsFilename` to be set before an attempt is made to use it to open the file:
void setPrefsFilename(const char *prefsFilename) {
_prefsFilename = prefsFilename;
}
and ensure you call it before calling `readPrefs()`.
This is all assumption of course, but that's all I have to work with.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "ios, objective c, c"
}
|
EF6: Foreign keys are not recognized on model generation for Sql Server DB
I'm getting started with Entity Framework and I'm trying to generate a model based on an already existing database. Most of the tables have foreign key references to other tables on unique identifiers that do not happen to be the primary key of the table.
It seems like the model generation is completely ignoring the FK references. The error list shows the following:
Error 6035: The relationship ' **My foreign key constraint** ' has columns that are not part of the key of the table on the primary side of the relationship. The relationship was excluded.
Here's a look at the model and error list
Anybody have any ideas? Is it just that EF doesn't like FK constraints on fields that aren't the primary key?
Thanks in advance.
|
Entity framework does not support unique constraints which unfortunately leaves the PK as the only candidate key.
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 6,
"tags": "c#, sql server, entity framework"
}
|
How to print the contents of a WPF control without using a PrintDialog?
Is there a way to print a WPF control's content without using PrintDialog? I want to avoid PrintDialog because its PrinterSettings.PrintToFile property is ignored unless the user checks it in the dialog. I need to print to a "FILE:" port without showing a print dialog or asking the user to provide a file name.
I looked into PrintDocument which does have the silent PrintToFile capability, but I couldn't find a way to draw the contents of my WPF control onto the document.
|
If the file format does not matter you can generate an image from the WPF control which you can then save to a file:
private static RenderTargetBitmap ConvertToBitmap(UIElement uiElement, double resolution)
{
dynamic scale = resolution / 96.0;
uiElement.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
dynamic sz = uiElement.DesiredSize;
dynamic rect = new Rect(sz);
uiElement.Arrange(rect);
dynamic bmp = new RenderTargetBitmap(Convert.ToInt32(scale * (rect.Width)), Convert.ToInt32(scale * (rect.Height)), scale * 96, scale * 96, PixelFormats.Default);
bmp.Render(uiElement);
return bmp;
}
If however you are after something like a postscript output or text file output then this won't be suitable.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c#, wpf"
}
|
iptables matching syntax
For the following iptables rule:
iptables -A INPUT -p icmp -m icmp --icmp-type 255 -j ACCEPT
I am not sure what the point of "-m" is given that "-p" is already present. Does it serve any purpose in this case? Can the above be simplified to one of the below while retaining all the functions?
iptables -A INPUT -p icmp --icmp-type 255 -j ACCEPT
OR
iptables -A INPUT -m icmp --icmp-type 255 -j ACCEPT
Thanks for any tips.
|
`-p` specifies the protocol while `-m` specifies the **matching module** which is used. The matching module might have a different type or you could specify multiple modules there. This is why you need separate flags. See the iptables manpage section `MATCH EXTENSIONS` for the various uses of -m.
However, in your case `-p x` implies `-m x`, so the second rule works equally well as the first one. The third rule is invalid. Though -m can stand alone in some cases, you have to use it along -p here as you cannot use a (protocol) matching module without explicitly specifying the protocol.
|
stackexchange-serverfault
|
{
"answer_score": 4,
"question_score": 1,
"tags": "iptables, firewall"
}
|
More Efficient Way to Avoid Multiple Calculations #2?
Here is a more difficult version of another post I made earlier today. More Efficient Way to Avoid Multiple Calculations? I have a lot of these chains in my sheet. Is there a more efficient way than what I am doing?
Here is an example post of more difficult formula needed. <
=INDIRECT("Data!E"&(K8-1))
=INDIRECT("Data!E"&(K9-1))
=INDIRECT("Data!E"&(K10-1))
etc.
Can I modify this to work?
=ARRAYFORMULA(ROW(A1:A20)*????)
It there a single formula or more efficient one that may reduce calculation time?
|
you can do it like this:
=ARRAYFORMULA(IFERROR(VLOOKUP(K8:K-1, {ROW(A:A), Data!E:E}, 2, 0)))

but I get a model.json and 3 weights file
group1-shard1of3.bin
group1-shard2of3.bin
group1-shard3of3.bin
and I want to get only one .bin file, how can I do that?
|
I am not too sure if this is possible using `save_keras_model` but from the command line with `tensorflowjs_converter` I would do the following. Where you specify the `--weigth_shard_size_bytes` to be the size of the model you have. If your model is <= 30Mb then setting it to `30000000 bytes` will result in a single file `group1-shard1of1.bin`.
tensorflowjs_converter --input_format keras --weight_shard_size_bytes 30000000 'model.h5' 'output_dir'
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "tensorflow, tensorflow.js, tensorflowjs converter"
}
|
How to get correct threshold level for CFAR (Constant False alarm algorithm)?
1. I have taken fourier transform for a sinusoidal signal (with noise added). I have to pass the values to the **CFAR algorithm** (a function) and get back the threshold values in my main matlab file.
2. After getting the values I plot the same and I get a graph as shown in the screenshots. Obviously the **_threshold values are above the signal and not on the signal_** (like a threshold line to differentiate between noise and the useful target).
Can anyone help me how to get the threshold at the right place or what I might be possibly doing wrong? Thanks for any pointers or hints to approach the problem.
,zeros(1,winGuard),ones(1,winRef)];
win=win/sum(win); % normalize
% CFAR
cfar=conv(signal,win,'same');
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "algorithm, matlab, threshold"
}
|
What's the exact margin size separating two side by side minipage environments?
Consider the following MWE with two `minipage` environments, ideally filling `1\textwidth` in total.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fouriernc,parskip,framed}
\usepackage[text={9in,6in},showframe,landscape]{geometry}
\begin{document}
%
\begin{minipage}[b][][b]{0.8\textwidth}
\begin{framed}
\end{framed}
\end{minipage}
%
\begin{minipage}[b][][s]{0.2\textwidth}
\begin{framed}
\end{framed}
\end{minipage}
%
\end{document}
With the following output
!enter image description here
I guess the answer is simple, but what is the exact size of the margin between the `minipage`s? `0.8\textwidth`+`0.2\textwidth` > `1\textwidth` by `1.97156pt`.
|
This is not different from
a
%
b
that will have a space between `a` and `b`. Just mask off the end-of-line after the first `\end{minipage}`:
\documentclass{article}
\usepackage{framed}
\begin{document}
\begin{minipage}{0.8\textwidth}
\begin{framed}
\end{framed}
\end{minipage}%
\begin{minipage}{0.2\textwidth}
\begin{framed}
\end{framed}
\end{minipage}
\end{document}
I've removed the inessential bits.
There's no space around a `minipage`, which will be as wide as the stated width.
|
stackexchange-tex
|
{
"answer_score": 5,
"question_score": 3,
"tags": "margins, minipage"
}
|
Single table vs multiple tables
I have different clients with their information. All the clients have the same information. One client is one table and each one have the same columns as other client.
My question is, What is more efficient or what is better or which is the best way to do this?
* Only one table with all the clients information (with a new column distinguishing the different clients)
* One table for each client
|
Definitely use one table with all the client's information. Something that could be of much use to you would be this site: SQL Tutorial Not only does it have explanations for the main programming of the SQL language, but the tutorial examples are a lot like what you are utilizing. When you use one table for each client, it gets extremely messy if you have more than 5, and it is tedious for your server to be working that hard. Good Luck!
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "mysql, database, database design, schema"
}
|
What is wrong with my Cpanel cronjob configuration?
My catalog rules are being reset and I know that this is a cron problem.
Here is what my cron config looks like on my Cpanel: !enter image description here
What is wrong with this? Do I need to do something else to get cron to work?
The server is a dedicated one.
|
Try to set it up like this
> Replace "username" with your own username
!enter image description here
This should set the cron to run every 5 minutes
|
stackexchange-magento
|
{
"answer_score": 2,
"question_score": 0,
"tags": "magento 1.9, cron"
}
|
Android development communicate a device with a server
I have a server that runs on Amazon ec2, which listens to a socket and prints the message ("hello world") sent by the client - which is an activity (android app).
I'm trying to send messages from the activity to the server in a function, for example: after a button is clicked to send the server a message that a button was clicked. I created a connectionHandler class which extends a thread and handle the connection to the server and writes the "hello world" message. I want to create a function called "send" that receive a string, that an activity can call it and the message will be passed to the server.
My connectionHandler is a thread, so when I start it, it just execute the run() function, and once it finished I cannot call other functions to send messages.
I hope I was clear with my question, Thanks, Itai.
|
Making a connection to server from android device with a thread call is a very wrong approach. You should use Asynctask or a library called **volley** which can make your work easier .
Reference link using Asynctask: <
Reference link using Volley: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, android, sockets, amazon ec2, communication"
}
|
Create a stuck thread (Weblogic)(J2SE)(1.5)
I need to test WLST script that checks for stuck threads across some managed instances on a weblogic deployment. Unfortunately when I need to test, I am unable to get my stuck thread problem to rear its head. How can I intentionally create a stuck thread to test my script's detection with? My thoughts presently have been to sleep a thread for more than my stuck thread limit on Weblogic's settings, but that is also longer than the timeout for webpages. So my request should timeout before the thread ever becomes stuck. Apache commons executor is another idea... Does anyone have an elegant solution to reproducing this ugly issue?
|
If you want to have a stuck thread you can simply suspend it
synchronized(this){
wait();
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "java, multithreading, weblogic"
}
|
Opensource v/s custom-developed e-store
I need to develop an _e_ -store application in C#.NET. There are number of open-source packages already available, like nopcommerce, dotnetcart and so on. I went through the source code of some and found them very tedious or to say very deep functional. My requirement is pretty straightforward. Need to have just one level of categorization and a simple and clean front-end. Therefore, i am bit sceptical about using such big solution for a simple e-store.
What do you think ?, should i use the already existing solutions or develop the one accustomed to my requirements.
|
Use Ecwid. It very simple, free and easy built shopping cart for any site: <
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "asp.net"
}
|
CGI form submit button using python
I am trying to create a cgi form that will allow a user to type in a word and then it will take that word and send it off to the next page (another cgi). I know how to do it with a .html file but I am lost when it comes to doing it with python/cgi.
Here is what I need to do but it is in html.
<html>
<h1>Please enter a keyword of your choice</h1>
<form action="next.cgi" method="get">
Keyword: <input type="text" keyword="keyword"> <br />
<input type="submit" value="Submit" />
</form>
</html>
Does anyone know how to create a submit button with cgi? Here is what I have so far.
import cgi
import cgitb
cgitb.enable()
form = cgi.FieldStorage()
keyword = form.getvalue('keyword')
|
To display html from a Python cgi page you need to use the print statement.
Here is an example using your code.
#!/home/python
import cgi
import cgitb
cgitb.enable()
print 'Content-type: text/html\r\n\r'
print '<html>'
print '<h1>Please enter a keyword of your choice</h1>'
print '<form action="next.cgi" method="get">'
print 'Keyword: <input type="text" name="keyword"> <br />'
print '<input type="submit" value="Submit" />'
print '</form>'
print '</html>'
Then on your next.cgi page you can get the values submitted by the form. Something like:
#!/home/python
import cgi
import cgitb
cgitb.enable()
form = cgi.FieldStorage()
keyword = form.getvalue('keyword')
print 'Content-type: text/html\r\n\r'
print '<html>'
print keyword
print '</html>'
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "python, cgi"
}
|
Example Code for Victory Zoom and Brush Guide
I want to create a chart similar to the example chart in the Victory Brush and Zoom Guide. I just found this library and this example is exactly what I want to do.
I wonder if there is some example code beside the description in the guide available? Does anybody know where I can find it?
I really appreciate any help from you! Thank you in advance.
|
The example code of the Brush and Zoom Guide is in the grey box under the example graph. In my Browser it's just necessary to click in the box and then click outside the box and the code will appear. So all the code is there but maybe it won't show up because of a strange focusing error.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "reactjs, charts, victory charts"
}
|
Solve trigonometric equation
I'm looking for a solution (graphic, numeric or analytic) for a function of the form:
$$a^2\tanh(x)=\tan(ax),\quad a ≥ 1,\ x > 0$$
preferably using _Mathematica_. Any advice?
|
Numerically (using `FindRoot` as you do):
fn[x_, a_] := a^2*Tanh[x] - Tan[a*x]
xmax = 5;
firstSol[a_] := First@Select[N@Sort@DeleteDuplicates@Rationalize[Quiet@Chop@
FindRoot[fn[x, a] == 0, {x, Range[0.1, xmax, 0.1]}][[1, 2]],10^-10], # >= .1 &]
Then you can either `Manipulate` or `Table`:
Manipulate[Column[{"First Solution = " <> ToString@firstSol[a],Plot[fn[x, a], {x, 0, 5},
ImageSize -> 500,Epilog -> {PointSize[Large], Point[{firstSol[a], 0}]}]},
Alignment -> Center], {a, 1, 5, 1}]
!Manipulate&FindRoot
Or:
Table[firstSol@a, {a, 1, 5}]
> {3.9266, 0.555377, 0.435336, 0.346333, 0.285585}
Although `xmax` and the domain in which you want to find solutions has to be chose carefully. In your function `a` has a big influence.
|
stackexchange-mathematica
|
{
"answer_score": 5,
"question_score": 2,
"tags": "equation solving, functions, trigonometry"
}
|
Sharepoint branding tools
i am getting started with SharePoint branding. Google search show me two major type of customization :
1. master page customization
2. composed look customization
Could you guys tell me if there are more ways and the tools i can used?
|
Hey there I see you've tagged this question with "sharepoint-online". Are you sure customizing the MasterPage is an investment you want to make? Publishing sites as we knew it are pretty much obsolete when communication sites are rolled out. When you're still on-premises it makes a bit more sense.
That said, if you want to have a custom MasterPage you can start here: Master Pages in SharePoint Add-ins
Another good read on branding SharePoint is Branding SharePoint sites in the SharePoint Add-in model
Also don't forget Microsofts own source for development on the Office 365 platform dev.office.com and dev.office.com/patterns-and-practices
Hopefully this helps!
|
stackexchange-sharepoint
|
{
"answer_score": 4,
"question_score": 3,
"tags": "sharepoint online, sharepoint designer, publishing site, branding, design manager"
}
|
Como uso apis en AJAX?
Se usar ajax, pero para el examen que tengo en unas horas me piden usar ajax con alguna api y de ahi sacar la información, no tengo idea alguna, alguien me puede explicar como puedo hacerlo? Gracias
|
Una API es una aplicacion web que sirve datos a los clientes, casi igual a una aplicacion web que utiliza ajax.
Puedes utilizar la API de prueba de `jsonplaceholder`. Por ejemplo, para obtener una lista de post con ajax solo tendrias que hacer lo siguiente:
function cargarPosts(){
$.get(" function(posts){
console.log(posts);
});
}
<script src="
<button onclick="cargarPosts()">Cargar posts</button>
Ahi obtienes la lista de posts y puedes utilizar esos datos para crear una tabla con los mismos.
|
stackexchange-es_stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ajax, api"
}
|
imagemagick convert command equivalent for iphone
I have no experience with imageMagick, it is a very powerfull library.
One question. How can i convert the command line example that uses command line "Convert" command to the iphone version ?
I mean, i do not know what command to use instead of convert command
Thanks to all
|
ImageMagick isn't installed by default on iPhones. It appears that someone has ported the project though: <
You'll probably need to use the Magick Wand C interface to talk to the library from your program.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "iphone, imagemagick"
}
|
Outer automorphisms of a holomorph
Let $G$ be a finite group. Although $G$ may have outer automorphisms, an easy way to "kill" them is taking the holomorph, $G\rtimes\mathrm{Aut}(G)$. However, this process may a priori produce more outer automorphisms.
> Does $G\rtimes \mathrm{Aut}(G)$ have outer automorphisms?
Surely there is an example of a group $G$ such that $G\rtimes\mathrm{Aut}(G)$ has outer automorphisms, but none come to mind.
|
The holomorph of the symmetric group $S_3$ is isomorphic to $S_3 \times S_3$. The automorphism of the latter interchanging the two copies of $S_3$ is outer.
|
stackexchange-math
|
{
"answer_score": 5,
"question_score": 2,
"tags": "group theory, finite groups, examples counterexamples, automorphism group, holomorph"
}
|
iOS / objective-c(++) equivalent to Windows I/O Completion Ports?
Suppose I want to implement a method that loads a file asynchronously and returns some task with the file's content as its result. In .NET, I could say:
public async Task<byte[]> GetFileContentsAsync(string path)
{
using (var fs = File.OpenRead(path))
using (var ms = new MemoryStream())
{
await fs.CopyToAsync(ms);
return ms.ToArray();
}
}
Under the covers, `CopyToAsync` will utilize IO completion ports to ensure that a thread won't be wasted idling, waiting for IO.
Is there an equivalent in Objective-C(++)? Can I implement the following contract efficiently?
ppl::task<StorageBufferPtr> GetFileContentsAsync(const shared_ptr<string> path)
{
???
}
|
The documentation you are looking for is here:
<
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ios, objective c, .net, objective c++, io completion ports"
}
|
Turn on subsection numbering in memoir
It seems that the `memoir` class automatically avoids numbering subsection headings. Chapter and section titles are numbered, but subsection headings contain only the subsection name, and are not prefixed by the subsection number. Why is this the case, and more importantly, how do I turn subsection numbering back on?
|
The correct way to do this, specifically for `memoir`, IMO, is to use
\setsecnumdepth{subsection}
Why?:
* It's a higher-level command --- `\setcounter` is somewhere in the bowels of memoir/LaTeX
* It's semantic --- saying "subsection" is hopelessly more meaningful than saying "2"
* It's practical --- it persists across `\mainmatter`
|
stackexchange-tex
|
{
"answer_score": 74,
"question_score": 65,
"tags": "numbering, memoir, sectioning"
}
|
If statement VBA Excel 2010
Ok so I am calculating rates with an if Statement
* * *
$2 kWh +
0\. First 150 kWh per kW @ $0.4
1. Next 150 kWh per kW @ $0.25
2. Next 150 kWh per kW @ $0.10
3. Additional kWh @ $0.05
* * *
I want to have three rows
* kWh - Use (kWuse \- 50kW, 160kW, 305kW, 500kW,
* kWh - Price (kWprice
* kWh - Cost (kWcost
Use will be how many Kw they use. Price will be the IF statement. And cost will be the calculation of the two.
But all I need help with is the Price if statement.
Thanks,
|
Assuming that you mean that there is a 2 dollar base charge + the kWh rate (4 pricing teirs), then here is a function that will give you the cost if you give it the usage. Since the rates are fixed at 3 tiers, you already know what the cost is for 150, 300, and 450 kWh, so I used that in my function.
With this, all you need is 2 columns. The usage, and the price (this formula).
Function GetCost(ByVal usage As Double) As Double
' $2 kWh base +
'First 150 kWh per kW @ $0.4
'Next 150 kWh per kW @ $0.25
'Next 150 kWh per kW @ $0.10
'Additional kWh @ $0.05
If usage > 450 Then
GetCost = 114.5 + ((usage - 450) * 0.05)
ElseIf usage > 300 Then
GetCost = 99.5 + ((usage - 300) * 0.1)
ElseIf usage > 150 Then
GetCost = 62 + ((usage - 150) * 0.25)
Else
GetCost = 2 + (usage * 0.4)
End If
End Function
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "vba, excel, if statement, excel 2010"
}
|
Simplest way to get the first n elements of an iterator
How can I get the first _n_ elements of an iterator (generator) in the simplest way? Is there something simpler than, e. g.
def firstN(iterator, n):
for i in range(n):
yield iterator.next()
print list(firstN(it, 3))
I can't think of a nicer way, but maybe there is? Maybe a functional form?
|
Use `itertools.islice()`:
from itertools import islice
print(list(islice(it, 3)))
This will yield the next 3 elements from `it`, then stop.
|
stackexchange-stackoverflow
|
{
"answer_score": 15,
"question_score": 7,
"tags": "python, iterator, generator"
}
|
Finding a particular non real value
I'm trying to give a counter example in an argument I am making, and it boils down to showing that for any nonzero $\alpha\in\mathbb{C}$ and for any $N\in\mathbb{Z}$, there are points $z\in S^1$ so that
$$\alpha z^N - i\alpha z^{N-1}\notin\mathbb{R}$$
I'm sure there's a slick argument by way of contradiction with some complex analysis, but I was hoping for a solution in terms of $\alpha$ and $N$
|
Alt.hint: by homogeneity in $\,\alpha\,$, it is enough to prove the proposition for $\,|\alpha|=1\,$.
* If $\,n=1\,$ then (at least) one of $\,z=1\,$ or $\,z=-1\,$ must satisfy $\,\alpha(z-i) \not\in\mathbb{R}\,$.
* Otherwise, if $\,\alpha \in \\{\pm1, \pm i\\}\,$ then $\,z=1\,$ satisfies $\,\alpha - i\alpha \not\in \mathbb{R}\,$.
* Otherwise, any of the $\,n-1\,$ solutions to $\,z^{n-1} = \overline \alpha\,$ satisfies: $$\alpha z^n - i\alpha z^{n-1}=|\alpha|^2 z - i|\alpha|^2 = z-i$$ Since $\,|z|=1\,$ it follows that $\,\operatorname{Im}(z) = i \iff z=i\,$, but that gives $\,\overline \alpha = i^{n-1} \in \\{\pm1, \pm i\\}\,$, which has been handled separately at the previous step. Therefore $\,\operatorname{Im}(z) \ne i\,$, so $\,z-i \not\in\mathbb{R}\,$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "complex analysis"
}
|
Let $f$ have a zero at $z_0$ of multiplicity $k$. Show that the residue of $\frac{f'}{f}$ at $z_0$ is $k$.
Let $f$ have a zero at $z_0$ of multiplicity $k$. Show that the residue of $\frac{f'}{f}$ at $z_0$ is $k$.
I tried approaching it by saying that $h(z) = \frac{f'}{f}$ has a simple pole because $f'$ has zero of order $k-1$ and $f$ has zero of order $k$ but I don't know if that is the correct strategy to calculate residue.
Any help will be appreciated.
|
**Hint:** $$f(z)=(z-z_0)^kg(z)$$ where $g$ is analytic and $g(z_0)\ne0$. Now calculate $f'/f$ explicitly.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 3,
"tags": "complex analysis"
}
|
How to load two times the same updated csv with d3
Is it possible to load the same csv twice with d3?
I have a flask server which updates a csv file every 10 seconds. I would like to reload the graph of the data every 10 seconds.
I used `setInterval` and inside I reuse
d3.csv("static/data.csv", function(error, data) {...
But when I print the data variable I always get the same graph, as if the csv didn't change.
When I refresh the page it takes the new data and there is no problem.
|
This is a result of browser caching. The easiest workaround is appending a random number, or the datetime stamp to the end of the url.
See this answer: Prevent browser caching of jQuery AJAX call result
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, python, csv, d3.js, flask"
}
|
JS using OR in string split
I have CSV with dates in format DD-MM-YYYY but sometimes I work in Excel and it changes the dates to format DD/MM/YYYY
Code example
var dateParts = value['TAX_CALCULATION_DATE'].split("/"); //id date has "-" or "/"
var dateObject = new Date(+dateParts[2], dateParts[1] - 1, +dateParts[0]);
firestoreObject.TAX_CALCULATION_DATE = firebase.firestore.Timestamp.fromDate(dateObject);
How to include "/" and "-" in one split?
|
You can use regex in split;
// Matches / or -
const regex = /\/|-/g;
yourDate.split(regex);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "javascript, date, split"
}
|
ADODB : Monetary format (number formatting for Euro)
I display the results of my sql ADODB as :
ActiveSheet.Cells(xlRow, Range("Colonne_10").Column).Value = RECSET2("Ecart").Value
ActiveSheet.Cells(xlRow, Range("Colonne_11").Column).Value = RECSET2("MT_BRUT").Value
Do you know, please, how to apply the monetary format ?
|
 from the dropdown and click OK.
Alternatively, you could do `NumberFormat = "_ * #,##0.00_) [$€-1]_ ;_ * (#,##0.00) [$€-1]_ ;_ * "-"??_) [$€-1]_ ;_ @_ "`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "excel, vba, adodb"
}
|
What am I lacking?
> Let $f$ be a continuous function on $X$. Let $E$ be any dense subset of $X$. Show that $f(E)$ is dense in $f(X)$.
Below, I have given my solution to the problem. However, I am not satisfied with my solution and feel something important is missing. Any hint is appreciated
solution:- since $E$ is dense in $X$, for any $\epsilon >0$ and $x$ $\in$ $X$ ,$ \exists s\in E $ such that $ 0<|x-s|<\delta $.$f$ is continuous in $X$ so for any $\epsilon >0$, we have $|f(x)-f(s)|< \epsilon $ whenever $|x-s|< \delta$. Then we see for any $\epsilon >0 $ and $f(x) \in X$, we find $f(s) \in f(E).$ This shows $f(E)$ is dense in $f(E)$
|
The first sentence of the solution makes no sense, since it ends with $\delta$, but you don't say what $\delta$ is.
Let $x\in X$ and ket $\varepsilon>0$. Since $f$ is continuous at $x$, there is a $\delta>0$ such that $\lvert y-x\rvert<\delta\implies\bigl\lvert f(y)-f(x)\bigr\rvert<\varepsilon$. And, since $E$ is dense in $X$, there is a $z\in E$ such that $\lvert z-x\rvert<\delta$. But then $\bigl\lvert f(z)-f(x)\bigr\rvert<\varepsilon$ and $f(z)\in f(E)$. So, every neighborood of any element of $f(X)$ contains an element of $f(E)$. In other words, $f(E)$ is dense in $f(X)$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "real analysis, solution verification"
}
|
exception with Linq to SQL using sdf file
I've set up a project with an SDF local database file and am trying to access it using an LINQ To SQL (".dbml") file. I have used the connection string provided by the sdf file and can instanciate the object with out a problem:
thisDataContext = new MyDataContext(GetConnectionString());
However, whenever i try to access any information from it eg
var collection = (from MyObject p in thisDataContext.MyTable select p);
I get the error -
"The table name is not valid. [ Token line number (if known) = 2,Token line offset (if known) = 14,Table name = Person ]"
I am using Visual Studio 2008 SP1 .Net 3.5 and SQL 2008 CE.
I gather something similar happened for SQL 2005 CE and a Hotfix was released, but i would have thought the fix would have been fixed in this version before release.
Does anyone know the fix for this?
Thanks
|
Get rid of the "dbo" in the Table attributes on the objects created by Linq to Sql
e.g.:
[Table(Name="dbo.Orders")]
class Order
{
}
Change that to:
[Table(Name="Orders")]
class Order
{
}
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 4,
"tags": "c#, .net, sql, database, sql server ce"
}
|
Schema (XSD) for Microsoft .NET configuration file
I'm searching the XSD (XML Schema) for the Microsoft .NET application configuration files. Till now I found only this: Configuration File Schema for the .NET Framework but I'm more interested in the XSD.
Or - asked in general - I search also XSDs in general for .NET configuration files listed here.
I've Visual Studio 2008 and don't see such files as in the first answer...
|
DotNetConfig.xsd updated by Peter Ritchie based on `C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas\DotNetConfig.xsd`. See Schema Cache.
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 7,
"tags": ".net, configuration files, msdn"
}
|
Keep track of where lookup items were used
I have a custom list A that has a lookup field for items in a custom list B, is there a way to know where a list B item was used in the list A?
edit:
I'll try to give an example, say A is a list of stores and B is a list of products. I have a lookup column on list A that references the products on list B (which products does this store sell) and my question is: If i have a product (item from B), can i know which stores sell it (which items in A reference in their lookup column the item from B)?
.
* List Settings > at Below of page > Click create a View.
* Set its name.
* Select the column that you need to show.
* At `Group by` section select the Lookup field from Products (B)
* Also, at `Totals` select it to show count beside each product.
This should list all items at store list (A) grouped by all Products at (B) with its count.
|
stackexchange-sharepoint
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sharepoint online, custom list, lookup column"
}
|
Remix IDE File Explorers is missing
I have no idea what happened, but all of a sudden, the file explorers in remix ide is gone. I tried all I can to recover it, including restarting it, switching back and forth between new and old versions, reinstalling it and rebooting the pc. None of these worked. I'm wondering why this is happening and how I can get it back! Thanks.
 initWithObjectAtIndex: (NSUInteger) index inArray: (NSArray *) objects;
@end
@implementation DetailViewController
- (id) initWithObjectAtIndex: (NSUInteger) index inArray: (NSArray *) objects
{
self = [super initWithNibName:nil bundle:nil];
if ( self ) {
allObjects = [objects copy];
displayedObjectIndex = index;
}
return self;
}
@end
That way, a DetailViewController always knows both what object it is displaying details for and the previous/next objects, if any.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "objective c"
}
|
Is it good practice to create an inner class for simple functionality?
There are some different opinions about simple inner classes, so I was wondering if there is a general consensus on what is good, and when to use private inner classes.
Here's an example that I found, and for which I think it's unnecessary to create an inner class. How good/bad practice is this?
private static class InternalCounter {
int count;
public InternalTabManager() {
count = 0;
}
public int increment() {
return count++;
}
}
Mind you that in this particular case, one instance is kept in the surrounding class to keep track of a count.
|
Yeah, in this case it does seem very unnecessary but if you have a case where there is some significant functionality and you know that no other class will ever need your inner class and it makes no sense to create a class more globally available then do use an inner class.
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 7,
"tags": "java, inner classes"
}
|
Flask + python + jinja2: how can I partialy replace template arguments with html code?
I have a function to automatically replace issue IDs to links:
def addlinks(text):
from flask import Markup
idlist = getallissueids()
for issueid in idlist:
text = text.replace( issueid, "<a href=/browse/" + issueid +">" + issueid + "</a>")
return Markup(text)
Then {{text}} is passed to template.
It works, but there is a side effect - all kind of html is unescaped in text after this. Is there any way to avoid html escaping only for the link?
|
That's the workaroung I found during this night:
def addlinks(text):
from flask import Markup
idlist = getallissueids()
for issueid in idlist:
parts = text.split(issueid)
text = Markup("<a href=/browse/" + issueid +">" + issueid + "</a>").join(parts)
return text
Could you please explain how could I do the same thing using this "safe" feature?
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "python, html, flask, jinja2"
}
|
Best way to make a C++ software package and C# package access same enumeration/constant ints
I am developing a software package that transmits messages. Currently I have a header file that contains definition of message IDs. My coworker is creating a software tool in C# and needs access to these IDs. What is the best way for our software to access these IDs?
More details: He and I don't have control over what language we use. He wants to make 2 copies of the same list. I am always hesitant to make copies of the same code. (There will be a lot of message IDs). Is there an easy way for both these tools to access the same ID?
|
C++/CLI is your friend. I had the exact same scenario in one of my projects and I found C++/CLI very usefull in this respect. My design was based on 3 layers:
C#
_______
C++/CLI
_______
C++
This way, I could easily **reuse** my C++ definitions without **any duplications**
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "c#, c++, header files"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.