String behaviour during ordering data

Question: In my application I download some data from website providing landscape informations like population, landscape area and few more.
After parsing html code, data are stored in list of objects
public class Landscape
{
    public int Population { get; set; }
    public string Area { get; set; }
}

public List<Landscape> data;

No problem with that. Follows filling dataGrid and that's purpose of my application. Now, where is the problem? Area info on the website is in semi-numeric, semi-string format. For example: 10 000 km2.
I have possibility to choose whether to trim km2 suffix and store data as int, or do nothing about it and store data as string. Since I want have data in dataGrid in original format, I decided not to trim.
Finally, is there a way to order rows (by size of area) as int although it is string type?
Comment: Are you sure you want to store the area as a string? I'd use a `Decimal` in a standard unit and only convert to string for display purposes.
Comment: I am not sure hence I am posting my current solution and awaiting experienced to advise me :)
Answer: You can use linq to sort by the translated value but don't think this will be fast.
public class Landscape
{
    public int Population { get; set; }
    public string Area { get; set; }

    public int TrimAndConvert()
    {
        /* Your Code to trim and convert to int */
    }
}

data.OrderBy(landscape => landscape.Area.TrimAndConvert());

I think a better way would be to save the Area as a number and add the trimmed part just for output.
public class Landscape
{
    public int Population { get; set; }
    public int AreaValue { get; set; }
    public string AreaUnit { get; set; }

    public string Area
    {
        get
        {
            return AreaValue.ToString() + AreaUnit;
        }
    }
}

Comment: I thought this way, but I would rather solution where is no need of additional button for ordering data in dataGrid. If there is no way how to solve it just by clicking header in dataGrid, then your solution would be just fine. (Except there is no need of AreaUnit variable because I know trimmed part so I can only attach it as a string)
Comment: The AreaUnit property was just in case you would have different units (but that would of course make the sorting useless). You could implement `public int TrimAndConvert` as a property and have the DataGrid sort by it.
Answer: You will need to implement an IComparer and pass and instance of it to the List.Sort() method/overload that takes an IComparer.
This should get you started:
List<T>.Sort Method (IComparer<T>)
Comment: Is it possible implement this IComparer in way I can attach it to dataGrid? In dataGrid you order rows just by clicking header, I think dataGrid has its own ICompare method I can't affect.

String behaviour during ordering data


Visual Basic: Comma, ')',or valid expression continuation expected

Question: I have the following function:
Public Function HasCurrencyChanged(ByVal idPriceList As Integer, ByVal data As Dictionary(Of String, String)) As Boolean

        Dim param As ParamStruct() = New ParamStruct(2) {}

        Try
            param(0) = ProviderFactory.CreateParameter("@idPriceList", DbType.String, ParameterDirection.Input, idPriceList)
            param(1) = ProviderFactory.CreateParameter("@ID", DbType.String, ParameterDirection.Input, data["uidIDCurrency"])

In my C# class i call this method as  _clsPriceList.HasCurrencyChanged(Convert.ToInt32(priceListId), data);
In the last line i get a red line in data["uidIDCurrency"] telling me  Comma, ')',or valid expression continuation expected
What is wrong?
Answer: It looks like you may have translated some C# but failed to do so completely. You don't use brackets, i.e. [], to index in VB but rather parentheses, i.e. (). You should have known that from any beginners VB tutorial or the like or even the rest of your own code that you posted.
Comment: Just Added the C# code


Magnitude of rotation in $\mathbb R^3$ from rotation matrix

Question: Given a rotation matrix $Q \in \mathbb R^3$, how to find a magnitude of rotation. I guess it makes sense to say that identity matrix $I$ is considered 0 magnitude and the rotation of $-I$ is considered maximum magnitude. It would also makes sense that $mag(Q) = mag(Q^T)$.
Is there a way of computing this without going through the trouble of finding Euler angles and then deriving metric using identity $\cos^2(\alpha) + \cos^2(\beta) + \cos^2(\gamma) = 1$?
Comment: hmm,  I have doubts whether $-I$ we can treat as a rotation matrix in 3d ... its determinant $=-1$
Comment: I am pretty sure it is. Any orthogonal matrix can be considered a rotation matrix since the rotation has to follow property $Q Q^T = Q Q^{-1} = I$, it follows that determinant be +- 1. Also, you can verify that vector under this transformation remains constant length, since no scaling is done. Therefore it is rotation of some sort. But to make the matter concrete, consider vector $v = [1, 1, 1]$
Comment: I was taught that determinant must be +1. But maybe it is just more general approach..,
Comment: What's the connection between the Euler angles, the direction cosines identity and the rotation magnitude ???
Comment: On negative determinant. https://en.wikipedia.org/wiki/Rotation_matrix#Properties_of_a_rotation_matrix
Comment: Maybe it becomes clearer for what I am searching if I explain my necessity for it. I have data coming in from couple of devices accelerometers which are moving in unison, however the coordinate frames are not the same so I find a rotation Q such that the coordinate frames match minimizing square error. Next I am looking to make an automatic check of confidence on the coordinate frame we are in. One part of that is that, if rotation doesn't change too much we are more confident that it is correct.
Comment: @JoonatanSamuel: indeed, if your rotation determinant turns negative, you can suspect a mechanical problem, such as the Universe changing chirality.
Answer: I found it useful to think about the transformation rotation matrix $Q \in R^{3 \times 3}$ affects given vector $v$. That means what does $$\vec u = \vec v \times Q^T $$ look like. After that I can compare the initial vector $\vec v$ and compare it to $\vec u$ by dot product between them since $$cos\ \phi = \frac{\vec u \cdotp \vec v}{||\vec u|| \ ||\vec v||}$$.
$ \vec v \in R^3$; $\vec v$ should be unit vector, let us choose $[1, 0, 0]$. giving the metric from $[-1; 1]$ of $$metric(Q) = (\vec v Q^T) \cdot \vec v;\ v = [1, 0, 0]$$
This simplifies to $metric(Q) = Q_{11}$, which agrees with maximum of 1, when $Q = I$, minimum of -1 when $Q = -I$ and $metric(Q) = metric(Q^T)$
Answer: You don't really define what is meant by magnitude and I don't think that the Euler angles representation is appropriate for that purpose.
I suggest to use the axis/angle representation, and this method: https://en.wikipedia.org/wiki/Rotation_matrix#Determining_the_angle.
Comment: ..with axis/angle rotation he rather would not be able to go from $I$ to $-I$. He needs something additional....
Comment: @Widawensen: $-I$ is not a rotation.
Comment: How is -I not a rotation? It takes vector v and rotates it to negative v. Any matrix transformation that doesn't change length of v is considered rotation, and negative I definitely doesn't change the length of v.
Comment: @JoonatanSamuel: no, it's a reflection, $|-I|=-1$.
Comment: https://en.wikipedia.org/wiki/Rotation_matrix#Properties_of_a_rotation_matrix
Comment: @JoonatanSamuel Good luck to perform a physical rotation with matrix $-I$.
Comment: so $-I$ is rotation in a mirror..


how start implement MVVM pattern

Question: =======
So i decide to to develop my asp.net site into Silverlight.
I today start to search articles about MVVM pattern which i want use in my Silverlight app, and i am confused :/ It's hart to me understand how works this pattern. I am find 3 frameworks which supports MVVM pattern in Silverlight - Caliburn, MVVM Light Toolkit and GoodLight.

Should i start from own implementation of pattern or use framework?
Is this frameworks only a project solutions in which i can insert my code?
Which framework is the best for novice and which for professional?

I ask for this, cause i must start to rewrite my app from asp.net to Silverlight and i don't know that i can do it first and later (when i understand MVVM pattern and framework) implement this pattern in finished app ? Or from begining rewrite project to MVVM framework?
Answer: Going from ASP.NET to Silverlight is likely to require a (nearly) complete rewrite.  The usage scenario is quite different.  Silverlight is all about providing a client-side like development environment - it makes it so you can write an application the same way you'd write a client-side, desktop application, but execute this within the context of a browser.
This has fairly broad implications on how you'd use and develop your software.
That being said - for frameworks...  Personally, I'd recommend getting a good grasp of MVVM first, then choose a framework (if any).  MVVM is really a simple architectural design pattern.  Once you understand it, the frameworks will make more sense.  It's difficult to suggest "pick this framework", since they all add their own, valuable, additions and ways of working.
There are many good sources for learning about MVVM.  Personally, (I'm being biased here), I like the intro I wrote (even if it's WPF oriented instead of SL oriented, the concepts are the same).  That being said, Jerimiah Morrill's MVVM for Tards is also very good to get a basic understanding of what, exactly, it means when you say MVVM.
Once you understand this, the frameworks will be much more approachable (or avoidable, if you don't want them).
Comment: OK, so I start from learning MVVM. But can I implement MVVM in finish project? It's possible that "refactoring"?
Tnx for links! It will useful :)
Comment: You can slowly refactor SL/WPF code to use MVVM patterns, one "View" at a time.  That is possible to do...
Comment: I wish I could vote this answer up 100 times. People leaping to frameworks without knowing what they need is the biggest problem I've seen as a WPF/Silverlight guy. Too many projects out there are totally based around PRISM (and generally the nastier bits like EventAggregator because the original developers didn't understand commanding or IoC) when they really won't demand it - utter architecture astronautism.
Comment: Tnx for this answer! I now realized that i too much focused on choosing a framework than understanding pattern MVVM! I fix my fault!
p.s. View is the XAML code, Model is a LINQ queries to db ?I am correct? What part of Silverlight project can I name as ViewModel  and Controler?
Comment: Model is the data itself - typically via LINQ or whatever.  ViewModel is the "glue" that ties the model together,allowing it to be data bound to the View.
Comment: Basing at my asp.net website, all data from mssql db was strage in DataContext(creating by using visual studio orm tools) from I was querying it by LINQ. So ViewModel was codebehind LINQ queries and Model was this DataContext? Maybe it will be simpler for me when i understand how can i works with mssql db with Silverlight ... :/

how start implement MVVM pattern


Accessing DLC in Fallout 3 Game of the Year Edition (PC)

Question: I'm having trouble accessing the DLC in Fallout 3 Game of the Year Edition on PC. I completed the game and then installed the DLC from disc 2. I then re-inserted Disc 1 and loaded all of the files for the "Data Files" option in the launcher window.
How do I access my DLC? when I load my most recent save nothing pops up saying new quests or options are available. I've tried starting a new game and I've searched through the downloads option in the main menu but to no avail.
Answer: The DLC is just scattered around the wasteland. In order to find the locations turn on your radio and you will see a bunch of new radio broadcasts. Listening to said broadcasts will make the DLC locations appear on your map (with the exception of Broken Steel). You can also go here and read the main article for each of the DLC's listed. The first quest in the main article has a "given by" section which will tell you how to access them:

As a side note when you reloaded the first disk after installing the dlc you should have gotten notifications that a new signal has appeared on your radio. So hopefully this isn't actually a bug.
The physical locations of the DLC (on your pc) are:

<code>%USERPROFILE%\Local Settings\Application Data\Microsoft\Xlive\DLC (Windows XP)
%USERPROFILE%\AppData\Local\Microsoft\XLive\DLC (Windows Vista & Windows 7)
</code>

Just in case you want to check if they actually installed.
Answer: If you wander the Wasteland for a short while, you should start picking up some radio signals. If they don't appear, try looking at the radio in your Pipboy. If that still doesn't work, start a new game and head off to Megaton. If they STILL haven't appeared, then you will probably need a reinstall.


nodejs, mongodb and handlebarjs with async-await CRUD operation

Question: Project on Get-Post-Update-Delete requests using the mongoDB mongoose and Express-handlebars. My code works fine for get and post request, but it's giving error for my update and delete request. So, I am requesting for codes from your side on how to do update and delete operation works with async function and hbs.
Comment: Hello. To improve your question, please give more information about what you already
tried. https://stackoverflow.com/help/how-to-ask
Answer: For update you can use the PATCH like so
router.patch('/users/:id', async (req, res) => {
    const updates = Object.keys(req.body)
    const allowedUpdates = ['name', 'email','password','age']
    const isValidOperation = updates.every((update) => allowedUpdates.includes(update))
    if(!isValidOperation){
        return res.status(404).send({ error: "Invalid update field" })
    }

    try{
        const _id = req.params.id

        const updateUser = await User.findById(_id)

        updates.forEach((update) => updateUser[update] = req.body[update]);

        await updateUser.save()

        if(!updateUser){
            return res.status(404).send()
        }

        //render your hbs file here

    }catch(e) {
        res.status(500).send()
    }
})

For the DELETE
router.delete('/users/:id', async (req, res) => {
    try{

        const userDelete = await User.findByIdAndDelete(req.params.id)

        if (!userDelete) {
            return res.status(404).send("Error")
        }

        //then you render your HBS file here
         res.render()
    }catch(e) {
        res.status(500).send(e)
    }
})


Django- ListView returning a list of users with a given tag in a tag field

Question: I'm trying to return a list of users with a particular skill and skills is a TagField (django taggit) in a CustomUser model. I'm struggling to get the queryset right in my ListView (skill_list.html). I want to be able to click on the skill listed on a user's profile (profile.html) and then have that return the skill list page with a list of all users that have that skill.
models.py:
class CustomUser(AbstractUser):
    objects = CustomUserManager()
    position = models.CharField(max_length =200, null=True, default='',
    blank=True)
    bio = models.CharField(max_length=400, null=True, default='',
    blank=True)
    skills = TaggableManager(help_text="A comma-separated list of tags.")

views.py:
class SkillView(ListView):
model = CustomUser
template = 'skill_list.html'
queryset = CustomUser.objects.all()

def get_queryset(self):
    queryset = CustomUser.objects.filter(skills__name__in=
    [self.kwargs['skill']])
    return queryset

profile.html:

            {% for skill in user.skills.all %}

{{ skill.name }}

            {% endfor %}

skill_list.html:

    {% for user in object_list %}

{{ user.first_name }}&nbsp{{ user.last_name }}

{{user.position}}

I have the url set up on the profile page to return the 'skill_list.html', however I get an key error on the skill_list page: Exception value "skill."
Comment: You haven't shown your URL pattern. For `self.kwargs['skill']` to work, you need to include the skill in the URL.
Comment: Do you mean include a pk for the customuser model so I can access the skill associated with it? My url is:  path('skills/', views.SkillView.as_view(), name='skills'). I know how to do this for a model instance, but I'm a bit confused now because this is not a model instance but a model field with many entries.
Comment: You want a list of users with the skill, so you need to include the *skill* in the URL, not the user's PK. See my answer below.
Answer:
I want to be able to click on the skill listed on a user's profile (profile.html) and then have that return the skill list page

In that case, the URLs need to include the skill in them, e.g. /skills/python/ or /skills/sql/.
You can do this by changing the URL to something like:
path('skills/<slug:skill>', views.SkillView.as_view(), name='skills')

Now self.kwargs['skill'] will work in the SkillView.get_queryset method.
You now need to include the skill in the URL tag, for example:
{% url 'skills' skill %}

Finally, since you are only using a single item in your list,
queryset = CustomUser.objects.filter(skills__name__in=[self.kwargs['skill']])

you can remove the __in and change the query to:
queryset = CustomUser.objects.filter(skills__name=self.kwargs['skill'])

