How to generate id and name attribute input form and model dynamically using Entity-Attribute-Value EAV?

Question: I need to use Entity-Attribute-Value (EAV) approach for my database design. These are my models.
public class TableMetadataTemplate
{
    public Guid Id { get; set; }
    public string? TableName { get; set; }
    public string? FieldName { get; set; }
    public string? FieldType { get; set; }
    public string? FieldLabel { get; set; }
    public int Sequence { get; set; }
    public bool Required { get; set; }
    public string? DefalutValue { get; set; }
}

public class TableMetadata
{
    public Guid Id { get; set; }
    public Guid TableMetadataTemplateId { get; set; }
    public Guid RecordId { get; set; }
    public string? FieldValue { get; set; }
}

This is the sample data in the table:

I am using Razor pages and this is my code for the Create form:
@foreach (var row in Model.TableMetadataTemplate)
{
    var fieldType = row.FieldType;
    switch (fieldType)
    {
        case "TEXT":

                @fieldLabel
                <input type="text" asp-for="@row.FieldName" class="form-control" value="">

            break;

    }
}

Note: The above is just one example.
But, as I inspect the textbox attributes, it doesn't generate the correct id and name attribute value that I need.
<input type="text" id="row_FieldName" name="row.FieldName" value="">

The correct id and name attribute value that I need is something like below:
<input type="text" id="TableMetadataTemplate_application_name" name="TableMetadataTemplate.application_name" value="">

