text:
Q: Android: Obtaining image URL directly from Parse For fetching url for images from Parse, I have implemented the below codes from Parse.com's examples, as follows:
Code:
@Override
protected Void doInBackground(Void... params)
{
    // Create the array
    url_photoarraylist = new ArrayList<String>();
    all_info_photoarraylist = new ArrayList<Photos>();
    try
    {
        ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("photo_database");
        query.orderByAscending("photo_id");
        ob = query.find();
        for (ParseObject photo_data : ob)
        {
            ParseFile image = (ParseFile) photo_data.get("photo_file");
            Photos map = new Photos();
            map.set_photo_ref(image.getUrl());
            map.set_user_name((String) photo_data.get("user_name"));
            url_photoarraylist.add(map.get_photo_ref());
            all_info_photoarraylist.add(map);
        }
    }
    catch (ParseException e)
    {
        Log.e("Error", e.getMessage());
        e.printStackTrace();
    }
    return null;
}

Question:
While this works successfully, since I have also used UniversalImageLoader at https://github.com/nostra13/Android-Universal-Image-Loader to load Parse images to GridView, where at there it also re-download the same set of images using URL, I would like to ask whether at the above code, just to obtain the image URL directly instead of getting a ParseFile?
Thanks!

A: As written here, running a Parse query does not download the contents of the PFFile. This means that running your query to get the PFFiles, and then using UniversalImageLoader with image.getUrl(); won't result in the image downloading twice.


text:
Q: Can't create a view with a select with a case when clause If I execute the select part, it works and I get the information but if I try to do a view of this select and then call to that view it says "ORA-00942: table or view does not exist ". I have other views without the case when clause that works.
    $oracletext10="create or replace view consulta1
     as (SELECT ArticulosCanal99.CODIGO,
                ArticulosCanal99.UBICACION,
                SumaArticulosenPalets.CODIGO,
                SumaArticulosenPalets.UBICACION,
                case ArticulosCanal99.codigo when
                    SumaArticulosenPalets.codigo then 1 end as Expr1,
                ArticulosCanal99.UNIS_PALET_COMPLETO AS Palet_Completo
    FROM SumaArticulosenPalets
    RIGHT JOIN ArticulosCanal99
       ON SumaArticulosenPalets.CODIGO = ArticulosCanal99.CODIGO)";

    $stid10 = oci_parse($db,$oracletext10);
    oci_execute($stid10);

A: To elaborate on @RobvanWijk's comment:
Quoting here from the Oracle 11.2 SQL reference's page on CREATE VIEW, "The owner of the schema containing the view must have the privileges necessary to either select, insert, update, or delete rows from all the tables or views on which the view is based. The owner must be granted these privileges directly, rather than through a role". So your user has been granted privileges on the base tables/views of your new view through a role, and can thus execute the SELECT statement successfully. However, when you go to create a view from this SQL statement your user's role-based permissions are not sufficient: you'll need to execute the following GRANT statements to be able to create the view:
GRANT SELECT ON SUMAARTICULOSENPALETS TO your-user-here;
GRANT SELECT ON ARTICULOSCANAL99 TO your-user-here;

replacing "your-user-here" with the user name you're using.
Best of luck.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Haskell parsec match if (3) as if (3 > 0) I'm using Parsec and the example version of boolExpr http://hpaste.org/86299 at the moment. I'm compiling on Windows via GHC.
The code above will match a boolean expression like 3 < 4 or a not 3 however it will not match an expression like 3, true or (((3 < 1))). Can anyone give me advice on how to match such expressions like 3 and (((3 < 1))) the same as 3 > 0 and (((3 < 1))) > 0, where the >0 is assumed/added automatically on RHS-less expressions?

A: This looks like you're trying to push the semantics of your language into a syntax parser. The "correct" thing to do from a programming-languages perspective is to accept both number and boolean-valued expressions in your syntax tree. Then, at a later stage -- type reconstruction not parsing -- decide that number-valued expressions get a single "> 0" added to them while boolean valued expressions do not.


text:
Q: Log is not getting printed for Extent Test Manager reports I am using extent test manager reports but while the reports are generated there are no step name column added in the reports that is generated
I have used the below method:
ExtentTestManager.getTest().log(LogStatus.PASS,"Click on the \"Add Alarm Group\" button.","'Add Alarm Group' should be clickable.");

Issue is that the 2nd parameter in the .log is not getting printed that is the step name.

A: If you are using the latest version 3 of Extent Reports you can actually use the Markups to achieve a better reporting, please find below the code
String stepName = "Click on the \"Add Alarm Group\" button.";
String description = "'Add Alarm Group' should be clickable.";

String code = "Step Name: " + stepName + "\nDescription: " +
description;
Markup m = MarkupHelper.createCodeBlock(code);
t1.pass(m);


text:
Q: Parsing calculation tree from string I there any built in library in c# or automatic code generator which recieves configuration file and builds parser of calculaton tree from string if there is no could you please help me with advice
Example:
"-2+5>3" I would like to build calculation tree where < is root '+' is its right son 3 is left son '-2' is left son of the + and 5 is its right son.
And the tree could do evaluation in this case true or false.
Thank you.

A: Take a look at sprache.  It's a simple parser which would allow you to build the expression tree and then evaluating it should be the easy bit.

A: Have you looked at the System.Linq.Expressions? for example How to convert string into System.Linq.Expressions.Expression in C#?

A: The Irony library is very simple to use, and comes with an expressions parser in the examples.

A: If your goal is evaluating the expression and not the tree itself - you can look at this:
http://www.codeproject.com/KB/recipes/sota_expression_evaluator.aspx
It's probably worth noting, that the implementation of most expression evaluators is using RPN.
http://en.wikipedia.org/wiki/Reverse_Polish_notation


text:
Q: multiple choice question on holomorphic functions
Possible Duplicate:
analytic functions defined on $A\cup D$

Let $f$ and $g$ be holomorphic functions defined on $A\cup D$ , where $A=\{z\in\mathbb{C}:1/2<|z|<1\}$  and   $D=\{z\in\mathbb{C}: |z-2|<1\}$. Which of the following are true?

*

*If $f(z)g(z)=0$ for all $z\in A\cup D$, then either $f(z)=0$ for all $z\in A$ or $g(z)=0$ for all $z\in A$.

*If $f(z)g(z)=0$ for all $z\in D$, then either $f(z)=0$ for all $z\in D$ or $g(z)=0$ for all $z\in D$.

*If $f(z)g(z)=0$ for all $z\in A $, then either $f(z)=0$ for all $z\in A$ or $g(z)=0$ for all $z\in A$.

*If $f(z)g(z)=0$ for all $z\in A\cup D$, then either $f(z)=0$ for all $z\in  A∪D $ or $g(z)=0$ for all $z\in  A\cup D$.

How should I solve this problem?


text:
Q: HTACCESS Works, But php $_GET Does Not I have read through almost every post regarding this issue, and nothing seems to work.
I have successfully rewritten the below code, and it works just fine. The .htaccess file is in the /~user/business/ folder. I use RewriteRule ^index/([0-9]+)/?$ /index.php?id=$1 [QSA,PT] while accessing http://localhost/~user/business/index/155/. However, when I try to get the variable in php, it returns nothing. The rewrite works as it does load index.php, but no get variables at all.
My main goal, I want to access the id from the code above, but nothing shows up. <?php echo $_GET['id']; ?> Even when I try this print_r($_GET); the array of all get variables, it returns an empty array. I also do not want to append the query to the end of url at all.
Lots of posts have answers that work according to responses, and even when I copy them word for word, letter for letter, changing the directories and addresses, nothing seems to work.
I am using Apache 2, set up on a MAC as localhost. Is there something wrong, maybe in the php.ini file?

A: After many times trying, as much as reconfiguring the entire virtual host setup on my mac, I realized that it was a very simple error once I realized it, and it had nothing at all to do with my .htaccess file.
My file name was index.php and my rewrite was RewriteRule ^index/([a-zA-Z0-9_-]+)/ index.php?id=$1 [NC,L] and for some reason, it will not let me use ^index if there is a file called index.php. I can name ^index to ^page or ^blue or anything else but not ^index and it will work fine.
What I realized was that my /index.php page can be loaded simply by typing /index. And therefore, was not actually a redirect, it was the stand alone page.
In order to fix this I had to add a few lines of code to my vhost.conf or my user.conf file under <Directory "/Users/User/Sites"> file using the terminal.
sudo nano /private/etc/apache2/extra/httpd-vhosts.conf

and in this, the code I had to removed MultiViews from the options.
<Directory "/Users/User/Sites">
    Options Indexes FollowSymLinks SymLinksifOwnerMatch MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

so it now looks like this
<Directory "/Users/User/Sites">
    Options Indexes FollowSymLinks SymLinksifOwnerMatch
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Once I did so, /index.php page can no longer be loaded by typing /index. And therefore, I could use the code I originally used in my .htaccess file. And all is solved in paradise. It took a lot of very hard digging and one major headache.
Thanks for your help guys.


text:
Q: How to set up a layout using code and not XML I'm learning to develop android apps and in the process I realized that there two ways to get a job done. Using xml or normal code. Suppose I want to change the position of a button, I'll be doing it in xml using align left/align centre etc., This will be done in the XML file. If I want to achieve the same through code, where should I place the code ? Inside which class ?

A: There are two aspects to your question that I understand.
 1. Creating a whole layout file dynamically (without XML).
 2. Creating a layout through XML and changing the components positions and properties dynamically through your activity file.
Now, it's upto the developer what he wishes to choose.
To help you further, please view this video link posted by the Android team.
It's all about layouts and includes how to layout apps using Java, not XML. However, you are warned that the android team wants you to use XML.

A: The code will be placed in the same class as the class where you reference your xml code. Do a read up in your android docs for insight.


text:
Q: How to prove this sufficient condition for when a monomial ideal is primary. This answer does a good job at explaining that if $I$ is primary monomial ideal in $k[x_1, \dots, x_n]$, then $I = (x_{i_1}^{a_1}, \ldots, x_{i_m}^{a_m}, m_1, \ldots, m_k)$ where $m_1, \ldots, m_k$ only involve variables among $x_{i_1}, \ldots, x_{i_m}$.

However, it doesn't show that if $I = (x_{i_1}^{a_1}, \ldots, x_{i_m}^{a_m}, m_1, \ldots, m_k)$ as above, then $I$ is primary.
How do we prove this?
One thing we know is that if $I = (x_{i_1}^{a_1}, \ldots, x_{i_m}^{a_m}, m_1, \ldots, m_k)$ where $m_1, \ldots, m_k$ only involve variables among $x_{i_1}, \ldots, x_{i_m}$, then ${\rm rad}(I)=(x_{i_1}, \ldots, x_{i_m})$ which is prime.

A: As you mentioned, $\sqrt{I} = (x_{i_1}, \ldots, x_{i_m})$ is prime.
Now suppose that $ab \in I$ and that $b^n \notin I$ for all $n \in \mathbb{N}$, i.e. $b \notin \sqrt{I}$.  We want to conclude that $a \in I$.
That $b \notin \sqrt{I}$ implies that $b$ has a monomial component $b_\lambda$ such that $x_{i_l} \nmid b_\lambda$ for each $1 \leq l \leq m$.
Recall that a polynomial $f$ is in a monomial ideal $J$ iff each monomial of $f$ is in the ideal $J$.
Pick a lexicographic ordering that prioritizes all of the $x_{i_l}$, $1\leq l \leq m$, over the other $x_j$. Assume WLOG that $b_\lambda$ is the monomial summand of $b$ with the lowest degree with respect to this ordering.
Now with this lexicographic ordering in mind, consider the product $ab \in I$.  The contributions to the lowest degree term of the product come exclusively from $b_\lambda$ and the lowest degree term $a_\gamma$ of $a$.  Thus $b_\lambda a_\gamma \in I$, and hence is a constant multiple of either $m_i$ or $x_{i_l}^{a_l}$.  In either case we can deduce from $x_{i_l} \nmid b_\lambda$ that $m_i$ or $x_{i_l}^{a_l}$, respectively, divides $a_\gamma$.  Thus $a_\gamma \in I$, and we can iterate the reasoning on the product $(a - a_\gamma)b \in I$ and so on to conclude that every monomial term of $a$ is in $I$, thus $a \in I$.