Comment: Thanks for your help! Now I'm not getting an error but the list is empty. Do you know if I'm supposed to reference the queryset in the skill_list.html template like so:        {% for user in object_list %} ?
Comment: `{% for user in object_list %}` [should work](https://docs.djangoproject.com/en/2.1/topics/class-based-views/generic-display/#making-friendly-template-contexts). Try adding some printing/logging to your queryset to make sure that it is returning results
Comment: So I've determined that the problem is not with how I'm calling the queryset in the template. The line: queryset = CustomUser.objects.filter(skills__name=self.kwargs['skill']) is not finding the name of the skills properly. Is this how I should reference the skill in the profile.html: {{ skill.name }} ?
Comment: Yes, you need to include the skill in the `{% url %}` tag somehow, but I'm not familiar with django taggit so I'm not sure whether the correct usage is `{% url 'skills' skill.name %}` or something slightly different.
Comment: That was it! Thanks sooo much
Answer: I think it should be :request.user instead of user in profile.html
Comment: No, that template works fine when I change the queryset to something else. The problem is with getting the correct queryset. I think the issue is with this line: queryset = CustomUser.objects.filter(skills__name__in=
    [self.kwargs['skill']])
Answer: Then why dont you just use a 'Q' search query. Check it in the docs


Not initialized variable in nested for js react

Question: I am trying to create 40 cells with react , each should have a different title. For example a0 ...a9, b0 ..b9 etc. This is my code
const mapItems = () => {
    let playerId = ["a", "b", "c", "d"];
    let cellId;
    let l, j;
    for (j = 0; j < 4; j++) {
        for (l = 0; l < 10; l++) {
            cellId = playerId[j].concat(l);
            return (
                    <Cell title={cellId} className={"column"}>
                        {returnItemsForCell(cellId)}
                    </Cell>
            )
        }
    }

}

For some reason I get an error that a variable is not initialized , and only one in nested For loop.
Any ideas on how to do it right? Thanks in advance
Comment: Your nested loop looks correct may be your editor showing it wrongly, but you will get only 4 results in this code. 40 items will not be there on the list! because you are returning instantly on second loop
Comment: You can use snippets for such questions
Answer: If someone ever has the same problem , this is the solution.
const mapItems = () => {
    let playerId = ["a", "b", "c", "d"];
    let cellId;
    let cellsList = [];
    for (let j = 0; j < 4; j++) {
        for (let l = 0; l < 10; l++) {
            cellId = playerId[j].concat(l);

            cellsList.push(
                <Cell title={cellId} className={"column"}>
                    {returnItemsForCell(cellId)}
                </Cell>
            )
        }
    }
    return cellsList;

The return just jumped out of the loop.


How to prevent background service from crashing in Android

Question: I am using the google calendar api to fetch the user data from a background service.
The service runs periodically to fetch the user data from the api and some operation is performed on that data.
Since it is a background service there is no user interaction when I fetch the data after the authorization process.
So what is the correct way of handling the crash that might be caused due to failure of the service.
Comment: I am sure failure of service or some unexpected behavior might lead to generation of exception, which in turn leads to crashing as it was unhandled. I would suggest you read what are exception and errors? how to handle it? and decide how your app should behave in such cases. Now if you are talking of background service not working in latest Android OS (i.e Android 10) then kindly [refer](https://developer.android.com/guide/components/activities/background-starts) and also [refer](https://developer.android.com/about/versions/oreo/background)
Answer: First analyze the root cause of the crash ,check the log proper . most of the time it may occur because of the null pointer exception.Handle all the null from the service.


Python: using regex and while loop to break out paragraphs in a PDF

Question: I have a pdf file that has 82 paragraphs, my goal is to use python to break each paragraph into its own block of text. I have already extracted the text using PyPDF2.
The paragraphs all begin with a number and a period (1. 42. 76. etc.). It is working for most of the paragraphs with the code below, but it doesn't always take the period into account. For example, number 18's match output is: "18 (06/". This shouldn't have gotten picked up though because there isn't a period after it. Any suggestions?
Code for finding positions:
i = 1
all_positions = []
found = "found"

while found == "found":
    matches = []
    matches_positions =[]
    standard_length = 0
    substring = str(i) + "."
    matches = re.finditer(substring, text, re.IGNORECASE)
    matches_positions = [match.start() for match in matches]
    standard_length = len(matches_positions)
    if standard_length > 0:
        all_positions.append(matches_positions[0])
        i += 1
    else:
        found = "not found"

Code for printing output:
for i in range(0,len(all_positions)):
     print('---')
     print(text[all_positions[i]:all_positions[i+1]])

Comment: Can you add an example of the text to the question? I think you are using a number plus a dot as the substring which will turn into a regex that matches a digit followed by any character except a newline.
Answer: You can use the below regex to achieve your result:
^\d+\. ?(.*)

Explanation of the above regex:

^ - Represents the start of the given test String.
\d+ - Matches digits[0-9] one or more times.
\. - Matches dot literally.
 ? - Represents zero or one space character.
(.*) - Represents capturing group capturing the paragraph text greedily.

You can find the regex demo here.
IMPLEMENTATION IN PYTHON:
import re
pattern = re.compile(r"^\d+\. ?(.*)", re.MULTILINE)
match = pattern.findall("1. Hellow World\n"
    "23. This is loremIpsum text\n"
    "9001. Some random textbcjsbcskcbksck sbcksbcksckscsk\n"
    "90 (89. Some other")
print (match)
# Output - ['Hellow World', 'This is loremIpsum text', 'Some random textbcjsbcskcbksck sbcksbcksckscsk']

You can find the implementation of the above code here.
Comment: You can omit the lazy part `?` matching the digits, as matching the digits can not cross the dot itself.
Comment: Thanks for the same @Thefourthbird. Updated the same.


Bluetooth isn't working in Dell Vostro 3560 with BCM43142 wireless adapter

Question: I installed the wireless driver using this instruction How do I install BCM43142 wireless drivers for Dell Vostro 3460/3560 and I have WiFi working. No problems here.
But unfortunately the bluetooth doesn't work. The Ubuntu bar shows the bluetooth sign and I can turn the bluetooth on/off but I can't discover any devices. And I can't find my laptop when I turn visibility On. So, obviously bluetooth doesn't work.
I couldn't find the reports that blutooth can actually work with this adapter in Ubuntu. So, is there anyone with BCM43142 adapter that have bluetooth working? I am using Ubuntu 12.10 x64.
Answer: From Revision #2 of the question:

After some fiddling around with different drivers from different sources I managed to get bluetooth working. Not flawlessly but at least I can pair a device.
  Bluetooth started working after installation of this package bt-bcm43142-onereic_0.0+20111116somerville2_amd64.deb.
Originally I found this package on the disk with Ubuntu which came with the Laptop.
  What this package does, it installs a firmware loader and a firmware itself. This firmware needs to get bluetooth working.
Still bluetooth sometimes doesn't work even with this package. But manual loading the firmware helps.
brcm_patchram_plus_usb --patchram /lib/firmware/BCM43142A0_001.001.011.0028.0036.hcd hci0

Also I found it strange that this package writes all different ids into /sys/bus/usb/drivers/btusb/new_id because only one from the list matches my device ID
Content of bcm43142.conf:
install btusb /sbin/modprobe --ignore-install btusb && echo '0a5c 21d3' > /sys/bus/usb/drivers/btusb/new_id && echo '0a5c 21d7' > /sys/bus/usb/drivers/btusb/new_id && echo '0a5c 21e1' > /sys/bus/usb/drivers/btusb/new_id && echo '0a5c 21e3' > /sys/bus/usb/drivers/btusb/new_id && hciconfig hci0 up && /usr/bin/brcm_patchram_plus_usb --patchram /lib/firmware/BCM43142A0_001.001.011.0028.0036.hcd hci0 &

Output of lsusb:
...
Bus 002 Device 003: ID 0a5c:21d7 Broadcom Corp.

In conclusion: bluetooth works not nearly as good as in Windows. Once I even got a complete crash of the system because of the btusb module. Luckily WiFi works perfectly.
Answer: I had the same issue on an Asus X202E (BCM43142 chip): with Ubuntu 12.10 x64, I had to install wireless driver as described above. Which works for wifi... but not for BT.
Now switched to 13.04 x64 and had wireless working without the need of installing wifi driver, Bluetooh still not working.
I'll try this evening the bt-bcm43142 package and see if I can get my BT working.
In anycase, thanks for the post, it's a nice resume of the BCM43142 challenge in Ubuntu.
Update
I have just installed the above mentionned package, rebooted and I now have BT working and connecting to devices :)
For readers who might face the same issue, here are some command output before installing the package:
$ lsusb
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 13d3:3388 IMC Networks
Bus 001 Device 004: ID 13d3:5188 IMC Networks
Bus 001 Device 005: ID 03eb:8417 Atmel Corp.

$ lspci -nn
02:00.0 Network controller [0280]: Broadcom Corporation BCM43142 802.11b/g/n [14e4:4365] (rev 01)
03:00.0 Ethernet controller [0200]: Qualcomm Atheros AR8162 Fast Ethernet [1969:1090] (rev 10)

$ rfkill list
0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: brcmwl-0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
3: asus-wlan: Wireless LAN
    Soft blocked: no
    Hard blocked: no
4: asus-bluetooth: Bluetooth
    Soft blocked: no
    Hard blocked: no
5: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no

$ hcitool dev
Devices:
    hci0    DC:85:DE:AB:4D:38

$ hciconfig
hci0:   Type: BR/EDR  Bus: USB
    BD Address: DC:85:DE:AB:4D:38  ACL MTU: 1021:8  SCO MTU: 64:1
    UP RUNNING PSCAN
    RX bytes:549 acl:0 sco:0 events:31 errors:0
    TX bytes:1168 acl:0 sco:0 commands:31 errors:0

$ sudo service bluetooth status
bluetooth start/running, process 944

$ dmesg | grep Blue
[    8.954020] Bluetooth: Core ver 2.16
[    8.954086] Bluetooth: HCI device and connection manager initialized
[    8.954096] Bluetooth: HCI socket layer initialized
[    8.954100] Bluetooth: L2CAP socket layer initialized
[    8.954114] Bluetooth: SCO socket layer initialized
[   10.975507] Bluetooth: hci0 command 0x1003 tx timeout
[   11.088728] Bluetooth: can't load firmware, may not work correctly
[   12.901647] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   12.901653] Bluetooth: BNEP filters: protocol multicast
[   12.901664] Bluetooth: BNEP socket layer initialized
[   12.909989] Bluetooth: RFCOMM TTY layer initialized
[   12.910004] Bluetooth: RFCOMM socket layer initialized
[   12.910007] Bluetooth: RFCOMM ver 1.11
[   15.226150] Bluetooth: hci0 command 0x1003 tx timeout
[44180.125379] Bluetooth: can't load firmware, may not work correctly

We can notice that firmware can be loaded as per last libe here above. But after having installing it and rebooting the computer... All Good :)
$ dmesg | grep Blue
[    8.768600] Bluetooth: Core ver 2.16
[    8.768625] Bluetooth: HCI device and connection manager initialized
[    8.768634] Bluetooth: HCI socket layer initialized
[    8.768638] Bluetooth: L2CAP socket layer initialized
[    8.768644] Bluetooth: SCO socket layer initialized
[    8.989943] Bluetooth: can't load firmware, may not work correctly
[   13.036311] Bluetooth: RFCOMM TTY layer initialized
[   13.036327] Bluetooth: RFCOMM socket layer initialized
[   13.036330] Bluetooth: RFCOMM ver 1.11
[   13.037056] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   13.037059] Bluetooth: BNEP filters: protocol multicast
[   13.037064] Bluetooth: BNEP socket layer initialized

wireless 13.10 bluetooth asus x202e broadcom bcm43142


EV charger wiring - sub-panel requirements

