Reversed array not saving in NodeJS Mongoose MongoDB

Question: I'm using NodeJS and Mongoose to store data to a MongoDB database.  It is mostly working fine, as I'd expect.
I have an array, as part of a Schema, saved to a database document in Mongoose.  It looks like this, in the Schema:
var GameSchema = new mongoose.Schema({
    ...
    PlayerOrder: [Number],
    ...
}

When I call a findOne(...) to get this document from the DB, it works as expected, and I get a result, let's say ... [1,2,3,4] ....
Then, within the callback that's fired on successful findOne(...) execution, I modify some values, including PlayerOrder itself and other values.  I verify before saving to the DB, via console, that the changes were made to the local GameModel object.  One of these changes is to reverse the PlayerOrder array using `game.PlayerOrder.reverse();'.  Then I use the GameModel.save(...) function.
Here are some snippets of the code:
if (game.Turn >= game.PlayerCount) {
    console.log('Commuting to Phase 3.');
    game.Phase = 3;
    game.Turn = 0;
    // in phase 3, the player order is reversed; do that here
    console.log('player order before reverse: ' + game.PlayerOrder);
    game.PlayerOrder.reverse();
    // NOTE: this verifies that the array is correctly reversed in the model
    console.log('player order after reverse: ' + game.PlayerOrder);
}

game.save( function (err, game) {
    if (err) console.error(err);

    console.log('+ + + Execution successful; DB updated.');
});

Then, when I pull the same document from the DB again, all the changes I made are there.  In other words, after pulling the document I can see that all the changes I made to the document elements, such as player cash, game board state, etc, were all correctly made, and saved in the save(...) function.  EXCEPT for the reversed array, which never gets modified for some reason.
Why?
Answer: This happens because Mongoose can't track the changes made in the array when you used reverse().
In order to notify the changes, use markModified(), like this:
if (game.Turn >= game.PlayerCount) {
    console.log('Commuting to Phase 3.');
    game.Phase = 3;
    game.Turn = 0;
    // in phase 3, the player order is reversed; do that here
    console.log('player order before reverse: ' + game.PlayerOrder);
    game.PlayerOrder.reverse();
    game.markModified('PlayerOrder'); // <== this line notifies Mongoose of the change

    // NOTE: this verifies that the array is correctly reversed in the model
    console.log('player order after reverse: ' + game.PlayerOrder);
}

More info on this, Mongoose FAQ has some answers.
Comment: Yes, the `set()` function is only for setting a single position in the array. Since you are reversing the entire array, it is not needed.
Comment: Thanks for the answer, that works perfectly.  In the linked FAQ they suggest using Mongoose's `array.set(...)` method as well, but somehow I'm getting away with it without using that.  Just using `markModified(...)` is working for me.


AWS elastic-search. FORBIDDEN/8/index write (api). Unable to write to index

Question: I am trying dump a list of docs to an AWS elastic-search instance. It was running fine. Then, all of sudden it started throwing this error:
{ _index: '<my index name>',
  _type: 'type',
  _id: 'record id',
  status: 403,
  error:
   { type: 'cluster_block_exception',
     reason: 'blocked by: [FORBIDDEN/8/index write (api)];' } }

I checked in forums. Most of them says that it is a JVM memory issue. If it is going more than 92%, AWS will stop any writes to the cluster/index. However, when I checked the JVM memory, it shows less than 92%. I am missing something here?
Answer: This error is the Amazon ES service actively blocking writes to protect the cluster from reaching red or yellow status. It does this using index.blocks.write.
The two reasons being:
Low Memory

When the JVMMemoryPressure metric exceeds 92% for 30 minutes, Amazon ES triggers a protection mechanism and blocks all write operations to prevent the cluster from reaching red status. When the protection is on, write operations fail with a ClusterBlockException error, new indexes can't be created, and the IndexCreateBlockException error is thrown.
When the JVMMemoryPressure metric returns to 88% or lower for five minutes, the protection is disabled, and write operations to the cluster are unblocked.

Low Disk Space

Elasticsearch has a default "low watermark" of 85%, meaning that once disk usage exceeds 85%, Elasticsearch no longer allocates shards to that node. Elasticsearch also has a default "high watermark" of 90%, at which point it attempts to relocate shards to other nodes.
Answer: This error indicates that AWS ElasticSearch has placed a block on your domain based upon disk space. At 85%, ES will not allow you create any new indexes. At 90%, no new documents can be written.
Answer: ES could apply write block on index during rollovers, or Low disk space or memory.
In order to stop these errors you need to remove the write block on the index by setting index.blocks.write to false

curl -X PUT -H "Content-Type: application/json" \
'http://localhost:9200/{index_name}/_settings' \
  -d '{ "index": { "blocks": { "write": "false" } } }'

Answer: The accepted solution was not enough in my case, I had to remove index.blocks.read_only_allow_delete as well
PUT /my_index/_settings
{
  "index.blocks.read_only_allow_delete": null,
  "index.blocks.write": null
}

ES version 7.15
Comment: I found that setting index.blocks.write to true did not help, but setting it to null did, so thanks for this.
Answer: This can also happen if the index you're trying to write to has been marked as read only. I've had it happen due to an Index State Management misconfiguration which caused a weekly index to be moved to a warm state after one day.


How do I compare 2 columns and return a third based off the result?

Question: List the employee names and alongside their supervisor names
CREATE TABLE Employees (
   EmployeeID char(4) PRIMARY KEY,
   EmployeeName varchar(30) NOT NULL,
   HourlyRate real,
   SkillType varchar(20),
   SupervisorID char(4) NOT NULL
)

So I want to return a table showing
Employee Name || Supervisor Name

I have tried
Select
    EmployeeName,
    (Select EmployeeName Where SupervisorID = EmployeeID) As Supervisor
From Employees

but it only shows values where the Employee is their own supervisor, for the others it returns null. I must be missing something simple, but I cannot figure it out
Answer: You need to join the same table again
Select e.EmployeeName, s.EmployeeName As Supervisor
From Employees e
left join Employees s on s.employeeID = e.supervisorID

Comment: Cheers, hadn't covered joins in lectures yet, but from what I read this makes sense now :)
Answer: SELECT EMAIN.EmployeeName AS Employee,
      (SELECT E.EmployeeName FROM Employees AS E WHERE EMAIN.EmployeeID = E.SupervisorID) AS Supervisor
FROM Employees AS EMAIN


Can p(1,2)= 1 and p(2,4)=3 be linear opperators?

Question: This is a linear algebra question...
<code> So I know that the two conditions for linearity are additivity and homogeneity.
</code>
Typically Ives seen examples where the functions are L(1,2)= (2,5). However the functions I am trying to prove to be linear seem to be equal to scalars. Am I wrong to think that I can only use the condition of homogeneity?
<code>  L(cv)= cL(v)
</code>
Any clarity on proving this would be a great help. Thanks.
Comment: Scalars form a vector space as well.  Just as polynomials naturally form a vector space, and continuous functions, and sequences which converge to zero, etc...  That it equals a scalar is utterly irrelevant.  Ask yourself, what is twice $\binom{1}{2}$?  If $p$ was in fact linear, what should that equal?  Given your conditions, is that the case?
Answer: You want $x+2y=1$ and $2x+4y=3\implies x+2y=\frac{3}{2}$
This is impossible.
Answer: Your question is the same as asking: "are there scalars $a$ and $b$ so that $a \cdot 1+ b \cdot 2 = 1$ and $a \cdot 2 + b \cdot 4 = 3$."  You should be able to show easily that this is impossible, so the function is not linear.
Answer: $$p(2,4)= p((1,2)+(1,2))=p(1,2)+p(1,2)=1+1=2\neq3,$$
so $p$ is non linear.
Comment: the function is $p: \mathbb{R}^2 \to \mathbb{R}$, and both spaces are vector spaces so you can construct linear functions between them, you don't necessarily need to have the same domain and codomain to do that.


Ambiguity with Bluetooth mouse

Question: I'm running Kubuntu 21.10.  My Bluetooth mouse shows up in the Devices list twice: both as a BT3.0 mouse and a BT5.2 mouse, and I can't connect to it.  How can I fix this?
Answer: The problem seems to have resolved itself; the 3.0 mouse just went away.  But if it hadn't, I think I could have solved the issue by removing it explicitly with the remove option in the mouse's menu.

Ambiguity with Bluetooth mouse


Regular expression allowing zero-length string while editing

Question: So I'm trying to create a regular expression that will allow a user to change three numbers separated by colons. I'm currently using the following regex:
"\\b([1-9][0-9]?[0-9]?[0-9]?|[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|65[0-4][0-9][0-9]|655[[0-2][0-9]|6553[0-5]|0)\\:([1-9][0-9]?[0-9]?[0-9]?|[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|65[0-4][0-9][0-9]|655[[0-2][0-9]|6553[0-5]|0)\\:([1-9][0-9]?[0-9]?[0-9]?|[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|65[0-4][0-9][0-9]|655[[0-2][0-9]|6553[0-5]|0)\\b"

It works for the most part and prevents any strings from being invalid, but there's an issue with editing the individual numbers.  Using 401:53:3 as an example, if I put my cursor to the far end of the entire string, I can hold backspace and delete the entire thing. Then I can type a valid value and save it (if it's invalid, it won't let me keep it).
The problem happens when I try to edit just one of the numbers. So, if I put my cursor in the 401 block at the end of the 1 and then hold backspace, it removes the last two numbers, but won't delete the 4. This can be a hassle for a user that wants to change the first number, but doesn't want to rewrite the whole thing.
Does this make sense? Is there anyway that I can allow zero-length strings in my regular expression sections?
Comment: It does not seem true, since - if I get you right - the string is still matched with your regex, and thus is valid. See [this demo](https://regex101.com/r/eF4zT0/1), feel free to modify to show what the actual issue looks like. Or do you want `:53:3` to also be matched with the regex?
Comment: Could you show us the rest of your code?
Comment: I am just guessing, but perhaps, [that is what you are looking for](https://regex101.com/r/yR1iM2/1).
Comment: @stribizhev So yeah, I suppose I would like to be able to match :53:3. The input is checked in two different circumstances. It is checked while it is being edited, and then again after it loses focus. If the input is wrong after the focus, it will revert to its original value. So, I think what you suggested in your second comment should work.  I'll try that out real quick.
Comment: I doubt you can use the same regex for both live validation (onkeyup) and final validation (onblur). You can use mine above for live validation and yours for final one. Makes sense? Or maybe sln's one below is working better? Please let me know if you think I should post this as an answer.
Comment: @stribizhev So that worked.  The regex you suggested did what I needed.  Thanks!  Now, how do I make it a suggested answer?
Comment: @Giblo: I posted my answer.
Answer: Posting my suggestion since it proved working for you.
I suggest to allow matching the string even when a user is deleting the whole numeric subsection in the string. \b is matching at the word boundary, and thus does not let us match \b:, that is why I suggest adding an alternative with \B that matches at a non-word boundary.
We need to add it for all the numeric sections, so that they could become "optional".
(\b(?:[1-9][0-9]?[0-9]?[0-9]?|[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|65[0-4][0-9][0-9]|655[[0-2][0-9]|6553[0-5]|0)|\B):([1-9][0-9]?[0-9]?[0-9]?|[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|65[0-4][0-9][0-9]|655[[0-2][0-9]|6553[0-5]|0|\B):((?:[1-9][0-9]?[0-9]?[0-9]?|[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|65[0-4][0-9][0-9]|655[[0-2][0-9]|6553[0-5]|0)\b|\B)
                                                                                ^                                                                                ^                                                                                ^

See demo
Mind that this regex is only good for live validation. Final validation can be performed with your initial regex, I believe.


JavaScript: Saving/Loading cookies using HTML documents for a website

Question: For school work I need to use JavaScript to Save and read a cookie. The code for setting the cookie is all good, I got it from w3Schools (I know it's a terrible guide apparently). My problem is getting it to work with HTML/notepad using the "path" thing going on.
When the webpage loads a function called checkcookie checks if the cookie exists, if it doesn't, it asks the user to enter their name and then saves a cookie for later. If a cookie already exists, it displays a greeting message :). So far, I have made the functions work on the example running interface thing that you can access on w3schools. However, I recently tried setting them up using HTML documents, and the cookies don't seem to save properly. I open a NotePad document, paste the code, save as HTML, and open with Google Chrome. The pop-up asks for my name, I enter, but when I reload, the pop-up asks for my name again, and again, and so on. Here is the page I got the functions from: http://www.w3schools.com/js/js_cookies.asp
I think I need to sort out a path for the cookie, or something, I looked at this webpage for more info http://www.quirksmode.org/js/cookies.html but I still don't understand.
Why does this not work? Should I set the path to the file directory which the webpage's html documents are saved in? Why does it work in the w3schools TryIt system but not with raw HTML documents?
<code>function setCookie(cname,cvalue,exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires=" + d.toGMTString();
    document.cookie = cname+"="+cvalue+"; "+expires+"; path=/";
}

function getCookie(cname) {
    var title = cname + "=";
    var cookie_array = document.cookie.split(';');
    for(var i=0; i<cookie_array.length; i++) {
        var check = cookie_array[i];
        while (check.charAt(0)==' ') check = check.substring(1);
        if (check.indexOf(title) != -1) {
            return check.substring(title.length, check.length);
        }
    }
    return "";
}

function checkCookie() {
    var name=getCookie("name");
    if (name != "") {
        alert("Welcome again " + name);
    } else {
       name = prompt("Please enter your name:","");
       if (name != null && name != "") {
           setCookie("name", name, 30);
       }
    }
}
</code>
Comment: I think you need a web server to test cookies. You could use Apache other some other web server for that purpose. http://httpd.apache.org/download.cgi  Once you're hosting your web page, you can use for example Chrome the view your cookies http://stackoverflow.com/questions/27201564/javascrip-cookie-save-form/27202745#27202745
Answer: Yep, as mentioned by jyrkim is a webserver thing


Capping a Side Spray Opening on a Moen Faucet

Question: I am setting up a portable dishwasher (an 18-inch GE portable dishwasher). Similar to this question from last year, I am planning to connect the dishwasher to a kitchen faucet with a side spray.
According to GE, "A sink spray attachment hose can burst if it is installed on the same faucet as your dishwasher. We suggest that you disconnect the sink spray attachment, if your sink has one, and place a cap over the opening."
So I've been trying to figure out how to cap the opening. I have a Moen Adler one-handle kitchen faucet.

I spoke with a representative from Moen and they claim that they don't create a cap/plug for this model. (They have a side spray plug service kit for other faucets.)
Does anyone know if there are any other options to cap the opening? I am looking for some way to remove the spray hose and block the flow of water that would normally go to the spray hose. As you can see in the diagrams below, the opening doesn't appear to be a standard shape with a set diameter.
Here is a diagram of the spray:

Here are diagrams illustrating how to connect the spray to the faucet:

For your reference, the specifications for the faucet can be found here, the parts list here, and the installation guide here.
I would greatly appreciate any guidance that you could share.
Thank you.
Comment: Why would the line burst? Where are you getting the water from I have had many side sprays until pull out nozzles became popular and I always T my hot to the dishwasher how is that doing to have any affect on the faucet? Am I missing something?
Comment: Duston, Alaska Man, Kris: Thank you for your comments! Very helpful. I've been coming to the same conclusion.
Comment: https://www.amazon.com/Moen-22897-Cover-Stainless-Steel/dp/B01M7YLGVD
Comment: You are probably going to need a different faucet.
Comment: As the person that asked the referenced question, the bottom line isn't the side spray, it's the diverter that's the concern.  My faucet's diverter was a separate piece on the bottom that I removed to disconnect the side spray.  Looks like your faucet has the diverter integrated into it.  I think I'd go along with @Alaska Man and get a new faucet.
Comment: @EdBeal I was also wondering if I really need to do this. My understanding is that the spray hose and faucet are integrated. Here's the explanation from GE: "When the sink faucet is turned on to furnish water to the portable dishwasher, it is also putting the same pressure on the spray hose at the sink. These spray hoses are not designed for constant water pressure for the length of a wash cycle. After a while the hose will begin to leak at the joints or split and flood."
Comment: Ok is your faucet being directly connected to the dishwasher like a portable connection ? This is what they are talking about if you tap your plumbing supply the faucet is in the off position and you don't need to worry, I will make this an answer now that I understand the issue.
Answer: You only need to disconnect the spray wand if you have a portable connection to the faucet nozzle with the faucet in the on position.
If you connect to the plumbing so the faucet is in the off position you do not need to remove your sprayer.
Sorry I did not catch that sooner but connecting prior to the faucet it self is the same as every other point on the plumbing system. At the nozzle faucet on 100% hot I can see the sprayer not being rated for that combination of pressure and heat.  If you add an adapter to your hot line for the quick disconnect that would be the way around having to disconnect the sprayer.


Where are the Canon MF8080cw wireless drivers?

Question: I recently bought Canon MF8080cw wireless printer and scanner
but I am unable to find the drivers for it, I am using ubuntu 13.10 x64
Answer: please check canon official website here .


AWS SNS text message publishing not working

Question: I'm trying to send an SMS(Text message) to a specific mobile number(IN : India, FROM : India) from the AWS management console. I have tried several times, from several regions but none of the messages has been delivered but it shows

SMS message published to phone number +91xxxxx successfully.

but the delivery statistics show that the messages have been failed.
Note: I'm using a root user account.
I'm new to AWS.
Any help will be really helpful.
Answer: there are special requirements when sending messages to recipients in India. Verify if you are using message type as Transactional. Because Promotional might be blocked on default settings.
https://docs.aws.amazon.com/sns/latest/dg/channels-sms-senderid-india.html
you will need to adhere to it before using AWS SNS in India.
Comment: Thank you for your valuable reply but i tried both transactional and promotional but both are not working.


What's the appropriate way to take pandas groupby results with no function and combine them into columns?

Question: I have a dataframe that I'm grouping by index, in this case Household_0. I would like to combine all of the grouped data into a series and lay them out as Individuals.
Sample data:
data = {'Household_0':['2374550','2374550','2374553',
                       '2374554','2374554',
                       '2374555','2374555'],
        'Individual_0':['2374548','2374548','','',
                        '4444444','2379908','2379909'],
        'Individual_1':['2374549','','','','','2379910','']}
df=pd.DataFrame(data)
df.set_index('Household_0',inplace=True)

Which results in:
            Individual_0 Individual_1
Household_0
2374550          2374548      2374549
2374550          2374548
2374553
2374554
2374554          4444444
2374555          2379908      2379910
2374555          2379909

I want to group Household_0 and have only one entry for each Household, which includes all of the values for Individuals, and removes duplicates.
The resultant dataframe would look like:
Household_0     Individual_0   Individual_1  Individual_2
2374550         2374548        2374549
2374553
2374554         4444444
2374555         2379908        2379909       2379910

Note that I already have fields up to Individual_9 in my existing dataframe. The appended digit has no significance, so ideally I'd just collapse all of the results down to the first Individual column that's free. And I'd also prefer to have them sorted from lowest to highest, but I can surely figure that one out on my own.
Answer: The first step stacks all the households, ignores the empty strings and removes the duplicates. Sorting gives your preferred order.
df1 = (df.stack().loc[lambda x: x!='']
         .reset_index()
         .drop(columns='level_1')
         .drop_duplicates()
         .sort_values(0))

#  Household_0        0
#0     2374550  2374548
#1     2374550  2374549
#4     2374555  2379908
#6     2374555  2379909
#5     2374555  2379910
#3     2374554  4444444

Now this is a pivot problem. We'll use a groupby + cumcount to create the column indicator for the pivot. Finally, we'll need to reindex to include Household's that have nobody. Also some housekeeping on the column names.
df1['col_num'] = df1.groupby('Household_0').cumcount()
(df1.pivot(index='Household_0', columns='col_num', values=0)
    .add_prefix('Individual_')
    .rename_axis(None, axis=1)
    .reindex(df.index.unique()))

            Individual_0 Individual_1 Individual_2
Household_0
2374550          2374548      2374549          NaN
2374553              NaN          NaN          NaN
2374554          4444444          NaN          NaN
2374555          2379908      2379909      2379910

I don't suggest this method because of the slow .apply(pd.Series) which will lead to a big performance hit, but this is possible by getting the uniques within group and then applying pd.Series. Much less code, at the cost of being inefficient.
(df.replace('', np.NaN).stack()
   .groupby(level=0).unique().apply(pd.Series)
   .add_prefix('Individual_')
   .reindex(df.index.unique()))

Comment: This works on the sample data I created, as you show. I'm having some trouble on my working data but I think you've done a good enough job explaining yourself that I can back into my issue. I will mark as accepted once I am able to confirm. Thank you for laying it out so well.
Comment: @markf I did all the manipulations on a new object `df1` because at the very end I need the original `df.index` in: `.reindex(df.index.unique())`; this is **not** df1's index. Perhaps you're incorrectly reindexing on `df1`'s index? The other thing could be that you kept everything named `df`, instead of creating a separate object. That's perfectly fine, but before even the stacking step do something like `households = df.index.unique()` then do all the manipulations and in the end you can `.reindex(households)`
Comment: You found it. I was able to get a partial result removing that reindex, so I knew it had something to with it. I just visually missed the df/df1 difference, since my working frame is named differently. Thanks for the patience and help. Our nonprofit appreciates it..
Comment: Specifically what's happening is that Household_0 isn't represented anymore after the pivot, and the created Individuals are all NaN. Prior to the pivot, the stack looks correct as does the column indicator. I'm still digging. I definitely tried to make an example that was representative of some of the data challenges.


Norm on unitisation is submultiplicative

Question: Let $A$ be a $C^\ast$-algebra and let $\widetilde{A}$ denote its unitisation. Define a norm on $\widetilde{A}$ as $\|(a,\lambda)\| = \sup_{\|b\|=1} \|ab + \lambda b\|$.
I could show that $\|(a,\lambda)^\ast (a,\lambda)\| = \|(a,\lambda)\|^2$ using the submultiplicativity of the norm but now I'm having trouble showing it is submultiplicative.
Please could someone help me and show me how to show
$\displaystyle \|(a,\lambda)(b,\mu)\| \le \|(a,\lambda)\| \|(b,\mu)\|$?
Answer: What you are doing here is that you identify the element $(a, \lambda)$ with the linear operator $T_{(a,\lambda)} : x\mapsto ax + \lambda x$.
The norm $\Vert (a,\lambda) \Vert$ is then the operator norm $\Vert T_{(a,\lambda)} \Vert$.
It is easy to see that the operator norm in general is submultiplicative.
First show that $\Vert Tx \Vert \leq \Vert T\Vert \cdot \Vert x \Vert$ for all $x$ (using homogeneity of the norm).
This implies $\Vert TS x \Vert \leq \Vert T\Vert \Vert Sx\Vert \leq \Vert T\Vert \cdot \Vert S\Vert \cdot \Vert x \Vert$, which yields the submultiplicativity.
Comment: Great answer, thank you! There where you mention to use the homogeneity of the norm I am wondering if it doesn't follow straight from the definition: $\|T\|= \sup_{\|x\|\neq 0} {\|Tx\|\over \|x\|}$.
Comment: Oh, yes. I thought you were using the definition $\Vert T \Vert = \sup_{\Vert x \Vert = 1} \Vert Tx\Vert$, which of course is the same in the end.


Is there a DBGrid component that can handle large datasets fast?

Question: Large datasets, millions of records, need special programming to maintain speed in DBGrids.
I want to know if there are any ready-made components for Delphi (DBGrids) that do this automatically?
EDIT For Example: Some databases have features such as fetch 1st X records (eg 100 records). When I reach the bottom with scrolling, I want to auto fetch the next 100. Conversely when I reach the beginning, I want to fetch the previous 100. I know I can program this, but it sure is possible to propagate that feature to a DBGrid control where the DBGrid does the buffering. It will save quite a bit of programming - you simply have to set the "buffer size" so to speak.
Answer: You might want to take a look at the wonderful (free, open source, dual licensed as MPL 1.1 and GPL thus usable in closed source apps) Virtual TreeView and its user-supplied descendants (scroll down the page to find those.)
Edit to reflect the question's edit: Virtual TreeView not only allows you to handle millions of nodes without keeping them in memory, but that is in fact the preferred way of using it. You supply the data through event callbacks when it's needed, and you can tell the tree to cache that data (or not.)
Oh, and of course it also has a grid / report mode where it can function as a table (just set the GridExtensions property to True.)
Answer: NextGrid is light, fast and nice looking grid for Delphi
http://www.bergsoft.net/component/next-grid/features.htm

HANDLING LARGE AMOUNT OF CELLS WITHOUT LOOSING SPEED
NextGrid can handle very large amount
  of cells without losing speed. Speed
  of adding, modifying and deleting data
  doesn't depend of the amount of cells.
  In NextGrid demo you can see how fast
  NextGrid work with 100,000 rows and 10
  columns = 1,000,000 cells
Answer: I would have a look at Developer Express QuantumGrid Suite. (@birger: you just were a tick faster ;-) ) So I'm not just duplicating the answer, some elaboration:
The DevExpress Grid uses a data controller that has several modes to controll the data bound to the grid. One of these is exactly what you are looking for:

Grid Mode
When using Grid Mode, only a fixed
  number of dataset records is loaded
  into memory. Because only a limited
  set of records are retrieved from the
  dataset, automatic sorting, filtering
  and summary calculations are disabled
  in Grid Mode (must be controlled
  manually instead). By default, this
  mode is disabled and the
  ExpressDataController loads all
  records in a dataset.

It does have some drawbacks, which seem pretty obvious: you cannot make a summary, sort, or filter if you do not have all records at hand.
Comment: Thanks for this info, hard to come by via Google. :)
Comment: Thanks for pointing out the shortcomings of the DevExpress product (inability to filter, sort and summarize), especially as it is far more expensive than the alternatives mentioned here. And this drawback isn't obvious at all - the whole point of these virtual datasets is that the heavy lifting is done server-side; the control only manipulates the SQL to pull just the data it needs over the network.
Answer: I think the DevExpress Quantumgrid supports this very good.
Answer: sorry, I just saw your comment to Neftalí
if you would to bring 100 record per time, and then fetch the next 100, this work related to database access components, look at devart components, they are offer direct access components to most used database, and they have the feature you are asking about and more:
http://www.devart.com/products-vcl.html
Comment: I want the DBGRid to do the buffering


Dell XPS 13 9310 bluetooth wont find anything

Question: Just installed Ubuntu 20.04 on my brand new XPS 13. Bluetooth is active and it wont find anything. There is one time where it found "Audio Device" and "Unknown" but I can't even click.
I tried bluetoothctl with power on, scan on and etc, but it won't find anything.
I don't even know which bluetooth device my Dell uses, because it won't appear on lspci or lsusb:
lz@xps13:~$ lspci
0000:00:00.0 Host bridge: Intel Corporation Device 9a14 (rev 01)
0000:00:02.0 VGA compatible controller: Intel Corporation Device 9a49 (rev 01)
0000:00:04.0 Signal processing controller: Intel Corporation Device 9a03 (rev 01)
0000:00:06.0 System peripheral: Intel Corporation Device 09ab
0000:00:07.0 PCI bridge: Intel Corporation Device 9a23 (rev 01)
0000:00:07.2 PCI bridge: Intel Corporation Device 9a27 (rev 01)
0000:00:0a.0 Signal processing controller: Intel Corporation Device 9a0d (rev 01)
0000:00:0d.0 USB controller: Intel Corporation Device 9a13 (rev 01)
0000:00:0d.2 USB controller: Intel Corporation Device 9a1b (rev 01)
0000:00:0d.3 USB controller: Intel Corporation Device 9a1d (rev 01)
0000:00:0e.0 RAID bus controller: Intel Corporation Volume Management Device NVMe RAID Controller
0000:00:12.0 Serial controller: Intel Corporation Device a0fc (rev 20)
0000:00:14.0 USB controller: Intel Corporation Device a0ed (rev 20)
0000:00:14.2 RAM memory: Intel Corporation Device a0ef (rev 20)
0000:00:15.0 Serial bus controller [0c80]: Intel Corporation Device a0e8 (rev 20)
0000:00:15.1 Serial bus controller [0c80]: Intel Corporation Device a0e9 (rev 20)
0000:00:16.0 Communication controller: Intel Corporation Device a0e0 (rev 20)
0000:00:19.0 Serial bus controller [0c80]: Intel Corporation Device a0c5 (rev 20)
0000:00:19.1 Serial bus controller [0c80]: Intel Corporation Device a0c6 (rev 20)
0000:00:1c.0 PCI bridge: Intel Corporation Device a0b8 (rev 20)
0000:00:1d.0 PCI bridge: Intel Corporation Device a0b3 (rev 20)
0000:00:1e.0 Communication controller: Intel Corporation Device a0a8 (rev 20)
0000:00:1f.0 ISA bridge: Intel Corporation Device a082 (rev 20)
0000:00:1f.3 Multimedia audio controller: Intel Corporation Device a0c8 (rev 20)
0000:00:1f.4 SMBus: Intel Corporation Device a0a3 (rev 20)
0000:00:1f.5 Serial bus controller [0c80]: Intel Corporation Device a0a4 (rev 20)
0000:55:00.0 Network controller: Qualcomm Device 1101 (rev 01)
0000:56:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5260 PCI Express Card Reader (rev 01)
10000:e0:06.0 PCI bridge: Intel Corporation Device 9a09 (rev 01)
10000:e1:00.0 Non-Volatile memory controller: Toshiba Corporation Device 011a

lz@xps13:~$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 0c45:672a Microdia Integrated_Webcam_HD
Bus 003 Device 007: ID 22b8:2e25 Motorola PCS XT1650
Bus 003 Device 002: ID 27c6:533c Shenzhen Goodix Technology Co.,Ltd. FingerPrint
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I'm on 5.10.0-051000rc6-lowlatency because the one that comes with ubuntu 20.04 has problems with sleep and other things.
How do I know which bluetooth device I'm using?
PS: I also have no wifi yet, seems like the driver for Network controller: Qualcomm Device 1101 (rev 01) is not ready yet.
I tried ubuntu 20.10 but I get error on installation, tried many times. But I guess the problem is more kernel related.
[bluetooth]# list
Controller 00:00:00:00:5A:AD xps13 [default]

UPDATE:
lz@xps13:~$ sudo dmesg | grep -i blue
[sudo] password for lz:
[   37.837663] Bluetooth: Core ver 2.22
[   37.837675] Bluetooth: HCI device and connection manager initialized
[   37.837678] Bluetooth: HCI socket layer initialized
[   37.837680] Bluetooth: L2CAP socket layer initialized
[   37.837683] Bluetooth: SCO socket layer initialized
[   37.854802] Bluetooth: HCI UART driver ver 2.3
[   37.854804] Bluetooth: HCI UART protocol H4 registered
[   37.854804] Bluetooth: HCI UART protocol BCSP registered
[   37.854810] Bluetooth: HCI UART protocol LL registered
[   37.854810] Bluetooth: HCI UART protocol ATH3K registered
[   37.854814] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   37.854845] Bluetooth: HCI UART protocol Intel registered
[   37.854863] Bluetooth: HCI UART protocol Broadcom registered
[   37.854866] Bluetooth: HCI UART protocol QCA registered
[   37.854866] Bluetooth: HCI UART protocol AG6XX registered
[   37.854870] Bluetooth: HCI UART protocol Marvell registered
[   37.969110] Bluetooth: hci0: setting up ROME/QCA6390
[   37.974178] Bluetooth: Received HCI_IBS_WAKE_ACK in tx state 0
[   38.275421] Bluetooth: hci0: QCA Product ID   :0x00000010
[   38.275422] Bluetooth: hci0: QCA SOC Version  :0x400a0200
[   38.275422] Bluetooth: hci0: QCA ROM Version  :0x00000200
[   38.275423] Bluetooth: hci0: QCA Patch Version:0x00000d2b
[   38.275424] Bluetooth: hci0: QCA controller version 0x02000200
[   38.275425] Bluetooth: hci0: QCA Downloading qca/htbtfw20.tlv
[   38.275588] bluetooth hci0: Direct firmware load for qca/htbtfw20.tlv failed with error -2
[   38.275590] Bluetooth: hci0: QCA Failed to request file: qca/htbtfw20.tlv (-2)
[   38.275591] Bluetooth: hci0: QCA Failed to download patch (-2)
[   38.985832] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   38.985833] Bluetooth: BNEP filters: protocol multicast
[   38.985837] Bluetooth: BNEP socket layer initialized
[   46.210793] Bluetooth: RFCOMM TTY layer initialized
[   46.210798] Bluetooth: RFCOMM socket layer initialized
[   46.210800] Bluetooth: RFCOMM ver 1.11

After inserting the firmware:
lz@xps13:~$ sudo dmesg | grep -i blue
[   10.126340] Bluetooth: Core ver 2.22
[   10.126356] Bluetooth: HCI device and connection manager initialized
[   10.126360] Bluetooth: HCI socket layer initialized
[   10.126362] Bluetooth: L2CAP socket layer initialized
[   10.126364] Bluetooth: SCO socket layer initialized
[   10.168251] Bluetooth: HCI UART driver ver 2.3
[   10.168252] Bluetooth: HCI UART protocol H4 registered
[   10.168253] Bluetooth: HCI UART protocol BCSP registered
[   10.168261] Bluetooth: HCI UART protocol LL registered
[   10.168262] Bluetooth: HCI UART protocol ATH3K registered
[   10.168271] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   10.168303] Bluetooth: HCI UART protocol Intel registered
[   10.168321] Bluetooth: HCI UART protocol Broadcom registered
[   10.168324] Bluetooth: HCI UART protocol QCA registered
[   10.168325] Bluetooth: HCI UART protocol AG6XX registered
[   10.168327] Bluetooth: HCI UART protocol Marvell registered
[   10.276703] Bluetooth: hci0: setting up ROME/QCA6390
[   12.322211] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   12.322212] Bluetooth: BNEP filters: protocol multicast
[   12.322216] Bluetooth: BNEP socket layer initialized
[   12.685060] Bluetooth: hci0: command 0xfc00 tx timeout
[   21.069061] Bluetooth: hci0: Reading QCA version information failed (-110)

UPDATE:
lz@xps13:~$ sudo dmesg | grep -i blue
[sudo] password for lz:
[   22.779705] Bluetooth: Core ver 2.22
[   22.779720] Bluetooth: HCI device and connection manager initialized
[   22.779723] Bluetooth: HCI socket layer initialized
[   22.779725] Bluetooth: L2CAP socket layer initialized
[   22.779728] Bluetooth: SCO socket layer initialized
[   22.790061] Bluetooth: HCI UART driver ver 2.3
[   22.790063] Bluetooth: HCI UART protocol H4 registered
[   22.790064] Bluetooth: HCI UART protocol BCSP registered
[   22.790070] Bluetooth: HCI UART protocol LL registered
[   22.790070] Bluetooth: HCI UART protocol ATH3K registered
[   22.790074] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   22.790096] Bluetooth: HCI UART protocol Intel registered
[   22.790126] Bluetooth: HCI UART protocol Broadcom registered
[   22.790130] Bluetooth: HCI UART protocol QCA registered
[   22.790130] Bluetooth: HCI UART protocol AG6XX registered
[   22.790134] Bluetooth: HCI UART protocol Marvell registered
[   22.931800] Bluetooth: hci0: setting up ROME/QCA6390
[   22.939205] Bluetooth: hci0: Frame reassembly failed (-84)
[   23.245423] Bluetooth: hci0: QCA Product ID   :0x00000010
[   23.245424] Bluetooth: hci0: QCA SOC Version  :0x400a0200
[   23.245425] Bluetooth: hci0: QCA ROM Version  :0x00000200
[   23.245425] Bluetooth: hci0: QCA Patch Version:0x00000d2b
[   23.245427] Bluetooth: hci0: QCA controller version 0x02000200
[   23.245428] Bluetooth: hci0: QCA Downloading qca/htbtfw20.tlv
[   24.118016] Bluetooth: hci0: QCA Downloading qca/htnv20.bin
[   24.118039] bluetooth hci0: Direct firmware load for qca/htnv20.bin failed with error -2
[   24.118041] Bluetooth: hci0: QCA Failed to request file: qca/htnv20.bin (-2)
[   24.118044] Bluetooth: hci0: QCA Failed to download NVM (-2)
[   24.155330] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   24.155332] Bluetooth: BNEP filters: protocol multicast
[   24.155336] Bluetooth: BNEP socket layer initialized
[   39.842936] Bluetooth: RFCOMM TTY layer initialized
[   39.842943] Bluetooth: RFCOMM socket layer initialized
[   39.842946] Bluetooth: RFCOMM ver 1.11
[  136.016876] Bluetooth: hci0: command 0x0c1a tx timeout
[  138.064522] Bluetooth: hci0: command 0x0c3a tx timeout
[  140.112331] Bluetooth: hci0: command 0x0c1a tx timeout
[  142.160092] Bluetooth: hci0: command 0x0c52 tx timeout
[  146.255507] Bluetooth: hci0: failed to disable LE scan: status 0x1f
[  146.255555] Bluetooth: hci0: command 0x2042 tx timeout

Comment: I guess the BT is not supported by Linux kernel. As simple as that.
Comment: @Pilot6 but sometimes if I leave for too long, it recognizes some real devices but I can't conect. So the support exists but is broken. How can I know which driver it's using and which device?
Comment: Look into `dmesg`. That can give some clue. But you won't find any "drivers" in the meaning you can install them. Start with `dmesg | grep -i blue`.
Comment: @Pilot6 please look at my update
Comment: Have you downloaded the latest bios updates for your system? https://www.dell.com/support/home/en-us/product-support/product/xps-13-9310-laptop/drivers
Answer: As you can see there is no firmware for the Bluetooth device.
You can install it this way. Run in a terminal
sudo apt install git
git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
sudo cp linux-firmware/qca/htbtfw20.tlv /lib/firmware/qca
sudo cp linux-firmware/qca/htnv20.bin /lib/firmware/qca

Then reboot.
Note: Ubuntu 20.10 has this firmware initially.
Update: Now you have another problem
[   12.685060] Bluetooth: hci0: command 0xfc00 tx timeout
[   21.069061] Bluetooth: hci0: Reading QCA version information failed (-110)

This is related to the kernel driver. I suggest installing the 5.8 kernel by running
sudo apt install linux-generic-hwe-20.04-edge

and rebooting.
Your current kernel will stay intact, you will always be able to revert it.
Comment: Please take a look at my update. After inserting the firmware and reboting, my bluetooth wont turn on. Also `lz@xps13:~$ sudo bluetoothctl
[sudo] password for lz:
Agent registered
[bluetooth]# power on
No default controller available`
Comment: Please update output of `dmesg | grep -i blue` after you added the firmware. And add infromation to your question, not to comments.
Comment: I updated my question with dmesg after adding the firmware
Comment: And I updated the answer.
Comment: Installing and reboting didnt change my kernel, still on `5.10.0-051000rc6-lowlatency`
Comment: You are using an unsupported mainline release candidate kernel. Boot with an Ubuntu kernel using grub menu.
Comment: And you also need `qca/htnv20.bin`. I updated the answer.
Comment: Thanks, 5.8 kernel worked. Do you think things will be fixed on 5.11?
Comment: I wouldn't recommend using mainline kernels with Ubuntu unless there is no other choice. Did you try the 5.4? It could work as well.
Comment: on the kernel that came with ubuntu, sleep and touchscreen wouldn't work, but they work on 5.8 thankfully. I'll wait for another ubuntu kernel then
Comment: So you can stick with the 5.8. It will get updates the way you installed it.


accessing collection data from view in backbone.js

Question: I got fully stuck truing to understand how should I work with models and collections. Data is fetching from server into collection but then I do not know how to access this data in view to use it while rendering
here is my code:
ImmoObject = Backbone.Model.extend();

Realty = Backbone.Collection.extend({
    model: ImmoObject,
    url: 'getall',

    initialize: function(){
        this.fetch();
    }
});

Application = Backbone.Router.extend({
    _realty: null,
    _view: null,
    routes: {
        "": "index",
        //"details": "details"
    },

    initialize: function(){
        this._realty = new Realty();
        if (this._view === null){
            this._view = new StartPage({collection: this._realty});
        }
    },

say, each ImmoObject have name. how I can go through all elements in collection (while rendering view) and output their names? Can I do something like this in StartPage.render()?
$.each(this.collection, function(k, v){
console.log(v.name);
})

Comment: If you don't want to extend model you can wright just this `ImmoObject = Backbone.Model;`
Answer: You can use the each method of underscore.js :
StartPage = Backbone.View.extend({
  el: $("#ul-immo-list"),

  initialize: function() {
    _.bindAll(this, "render");
    this.collection.bind('reset', this.render);
  },
  ...
  render: function() {
    this.collection.each(function(immoObject) {
      console.log(immoObject.name);
      this.el.append("
" + immoObject.name + "
")
    }
  }
});

And in your router :
Application = Backbone.Router.extend({
  _realty: null,
  _view: null,
  routes: {
    "": "index",
  },

  initialize: function(){
    this._realty = new Realty();
    if (this._view === null){
      this._view = new StartPage({collection: this._realty});
    }
    this._realty.fetch();
  },
});

this._realty.fetch(); will fire a reset event on the collection, which will re-render the the StartPage view.
Comment: but i can't work with this.collection in view cuz it say `this.collection is undefined`
Comment: make sure you pass "collection" in the constructor as Tricote's example above does. As well as having the _.bindAll() part as well (so the "this" is in the correct context).
Comment: yes i pass collection in view constructor and i have `_.bindAll(this, "render");` in StartPage.initialize But i still got `this.collection is undefined` while trying to do `this.collection.bind('reset', this.render);` in StartPage.initialize:
Comment: http://blog.bigbinary.com/2011/08/18/understanding-bind-and-bindall-in-backbone.html
Answer: Yes you can do it in the render method.
Or in the addOne method of the application view.
The addOne method receives the model (if you keep your application code close to the demos) you should have something like this in AppView.
addOne: function(immo) {
  var name = immo.name; //Accesing the name for the model here
  var view = new ImmoView({model: immo});
  this.$("#todo-list").append(view.render().el);
},

Hope this helps.


Math.random reproducing value twice

Question: Having a bit of problem with something surely most of you will find trivial, but still would appreciate your help. It's our favorite Rock Papaer Scissors game:

var user = document.querySelector(".userchoice");
var computer = document.querySelector(".computerchoice");
var startBtn = document.querySelector(".startBtn");
var result = document.querySelector(".result");

var winStates = ["Rock", "Paper", "Scissors"];

startBtn.addEventListener("click", playGame);

function playGame() {
  startBtn.disabled = true;
  user.classList.add("count-in");
  computer.classList.add("count-in");
}

document.addEventListener("animationend", function () {
  user.classList.remove("count-in");
  computer.classList.remove("count-in");
  startBtn.disabled = false;
  var randomU = winStates[Math.floor(Math.random() * 3)];
  var randomC = winStates[Math.floor(Math.random() * 3)];
  computer.className = "computerchoice " + randomC;
  user.className = "userchoice " + randomU;
});
.container {
  width: 650px;
  margin: 0 auto;
  text-align: center;
  padding: 25px;
}

.player {
  width: 150px;
  height: 150px;
  margin: 100px 50px;
  display: inline-block;
}

.player p {
  font-weight: 700;
}

.player div {
  width: 100%;
  height: 100%;
}

.Rock {
  background-image: url(https://placehold.it/100x100?text=Rock);
}

.Paper {
  background-image: url(https://placehold.it/100x100?text=Paper);
}

.Scissors {
  background-image: url(https://placehold.it/100x100?text=Scissors);
}

.Rock,
.Paper,
.Scissors {
  background-size: contain;
  background-repeat: no-repeat;
}

.startBtn {
  border: none;
  padding: 10px 100px;
}

@keyframes count-in {
  0% {
    transform: translateY(0);
  }
  60% {
    transform: translateY(-100px);
  }
  100% {
    transform: translateY(0);
  }
}

.count-in {
  animation: 0.7s count-in 3;
}

Rock, Paper, Scissors

Player 1

Computer

  <button class="startBtn">Play</button>

The problem gets when Math.random is executed, it seems like it is being triggered two times and getting two values out of the winStates array. Naturaly it should pick one value and concat it with the css class already defined
Comment: _"...and getting two values out of the winStates array"_ - like `randomU` and `randomC`? o.O
Comment: You haven't shown your CSS code, but would it be possible that there are two animations ending at the same time?
Comment: This looks like it's working to me? I only see one result from each Player.
Comment: You only _see_ one result but the code will run twice.
Answer: The count-in class is added to two elements so the animationend event listener will fire twice.
Since the animations run concurrently, and therefore end at the same moment, you should be able to get away with binding the event to a single element, userchoice or computerchoice by using...
document.querySelector('.userchoice').addEventListener("animationend", ...

var user = document.querySelector(".userchoice");
var computer = document.querySelector(".computerchoice");
var startBtn = document.querySelector(".startBtn");
var result = document.querySelector(".result");

var winStates = ["Rock", "Paper", "Scissors"];

startBtn.addEventListener("click", playGame);

function playGame() {
  startBtn.disabled = true;
  user.classList.add("count-in");
  computer.classList.add("count-in");
}

document.querySelector('.userchoice').addEventListener("animationend", function () {

  console.log('animationend event');

  user.classList.remove("count-in");
  computer.classList.remove("count-in");
  startBtn.disabled = false;
  var randomU = winStates[Math.floor(Math.random() * 3)];
  var randomC = winStates[Math.floor(Math.random() * 3)];
  computer.className = "computerchoice " + randomC;
  user.className = "userchoice " + randomU;
});
.container {
  width: 650px;
  margin: 0 auto;
  text-align: center;
  padding: 25px;
}

.player {
  width: 150px;
  height: 150px;
  margin: 100px 50px;
  display: inline-block;
}

.player p {
  font-weight: 700;
}

.player div {
  width: 100%;
  height: 100%;
}

.Rock {
  background-image: url(https://placehold.it/100x100?text=Rock);
}

.Paper {
  background-image: url(https://placehold.it/100x100?text=Paper);
}

.Scissors {
  background-image: url(https://placehold.it/100x100?text=Scissors);
}

.Rock,
.Paper,
.Scissors {
  background-size: contain;
  background-repeat: no-repeat;
}

.startBtn {
  border: none;
  padding: 10px 100px;
}

@keyframes count-in {
  0% {
    transform: translateY(0);
  }
  60% {
    transform: translateY(-100px);
  }
  100% {
    transform: translateY(0);
  }
}

.count-in {
  animation: 0.7s count-in 3;
}

Rock, Paper, Scissors

Player 1

Computer

  <button class="startBtn">Play</button>

Math.random reproducing value twice


How to pass string in objective-c instance method?

Question: Hi I have multiple UIButtons (foo and bar) and when pressed each invokes a different instance method (doSomethingFoo and doSomethingBar). Here is the code I have working:
CGRect fooImageRect = CGRectMake(38.0f, 192.0f, 130.0f, 25.0f);
    UIButton *buttonFoo = [[UIButton alloc] init];
    buttonFoo.frame = fooImageRect;
    [buttonFoo setImage:[UIImage imageNamed:@"button_foo_130x25.png"] forState:UIControlStateNormal];
    [buttonFoo addTarget:self action:@selector(doSomethingFoo:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:buttonFoo];
    [buttonFoo release];

CGRect barImageRect = CGRectMake(172.0f, 192.0f, 130.0f, 25.0f);
    UIButton *buttonBar = [[UIButton alloc] init];
    buttonBar.frame = barImageRect;
    [buttonBar setImage:[UIImage imageNamed:@"button_bar_130x25.png"] forState:UIControlStateNormal];
    [buttonBar addTarget:self action:@selector(doSomethingBar:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:buttonBar];
    [buttonBar release];

And the instance methods doSomethingFoo and doSomethingBar
    -(void)doSomethingFoo:(id) sender {
    // code doing something with a NSString having value 'foo'
}

     -(void)doSomethingBar:(id) sender {
        // same code doing something with a NSString having value 'bar'
}

What I am trying to do is to create a single method (doSomething) that I can invoke when either button is pressed, and pass it the string (value 'foo' or 'bar') that I'll reference in the method.  I'm struggling with the syntax.
Answer: You can use the same method to handle both buttons, but you cannot choose the arguments that get sent.  The action selector must be one of the following forms:
- (void)action
- (void)action:(id)sender
- (void)action:(id)sender forEvent:(UIEvent *)event

Where sender is the control that sent the message.  So you'll be able to tell which of the two buttons sent the message by checking the sender.  On possibility to make the check straight-forward would be to to set the tag property of the UIButton when you create it with some well known value (a #define or some other constant) and check that property in your action method.
Answer: simply make an NSString ivar called buttonTitle and write the method like so:
// first set buttonTitle:
self.buttonTitle = @"foo"; //for buttonfoo
self.buttonTitle = @"bar",  // for buttonbar

-(void)doSomething:(id) sender {
 NSString *title = self.buttonTitle;
}


Trying to initialize neural network in Tensorflow, receiving TypeError

Question: I am having troubles initializing my neural network properly in Tensorflow.
In my BayesianNN class, I have a build_graph function:
def build_graph():
 self._create_feedforward()
 self._initializer()
 self._define_layers()
 self._regularization()

As of right now, my _create_feedforward() sets the framework for how I want my weights and biases initialized, as well as their output:
def _create_feedforward(self, input, output, scope):
    with tf.variable_scope(scope, reuse=tf.AUTO_REUSE) as scope:
        self.weights = tf.get_variable('weights',
                                       shape=(input.shape[1], output),
                                       initializer=tf.random_normal_initializer(0,0.01),
                                       dtype=tf.float32)
        self.biases = tf.get_variable('biases',
                                      shape=(output),
                                      initializer=tf.constant_initializer(0.0),
                                      dtype=tf.float32)

        activation = tf.matmul(input, self.weights) + self.biases

        return tf.matmul(tf.diag(self.Bern_prob.sample((input.shape[1],))),
                                  activation)

While my _define_layers function sets the input parameters for my network:
def _define_layers(self):
    layer_1_output = _create_feedforward(model_X, self.layer_1_dim, 'layer_1')
    layer_2_output = _create_feedforward(self.layer_1_dim, self.layer_2_dim, 'layer_2')
    layer_3_output = _create_feedforward(self.layer_2_dim, [1], 'layer_3')

Because _create_feedforward is called before _define_layers, I am receiving a typeError for not enough inputs. But I cant call _define_layers first because _create_feedforward has not been defined yet.

TypeError: _create_feedforward() missing 3 required positional
  arguments: 'input', 'output', and 'scope'

I know why this error is happening, but how about do I implement this in code neatly and without errors?
Answer: The issue here is that in _create_feedforward you have the argument self. However, when you call it in _define_layers, you don't call the function as part of a class. Try this:
def _define_layers(self):
    layer_1_output = self._create_feedforward(model_X, self.layer_1_dim, 'layer_1')
    layer_2_output = self._create_feedforward(self.layer_1_dim, self.layer_2_dim,'layer_2')
    layer_3_output = self._create_feedforward(self.layer_2_dim, [1], 'layer_3')

Comment: @Camben, thanks! Worked like a charm! On a similar note, if I wanted to add regularization for each layer, would I have something similar like  self._create_regularization? If each layer is defined like I did in the code above, would I have layer_1_output.self._create_regularization?
Comment: @JamieDimon yes you would do something similar


How to automate downloading "txt.htm.xls" file format using Selenium Webdriver?

Question: I have an application where user click on icon and a file get downloaded. The extension of the file is:

txt.htm.xls

I have set the preference:
<code>             profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;");
</code>
but this is not working as it seems to be incorrect MIME type.
Comment: Possible duplicate of [Auto-download in firefox browser with java-selenium not working](https://stackoverflow.com/questions/45589571/auto-download-in-firefox-browser-with-java-selenium-not-working)
Comment: Please read [Under what circumstances may I add "urgent" or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.
Comment: I am able to download pdf correctly but this is an issue with format "txt.htm.xls"
Answer: <code>profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
        "text/plain,text/html, application/xml");
</code>
This should solve your problem
Comment: No. I am not able to solve the problem using above code.


How to read .mdf file in node js

Question: I have one .mdf file. I wanted to read it and convert it to JSON file.
Where .mdf is Primary database data file.
I tried mdf npm package but, it did not work.
Please let mke know if thee is any other way to read .mdf file.
Comment: `.mdf` files are typically **SQL Server** database files
Comment: I will upload the file from UI then I have to convert that schema to json.
Answer: You need to create database from .mdf file then use mssql driver to use it with the node (use of mssql driver: http://www.tutorialsteacher.com/nodejs/access-sql-server-in-nodejs) .
Creating database from .mdf file:
--SQL Script
Create database dbname
On
(
Filename= 'path where you copied .mdf files',
Filename ='path where you copied .ldf log' --Optional
)
For attach;

OR follow the steps below:

First put the .mdf and .ldf file into C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ folder
Then go to SQL Server Management Studio, right-click "Databases" and click the "Attach" option to open the attach databases dialog box
Click the "Add" button to open and locate database files from C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ folder
Click the "OK" button. SQL Server Management Studio loads the database from the .MDF file.
Comment: Thanks for you answer, But I am not looking for this. I want read this file from node itself without any database.

How to read .mdf file in node js


Windows becomes dim when button press takes longer time

Question: How could I prevent the mainwindow goes to dim, even the button click event take long time to response.
For example:
file myframe.h
<code>class MyFrame : public QFrame
{
    Q_OBJECT
public:
explicit MyFrame(QWidget *parent=0);
~MyFrame();
void mousePressEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent *event);

private:
Ui::MyFrame *ui;
}

file myframe.cpp
MyFrame::MyFrame(QWidget *parent):
    QFrame(parent),ui(new Ui::FerryFrame)
{
    ui->setupUi(this);
}

void MyFrame::mouseReleaseEvent(QMouseEvent *event)
{
// do something cost long time,
// this will make the frame background becomes dim,

}
MyFrame::~MyFrame()
{
}
</code>
Any solution?
Thanks,
John
Comment: `QRunnable` / QtConcurrent.
Answer: You need to start a thread for long running operations.  You may need to manually gray/dim buttons or other options while your thread runs to prevent the user from issuing the same commands over and over.  See the QT docs for specifics on threading:
Threading in QT
Pay special attention to thread pools.  They are useful for GUI events.  Also be aware of complexities of updating the user interface from threads.


Jmeter stops after amount of samples achieve threads count

Question: I started the script with 100 threads, infinite loop count, 30 minutes duration and 200 ramp-up period. After amount of samples by every request achieve threads amount jmeter stops sending new requests. How to fix it?
jmeter 5.2.1,
macOS Big Sur 11.6
example image
Comment: Hi @Polina , Can you please check if you have any error in the `JMETER_HOME/bin/jmeter.log` ? What's the configuration of your machine?  Please note that It's recommended to use the latest version of JMeter. Can you include a screenshot of your Thread Group?
Comment: Please provide enough code so others can better understand or reproduce the problem.
Answer: JMeter GUI is for tests development and debugging only, when it comes to test execution you should (or even must) be using command-line non-GUI mode like:
./jmeter -n -t test.jmx -l result.jtl

when your test will be finished you can either open result.jtl file in the Listener of your choice or generate HTML Reporting Dashboard from it and analyze the outcome
During test execution all the Listeners should be disabled as they don't add any value and just consume CPU time and other resources.


Introducing navigation icons with labels, then removing them

Question: In Meng To's Design+Code book, he says the following while referring to icons with labels in navigations:

"Pro tip: If you don't want to always have text next to the icon,
  introduce it first and the next time, the icon can be without text.
  Once the user learns the first time, they don't need to learn it
  again."

I'm just wondering how true this is?
Update:
Bowen has mentioned that this feels like a solution without a problem, which is a fair comment. So let's give a more detailed example:
Imagine you have an application which has a lot of content, and you also have users which use the app frequently (for their job, for example - getting at least 5-10 hours use of it each week).
Usually removing the label may seem counterintuitive. As many people have pointed out: icons are not universal and are open to interpretation. But equally, when people use an app frequently they become accustomed to the placement of buttons as opposed to any accompanying label or icon.
So in the case of an app where you have people using it very frequently and you need to save space, then am I right in thinking this may actually be a reasonable case to remove labels entirely?
Comment: This feels like a solution without a problem. "If you don't want to" is not good underlying cause for removing useful information.
Comment: some icons can be stand alone without text or even an introduction such as home (house), email (mail), write a new email (pencil)
Comment: @Bowen sure, I'd mostly agree. Getting rid of useful information for as aesthetic purposes wouldn't be great, however, if the reason was to allow more content to be seen then that may be a reasonable trade-off for apps which are used by people frequently and have lots of content.
Comment: @Bowen Updated the question with a detailed example, thanks.
Comment: Let *users* turn off/on showing of labels.
Answer: Cognition suggests quite the opposite
Associative memory

Our memory is associative, and is considered to be an emerging property of an adaptive complex system - the neural network.
Recall is reconstructive. The brain isn't a hard-drive.
You may have heard this famous quote by Wittgenstein:

The meaning of a word is its use in the language.

Similarly, with cognition:

The semantic of something is its associations.

Strip all associations from the word 'Tomato' (like something that is red, round, edible, that often goes in a salad) and it is as good as a random collection of letters like 'Buxiarw'.
What's important to remember is that neither text, nor icons are the actual semantic - they are just a step on the way to it.
What you really want people to learn is the association between the icon and its semantics. That is, create associations from a pictorial representation to some desired function.
The problem with icons

As others have mentioned, icons are ambiguous at best, or plain cryptic. To give an example, a spanner icon could mean:

Preferences
Fix
Configuration
Work
Etc.

So inferring the semantic of an icon is often not easy, sometimes impossible.
The problem with more

As with many aspects of life - more is less.
If an interface has only one icon, and the icon is key for (frequent) task completion, nearly anything goes. Think of the hamburger icon, that now seems so bluntly clear - there is little in the icon (when you see it for the first time) to suggest its function.
But when there are many icons, the recall ability decreases, and not in a linear way.
Formula sheets

Putting text next to an icon seems reasonable - after all, the text clarifies the meaning of the icon.
There is a hidden assumption in the pro tip you've shared that this will suffice. But this can have an opposite effect.
Consider students who are allowed a formula sheet whilst taking an exam. Such group is far less likely to remember the formulas compared to a group that is not allowed such sheet (at least in the short term).
The brain is lazy, thus powerful

When processing information, our brain makes gross generalisations and pretty much takes any possible shortcut - doing as little as possible to get the task done.
For example, when reading, we do not read each word in its whole - we glance at the start (and end), and even this is done within a confirmatory process rather inference from scratch (see predictive brain).
This is all part of cognitive economy - within a time frame, the less needs to be done, the more can be done.
Task based behaviour

Within task based behaviour - when the user is trying to complete a task - she will normally adhere to the principle above; namely, do as little as possible.

Users don't use systems not because they want to learn them, but because they have a goal - a desired state.

So by providing a text next to an icon, the semantic becomes immediately clear and there will be little incentive to create any association at all!
The power of success

Considering a fundamental (albeit crude) cognitive modal - the TOTE model - we know that accomplishing a goal makes us feel good. Sometimes it's the release of dopamine, sometimes its the sheer reduction in cognitive load.
This is a fundamental reward mechanism.
So as counterintuitive as it may sound, letting users to struggle a bit can yield better learning and retention.
This concept is well proven within the education field: spoon-feed your students with answers and they'll learn little (à la behaviourist theories); challenge them, specifically when self-exploring, and they learn much more (à la cognitive theories).
The flow theory suggests the optimal tuning of such paradigm.
Summary
As I've argued, there is a (good) chance that if you put this pro tip to test you'll find it won't work but rather have the opposite effect. Of course, there are many variables involved so in some situations it may well work.
But more than all, I hope that the information would be transferable to other scenarios.
Comment: Very interesting and detailed response, thank you. I've updated the original question with a more specific example of a particular situation I'm currently dealing with which takes into consideration the amount of time a user spends on the app and the reason for removing the labels.
Answer: Update:
I still think it is not a good idea to remove the label because:

The user might forget
A different user might use the app

You could give the user the possibility to remove the labels from the app settings, the same way apps let the user customize the UI. Only in the case a set of icons belong to a convention (and this discern has to be done carefully) it might be alright to remove the label, but keep it in a tooltip.

According to this research "think with Google - Principles of Mobile App Design: Engage Users and Drive Conversions":

22. Provide text labels and visual keys to clarify visual information.
Visuals and iconography need text labels for consistent and proper interpretation. In our research, we found that icons for a menu, cart, account, or store locator as well as for actions like filtering or sorting are not universal and not well understood across apps. Icons that are labeled are much more likely to be used. Also, apps that provide visual categorisations without a key require users to guess what they represent. Make sure to include a key to reduce confusion and keep users on task.

My thoughts are that one can get used to click a certain tab to navigate to a certain place. Even if the icon is not understood, the relation button/destination can be memorised.
However, even if the user memorises the meaning of the icon or the button purpose, a different user might use the app, it might be difficult to track if a user really memorised it, or the user forgot it. So it is better to include the text label.
Answer: According to research by NNG:
"Universal" Icons Are Rare -
There are a few icons that enjoy mostly universal recognition from users. The icons for home, print, and the magnifying glass for search are such instances. Outside of these examples, most icons continue to be ambiguous to users due to their association with different meanings across various interfaces. This absence of a standard hurts the adoption of an icon over time, as users cannot rely on it having the same functionality every time it is encountered.
Most users don't live on one site. They jump from site to site with multiple tabs and/or windows open. Icons are used from a business's perspective, so if not labeled, a user may mistake your icon for another company's definition of the icon.
If your team is more "pretty-design" driven, then sometimes this can be a tricky situation as many UI designers without a UX background prefer just icons. The UX cost for these "pretty" decisions may leave your users pogo-sticking through the website, scratching their heads, or closing the website and google searching for another "plain language" solution.
Instead of thinking about having either an icon or both icon and text, have you considered just text as an option if limited space is the issue? If short words like "Menu" are used, it can take up about the same amount of space as a hamburger menu yet be more clear to the user. With the myriad of beautiful display-only fonts available these days, design doesn't necessarily have to be compromised for usability.
Happy researching!
Answer: I find this article, "Icon Usability", on Nielsen Norman Group very useful for this issue:

To help overcome the ambiguity that almost all icons face, a text label must be present alongside an icon to clarify its meaning in that particular context. (And even if you're using a standard icon, it's often safer to include a label, especially if you slightly altered the icon to match your aesthetic preferences or constraints.)
Icon labels should be visible at all times, without any interaction
  from the user. For navigation icons, labels are particularly critical.


How to deal with lath and plaster over top plate of partition wall?

Question: I'm renovating a bathroom, and there was lath and plaster on one wall and in the ceiling, which I have ripped out. The problem is that the room was not originally a bathroom, but a bigger room that had been partitioned to form a bathroom and a hallway. The partition wall was put in without removing the lath and plaster underneath it (see pictures). In order to get rid of all the lath and plaster, I would have to dismantle the wall... which would mean renovating 2 rooms - bathroom AND hallway, which I want to avoid doing.
I plan to re-do the walls in the bathroom with mold resistant drywall. So how would I do this? I'm guessing that I should cut (with a recip saw?) the lath as close the partition wall as possible, then add furring strips to the studs and ceiling joists to push the drywall past the level of the lath and plaster. But this is only guesswork.
Any help appreciated.
Comment: The wood in left in the 2nd picture (lath and plaster) looks a bit rotten to me... which is probably why it cracked so easily. I would honestly get rid of it all. Perhaps give it a shave with a belt sander first and see if it looks better underneath? I've recently refurbished some 60-year old windows that looked even worse on the surface, but 1mm deep [surprisingly] the wood looked like new... My windows' wood however didn't have the deep splits and cracks I see here.
Comment: It's rock solid, and didn't crack easily :-p
There are other areas that have some water damage that I'll be replacing, but that partition wall and the areas I photographed are not some of them.
Answer: Like you're guessing, I would cut the lath as close to the partition wall as possible, then put furring strips [if necessary, see comments below] and drywall over it.
To cut the lath, I wouldn't use a reciprocating saw except maybe with a very fine-toothed blade.  Cutting those lathing strips with a reciprocating action is going to flex them back and forth.  That vibration may propagate into the other room, causing the lath to pull away from the plaster from above.  The result would be cracks in the wall/ceiling or falling plaster.
Instead, I would use a circular saw.  Or maybe a circular saw attachment to an angle grinder if you can't hold your regular circular saw up in the air or against the ceiling lath.
Comment: Furring strips where? Everything looks flat/flush to me.
Comment: @isherwood: I thought that too.  I figured the OP knew differently since they brought it up.
Comment: Elsewhere, someone has suggested using an oscillating multi-tool. That WOULD have some vibrating / reciprocating action, but on the upside, it's actually designed for flush cuts such as this.
Comment: @Bintz: Yes, I have used my oscillating multitool to make cutouts in plaster/lath walls for outlet boxes.  Pluses and minuses, like you say.  I find the blade dulls pretty quickly on plaster and lath, though, so to make a long straight cut like you need to do might be hard.


sudo systemct enable apache2

Question: When I want to enable the apache2 in VMWare workstation by:
<code>$ sudo apt-get install apache2 apache2-utils

$ sudo systemctl enable apache2
</code>
Then I receive an error like this:
<code>apache2.service is not a native service, redirecting to systemd-sysv-install
executing /lib/systemd/systemd-sysv-install enable apache2
</code>
I think this problem arise form host IP but I can't figure out what it is
what should I do?
Comment: What makes you think that it is an error message? It is not an error message; `systemctl` is just telling you what it does. Indeed, `apache2` is not a native `systemd` service, so `systemctl` calls a helper program to do the work. And by the way, normally after installation `apache2` is already enabled.
Answer: It's not an error. Apache2 on Ubuntu 16.04 doesn't provide a native systemd service file, so your command was redirected to systemd-sysv-install and it was successfully executed.

sudo systemct enable apache2


Full Swivel TV Mount on Vertical Studs

Question: I am trying to mount our new 60 inch TV onto a wall.  The studs behind the drywall in the particular area are horizontal and there is too much space in between to mount into the studs.  I cut 2x8s and secured them into the studs vertically in front of the drywall. Will this be okay to hold the weight of the TV (50lbs) and the full motion swivel mount (20lbs)?
Any suggestions?
Thanks!
Comment: studs are never horizontal. You have some other interesting framing going behind there. What kind of wall is this (interior? Exterior?)
Comment: Sounds like you may have some kind of strapping, or maybe a sound attenuation channel you've attached to, but not the stud. Otherwise, what's holding your ceiling up?
Comment: Yeah I think maybe you have the words "vertically" and "horizontally" swapped. If you can hang off the 2x8 then so can your TV.
Comment: Thanks for the replies.  I wish I could send a picture of the area.  The wall is interior.  There are two studs going up vertically and then studs (I found them with a stud finder and felt the wood behind the drywall when my electrican put to do some wiring).  That is the horizontal part I was talking about
Comment: There may be horizontal fire or brace blocking that you're confusing for studs. In any case, your original plan is fine (if a bit unsightly). It doesn't take much to hang 50 lbs. on a wall, and that would certainly do it. 3" construction screws (gold "drywall" type screws) would be fine at 2 per contact point. Lag screws are overkill here.
Answer: It sounds like maybe there used to be a window where you're putting the TV, is that possible?  That would explain the framing you're hitting.
Anyway - it sounds like you put 2x8s from the top of what used to be the window to the bottom.  This will be more than enough support, as long as the 2x8s were attached with big screws, lag screws, lumber screws, etc.
Answer: The better option would be to cut the 2x8, and secure it to the vertical studs.  A couple lag screws into each stud, and the 2x8 should be a permanent fixture. Some folks prefer to use plywood for this, instead of 2x lumber.
Since you don't know what the purpose of the horizontal members, or how they're attached to the studs. It's better not to use them to support anything.
Make sure to drill pilot holes through the 2x8, and put the screws in the center of the studs edge. This will prevent the wood from splitting, and give you the best hold.  Cutting the board a bit longer than needed, will reduce the chances of the board splitting.
You'll also want to use some fairly large washers on the lag screws, so they spread the load against the 2x8s face. This will prevent the screw heads from digging into the wood too much.
Comment: Also:  if you're mounting the 2x8's on the wall surface and affixing them on to the studs edge with lags it would be wise to cut the length an inch or more longer so as not to have the lags at the very edge of the 2x8? To avoid potential splitting?
Comment: Hi Everyone, thanks for the comments!  I think I'll go the route I already took and maybe have my contractor take a look at it.

Full Swivel TV Mount on Vertical Studs


How to change variables $\tilde{x} = \frac{x-1}{x+1}$ in a differential equation

Question: I'm told that the Legendre equation
$$(1-x^2)\frac{d^2P_n}{dx^2}-2x\frac{dP_n}{dx} +n(n+1)P_n=0$$
can be transformed by a change of variables $\tilde{x}=\frac{1-x}{1+x}$ into the hypergeometric equation.  So to try to perform that change of variables I write
$$\tilde{x}+x\tilde{x}=1-x \qquad \Rightarrow \qquad x(\tilde{x}+1)=1-\tilde{x} \qquad \Rightarrow $$
$$x=\frac{1-\tilde{x}}{1+\tilde{x}}$$
Next I want to know the relationship between derivatives, so
$$\frac{dx}{dx} = \frac{-\frac{d\tilde{x}}{dx}(1+\tilde{x})-(1-\tilde{x})\frac{d\tilde{x}}{dx}}{(1+\tilde{x})^2} \qquad \Rightarrow $$
$$1=\frac{-2\frac{d\tilde{x}}{dx}}{(1+\tilde x)^2}$$
So $\frac{d\tilde x}{dx} = -(1+\tilde x)^2/2$.
So now we can write $P_n(x) = y(\tilde x)$ and
$$\frac{dP_n}{dx} = \frac{d}{dx}y(\tilde x) = y'(\tilde x)\cdot -(1+\tilde x)^2/2$$
$$\frac{d^2P_n}{dx^2} = -\frac{1}{2}\left( 2(1+\tilde x)\frac{d\tilde x}{dx}y'(\tilde x) + (1+\tilde x)^2y''\frac{d\tilde x}{dx} \right)$$
$$=\frac{(1+\tilde x)^3}{4}\left(2y'+(1+\tilde x)y''\right)$$
After substituting these into the Legendre equation, though, doesn't seem to transform it into anything nice or useful.  It's making me wonder if I've done something wrong.
Comment: You have done a mistake $$\tilde{x}+x \tilde{x}=x-1 \quad \text{not} \quad1-x.$$ Better to cross check before posting.
Comment: @ManojKumar Is this not going from $\tilde x = \frac{1-x}{1+x}$ to $(1+x)\tilde x = 1-x$ and from here $\tilde x + x \tilde x = 1-x$?  Perhaps I'm not seeing what you're referring to.
Comment: @Addam But in title of your question transformation is different. May be it is just typo.
Answer: The problem here is that you have to set
$$
P_n(x) = \frac{y(\tilde{x})}{(1-\tilde{x})^n}.
$$
Do this and it should all work out.
Alternatively you could set $\tilde{x} = (1-x)/2$, which also gives the hypergeometric equation and is algebraically simpler. The form for $\tilde{x} = (x-1)/(x+1)$ then follows from the Pfaff transformation.
Comment: Is this the same as setting $\tilde x = \frac{1-x}{1+x}$ and I'm not understanding how this is the same?  Or are you saying that the transformation given is not correct, and to use your different transformation instead?
Comment: @Addem First, the transformation is $\tilde{x} = (x-1)/(x+1)$. You have it right in the title but not the body of the question. So you'll need to redo the work of finding $d\tilde{x}/dx$. Second, you need to set $y(\tilde{x}) = (1-\tilde{x})^n P_n(x)$ or else the resulting equation isn't the hypergeometric equation. Which means you'll also have to redo the calculations for $y'(\tilde{x})$ and $y''(\tilde{x})$. But it does all work out.


Straight cracks on drywall ceiling

Question: Long straight cracks in same section of the drywall ceiling. Is this due to poor drywall installation or structural?
Comment: Usually just due to two pieces of drywall moving slightly relative to each other. Tape, mud, paint.
Comment: It may be because of the type of tape used. I stopped using fiberglass mesh tape when I started seeing this occur. If you look real close in the gap, you should see fine lines going across the crack, this will be the threads of the mesh tape, Check closer and please confirm.
Comment: Shoot some properly exposed photos up close. This is badly underexposed and too far away.
Comment: Added additional close up photos.
Answer: Poor installation.
From the looks of it, this joint was not taped before drywall mudding began.
Drywall joints are taped and mudded as part of the finishing process, this prevents this type of cracking among other things.
You will likely need to have a drywall contractor come out and get it fixed up for you, unless you are comfortable doing it on your own.

Straight cracks on drywall ceiling


Can I use an insulated ground wire in a sub-panel?

Question: I'm running a new sub-panel to my basement (the main panel is in the garage). I bought a 500' spool of 6 AWG THHN. The distance to the sub-panel is about 110' so I cut the spool into 4 x 125' lengths. I was planning on using one of the THHN cables as the ground. I just wanted to confirm that it would not be an issue running an insulated wire as the ground. I don't see why it would be a problem but just wanted to double check.
And as a follow-up, I saw one place that if you are using 6 AWG or larger you must use different colored cables. The spool I purchased is all black and I color coded each cable every couple of feet with colored tape. Is that going to be a problem or is that more of a inspector-by-inspector issue?
Comment: This is in conduit, right?
Comment: You should be fine on both counts, assuming of course that this is single phase power and that your "color coding" is red and black for power, white for neutral and green for ground.
Comment: Yeah, good point. I assumed so because of mentioning THHN, but yes, it would have to be in conduit too.
Comment: Yes, single phase and in 1-1/4" conduit. Thanks for the confirmation.
Answer: You have it backwards the larger sizes are allowed to be re identified not the smaller sizes. 6awg and smaller need to have the proper color insulation 250.119.A . The ground is allowed to be solid, stranded insulated or bare. But if insulated 4 and above can be reidentified at the terminations and splices.
Comment: Well you asked about your ground, but the same rule is true for the neutral but gray or white are the required colors 6awg and smaller 200.6.A 1 & 2. Note it is common to identify L1 & L2  but not a big deal as they are a pure 180 out of phase meaning it doesn't matter unlike 3 phase where they are 120 out and depending on the type of system the B phase will have a higher voltage to ground.
Comment: So it looks like 250.119 is only referring to the ground having to be identified with proper color at 6AWG. Does that mean the conductors are ok to be identified just at the termination/splice points?
Comment: Thanks for the clarification, I appreciate your help.
Comment: An upvote or accepting the answer is the normal thanks for the site. Accepting an answer helps others find answers if they have similar questions.


Search dates between ranges of periods and count occurrences

Question: suppose to have the following:

data have;
input ID :$20. Start :date9. End :date9.;
format start end ddmmyy9.;
cards;
0001 01JAN2015 30JUN2015
0001 01JUL2015 01FEB2016
0001 02FEB2016 11DEC2016
0001 12DEC2016 06FEB2017
0001 07FEB2017 31DEC2017
0002 01JAN2016 31DEC2017
0002 01JAN2018 01MAR2018
0002 01APR2018 31NOV2018
......................
;

and a list of dates:
data dates;
input dates :$20.;
format dates ddmmyy9.;
cards;
01JAN2015
31DEC2015
01JAN2016
31DEC2016
01JAN2017
31DEC2017
01JAN2018
31DEC2018
;

Is there a way to know if, for each ID, each date is in the range? For example:  the ID 0001 contains all dates except 01JAN2018 and 31DEC2018.
Moreover, for each year I need to count how many IDs start at 01/01 and end at 31/12 so they appear for the entire year. For example, ID 0002 will not be counted for 2018 because it ends before 31/12. Desired output:

ID       01JAN2015  31DEC2015  01JAN2016 31DEC2016 01JAN2017  31DEC2017  01JAN2018   31DEC2018
0001        yes        yes         yes       yes       yes      yes         no         no
0002         no         no         yes       yes       yes      yes         yes        no

Final table:

 Year       Count
 2015         1
 2016         2
 2017         2
 2018         0

To match the dates in the range I tried:

   proc sql;
   create table want as;
   select dates as t1;
   join have as t2;
   t2.dates between t1.start and t1.end
   order by 1,2;
   quit;

Unfortunately I lose the ID correspondence.
Can anyone help me please?
Thank you in advance
Comment: Do you need both the data for each ID and the final table?
Comment: It would be preferable to have both for subsequent analysis, but only if it is not so hard to generate it.
Answer: The first output can be achieved using proc sql followed by proc transpose and then a data step.
(The variables are created in a different order than in your desired output - hopefully that is not a problem for you.)
The second can be done with a data step followed by proc summary.
NB - I changed the invalid date 31NOV2018 to 30NOV2018 before running my code.
Output 1
* First, join the HAVE and DATES data sets to check which dates fall within a range;
proc sql;
    create table want1 as
        select h.ID, d.dates format=date9., 'yes' as flag
            from dates d left join have h on (d.dates between h.start and h.end)
            order by ID, dates
            ;
run;

* transpose this to the wider format required. Cells where there is no match will be blank;
proc transpose data=want1 out=want1 (where=(ID ne '') drop=_name_);
    by ID;
    id dates;
    var flag;
run;

* Now populate the blank cells with "no";
data want1;
    set want1;
    array datevars (*) _all_;
    do i = 1 to dim(datevars);
        if datevars(i) = '' then datevars(i)='no';
    end;
    drop i;
run;

Output 2

* This assumes the data are in order by ID, start and end - if not then sort the data before this step;
* First read throught the HAVE data set and set count = 1 for each year that is fully covered by each ID;
data want2;
    set have;
    by ID;
    retain first last count; * FIRST and LAST are the earliest START and latest END respectively for each ID;
    if first.ID then do;
        first=start;
        count=0;
    end;
    if last.ID then do;
        last=end;
        do yr=year(first) to year(last); * for each ID we want to cycle through all the years covered;
            if first <= mdy(1,1,yr) and last >= mdy(12,31,yr) then count = 1; * sets count=1 if the year is fully contained within the range;
            output;
            count=0;
        end;
    end;
    drop start end first last;
    format first last date9.;
run;

* The step above produces a row for each combination of year * ID, we just want totals by year which is done by PROC SUMMARY;
proc summary data=want2 nway;
    class yr;
    var count;
    output out=want2 (drop=_type_ _freq_) sum=;
run;


What program will change AVI Files into files I can burn on K3B to burn dvds?

Question: I have AVI Files that are videos. Im am looking to burn these movies onto a DVD-R. It only burns as data to the disc if I burn it directly. So im wondering what program will convert these AVI Files to burnable files to watch on DVD player?
Answer: A very simple program that do the trick is DeVeDe.
To install it, you can use the version in multiverse. Notice that I think that there is some strange interaction with the normal video packages (it will unisintall things like libavutil51 to install libavutil-extra-51... it works for me, but can have collateral effects that I do not know).
It is straightforward to use.

If it happens that you have to remove it, I post here the installation log, so that if needed you can re-install the other packages.
The following extra packages will be installed:
  dvdauthor libavcodec-extra-53 libavformat-extra-53 libavutil-extra-51
  libpostproc-extra-52 libswscale-extra-2 mencoder
Suggested packages:
  mplayer-doc
The following packages will be REMOVED:
  libavcodec53 libavformat53 libavutil51 libpostproc52 libswscale2
The following NEW packages will be installed:
  devede dvdauthor libavcodec-extra-53 libavformat-extra-53 libavutil-extra-51
  libpostproc-extra-52 libswscale-extra-2 mencoder
0 upgraded, 8 newly installed, 5 to remove and 0 not upgraded.
Need to get 6,391 kB of archives.
After this operation, 7,455 kB of additional disk space will be used.

Comment: Hey thanks for the fast response Rmano! I actually installed and used DeVeDee when I was first searching the programs. I was having issues with the copies I was burning. Its real glitchy and the first thing that came to mind was that it was the program I chose to RE Create the avi file (DeVeDee) was the reason why. This assumption was after I slowed down the writing speen to X4 when noticing I still had this issue, even with other avi movie files I tried burning. Any other thoughts on this? Thank you all for your help


Wide cracks across asphalt road

Question: Location: US California desert
What would cause multiple 1 to 1.5 inch wide cracks, averaging 25 ft apart in asphalt roadway? (not regularly spaced, though)
Comment: Are the cracks across the roadway, along the roadway or both?
Comment: @Lee Sam  Strictly across
Comment: This happens everywhere when there is no traffic.
Answer: Normal expansion and contraction. That's what asphalt does. In Minnesota those cracks show up within two years of road resurfacing due to our weather extremes. It is exacerbated by age, where the asphalt has dried and doesn't stretch as well.
Comment: Would this be worse if the asphalt was poured in the heat of the summer and then shrank in the winter? And then settles in to the smaller size?
Comment: I have often wondered about that myself, but I can't say for sure.
Answer: I believe that the cracks appeared between asphalt pours, i.e., instead of paving one lane, then the other, they paved this road edge-to-edge by the truckload. The successive pours did not blend/bond seamlessly because the new hot pour didn't seam well with the previous cooler pour.

Wide cracks across asphalt road


Definition of 'entry' must be imported from module 'Darwin.POSIX.search' before it is required

Question: #include <Foundation/Foundation.h>

int lookup (const struct entry dictionary[],const char search[], const int entries);

struct entry
{
    char word[15];
    char definition[50];
};

struct entry dictionary[100] =
  {
    { "aardvark", "a burrowing African mammal" },
    { "abyss", "a bottomless pit" },
    { "acumen", "mentally sharp; keen" },
    { "addle", "to become confused" },
    { "aerie", "a high nest" },
    { "affix", "to append; attach" },
    { "agar", "a jelly made from seaweed" },
    { "ahoy", "a nautical call of greeting" },
    { "aigrette", "an ornamental cluster of feathers" },
    { "ajar", "partially opened" }
  };

int lookup (const struct entry dictionary[],const char search[],const int entries)
{
    int i;

    for ( i = 0; i < entries; ++i )
        if ( strcmp(search, dictionary[i].word) == 0 )
            return i;
    return -1;
}

int main (void)
{
    char word[10];

    int entries = 10;
    int entry;
    printf ("Enter word: ");
    scanf ("%14s", &word);
    entry = lookup (dictionary, word, entries);
    if ( entry != -1 )

        printf ("%s\n", dictionary[entry].definition);
    else
        printf ("The word %s is not in my dictionary.\n", word);
    return 0;
}

enter image description here
Comment: How do you get the quoted warning? When compiling it with a compiler? E.g. gcc?
Comment: Welcome to SO. Please add all code here. Links to external resources are welcome but only as an addition. Also please describe your problem more thoroughly and read: https://stackoverflow.com/help/mcve
Comment: Stop posting comments that are not in English. Stack Overflow is an English-only website.
Answer: Your code is wrong for so many reasons.
To start with, with an array defined like
  char word[10];

using
  scanf ("%14s", &word);

is very wrong.

You don't need to pass the address of array variable, the array name decays to the pointer to the first element. with scanf(), %s expects an argument as a pointer to the start of a character array long enough to hold the converted input and the null terminator.
for an array size 10, which can hold a string of size 9 (plus, null-terminator), you're allowing 14 characters to be scanned and stored, this is invalid memory access which leads to undefined behavior.

That said, you did not check for the success of the scanf() call, either. In case scanf() fails, you'll be accessing indeterminate values.
Comment: @АлександрБатин no can do sir. I have pointed out the errors, please show some effort, fix it, if you run into issues, will be happy to help.
Comment: correct me my code please
Answer: You should do the declaration of the struct type struct entry before you use it the first time, which is in the prototype just before your declaration.