INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Android ListFragmentIssue
I got a FragmentActivity with 2 ListFragments, Every time I swype beteen them, a layout progress begins and causes getView on the adapter for all visible items. How can I avoid this behavior?
I got 7 visible items in my list, and getView occuers too many times... (400 times when app starts)
Any suggestions? | If you maintain someone else code and he is using ListFragment Make sure he didn't override the onCreateViewRoot method!!! | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "android"
} |
Index of an Operator
I've been working through the heat-equation proof of the Atiyah-Singer index theorem. My question is what is the motivation for the definition of the index of an operator? I know there is the isomorphism between the homotopy classes of maps from a compact topological space to the space of Fredholm operators and the first K-group of the topological space given by the index map, but is there a simpler example of why we want to study the index? | Usually one really wants to know the dimension of the kernel of an operator rather than its index. The problem is that the dimension of the kernel is not a continuous function of the operator, so is very hard to compute in terms of topological data. The key point about the index is that it is a continuous function of the operator, which makes it a lot easier to compute. And it's a modification of the kernel, so with some luck one can compute the kernel from it. | stackexchange-mathoverflow_net_7z | {
"answer_score": 16,
"question_score": 7,
"tags": "dg.differential geometry, fa.functional analysis"
} |
Can't access elements in array using key
I'm trying to get a list of all pages on a wordpress site and access their ID. I can get a list of pages using the get_pages() function. When I try to access any of the elements with their keys, it doesn't interpret.
For example, the following code wouldn't work:
$pages = get_pages();
foreach ($pages as $page) {
$ID = $page['ID'];
}
But, if I do this:
$pages = get_pages();
foreach($pages as $page) {
foreach ($page as $key => $value) {
echo("<p>$key</p>");
}
}
It clearly prints out ID as a valid key.
What am I doing wrong? | When you do this
$pages = get_pages();
foreach($pages as $page) {
foreach ($page as $key => $value) {
echo("<p>$key</p>");
}
}
So the above $pages becomes associated array, and you can access key with associative array. Associated arrays are used in php for KEY VALUE PAIR
So you can use
$pages = get_pages();
foreach ( $pages as $page ) {
echo $page->ID;
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "php, wordpress"
} |
Check if string variations exists in another string
I need to check if a partial name matches full name. For example:
Partial_Name | Full_Name
--------------------------------------
John,Smith | Smith William John
Eglid,Timothy | Timothy M Eglid
I have no clue how to approach this type of matching.
Another thing is that name and last name may come in the wrong order, making it harder.
I could do something like this, but this only works if names are in the same order and 100% match
`decode(LOWER(REGEXP_REPLACE(Partial_Name,'[^a-zA-Z'']','')), LOWER(REGEXP_REPLACE(Full_Name,'[^a-zA-Z'']','')), 'Same', 'Different')` | This is what I ended up doing... Not sure if this is the best approach. I split partials by comma and check if first name present in full name and last name present in full name. If both are present then match.
CASE
WHEN
instr(trim(lower(Full_Name)),
trim(lower(REGEXP_SUBSTR(Partial_Name, '[^,]+', 1, 1)))) > 0
AND
instr(trim(lower(Full_Name)),
trim(lower(REGEXP_SUBSTR(Partial_Name, '[^,]+', 1, 2)))) > 0
THEN 'Y'
ELSE 'N'
END AS MATCHING_NAMES | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "sql, regex, oracle"
} |
ETA for Expo-payments-stripe for managed workflow
Does anyone know what the ETA (expected time of release) of the Expo-payment-stripe for managed workflow? This information helps in project planning and using the right solutions for our product. Thank you! | I work on Expo. It will take at least a few more months, and possibly longer, for us to integrate Stripe into the managed workflow, as is.
The reason for this is that Apple will sometimes reject apps if they have any Stripe code in them but aren't collecting payments, and right now, all managed workflow apps have the same binary code.
For now, the bare workflow is the best way to integrate Stripe and other payments solutions. In the medium term, we are working on ways to give you the best of both worlds. And eventually, we'll probably be able to put it into something that looks like the managed workflow.
I'm sorry we don't have a better solution for you already. This is one of the most requested features and we are working on stuff now that will give you more options to solve it in good ways. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "react native, expo"
} |
Thread safe and concurrent use, multiple instances?
Looking at `com.ui4j.api.browser.BrowserFactory` it appears as if the `getBrowser` method can only return one instance, as is also documented.
This is quite problematic for anyone trying to write some sort of multi threaded crawler, as there will only exists one browser at all times. There is no way to create a new tab on the browser, so you can only navigate one page at a time which is likely queued up in an list.
Do I really have to resort to having to copy and paste and rewrite the entire BrowserFactory class to get another instance, or is there a way to navigate multiple pages and parse out content concurrently?
Or is this a complete miss? As it stands now, the library is probably only suitable for test purposes. Threaded context is a neccessity in any production system.
Ofcourse I can copy and paste the code but is there another way? | BrowserFactory creates a singleton instance of BrowserEngine. BrowserEngine could create more than one page/tab. If you are trying to crawl a site you should review this example. The example create a thread pool with pool size 2. This means that browser could run 2 pages together. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "java, multithreading, ui4j"
} |
What is the best method of getting objects from a class that belong to the current user
I'm just starting out with Parse (REST API) and would like to know the best method of getting private objects from a class that belong to the current user. As far as I see it, there are two options:
1/ Pass the user id in the query string - I thought this was bad practise though.
2/ Each object would have an ACL set - could I just hit the class endpoint and let the ACL's take care of things and just return the objects that belong to the user?
Thanks. | You potentially could just let the ACL handle things, using the user's session token. This requires public find access to be disabled, though.
It's also not ideal, as it can not utilize database indexes. Your database is going to find all objects that match your query and parse-server will filter out the ones that don't pass a CLP / ACL check. At scale, this could damage performance significantly. Do objects only belong to a single user? Consider storing the user's ID on the object, then you can query for all objects that match that ID, and you can index your database by that id for fast results. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "parse platform, parse server"
} |
URL Rewrite in htaccess not working
i have a url www.example.com/mybooks/list.php?id=novel-15 now i want to rewrite this url as www.example.com/mybooks/novel-15 for this i have the following code in .htaccess file
<Files ~ "\.log$">
Order allow,deny
Deny from all
</Files>
RewriteEngine on
RewriteRule ^mybooks/([A-Za-z0-9-]+)/?$ mybooks/list.php?id=?id=$1 [NC,L]
but this is not working. anybody give me a good solution... | Try this rule in your `/mybooks/.htaccess`:
RewriteEngine on
RewriteBase /mybooks/
RewriteCond %{THE_REQUEST} /list\.php\?id=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/?$ list.php?id=$1 [L,QSA] | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "apache, .htaccess, mod rewrite, url rewriting"
} |
Voting down because idea in the question is wrong?
What is wrong with this question? (Basically question is "should I use approach A or B" where there is another better option not mentioned in the post, but shown in answer).
It got -4 votes quickly but I don't really see anything particularly bad with the question - have good title, clear sample code, definitely not "useful just for me", does not look immediate duplicate.
My guess people think both options suggested in the question were bad and down-vote based on that - would it be valid reason for SO? Or maybe I'm missing something and should have voted down too?
What would make such question not to attract down-votes?
EDIT: note that there were no close votes that seem to rule out "question is opinion based" voting, which makes voting reasons interesting for me. | Disclaimer: you're free to use your votes however you like, so long as you're not actively committing vote fraud (excessive votes for any one person, up or down).
> What would make such question not to attract down-votes?
This question isn't going to be able to not attract downvotes, since it's extremely subjective and not one of the questions we want to tout as a "good" sample of what to ask. For instance, what one person's helper class may hold is different than what mine may hold. There's no canonical, reasonable answer to this.
_If_ the question could be salvaged to be less broad/subjective, then _maybe_ it wouldn't be hit with such downvotes. But that's a pretty slim if for questions of this caliber. | stackexchange-meta_stackoverflow | {
"answer_score": 8,
"question_score": 16,
"tags": "discussion, downvotes"
} |
convert language of a div
I am recently working in a project. There I need to convert language from English to Japanese by button click event. The text is in a div. Like this:
"<div id="sampletext"> here is the text </div>"
"<div id="normaltext"> here is the text </div>"
The text is come from database. How can I convert this text easily? | A combination of AJAX and JQuery should do the trick.
* AJAX - Go to the database and get the relevant text string
* JQuery - Change the text in the div, identifying it by class. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "php"
} |
Describe the structure of the ring $(ℤ/2ℤ)[α]$.
Let $R = (ℤ/2ℤ)[α]$ for $α$ satisfying $α^2 + α + 1 = 0.$ Describe the structure of this ring.
I have gotten as far as saying that this can be considered the quotient ring $(ℤ/2ℤ)[x]/(x^2+x+1)$ but I'm pretty stumped on where to go from there. Any help would be appreciated. | You can start by interpreting $R$ as a vector space. Your restriction $\alpha^2+\alpha+1=0$ gives a hint that any power of $\alpha$ larger than or equal to $2$ can be written as a linear combination of $\alpha$ and $1$.
Thus, this ring, additively, is isomorphic to the vector space $(\mathbb{Z}/2\mathbb{Z})^2$.
For the multiplicative part, you can figure out by writing down the multiplicative table. Since there is only 4 elements in the ring, I think that is rather easy.
Hope I helped. If you need extra help on the multiplicative part, I can write down that part for you.
Thanks for Tobias's comment. I have not reached a rep of 50 so I cannot reply, but changing $\alpha^k$ to $R$ is definitely necessary. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "abstract algebra, polynomials, ring theory"
} |
Unpivot pairs of associated columns to rows
I have a table with staggered article prices like this:
ArtNr Amount1 Price1 Amount2 Price2 Amount3 Price3
--------------------------------------------------------------
4711 1 3.5 5 3.0 10 2.5
4712 1 5.0 3 4.5 5 4.0
4713 1 7.0 10 6.0 100 5.0
I want to transpose that into this structure:
ArtNr Amount Price
----------------------
4711 1 3.5
4711 5 3.0
4711 10 2.5
4712 1 5.0
4712 3 4.5
4712 5 4.0
...
Can this be done with PIVOT/UNPIVOT in T-SQL, or do I have to use UNION? | `CROSS APPLY (VALUES` is the easiest way to unpivot usually, especially with multiple columns
SELECT
t.ArtNr,
v.Amount,
v.Price
FROM YourTable t
CROSS APPLY (VALUES
(Amount1, Price1),
(Amount2, Price2),
(Amount3, Price3)
) v(Amount, Price)
> Some more tricks you can do with `CROSS APPLY` | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "sql, sql server, pivot, transpose, unpivot"
} |
Delayed indexing in postgres
We have a system which stores data in a postgres database. In some cases, the size of the database has grown to several GBs.
When this system is upgraded, the data in the said database is backed up, and finally it's restored in the database. Owing to the huge amounts of data, the indexing takes a long time to complete (~30 minutes) during restoration, thereby delaying the upgrade process.
Is there a way where the data copy and indexing can be split into two steps, where the data is copied first to complete the upgrade, followed by indexing which can be done at a later time in the background?
Thanks! | There's no built-in way to do it with `pg_dump` and `pg_restore`. But `pg_restore`'s `-j` option helps a lot.
There is `CREATE INDEX CONCURRENTLY`. But `pg_restore` doesn't use it.
It would be quite nice to be able to restore everything except secondary indexes not depended on by FK constraints. Then restore those as a separate phase using `CREATE INDEX CONCURRENTLY`. But no such support currently exists, you'd have to write it yourself.
You can, however, filter the table-of-contents used by `pg_restore`, so you could possibly do some hacky scripting to do the needed work. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 5,
"tags": "postgresql"
} |
Titlepage: text left of picture
I tried to get a titlepage similar to the one in the picture, which I made with MS Word.
The problem is that I can't put the text on the left of the profile-picture in the way it is in the eaxmple-picture. I tried it with "wrapfigure", but I didn't manage to put the "name" at the bottom (left) of the profile-picture and all the other text on the bottom of the picture. Is this even possible?
Thanks for your help.
best reagrds
;
background-repeat: no-repeat;
background-position: center;
max-height: 90%;
max-width: 90%;
}
Thanks for your help.
ps: I used google but can't find something useful. I know somewhere out there it would be, but I have to less time to search 2 hours. | If you want the background image not to be cropped and always fit in the container, you can use `background-size: contain;` _(more info on MDN)_.
You also need to change the `max-width/max-height` to `height/width` otherwise your element will have 0 height/width as it doesn't contain anything :
.camera {
position:absolute;
background-image: url(../img/svg-bild.svg);
background-repeat: no-repeat;
background-position: center;
background-size:contain; /** add this **/
height: 90%; /** change this **/
width: 90%; /** change this **/
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "html, css, image, svg, width"
} |
Enumerating Lattice points
Let $A \in \mathbb{R}^{d\times d}$ be an invertible matrix. Consider the set $$P_d := A\mathbb{Z}^d = \\{A x| x \in \mathbb{Z}^d \\} \subset \mathbb{R}^d$$. and $$ Q_d := [-1,1]^d.$$
I am interest in enumerating (not just counting) all the points in $$Q_d \cap P_d.$$
Unfortunately I am not familiar with discrete mathematics/optimization and related subjects. Hence I would appreciate pointers to established methods/algorithms and literature, that are suited to tackle this problem.
Thank you. | Let $B = \left({A\atop -A}\right)$ be a matrix, whose rows are formed by the rows of matrices $A$ and $-A$. Then $$C = \\{ x\in\mathbb{R}^d \mid Bx \leq u \\},$$ where $u=(\underbrace{1,1,\dots,1}_{2d})^T$, is a convex polyhedron. Furthermore, $$Q_d \cap P_d = \\{ Ax \mid x\in C\cap \mathbb{Z}^d \\}$$ and thus the problem is reduced to enumerating the integral points in the polyhedron $C$.
There is a readily available software called LattE for lattice point enumeration, which can find the integral points of $C$ in the form of multivariate generating function (with the command "count --multivariate-generating-function"). While it requires elements of the matrix be integer, it is not hard to achieve that by taking an appropriate rational approximations and multiplying $Bx\leq u$ by an integer constant to make all entries integer.
See LattE documentation for further references and examples. | stackexchange-mathoverflow_net_7z | {
"answer_score": 3,
"question_score": 1,
"tags": "co.combinatorics, discrete geometry, discrete mathematics"
} |
Time spends in CPU faster than in reality
I am wondering why my entire application runs in less than `8 seconds` while the time obtained from `clock_gettime` is `19.3468 seconds` which is more than two times as much as what happens in reality. Where is the problem from?
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time_start);
... // many calculations
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time_stop);
double time_diff=(time_stop.tv_sec-time_start.tv_sec+
(1e-9)*(time_stop.tv_nsec-time_start.tv_nsec);
* * *
**Update:**
I am not using any OpenMP explicitly. | **CLOCK_MONOTONIC** should be used if you want to measure total elapsed time, including time spent blocked waiting for IO, but it will also include slowdowns caused by other processes getting scheduled while your program is trying to run. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "c++, linux, gcc, cpu, ctime"
} |
Facebook API : Can we know the number of likes, posts, shares, comments individually?
Can we know per daily basis through the Facebook API the number of likes, the number comments, the number of shares on our posts and the number of posts made by users to ourg page? Not a sum of all these but each one separately. | You can use FQL to query the insights data for your app or page. See documentation and list of available metrics.
`page_fan_adds` will give you the new fans per day, for a page (`application_like_adds` for apps). `page_like_adds`, `page_comments_adds` and `page_wall_posts` are deprecated, so you will have to look for some other metric to replace this info. `page_stories` maybe?
Alternatively you can use the Graph API.
| stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "facebook, facebook graph api"
} |
finding value of indefinite integration of $\frac{y^7-y^5+y^3-y}{y^{10}+1}dy$
finding value of indefinite integration $\displaystyle \int\frac{y^7-y^5+y^3-y}{y^{10}+1}dy$
$\displaystyle \int\frac{y^5(y^2-1)+y(y^2-1)}{y^{10}+1}dy = \int\frac{(y^5+y)(y^2-1)}{y^{10}+1}dy = \int\frac{(y^5+y)(y^2+1-2)}{y^{10}+1}dy$
$\displaystyle =\int\frac{y^5+y}{y^8-y^6+y^4-y^2+1}-2\int\frac{y^5+y}{y^{10}+1}dy$
i wan,t be able to proceed after that, could some help me with this | **Hint** : We can write our integral as, $$I = \int \frac{y^7-y^5+y^3-y}{y^{10}+1} dy = \int \frac{y(y^6-y^4 + y^2-1)}{y^{10}+1} dy = \int \frac{y(y^6-y^4+y^2-1)}{(y^2+1)(y^8-y^6+y^4-y^2+1)} dy$$ We can use partial fractions and get $$I = \frac{1}{5}\int \frac{4y^7-3y^5 +2y^3-y}{y^8-y^6+y^4-y^2+1} dy -\frac{4}{5} \int \frac{y}{y^2+1} dy =I_1-I_2$$ I hope you can take it from here. | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "indefinite integrals"
} |
multisite or multi install?
I am planning a Drupal 7 site for video sharing, where registered users can share videos.
Main Site: example.com
Subdomain for blog for registered users would be: blog.example.com.
The database would be different for main site and subdomain. Since the target of main site would be very high traffic, what would be the efficient choice ? either Multisite or Multiple Drupal installation (one installation for Main and another installation for blog) ?
what would you advice and why ? (I mean from personal experience, difficulty to handle and maintain, performance issues, etc) | Your choice of site architecture (e.g. multisite or multiple drupal installations) doesn't necessarily play into performance. Meaning any site can be made performant using the right mix of modules (memcache, Varnish on the front end, etc.);
With that in mind, look at the following criteria when selecting multisite over multi-installation instead:
* Will most of the modules on the sites be shared with one another?
* Related, will the modules always be in sync via version? i.e. Context 3 vs. Context 2.
* Will the versions need to be in sync? i.e. If you upgrade the main site, will the blog site also need to be upgraded?
If the answer to any of these questions is yes, use a multisite. If there is concern about them, use two document roots with one site a piece. Sharing content can easily be done through any of the following projects so multisite or multi-installation doesn't matter:
* <
* <
* < | stackexchange-drupal | {
"answer_score": 2,
"question_score": 0,
"tags": "7, multi sites"
} |
What is the range of a melee attack?
What is the range, in yards, in which you can perform a melee attack? Not including, of course, stuff like Deadly Reach.
(it is my understanding that weapon type does not matter) | I am almost certain the range is 8 yards. I remember reading this somewhere, and upon testing this and comparing the range of melee to that of skills with know range, I found it to be accurate. I further compared it to the image in the post referred to by the question, and found that my test results matched the 8 yard mark on that image very closely. | stackexchange-gaming | {
"answer_score": 1,
"question_score": 1,
"tags": "diablo 3"
} |
Matching anything but a letter - regex
How to match anything BUT a letter? i thought `[^a-z]+` will do but not really.
I have this string to search in:
"price":"7.99","opt":{"1":[1.01,1.02]},"mixedId":0,"price":"8.99","opt":{"3":[1.03],"4":[1.04,1.05]}
I want to get these values `8.99` and `1.04,1.05` but it can't match `7.99`
I did like this:
'"price":"(.+?)","opt":\{"[^a-z]*"4":\[(.+?)]'
but it finds nothing. Need some support :) | Your fixed RegEx should look something like this:
`"price":"([\d\.]+?)","opt":\{"[^a-z]*"4":\[(.+?)\]`
Live demo here: < | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "python, regex, python 2.7"
} |
Is the satyr's Mirthful Leaps trait affected by jump multipliers?
In the new sourcebook _Mythic Odysseys of Theros_ (p. 25), the new Satyr race has the Mirthful Leaps trait:
> Whenever you make a long or high jump, you can roll a d8 and add the number rolled to the number of feet you cover, even when making a standing jump. This extra distance costs movement as normal.
If you have a multiplier on jump distance, such as that provided by the _Boots of Striding and Springing_...
> In addition, you can jump three times the normal distance, though you can't jump farther than your remaining movement would allow.
... would the +1d8 feet from Mirthful Leaps be multiplied by 3 as well? | ### Boots of Striding and Springing triple your unmodified jump distance.
I would make the argument that when Boots of Striding and Springing says
> you can jump three times the **normal** distance,
this is referring to your unmodified (normal) jump distance, to which you may then add modifiers.
I believe if the Boots multiplied the modifiers as well, it would read similar to the _Jump_ spell:
> the creature's jump distance is tripled
_Jump_ triples your jump distance for its duration, modifiers included; if it was intended to triple your distance without first accounting for modifiers it would read as the Boots do, using the word "normal". | stackexchange-rpg | {
"answer_score": 18,
"question_score": 15,
"tags": "dnd 5e, movement, racial traits"
} |
How can I change InfoBox content?
I have this code :
var infoWindowOptions = {
content: "content",
... some other options ...
};
var infowindow = new InfoBox(infoWindowOptions);
infowindow.open(map, marker);
and it works without problems. Now, I'd like to change content, so I've done :
infowindow.content = "new content";
infowindow.open(map, marker);
but it doesnt change! Why? And how can I fix it? | infoWindow.setContent("new content");
DOM elements are also accepted. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "google maps, google maps api 3"
} |
ASP .NET Core Where to store application custom settings
For example, i have an entity called InventorySettings and at the moment i am using a table in SQL to store these settings using single row approach but i would like to know if is there a more productive way for storing this type of data without having to create a table in my database just for a single row and having to query it all the time | There are **multiple ways** to store custom settings.
1. If you want to change it on run-time then storing it in database is the best option.( **BEST WAY** )
2. If you dont want to change it on run-time then store them in appsetting ( **GOOD WAY** )
3. If you want to change it on run-time and dont want to store in database then you can store then in files.You also can make user wise files and store and modify them. ( **Not Recommended** ) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "asp.net core"
} |
Where can I have my work reviewed?
I'm new to graphic design coming from a software development background. In this area, I can easily have feedback about my work by open-sourcing my code, participate to existing open-source projects, or simply ask others what they think...
At a moment I envisaged to participate to crowd-sourcing design sites, but changed my mind as it seems finally to be a bad idea...
So, where could I find the best comments and advice about my graphic design work? | These two are probably the best places on the 'net to get feedback on your designs:
* Dribbble
* Deviant Art | stackexchange-graphicdesign | {
"answer_score": 3,
"question_score": 6,
"tags": "designers, portfolio"
} |
SKRequest didFailWithError
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
}
With in this method one could arrest the error that happened for ex - ("Failed to Connect to iTunes") etc. Now if one wants to show this error message as an alert it would be really helpful for users. Like one example is when the "Failed to Connect to iTunes" error is shown as an UIAlertView, it can lead the user to the problem that his wi-fi was off all this while. He can rectify this problem and retry. But before one chooses to display these errors as UIAlertView, one must know all the possible error values that are returned because a user won't be pleased to see something like "Error %^@)$()(!)#()+! code 123_123443 blah"i.e.something incomprehensible to him. How to best handle this ? As an after thought, it would be nice to know all the possible error messages of NSError thrown in this method.
Thanks in advance | > one must know all the possible error values that are returned because a user won't be pleased to see something like "Error %^@)$()(!)#()+! code 123_123443 blah"i.e.something incomprehensible to him
I don't know all the possible errors that particular method can return but I think it is safe enough to use the `localizedDescription` method of `NSError` to present the error to the user.
From Apple docs:
> Error objects in the Cocoa domain are always localized and ready to present to users, so they can often be presented without further evaluation. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "iphone, ios4, storekit, nserror"
} |
C String Pointers
why is it not possible for sscanf() to write the string into char* s? I initialised it to NULL as I do not want uninitialised variables.
#include <stdio.h>
#include <string.h>
int main()
{
char* t = "I am a monkey";
char *s = NULL;
sscanf(t, "%s",s);
printf("%s\n",s);
} | The line `char *s = NULL` creates a variable that holds the memory address of a character. Then it sets that memory address to zero (`NULL` is address zero).
Then the line `sscanf(t, "%s",s);` tries to write the contents of `t` to the string at the location `s`. This will segfault because your process cannot access address zero.
Your instincts were good to avoid uninitialized variables, but you traded this for unallocated pointers!
Fix this by allocating some space on the stack (or heap) for s by declaring:
char s[STRING_LENGTH];
Where `STRING_LENGTH` is `#defined` to be however many characters you want to allocate. This allocates a chunk of memory to hold the null-terminated character array and sets `s` to the address of the first character | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 3,
"tags": "c"
} |
Instantiating classes with params in singleton factory
I have a class that produces singleton classes. _(Note that this is overly simplified code for the purpose of this question, for example it doesn't check that the filepath exists)_
class Singleton
{
public function Load($classname, $params)
{
$filepath = 'classes/'.$classname.'.php';
require_once($filepath);
return $classname();
}
}
Now say that I wanted to pass an array of parameters that can vary in size to the constructor of the class being created. What is the best way to do this? I envision something along the lines of `call_user_func_array` but for classes? | You can achieve some interesting results with the use of PHP's Reflection library.
function Load( $class, $args )
{
$reflection = new ReflectionClass( $class );
$object = $reflection->newInstanceArgs( $args );
return $object;
}
This is simplified and implies use of the `__autoload` function, nor does it check for namespaces if you use them, plus it'll create a new instance of the class every time you call it, so you'll need to implement an array of objects to keep track of which ones you've created already, etc...
And for basic documentation: `$class` is a string with the name of the class you're wishing to instantiate, and `$args` is an array of arguments that you'll pass to the `__construct( )` method. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "php, singleton"
} |
JBoss POJO Object pooling
I am using a POJO (Non-EJB) class inside my JBoss server and creating multiple instances of it. Will JBoss create an object pool and manage this resource or will it simple create as many objects as I instantiate ? | Plain Old Java Objects are "unmanaged" the container has no way to know that when you say "new" you don't really mean "new".
EJBs have managed life cycles, are trivial to implement. If you want pooling why not use one? | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "jboss, ejb 3.0, pojo"
} |
How to cast string to number in angular template
I have a select box from which I am binding the selected value to `startingYear` variable. I want type of startingYear to be in number. But its always in string.
How can I cast it to number?
console.log(StartingYear);
<select [(ngModel)]="StartingYear">
<option *ngFor="let item of [0,1,2,3,4]; let i = index">
{{i}}
</option>
</select> | The `value` property would be a string by default, so use `ngValue` property to the option tag. Unlike the value binding, ngValue supports binding to objects.
<select [(ngModel)]="StartingYear">
<option *ngFor="let item of [0,1,2,3,4]; let i = index" [ngValue]="i">
{{i}}
</option>
</select> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "angular, typescript"
} |
Show that the value of the following definite integral is greater than 0.405
Given $F(0) = \frac{1}{\pi D} \int_{0}^{\frac{\pi}{D}} \frac{\sin^2[Dy]}{\sin^2[y]} dy$. Assume D is some constant.
Using the following properties prove: $F(0) \geq \frac{4}{\pi^2} > 0.405$
Properties:
1. $|\sin [x]| \leq |x| ~\forall x \in \mathrm{R}$,
2. $|\sin [x]| \geq |(\frac{2}{\pi})x| ~\forall x \in [0,\frac{\pi}{2}]$
3. $|\sin [x]| \geq |-(\frac{2}{\pi})x+2| ~\forall x \in [\frac{\pi}{2},\pi]$
I did not understand the following proof:  \approx 0.248$, which is weaker than what is claimed in the paper. However, you can use the following simpler argument to obtain a better lower bound: $$ \frac{1}{{\pi D}}\int_0^{\frac{\pi }{D}} {\frac{{\sin ^2 (Dy)}}{{\sin ^2 y}}dy} = \frac{1}{{\pi D^2 }}\int_0^\pi {\frac{{\sin ^2 t}}{{\sin ^2 (t/D)}}dt} \ge \frac{1}{{\pi D^2 }}\int_0^\pi {\frac{{\sin ^2 t}}{{(t/D)^2 }}dt} = \frac{1}{\pi }\int_0^\pi {\frac{{\sin ^2 t}}{{t^2 }}dt} \\\ = 0.4514116667 \ldots > \frac{4}{{\pi ^2 }} = 0.4052847345 \ldots > 0.405. $$ | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "calculus, integration, inequality, definite integrals, approximation"
} |
Will int32 be the same size on all platforms?
I'm developing a multi platform app (iOS, Android, etc), using C++.
Are there base types in the C++ standard which are guaranteed to be a fixed width, and portable across multiple platforms?
I'm looking for fixed-width types such as Int32, UInt32, Int16, UInt16, Float32, etc. | `int32` is a custom typedef, only `int` exists by default. If you need a specified width take a look at `stdint.h`
#include <cstdint>
int32_t integer32bits;
I don't think any floating point counterpart exists in the standard, correct me if I'm wrong. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "c++"
} |
Select2 bootstrap styling issue
I have below issues for my select2 box.
1) I want to change the background-color to white of previously selected item. For eg when you open the select box and then hover on the next item the previous selected item has a background-color grey, which i want to change to white.
2) After an item is selected from the dropdown there are two borders displayed, want to get rid of one border in grey color.
Fiddle -
 and the ErrorLog in a VirtualHost is limited to error messages specific to events regarding thatVirtualHost. (for instance a 404 error)