Comment: Hi @Steve, for your shared correct id and name, what is the ApplicationName? The actual value of the `FieldName` property? If so, why you want to do like this? It will cause model binding error if you also want to post the input value to backend. The correct way is to use `PropertyName.PropertyName`, the first propertyName depends on what you set in the PageModel, you use `Model.TableMetadataTemplate`, so the propertyName is the same as the ModelName, so current correct name should be `ModelName.PropertyName`.
Comment: If you want to receive the list model, the correct name should be `ModelName[index].PropertyName`. So it is better for you to pls share your scenario with us.
Comment: @Steve EAV is a well known *bad database design*. Despite the name, you no longer have entities with attributes at all, just names and values with no type, constraints or validity. As for the code, it behaves as expected - it generates an input and labels for the field named `FieldName` in the object `row. `asp-for` is used to specify which property to bind to. It's meant to work with concrete types and attributes, eg `Customer` and `Name`, `Address` etc
Comment: At the database level, the only reason to want to use an EAV schema is to store arbitrary attributes. Known attributes are stored in their own columns, allowing easy querying, indexing, inserting etc. Even for arbitrary attributes you can use XML columns in almost all databases for nearly 20 years, and JSON for a decade or more. In SQL Server, you can have ~30K sparse columns per table (columns that are usually empty), backed by an XML field. Databases offer querying and even indexing XML and JSON values
Comment: @Rena, I have added the sample table data in the original post. In the [TableMetadataTemplates] table, there is a record which the fieldname is "application_name". Not sure how can I create a dynamic table which can have dynamic property so that I use it at `asp-for` and to bind it during form posting.
Answer: From your description, it seems you want to bind the value to backend. but the ApplicationName here is the actual value of your property FieldName.
You need know that model binding binds the property by name attribute. That is to say the value of the name attribute should match the property name.
Example for further explanation
Model.TableMetadataTemplate is a List model type. If you want to post the value to this type property, you need set the unique name like:ModelName[index].propertyname no matter your foreach loop contains one or multiple records.
Page:
@page
@model IndexModel
<form method="post">
    @for (int i=0;i< Model.TableMetadataTemplate.Count();i++)
    {

            <input type="text" asp-for="@Model.TableMetadataTemplate[i].FieldName" class="form-control" value="">

    }
    <input type="submit" value="Post"/>
</form>

Backend:
public class IndexModel : PageModel
{
    //you can see the value here when form submit...
    [BindProperty]
    public List<TableMetadataTemplate> TableMetadataTemplate { get; set; }

    public async Task OnGet()
    {
        // be sure set the data value here, otherwise `Model.TableMetadataTemplate` in page will get null exception...
        TableMetadataTemplate =xxx
    }
    public void OnPost()
    {
         //do your stuff...
    }
}

Comment: Pls check my previous comment and share more details. My current code is used to generated the id/name with value `TableMetadataTemplate_FieldName`/`TableMetadataTemplate.FieldName`.
Comment: Hi @Steve, I have updated my answer and explain how does the model binding work. Pls check if I understand your scenario or not.
Comment: Your code looks the same as mine. Just that my object name is `row`
Comment: Ok, I have updated the original post with more info
Comment: I tried your code but when I inspect the html, it is ``
Comment: Hi @Steve, yep. Why you insist on `name=TableMetadataTemplate.Application`? This is not the correct model binding name...


Do users choose randomly for mandatory fields with no default, just to get through the form?

Question: I am working for a non-profit that wants to collect its donors' reason for donating, via a long dropdown of 'What prompted you to donate?' options like 'Received an email', 'Saw a TV ad', 'Friend or family was helped by charity', etc. This helps them understand how to communicate with the donors, and where to focus fundraising efforts. But I'm wondering how accurate the data is, or whether users will just pick one at random because they can't be bothered to read the list and make a selection. Does anyone have any evidence of this kind of user behavior?
Comment: If respondents don't want to respond to the question, they are more likely to pick the first one in the list, not a response at random -- first in the list is the easiest to select.  To avoid this, simply randomize the order in the drop-down.  That said, if they don't know to avoid this issue, someone involved with this effort should read a book on basic survey design. This issue is far from the only one they would encounter, especially on a topic like charitable donations where response biases such as social desirability bias are very likely to occur.
Comment: @nadyne, while you make some valid points, this is not 100% true. Consider forms that *drop up* based on screen position. By Fitt's law (and I verified it with my own testing), they will choose the closest to the mouse position. And in many cases, no matter if the select drops up or down, if they don't want to choose an option, they will use *Other* (or similar). I think the real problem here is that field **shouldn't be mandatory**
Comment: Check for how many people come from ['Afghanistan'](http://www.listofcountriesoftheworld.com/)
Comment: Users will pick a value for a required field if they have some motivation to get to the end. If they don't have motivation to continue, many users just abandon the form once they hit a required field that gives them any pause. Better to rely on voluntary over-disclosure than arbitrary required fields. http://research.microsoft.com/en-us/projects/webforms/
Comment: Maybe a free text field would solve the problem, but it have to be tested. Ofcource this will require a lot of effort for processing all this free text data.
Answer: I agree with the comments above! Generally, users are least bothered about this field; they will pick any random option.
As Michael tells the story, he was working for a business that was having a big sale one Saturday. Prior to the sale they did a lot of advertising in the local market and wanted to determine which marketing project paid off. To do that Mike and his boss stood at the door all day and asked every customer where they heard about the sale. 30% said TV, 20% said Newspaper, and 50% said Radio – Good to know, right? Except they never had a TV ad. When they asked people if they were sure they heard about it on TV everyone assured them that they had.

To wisely invest your marketing dollars, you NEED to know where your
  leads are coming from. The internet marketing guru's have this one
  figured out; they always know exactly where the leads are coming from
  by tracking the "referral sites" to their website.
http://ethicalbusinessbuilder.com/2008/02/14/asking-your-customer-where-did-you-hear-about-us-is-a-waste-of-time-and-what-to-do-about-it/

A tool like Convertable will help you automatically tracks the source of every web lead
Comment: This is a good answer and gets to the gist of the matter: you don't need this field at all. I'll add to this answer that any reasonable campaign will use some sort of tracking (such as Google Analytics) to know where did users came from
Comment: The original poster will have to identify if they care about the difference where users came from, and why people chose to make the donation.  "What prompted you to make the donation" muddies the waters between the two, especially for repeat givers.


Is it worth stashing items for twinks?

Question: While playing with my main char I sometimes find some quite good items for my other chars but at higher levels, so I cannot use them immediately.
Is it worth stashing them or should I just sell them in the AH and buy similar items once my twinks reach that level? I mean they should cost about the same amount of gold.
Answer: Save all decent rare rings & amulets; they are hard to come across compared to other equipment. Also, if you are playing DH & will later go for Monk (or vice versa) - save your lower level DEX items as hand-me-downs if they are good.
You need to elaborate what is meant by 'quite good items' - I was trying to save all semi-decent rares, but its impractical and you want to focus on specific properties like

Gives boost to main stat
Has other useful props besides MF or GF (if ur focused on that)
For weapons, has life leech or 'on hit'

Saving space in your stash

Even if you don't plan to play a particular class, might work better to start a lvl 1 char so he/she holds the class specific items which are taking up a lot of space
Don't stock up much for the first 10-15 levels as they pass by very quickly: move any 'starter' equip onto new chars, but feel free to just keep a decent weapon and sell everything else
Remember that you can also park some good sword/shield, 2h weapons etc. on the followers. If you plan to actually use the follower, give them stuff that boosts stats but otherwise it is extra slots for amulet/rings etc.
Answer: Its quite likely that we're going to see some significant inflation in the game over time.  Since more gold is constantly being generated, people will be willing to pay more for what they want, and thus prices will go up.  So unless you need the money now, I would say that you should hold on to it, using additional characters as excess "stash" as needed.
If inflation occurs and you end up wanting the item (or its equivalent), you'll have to pay more in the future to get it back.  If inflation occurs and you don't end up wanting the item, you'll get more money by selling it in the future then by selling it now.  So the only reason to sell it now is if the item is unlikely to ever be auctionable (because it just isn't something people will want), or you don't have the space to hold onto it (with 10 character slots, it should take quite a while to reach this point), or you need the money immediately for some big purchase.
Answer: For the most part, I'd suggest selling your items and buying better suited ones when you play a particular character.  It's really kind of hard to determine if at the time you'd be able to use a particular bit of gear, if it would be appropriate to your build.
More often than not, if I stash a bit of gear I can't currently use on any of my characters, I end up coming back to it later and going "why did I save this?  This is junk."  Or I'll stash a halfway decent rare for a particular slot, and then get to the point I would use it, and I've found just one good piece of gear, and it's for that slot.  (sigh)
If something has a very high primary stat for the item level, or if I find a legendary, sometimes I'll hang on to it.  Most stuff, though, goes straight to the vendor.  Interesting/exceptional rares end up at the auction house.
Instead of stashing random loot for twinking, I keep a few items on hand that I bought at the AH:

A good socketed helm, for a +XP% Ruby (must be level 15 or higher)
A good universal socketed weapon or two (several classes can use 1-handed swords, for instance) with a +DPS ruby
Perhaps a couple of bits of +primary stat gear with low level requirements, just to make the early going faster.
Comment: Plus with the staggering rate of deflation if you sell the item now and buy it back later, you would probably net profit.
Comment: @Nick You don't think that deflation is going to continue forever do you?  I think we're going to switch to inflation.  In fact, I think we're probably already experiencing inflation as many people are now past the initial level up period.
Answer: I would definitely save it if its an exceptional item, although if its only mediocre then I'll AH and buy better items later on.
The AH does not guarantee the availability of any item, so if you want something for later, save it.
Typically I keep all items stored for one specific character in one place (such as all my Wizard items in a specific row in my stash), and I'll periodically clean it out and sell duplicate items.

Is it worth stashing items for twinks?


What are the tiers of loot?

Question: Anthem is a gear driven game, and I've seen videos mentioning Legendary and Masterwork items.
What are the actual tiers of gear in the game? Are Masterworks the highest tier?
Comment: The game has been released to Origin Access subscribers since the 15th.
Comment: Be careful with this kind of question as Anthem is not yet released. Currently this question would be off-topic as per the help center
Answer: There are 6 different tiers of gear in Anthem, the order from lowest to highest is as follows:

Common (White)
Uncommon (Green)
Rare (Blue)
Epic (Purple)
Masterwork (Orange)
Legendary (Yellowish)

In addition to the colors, tiers can be identified by the number of triangles displayed, ranging from none for Common rarity all the way up to five for Legendary gear.
Comment: They also seem to display a certain number of triangles to denote the tier. With Legendary gear showing 5 triangles.https://cdn.discordapp.com/attachments/518001069415202816/547430113290223631/unknown.png
Comment: @DavidYell good point, edited my answer accordingly.

What are the tiers of loot?


Conditional probability question.

Question: I'm having trouble answering the question below:
You purchase a certain product. The manual states that the lifetime T of the product, defined as the amount of time (in years) the product works properly until it breaks down, satisfies
$P(T≥t)=e^{−t/5}$, for all $t≥0$.
For example, the probability that the product lasts more than (or equal to) 2 years is $P(T≥2)=e^{−2/5}=0.6703$.
I purchase the product and use it for two years without any problems. What is the probability that it breaks down in the third year?
It's a conditional probability question. I tried answering the following way, but my final answer doesn't seem to be correct.
$P(T≥2)=e^−2/5=0.6703$  =  Prob. that product lasts two or more years.
$P(T≥3)=e^−3/5= 0.5488$ = Prob. that product lasts three or more years.
I figured that by subtracting the two $P(T≥2)-P(T≥3)$, I would be left with the probability that the product would break down within the third year.
Since we are calculating the prob that it breaks down within the third year, we are already assuming the condition that the product lasted two years. Thus the conditional should already included within the answer. Subtracting the two, I get the answer .1211, but answer seems to be .1813.
The answer can be found here:
https://www.probabilitycourse.com/chapter1/1_4_5_solved3.php
Thank you.
Comment: The probability it breaks down in the third year not knowing anything at all about when it breaks down (which is what you calculated first) is not the same as the probability it breaks down in the third year given it hasn't broken down in the first or second years, i.e. you know already it didn't break down the first two years; think about it, it makes sense.
Comment: Ah! I think I understand it.
Comment: It's tricky stuff, but once you understand, it becomes quite natural.
Answer: You don't want to subtract; division is the operation you need.   As you said, it's a conditional probability problem.   So use the formula for that.
$$\begin{align}\mathsf P(X> 3\mid X>2) ~&=~ \dfrac{\mathsf P(X>3 \cap X>2)}{\mathsf P(X>2)} \\[1ex] ~&=~ \dfrac{\mathsf P(X>3)}{\mathsf P(X>2)}\end{align}$$
Then use $\mathsf P(X\leq 3\mid X>2) = 1-\mathsf P(X>3\mid X>2)$

Remark: The "the conditional is already included" bit you were thinking of may be that the event $X>3$ is a subset of the event $X>2$, and hence their conjunction is just the event $X>3$.

Addemdum: The result does demonstrates that $\mathsf P(X>3\mid X>2)=\mathsf P(X> 3-2)$, with which you may also have had that confused.   This is a consequence of a the memoryless property of exponential distributions.
Comment: "Remark: The "the conditional is already included" bit you were thinking of may be that the event X>3X>3 is a subset of the event X>2X>2, and hence their conjunction is just the event X>3X>3."

Yes. But I was thinking X>2 is a subset of X>3, in the sense that if it didn't break within three years, we know that it didn't break the first two years.
I'm going to rethink everything after reading all the replies and see if I have a better understanding intuitively. Thanks for the reply.
Comment: Any outcome in the event of $\{X>3\}$ will be an outcome in the event of $\{X>2\}$, but there are outcomes in the later event that are not in the former.  Hence $\{X>3\}\subsetneq\{X>2\}$   @moondra
Answer: By taking
$P(T≥2) - P(T≥3) = 0.1215$
You've actually worked out the chance of the product failing in the third year. $P(T\leq3\cap T\geq 2)$ The formula for the conditional probability of $A$ happening given $B$ has happened is
$P(A|B)={\frac {P(A\cap B)}{P(B)}}$
$P(T\leq3|T\geq 2 )={\frac {P(T\leq3\cap T\geq 2)}{P(T\geq 2)}}$
$P(T\geq2)=0.6703$
$P(T\leq3\cap T\geq 2) = 0.1215$
$P(T\leq3|T\geq 2 ) = {\frac {0.1215}{0.6703}} = 0.1813$
Answer: Here's an analogy:
Pick three cards from the top of a standard deck. What's the probability the third card is a queen? Simply 4/52 as you don't know what the first or second cards were. However, suppose you know the first and second cards weren't queens? Then the probability increases to 4/50.
Consider also if the question had been "I purchase the product and use it for two years and it breaks down during that two-year period. What is the probability that it breaks down in the third year?"
In this case, the probability is zero that it breaks down in the third year (assuming it can only break once of course). In other words, what happens in the first couple years definitely has an effect on the probability of breakdown in the third year. If you know it didn't break down those first couple years, the probability it will break down the third year goes up.

Conditional probability question.


How to automatically set RAILS_ENV based on server

Question: While in development we don't need to set RAILS_ENV when we run rails c and it automatically load development environment. However, when I am on staging server I would like to ignore passing RAILS_ENV when we run rails c; it should automatically load staging environment rather than development. Unfortunately, we always face loading development environment. So we would like to know how to do this automatically to load dynamic environment when on staging or production server.
Answer: You could probably set an environment variable in your ~/.bashrc file like so:
export RAILS_ENV=staging


android MediaPlayer alternative for rtsp streaming

Question: I need to a multi viewer in my app, each view in a gridlayout must show a video from a camera that streaming over rtsp.
I try using Android VideoView and MediaPlayer, but results does not satisfy me, I have much latency for starting video, and compatibility problems using Lg L9 phone (see my question here )
I search a lot for 3rd party sdk , and I found Vitamio, but it not support multi-views in same activity (there is a bug). Another commercial sdk is Nexstreaming but not works on rtsp protocol.
I not found nothing else. Do you know others ?
Using NDK could be another way to do it, so I seen for Gstreamer (tutorial)  but it seems too complicated. Another way could be FFMPEG, but I have not found a definitive guide for it.
Any help ?
Comment: Havy you tried to use GStreamer anyway? Was it working better than default way to play videos?
Answer: VideoView and MediaPlayer are based on the hardware decoders, specific for different devices, manufacturers, platforms. They are optimized to deliver best playback experience (e.g. 1080p), but are rather crippled when more than one instance must be active concurrently. I have never seen an Android device that could open more than 4 "OMX handles". But there is even no guarantee that two will work. And these frameworks are not built to fallback to software decoders when the HW resource is exhausted.
Luckily, contemporary devices have enough generic computational power to fill the whole screen with decoded video streams (e.g. four 270p streams for a 960 x 540 display). Gstreamer uses ffmpeg to decode the streams, but this library is probably more suited fro your purposes because it wraps up the necessary functionality, and you can ignore the minor impleentation details.
I believe that you will be better served with an OpenGL presentation layer, because this way you can offload color conversion to GPU with a shader that takes YUV 4.2.0 planar image (as produced by the decoder), and displays an RGB 24 bpp texture.
Comment: So, what is easy way for a newbie of video stream for do it ?
Comment: Have you tried to multiply video sinks in the [video player tutorial](http://docs.gstreamer.com/display/GstSDK/Android+tutorial+3%3A+Video)? As I said, you may find the performance improved significantly if you use GPU for yuv to rgb conversion and scaling. [This discussion](http://forum.openframeworks.cc/t/gstreamer-and-opengl/4789) suggests that the idea is not completely strange to GStreamer paradigm.


Why amqsput command is dividing my data and push to the message queue?

Question: While testing my application, I tried with a string taking space of some 200KB. But amqsput  divided my request in multiple chunks. I am not sure why it's happening. If I reduce the size to some 100KB then it works fine.
I am using following command to push data into the message queue:
amqsput MESSAGE_QUEUE MQM < /home/usr/sampleRequest.xml
This sampleRequest.xml contains an XML formatted as one line. I don't know much about MQ admins/configuration and want an idea what's wrong.
Why it's dividing my data and push it to queue when file size is greater than a certain value.
Answer: amqsput & amqsget are simple applications for putting and getting small messages to and from a queue.  If you look at the code for amqsput (i.e. amqsput0.c), you will see that the buffer size used is 65535 (64KB).
There are lots of programs that are better suited for your type of testing.  There is a long list of C sample MQ applications here.  The 2 that you might want to use are file2msg and msg2file.  There is also Paul Clarke's QLoad program (it used to be SupportPac).


npm package for identifying image morphology closing

Question: I am looking for some npm package which can decompose an image into outlines of objects in that image with each object programmatically identifiable (e.g. can be accessed by index or id or by some other method). A module with similar functionality is skimage.morphology.closing, but it's for Python.
Any help/hint is appreciated!
Answer: Actually using node-dv ,it use leptonica library to make image operations like opening and closing.


Memory loss in multi-threaded wpf application

Question: The scenario is as follows: an application with several threads: 2 to request data from different sources, 3 to update different information on the screen, and 1 to play audios on demand.
The problem: the application has to work non-stop, and when starting it works fine, but after a while (not always the same, usually between 5 and 8 hours) it ends up failing. The error trace points
to one of the painting threads, where I get the exception "System.OutOfMemoryException" for 5 or 6 minutes, until finally the program stops. That thread runs inside two others, which are 2 animations (fadeIn, fadeOut) that last 1sec, before and after updating the information. If I remove those animations the program does not fail (at least 24 hours). I would like to keep the animations, and help to detect what I am doing wrong, I suppose I am not releasing resources or something similar.
I have look at two things:
1) Application Memory: I have created this variable
PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes");"
and in each thread pass I execute it this way:
"RAM disponible: " + ramCounter.NextValue() + "MB"
The value is always around 3.5/4Gb, so it doesn't seem to be losing memory.
2) Number of threads: I read that there is a limit of threads that an application can create, and I thought that if I was not closing them properly maybe that was the problem. But it does not seem either. I execute this on each thread pass and it always gives me a stable value between 30 and 35:
"NumThreads: "+System.Diagnostics.Process.GetCurrentProcess().Threads.Count"
I attach the code, and see if you can tell me what I'm doing wrong:
Thread that paints information (if I remove the lines of the animations the application works ok)
while (true){
try{
    EscribirLogError("PintarTiempos - RAM disponible: " + ramCounter.NextValue() + "MB",false);
    tiempoPrevisiones = int.Parse(ConfigurationManager.AppSettings["TIEMPOPREVS"]);

    //Animación quitar tiempos
    tFadeOut = new Thread(new ThreadStart(FadeOut));
    tFadeOut.SetApartmentState(ApartmentState.STA);
    tFadeOut.Start();
    //Pintar tiempos
    this.window.pintaTiempos(previsiones);
    Console.WriteLine("NumThreads: " + System.Diagnostics.Process.GetCurrentProcess().Threads.Count);
    EscribirLogError("NumThreads: "+System.Diagnostics.Process.GetCurrentProcess().Threads.Count,false);
    //Animación tiempos nuevos
    tFadeIn = new Thread(new ThreadStart(FadeIn));
    tFadeIn.SetApartmentState(ApartmentState.STA);
    tFadeIn.Start();

    Thread.Sleep(tiempoPrevisiones * 1000);

}catch(Exception e){
    EscribirLogError("PintaTiempos:" + e.Message, true);
}

public void FadeIn()
    {
        TimeSpan fadeInTime = TimeSpan.Parse("00:00:01");
        Double opacityFinalFadeIn = 1d;
        Thread.Sleep(750);
        this.window.FadeIn(fadeInTime, opacityFinalFadeIn);
    }`

