Decrease the width of DatePicker in UWP XAML

Question: What is the right way to set the width on the DatePicker element?
I tried:
<DatePicker x:Name="birthDatePicker" Width="200" Header="Date of birth"/>

Which lead to the date picker button cutoff:
Answer: I can reproduce your issue, you could put the DatePicker inside Viewbox control and set the MaxHeight and Maxwidth property of ViewBox to resolve this issue.
As follows:
<Viewbox MaxHeight="50" MaxWidth="100">
      <DatePicker x:Name="birthDatePicker1" />
</Viewbox>

Update:
You could set the Stretch property to Fill, then you could adjust the height and width of DatePicker according the MaxHeight and MaxWidth properties of Viewbox. As for the font size, you could change the FontSize property of DatePicker directly.
<Viewbox MaxHeight="40" MaxWidth="200" HorizontalAlignment="Left" Stretch="Fill">
            <DatePicker x:Name="birthDatePicker1" FontSize="20" />
</Viewbox>

Comment: This works. But, it scales down the entire element including font size and the height of the date picker.
Comment: @gunturumahesh I have updated my answer, please try it.
Answer: A bit long, but this is the DatePicker template, I added a desired width in the grid I called "TheGridIChanged" in line 21.
add it to <Page.Resources> </Page.Resources>
and add to the DatePicker: Style="{StaticResource DatePickerStyle1}"

                        </Grid.Resources>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource DatePickerHeaderForegroundDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstPickerSpacing" Storyboard.TargetProperty="Fill">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource DatePickerSpacerFillDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SecondPickerSpacing" Storyboard.TargetProperty="Fill">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource DatePickerSpacerFillDisabled}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="HasDateStates">
                                <VisualState x:Name="HasDate"/>
                                <VisualState x:Name="HasNoDate">
                                    <VisualState.Setters>
                                        <Setter Target="DayTextBlock.Foreground" Value="{ThemeResource TextControlPlaceholderForeground}"/>
                                        <Setter Target="MonthTextBlock.Foreground" Value="{ThemeResource TextControlPlaceholderForeground}"/>
                                        <Setter Target="YearTextBlock.Foreground" Value="{ThemeResource TextControlPlaceholderForeground}"/>
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter x:Name="HeaderContentPresenter" AutomationProperties.AccessibilityView="Raw" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Foreground="{ThemeResource DatePickerHeaderForeground}" HorizontalAlignment="Stretch" Margin="{ThemeResource DatePickerTopHeaderMargin}" MaxWidth="{ThemeResource DatePickerThemeMaxWidth}" Grid.Row="0" TextWrapping="Wrap" VerticalAlignment="Top" Visibility="Collapsed"/>
                        <Button x:Name="FlyoutButton" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" IsEnabled="{TemplateBinding IsEnabled}" MinWidth="{StaticResource DatePickerThemeMinWidth}" MaxWidth="{StaticResource DatePickerThemeMaxWidth}" Grid.Row="1" Style="{StaticResource DatePickerFlyoutButtonStyle}" UseSystemFocusVisuals="{TemplateBinding UseSystemFocusVisuals}" VerticalAlignment="Top">
                            <Grid x:Name="FlyoutButtonContentGrid">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition x:Name="DayColumn" Width="78*"/>
                                    <ColumnDefinition x:Name="FirstSpacerColumn" Width="Auto"/>
                                    <ColumnDefinition x:Name="MonthColumn" Width="132*"/>
                                    <ColumnDefinition x:Name="SecondSpacerColumn" Width="Auto"/>
                                    <ColumnDefinition x:Name="YearColumn" Width="78*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock x:Name="DayTextBlock" AutomationProperties.AccessibilityView="Raw" FontWeight="{TemplateBinding FontWeight}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" Padding="{ThemeResource DatePickerFlyoutPresenterItemPadding}" Text="Day" TextAlignment="Center"/>
                                <TextBlock x:Name="MonthTextBlock" AutomationProperties.AccessibilityView="Raw" FontWeight="{TemplateBinding FontWeight}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" Margin="1,0,0,0" Padding="{ThemeResource DatePickerFlyoutPresenterMonthPadding}" Text="Month" TextAlignment="Left"/>
                                <TextBlock x:Name="YearTextBlock" AutomationProperties.AccessibilityView="Raw" FontWeight="{TemplateBinding FontWeight}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" Padding="{ThemeResource DatePickerFlyoutPresenterItemPadding}" Text="Year" TextAlignment="Center"/>
                                <Rectangle x:Name="FirstPickerSpacing" Grid.Column="1" Fill="{ThemeResource DatePickerSpacerFill}" HorizontalAlignment="Center" Width="2"/>
                                <Rectangle x:Name="SecondPickerSpacing" Grid.Column="3" Fill="{ThemeResource DatePickerSpacerFill}" HorizontalAlignment="Center" Width="2"/>
                            </Grid>
                        </Button>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

To get to the template of an object, you can right-click on it (in Design) and select Edit Template:
To get to the template of an object, you can right-click on it (in Design) and select Edit Template:


export mysql related tables to csv

Question: I have 3 tables in a database that are related as follows:
fruit_names ----> data <---- features

with foreign key relations in data that relate to the names and features tables. So, there is a range of fruits and a range of features which are specified in separate tables, information on each feature for each fruit is given in the data table. In other words, each data row is associated with only one fruit name and one feature name; and other information on the fruits and the features is stored in the other two tables.
I want a csv that is formatted as a table, with the features as columns and the fruits on rows:
        roundness           enlongatedness          tastyness           difficulty_to_peel
apple   10 quite round      1 not enlongated        5 depends           2 very difficult
banana  1 not round at all  8 quite enlongated      10 always tasty     9 very easy
kiwi    8 little bit round  3 little bit enlongated 5 depends           7 easy
orange  10 quite round      1 not enlongated        6 most often tasty  7 easy

This command of course gives me the relevant information, but not in the right format:
SELECT fruit_names_name, data_x, features_feature_name
FROM data
JOIN features
ON data.features_foreign = features.features_id
JOIN languages
ON data.fruit_names_foreign = fruit_names.fruit_names_id;
as it presents the data in a table as follows:
fruit_names_name    data_x              features_feature_name
apple               10 quite round      roundness
apple               1 not enlongnated   enlongatedness
apple               3 depends           tastyness
apple               2 very difficult    difficulty_to_peel
banana              1 not round at all  roundness
banana              8 quite enlongated  enlongatedness
etc.

Is it possible to use phpmyadmin, a php script or mysql itself to generate a usable .csv file?
Comment: [SELECT INTO OUTFILE](http://dev.mysql.com/doc/refman/5.6/en/select-into.html)
Comment: Yes, I realise SELECT INTO OUTFILE is the way to go here. But how to combine the information from the three different tables into the required format? I have tried combining SELECT INTO OUTFILE with UNION, something like
SELECT data_x FROM data
UNION SELECT features_feature_name FROM features
UNION SELECT fruit_names_name FROM fruit_names
INTO OUTFILE /Users/....;
but this obviously doesn't work.
Answer: You could concactenate the fields like this:-
SELECT CONCAT(fruit_names_name, ', ', data_x, ', ', ... etc)
FROM data
JOIN features
ON data.features_foreign = features.features_id
JOIN languages
ON data.fruit_names_foreign = fruit_names.fruit_names_id;

and then copy the output into a text file
Comment: That still outputs the data in the list format, with every fruit name listed X times, then its feature, and then feature_names, listed for each row that is in data. This is not what I want, see question.
Comment: Apologies, I did not see that part.  You probably need a PIVOT or CROSSTAB - perhaps this link will assist: http://en.wikibooks.org/wiki/MySQL/Pivot_table

export mysql related tables to csv


Configure email with TLS in Laravel - Error SSL operation failed with code 1

Question: I want to configure a custom email (not gmail) with TLS using Laravel and I can't make it work.
The error I get is:

stream_socket_enable_crypto(): SSL operation failed with code 1.
OpenSSL Error messages:\nerror:1416F086:SSL
routines:tls_process_server_certificate:certificate verify failed

In my .env file I have:
MAIL_DRIVER=smtp
MAIL_HOST=mail.**********.com
MAIL_PORT=587
MAIL_USERNAME=system@**********.com
MAIL_PASSWORD=**********
MAIL_FROM_ADDRESS=system@**********.com
MAIL_ENCRYPTION=tls

I tried the same account in a non Laravel PHP project and it works just fine. In that project, I have this option that I think is the key:
$mailer->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
        )
    );
$mailer->SMTPAuth = true;
$mailer->SMTPSecure = 'tls';

How can I configure this options in Laravel? Or is another mistake?
Thanks for your help.
Comment: Possible solution? https://stackoverflow.com/a/30686838/11801683
Comment: As another user said in that post: "that answer doesn't describe the consequences of that change. If you change it to 'mail' it will then send the mail via PHP mail meaning that it will be subject to higher spam scores because PHP is essentially spoofing the email." Tks anyway.
Answer: Finally when I change the MAIL_ENCRYPTION to null, it worked just fine. I assume that is a server configuration problem, I'll check it with the sysadmin.
Regards
Comment: Disabling encryption seems like a poor solution to your problem, as does disabling security measures in your "non Laravel PHP project"


how to use an MS-Access file from Linux?

