INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
How to pass object using segue
I carry a uitableview with a collection of objects. And when I click on a UITableViewCell open another UIView. But I wanted to send the object that is in UITableViewCell for this new UIView and there to show their details. I followed to answer this question to load another view: ViewController Segue Xamarin I am very grateful if someone help

{
if (segue.Identifier == "TaskSegue") { // set in Storyboard
var navctlr = segue.DestinationViewController as TaskDetailViewController;
if (navctlr != null) {
// some public method you create in your destination controller
navctlr.SetTask (this, item);
}
}
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, ios, uitableview, uiview, xamarin"
} |
How to setup IPv6 on ubuntu host with two VMs
I want to setup IPv6 network with two VMs(virtual box) on a ubuntu 12.04 host. One VM is backtrack and second is window XP. I want to know that how can i setup a fully IPv6 network so that i can communicate form backtrack to XP on virtual box network attached in bridged adapter mode, all traffic from backtrack to XP should goes through Ubuntu host. is it also possible to configure ubuntu host as a DHCPv6 server so that it serve IPv6 to VMs automatically and able to communicate. I appreciate any help. Thanks | WinXP does support IPv6, but you are required to have SP2 and you must manually add/install the protocol, and it does NOT support DHCPv6....use Win7 instead, as IPv6 is native...you will be much happier in your testing.
I have setup many similar scenarios as you are asking about on VMware workstation, but I have no experience w/virtual box, but I suspect it will work just fine.
hth...Jeff Carrell | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 2,
"tags": "networking, ipv6, virtualization"
} |
Google Maps API v3 - Map not loading
I used the Google Maps API v3 to create a map on < but the image tiles of the actual map aren't loading. Chrome's Developer Console doesn't give any errors.
EDIT: unfortunately the map got removed | I solved it!
My script resizes the map, so I must trigger the map's resize event everytime I change it's size like this:
google.maps.event.trigger(map, "resize"); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "javascript, jquery, html, maps"
} |
What's a phrase to describe this situation?
Let's say hypothetically a country proactively allocate millions of tax dollars towards creating vaccines and setting up camps to quarantine and prevent the spread of Ebola in a neighbouring country. Two months later the Ebola is completely gone. Then people from the country that spent millions are mad and say "look at all this money spent, this country didn't even want our help and it was purged of Ebola really quickly, what was the point, we are in a worst situation than before because the country hates us now and we are out millions on vaccines which weren't used", etc. But those people are making the assumption that things WOULDN'T HAVE BEEN MUCH WORSE had they not done anything. There COULD have been unforetold catastrophic events as a result of inaction. This is a usual argument I see against proactive government foreign policy. Is there a name for this fallacy because I see it all the time. Thanks. | This is a _damned if you do, damned if you don't_ fallacy. If the proactive effort works, opponents will claim it was not needed and the money was wasted. If the effort fails, the same opponents will claim not enough money was spent!
Another term for this thinking is _politics as usual._ | stackexchange-english | {
"answer_score": 2,
"question_score": 0,
"tags": "terminology, logic"
} |
Adding custom information to Magento 2's checkout "order summary"
I'm working on my first Magento 2 project, and I'm slowly getting to grips with how everything works.
Then, I reach the point where I need to customize the checkout page and it throws a **massive curveball** , replacing the phtml/XML template system I've gotten used to with a completely different Knockout one.
In a nutshell, I store some personalization data in the quote item's "additional_data" field, and I need to show it in the checkout order summary.
I have successfully overridden `/frontend/web/template/summary/item/details.html` with my own custom template, but I have no idea how to get the data from the product object and display it using Knockout.
Has anyone done anything similar they wish to share to get me started? | You should be able to access the quote's 'additional data' here: `window.checkoutConfig.quoteItemData[0].additional_data`
So in your knockout template, you might have something like this:
<span data-bind="text: window.checkoutConfig.quoteItemData[0].additional_data"></span> | stackexchange-magento | {
"answer_score": 1,
"question_score": 1,
"tags": "magento2, frontend, knockoutjs"
} |
Label wrapping and editable
How do you make Labels wrap like Span Labels, but also be inline with following Labels so things look right?
Also, how can you make the Labels editable on click/touch? | Use a BoxLayout Y to align them to the left together.
If you want a text area to look like a label do:
TextArea t = new TextArea();
t.setUIID("Label"); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "codenameone, label"
} |
Including related fields in Linq group by query
I'm trying to create a query that groups by a field in the first table, sums a first table field, and includes a single field from a second. I keep getting an error when attempting to refer to a field from the joined table.
**Table1: Users**
Id
DisplayName
**Table2: TimeEntries**
WeekEnding
UserId
Hours
**Query:**
from u in Users
join t in TimeEntries on u.Id equals t.UserId
group t by new {t.WeekEnding, t.UserId } into g
select new {WE = g.Key.WeekEnding, User = g.Key.UserId,
HoursTotal = g.Sum(s => s.Hours), DisplayName = g.First(n => n.DisplayName)}
I've tried many things but "DisplayName" is not a valid field. Any help on this will be greatly appreciated. Thank you. | Here's a couple options.
from t in TimeEntries
group t by new {t.WeekEnding, t.UserId } into g
let firstT = t.First()
select new
{
WE = g.Key.WeekEnding,
User = g.Key.UserId
HoursTotal = g.Sum(x => x.Hours)
DisplayName = firstT.User.DisplayName
}
from t in TimeEntries
group t by new {t.WeekEnding, t.UserId } into g
let user = (from u in Users where u.UserId == g.Key.UserId select u).Single()
select new
{
WE = g.Key.WeekEnding,
User = g.Key.UserId
HoursTotal = g.Sum(x => x.Hours)
DisplayName = user.DisplayName
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, linq, group by"
} |
"/bin/rm: cannot remove files .. No such file or directory " though they exist
I am trying to fix ffmpeg library conflicts between manually installed and John Sverissons's ppa. In this context I attemped to remove `libavcodec.so libavutil.so, libswscale.so, libswresample.so, libavresample.so, libavfilter.so` in my system by doing
locate -0b libavfilter.so | xargs -0 rm
for each *.so files above.
I could remove all above files except `libavfilter.so` When I issue `locate -b libavfilter.so` it lists paths but when I attempt to remove it I get
/bin/rm: cannot remove '/usr/lib/i386-linux-gnu/libavfilter.so': No such file or directory
What happens here? | Did you check that the file exists, other than by using `locate`? Locate uses a database, so you may be looking at stale information.
Three solutions:
* Use the `--existing` option for `locate`
* Run `sudo updatedb` before running `locate`
* Try again tomorrow, after the daily cron jobs have run | stackexchange-askubuntu | {
"answer_score": 3,
"question_score": 0,
"tags": "gnome terminal"
} |
How to unblock pan and pinch events in a UIScrollViewDelegate?
I have a UIView which has a UIScrollView subview and is a UIScrollViewDelegate. Since I've implemented `viewForZoomingInScrollView` I stopped getting pan and pinch events for the UIView.
How can I get these events back? | Try adding a delegate to your gesture recognizer that implements
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ios, events, gestures, uiscrollviewdelegate"
} |
Cannot assign new value to LINQ-selected data
namespace ConsoleApplication4
{
class T1
{
public int MyProperty { get; set; }
}
class Program
{
static void Main(string[] args)
{
var tmp = (new[] { 1, 3, 4 }).Select(x =>new T1 { MyProperty=x});
foreach (var s in tmp)
{
s.MyProperty = 9;
}
foreach (var s in tmp)
{
Console.WriteLine(s.MyProperty);
}
Console.ReadLine();
}
}
}
I expect there are **three 9** on screen, but the values are still same.
However, if I modify code a little bit, the values would be changed successfully i.e. :
var tmp = (new[] { 1, 3, 4 }).Select(x =>new T1 { MyProperty=x}).ToList();
I wonder why? | The reason is **deferred execution**.
`tmp` is _not a list or an array_. It's only a _definition how to create the enumeration_. Or in other words: `tmp` is only the _question_ , but not the _answer_.
So in the second `foreach`, the enumerator created by the `Select` is executed **again** , creating **new** instances of `T1`.
When you use `.ToList()` instead, the enumeration is converted to a `List` (so `tmp` is a `List<T1>`). And you can iterate that `List` as often as you want without creating _new_ instances. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 1,
"tags": "c#, linq, select, foreach"
} |
Could someone identiy this SMD connector?
does someone know what the part number etc of this connector is? It is used to connect two boards. There are 5 pins on one side and 6 pins on the other. The smallest markings on the tape measure are in mm.

echo 'script-2 has run' >> $HOME/script-1-output.txt
else
echo 'script-2 has not run' >> $HOME/script-1-output.txt
fi
if (-f $HOME/script-3-output.txt)
echo 'script-3 has run' >> $HOME/script-1-output.txt
else
echo 'script-3 has not run' >> $HOME/script-1-output.txt
fi | In bash, if conditions are wrapped between [] not (). There should always be space between condition and square brackets. And you need then in if-then-else-fi syntax.
if [ -f file.txt ]; then
echo "yes"
else
echo "no"
fi | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "linux, bash, ubuntu"
} |
JavaScript: \\d{4} RegExp allows more than 4 digits
Have following validation for year value from text input:
if (!year.match(new RegExp('\\d{4}'))){
...
}
`RegExp` equals `null` if numeric of digits from 0 to 3. **It's OK.**
In case 4 digits it returns value. **It's OK.**
In case more than 4 digits it returns value again,that it's **NOT OK**.
Documentation says `{n}` declaration means exact number,but works like:
exact+
With such ugly validation it work's fine:
if (!year.match(new RegExp('\\d{4}')) || year.length>4){
...
}
I wish to utilize RegExp object only. | Yes it would allow more than 4 digits since it would be a partial match use the `^` and `$` to mark the beginning and the end of the string.
if (!year.match(new RegExp('^\\d{4}$'))){
...
} | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": -1,
"tags": "javascript, regex, numbers"
} |
Radioisotope thermoelectric generator vs Solar?
What circumstance would a radioisotope thermoelectric generator is better to use than solar cells in space probes and rovers?
 would you recommend, for the rest of setup being:
* Kingston 8GB 3000MHz HyperX Savage Black CL15
* MSI Z170A GAMING PRO (Z170 3xPCI-E DDR4)
* Intel i5-6500 3.20GHz 6MB BOX
* A-DATA 240GB 2,5'' SATA SSD Premier SP550
* Monitor: Eizo FlexScan S1901 (1280 x 1024)
Also, any suggestions regarding above setup are welcomed.
EDIT: Also, I plan learning to program for CUDA, so I guess only GeForce is on the table. | That resolution is pretty easy to drive. I'd actually consider a newer monitor, even if my experience, eizos are pretty nice.
At the current resolution, and in fact up to QHD, a 960 would likely be a good bet - my old 660 with 2gb of ram handled 1080p out fine at ultra settings for most games I threw it at.
A 970 would likely be overkill, and of course, a 980 or 980TI would be more so.
Get a better video card _if_ you intend to upgrade. | stackexchange-hardwarerecs | {
"answer_score": 3,
"question_score": 7,
"tags": "gaming, graphics cards, desktop"
} |
"Trace" as a synonym for "trail" in AmEng
As far as AmEng is concerned, does "trace" mean just about the same as "trail" in "break/blaze a trace", and -- if indeed it does -- can "trace" be used pretty much interchangeably in every which literal sense of "trail"?
> _It takes about two people to **break a trace** through the brush ahead_... source
>
> _Only tortuous paths and **blazed traces** led over the Appalachians_... source | 'trace' does have a meaning similar to 'trail'. It is uncommon - probably the most famous is the Natchez Trace from Nashville to Natchez in Mississippi, set out in the early 1800s.
The implication is that a trail is more 'improved' and used than a trace. If I make a trace and others use it, it becomes a trail. The trace is more akin to the route you took than any kind of improved path.
I would not use the words interchangeably because of the rarity and this difference in meaning. | stackexchange-english | {
"answer_score": 7,
"question_score": 5,
"tags": "american english, usage, dialects, vernacular, regional"
} |
Updating mean value and standard deviation
I have a set of data $\\{x_1,\ldots, x_N\\}$, with large $N$. To compute the mean value I perform the operation:
$$\mu = \frac{1}{N}\sum_{i=1}^Nx_i.$$
The standard deviation is dependent on the value of $\mu$, of course. Suppose that I add $x_{N+1}$ to my data set, so that the new mean value is:
$$\mu' = \frac{1}{N+1}\sum_{i=1}^{N+1}x_i = \frac{1}{N+1}\sum_{i=1}^{N}x_i + \frac{x_{N+1}}{N+1} = \frac{\mu N + x_{N+1}}{N+1}.$$
Instead of evaluating the complete sum, $\mu'$ can be computed after only a few operations. This is desirable if I constantly add, or remove data from my dataset. For instance, if I remove $x_k$, then:
$$\mu' = \frac{\mu N - x_k}{N-1}.$$
However I see that updating the standard deviation $\sigma$ is not so simple. Does anyone know a "quick" formula for updating $\sigma$? Thanks a lot. | Note that $$\sum \limits_{i = 1}^n (x_i - \overline x)^2 = \sum \limits_{i =1}^n (x_i^2 -2x_i\overline x +\overline x^2) = \sum \limits_{i = 1}^n x_i^2 - 2n\overline x^2 + n\overline x^2 = \sum \limits_{i = 1}^n x_i^2 - n\overline x^2$$ holds, where $\overline x$ denotes the mean of the $x_i$. Now you just need to update the mean and the sum of the squares of the $x_i$. | stackexchange-math | {
"answer_score": 4,
"question_score": 2,
"tags": "arithmetic, descriptive statistics"
} |
Python lowest price in dictionary
This is a follow up question. I know how to remove minimum in a list with `remove(min())` but not dictionary. I'm trying to remove the lowest price in the dictionarys in Python.
shops['foodmart'] = [12.33,5.55,1.22]
shops['gas_station'] = [0.89,45.22] | Specifically, for the example given :
shops['foodmart'].remove(min(shops["foodmart"]))
More generally, for the whole dictionary :
for shop in shops :
shops[shop].remove(min(shops[shop]))
The logic is the same as removing values from a list which you mention you know. `shops[shop]` is in itself a list as well in your case. So what you do on lists, is applicable here as well.
A faster and cleaner method as suggested by Lattyware would be :
for prices in shops.values():
prices.remove(min(prices)) | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": -3,
"tags": "python"
} |
How to React to an Introduction Email
So, someone (A) introduced me to someone else (B) via email, so that I can ask B questions and get advice. The email is directed at B, and I am copied. Should I wait for B to email me, or should I email B first? If the latter, should I reply to the original email and copy A, or should I just open another thread with B?
Also, I don't know if it is important or not, but the email ends like this:
> Thanks for connecting with him, he is copied on this email.
Needless to say, "him" means me. | I find it worrying to see so many questions like this. They make academia seem like a terrifying place. It really isn't. Standard rules of engagement apply (pun intended).
> So, someone (A) introduced me to someone else (B) via email, so that I can ask B questions and get advice. The email is directed at B, and I am copied. Should I wait for B to email me, or should I email B first?
Unless cultural rules say otherwise, **you should email B first**. Beyond saving B time (in emailing you unnecessarily), you can ask for what you want.
> If the latter, should I reply to the original email and copy A, or should I just open another thread with B?
**Reply to the original email, do not copy A, perhaps blind copy A** , maybe mentioning you've done so to avoid bombarding them with further mail, e.g., _Thanks for the kind introduction A (bcc to avoid further inclusion)._
(Don't start a new thread with B. That thread wouldn't include the introduction and B may forget who you are.) | stackexchange-academia | {
"answer_score": 1,
"question_score": 0,
"tags": "etiquette, email"
} |
Miner APIs are not found in web3.js package
How can I start and stop miner( `miner.start()`, `miner.stop()`) from my DApp if Miner APIs are available in web3.js package? I am using `web3 v0.20.6`. | You can sue Web3Admin, which extends web3 to give more methods regarding many ethereum tools.
here is their GitHub : < | stackexchange-ethereum | {
"answer_score": 1,
"question_score": 0,
"tags": "web3js, dapp development"
} |
I need a free php bug tracker
I need a free bug tracker for my small project. I need keep track of bug, todo list and test case. Any suggestion? | Check out mantis <
If it's a small project, though, you might want to think about using something with less overhead than a PHP-based system. Are you the only person working on it? A whiteboard and post-it notes might be less upkeep and could ultimately save you time and energy that would be better spent on the project itself. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 4,
"tags": "php, bug tracking"
} |
Python regex for one word
I have this dataframe where I'm trying to delete all one word responses, with/without punctuation and could have spaces in front too. Most of the values are full, long sentences but please find below the kind I am trying to remove.
column
---
thanks
hello!
really....
My try `textonly = re.sub('^.\w+\w+.$' , " " , df.column)`
error (even though dtype is string) : expected string or bytes-like object
Another try which seems to go through but doesnt change anything :/
`textonly = re.sub('^.\w+\w+.$' , " " , str(df.column))`
Please help identify what I'm missing | You can use
df['column'] = df['column'].str.replace(r'^\W*\w+\W*$', '', regex=True)
If you mean _natural language words_ by "words", i.e. only consisting of letters, you may use
df['column'] = df['column'].str.replace(r'^[\W\d_]*[^\W\d_]+[\W\d_]*$', '', regex=True)
The regex matches
* `^` \- start of string
* `\W*` \- zero or more non-word chars
* `[\W\d_]*` \- zero or more non-word chars, digits and `_`
* `\w+` \- one or more word chars
* `[^\W\d_]+` \- one or more chars other than non-word chars, digits and `_`
* `\W*` \- zero or more non-word chars
* `$` \- end of string. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python, regex"
} |
input box in asp.net c#
I need to create a simple input box on my website in C#. It should pop up, when i call it in the code like that
String input = InputBox("Name the file");
and then I need the use string the users enters later in the code In a .net application, it is pretty easy to accomplish, but how can i make it work in a web application? I think it should be possible with ajax, but it seems pretty complicated for such a (seemingly) trivial thing. Is there any kind of library or framework, that I can use for this right away?
thanks in advance | It sounds to me like the behavior you are looking for is to get a popup window with a text box for the user to enter a value and click ok. Is that right?
You're right in saying that it is more complicated with a web app. In a windows app, whenever you run the C# code, whatever happens, happens at that moment. It's pretty straightforward. However, in a web app, all of the C# runs before the page is even rendered in the browser. Therefore, C# in web forms can't _really_ pop up a window.
In order to get a popup, you'll need to do that with JavaScript. The textbox inside the popup should be an `<asp:Textbox>` control. You can use the Ajax Control Toolkit if youre most comfortable with .NET controls. If youre comforatble with jQuery, you should check out jQuery UI. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "c#, asp.net, inputbox"
} |
Android Studio Freezes
I use Android Studio 0.8.6 for Android Development, and when I'm editing a file, it will freeze, and I have to restart computer to close it, since System Monitor (I am on Ubuntu 14.04 LTS) won't close it. It's always the same file I'm editing, this never happens with any other file. It shouldn't matter, but the name of the file is `sun_vertex_shader.glsl`. There's no error, or log output, or anything.
Here's exactly what happens - I'm typing in the file, the cursor freezes, stops blinking, and the mouse pointer is an I-beam, no matter where in the window I move it. The window doesn't close when I press the X, and when I restart my computer and open Android Studio again, I start editing the file and seconds later, it happens again.
I know you probably can't help me without any error logs, but I couldn't find any. If you know where I could find them, I will post them here. | I found out what is causing this: the GLSL plugin I downloaded from here is causing Studio to freeze, as I have read in the comments. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "crash, android studio, ubuntu 14.04, freeze"
} |
how to remove duplicated tokens in solr
Followup question to Why solr RemoveDuplicatesTokenFilterFactory dont work?
How I can make solr remove duplicated words regardless of word position?
For example:
Field value: text word word text word word
Expected tokens after X filter: text word | It should be pretty easy to write your own TokenFilter to achieve this. One thing that might not be straightforward is the handling of the position increment (in case your are interested in running span of phrase queries over this field). If you don't know how to get started, you can look at StopFilter implementation. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "solr, duplicates"
} |
install_requires in setup.py depending on installed Python version
My setup.py looks something like this:
from distutils.core import setup
setup(
[...]
install_requires=['gevent', 'ssl', 'configobj', 'simplejson', 'mechanize'],
[...]
)
Under Python 2.6 (or higher) the installation of the ssl module fails with:
ValueError: This extension should not be used with Python 2.6 or later (already built in), and has not been tested with Python 2.3.4 or earlier.
Is there a standard way to define dependencies only for specific python versions? Of course I could do it with `if float(sys.version[:3]) < 2.6:` but maybe there is a better way to do it. | It's just a list, so somewhere above you have to conditionally build a list. Something like to following is commonly done.
import sys
if sys.version_info < (2 , 6):
REQUIRES = ['gevent', 'ssl', 'configobj', 'simplejson', 'mechanize'],
else:
REQUIRES = ['gevent', 'configobj', 'simplejson', 'mechanize'],
setup(
# [...]
install_requires=REQUIRES,
# [...]
) | stackexchange-stackoverflow | {
"answer_score": 13,
"question_score": 8,
"tags": "python, setuptools"
} |
Can you password restrict access to certaion projects with Cruisecontrol.net?
I would like to give access to a subset of projects to a user in cc.net. Is it possible to restrict access to some projects in cc.net?
Alternatively, is it possible to have a second cc.net installation on the same machine? | Yes, in version 1.5 only however.
CC.NET Security | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "cruisecontrol.net"
} |
pg_dump without setting search_path
When I use `pg_dump` to export schema from a database, it adds the following line at the beginning:
SELECT pg_catalog.set_config('search_path', '', false);
Is it possible set an option where `pg_dump` will not add this line? It is causing issues later when I try to execute other SQL commands, without the schema qualifier.
This is the `pg_dump` command I am using right now:
pg_dump -O -x -h <db-host> -p <db-port> -U <db-user> -d <db-name> --schema public --schema-only > public-schema.sql | No, there is no such option.
I recommend that you restore a dump with `psql -f dumpfile` rather than using `\i` to execute it in the current session. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 10,
"tags": "postgresql, pg dump"
} |
How to extract functionvariables
In R I have a function. I want to extract some variables in this function
get <- function() {
ra <- sample(2:23,1)
}
Say I want to get the value `ra` then I type `get$ra` but R gives me this error-message:
Error: object of type 'closure' is not subsettable.
I want to get `ra` as a variable so I can use it in my further calculations. | Is this possibly what you're after? (too long for a comment):
set.seed(1)
get <- function() {
list(ra=sample(2:23,1),somethingelse=sample(1:10,1))
}
Our function returns a names list, with `ra` and `somethingelse`. You can access by name using code like this:
get()$ra
#[1] 7
get()$somethingelse
#[1] 10
Or by assigning the whole list to a variable.
test <- get()
test
# $ra
# [1] 6
#
# $somethingelse
# [1] 9 | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "r"
} |
Preserving the order of a sequence of real numbers
If a have a sequence of real numbers ordered from greatest to smallest $Y_o\geq Y_1 \geq...\geq Y_k$ and I divide each number of the sequence by $\delta<0$, is the order of the sequence flipped, i.e. $\frac{Y_0}{\delta}\leq \frac{Y_1}{\delta}\leq...\leq \frac{Y_k}{\delta}$? | Yes, multiplying or dividing by negative numbers reverses inequalities. On the other hand, multiplying or dividing by positive numbers preserves inequalities. | stackexchange-math | {
"answer_score": 2,
"question_score": 3,
"tags": "inequality"
} |
Use of unicode in Django
Why is a unicode function required in models.py?
i.e,
def __unicode__(self)
return sumid; | It's not. If you define a `__unicode__()` method, Django will call it when it needs to render an object in a context where a string representation is needed (e.g. in the model's admin pages).
The documentation says:
> The `__unicode__()` method is called whenever you call `unicode()` on an object. Since Django's database backends will return Unicode strings in your model's attributes, you would normally want to write a `__unicode__()` method for your model. | stackexchange-stackoverflow | {
"answer_score": 24,
"question_score": 19,
"tags": "python, django"
} |
Wondering if I can change a cap value in a design
I am assembling a circuit from the ESP32 reference design.
Looking at value C1 page 18 < (10uF) but I don't have any of these on hand, I have 4.7uF and 100uF.
Would either of those sizes be an acceptable substitute?
!Reference schematic | That is a bulk capacitor for the ESP32 module. Since there is already capacitance on the board itself, that value is less critical. The 0.1uF is far more critical, but can be substituted for a 0.47uF or 0.33uF in a pinch.
I would choose the 4.7uF, but you could always put down two of them instead of 1 and that makes close to 10uF.
100uF would probably work, but the impedance of the capacitor will have somewhat different characteristics from the 10uF and may not be as effective (assuming they did their homework with the reference design). | stackexchange-electronics | {
"answer_score": 0,
"question_score": 1,
"tags": "capacitor, substitution"
} |
nginx max upload size elasticbeanstalk aws
i have a probleme whene i want to maximize upload size with nginx on elasticbeanstalk aws, i created a file .platform/nginx/conf.d/proxy.conf :
client_max_body_size 100M;
then i commited and eb deploy it works for a while and i could uploade files with big sizes with my dashboard but after a period (10 --> 15 min ) an error in the log comes after any request
21311#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: ***.**.**.***, server: , request: "GET / HTTP/1.1", upstream: " host: "***.**.**.**"
any suggestions to solve this probleme!! | for anyone who have the same probleme .. the solution that i found is to put the .conf file in
.platform\nginx\conf.d\elasticbeanstalk/proxy.conf
with content
client_max_body_size 1G;
proxy_buffering off;
proxy_request_buffering off;
it worked for me | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "nginx, amazon elastic beanstalk"
} |
package.json version error on visual studio cordova ionic2 template
I have used **this article** to create an ionic2 app.It is working fine.But on the `package.json` file where it shows below error.Can you tell me how to solve that? I'm using Resharper latest version with VS 2015 community edition.