Question: I am looking to add a 30A outlet in my garage for the purpose of charging an EV.  My home has 200A service coming through the main panel, and currently there are no sub-panels except one for the central air AC unit.
My dryer is located on the other side of the garage wall where I would like to place the outlet.  When we bought the home, the previous owner had tapped into the dryer outlet and added a 240V outlet where I would like this one.  This was not up to code, so we had them remove the outlet and plate over the box before we closed.
Fast forward a few years and I'd like to put an outlet here but do it right.  I do NOT want to install a dedicated charger, but would rather install a 14-30 outlet that most any non-hardwired car charger can use, both for my current use and future-proofing.
I opened the box where the previous outlet was and found 10/3 wire w/ground (picture below), even though the dryer outlet on the other side of the wall and the one we had removed are both 10-30 receptacles, and so ungrounded (home was built in '92).  Testing these wires confirmed two hots at 120V each, one neutral and a dead ground.  Odd thing is, the bare copper wire which should be the ground wire is wired as neutral, and the white neutral wire is dead. A no-contact voltage tester indicates the bare copper has live but low voltage present. With a DMM, I get 120V from either hot to this wire, and nothing from either hot to what I thought should be the neutral. Is this normal, or am I doing it wrong?
I was NOT planning to just add a receptacle back where it used to be, tapped off the dryer.  My plan is to add a 60Amp breaker at the main panel (about 25 feet away) and run 6ga wire to a subpanel in the garage, and within that panel add two 30A breakers, one to feed the dryer (with a proper 14-30 outlet) and one to feed the EV outlet (also 14-30), feeding both with 10/3 romex. I consulted an electrician about this and he said I only need a 50A breaker in the main panel for this setup(???). I may, MAY, elect to add a 14-50 outlet instead of the 14-30 for the EV outlet in the garage, in which case I'd upgrade that respective breaker and wiring as well as bump the 60A breaker to feed the sub up to 80.  I'd cap off the existing run to the dryer, and yank out the wires the previous homeowner ran to the aforementioned garage outlet.  I plan to do all this work myself, with the exception of the work at the main panel.  I will hire an electrician (a different one) for that after I've wired everything else up.
I get that I could leave the current dryer setup alone and just add a receptacle on a dedicated circuit for the EV charging, but after seeing inside the box for the receptacle we removed I'm growing increasingly uncomfortable with how the dryer line was tapped, and I figure I'll just go ahead and update that to 14-30, and try to do it right. Does all this sound reasonable? I would greatly appreciate any input, insights, or comments.
Comment: Was there any protection on those cut wire ends when you opened the box up?  Having bare wire like that with no protection, I'd think would be a safety hazard, even if nothing were connected to them.  I'd at least put wire nuts on them for protection.
 Also, it looks like when they took out the previous outlet that was there, they just cut the wires, and didn't do you any favors doing that by cutting them so short.  There's probably not enough wire length in there to even make pigtail connections, as I believe code typically says that one needs a minimum of 6" of wire in the box.
Comment: *"With a DMM, I get 120V from either hot to this wire, and nothing from either hot to what I thought should be the neutral. Is this normal, or am I doing it wrong?"*  No, you're not doing it wrong - this is why 10-30 outlets are dangerous and illegal now.  Also why tapping it to feed a 14-30 is equally dangerous and illegal.
Comment: @Milwrdfan; Totally agree with your comments and no, there was no protection on these wires.  When i pulled the faceplate off this is exactly how it looked. i know, very dangerous.  i have yet to pull the faceplate off the dryer receptacle on the other side of the wall but I already know I'm going to cringe when I see how he tapped the line. that's why i plan to just yank all this out and run new wire for the dryer too, upgrading the receptacle/circuit in the meantime.
Answer: The old wiring is 100% irrelevant to this, since you know it isn't large enough for anything more than 30A. So ignore all that and the plastic box, etc. Except that you should replace the existing 30A dryer 10-30 receptacle  with a 14-30 receptacle, which will be easy since the new subpanel will have ground going back to the main panel. You will need to change the dryer cord and remove the neutral/ground bond on the dryer.
Back to the main issue: subpanel. That is the right way to do it. Better than 6 AWG copper is 2 AWG aluminum, which should get you all the way up to 90A! You don't have to install a 90A feed breaker - any size large enough for what you plan to use in the subpanel is fine, but no larger than 90A. You can always change it later.
I am fairly certain that the subpanel is not required to have a main breaker. If it were in a separate building then a shutoff would be required, which a main breaker would satisfy. But a main breaker for convenience when working on the panel is just fine if you want to have one. If you have a main breaker in the subpanel, any size >= the feed breaker size is fine. You can have a 100A breaker with a 60A feed.
You probably don't need a huge subpanel, but you should always get larger than you think you need. You should certainly have enough for:

2 EV chargers (Tesla + Ford, based on comments to another answer) - 240V
Dryer - 240V
1 receptacle circuit - 120V
1 lighting circuit - 120V

which is 8 spaces. But bigger is better. Maybe someday you'll want to build a shop (240V tools) or do other things with the space. Also keep in mind that many circuits, especially in garages, require AFCI and/or GFCI, and those won't work in 1/2-size spaces. If a panel says 20 spaces/40 circuits, treat it as 20 spaces/20 circuits.
As a semi-random example from Home Depot (your local pricing at various sources will vary, of course), there is a Square D Homeline panel currently selling for < $100, in stock in at least some locations (i.e., not some "can't find it anywhere due to supply shortages" thing) with 24 spaces ("48 circuits" - ignore that), 3 x 20A single pole breakers, 2 x 30A double pole breakers (one of those will be for your dryer). You'll need to add more breakers, and you may need a ground bar (not sure, haven't checked the specs in detail) because this is being installed as a subpanel. But compared to everything else (particularly the cost of 25' of 6 AWG copper, though hopefully you'll be able to switch to cheaper aluminum) this is "nothing" and provides lots of room for the future. Also keep in mind that the biggest drawback to any subpanel (instead of individual receptacles going back to the main) is making sure you have code-required workspace in front of it. But that will be the same for any panel, so might as well go big.
Don't worry about aluminum. The problems with aluminum is with small circuits. Done properly, aluminum is perfectly fine for large circuits. There are restrictions in some places (at least Montgomery County, MD) with aluminum for branch circuits, but not for subpanels.
Comment: IIUC, aluminum for branch circuits is just fine too, _if the connections are done properly_. Of course, AL branch circuits are _outlawed_ in some jurisdictions, but that's a different story
Comment: I'd say 8 space is the absolute minimum. I'll add more...
Comment: Ahhh, AFCI/GFCI, I can't believe I forgot all about that!  Hadn't considered aluminum, will have to check out local restrictions to investigate further.  Totally agree with making as much future capacity as possible available for expansion. Was planning to add at least an 8 space panel, even if only using the 4 for now.
Answer:
I opened the box where the previous outlet was and found 10/3 wire w/ground (picture below), even though the dryer outlet on the other side of the wall and the one we had removed are both 10-30 receptacles, and so ungrounded (home was built in '92). Testing these wires confirmed two hots at 120V each, one neutral and a dead ground. Odd thing is, the bare copper wire which should be the ground wire is wired as neutral, and the white neutral wire is dead.

Yes, that's just the kind of horky nonsense we see anytime NEMA 10 is involved.  In fact it's a bit of a surprise to find a groundless NEMA 10 in 1992, since groundless #10 wires were all but gone from the market. Some people installed 10/2 w/ground, and abused the ground as neutral; but that has always been forbidden (and thus, NOT grandfathered). Once old stocks of 10/3 "without ground" ran out, you were to use 10/3 with ground and simply not connect the ground if using a NEMA 10-30.
However, one thing was legal: having multiple outlets on a 30A circuit.

I was NOT planning to just add a receptacle back where it used to be, tapped off the dryer. My plan is to add a 60Amp breaker at the main panel (about 25 feet away) and run 6ga wire to a subpanel in the garage, and within that panel add two 30A breakers, one to feed the dryer (with a proper 14-30 outlet) and one to feed the EV outlet (also 14-30), feeding both with 10/3 romex

Well, 6/3 Romex (NM or UF) is only good to 55A, but I wouldn't use it anyway.   They don't make that breaker size, so you're free to either "round down" or "round up".     Code requires that you provision a subpanel feeder "sufficient for the load to be served", so you couldn't plan to use more than 55A.  The EV charging requires a 125% derate on the maximum current the EVSE will authorize, so 24A max programmed charge rate requires 30A provisioning, 30A wire and 30A breaker. So you would be counting on the dryer being <25A actual.
I wouldn't use it because you can get more suitable feeder for <1/2 the price, as manassehkatz discusses.  #2AL feeder is about the price of 10/3 Romex.  Large feeders work best as aluminum - long history has proven its reliability and economy (and the lugs you'll be attaching to will be aluminum). Part of its secret to success is electricians have always used torque wrenches to set large lugs. As far as stiffness, AL is about the stiffness of the next size smaller copper (so akin to #4 Cu).
90A will cover present and future EV charging to 60A+ your dryer simultaneously, and if you can avoid simultaneous dryer use (or certain tech solutions were are expecting soon), you can run 80 or 90A shared between two EVSE's, which is pretty much the "state of the art" for EV charging.
Comment: EV chargers with inputs for connecting current transformers have been a thing over here in the UK for a while, I'm kind of suprised you don't have them in north america yet.
Answer: Do consider future usage - the car several generations away might have 50A or more of charging capacity.
A future car might be capable of reverse-feeding your home at certain peak times of the day as part of load-shifting.
I would suggest exploring the possibility of a completely separate circuit just for charging cars, AND how much the opportunity cost is to ridiculously oversize that circuit.
None of us know what the next decades will hold in terms of vehicles and energy management in the home.  If the incremental cost to go up in capacity is small, it may be worth doing now.
Comment: Great points to consider. Will need to investigate further. I have a reservation for the new F-150 lightning, which advertises this capability, but I wasn't planning to order that option. Between this and other comments, I think I'm going to go all in on charging capability, which is really the whole point of this exercise anyway. My thought process has been "24A is plenty," mainly b/c I currently have a Model Y, and easily top it off every day with the standard 12A 120V cable that comes with the car. 24A is at least 4 times faster, but I know some newer platforms are already beyond that.
Comment: "Reservation for the F-150" + "I currently have a Model Y" which validates my hypothetical "2 chargers" line in my answer. Definitely put in big (e.g., 40A 240V) charger circuits for *both*. The electricity (OK, there are some exceptions with peak demand pricing, but EV charging is still a lot less load than on-demand water heating...) costs the same whether you load it up at 32 x 240 or 16 x 120 but you'll charge 4x as fast. Makes a big difference if you have decent size trips two days in a row.
Comment: Excellent points, but would probably be better as a comment.
Answer: First of all, if that dryer outlet was for a 220v only dryer, that configuration would be correct. They probably just only had that wire type available. You only need the neutral connected if there is a 120v requirement as part of your device. Otherwise 220v plus ground is all that outlet needed. And it would be absolutely correct to read 120v between each leg and ground. Remember that your neutral wire is grounded at your main panel in standard configuration, so with no current flowing they will measure about the same.
Now, about your car charger:

Don't use aluminum wire without knowing the code in your area.

If you don't NEED 90A, then you might not want to spend the money for 2/3 AWG.

IF 50A will do it for you (actual draw being 30A), just install your disconnect on the existing wire and connect a suitable outlet.

Remember, depending on how the chargers you will be using are configured, you might WANT to connect a 4 pin outlet, 2 of the pins being 220v "hot" with the white neutral connected to the 3rd pin and the real earth ground connected to pin 4 (with the notch). Otherwise, if your charger just calls for 220v and ground, it would be connected just as your predecessor had the outlet wired (with the white "neutral" wire not connected at either end).
Comment: I can tell you offhand that it'd be *utterly bizarre* for EVSE to require a neutral (the carmakers don't want to build a different model of EVSE for North America from the rest of the world!)


Why does appending my dynamic textarea to a div result in an empty textarea?

Question: I'm simply trying to edit a div named meta description inside of a div named post by taking the html and creating a textarea with it then plugging it back in. I have it working for the Title, content, and even meta keywords, but for some reason the description's textarea just keeps coming up empty in the end.
    //---------------edit meta Description------------
var Description = metaDescription;
Description.show();
//save the html within the div
var ogDescription = "None";
if (metaDescription.html()) {
    ogDescription = $(Description).html().trim();
}
console.log('ogDescription = ' + ogDescription);
// create a dynamic textarea
var editDescription = $("<textarea />");
editDescription.val(ogDescription);
console.log('editDescript val after adding === ' + editDescription.val());
console.log('editDescript html after adding === ' + editDescription.html());
editDescription.attr('class', 'editDescription')
            .css('height', metaHeight)
            .css('width', post.css('width'));