Question: I'm studying an introductory course in databases and one of the exercises is to work with MS-Access. However I'm using Linux at home and although I can use the computer classes at the university it is far from convenient (limited open time - my studying time is mostly nights).
So how can I use an Access file (*.mdb) in Linux? By use I mean changing tables, writing queries and so on.
Are there tools to convert it to another database format (mysql, postgresql or even gadfly)?
Also what problems may I encounter?
Comment: Thanks for all the answers. I forgot about OpenOffice Base.
I hope to try the various suggestions during the weekend and see what works out best for me.
Comment: For more information on using [Open | Libre]Office Base with Access databases under Linux, see [this answer on Ask Ubuntu](https://askubuntu.com/a/519571/323236).
Answer: Although a bit dated, I've had good success with mdbtools which is a set of command line tools for accessing and converting Access databases to other formats. I've used it for importing databases into PostgreSQL.
If you're running an Ubuntu variant you can install it with:
sudo apt-get install mdbtools

or you can download it from here.
Comment: I will second that - but be warned that different versions of mdbtools will result in a slightly different output.  Types and schema can vary.
Comment: To easily export full MS Access database using `mdbtools` tools from this answer, check out https://gist.github.com/turicas/2592877 script. To export to mysql (or postgresql) two lines should be fixed (described in comments from same link)
Answer: You're out of luck. Access has no real equivalent on Linux and while Kexi is an interesting alternative that can import Access files and aims to provide similar functionality, it doesn't actually uses Access files once the data is imported.
If your assignment is to develop an Access application with forms etc as opposed to just using and mdb database as a store, then you can try a recent release of Wine with a compatible Access version (see compatibility list) or, even better, find a Windows machine where you're sure it's going to work.
Not to be forgotten, the use of a Virtual Machine loaded with Windows would help you achieve the same thing on your Linux box.
Answer: I am currently trying Access with Wine on Ubuntu and I seem to be getting there. I have found that I need to copy various dlls manually, but that could easily be lack of reading up on the subject.
Answer: From the documentation: Connecting To Microsoft Access. However, this seems to indicate that you need access running in a windows host and connect via ODBC... See also Known Problems.
Comment: MS Jet does not run on anything but Windows. It's record locking is very tightly tied to Windows file systems, and I won't even allow my clients to store their MDBs on file servers that aren't running native Windows file systems (that means no Novell and no Linux/Samba).
Answer: I recently discover https://dbeaver.io/ which is a software (in java) to manage different database types (MySQL, PostGreSQL…), a bit like phpmyadmin (but as a host based soft, no server require) and it can manage MS Access excep if version is too old (it is probably my case)
Answer: You can work with Access through a connection (ODBC or OLEDB), as long as you only need to manage the "database" dimension of the file (tables and views, which are called "queries" in Access).
Once the connection is open (see here for connection strings), you can send SQL commands to your mdb database, such as (where cn is here a connection object):
cn.execute "CREATE TABLE myTableName (myTable_id autoNumber, myTable_code Text, ...)"

Please note that MsAccess uses a specific DDL that looks like the standard T-SQL but is not really it. Check the syntax in MsAccess help.
Depending on your database (and its constraints, default values, primary keys used, relations, data validation rules, aso), transfering Access can be easy and straight or might not even be possible. You will encounter a problem each time your database implement an access-specific/non-standard SQL rule.
If you really need to convert your access data to something else, I'd adise you to (1) export it under MS-SQL (the free version will be ok, an upsizing wizard is available in Access or on this site), (2)use an additional tool like this one to generate a "CREATE DATABASE" SQL Script, including or not data inserts, (3) use this script to try to create the database and its data on another database server.
Answer: If you've got an assignment to work with Access, then frigging find a Windows computer and do your exercise on the native platform for Access. It's completely senseless to do anything else, as you won't be learning anything useful about Access.
If the assignment is to use a Jet data store, then that's something of a different story. And if it is, then you should have worded your question differently. I wouldn't recommend using Jet on anything but a native Windows file system. Certainly if the project is to actually read/write data to a Jet data file then you're not really fulfilling the assignment if you're not using Windows at least as the ODBC host.
Comment: Despite the wording, this is a very realistic answer.  Surely the uni has lab computers that could be used for this purpose!?


Proof that $ \sum_k (-1)^k \binom{n-k}{n-m} \binom{m}{k} = \binom{n-m}{m}$

Question: Proof that
$$ \sum_k (-1)^k \binom{n-k}{n-m} \binom{m}{k} = \binom{n-m}{m}$$
I tried to solved that in two approaches (in both failed):
1. Algebraically:
Use negation theorem:
$$ \sum_k (-1)^k \binom{n-k}{n-m} \binom{m}{k} = \sum_k \binom{n-k}{n-m} \binom{k-m-1}{k} $$
and after than I can:
$$ \sum_k \binom{n-k}{n-m} \binom{k-m-1}{k} = \sum_k \binom{n-k}{n-m} \binom{k-m-1}{-m-1} $$
but stucked...  Another approach was trying to proof that via combinatoric's interpretation. Because lack of result I don't have anything to show there in that way..
Comment: @KevinLong You are forgetting that $\binom{r}k:=\frac{r(r-1)\cdots (r-k+1)}{k!}$ is nonzero when $r<0$.
Comment: I'm not sure what the negation theorem is, but the right hand side of your equation after using it seems wrong, since (assuming $m\geq 0$) $\binom{k-m-1}{k}=0$ since $k-m-1<k$.
Comment: @MikeEarnest I see, I admittedly don't often think about binomial coefficients with negative inputs.
Answer: Algebraic proof
\begin{align}
    \sum_k (-1)^k\binom{n-k}{n-m}\binom{m}{k}
  &=(-1)^m\sum_k (-1)^{m-k}\binom{n-k}{m-k}\binom{m}{k}
\\&\stackrel{\text{n}}=(-1)^m\sum_k \binom{m-n-1}{m-k}\binom{m}{k}
\\&\stackrel{\text{V}}=(-1)^m\binom{2m-n-1}{m}
\\&\stackrel{\text{n}}=\binom{n-m}m
\end{align}
$\stackrel{\text{n}}=$ is the negation theorem.
$\stackrel{\text{V}}=$ is the (Chu)-Vandermonde identity.
Combinatorial proof sketch
Both sides answer the question

How many subsets of $\{1,2,\dots,n\}$ have size $m$, no two consecutive elements, and do not contain $n$?

The RHS is true because
$$
(i_1,i_2,\dots,i_m)\implies (i_1,i_2+1,i_3+2,\dots,i_m+{m-1})
$$
is a bijection from increasing sequences of length $m$ whose entries are between $1$ and $n-m$, to subsets of $\{1,2,\dots,n-1\}$ with no adjacent elements (written in increasing order).
We count such subsets using the principle of inclusion exclusion. Namely, for $1\le i\le n-1$ let $E_i$ be the set of subsets where the $i^{th}$ smallest element is adjacent to the $(i+1)^{st}$ smallest element, and let $E_n$ be the set of subsets which include $n$. These are the bad subsets, so we want $|E_1^c\cap E_2^c\cap \dots \cap E_n^c|$, which is
$$
\sum_{S\subseteq \{1,2,\dots,m\}} (-1)^{|S|}\left|\bigcap_{i\in S}E_i\right|
$$
It turns out that $\left|\bigcap_{i\in S}E_i\right|=\binom{n-k}{m-k}$ whenever $|S|=k$. Roughly, when $k$ of the elements of the subset are constrained to be adjacent, we can group these elements together into a single block, so there are only $m-k$ elements to be chosen in a smaller space of $n-k$. I leave the messy details to you.
Answer: With $n\ge m$ where $m\ge 0$ we seek to show that
$$\sum_{k=0}^m {m\choose k} (-1)^k {n-k\choose n-m}
= {n-m\choose m}.$$
The sum is
$$\sum_{k=0}^m {m\choose k} (-1)^k
[z^{n-m}] (1+z)^{n-k}
\\ = [z^{n-m}] (1+z)^n
\sum_{k=0}^m {m\choose k} (-1)^k (1+z)^{-k}
\\ = [z^{n-m}] (1+z)^n
\left(1-\frac{1}{1+z}\right)^m
\\ = [z^{n-m}] (1+z)^{n-m} z^m
= [z^{n-2m}] (1+z)^{n-m}
\\ = {n-m\choose n-2m} = {n-m\choose m}.$$
Remark. We  may want to prove  that this holds even  when $n\lt m$
where again $m\ge 0.$ We are using formal power series and there is no
principal part as in a Laurent series, hence the coefficient extractor
$[z^{n-m}]$ is defined to return zero  when $n\lt m.$ This is also the
behaviour when the Cauchy Coefficient Formula is used, where we have
$$\frac{1}{2\pi i}
\int_{|z|=\epsilon}
\frac{1}{z^{n-m+1}} (1+z)^{n-k} \; dz$$
and  with  $n\lt m$  no  pole  at zero  will  ever  appear.  In  these
circumstances  some authors  and computer  algebra systems  like Maple
define the value to be
$${n-k\choose (n-k)-(n-m)} = {n-k\choose m-k}
= \frac{(n-k)^{\underline{m-k}}}{(m-k)!}$$
supposing that  $m\ge k.$ With  this setting  we in fact  get non-zero
values when  $n\lt k \le  m.$ We also  have agreement with  the values
from the first case ($n\ge m$).
We then obtain for our sum
$$\sum_{k=0}^m {m\choose k} (-1)^k
[z^{m-k}] (1+z)^{n-k}
\\ = [z^m] (1+z)^n
\sum_{k=0}^m {m\choose k} (-1)^k z^k \frac{1}{(1+z)^k}
\\ = [z^m] (1+z)^n
\left(1-\frac{z}{1+z}\right)^m
= [z^m] (1+z)^{n-m} = {n-m\choose m}.$$
This proof goes through for all integer $n$ and $m\ge 0.$
Answer: Here's a semi-combinatorial proof. We'll consider a term on the left hand side. First, we know that $\binom{m}{k}$ counts size-$k$ subsets of $[m]$. Then consider $\binom{n-k}{n-m}=\binom{n-k}{m-k}$; since we have a size-$k$ subset $A$ of $[m]$, we can think of this as counting size-$(m-k)$ subsets of $[n]-A$. Hence, the left hand side counts pairs of sets $(A,B)$ such that $A\subseteq [m]$ with $|A|=k$ and $B\subseteq [n]-A$ with $|B|=m-k$. However, there's the caveat that such a pair $(A,B)$ has a positive contribution if $|A|$ is even, and a negative contribution if $|A|$ is odd.
Since $A$ and $B$ are disjoint, the union $A\cup B=C$ has size $m$. By looking instead at all such $C=A\cup B$, this is equivalent to looking at all $C\subseteq [n]$ such that $|C|=m$, and for each such $C$, considering all subsets $A\subseteq C\cap [m]$; each such $(C,A)$ pair gives a positive contribution if $|A|$ is even, and a negative contribution if $|A|$ is odd.
Now I make the following claim: for each such $C$, the sum of contributions of all $(C,A)$ pairs is $0$ if $C\cap [m]$ is nonempty, and $1$ if $C\cap[m]=\varnothing$. You can show this using the same argument that a size-$n$ set has exactly as many odd subsets as it does even subsets when $n\geq 1$, and only one even subset (itself) and no odd subsets when $n=0$. It then follows that we're really just counting size-$m$ sets $C$ with $C\subseteq [n]-[m]$, which are counted by $\binom{n-m}{m}$. There are some details you can fill in to understand why this works.


Convert guid bytes to string in javascript

Question: I am getting arrayBuffur from WebSocket connection, and I can get range of byte arrays that is
Guid created in c#.
How I can convert this guid bytes to string in javascript?
Guid="FEF38A56-67A9-46DF-B7D8-C52191CD70F4"
Bytes=[86, 138, 243, 254, 169, 103, 223, 70, 183, 216, 197, 33, 145, 205, 112, 244]
Thanks.
Comment: https://github.com/dalaqa/guid/blob/master/javascriptGuid the exact representation of C# GUID from byte array
Answer: In addition to JohanShogun answer, a simple script to do that would utilize map function on an array of bytes. However, according to Remarks section of this: http://msdn.microsoft.com/pl-pl/library/system.guid.tobytearray.aspx , first four bytes should be reversed, as well as two next and two after them. So... here's correct solution (don't forget about zero-padding of resulting values 15 should be "0F" not "F"):
<code>var x = [168, 199, 56, 91, 146, 52, 231, 64, 175, 133, 167, 15, 146, 60, 83, 107];

// reverse first four bytes, and join with following two reversed, joined with following two reversed, joined with rest of the bytes
x = x.slice(0, 4).reverse().concat(x.slice(4,6).reverse()).concat(x.slice(6,8).reverse()).concat(x.slice(8))

var guid = x.map(function(item) {
    // return hex value with "0" padding
    return ('00'+item.toString(16).toUpperCase()).substr(-2,2);
})

// guid variable now holds string: 5B38C7A8349240E7AF85A70F923C536B
</code>
Testing example here: http://jsbin.com/ogegut/4/edit
Comment: Hmm..Bytes and guid is correct I have just verified. Why it can be different, any thoughts ?
Comment: First, big thanks for your help and Yes, it work for example guid. But for another is missing one symbol in length, it equal 15 in final string but must be 16. GUID_BYTES=[168, 199, 56, 91, 146, 52, 231, 64, 175, 133, 167, 15, 146, 60, 83, 107] , GUID="5B38C7A8-3492-40E7-AF85-A70F923C536B". Bytes and guid is ok, I checked.
Comment: It's because I didn't add padding to hex-ish values, hence byte 15 is converted to just "F" instead of "0F". I've updated the code in my answer.
Comment: This helped a lot. In my case, the GUID was returned as raw binary data, but you can convert it to an array with `var x = Array.prototype.slice.call(binaryData);` then proceed with WTK's code.
Comment: Instead of `.substr(-2,2)` use `.slice(-2)`.
Answer: If you're using these as Numbers (http://www.w3schools.com/jsref/jsref_obj_number.asp) you can simply do .toString (16) to get them in hex.


Troubleshooting a NotReady node

Question: I have one node that is giving me some trouble at the moment. Not found a solution as of yet but that might be a skill level problem, Google coming up empty, or I have found some unsolvable issue. The latter is highly unlikely.
kubectl version v1.8.5
docker version 1.12.6

Doing some normal maintenance on my nodes I noticed the following:
NAME                            STATUS   ROLES     AGE       VERSION
ip-192-168-4-14.ourdomain.pro   Ready    master    213d      v1.8.5
ip-192-168-4-143.ourdomain.pro  Ready    master    213d      v1.8.5
ip-192-168-4-174.ourdomain.pro  Ready    <none>    213d      v1.8.5
ip-192-168-4-182.ourdomain.pro  Ready    <none>    46d       v1.8.5
ip-192-168-4-221.ourdomain.pro  Ready    <none>    213d      v1.8.5
ip-192-168-4-249.ourdomain.pro  Ready    master    213d      v1.8.5
ip-192-168-4-251.ourdomain.pro  NotReady <none>    206d      v1.8.5

On the NotReady node, I am unable to attach or exec myself in which seems normal when in a NotReady state unless I am misreading it. Not able to look at any specific logs on that node for the same reason.
At this point, I restarted kubelet and attached myself to the logs simultaneously to see if anything out of the ordinary would appear.
I have attached the things I spent a day Googling but I can not confirm is the actually connected to the problem.
ERROR 1
unable to connect to Rkt api service

We are not using this so I put this on the ignore list.
ERROR 2
unable to connect to CRI-O api service

We are not using this so I put this on the ignore list.
ERROR 3
Image garbage collection failed once. Stats initialization may not have completed yet: failed to get imageFs info: unable to find data for container /

I have not been able to exclude this as potential pitfall but the things I have found thus far do not seem to relate to the version I am running.
ERROR 4
skipping pod synchronization - [container runtime is down PLEG is not healthy

I do not have an answer for this one except for the fact that the garbage collection error above appears a second time after this message.
ERROR 5
Registration of the rkt container factory failed

Not using this so it should fail unless I am mistaken.
ERROR 6
Registration of the crio container factory failed

Not using this so it should fail unless, again, I am mistaken.
ERROR 7
28087 docker_sandbox.go:343] failed to read pod IP from plugin/docker: NetworkPlugin cni failed on the status hook for pod "kube-dns-545bc4bfd4-rt7qp_kube-system": CNI failed to retrieve network namespace path: Cannot find network namespace for the terminated container

Found a Github ticket for this one but seems it's fixed so not sure how it relates.
ERROR 8
28087 kubelet_node_status.go:791] Node became not ready: {Type:Ready Status:False LastHeartbeatTime:2019-05-06 05:00:40.664331773 +0000 UTC LastTransitionTime:2019-05-06 05:00:40.664331773 +0000 UTC Reason:KubeletNotReady Message:container runtime is down}