The fadeIn function from instance this.window
public void FadeIn(TimeSpan fadeInTime, Double d)
{
  this.Dispatcher.Invoke(new System.Action(() =>
  {
    try
    {
        var fadeInAnimation = new DoubleAnimation(1d, fadeInTime);
        for (int i = 0; i < this.lblTiempos.Length; i++)
        {
            this.lblLineas[i].BeginAnimation(Label.OpacityProperty, fadeInAnimation);
            this.lblDestinos[i].BeginAnimation(Label.OpacityProperty, fadeInAnimation);
            this.lblTiempos[i].BeginAnimation(Label.OpacityProperty, fadeInAnimation);
        }
    }
    catch (Exception e)
    {
        this.programa.EscribirLogError("FadeIn.Dispatcher:" + e.Message, true);
    }
  }), null);
}

I put this info about timers and events at the request of the user @Kelly:
//Timers definition
private System.Windows.Forms.Timer time;
private System.Windows.Forms.Timer wakeup;

//Timers init
this.wakeup = new System.Windows.Forms.Timer();
this.wakeup.Tick += new EventHandler(wakeup_Tick);
this.wakeup.Interval = 30000;

this.time = new System.Windows.Forms.Timer();
this.time.Tick += new EventHandler(time_Tick);
this.time.Interval = 1000;

//Timer functions
private void wakeup_Tick(object sender, EventArgs e){
    SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
}

private void time_Tick(object sender, EventArgs e){
    try{
        this.window.setFechaHora(DateTime.Now.ToString("dd / MM / yyyy"), DateTime.Now.ToString("HH:mm"));
    }catch (Exception ex){
        EscribirLogError("time_Tick " + ex.Message,false);
    }
}

//Window function
public void setFechaHora(String fecha, String hora){
    this.lblFecha.Content = fecha;
    this.lblHora.Content = hora;
}

Comment: You need to use a memory profiler
Comment: https://blogs.msdn.microsoft.com/wpfsdk/2007/01/18/wpf-animations-tips-and-tricks/ `To remove animations from a specific property, use the BeginAnimation method. Specify the property being animated as the first parameter, and null as the second. This will remove all animation clocks from the property.` Does it help if you do that immediately prior to your `BeginAnimation` calls?
Comment: I'm going to try it @mjwills thanks. I have to wait until tomorrow to know if it works. I will let you know
Comment: It doesn't work mjwills, thanks on the try
Comment: Why do you need separate threads to do animation when they just use Dispatcher.Invoke to do animation on UI thread?
Comment: Btw, threads may be stopped, but you probably also need to dispose them (see if they have state transition events to listen to)
Comment: I'm really not sure why I need separate threads. This code was inherited, I assume the expected behavior was to make the animation at the same time that the other function updates the times on the window. Don't know very much about the Dispatcher, do you mean that if the three threads are calling to te Dispatcher at the end, then they're not really executing concurrently?? Then it is a nonsense, and I would change the threads for normal voids. About disposing threads, Thread class doesn't have Dispose function, and I think they are disposed when they finish its taks, isn't it?
Comment: Well, yesterday I solved it. I changed the two animation threads, invoking them as normal voids instead of creating new threads. The behavior in the user interface is practically the same, and has worked for a whole day without exceptions.
I still do not know why it does not work with threads, which are supposed to release resources at the end. Problem is solved, but i would like to know why it didn't work the other way. If anyone could explain I would be grateful
Answer: There is not enough info from what you posted to help solve this. A memory profiler is what you need. I've had good luck with Redgate ANTS.
A few things to look at:

Do you call an event in a loop using myEvent += blah. If so you need to -= it, else you cause a memory leak.
Is there a Timer object created? Need to be careful with these, if you don't dereference them correctly you get a leak.
Comment: I prefer explore other options before MemoryProfiler, I have low profile at c# and VS, and I think I'm probably making some basic error about memory management.
I have 2 timer objects, which are always active, but I'm not creating new timer objects.
Events only used on the timers. I think they are fine, but I put this info on the questio to let you see it.
Comment: From what I see those look fine. One issue is putting a += Event in the loop but you don't seem to have that.
I would look more at any timer events you have as well as loops. A slow leak could be anywhere. A fast leak is almost always in a loop or a timer.


Proving that the CDF of any CDF is a Constant Number

Question: If $X$ is a random variable, we define the probability distribution function (PDF) of $X$ as $f(x)$ and the cumulative distribution function (CDF) of $X$ as $F(X)$. As such, the cdf can be written in different ways:
$$F(X = a) = P(X \leq a) = \int_{-\infty}^{a} f(x) \, dx$$
I am trying to prove the following relationship: The CDF of ANY CDF has a  Uniform Probability Distribution
I think I was able to prove this indirectly:

Part 1: In general, the following properties are true about functions:

$$y = f(x)$$
$$f^{-1}(y) = x $$
$$f(f^{-1}(y)) = y$$

Part 2: If we have some CDF $F(X=x)$, then we can write the "CDF of this CDF" as:

$$F[F(X=x)=y] = P[F(X=x) \leq y] = P[X \leq F^{-1}(y)] = F [F^{-1}(y)] = y$$
Here, $y$ is a constant number.

Part 3: If $X$ has a Uniform(0,1) distribution, the CDF of $X$  is then $x$. Intutively, imagine a rectangle of width = 1 (i.e. 0:1) and height = 1 (i.e.0:1). This means that if you choose some point $x$ on the width, the area from the origin to this point $x$ will be $x$ ... for all $x$. Here, $x$ is a constant number.

Thus, I have shown that the CDF  of any CDF is a constant number, and the CDF of a Uniform Distribution is also a constant number. Therefore, the claim is true.
Is my proof correct?
Thanks!
Comment: Please [edit] your post to clarify what you are trying to prove.  I don't understand what "CDF of a CDF" means.  Note that the notation for the CDF is $F(x)$, not $F(X=x)$.
Comment: Yep, thats right, you just have to prove that $F_{Y}(y) = y$ for $0<y<1$
and that's what you did
Comment: @ daniel: thank you so much!
Comment: PDF = probability density function.
Answer: Yes, but I think there are a few things you should be careful about. In particular, PDF is short for probability density function, not probability distribution function. Also, a CDF is just a function $F: \mathbb R \to [0, 1]$, so (if $F$ is the CDF of a random variable $X$) people usually write $F(a) = P(X \leq a)$, not $F(X = a)$. So part 2 should go something like, for $0 < y < 1$,
$$
  P(F(X) \leq y) = P(X \leq F^{-1}(y)) = F(F^{-1}(y)) = y.
$$
so the CDF of $F(X)$ (which is not $F$!) is exactly the uniform CDF, so $F(X)$ is uniformly distributed.
Comment: I wonder why this question was suddenly downvoted and closed?
Comment: As for part 3, yes, assuming you are imagining the integral of a constant density.
Comment: @ daisies: thank you so much for your answer! I accepted it