A: After a reordering of indeterminates we may assume that $i_1=1,\dots,i_m=m$. Let $I'$ be the ideal generated by $x_1^{a_1},\dots,x_m^{a_m},m_1,\dots,m_k$ in the polynomial ring $k[x_1,\dots,x_m]$. Then $\sqrt{I'}=(x_1,\dots,x_m)$ is a maximal ideal, hence $I'$ is primary.
Then notice that $I=I'[x_{m+1},\dots,x_n]$, that is, $I$ is the extension of $I'$ to $k[x_1,\dots,x_n]$. But the extension of a primary ideal to a polynomial ring is also primary; see Extension of primary ideal in polynomial ring.


text:
Q: Print word between two characters by going backward in the line I having problems in extracting the word from a line. What i want is that it picks the first word before the symbol # but after the /. Which is the only delimiter that stand out.
A line looks like this:
,["https://picasaweb.google.com/111560558537332305125/Programming#5743548966953176786",1,["https://lh6.googleusercontent.com/-Is8rb8G1sb8/T7UvWtVOTtI/AAAAAAAAG68/Cht3FzfHXNc/s0-d/Geek.jpg",1920,1200]
I want the word Programming.
To get that line i am using this which narrows it down.
sed -n '/.*picasa.*.jpg/p' 5743548866439293105

So i want it to pretty much find # and then go backward until it hit the first /. Then print it out. In this case the word should be Programming but could be anything.
I want it to be as short as possible and have experimented with
sed -n '/.*picasa.*.jpg/p' 5743548866439293105 | awk '$0=$2' FS="/" RS="[$#]"

A: You can do that with sed (slightly shortened for formatting but works on your original string as well):
pax> echo ',["https://p.g.com/111/Prog#574' | sed 's/^[^#]*\/\([^#]*\)#.*$/\1/'
Prog
pax>

Explaining in more detail:
    /---+------------------> greedy capture up to '/'.
   /    |
   |    | /------+---------> capture the stuff between '/' and '#'.
   |    |/       |
   |    ||       | /-+-----> everything from '#' to end of line.
   |    ||       |/  |
   |    ||       ||  |
's/^[^#]*\/\([^#]*\)#.*$/\1/'
                      ||
                      \+---> replace with captured group.

It basically searches for an entire line that has the pattern you want (first # following a /), whilst capturing (with the \( and \) brackets) just the stuff between / and #.
The substitution then replaces the entire line with just that captured text you're interested in (via \1).

A: Using grep with some Perl regex extensions:
echo $string | grep -P -o "(?<=/)[^/]+(?=#)"

-P tells grep to use Perl extensions. -o tells grep to display only the matched text. To understand what gets matched, break the regex into three parts: (?<=/), [^/]+?, and (?=#). The first part says that the matched text must follow a '/', without including the '/' in the match. The second parts matches a string of non-'/' characters. The last part says that the matched text must be immediately followed by a '#', without including the '#' in the match.
Another grep, using the "\K" feature to "throw away" the match up to the last '/' before the '#':
# Match as much as possible up to a '/', but throw it away, then match as much as you can
# up to the first #
echo $string | grep -oP ".*/\K.+(?=#)"

Using cut and awk to get the first field (splitting on #) followed by the last field (splitting on /):
echo $string | cut -d# -f1 | awk -F/ '{print $NF}'

Using some temporary variables and bash's parameter expansion facilities:
$ FOO=["https://picasaweb.google.com/111560558537332305125/Programming#5743548966953176786",1,["https://lh6.googleusercontent.com/-Is8rb8G1sb8/T7UvWtVOTtI/AAAAAAAAG68/Cht3FzfHXNc/s0-d/Geek.jpg",1920,1200]
$ BAR=${FOO%#*}      # Strip the last # and everything after
$ echo $BAR
[https://picasaweb.google.com/111560558537332305125/Programming
$ BAZ=${BAR##*/}     # Strip everything up to and including the last /
$ echo $BAZ
Programming

A: This might work for you:
sed '/.*\/\([^#]*\)#.*/{s//\1/;q};d' file


text:
Q: In SQL, how can you calculate maximum concurrent number of users I have a table.
this table has usage period of user.
example is follow
|user_id|start_at  |end_at    |
|1      |2014/11/02|2014/11/05|
|2      |2014/11/03|2014/11/07|
|3      |2014/11/08|2014/11/09|

I would like to get maximum concurrent number of users
above case,
Between 2014/11/03 ~ 2014/05, 2 user used.
I would like to get this "2".
Is there an easy way to set this up? What do you recommend?

A: The maximum is going to occur at one of the start_at times.  So, you can do this with a self-join:
select u.start_at, count(*) as numconcurrent
from usage u join
     usage u2
     on u.start_at between u2.start_at and u2.end_at
group by u.start_at

If you want the maximum number, then add:
order by count(*) desc
limit 1;

A: sounds like you may have mis-stated the question. Do you really mean "max" ?   or just the number of users between two dates ? If that is so, then
Select count(*) from table
where start_at < @end
   and end_at > @start

A: sum(case when start_at >= @startdate and end_at <= @enddate
          then 1
          else 0
    end) as total

this would follow a qualifying set declare statement or embedded in a stored procedure. Your choice.
This will increment by 1 every time it sees a row that meets those credentials and sum the total.


text:
Q: how to insert into the singly linked list using double pointers? codepad linkI'm trying to insert into a linked list using double pointers.but i don't understand where i'm going wrong i followed up other links on stack overflow,i even referred to couple of books so please help me.i kept code for insertion at position 1.In the output the previous insertion is lost.
struct node
{
         int data;
         node *next;
};

 void insert(node **head,int k,int pos)//k refers to the element to be inserted
{
   if(pos==1)
   {
    node *newnode=(node *)malloc(sizeof(node));
    newnode->data=k;
    newnode->next=*head;
    *head=newnode;
   }
 }

   void print(node **head)
  {
    printf("the elements are.. ");
    while(*head!=NULL)
    {
      printf("%d ",(*head)->data);
     (*head)=(*head)->next;
    }
   printf("\n");
  }
   int main()
   {
        insert(&head,5,1);
        print(&head);
        insert(&head,4,1);
        print(&head);
      return 0;
  }

sorry for poor indentation.i'm beginner please help me.

A: Your print function is incorrect. You are erasing your head in line (*head)=(*head)->next;. Change function to
void print(node **head)
  {
    printf("the elements are.. ");
    node *temp = *head;
    while(temp!=NULL)
    {
      printf("%d ",temp->data);
     temp=temp->next;
    }
   printf("\n");
  }

You will receive following output:

the elements are.. 5
  the elements are.. 4 5

A: Check this out.
struct node //Missed struct's name
{
    int data;
    node *next;
};

void insert(node **head,int k,int pos)//k refers to the element to be inserted
{
    if(pos==1)
    {
        node *newnode= new node();
        newnode->data=k;
        newnode->next=*head; //You called head which is not a member of node's struct
        *head=newnode;
    }
}

int main()
{
    node *head=NULL;
    insert(&head,5,1);
    insert(&head,4,1);
}


text:
Q: initialization makes pointer from integer without a cast So my code is this
int theTime = [timeEnter.text intValue];

Why does that return the error?
initialization makes pointer from integer without a cast
Thanks.

A: Try
NSInteger theTime = [timeEnter.text intValue];

If this doesn't work, check out the text and make sure it really is an integer e.g. write it to the console with
NSLog(@"%@",timeEnter.text);

A: I tried the same thing, it works fine, just make sure that you have an integer value in the timeEnter.text (I'm guessing it's a textbox)


text:
Q: Cross-build, link issue I have to build a small program to run on a set-top box, and for that I use a specific build toolchain: toolchain-final-mipsisa32r2el-timesys-linux-gnu
The build is composed of 2 parts: one lib static .a file and an executable that use the library.
The lib is correctly build with the following option:
mipsisa32r2el-timesys-linux-gnu-gcc -c --param max-inline-insns-single=2400
-o ../../../build/LinuxHost_STB_release/_outLib/STB.o -O2 -fno-strict-aliasing
-Winline -Wall -I../../../Modules -I../../../Source
-I/opt/toolchains/toolchain-final-mipsisa32r2el-timesys-linux-gnu/include
-I -fno-rtti ../../../Source/STBLib/STB.cpp

if I run nm on the libSTB.a, I saw the function define in STB.cpp as:
 0000000000000124 T STB_Create
 0000000000000460 T STB_Destroy

To compile and link the executable, I use the following command line:
mipsisa32r2el-timesys-linux-gnu-c++ -o ../../../build/LinuxHost_STB_release/STBExample
--sysroot=/opt/toolchains/toolchain-final-mipsisa32r2el-timesys-linux-gnu/
-I/opt/toolchains/toolchain-final-mipsisa32r2el-timesys-linux-gnu/include
-L../../../build/LinuxHost_STB_release
-lSTB ../../../Source/STBLib/STBExample.c

But I get the following linker error:
STBExample.c:(.text+0x488): undefined reference to `STB_Create'

Any idea of where I made a mistake or on how to investigate ?

A: As explained by @H2CO3 and @Joe Z, the problem was in the parameter ordering.
Additional static lib set with -lmust be place AFTER the .c file. As in the following example, a switch of the 2 last arguments solved the issue.
mipsisa32r2el-timesys-linux-gnu-c++ -o ../../../build/LinuxHost_STB_release/STBExample
--sysroot=/opt/toolchains/toolchain-final-mipsisa32r2el-timesys-linux-gnu/
-I/opt/toolchains/toolchain-final-mipsisa32r2el-timesys-linux-gnu/include
-L../../../build/LinuxHost_STB_release
../../../Source/STBLib/STBExample.c -lSTB


text:
Q: delete a cell if the values are existing in a countif Got the following question. More likely to be solved by VBA code but as I'm newcomer on VBA, I don't know how.
I have the following table

I'm putting the formula in the cell F2, see below, to figure out redundant values and ultimately, to remove them.
IF(COUNTIF(B2:E58,A2)>0,"YAHOO","Not Present")
My aim is to remove these redundant values automatically and not manually, by either deleting the cell or deleting the values inside.
I've checked on the internet and some solutions that came out, were talking about helpers columns or intermediate table, some others came out with VBA. I had look at the helpers column but I don't see how I can remove my values automatically through helpers columns.
Any suggestions are welcomed.
Thanks in advance.
Edited (1st take):
Thanks to Don Relentless for his help but I think my explanation is not clear enough.
Have: One column, A. Looking within that column A for values that exist when doing a search within an array , B2:E58.
Method/ Solution: Use IF(COUNTIF(B2:E58,A2)>0,"YAHOO","Not Present") to spot the values within colmun A and also present in the array.
Example: For A2, check on B2 to E2 until E58. Next will be for A3 , check on B2 to E2 until E58.
Want: Remove the cell either within the array or in the column by either making them empty or put something like YAHOO.
I hope I'm clear. If not give me a shout.

A: If you are trying to replace the rows in columnA with blanks or "Yahoo" when a match occurs, then follow these two steps
1) Select cells B2:E58 and name them MyArray
2) Run the code below
Sub ReplaceBlanks()
    Dim i
    Range("A2").Select
    Do While Not IsEmpty(ActiveCell)
    If WorksheetFunction.CountIf(Worksheets("Sheet1").Range("MyArray"), ActiveCell.Value) > 0 Then
        ActiveCell.Value = ""
    End If
    ActiveCell.Offset(1, 0).Select
    Loop
End Sub

A: *

*"either deleting the cell or deleting the values inside" - please clarify, because deleting the cell will imply shifting the rest left, or right, etc - must be clarified). Instead of deletion you can set the cell value to empty ("") or any other string using VBA like Range("B2").Value="" (no actual deletion here).Finding sub-string (e.g. "ABC") within another string (e.g. "10ABCD") in VBA is performed by function InStr(), like InStr("10ABCD", "ABC")>0 which indicates a match. You can apply these functions while looping through a range of cells, e.g. Range("B1:E58") pertinent to your particular task and accumulate the results of each`InStr(): non-zero will indicate the existing match (one or many) for the cell under the test ("A1", then "A2", etc.).

*The same task can be completed using Worksheet functions as per your example, expanding them to entire column "E".
Regards,


text:
Q: Query in hive to pick second value in col2 for same value in col1 I need help with the below output. The real table set is bigger but I have simplified it here for better understanding.
Input table:
id level
1   L1
2   L1
3   L1
3   L2
4   L2

Desired Result:
ID Level
1  L1
2  L1
3  L2
4  L2

Basically out of L1 & L2, the query should pick L2 if present for the given id and filter out L1

A: The condition can be prioritized in order by of row_number function.
select id,level
from (
select id,level,row_number() over(partition by id
                                  order by case when level='L2' then 1
                                                when level='L1' then 2
                                           else 3 end) as rnum
from tbl
) t
where rnum=1


text:
Q: AbstractFactory Versus Bridge Pattern I have just learned the Bridge Pattern and its intent : Decouple an abstraction from its implementation so that the two can vary independently.
But why couldn't just an AbstractFactory do the same thing ?
I know that an AbstractFactory can create a particular bridge but my question concerns usage of AbstractFactory instead Bridge for decoupling Abstraction and Implementation.
Could you please explain me the real difference between AbstractFactory and Bridge Pattern?

A: First off the bridge pattern from what I've read is more for when both the class and what it does varies often.  The class itself can be considered as the implementation and the behavior of the class as the abstraction.
The Abstract Factory on the other hand provides an interface for creating groups of related or dependent objects, without specifying their concrete classes; their implementation concerns.
So I guess to sum it up, you are comparing apples to oranges and maybe that is where the confusion is coming from.  They are for solving different problems.
To me operations imply methods in java, so the operations are defined or declared by the abstraction, but are implemented in the class itself. So yes the abstraction is just declaring what the operations could do as far as behavior, but the actual implementations are done in the class. Also, the Abstract Factory is correct as well.
I guess the defining part for bridge is that it could have sets of abstractions that vary versus one abstraction.
Design Patterns uses the word abstraction to refer to a class that relies on a set of abstract operations, where several implementations of the set of abstract operations are possible.
See these links for more information:
Using Abstractions and the Bridge Pattern in Java
Wikipedia: Bridge_Pattern
Bridge Pattern in Java
The Bridge Pattern Design Pattern

A: There are few differences and we can't compare both of them.

*

*Abstract Factory is creational design pattern, which deals with object creation. Bridge is structural design pattern, which deals with class structure and composition.

*In Bridge, abstraction and implementation will vary independently. But in abstract factory, if you change abstraction ( interface), you have to change client.
abstract_factory pattern use case:

*

*When your system has to create multiple families of products or you want to provide a library of products without exposing the implementation details.

Checklist:

*

*Decide if "platform independence" and creation services are the current source of pain.

*Map out a matrix of "platforms" versus "products".

*Define a factory interface that consists of a factory method per product.

*Define a factory derived class for each platform that encapsulates all references to the new operator.

*The client should retire all references to new, and use the factory methods to create the product objects.

bridge pattern:
Use it when :

*

*you want run-time binding of the implementation,

*you have a proliferation of classes from a coupled interface and numerous implementations,

*you want to share an implementation among multiple objects,

*you need to map orthogonal class hierarchies.

Related SE questions:
Does the Bridge Pattern decouples an abstraction from implementation?
What is the basic difference between the Factory and Abstract Factory Patterns?
Have a look at this journaldev  article  and sourcemaking  article  for in-depth understanding of various design patterns.

A: Yes. They are similar. AF is used to create families of objects. Where as Bridge is more about behavior and also allows loose coupling between algorithm and platform.
eg: Suppose we develop a program for network diagnostics using Ping and Traceroute, the commands on different platform are different. Abstract factory can be used to get an instance of ping or traceroute for any of the platforms.
It does not end there. Bridge allows us to develop higher level algorithm using those ping and trace commands returned by AF. The algorithm which can use a different sequence of ping and traceroute, depending on the platform,can be abstracted from the platform specific implementation details using bridge pattern.


text:
Q: Unable to play the pcm file recorded using AudioRecord in Android I am developing an Android app. In my app I need to record audio using AudionRecord and need to play it. But throwing error when play the recorded pcm file. The main problem is I cannot log know the error as well because I have to test on real device and cannot run on emulator. Because when I run on emulator and record, my application crash.
This is my activity
public class MainActivity extends AppCompatActivity {

    Boolean recording;
    private Thread recordingThread = null;
    DataOutputStream dataOutputStream;
    short[] audioData;

    private Button btnPlay,btnStop,btnRecord;
    private String outputFile = null;
    //outputFile = Environment.getExternalStorageDirectory().getAbsolutePath()+"/recording.3gp";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initialize();
        initViews();
        setUpViews();
    }

    private void initialize()
    {

    }

    private void initViews()
    {
        btnPlay = (Button)findViewById(R.id.btn_play);
        btnRecord = (Button)findViewById(R.id.btn_record);
        btnStop = (Button)findViewById(R.id.btn_stop);
    }

    private void setUpViews()
    {
        btnRecord.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startRecord();
            }
        });

        btnStop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                recording = false;
                Toast.makeText(getBaseContext(),"Stopped",Toast.LENGTH_SHORT).show();
            }
        });

        btnPlay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                playRecord();
            }
        });
    }

    private void startRecord(){

        File file = new File(Environment.getExternalStorageDirectory(), "test.pcm");

        try {
            file.createNewFile();

            OutputStream outputStream = new FileOutputStream(file);
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
            dataOutputStream = new DataOutputStream(bufferedOutputStream);

            final int minBufferSize = AudioRecord.getMinBufferSize(11025,
                    AudioFormat.CHANNEL_CONFIGURATION_MONO,
                    AudioFormat.ENCODING_PCM_16BIT);

            audioData = new short[minBufferSize];

            final AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
                    11025,
                    AudioFormat.CHANNEL_CONFIGURATION_MONO,
                    AudioFormat.ENCODING_PCM_16BIT,
                    minBufferSize);

            audioRecord.startRecording();

            Toast.makeText(getBaseContext(),"Recording",Toast.LENGTH_SHORT).show();

            recordingThread = new Thread(new Runnable() {
                public void run() {
                    while(recording){
                        int numberOfShort = audioRecord.read(audioData, 0, minBufferSize);
                        for(int i = 0; i < numberOfShort; i++){
                            try{
                                dataOutputStream.writeShort(audioData[i]);
                            }
                            catch (IOException e)
                            {
                                Toast.makeText(getBaseContext(),e.getMessage(),Toast.LENGTH_SHORT).show();
                            }
                        }
                    }
                }
            }, "AudioRecorder Thread");

            audioRecord.stop();
            dataOutputStream.close();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    private void playRecord(){

        File file = new File(Environment.getExternalStorageDirectory(), "test.pcm");

        int shortSizeInBytes = Short.SIZE/Byte.SIZE;

        int bufferSizeInBytes = (int)(file.length()/shortSizeInBytes);
        short[] audioData = new short[bufferSizeInBytes];

        try {
            InputStream inputStream = new FileInputStream(file);
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
            DataInputStream dataInputStream = new DataInputStream(bufferedInputStream);

            int i = 0;
            while(dataInputStream.available() > 0){
                audioData[i] = dataInputStream.readShort();
                i++;
            }

            dataInputStream.close();

            AudioTrack audioTrack = new AudioTrack(
                    AudioManager.STREAM_MUSIC,
                    11025,
                    AudioFormat.CHANNEL_CONFIGURATION_MONO,
                    AudioFormat.ENCODING_PCM_16BIT,
                    bufferSizeInBytes,
                    AudioTrack.MODE_STREAM);

            audioTrack.play();
            audioTrack.write(audioData, 0, bufferSizeInBytes);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

The problem is with playing the recorded pcm. When I click play button, application throws fatal error and stopped. I cannot log the error as well. The pcm file really exists at the defined path as well. What is wrong with my code? Why can it not play?
As you can see below, pcm file created successfully after recording

A: Without seeing the Logcat, it is hard to figure the issue in your code. Take a look at this working code on 'How to play pcm files using AudioTrack':
private void PlayAudioFileViaAudioTrack(String filePath) throws IOException
{
// We keep temporarily filePath globally as we have only two sample sounds now..
if (filePath==null)
return;

int intSize = android.media.AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO,
AudioFormat.ENCODING_PCM_16BIT);

AudioTrack at = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO,
AudioFormat.ENCODING_PCM_16BIT, intSize, AudioTrack.MODE_STREAM);

if (at==null){
Log.d("TCAudio", "audio track is not initialised ");
return;
}

int count = 512 * 1024; // 512 kb
//Reading the file..
byte[] byteData = null;
File file = null;
file = new File(filePath);

byteData = new byte[(int)count];
FileInputStream in = null;
try {
in = new FileInputStream( file );

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

int bytesread = 0, ret = 0;
int size = (int) file.length();
at.play();
while (bytesread < size) {
   ret = in.read( byteData,0, count);
   if (ret != -1) { // Write the byte array to the track
    at.write(byteData,0, ret);
    bytesread += ret;
    }

    else break;
}
    in.close();
    at.stop();
    at.release();
}

code from http://jongladwin.blogspot.co.uk/2010/03/android-play-pcmwav-audio-buffer-using.html


text:
Q: Grails Spring Security redirect to login page using https I have a Grails app using Spring Security Core running on an AWS machine behind a load balancer.
The load balancer decrypts the ssl connections and forwards to port 8080 of our instance adding appropriate X-Forwarded-Proto headers.
I would like any direct access to a secured page to redirect to the login page using https.
For example a request https://myapp.com/private/page should redirect to https://myapp.com/login/auth
I put this in my config.groovy:
grails.plugin.springsecurity.secureChannel.definition = [
    '/login/**':        'REQUIRES_SECURE_CHANNEL'
]

but this causes a redirect loop (HTTP code 302) to the http login page (http://myapp.com/login/auth)
Then I tried just with:
grails.plugin.springsecurity.secureChannel.useHeaderCheckChannelSecurity = true
grails.plugin.springsecurity.auth.forceHttps = true

but this causes a redirect (HTTP code 302) to the http login page (http://myapp.com/login/auth)

*

*The issue is presentig just with the production setup (war deployed to Tomcat behind the load balancer).

*If I test the same config.groovy on my loacal dev machine the redirect to https://myapp.com/login/auth happens just fine.

*I tried to specify a different httpsPort for spring security, again it works on my local dev machine but it is completely ignored in the deployed app that keeps redirecting to http

No luck lurking at similar posts, any idea?

A: I also am hosting my Grails app with Spring Security Core 2.0-RC4 on AWS with https and a load balancer, and thanks to spock99 (above) and Ravi L of AWS, I got it working.
I did the following in config.groovy:
    // Required because user auth uses absolute redirects
    grails.serverURL = "http://example.com"

    grails.plugin.springsecurity.secureChannel.definition = [
        '/assets/**':     'ANY_CHANNEL',// make js, css, images available to logged out pages
        '/**':            'REQUIRES_SECURE_CHANNEL',
    ]

    // overriding values in DefaultSecurityConfig.groovy from the SpringSecurityCore 2.0-RC4
    grails.plugin.springsecurity.secureChannel.useHeaderCheckChannelSecurity = true
    grails.plugin.springsecurity.portMapper.httpPort = 80
    grails.plugin.springsecurity.portMapper.httpsPort = 443

NOTE: The following were not needed in Spring Security Core 2.0-RC4 - they are already in DefaultSecurityConfig.groovy
    secureHeaderName = 'X-Forwarded-Proto'
    secureHeaderValue = 'http'
    insecureHeaderName = 'X-Forwarded-Proto'
    insecureHeaderValue = 'https'

I was getting false 'Unhealthy' readings because hitting '/' returns a 302 redirect to /login/auth, so I added a health() method to HomeController (which I mapped to '/health') for AWS to hit:
    class HomeController {
        @Secured('IS_AUTHENTICATED_FULLY')
        def index() { }

        @Secured('permitAll')
        def health() { render '' }
    }

Key for me was that session cookies were not being handled properly with multiple instance running on the Load Balancer (I did not discover this until setting the minimum instance to 2), so in order for users to be able to log in and stay logged in, I did the following on AWS:
1.  At Services / Elastic Beanstalk / Configuration / Load Balancing
    a. set Application health check URL: /health
    b. left Session Stickiness: unchecked
2. At Services / EC2 / Load Balancers / Description / Port Configuration:
    For both port 80 (HTTP)  and 443 (HTTPS)
        1. Edit and select 'Enable Application Generated Cookie Stickiness'
        2. Cookie Name: JSESSIONID

A: I just went through the same scenario.  Got stuck on the https, then the redirects, and now all is well.  Use these Config.groovy settings:
grails.plugin.springsecurity.secureChannel.useHeaderCheckChannelSecurity = true
grails.plugin.springsecurity.portMapper.httpPort = 80
grails.plugin.springsecurity.portMapper.httpsPort = 443
grails.plugin.springsecurity.secureChannel.secureHeaderName = 'X-Forwarded-Proto'
grails.plugin.springsecurity.secureChannel.secureHeaderValue = 'http'
grails.plugin.springsecurity.secureChannel.insecureHeaderName = 'X-Forwarded-Proto'
grails.plugin.springsecurity.secureChannel.insecureHeaderValue = 'https'

Note for those not using springsecurity 2.0, it is 'plugins' and not 'plugin' without the 's'.
My beanstalk load balancer settings look like this (I have an SSL cert installed, I didn't show it):

In the EC2 load balancer settings make sure your listeners are set right:

And finally in the EC2 security groups make sure the EB accepts requests on ports 80 and 443 from the ELB:

Note that nowhere in my setup of anything do I ever reference ports 8080 or 8443, even though that is what I use on my localhost for testing.  Somebody reading this may think about trying to use those ports to fix the issues.  My setup didn't require that.

A: I faced similar issue in similar environment where the front end was on https and behind the firewall grails server was on http.
When session was timed out,  ajax and angular $http used to get a redirect message to http://myclient.com/myWar/login/auth. This redirect request used to cause access denied in browser because original url was https and mixed content was disabled.
I used to get SCRIPT7002: XMLHttpRequest: Network Error 0x80700013, Could not complete the operation due to error 80700013."
This error occurred only in production and not in test environment.
Fix is simple, simply add the following to the configuration file.
grails.serverURL = "https://mywebsitespublicaddress.com/myWar"


text:
Q: extra alignment tab has been changed to \cr after I changed to ltablex package I am getting extra alignment tab has been changed to \cr after I changed to ltablex package. I don't have this problem if I use tabularx package.
This is my MWE, Error is thrown at line#46:
%!TEX TS-Program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass{article}

\usepackage{graphics}
\usepackage{fancyhdr}
\usepackage{ctable}
\usepackage{array}
\usepackage{ltablex}
\usepackage[margin=2.5cm]{geometry}

\setlength\parindent{0pt}

\newcommand{\sectionheader}[1] {
\textbf{#1}

\rule{\textwidth}{6pt}
}

\newcommand\zcolumn[1]{%
{\begin{tabular}{c}#1\end{tabular}\linebreak[0]}}

\setlength{\heavyrulewidth}{0.12em}

\pagenumbering{arabic}
\pagestyle{fancy}
\lhead{Patient Name: Claire  Roberts}
\rhead{\thepage}
\cfoot{}
\keepXColumns
\begin{document}

\sectionheader{PATIENT INFORMATION}
\begin{tabularx}{\textwidth}{lX}
Birth Date: & 10/10/69 \\
 Gender: & F \\
 \end{tabularx}

\sectionheader{CONTACT INFORMATION}
\begin{tabularx}{\textwidth}{lX}
Phone: & 206.555.1212 \\
Email: & claire@patient.com \\
Address: & {\begin{tabularx}{\textwidth}{l}7000 Central Ave NE\\default location
line2\\Minneapolis MN 55432\\ \end{tabularx}}
\end{tabularx}
\bigskip
 \newpage

\sectionheader{SYMPTOMS}

\begin{tabularx}{\textwidth}{lX}
\textbf{PERCEPTION}\\
SATISFACTION &
\begin{raggedright}
\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ 2}
\zcolumn{6/6/16 \\ -}
\zcolumn{6/7/16 \\ 2}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}
\\
\hline
\textbf{VOID}\\

    AWAKE &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ 5}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ -}
\zcolumn{6/6/16 \\ 2}
\zcolumn{6/7/16 \\ 1}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\SLEEPING &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ 5}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ 1}
\zcolumn{6/6/16 \\ -}
\zcolumn{6/7/16 \\ -}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\URGENCY &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ 2}
\zcolumn{6/5/16 \\ -}
\zcolumn{6/6/16 \\ -}
\zcolumn{6/7/16 \\ -}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\
\hline
\textbf{UR}\\

    UR\_LEAK\_AMOUNT &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ -}