And here the node goes into NotReady.
Last log messages and status
    systemctl status kubelet
  kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/etc/systemd/system/kubelet.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Mon 2019-05-06 05:00:39 UTC; 1h 58min ago
     Docs: http://kubernetes.io/docs/
 Main PID: 28087 (kubelet)
    Tasks: 21
   Memory: 42.3M
   CGroup: /system.slice/kubelet.service
           └─28087 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --pod-manifest-path=/etc/kubernetes/manife...
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310305   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for vo...4a414b9c")
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310330   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for vo...4a414b9c")
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310359   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for volume "varl...
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310385   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for volume "cali...
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310408   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for volume "kube...
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310435   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for vo...4a414b9c")
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310456   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for vo...4a414b9c")
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310480   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for volume "ca-c...
May 06 05:00:45 kube-master-1 kubelet[28087]: I0506 05:00:45.310504   28087 reconciler.go:212] operationExecutor.VerifyControllerAttachedVolume started for volume "k8s-...
May 06 05:14:29 kube-master-1 kubelet[28087]: E0506 05:14:29.848530   28087 helpers.go:468] PercpuUsage had 0 cpus, but the actual number is 2; ignoring extra CPUs

Here is the kubectl get po -o wide output.
NAME                                              READY     STATUS     RESTARTS   AGE       IP               NODE
docker-image-prune-fhjkl                          1/1       Running    4          213d      22.214.171.124     ip-192-168-4-249
docker-image-prune-ltfpf                          1/1       Running    4          213d      18.104.22.168    ip-192-168-4-143
docker-image-prune-nmg29                          1/1       Running    3          213d      126.96.36.199    ip-192-168-4-221
docker-image-prune-pdw5h                          1/1       Running    7          213d      18.104.22.168    ip-192-168-4-174
docker-image-prune-swbhc                          1/1       Running    0          46d       18.104.22.168   ip-192-168-4-182
docker-image-prune-vtsr4                          1/1       NodeLost   1          206d      220.127.116.11   ip-192-168-4-251
fluentd-es-4bgdz                                  1/1       Running    6          213d      192.168.4.249    ip-192-168-4-249
fluentd-es-fb4gw                                  1/1       Running    7          213d      192.168.4.14     ip-192-168-4-14
fluentd-es-fs8gp                                  1/1       Running    6          213d      192.168.4.143    ip-192-168-4-143
fluentd-es-k572w                                  1/1       Running    0          46d       192.168.4.182    ip-192-168-4-182
fluentd-es-lpxhn                                  1/1       Running    5          213d      192.168.4.174    ip-192-168-4-174
fluentd-es-pjp9w                                  1/1       Unknown    2          206d      192.168.4.251    ip-192-168-4-251
fluentd-es-wbwkp                                  1/1       Running    4          213d      192.168.4.221    ip-192-168-4-221
grafana-76c7dbb678-p8hzb                          1/1       Running    3          213d      18.104.22.168    ip-192-168-4-174
model-5bbe4862e4b0aa4f77d0d499-7cb4f74648-g8xmp   2/2       Running    2          101d      126.96.36.199    ip-192-168-4-221
model-5bbe4862e4b0aa4f77d0d499-7cb4f74648-tvp4m   2/2       Running    2          101d      22.214.171.124    ip-192-168-4-221
prometheus-65b4b68d97-82vr7                       1/1       Running    3          213d      184.108.40.206     ip-192-168-4-174
pushgateway-79f575d754-75l6r                      1/1       Running    3          213d      22.214.171.124     ip-192-168-4-174
rabbitmq-cluster-58db9b6978-g6ssb                 2/2       Running    4          181d      18.104.22.168    ip-192-168-4-174
replicator-56x7v                                  1/1       Running    3          213d      126.96.36.199     ip-192-168-4-174
traefik-ingress-6dc9779596-6ghwv                  1/1       Running    3          213d      126.96.36.199     ip-192-168-4-174
traefik-ingress-6dc9779596-ckzbk                  1/1       Running    4          213d      188.8.131.52    ip-192-168-4-143
traefik-ingress-6dc9779596-sbt4n                  1/1       Running    3          213d      22.214.171.124    ip-192-168-4-221

Output of kubectl get po -n kube-system -o wide
NAME                                       READY     STATUS     RESTARTS   AGE       IP
calico-kube-controllers-78f554c7bb-s7tmj   1/1       Running    4          213d      192.168.4.14
calico-node-5cgc6                          2/2       Running    9          213d      192.168.4.249
calico-node-bbwtm                          2/2       Running    8          213d      192.168.4.14
calico-node-clwqk                          2/2       NodeLost   4          206d      192.168.4.251
calico-node-d2zqz                          2/2       Running    0          46d       192.168.4.182
calico-node-m4x2t                          2/2       Running    6          213d      192.168.4.221
calico-node-m8xwk                          2/2       Running    9          213d      192.168.4.143
calico-node-q7r7g                          2/2       Running    8          213d      192.168.4.174
cluster-autoscaler-65d6d7f544-dpbfk        1/1       Running    10         207d      184.108.40.206
kube-apiserver-ip-192-168-4-14             1/1       Running    6          213d      192.168.4.14
kube-apiserver-ip-192-168-4-143            1/1       Running    6          213d      192.168.4.143
kube-apiserver-ip-192-168-4-249            1/1       Running    6          213d      192.168.4.249
kube-controller-manager-ip-192-168-4-14    1/1       Running    5          213d      192.168.4.14
kube-controller-manager-ip-192-168-4-143   1/1       Running    6          213d      192.168.4.143
kube-controller-manager-ip-192-168-4-249   1/1       Running    6          213d      192.168.4.249
kube-dns-545bc4bfd4-rt7qp                  3/3       Running    13         213d      126.96.36.199
kube-proxy-2bn42                           1/1       Running    0          46d       192.168.4.182
kube-proxy-95cvh                           1/1       Running    4          213d      192.168.4.174
kube-proxy-bqrhw                           1/1       NodeLost   2          206d      192.168.4.251
kube-proxy-cqh67                           1/1       Running    6          213d      192.168.4.14
kube-proxy-fbdvx                           1/1       Running    4          213d      192.168.4.221
kube-proxy-gcjxg                           1/1       Running    5          213d      192.168.4.249
kube-proxy-mt62x                           1/1       Running    4          213d      192.168.4.143
kube-scheduler-ip-192-168-4-14             1/1       Running    6          213d      192.168.4.14
kube-scheduler-ip-192-168-4-143            1/1       Running    6          213d      192.168.4.143
kube-scheduler-ip-192-168-4-249            1/1       Running    6          213d      192.168.4.249
kubernetes-dashboard-7c5d596d8c-q6sf2      1/1       Running    5          213d      22.214.171.124
tiller-deploy-6d9f596465-svpql             1/1       Running    3          213d      184.108.40.206