Meteor CLI not working on fresh installation

Question: I am new to Meteor and am trying to get started. I have run the curl https://install.meteor.com/ | sh command and it apparently installed fine, but whenever I use a command with meteor prepended to it, I get a "Killed" message:
➜  ~ curl https://install.meteor.com/ | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7786    0  7786    0     0  15678      0 --:--:-- --:--:-- --:--:-- 15697
Downloading Meteor distribution
######################################################################## 100.0%

Meteor 22.214.171.124 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.

To get started fast:

  $ meteor create ~/my_cool_app
  $ cd ~/my_cool_app
  $ meteor

Or see the docs at:

  docs.meteor.com

➜  ~ /usr/local/bin/meteor --version
[1]    13302 killed     /usr/local/bin/meteor --version
➜  ~ meteor --version
[1]    13324 killed     meteor --version
➜  ~ cd .meteor
➜  .meteor ls
meteor           package-metadata packages
➜  .meteor meteor
[1]    13361 killed     meteor
➜  .meteor meteor --version
[1]    13383 killed     meteor --version
➜  .meteor mrt install
zsh: command not found: mrt
➜  .meteor meteor --help
[1]    13416 killed     meteor --help
➜  .meteor cd ..

This is very frustrating. I don't usually post to SO unless I've exhausted my options, and since I am trying to learn Meteor, those options are limited, and I have no idea how to debug this. I have been looking around for a while and no one else seems to be having this problem — just seems to be an issue on Windows, but I am on macOS 10.13.6 with 16 GB of RAM. I saw a post that mentioned having this problem on a DO Droplet and they were out of memory, but that's not my issue, I don't think.
Any help would be appreciated.
Edit: Permission settings on the respective directories
usr/local/bin
-rwxr-xr-x 1 {username} admin 4785 Feb 20 06:48 meteor

~/.meteor
lrwxrwxrwx 1 {username} wheel 52B Jan 6 16:51 meteor -> packages/meteor-tool/1.8.0_2/mt-os.osx.x86_64/meteor | drwxr-xr-x 3 {username} wheel 96B Jan 6 16:51 package-metadata | drwxr-xr-x 141 {username} wheel 4.4K Jan 6 16:51 packages | ➜ .meteor meteor create ~/cool-app | [1] 6925 killed meteor create ~/cool-app

Comment: I can at least check on Monday at my Mac at work  the permission and let you know if they differ from yours.
Comment: These are my file permissions: `/usr/local/bin/meteor` is `-rwxr-xr-x    1 root    wheel      4785  6 Dez  2016 meteor` and `~/.meteor` is `lrwxr-xr-x    1 {username}  staff     52 29 Jan 14:13 meteor -> packages/meteor-tool/1.8.0_2/mt-os.osx.x86_64/meteor`
Comment: So does this also occur, when you create and start a new project via `cd ~ && meteor create apptest && cd apptest && meteor npm install && meteor` ?
Comment: Yes, when I type `meteor create myapp` I get the same error. It doesn't even make it to the directory creation. Even `meteor —help` doesn't work.
Comment: That's strange. Is there anything special about your `/usr/local/bin` in terms of permission etc?
Comment: `-rwxr-xr-x  1 {username}  admin     4785 Feb 20 06:48 meteor` is what I have in my usr/local/bin. Most of the other files in there are sym linked though. I don't know if that's a relevant detail or not. There's also a mix of {username}:admin and root:admin ownership. The permission pattern for most everything in there — that _is_ sym linked — is `lrwxr-xr-x` whereas, the non-sym-linked stuff have the same permissions as meteor (mentioned previously).
Comment: BTW here's the output from your command:
`➜  ~ meteor create ~/my_cool_app` |
`[1]    1740 killed     meteor create ~/my_cool_app` |
`➜  ~ cd ~ && meteor create apptest && cd apptest && meteor npm install && meteor` |
`[1]    1762 killed     meteor create apptest`
Comment: This is beyond my knowIedge. I added tags on file permissions and failed installation to attract more help here.
Comment: For what it's worth, I installed this correctly on an Ubuntu machine. However the permisisons were root:root (even though I installed using my regular user), instead of {username} admin like they are for my mac.
Comment: Here are the permissions in my .meteor directory.
`lrwxrwxrwx    1 {username}  wheel    52B Jan  6 16:51 meteor -> packages/meteor-tool/1.8.0_2/mt-os.osx.x86_64/meteor` |
`drwxr-xr-x    3 {username}  wheel    96B Jan  6 16:51 package-metadata` |
`drwxr-xr-x  141 {username}  wheel   4.4K Jan  6 16:51 packages` |
`➜  .meteor meteor create ~/cool-app` |
`[1]    6925 killed     meteor create ~/cool-app`
Answer: TL;DR
I have discovered this is an issue with some cloud-configured software that my work provides called Cylance. It is determining that Meteor is a malicious exploit and killing the process whenever I try to run the command.
Debgging steps
To debug why this process was being killed I went to my macOS Console, and ran the command meteor create ~/myApp, a process named CylanceSvc then logged a message saying, "Too many groups requested (65). Can cause Performance issues when network directories are involved." Then the next entry was:
Process:terminated path:/{user}/.meteor/packages/meteor-tool/.1.8.0_2.cty1uc.prsil++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/bin/node pid: violation:None occurences:1 SHA:

When I opened the Cylance program it mentioned it had happily blocked an exploit. I guess it's time to talk to IT. I hope this helps someone else coming here.


qemu-system-i386 quit unexpectedly when starting AVD (Android Virtual Device) on a Mac (illegal instruction 4)

Question: I installed Android Studio on my Mac (Macbook Pro, August 2017, OSX 10.12.4), then started up, created a hello world project and created an AVD (Android Virtual Device, Nexus 5) to run my project on it.
The error shows when I try to run my project on the simulator (pressing the play button) or when I try to start up the emulator itself.
Here's a screenshot of the error:
Here's the beginning of the stack trace:
Process:               qemu-system-i386 [5779]
Path:                  /Users/USER/Library/Android/*/qemu-system-i386
Identifier:            qemu-system-i386
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        studio [4683]
Responsible:           qemu-system-i386 [5779]
User ID:               502

Date/Time:             2017-08-22 13:20:02.612 +0100
OS Version:            Mac OS X 10.12.4 (16E195)
Report Version:        12
Anonymous UUID:        A816A6BA-C97F-6831-E59F-1431A005F23C

Sleep/Wake UUID:       48F2FC89-DF11-4A13-ACEB-E81AF10174B0

Time Awake Since Boot: 15000 seconds
Time Since Wake:       7900 seconds

System Integrity Protection: enabled

Crashed Thread:        4

Exception Type:        EXC_CRASH (SIGILL)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Illegal instruction: 4
Termination Reason:    Namespace SIGNAL, Code 0x4
Terminating Process:   qemu-system-i386 [5779]

And here is the full stack trace: https://pastebin.com/raw/Btt2igX4
Comment: did you find a solution?
Comment: unfortunately not yet
Answer: Disabling / Uninstalling CylancePROTECT solved this issue for me.
sudo launchctl remove com.cylance.agent_service

The same software was also preventing me from compiling go programs.
Some memory protection is at the source of the problem. Here is the relevant article for some fine tuning of CylancePROTECT that could resolve the issue with uninstalling completely the software: runtime: bsdthread_register fatal error (CylancePROTECT)
Comment: I have added the following in my .bashrc `if [ $(sudo env -i bash -c "launchctl list | grep -i cylance | wc -l") -gt "0"  ]; then
      sudo env -i bash -c "launchctl remove com.cylance.agent_service"
fi`
Comment: I am using M1 MBP and this doesn't fix the problem.
Answer: I solved it by go to ADV manager -> Select Virtual Device -> edit icon -> Select Graphics to Software GELS-2.0
Comment: For Tiramisu (API 32) this option is not available on Mac OS X.
Comment: For Android 12 arm64-v8a image only GLES 1.1 is available and if I select it emulator doesn't boot.


change screen angle .NET

Question: Does anyone know how can I change screen angle from .NET Framework 4? (you can not use  Microsoft.WindowsCE.Forms in this version of .NET I believe).
Thank you.
Comment: Yes. I want to rotate screen on .NET 4
Comment: That's a feature of portable devices.  .NET 4 only supports heavy ones.  If you try to target a Windows Mobile device then you need .NET CF and steer clear from .NET 4.  Future slates with Metro require .NET 4.5
Answer: .NET has no built-in functions to do this.
Have a look at this article it describes how to use PInvoke to manipulate the display.

change screen angle .NET


Where can I find a complete skill tree with links to skill info?

Question: I'm looking for a complete skill tree, preferably with a mouseover/link/etc. that shows the details of each skill.  The certification planner is somewhat helpful, but I'm looking for something a little more "big picture".
Comment: What did you want a skill tree for? The skill tree in EVE is very flat and broad.
Comment: Certifications focus on fairly small groups of skills and don't make the overlap between different areas very clear. I feel that a complete skill tree would be better for "big picture" long-term planning. For example, finding different "jobs" or skill groups that share skills, in the short and long term. This seems pretty vital since getting skills past level 3 or so can take days or weeks.
Comment: What overlap between which different areas?  For any given task, there's a small number of related skills.  The relation is shown in certifications.  There is no 'bigger picture' here.  Do you have a single example of what you're talking about?  /me Confused!
Comment: I think the relationship you are looking for, outside of certificates, is the "recommended" tab on ships and modules which points you to groups of certificates.
Answer: EveMon has a pretty good skill tree in it, but it's hard to see everything at once. I don't think I've seen a "complete skill tree" anywhere. But I haven't looked too hard.
Comment: I haven't seen them any better than in EveMon. The problem is that there are so many skills and dependencies. I think putting all of that into one picture would be too confusing anyway.
Comment: I think i already saw a full tree... But i does remember it looking more like a blob... i'll try to find the link =)
Comment: [I found it!](http://go-dl.eve-files.com/media/0802/skillchart.png) But i hope you have a extremely large screen... (not sure it's totally up to date, though...) (EDIT: it's not up to date... no PI skills, still the learning skills... i'll try to look for a recent version)


Can't Paste Python Code without Breaking Indents

Question: I do have editor.formatOnPaste set to true but I get the most annoying bug whenever I copy paste any python code into vscode.
<code>unexpected indentPython(parser-32)
</code>
It seems to fix itself if I backspace and re-indent but sometimes it doesnt and I have to retype the code...
Any suggestions?
Comment: Try going to `Settings` -> `Text Editor` -> `Formatting` and uncheck `Editor: Format On Paste`
Answer:
This was my problem! Opening files from another repo (not created locally) caused
indentation messup and I realized it was reverting to using tabs. Unchecked to fix.


Get Data From firebase Realtime database using angular http

Question: I'm trying to retrieve data from firebase using angular httpClient

my code to get the data :

Service
getUsers() {
return this.http.get(this.fireBase+"/users.json").map(res => {
  const data = res;
  return data;
});

Component
getUsers() {
this.getWeather.getUsers().subscribe(
  (response: any) => {
    console.log(response);
  },
  err => console.log(err)
)
}

the result is :

what I want is to get those objects without keys . I was trying to push them in array. but failed.
can anyone help please.
thanks in advance.
Answer: I fixed this problem by converting the object to array
here's the code :
getUsers() {
this.getWeather.getUsers().subscribe(
  (res: any) => {
    this.users = Object.keys(res).map((key) => { return res[key] });
    console.log(this.users);
  }
)
}


Using C++ inheritance to enhance a class with ownership semantics

Question:
I have some (in my opinion) fairly specific ownership requirements: I have a class that basically interprets an array of doubles is a specific way (a concatenation of some fairly large matrices), and want to communicate with a C library that interprets then in another way (a very long mathematical vector). In some cases, I want to interpret a pointer that is passed to a callback by the C library, that is, without taking ownership. In that case, copying would be very impractical. In other cases, I want to allocate the buffer myself, and pass it to the C library myself. In that case, my code owns buffer.
I created a "building block" that interprets the double array as the matrices (with boost::numeric::ublas::shallow_array_adaptor, but that is mostly irrelevant), like this:
class Foo {
 public:
  explicit Foo(double *buffer);
  Foo(const Foo &) = delete;
  Foo(Foo &&) = delete;
  Foo &operator=(const Foo &) = delete;
  /* Some accessors. */
 protected:
  Foo &operator=(Foo &&) = default;
 private:
  /* Some things that store pointers into the buffer. */
};