\zcolumn{6/6/16 \\ Moderate}
\zcolumn{6/7/16 \\ -}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\TOTAL &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ 1}
\zcolumn{6/6/16 \\ -}
\zcolumn{6/7/16 \\ -}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\
\hline
\textbf{BM}\\

    AWAKE &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ -}
\zcolumn{6/6/16 \\ -}
\zcolumn{6/7/16 \\ 3}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\SLEEPING &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ -}
\zcolumn{6/6/16 \\ 5}
\zcolumn{6/7/16 \\ -}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\SOIL\_AMOUNT &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ -}
\zcolumn{6/6/16 \\ -}
\zcolumn{6/7/16 \\ -}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\
\hline
\textbf{BOWEL}\\

    AMOUNT &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ 6}
\zcolumn{6/5/16 \\ -}
\zcolumn{6/6/16 \\ 5}
\zcolumn{6/7/16 \\ -}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\TOTAL &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ 8}
\zcolumn{6/6/16 \\ -}
\zcolumn{6/7/16 \\ 9}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\
\hline
\textbf{PADS}\\

    TOTAL &

\begin{raggedright}

\zcolumn{5/31/16 \\ -}
\zcolumn{6/1/16 \\ -}
\zcolumn{6/2/16 \\ -}
\zcolumn{6/3/16 \\ -}
\zcolumn{6/4/16 \\ -}
\zcolumn{6/5/16 \\ 9}
\zcolumn{6/6/16 \\ -}
\zcolumn{6/7/16 \\ 8}
\zcolumn{6/8/16 \\ -}
\zcolumn{6/9/16 \\ -}
\zcolumn{6/10/16 \\ -}
\zcolumn{6/11/16 \\ -}
\zcolumn{6/12/16 \\ -}
\zcolumn{6/13/16 \\ -}
\zcolumn{6/14/16 \\ -}
\zcolumn{6/15/16 \\ -}
\end{raggedright}