I am a bit lost at this point of where to go from here. Any suggestions are welcome.
Answer: Most likely the kubelet must be down.
share the output from below command
journalctl -u kubelet

share the output from the below command
kubectl get po -n kube-system -owide

It appears like the node is not able to communicate with the control plane.
you can below steps

detached the node from cluster ( cordon the node, drain the node and finally delete the node)
reset the node
rejoin the node as fresh to cluster
Comment: Hi,

Here is a tail of the log that comes with the systemctl command. Be happy to share the full log if you think that would be helpful but it will take some time to clean it up. Here I just wanted to show that kubelet is running but maybe you asked about something I did fully understand?

Appending the logs to my original message.
Comment: Appended the asked output to the original question
Comment: kubectl get po -n kube-system -owide
Comment: need core services status from kube-system namespace
Comment: Added the requested output.
Comment: Thank you. I am familiar with the steps mentioned in 1 but not in 2 and 3. Can you link to some documentation or elaborate?
Comment: how did you join the node to cluster?
Comment: No idea. Inherited this thing and just learning as I go. I did find a config file using kubeadm config view
Comment: Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/192897/discussion-between-petter-and-p-ekambaram).

Troubleshooting a NotReady node


How does an ATI Mobility HD 4250 compare with a discrete graphics card?

Question: I'm considering getting Diablo III to play on my laptop but my system doesn't meet all the requirements:

As you can see my only issue is my video card. Is it so extreme an issue that I'm screwed or will this shortfall be only a small problem with playability (viz. if turn everything to its lowest setting, etc.)?
Comment: You will have to wait until a Trial/Starter Edition is offered to find out.  There is no way to know for sure, any experience with the beta client, wouldn't be accurate information.  It has been stated that the performance with the beta client and retail client will have a significant difference.  My guess even if it does run, the game will be unplayable, you have a very poor performing card.
Comment: @Ramhound I can't see Blizzard making any *drastic* changes between the public beta a couple weekends ago and the released version.  Early beta, sure, but it's diminishing returns now.
Answer: The ATI Mobility Radeon HD 4250 is part of the 4000-series which is 2 generations ahead of the 1000-series it recommends (which is why the pixel/vertex shaders versions are fine), though the <code>*2**</code> ATI graphics cards are among the "budget" models and generally underpowered.
It's hard to compare notebook graphics to desktop as reviews aren't generally going to compare them head-to-head, but some generic benchmarks might offer insight:

X1950 Pro

Default: 4640
SM 2.0: 1783
SM 3.0: 1931

HD 4250

?: 1016-2110 (depending on system, memory, CPU)

Unfortunately I can't find the specifics of notebookcheck.net's (their benchmark numbers above for the 4250) 3Dmark06 test.  If it's the "default" then it's clearly abysmal, otherwise it's somewhat competitive.
A Tom's Hardware Guide table ranks the 4250 along with the ATI 9700, X800, X1600, etc., 7 tiers below the X1950 Pro and 6 below the NVidia 7800 GT.
Your experience will likely be "poor" on your current hardware, but what does that mean?  Blizzard games in general scale extremely well to hardware, so cranking everything to low (resolution included) may afford you a "playable" game.  I doubt the game developer wants it to simply be playable but something a bit more spectacular (read: not ugly), so they may be a bit conservative in their requirements.
Comment: wait, is he saying that even though my video card is newer it still sucks?
Comment: what do you mean by .*.*.2.*. ATI ? are you referring to how its a 4250 hence the 2? And what do you mean by SM #.#? Some of this is beyond me. Also you said in the beginning that I was 2 tiers ahead of recommended 1000 series, and then in the end you said I was 7 tiers below? I'm rather confused.
Comment: @Ender It's like comparing a 2007 Mercedes S-class with a 2010 Ford Fiesta.  The Fiesta may be better in some respects (efficiency, a newer gadget here or there), but the Merc is still a way better car overall.
Comment: i really appreciate the help! but i know nothing about cars
Comment: @ender You're right but you can still play diablo 3 though... tried it on my notebook, it works fine. We have the same graphics card btw. but all settings should be, like NiQAlas said, on low.
Comment: @Dyordz I played well enough until nightmare Baal. I my fps is too low during his fight to properly dodge his attacks. I'm officially stuck until I upgrade. :(


Does every isomorphism of vector spaces induce an isomorphism of affine spaces?

Question: By reading the first sentence in this article I interpret that, for every projective space, every isomorphism of its underlying vector space gives rise to an isomorphism of projective spaces.
Is this also true for affine spaces (and their underlying vector space)?
Or, at the very least, is every isomorphism of affine spaces induced by an isomorphism of the underlying vector space?
Answer: Let $\mathcal A$ and $\mathcal A'$ be affine spaces over the vector spaces $E$ and $E'$ respectively, both over the same field.
If
$$ \varphi \;:\; E \;\longrightarrow \; E' $$
is a linear isomorphism, then the function $ \; f \;:\; \mathcal A \;\longrightarrow \; \mathcal A' \;$ defined by
$$ f(P) = O'+\varphi(P-O), $$
where $O$ and $O'$ are arbitrarily fixed points of $\mathcal A$ and $\mathcal A'$ respectively, is an affine isomorphism. In fact,
\begin{align}
f(P) - f(Q) &= \big(O'+\varphi(P-O)\big) - \big(O'+\varphi(Q-O)\big) =\\[1.5ex]
&= \varphi(P-O) - \varphi(Q-O) =\\[1.5ex]
&= \varphi(P-Q).
\end{align}
The isomorphism $f$ depends on the arbitrary choice of O and O', so it is not unique.
The vice versa is obvious precisely because of the definition of isomorphism of affine spaces:
Def. $\;$ A function $\;f\;:\; \mathcal A \to \mathcal A'\;$ is an affine isomorphism iff there is a linear isomorphism $\varphi\;:E\;\to E'$ such that
$$ f(P)-f(Q) = \varphi(P-Q)\qquad \forall \;P, Q\in \mathcal A. $$
In this case, $\varphi$ is unique since $P-Q$ describes all $E$, so that $\varphi$ is known over its entire domain.


c++: atomic variable's value is invalid when saved in local variable

Question: I defined atomic variable current inside some Obj-C file:
std::atomic<long long> current;

after that it was initiated:
current=4;

After that the variable became accessible by number of threads.
Some threads modified the variable like this:
current=(current.fetch_add(1))%4;

While other threads modified the variable in different way:
current.fetch_add(1);
if(current>=4){
    current=0;
}

Finally next line is executed:
long long cs=current;

At this point something strange happened: it appears in debugger that cs is 4 while current has different value, usually 1.
My expectation was that cs should have the latest value of current and should never be greater than 3.
I checked all other instances of current; they are not many and used properly everywhere.
What am I missing?
Comment: Improper expectations of atomic behaviour.  Races between reading and writing.
Comment: typo only, nothing else.
Comment: There can be many execution paths that will produce the observed results. The shown access patterns are fundamentally broken, for their stated purpose.
Comment: Side note: `current=4;` is assignment, not initialization.
Answer: Atomic values are not synchronisation primitives. One of possible execution flows:
current.fetch_add(1);  // T1
long long cs=current;  // T2
if(current>=4){  // T1
    current=0;
}

And
auto tmp = current.fetch_add(1);  // T1
long long cs=current;  // T2
current=tmp%4;  // T1

The solution is in using mutexes or spin locks with compare-exchange.
Answer: This is a scenario which is very likely to happen in a multithreaded environment. Assume only 2 threads, the main thread which I called here THREAD-2 and a worker thread THREAD-1. Let's start with current having the value 3, and now it's being incremented by THREAD-1, while THREAD-2 is updating the variable cs.
THREAD-1:    current.fetch_add(1);
THREAD-2:    cs = current;
THREAD-1:    if(current>=4){ current=0; }

as you can see cs gets it's value when current is 4.
Also, this is not an objective-c issue, this is C++ alone.


Display all clients who have booked a room

Question: Subquery returns more than 1 row and this is the error. I want to print all the booked room details showing the client id and the owner id.
$query = "SELECT r.room_id, r.roomsize, r.numberroom, r.price, u.username,
(SELECT u.username FROM room_register r
INNER JOIN user_info u on r.owner_id = u.user_id
INNER JOIN booked b on b.room_id = r.room_id)as owner_name
FROM room_register r INNER JOIN booked b on b.room_id = r.room_id
INNER JOIN user_info u on u.user_id = b.booked_by";

Comment: Please edit your question and add your table here
Answer: You have too many joins in the subquery:
SELECT r.room_id, r.roomsize, r.numberroom, r.price, u.username,
       (SELECT u.username
        FROM user_info u
        WHERE r.owner_id = u.user_id
       ) as owner_name
FROM room_register r INNER JOIN
     booked b
     ON b.room_id = r.room_id INNER JOIN
     user_info u
     ON u.user_id = b.booked_by;

Or just use two separate JOINs:
SELECT r.room_id, r.roomsize, r.numberroom, r.price, u.username,
       uo.username as owner_name
FROM room_register r INNER JOIN
     booked b
     ON b.room_id = r.room_id INNER JOIN
     user_info u
     ON u.user_id = b.booked_by LEFT JOIN
     user_info uo
     ON uo.user_id = r.owner_id


What is the maximum possible bonus to Karma?

Question: I've been saving my Jugs of Liquid Karma from completing daily and monthly achievements, and I've got quite a few stashed away. Since it's possible to get bonuses to Karma through things like guild banners and some food types, I want to make sure that I get the most use out of them that I can.
What is the maximum possible Karma bonus and what do I need to do to reach it?
Answer: With regards to using Jugs/Flasks/Gulps/Drops of Karma most efficiently, the largest possible bonus at this time is 95%.
To obtain this bonus, you'll need to:

Use a Karma Booster for 50%
Touch a "+10% Karma and +10% Experience" Banner
Eat an ice cream food item for 5%
Be under the effect of the "+15% Karma for 24 hrs" guild buff
Have an item with a Karmic Infusion in it equipped (15% bonus).

Altogether, these bonuses will combine additively to give a 95% bonus.
Additional Notes:

95% is not a fixed cap, it is simply the largest bonus available at this time. It is possible that more Karma Modifiers will be added at a later date.
It's worth noting that although the Outmanned buff claims to add an extra 33% to Karma gain, it does not work for liquid karma items (and as Raven Dreamer pointed out, it actually does not work at all right now). The Outmanned buff no longer claims to add a Karma bonus (Thanks for pointing this out, Brian).
Thanks to Metemer for pointing out that there is now a 10% Karma Banner.

Source: Guild Wars 2 Wiki page on Karma Modifiers
Comment: Update: for anyone wondering, the bonfire does not give +50% if you're already using a karma boost on the character. Vice versa.
Comment: Another update: Outmanned no longer claims to affect karma.
Comment: I'm not sure the largest possible bonus is 75% - the Outmanned buff doesn't work at all, so I wouldn't use that as proof that it caps at 75%.
Comment: @RavenDreamer The Outmanned buff shouldn't matter either way since it definitely doesn't affect liquid karma items, I only mentioned it for clarification. If it turns out that the wiki is wrong and the maximum is something other than 75%, I'll certainly accept an answer with the proper value.
Comment: That's what I mean, though -- the outmanned buff *doesn't* provide bonus karma (despite the tooltip) from *either* WvWvW events **or** liquid Karma. The so-called "cap" of 75% is simply the highest attainable karma increase. Before the Karma food came out, the "cap" was 70%. (And it turned out to not be one when the ice cream was released and folks confirmed 75%)
Comment: @RavenDreamer Ah, I understand. I wasn't meaning to suggest that there is a cap at all, but I see how you would think that from my wording. I was just interested in the maximum amount available *right now*, so that if I decided to use the items I would get the most out of them. I'll update my answer to be more clear.
Comment: So, instead of 4500 karma, it would give 7850, right?
Comment: @EduardoCopat 7875, I believe.
Answer: As of the 2013.02.26 update, there is a banner that adds 10% karma bonus instead of the usual 5%. It doesn't stack with the 5% therefore the new maximum is 95% making a jug give 8775 karma instead of 4500 (4275 more).
Comment: This should either be a comment or an edit to Brysonic's answer.


Android alert alignement issue with radio button

Question: I am very new to android programming. I created an alert box having a title question and body contains answers (radio Button).
1 . I want to reduce the fort size of title (My Question)
2 . Align radio options below the text center..

My Dialogbox.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#800080" >

    <LinearLayout
        android:id="@+id/namelayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true">

        <TextView
            android:layout_width="73dp"
            android:layout_height="50dp"
            android:gravity="center"
            android:text="5am-6am" />

        <TextView
            android:layout_width="73dp"
            android:layout_height="50dp"
            android:gravity="center"
            android:text="6am-8am" />

        <TextView
            android:layout_width="73dp"
            android:layout_height="50dp"
            android:gravity="center"
            android:text="6pm-8pm" />

        <TextView
            android:layout_width="73dp"
            android:layout_height="50dp"
            android:gravity="center"
            android:text="8pm-11pm" />
    </LinearLayout>

    <RadioGroup
        android:id="@+id/radiogroub"
        android:layout_width="280dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/namelayout"
        android:gravity="center"
        android:orientation="horizontal"
        android:layout_centerHorizontal="true">

        <RadioButton
            android:id="@+id/sms1"
            android:layout_width="60dp"
            android:layout_height="50dp" />

        <RadioButton
            android:id="@+id/sms2"
            android:layout_width="60dp"
            android:layout_height="50dp" />

        <RadioButton
            android:id="@+id/sms3"
            android:layout_width="60dp"
            android:layout_height="50dp" />

        <RadioButton
            android:id="@+id/sms4"
            android:layout_width="60dp"
            android:layout_height="50dp" />
    </RadioGroup>

    <LinearLayout
        android:id="@+id/btnlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/radiogroub"
        android:gravity="center"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/sendbtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:text="Send" />

        <Button
            android:id="@+id/closebtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:text="Close" />
    </LinearLayout>

</RelativeLayout>

Comment: Your `xml` is totally different from the `screen` you have pasted here.
Comment: Yes...the screen is just a demo....i want to align radio directly under the text....i mean center
Answer: Use this layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#800080"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/namelayout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_weight="0"
        android:orientation="horizontal"
        android:visibility="visible" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:gravity="center"
            android:text="5am-6am" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:gravity="center"
            android:text="6am-8am" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:gravity="center"
            android:text="6pm-8pm" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:gravity="center"
            android:text="8pm-11pm" />
    </LinearLayout>

    <RadioGroup
        android:id="@+id/radiogroub"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center" >

            <RadioButton
                android:id="@+id/sms1"
                android:layout_width="wrap_content"
                android:layout_height="match_parent" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center" >

            <RadioButton
                android:id="@+id/sms2"
                android:layout_width="wrap_content"
                android:layout_height="match_parent" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center" >

            <RadioButton
                android:id="@+id/sms3"
                android:layout_width="wrap_content"
                android:layout_height="match_parent" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center" >

            <RadioButton
                android:id="@+id/sms4"
                android:layout_width="wrap_content"
                android:layout_height="match_parent" />
        </LinearLayout>
    </RadioGroup>

    <LinearLayout
        android:id="@+id/btnlayout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_weight="0"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/sendbtn"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Send" />

        <Button
            android:id="@+id/closebtn"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Close" />
    </LinearLayout>

</LinearLayout>


Wifi and Bluetooth headset issues

Question: I am using Qualcomm Atheros AR9565 card and when I use bluetooth headset, wifi slows down. I tried to disable Bluetooth collaboration on windows but I didn't find any option on windows. I have Ubuntu 18.04.3 LTS installed on my lenovo g50-70 laptop.
EDIT:
02:00.0 Network controller [0280]: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter [168c:0036] (rev 01)
    Subsystem: Lenovo QCA9565 / AR9565 Wireless Network Adapter [17aa:4026]
    Kernel driver in use: ath9k
    Kernel modules: ath9k
Bus 001 Device 002: ID 8087:8000 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 007: ID 0cf3:3004 Atheros Communications, Inc. AR3012 Bluetooth 4.0
Bus 002 Device 003: ID 5986:055d Acer, Inc
Bus 002 Device 002: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Comment: Please [edit] your question and add output of `lspci -knn | grep Net -A3; lsusb` terminal command.
Comment: Does it slow down on Windows or Ubuntu?
Comment: @Pilot6 on both.
Answer: When you are using 2.4 GHz Wi-Fi and stream audio using bluetooth, it is generally normal that Wi-Fi slows down. Bluetooth uses the same frequency.
You can enable bluetooth coexistence on Ubuntu, but it is not perfect either.
It can  be enabled by a terminal command
sudo tee /etc/modprobe.d/ath9k.conf <<< "options ath9k btcoex_enable=1"

Reboot to apply.
If this setting doesn't help or makes things worse, revert it by
sudo rm /etc/modprobe.d/ath9k.conf

Comment: It didn't create any difference, situation is still worse like around 2mbps when listening to songs on headset but 20mbps when I disconnect the device.
Comment: There is nothing else to suggest with this hardware.
Comment: Alright so every bluetooth device will create problems with my laptop? unless I some how use 5ghz wifi?
Comment: You have a combo Wi-Fi+BT device. If you use another BT device, it may be better.
Comment: You mean a usb bluetooth device for laptop?
Comment: Exactly. Another option is to replace the internal device. You can get a 802.11ac combo device, e.g Intel and replace. I did it for my laptops a couple of times.
Comment: Alright. Thank you so much for explaining. Have a nice day!
Comment: Can you explain why usb bluetooth will solve this issue? using 5ghz makes sense to me.
Comment: It may solve the issue. It will be another device with its own antenna and radio, etc.
Comment: Alright so can you explain why using same device causes issue and separate devices will not?
Comment: I never wrote that "separate devices will not". I wrote that a separate device MAY solve the issue, because it has anoter antenna and is located in another place. This discussion is off-topic here, and there is nothing to add really.

Wifi and Bluetooth headset issues


If $f\in L^1(\mathbb R)$ and $g\in C_c^\infty(\mathbb R)$ such that $f\star g=0$ a.e. then $f=0$

Question:
Let $f\in L^1(\mathbb R)$ and $g\in C_c^\infty(\mathbb R)$ such that $f\star g(x)=0$ a.e. Then show that $f=0$ a.e. Note, $g$ is a fixed function.

So from the given condition I can see $\hat{f}(y)\hat{g}(y)=0$ for every $y\in\mathbb R$ so $\hat{f}(y)=0$ or $\hat{g}(y)=0$ for every $y$.
I now thought of applying the uncertainty principle. The set $\{y:g(y)\neq 0\}$ is bounded, hence $\{y:\hat{g}(y)\neq 0\}$ must have infinite Lebesgue measure, in particular must be unbounded. So $\hat{f}(y)\neq0$ over a set with infinite measure. So what?
Comment: You'd better rule out $g = 0$.
Comment: you also have $f*g^n(x) = 0$ where $g^n(x)$ is the $n^{th}$ derivative.
Comment: But how does that help?
Comment: An approach you can try is if $F(g)(y)=0$ in an closet set $y \in S=[a,b]$ ($F(g)$ is the fourier transform of $g$) then since $(I_{[a,b]} F(g) )(y) = 0$ we can write $(g*sinc)(x) = 0$. So you have to rule out $(g*sinc)(x) = 0$. Now if you let $a$ closer to $b $ until center positive part of sinc function becomes wider than support of $g(x)$. Now if $g$ is positive, this gives a contradiction. So if $g>0$ then i think you can prove it.
Answer: We can say much more about $\hat{g}$ than just that it is nonzero on an unbounded set.  In particular, we can say that $\hat{g}$ is analytic (indeed, it is an entire function if we let its input range over $\mathbb{C}$).  This means that if $\hat{g}$ is not identically $0$, its zeroes are isolated (and in particular form a set of measure $0$).  So we must have $\hat{f}=0$ a.e., and so $f=0$ a.e.
Comment: Oh okay, I did not know anything about the analyticity. Haven't got to that part yet in class.


How do I change the reset password text in Drupal 7 (one-time login)

Question: How do I change the text on the one-time login page for Drupal 7.
"This is a one-time login for user and will expire on date.
Click on this button to log in to the site and change your password.
This login can be used only once."
Answer: Specifically...
In template.php in your custom theme, create this function:
<?php
/**
 * Implements hook_form_FORM_ID_alter()
 *
 * Set custom text on the user password reset form.
 */
function YOUR_THEME_form_user_pass_reset_alter(&$form, &$form_state, $form_id) {
  $form['message']['#markup'] = "
Your custom text goes here.
";
  $form['help']['#markup'] = "
This is another line of custom text.
";

  // If you prefer, you can just delete the second line of markup with:
  // unset($form['help']);
}