Copying and moving is forbidden so that and instance cannot accidentally be created or moved somewhere which outlives the buffer itself. Of course, deliberate creation of such instances is possible by directly passing the pointer somewhere but can be spotted more easily in the source.
The first part of my question: Does it make sense to let "Foo enhanced with ownership of the buffer" be a subclass of Foo?
Every operation of Foo is possible with the owning-Foo, additionally, owning-Foo can be freely copied and moved. It smells like the Liskov substitution principle is satisfied. Being able to handle owning-Foo and Foo the same way syntactically without writing a bunch of methods in owning-Foo that delegate to a member variable is very comfortable.
On the other hand, there could be owner-of-Foo instead, that deals with the ownership and nothing else, and contains an instance of Foo that may be accessed from outside, providing better separation of concerns.
I implemented owning-Foo like this:
class OwningFoo : private std::unique_ptr<double[]>, public Foo {
 public:
  explicit OwningFoo(std::size_t size)
      : std::unique_ptr<double[]>(new double[size]),
        Foo(std::unique_ptr<double[]>::get()), size_(size) {
  }
  /* Implementation of copy and move constructors and
   * assignment operators redacted. */
  OwningFoo(const OwningFoo &);
  OwningFoo(OwningFoo &&);
  OwningFoo &operator=(const OwningFoo &);
  OwningFoo &operator=(OwningFoo &&);
 private:
  std::size_t size_;
};

My second part of my question: Is this a good case for multiple and private inheritance? Am I shooting myself in the foot somewhere?
Note that if Foo is not a member, than std::unique_ptr can neither be a member, because it needs to be initilized before Foo.
Comment: If you want to check for mathematical correctness at compile time, go with a functional language. The C language was invented for the express purpose of writing operating systems, and C++, despite adding lots of fancy stuff like OOP, very much follows the same design principles. If you are doing math, use a language that is well suited for math, such as Haskell or Scala. You may lose some run-time performance, but you gain development-time efficiency and compile-time correctness checking.
Comment: This is rather complicated and hard to follow IMHO. I think you need to keep it simple. The core issue is that sometimes you have data that is owned by your code, and other times it is owned by some external library, correct? So how about just a flag in `Foo` about who the owner is, and the destructor looks at the flag and deletes (or not) appropriately.
Comment: Well, I do not think that could work. An owning-`Foo` (or owner-of-`Foo`) is movable or copiable, while a non-owning-`Foo`, I think, shouldn't be so, lest it outlives the buffer it doesn't own. Due to the fact my code is already confusing for *mathematical* reasons (i.e. it is an implementation of a nontrivial mathematical model), I would like to check for as much correctness at compile time as it is practically possible.
Comment: Regarding non-owning Foo outliving a buffer it doesn't own, that's a good point. A partial fix would be to check the ownership flag I suggested not just at destruction time, but also at copy/move time, and possibly throw an exception. Obviously this isn't quite as good as a compile-time check, but considering how nasty your situation is to begin with, a clean solution may not be worth it. I'm sure you'd rather spend your time on the mathematics you are implementing/solving than on battling the language/compiler.
Answer: The way I do it is push the ownership issue farther down.  Foo has a buffer, and knows how to clean up that buffer when it is destroyed.  The std::shared_ptr has a destroy callback that can be used for that purpose, for example.  This shows the accepted pattern of having the smart pointer know how this particular instance is to be deleted.
Really, you should have a possibly shared buffer so the total ownership is tracked.  Implicitly programming it to be "not me" with some other place knowing what's going on is rather brittle.
"checking ownership flags" is just a special case of "am I the last/only owner" which has a general robust implementation you can use.
In the twist you mention, how does the C code that owns the buffer coordinate with your class's lifetime?  It sounds bad, and having your class know it doesn't own the buffer (in a well-encapsulated way) doesn't change the problem of the C code not knowing when your instance is done with it.
Comment: Thanks.  'Tis true but often not taught to the extent that is needed in real life, that one has to deal with issues such as this.  C++ is nearly unique in being able to do "anything you want" with respect to memory and interfacing, so it's well suited for such tasks.
Comment: In the problem I was facing, I wanted to avoid any modification of the C library (in fact, a FORTRAN library referenced through `extern "C"`). While I did have the (open) source, the library did numerical optimization stuff I was unfamiliar with and afraid to break. However, my question is rather old and in happier situations, your approach is the preferable, so I mark it accepted.


Getting NullPointerException on ArrayAdapter

Question: I created one function with name spinner_fn(). But when this function is called, it shows NullPointerException. All the values coming from database. Can anyone please help me how to solve this issue?
Source code
    ...
    String result = DatabaseUtility.executeQueryPhp("initialName","");
    System.out.print(result);

    try
    {
        JSONArray JA = new JSONArray(result);

        initial_name = new String[JA.length()];
        initial_id = new String[JA.length()];

        String initialname="";
        String initialid="";

        for(int i=0;i<JA.length();i++)
        {
            initialname = JA.getJSONObject(i).getString("initial_name");
            initialid = JA.getJSONObject(i).getString("initial_id");
            initialMap.put(initialname,initialid);
        }

        spinner_fn();
    }
    catch(Exception e)
    {
        Log.e("Fail 3", e.toString());
        e.printStackTrace();
    }
}

private void spinner_fn() {
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(
            getApplicationContext(), android.R.layout.simple_spinner_item,
            initial_name);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    initial.setAdapter(dataAdapter);

    initial.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int position, long id) {

            Log.e("Position new", initial_name[position]);
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {

        }
    });

LogCat
11-03 07:27:36.161: E/AndroidRuntime(2896): FATAL EXCEPTION: main
11-03 07:27:36.161: E/AndroidRuntime(2896): java.lang.NullPointerException
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:193)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.Spinner.onMeasure(Spinner.java:439)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1034)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1217)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.ScrollView.onMeasure(ScrollView.java:321)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.View.measure(View.java:15518)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.Choreographer.doFrame(Choreographer.java:532)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.os.Handler.handleCallback(Handler.java:725)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.os.Looper.loop(Looper.java:137)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at android.app.ActivityThread.main(ActivityThread.java:5041)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at java.lang.reflect.Method.invokeNative(Native Method)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at java.lang.reflect.Method.invoke(Method.java:511)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-03 07:27:36.161: E/AndroidRuntime(2896):     at dalvik.system.NativeStart.main(Native Method)

Comment: You are returning null in your array adapter. Show me adapter code.
Comment: above one is my adapter code
Comment: check your initial_name array items having String values with doesnt having null
Answer:
initial_name = new String[JA.length()];

...

ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(
        getApplicationContext(), android.R.layout.simple_spinner_item,
        initial_name);

Your initial_name array is full of nulls as you haven't assigned any values there. All ArrayAdapter array elements must be non-null.
Guessing you want to change