The second:
When Apache starts as root (to be able to bind to privileged ports 80 and 443) it can drop privileges and will subsequently run as the user defined in the User directive: Apache. Log files are opened at startup (before dropping privileges) and are therefore owned by the user starting Apache I.e. root. | stackexchange-serverfault | {
"answer_score": 0,
"question_score": 0,
"tags": "apache 2.4, centos7, log files, httpd.conf"
} |
Repeating a function in regular intervals
setInterval(function(){
setTimeout(function(){
$('#a').addClass('x');
},1000);
setTimeout(function(){
$('#a').removeClass('x');
},2000);
},4000);
I was trying to add the class "x" to the div "#a" after 1 s & remove the class after 2 s & repeat the entire function as a loop which executes every 3 s.But the loop worked only once as the time in the setTimeout function did not get incremented after 3 s .So can you help me to make this working. | you have incorrect syntax. also, this can be done without timeouts, just to give you a brief idea:
setInterval(function(){
$("#a").addClass("x").delay(1000).queue(function(next){
$(this).removeClass("x");
next();
});
},6000);
See it in a fiddle | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "javascript, jquery"
} |
Opening Bash on Windows on a specific folder
I started using bash on the Windows anniversary update and recently I tried to start an Android project but want to open the terminal on the project folder. I tried googling this but couldn't find any solutions that allowed for this through command line. | I didn't find a way to set a default folder so I just created a script that would cd into the right folder and ran that every time I opened bash | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "windows, bash"
} |
Why are extremely small masses expected to be in relativistic motion?
For example, neutrinos have an extremely small mass and are expected to be in relativistic motion. Why is that so? | The most common neutrino, here, now, is the solar neutrino. The spectrum is:
:
$$ \gamma_{\nu} =\frac E {m_{\nu}} \approx 5,000,000$$
which is squarely in the "ultra-relativistic" category.
In short: the nuclear transitions that produce neutrinos have energies that are much, much, greater than the neutrino mass.
Also: since they are weakly interacting, they don't thermalize with their surroundings, expect perhaps in extreme cases (high density) like core collapse supernovae and the Big Bang. | stackexchange-physics | {
"answer_score": 4,
"question_score": 2,
"tags": "special relativity, kinematics, momentum, mass, estimation"
} |
How to put images at exact location dynamically
I saw this somewhere and was wondering how to achieve this. suppose i have a shelf background !Like this one
and i have cover images of books. how can i put those images exactly on each wodden plates edges dynamically.Number of books are not fixed they might go beyond the capacity of shelf then shelf will also grow. Each level of shelf contains maximum 3 cover images of book.
can i do this on background or do i need to draw a shelf on canvas or something else?? | Once I tried this kind of UI , There might be several approach , My approach was ,
I had a list view with background as 3D shelf , not like the one which you have shown which has white color wall and other things. Background(3D shelf) which I used to fit entire screen , and space each row of list item exactly to the row of 3D shelf and in list items have 3 buttons with horizontal orientation.
There is already an app called Shelves , Check UI there , it is open source , code there might help you better
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "android, android layout"
} |
Function name must be a string php?
After few hours of googling and searching for answer, i gave up and got very frustrated with php, no support out there on basic errors. Anyway, here is my function, what am I doing wrong?
$accessToken = function(){
$array = array(
"foo" => "bar",
"bar" => "foo"
);
$obj = json_encode($array);
$obj = json_decode($obj);
return $obj->foo;
};
$getInfo = function(){
$code = $accessToken();
return $code;
};
$getInfo();
I get error
> Notice: Undefined variable: accessToken in C:\inetpub\wwwroot\mysite\lab\cfhttp.php on line 43
>
> Fatal error: Function name must be a string in C:\inetpub\wwwroot\mysite\lab\cfhttp.php on line 43 | `$accessToken` isnt in scope inside `$getInfo()`
$accessToken = function(){
$array = array(
"foo" => "bar",
"bar" => "foo"
);
$obj = json_encode($array);
$obj = json_decode($obj);
return $obj->foo;
};
$getInfo = function($accessTokenFunction){
$code = $accessTokenFunction();
return $code;
};
$getInfo($accessToken); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "php, scope"
} |
Override tab behavior in WinForms
I have a UserControl that consists of three TextBoxes. On a form I can have one or more or my UserControl. I want to implement my own tab behavior so if the user presses Tab in the second TextBox I should only move to the third TextBox if the the second TextBox has anything entered. If nothing is entered in the second TextBox the next control of the form should get focus as per the normal tab behavior. If the user hasn't entered anything in the first or second TextBox and the presses tab there is this special case where a control on the form should be skipped.
By using the ProcessDialogKey I have managed to get it work kind of ok but I still have one problem. My question is if there is a way to detect how a WinForms control got focus since I would also like to know if the my UserControl got focus from a Tab or Shift-Tab and then do my weird stuff but if the user clicks the control I don't want to do anything special. | As a general rule, I would say overriding the standard behavior of the TAB key would be a bad idea. Maybe you can do something like disabling the 3rd text box until a valid entry is made in the 2nd text box.
_Now, having said this, I've also broken this rule at the request of the customer. We made the enter key function like the tab key, where the enter key would save the value in a text field, and advance the cursor to the next field._ | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 5,
"tags": "c#, .net, winforms"
} |
separating values in R
I am trying to separate values in R and I am stuck. Let's say I have this string
data <- data.frame(Variable = "2018 Hyundai Sonata VALUE Edition Limited 2.0")
Here's what I am looking for: "2018", "Hyundai", "Sonata", "VALUE Edition Limited 2.0"
Here's what I did:
library(tidyr)
fixed <- data %>%
separate(Variable, into = c("Year", "Make", "Model", "Trim"), sep = " ")
# Year Make Model Trim
# 1 2018 Hyundai Sonata VALUE
It works but cuts off after VALUE, is there a way leave the rest of the string as it is? | Never mind. THe answer is:
extra = "merge" | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "r, string, tidyverse"
} |
EXCEL 2010: INDEX/MATCH dropping cell formatting (Accounting & $$)
**Program:** Excel 2010
**Experience:** Basic
Issue:
I am using INDEX/MATCH
This is the original cell which resolves to:
1) 1.0692 (exchange rate)
2) 147.50 (exch * value)
3) $39.99 (prod cost)
4) Ex: 1.0692 SubT: 147.5046936
=INDEX(ssExchRate,MATCH(A33,ssRepDist,0))
=" SubT: " &INDEX(ssExchST4,MATCH(A33,ssRepDist,0))
=INDEX(ssUnitPr,MATCH(A33,ssRepDist,0))
="Ex: "&INDEX(ssExchRate,MATCH(A33,ssRepDist,0)) & " SubT: " &INDEX(ssExchST4,MATCH(A33,ssRepDist,0))
To be able to get $ or - (for discounts) I need to use:
="-$"&INDEX(ssBankAU,MATCH(A33,ssRepDist,0))
Is there a way for the formula to retain cell information, or do I have to hardcode it like my final example?
Cheers. | Take a look at the `TEXT` formula.
=TEXT(INDEX(ssBankAU,MATCH(A33,ssRepDist,0)),"-$#,##0.00) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "excel, excel formula, excel 2010"
} |
How to add Firebase auth onCreate listener in Admin Sdk
I want to run a listener in Firebase Admin SDK that runs whenever a new account is created. It is possible to do this in cloud functions as shown here: < Can the same be done in Firebase Admin SDK? | Nope. There is no `onCreate` listener in the Auth SDKs.
Since creating a user from the authentication SDK happens completely under control of your code, you're expect to handle any downstream actions in your own code once the user creation completes.
For example, in the documentation on creating a user with the Admin SDK for Node.js, you can put any code that needs to run after the user has been created in the `then()` callback. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "firebase, firebase authentication, firebase admin"
} |
Use variable in SPICE parameter list
I'm using LTSpice XVII to try and simulate a circuit.
I've created a schematic which uses a Pulse voltage source to simulate a rotary encoder as follows:  {
return (
<Child key={child}/>
);
},
render: function() {
return (
<div>
{Object.keys(hashObj).map(this.renderChild)}
</div>
);
}
But I've also got a variable I want to send along to this renderChild.
Would the best way to go about this is setting a state, or can I send a prop down through to the `this.renderChild` somehow through the map render?
Something along the lines of (which is wrong because I know it doesn't work): `{Object.keys(hashObj).map(this.renderChild, someVariable)}`
I would like to send it via a prop within the map, so I don't have to have a state to keep track of.
Was wondering if that is possible? | You can pass in an anonymous function that _calls_ `this.renderChild` instead of a direct reference to it. Don't forget to make sure `map` uses the right value for `this`:
render: function() {
return (
<div>
{Object.keys(hashObj).map(function(item) {
return this.renderChild(someVariable);
}, this)}
</div>
);
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "reactjs"
} |
How can I show DTFT result in MATLAB?
, then please let me know how can I use, and input value mean. | The DTFT is continuous, so you have to approximate the DTFT on a computer.
Zero padding “interpolates” the DFT, so a lot of zero padding will approximate the DTFT | stackexchange-dsp | {
"answer_score": 1,
"question_score": 0,
"tags": "fft, fourier transform, sampling, ifft, dtft"
} |
Algunos iconos de la página Font Awesome no se ven
estoy haciendo una página y estoy usando varios iconos de esa web, algunos se ven y otros no. ¿Alguien sabe que pasa?
Importo todos los iconos de la version 6.0.0 con esta línea:
<link rel="stylesheet" href=" integrity="sha512-9usAa10IRO0HhonpyAIVpjrylPvoDwiPUiKdWk5t3PyolY1cOd4DSE0Ga+ri4AuTroPR5aQvXU9xC6qOPnzFeg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> | Primero que todo, debes colocar la etiqueta **link** dentro de la etiqueta **head**
Y por otra parte te recomiendo que utilices Font Awesome en su versión 4.7.0
Aquí te dejo el ejemplo práctico:
<html>
<head>
<title>Página Web</title>
<link rel="stylesheet" href="
</head>
<body>
<span class="fa fa-info-circle"></span>
<span class="fa fa-edit"></span>
<span class="fa fa-eye"></span>
...
</body>
</html> | stackexchange-es_stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "html, css, web, font awesome"
} |
does <textarea> auto-encode inner html?
I was trying to print some text between `<textarea>` and `</textarea>` tags, but I've noticed that if I input some characters like `<` and `>`, textarea automatically converts them to `<` and `>`.
Example:
`<textarea><script></textarea>`
will produce this HTML
`<textarea><script></textarea>`
Can you explain me why this happens?
Thanks in advance, any help is appreciated, best regards. | It doesn't escape the contents. The HTML source remains exactly the same. It just has the capability to display the contents as is which I guess is a requirement of the `<textarea>` tag. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 7,
"tags": "html, textarea"
} |
How to set minimal window size to kivy application?
I try to set a minimum width and height to my kivy app. I want it resizable with min size restriction.
In the kivy doc I read about `WindowBase` class which has parameters `minimum_height` & `minimum_width`.
WindowBase description: <
How can I set the min size restriction to the basic window which `App` class creates automatically? | You have to use the Window object:
from kivy.app import App
from kivy.uix.button import Button
from kivy.core.window import Window
Window.minimum_height = 400
Window.minimum_width = 400
class MyApp(App):
def build(self):
return Button(text="Hello World")
if __name__ in ("__android__", "__main__"):
MyApp().run() | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "python, kivy"
} |
Good examples of when conditioning decreases/increases mutual information
I'm looking for two intuitive examples of random variables X, Y and Z. One where
$ I(X;Y|Z) > I(X;Y) $
and another set of X,Y and Z where
$ I(X;Y|Z) < I(X;Y)$
According to wikipedia conditioning can both reduce and increase mutual information, but I haven't found any simple, clear and intuitive examples of this yet. | $I(X;Y|Z)$ is interpreted as `` the reduction in uncertainty of $X$ due to the knowledge of $Y$ when $Z$ is given''.
The Data Processing inequality tells you if $X \to Y \to Z$ (that is, $X,Y,Z$ form a Markov Chain), then $I(X;Y) \geq I(X;Z)$. Taking $Z=g(Y)$, you get $I(X;Y) \geq I(X;g(Y))$ - that is, functions of $Y$ cannot increase mutual information. Another corollary is, $I(X;Y|Z) \leq I(X;Y)$ where $X \to Y \to Z$.
In the case where $X,Y,Z$ do not follow a Markov chain, you can have $I(X;Y|Z) > I(X;Y)$. Easy example is $X,Y$ are independent Bernoulli(1/2) random variables and $Z=X+Y$. $I(X;Y) = 0$, but $I(X;Y|Z) = 1/2$.
(This is taken from Cover & Thomas, Elements of Information Theory 2e, Chapter 2. There is a nice problem in Chapter 2 on what goes wrong with extending mutual information to multiple variables, but it isn't the same idea.) | stackexchange-math | {
"answer_score": 3,
"question_score": 1,
"tags": "information theory"
} |
Find $n$ such that there are $11$ non-negative integral solutions to $12x+13y =n$
> What should be the value of $n$, so that $12x+13y = n$ has 11 non-negative integer solutions?
As it is a Diophantine equation, so we check whether the solution exists? it exists if $gcd(12,13)|n$ that is $1|n$ and hence integer solutions to $12x+13y = n$ exist.
To find the solutions explicitly, we write $1 $ as the linear combinations of $12$ and $13$ that is $1 = 12(1) + 13(-1)$, next we write $n = 12(n) + 13(-n)$ so that the integer solutions to $12x+13y = n$ is $x = n + t(12)$ and $y = -n + t(13)$. To check for non-negative integral solutions, $x \geq 0$ and $y \geq 0$ so that $t \geq -\frac{n^2}{12}$ and $t \geq \frac{n^2}{13}$ so $t \geq \frac{n^2}{13}$. But now I am struggling how to relate this to the 11 number of non-negative integral solutions?.Any help? | If $(x,y)$ and $(x',y')$ are two of the eleven solutions, then $x'=x+13t$, $y'=y-12t$ for some integer $t$. Hence the $11$ solutions will be of the form $x=x_0+13t$, $y=y_0-12t$ with $t$ ranging over $11$ consecutive integers, wlog over the integers $\\{0,1,\ldots,10\\}$. As $t=-1$ does not lead to a solution, we conclude $x_0-13<0$. As $t=11$ does not lead to a solution, we conclude $y_0-11\cdot 12<0$, i.e. $x_0<13$ and $y_0<132$. On the other hand $t=0$ and $t=10$ do lead to solutions, so $x_0\ge0$ and $y_0\ge120$. For any choice of $x_0\in\\{0,1,\ldots, 12\\}$ and $y_0\in\\{120,121,\ldots, 131\\}$, letting $n=12x_0+13y_0$ will lead to exactly $11$ non-negative integer solutions (and for no other $n$). | stackexchange-math | {
"answer_score": 5,
"question_score": 1,
"tags": "number theory, integers, linear diophantine equations"
} |
Grails domain associations with cascading save enabled and transactions
Say we have the following two domain classes:
class Book {
static belongsTo = [author: Author]
}
class Author {
static hasMany = [books: Book]
}
No if an `Author` is initialized with several books and `Author.save()` is called then the save cascades to `Book` and both `Author` and `Book` instances are saved into db.
However I can't find anywhere in documentation if the mentioned operation will be done transactionally or not.
Any idea?
Any resource to check ? | The answer depends on **where the save is done**. Is it done in a controller action marked as transactional? Is it in a service which uses transactions by default? Or is it done somewhere else where there is no transaction.
If the save is done somewhere that supports transaction (two examples above) then yes, it will be. Otherwise, no it won't be. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "grails, transactions, grails orm, cascading"
} |
Почему WebStorm добавляет комментарий, когда я с помощью emmeta пишу сокращенную запись элемента с классом?
 то есть ставлю точку и пишу название класса (.nav) то Emmet дописывает сам потом снизу коментарий??? Не могу никак найти в настройках как это убрать... В остальном Emmet работает как надо. Заранее благодарю!!!! | Похоже, у вас включен соответствующий фильтр. В **Settings | Editor | Emmet | HTML** , **Filters enabled by default** , отключите **Comment tags** | stackexchange-ru_stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "webstorm, emmet"
} |
How can I remove a byte of type []byte
I have a variable `cmd` that returns `[50 48 ... 50 53 10]`
It's possible to remove any bytes of this var? In my case, I want to remove the last byte [10] == LF (Line Feed) to obtain: `[50 48 ... 50 53]`
P.S.: I have not found any similar question because the function `bytes.Trim(cmd, "\x10")` does not work for me, or maybe, I don't use it fine... | For example,
package main
import (
"bytes"
"fmt"
)
func main() {
b := []byte{50, 48, 50, 53, 10}
fmt.Println(b)
b = bytes.TrimSuffix(b, []byte{10}) // Line Feed
fmt.Println(b)
b = []byte{50, 48, 50, 53, 10}
fmt.Println(b)
b = bytes.TrimSuffix(b, []byte("\n")) // Line Feed
fmt.Println(b)
}
Output:
[50 48 50 53 10]
[50 48 50 53]
[50 48 50 53 10]
[50 48 50 53] | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "arrays, go, byte"
} |
Closed irreducible subset of affine plane
This is an exercise from the book _Algebraic Geometry I_ by Görtz and Wedhorn:
> Show that $Z=V(TU,T^2)\subset \rm{Spec}(k[T,U])=X$ is closed irreducible of codimension $1$, but there is no $f\in k[T,U]$ satisfying $V(f)=Z$.
I have my doubts that this exercise is correct for the following reason:
I computed $$\sqrt{(TU,T^2)}=\sqrt{\sqrt{(TU)}+\sqrt{(T^2)}}$$ and furthermore $\sqrt{(TU)}=\sqrt{(T)}\cap\sqrt{(U)}=(TU)$ by comaximality and $\sqrt{(T^2)}=(T)$ since $(T)$ is prime. Hence we find $\sqrt{(TU,T^2)}=(T)$ which implies $V(TU,T^2)=V(T)$, contradicting the claim made in the exercise.
Is my reasoning correct or did I make a mistake somewhere? | Your work shows that $V(TU,T^2)$ and $V(T)$ have the same underlying topological space, but not that they are isomorphic as schemes. If they were isomorphic as schemes, then $k[T,U]/(T^2,TU)$ would be isomorphic to $k[T,U]/(T)\cong k[U]$ as rings, which cannot be true as the first contains nontrivial zero-divisors ($T$, for example) while the second does not.
This does show that $V(TU,T^2)$ is irreducible and codimension one - this combined with the fact that $V(I)$ is closed for any ideal $I$ shows that you've successfully completed the first portion of the problem. All that's left is checking the claim about the non-existence of $f$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "algebraic geometry, ideals"
} |
What happened to the colours?
The colour of hyperlinks on the main site changed today. While basic links remain blue, they turn orange on hover, and a darker orange-brown colour when visited:

puts "Fetching from #{self.url}"
feed.entries.each do |entry|
unless Feed.exists? guid: entry.id
newFeed = Feed.create(name: entry.title,
summary: entry.summary,
url: entry.url,
published_at: entry.published,
guid: entry.id)
self.feeds << newFeed
end
end
I found these entries from tutorials. I haven't found entries from documentation. Are there any other entries that I can get from url like categories? | From the source of feedjira, category is defined as categories for RSS feed.
> `elements :category, :as => :categories`
The type of available elements depends on the source of the feed. (Atom/iTunes/FeedBurner)
So you can use `author`, `content`, `updated`, and `image` for RSS feed. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, ruby, feedzirra, feedjira"
} |
jquery how to change dom properties on different webpages?
i have 2 webpages: `xxx.com\index.php` and `xxx.com\test.php`
what i am trying to accomplish is when i click a button on `index.php` something to change on the `test.php`, maybe something like:
$('input#submit').click(function() {
$('.online_sent'). show();
});
where `input#submit` in on `index.php` and `.online_sent` in on `test.php`
i'm not using iframes, they are just 2 webpages, more exactly 2 sub-webpages on the same domain | You'll need to use something like node.js.
When a user clicks on the button you send something to node.js, then it'll send an update. On test.php have a listener that listen's for this button click and changes the page to correspond with the new state. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "jquery, dom"
} |
Quais são as diferenças entre HashMap e Hashtable?
Quais são as diferenças entre `HashMap` e `Hashtable` em Java?
Qual é mais eficiente? | # Hashmap
* Não é sincronizada
* Aceita valores nulos e uma chave nula
* É possível varrer toda estrutura com um iterador de forma simples
* Possui `containsValue()` e `containsKey()`
* É mais rápida
* Consome menos memória
* Mais moderna
* Mãe: `AbstractMap`
# Hashtable
* Sincronizada e pode ser facilmente usada em ambiente concorrente
* Não aceita nulos
* Iterar é mais complicado
* Possui `contains()`
* Tem _overhead_ pela sincronização
* Ocupa mais memória
* Considerada obsoleta
* Mãe: `Dictionary`
Retirei a informação principalmente dessa resposta no SO.
Coloquei no **GitHub** para referência futura. | stackexchange-pt_stackoverflow | {
"answer_score": 12,
"question_score": 9,
"tags": "java, hashmap, coleção"
} |
Integral of $\frac{e^{-x^2}}{\sqrt{1-x^2}}$
I am stuck at an integral $$\int_0^{\frac{1}{3}}\frac{e^{-x^2}}{\sqrt{1-x^2}}dx$$
My attempt is substitute the $x=\sin t$, however there may be no primitive function of $e^{-\sin^2 t}$.
So does this integral has a definitive value? If does, how can we solve it? Thank you! | It does not seem that a closed form exist. To evaluate the integral, start with a Taylor expansion which gives $$\frac{1}{\sqrt{1-x^2}}=1+\frac{x^2}{2}+\frac{3 x^4}{8}+O\left(x^6\right)$$ So you are let with the weighted sum of integrals $$I_n=\int x^{2n}e^{-x^2}\,dx$$ which lead to gamma functions. For the given bounds, the sum seems to converge very quickly to the value given by Travis (only four terms required for six significant digits). | stackexchange-math | {
"answer_score": 3,
"question_score": 1,
"tags": "integration, definite integrals"
} |
API to Access "Open in other devices" from google
I am looking for an API that google may or may not have to let developers have access to users tabs they have open in other devices. Anyone know of such an API or a method of retrieving the urls?
Preferably Obj-C but python or something would be fine. | Chrome is based on the open source Chromium browser, which also has the 'open in other devices' feature.
You might want to check out the chromium developer documentation - esp. the design documents related to the synch feature.
From what I understand, the browsing history, open in other devices, etc is a subset of the data synched via this feature.
Worst case you can download a copy of the chromium source and work it out from there. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "api, google chrome"
} |
What does "eau" mean?
I read it from a jewelry website relating to a bottle of perfume or cologne maybe? Some sort of spray? I can't seem to find a definition on google. I'm assuming French roots. | **eau** means **water** in French. Eau de cologne is a fragrant liquid (toilet water, where toilet is French for the process of washing oneself, dressing, and attending to one's appearance, or denoting articles used in the process of washing and dressing oneself) with a strong, characteristic scent, originally made in Cologne, Germany. | stackexchange-english | {
"answer_score": 4,
"question_score": -1,
"tags": "meaning"
} |
How to accept user input in an embedded message Discord.py
I was wondering how I would be able to accept user input from an embedded message like this image does: 
async def on_message(message):
if message.author==bot.user:
return
msg = message.content
if msg.startswith("!cal "):
names = msg.split("!cal ",1)[1]
data = names.split("*")
a = data[0]
b = data[1]
c=int(a)*int(b)
r=str(c)
em=discord.Embed(title=f"Calculator",description=f"Input\n```{a}*{b}```\n\nOutput\n```{r}```")
await message.channel.send(embed=em)
You can use this code to show the same result. NOTE : User must enter the command properly as `!cal 5*5` | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "python, discord.py"
} |
CakePHP - Created and Modified server time offset for save
My target market is based in a very different time zone compared to where the webserver is based. Therefore, my save method timestamps Created and Modified are a lot less useful than they could be. Is there anyway that I could define a global offset for my app for those two fields whenever they are saved in the app so that the time matches my target market timezone? For example, deduct 5h from every Created record? | Put this in your Config/bootstrap.php:
date_default_timezone_set('UTC'); //or whatever your timezone is
It's just based on the server time and really has nothing to do with CakePHP - so just change the default timezone with PHP, and you should be good to go. `'created'` and `'modified'` will be based on the specified timezone. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "cakephp"
} |
C# : Pass int array to c++ dll
I have a C++ dll which is used to card printing( ID cards ). My implementation done using C#.Net. I used following code to call c++ dll.
[DllImport(@"J230i.dll",CallingConvention = CallingConvention.Cdecl,SetLastError=true)]
public static extern int N_PrintJobStatus(ref int[] nPrtintjobStatus);
int[] pJob = {0,0,0,0,0,0,0,0} ;
ret = N_PrintJobStatus( ref pJob);
N_PrintJobStatus method signature given as bellow
N_PrintJobStatus(int *pJobStatus )
After calling the method it gives following error
A call to PInvoke function '********!*********.frmCardPrint::N_PrintJobStatus' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
How can I fix this issue
thank you ..... | Your translation is incorrect. An int array, `int*` does not map to `ref int[]`. The latter would be marshalled as `int**`. You need instead to use `int[]`.
[DllImport(@"J230i.dll", CallingConvention = CallingConvention.Cdecl,
SetLastError = true)]
public static extern int N_PrintJobStatus(int[] nPrtintjobStatus);
Allocate the array before calling the function. Presumably you have some way to determine how long it should be. As it stands this function looks like a buffer overrun waiting to happen. How can the function know how long the array is and so take steps to avoid writing beyond its end?
It's not clear that this is the only problem. We cannot be sure that the return type really is `int`. Or that the calling convention is cdecl. Or that the function really does call `SetLastError`. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "c#, c++, .net, pinvoke, dllimport"
} |
What is the box on inspect browser
What does this purple box represent when inspecting element in inspect, because it is not a padding, margin or Border and occupies the space inside the div
[[1]: | You can think of it as space that belongs to an element that is not:
* padding
* margin
* border
* children
I might be missing some, but it's just space not used that has to be accounted for somehow. It comes up when you do a layout that isn't the result of sizing and padding and margins. So, for example, if you use the spacing features of flexbox or cssgrid then you'll see these purple spaces. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "css, inspect, web inspector"
} |
How to get URL name in template?
I tried to print this in the template, but it renders blank. Whats the correct way to get URL name in template?
{{ request.resolver_match.url_name }}
I wanted it to highlight something in the top bar (if path is 'admin-stuff' add highlight class). | In the application settings `TEMPLATE_CONTEXT_PROCESSORS` must include
"django.core.context_processors.request"
for the `request` to appear in the template context. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 9,
"tags": "django"
} |
Telerik WPF - TreeMap Select item programatically
Is it possible to select an item programatically? After I bind the TreeMap control I would like to select a default item. | Sure. Set the `IsSelectionEnabled` property to `true` and then set or bind the `SelectedItem` or `SelectedValue` property to an item in the `ItemsSource` like you would do with any other `ItemsControl`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "wpf, telerik, treemap"
} |
How does Laravel Artisan created php files with properly formatted lines
This is just a general question, how does Laravel Artisan able to create proper .php file e.g. make:controller with the correct formatting and line breaks?
Is there a good PHP script which can help one develop similar php codes.
Thanks | PHP files are just text files, you can easily create them with any language. Also in Laravel usually used so called `stubs`, templates for classes like migrations, controllers etc.
Just go and look how as Laravel does that under the hood. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "php, laravel, laravel artisan, file writing"
} |
No displaying the score on the last ScoreViewController Swift
Im having trouble with my segue function, Im trying to pass the final score to the second view but is not displaying on the label this is what i have for my segue function:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let destinationScore : ScoreViewController = segue.destinationViewController as! ScoreViewController
destinationScore.scoreBoard?.text = String(finalScore)
NSLog(String(finalScore))
}
Here is the second view controller.
@IBOutlet weak var scoreBoard: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
}
PS: My NSLog is displaying the final score on the terminal but not on the label. Thank you | When prepareForSegue performed, the contents (including view and subviews) of ScoreViewController haven't been loaded yet. So the scoreBoard label was nil when you set the value for label. Therefore the scoreBoard label can't show your score.
To resolve this problem:
* You'd better add property `var score: String` in ScoreViewController, then assign text for label in `viewDidLoad` function.
* In prepareForSegue, assign score property instead of scoreBoard label. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "swift, label, segue, viewcontroller"
} |
transition parameter in afterModel emberjs
i don't understand why the `afterModel` method get a `transition` parameter, and what its represent (yeah a transition from one page to the other, but in `afterModel` method there is no transition running, and that the prupose of `afterModel`, starting a transition if required, using model data.)
< | The `afterModel` hook is the third of the three model hookes, which all run _before_ the transition is done.
So the transition in `afterModel` is the same then in `beforeModel`.
The difference is that sometimes you need the model to decide if you want to abort the transition and redirect to somewhere else or not.
A example could be a `/userEdit/:user_id` route where admins can edit all users and normal users only can edit their own user. In the `beforeModel` you could check if the the user is admin and if not but you can't abort the transition based on information on the model. In the `atferModel` hook you can do exactly this, and save the transition away to may retry it later, for example after the user got admin privileges.
The router does _not_ enter the route after the Promise returned by the `afterModel` hook resolves. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -1,
"tags": "javascript, ember.js"
} |
Ubuntu 13.04 Login Loop
I have a problem with Ubuntu **13.04**.
I cannot log in to my account. I put the right password but there is an endless loop. (if i put wrong pass, it says "Invalid password..."). Also, it doesnt show the small drop down menu with choices "Gnome fallback, Default, etc.."
If i login as guest, the desktop is clear, no bars, no menus, anything. Just right clicks works only.
I have already try this solution ( `chown username:username .Xauthority` ) but there is no "Xauthority" at ubuntu 13.04. (?)
Is the problem about lightdm? Also, i tried `sudo dpkg-reconfigure lightdm` but it soesn't work.
I use the recovery mode (root command shell or something like this) in order to try the above commands.
Has anyone a solution?
Thank you. | Try deleting `$HOME/.profile`, I had the same problem before, because I added a function into `$HOME/.profile`.
When I deleted the function, I could login again. The original content of `$HOME/.profile` is
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi | stackexchange-askubuntu | {
"answer_score": 2,
"question_score": 4,
"tags": "login"
} |
Somar valores de dentro de uma coluna com postgres
Estou tentando somar os valores de dentro de uma coluna com postgres, a estrutura da tabela é a seguinte:
id |nome_municipio |valores
1 |Porto Alegre |100.01;95.0;50.1
2 |Ivoti |87.0;80.1;45.1
3 |Novo Hamburgo |210.0;99.2;100.0
Gostaria que o resultado final fosse
id |nome_municipio |valores
1 |Porto Alegre |245.2
2 |Ivoti |207.2
3 |Novo Hamburgo |409.2
Isso é possível?
Postgres 9.1 | select id , nome_municipio, (SELECT SUM(s) FROM
UNNEST(CAST(regexp_split_to_array(valores, E';') as real[])) s) from "tabela" | stackexchange-pt_stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "sql, postgresql"
} |
Average of the Averages.
From $10$ numbers $a,b,c,...j$ all sets of $4$ numbers are chosen and their averages computed. Will the average of these averages be equal to the average of the $10$ numbers?
I tried analyzing smaller set of numbers but it became cumbersome and I couldn't reach to definite conclusion for this.
Can someone please help me with this? How can we derive at the answer for this? How can we prove this to be $TRUE$ or $FALSE$. Also if this is true then can it be generalized for $N$ numbers too like :-
From $N$ numbers $a,b,c,...$ all sets of $n$ numbers are chosen and their averages computed. Will the average of these averages be equal to the average of the $N$ numbers?
Thanks in advance ! | There are $C(10,4)={10!\over4!6!}$ different sets of 4 numbers chosen among $x_1,x_2,\dots x_{10}$. Each number $x_i$ belongs to $C(9,3)={9!\over3!6!}$ such sets, because the other three numbers in the same set can be chosen in $C(9,3)$ different ways. Hence the average on all sets is: $$ \begin{align} {1\over C(10,4)}\sum_{1\le i<j<k<l\le10}{x_i+x_j+x_k+x_l\over4}& ={1\over 4C(10,4)}\sum_{i=1}^{10}C(9,3)x_i\\\ &={C(9,3)\over 4C(10,4)}\sum_{i=1}^{10}x_i={1\over10}\sum_{i=1}^{10}x_i \end{align} $$ and both averages are the same.
This also works in general for the case of all sets of $n$ numbers chosen among $N$. The key is all numbers $x_i$ appear the same number of times in the final sum. | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "sequences and series, contest math, average"
} |
Set mouse cursor position in Flutter
Is it possible to set the position of the mouse cursor using Flutter for desktop?
I'm sure this is possible using custom plugins, but I'm hoping for a cross-platform Dart solution or an existing plugin. | There is no such functionality built into Flutter. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "flutter, flutter desktop"
} |
無線LANインターフェスをブリッジインタフェースに追加できません。
linux(Ubuntu 16.04.4 LTS)LAN
# brctl addbr br0
# brctl addif br0 wlp1s0
can't add wlp1s0 to bridge br0: Operation not supported
`wlp1s0`LAN
PCSurface pro3LAN`mwifiex_pcie`
|
linux
`net/wireless/core.c`
if ((wdev->iftype == NL80211_IFTYPE_STATION ||
wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
dev->priv_flags |= IFF_DONT_BRIDGE;
LAN
| stackexchange-ja_stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "linux"
} |
How to fix runtime error 201?
I compiled the program with `-Criot -gl` flags and instead of 1 I get a lot of results to my surpise (in fact, I was looking for fix a 216 error). The first is with the below code that's a simple hashing function. I have no idea how to fix this.
function HashStr(s : string) : integer;
var h : integer;
var c : char;
begin
h := 0;
for c in s do
h := ord(c) + 31 * h; { This is the line of error }
HashStr := h;
end;
How can this be out of ranges? | Easily, say you have a string "zzzzzzzzzzz". Ord(c) wil be 122, so the sequence is
H = 122 + (31* 0 ) = 122
H = 122 +(31*122) = 3902
H = 122 +(31*3902) = 121146
Which exceeds the 32767 limit for 16 bit ints, if it's a 32 but int, it won't take many more iterations to exceed that limit. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "runtime error, pascal, fpc"
} |
Creating a merge of two directories using symlink on Windows
Is it possible to combine two separate directories into the same place on Windows using symbolic links?
Something like this:
mklink /J c:\Merged c:\Data\Dir1
mklink /J c:\Merged c:\Data\Dir2
Which doesn't actually work because C:\Merged cannot be created twice.
Or maybe there is an alternative way of dong this other than symlinks? | That's not how symbolic links work. (So the answer to your question is "No", at least not with symbolic links.)
What you are looking for is called a Union Mount \- I'm not aware of any way to accomplish this on Windows, though it may be possible and I've just never seen it... | stackexchange-serverfault | {
"answer_score": 5,
"question_score": 1,
"tags": "windows, symlink"
} |
Images generated on server real time to be streamed to android mobile
I am generating a set of images on server. I need to encode and stream these real time to a android mobile, what is the best way possible, best encoder server side to do this? | Well, you can just have picutres stored in any format and just download them into device one by one. Only matters are how fast connection do you have, how many pictures do you want to send and how fast whole operation has to be finished.
Images downloaded from server in that way are stored in inputstream, which can be saved into file or used to create Bitmap with BitmapFactory and displayed within application. Be aware of OutOfMemoryError, which occurs while creating big resolution Bitmaps with BitmapFactory, as heap is shared amog all applications and is limited to 16 MB.
As for downloading process you can do that with HttpClient library available in Android. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 3,
"tags": "android, stream"
} |
How do I send a command through cmd in Java?
Here's my dilemma: I'm trying to make a command-line Java program, and I want one of the features to be to call on Notepad to open up a file. Now I know you can do this from CMD with something like
notepad "filename.txt"
and I know that you can do it in VB using Shell() or .NET using Process.Start().
However, is there any way to do this from Java? I would see why not since it's cross-platform and all and this kind of defeats the purpose, but it would be awesome to (know how to) implement this. | Here is a quick example using the Runtime.getRuntime().exec().
import java.io.IOException;
import java.util.Scanner;
public class SOTest
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("File Name: ");
// Get the file path and close scanner
String file = in.next();
in.close();
try
{
Runtime.getRuntime().exec("notepad " + file);
}
catch (IOException e)
{
e.printStackTrace();
}
}
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "java, process, cmd, command"
} |
line count on all the PHP scripts within my webroot with wc
How can I do a line count on all the PHP scripts within my webroot?
I am trying something like this below to no avail:
wc -l *.php | You need to use either a shell whose wildcard expansion includes subdirectories, or to stack another tool for directory transversal, such as `find`:
`find -name "*.php" | xargs wc -l`
If, OTOH, your goal is to sum it all, join the code first:
`find -name "*.php" | xargs cat | wc -l` | stackexchange-unix | {
"answer_score": 1,
"question_score": 1,
"tags": "directory, utilities, recursive"
} |
Fixed Point of continous map on a closed ball to R^n
For a closed ball $\overline{B_R(0)}\subset \mathbb{R}^n$ with $R>0$ we have $f\in C^0(\overline{B_R(0)},\mathbb{R}^n)$ with $\langle x,f(x) \rangle\leq \langle x,x \rangle$ for $x \in \partial \overline{B_R(0)}$. Show that $f$ has fixed point.
My guess (I'm very sceptical): $f$ continuous implies that Im$(f)$ is compact. \begin{align} \text{Im}(f)\subset \overline{B_{R_i}(0)} \;\; \text{for} \;\; R_i\geq\\!\\!\max_{x\in \overline{B_R(0)}}\\! ||f(x)||. \end{align} If $R>R_i$ I'm done, since I can use Brouwer fixed point theorem. For $R<R_i$ define $g_i: \mathbb{R}^n\rightarrow \mathbb{R}^n, x\mapsto \frac{R}{R_i} x$, so that $g_i\circ f(\overline{B_{R_i}(0)})\subset \overline{B_{R_i}(0)}$ and by Brouwers theorem there exists $x_0$ so that $g_i\circ f(x_0)=x_0$, hence there exists $x_0$ so that $f(x_0)=\frac{R_i}{R}x_0$ is true. But since $R_i$ can chosen arbitrary large, $x_0$ has to be $0$.
Does it work? | Hint: Try using the following well-known result in fixed point theory:
> **(Leray-Schauder Nonlinear Alternative):** Let $E$ be a Banach space and $C \subset E$ a closed convex set. Let $p \in \text{int}(C)$ and $U\subset C$ be an open set containing $p$. If $f: \overline{U} \longrightarrow C$ is continuous and compat (that is, $\text{Im}(f)$ is contained in a compact of $C$), then either:
>
> $(1)$ $f$ has a fixed point in $\overline{U}$; or
>
> $(2)$ There is some $u \in \partial U \subset C$ and some $\lambda \in (0,1)$ such that
>
> $$u=\lambda \cdot f(u) + (1-\lambda)\cdot p$$
What should $E$, $C$, $p$ and $U$ be in your example? Is $f$ compact (duh)? After answering these questions, all you have to do is show that $(2)$ does not apply. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "functional analysis, hilbert spaces, fixed point theorems"
} |
Can we conclude that two of the variables must be $0$?
> Assuming $$a^2+b^2+c^2=1$$ and $$a^3+b^3+c^3=1$$ for real numbers $a,b,c$, can we conclude that two of the numbers $a,b,c$ must be $0$ ?
I wonder whether mathworld's result that only the triples $(1,0,0)$ , $(0,1,0)$ , $(0,0,1)$ satisfy the given equation-system , is actually true.
Looking at $(a+b+c)^3$ and $(a+b+c)^2$ , using \begin{align} &(a+b+c)^3= (a+b+c)^2(a+b+c)=\\\ &(1+2(ab+ac+bc))(a+b+c)= \\\ &2(a+b)(a+c)(b+c)+a+b+c+2abc \end{align} and eliminating $(a+b)(a+c)(b+c)$, with $S:=a+b+c$ , I finally got $$(S-1)^2(S+2)=6abc$$
I guess this is not enough to show the above result (if it is true at all).
This question is inspired by an exercise to determine the possible values of $a+b+c$ assuming the above equations, so this question could be a duplicate, but I am not sure whether it actually is. | Without loss of generality assume that $a\not=0$ and $b\not=0$ such that $a^2+b^2+c^2=1$ and $a^3+b^3+c^3=1$. Then $|a|<1$, $|b|<1$ and $|c|<1$ (otherwise $a^2+b^2+c^2>1$). Therefore $$1=|a^3+b^3+c^3|\leq |a|^3+|b|^3+|c|^3<|a|^2+|b|^2+|c|^2=1$$ Contradiction. | stackexchange-math | {
"answer_score": 9,
"question_score": 5,
"tags": "calculus, systems of equations, symmetric polynomials"
} |
Windows SBS 2008 - Applying user restrictions
I have a SBS2008 server and I need to restrict program access on a per group basis, see below for the view from Active Directory.
How do I go about restricting the User's in the group "Advisors With Restrictions". I need to stop them from opening certain programs (Word, Excel, Internet Explorer, RegEdit, Control Panel etc etc)
!enter image description here | You can manage this through Group Policy
User Configuration > Administrative Templates > System > Run only allowed Windows applications | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 0,
"tags": "active directory, permissions, windows sbs 2008, windows sbs"
} |
RAR password recovery
If I have the encrypted RAR file, and I also have the unencrypted file, does there exist any way to find the cipher used by AES to decrypt it?
How does RAR encrypt files, separately, or does it encrypt them all in one? (in the case of unencrypted file name) | No you cannot find the key, that would require a brute force attack.
It encrypts the files separately, info that can be easily found on the internet. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "encryption, rar"
} |
Is my machine key auto-generated or isolated?
I'm attempting to share `.ASPXAUTH` cookies between an ASP.NET MVC 4 application (in IIS 7.5) and a service using `HttpListener` on the same host.
The browser presents the cookies to both correctly, but my service receives `System.Web.HttpException: Unable to validate data.` at `FormsAuthentication.Decrypt`, which I would expect if the two applications were using different machine keys.
So: how do I find out if my machine is configured to use different machine keys? | the default setting of IIS is autogenerate machine-key and isolate per application you can change this setting globaly in your machine.config or localy (per application) in your web.config
for details please see
* <
* <
You can see the current setting for machine-key in IIS manager. For details, see < | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "asp.net, iis"
} |
Does the universe have a celestial north?
You are away from the Earth in one part of the universe and looking at a galaxy in another part of the universe, then which way is up? Does the universe (or near universe) have a celestial north? If you took a picture of that galaxy, then is there a correct orientation for displaying that photograph? | Short answer, no, not like we do for the Earth and solar system.
Longer answer: kinda. The IAU has defined the International Celestial Reference Frame (ICRF). It is the coordinate system used to locate an object in the universe in as near a fixed coordinate system as we can define, based on very distant radio sources. A simplified defintion is the Z axis is aligned with where the Earth's North pole was pointing Jan 1 2000 00:00 UT1. The X axis point to the J2000 ra/dec coordinate 0,0. And the Y axis is perpendicular to both of those.
So this Z axis is the best definition for North or "up" we have. | stackexchange-astronomy | {
"answer_score": 9,
"question_score": 9,
"tags": "cosmology"
} |
process A starts B and waits forever when B fails ??? ipc design needed !
i have the following Problem: i have two Processes process A which starts process B and have to wait until process B returns some info, which is needed for further work of process A. the problem is that Process B may fail and break its work, process A doesnt know about it and keeps waiting!
in this case what is the ideal communication way, and how would you ensure that process A knows if process B still working or not (without Watchdog timer)?
for the interprocess-communication i considered named pipes, sockets and simply a file on the disk as the information process B provides process A with, can be saved in text.
any ideas to achieve this? | Let B create a Mutex on startup and lock it. Then, make A wait for it using WaitForSingleObject api. The Mutex is automatically destroyed when its owner process is terminated, but you can release it sooner if you like to (for instance, B can release the mutex to notify A that it's ready, while it still has some cleaning up to do. That will keep A from waiting unnecessarily long.)
You can specify a timeout too, if you like, so you can give B a maximum time to execute before A will stop waiting. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "ipc"
} |
identify the rows with the lowest values in an array based on identical values in a column of that array
I have an array of product data which includes code, description and cost. code is unique, cost is numeric and description is non-unique. Please see example. How can I select the cheapest of each product based on the description and price?
!enter image description here
This is the result of using the MIN formula.
!enter image description here | Add this array formula as a new "Lowest" column (adjusting range for your actual range), and copy down:
={IF(B2=MIN(IF($A$2:$A$9=A2,$B$2:$B$9)),"Y","")} | stackexchange-superuser | {
"answer_score": 1,
"question_score": -2,
"tags": "microsoft excel, worksheet function, array"
} |
Get the image source from get_the_post_thumbnail($post->ID);
I have to get the image source from the code below.
$thumburl = get_the_post_thumbnail($post->ID);
Here I'm getting
<img width="325" height="202" src=" class="attachment-post-thumbnail wp-post-image" alt="film" title="film">
I want to get this part.
"
How can I get the source ? | $post_thumbnail_id = get_post_thumbnail_id($post->ID);
$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id ); | stackexchange-stackoverflow | {
"answer_score": 25,
"question_score": 6,
"tags": "php, html, wordpress"
} |
how to hide the adminblog link in the teaser
how to remove admin`s blog in footer of teasers i can remove the add comment link with this code :
function mytheme_node_view_alter(&$build){
if ($build['#view_mode'] == 'teaser')
{
// remove "add comment" link from node teaser mode display
unset($build['links']['comment']['#links']['comment-add']);
// and if logged out this will cause another list item to appear, so let's get rid of that
unset($build['links']['comment']['#links']['comment_forbidden']);
}
but i can`t remove admin`s blog what can i do ?! | Try to use something like the below code to hide admin's blog from teaser's view in your theme's template.php, hope it will work for you:
function THEME_preprocess_node(&$variables) {
if ($variables['view_mode'] == 'teaser') {
if ($variables['type'] == 'blog' && (arg(0) != 'blog' || arg(1) != $variables['uid'])) {
unset($variables['content']['links']['blog']['#links']['blog_usernames_blog']);
unset($variables['content']['links']['node']['#links']['node-readmore']);
}
}
} | stackexchange-drupal | {
"answer_score": 5,
"question_score": 0,
"tags": "theming, users, nodes"
} |
Table for 3D list plot
I have a function which is defined with an integral and a sum, in other words, its numerical, so i want to make a table (nxm) with the following entries:
data={{x1,y1,f[x1,y1]},{x1,y2,f[x1,y2],{x2,y2,f[x2,y2],...,{xn,ym,f[xn,ym]}
Is there an easy way of achieving this? Thanks! | f[x_, y_] := Sin[x y]
ListPlot3D@ Flatten[Table[{x, y, f[x, y]}, {x, 0, 2 Pi, 2 Pi/50}, {y, 0, 2 Pi, 2 Pi/50}], 1]
!Mathematica graphics | stackexchange-mathematica | {
"answer_score": 3,
"question_score": 2,
"tags": "plotting"
} |
What is the definition of pathology?
While trying to get more information for my previous question, I found several different definitions for the terms "pathology" and "pathological." While under normal circumstances I'd be inclined to say the latter stems from the former, there seems to be heavy connotation where terms such as "pathological liar" are concerned.
One of the definitions at dictionary.com states:
> Caused by or evidencing a mentally disturbed condition
Seems a bit vague, to me. **Can anyone clarify this?** | I think the answer can actually be found in the Dictionary.com link you cite:
> `-ological`; _suffix_ ; used to form adjectives; belonging or relating to a particular type of scientific study; e.g. biological, technological
And (taken from Wikipedia):
> The word pathology is from Ancient Greek _πάθος_ , pathos, "feeling, suffering"; and _-λογία_ , -logia, "the study of".
So `pathological` would be:
> an adjective describing a thing that belongs or relates to suffering or the feeling of suffering.
(literally translated, of course)
So we can see that it's not just disease-related (suffering) but also mental health-related (feeling of suffering). | stackexchange-cogsci | {
"answer_score": 3,
"question_score": 6,
"tags": "terminology, abnormal psychology"
} |
UIViewController rendering behind the navigation bar
I have a UIViewController which has a table view and a date picker view. I push this view from another view using the navigation controller but this view gets rendered behind the navigation bar. I am not able to figure out why this is happening. All other views in my app render correctly. This is the only UIViewController in my app all other are UITableViewController.
The following is the screenshot.!Screenshot | I figured out why the view was rendering behind the navigation bar. I had set the translucent property to yes on the navigation bar in the app delegate. This was causing the view to render behind the navigation bar. Setting it to no solved the issue. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "iphone, uiviewcontroller, uinavigationcontroller"
} |
Mathematical operations in Android layout attributes
I need to use following otherwise my custom widget was overlapped by a `Toolbar`:
android:layout_marginTop="?android:attr/actionBarSize"
But I want to have additional margin, say 10dp. I cannot do something like:
android:layout_marginTop="?android:attr/actionBarSize + 10dp"
because + is not allowed character there. Is there any other way except coding a rule programmatically? | You could wrap your ViewGroup into another one just to add the 10dp margin. Not optimal but that would work. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "android, android layout"
} |
How to create a ticketing system from email sent by users?
I am new to Sharepoint development and was going through tutorials to create a ticketing system which we need badly. I found a lot of information on those but couldn't find if there is a way to create tickets using emails from users to a specified email address. At present we receive emails and create tickets based on those, but it would be really helpful if the emails can directly create the tickets. Remedy has this option but I don't know about Sharepoint. Is there any way to do this or maybe through outlook with an extension that Microsoft provides? Any inputs would be helpful.
Thanks | This is how I would do it no code solution:
1. Create a SharePoint Document Library
2. Activate Incoming Email services in that list
3. Create a Form in Microsoft word using quick parts where you can map the columns of the SharePoint Site.
4. Upload that template in SharePoint Library as a default template.
Once you have That set up, publish that form to users as a input form. So if users send that form to [email protected]( which is mapped to that document library) All the information will be prepopulated and new item would be created.
From that point on you can manage the data you have captured way you want.
Thank You | stackexchange-sharepoint | {
"answer_score": 2,
"question_score": 0,
"tags": "sharepoint enterprise, sharepoint designer, sharepoint addin"
} |
Drupal tagging via tagadelic
this module does a good job at creating a tagcloud block - all good here. now id also like to have a page that lists all tags with next to each tag the number of posts that were tagged with this term. all terms are listed ok on < but i dont think tagadelic can add the number of posts per tag?
also, it seems tagadelic can just output one single block "tags in tags". whatever changes i make in the tagadelic configuration is applied to the tagadelic/list/3 url AND to the tagcloud block in the sidebar (the order of tags and number of tag levels)
does what i need require some custom module or are there others around that can achieve this? ive been playing around with Views 2 but cant quite get what I need | Use views and views_cloud for a much more flexible solution.
**Edit:** If you are having trouble with the views module, there is some very good in-browser instructions that come with it, but they require the advanced_help module. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "drupal"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.