Comment: And the original form is here https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_pass_reset/7.x
Answer: If you need to change the text on the password reset page, not just in the e-mail, that has to be done via a theme function. There's a page on how to do it (for both D6 and D7) in the Theming Guide on Drupal.org: https://drupal.org/node/350634
It also covers the user login and registration pages. Note that in sample code provided for D7 in Steps 2 & 3, they've left out the function for the password reset page, but you can create a function for that following the same pattern they use for the other two.
Answer: This can be found at the Interface Translation in your settings.
This way you can replace the strings with your own text without having to hook anything.
Answer: This page is a Drupal form, just make use of hook_form_alter. The form id is "user_pass_reset".


Can't connect bluetooth headphones anymore

Question: I believe after an update I lost connection to my bluetooth headset, which was working fine but now it fails to connect with an error message of Connection Failed:  Protocol not available I'm on OS: Ubuntu 20.04.4 LTS x86_64 and Kernel: 5.15.0-41-generic
╰─$ sudo systemctl status bluetooth                                                                        130 ↵
● bluetooth.service - Bluetooth service
     Loaded: loaded (/etc/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-07-30 09:27:39 +03; 13min ago
       Docs: man:bluetoothd(8)
   Main PID: 2403102 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 38324)
     Memory: 1.4M
     CGroup: /system.slice/bluetooth.service
             └─2403102 /usr/lib/bluetooth/bluetoothd --noplugin=avrcp

Tem 30 09:27:39 bluetoothd[2403102]: Starting SDP server
Tem 30 09:27:39 bluetoothd[2403102]: Excluding (cli) avrcp
Tem 30 09:27:39 bluetoothd[2403102]: Bluetooth management interface 1.21 initialized
Tem 30 09:27:39 bluetoothd[2403102]: Failed to set mode: Not Supported (0x0c)
Tem 30 09:39:10 bluetoothd[2403102]: a2dp-sink profile connect failed for F4:4E:04:01:D7:23: Protocol not >
Tem 30 09:39:10 bluetoothd[2403102]: a2dp-source profile connect failed for F4:4E:04:01:D7:23: Protocol no>
Tem 30 09:39:21 bluetoothd[2403102]: a2dp-sink profile connect failed for F4:4E:04:01:D7:23: Protocol not >
Tem 30 09:39:21 bluetoothd[2403102]: a2dp-source profile connect failed for F4:4E:04:01:D7:23: Protocol no>
Tem 30 09:39:26 bluetoothd[2403102]: a2dp-sink profile connect failed for F4:4E:04:01:D7:23: Protocol not >
Tem 30 09:39:26 bluetoothd[2403102]: a2dp-source profile connect failed for F4:4E:04:01:D7:23: Protocol no>
lines 1-21/21 (END)

╰─$ pactl info
    Server String: /run/user/1000/pulse/native
    Library Protocol Version: 33
    Server Protocol Version: 35
    Is Local: yes
    Client Index: 51520
    Tile Size: 65472
    Server Name: PulseAudio (on PipeWire 0.3.56)
    Server Version: 15.0.0
    Default Sample Specification: float32le 2ch 48000Hz
    Default Channel Map: front-left,front-right
    Default Sink: alsa_output.pci-0000_0a_00.4.iec958-stereo
    Default Source: alsa_input.usb-046d_HD_Pro_Webcam_C920_A35E7F4F-02.analog-stereo
    Cookie: c74a:d65d

Answer: Run these two commands:
sudo apt-get install pulseaudio-module-bluetooth
killall pulseaudio
Try to connect again.
Solution source
Comment: Please be a little cautious with using *exact* copy and paste answers for slightly different questions on AU...
Comment: @andrew.46 Yes, but this answer worked for me with the exact same question as ggnoredo's.


Subsheaf generated by one section is coherent

Question: I'm working on exercise II.5.15 in Hartshorne's book. I need to prove the following bit.

Let $ X $ be a noetherian scheme. Let $\mathscr {F }$ be a quasi coherent sheaf on $ X$. Then the subsheaf $ \mathscr{G}\subset\mathscr{F}$ generated by $s\in \mathscr{F}(X)$ is coherent.

One idea I have is to show that $ \mathscr{G}(V)=\mathcal{O}_{X}(V)s$. I'm unable to prove that the gluing axiom of sheaves in this case.
This answer explains the idea of a subsheaf generated by sections. However, the definition is nonconstructive and I don't see a way to use it:
Some question of sheaf generated by sections
As a bonus, can we generalise this question to finitely many sections?
Answer: 0) To a section $s\in \mathscr F(X)$ of an $\mathscr O$-module (quasi-coherent or not) we can associate a morphism of $\mathscr O$-modules $h=h_s:\mathscr O\to \mathscr F$ given by $\mathscr O(U)\to \mathscr F(U):f\mapsto f\cdot (s\mid U) $.
The subsheaf of $\mathscr F$ generated by $s$ is then the image $Im(s)=s(\mathscr O)\subset \mathscr F$ of $h$.
1) If now $\mathscr F$ happens to be quasi-coherent then  that image is quasi-coherent, like any image of a morphism between quasi-coherent $\mathscr O$-modules.
2) The same technique shows that a section of a coherent sheaf generates a coherent subsheaf as soon as $\mathscr O$ is coherent (which strangely is not always the case if $X$ is not noetherian).
NB
Hartshorne defines "coherent sheaf" in an idiosyncratic way , different from the definition in FAC, EGA or essentially all the literature in algebraic or analytic geometry. This is an unfortunate choice.
Comment: Mumford does it too, so it's okay!
Comment: That's incredibly helpful. It's very simple once you put it this way.
Comment: Dear Peter, I'm glad you find the answer simple and helpful.


Extract plain text from silverlight rich text box - LINQ to XML

Question:
I am trying to get the plain text from the xaml content of the SL 4 rich text box.
The content looks like this:

    <Paragraph FontSize=\"12\" FontFamily=\"Arial\" Foreground=\"#FF000000\" FontWeight=\"Normal\" FontStyle=\"Normal\" FontStretch=\"Normal\" TextAlignment=\"Left\">
         <Run Text=\"Biggy\" />
    </Paragraph>

When I try this:
            XElement root = XElement.Parse(xml);
            var Paras = root.Descendants("Paragraph");
            foreach (XElement para in Paras)
            {
                foreach (XElement run in Paras.Descendants("Run"))
                {
                    XAttribute a = run.Attribute("Text");
                    text += null != a ? (string) a : "";
                }
            }

Paras is empty.
What am I doing wrong?
Thanks for any hints...
Answer: You need to account for the namespace in your XML when selecting elements, you can use XNamespace to declare and use it - this works:
XNamespace xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
var Paras = root.Descendants(xmlns + "Paragraph");

Answer: Thanks to BrokenGlass.The full function:
string StringFromRichTextBox(string XAML)
    {
        XElement root = XElement.Parse(XAML);
        XNamespace xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
        StringBuilder sb = new StringBuilder();
        var Paras = root.Descendants(xmlns + "Paragraph");
        foreach (XElement para in Paras)
        {
            foreach (XElement run in Paras.Descendants(xmlns + "Run"))
            {
                XAttribute a = run.Attribute("Text");
                sb.Append(null != a ? (string)a : "");
            }
        }
        return sb.ToString();
    }

It worked! Hope this help you.
Nguyen Minh Hien


Listview in a table or tableview

Question: Is it possible to put a listview with database adapter in a Scrollable table of a table view? To me and others this might sound sound silly but I already have an app coded with multiple scrollable table areas. The screen is split into 4 quadrants with data in each. The data comes from one table in a database. The display always works really great.
This part is for all to hear: I have coded the database data displays into each quadrant with tablerow objects. The problem arises when deleting records. The application has to update all the other table views. This will promote two monsters: 1:)app way too big and 2:) Slow performance. I have a demon crawling up my back that tells me I am programming myself into a corner.
Any hacks, concerns, or start overs are welcome.
Comment: I see this: http://stacktips.com/tutorials/android/android-table-layout-example. I don't see any search returns for a listview in a tableview. I smell a rewrite encroaching...
Comment: I believe this might set a better course of action/repair to what I want to do as compared to how the android application is set up for originally. http://www.tutorialsbuzz.com/2014/01/android-loading-sqlite-data-tablelayout.html
Answer: There is a open source library whois name is TableView that is located in github.
There is also a sample app in this repo to display how it can us your own app.

Listview in a table or tableview


I am new on sqlite3 when I want to create a table on my raspberry,I meet a question insouble this is my code

Question:
CREATE TABLE  tempANDhum_data(
    ID INTEGER PRIMARY KEY,
    temperature   NUMERIC NOT NULL,
    humidity  NUMERIC NOT NULL,
);

Comment: Welcome to Stack Overflow! Please read [ask] and https://stackoverflow.com/editing-help .
Answer: Remove the last comma within the CREATE TABLE command.
Comment: Please upvote and mark the accept the answer if it answers your question, thanks!


Python shutil.copytree saying Destination file it should be copying is missing

Question: been fighting with this all night.  Worked like 3 days ago, now I can't get it to work for the life of me.
When I try using this
 def unzip_file(archiveFile, finalFolder, archiveFolder):
    write_to_log(logFile, 'Unzipping file ' + archiveFile)
    shutil.copy(tempFolder + '/' + archiveFile, archiveFolder)
    try:
        zip_ref = zipfile.ZipFile(tempFolder + '/'+ archiveFile, 'r')
        zip_ref.extractall(tempFolder)
        zip_ref.close()
        if os.path.exists(finalFolder):
            shutil.rmtree(finalFolder)
        sleep(5)
        shutil.copytree(tempFolder, finalFolder, symlinks=True)
    except zipfile.BadZipFile as e:
        write_to_log(logFile, 'Unzipping file ' + archiveFile + ' failed.  Bad Zip File.')
        shutil.copy(tempFolder + '/' + archiveFile, zipFailFolder)

I ALWAYS get the same error no matte what zip file I feed it.  It says the destination file is missing.  The first file in the zip file give me the following error.
shutil.Error: [('D:/temp/file.zip', '//DestPath/file.zip', "[Errno 2] No such file or directory: '//DestPath/file.zip'")]

I am totally out of ideas.  Its not a permission issue, its not the fact the file is missing from the source, the file isn't locked (threw that timer in there just in case).
Anyone run across this before?
Answer: That means your //DestPath doesn't exist in first place, so file.zip can't be created there.
Are those double slashes intentional?
Comment: Yes, they are, its a file share.  I sanitized the folder names because they were long as heck.  The folder is there, I can go look at it.  It creates the folder, then tries to move the first file and errors out.
Comment: Try changing the folder name to some other local folder to test; Also make sure the user running the script has write permissions in the destination folder.  I'm still convinced the problem is in the destination folder @OmegaNine
Comment: After running a few more tests it looks like i gave you some misinformation.  All the files move over fine except the zip file.  The zip file is the actual file i unzipped.  I am thinking maybe its locked still?  Running in more circle, but thank you for making me look at it from another angel.
Comment: I have no idea why this worked, but I moved the zip out of the folder before doing the shutil.copy and it works fine now.  I wouldn't have done that without your help though.  Thanks!