for(int i=0;i<JA.length();i++)
    {
        initialname = JA.getJSONObject(i).getString("initial_name");

to something like
for(int i=0;i<JA.length();i++)
    {
        initial_name[i] = JA.getJSONObject(i).getString("initial_name");

Comment: where i need to change the can you please tell me
Comment: @user can't you see this? Or my dear friend, `debug` is always a best friend of developer!


F1 2016 - Loading setups from Steam Workshop

Question: I'm playing F1 2016 on Steam, and joined a couple of online races; I noticed that at the start of every race I can edit the car setup and there is also the button to open the Steam Workshop and load setups from there, but it's always empty: why?
Do I have to subscribe to the setups from the Steam client in order to have them listed on the game?
Thanks!
Answer: The way the Steam Workshop works is similar to how you described.
Yes, you have to subscribe to the Wokrshop Item you want to load in to (perhaps *) use it.
And you probably know, but to reassure you, you don't pay anything when subscribing to any item on the Workshop.
(*: If the item is broken or incomplete, errors may occur, hence why I put the * there to tell you.)


Why is this Fizz Buzz generator significantly faster than this Fizz Buzz Iterator class?

Question: After learning about iterator class methods and generators, I tested the performance characteristics of simple Fizz Buzz solutions utilizing each idiom:
>>> from timeit import timeit
>>> timeit('tuple(fizzbuzz.FizzBuzzIterator(10))', 'import fizzbuzz')
13.281935930252075
>>> timeit('tuple(fizzbuzz.fizz_buzz_generator(10))', 'import fizzbuzz')
7.619534015655518

According to timeit the generator function is about 1¾ times faster than the iterator class.
My question again: Why is this Fizz Buzz generator significantly faster than this Fizz Buzz Iterator class?
Fizz Buzz iterator class
class FizzBuzzIterator:

    def __init__(self, low, high=None):
        if high is None:
            self.high = low
            self.current = 1
        else:
            self.high = high
            self.current = max(low, 1)

    def __iter__(self):
        return self

    def next(self):
        if self.current > self.high:
            raise StopIteration
        else:
            c = self.current
            self.current += 1
            if (c % 5 + c % 3) == 0:
                return 'FizzBuzz'
            elif c % 5 == 0:
                return 'Buzz'
            elif c % 3 == 0:
                return 'Fizz'
            else:
                return str(c)

Fizz Buzz generator function
def fizz_buzz_generator(low, high=None):
    if high is None:
        high = low
        cur = 1
    else:
        cur = max(low, 1)
    while cur <= high:
        c = cur
        cur += 1
        if (c % 5 + c % 3) == 0:
            yield 'FizzBuzz'
        elif c % 5 == 0:
            yield 'Buzz'
        elif c % 3 == 0:
            yield 'Fizz'
        else:
            yield str(c)

Comment: Thanks to moderator/admin who removed the off-topic answers :)
Answer: Because apparently, generators are implemented more efficiently than iterators.
Your first solution has the following interesting characteristics:

It uses objects.
For an iteration over n numbers, 3 + n methods are called and 2 + 4·n attributes are accessed, which are both potentially slow operations.
Exceptions are used for control flow.

The second solution does none of these, instead it yields which means that the language runtime performs the heavy lifting. As the runtime is usually implemented in C, this can be far more optimized than the very high-level code of your first solution.
Next, you should consider what you are actually benchmarking. For a good benchmark you should choose different input sizes n and watch how the two solutions compare at different scales.

For very small n, we expect the initalization cost to dominate. This is consistent with your results, as performing a function call is less expensive than creating an object.
For larger n, we expect the features of the algorithm to dominate. As the algorithms are exactly the same, the graphs should have the same shape. But per iteration, the first solution has a much higher cost (four attribute accesses, one method call). The two solutions would then be graphs with slightly different slopes. The exact relation of the per-iteration costs can only be assessed by obtaining a large data set of many timings for many input sizes n, and then fitting a function to that data.
Comment: I made some graphs to see how much difference the lines are plotted. http://imgur.com/a/Ehb8U It's amazing the measurable difference. Thanks again for the awesome answer!


Will all applications work fine on 64-bit Ubuntu?

Question: I used Ubuntu some time ago and now I want to switch on it again since community raised a lot and so did support for applications like Wine. I remember that when 64bit version just came out many applications didn't work as they did on 32bit version. Is it not better or still the same? Maybe they implemented something like WoW in Windows that simulates 32bit architecture and every possible app is working just fine. I am asking because I have lots of ram and I don't want to sit on 3GB when I have 8.
Also, I am somewhat of a programmer, but that is not a problem because if I write PHP I use NetBeans on Windows anyway, and it works on Linux just as fine. But I also love to write C++/C# code. Is it well supported? I really like Visual Studio 2010, it is very slick and has good auto completion, debugging and so on... Is there any IDE on Ubuntu that is similar to Visual Studio in terms of auto-completion, code formatting, GUI designer, debugging?
I really hope you will answer me these questions because I really like to "convert" myself to Ubuntu once and for all.
Comment: Consider breaking your questions into separate inquiries.
Comment: For C# on Ubuntu, I'd definitely take a look at MonoDevelop: http://monodevelop.com/
Comment: Kory is right, the second paragraph should be a completely separate question.
Answer: *Most applications work just fine in a 64-bit OS. I haven't actually run across any that don't, but as soon as I say all applications one is bound to pop up.
As to your 8GB RAM point. Unless you have processes that take more than 4GB of RAM then a 32-bit OS with the PAE kernel will address all 8GB of your RAM.
Comment: Pretty much anything in the Ubuntu Software Center should be fine, but I got so sick of fighting with 64-bit Flash and Java, that I eventually moved back to 32-bit.
Comment: 64-bit Flash and 64-bit Java work for me
Comment: Also install ia32-libs.
Answer: As far as the 64-bit Ubuntu version is concerned, I have had zero difficulties running either native Linux applications and/or Windows programs under Wine.  Obviously there is software out there, with which I have no experience, but I would suggest that the 64-bit Ubuntu version is much better than it was a few years ago when I was trying to get it up and functioning properly on a past laptop.
Answer: I installed 64-bit Ubuntu just a few weeks ago and the only problem I've encountered so far is that LinkSys AE1000 wireless adapter doesn't work with it: the drivers provided by Ralink are only 32-bit and I couldn't get them to work with 64-bit Ubuntu.  Everything else, though, has worked as well, if not better, than before.  I'm very glad I made the switch, since the 64-but OS seems to be a little faster overall (more than I expected, frankly).
But I'm not a programmer: your mileage may differ.
Answer: Regarding 64 bit Linux: in many respects, linux has better 64 bit support than windows in that there are more key applications that are 64 bit native.  Ubuntu has improved very much in the past few years with regard to 64 bit support; flash is now available in "preview" mode for native 64 bit support.  Also, the 32-bit support w/in 64 bit generally works as a fallback.
Regarding an IDE, I would recommend Eclipse, if you're looking for an all-language, integrated IDE.  It has the richest plugin ecosystem (moreso than VS).  But, being a guy who considers it "forced" to have to use VS2010, I personally like gedit.  Good old gedit has syntax highlighting for most languages (and community available packages for more), and very many plugins to do code completion, bracket completion, etc...  It's lightweight and easy to use.  http://live.gnome.org/Gedit/Plugins


how to track a struct member value change in C?

Question: struct STATE{
  uint8 bit;
  uint8 cop;
}
STATE *state_array[1024];

state_aray[0]->bit = 8;
state_aray[0].cop =  8;
state_aray[1]->bit = 0;
state_aray[1].cop = state_aray[1]->bit & 8 != state_aray[0]->bit & 8
state_aray[2]->bit = 12;
state_aray[2].cop = state_aray[1]->bit & 8 != state_aray[0]->bit & 8 && state_aray[2]->bit & 8 != state_aray[1]->bit & 8
state_aray[3]->bit = 0;
state_aray[3].cop = state_aray[1]->bit & 8 != state_aray[0]->bit & 8 && state_aray[2]->bit & 8 != state_aray[1]->bit & 8 && state_aray[3]->bit & 8 != state_aray[2]->bit & 8
state_aray[4]->bit = 8;
state_aray[4].cop = ...

state_aray[5].cop = ... ...
...
state_aray[100].cop = ... ...... ......... ....... ......... ....... ...... ....... ............... ........ ...... ............ .... ......... ...... ..

is there a way to only use state_aray[i-1]->cop and state_aray[i-1]->bit and state_aray[i]->bit to get state_aray[i]->cop?
tks
Comment: Please rephrase your question. I have no idea what you're trying to do.
Comment: Rolled back your last edit.  Questions can't be deleted if there are more than one answer.  See [here](http://meta.stackexchange.com/questions/5221/what-can-cause-a-post-to-be-deleted-and-what-does-that-actually-mean/5222#5222).
Comment: if your question can be deleted, there is a 'delete' link just under the tag box for 'c'.  I'm not sure whether the rules have changed so that if there are answers, or answers with up-votes, then the question cannot be deleted.  You could also consider flagging the moderators, and ask them to delete it for you.  If the question cannot be deleted, it is best to leave it visible, possibly with a better explanation of what you're trying to do.
Comment: You need to be consistent in your use of '`.`' vs '`->`'.  Given that you have an array of pointers, you need to ensure you have initialized those pointers - signally missing in the code shown.  Or you need a simple array of your structures (more plausible).  For the first option, you need to use the '`->`' notation; for the second option, you need to use the '`.`' notation.  Also, you should use a few parentheses, and probably a loop, or even a pair of nested loops.
Answer: Won't work. There's no "I'm a member of this structure" mechanism in C, as opposed to OOP's "this" or "self" concepts.
That's why in C you simply hide your structure implementation and provide functions to change the values in which you sneakily set other values.
STATE *create_state(void)
{
    STATE *retval;

    if( (retval = malloc(sizeof(STATE))) == NULL )
        return NULL;
    retval->cop = -1;
    retval->bit = 0;
    return retval;
}

void set_state(STATE *st, int val)
{
    st->bit = val;
    st->cop++;
}

int has_state_changed(STATE *st)
{
    return st->cop;
}


jQuery multiple file upload from scratch

Question: I am trying to implement a multiple image uploader in jQuery using the new HTML5 multiple attribute.
My code is the following:
<form action="file-upload.php" method="post" enctype="multipart/form-data">
    <input name="userfiles" type="file" multiple="multiple">
</form>

The JS code I am using is taken from a discussion here on SO, and is the following:
 $('input[name=userfiles]').change(function() {
    var names = [];
    for (var i = 0; i < $(this).get(0).files.length; ++i) {
        names.push($(this).get(0).files[i].name);
        console.log(names[i]);
    }
 });

With this I am able to print on the console the file names I select, but what if I need to get the exact val() of those files? I tried replacing .name with .val(), but I get an error.
I think I would need a fakepath of every single file if I want to be able to work with them with $.ajax. If this is correct, how can I cycle though them in the PHP file where the get request is sent, in order to upload them?
Answer: You can make use of HTML5 FormData API. https://developer.mozilla.org/en-US/docs/Web/Guide/Using_FormData_Objects
var form = new FormData();
for (var i = 0; i < $(this).get(0).files.length; ++i) {
    form.append('userfiles[]', $(this).get(0).files[i]);
}

// send form data with ajax
$.ajax({
    url: 'url',
    type: "POST",
    data: form
});

Or if you cannot use FormData there is a way to send it natively:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Submitting_forms_and_uploading_files
Comment: Yes, because you're using multiple option
Comment: Thanks. Do I need to change the input name from `userfiles` to `userfiles[]`?
Comment: I have difficulties to select the input by name then, if I use `$('input[name=userfiles[]]')` I receive an error because of the `[]`
Comment: Nevermind, managed to do it with `$('input[name=userfiles\\[\\]]')`. I will let you know if I'll do it :)
Answer: You don't need to manipulate file path, in your ajax call just use the File and put it into a new FormData
Something like that:
 $.ajax({
'type':'POST',
'data': (new FormData()).append('file', $(this).get(0).files[i])

See HTML5 multiple file upload: upload one by one through AJAX
Comment: Wouldn't it be better to send the whole form via `data` as @insanebits suggested?
Comment: I don't know why you need to loop on each of your file. If you want to add a progressbar and send files one by one (like gmail attachments) it is a solution.
If you don't care, just send them all in once.
Comment: My target would be, in the PHP file, to do: `if (isset($_FILES['userfiles']))` and so on. I don't need the progress bar to appear, but will I be able to do this if I send the whole form? Because right now, it doesn't even seems to enter the `if` statement.
Comment: (Also, in the ajax call I had to disable the processData with `processData: false`)
Comment: dump the content of $_FILES or do network capture to see what it is send. My example will upload in $_FILES['file']
Answer: If you use jquery-file-upload plugin you can use this
<input class="fileupload" type="file" name="file">

and
$('.fileupload').each(function () {
  $(this).fileupload({
  //your code goes here
})


Linq to entities: how to do a subquery

Question: How can i do this query with Linq To Entities
SELECT * FROM TableA
WHERE MyID IN
(
    SELECT MyID
    FROM TableB
)

The thing is that TableB does not exist as an entity because it contains only foreign keys to other tables, and there is no direct link between TableA and TableB
Answer: Without TableB being an entity, I am not sure what you could do. If you did make TableB an entity, so that it was in your model, you should be able to do something like the following (not sure if this is exactly correct, but the concept should be sound):
var tableAResults = from ta in db.TableA
                    where
                    (
                        from tb in db.TableB
                        select db.MyID
                    ).Contains(ta.MyID)
                    select ta;

If you are using EF v1.0, this kind of query may not work. EF v1.0 had some significant limitations on the linq queries it supported, and its SQL generator was terrible. I do not have quite as much experience with EF v4.0 (from .NET 4.0 betas) as I do with v1.0, but I do believe the above query should be possible, and it should be translated to something very similar to you're original SQL query.
(If you are using EF v1.0, plan for a migration to EF v4.0 soon, and have it ready to go once .NET 4.0/VS2010 is out. EF v1.0 has countless annoying limitations, quirks, stupid rules, etc. that just make it a nitemare to use...this one is quite mild compared to some.)
Comment: You would use Any(), not Contains() for this, and it would work fine in EF 1. But I think the problem is actually far easier to solve.
Answer: Presuming TableB doesn't appear because it is part of a many-to-many relationship between TableA and some TableC (the only way your question makes sense to me), you would do:
var q = from a in Context.TableA
        where a.TableC.Any() // replace "TableC" with the relationship property name
        select a;

Easy, but you need to get your head around how the relationships work.

Linq to entities: how to do a subquery


How are equipment grounding conductors counted for determining conduit or junction box fill?

Question: Suppose one is doing junction box fill calculations for a typical NM-B installation such as the one shown below for a switch box with one normal and one three-way switch. Which of the wires count towards conductor fill?

Section 314.16(B) of the 2011 NEC states (in part):

314.16(B)(1) Conductor Fill
Each conductor that originates outside the box and terminates or is spliced within the box shall be counted once, and each conductor that passes through the box without splice or termination shall be counted once. Each loop or coil of unbroken conductor not less than twice the minimum length required for conductors in 300.14 shall be counted twice. The conductor fill shall be calculated using Table 314.16(B). A conductor, no part of which leaves the box, shall not be counted.

and

314.16(B)(5) Equipment Grounding Conductor Fill
Where one or more equipment grounding conductors or equipment bonding jumpers enters a box, a single volume allowance in accordance with Table 314.16(B) shall be made based on the largest equipment grounding conductor or equipment bonding jumper present in the box. Where an additional set of equipment grounding conductors, as permitted by 250.146(D), is present in the box, an additional volume allowance shall be made based on the largest equipment grounding conductor in the additional set.

So how many conductors, and how many equipment grounding conductors are present in the box shown here?
Comment: I get 7 + the single grounding allowance, or 8. Don't be foolish though. Don't stuff it so full of pigtails and long leads such that the wires are really packed in there with little free air and pushing everything in could displace or damage something.
Comment: You've got eight conductors.
Comment: @Edwin oh man, you're giving me flashbacks to the Star Trek: The Next Generation episode when Picard had that Code compliance disagreement with the Cardassian...
Answer: Please see this answer, for more detail. Basically if you have equipment grounding conductors enter the box, you add 1 fill unit.
Example Breakdown
In the example you've provided you have 12 if it's a box without internal clamps, and 13 if it has internal clamps.

Current Carrying Conductors
    Ungrounded (hot)            4
    Grounded (neutral)          3
    ----------------------------------
                                    7

Equipment Grounding Conductor       1

Clamps  (maybe)                     1

Devices                         2
                               x2
    ----------------------------------
                                    4
    ----------------------------------
Total                               13
Answer: It requires yet another section of the code, but I think you are actually low.
The EGC is clear - 1, at the biggest size, and done.
Current-carrying wires (hots and neutrals and travelers) count once per wire.
But I think there is another paragraph (or sentence) which indicates that a "device" in the box ALSO counts (2 each.)
From  Tester101's resonse to another question (but I think he's just quoting the code here)

Clamp Fill

If there are any internal cable clamps, add 1 (not 1 per, just 1).

Support Fittings Fill

If there are any luminaire studs or hickeys, add 1 (not 1 per, just 1).

Device or Equipment Fill

For each yoke or strap containing one or more devices, add 2.

So you have 8 count of wires, but 12 count (at least) of "fill units" - 13 if you have clamps.
Answer: Equipment Grounding Conductors aren't Conductors
In the maddening language of the NEC, this is true.  "Conductors" (generally) refers to non-grounds: meaning

Ungrounded Conductors (hots which are not neutral but normally carry current)
Neutral, whose NEC lawyer-name is "Grounded Conductor" and carries current

These two are called "conductors" because they carry current in normal operation.
The lawyer-name for neutral has driven me absolutely bat-crazy, because everyone goes "Oh! You mean ground!" No no, the "Grounded Conductor" is a conductor. Ground isn't, that's why they call the Equipment Grounding, uhhhh, Conductor.  You can't fight in here. This is the War Room!


Postgresql Exclude constraint on a set of values

Question: Suppose I have a table with two columns:
| id | status |

Status can take 3 values: booked, started, completed
I need a constraint that will satisfy the following requirement:
For entire set of rows, only one record can be in non completed state: booked or started.
I believe I need an Exclude constraint for that, but I don't know what operator can be specified:
add constraint constraint_x   exclude (status with ANY?)
   where  (status <> 'Completed')

That's the solution I came up to:
add constraint constraint_x exclude ((1) with =) where ((status) <> 'Completed')

Is this a good one?
Answer: Your solution is ok.
I would solve that with a partial unique index like this:
CREATE UNIQUE INDEX ON table_name ((1)) WHERE status <> 'Completed';

Answer: That's the solution I came up to:
add constraint constraint_x exclude ((1) with =) where ((status) <> 'Completed')


Should I include an expansion joint between steps and a foundation?

Question: I am building this retaining wall that ends with steps. The steps will be on one side against the foundation of the house.

My question is should I use expansion joints between the step units (SRW concrete units) and the foundation or it'd be over-engineering?
The 2 options I found are:

SAKRETE Concrete Expansion Joint
QUIKRETE 4-in x 60-in Concrete Expansion Joint

If yes to the above question, which option is better?
Any other suggestion would be very much appreciated.
Comment: Yes to the expansion joint, either you do one now, or the weather will choose a time and place.  I do not know what product is best, I let nature put the expansion joint for me, and have not filled it in yet.
Comment: for what it is worth, mine took more than 10 years before I had to get serious and redo it completely. :)
Comment: It's not clear what the layout is to me. If the run is as short as it appears, I wouldn't bother. Concrete has a very low coefficient of expansion, and it would be extremely unlikely to cause problems over a length of a few feet.
Comment: I guess it is going to be the weather now :-) as I already went ahead and did not use the expansion joint. It looked odd, half inch of oddity.
Thanks for taking time though.
Answer: Both of your expansion joints are OK to use. And yes its not over engineering, Better to deal with it now then pay for it in the longrun.
Answer: depends on where you are.  in cold climates like here in Ontario, expansion joints are gospel.  when the temperature gets down to -40 c, an assembly like that without an EJ can blow a hole right through a poured wall.  if its cold like it is here, pull it apart and put the EJ in before it freezes up for the winter.


Which Nvidia card driver do I choose?

Question: I am looking at the tab "Addition drivers" in the "Software & Updates" window, and I am seeing 5 options.

It is quite clear that the last option must be the open source version of my graphic card driver. But what about the other 4? What is each, and which one should I chose to perform better?
Answer: I've had success with running sudo apt-get install nvidia-current. I feel like this is the most fool-proof way to install the nvidia drivers (and the change will be reflected in the additional drivers dialog)
If you have problems with the driver chosen by nvidia-current, you could try to select the other options from additional drivers and see if they work better.
If you still have problems, you could try the very latest drivers from the nvidia website, but this I think is a bit more complicated and I've personally never done it.
I try to stick with the apt package manager as much as possible when installing drivers and software.
Also, I would just stick with the open-source drivers if they are working, unless you have a reason to use the proprietary drivers.
Answer: In my experience, you should leave the system decide the correct driver,
since it's an nvidia card there is no support behind it if something goes wrong.
To answer your question though, these options are different driver revisions that support your hardware (graphics card), usually the latest the better.
If it is also tested, as stated in the brackets, it adds more security to your choice.
About performance I am not an expert, but I guess you have to run some test for your machine.
You can have a look on this guide: HOWTO: Install OpenGL/Graphic card Benchmark utility - SVN
Comment: That post is from 2006! Does it content stand today?
Comment: As I said, I am not an expert, I only have personal experience with nvidia drivers, since my laptop also has an nvidia card.
You can try out if the guide from the link works for you, or with a fast search I made, I also found this link which I haven't tested my self either [http://www.phoronix.com/scan.php?page=news_item&px=NzA3Mg](http://www.phoronix.com/scan.php?page=news_item&px=NzA3Mg).
Generally, benchmarking for linux will test the openGL capabilities of your card since directX is a Microsoft "thing".

Which Nvidia card driver do I choose?


Are the individual breakers and branch circuits on a service main truly isolated from one another?

Question: United States here. I have a 150-amp main service panel in my house and I'm trying to understand how (if at all) the individual branch circuits (and their breakers) interact with each other and the panel at large.
I have several "slots" open and unused in the panel. Meaning, several locations where more breakers could be added, and hence, more branch circuits.
But, to me, just because the panel has more slots doesn't necessarily mean it can handle more breakers + circuits. If every time I added a new breaker that previously wasn't there, will that some how reduce the amount of voltage or amperage available to the other breakers/circuits? And somehow put more strain on them or hurt their "performance"? Or is each branch circuit completely isolated from the others, making it so that I am free + clear to fill all the unused slots up with breakers and more circuits?
Comment: Most panels if you add up all the breakers, will be more than the main breaker.  Most people will never use all the power at once, that the breakers will supply.  Most breakers/circuit use only about 10 to 50% of the rated amount at any time.  This goes out the window if someone starts 10 to 20 AC units at once.
Comment: They all share the same path to ground and the same neutral tap on the transformer, so no. That's why when your gutter gets struck by lightning, *everything* in your house burns out. And why using blenders in another room screws up the picture on analogue TVs, reception notwithstanding. It's called *dirty power* - if you have it, you'll know.
Answer: Correct - number of breaker spaces has no bearing on system ampacity.  They are two unrelated parameters, like money in your account vs checks in your checkbook.
Every appliance draws the current it needs, and no more.  Varying as its needs change.  The sum total of those actual draws (for each phase) constitutes the actual load on your panel.  Having more breakers in your panel doesn't add any load, the loads do.
Around here, we advocate a gross excess of breaker spaces, since they're dirt cheap. But your whole 150A ampacity could be consumed in 4 spaces.  I had a friend with 400A service (two 200A panels). 2 breakers (4 spaces) accounted for 140A of emergency heat on a heat pump.  But only when the emergency heat was on, and that means the heat pump proper is not on, so the 16A heat pump can overlap into that same 140A.  So it isn't 140A+16A, it's 0A with nothing running, 16A with heat pump running, OR 140A with emergency heat running.
If you overload your panel you will get a main breaker trip. That breaker is there to protect the panel and service wiring from damage from overloading.
No professional electrician will build a panel that will overload.  This is determined by a formal process (2 actually) called a Load Calculation. You input square footage of house (as a catch-all for general lighting and receptacles), an allocation for 20A kitchen and bathroom circuits, the nameplate data of most 240V appliances except some wild math on the range, and you add them up.  It must be less than the service ampacity or they won't give you an occupancy permit.
That is vanishingly unlikely to trip the main breaker.  Back in the dark days, they permitted house with up to six "main breakers" which added up to well over the service ampacity, hanging their hat entirely on the load calc.
The Achilles' heel of this system is upgrades.  People add loads and don't redo the load calc.  That was particularly a problem with Rule of Six panels, which is why they are outlawed.
Comment: To complete this answer, I would add that branch circuits are not electrically "isolated" as stated in the question, unless they are switched off.  Maybe that part could be interpreted different ways.
Answer: Each breaker/circuit is independent of the others, with some specific exceptions:

MWBC - You can have two breakers next to each other, on different legs of the service, that share a neutral. That is a "Multi-Wire Branch Circuit" (MWBC). An MWBC in some ways is "one circuit" and in some ways it is "two circuits". Not really the issue here, but it is a "two breakers affect each other" situation, and as a result they (a) have to be next to each other and (b) have to be physically connected (double breaker or handle tie) so that turning off one turns off the other. The sharing actually helps on the neutral because the neutral carries the difference between the two instead of adding together.
AFCI - Due to the way arc fault detection is done, there can be some effect from one circuit on another. But that should be relatively rare, and would likely be an indication of a big potential problem. It isn't so much that the circuits affect each other but rather that the arc could be detected in more places than just the circuit where it happened.

In any case, more breakers is fine. There is no effect on voltage unless you draw so much power that you effectively cause a brown-out for your house. (Think "laser printer starts up and lights dim" - normally happens only on the same circuit but enough usage throughout the house could have impact on everything else in the house.)
There is a concern about current, but more breakers/circuits is an improvement, at least compared to simply putting more stuff on each existing circuit, because it decreases the likelihood that any one circuit will be overloaded because you are splitting the current across more circuits.
All that being said, there is a concern if you dramatically increase the total usage - e.g., by adding EV charging or on-demand water heating - that you could overload the main service. So when a major change is made, you really should have a load calculation to determine if your total service is up to the task. But adding new circuits that either have short term usage (e.g., circuits for tools that get used for a few minutes at a time) or low continuous usage (e.g., LED lighting) generally will have minimal effect on the total building electrical load.


Good Book for methods of Convergence

Question: First of all I'm interested in methods of convergence (for sums and integrals) so are there good books which tackle these methods one after the other and with examples that are not too trivial?
For example how would you proof that
$$
\int_{-\infty}^\infty \frac{{\rm e}^{ikt} \, {\rm d}k}{\left(1+a^2\sin^2(k)\right)\left(k-b\right)^{\epsilon}}
$$
where $\Im (b) < 0$, $0<\epsilon\leq 1$, $a>0$, converges and for which $t$. Analogously one could ask when does
$$
\sum_{n=-\infty}^\infty \frac{ {\rm e}^{i\pi tn} }{ \left( n + c \right)^{\epsilon} }
$$
converge $(\Im(c)>0)$? Feel free to try this.
Answer: A nice book in my opinion is "Advanced Mathematical Methods with Maple", by D. Richards.
 It is used as a text book in the homonymous course in the MSc in mathematics by the Open University. It is not only about convergence, but it has quite a theoretical underpinning and practical exercises too about that topic, where maple is used to illustrate and investigate the subject.

Good Book for methods of Convergence


I lose every battle in Dragon Front and don't know why. Any general guidelines?

Question: I tried all 4 available factions, I tried building my own deck. I tried things.. But nevertheless, I always end up loosing. As if every opponent on earth is better than me. I want to believe that it's not the case.
Any general advise to have a better chance of wining some games ?

what should be the ratio between low and high mana card ?
what should be the ratio between spells / creatures ?
should I try to defend at all cost ?
should I try to attack ASAP ?
should I try to block opponent's mana generation instead of building mine ?
Am I just a desperate case ?
?..

I have really no clue about why I'm so bad at this game. Any general advice would be appreciated.
Or, is there actually any tips that can be given like that without more context ?
Answer: Most people familiar with modern CCGs assume that you get incremental mana at the start of the turn.
In fact, you get 1 mana each turn, and an additional mana for each unit you have stationed in your spawn row at the start of the turn. This means if your four space mana row is full, you will generate 5 mana at the start of your turn. You will see a blue highlight under the units that will be generating mana for you.
This design encourages you to keep your units back in your spawn row until you are comfortable with your mana growth. At that point send them to battle! Sending units across the battlefield too early in the match will surely put your mid-game mana generation at risk.
If you are one mana away from being able to afford a card, you have a few options. Once per turn, you can discard a card from your hand to generate one mana. Just remember having card options is equally powerful, so I would only do this in the early game, or if you REALLY need that 1 mana.
Also, when one of your units is destroyed you gain mana fragments. These are the tiny blue skulls on the right panel when you examine a card. This helps recover enough mana to bring out other units. In cases where you really need to bring out a higher costed card, sacrificing a unit is a great option! Remember the BLIGHT trait removes these fragments, earning you NOTHING for its death.
THORNS is a great faction for mana generation, with units, spells and forts that contribute mana.
SCALES - Command Headquarters in the Scale faction is one of the best Mana generating forts in the game.
STRIFE requires some finesse, as they have units that can spawn outside of their spawn row, which is great for aggressive gameplay, but hinders their mana generation.
ECLIPSE wins with its swarm tactics, easily filling the spawn row in the first couple turns of the game, creating strong and reliable mana generation. They also have the Soul Foundry fort to generate decent mana.
There are a few great unaligned cards that work in any faction. These are:
1.  Ice Leech – which gives you 1 mana for each unit in the enemy's spawn row.
2.  Battlefield Surveyors – which give you 1 mana at the end of the turn, if they didn't take an action.
3.  And if you are super aggressive, Spoils of War gives you 2 mana for each of your units in enemy territory.
Lastly, If you run into the fortunate case of having TOO MUCH mana, you can always bank some to your Champion to reduce its cost. Always try to make a mental calculation of how much mana you will have on your next turn. If this is over 10, BANK IT or lose it! Remember, you can never have more than 10 mana in your pool.