// add the textarea
Description.html("
meta Description:
");
$(Description).append(editDescription);
//--end edit meta Description

Output
Title = Newly Added Post
Posts.js:79 Content = Testing 1, 2, 3
Posts.js:105 ogDescription = Testing 1,2 and u know 3
Posts.js:110 editDescript val after adding === Testing 1,2 and u know 3
Posts.js:111 editDescript html after adding ===
Posts.js:129 Keywords = none, for, now
Description html after ===
meta Description:
<textarea class="editDescription" style="height: 80px; width: 262px;"></textarea>

Answer: Textarea doesn't have a value attribute. Unlike input, the "value" of textarea is the content between the beginning and end tags. You will need to set the innerHtml instead using .html("blah") or .text("blah")
See Set value of textarea in jQuery
Comment: Correct me if I am wrong, but the link you sent me to has the answer of "$("textarea#ExampleMessage").val(result.exampleMessage);" which is exactly what I am using "editDescription.val(ogDescription);"
Comment: Sorry, if you look further down, other responses go into more detail.
Comment: Are you able to inspect the element? Textarea should have an end tag. It is possible you created a custom attribute which is where the content is being stored
Comment: Thanks! By using .text() I get the right output "Description html after === meta Description:Testing 1,2 and u know 3"
Answer: Try to create the textarea as follows
var editDescription = $("<textarea>" + ogDescription + "</textarea>");


Help on an (another) SQL query

Question: Following my previous question.
I have a table named activity with 2 columns:
`when` as datetime // last time i saw a user
guid as varchar  // a unique identifier for each user

I have a query that returns how many new users I have for a given date and timespan:
 SET @till_date='2009-11-01'; #for today, give CURDATE()+1
 SET @duration=1; # this can be changed to 7, 31, etc
 SELECT COUNT(guid) AS total_new_users, DATE_SUB(@till_date, INTERVAL @duration DAY) AS since_date, @till_date AS till_date
 FROM `activity` WHERE 1
  AND `when` BETWEEN DATE_SUB(@till_date, INTERVAL @duration DAY) AND @till_date
  AND guid NOT IN
  (
   SELECT guid
   FROM `activity`
   WHERE `when` < DATE_SUB(@till_date, INTERVAL @duration DAY)
  )

I want to be able to build a query that will return a list of new users per date, for a given time span. It will be used to build a graph of new users per day for a month, week, etc.
Something like this:
total_new_users  |  since_date  |  till_date
----------------------------------------------
   10            |  2009-11-20  |  2009-11-21
   10            |  2009-11-21  |  2009-11-22
   10            |  2009-11-22  |  2009-11-23

I thought about using UNION with LOOP, but my SQL knowledge is pretty basic, help?

The result (thanks to @pilcrow):
SET @till_date='2009-11-15';
SET @since_date='2009-11-01';
SELECT first AS yyyymmdd,
   COUNT('x') AS new_user_count
FROM (SELECT guid,
             DATE(MIN(`when`)) AS first
      FROM activity
      GROUP BY 1) first_appearance
WHERE first BETWEEN @since_date AND @till_date
GROUP BY 1

Comment: Do you have the actual layout of the table?
Comment: @Suriit: yea, was in my previous question, added here as well.
Answer: Presuming SET SESSION sql_mode = 'ANSI_QUOTES':
SELECT first AS yyyymmdd,
       COUNT('x') AS new_user_count
FROM (SELECT guid,
             MIN("when") AS first
      FROM activity
      GROUP BY 1) first_appearance
WHERE first BETWEEN @since_date AND @till_date
GROUP BY 1

You may of course substitute your DATE_SUB() for @since_date, if you like.
Answer: SELECT
    COUNT(DISTINCT guid) AS total_new_users,
    DATE(when) AS since_date,
    DATE(DATE_ADD(when, INTERVAL 1 DAY)) AS till_date
FROM
    Activity
GROUP BY
    DATE(when)

Comment: @Suroot: your query returns the unique guids per day. but a "new user" is identified by showing up in that day, and not in any of the previous days. this is why i have the complicated query in my question.
Comment: @Suroot, see Am's linked question -- the dataset is more clearly articulated there.

Help on an (another) SQL query


Match @Input() with a defined list in Angular

Question: What is the best practice to check if a user input is in a whitelist of entries?
export class myClass {
  @Input() type: string;
}

To set type should be only possible if it is in a defined list, otherwhise it should be empty. Is there a common way with angular or typescript?
Comment: Use a private property to store the validated input. And take a look to getter and setter for validating your input.
Answer: Use a combination of a private instance field and a getter/setter for the @Input. Like this:
export class myClass {
    private validType: string;

    @Input()
    public set type(value: string) {
       if(this.validate(value)) {
          this.validType = type;
       } else {
          this.validType = '';
       }
    }

    public get type() {
       return this.validType;
    }

    private validate(value: string) {
       // do your validation here
       return true;
    }
}

This makes sure that everytime the input property changes, it's getting checked my a validation method (I used validate as a name for this example). And if you're using the type property you will always get the validated property validType.
If you're handling form inputs you should definitly define your own validator for such a task and apply it to the form fields.


UIImageView not displaying image when property is set too early

Question: I have an image I want to display inside a UIView. In Interface Builder, the UIView is the root and a UIImageView is its child.
The view is connected to view controller's view outlet, and the image view is connected to the image view outlet:
@property (nonatomic, retain) IBOutlet UIImageView *imageView;

If I try to set the image property of UIImageView before it's visible, the image doesn't show up.
TestView *testView = [[TestView alloc] initWithNibName:@"TestView" bundle:nil];
testview.imageView.image = [logos objectAtIndex:indexPath.row];
[self.navigationController pushViewController:testView animated:YES];

If, however, I pass the image to the controller and set the image property in viewDidLoad, the image becomes visible.
TestView *testView = [[TestView alloc] initWithNibName:@"TestView" bundle:nil];
testview.image = [logos objectAtIndex:indexPath.row];
[self.navigationController pushViewController:testView animated:YES];

- (void)viewDidLoad
{
    [super viewDidLoad];
    imageView.image = image;
}

What is causing the image to not show up in the first scenario?
Comment: there's something not clear (to me): TestView is (inherits from) UIView, right? But then how can you set its ".image" property in your code?
Comment: @meronix image is a property of my TestView class
Answer: The iOS documentation for a UIViewController's initWithNibName:bundle: method states that:

…
  The nib file you specify is not loaded right away. It is loaded the first time the view controller's view is accessed. If you want to perform additional initialization after the nib file is loaded, override the viewDidLoad method and perform your tasks there. …

A consequence of the nib/xib file not being loaded immediately (i.e. it uses so called lazy loading) means that the imageView IBOutlet property in your TestView controller is still nil when you try to set it in your first example.
In your second example you are setting it in the viewDidLoad which is called after the nib/xib file is loaded, and therefore it works as you expect.
Comment: I was definitely unaware that nibs are loaded lazily. Makes perfect sense now. Thank you.


Microsoft Graph: Organization User Details (Address Book) with Directory.AccessAsUser.All

Question: I am building an email client, attempting to perform a search against the Graph API users endpoint, similar to what was possible in Exchange Web Services via SOAP.
In EWS with ResolveNames, the server would return details (i.e. job title, office, phone, etc.) from only the authenticated user's organization scope similar to an address book search from an email client (i.e. OWA).
Using the Graph API (which based on what I have found is the recommended API for next generation O365 email apps) the user details return null:
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
  "businessPhones": [],
  "displayName": "John Smith",
  "givenName": "John",
  "jobTitle": null,
  "mail": "firstname.lastname@example.com",
  "mobilePhone": null,
  "officeLocation": null,
  "preferredLanguage": null,
  "surname": "Smith",
  "userPrincipalName": "firstname.lastname@example.com",
  "id": "xxxx"
}

I have requested the following scopes: User.Read, User.ReadBasic.All, Calendars.Read, Calendars.ReadWrite, Calendars.Read.Shared, Calendars.ReadWrite.Shared, Contacts.Read, Contacts.Read.Shared, People.Read
I have attempted several calls, but just a simple request for organization users demonstrates the issue:
https://graph.microsoft.com/v1.0/users
Based on the documentation, it looks like this information is only visible with Directory.AccessAsUser.All granted--an Admin level scope which is prohibitive\impractical for a general use application.
Is there a way to perform a simple address book search with limited user details using the Graph API without admin consent?  If not, is there another API or method I can use?  Or, does Microsoft have plans to extend the Users endpoint to include this basic information?
If the user is authenticated, it seems appropriate to allow an address book\GAL\user search.
Comment: What call are you making to retrieve the user information? Also, which scopes have you requested?
Comment: Thanks @MarcLaFleur-MSFT. I have updated the question with requested information.
Answer: The User.ReadBasic.All scope only provides access to a (no pun intended) basic set of user properties:

Allows the app to read a basic set of profile properties of other users in your organization on behalf of the signed-in user. This includes display name, first and last name, email address, open extensions and photo. Also allows the app to read the full profile of the signed-in user.

In order to read the complete set of user properties, you need (at a minimum) to request User.Read.All:

Allows the app to read the full set of profile properties, reports, and managers of other users in your organization, on behalf of the signed-in user.