Laravel Storage method allDirectories() does not return recursively directories from FTP server

Question: I need to get list of all directories from the FTP server.
After successful FTP driver setup, Storage::allDirectories() method is returning all directories from root directory. I have also tried to use:
Storage::directories('/', true)
Which should also return recursive values but it's the same case.
Does anyone have any idea what should be problem?
This is my FTP connection setup:
$ftp = Storage::createFtpDriver([
   'host' => $streamServer->url,
   'username' => $streamServer->username,
   'password' => $streamServer->password,
   'port' => '21',
   'timeout' => '30',
]);

Comment: you will have to iterate over the directories list recursively yourself,
Comment: That's what I am doing at the moment but I was hoping to find optimal solution. But thanks for your feedback.
Answer: Welcome to Stackoverflow
I have checked with my code and it's working when I added the following line in my filesystems.php
I have created ftp driver in filesystems as below.
'ftp' => [
        'driver' => env('DOCUMENT_UPLOAD_DRIVER','sftp'),
        'host' => env('DOCUMENT_UPLOAD_HOST','127.0.0.1'),
        'username' => env('DOCUMENT_UPLOAD_USERNAME','root'),
        'password' => env('DOCUMENT_UPLOAD_PASSWORD','root'),
        'root'=> env('DOCUMENT_UPLOAD_ROOT', '/var/www/html')
        'port'     => env('DOCUMENT_UPLOAD_PORT', 22),
        'timeout'  => env('DOCUMENT_UPLOAD_TIMEOUT', 30),
    ],

this line is additionaly added.
'root'=> env('DOCUMENT_UPLOAD_ROOT', '/var/www/html')

and when I use the following command it works for me.
Storage::disk('ftp')->allDirectories('directoryName');

provide directory name from which you want to get list or leave blank will provide you the list of all the recursive directories from html directory because we have provided it as a root.
after that you need to extract directories manually, as it just gives you an array like namespace will all the recursive directories.
Comment: The thing is that users have to add ftp parameters by themselves so I have to setup connection in Controller.

But I have now tried with another FTP server and allDirectories() method worked fine... Seems like it has to do something with FTP server but I am not sure what could that be.

Edit:
Difference between old and new FTP is that the old one has more that 2000 directories only in root, and the new FTP where recursion worked, has only 100 directories.
Perhaps there is some problem with number of directories.


Check for duplicate names in text file and change them C#

Question: I am trying to write to a file with around 20 fields. That part works. The first field needs to be unique (can't have duplicates). I cannot figure out how to take only the first field(column) and compare it to the rest in that column. Also I am not sure how to get the variable from the file. The field is a combination of the first and last name. That works just fine but I need to run through the userName and compare it to the rest of them. If another one is the exact same, I need a number added to one of them.
This is what I started but I am not sure now to continue:
class userName
{
    public string Name(string userName)
    {
        string initialUserName
        string tempUserName = string.Empty;
    }
}

This is how I create the user name:
username = firstName.Substring(0, 4) + lastName.Substring(0, 4);

Comment: You say you are using Streamwriter to write your file yet I can't seem to find it in your code
Comment: does it need to be a text file? people could edit it easily by hand then.. add dups etc.. how are you writing it - what is its purpose
Comment: @Gianlucca I wanted to try to uses StreamWriter but I'm not sure how.
Comment: Then update your question to "How to use StreamWriter". You have a misleading title
Comment: @BugFinder yes it does. Well I have an original file that is not in the correct format or layout. I need to rearrange the fields and do some formatting to certain fields. The user name being one of them. I haven't had any issues with any of the other fields.
Answer: Without knowing the specifics of how you are writing these "fields," im assuming a single line (row) of your file contains all 20 fields. Hopefully you have delimited each of these fields. You should be able to get all the variables in the first column by reading the lines of the file, one at a time, and using the String.Split method to get a string array containing all of your 20 fields. Simply compare the first array member to your new value, if its equal then append a number to the new string, continue this until all rows are parsed.
Comment: basically each line is a persons name and their information. I read the contents of the original file, format what needs to be, and then write to a new text file.
Comment: @imsohappy So giving what you just said, my above stated answer should suffice. Just a tip or two: if you know the first field is what you are comparing, you could also use string.substring(0, string.firstindexof([your delimiter])), I have not bench-marked, so I cannot guarantee this would be more optimal, but its another idea. Also (unless there is a specific need for rewriting the entire file) consider appending the original file.
Answer: Hope this will help. Use streamreader and streamwriter to read and write the text file. Create hashtable store the column read value in it. If you find same content just don't write it.


Finding a polynomial sequence approximating certain function on complex plane

Question: I'm trying to find a polynomial sequence on complex plane, which converges to $1$ on the upper-half plane, $0$ on the real line, and $-1$ on the lower-half plane...but just don't have a clue.
Thanks for any help!
Comment: Let's see ... you have no clue, but you just covered Runge. Correct?
Comment: Yes...It's an exercise.
Comment: I was thinking if something look like $\arctan z$ will work...
Answer: Typically a polynomial will not converge to a finite limit. Consider any polynomial of the form $\sum_{i=0}^na_iz^i$. You will always be able to find values of $z$ such that it diverges as for large enough values of $|z|$ it will be dominated by the highest power.
If are after a power series (effectively an infinite polynomial) then the taylor series of either:
$$\frac{2}{\pi}\arctan(\Im z)$$
or
$$\frac{2}{1+e^{-\Im z}}-1$$
would fit your criteria.
However I get the impression that probably wasn't what you were after. Perhaps you can clarify your question.
Comment: Is that the imaginary part of $z$ that you used in your expression?
Comment: Yes. Latex renders "Im z" as $\Im z$.


How to check for empty variable in PHP Opencart?

Question: I am trying to check if $video variable is empty. I am using PHP based Opencart version 2x. My setup is:
Controller:
$product_info = $this->model_catalog_product->getProduct($product_id);
$data['video'] = $product_info['video'];

View:
<img src="<?php echo $video?>" />

I have tried using inbuilt function empty function :
if (empty($video)) {
  echo "Variable 'a' is empty.
";
}

but it's not working.
Answer: First of all, check if model is implemented in controller. It should work like this
$this->load->model('catalog/product'); // this should be added somewhere before
$product_info = $this->model_catalog_product->getProduct($product_id);
$data['video'] = $product_info['video'];

If you are checking $video in controller - the style will be:
if (empty($data['video']) {
  echo "Variable 'a' is empty.
";
}

For the view (.tpl file) it will be:
<?php if (empty($video)) { ?>
   Variable 'a' is empty.

<?php } ?>

Comment: Thanks for the response and sorry for the slow reply.

After the checking ( Controller and Model all working ) , and i have followed the "view" code that you provided , it managed to work , which means that my view is wrong when "echo-ing" the result .


Can D.Va hide behind teammates to protect herself from her own Self Destruct ultimate?

Question: D.Va's ultimate Self Destruct will do damage to her if she's within line of sight of her mech, so by hiding behind cover, D.Va can avoid being killed by her own ultimate.
Is it possible for D.Va to use her own teammates as cover to protect herself from her own ultimate? So, for example, could a D.Va player hide behind a friendly Roadhog to avoid taking from her own ultimate?
Comment: I doubt a roadhog would work, but I wonder if a friendly *barrier* would
Comment: @DarthPizza, you may wish to switch your accepted answer to jojo's, as a recent patch has changed this (now D.Va is immune to her self-destruct and simply no longer needs to hide)
Comment: @DoktorJ Yuuki's answer is the one that helped me at the time when it was relevant, so I will leave it as the accepted answer. Just upvote the most up-to-date one, it's timestamped anyways.
Answer: Long overdue update to this answer: D.Va can no longer self-damage with her ult, so this question/answer is moot.
Previous answer:
D.Va can't use allied hitboxes or allied barriers to block self-damage from her ultimate. She can, however, use an enemy barrier (Winston's or Reinhardt's, but not Zarya's as it is targeted) to block self-damage.
Comment: Mei's Ice Wall also works.
Comment: As addition: She can also not use enemy hitboxes to block the damage. https://youtu.be/LzuapRj_LeA?t=1m54s
Comment: What about hiding behind a friendly Mei that just Cryo-Freezed herself? I read that Mei can be used as cover in those situations, but I'm not sure if that applies for when you're trying to avoid damage from your own D.Va ultimate.
Comment: You may want to change the wording. At a glance I though you meant Dva not being immune to her ult was the "long overdue update"
Answer: As of today's patch, the player who casts Self-Destruct is now immune to their own explosion:

Self-Destruct

Ultimate cost decreased by 15%
Explosion delay reduced from 4 seconds to 3 seconds
Explosion no longer damages D.Va (the player who activates it)


Find the sum: $\sum_{n=1}^{\infty} \ln\left(\frac{b+n+1}{a+n+1}\right)$

Question: Let $0<a<b$, I would like to compute the sum
$$\sum_{n=1}^{\infty} \ln\left(\frac{b+n+1}{a+n+1}\right).$$
But first I am worrying that a test convergence might lead to the divergence of this series
What do I miss here?
$$\begin{split}\sum_{n=1}^{\infty} \ln\left(\frac{b+n+1}{a+n+1}\right)&= \sum_{n=1}^{\infty} \int^{\frac1{a+n}}_{\frac1{b+n}}\frac{dx}{x+1}\\
&= \sum_{n=1}^{\infty} \int_{a+n}^{b+n}\frac{dt}{t(t+1)}~~~~(t= 1/x)\\
&= \sum_{n=1}^{\infty} \int_{a}^{b}\frac{dt}{(t+n)(t+n+1)}\\
&=\int_{a}^{b}dt \sum_{n=1}^{\infty} \frac{1}{t+n}-\frac{1}{t+n+1}~~~(\text{Monotone convergence})\\
&= \int_{a}^{b}\frac{dt}{t+1} ~~~~(\text{by Telescoping sum})\\
&= \ln\left(\frac{b+1}{a+1}\right) \end{split}$$
However the series seems $\sum_{n=1}^{\infty} \ln\left(\frac{b+n+1}{a+n+1}\right)$ not to be convergent.
Have I missed something ?
Answer: HINT:
Note that if $a\ne b$, then
$$\begin{align}
\int_{1/(b+n)}^{1/(a+n)}\frac1{x+1}\,dx&=\log\left(\frac{1+1/(a+n)}{1+1/(b+n)}\right)\\\\
&=\log\left(\frac{a+n+1}{a+n}\frac{b+n}{b+n+1}\right)\\\\
&\ne \log\left(\frac{a+n+1}{b+n+1}\right)
\end{align}$$
Comment: OOO my GoD a big mistake. thanks
Comment: You're welcome.  My pleasure.
Answer: Btw., the series does not only seem divergent but it is divergent indeed as can be seen as follows:
$$\ln\left(\frac{b+n+1}{a+n+1}\right) = \ln (b+n+1) - \ln(a+n+1) \stackrel{a < \xi_n < b}{=}(b-a)\frac{1}{\xi_n+n+1} \geq (b-a)\frac{1}{\lceil b\rceil+n+1}$$
Hence, the given sum has a divergent tail of the harmonic series as a minorant.
Answer: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\bbox[10px,#ffd]{\left.\sum_{n = 1}^{N}\ln\pars{b + n + 1 \over a + n + 1}
\,\right\vert_{\ 0\ <\ a\ <\ b}} =
\ln\pars{\prod_{n = 1}^{N}{n + b + 1 \over n + a + 1}} =
\ln\pars{{\bracks{b + 2}^{\overline{N}} \over \bracks{a + 2}^{\overline{N}}}}
\\[5mm] = &\
\ln\pars{\Gamma\pars{b + 2 + N}/\Gamma\pars{b + 2} \over
\Gamma\pars{a + 2 + N}/\Gamma\pars{a + 2}}
\\[5mm] \stackrel{\mrm{as}\ N\ \to\ \infty}{\sim}\,\,\,&
\ln\pars{\Gamma\pars{a + 2} \over \Gamma\pars{b + 2}} +
\ln\pars{\root{2\pi}\pars{N + b + 2}^{N + b + 5/2}\expo{-N - b - 2} \over
\root{2\pi}\pars{N + a + 2}^{N + a + 5/2}\expo{-N - a - 2}}
\\[5mm] \stackrel{\mrm{as}\ N\ \to\ \infty}{\sim}\,\,\,&
\ln\pars{\Gamma\pars{a + 2} \over \Gamma\pars{b + 2}} +
\ln\pars{{N^{N + b + 5/2}\,\bracks{1 + \pars{b + 2}/N}^{N} \over
N^{N + a + 5/2}\,\bracks{1 + \pars{a + 2}/N}^{N}}\,\expo{-\bracks{b - a}}}
\\[5mm] \stackrel{\mrm{as}\ N\ \to\ \infty}{\sim}\,\,\,&
\ln\pars{\Gamma\pars{a + 2} \over \Gamma\pars{b + 2}} + \pars{b - a}\ln\pars{N}
\,\,\,\stackrel{\mrm{as}\ N\ \to\ \infty}{\LARGE\to}\,\,\,\bbx{+\infty}
\end{align}


In what ways will 4GB limit my Xbox usage?

Question: Microsoft recently announced that "Kinect bundle" that includes Kinect and Xbox 4GB. The price is good, I'm thinking of getting one - but I have two questions:

In what ways 4GB would limit my Xbox usage?
Will I be able to extend the storage if needed, either using internal or external storage?
Comment: Great question.
Answer: The 4GB refers to a 4GB memory unit for the system. You use the storage for saved games, user profiles, downloads from Xbox Live, and "downloading" a game disk to your Xbox for faster loading. The only thing you would be missing out on that really matters is space for demos, videos, and other content from Xbox Live, as you won't have much space for them.  Game demos are several GB each, so the built-in 4GB won't hold many.
The upside is that there are several choices to upgrade the space in your system. USB thumb drives can be used for storage space in an Xbox 360.  You can buy 16GB flash drives from ~$30 any more, so that's one way you could go. Another method is to buy one of the internal Xbox hard drives. According Aaron Greenberg, via Joystiq, 'this 4GB unit "absolutely does have that expansion bay that we have the opportunity to use in the future."'  So you will be able to buy any of the Xbox 360 S-capable hard drives to put in your expansion slot.
Comment: USB flash drive is a good solution. More here: http://gaming.stackexchange.com/questions/3140/usb-flash-drives
Comment: Won't using a USB drive be incredibly, tortiously slow?
Comment: 4GB refers to storage not "memory unit", edit?
Comment: @AnthonyBlake "4GB memory unit" is the terminology the Xbox team uses in the system for the 4GB integrated flash memory bank. I used to have an Arcade that showed it as "MU", meaning memory unit. I don't have it anymore, but I don't think they've changed terminology.
Answer: The only thing "wrong" with it is the 4GB disk (not all of that will be usable - some is used for the OS and such). I have a 120GB Elite, and I love that I can install/copy games to the hard drive. This makes the Xbox run much quieter, and generally speeds up loading times.
It's also nice not to worry about deleting DLC and downloaded games (even though there is the option to re-download them). More space is generally better.
Answer: I have a 4 GB console. I have plenty of games through the Marketplace and yet i can't play them all. Some other games will also lack features: I just bought Forza 4 for 59$ and, to my disappointment, there are no replays available...
4 GB are good if you don't want to download content and save games.
Comment: Is this an answer or a rant?
Answer: The limits you will encounter are as follows;
Downloading content from Xbox Live or disk, games on demand for example; Destiny is 6.8GB to download as a full game and can only be ran from a HDD. Meaning USB won't cut it.
Demos range from under a gigabyte(GB) to the size of the game disk(i.e, arcade demos are the same as the full version in size and are meerly activated and registered to the Xbox.
You can download all your C.D's to your Xbox, they will be compressed, though once again HDD only.
The larger HDD will cost you around $100-$170AUD to buy later, though in the deal above the one your looking at you get the larger HDD and another controller and a game or two for the extra $100-$150. So if you get that, sell the game and controller for 50.
Disks can be downloaded to run off the Xbox as long as the disk is in the tray, and the first thing to go is generally the disk drive if you play for long periods or music games like guitar hero.
Streaming movies through live will be fine, though if you want to buy and download them then keep in mind movies are around 6GB in size generally.
USB storage is limited to 32GB for any size of USB over 32GB too.
I'll add more if it crosses my mind.


How to Replace timer with turn based onClick in Android?

Question: I am trying to make a TicTacToe online multiplayer game in Android Studio using Firebase, below is the code I am using for the buttons (1 of the 9 blocks of TicTacToe). Right now I am using a timer to stop the user from clicking any other buttons after he once click the button to give the other user time to click. But I want to make it so that one user won't be able to click any button till the other user clicks a button. Is there a way to do so?
The default values of nothing & face & a1 is "zero" and default value of added is "one" whereas rface is just a string variable getting its value from "face".
//below clicking
        a1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //below
                //starting if condition
                if (ra1.equals(nothing)){

                    if (rface.equals(nothing)){
                        a1.setBackgroundResource(R.drawable.rounded);
                        Firebase refChild = ref2.child("a1");
                        refChild.setValue("round");
                        refChild = ref2.child("face");
                        refChild.setValue("one");
                    }

                    else if (rface.equals(added)) {
                        a1.setBackgroundResource(R.drawable.crossed);
                        Firebase refChild = ref2.child("a1");
                        refChild.setValue("cross");
                        refChild = ref2.child("face");
                        refChild.setValue("zero");
                    }
                    //timer below

                    a1.setClickable(false);
                    a2.setClickable(false);
                    a3.setClickable(false);
                    b1.setClickable(false);
                    b2.setClickable(false);
                    b3.setClickable(false);
                    c1.setClickable(false);
                    c2.setClickable(false);
                    c3.setClickable(false);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            a1.setClickable(true);
                            a2.setClickable(true);
                            a3.setClickable(true);
                            b1.setClickable(true);
                            b2.setClickable(true);
                            b3.setClickable(true);
                            c1.setClickable(true);
                            c2.setClickable(true);
                            c3.setClickable(true);
                        }
                    }, 3000);
                    //timer above
                }
            }
        });