def download(self, url, name):
request = self.client.get(url)
with open(name, "wb") as code:
code.write(request.content)
print "done"
The problem is that when the download is finished, python does not clear the memory, so everytime I download an mp3, the memory usage of the application raises by the size of the mp3. The memory does not get cleared again, leading to my app using a lot of memory.
I assume this has to do with how I save the file, or how requests.session works.
Any suggestions.
Edit: Here is the code: <
The relevant part is in lib/vklib.py | You could try streaming the content in chunks:
def download(self, url, name):
request = self.client.get(url, stream=True) # `prefetch=False` for older
# versions of requests
with open(name, "wb") as code:
for chunk in request.iter_content(1024):
if not chunk:
break
code.write(chunk) | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 5,
"tags": "python, python requests"
} |
How to select only a part of a UITableViewCell
I have table cells with an image on the left. Now, every time one taps the cell, the image changes, but I only want the image to change when the left area of the cell is tapped. How can I do this?
Right now I have:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
if (cell.imageView.image == [UIImage imageNamed:@"checkboxfull.png"]) {
cell.imageView.image = [UIImage imageNamed:@"checkboxblank.png"];
}
else if(cell.imageView.image == [UIImage imageNamed:@"checkboxblank.png"]) {
cell.imageView.image = [UIImage imageNamed:@"checkboxfull.png"];
//[alert show];
}
} | A table cell is just an `UIView`. Make a custom cell and use a `UIImageView` subclass or a button that responds to your taps.
Or use `- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event` of the table cell and compute the location.
For information on table cells look here | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "objective c, ios, uitableview"
} |
Rails arel query for matching multiple habtm records
I have a setup as follows,
Post
- has_and_belongs_to_many :tags
Tag
- has_and_belongs_to_many :posts
**THE PROBLEM:**
> I want to find all the posts which have `social`, `informative` tags in it, I can also use their ID's suppose `1` and `2`. Using arel or ActiveRecord or plain SQL.
I can find `posts` having `any` tags using: `post_tags[:tag_id].in([1, 2])`
I can find `posts` having `none` tags using: `post_tags[:tag_id].not_in([1, 2])`
But I can't do: `post_tags[:tag_id].in_all([1, 2])` that's because one record cannot match all the tag ID's ever.
How could I do this? | Found the answer!
posts = Arel::Table.new(:posts)
posts_tags = Arel::Table.new(:posts_tags)
tag_ids = [1, 2]
ids_predicate =
posts.
project(posts[:id]).
join(posts_tags).on(
posts[:id].eq(posts_tags[:post_id])
).
where(
posts_tags[:tag_id].in(tag_ids)
).
group(posts[:id]).
having(
posts_tags[:tag_id].count.eq(tag_ids.count)
)
Post.where(posts[:id].in(ids_predicate))
Pretty cool I think! | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, ruby, activerecord, has and belongs to many, arel"
} |
How do I make the Expo Camera View Clickable
I am using the Expo Camera in React Native. I want to snap a picture when the Camera view is tapped. How do I do this?
I have tried putting the TouchableOpacity inside the camera tag but when i try to log to console when the user taps the camera view nothing happens
<Camera style={{ height: '100%', width: '100%', display: this.state.camera }} type={this.state.type} autoFocus={'on'} ratio={'4:3'} focusDepth={0} ref={(ref) => { this.camera = ref }}>
<TouchableOpacity style={{width:'100%', height:'100%'}} onPress={()=>console.log("Testing cam")}>
</TouchableOpacity>
</Camera>
I want it to print the "Testing Cam" in the console when i tap on the Camera View | You should put `Camera` inside `TouchableOpacity`, and not other way around:
<TouchableOpacity style={{width:'100%', height:'100%'}} onPress={()=>console.log("Testing cam")}>
<Camera style={{ height: '100%', width: '100%', display: this.state.camera }} type={this.state.type} autoFocus={'on'} ratio={'4:3'} focusDepth={0} ref={(ref) => { this.camera = ref }}>
</Camera
</TouchableOpacity> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "reactjs, react native, expo"
} |
Puppet & Facter - how to determine if running Cent 6 or Cent 5
How would you use facter and puppet to determine if the OS is running Cent 6.x or Cent 5.x ?
facter operatingsystemrelease
6.4
I only care about the major release (6)
I've thought about using awk, but there must be a better way that is more 'puppet manifest' friendly.
#This works, but is ugly trying to use this in a puppet manifest
facter operatingsystemrelease |awk -F. '{print $1}'
6
**Update** :
It looks like the newer versions of facter have some additional information about major releases that isn't in my version. My initial provisioning needs to assume that facter is out of date.
facter --version
1.6.4
puppet --version
2.7.20
I've tried searching for any additional facts that might show the major release, with the following command
facter |grep 6 | There is **operatingsystemmajrelease**
% facter operatingsystemmajrelease
6
If you have redhat-lsb-core package installed, facter will get as well the family of lsb-provided facts (which includes **lsbmajdistrelease** ):
% facter |grep ^lsb
lsbdistcodename => Final
lsbdistdescription => CentOS release 6.4 (Final)
lsbdistid => CentOS
lsbdistrelease => 6.4
lsbmajdistrelease => 6
lsbrelease => :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
**NOTE:** You need at least **Facter 1.7** in order have `operatingsystemmajrelease`. Core facts in Facter 1.6 are quite limited. | stackexchange-serverfault | {
"answer_score": 12,
"question_score": 5,
"tags": "puppet, awk, facter"
} |
Google maps generate link
I have google maps embedded in my website. Its has markers and when clicked, it displays the property information at the position. (infobox). Now the user wants the following functionality:
* * *
I search for a place , the map displays the place with properties. After I drag the map and get some other property, I would like to share this one to some body. can I get a link to share the dragged position?
* * *
I know we can get the link in maps.google.com . It changes whenever we drag. But how to do it in our website? Is there a way in google maps api to get that link? | Listen to events on the `Map`
The `idle` event is particully useful, but can use say `bounds_changed` to get events while dragging (or even the `drag` event itself!).
In that event update whatever link you are talking about. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "google maps, google maps api 3"
} |
Is it feasible to train a Machine Learning Model (with image inputs) in an average personal computer?
There are lots of examples of machine learning systems that can recognize objects and extract other information from images with very high precision. To train the models of such systems is necessary (I guess) a computer with a lot of computational power.
My question is: For a system with images as inputs, depending on the complexity of the problem, is feasible to train a model in an average laptop? It will take to much time?
I know the time taken to train any machine learning model will be a function of lots of variables. I really don't expect a quantitative answer here, I just want to know whether I will be forced to upgrade my computer to develop and train machine learning models that have images as inputs. | You may play around on an average laptop but training will be very slow and you will be limited on the size of your model.
Once you try to build something more serious you will run out of memory very fast. A system with a GPU is recommended if you want to really do things like image recognition. If you buy something I would not go for any GPU with less than 8 GB memory and for an X99 motherboard to keep the flexibility to add a second GPU on full speed later if needed.
Don't mix up image recognition running on phones etc. Those are trained models and actually just being applied that is much easier process. Training is way much more expensive. | stackexchange-ai | {
"answer_score": 0,
"question_score": 0,
"tags": "neural networks, machine learning, image recognition, training, computer vision"
} |
DynamicProxyFactory Usage
need some help with `DynamicProxyFactory`, i am creating a small app with WCF [C#], need to dynamically generate the proxy classes at run time.
I am not able to find any good page on how to use it! | Have you read this?
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, .net, wcf, dynamic proxy"
} |
$|y-x|^{-7} = C^*$?
I'm trying to solve this differential equation - $$\frac{dy}{dx} = \frac{y(y-8x)}{x(x-8y)}$$ and to get the answer for $$|y-x|^{-7} = C^*?$$ I used the stuff we learned- that $$\frac{dy}{dx} = F\left(\frac{y}{x}\right) = F(v)$$ and got here: $$\frac{1-8v}{v\cdot(9v-9)}\cdot \frac{dv}{dx} = \frac{1}{x}$$ $$\frac{-1}{9}\cdot\int(\frac{1}{v}+\frac{7}{v-1})\,dv = \int\frac{dx}{x}$$ $$\frac{-1}{9}\cdot(\ln(v)+7\cdot(\ln(v-1)))=\ln(x)+c$$ and after integration I'm stuck here- $$e^{\frac{-1}{9}}\cdot(v-1)^{7}\cdot v = x+c$$ and now I don't know how to continue. and I don't understand what $y(x)$ is supposed to be. What do I do from here? | With the correct application of the exponentiation rules, you should get from the logarithm equation to $$ \ln|v|+7\ln|v-1|=-9\ln|x|+\tilde c\\\ v(v-1)^7=Cx^{-9}\\\ y(y-x)^7=Cx^{-1} $$ | stackexchange-math | {
"answer_score": 0,
"question_score": 1,
"tags": "integration, ordinary differential equations, partial differential equations"
} |
Elastix - Prioritize incoming DDI
i need a little help regarding the queues. I have a situation where i want to set an incoming number as VIP number so whenever that number calls in, it jumps to first place. For example, we have 20 calls in queue, VIP number calls in, he would automatically need to be first in queue.
Any ideas ? I know that there's a blacklist function in Elastix, but i couldn't find any VIP list functions in there. | You have use queue priority module in elastix web.
If you have no such menu entry, you have use Module Admin and install it. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "asterisk, voip, elastix"
} |
What is the noise my Canon 100mm macro makes when image stabilization is enabled?
I'm currently using a brand new Canon 100mm f/2.8L macro lens. I noticed that when IS is enabled and I press the button mid-air (no shoot), I hear a little noise. Is it the image stabilizer? With IS disabled, the lens is absolutely silent. I'm asking because I have another lens with IS (18-55mm standard kit lens), and when IS is enabled I hear absolute nothing. | Yes, that's what it is. Different lenses use slightly different methods for implementing image stabilization, and it's more audible in some than others. Among other things, longer lenses need more motion to compensate. If you listen _very_ closely, I bet you can hear it on the 18-55mm as well. | stackexchange-photo | {
"answer_score": 5,
"question_score": 2,
"tags": "lens, canon, image stabilization, sound"
} |
Removing rows with all NA's, from data.frames within a list
Example Data:
df1 <- as.data.frame(rbind(c(1,2,3), c(1, NA, 4), c(NA, NA, NA), c(4,6,7), c(4, 8, NA)))
df2 <- as.data.frame(rbind(c(1,2,3), c(1, NA, 4), c(4,6,7), c(NA, NA, NA), c(4, 8, NA)))
dfList <- list(df1,df2)
colnames <- c("A","B","C")
dfList[[1]]
V1 V2 V3
1 1 2 3
2 1 NA 4
3 NA NA NA
4 4 6 7
5 4 8 NA
dfList[[2]]
V1 V2 V3
1 1 2 3
2 1 NA 4
3 4 6 7
4 NA NA NA
5 4 8 NA
How do I remove the rows that are empty/have ALL values NA, within each of the data.frames in the list?
Desired outcome:
V1 V2 V3
1 1 2 3
2 1 NA 4
3 4 6 7
4 4 8 NA
V1 V2 V3
1 1 2 3
2 1 NA 4
3 4 6 7
4 4 8 NA | You can use `lapply` to iterate over the list and `rowSums` to drop rows with all `NA` values.
lapply(dfList, function(x) x[rowSums(!is.na(x)) != 0, ])
#[[1]]
# V1 V2 V3
#1 1 2 3
#2 1 NA 4
#4 4 6 7
#5 4 8 NA
#[[2]]
# V1 V2 V3
#1 1 2 3
#2 1 NA 4
#3 4 6 7
#5 4 8 NA | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "r, list, dataframe, na"
} |
Selectively Disable cells of row in DataBound DataGridView
I need to be able to turn off some cells in a row based on a boolean flag. If the flag is true I everything should be enabled and visible like normal. If the flag is false however I need to have several cells in the row made invisible and readonly. | You can handle the CellPainting event, check the status of your flag there and then paint the cell to be shown/hidden.
This link on MSDN may help you in this:
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, winforms, datagridview"
} |
Set of orthogonal vectors in $\mathbb{R}^n$
How can we show that a set of pairwise orthogonal vectors in $\mathbb{R}^n$ has size at most $n$? I know it seems very intuitive, but not sure what the formal proof would look like (whether "elementary" or not). | Take a linear combination of any set of $k$ vectors with this pairwise-inner-product property. Suppose this linear combination happens to equal zero. Dot it with each of them in turn to show that each coefficient is zero. Hence the vectors are linearly independent.
In an $n$-dimensional space, a linearly independent set has at most $n$ elements, hence $k \le n$.
Note though, that the "each coeff is zero" step requires that the elements of your set all be _nonzero_. Otherwise the set $\\{ (1, 0), (0, 1), (0, 0) \\}$, all of which are pairwise orthogonal (at least by the "orthogonal means dot-product-is-zero" definition), would violate your conclusion. | stackexchange-math | {
"answer_score": 4,
"question_score": 1,
"tags": "real analysis, vector spaces"
} |
Is it true that $[T_A]=[L_A]$?
Given two linear transformations, $T_A: M_n(F)\rightarrow M_n(F), T_A(B)=AB$ and $L_A:F^n\rightarrow F^n, L_A(v)=Av$, I am trying to show that their eigenvalues are the same.
I would like to say that their matrix representations are equal, i.e. $[T_A]=[L_A]$ with respect to some basis. If this is true, then $\det(T_A-\lambda id_{M_n(F)})=\det([T_A-\lambda id_{M_n(F)}])=\det([T_A]-\lambda[id_{M_n(F)}])=\det([L_A]-\lambda I_n)=\det(L_A-\lambda id_{F^n})$.
Am I on the right track? Is my initial assumption true? | No, this can't be true, as $\dim F^n=n$, so $[L_A]$ is an $n\times n$ matrix, but $\dim M_n(F)=n^2$, so $[T_A]$ will be much bigger, an $n^2\times n^2$ matrix.
To prove they share the eigenvalues, show that
* any eigenvalue of $L_A$ is an eigenvalue of $T_A$,
* any eigenvalue of $T_A$ is an eigenvalue of $L_A$.
> Consider an element of $M_n(F)$ as an $n$-tuple of the column vectors: $B=(b_1|\dots|b_n)$.
> Then $T_A(B)=AB=A\cdot(b_1|\dots|b_n)=(Ab_1|\dots|Ab_n)$. | stackexchange-math | {
"answer_score": 0,
"question_score": 2,
"tags": "linear algebra, matrices, proof verification, eigenvalues eigenvectors, linear transformations"
} |
Can't restore GPO to new domain/new OS/new NETBIOS name
I'm trying to restore from an old GPO backup for which the OS installation no longer exists, but I'm not having much luck.
Some things have changed for the new installation:
1. The NETBIOS name (was `SERVER2`, is now `SERVER3`)
2. The GPO itself (was `Default Domain Policy`, is now `Custom Domain Policy`)
3. The OS version (was `Server 2012 RTM`, is now `Server 2012 R2`)
But no available backups are showing in the list when I run the Restore Wizard:
;
box-sizing: border-box;
margin: 0;
padding: 0;
height: 200px; /* Make sure the body is visible */
width: 200px;
}
<body>
</body>
I am learning CSS, please help me! Thank you in advance! | Just set background separately from the body, i.e. you can use pseudoelement and filter just this pseudo
html {
width: 100%;
height: 100%;
}
body {
width: 100%;
height: 100%;
position: relative;
box-sizing: border-box;
margin: 0;
padding: 0;
}
body::before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: linear-gradient(100deg, #3B53D6,#4AFAFA);
filter: blur(10px);
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "css"
} |
Playing 2 videos together in python
I would like to play 2 videos together using python. Apart from that, I would like to pause , forward and rewind just 1 video at certain times in other video. I started implemented this using Python Gstreamer and its possible to play 2 videos together but the second part is complicated. Does any one know python libraries which can do this ?
Thanks a lot, Thothadri | Take a look at GStreamer GNonLin plugins. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "python, python gstreamer"
} |
How to string concatenate two bindings in asp.net?
I would like to string concatenate two bindings into one string. How can I do this? I tried the below, but only LastName shows up when I run the application.
<asp:Label ID="txtFacultyName" runat="server" Text='<%#Bind("FirstName") + Bind("LastName") %>'/> | There are a couple of options.
1. Create a combined property in your code behind/model:
// cs
public string FullName
{
get { return $"{FirstName} {LastName}"; }
}
// aspx
<asp:Label ID="txtFacultyName" runat="server" Text='<%#Bind("FullName") %>'/>
2. Use `Eval`. Eval will allow one-way binding which is fine for displaying in an `asp:Label`
<asp:Label ID="txtFacultyName"
runat="server"
Text='<%# string.Format("{0} {1}", Eval("FirstName"), Eval("LastName")) %>'/> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "asp.net, string, gridview, binding"
} |
jquery fadeout, fadein, wait, fadein again broken
I am trying to store the content of a div, temporarily display a thank you message, and then put back the original content of div. For some (possibly, many) reasons, it is failing, and I cannot figure out why. What have i done wrong?
$('#btn').on('click', function() {
//store original content
//appears to be a text string, rather than a jquery object
var content = $('#container').html();
console.log(content);
$('#container').children().fadeOut(800, function() {
$('#container').html('<div id="thanks">Thanks!</div>', function() {
$('#thanks').fadeIn(800, function() {
var t=setTimeout(function(){$('#container').html(content)},3000)
});
});
});
});
< | the html function is synchronous... there's no need for a callback: <
$('#container').children().fadeOut(800, function() {
$('#container').html('<div id="thanks">Thanks!</div>');
$('#thanks').fadeIn(800, function() {
$(this).delay(3000).fadeOut(800, function() {
$('#container').html(content).children().hide().fadeIn(800);
});
});
});
Also, `delay` is going to be cleaner (and more concise) than setting a timeout in this case. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, jquery, settimeout"
} |
How to get integer value from byte array returned by MetaMessage.getData()?
I need to get the tempo value from midi file. I found out, that the set_tempo command has value 0x51, so i have this piece of code:
for (int i = 0; i < tracks[0].size(); i++) {
MidiEvent event = tracks[0].get(i);
MidiMessage message = event.getMessage();
if (message instanceof MetaMessage) {
MetaMessage mm = (MetaMessage) message;
if(mm.getType()==SET_TEMPO){
// now what?
mm.getData();
}
}
}
But the method getData() returns an array of bytes! How can I convert it to normal human form, a.k.a. integer? I have read it is stored in format like this: "tt tt tt", but the whole big/little endian, signed/unsigned, and variable length things make it too confusing. | _Tempo_ is a 3-byte big-endian integer and _Bits Per Minute_ is calculated as
`BPM = 60,000,000 / (tt tt tt)`
byte[] data = mm.getData();
int tempo = (data[0] & 0xff) << 16 | (data[1] & 0xff) << 8 | (data[2] & 0xff);
int bpm = 60000000 / tempo; | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 1,
"tags": "java, int, arrays, midi, javax.sound.midi"
} |
Way to make Windows Phone 7 Panorama Items Text gather up?
How would I allow panorama items text to gather up like in the picture below? (By the way the image is not mine).
Notice how the Panorama Item titles are like "Contacts Chats" not spaced out like regular Microsoft panorama has it? How would I do that?
Thanks.
!enter image description here | I'm pretty sure that is a Pivot Control, which looks similar to a Panorama Control.
There's a good video at Channel 9 on the two controls: Windows Phone Design Days - Pivot and Pano | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "windows phone 7"
} |
how to check for activity or lack thereof on a unix file directory using perl or unix commands
**Scenario:** I have a process where many files are being copied (scp'd) to a DestinationServer by Host1, Host2, Host3, Host4 for example. Going to the same common directory: DestinationServer:/home/target. All the files are unique so no files will be overwritten. Host1-Host4 will have a cronjob that will launch their scp script to DestinationServer. The caveat is the Hosts are in different time zones, locations. So, they will finish at different times.
**Need:** Since the files are being scp'd to Destination:/home/target, what is the best way to programmatically check when those scp's from the other Hosts are done??
**Options:** My options are to programmatically do this either in perl or shell if possible.
What do I look for, what unix commands or perl modules could I use to help determine when the processes would finish? Any ideas, examples would be great! Thanks. | Use a Maildir kind of approach: copy all files to a temporary directory, then after the transfer is complete have the originating host perform a rename into the target directory via ssh. That way when a file appears in the target directory, you know that it is complete.
I suggest this because if you just scp files into the target directory and monitor the directory in whatever way, you cannot distinguish a complete transfer from an interrupted scp command or a network failure. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "perl, shell, unix"
} |
Use VBA to tell Outlook to print to a specific printer
Is there any way to write a VBA macro in Outlook that forces a printout to a specific printer (even if it's not necessarily the default printer), similar to the Word
Application.ActivePrinter = "Printer Name"
option? I'd like to create a button that prints the current email and attachments to a specific printer (in this case a PDF printer, but I'm guessing it should be the same principle regardless), but can't seem to find a way to force which printer is used in the code. | No, Outlook only exposes `MailItem.PrintOut` method.
You can save the message in the DOC or RTF format using MailItem.SaveAs, open it in Word, and use the Word Object Model to print it. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "vba, printing, outlook"
} |
SmtpMail - Change the "From Address" to Name
I use SmtpMail for users to forward site content. The user fills out a form which includes first name and email.
The email sent has the full email address as the "From address" in the recipients inbox (they see From: [email protected] while I want them to see From: Joe).
How can I format the "From address" to be the users inputted first name?
Thanks! | The format I ended up using was: `mailer.From = name & "<" & emailer & ">"`
This formats the from address to include Name as well as Email address. It will be displayed in most email clients as `Joe <[email protected]>`. This was my desired outcome.
Thank you Knslyr and lincolnk for the support. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "vb.net, email, smtp"
} |
How to create a view of all elements in many collections in Java?
I have this boilderplace code
for(Person p: school.getStudents())
p.setName(null);
for(Person p: school.getTeachers())
p.setName(null);
for(Person p: school.getStrangers())
p.setName(null);
I it possible to "combine" all those collections in a view (ie. avoid copying / allocating memory like via `addAll()`) and iterate over the view?
e.g.
for(Person p: allOf(school.getStudents(), school.getTeachers(), school.getStrangers())
p.setName(null); | You can use Guava's `Iterables.concat()` method. It creates a view over multiple iterables passed to it, and then you can iterate over the resulting `Iterable`. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "java, collections"
} |
How to show the space is totally bounded?
the space the Real line with bounded metric (i.e. d/(1+d), d: euclidean)
we know that totally boundedness means that there exists a finite epsilon-net. we first approached to question by directly try to find finitely many points s.t. their metric balls cover the space. then, tried , by contradiction, but failure. | HINT: Let $d_b$ be the bounded metric, so that $$d_b(x,y)=\frac{|x-y|}{1+|x-y|}$$ for all $x,y\in\Bbb R$. Suppose that $m,n\in\Bbb Z$ and $m\ne n$; then $d_b(m,n)\ge\ldots\;$? | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "real analysis, functional analysis, metric spaces"
} |
Stupid question: does my rear derailleur have a hanger?
I don't see it. The place where it should be seems to be part of the frame. If not, why not?
 bend it back to shape. | stackexchange-bicycles | {
"answer_score": 5,
"question_score": 2,
"tags": "derailleur rear"
} |
What does "this function will fuse" mean?
The documentation for scanl says "this function will fuse". What exactly does _fuse_ mean here? Is it bad? | <
(and, for more information: <
If a function will fuse, that is a good thing. It means that a chain of functions can be merged into one function, which means less allocation, less stack, and more speed! Awesome!
Here's a trivial fusion: `map f . map g` \----> `map (f . g)`.
As detailed above, there are many others that get applied by the RULES of the standard library as well. | stackexchange-stackoverflow | {
"answer_score": 13,
"question_score": 13,
"tags": "haskell, terminology"
} |
Keep a live clone of a machine into another
I am trying to find the easiest and most elegant solution to keep two desktops running that are clones of each other. I have a machine running cobbler. Every once in a while a few delicate changes are made to it (New images, some setting changes). I would like there to be another machine that is constantly running on the same network, and that clones the other machine overnight every day (In case the primary one breaks). The OS is CentOS 6.3. My idea was to have a script that runs automatically that creates a backup of the main one using tar. Sends it to the clone using scp. And another script on the clone that daily installs that backup. But I believe there might be a better way to keep them in sync (that uses versioning to just keep track of the differences). | A widely used solution to this problem of how to maintain duplicate machines attacks the problem from a slightly different angle - use a provisioning tool such as Ansible ( or puppet / chef) to script the set up of one machine as required, then use the Ansible scripts to clone a second ( or third, or fourth...) machine as needed. Any change required for the setup is first tested on a staging machine, and then written into the Ansible script to be applied to the main machine, giving a so called 'immutable' infrastructure. Any data on the machine that is not described by the Ansible scripts is then backed up and restored as part of the provisioning process.
Your machine 'clone' then consists of a set of provisioning scripts plus backups, which should be easier to manage, and smaller in size than a direct clone.
With this setup, creating a duplicate machine is simply a case of running the scripts on a freshly cobbled OS and applying the backups. | stackexchange-unix | {
"answer_score": 3,
"question_score": 1,
"tags": "linux, centos, backup"
} |
What does the command "Sudo apt-get install *" do?
I'm just wondering what would happen if you typed in the titular command in a terminal, but not curious enough to try it. Does anyone actually know? | Nothing particularly interesting. `*` is expanded by the shell as a list of all the filenames in your current directory, and chances are that most of those will not be valid package names.
If you did pass `apt-get install` a list of all available packages, installing them all would fail (after spending quite a while thinking about dependencies), because at least some of those packages will conflict with each other. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -1,
"tags": "linux"
} |
Ignore a specific file in resource directory
This is my .gitignore file:
HELP.md
tmp/
target/
!**/src/main/**
!**/src/test/**
How can I exclude only this file:
src/main/resources/application.properties
Thank you | It should be fairly easy:
HELP.md
tmp/
target/
!**/src/main/**
!**/src/test/**
src/main/resources/application.properties
should work.
In case it doesn't, as it appears to be your case1, git allows you to ignore files, but remember this is a _local setting_ and it _will not be pushed_ to any other repository: go to `.git/info/exclude` and edit the file. It works like `.gitignore`.
Also remember: `.gitignore` has an higher priority on your `info/exclude` (source).
* * *
1\. _this might be due to the fact that you have multiple_ `.gitignore` _files in your directory, and thus there is overmatching of patterns._ | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "gitignore"
} |
Get Windows Authentication Token Using Javascript to have Integrated Security (NOT using IIS)
I want to authenticate users on a web application. The users are already logged into their Windows Network. Notice, this is NOT Internet Information Server. I have a Java Application Server on the other side. Is there a way using Javascript or something, so that a Windows Authentication can be taken, then sent to the server, and on the server, that token being validated (assuming the server is on the same network). I have found that you can convert a token into a Windows Principal So I need the Client part. A way to send that token to the server.
Any ideas? | If you setup your Java web application to support NTLM authentication, e.g. by using the HttpServletFilter from the Samba Java library, this should work without implementing any client side JavaScript.
Depending on which browser the client is using, you may however have to configure the browser to enable NTLM authentication against you server. If I'm not wrong, IE is by default configured to allow transparent NTLM authentication against servers on the local network, but in Firefox, you have to enable NTLM for each specific server address. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "javascript, security, authentication, integrated"
} |
Does an iOS app automatically check for new versions?
Do I need to implement functionality within my app to check the store for newer versions, or is this done for you automatically? If I do need to do this, how would I go about it? | Its done automatically by the app store. When the user enters to the App Store on his iPhone and theres a new version the "Updates" count will increase and notify the user.
Some like posting this stuff as Push notifications for the user, but many users don't appreciate it much :) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "objective c, ios, cocoa touch"
} |
Вывести слaгаемые используемые при расчёте числа.Python
Ну могу понять как вывести все участвующие в расчёте числа... Само решение у меня правильное, не могу вывести согласно образцу весь путь сложения....
Решение должно быть через "while"....
Пример:
Число: 10
Cложение чисел 1 + 2 + 3 + 4 = 10
Мой код:
num = 1
summa = 1
x = int(input("Число: "))
while summa < x:
num += 1
summa += num
print("Сложение чисел", x//num, "+", num, "=", summa ) | Можно воспользовать аргументом `end` функции `print`, который отвечает за то, что будет в конце выводимой строки и переписать ваш код так:
num = 1
summa = 1
x = int(input("Число: "))
print(f"Сложение чисел: { num } ", end='')
while summa < x:
num += 1
summa += num
print(f"+ {num} ", end='')
print(f"= {summa}") | stackexchange-ru_stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, while"
} |
"UML is the worst thing to ever happen to MDD." Why?
William Cook in a tweet wrote that:
" _UML is the worst thing to ever happen to MDD. Fortunately many people now realize this ..._ "
I would like to know the reasoning behind that claim (apparently, I'm not referring to his personal opinion).
I've noticed that many people out there don't like UML that much. Also it is worth mentioning that he is in academia, where UML is preety much the holy grail of effective design and modelling. | Well, I'm the academic who posted the original tweet. Tweets are not meant to be scholarly articles. They are advertisements, and I think they can also be controversial. Here are my follow-up tweets:
1) UML was created to model OO designs. It effect you are modeling the code of a system, not the system's behavior. UML is at wrong level.
2) the idea that 7 (or 13) diagram formats in UML can cover everything is crazy. What about GUIs, web wireframes, authorization, etc. ???
3) UML has encouraged the idea that models must be graphical. Ridiculous! Text and graphic models are both useful and often interchangeable
4) UML is at once too large and complex and at the same time very limiited. Stereotype and profiles are not effective for usable extensions.
Note that I'm not necessarily saying UML is bad. I'm simply saying that it is not helping the goal of "model-driven development", which is what I'm interested in. I don't understand the comment about "holy grail". | stackexchange-softwareengineering | {
"answer_score": 44,
"question_score": 17,
"tags": "design, uml, mdd"
} |
Can I edit a style dynamically?
I'm currently developing an app which should be totally customizable by endusers. Imagine the application has many activities with some `TextViews`, `Buttons`, etc.
So the client can create a XML file like this one:
<style >
<h1>25dp</h1>
<h2>30dp<h2>
<actionbar>#cecece</actionbar>
</style>
As you can imagine, for example, there are several TextViews which are always "titles" so they should always take this `h1 value`.
I know I can parse this XML file and **for each** textview, apply this style manually, but this is not a good way of achieving this because if I had 3000 textViews, I should manually edit them all.
**What I want is to "edit" the actual Style programmatically.**
Any tip? | You can't access a resource file in the created APK as they are compiled into it. So your idea to "customizable" styles works only in the following scenario:
1. your app is a library project
2. your client uses that library project and create a style which extends/overwrites your own style and compile that into a new APK
You are not clearly telling us if the "enduser" is a user of your app/apk or a customer that can do the above mentioned modifications.
An alternative might be to create your own extensions of TextViews, Buttons etc which can load your style set. You need to create your own style language for that and you need to make sure that the custom views understand and apply them.
A lot of work, if you ask me... I would, in general, suggest to make different themes so that the customer can pick the best suited for them... | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "android"
} |
Difference between $\vec{\omega}\times(\vec{\omega}\times\vec{r})$ and $-|\omega^2|\vec{r}$ in circular motion
I am a new user in the Physics Exchange and I am currently studying rotational dynamics.
So I am encountering a problem where it is stated that $\vec{\omega}=-6\vec{i}+4\vec{j}+12\vec{k}$ with $|\omega|=14$ and $r=0.3\vec{i}-0.4\vec{j}$.
I know that there are two formulas to express the normal acceleration, namely $$\vec{\omega}\times(\vec{\omega}\times\vec{r})$$ and $$-|\omega|^2\vec{r}$$
However, when I use the two formulas, I get different answers. Using the first formula involving cross products, I get $\vec{a_{n}}=4.8\vec{i}+3.6\vec{j}+1.2\vec{k}$ while the second formula gives me $\vec{a_{n}}=-58.5\vec{i}+78.4\vec{j}$.
**So my question is** : Why is there a difference when using $\vec{\omega}\times(\vec{\omega}\times\vec{r})$ versus $-|\omega|^2\vec{r}$ in circular motion? | > **So my question is** : Why is there a difference when using $\vec{\omega}\times(\vec{\omega}\times\vec{r})$ versus $-|\omega|^2\vec{r}$ in circular motion?
There is a difference because they are different.
The difference is literally: $(\vec \omega \cdot \vec r)\vec \omega$.
In other words: $$ \vec \omega \times(\vec \omega \times \vec r) = (\vec \omega \cdot \vec r)\vec \omega - |\omega|^2\vec r $$
Therefore, these two things ($\vec \omega \times(\vec \omega \times \vec r)$ and $- |\omega|^2\vec r$) are only the same when $(\vec \omega \cdot \vec r)\vec \omega = 0$. So, assuming $\vec \omega \neq 0$, this means that you need to have $\vec \omega \cdot \vec r=0$ for there to be no difference between the two. I.e., if $\vec \omega$ and $\vec r$ are orthogonal then the two quantities are the same, otherwise they are not the same.
In your case $\vec \omega \cdot \vec r = -0.2 \neq 0$, so the two quantities are not the same. | stackexchange-physics | {
"answer_score": 2,
"question_score": 0,
"tags": "homework and exercises, vectors, rotational kinematics"
} |
C: Is this type of initialization correct?
int startingPoint[2]={i,j};
I got this after reading an online code.Is this correct? Means if values of i and j can be changed at runtime before this statement, will this initialize the array with the correct values? Please explain. | This works in C99 but not in C89. | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 3,
"tags": "c"
} |
Reservoir sampling of distinct values
I'm faced with a situation where I need to get _m_ samples from a data stream (without replacement). Only one pass through the data is possible.
In my case, the stream contains many duplicate values, and I need to make sure that my sample won't include any duplicate values. It is important to note the the number of distinct values in the stream is huge as well (to big to fit memory).
Standard reservoir sampling algorithms (e.g. Algorithm R) ensure that the probability of any **index** being sampled is equal or about equal. In my case however, I need to make sure that the probability of any **value** being sampled is equal, or about equal.
Is there any way to achieve this? | This is something that min-wise independent hashing is good for. (See a wikipedia explanation here. The idea is to use a family $\mathcal{H}$ of hash functions so that when you pick a random function $h\in H$ from the family, for any set $S$ of $n$ elements, for any $x\notin S$, $\Pr_{h\in \mathcal{H}}[h(x) < \min_{y\in S} \\{h(y)\\}] = \frac{1}{n+1}$. This means that every element in $S$ has the same likelihood of being the only one with the smallest hashed value.
As you scan the stream, keep track of the smallest hashed value that you have seen, and whichever element was mapped to that value is your sample. There are families of hash functions that are _almost_ minwise independent families. For example a paper by Dahlgaard and Thorup . If you want to sample $k$ elements you could do this naively using $k$ hash functions, but you could also use ideas from bottom-$k$ sketching with only one function. See this paper by Thorup. | stackexchange-cstheory | {
"answer_score": 5,
"question_score": 7,
"tags": "ds.algorithms, pr.probability, streaming algorithms"
} |
Blockchain Consensus 51% vs 50%
All explanations of Blockchain consensus algorithms refer to 51% as the minimum percentage for confirming nodes. Why would a smaller percentage not work, as long as it was strictly greater than 50%? Is this to avoid metastability issues in the consensus dynamics that could result from a percentage that was too close to 50% making it less decisive? If so, why not make it 52%? Is there something special in some tradeoff that makes 51% special? | 51% is just a notation for (n/2 + 1) where n: the total number of nodes participating in the consensus algorithm. I agree that it is a bad notation, more precisely it should be something like 50% + ε.
In academic papers you might find relations with the number of Byzantine nodes f in the system. So for PoW consensus, n > 2f + 1 (which is equivalent to the statement that at more that half of the nodes should be "honest"). For PBFT consensus in permissioned blockchains, it will be n > 3f + 1 (which translates to honest nodes should be more than double of the Byzantine nodes, or using the "bad" notation, 66.6666% + ε). | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "blockchain, consensus"
} |
Research Tree glitches in X-com TFTD?
I have recently started to replay this game, and I have a dim recollection that there are several glitches in the research tree, such that if you research the wrong thing first, you could end up in a situation where you can't research what you need to complete the game. Is there a complete list of all of these glitches? | There looks to be a full discussion on this page from UFOPaedia. A basic recap is
> **Glitches in the System**
>
> There are two major occasions where research can grind to a halt:
>
> * An alien is required to further research AFTER certain projects are completed
>
> * An object is needed in storage before research is completed
>
>
So if X is a trigger to unlock some new research, but it also requires A and B, you need to make sure that you have A and B when you complete X. Otherwise, you may need to complete X again (in the case of interrogations) or be stuck completely in some cases.
The page lists all the places where you can get stuck and how to avoid it. | stackexchange-gaming | {
"answer_score": 3,
"question_score": 3,
"tags": "x com terror from the deep"
} |
How can I get Play Google accounts?
How can I get Play Google accounts? If I use
AccountManager manager = (AccountManager) getSystemService(ACCOUNT_SERVICE);
Account[] list = manager.getAccounts();
It gives device accounts list. Those account lists are not the same. | This is how I do it :
<
There is good documentation around that will help you with setting this up. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "java, android, google play"
} |
adding Artifactory.newServer to jenkins pipeline
I would like to instantiate a an instance of a Artifactory.newServer object in a jenkins pipeline. This object is instantiated like so
def rtServer = Artifactory.newServer url: SERVER_URL, credentialsId: CREDENTIALS
My question is where do I set the `SERVER_URL` and `CREDENTIALS` in jenkins. The documentation on the jenkins plugin does elaborate on this: < but I need some help understanding how to reference the environment variables in the Jenkins file itself. I am using a simple pipeline job. Any help with this would be much appreciated. | The correct way to instantiate a server object is like so
rtServer = Artifactory.newServer url: 'server', username: username , password: password
To set this up properly you'll need to go to **Manage Jenkins** select the artifactory plugin and create a new artifactory server. After I did that everything worked just fine. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jenkins, artifactory"
} |
Why Scala can't inferred type of method without parentheses and dots
I wrote simple code, that returns immutable map of characters and their indexes as vector:
def indexes(string: String): Map[Char, Vector[Int]] = (0 until string.length).
foldLeft(Map[Char, Vector[Int]]()){
(m, i) => m + (string(i) -> m.getOrElse(string(i), Vector()).:+(i))
}
For example:
println(indexes("Mississippi"))
// Map(M -> Vector(0), i -> Vector(1, 4, 7, 10), s -> Vector(2, 3, 5, 6), p -> Vector(8, 9))
Why Scala can't inferred that `m.getOrElse(string(i), Vector()) :+ i` is `Vector[Int]` and compile it? I should wrote `m.getOrElse(string(i), Vector()).:+(i)` instead. | It'll work fine with the Map value parenthesized:
def indexes(string: String): Map[Char, Vector[Int]] = (0 until string.length).
foldLeft(Map[Char, Vector[Int]]()){
(m, i) => m + (string(i) -> (m.getOrElse(string(i), Vector()) :+ i))
}
indexes("Mississippi")
// res1: Map[Char,Vector[Int]] = Map(M -> Vector(0), i -> Vector(1, 4, 7, 10), s -> Vector(2, 3, 5, 6), p -> Vector(8, 9))
Without parenthesizing the Map value, the `(k -> a :+ b)` key-value portion of the code below will be treated as `(k -> a) :+ b`, hence causes compilation error:
(m, i) => m + (string(i) -> m.getOrElse(string(i), Vector()) :+ i)
// <console>:28: error: value :+ is not a member of (Char, Vector[Int]) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "scala, scala collections"
} |
What value type would a chromosome position be in a database or form?
I wanted to create a tool for some fields like SIFT, Phenotype, etc..so for example I know Phenotype will have "Text" values or SIFT will have some determined values from a drop down list...but what about Chrom Positions? what are some valid sample values for that? so I can know what type I can use for it. | Since it sounds like you are the one designing the database, you can make this a number of ways. The simplest is probably to reduce it to two variables, likely two decimals.
See this hemoglobin example for a chromosomal locus example.
* There are N chromosomes (23 for humans, if you like, sex chromosomes can be treated as a pair).
* There are 2 chromatids per chromosome.
* The part of the chromatid is either p or q (short or long arm).
* Then there is the location on the portion of the chromatid (eg, 15.5).
Chromatid can be easily represented as a decimal, where the integer portion is the chromosome number, and the decimal portion corresponds to the chromatid and arm.
The chromosomal locus can be another decimal, such as 15.5 for the example above.
This is of course one way, and there are many other ways you could do this. | stackexchange-biology | {
"answer_score": 2,
"question_score": 4,
"tags": "bioinformatics, chromosome"
} |
Profiling Template Haskell
I have a TH-heavy file which takes around 30 seconds to compile. What are some techniques I can use to help debug the performance of my Template Haskell? | If I understand compile flow of TH correctly, the ordinary haskell functions are being executed while splicing at compile time. But you can run then at the runtime on your own, of course.
For example you have something like $(foo x y ...) in your TH-heavy file. Create another file and call 'foo x y' there but don't splice the result. Then you'll be able to profile 'foo' as usual. If the bottleneck is at the AST generation stage you'll locate it. Don't forget to consider lazyness. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 15,
"tags": "haskell, ghc, template haskell"
} |
Hiding videos on android sd card
I am playing videos locally from sd card in listview in an android app. Now i want to hide those videos from user so that he can only play those videos but should not locate those videos to copy from sd card. Is there any way to hide videos on sd card? | You cannot prevent access to files on external storage.
You can encrypt those videos so that only you can decrypt & play them. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "android, video, sd card"
} |
how do i make sure the value in a table entity is not repeated in mysql?
in the below table i would want the property_id to be unique so that it doesn't have duplicate values. what is the syntax for this?
CREATE TABLE IF NOT EXISTS `propFeatures` (
`id` bigint(20) NOT NULL auto_increment,
`bedroom` int(10) NOT NULL,
`bathroom` int(10) NOT NULL,
`balcony` int(10) NOT NULL,
`furnished` tinyint(1) NOT NULL,
`property_id` int(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | You can add `UNIQUE` constraint to your `property_id` column so that it does not allow duplicates if you want.
* * *
To check duplicates, you can run this query:
select property_id, count(property_id) as total from propFeatures
group by property_id having count(property_id) > 1
If you want to remove duplicates, check out this post for more info:
MySQL: Remove Duplicate Rows/Records from Table | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "mysql"
} |
Is this Approach correct? Determine number of dice rolls required to obtain the 3rd five
If we roll a pair of dice repeatedly, how many rolls do we need to obtain the nth five (example 3rd five)?
I think this can be modeled using a negative binomial distribution. Is this naive?
If we want to calculate the Pr(N>5) where N is the number of rolls required, can I approach it as 1-Pr(N<=4)?
\- If so, does that mean I calculate $\sum\limits_{i=0}^4 (negativeBin(i,p))$ ? | Suppose that we perform an experiment independently until the $k$-th success, where the probability of success on any trial is $p$. Let $N$ be the number of trials we use.
Then $N$ has negative binomial distribution with parameters $k$ and $p$. Let us find the probability that $N=n$.
We have $N=n$ if we have $k-1$ successes in the first $n-1$ trials, and success on the $n$-th trial. Thus $$\Pr(N=n)=\binom{n-1}{k-1}p^{k-1}(1-p)^{n-k}p=\binom{n-1}{k-1}p^{k}(1-p)^{n-k}.\tag{1}$$
Suppose for example that $k=3$ and we want $\Pr(N\gt 5)$. We have $N\gt 5$ precisely if it is not the case that $N\le 5$. Thus $N\gt 5$ has probability $$1-(\Pr(N=3)+\Pr(N=4)+\Pr(N=5)).$$ For the above probabilities, use Formula (1), with $p=1/6$.
**Remark:** The negative binomial $N$ with parameters $k$ and $N$ is the sum of $k$ (independent) geometric random variables with parameter $p$. Thus $E(N)=\frac{k}{p}$. | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "probability, statistics"
} |
How to add a block to richtextbox
How can I add a new block to the `richtextbox.document.blocks` collection? In a different thread, a check finds place about how many characters are in the richtextbox.
If the amount is above 25000 chars, i clear up the richtextbox using `richtextbox.document.blocks.clear()`
But this removes my initial blocks which i had created in the UI-Thread:
Paragraph p = this.richtextbox.Document.Blocks.FirstBlock as Paragraph;
p.Margin = new Thickness(0);
Trying this code in that other thread than the UI-Thread, gives me an invocation exception at runtime. Because 'p' is null.
What am i missing guys? | The code you showed does not create any blocks it just gets the first one which usually will be there by default so if you clear all blocks you will first need to add a new one using something like:
var p = new Paragraph();
richtextbox.Document.Blocks.Add(p);
p.Margin = ...;
You can just have an `if` which checks the number of blocks, if there is more than one get the first one with you original code if not create and add it. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, wpf, richtextbox, block"
} |
Buying a used car jack
I'm planning on buy a used 2 ton car jack.
What are some warnings/items I should be on the look out for?
Is buying a used car jack a safe idea? | I'm assuming you are saying you are going to purchase a used "hydraulic" jack? If so, the main thing to look out for is if it is leaking or not. If it's a scissor style jack, ensure smooth operation. Test out the jack to ensure it works, such as does it smoothly jack your car up? Does it smoothly let your car down? Make sure YOU know how to use it. A used jack is like any other piece of equipment. If it is used and maintained correctly, it can last a lifetime.
As a safety item, remember to use wheel chocks when jacking your vehicle. Use jack stands to support your vehicle if you plan to go under the vehicle. A jack can fail a lot easier than a properly positioned jack stand, and as long as it is never over burdened (too much weight on it), a jack stand will continuously hold a vehicle up in the air without issue. | stackexchange-mechanics | {
"answer_score": 6,
"question_score": 1,
"tags": "jack"
} |
Error when using xwatermark and babel
I get this error when using xwatermark:
> ! Package catoptions Error: '\XDeclareOption*' multiply defined in (catoptions) package 'babel'.
>
> See the catoptions package documentation for explanation. Type H for immediate help. ...
>
> l.457 \DeclareOption*{}
>
> ?
My code is something like:
\documentclass[12pt]{article}
\usepackage[printwatermark]{xwatermark}
\newwatermark[allpages,color=red!50,angle=45,scale=3,xpos=0,ypos=0]{DRAFT}
...
\usepackage[english]{babel} % English language/hyphenation
...
\begin{document}
Any ideas how to solve this? Thank you in advance | The `xwatermark` package loads `catoptions` which is very unfriendly towards packages not using it and that try to manage options in a nonstandard way.
Load `babel` before it.
\documentclass[12pt]{article}
\usepackage[english]{babel} % English language/hyphenation
\usepackage{xcolor}
\usepackage[printwatermark]{xwatermark}
\newwatermark[allpages,color=red!50,angle=45,scale=3,xpos=0,ypos=0]{DRAFT}
\begin{document}
abc
\end{document}
, you can try the ported extension(s) for Chrome:
* Sidewise Tree Style Tabs
* Tree Style Tabs (Beta)
It won't remove the tabs on top though. | stackexchange-superuser | {
"answer_score": 3,
"question_score": 2,
"tags": "ubuntu, google chrome, browser addons, browser tabs"
} |
Using try, catch and finally in test class (dreamhouseapp)
In the test classes of the DreamHouse Sample app all the functions have the following structure:
static testMethod void testSomething() {
Boolean success = true;
try {
...
} catch (Exception e) {
success = false;
} finally {
System.assert(success);
}
}
Source: <
What is the reason for or advantage of this structure?
I am asking, since this app is kind of Salesforce-official (if I got that right) and it says _" Get inspired and learn best practices."_, so I thought there must be a reason...
Thank you! | `finally`-`assert` is not your friend. Do not ever do this. Finally executes even if an exception is thrown, so the test will fail, but for the wrong reason. In any situation where it'd make sense to use finally, you can do it shorter without finally.
In fact, you should only use try-catch if you expect a specific exception:
try {
doSomething();
System.assert(false, 'Expected to get an exception');
} catch(SpecificException e) {
// Good, but maybe System.assert for a specific message, etc
}
If no exception is thrown, you get an assertion failure, if you get the wrong exception, you get a failed test from the thrown exception, otherwise the test passes. `finally` might look pretty, but it's really just adding more code for no real reason. `finally` **is** useful in some situations, but not in unit tests. | stackexchange-salesforce | {
"answer_score": 10,
"question_score": 10,
"tags": "unit test, try catch"
} |
How to offset an EntityFieldQuery when using pager?
Is there some way to easily offset an EntityFieldQuery when using `pager()`, i.e. skip the first 3 nodes? `range(3, NULL)` doesn't work as the second value must be set, and `range()` also doesn't work when also using `pager()` which is a requirement.
Is there a substitute for something similar to this:
$query
->range(3, NULL) // <- Wishful thinking..
->pager(10)
;
Thanks, | First question, you've asked if you can offset the results, without having to set the limit for the total results. Logically it would make sense to be able to set `$limit = FALSE`, to return all results. But I believe `range($offset, $limit)` requires you to enter both the offset and limit. A workaround is to enter `range(3,9999999999);`.
Second question, you've mentioned that the `-range()` is not working when `-pager()` is set. It's a known limitation. I would assume you can run a separate query to create a pager, but that would require additional SQL requests. | stackexchange-drupal | {
"answer_score": 2,
"question_score": 5,
"tags": "paging, database"
} |
How do I build Boost when "b2" does not work
In theory, boost needs to be built with `b2`. In my case, with `b2 --build-dir=c:\boost\ --toolset=msvc complete stage`.
This produces a warning `the --build-dir option was specified but Jamroot at '.' specified no project id the --build-dir option will be ignored` (looks harmless) and then the fatal notice[sic] `
could not find main target complete
assuming it is a name of file to create.
could not find main target stage
assuming it is a name of file to create.
Apparently the targets have been renamed. What is the correct target to build?
Googling finds only a few hits, none on the current (1.54.0) Boost version. | The recognized target names depend on the build type. Since the command line is missing `--buildtype=`, the next token `complete` is incorrectly interpreted as a target and not recognized. The next token `stage` IS a target, but is not recognized because the buildtype is not set. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "c++, boost"
} |
htaccess - how to find last hyphen
I have two types of URLs without page number: < and with it <
So far I have this:
RewriteRule ^promotional-(*)$ /section.php?xName=promotional-$1 [QSA,L]
And here I need help
RewriteRule ^promotional-()-p([0-9]*)$ /section.php?xName=promotional-$1&xPage=$2 [QSA,L]
Thanks | Try :
RewriteRule ^promotional-(.*)-p([0-9]+)/?$ /section.php?xName=promotional-$1&xPage=$2 [QSA,L]
RewriteRule ^promotional-(.*)/?$ /section.php?xName=promotion-$1 [QSA,L] | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "apache, .htaccess"
} |
How to extract file name from file list?
Now I have several files, their names include version number, I want to extract their file name only and strip the version number,
ES File Explorer_3.0.5.5.apk
ES Task Manager_1.4.1.apk
Facebook_3.7.apk
Gmail_4.6 (836823).apk
Google+_4.1.2.51968121.apk
Google Play Books_2.9.21.apk
Google Search_2.8.8.849369.arm.apk
Hangouts_1.2.018 (849105-30).apk
Instagram_4.1.2.apk
Kingsoft Office_5.7.3.apk
Maps_7.2.0.apk
Skype_4.4.0.31369.apk
Translate_2.8.apk
Twitter_4.1.8L.apk
WhatsApp_2.11.93.apk
YouTube_5.1.10.apk
How to do? using vi, sed or awk? Such as extract YouTube or YouTube.apk from YouTube_5.1.10.apk. | Using `awk`
awk -F_ '{print $1 ".apk"}' file
ES File Explorer.apk
ES Task Manager.apk
Facebook.apk
Gmail.apk
Google+.apk
Google Play Books.apk
Google Search.apk
Hangouts.apk
Instagram.apk
Kingsoft Office.apk
Maps.apk
Skype.apk
Translate.apk
Twitter.apk
WhatsApp.apk
A version to fix `cn.msn.messenger.1370207212755.apk`
awk '{gsub(/[0-9].*|_/,x);gsub(/\.$/,x)} {print $0 ".apk"}' file | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "linux, sed, awk, vi, kingsoft"
} |
Classical solutions to the wave equation
Suppose $u(t,x)$ and $v(t,x)$ are $C^2$ functions defined on $\Bbb R^2$ that satisfy the first-order system of partial differential equations $u_t$ = $v_x$, $v_t$ = $u_x$.
Now I have to answer the following questions, but I have no clue how to start.
1: Show that both $u$ and $v$ are classical solutions to the wave equation $u_{tt}$ = $u_{xx}$.
2: Which result from multivariable calculus do you need to justify the conclusion? | 1. Since the functions belong to the $C^2$ class, you have $$ u_{tt}=\frac{\partial}{\partial t} u_t= \frac{\partial}{\partial t} v_x = \frac{\partial}{\partial x} v_t=\frac{\partial}{\partial x} u_x=u_{xx}\iff u_{tt} = u_{xx} $$
2. The result in multivariable calculus used to justify the conclusion is the following one: _if $f\in C^2(\Bbb R^n)$, then the first order partial derivatives to $f$ commute each other_, i.e. $$ \frac{\partial}{\partial x_i}\left( \frac{\partial f(\boldsymbol{x})}{\partial x_j} \right) =\frac{\partial}{\partial x_j}\left(\frac{\partial f(\boldsymbol{x})}{\partial x_i} \right)\quad\forall i,j=1,\ldots,n,\:\:\: i\neq j,\:\: \boldsymbol{x}=(x_1,\ldots,x_n) $$ | stackexchange-math | {
"answer_score": 0,
"question_score": 2,
"tags": "ordinary differential equations, partial differential equations, wave equation"
} |
"SIS ESCAPE" message on dash of 2015 Isuzu NQR?
Does anyone know what the this message means? I can't find any references to it online. | I have since discovered that our drivers switched the display to Spanish, and that SIS ESCAPE is Spanish for EXH. SYSTEM - alerting the driver to an issue with the emissions control system. Requires dealer inspection/service. | stackexchange-mechanics | {
"answer_score": 1,
"question_score": 2,
"tags": "diesel, isuzu"
} |
can't see Outlook folder from mfcmapi
I'm using MFCMAPI to try to view some properties of a folder (named 'test') that's in my Outlook 2007 mailbox. However, when I go quickstart > open folder in the menu, I don't see my folder listed. Thank you for your time!
 and it can tolerate about 500 requests a second (with a 50/50 mix of INSERTS and SELECTS) and under 1 second response time. However, I am concerned if this number increases to 1000 for example, the RDS will simply not be able to keep up and response times will increase. To reduce this, I've created a "Read Replica" for performing reads to reduce the load on the "Master" server.
I was wondering however, if it was worth me setting up my own MySQL Cluster instead. Would this give me true scaling "out"? Could I simply fire up more nodes when my MySQL cluster was getting busy etc etc? Would it remove the need for "Read Replicas"? Does anyone have any experience with this on AWS?
Thanks in advance for any advice! | What is the instance type that you are using for your RDS? Have you read the FAQ here -- <
If you are already using the largest instance type see here --
> Q: How can I scale my DB Instance beyond the largest DB Instance class and maximum storage capacity?
>
> Amazon RDS supports a variety of DB Instance classes and storage allocations to meet different application needs. If your application requires more compute resources than the largest DB Instance class or more storage than the maximum allocation, you can implement partitioning, thereby spreading your data across multiple DB Instances.
Hope this helps | stackexchange-serverfault | {
"answer_score": 0,
"question_score": 1,
"tags": "mysql, database, amazon web services, mysql cluster"
} |
Creating custom login portal
Our company has several clients for some major corporations, and we're looking into giving our portal page a little something extra by having customized urls all link to the same portal.
client1.ourcompany.net
client2.ourcompany.net
Ideally, we'd like for the urls to be superficial, I found the Request.Url.ToString() function that could be utilized on the code behind, but would I still need to create custom ASPX pages for each portal? | No, you could handle this in IIS. Basically, you set up your IIS endpoint to respond to all *.ourcompany.net requests with the same IIS application and your code can disambiguate details from there in the fashion you describe. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, asp.net, url"
} |
Do disconnected remote desktop sessions lock accounts?
I'm getting an account locked daily - I've read that this could be due to disconnect remote desktop sessions ? Is this true? Is it a group policy setting?
Regards, Jason | Absolutely. If you've changed your password but have a logged in session with an olld password, you will have issues. | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 1,
"tags": "active directory, rdp"
} |
change point style in EXCEL 2010 chart
I need to change the point style of a chart in EXCEL 2010.
I have 10000 points, all are represented by diamonds that are overlaped each other in the chart.
It is very hard to see them clearly.
How to change them to a small point not diamonds ?
In EXCEL, available shapes are only diamonds.
Any help would be appreciated. | This will change the marker style of the first series of the active chart:
ActiveChart.SeriesCollection(1).Select
With Selection
.MarkerStyle = 1
.MarkerSize = 5
End With
MarkerStyle 1 sets the series markers to circles and MarkerSize sets their size. Not sure if you have many series or all points on the same series. You will maybe have to loop over the series collection to change the style on all the series. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "vba, excel, charts, excel 2010"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.