\\
\hline

\end{tabularx}
\newpage

\bigskip

\end{document}

below is the code around line#46:
\sectionheader{CONTACT INFORMATION}
\begin{tabularx}{\textwidth}{lX}
Phone: & 206.555.1212 \\
Email: & claire@patient.com \\
Address: & {\begin{tabularx}{\textwidth}{l}7000 Central Ave NE\\default location
line2\\Minneapolis MN 55432\\ \end{tabularx}}
\end{tabularx} % line#46

A: For some reason, the nested tabularx don't work. I replaced them with a \makecell command and re-defined the \zcolumn command, so that the second line (mostly  a hyphen,that I changed to a more relevant endash) be a optional argument.  This results in a simpler code. I added some padding between groups of rows, and replaced the \hlines with \midrules.
%!TEX TS-Program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass{article}

\usepackage{graphics}
\usepackage{fancyhdr}
\usepackage{ctable}
\usepackage{url}
\usepackage{array, booktabs, makecell}
\usepackage{ltablex}
\usepackage[margin=2.5cm]{geometry}

\setlength\parindent{0pt}

\newcommand{\sectionheader}[1] {
\textbf{#1}

\rule{\textwidth}{6pt}
}

%\newcommand\zcolumn[1]{%
%{\begin{tabular}{c}#1\end{tabular}\linebreak[0]}}
\newcommand\zcolumn[2][\textendash]{\makecell[tc]{#2\\#1}}
\setlength{\heavyrulewidth}{0.12em}

\pagenumbering{arabic}
\pagestyle{fancy}
\lhead{Patient Name: Claire Roberts}
\rhead{\thepage}
\cfoot{}
\keepXColumns

\begin{document}

\sectionheader{PATIENT INFORMATION}
\begin{tabularx}{\textwidth}{lX}
Birth Date: & 10/10/69 \\
 Gender: & F \\
 \end{tabularx}

\sectionheader{CONTACT INFORMATION}
\begin{tabularx}{\textwidth}{lX}
Phone: & 206.555.1212 \\
Email: & \url{claire@patient.com} \\[1ex]
Address: & \makecell[lt]{7000 Central Ave NE\\default location
line2\\Minneapolis MN 55432}
\end{tabularx}
\bigskip
 \newpage

\sectionheader{SYMPTOMS}
\setlength\tabcolsep{5pt}
\begin{tabularx}{\textwidth}{@{}l*{8}{X}}
\\\midrule
\endfoot
\\\bottomrule
\endlastfoot
\textbf{PERCEPTION} \\[1ex]
SATISFACTION
 & \zcolumn{5/31/16}
 & \zcolumn{6/1/16}
 & \zcolumn{6/2/16}
 & \zcolumn{6/3/16}
 & \zcolumn{6/4/16}
 & \zcolumn[2]{6/5/16}
 &  \zcolumn{6/6/16}
  & \zcolumn[2]{6/7/16}\\
  \addlinespace
  &  \zcolumn{6/8/16}
 & \zcolumn{6/9/16}
 & \zcolumn{6/10/16}
 & \zcolumn{6/11/16}
 & \zcolumn{6/12/16}
 & \zcolumn{6/13/16}
& \zcolumn{6/14/16}
 & \zcolumn{6/15/16} \\
\midrule
\addlinespace
\textbf{VOID}\\[1ex]
AWAKE
 &\zcolumn{5/31/16}
 & \zcolumn{6/1/16}
 & \zcolumn{6/2/16}
 & \zcolumn[5]{6/3/16}
 & \zcolumn{6/4/16}
 & \zcolumn{6/5/16}
 & \zcolumn[2]{6/6/16}
 & \zcolumn[1]{6/7/16}\\
 \addlinespace
 & \zcolumn{6/8/16}
 & \zcolumn{6/9/16}
 & \zcolumn{6/10/16}
 & \zcolumn{6/11/16}
 & \zcolumn{6/12/16}
 & \zcolumn{6/13/16}
 & \zcolumn{6/14/16}
 & \zcolumn{6/15/16}\\[5ex]
SLEEPING
& \zcolumn{5/31/16}
 & \zcolumn{6/1/16}
 & \zcolumn[5]{6/2/16}
 & \zcolumn{6/3/16}
 & \zcolumn{6/4/16}
 & \zcolumn[1]{6/5/16}
 & \zcolumn{6/6/16}
 & \zcolumn{6/7/16}\\
 \addlinespace
 & \zcolumn{6/8/16}
 & \zcolumn{6/9/16}
 & \zcolumn{6/10/16}
 & \zcolumn{6/11/16}
 & \zcolumn{6/12/16}
 & \zcolumn{6/13/16}
 & \zcolumn{6/14/16}
 & \zcolumn{6/15/16}\\[5ex]
URGENCY
& \zcolumn{5/31/16}
 & \zcolumn{6/1/16}
 & \zcolumn{6/2/16}
 & \zcolumn{6/3/16}
 & \zcolumn[2]{6/4/16}
 & \zcolumn{6/5/16}
 & \zcolumn{6/6/16}
 & \zcolumn{6/7/16} \\
 \addlinespace
 & \zcolumn{6/8/16}
 & \zcolumn{6/9/16}
 & \zcolumn{6/10/16}
 & \zcolumn{6/11/16}
 & \zcolumn{6/12/16}
 & \zcolumn{6/13/16}
 & \zcolumn{6/14/16}
 & \zcolumn{6/15/16} \\
\midrule
\addlinespace
\textbf{UR}\\[1ex]
 UR\_LEAK\_AMOUNT
 & \zcolumn{5/31/16}
 & \zcolumn{6/1/16}
 & \zcolumn{6/2/16}
 & \zcolumn{6/3/16}
 & \zcolumn{6/4/16}
 & \zcolumn{6/5/16}
 & \zcolumn[\footnotesize Moderate]{6/6/16}
 & \zcolumn{6/7/16} \\
 \addlinespace
 & \zcolumn{6/8/16}
 & \zcolumn{6/9/16}
 & \zcolumn{6/10/16}
 & \zcolumn{6/11/16}
 & \zcolumn{6/12/16}
 & \zcolumn{6/13/16}
 & \zcolumn{6/14/16}
 & \zcolumn{6/15/16}\\[5ex]
TOTAL
 & \zcolumn{5/31/16}
& \zcolumn{6/1/16}
& \zcolumn{6/2/16}
& \zcolumn{6/3/16}
& \zcolumn{6/4/16}
& \zcolumn[1]{6/5/16}
& \zcolumn{6/6/16}
& \zcolumn{6/7/16} \\
 \addlinespace
& \zcolumn{6/8/16}
& \zcolumn{6/9/16}
& \zcolumn{6/10/16}
& \zcolumn{6/11/16}
& \zcolumn{6/12/16}
& \zcolumn{6/13/16}
& \zcolumn{6/14/16}
& \zcolumn{6/15/16} \\
\midrule
\addlinespace
\textbf{BM}\\[1ex]
 AWAKE
 & \zcolumn{5/31/16}
 & \zcolumn{6/1/16}
 & \zcolumn{6/2/16}
 & \zcolumn{6/3/16}
 & \zcolumn{6/4/16}
 & \zcolumn{6/5/16}
 & \zcolumn{6/6/16}
 & \zcolumn[3]{6/7/16} \\
 \addlinespace
 & \zcolumn{6/8/16}
 & \zcolumn{6/9/16}
 & \zcolumn{6/10/16}
 & \zcolumn{6/11/16}
 & \zcolumn{6/12/16}
 & \zcolumn{6/13/16}
 & \zcolumn{6/14/16}
 & \zcolumn{6/15/16} \\[5ex]
SLEEPING
 & \zcolumn{5/31/16}
 & \zcolumn{6/1/16}
& \zcolumn{6/2/16}
& \zcolumn{6/3/16}
& \zcolumn{6/4/16}
& \zcolumn{6/5/16}
& \zcolumn[5]{6/6/16}
& \zcolumn{6/7/16} \\
\addlinespace
& \zcolumn{6/8/16}
& \zcolumn{6/9/16}
& \zcolumn{6/10/16}
& \zcolumn{6/11/16}
& \zcolumn{6/12/16}
& \zcolumn{6/13/16}
& \zcolumn{6/14/16}
& \zcolumn{6/15/16} \\[5ex]
SOIL\_AMOUNT
& \zcolumn{5/31/16}
& \zcolumn{6/1/16}
& \zcolumn{6/2/16}
& \zcolumn{6/3/16}
& \zcolumn{6/4/16}
& \zcolumn{6/5/16}
& \zcolumn{6/6/16}
& \zcolumn{6/7/16} \\
\addlinespace
& \zcolumn{6/8/16}
& \zcolumn{6/9/16}
& \zcolumn{6/10/16}
& \zcolumn{6/11/16}
& \zcolumn{6/12/16}
& \zcolumn{6/13/16}
& \zcolumn{6/14/16}
& \zcolumn{6/15/16} \\
\midrule
\addlinespace
\textbf{BOWEL}\\
 AMOUNT
& \zcolumn{5/31/16}
& \zcolumn{6/1/16}
& \zcolumn{6/2/16}
& \zcolumn{6/3/16}
& \zcolumn{6/4/16 \\ 6}
& \zcolumn{6/5/16}
& \zcolumn{6/6/16 \\ 5}
& \zcolumn{6/7/16} \\
\addlinespace
& \zcolumn{6/8/16}
& \zcolumn{6/9/16}
& \zcolumn{6/10/16}
& \zcolumn{6/11/16}
& \zcolumn{6/12/16}
& \zcolumn{6/13/16}
& \zcolumn{6/14/16}
& \zcolumn{6/15/16} \\[5ex]
TOTAL
& \zcolumn{5/31/16}
& \zcolumn{6/1/16}
& \zcolumn{6/2/16}
& \zcolumn{6/3/16}
& \zcolumn{6/4/16}
& \zcolumn[8]{6/5/16}
& \zcolumn{6/6/16}
& \zcolumn[9]{6/7/16} \\[5ex]
& \zcolumn{6/8/16}
& \zcolumn{6/9/16}
& \zcolumn{6/10/16}
& \zcolumn{6/11/16}
& \zcolumn{6/12/16}
& \zcolumn{6/13/16}
& \zcolumn{6/14/16}
& \zcolumn{6/15/16} \\
\midrule
\addlinespace
\textbf{PADS}\\
 TOTAL
& \zcolumn{5/31/16}
& \zcolumn{6/1/16}
& \zcolumn{6/2/16}
& \zcolumn{6/3/16}
& \zcolumn{6/4/16}
& \zcolumn[9]{6/5/16}
& \zcolumn{6/6/16}
& \zcolumn[8]{6/7/16}\\
\addlinespace
& \zcolumn{6/8/16}
& \zcolumn{6/9/16}
& \zcolumn{6/10/16}
& \zcolumn{6/11/16}
& \zcolumn{6/12/16}
& \zcolumn{6/13/16}
& \zcolumn{6/14/16}
& \zcolumn{6/15/16}
\end{tabularx}
\newpage
\bigskip

\end{document}


text:
Q: Prove that $x$ is congruent to $y \pmod m$ if and only if $x = km + y$
Prove that $x$ is congruent to $y \pmod m$ if and only if $x = km + y$

I'm not sure how to prove this, and honestly I don't really understand why it's true in the first place.

A: If $x \equiv y \pmod m$, then after division of $x$ by $m$, I have a remainder of $y$, assuming $0 \leq y < m$. So, via the division algorithm, $x = mq +y$.
The other direction is trivial using the division algorithm.


text:
Q: Best practice for "graphic" if-statments in MVC 3 Just started converting to MVC from classic ASP and wondering about best practice for if-statements that is used to decide if a HTML-element should be visible or deciding if that or that HTML-element should be visible.
Example:
if (type = 1)
{

}
else
{

}

I see several options here.
1. Use if-statements in my views (prefer not to)
2. Use a HTML-helper (will be a lot of helpers = Hard to work with the code)
3. Create HTML-snippets in my controller and pass into my view
4. Work with JavaScript to show/hide element on document load.
The example above if of course a simplification of my problem. Many thanks for the help!
/Mike
EDIT:
Took a bad example, here comes a new:
if (type = 1)
{
    Something something
}
else
{

        text

}

A: Personally I'm starting to use a separate layer for loading up by viewmodels with html specific information.
 public class ViewModel
 {
     public string ImageName { get; set; }
 }

Keeps the views clean:
<img src="/Content/Images/<%= Model.ImageName %>.jpg" />

A: I personally prefer to use HtmlHelper extensions or declarative HTML helpers for all but most trivial conditional expressions. However in this case I would probably let my laziness win, and express the conditional directly in the view like so:

Edit
For more complex scenarios, definitely HTML helpers. If you're using the Razor syntax, you can create declarative helpers by placing them into your ~/Views/Helpers directory. They're very clean to write and use.
But the idea behind creating a good helper is that it encapsulates an intention. This is easy to test by trying to give your helper a name. If the name is IfOneThenShowSomethingElseGrayImage, you should try to break it into further pieces still.
So let's imagine the intention in your example is to show information about the current user based on the user type. You could create a helper like this:
@helper UserType(int type) {
   @if (type == 1) {
    Something something
   } else {

        text

   }
}

And then use it in your view like this:
@UserType(Model.UserType)

Even though it's only used on one page, it enhances the readability in the view, and can be reused if necessary.
Just my two cents.


text:
Q: Proof of the existence of the unique continuous *-homomorphism form $C(\sigma(a))$ to $\mathcal(A)$ Let $\mathcal{A}$ be a commutative unital C*-algebra and $a\in\mathcal{A}$ an element such that the polynomials in $a$, $a^*$ and $1$ are dense in $\mathcal{A}$. There is an isometric *-isomorphism $\Psi:C(\sigma(a)\rightarrow\mathcal{A}$ such that
\begin{align}
\Psi(id_{\sigma(a)})=a,\quad\Psi(1_{\sigma(a)})=1.
\end{align}
It is the unique continuous *-homomorphism from $C(\sigma(a))$ to $\mathcal{A}$.
So, I am having trouble proving both the existence part and the uniqueness part. For the existence part I used the theorem:
Let $\mathcal{A}$ be a commutative unital C*-algebra and $a\in\mathcal{A}$ an element such that the polynomials in $a$, $a^*$ and $1$ are dense in $\mathcal{A}$. Let $\Delta$ denote the character space of $\mathcal{A}$. Then the map $\Phi:C(\sigma(a))\rightarrow C(\Delta)$ given by $\Phi(f)=f(\phi)$ is an isometric *-isomorphism obeying $\Phi(id_{\sigma(a)})=â$.
â is the function $â:\Delta\rightarrow \mathbb{C}$ with $â(\omega)=\omega(a)$ from the Gelfand transform and $\sigma(a)$ the spectrum of $a$.
I used $\Phi$ from this theorem to obtain $\Psi(id_{\sigma(a)})=a$ by putting $\Psi=\Gamma^{-1}(\Phi)$ and computing $\Gamma^{-1}(\Phi(id_{\sigma(a)}))$, where $\Gamma^{-1}$ is the inverse of the Gelfand transform but I am not sure how to derive the other equation from this construction of $\Psi$.
The uniqueness part I neither am sure how to prove.

A: I'll try to use your notation, hopefully I managed to do so. Concerning $\Psi$ being unital, we will need the explicit identification $\mu\colon \sigma(a) \cong \Delta$ given by
$$\mu(\omega) = \omega(a), \quad a\in A, \ \omega \in \Delta.$$
Set
$$\pi \colon C(\sigma(a)) \rightarrow C(\Delta); \quad \pi(f)(\omega) = (f \circ \mu)(\omega), \quad \omega \in\Delta.$$
The isomorphism you're looking for, is the composition
$$\Phi = \Gamma^{-1} \circ \pi$$
First of all, $\Gamma^{-1}$ is unit-preserving due to inverse of unital $\ast$-homomorphisms being unital again: If $\rho\colon E \rightarrow D$ is a unital $\ast$-isomorphism, then
$$\rho^{-1}(1_D) = \rho^{-1}(\rho(1_E)) = 1_E.$$
Now, for every character $\omega$ on $A$, $1_{\sigma(a)}$ maps $\mu(\omega)=\omega(a)$ into the real number $1$ (by definition), so
$$
\Phi(1_{\sigma(a)})(\omega) = \Gamma^{-1}((1_{\sigma(a)}\circ \mu)(\omega))=\Gamma^{-1}(1)=1_A
$$
I hope this helps with the second equation.


text:
Q: Suddenly cannot connect to university network, 16.04 I have two university networks available at my work place (eduroam and the own's university net). Both have good signal strength and both use the same username and the same password to log in. I have always been connected to the university's network without problems.
Today I was connected for some time, then I could not access websites anymore though remained connected (according to the network symbol). When I turned Wi-Fi off and on again it would not connect me again, to none of the two networks. I tried with a Windows laptop and could not connect to either of those two for a minute or so also but now it works and the connection remains solid. I restarted the Ubuntu laptop after that and succesfully connected to the university's network again, then after a minute the connection dropped off again and will not reconnect.
Trying to reconnect now to eduroam it won't establish a connection and just asks me for my password again and again. Trying to connect to the university's network it tries for a while, shows a message (not able to connect) and won't try further.
Any help wih this issue is greatly appreciated!


text:
Q: Python3 | Expected type 'union[bytes, bytearray], got 'str' instead I have a stable working project with python. It's running on python 2.7. I upgraded it to python 3.x. So, it's not working on Python3.
The logic is writing values to csv file.
Broken code is that:
csv = io.BytesIO()

csv.write('fiscalYear\t'
                      'VKN\t'
                      'recordPeriod\t'
                      'enteredBy\t'
                      'entredDate\t'
                      'entryNumber\t'
                      'entryComment\t'
                      'batchID\t'
                      'batchDescription\t'
                      'totalDebit\t'
                      'totalCredit\t'
                      'amountOriginalExchangeRate\t'
                      'amountOriginalExchangeRateSource\t'
                      'amountOriginalExchangeRateComment\n'
            )

return csv.getvalue()

My problem is that:
Expected type 'union[bytes, bytearray], got 'str' instead

Python log error:
TypeError: a bytes-like object is required, not 'str'

I need your help!

A: As the error message says, you should pass binary data, not strings. Instead of
csv.write(my_text)

write
csv.write(my_text.encode())

to convert it to binary.

A: You are writing a string (Unicode) to a BytesIO object.  You should probably switch your BytesIO to a StringIO.  If you truly want bytes, you can convert your Unicode strings to bytes using their encode() method, passing your preferred encoding scheme (e.g. 'utf-8').


text:
Q: What's the meaning of the ethereum Parity console output lines? Parity doesn't seem to have any documentation on what it's console output means. At least none that I've found which admittedly doesn't mean a whole lot. Can anyone give me a breakdown of the meaning of the following line?
2018-03-09 00:05:12 UTC Syncing #4896969 61ee…bdad     2 blk/s  508 tx/s  16 Mgas/s    645+    1 Qed  #4897616   17/25 peers      4 MiB chain  135 MiB db   42 MiB queue    5 MiB sync  RPC:  0 conn,  0 req/s, 182 µs

Thanks.

A: Why document when you can just read code? (bleh)

2018-03-09 00:05:12 UTC(1) Syncing #4896969(2) 61ee…bdad(3)     2 blk/s(4)  508 tx/s(5)  16 Mgas/s(6)    645+(7)    1(8) Qed  #4897616(9)   17/25 peers(10)      4 MiB chain(11)  135 MiB db(12)   42 MiB queue(13)    5 MiB sync(14)  RPC:  0 conn(15),  0 req/s(16), 182 µs(17)

*

*Timestamp

*Best block number (latest verified block number)

*Best block hash

*Blocks downloaded per second

*Transactions downloaded per second

*Millions of gas processed per second

*Unverified queue size

*Verified queue size

*Latest block number

*Number of active peer nodes/number of total peer nodes

*Blockchain header cache size

*Blockchain state cache size

*Queue cache size

*Node sync metadata cache size

*Number of open RPC sessions to your node

*RPC requests per second

*Approximate roundtrip ping

A: Now the answer to this question is also included in Parity's FAQ. It provides a comprehensive explanation of different command line output:
What does Parity's command line output mean?


text:
Q: Postgres SELECT 2 columns into 1 combined column without null values Suppose I have 2 columns in which one column always has non-null values but the other might have null values:

c1
c2

v1
null

v2
v3

I know I can combine 2 columns into 1 like so:
SELECT DISTINCT unnest(array[c1, c2]) as c3 FROM ...

Which forms a single column c3:

c3

v1

null

v2

v3

But I would like to be able to select into 1 column without null values. The only way I can think of is by selecting from my select statement:
SELECT c3 FROM (SELECT DISTINCT unnest(array[c1, c2]) as c3 FROM ...)
WHERE c3 IS NOT NULL

Is there a better way?

A: I would do it using a cross join against a values clause:
select distinct x.col
from the_table t
  cross join lateral ( values (t.c1), (t.c2)) as x(col)
where x.col is not null;

A UNION might actually be faster, but gets a bit clumsy if you have more than two columns:
select x.col
from (
  select c1  as col
  from the_table t
  where c1 is not null
  union
  select c2
  from the_table t
  where c2 is not null
) x


text:
Q: Pointer as a structure variable in c When I use code like this :
typedef struct {
        int x;
        int *pInt;
} tData;

tData *ptData = malloc(sizeof(tData));

If i understand it right, i allocated memory with size of tData and returned adress to this allocated memory to pointer *ptData.
But what if i used this code :
typedef struct {
        int x;
        int *pInt;
} *tData;

If I want to allocate memory to this struct, do I need a struct name? Because for me, if I allocate like malloc(sizeof(*tData));, it seems to me like I am allocating memory only for the pointer, not for the structure itself. When I want to refer to data in this structure, do I need to use pointer to pointer to a struct?
It confuses me a bit and I couldn't find the answer I am looking for.
Thank you for any explanation!

A: This is one of the reason one should avoid creating type-aliases of pointers.
As for how to use it, instead of passing the type to the sizeof operator, use the variable. Like e.g.
typedef struct {
        int x;
        int *pInt;
} *tData;

tData ptData = malloc(sizeof *ptData);  // Allocate memory for one structure


text:
Q: Is the function math.ulp more precise than the explicit formula in Python? In floating-point arithmetic, the unit in the last place (ULP) of a floating-point number is the spacing between that number and the consecutive one, i.e. the value of its least significant digit (rightmost digit) if it is 1. It is given by this formula:

ULP(x) = b−(p−1) • |x|

where b is the base (2 for binary numerals) and p (53 for double-precision significands) is the precision.
Python 3.9 introduced a new function math.ulp to compute the ULP of a floating-point number.
With this function, the previous formula is verified as expected for the ULP of 1:
>>> math.ulp(1)
2.220446049250313e-16
>>> 2**(-(53 - 1)) * abs(1)
2.220446049250313e-16

but it is not verified for the ULP of 10−10 for instance:
>>> math.ulp(1e-10)
1.2924697071141057e-26
>>> 2**(-(53 - 1)) * abs(1e-10)
2.2204460492503132e-26

Is math.ulp(x) more precise than 2**(-(53 - 1)) * abs(x)? Why?
The CPython implementation is in Modules/mathmodule.c#L3408-L3427 but I cannot find the implementation of the called function nextafter to understand:
static double
math_ulp_impl(PyObject *module, double x)
/*[clinic end generated code: output=f5207867a9384dd4 input=31f9bfbbe373fcaa]*/
{
    if (Py_IS_NAN(x)) {
        return x;
    }
    x = fabs(x);
    if (Py_IS_INFINITY(x)) {
        return x;
    }
    double inf = m_inf();
    double x2 = nextafter(x, inf);
    if (Py_IS_INFINITY(x2)) {
        /* special case: x is the largest positive representable float */
        x2 = nextafter(x, -inf);
        return x - x2;
    }
    return x2 - x;
}

A: 2−(53−1) • |x| (or 2**(-(53 - 1)) * abs(x)) is not a formula for ULP(x) (or math.ulp(x)) because it does not give the value of a 1 in the position of the lowest bit of x but rather the value of the significand of x (1.something) scaled to the position of the lowest bit of x. When x is not a power of two, its significand exceeds 1, and the formula is too high.
The correct formula is 2−(53−1) • 2max(e, −1022) where e is the IEEE 754 normalized exponent of x, i.e. 2e ≤ |x| < 2e+1 (or 2**(-(53 - 1)) * 2**max(math.floor(math.log2(x)), -1022)).


text:
Q: Find by multiple conditions in rails I want to search a table with multiple conditions in Rails. I am using Active record and rails version 3.1.0.
I have Movies object, and want to achieve the equivalent of the following in rails:
Select * from Movies where rating = 'R' OR rating = 'PG'

I tried the following but it does not work
@filtered = Movies.find(:all, :conditions => { :rating => 'R', :rating => 'PG' })

Can you please provide help to write an equivalent of SQL query mentioned above.

A: i guess that would be
Movie.where("rating = ? OR rating = ?", 'R', 'PG')

have a look at the guides for more info: http://guides.rubyonrails.org/active_record_querying.html#conditions
i would recommend using an IN statement instead.

A: You can do it using:
Movie.where(:rating => ['R','PG'])

A: One way would be to build an "IN" condition with:
 @filtered = Movie.where(:rating => ['R', 'PG']).all

EDIT: I changed your class to "Movie" from "Movies".  I assume that's what you will want.

A: In Rail 4, find with multiple conditions for example consider find Profile with first_name and last_name
Profile.find_by first_name: 'stack', last_name: 'flow'

Finds the first record matching the specified conditions. There is no implied ordering so if order matters, you should specify it yourself.
If no record is found, returns nil
Profile.find_by! first_name: 'stack', last_name: 'flow'

Like find_by, except that if no record is found, raises an ActiveRecord::RecordNotFound error.
For more information read  Rails Finder Method
1: http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find_byIn Rail 4, find with multiple conditions for example consider find Profile with first_name and last_name
Profile.find_by first_name: 'stack', last_name: 'flow'

Finds the first record matching the specified conditions. There is no implied ordering so if order matters, you should specify it yourself.
If no record is found, returns nil
Profile.find_by! first_name: 'stack', last_name: 'flow'

Like find_by, except that if no record is found, raises an ActiveRecord::RecordNotFound error.
For more information read  Rails Finder Method


text:
Q: Questions for making a MySQL table from a DTD file I have a dtd file which describes what columns my columns should have.
The problem is, it gives no info on what data type I should use for the columns, i.e whether INT, Varchar, or Text, and no info on the max length of the columns. In most places it says #PCDATA which I believe simply means mixed data.
Is there a way for me to find out what data type and max lenghts I should use, or should I simply make a table full of Varchar (255)s?

A: SGML is (in)famously lacking a type system, so there is no mechanized way to infer the correct type for any sort of element. Note that #PCDATA doesn't mean "mixed data", but "parsed character data" -- an element with content #PCDATA mustn't contain any other elements, but it can contain entity references (and in SGML it is subject to inclusion/exclusion exceptions, but those are not present in XML). "Mixed content" is something like (element1 | #PCDATA), which would be a lot harder to translate into a database schema.
Your best bet is to either deduce the content type from the element type names or from helpful comments in the DTD, and/or to inspect a series of documents in observe their usage pattern.


text:
Q: Delegates with three viewControllers So I have 3 views as follows: viewController >> viewController2 >> viewController3.
In viewController3 I have created a Delegate Protocol. The protocol method is a simple method that prints out an NSLog.
When I call the delegates from ViewController3, only its parent (viewController2 ) responds not the (first) viewController. There are no errors.I think problem has got something to do with [v2 setDelegate:self]; in the viewController.m file.
Nevertheless,[self.v3 setDelegate:self]; works fine in ViewController2.m file.
Why does the (first) viewController delegate not respond ? Do delegates only work with its immediate child ??
> **ViewController.h**
   #import <UIKit/UIKit.h>
   #import "ViewController2.h"
   #import "ViewController2.h"
   @interface ViewController : UIViewController <PassData>{

    ViewController2 *v2;
   }
   @property (strong, nonatomic) ViewController2 *v2;

> Blockquote

    - (IBAction)button:(id)sender;
    @end

> **ViewController.M**

    #import "ViewController.h"

   @interface ViewController ()

   @end

   @implementation ViewController
   @synthesize v2;

    - (IBAction)button:(id)sender {

    v2 = [[ViewController2 alloc]initWithNibName:@"ViewController2" bundle:nil];
    [v2 setDelegate:self];
    [self.view addSubview:v2.view];
    }

    -(void)print: (BOOL)success;{

    if (success == YES) {
        NSLog(@"ViewController called");
    }

    }

    @end

> > ViewController2.h

   #import <UIKit/UIKit.h>
   #import "ViewController3.h"

    @interface ViewController2 : UIViewController <PassData> {

    ViewController3 *v3;

     }
     @property (strong, nonatomic)ViewController3 *v3;
     @property (retain) id delegate;

   - (IBAction)button:(id)sender;
     @end

   ViewController2.m

   #import "ViewController2.h"

    @interface ViewController2 ()

     @end

    @implementation ViewController2
   @synthesize v3,delegate;

     - (IBAction)button:(id)sender {

    v3 = [[ViewController3 alloc]initWithNibName:@"ViewController3" bundle:nil];
    [self.v3 setDelegate:self];
    [self.view addSubview:v3.view];

     }

    -(void)print: (BOOL)success;{

    if (success == YES) {
          NSLog(@"ViewController2 called");
    }
    }
     @end

> ViewController3.h

   #import <UIKit/UIKit.h>

    @protocol PassData <NSObject>

    @required

    -(void)print:(BOOL)success;

    @end

    @interface ViewController3 : UIViewController {

    id<PassData>  delegate;

     }

    @property (retain) id delegate;

   - (IBAction)callButton:(id)sender;

    @end

     ViewController3.m

    #import "ViewController3.h"

    @interface ViewController3 ()

    @end

    @implementation ViewController3
    @synthesize delegate;

    - (IBAction)callButton:(id)sender {

    // call all delegates
      [[self delegate]print:YES];

     }
    @end

A: v2 doesn't have a method "print", that's a protocol method of v3 -- you can't chain delegate messages like this. If you want multiple controllers to respond to something in another controller, then you should use an NSNotification -- any number of objects can register to receive a notification.


text:
Q: Making a scrollable flat button in Flutter application I'm trying to embed a flat button with a variable amount of text within a scroll view, so that the user can scroll the text but also tap it in order to perform an action. I tried doing this with a flat button embedded in a ConstrainedBox, which itself is embedded in a SingleChildScrollView.
I've tried embedding the FlatButton in a SingleChildScrollView as below. Earlier, I tried wrapping the text in an expanded widget with a SingleChildScrollView ancestor but that caused runtime errors because the requirements of the scroll view and the expanded view conflict (as far as I understand).
Widget contentScreen() {
    return SingleChildScrollView(
        child: ConstrainedBox(
            constraints: BoxConstraints(),
            child: FlatButton(
                onPressed: () {
                  _toggleContent();
                },
                child:
                    Column(children: <Widget>[
                      Container(
                    child: Text(
                      "Lorem Ipsum....",
                      style: TextStyle(color: Colors.white, fontSize: 20))),
                ]
                    )
            )
        )
    );
  }

The text just doesn't scroll. Instead it overflows and shows the diagonal yellow bars. I don't have a list of exactly what I've tried, but where I'm at right now is that I'm using the above code but there is no scrolling behavior as expected. :\
I tried this: How to make the Scrollable text in flutter?
This: Make scrollable Text inside container in Flutter
And this: how to make text or richtext scrollable in flutter?
Is there something about the FlatButton's behavior that just precludes scrolling? If so, how can I work around that to still get the two behaviors (ability to both scroll and tap to perform action) that I want?

A: Have you tried this? Why do you need Expanded widget?
Container(
  height: 20.0,
  child: FlatButton(
      onPressed: () {},
      child: SingleChildScrollView(
       child: Text('Lorem ipsum'),
      ),
  ),
),

Gesture Detector should also work well.

A: Container(
  height: 20.0,
  child: FlatButton(
      onPressed: () {},
      child: SingleChildScrollView(
       child: Text('Lorem ipsum'),
      ),
  ),
),


text:
Q: Images with their path added in useState not loading in production build I made a React app with Vite for my portfolio. There I have buttons that change the image of my known skills when i click them. I have implemented this locally using useState. My website works correctly locally and the images load correctly. But when I build it for production only the images that I have imported as components and added load, but the images in the skills section do not load. I have identified the issue to be that the image path does not translate to the production build directory structure after build so the images are not found. But i dont know how to fix this.
Here is my github repo : https://github.com/coderboy53/portfolio

A: Putting the images under public folder should solve the issue
You can keep the images under public/images


text:
Q: Reducing aggregation execution time I'm able to have the result that I want, but I would like to know if there is some ways to reduce the execution time of the aggregation that I do.
First, here is my data :
..................................................................................
table activites :
{ "_id" : ObjectId("58872a885bd87fa3b7e736cf"), "jour" : "2015-01-01", "sgt_id" : 1, "produit_id" : 1, "affichages" : 1525, "clics" : 16, "consultations" : 20, "ajoutsPanier" : 1, "unites" : 0, "commandes" : 0, "recettes" : 0, "demandeBrute" : 0, "txDispo" : "NULL" }
{ "_id" : ObjectId("58872a885bd87fa3b7e736d0"), "jour" : "2015-01-01", "sgt_id" : 1, "produit_id" : 3, "affichages" : 519, "clics" : 6, "consultations" : 7, "ajoutsPanier" : 0, "unites" : 0, "commandes" : 0, "recettes" : 0, "demandeBrute" : 0, "txDispo" : "NULL" }
{ "_id" : ObjectId("58872a885bd87fa3b7e736d1"), "jour" : "2015-01-01", "sgt_id" : 1, "produit_id" : 5, "affichages" : 421, "clics" : 5, "consultations" : 6, "ajoutsPanier" : 1, "unites" : 0, "commandes" : 0, "recettes" : 0, "demandeBrute" : 0, "txDispo" : "NULL" }

and 14 millions of entries like that...
..................................................................................
table categories2 :
{ "_id" : ObjectId("5888609e5bd87fa3b7c72551"), "categorie_id" : 108, "type" : 1, "niveau" : 2, "hierarchie" : 2, "cat_id_client" : "Accessories", "categorie" : "Accessories", "label" : "NULL", "createur_id" : "NULL", "produit_id" : [ 867, 2943, 6443, 6447, 6525 ] }
{ "_id" : ObjectId("5888609e5bd87fa3b7c7259f"), "categorie_id" : 110, "type" : 1, "niveau" : 2, "hierarchie" : 2, "cat_id_client" : "Jewelry & watches", "categorie" : "Jewelry & watches", "label" : "NULL", "createur_id" : "NULL", "produit_id" : [ 2849, 2853, 2857, 2867, 2873, 2885, 2891, 2893, 2897, 2903, 2907, 2913, 2919, 2927, 2945, 2957, 2963, 3531, 3533, 3535, 3537, 3539, 3541, 3543, 3545, 3547, 3549, 3551, 3553, 3555, 3557, 3559, 3561, 3563, 3565, 3567, 3569, 3571, 3573, 3575, 3577, 3579, 3581, 3583, 3585, 3587, 3589, 3591, 3593, 3595, 3597, 3599, 3601, 3603, 3605, 3607, 3609, 3611, 3613, 3615, 3617, 3619, 3621, 3623, 3625, 3627, 3629, 3631, 6441, 6443, 6445, 6449, 6451, 6453, 6455, 6457, 6459, 6461, 6463, 6465, 6467, 6469, 6471, 6473, 6475, 6477, 6479, 6481, 6483, 6485, 6487, 6489, 6491, 6493, 6495, 6497, 6499, 6501, 6503, 6505, 6507, 6509, 6511, 6513, 6515, 6517, 6519, 6521, 6523, 6527 ] }
{ "_id" : ObjectId("5888609e5bd87fa3b7c725a2"), "categorie_id" : 106, "type" : 1, "niveau" : 2, "hierarchie" : 2, "cat_id_client" : "Clothing", "categorie" : "Clothing", "label" : "NULL", "createur_id" : "NULL", "produit_id" : [ 1485, 1487, 1489, 1491, 1493, 1495, 1497, 1499, 1501, 1503, 1505, 1507, 1509, 1511, 1513, 1515, 1517, 1519, 1521, 1523, 1525, 1527, 1681, 1683, 1685, 1687, 1689, 1691, 1693, 1695, 1697, 1699, 1701, 1703, 1705, 1707, 1709, 1711, 1713, 1715, 1717, 1721, 1723, 1725, 1727, 1729, 1731, 1733, 1735, 1737, 1739, 1741, 1743, 1745, 1747, 1749, 1751, 1753, 1755, 1757, 1759, 1761, 1763, 1765, 1767, 1769, 1771, 1773, 1775, 1777, 1779, 1781, 1783, 1785, 1787, 1789, 1791, 1793, 1795, 1797, 1799, 1801, 1803, 1805, 1807, 1809, 1811, 1813, 1815, 1817, 1819, 1821, 1823, 1825, 1827, 1829, 1831, 1833, 1835, 1837, 1839, 1841, 1843, 1845, 1847, 1849, 1851, 1853, 1855, 1857, 1859, 1861, 1863, 1867, 1869, 1871, 1873, 1875, 1877, 1879, 1881, 2845, 2851, 2855, 2859, 2863, 2869, 2871, 2877, 2879, 2881, 2887, 2895, 2905, 2909, 2911, 2917, 2923, 2925, 2929, 2933, 2935, 2939, 2941, 2947, 2951, 2953, 2959, 3849, 3851, 3853, 3855, 3857, 3859, 3861, 3863, 3865, 3867, 3869, 3871, 3873, 3875, 3877, 3879, 3881, 3883, 3885, 3887, 3889, 3891, 3893, 3895, 3897, 3899, 3901, 3903, 3905, 4969, 4971, 4973, 4975, 4977, 4979, 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 5001, 5003, 5005, 5007, 5009, 5011, 5013, 5015, 5017, 5019, 5021, 5023, 5025, 5027, 5029, 5031, 5033, 5035, 5037, 5039, 5041, 5043, 5045, 5047, 5049, 5743, 5745, 5747, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 5763, 5765, 5767, 5769, 5771, 5773, 5775, 5777, 5779, 5781, 5783, 5785, 5787, 5789, 5791, 5793, 5795, 5797, 5799, 5801, 5803, 5805, 5807, 5809, 5811, 5813, 5815, 5817, 5819, 5821, 5823, 5825, 5827, 5829, 5831, 5833, 5835, 5837, 5839, 5841, 5843, 5845, 5847, 5849, 5851, 5853, 5855, 5857, 5859, 5861, 5863, 5865, 5867, 5869, 5871, 5873, 5875, 5877, 5879, 5881, 5883, 5885, 5887, 5889, 5891, 5893, 5895, 5897, 5899, 5901, 5903, 5905, 5907, 5909, 5911, 5913, 5915, 5917, 5919, 5921, 5923, 5925, 5927, 5929, 5931, 5933, 5935, 5937, 5939, 5941, 5943, 5945, 5947, 5949, 5951, 5953, 5955, 5957 ] }
{ "_id" : ObjectId("5888609e5bd87fa3b7c725c0"), "categorie_id" : 107, "type" : 1, "niveau" : 2, "hierarchie" : 2, "cat_id_client" : "Shoes", "categorie" : "Shoes", "label" : "NULL", "createur_id" : "NULL", "produit_id" : [ 1719, 1865, 2861, 2875, 2883, 2889, 2899, 2901, 2915, 2921, 2931, 2937, 2949, 2955, 2961, 5487, 5489, 5491, 5493, 5495, 5497, 5499, 5501, 5503, 5505, 5507, 5509, 5511, 5513, 5515, 5517, 5519, 5521, 5523, 5525, 5527, 5529, 5531, 5533, 5535, 5537, 5539, 5541, 5543, 5545, 5547, 5549, 5551, 5553, 5555, 5557, 5559, 5561, 5563, 5565, 5567, 5569 ] }
{ "_id" : ObjectId("5888609e5bd87fa3b7c725ea"), "categorie_id" : 109, "type" : 1, "niveau" : 2, "hierarchie" : 2, "cat_id_client" : "Handbags", "categorie" : "Handbags", "label" : "NULL", "createur_id" : "NULL", "produit_id" : [ 845, 847, 849, 851, 853, 855, 857, 859, 861, 863, 865, 2847, 2865 ] }
{ "_id" : ObjectId("5888609e5bd87fa3b7c725f9"), "categorie_id" : 111, "type" : 1, "niveau" : 2, "hierarchie" : 2, "cat_id_client" : "Health & beauty", "categorie" : "Health & beauty", "label" : "NULL", "createur_id" : "NULL", "produit_id" : [ 3249, 3251, 3253, 3255, 3257, 3259, 3261, 3263, 3265 ] }

What I would like to have in result is that :
{ "_id" : 106, "categorie" : "Clothing", "consultations" : 185507, "recettes" : 1592183.49 }
{ "_id" : 107, "categorie" : "Shoes", "consultations" : 53636, "recettes" : 277869.81 }
{ "_id" : 110, "categorie" : "Jewelry & watches", "consultations" : 47071, "recettes" : 116746.03 }
{ "_id" : 109, "categorie" : "Handbags", "consultations" : 7149, "recettes" : 90921.05 }
{ "_id" : 111, "categorie" : "Health & beauty", "consultations" : 4542, "recettes" : 7671.51 }
{ "_id" : 108, "categorie" : "Accessories", "consultations" : 1718, "recettes" : 15689.43 }

For each categorie, have the sum of the consultations and recettes for each product which belongs to this categorie.

My code to obtain this result :
db.categories2.aggregate([
    {
        $match: {
            type: 1,
            niveau: 2,
            hierarchie: 2
        }
    },
    {
        "$unwind": "$produit_id"
    },
    {
        $lookup: {
            from: "activites",
            localField: "produit_id",
            foreignField: "produit_id",
            as: "activites"
        }
    },
    {
        $project: {
            _id: 1,
            categorie_id: 1,
            categorie: 1,
            produit_id: 1,
            activites : {
                $filter: {
                    input: "$activites",
                    as: "activite",
                    cond : { $and: [
                        { $gte: [ "$$activite.jour", "2016-09-01" ] },
                        { $lte: [ "$$activite.jour", "2016-11-03" ] },
                        { $eq : [ "$$activite.sgt_id", 1] }
                    ] }
                }
            }
        }
    },
    {
        $unwind: "$activites"
    },
    {
        $group: {
            _id: "$categorie_id",
            consultations: { $sum: "$activites.consultations" },
            recettes: { $sum: "$activites.recettes" }
        }
    },
    {
        $sort: { "consultations" : -1 }
    }
])

Explanation :

*

*Match the categories asked by the user. Each categories contains a produits field which is an array of products id

*Unwind this array

*For each line (so each product), look into the activites table to obtain consultations and recettes fields

*Filter the activites result to match the dates given by the user

*Unwind all the activites found to have one line per activite per day

*Group the result by categorie_id to do the sum of consultations and recettes

The problem is :

*

*the $lookup from activites take approximately 1~2 seconds (I don't think that we can do better because of the 14 millions of entries of this table)

*the last $group take something like 5 seconds to group all thecategorie_id` and do the sum

So in total, the request is done in 7,5 seconds.
Is there a way to do better, with another kind of request maybe ?
Thanks a lot for your help !
UPDATE : I thought maybe there is a way to group the children activites after the $project, and so avoid the $unwind and $group after that ?

A: I achieve to reduce the execution time to 300 ms, by splitting in two functions and doing the sum by hand in Javascript :
var before = new Date()

var pdtCat = db.categories2.aggregate([
    {
        $match: {
            type: 1,
            niveau: 2,
            hierarchie: 2
        }
    },
    {
        "$unwind": "$produit_id"
    }
]);

var produits_id = [];
var categories = [];
var prev = [];

pdtCat.forEach(produit => {
    produits_id.push(produit.produit_id);

    var index = prev.indexOf(produit.categorie_id);

    if(index > -1) {
        categories[index].produits_id.push(produit.produit_id);
    }
    else {
        prev.push(produit.categorie_id);
        categories.push({
            categorie_id: produit.categorie_id,
            categorie: produit.categorie,
            consultations: 0,
            recettes: 0,
            produits_id : [ produit.produit_id ]
        });
    }
});

var produits = db.activites.find({
    "jour" : {
        $gte: "2016-09-01",
        $lte: "2016-11-03"
    },
    sgt_id: 1,
    produit_id : { $in: produits_id }
}).forEach(produit => {
    for(var i=0; i < categories.length; i++) {
        if(categories[i].produits_id.indexOf(produit.produit_id) > -1) {
            categories[i].consultations += produit.consultations;
            categories[i].recettes += produit.recettes;
        }
    }
});

categories.sort(function(a, b) {
    return b.consultations - a.consultations;
});

categories.forEach(categorie => {
    delete categorie.produits_id;
    print(JSON.stringify(categorie));
});

var after = new Date()
execution_mills = after - before


text:
Q: How to update object using where condition in CosmoDb with DocumentDb api Using CosmoDb with MongoDb api from c# I can update a document with filter condition rather than using the Id.
For example this code work fine with CosmoDb with MongoDb api.
        public bool UpdateTask(MyTask myTask)
    {
        var mongoCollection = GetBsonCollectionForEdit();
        var builder = Builders<BsonDocument>.Filter;

        var filterName = builder.Eq("Name", myTask.Name);
        var filterCategory = builder.Eq("Category", myTask.Category);
        var filter = builder.And(new[] { filterName, filterCategory });

        var replaceUpdate = Builders<BsonDocument>.Update;
        var ret = mongoCollection.ReplaceOne(filter, myTask.ToBsonDocument());

        return ret.ModifiedCount == 1;
    }

Can I do the same thing with CosmoDb using the SQL DocumentDb api ?
(Without implement UDF or StoredPoc)
Thanks

A: No, but you can perform a query for the criteria using CreateDocumentQuery, then iterate through the matching IDs and perform an update on each of them using ReplaceDocumentAsync.


text:
Q: How do I create a function to accept [[customerID]] and return CustName Please look at details I have been asked to created a Function to accept CustomerID and return CustomerName for the CustomerID, I m a new Student/Developer Please if the question is not clear let me know so i can add more details about it, but that is what I was exactly asked.

A: functions in SQL are of three types.ignoring rest CLR functions ...
create table test
(
id int,
name varchar(4)
)

insert into test
select 1,'abc'
union all
select 2,'cde'

1.Scalar function takes one value and return one value
now for the above table ,you can create scalar function like below
create function dbo.test
(
@id int
)
returns varchar(4)
as
begin
declare @name varchar(4)
select @name=name from test where id =@id
 return @name
End

You invoke it like:
select  dbo.test(1)

2.Inline table valued functions:takes a single input same like scalar functions and returns table
create function dbo.test
(
@id int
)
as
returns TABLE
(
select * from test where id=@id)

You invoke it like:
select * from dbo.test(1)
3.Multi table valued function:
create function dbo.test
(
@id int
)
returns
@test table
(
id int,
name varchar(4)
)
as
begin

insert into @test
select * from test where id =@id

return

end

You invoke it like:
select * from dbo.test(1)
Take any one of Itzik Ben Gan books and start learning SQL the way it should be learned


text:
Q: Why does Jupyter notebook server refuse to connect? The OS is Ubuntu server 20.04 LTS(HVM)
I am trying to configure a server to start Jupyter notebook service when it boots. The problem is it refuses connections. I don't know why.
The notebook, and the virtual environment, below to another user (not root).

*

*Starting the notebook service manually as the other user works
If I ssh into the server, su to the other user, enter the password for that user, cd to their  home directory and start the notebook service then it works. That is, it does not refuse connections.

*Starting the notebook service manually as root does not work.  In this case, the startup script runs as root and connections are refused. In this case, the notebook service appears to start normally but refuses connections from the outside world.

*Starting the notebook service automatically does not work
The script I use to start it is
       cd /home/anna_user2
       source .venv/jupyter/bin/activate
       jupyter notebook

I could su to the other user within the startup script, but in my limited understanding there are two issues:

*

*su asks for a password even if NOPASSWD is set via visudo

*The posts I have seen on forums always ask "why do you want to su within a script?" which leads me to believe that I should not do that and that there is a better way.

I start the virual environment with the command source ~/.venv/jupyter/bin/activate. One cannot sudo source... (command not found)
The server is an Amazon AWS instance and this service provides the ability to specify a script ("User data) that runs at boot time.
The reason I am asking here is that it seems to be a user permissions issue. I was hoping to get some insight as to why the service doesn't work if it is started by root and/or the issues around using su inside a script.


text:
Q: Merging GIT branches automatically in azure pipeline I've GIT repo in Azure DevOps used in my pipelines.
This repo contains three branchs --> master (useless), PreProd and Prod
In pipeline I working on PreProd branch and after deployment I want to perform a task which merging the latest code in PreProd branch into a new commit in Prod.
So, is that possible and how?
Thanks in advance.

A: You could try API as @Tomasz suggested, or invoke git command to merge branches.
In addition, you could try Create Pull Request task to create a Pull Request and set Auto Complete:
https://marketplace.visualstudio.com/items?itemName=ShaykiAbramczyk.CreatePullRequest

A:
I think you are looking for this.

A: If for some reason GitMerge task is not working for you, try calling Azure DevOps API for Git operations directly from script.
Doc: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/merges/create?view=azure-devops-rest-6.0


text:
Q: How to resize view according to keyboard show/hide if keyboard is already shown In view A, I have a text field. I tap a control to push in a new view controller B. View B only has a text view whose frame should be adjusted to accommodate the keyboard, and I always set the text view to be the first responder and the keyboard should show immediately when view B is pushed in.
I do the usual keyboard notification handling in view controller B. So if the keyboard is not shown before view B is pushed, there is no problem. However, if the text field in view A is the first responder and the keyboard is already shown when I push in view controller B, I won't receive UIKeyboardWillShowNotification/UIKeyboardDidShowNotification. Any suggestion to handle this situation?

A: I haven't met this problem before, but I have a suggestion. Maybe in View B, you can let your textView resignFirstResponder and then becomeFirstResponder to force the keyboard notification comes out. Sample below:
[textView resignFirstResponder];
[textView becomeFirstResponder];

And there is another walk around way, maybe you can resignFirstResponder in View A before pushing, and then becomeFirstResponder after View B is viewDidAppear.
Hope it helps.

A: You can pass the keyboard status info to viewController B ... This is not a good way, but I've tried some other ways like call [textView resignFirstResponder] in viewWillDisappear of viewController A  , all of them're not work.

A: To resign first responder then become first responder again is not a good solution that I dropped immediately the first time I thought about it. Forcing the keyboard to hide and show up again immediately when the keyboard is already there is just not the right thing to do — it is a waste and breaks the smooth transition.
Sending keyboard status from view A to view B by breaking the encapsulation of B is neither an acceptable thing to do in software engineering.
So I believe it deserves a bug report and I did one — #11205521.

A: You should try UITouch.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  // Detect touch anywhere
  UITouch *touch = [touches anyObject];

  // Get the point that was touched
  CGPoint point = [touch locationInView:self.view];
  NSLog(@"pointx: %f pointy:%f", point.x, point.y);

  // Check if the point touched is within these rectangular bounds
  if (CGRectContainsPoint(CGRectMake(5, 5, 40, 130), point))
  {
    //do something...
  }
}

A: Hi to resize the view according to the keyboard i use something like this
- (void) animateView: (BOOL) up
{
    CGRect rect = self.view.frame;

    if(up)
    {
        float movement = (up ? 264 : 416);
        rect.size.height = movement;
        self.view.frame = rect;
    }
    else
    {
        rect.size.height = 480;
        self.view.frame = rect;
    }
}

the BOOL variable up is used to indicate if the keyboard is showed or not
hope this helps!
regards,
Jorge

A: You could monitor the keyboard status in some central place in your app, like the appDelegate, and have all the components get the current keyboard information from it.