Comment: Variable names which end in a number usually indicate that you should use an array or List.
Comment: As to your actual question, do you have a computer player or is this built for two human players? Are the two human players playing on the same device or over a network?
Comment: Your variable names are a little confusing. What do `ra1` and `rface` mean? What is `nothing` and `added`?
Answer: I suggest having two different OnClickListeners rather than an if statement. One for Xs and the other for Os. Then you can set the listener back and forth. For example, at the end of the OnClickListener for X, it calls setOnClickListener() using the one for Os.
Comment: can you please provide me with some code example that would be really helpful, thank you.
Answer: I finally came up with this algorithm for my solution:
online=0;
offline=1;

if (online!=offline){
    offline=random;
    online=offline;
    if(shape=0)
    {
        click(set round);
    }
    else if(shape=1)
    {
        click(set cross);
    }
}

where shaper is another integer which I am using as a switch.


Why would a bathroom faucet bib (spigot) have a tap?

Question: My house was built in the 1950s. I was redoing my bathroom, and I noticed there was a pipe coming out of my pipe. Someone tapped onto the 1/2 inch cold-water faucet bib. What could be the reason for this? Whatever was on the other side of the tap isn't there anymore it was copper tube crimped and bent over.

I know it's just speculation, but why?
Comment: @RayButterworth I've never met a cold water only bidet and hope not to, but I suppose it could be British. Or might have an instant water heater. The line might be for an instant water dispenser adjacent to the throne for the King's/Queen's tea whilst pondering the issues of the subjects.
Comment: I'm voting to close this question because "You should only ask practical, answerable questions based on actual problems that you face. Chatty, open-ended questions diminish the usefulness of our site and push other questions off the front page." There is no way of providing an answer to this without finding a previous owner of the house who has the answer in hand. Anything else is pure speculation, and there's no practical, correct answer to this question.
Comment: For the steam generator.  You do have a steam room, right?  Was it on the hot or cold line?  Humidifiers and ice makers have different preferences.
Comment: was the cold line
Comment: Perhaps a bidet?
Answer: We had two of those in the Midwestern home I grew up in. One was to feed a humidifier installed in the furnace duct and the other one was for the ice maker for the refridge. Back then, those appliances weren't pre-plumbed.
Comment: I really like the humidifier theory in the furnace... that makes the most sense imho. The only thing I could come up with was a ice machine in the bathroom. Your theory makes more sense. Especially being it shared a wall with the bedroom. So perhaps that explains it.
Comment: @EvanCarroll  It could also have been for a bidet.
Answer: Really, it could be for any reason - you'll probably never know. Humidifier, ice maker, instant hot water maker (coffee, tea, soup, etc). Why they chose the bathroom is also a question.
By the way, those are quick, DIY devices. I never use them because they eventually leak and are usually in places where you don't realize it's leaking - good riddance.
Comment: yep, re-pexing that vertical drop. good riddance is right. that unionized plumbing labor from Texas in the 1950s, good horror story.