This is a lot more restrictive scope than the Directory.AccessAsUser.All scope you mentioned, but it does require Admin Consent before normal users can consent to it. There is no mechanism for getting around the Admin Consent prerequisite.
Comment: Thanks again, Marc. I still stand by my assertion that access to these limited details should be available by virtue of authentication.  The same data is available by default through OWA (that is, it's already available to all authenticated O365 users, albeit with a MS application) and Admin Consent is quite prohibitive for third-party developers.  Is there a channel where I might communicate this with the Graph team?


Linking an Android library that is on local machine

Question: I have a set of utils and custom widgets that I want to pull out of my project as an Android library so that I can use them in other projects (and possibly share in the future).  I created a new Android Studio project and changed the build.gradle file so that 'com.android.application' was 'com.android.library' and deleted the applicationId.  It all compiles fine and I have a .aar file created.
I now want to use this new library as a module in my original project.  When I do an Import Project, all the files from the library project are copied into my original project.  But I don't want that because if I change the imported library code, it isn't reflected in the library project or vice versa.
I also tried adding this to settings.gradle:
include ':myutils'
project(':myutils').projectDir = new File(settingsDir, '../../../../Development/MyUtils/')

and in the original project app build.gradle:
dependencies {
    implementation project(':myutils')
...

But I get this error:
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :myutils.
Show Details
Affected Modules: app

How can I link the library to my project without importing it?  I would prefer not to go through an external maven repo yet.  I'm happy to (and would expect to) recompile my library whenever there is a change there and then rebuild my original project.
Thank you in advance.
Comment: Are you interested in using the aar file directly like this question? https://stackoverflow.com/q/16682847/8040697
Answer: I think I just had the same problem - I wanted to put the library .aar file somewhere on my local drive and then use it in a new app as a dependency. I didn't want to have to go through a repo or to include it in the libs folder in the new app. Hopefully that is what the OP asked and the following might be of help to others.
Searching on SO (Aug 2021), majority of answers seemed much more involved than what Android Studio offers (tested on version 4.2). That is, an .aar file that lives outside the app project can now be added as an implementation file in the gradle dependencies. So, it doesn't have to go through a repo, and it doesn't have to be included in the libs folder in the project.
The current documentation (Aug 2021) gives a fairly straightforward answer how to do it:
https://developer.android.com/studio/projects/android-library#psd-add-aar-jar-dependency
In short, if you have put your .aar file somewhere on your local drive, this is how to add it as an implementation file in another app project:

In Android Studio, in your new app project, go to: File > Project Structure > Dependencies.
In: Modules > app > Declared Dependencies, click '+' and select 'Jar Dependency'. (Even though you are trying to use an .aar file, you still select 'Jar Dependency').
In the 'Add Jar/Aar Dependency' popup dialog:

in step 1 enter the path to your .aar file on your local drive, and
in step 2 select 'implementation'.

If everything worked out, your build.gradle(Module) should have a line in the dependencies that looks like:
dependencies {
implementation files('../../../MyFolder/MyLibraryFile.aar')

A few notes:

You can actually just add the dependency manually, by typing it into the build.gradle(Module) dependencies, so you don't actually have to go through the Android Studio dialog outlined above.
you can either use a relative path (as the example above), or an absolute path.
the Android Studio dialog is somewhat limited in that you cannot just browse to your file (in point 3, step 1), but you have to actually enter the path manually.
Probably the most important: Whenever you make a change in the library and assemble a new .aar file, then remember to do the following in your app project that uses the .aar file as a dependency: Clean Project, then Sync Project with Gradle Files, and only then run the app, so that the changes in the library could take effect in your app.
Answer: I have been using Phgr's above technique for four years. I have three comments -
First, I don't clean the app project each time I change the library - I just do a Sync Project before building and testing the app.
Second, I changed the File-Settings-Keymap-Main Menu-File-Sync to Alt-S for easy of syncing - I hate wasting time using the mouse for selecting the Sync icon.
Third, I have an implementation line in the app's build module file for each app variant such as the following -
debugImplementation files('c:/Android Studio Projects/PciLibrary/app/build/outputs/aar/PciLibrary-debug.aar')
releaseImplementation files('c:/Android Studio Projects/PciLibrary/app/build/outputs/aar/PciLibrary-release.aar')

All of this is working fine with Android Studio 4.2.2 and sdk version 30.
Hope this helps others with this problem


Initialize value of a text field in a form created by ng-repeat

Question: I have created one form using ng-repeat. How should I initialize value of a text box ?. I have tested with ng-init
    ng-init="data.item.rate[$index]=10" and this is working
But I want to initialize with value in items as  ng-init="data.item.rate[$index]={{item.rate}}" but this code not working
<ion-list id="item_list" ng-repeat="item in items track by $index">

<input   type="text" id="rate_{{ $index }}" name="rate_{{ $index }}" ng-model="data.item.rate[$index]" ng-init="data.item.rate[$index]={{item.rate}}">

</ion-list>

Answer: Not use brackets ({{}}) in ng-init.
<ion-list id="item_list" ng-repeat="item in items track by $index">
   <input   type="text" id="rate_{{ $index }}" name="rate_{{ $index }}" ng-model="data.item.rate[$index]" ng-init="data.item.rate[$index]=item.rate">
</ion-list>

Comment: Thanks for the help


How to read the database table name of a Model instance?

Question: Given a model's instance object, how can I get the database table's name?
I don't want to specify names explicitly in the Meta class.
Answer: Found the answer myself: the _meta attribute of an instance has the information:
<code>model_instance._meta.db_table
</code>
Comment: @Alex-Bogdanov: the `_meta` property is not protected. It is a documented part of the public API. It is prefixed with the leading underscore to avoid conflicts with names that people may actually want to use on their models.
Comment: If you would like to, create a property method to return it...

`@property`
    `def table_name(self):`
        `return self._meta.db_table`
Comment: this is quite weird that Model's table name accessible from protected attribute `_meta::Options`


A question about the proof of Godel's Incompleteness Theorem

Question: The article A Computability Proof of Gödel's First Incompleteness Theorem, by Jørgen Veisdal on Cantor's Paradise contains the following passage:

The second property regards the complement of a set $E$, that is, all the strings which are not in set $E$. First, notice that if $E$ is decidable, so is the complement of $E$ (we can construct a set $F$ of all the strings that are shown to not belong to $E$). As such, if the set $E$ can be constructed by a mechanical process (is computably enumerable), so too must its complement.

If a set $E$ is enumerable, why does its complement also have to be enumerable? What if its complement is infinite? Moreover, if a set $E$ is decidable, why does its complement have to be decidable?
Comment: Recursively enumerable and decidable are **not** the same.
Comment: The text above says: if E is **decidable** (and thus "computably" enumerable) also its complement is decidable. IF $E$ is decidable, both $E$ and its complement $E^c$ are enumerable. But then, we have that $E^c$ and $(E^c)^c=E$ are both enumerable; thus, also $E^c$ is decidable.
Comment: It is a basic result of [Computability theory](https://en.wikipedia.org/wiki/Recursive_set#Properties) that : A set A is a recursive (i.e. *decidable*) set if and only if A and the complement of A are both recursively enumerable sets.
Comment: Instead of posting screenshots of text, please take the time to type out the quote you're asking about, and provide a reference to the source you're reading. This time, I tracked down the article and replaced the image with text for you.
Comment: @AlexKruckman- Thanks for typing the text. I'll keep this in mind in the future.
Answer: Decidable means there's a decision procedure for determining whether an element is in the set or not. By symmetry, this holds for the complement too: we can determine whether the element is not in the set or not.
However, it is false that the complement of a computably enumerable set is computably enumerable. In fact, this fact is very important to Gödel's theorem: one example of such a set is the set of all Gödel numbers of theorems. (Another famous one is the halting set.)
If a set $S$ is computably enumerable and so is its complement, then it is decidable, since we can decide if $x$ is in $X$ by enumerating both $S$ and it complement and seeing which list $x$ appears in. The converse is clearly true as well, so one characterization of decidable sets is those that are c.e. and whose complements are also c.e.
Comment: Ah I see. I thought that the complement being decidable meant that we could see if the complement of a string was in a set or not.


Dualshock4 keeps disconnecting from Windows 10

Question: I have a new PC with an ASUS TUF X570-Pro (Wi-Fi) motherboard, which has Bluetooth. I have the Wi-Fi/Bluetooth antenna connected and sitting on my desk about two feet from me.
For the last couple of weeks I have been playing games with a DualShock 4 v2, flawlessly. But starting last night, whenever I connect the controller, it disconnects within two or three seconds, and reverts to "Paired" instead of "Connected" in Bluetooth settings. Pressing the PS button reconnects the controller, but only for those two or three seconds.
If I'm in Steam Big Picture Mode, I can sometimes move the cursor one or two items before the controller disconnects, so it is working during those seconds.
The only other thing I can note is that right before it disconnects, the light on the controller flashes bright blue, then goes out. I don't know if that bright blue is the color I've assigned it through Steam, because it won't stay connected long enough for me to check.
Deleting and re-pairing the device, rebooting between pairings, doesn't help; I've done it several times. I didn't change anything else last night when this started. What could be causing this?
Comment: I'm voting to close as "needs more info" because we don't know what model of controller it is (DS4 v1 and v2 work slightly differently) and Bluetooth dongle and/or chipset (the DS4 is a bit sensitive when it comes to data transmission over BT).
Comment: What Bluetooth dongle are you using?
Answer: When this would happen to me, I would go into my bluetooth settings, scroll down until I see "Wireless Controller" and remove the device. I would then reconnect by holding the menu and share buttons on the DS4 controller for 10 seconds until the light starts flashing rapidly. Click "Add Bluetooth or other device" in the settings, then "Bluetooth" and your device should appear. Once connected hopefully it will not disconnect again.
Answer: Remove wireless controller from audio in "Bluetooth & other devices" on show Bluetooth devices, and reconnect again
Answer: Same problem happend to me after i installed Star Wars The Force Unleashed 2. Game was unplayable until i remove controller. When i tried to reconnect controller problem same as urs occured. Answer above me suggested something and it helped me, so:

Go to devices and printers in control panel.
Remove Wireless controller
Connect controller with pc
In devices and printers very fast remove device x360 controller (or sth like that), before controller got disconnected.

I think SW TFU2 installed another driver for controller (xbox) and windows tried to install 2 different drivers in same time for one device.


Introducing a Facebook Login

Question: Currently we have a site that uses basic site login using a username and password that is stored on the server.  Our client wants to introduce Facebook login alongside the current site login.
Concerns are:
If a user already has a 'site' account then decides to signup with Facebook then we can match the two up if the email is the same (as would be the case in most scenarios) - The problem is introduced when the user has a different email for their Facebook account / site account.  This would then leave the user with two accounts and could potentially lead to issues (users earn points for each purchase).
Has anyone had any experience with this and if so what are the pitfalls to avoid / best practice for dealing with this.
Comment: Give them an opportunity to link/merge both accounts. For example after signing in for the first time via face book. Or make something like "search for old account" for those "facebook" users that you couldn't automaticaly match.
Comment: As an example, [rememberthemilk.com](http://blog.rememberthemilk.com/2010/11/sign-into-remember-the-milk-with-your-google-account/) have provided an ability to associate a Google account with an existing website account so you can sign in with either account.
Comment: Thanks guys- this seems like the logical approach, it will be interesting to see the results.  We will just have to make everything very clear for them.
Comment: yes i have faced an issue in similar way, we had to open both account for user to login and thus internally merging the same with system account. we have not got any problem as of now. I cannot post link as it am not allowed.
Answer: We faced the same conundrum a year or so ago. This was my simple version of the Facebook Connect Login flows. The happy path in bold is for brand new members. What's not pictured, and is the crux of your question is at the bottom-right: when they log in, the system matches their login to their new FB userID key. [Note, the site we were working on is called Shoptopia.]
We created this flow before Facebook expanded the permissions they allow you to ask (email address, for one). So, were we to draft this today, we would tell users if we found an existing account to match up with, and if not, would ask them to also "log in" to match up accounts.
Answer: If you let the users who already have an account connect through Facebook, just merge the data. How does having a separate email affect that. Every user should have an ID in the database.
Make separate columns in the user table for Facebook: facebookemail, facebookid, etc..
Write a cookie to the browser with the user id and then when they connect through Facebook and come back to your site, save the facebook fields to the user table with the record that has the ID stored in the cookie.
The page that catches the user after the facebook connect can check to see if the user already has Facebook fields stored in their user table, if not, add the fields, if so, skip it and just log them in.
I guess at that point, the email doesn't really matter. You'll have two. I guess you can go a step further and display both emails and ask the user which one they want to use.
Comment: You have no way of matching one email to the other just by Facebook uid, because the fbuid is only tied to one email address. They would have to manually login after connecting, or connect after logging in to make the merge. Which is fine, but you need to name that step.

Introducing a Facebook Login


Binary tree , Where am I wrong?

Question: Well this seems to be wrong somewhere ,  maybe memory allocation or pointers(most likely) , what am i doing wrong?
I get the error when i am creating a new node except the first node.The error is not clear.
Thanks
#include <stdio.h>
#include <stdlib.h>

struct binary_tree{
    int data;
    struct binary_tree *leftnode;
    struct binary_tree *rightnode;
};

void create_node(struct binary_tree *node , int input)
{
    struct binary_tree *new_node;

    new_node = (struct binary_tree *)malloc(sizeof(struct binary_tree));

    new_node->data      = input;
    new_node->leftnode  = NULL;
    new_node->rightnode = NULL;

    node = new_node;
}

void LNR_traversal(struct binary_tree *node)
{
    while(!(node->leftnode== NULL && node ->rightnode==NULL))
    {
        if(node->leftnode!=NULL)
            LNR_traversal(node->leftnode);
        printf("%d",node->data);
        if(node->rightnode!=NULL)
            LNR_traversal(node->rightnode);
    }

}

int main()
{
    int i;
    int input;

    struct binary_tree *start;
    struct binary_tree *node;

    printf("Data:");
    scanf("%d",&input);
    create_node(start,input);

    //node = start;

    printf("\nDATA:");
    scanf("%d",&input);

    while(input!=-1)
    {
        node = start;

        if(node->leftnode == NULL){
            create_node(node->leftnode,input);
            printf("1");
        }
        else if(node->rightnode == NULL)
            create_node(node->rightnode,input);
        else if(node->leftnode != NULL && node->rightnode!=NULL){
            node = node->leftnode;
            node = node->rightnode;
        }
        printf("\nDATA:");
        scanf("%d",&input);
    }
    node=start;

    LNR_traversal(start);
    return 0;
}

Comment: What error? Care to elaborate?
Comment: and what is the error?
Comment: Well , i dont seem to know that , I use command line to compile and run C programs! Sorry! :)
Comment: @AmritRajVardhan What is the expected output? What output you are getting? Do you think *elaborating this* has anything to do with you being using command line to run `c` programs?
Comment: Please copy-and-paste the actual and complete output from the compiler and linker, and edit your question to show it. *If* you get build error that is. If you *don't* get build errors, then say so. If you get unexpected results then tell us what you get and what you expected. If you get runtime errors (i.e. crashes) then run in a debugger to locate the crash in your code.
Please [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask).
Comment: Assigning `node->rightnode` to `node` just after assigning `node->leftnode` to `node` seems not what you want.
Comment: This is my question : Is the binary tree sorted or not?
Comment: @rootkea  , well sorry  , i'll try to be more clear next time , noob here , first question in Stack Overflow :), Yes it has a runtime error
Comment: Implementing this program sorted is easier and better
Comment: @MikeCAT Thanks for pointing that out , definitely not what i want!
Comment: @JoachimPileborg Thanks for the clear explanation of how to use Stack Overflow :) , noob here
Answer: On function call in C, arguments are passed by value. It means the parameters are copied as arguments, so modifying arguments in callee won't affect variables in caller.
Use pointers to modify caller's local variables in callee.
In this case, I think returning allocated node from create_node() and having the caller assign the return value is better than using pointers to modify variables.
Answer: The problem relies in your create_node function.
Code :
struct binary_tree *new_node;

new_node = (struct binary_tree *)malloc(sizeof(struct binary_tree));
if ( node ==NULL ) {
    new_node->data      = input;
    new_node->leftnode  = NULL;
    new_node->rightnode = NULL;

    node = new_node;
}
else if (input < node->data) {
    create_node(node->left,input);
}
else {
    create_node(node->right,input);
}
}

Actually this is for Binary Sorted Tree
This way when you want to add something to tree just use :
create_node(root_node,value);

Comment: "Only the root node is allocated."  Yes, if the undefined behavior (using uninitialized auto variable) `node->leftnode == NULL` cause termination of the program.
Comment: This way in your main fucntion just initialize root node and then when you want to add node just call create_node with root as argument

Binary tree , Where am I wrong?


How to know when a user leave my website

Question: Please i am trying to track users on my asp.net application, i want to know when a user leaves my web application either by using the log-out button or close the webpage totally.
Please any clue on what to do
Comment: The log-out button should be obvious of what you need to do
Answer: You use onbeforeunload event for this.
See this demo.
Comment: I'm curious if you can send an AJAX call to record this on a server. Wouldn't the page unload so far that this would be impossible?
Comment: You mean so "fast"? I haven't actually tried logging everything but if it is not possible because the request will be cut off immediately, I am sure there are workarounds. Like saving in localstorage first and doing the request on next visit but this would require a revisit.
Comment: This solution is okay, but when i click a page on my website it popup the message which made it not suitable for my purpose


rename command Debian server

Question: The following worked on my old server (Ubuntu)
rename -n 's/(.*)\/.*\./$1\/$1./' */*

but not on my new server (Debian).
I'm guessing the new server is using the Perl rename. How would one convert the above to work the same with Perl rename? All it was meant to do is rename files in a folder so that the name starts with the name of the parent folder (removing any name before the last dot in the original filename).  Thus, include/anything.h would become include/include.h.
Comment: [so] is for programming questions, not questions about using or configuring Unix and its utilities. [unix.se] or [su] would be better places for questions like this.
Answer: The rename command that is part of the util-linux package, won't work.
You need to run :
# apt install rename

If you run the following command (GNU)
$ file "$(readlink -f "$(type -p rename)")"

and you have a result that contains Perl script, ASCII text executable and not containing ELF, then this seems to be the right tool =)
If not, to make it the default (usually already the case) on Debian and derivative like Ubuntu :
# update-alternatives --set rename /usr/bin/file-rename

Comment: which means: if you port or maintain a DEB package, _and this package indeed uses `rename`,_ you should add the 'rename' package to its build-dependencies (starting with Debian/Buster). This will also automatically ensure the `update-alternatives` is performed

rename command Debian server


Removing display of row names from data frame

Question: I am creating a dataframe using this code:
df <- data.frame(dbGetQuery(con, paste('select * from test')))

Which results in this:
    UID      BuildingCode   AccessTime
1   123456   BUILD-1        2014-06-16 07:00:00
2   364952   BUILD-2        2014-06-15 08:00:00
3    95865   BUILD-1        2014-06-06 09:50:00

I am then trying to remove the row names (1, 2, 3, etc) as suggested here by using this code:
rownames(df) <- NULL

But then when I print out df it still displays the row names. Is there a way to not include the row names when creating the data frame? I found a suggestion about row.name = FALSE but when I tried it I just got errors (I might have placed it in the wrong place).
EDIT: What I want to do is convert the dateframe to a HTML table and I don't want the row name to be present in the table.
Comment: so just `print(df, row.names = F)` should do
Comment: It is not clear what you mean by "when I print out df". Is `row.names = FALSE` in `write.table` relevant?
Comment: @Henrik probably offers the best solution here. I wonder though why doing something like `attributes(df)$row.names <- NULL` erases all values form df
Comment: What I mean by "when I print out df" is I type `df` into the terminal which then prints out the data frame. I don't have `write.table` because I'm not writing a table (and when I do I'm going to be using xtable).
Comment: @DavidArenburg your correct, that works! But how would I put that into a html table?
Answer: You have successfully removed the row names. The print.data.frame method just shows the row numbers if no row names are present.
df1 <- data.frame(values = rnorm(3), group = letters[1:3],
                  row.names = paste0("RowName", 1:3))
print(df1)
#            values group
#RowName1 -1.469809     a
#RowName2 -1.164943     b
#RowName3  0.899430     c

rownames(df1) <- NULL
print(df1)
#     values group
#1 -1.469809     a
#2 -1.164943     b
#3  0.899430     c

You can suppress printing the row names and numbers in print.data.frame with the argument row.names as FALSE.
print(df1, row.names = FALSE)
#     values group
# -1.4345829     d
#  0.2182768     e
# -0.2855440     f

Edit: As written in the comments, you want to convert this to HTML. From the xtable and print.xtable documentation, you can see that the argument include.rownames will do the trick.
library("xtable")
print(xtable(df1), type="html", include.rownames = FALSE)
#
#
#

#
  values 	  group

#
  -0.34 	  a

#
  -1.04 	  b

#
  -0.48 	  c

#

Comment: After doing as I said above, when I do `attributes(df)` I get this result: `$row.names [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15`. Does this not indicate that the row names are still there? Basically what I want to do is convert the DF to a HTML table and I just don't want the row name to be present.
Comment: @DomAbbott From the R docs, a `data.frame` is "is a `list` of variables of the same number of rows with unique row names, given class '`data.frame`'. If no variables are included, the row names determine the number of rows." Hence row names are always present in the attributes. How do you do your conversion?
Comment: What do you mean by conversion? I am using this code to create a html table `print(xtable(df), type="html", file="example.html")` but this includes the row names.
Comment: @DomAbbott add this comment to your post, so we know what you are trying to accomplish.
Comment: @DomAbbott I've edited so you get what you want. You need to use the `include.rownames` argument.
Answer: Yes I know it is over half a year later and a tad late, BUT
row.names(df) <- NULL

does work. For me at least :-)
And if you have important information in row.names like dates for example, what I do is just :
df$Dates <- as.Date(row.names(df))

This will add a new column on the end but if you want it at the beginning of your data frame
df <- df[,c(7,1,2,3,4,5,6,...)]

Hope this helps those from Google :)
Answer: If you want to format your table via kable, you can use row.names = F
kable(df, row.names = F)

Answer: A dplyr solution :
df = df %>% `rownames<-`( NULL )

Comment: This isn't a "dplyr solution". If anything it's a magrittr solution. But a much simpler solution would be to just call rownames(df) <- NULL.
Comment: See https://stackoverflow.com/a/72318941/8806649 for `tidyverse` solution
Answer: ...or simply:
library(tidyverse)

df_data_with_rownames %>%
SOME STUFF %>%
tibble::remove_rownames() -> wrangled_df_data_without_rownames

Answer: Recently I had the same problem when using htmlTable() ('htmlTable' package) and I found a simpler solution: convert the data frame to a matrix with as.matrix():
htmlTable(as.matrix(df))

And be sure that the rownames are just indices. as.matrix() conservs the same columnames. That's it.
UPDATE
Following the comment of @DMR, I did't notice that htmlTable() has the parameter rnames = FALSE for cases like this. So a better answer would be:
htmlTable(df, rnames = FALSE)

Comment: htmlTable has the ```rnames``` parameter for this:

```htmlTable(df, rnames = FALSE)```
Answer: My answer is intended for comment though but since i havent got enough reputation, i think it will still be relevant as an answer and help some one.
I find datatable in library DT robust to handle rownames, and columnames
Library DT
datatable(df, rownames = FALSE)  # no row names

refer to https://rstudio.github.io/DT/ for usage scenarios
Answer: Another simple way is assigning c() to your rownames to get rid of your row names like this (thanks @Anders for data):
df <- data.frame(values = rnorm(3), group = letters[1:3],
                  row.names = paste0("RowName", 1:3))
df
#>             values group
#> RowName1 0.4189236     a
#> RowName2 1.8604397     b
#> RowName3 0.7030387     c
rownames(df) <- c()
print(df)
#>      values group
#> 1 0.4189236     a
#> 2 1.8604397     b
#> 3 0.7030387     c

Created on 2022-07-09 by the reprex package (v2.0.1)
Answer: I just wanted to add that data.table has an option for removing rownames when printing data.table's.
options(datatable.print.rownames = F)
This solved my problem in the console and when rendering RMarkdown files. See other printing options here
Answer: simply try rownames(df) <- ""


Can the water stains in this hardwood floor be sanded out?

Question: Do you think sanding will be able to take out these water marks, or do the boards need to be replaced? The water damage is old (prior to the previous owner, so at least 12 years) and the floor is possibly heart pine (definitely soft). I plan to sand & refinish the whole 2nd floor.
Thanks!
Comment: What was the source of the previous damage? Did they lay carpet over the hardwood? Does the house have humidity issues? Is the floor warped/uneven in addition to being water-damaged?
Comment: What is the age of the house and of the floor?
Comment: Age of house: built 1910. Source of damage: No idea the because it is from 2 owners ago (I just moved in) but there is a skylight above that hallway that seems like the likely culprit. The wood is not at all warped or uneven. The basement has humidity and I run a dehumidifier there, but this is the 2nd floor and I haven't noticed that extend upward.   @isherwood I'm looking for feedback on how to go about this.. if you don't think you can be helpful not replying is better.
Comment: I think I see a cut off nail in one of those stains. Are there cut off nails in some of the stains? Could be "iron staining."
Comment: After the floor is sanded down to bare wood, just before the last cut is made, treat the spots with oxalic acid. It may remove all of the stains, or get it so it will look acceptable. The rest will sand out. Use it only on the gray areas.
Answer: If it were me, I would get a chisel and knock out just one flooring strip. Preferably one of the most damaged strips, and preferably from the edge like under the quarter round. Pull it up and actually test sanding it with an orbital or even just by hand. See how much material you need to remove and consider the final thickness of the flooring - if it's already had three or four rounds of sanding and you're down to the tongues and grooves, it's time for a new floor! If you decide to move forward with a sanding, you can just apply a poly construction adhesive and lay it back down (it will be annoying to remove when it finally is time for a new floor, so others may disagree) or you can face nail it back and try to use a wax filler over the nailheads.
Comment: That's helpful thank you!


Export-Csv end with blank sheet

Question: I wrote script to get directory, filename, and count of lines, but when I exported to CSV I end with null sheet. What am doing wrong?
Here is the code I wrote:
Get-ChildItem C:\Users\bi\Desktop\MOMO_FILES -Include *.txt -Recurse
$result = % {
  $_ | select CreationTime, DirectoryName, name, @{n="lines";e={
    Get-Content $_ | Measure-Object -Line | select -expa lines
  }}
 }
 $result | Export-Csv C:\Users\bi\Desktop\filename.csv -NoTypeInformation

Answer: Your issue is that you are not incorporating the Get-ChildItem part in to your pipeline. You need to do this:
$result = get-childitem C:\Users\bi\Desktop\MOMO_FILES -Include *.txt -recurse  | % { $_ | select CreationTime, DirectoryName,name, @{n="lines";e={
   get-content $_ |
     measure-object -line |
         select -expa lines }
   }
}
$result | Export-csv C:\Users\bi\Desktop\filename.csv -NoTypeInformation

Or if you want it to be a little less horizontal, send the Get-ChildItem result to a variable and use that:
$files = get-childitem C:\Users\bi\Desktop\MOMO_FILES -Include *.txt -recurse
$result = $files | % { $_ | select CreationTime, DirectoryName,name, @{n="lines";e={
   get-content $_ |
     measure-object -line |
         select -expa lines }
   }
}
$result | Export-csv C:\Users\bi\Desktop\filename.csv -NoTypeInformation

Export-Csv end with blank sheet


Why does cmd cant run the python file on desktop, it keeps on showing "[Errno 2] No such file or directory"

Question: So basically the file is on the desktop/pythonBot folder, but the cmd cant open it up? The code I type in is python bot.py. I followed this dude's guide here:
https://www.smartspate.com/how-to-create-a-telegram-bot-with-ai-in-30-lines-of-code-in-python/
(Sorry I am just a senior high student with no coding background)
Comment: How about you show us your code?
Answer: It looks like you are not in the correct directory, us cd to navigate to desktop/pythonBot or alternatively, use the full path when running the file.
Comment: cmd is searching  for "bot.py" file in C:\Users\s9800 directory.From error i can guess your bot.py file is in another direcotry.Provide full of .py file(open cmd,drag and drop .py file to cmd and press enter)
Answer: From screenshot i guessed you have .py in another directory.
cmd is searching for "bot.py" file in C:\Users\s9800 directory.From error i can guess your bot.py file is in another direcotry.Provide full of .py file

How to run .py file

1st way :open cmd,drag and drop .py file to cmd and press enter
2nd way:Go to directory where your .py file is.Wrtie "cmd" in address bar ,it will open cmd ,type file name and press enter.


CSS tooltip not showing

Question: I have the following code and I can´t figure out why the tooltip is not showing!
I tried this css on a static table and it is working!
In the code the table is built from information of an array with the headers, and the data come from an associative array.
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Json Array to Html Table</title>

What is wrong about the code?
Regards,
Elio Fernandes
Comment: Are you seeing any errors in the console?
Comment: Its better to use bootstrap tooltip !
Comment: No errors in the console!
Answer: It was binding issue. you created bind event before element really created on DOM.

$(document).ready(function(){
        // Table Headers
        var headers = ["S", "M", "T", "W", "T", "F", "S"];

        // Json Array
        var myData = [
             {"Date":"25/12/2016", "MonthName":"January","DataDiff":"7","MonthDays":"31"},
             {"Date":"29/01/2017", "MonthName":"February","DataDiff":"3","MonthDays":"28"},
             {"Date":"26/02/2017", "MonthName":"March","DataDiff":"3","MonthDays":"31"},
             {"Date":"26/03/2017", "MonthName":"April","DataDiff":"6","MonthDays":"30"}
            ];

        // Create Table
        var cityTable = makeTable_HeadersOnly($('#tblContainer'), headers, "Planner", 6 );

        // Append data from Json array
        appendTableRowsJsonFile(cityTable, myData);
    });

    // Make Table just with headers
    function makeTable_HeadersOnly(container, data, id, nrTimes) {
        var table = $('
');
        var row   = $('
');

        row.append($('
'));

        // First Column
        row.append($('').text(""));

        // Generates the columns
        for (i=1; i <= nrTimes; i++) {
            $.each(data, function(colIndex, c) {
                row.append($("").text(c));
            });
        }
        table.append(row);

        // tbody
        row   = $('
');
        table.append(row);

        return container.append(table);
    }

    // append table row from json file
    function appendTableRowsJsonFile($table, jdata) {
        var day = 1;
        var diff = 0;
        var daysMth = 0;
        var data = "";
        $.each(jdata, function(key, value){
            // Month
            let tr = $("
");
            tr.append($("").text(value.MonthName));

            // Fill days
            diff = parseInt(value.DataDiff);
            daysMth = parseInt(value.MonthDays);
            for (i = 1; i <= 42; i++) {
                if (i <= diff ){
                    tr.append($("").text(''));
                } else if (i <= diff + daysMth) {
                    day = i - diff;
                    tr.append($('').text(day));
                } else{
                    tr.append($("").text(''));
                }
            }
            $table.find('tbody').last().append(tr);
        });
         bindhover();
    }
function bindhover() {
          // Tooltip - class 'day'
          $('.day').unbind();
          $('.day').bind({
              mouseenter: function (e) {
                  title = $(this).attr('data-date');
                  $(this).append('' + title + '');
              },
              function (e) {
                  $('span', this).remove();
              }
          });
      }
.day {
            position: relative;
        }

        .day .tooltiptext {
            visibility: hidden;
            width: 120px;
            background-color: #555;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px 0;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            margin-left: -60px;
            opacity: 0;
            transition: opacity 1s;
        }

        .day .tooltiptext::after {
            content: "";
            position: absolute;
            top: 100%;
            left: 50%;
            margin-left: -5px;
            border-width: 5px;
            border-style: solid;
            border-color: #555 transparent transparent transparent;
        }

        .day:hover .tooltiptext {
            visibility: visible;
            opacity: 1;
        }

Comment: Rush. It's working fine. I almost got crazy! Thanks. How did you find that was a binding issue?
Comment: :) ... Experience bro ... you will also get this after few more tasks ... Good Luck .... :)

CSS tooltip not showing


Learning how to buy Runes

Question: I'm a little insecure about buy runes. Runes costs a lot of IP, so I'm researching a bit before.
I know that I need to be in level 20 to buy the best/final runes.
1) I need buying only "Greater" runes. Am I correct?
2) How do I know if a rune is "primary"?
3) By example, let's say that I want to buy Cooldown Reduction (CDR) runes. I found out that I will need Focus and/or Celerity runes.
Celerity has Glyphs and Quintessences. Focus has Glyphs, Quintessences, Marks and Seals. It's implies I can (If I want) fill an entire rune page with CDR Runes? What an efficient buy of CDR Runes, considering that I want buy Magic Penetration and Mana Regen Runes too?
4) I've got the runes list here, but it presents ALL runes, so is really boring to check that list. There is some list/table where we can check only "primary" and "greater" runes?
Thanks!
Answer: I highly suggest you use this link: http://www.mobafire.com/league-of-legends/build/rune-tips-what-secondary-and-primary-means-and-more-24255
It helped me immensely on my runes choices. It also ranks runes within what is good or bad (Based on the stat you get vs gold cost). As long you get S to A range runes you're good, mix and match based on your tastes. Each champ can honestly have a rune page devoted to them alone. If you notice the S to A range is A LOT of choices still and he suggests basic runes for anyone.
Mine are:
AD Carry
AD Red
HP Per Level Yellows
MR Blues
AD Quints
AP Carry
MrP Reds
HP per Level Yellows
AP Blues
AP Quints
Tank
AS Reds (For jungling)
Armor Yellows
MR or AP Blues
Movement Speed Quints
UPDATE: Also the CDR runes are INSANELY EXPENSIVE. So if you want them, save for them but getting a full blue set is like 6300 IP. I still don't have CDR blues and I've been playing for years and have 50% of all champions in the game.
Answer: 1) yes.
2) check on the list you posted.
3) magicpen red, manareg / level yellow (since they get better than the flats at lvl 7) and CDR blue. Quints depend on your role and character aswell as your laning opponent. For you playing an AP Carry, you could take AP. If you are support you could take gold/10.
And yes, you could fill an entire rune page with cdr.
4) The list you presented already gives you the sorted informations you are asking for. Sorted by primary and greater runes, so exactly what you are asking for. Yes, you have to put in an effort of <5 minutes for planing a runepage.

Learning how to buy Runes