text:
Q: How I can amount of query result I need to change value of EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE in case of the number of result rows.
For example, if query return one row INS should be just INS, if return two rows then INS from first row + '' + INS from second row and if more than 3 rows return - INS from first and number or rows - 1
Here is my code at the moment.

SELECT

EDU_INSTITUTIONS.FULL_NAME_GENITIVE_CASE AS GEN,
EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE AS INS,
EDU_INSTITUTIONS.FULL_NAME_DATIVE_CASE AS DAT,
NOTIFICATIONS.[ADDRESS] AS [ADDRESS],
NOTIFICATIONS.NUMBER AS NUM,
NOTIFICATIONS.RESPONSE_NUMBER AS RNUM,
NOTIFICATIONS.SIGN_DATE AS SDATE,
NOTIFICATIONS.SIGNER_POST AS SPOST,
NOTIFICATIONS.SIGNER_FULL_NAME AS SNAME,
RECIPIENT_FULL_NAME AS FIO,
RTRIM(ISNULL(APPLICATION_TYPES.NAME_GENITIVE_CASE,'') + ' ' + ISNULL(APPLICATION_REASONS.NAME_PREPOSITIONAL_CASE, '')) AS REAS

FROM NOTIFICATIONS
LEFT JOIN APPLICATIONS ON NOTIFICATIONS.APPLICATION_FK=APPLICATIONS.ID
LEFT JOIN APPLICATION_REASONS ON APPLICATION_REASONS.ID=APPLICATIONS.REASON_FK
LEFT JOIN APPLICATION_TYPES ON APPLICATION_TYPES.ID=APPLICATION_REASONS.APPLICATION_TYPE_FK
LEFT JOIN REFUSAL_TYPES ON REFUSAL_TYPES.ID=APPLICATIONS.REFUSAL_TYPE_FK
LEFT JOIN USERS ON USERS.ID=NOTIFICATIONS.EXECUTANT_FK
LEFT JOIN APPLICATION_INSTITUTIONS ON APPLICATION_INSTITUTIONS.APPLICATION_FK=APPLICATIONS.ID
LEFT JOIN EDU_INSTITUTIONS ON EDU_INSTITUTIONS.ID=APPLICATION_INSTITUTIONS.INSTITUTION_FK

WHERE
NOTIFICATIONS.ID=@ID

P.S. Sorry for my English.
UDP:
I resolve 1st and 3rd cases but I dont know how resolve 2nd
My code for now
select INSE =
case
when TotalRows = 1 then INS
--when TotalRows = 2 then INS + INS
when cast(TotalRows as int) > 2 then INS + ' и '+ cast(TotalRows-1 as nvarchar)+' филиалами'
end
from(
SELECT

EDU_INSTITUTIONS.FULL_NAME_GENITIVE_CASE AS GEN,
EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE AS INS,
EDU_INSTITUTIONS.FULL_NAME_DATIVE_CASE AS DAT,
NOTIFICATIONS.[ADDRESS] AS [ADDRESS],
NOTIFICATIONS.NUMBER AS NUM,
NOTIFICATIONS.RESPONSE_NUMBER AS RNUM,
NOTIFICATIONS.SIGN_DATE AS SDATE,
NOTIFICATIONS.SIGNER_POST AS SPOST,
NOTIFICATIONS.SIGNER_FULL_NAME AS SNAME,
RECIPIENT_FULL_NAME AS FIO,
RTRIM(ISNULL(APPLICATION_TYPES.NAME_GENITIVE_CASE,'') + ' ' + ISNULL(APPLICATION_REASONS.NAME_PREPOSITIONAL_CASE, '')) AS REAS,
APPLICATION_INSTITUTIONS.IS_APPLICANT as ORD,
COUNT(*) OVER () [TotalRows]

FROM NOTIFICATIONS
left join APPLICATIONS on NOTIFICATIONS.APPLICATION_FK=APPLICATIONS.ID
left join APPLICATION_REASONS on APPLICATION_REASONS.ID=APPLICATIONS.REASON_FK
left join APPLICATION_TYPES on APPLICATION_TYPES.ID=APPLICATION_REASONS.APPLICATION_TYPE_FK
left join REFUSAL_TYPES on REFUSAL_TYPES.ID=APPLICATIONS.REFUSAL_TYPE_FK
left join USERS on USERS.ID=NOTIFICATIONS.EXECUTANT_FK
left join APPLICATION_INSTITUTIONS on APPLICATION_INSTITUTIONS.APPLICATION_FK=APPLICATIONS.ID
left join EDU_INSTITUTIONS on EDU_INSTITUTIONS.ID=APPLICATION_INSTITUTIONS.INSTITUTION_FK

WHERE
NOTIFICATIONS.ID='20874f82-1887-4214-8812-53c21611202f'

) as tmp
order by  ORD desc

UPD2: This version is almost working, non-working is the second case
select INS_CASE =
case
when TotalRows = 1 then INS
when TotalRows = 2 then
    (SELECT TOP 1 FULL_NAME_INSTRUMENTAL_CASE FROM EDU_INSTITUTIONS AS EDU WHERE EDU.ID = tmp.ID ORDER BY EDU.FULL_NAME_INSTRUMENTAL_CASE ASC )
    + ' и ' +
    (SELECT TOP 1 EDU.FULL_NAME_INSTRUMENTAL_CASE FROM EDU_INSTITUTIONS AS EDU WHERE EDU.ID = tmp.ID ORDER BY EDU.FULL_NAME_INSTRUMENTAL_CASE DESC )
when TotalRows > 2 then INS + ' и '+ cast(TotalRows-1 as nvarchar)+' филиалами'
when TotalRows > 2 and ORD=0 then cast(TotalRows as nvarchar)+' филиалами ' + (SELECT top 1 INS from EDU_INSTITUTIONS as EDU where edu.id = id )
end
from(
SELECT
EDU_INSTITUTIONS.ID as ID,
EDU_INSTITUTIONS.FULL_NAME_GENITIVE_CASE AS GEN,
EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE AS INS,
EDU_INSTITUTIONS.FULL_NAME_DATIVE_CASE AS DAT,
NOTIFICATIONS.[ADDRESS] AS [ADDRESS],
NOTIFICATIONS.NUMBER AS NUM,
NOTIFICATIONS.RESPONSE_NUMBER AS RNUM,
NOTIFICATIONS.SIGN_DATE AS SDATE,
NOTIFICATIONS.SIGNER_POST AS SPOST,
NOTIFICATIONS.SIGNER_FULL_NAME AS SNAME,
RECIPIENT_FULL_NAME AS FIO,
RTRIM(ISNULL(APPLICATION_TYPES.NAME_GENITIVE_CASE,'') + ' ' + ISNULL(APPLICATION_REASONS.NAME_PREPOSITIONAL_CASE, '')) AS REAS,
APPLICATION_INSTITUTIONS.IS_APPLICANT as ORD,
COUNT(*) OVER () [TotalRows]

FROM NOTIFICATIONS
left join APPLICATIONS on NOTIFICATIONS.APPLICATION_FK=APPLICATIONS.ID
left join APPLICATION_REASONS on APPLICATION_REASONS.ID=APPLICATIONS.REASON_FK
left join APPLICATION_TYPES on APPLICATION_TYPES.ID=APPLICATION_REASONS.APPLICATION_TYPE_FK
left join REFUSAL_TYPES on REFUSAL_TYPES.ID=APPLICATIONS.REFUSAL_TYPE_FK
left join USERS on USERS.ID=NOTIFICATIONS.EXECUTANT_FK
left join APPLICATION_INSTITUTIONS on APPLICATION_INSTITUTIONS.APPLICATION_FK=APPLICATIONS.ID
left join EDU_INSTITUTIONS on EDU_INSTITUTIONS.ID=APPLICATION_INSTITUTIONS.INSTITUTION_FK

WHERE
NOTIFICATIONS.ID='20874f82-1887-4214-8812-53c21611202f'
--and APPLICATION_INSTITUTIONS.IS_APPLICANT =1

--'20874f82-1887-4214-8812-53c21611202f'    --=2
--'859eef0a-be0f-48e8-9bb0-83cbebca6c5d'    -->2
--'31992df7-a3ee-4d07-9596-21017424e594'    --=1
--'640d283d-57a7-4ddb-a7c3-f43caeb83aa1'    -->2 ORD 0

) as tmp
order by ORD desc

UPD3: Here is workaround for problem
select INS_CASE =
case
when TotalRows = 1 then INS
when TotalRows = 2 then
    (SELECT TOP 1 INS FROM (
SELECT
EDU_INSTITUTIONS.ID as ID,
EDU_INSTITUTIONS.FULL_NAME_GENITIVE_CASE AS GEN,
EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE AS INS,
EDU_INSTITUTIONS.FULL_NAME_DATIVE_CASE AS DAT,
NOTIFICATIONS.[ADDRESS] AS [ADDRESS],
NOTIFICATIONS.NUMBER AS NUM,
NOTIFICATIONS.RESPONSE_NUMBER AS RNUM,
NOTIFICATIONS.SIGN_DATE AS SDATE,
NOTIFICATIONS.SIGNER_POST AS SPOST,
NOTIFICATIONS.SIGNER_FULL_NAME AS SNAME,
RECIPIENT_FULL_NAME AS FIO,
RTRIM(ISNULL(APPLICATION_TYPES.NAME_GENITIVE_CASE,'') + ' ' + ISNULL(APPLICATION_REASONS.NAME_PREPOSITIONAL_CASE, '')) AS REAS,
APPLICATION_INSTITUTIONS.IS_APPLICANT as ORD,
COUNT(*) OVER () [TotalRows]

FROM NOTIFICATIONS
left join APPLICATIONS on NOTIFICATIONS.APPLICATION_FK=APPLICATIONS.ID
left join APPLICATION_REASONS on APPLICATION_REASONS.ID=APPLICATIONS.REASON_FK
left join APPLICATION_TYPES on APPLICATION_TYPES.ID=APPLICATION_REASONS.APPLICATION_TYPE_FK
left join REFUSAL_TYPES on REFUSAL_TYPES.ID=APPLICATIONS.REFUSAL_TYPE_FK
left join USERS on USERS.ID=NOTIFICATIONS.EXECUTANT_FK
left join APPLICATION_INSTITUTIONS on APPLICATION_INSTITUTIONS.APPLICATION_FK=APPLICATIONS.ID
left join EDU_INSTITUTIONS on EDU_INSTITUTIONS.ID=APPLICATION_INSTITUTIONS.INSTITUTION_FK

WHERE
NOTIFICATIONS.ID='20874f82-1887-4214-8812-53c21611202f'

) as tmp ORDER BY INS DESC )
    + ' и ' +
    (SELECT TOP 1INS FROM (
SELECT
EDU_INSTITUTIONS.ID as ID,
EDU_INSTITUTIONS.FULL_NAME_GENITIVE_CASE AS GEN,
EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE AS INS,
EDU_INSTITUTIONS.FULL_NAME_DATIVE_CASE AS DAT,
NOTIFICATIONS.[ADDRESS] AS [ADDRESS],
NOTIFICATIONS.NUMBER AS NUM,
NOTIFICATIONS.RESPONSE_NUMBER AS RNUM,
NOTIFICATIONS.SIGN_DATE AS SDATE,
NOTIFICATIONS.SIGNER_POST AS SPOST,
NOTIFICATIONS.SIGNER_FULL_NAME AS SNAME,
RECIPIENT_FULL_NAME AS FIO,
RTRIM(ISNULL(APPLICATION_TYPES.NAME_GENITIVE_CASE,'') + ' ' + ISNULL(APPLICATION_REASONS.NAME_PREPOSITIONAL_CASE, '')) AS REAS,
APPLICATION_INSTITUTIONS.IS_APPLICANT as ORD,
COUNT(*) OVER () [TotalRows]

FROM NOTIFICATIONS
left join APPLICATIONS on NOTIFICATIONS.APPLICATION_FK=APPLICATIONS.ID
left join APPLICATION_REASONS on APPLICATION_REASONS.ID=APPLICATIONS.REASON_FK
left join APPLICATION_TYPES on APPLICATION_TYPES.ID=APPLICATION_REASONS.APPLICATION_TYPE_FK
left join REFUSAL_TYPES on REFUSAL_TYPES.ID=APPLICATIONS.REFUSAL_TYPE_FK
left join USERS on USERS.ID=NOTIFICATIONS.EXECUTANT_FK
left join APPLICATION_INSTITUTIONS on APPLICATION_INSTITUTIONS.APPLICATION_FK=APPLICATIONS.ID
left join EDU_INSTITUTIONS on EDU_INSTITUTIONS.ID=APPLICATION_INSTITUTIONS.INSTITUTION_FK

WHERE
NOTIFICATIONS.ID='20874f82-1887-4214-8812-53c21611202f'

) as tmp  ORDER BY INS ASC )
when TotalRows > 2 then INS + ' и '+ cast(TotalRows-1 as nvarchar)+' филиалами'
when TotalRows > 2 and ORD=0 then cast(TotalRows as nvarchar)+' филиалами ' + (SELECT top 1 INS from EDU_INSTITUTIONS as EDU where edu.id = id )
end
from(
SELECT
EDU_INSTITUTIONS.ID as ID,
EDU_INSTITUTIONS.FULL_NAME_GENITIVE_CASE AS GEN,
EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE AS INS,
EDU_INSTITUTIONS.FULL_NAME_DATIVE_CASE AS DAT,
NOTIFICATIONS.[ADDRESS] AS [ADDRESS],
NOTIFICATIONS.NUMBER AS NUM,
NOTIFICATIONS.RESPONSE_NUMBER AS RNUM,
NOTIFICATIONS.SIGN_DATE AS SDATE,
NOTIFICATIONS.SIGNER_POST AS SPOST,
NOTIFICATIONS.SIGNER_FULL_NAME AS SNAME,
RECIPIENT_FULL_NAME AS FIO,
RTRIM(ISNULL(APPLICATION_TYPES.NAME_GENITIVE_CASE,'') + ' ' + ISNULL(APPLICATION_REASONS.NAME_PREPOSITIONAL_CASE, '')) AS REAS,
APPLICATION_INSTITUTIONS.IS_APPLICANT as ORD,
COUNT(*) OVER () [TotalRows]

FROM NOTIFICATIONS
left join APPLICATIONS on NOTIFICATIONS.APPLICATION_FK=APPLICATIONS.ID
left join APPLICATION_REASONS on APPLICATION_REASONS.ID=APPLICATIONS.REASON_FK
left join APPLICATION_TYPES on APPLICATION_TYPES.ID=APPLICATION_REASONS.APPLICATION_TYPE_FK
left join REFUSAL_TYPES on REFUSAL_TYPES.ID=APPLICATIONS.REFUSAL_TYPE_FK
left join USERS on USERS.ID=NOTIFICATIONS.EXECUTANT_FK
left join APPLICATION_INSTITUTIONS on APPLICATION_INSTITUTIONS.APPLICATION_FK=APPLICATIONS.ID
left join EDU_INSTITUTIONS on EDU_INSTITUTIONS.ID=APPLICATION_INSTITUTIONS.INSTITUTION_FK

WHERE
NOTIFICATIONS.ID='20874f82-1887-4214-8812-53c21611202f'

) as tmp
order by ORD desc

A: Maybe you can use next combination:
....

SELECT INSE =
CASE
WHEN TotalRows = 1 THEN INS
WHEN TotalRows = 2 THEN
    (SELECT TOP 1 EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE
      FROM tmp AS EDU
      ORDER BY EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE ASC) + ' ' +
    (SELECT TOP 1 EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE
      FROM tmp AS EDU
      ORDER BY EDU_INSTITUTIONS.FULL_NAME_INSTRUMENTAL_CASE DESC)
WHEN CAST(TotalRows AS int) > 2 THEN INS + ' и '+ CAST(TotalRows-1 as nvarchar)+' филиалами'
END

....


text:
Q: C# windows forms TabControl I have a Windows forms application with a TabControl with 2 tabs. tab1 does some calculations and tab2 has a chart that graphs updated values from tab1.
The issue is that I cannot click tab2 while tab1 processing are running. I want to be able to see the graph change in real-time but I have to wait until processes in tab1 are complete before I can click tab2, otherwise my app will lock.
I am using System.Windows.Forms.DataVisualization.Charting; for the graph.
Any advice?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Define Operator < in struct for 2 objects of another struct I have a little problem in C++ and i hope you are able to help me out.
I want to define a struct myPoint. This struct should be able to compare two objects from type point (defined as pair). I want every "Instance" of myPoint to be able to compare two points on its own. This is what i tried to code:
typedef pair<int,int> point;
struct myPoint{
    point p;
    inline bool operator<( point x, point y ){
    return !ccw(p,x,y);
}

So every myPoint should consider his own point p while comparing two points x,y.
The (translated) Error I get is
"error C2804:  Binary Operator '<' has too much Arguments/Parameters"

It seems like it's syntacticly possible to make this operator with only one point, I guess the it would compare a point to a myPoint, but that's not what it should be.
Background of the problem is that i want to use a predefined sort function to sort a vector of points and as sorting "function" I want to deliver a myPoint object.

A: I think (maybe) that what you are trying to do is write a functor
struct myPoint
{
    myPoint(point p) { this->p = p; }
    bool operator()(point x, point y) const
    {
        return !ccw(p,x,y);
    }
    point p;
};

A functor can be passed as the third argument to std::sort.
std::sort(vec.begin(), vec.end(), myPoint(p));

I have my doubts though, assuming ccw means counterclockwise I don't think this is a valid sort condition.

A: The < defines overload with only one parameter.  As noted by @KonradRudolph, it makes no sense to overload < in this case 'cause you couldn't use it in sorting or anything
typedef pair<int,int> point;
struct myPoint{
    point p;
    bool smaller(const point &a, const point &b)
    {
        return !ccw(p,a,a)
    }
};

A: This fragment should illustrate basic things for you:
#include <utility>

typedef std::pair<int,int> point;

bool less(const point& p1, const point& p2)
{
    return (p1.first < p2.first) ||
           ((p1.first == p2.first) && (p1.second == p2.second));
}

struct myPoint {
    point p;
    inline bool operator < (const point& p2) {
        return less(p, p2);
    }
};

int main()
{
    return 0;
}

*

*You had not 'closed' operator <.

*Operator < requires exactly one argument if is a method like here.

*Use constant references.


text:
Q: Creating Dynamically Allocated Strings from a file in C I am having some issues with dynamically allocating a string for a node in a tree. I have included my node structure below for reference.
struct node
{
    char *string;
    struct node *left;
    struct node *right;
};
typedef struct node node;

I am supposed to read words from a text file and then store those words into a tree. I am able to store char arrays that have been defined, such as char string[20] without problems, but not strings that are supposed to be dynamically allocated.
I am only going to post the code I am using to read my file and try to create the dynamically allocated array. I have already created the file pointer and checked that it is not NULL. Every time I try to run the program, it simply crashes, do I need to try and read the words character by character?
//IN MAIN
node *p, *root ;
int i;
int u;

root = NULL;
char input[100];

while(fscanf(fp, "%s", &input) != EOF)
{
    //Create the node to insert into the tree
    p = (node *)malloc(sizeof(node));
    p->left = p->right = NULL;

    int p = strlen(input); //get the length of the read string
    char *temp = (char*) malloc(sizeof(char)*p);
    //malloc a dynamic string of only the length needed

    strcpy(local, input);
    strcpy(p->word,local);

    insert(&root, p);
}

To be completely clear, I only want advice regarding the logic of my code, and only would like someone to help point me in the right direction.

A: You are invoking many undefined behaviors by

*

*passing pointer to object having wrong type to scanf(). i.e. In fscanf(ifp, "%s", &input), char(*)[100] is passed where char* is expected

*accessing out-of-range of allocated buffer when storeing terminating null-character in strcpy(local, input);

*using value of buffer allocated via malloc() and not initialized in strcpy(curr->word,local);
Your code should be like this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct node_t {
    struct node_t* left, *right;
    int count;
    char* word;
} node;
void insert(node ** tree, node * item);

int main(void) {
    FILE* ifp = stdin;

    node * curr, * root;
    int i;
    int u;

    root = NULL;
    char input[100];

    /* you should specify the maximum length to read in order to avoid buffer overrun */
    while(fscanf(ifp, "%99s", input) != EOF)
    {
        //Create the node to insert into the tree
        curr = malloc(sizeof(node));
        if(curr == NULL) /* add error check */
        {
            perror("malloc 1");
            return 1;
        }
        curr->left = curr->right = NULL;
        curr->count = 1;

        int p = strlen(input); //get the length of the read string
        char *local = malloc(sizeof(char)*(p + 1)); /* make room for terminating null-character */
        if (local == NULL) /* add error check again */
        {
            perror("malloc 2");
            return 1;
        }
        //malloc a dynamic string of only the length needed

        //To lowercase, so Job and job is considered the same word
        /* using strlen() in loop condition is not a good idea.
         * you have already calculated it, so use it. */
        for(u = 0; u < p; u++)
        {
            /* cast to unsigned char in order to avoid undefined behavior
             * for passing out-of-range value */
            input[u] = tolower((unsigned char)input[u]);
        }

        strcpy(local, input);
        curr->word = local; /* do not use strcpy, just assign */

        insert(&root, curr);
    }

    /* code to free what is allocated will be here */
    return 0;
}

//Separate insert function
void insert(node ** tree, node * item)
{
   if(!(*tree))
   {
      *tree = item;
      return;
   }
        if(strcmp(item->word,(*tree)->word) < 0)
            insert(&(*tree)->left, item);
        else if(strcmp(item->word,(*tree)->word) > 0)
            insert(&(*tree)->right, item);
        /* note: memory leak may occur if the word read is same as what is previously read */
}


text:
Q: Angular ngClass not working when using enum values I am using Angular 7.
I got this HTML:

 {{currentMoveMessage}}

....

Inside the component's class:
enum GameMode
{
    NONE_SELECTED = 0,
    ONE_SELECTED = 1,
    TWO_SELECTED_SUCCESS = 2,
    TWO_SELECTED_FAILURE = 3,
    GAME_OVER = 4
};

@Component({
  selector: 'app-cardcomponent',
  templateUrl: './cardcomponent.component.html',
  styleUrls: ['./cardcomponent.component.css'],
})

export class CardcomponentComponent implements OnInit
{
  currentMoveMessage: string;
  gameModeVar : GameMode;

  constructor(public cardService: CardService)
  {
    this.currentMoveMessage = "message";
    this.gameModeVar = GameMode.NONE_SELECTED;
...
}

When I load the page, nothing is rendered because of the ngClass. If I use the numeric values of the enum, meaning in the HTML I'm changing the comparison of gameModeVar to gameModeVar === 1 instead of gameModeVar === GameMode.ONE_SELECTED (but for all values, not just 1) , it does work.
1) Is the way I'm declaring the enum inside the same file of the class above the @Component (it couldn't be declared after it without compilation error), the correct way to do it, as it's supposed to be private to this component?
2) What's the issue with the ngClass ?

A: 1)
enum can't be really private but I think what you have is fine since you are not exporting it and it is only accessible through instance of that component. One other idea that comes to my mind could be simple object like this enum, public one or maybe private with getter (get) to access it.
  GameMode = {
    NONE_SELECTED: 0,
    ONE_SELECTED: 1,
    TWO_SELECTED_SUCCESS: 2,
    TWO_SELECTED_FAILURE: 3,
    GAME_OVER: 4
  };

2)
Add this line in your class: GameMode = GameMode;. As I wrote in the comments - "I believe it's about context of component since that class is connected with template". It's not only case for enum but whatever you declare outside component class, like const someNumber = 35; it won't be accessible in template by {{someNumber}}. When I faced this problem I found out that this is about context but if there is different reason or something more please do correct me.


text:
Q: How to check if a window style exists in a hexadecimal? I have a question regarding a window style hexadecimal.
According to http://support.microsoft.com/kb/111011/en-us, 0x16CF0000 contains window styles of WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX.
How do I check if a window style exist in a combination of window styles? For example, I would like to check if WS_BORDER (0x00800000) style exists in 0x16CF0000.

A: The standard form is:
if (value & WS_BORDER != 0) {  }

The & will do a bitwise-AND and only if the bit of WS_BORDER is set will the result be non-zero

A: Basically, you can just check whether yourValue AND WS_BORDER = WS_BORDER.
Unfortunately, some of the bits inside of the style flags are used twice, depending on context, so for example both WS_TABSTOP and WS_MAXIMIZEBOX are 0x00010000, so it depends on the context (position of the object and maybe other flags) whether a window really has that property (while a parent control cannot have a tab stop, a child control sometimes can have a maximize box)...
WS_OVERLAPPED      = 0x00000000,
WS_POPUP           = 0x80000000,
WS_CHILD           = 0x40000000,
WS_MINIMIZE        = 0x20000000,
WS_VISIBLE         = 0x10000000,
WS_DISABLED        = 0x08000000,
WS_CLIPSIBLINGS    = 0x04000000,
WS_CLIPCHILDREN    = 0x02000000,
WS_MAXIMIZE        = 0x01000000,
WS_BORDER          = 0x00800000,
WS_DLGFRAME        = 0x00400000,
WS_VSCROLL         = 0x00200000,
WS_HSCROLL         = 0x00100000,
WS_SYSMENU         = 0x00080000,
WS_THICKFRAME      = 0x00040000,
WS_GROUP           = 0x00020000,
WS_TABSTOP         = 0x00010000,

WS_MINIMIZEBOX     = 0x00020000,
WS_MAXIMIZEBOX     = 0x00010000,

WS_CAPTION         = WS_BORDER | WS_DLGFRAME,
WS_TILED           = WS_OVERLAPPED,
WS_ICONIC          = WS_MINIMIZE,
WS_SIZEBOX         = WS_THICKFRAME,
WS_TILEDWINDOW     = WS_OVERLAPPEDWINDOW,

WS_OVERLAPPEDWINDOW    = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
                         WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
WS_POPUPWINDOW     = WS_POPUP | WS_BORDER | WS_SYSMENU,
WS_CHILDWINDOW     = WS_CHILD,

A: if(0x16CF0000 & WS_BORDER)

A: Check IF((0x16CF0000 | WS_BORDER) == 0x16CF0000)

A: In the past, I have taken the header file where such things were defined and wrote a script to turn it into code that would take the Variable which the flags were and convert it into a text string containing the symbolic name of the constants.
Parsing #defines is rather easy back in the day I used something like AWK to do this.  Now days, if I have it on the machine I'm using at the time, Python or if Python's not readily available I'd drop back to AWK.

A: This question really concerned me as I was creating a win32 dialog builder. One of the features was setting the style of all win32 common controls, and also user defined controls. I have learnt alot via observation, and the little documentation provided by MSDN; and I wish to share my information. Which will go beyond answering this question.
How did the Microsoft team format their window styles?

*

*Their are general window styles that applies to all windows. They begin with 'WS_' and are found in the high order bits. 0xffff0000.

*Then there are Control specific/ user defined styles that begin with their specified prefix. Such as BS for ButtonStyle, CBS for ComboBoxStyle, and so on. They are found in the low order bits. 0x0000ffff.
There are 5 types in these two levels of styles:

*

*Default - These kinds of style are equal to zero. This style is only chosen if
style is equal to zero.

*flag - These kinds of style never equates to zero, and are placed on unique
bits. Meaning that these styles can be used simultaneously.

*exclusive - These kinds of styles normally share bits with each other. But this doesn't have to be the case as WS_POPUP and WS_CHILD are exclusive but they don't share bits. Most other styles such as CBS_SIMPLE and CBS_DROPDOWN are exclusive and indeed share bits. Exclusive styles often represent a category. BS_OWNERDRAW, BS_RADIOBUTTON, BS_PUSHBUTTON all represent the type of button category. BS_CENTER, BS_LEFT, BS_TOP are the alignment category. Note that BS_PUSHBUTTON is equal to zero and represents the Default for the type category.

*compound - These kinds of styles are comprised of multiply styles. Such as WS_OVERLAPPEDWINDOW, WS_POPUPWINDOW, DS_SHELLFONT, LBS_STANDARD.

*synonym - These kinds of styles refer to the same thing. Eg: WS_CHILDWINDOW vs WS_CHILD, WS_TILED vs WS_OVERLAPPED, WS_TILEDWINDOW vs WS_OVERLAPPEDWINDOW. Note that WS_TABSTOP and WS_MAXIMIZEBOX share the same value but they are not synonymns as they are semantically different. How? This is outside my scope of knowledge. WS_TABSTOP is applied to controls used in a dialog and the dialog implements the right behaviour. However, you can use isDialogMessage to simulate the same behaviour outside of a dialog. And child windows can have maximize box. For my application, I completely ignored WS_TABSTOP style.
How do we test for a style?
I created a function that converts a style to string. However, a function that test if a style exists in another style might be impractical, as this requires alot of context. A sample function prototype would look as follows...
/** \param className - use WC_DIALOG for dialog window
                       use NULL for top level window
*/
bool hasWindowStyle(const char *className,UINT style,UINT requiredStyle);

className would be used as the major context. If className is WC_DIALOG, then all of the DS_* styles are available to the window. But it cannot have styles that belong to the button class, edit class, etc. Problem is, the following is technically wrong...
return (style & requiredStyle) == requiredStyle;

This is faulty because, even if requiredStyle exist in style, doesnt mean that requiredStyle is a valid style for the particular className. This would require us to have a map of all styles of the particular class, and only if requiredStyle exist in that map, return the above formula.
std::map<std::string,UINT> win32_class_list;

auto elem = win32_class_list.find(className);
auto invalid = win32_class_list.end();

if(elem == invalid) return false;
else return (style & requiredStyle) == requiredStyle;

The above solved the first problem. But the last problem seems impractical to solve. Lets say you have a required style which is CBS_SIMPLE|CBS_LOWERCASE. How would you determine if this required style was apart of the combobox's style. This is a very contextual question.
Check out my Part 2 for a function that converts window style to string.

A: PART 2
A genaral function for converting a window style to string. Hope this is useful to some one. Note that due to space, you will have to implement the following two function prototypes.
Jav/string/builder.h
/** \brief builds a string from parts and appends it to result.
    \param result
    \param format a format string similar to sprintf, except that '?' is
           the only format specifier. C++ template system automatically
           deduces the type and count of format specifiers.
    \param arg first argument of parameter pack is always const char* in
           this case.
    \param REST... rest of parts. Can support any and every C++ type.
  */
template<class ...REST>
void buildString(std::string &result,const char *format,const char *arg,REST...);

Jav/string/numconv.h
/** \brief converts num to a hexidecimal string consisting of a
           hexidecimal prefix '0x'.
  */
const char* hex_string(uint num);

win_styles.cpp
namespace {

enum { USER_DEFINED_STYLE_MASK = 0xffff };

struct ClassNameCompare
{
    bool operator()(const char *lhs,const char *rhs)
    {
     return strcmp(lhs,rhs) < 0;
    }
};

using Win32StyleExpert = void(*)(std::string&,uint,const char*);
using Win32ClassList = std::map<const char*,Win32StyleExpert,ClassNameCompare>;

extern Win32ClassList win32_class_list;

Win32StyleExpert getWin32StyleExpert(const char *className)
{
 auto elem = win32_class_list.find(className);
 return elem == win32_class_list.end() ? NULL : &elem->second;
}

}

std::string windowStyleToString(const char *className,uint style,const char *sep)
{
    std::string s;

    if( (style & WS_OVERLAPPEDWINDOW) == WS_OVERLAPPEDWINDOW ) buildString(s,"??","WS_OVERLAPPEDWINDOW",sep);
    else
    {
     if( (style & WS_SIZEBOX) == WS_SIZEBOX ) buildString(s,"??","WS_SIZEBOX",sep);
     if( (style & WS_MINIMIZEBOX) == WS_MINIMIZEBOX )   buildString(s,"??","WS_MINIMIZEBOX",sep);
     if( (style & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX )   buildString(s,"??","WS_MAXIMIZEBOX",sep);
     if( (style & WS_SYSMENU) == WS_SYSMENU )   buildString(s,"??","WS_SYSMENU",sep);

     if( (style & WS_CAPTION) == WS_CAPTION )   buildString(s,"??","WS_CAPTION",sep);
     else if( (style & WS_BORDER) == WS_BORDER )    buildString(s,"??","WS_BORDER",sep);
    }

    if( (style & WS_CHILD) == WS_CHILD )buildString(s,"??","WS_CHILD",sep);
    else if( (style & WS_POPUP) == WS_POPUP ) buildString(s,"??","WS_POPUP",sep);

    if( (style & WS_MINIMIZE) == WS_MINIMIZE )  buildString(s,"??","WS_MINIMIZE",sep);
    if( (style & WS_MAXIMIZE) == WS_MAXIMIZE )  buildString(s,"??","WS_MAXIMIZE",sep);
    if( (style & WS_DISABLED) ==  WS_DISABLED)  buildString(s,"??","WS_DISABLED",sep);
    if( (style & WS_HSCROLL) ==  WS_HSCROLL)    buildString(s,"??","WS_HSCROLL",sep);
    if( (style & WS_VSCROLL) ==  WS_VSCROLL)    buildString(s,"??","WS_VSCROLL",sep);
    if( (style & WS_VISIBLE) ==  WS_VISIBLE)    buildString(s,"??","WS_VISIBLE",sep);

    if( (style & WS_DLGFRAME) ==  WS_DLGFRAME && (style & WS_CAPTION) != WS_CAPTION)
            buildString(s,"??","WS_DLGFRAME",sep);

    if((int)className == (int)WC_DIALOG)
    {
        if( (style & DS_SHELLFONT) == DS_SHELLFONT ) buildString(s,"??","DS_SHELLFONT",sep);
        else
        {
         if( (style & DS_FIXEDSYS) == DS_FIXEDSYS ) buildString(s,"??","DS_FIXEDSYS",sep);
         if( (style & DS_SETFONT) == DS_SETFONT )   buildString(s,"??","DS_SETFONT",sep);
        }

        if( (style & DS_ABSALIGN) == DS_ABSALIGN )  buildString(s,"??","DS_ABSALIGN",sep);
        if( (style & DS_CENTER) == DS_CENTER )  buildString(s,"??","DS_CENTER",sep);
        if( (style & DS_CENTERMOUSE) == DS_CENTERMOUSE )    buildString(s,"??","DS_CENTERMOUSE",sep);
        if( (style & DS_CONTEXTHELP) == DS_CONTEXTHELP )    buildString(s,"??","DS_CONTEXTHELP",sep);
        if( (style & DS_CONTROL) == DS_CONTROL )    buildString(s,"??","DS_CONTROL",sep);
        if( (style & DS_LOCALEDIT) == DS_LOCALEDIT )    buildString(s,"??","DS_LOCALEDIT",sep);
        if( (style & DS_MODALFRAME) == DS_MODALFRAME )  buildString(s,"??","DS_MODALFRAME",sep);
        if( (style & DS_NOFAILCREATE) == DS_NOFAILCREATE )  buildString(s,"??","DS_NOFAILCREATE",sep);
        if( (style & DS_SETFOREGROUND) == DS_SETFOREGROUND )    buildString(s,"??","DS_SETFOREGROUND",sep);
    }
    else if(auto pushStyle = getWin32StyleExpert(className))
    {
     if(style == 0) return "0";
     else pushStyle(s,style,sep);
    }
    else if( style == WS_OVERLAPPED ) return "WS_OVERLAPPED";
    else if(className == NULL) buildString(s,"??",Jav::hex_str(style&USER_DEFINED_STYLE_MASK),sep);

    if(s.empty()) return "";

    s.pop_back(); //remove the last seperator added
    return s;
}

namespace {

void pushAnimateControlStyle(std::string &s,uint style,const char *sep)
{
    if( (style & ACS_AUTOPLAY) == ACS_AUTOPLAY )    buildString(s,"??","ACS_AUTOPLAY",sep);
    if( (style & ACS_CENTER) == ACS_CENTER )    buildString(s,"??","ACS_CENTER",sep);
    if( (style & ACS_TIMER) == ACS_TIMER )  buildString(s,"??","ACS_TIMER",sep);
}

void pushButtonStyle(std::string &s,uint style,const char *sep)
{
    if( (style & 0xf) == BS_3STATE )buildString(s,"??","BS_3STATE",sep);
    else if( (style & 0xf) == BS_AUTO3STATE )   buildString(s,"??","BS_AUTO3STATE",sep);
    else if( (style & 0xf) == BS_AUTOCHECKBOX ) buildString(s,"??","BS_AUTOCHECKBOX",sep);
    else if( (style & 0xf) == BS_AUTORADIOBUTTON )  buildString(s,"??","BS_AUTORADIOBUTTON",sep);
    else if( (style & 0xf) == BS_CHECKBOX ) buildString(s,"??","BS_CHECKBOX",sep);
    else if( (style & 0xf) == BS_DEFPUSHBUTTON )    buildString(s,"??","BS_DEFPUSHBUTTON",sep);
    else if( (style & 0xf) == BS_GROUPBOX ) buildString(s,"??","BS_GROUPBOX",sep);
    else if( (style & 0xf) == BS_OWNERDRAW )    buildString(s,"??","BS_OWNERDRAW",sep);
    else if( (style & 0xf) == BS_RADIOBUTTON )  buildString(s,"??","BS_RADIOBUTTON",sep);
    else buildString(s,"??","BS_PUSHBUTTON",sep);

    if( (style & 0xc0) == BS_BITMAP )buildString(s,"??","BS_BITMAP",sep);
    else if( (style & 0xc0) == BS_ICON )buildString(s,"??","BS_ICON",sep);
    else buildString(s,"??","BS_TEXT",sep);

    if( (style & 0xf00) == BS_CENTER )buildString(s,"??","BS_CENTER",sep);
    else if( (style & 0xf00) == BS_VCENTER )    buildString(s,"??","BS_VCENTER",sep);
    else if( (style & 0xf00) == BS_LEFT )buildString(s,"??","BS_LEFT",sep);
    else if( (style & 0xf00) == BS_TOP )buildString(s,"??","BS_TOP",sep);
    else if( (style & 0xf00) == BS_RIGHT )buildString(s,"??","BS_RIGHT",sep);
    else if( (style & 0xf00) == BS_BOTTOM )buildString(s,"??","BS_BOTTOM",sep);

    if( (style & BS_FLAT) == BS_FLAT )buildString(s,"??","BS_FLAT",sep);
    if( (style & BS_MULTILINE) == BS_MULTILINE )    buildString(s,"??","BS_MULTILINE",sep);
    if( (style & BS_NOTIFY) == BS_NOTIFY )buildString(s,"??","BS_NOTIFY",sep);
    if( (style & BS_PUSHLIKE) == BS_PUSHLIKE )  buildString(s,"??","BS_PUSHLIKE",sep);
    if( (style & BS_LEFTTEXT) == BS_LEFTTEXT )  buildString(s,"??","BS_LEFTTEXT",sep);
}

void pushComboBoxExStyle(std::string &s,uint style,const char *sep)
{
    if( (style & CBES_EX_CASESENSITIVE) == CBES_EX_CASESENSITIVE )  buildString(s,"??","CBES_EX_CASESENSITIVE",sep);
    if( (style & CBES_EX_NOEDITIMAGE) == CBES_EX_NOEDITIMAGE )  buildString(s,"??","CBES_EX_NOEDITIMAGE",sep);
    if( (style & CBES_EX_NOEDITIMAGEINDENT) == CBES_EX_NOEDITIMAGEINDENT )  buildString(s,"??","CBES_EX_NOEDITIMAGEINDENT",sep);
    if( (style & CBES_EX_NOSIZELIMIT) == CBES_EX_NOSIZELIMIT )  buildString(s,"??","CBES_EX_NOSIZELIMIT",sep);
    if( (style & CBES_EX_PATHWORDBREAKPROC) == CBES_EX_PATHWORDBREAKPROC )  buildString(s,"??","CBES_EX_PATHWORDBREAKPROC",sep);
}

void pushComboBoxStyle(std::string &s,uint style,const char *sep)
{
    if( (style & 3) == CBS_SIMPLE )buildString(s,"??","CBS_SIMPLE",sep);
    else if( (style & 3) == CBS_DROPDOWN )  buildString(s,"??","CBS_DROPDOWN",sep);
    else if( (style & 3) == CBS_DROPDOWNLIST )  buildString(s,"??","CBS_DROPDOWNLIST",sep);

    if( (style & 0x30) == CBS_OWNERDRAWFIXED )  buildString(s,"??","CBS_OWNERDRAWFIXED",sep);
    else if( (style & 0x30) == CBS_OWNERDRAWVARIABLE )  buildString(s,"??","CBS_OWNERDRAWVARIABLE",sep);

    if( (style & 0x6000) == CBS_LOWERCASE ) buildString(s,"??","CBS_LOWERCASE",sep);
    else if( (style & 0x6000) == CBS_UPPERCASE )    buildString(s,"??","CBS_UPPERCASE",sep);

    if( (style & CBS_DISABLENOSCROLL) == CBS_DISABLENOSCROLL )  buildString(s,"??","CBS_DISABLENOSCROLL",sep);
    if( (style & CBS_NOINTEGRALHEIGHT) == CBS_NOINTEGRALHEIGHT )    buildString(s,"??","CBS_NOINTEGRALHEIGHT",sep);
    if( (style & CBS_SORT) == CBS_SORT )buildString(s,"??","CBS_SORT",sep);
    if( (style & CBS_AUTOHSCROLL) == CBS_AUTOHSCROLL )  buildString(s,"??","CBS_AUTOHSCROLL",sep);
    if( (style & CBS_OEMCONVERT) == CBS_OEMCONVERT )    buildString(s,"??","CBS_OEMCONVERT",sep);
}

void pushEditControlStyle(std::string &s,uint style,const char *sep)
{
    if( (style & 0x3) == ES_CENTER )buildString(s,"??","ES_CENTER",sep);
    else if( (style & 0x3) == ES_RIGHT )buildString(s,"??","ES_RIGHT",sep);

    if( (style & 0x18) == ES_LOWERCASE )    buildString(s,"??","ES_LOWERCASE",sep);
    else if( (style & 0x18) == ES_UPPERCASE )   buildString(s,"??","ES_UPPERCASE",sep);

    if( (style & ES_AUTOHSCROLL) == ES_AUTOHSCROLL )    buildString(s,"??","ES_AUTOHSCROLL",sep);
    if( (style & ES_AUTOVSCROLL) == ES_AUTOVSCROLL )    buildString(s,"??","ES_AUTOVSCROLL",sep);
    if( (style & ES_MULTILINE) == ES_MULTILINE )    buildString(s,"??","ES_MULTILINE",sep);
    if( (style & ES_NOHIDESEL) == ES_NOHIDESEL )    buildString(s,"??","ES_NOHIDESEL",sep);
    if( (style & ES_NUMBER) == ES_NUMBER )  buildString(s,"??","ES_NUMBER",sep);
    if( (style & ES_OEMCONVERT) == ES_OEMCONVERT )  buildString(s,"??","ES_OEMCONVERT",sep);
    if( (style & ES_PASSWORD) == ES_PASSWORD )  buildString(s,"??","ES_PASSWORD",sep);
    if( (style & ES_READONLY) == ES_READONLY )  buildString(s,"??","ES_READONLY",sep);
    if( (style & ES_WANTRETURN) == ES_WANTRETURN )  buildString(s,"??","ES_WANTRETURN",sep);
}

void pushHeaderControlStyle(std::string &s,uint style,const char *sep)
{
    if( (style & HDS_BUTTONS) == HDS_BUTTONS )  buildString(s,"??","HDS_BUTTONS",sep);
    if( (style & HDS_DRAGDROP) == HDS_DRAGDROP )    buildString(s,"??","HDS_DRAGDROP",sep);
    if( (style & HDS_FILTERBAR) == HDS_FILTERBAR )  buildString(s,"??","HDS_FILTERBAR",sep);
    if( (style & HDS_FULLDRAG) == HDS_FULLDRAG )    buildString(s,"??","HDS_FULLDRAG",sep);
    if( (style & HDS_HIDDEN) == HDS_HIDDEN )    buildString(s,"??","HDS_HIDDEN",sep);
    if( (style & HDS_HORZ) == HDS_HORZ )    buildString(s,"??","HDS_HORZ",sep);
    if( (style & HDS_HOTTRACK) == HDS_HOTTRACK )    buildString(s,"??","HDS_HOTTRACK",sep);
}

void pushListBoxStyle(std::string &s,uint style,const char *sep)
{
    if( (style & 0x30) == LBS_OWNERDRAWFIXED )  buildString(s,"??","LBS_OWNERDRAWFIXED",sep);
    else if( (style & 0x30) == LBS_OWNERDRAWVARIABLE )  buildString(s,"??","LBS_OWNERDRAWVARIABLE",sep);

    if( (style & LBS_DISABLENOSCROLL) == LBS_DISABLENOSCROLL )  buildString(s,"??","LBS_DISABLENOSCROLL",sep);
    if( (style & LBS_EXTENDEDSEL) == LBS_EXTENDEDSEL )  buildString(s,"??","LBS_EXTENDEDSEL",sep);
    if( (style & LBS_HASSTRINGS) == LBS_HASSTRINGS )    buildString(s,"??","LBS_HASSTRINGS",sep);
    if( (style & LBS_MULTICOLUMN) == LBS_MULTICOLUMN )  buildString(s,"??","LBS_MULTICOLUMN",sep);
    if( (style & LBS_MULTIPLESEL) == LBS_MULTIPLESEL )  buildString(s,"??","LBS_MULTIPLESEL",sep);
    if( (style & LBS_NODATA) == LBS_NODATA )    buildString(s,"??","LBS_NODATA",sep);
    if( (style & LBS_NOINTEGRALHEIGHT) == LBS_NOINTEGRALHEIGHT )    buildString(s,"??","LBS_NOINTEGRALHEIGHT",sep);
    if( (style & LBS_NOREDRAW) == LBS_NOREDRAW )    buildString(s,"??","LBS_NOREDRAW",sep);
    if( (style & LBS_NOSEL) == LBS_NOSEL )  buildString(s,"??","LBS_NOSEL",sep);
    if( (style & LBS_NOTIFY) == LBS_NOTIFY )    buildString(s,"??","LBS_NOTIFY",sep);
    if( (style & LBS_SORT) == LBS_SORT )    buildString(s,"??","LBS_SORT",sep);
    if( (style & LBS_USETABSTOPS) == LBS_USETABSTOPS )  buildString(s,"??","LBS_USETABSTOPS",sep);
    if( (style & LBS_WANTKEYBOARDINPUT) == LBS_WANTKEYBOARDINPUT )  buildString(s,"??","LBS_WANTKEYBOARDINPUT",sep);
}

void pushListViewStyle(std::string &s,uint style,const char *sep)
{
    if( (style & LVS_TYPEMASK) == LVS_REPORT )  buildString(s,"??","LVS_REPORT",sep);
    else if( (style & LVS_TYPEMASK) == LVS_LIST )   buildString(s,"??","LVS_LIST",sep);
    else if( (style & LVS_TYPEMASK) == LVS_SMALLICON )  buildString(s,"??","LVS_SMALLICON",sep);
    else buildString(s,"??","LVS_ICON",sep);

    if( (style & 0x30) == LVS_SORTASCENDING )   buildString(s,"??","LVS_SORTASCENDING",sep);
    else if( (style & 0x30) == LVS_SORTDESCENDING ) buildString(s,"??","LVS_SORTDESCENDING",sep);

    if( (style & LVS_ALIGNLEFT) == LVS_ALIGNLEFT )  buildString(s,"??","LVS_ALIGNLEFT",sep);
    if( (style & LVS_NOCOLUMNHEADER) == LVS_NOCOLUMNHEADER )    buildString(s,"??","LVS_NOCOLUMNHEADER",sep);
    if( (style & LVS_NOSORTHEADER) == LVS_NOSORTHEADER )    buildString(s,"??","LVS_NOSORTHEADER",sep);
    if( (style & LVS_AUTOARRANGE) == LVS_AUTOARRANGE )  buildString(s,"??","LVS_AUTOARRANGE",sep);
    if( (style & LVS_EDITLABELS) == LVS_EDITLABELS )    buildString(s,"??","LVS_EDITLABELS",sep);
    if( (style & LVS_NOLABELWRAP) == LVS_NOLABELWRAP )  buildString(s,"??","LVS_NOLABELWRAP",sep);
    if( (style & LVS_NOSCROLL) == LVS_NOSCROLL )    buildString(s,"??","LVS_NOSCROLL",sep);
    if( (style & LVS_OWNERDATA) == LVS_OWNERDATA )  buildString(s,"??","LVS_OWNERDATA",sep);
    if( (style & LVS_OWNERDRAWFIXED) == LVS_OWNERDRAWFIXED )    buildString(s,"??","LVS_OWNERDRAWFIXED",sep);
    if( (style & LVS_SHAREIMAGELISTS) == LVS_SHAREIMAGELISTS )  buildString(s,"??","LVS_SHAREIMAGELISTS",sep);
    if( (style & LVS_SHOWSELALWAYS) == LVS_SHOWSELALWAYS )  buildString(s,"??","LVS_SHOWSELALWAYS",sep);
    if( (style & LVS_SINGLESEL) == LVS_SINGLESEL )  buildString(s,"??","LVS_SINGLESEL",sep);
}

void pushMonthCalendarControlStyle(std::string &s,uint style,const char *sep)
{
    if( (style & MCS_DAYSTATE) == MCS_DAYSTATE )    buildString(s,"??","MCS_DAYSTATE",sep);
    if( (style & MCS_MULTISELECT) == MCS_MULTISELECT )  buildString(s,"??","MCS_MULTISELECT",sep);
    if( (style & MCS_WEEKNUMBERS) == MCS_WEEKNUMBERS )  buildString(s,"??","MCS_WEEKNUMBERS",sep);
    if( (style & MCS_NOTODAYCIRCLE) == MCS_NOTODAYCIRCLE )  buildString(s,"??","MCS_NOTODAYCIRCLE",sep);
    if( (style & MCS_NOTODAY) == MCS_NOTODAY )  buildString(s,"??","MCS_NOTODAY",sep);
}

void pushProgressBarStyle(std::string &s,uint style,const char *sep)
{
    if( (style & PGS_AUTOSCROLL) == PGS_AUTOSCROLL )    buildString(s,"??","PGS_AUTOSCROLL",sep);
    if( (style & PGS_DRAGNDROP) == PGS_DRAGNDROP )  buildString(s,"??","PGS_DRAGNDROP",sep);
    if( (style & PGS_HORZ) == PGS_HORZ )buildString(s,"??","PGS_HORZ",sep);
    if( (style & PGS_VERT) == PGS_VERT )buildString(s,"??","PGS_VERT",sep);
    if( (style & PBS_SMOOTH) == PBS_SMOOTH )    buildString(s,"??","PBS_SMOOTH",sep)
    if( (style & PBS_VERTICAL) == PBS_VERTICAL )    buildString(s,"??","PBS_VERTICAL",sep);
}

void pushReBarStyle(std::string &s,uint style,const char *sep)
{
    if( (style & RBS_AUTOSIZE) == RBS_AUTOSIZE )    buildString(s,"??","RBS_AUTOSIZE",sep);
    if( (style & RBS_BANDBORDERS) == RBS_BANDBORDERS )  buildString(s,"??","RBS_BANDBORDERS",sep);
    if( (style & RBS_DBLCLKTOGGLE) == RBS_DBLCLKTOGGLE )    buildString(s,"??","RBS_DBLCLKTOGGLE",sep);
    if( (style & RBS_FIXEDORDER) == RBS_FIXEDORDER )    buildString(s,"??","RBS_FIXEDORDER",sep);
    if( (style & RBS_REGISTERDROP) == RBS_REGISTERDROP )    buildString(s,"??","RBS_REGISTERDROP",sep);
    if( (style & RBS_TOOLTIPS) == RBS_TOOLTIPS )    buildString(s,"??","RBS_TOOLTIPS",sep);
    if( (style & RBS_VARHEIGHT) == RBS_VARHEIGHT )  buildString(s,"??","RBS_VARHEIGHT",sep);
    if( (style & RBS_VERTICALGRIPPER) == RBS_VERTICALGRIPPER )  buildString(s,"??","RBS_VERTICALGRIPPER",sep);
}

void pushScrollBarStyle(std::string &s,uint style,const char *sep)
{
    if( (style & SBS_VERT) == SBS_VERT )buildString(s,"??","SBS_VERT",sep);
}

void pushStaticControlStyle(std::string &s,uint style,const char *sep)
{
    if( (style & SS_TYPEMASK) == SS_BITMAP )    buildString(s,"??","SS_BITMAP",sep);
    else if( (style & SS_TYPEMASK) == SS_BLACKFRAME )   buildString(s,"??","SS_BLACKFRAME",sep);
    else if( (style & SS_TYPEMASK) == SS_BLACKRECT )    buildString(s,"??","SS_BLACKRECT",sep);
    else if( (style & SS_TYPEMASK) == SS_CENTER )   buildString(s,"??","SS_CENTER",sep);
    else if( (style & SS_TYPEMASK) == SS_ENHMETAFILE )  buildString(s,"??","SS_ENHMETAFILE",sep);
    else if( (style & SS_TYPEMASK) == SS_ETCHEDFRAME )  buildString(s,"??","SS_ETCHEDFRAME",sep);
    else if( (style & SS_TYPEMASK) == SS_ETCHEDHORZ )   buildString(s,"??","SS_ETCHEDHORZ",sep);
    else if( (style & SS_TYPEMASK) == SS_ETCHEDVERT )   buildString(s,"??","SS_ETCHEDVERT",sep);
    else if( (style & SS_TYPEMASK) == SS_GRAYFRAME )    buildString(s,"??","SS_GRAYFRAME",sep);
    else if( (style & SS_TYPEMASK) == SS_GRAYRECT ) buildString(s,"??","SS_GRAYRECT",sep);
    else if( (style & SS_TYPEMASK) == SS_ICON ) buildString(s,"??","SS_ICON",sep);
    else if( (style & SS_TYPEMASK) == SS_LEFTNOWORDWRAP )   buildString(s,"??","SS_LEFTNOWORDWRAP",sep);
    else if( (style & SS_TYPEMASK) == SS_OWNERDRAW )    buildString(s,"??","SS_OWNERDRAW",sep);
    else if( (style & SS_TYPEMASK) == SS_RIGHT )    buildString(s,"??","SS_RIGHT",sep);
    else if( (style & SS_TYPEMASK) == SS_SIMPLE )   buildString(s,"??","SS_SIMPLE",sep);
    else if( (style & SS_TYPEMASK) == SS_WHITEFRAME )   buildString(s,"??","SS_WHITEFRAME",sep);
    else if( (style & SS_TYPEMASK) == SS_WHITERECT )    buildString(s,"??","SS_WHITERECT",sep);

    if( (style & SS_ELLIPSISMASK) == SS_PATHELLIPSIS )  buildString(s,"??","SS_PATHELLIPSIS",sep);
    else if( (style & SS_ELLIPSISMASK) == SS_WORDELLIPSIS ) buildString(s,"??","SS_WORDELLIPSIS",sep);
    else if( (style & SS_ELLIPSISMASK) == SS_ENDELLIPSIS )  buildString(s,"??","SS_ENDELLIPSIS",sep);

    if( (style & SS_CENTERIMAGE) == SS_CENTERIMAGE )    buildString(s,"??","SS_CENTERIMAGE",sep);
    if( (style & SS_NOPREFIX) == SS_NOPREFIX )  buildString(s,"??","SS_NOPREFIX",sep);
    if( (style & SS_NOTIFY) == SS_NOTIFY )  buildString(s,"??","SS_NOTIFY",sep);

    if( (style & SS_REALSIZEIMAGE) == SS_REALSIZEIMAGE )    buildString(s,"??","SS_REALSIZEIMAGE",sep);
    if( (style & SS_RIGHTJUST) == SS_RIGHTJUST )    buildString(s,"??","SS_RIGHTJUST",sep);
    if( (style & SS_SUNKEN) == SS_SUNKEN )  buildString(s,"??","SS_SUNKEN",sep);
}

void pushStatusBarStyle(std::string &s,uint style,const char *sep)
{
    if( (style & SBARS_SIZEGRIP) == SBARS_SIZEGRIP )    buildString(s,"??","SBARS_SIZEGRIP",sep);
    if( (style & SBT_TOOLTIPS) == SBT_TOOLTIPS )    buildString(s,"??","SBT_TOOLTIPS",sep);
}

void pushTabBarStyle(std::string &s,uint style,const char *sep)
{
    if( (style & TCS_BOTTOM) == TCS_BOTTOM )    buildString(s,"??","TCS_BOTTOM",sep);
    if( (style & TCS_BUTTONS) == TCS_BUTTONS )  buildString(s,"??","TCS_BUTTONS",sep);
    if( (style & TCS_FIXEDWIDTH) == TCS_FIXEDWIDTH )    buildString(s,"??","TCS_FIXEDWIDTH",sep);
    if( (style & TCS_FLATBUTTONS) == TCS_FLATBUTTONS )  buildString(s,"??","TCS_FLATBUTTONS",sep);
    if( (style & TCS_FOCUSNEVER) == TCS_FOCUSNEVER )    buildString(s,"??","TCS_FOCUSNEVER",sep);
    if( (style & TCS_FOCUSONBUTTONDOWN) == TCS_FOCUSONBUTTONDOWN )  buildString(s,"??","TCS_FOCUSONBUTTONDOWN",sep);
    if( (style & TCS_FORCEICONLEFT) == TCS_FORCEICONLEFT )  buildString(s,"??","TCS_FORCEICONLEFT",sep);
    if( (style & TCS_FORCELABELLEFT) == TCS_FORCELABELLEFT )    buildString(s,"??","TCS_FORCELABELLEFT",sep);
    if( (style & TCS_HOTTRACK) == TCS_HOTTRACK )    buildString(s,"??","TCS_HOTTRACK",sep);
    if( (style & TCS_MULTILINE) == TCS_MULTILINE )  buildString(s,"??","TCS_MULTILINE",sep);
    if( (style & TCS_MULTISELECT) == TCS_MULTISELECT )  buildString(s,"??","TCS_MULTISELECT",sep);
    if( (style & TCS_OWNERDRAWFIXED) == TCS_OWNERDRAWFIXED )    buildString(s,"??","TCS_OWNERDRAWFIXED",sep);
    if( (style & TCS_RAGGEDRIGHT) == TCS_RAGGEDRIGHT )  buildString(s,"??","TCS_RAGGEDRIGHT",sep);
    if( (style & TCS_RIGHT) == TCS_RIGHT )  buildString(s,"??","TCS_RIGHT",sep);
    if( (style & TCS_RIGHTJUSTIFY) == TCS_RIGHTJUSTIFY )    buildString(s,"??","TCS_RIGHTJUSTIFY",sep);
    if( (style & TCS_SCROLLOPPOSITE) == TCS_SCROLLOPPOSITE )    buildString(s,"??","TCS_SCROLLOPPOSITE",sep);
    if( (style & TCS_SINGLELINE) == TCS_SINGLELINE )    buildString(s,"??","TCS_SINGLELINE",sep);
    if( (style & TCS_TABS) == TCS_TABS )buildString(s,"??","TCS_TABS",sep);
    if( (style & TCS_TOOLTIPS) == TCS_TOOLTIPS )    buildString(s,"??","TCS_TOOLTIPS",sep);
    if( (style & TCS_VERTICAL) == TCS_VERTICAL )    buildString(s,"??","TCS_VERTICAL",sep);
}

void pushToolBarStyle(std::string &s,uint style,const char *sep)
{
    if( (style & TBSTYLE_ALTDRAG) == TBSTYLE_ALTDRAG )  buildString(s,"??","TBSTYLE_ALTDRAG",sep);
    if( (style & TBSTYLE_CUSTOMERASE) == TBSTYLE_CUSTOMERASE )  buildString(s,"??","TBSTYLE_CUSTOMERASE",sep);
    if( (style & TBSTYLE_FLAT) == TBSTYLE_FLAT )    buildString(s,"??","TBSTYLE_FLAT",sep);
    if( (style & TBSTYLE_LIST) == TBSTYLE_LIST )    buildString(s,"??","TBSTYLE_LIST",sep);
    if( (style & TBSTYLE_REGISTERDROP) == TBSTYLE_REGISTERDROP )    buildString(s,"??","TBSTYLE_REGISTERDROP",sep);
    if( (style & TBSTYLE_TOOLTIPS) == TBSTYLE_TOOLTIPS )    buildString(s,"??","TBSTYLE_TOOLTIPS",sep);
    if( (style & TBSTYLE_TRANSPARENT) == TBSTYLE_TRANSPARENT )  buildString(s,"??","TBSTYLE_TRANSPARENT",sep);
    if( (style & TBSTYLE_WRAPABLE) == TBSTYLE_WRAPABLE )    buildString(s,"??","TBSTYLE_WRAPABLE",sep);
}

void pushToolTipStyle(std::string &s,uint style,const char *sep)
{
    if( (style & TTS_ALWAYSTIP) == TTS_ALWAYSTIP )  buildString(s,"??","TTS_ALWAYSTIP",sep);
    if( (style & TTS_BALLOON) == TTS_BALLOON )  buildString(s,"??","TTS_BALLOON",sep);
    if( (style & TTS_CLOSE) == TTS_CLOSE )  buildString(s,"??","TTS_CLOSE",sep);
    if( (style & TTS_NOANIMATE) == TTS_NOANIMATE )  buildString(s,"??","TTS_NOANIMATE",sep);
    if( (style & TTS_NOFADE) == TTS_NOFADE )    buildString(s,"??","TTS_NOFADE",sep);
    if( (style & TTS_NOPREFIX) == TTS_NOPREFIX )    buildString(s,"??","TTS_NOPREFIX",sep);
}

void pushTrackBarStyle(std::string &s,uint style,const char *sep)
{
    if( (style & TBS_AUTOTICKS) == TBS_AUTOTICKS )  buildString(s,"??","TBS_AUTOTICKS",sep);
    if( (style & TBS_VERT) == TBS_VERT ) buildString(s,"??","TBS_VERT",sep);
    if( (style & TBS_HORZ) == TBS_HORZ ) buildString(s,"??","TBS_HORZ",sep);
    if( (style & TBS_TOP) == TBS_TOP ) buildString(s,"??","TBS_TOP",sep);
    if( (style & TBS_BOTTOM) == TBS_BOTTOM )    buildString(s,"??","TBS_BOTTOM",sep);
    if( (style & TBS_LEFT) == TBS_LEFT ) buildString(s,"??","TBS_LEFT",sep);
    if( (style & TBS_RIGHT) == TBS_RIGHT ) buildString(s,"??","TBS_RIGHT",sep);
    if( (style & TBS_BOTH) == TBS_BOTH ) buildString(s,"??","TBS_BOTH",sep);
    if( (style & TBS_NOTICKS) == TBS_NOTICKS )  buildString(s,"??","TBS_NOTICKS",sep);
    if( (style & TBS_ENABLESELRANGE) == TBS_ENABLESELRANGE )    buildString(s,"??","TBS_ENABLESELRANGE",sep);
    if( (style & TBS_FIXEDLENGTH) == TBS_FIXEDLENGTH )  buildString(s,"??","TBS_FIXEDLENGTH",sep);
    if( (style & TBS_NOTHUMB) == TBS_NOTHUMB )  buildString(s,"??","TBS_NOTHUMB",sep);
    if( (style & TBS_TOOLTIPS) == TBS_TOOLTIPS )    buildString(s,"??","TBS_TOOLTIPS",sep);
    if( (style & TBS_REVERSED) == TBS_REVERSED )    buildString(s,"??","TBS_REVERSED",sep);
    if( (style & TBS_DOWNISLEFT) == TBS_DOWNISLEFT )    buildString(s,"??","TBS_DOWNISLEFT",sep);
}

void pushTreeViewStyle(std::string &s,uint style,const char *sep)
{
    if( (style & TVS_CHECKBOXES) == TVS_CHECKBOXES )    buildString(s,"??","TVS_CHECKBOXES",sep);
    if( (style & TVS_DISABLEDRAGDROP) == TVS_DISABLEDRAGDROP )  buildString(s,"??","TVS_DISABLEDRAGDROP",sep);
    if( (style & TVS_EDITLABELS) == TVS_EDITLABELS )    buildString(s,"??","TVS_EDITLABELS",sep);
    if( (style & TVS_FULLROWSELECT) == TVS_FULLROWSELECT )  buildString(s,"??","TVS_FULLROWSELECT",sep);
    if( (style & TVS_HASBUTTONS) == TVS_HASBUTTONS )    buildString(s,"??","TVS_HASBUTTONS",sep);
    if( (style & TVS_HASLINES) == TVS_HASLINES )    buildString(s,"??","TVS_HASLINES",sep);
    if( (style & TVS_INFOTIP) == TVS_INFOTIP )  buildString(s,"??","TVS_INFOTIP",sep);
    if( (style & TVS_LINESATROOT) == TVS_LINESATROOT )  buildString(s,"??","TVS_LINESATROOT",sep);
    if( (style & TVS_NOHSCROLL) == TVS_NOHSCROLL )  buildString(s,"??","TVS_NOHSCROLL",sep);
    if( (style & TVS_NONEVENHEIGHT) == TVS_NONEVENHEIGHT )  buildString(s,"??","TVS_NONEVENHEIGHT",sep);
    if( (style & TVS_NOSCROLL) == TVS_NOSCROLL )    buildString(s,"??","TVS_NOSCROLL",sep);
    if( (style & TVS_NOTOOLTIPS) == TVS_NOTOOLTIPS )    buildString(s,"??","TVS_NOTOOLTIPS",sep);
    if( (style & TVS_RTLREADING) == TVS_RTLREADING )    buildString(s,"??","TVS_RTLREADING",sep);
    if( (style & TVS_SHOWSELALWAYS) == TVS_SHOWSELALWAYS )  buildString(s,"??","TVS_SHOWSELALWAYS",sep);
    if( (style & TVS_SINGLEEXPAND) == TVS_SINGLEEXPAND )    buildString(s,"??","TVS_SINGLEEXPAND",sep);
}

void pushUpDownControlStyle(std::string &s,uint style,const char *sep)
{
    if( (style & UDS_ALIGNLEFT) == UDS_ALIGNLEFT )  buildString(s,"??","UDS_ALIGNLEFT",sep);
    else if( (style & UDS_ALIGNRIGHT) == UDS_ALIGNRIGHT )   buildString(s,"??","UDS_ALIGNRIGHT",sep);

    if( (style & UDS_ARROWKEYS) == UDS_ARROWKEYS )  buildString(s,"??","UDS_ARROWKEYS",sep);
    if( (style & UDS_AUTOBUDDY) == UDS_AUTOBUDDY )  buildString(s,"??","UDS_AUTOBUDDY",sep);
    if( (style & UDS_HORZ) == UDS_HORZ ) buildString(s,"??","UDS_HORZ",sep);
    if( (style & UDS_HOTTRACK) == UDS_HOTTRACK )    buildString(s,"??","UDS_HOTTRACK",sep);
    if( (style & UDS_NOTHOUSANDS) == UDS_NOTHOUSANDS )  buildString(s,"??","UDS_NOTHOUSANDS",sep);
    if( (style & UDS_SETBUDDYINT) == UDS_SETBUDDYINT )  buildString(s,"??","UDS_SETBUDDYINT",sep);
    if( (style & UDS_WRAP) == UDS_WRAP ) buildString(s,"??","UDS_WRAP",sep);
}

Win32ClassList win32_class_list =
{
 {ANIMATE_CLASSA, pushAnimateControlStyle},
 {WC_BUTTONA, pushButtonStyle,},
 {WC_COMBOBOXEXA, pushComboBoxExStyle},
 {WC_COMBOBOXA, pushComboBoxStyle},
 {DATETIMEPICK_CLASSA, pushDateTimePickerStyle},
 {WC_EDITA, pushEditControlStyle},
 {WC_HEADERA, pushHeaderControlStyle},
 {WC_LISTBOXA, pushListBoxStyle},
 {WC_LISTVIEWA, pushListViewStyle},
 {MONTHCAL_CLASSA, pushMonthCalendarControlStyle},
 {PROGRESS_CLASSA, pushProgressBarStyle},
 {REBARCLASSNAMEA, pushReBarStyle},
 {WC_SCROLLBARA, pushScrollBarStyle},
 {WC_STATICA, pushStaticControlStyle},
 {STATUSCLASSNAMEA, pushStatusBarStyle},
 {WC_TABCONTROLA, pushTabBarStyle},
 {TOOLBARCLASSNAMEA, pushToolBarStyle},
 {TOOLTIPS_CLASSA, pushToolTipStyle},
 {TRACKBAR_CLASSA, pushTrackBarStyle},
 {WC_TREEVIEWA, pushTreeViewStyle},
 {UPDOWN_CLASSA,pushUpDownControlStyle},
};

}


text:
Q: Why is Heroku build cache getting bigger with every release? On my Heroku app, I deploy multiple times a day. With every release, the Heroku "slug" keeps getting bigger even with minor code changes. This is the kind of message I see in the build log:
Warning: Your slug size (446 MB) exceeds our soft limit (300 MB) which may affect boot time.

The prior build was 444 MB, the one before 441, etc.
With every release it gets bigger, until it reaches Heroku's hard limit of 500 MB and then I need to clear the build cache manually.
Why is the build cache getting bigger for minor code changes? How can I prevent it from reaching the hard limit of 500 MB, which breaks my automated deployments?

A: Have you tried downloading the slugs for two builds and comparing the contents? You could use the slugs CLI plugin to download them and see what extra files are clogging things up: https://github.com/heroku/heroku-slugs


text:
Q: Magento: Filtering a Collection with grouped Clauses
I would like to filter a collection with grouped clauses. In SQL this would look something like:
SELECT * FROM `my_table` WHERE col1='x' AND (col2='y' OR col3='z')

How can I "translate" this to filtering a collection with ->addFieldToFilter(...)?
Thanks!

A: If your collection is an EAV type then this works well:
$collection = Mage::getResourceModel('yourmodule/model_collection')
    ->addAttributeToFilter('col1', 'x')
    ->addAttributeToFilter(array(
        array('attribute'=>'col2', 'eq'=>'y'),
        array('attribute'=>'col3', 'eq'=>'z'),
    ));

However if you're stuck with a flat table I don't think addFieldToFilter works in quite the same way. One alternative is to use the select object directly.
$collection = Mage::getResourceModel('yourmodule/model_collection')
    ->addFieldToFilter('col1', 'x');
$collection->getSelect()
    ->where('col2 = ?', 'y')
    ->orWhere('col3 = ?', 'z');

But the failing of this is the order of operators. You willl get a query like SELECT * FROM my_table WHERE (col1='x') AND (col2='y') OR (col3='z'). The OR doesn't take precedence here, to get around it means being more specific...
$collection = Mage::getResourceModel('yourmodule/model_collection')
    ->addFieldToFilter('col1', 'x');
$select = $collection->getSelect();
$adapter = $select->getAdapter();
$select->where(sprintf('(col2 = %s) OR (col3 = %s)', $adapter->quote('x'), $adapter->quote('y')));

It is unsafe to pass values unquoted, here the adapter is being used to safely quote them.
Finally, if col2 and col3 are actually the same, if you're OR-ing for values within a single column, then you can use this shorthand:
$collection = Mage::getResourceModel('yourmodule/model_collection')
    ->addFieldToFilter('col1', 'x')
    ->addFieldToFilter('col2', 'in'=>array('y', 'z'));


text:
Q: Binding object to directive's bindToController I have the following directive
.directive('showMessage',[function(){
    return{
        scope:true,
        restrict:'E',
        bindToController:{
            sprop:"="
        },
        templateUrl:'Communicator/Views/showMessage.html',
        controllerAs:"showMessCtrl",
        controller:function($scope){
            console.log(this.sprop);
        }
    }
}]);

I am trying to pass a object to the directive into sprop like this
//base controller
        $scope.mySplitterProp ={
            orientation:"vertical",
            collapsible:false,
            max:"75%"
        }

The calling of directive is like this
<show-message sprop="{{mySplitterProp}}"></show-message>

If i use sprop:"@", this return a string in the console.log (i need object)
and if i use sprop:"=" (which is supposed to be used), i get a error like

[$parse:syntax]
  http://errors.angularjs.org/1.4.5/$parse/syntax?p0=%7B&p1=invalid%20key&p2=2&p3=%7B%7BmySplitterProp%7D%7D&p4=%7BmySplitterProp%7D%7D

I am using angular 1.4

A: {{mySplitterProp}} will replace the variable by the value, and, will not pass it to the directive scope when using two-way binding '=' (because it expect the expression to change ...). Remove the curly braces.
https://docs.angularjs.org/guide/expression


text:
Q: Can the cache (or other variables) change during code execution? This might just be a theoretical question but I haven't been able to find a satisfying answer to it.
I'm using the cache on one of my sites which got me thinking about it's data and when and if it changes. Can the cache change during the execution of some code?
Here's an example
if (Cache["name"] != null) {

    // Long and heavy code execution done here

    if (Cache["name"] == null) Response.Write("Lost the data");
}

Can the process that change the cache run parallel with the above code or does it wait until it has finished?
Is there a theoretical chance that this would print "Lost the data"?
If yes, is it always good practice to save the variable first or always check for null and never not null?
Thanks in advance!
/Niklas

A: Absolutely it can.
Always snapshot values from cache, and work with the snapshot:
var snapshot = Cache["name"];
if(snapshot != null) {...}

and use snapshot throughout. When it comes to threading, the above is generally a sane approach; the only caveat being you might want to look at Interlocked for a range of methods that let you see (safely) whether a variable/field changed while you weren't looking, and only apply a change it it hadn't changed.

A: It can surely expire so checking for null should be done before using it. And as you said keeping a saved copy to work upon is good.


text:
Q: Presto SQL window aggregate looking back x hours/minutes/seconds I want to do aggregate on presto sql by looking back x hours/minutes/seconds ago.
Data
id    |       timestamp       |    status
-------------------------------------------
A     |   2018-01-01 03:00:00 |     GOOD
A     |   2018-01-01 04:00:00 |     BAD
A     |   2018-01-01 05:00:00 |     GOOD
A     |   2018-01-01 09:00:00 |     BAD
A     |   2018-01-01 09:15:00 |     BAD
A     |   2018-01-01 13:00:00 |     GOOD
A     |   2018-01-01 14:00:00 |     GOOD
B     |   2018-02-01 09:00:00 |     GOOD
B     |   2018-02-01 10:00:00 |     BAD

Results:
id    |       timestamp       |    status    | bad_status_count
----------------------------------------------------------------
A     |   2018-01-01 03:00:00 |     GOOD     |       0
A     |   2018-01-01 04:00:00 |     BAD      |       1
A     |   2018-01-01 05:00:00 |     GOOD     |       1
A     |   2018-01-01 09:00:00 |     BAD      |       1
A     |   2018-01-01 09:15:00 |     BAD      |       2
A     |   2018-01-01 13:00:00 |     GOOD     |       0
A     |   2018-01-01 14:00:00 |     GOOD     |       0
B     |   2018-02-01 09:00:00 |     GOOD     |       0
B     |   2018-02-01 10:00:00 |     BAD      |       1

I am counting bad status over the period of last 3 hours by business. How can I do that?
I am trying something like this:
SELECT
  id,
  timestamp,
  status
  count(status) over(partition by id order by timestamp range between interval '3' hour and current_row) as bad_status_count
from table

Of course it doesnt work yet and I still have to filter out for bad status. I got this error:
 Error running query: line 7:1: Window frame start value type must be INTEGER or BIGINT(actual interval day to second)

A: I'm not 100% how to represent express this in PrestoDB, but the key idea is to convert the timestamps to hours:
select t.*,
       sum(case when status = 'Bad' then 1 else 0 end) over
           (partition by id
            order by hours
            range between -3 and current row
           ) as bad_status
from (select t.*,
             date_diff(hour, '2000-01-01', timestamp) as hours
      from t
     ) t;


text:
Q: why my asp.net application design can be vary with system to system ?how to acheive this? i developed one asp.net application.i published the application in iis server.then by using that url i am testing the application in my system the design is coming fine.But in other systems the design is vary.both the systems are having IE8 Browser and both are same versions.
why the designing is vary can u pls let me know.
and also button styles all are different changing in system to system.

A: As regards button styles, they do change from "system" to "system" if by system you mean computer and operating system. Unless you've styled your buttons is a specific way that does not rely on operating system defaults/styles, they will appear different.
Can you be more specific about the other variances you see?


text:
Q: Check if NavDestination represents a DialogFragment I have an Activity layout that surrounds the fragment container in a CoordinatorLayout. When switching destinations, I want to hide the FAB and dismiss the SnackBar if either is currently displayed, and let the destination Fragment reshow the FAB if it needs to in its onViewCreated(). This is consistent with the Material Design guidelines that say the FAB should visibly disappear and reappear when you switch destinations.
So I did this:
navController.addOnDestinationChangedListener { _, navDestination, _ ->
    binding.floatingActionButton.apply {
        hide()
        setOnClickListener(null)
    }
    currentSnackbar?.dismiss()
    //...
}

However, when a DialogFragment is the navigation destination, the previous Fragment will not have onViewCreated() called again when navigating back, because it never left the screen.
NavDestination doesn't seem to have any way to inspect whether it represents a DialogFragment, even though the XML distinguishes between fragment and dialog.
I realize I could move the FAB showing code to onResume in the fragment, but it would look silly to hide it in the first place when only opening an alert dialog. I realize I could also create a parent Fragment class that hides it in onStop(), but I try to avoid creating class hierarchy layers when possible to make code less fragile (composition over inheritance), and I also want to avoid repeating the code all over the app.

A: Dialog destinations implement the FloatingWindow interface:

A marker interface for NavDestination subclasses that float above the view of other destinations (i.e. DialogFragmentNavigator.Destination).
NavController.OnDestinationChangedListener instances can also customize their behavior based on whether the destination is a FloatingWindow.

Therefore you can ignore navigating to dialog by using if (!(navDestination is FloatingWindow)).


text:
Q: Embedd a xsd file in C# Right now we have static code to a XML schema file. But now we want to embedd that file
Code right now:
XmlTextReader reader = new XmlTextReader("schema.xsd");
XmlSchema schema = XMLSchema.Read(xReader, new ValidationEventHandler(ValidationEventHandler));

But now I want to have it embedded in a Resouce file. So how do I do.
XmlTextReader reader = new XmlTextReader(Resouces.Schema);
XmlSchema schema = XMLSchema.Read(xReader, new ValidationEventHandler(ValidationEventHandler));

This is not the way.

A: // Get the assembly that contains the embedded schema
var assembly = Assembly.GetExecutingAssembly();
using (var stream = assembly.GetManifestResourceStream("namespace.schema.xsd"))
using (var reader = XmlReader.Create(stream))
{
    XmlSchema schema = XMLSchema.Read(
        reader,
        new ValidationEventHandler(ValidationEventHandler));
}

A: If you have a single file, just extract it (GetManifestResourceStream) and use directly. If you have multiple related files, you'll need to write an XmlResolver. I have a resx-based resolver somewhere... You then set this as the XmlResolver or an XmlReaderSettings, and pass in your XmlReaderSettings when calling XmlReader.Create.

A: Use:
Stream xsdStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("schema.xsd");


text:
Q: Does if-structure in C affect the value of variable? Im trying to write a simple C program to convert the cases of letters
char a;
a = getchar();
if(a<=90&&a>=65)
    putchar(a+32);
else if(a<=122&&a>=97)
    putchar(a-32);
else
    putchar(a);

When the input is 'A' or 'c',the output is correct;however,when it comes to 'g',the output becomes space and when entering numbers and signals,only get a different output instead of itself.Then I changed the order of ifs,the second problem was solved but the 'g' problem remains.
But I thought the if-structure wouldnt change the value of a;Im quite confused and wonder how.

A: The function getchar reads all symbols including white spaces from the input stream.
Use instead
scanf( " %c", &a );

Also it is a bad idea to use magic numbers like for example 65 or 32.
Here is a demonstrative program
#include <stdio.h>

int main(void)
{
    char c;

    while ( scanf( " %c", &c ) == 1 )
    {
        if ( 'A' <= c && c <= 'Z' )
        {
            putchar( c | ' ' );
        }
        else if ( 'a' <= c && c <= 'z' )
        {
            putchar( c & ~' ' );
        }
        else
        {
            putchar( c );
        }
    }

    return 0;
}

If to enter for example
A
a
1
G
g
2

then the program output will be
aA1gG2

If to use getchar then the approach can look the following way
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    int c;

    while ( ( c = getchar() ) != EOF )
    {
        if ( 'A' <= c && c <= 'Z' )
        {
            putchar( c | ' ' );
        }
        else if ( 'a' <= c && c <= 'z' )
        {
            putchar( c & ~' ' );
        }
        else if ( isgraph( ( unsigned char )c ) )
        {
            putchar( c );
        }
    }

    return 0;
}

A: first, for readability, (And to help you to see what your code is doing.) replace the magic numbers in your code by using _ASCII table char values (eg: 'A' instead of 65) and a variable representation of 32, (distance between cases) in your expressions.
  For example:
char a;
a = getchar();
if(a<=90&&a>=65)
    putchar(a+32);
else if(a<=122&&a>=97)
    putchar(a-32);

to
char a;
int convert = 32; //distance between cases

a = getchar();
if(a <= 'Z' && a >= 'A')
    putchar(a + convert );
else if(a <= 'z' && a >= 'a')
    putchar(a - convert );

And because getchar() picks up unwanted content, use a more precise way to read your input.
Replace
a = getchar();

with
scanf(" %c", &a);

A: This is difficult to do from scratch in portable C. This is because the character encoding is left to the implementation. ASCII is common but by no means ubiquitous. Fortunately the C standard library provides the functions you need and the function names render them self-documenting:
int a;
a = getchar();
if (isupper(a)){
    putchar(tolower(a));
} else if (islower(a)){
    putchar(toupper(a));
} else {
    putchar(a);
}

A: From what I understand, the putchar takes an int, but you give it a char.
The same way, getchar returns an int, but you assume it to return a char.
So you might be wanting to try to change the declaration of a from char to int.


text:
Q: Add C++ redistribuitable in my .msi and install on silent I am working with a setup project of Visual Studio 2015. I want to distribute the 2015 C++ library, vc_redist.x86.exe. But I don't want user to be aware of this pre-requisite, so the idea is that while he is running the .msi, the C++ library will be auto-installed.
I have been reading about the merge modules, but this cannot fix my problem because the setup.exe should be run. Please, could anybody tell me how to deal with this?
Many thanks!

A: You'll need to change (or create your own custom one) the standard bootstrapper that has documentation starting here:
https://msdn.microsoft.com/en-us/library/ms165429.aspx
The bootstrapper packages contain the detection and install logic for the redistributables. For example, the \Bootstrapper\Packages folder has VC redist folders, each with a product.xml and a package.xml about installing them as prerequisites. They have standard command lines such as:
Command PackageFile="vcredist_x64.exe" Arguments=' /q:a
and you can substitute that command with something like those listed here:
http://asawicki.info/news_1597_installing_visual_c_redistributable_package_from_command_line.html
that show the quiet options (as do standard Microsoft docs somewhere).


text:
Q: How do I style a dropdown using Less? My HTML code is as below:

Overview

More PV Dashboards

Wave

W/S Omni

Site Analyser

Spotzer

iPromote

BW Reports

Change Customer

And my CSS code is as below:
.nav-collapse {
     margin-top: 5px;
     padding: 0px;
      background-color: #ccc;
      z-index: 5000;
      width: 200px;
       .nav {
         li {
           display: list-item;
           list-style-type: square;
           margin-left: 47px;
           color: #000;
           .listitem(1);
            a {
            color: #006493;
            font-size: 13px;
            padding-left: 0;
            span{
              font-size: 14px;
              font-family: 'Open Sans'semibold;
              color: #000;
             }
            }
            &.divider {
            margin: 1px 1px;
            border-bottom: 1px solid #000;
            opacity: 0.2;
            list-style-type: none;
          }
         }
         .listitem(@i){
           &:nth-child(@{i}){
             background-color: #fff;
             opacity: 0.8;
             list-style-type: none;
           }
           &:last-of-type{
             list-style-type: none;
           }
         }
        }
      }

A: By looking at your question it seems you wanted to now how to create custom drop down with the help of UL. http://jsfiddle.net/elclanrs/H63MU/ hopefully this link will help.
var ulSelect = function($select) {

    // $select.hide();
    var $opts = $select.find('option');

    return (function() {
        var items = '',
            html = '';
        $opts.each(function() {
            items += '
' + $(this).text() + '
';
        });
        html =
            '
'+
                '
'+
            ''+ $opts.filter(':selected').text() +'' +
                    '
' + items + '
'+
                '
'+
            '
';
        $(html)
            .find('.sub a')
            .click(function(e) {
                e.preventDefault();
                var $this = $(this);
                $this.parents('.menu').find('.sel').text($this.text());
                $opts.eq($this.parent().index()).prop('selected', true);
            }).end().insertAfter($select);
    }());

};

ulSelect($('#select'));

Update:
In case you are also wanted to style default drop down created using "select" tag check this link.
https://www.sitepoint.com/community/t/how-do-i-style-this-drop-down-box/103484/2


text:
Q: Getting enum value from user I wonder how it is possible to get the enum value into the enum variable "today" from the user and not by initializing it like in the given example.
do I have to use a scanf to string array and make today = string array?
#include <stdio.h>
enum week{ sunday, monday, tuesday, wednesday, thursday, friday, saturday};
int main(){
enum week today;
today=wednesday;
printf("%d day",today+1);
return 0;
}

A: This is not possible with a plain enum. A classic trick is to augment the enum with an array of const char* in which you store the names in the same order as the enum. You then can use an enum value as an index into the array to retrieve the corresponding string value.
// enum to string
printf("%s\n", week_str[MONDAY]);
// string to enum
const char* input = "tuesday"; // get this from scanf or something
size_t length = strlen(input);
int i;
int found = -1;
for (i = 0; i <= WEDNESDAY; i++) {
  if(strncmp(input, week_str[i], length) == 0) {
    found = i;
    break;
  }
}
printf("Found: %i", found);

A: Yes more or less. Enums are represented internally as ints and the names of the enum type is lost during compilation.
Your program will print
4 day

If you want to preserve the names of the days you must have a string array such as
const char *days[] =
{
  "sunday", "monday", "tuesday", "wednesday", ...
} ;

and do the conversion yourself. For example :
printf ("The day is %s", days[monday]) ;

will print
The day is monday

A: I'd do like that:
#include <stdio.h>
#include <ctype.h>

enum week{ sunday, monday, tuesday, wednesday, thursday, friday, saturday };

char * EnumToString(int day)    {
    switch (day)    {
        case sunday: return "sunday";
        case monday: return "monday";
        case tuesday: return "tuesday";
        case wednesday: return "wednesay";
        case thursday: return "thursday";
        case friday: default: return "friday";
    }
}

enum week StringToEnum(char * day)  {

    // To not be case sensitive
    for(int i = 0; str[i]; i++){
      day[i] = tolower(day[i]);
    }
    switch (day)    {
        case "sunday": return sunday;
        case "monday": return monday;
        case "tuesday": return tuesday;
        case "wednesday": return wednesay;
        case "thursday": return thursday;
        case "friday": default: return friday;
    }
}

int main(){
    enum week today;
    today=wednesday;
    printf("%dth day is %s",today+1, EnumToString(today+1));
    return 0;
}

It will print :
4th day is thursday


text:
Q: Simulate Hardware Level Keystrokes Through XBee I have been working on a project and I have been trying to simulate keyboard strokes on my laptop at a hardware level without actually pressing down my laptop keys. That is straight through the I/O registers. Rather than going through software, I had a few Xbee's lying around and figured I would make a wireless keyboard of sorts. My question is whether or not data sent through the ZigBee framework will be interpreted at a hardware level by my laptop? I figured it must be somewhat similar to my Logitech Unifying receiver which I know gets interpreted at the hardware level. Also, is there a way that I can see the code generated both by a physical keypress on my laptop vs the code sent by an Xbee module? Would there be an additional value present in the code sent by the Xbee to symbolize that it wasn't an physical keypress on the laptop? Thanks!

A: The XBee connects to your laptop as an asynchronous serial port.  I suspect that your keyboard connects via USB, Bluetooth or some other wireless dongle.  Even the built-in keyboard is probably USB as well, and should appear as an HID (human interface device).
You'd need to write a program on the laptop to receive the serial data and somehow pass it on to the OS so it appears as keyboard input.


text:
Q: what determines the lower limit on the number of turns in a secondary coil in a step down transformer? I am interested in understanding what factors govern the lower limit on the number of turns in the Secondary coil of a step down transformer. I have read that a Primary coil with too few turns will induce a very weak magnetic field in the core, but what happens if the secondary coil has a very low number of turns?
If the secondary coil uses a shorter wire, the resistance is lower and so voltage induced in the secondary coil produces a greater current, as per Ohm's law. This greater current may be higher than the wire's maximum current capacity and cause dangerous or undesirable levels of heat in the wire, but is this the only factor governing the minimum number of turns in the secondary coil? If the secondary coil has too few turns, can the efficiency of the transformer be reduced in some other way?
If I want to have a step down transformer with as few turns as possible in the secondary coil, what problems do I need to be aware of, and how can I calculate what the minimum number of turns in the secondary coil could be?

A:
I am interested in understanding what factors govern the lower limit on the number of turns in the Secondary coil of a step down transformer.

Good.

I have read that a Primary coil with too few turns will induce a very weak magnetic field in the core,

You have remembered wrongly, or misread.
You need at least a minimum number of turns on the primary in order to keep the core field below its maximum.
Core materials, iron or ferrite, have a maximum magnetic field. With iron, the limit tends to be saturation, with ferrite, heating from losses tends to bite before saturation. The maximum fields are typically in the order of 1.5T for mains iron transformers, and in the range 0.1T to 0.3T for ferrite depending on frequency and grade.
The core has an area \$A\$, and the core material has a maximum field \$B_{max}\$. The transformer has an operating frequency \$f\$. We can calculate the maximum voltage induced in one turn via the maximum rate of change of flux, which is \$V_{max} = 2\pi f B_{max} A\$ for a sinusoidal input, with all terms in SI units. This gives us the peak voltage. Divide by sqrt(2) to give the RMS voltage. We need enough turns to equal our input voltage.
To give an example, I have an iron toroid with cross section 13x25mm, operating at 50Hz, and I am going to assume a \$B_{max}\$ of 1.5T.
\$V_{max} = 2 \pi \times 50 \times 0.013 \times 0.025 \times1.5 = 0.153V  \$
0.153V peak is about 0.108V rms. At 240v, we would need 2222 turns on the primary, minimum. A few more wouldn't hurt.

but what happens if the secondary coil has a very low number of turns?

then you get a very low secondary voltage produced.

If the secondary coil uses a shorter wire, the resistance is lower and so voltage induced in the secondary coil produces a greater current, as per Ohm's law.

well, yes, if you shorted the secondary. But we don't do that. The resistance of the load tends to exceed that of the winding, and so it's the load that determines the current.
You do several things to design a transformer. Note that a full design could get much more detailed, but this gives you a good start.
1) Start with a big enough core for your power. Go to a transformer catalogue, and find a transformer with a similar power to what you want to use. Halve its weight, the copper is about the same weight as the iron. Start with a core this weight.
2) Calculate the minimum number of turns needed on the primary, as above
3) Caluclate the number of turns needed on the secondary, to give your design voltage, using the same volts per turn figure.
4) Choose a the maximum thickness of wire that will half-fill the winding window. 50% is a good fill factor, you will be doing well to get a better factor.
5) Check that the current density doesn't exceed about 3A/mm2 (a rule of thumb valid for small to medium transformers) at your load power.

A: For an Inductor we have the following equation and we can think of transformers as coupled inductors.
$$V = L \cdot \dfrac{\text{d}I}{\text{d}t} = N \cdot A_e \cdot \dfrac{\text{d}B}{\text{d}t}$$
Where \$V\$ is the voltage across the winding, \$L\$ is the inductance of the winding, \$I\$ is winding current, \$N\$ is winding turns, \$A_e\$ is the effective area of the core and \$t\$ is time.
Is the basic answer to your question. All magnetic cores will saturate it you allow \$B\$, the flux density to become too large.  Knowing what the voltage across a winding should be and how long it's there we can come up with this related equation.
$$N = \dfrac{1}{B_{max} \cdot A_e}\int V \text{d}t$$
\$ B_{max} \$ is the maximum allowable flux density and this will depend on the frequency of operation and the material properties of the core.
I usually start by designing the lowest voltage winding first and then increase turns if required to get the turns ratio I want.

A:
If I want to have a step down transformer with as few turns as
  possible in the secondary coil, what problems do I need to be aware
  of, and how can I calculate what the minimum number of turns in the
  secondary coil could be?

It can be as low as one turn on the secondary (but read further down because if you want to step down 240 V AC to 80 VAC, having 3 turns on the primary will be a disaster).

If the secondary coil uses a shorter wire, the resistance is lower and
  so voltage induced in the secondary coil produces a greater current,
  as per Ohm's law.

Secondary current is only due to the secondary voltage being applied to a load - the secondary doesn't inherently circulate current without a load so it's ohms law, the output voltage and the load that governs secondary current.

This greater current may be higher than the wire's maximum current
  capacity and cause dangerous or undesirable levels of heat in the wire

You can overload a transformer by trying to take too much current from it and it will overheat for sure.

is this the only factor governing the minimum number of turns in the
  secondary coil?

Your secondary coil has to be designed from thick enough wire to sufficiently power the anticipated load at full current without over-heating.

If the secondary coil has too few turns, can the efficiency of the
  transformer be reduced in some other way?

Now we're getting to the important stuff. If you design your secondary with too few turns then, for the required step down ratio from the primary voltage, there will be too few turns on the primary AND too few turns on the primary usually means tears and disappointment.
You have to forget the secondary when designing the primary (despite other claims). You have to consider how much flux is produced in the core when the primary connects to the AC power line. Too few a number of turns will mean too much magnetization current in the primary and the core will saturate and you may, in worst case scenarios, get melt down or a fire.
The primary is an inductor after all and if the inductance is too low it draws too much current to magnetize the core irrespective of what the secondary is doing so, you ignore the secondary when designing the primary.
Once you have calculated the primary turns (in order to avoid excessive core saturation) you simply wind the secondary turns based on the voltage step down ratio required.
There are of course a few more subtleties involved but the above is the main issue.

I have read that a Primary coil with too few turns will induce a very
  weak magnetic field in the core

You may have read it but at best it's misleading.

A: The number of turns in the secondary is governed by whatever step-down ratio you require.
That is: Secondary_Turns = Primary_Turns x Vin / Vout.
But I think you know that...
Your real question ought to be, how do I calculate the number of turns required on the primary. That's defined by a much more complex equation and is dictated by the geometry, materials, and design of the transformer core along with the applied primary voltage and frequency and power levels you need to transfer.
The latter is all a bit of a dark art.. and way beyond my experience level to quote for you.
As far as currents are concerned, that is a matter of using the appropriate gauge (diameter) of wires on both sides rather than the actual length of wire. That and having enough magnetics to support those currents.


text:
Q: Como fazer um layout de colunas responsivo com js? Eu preciso criar um layout de colunas (masonry) responsivo com js puro. Já tentei de várias maneiras, mas a maioria das colunas não são responsivas, e o CSS organiza a numeração de cima para baixo.

A responsividade seria:

*

*Em celulares: ter uma coluna horizontalmente.

*Em tablets: ter duas colunas horizontalmente.

*Em computadores: ter três colunas horizontalmente.
Estou usando esse código, mas não consigo deixar o layout responsivo ou mudar as larguras sem destruir o layout.

function renderGrid() {
    var blocks = document.getElementById("grid_container").children;
    var pad = 10,
        cols = 3,
        newleft, newtop;
    for (var i = 1; i < blocks.length; i++) {
        if (i % cols == 0) {
            newtop = (blocks[i - cols].offsetTop + blocks[i - cols].offsetHeight) + pad;
            blocks[i].style.top = newtop + "px";
        } else {
            if (blocks[i - cols]) {
                newtop = (blocks[i - cols].offsetTop + blocks[i - cols].offsetHeight) + pad;
                blocks[i].style.top = newtop + "px";
            }
            newleft = (blocks[i - 1].offsetLeft + blocks[i - 1].offsetWidth) + pad;
            blocks[i].style.left = newleft + "px";
        }
    }
}
window.addEventListener("load", renderGrid, false);
window.addEventListener("resize", renderGrid, false);
div#grid_container {
    width: 900px;
    margin: 0px auto;
    height: 860px;
    border: #999 1px dashed;
}
div#grid_container > div {
    position: absolute;
    width: 291px;
    border: #000 1px solid;
}
div#grid_container > div:nth-child(2n+0) {
    background: #FFDC64;
}
div#grid_container > div:nth-child(2n+1) {
    background: #FEC910;
}
div#grid_container > div > div {
    padding: 20px;
    font-size: 27px;
    color: #D9A800;
}
<!DOCTYPE html>

<meta charset="UTF-8">

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

A: Você consegue fazer isso apenas com CSS:
.grid_container{
  width: 100%;
  column-count: 4;
}

.child{
  display:block;
  min-height: 110px;
  width: 100%;
  -webkit-column-break-inside: avoid;
  -moz-column-break-inside: avoid;
  column-break-inside: avoid;
}

JSFIDDLE: https://jsfiddle.net/lucassilvax/bqb3a3hk/


text:
Q: How can I reference elements with names like 'element-name' using SimpleXml How can I parse an XML document like this:
<feed>
  <item>
    <element-name>Element value</element-name>
  </item>
</feed>

If I try the following, it doesn't work:
$xmlObject = simplexml_load_string($xmlString);

foreach($xmlObject->item as $item) {
    $elementName= $item->element-name; // Obviously doesn't work.
}

I've tried:
$item->element_name;
$item->elementname;
$item->elementName;

None work.  How do I access this element's value?

A: You could use something like this:
$name = "element-name";
$item->{$name};

A: simplexml_load_string does not like it when you try and pass it element nodes with dashes/hyphens (-).
You have two options here.
Encapsulate the element name with curly braces ({}):
$elementName = $item->{'element-name'};

Or turn it into a variable you can replace out:
$elementNameNode = 'element-name';
$elementName = $item->$elementNameNode;


text:
Q: Intern - Debugging out of memory exceptions We're currently running into the following error when running Intern test runner for our JS test suite.
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
This error occurs before any test information is passing. I suspect that some of our tests are leaking memory or doing some expensive operations. How can I debug this?

A: That is a Node error rather than an Intern error. It indicates that the Node runtime has run out of memory.
A brute force fix would be to just allocate more memory to Node. You could try running node with the --max_old_space_size option, which affects the maximum amount of memory node can have allocated. The value is in megabytes; by default it's 512. Try something like node --max_old_space_size=2048.
A better fix would be to try to narrow down which suite (assuming it's a test suite) is allocating so much memory, and to modify the test or suite to mitigate the problem.


text:
Q: Subtracting factor level from another Given the following data frame:
set.seed(42)
test <- data.frame(tb = c(rep("top", 5), rep("bottom", 5)),
                   name = rep(c("q1", "q2", "q3", "q4", "q5"), 2),
                   values = rnorm(10, 1))

I'd like to subtract each "name" (bottom) level from its corresponding (top) value. For example: top q1 - bottom q1 = 1.4770829, top q2 - bottom q2 = -2.0762202, etc.
How can I produce the following results? In reality, "name" will have many more levels than five.
q1  1.4770829
q2  -2.0762202
q3  0.4577874
q4  -1.3855611
q5  0.4669824

A: You can reshape the data and subtract the two columns.
library(dplyr)
library(tidyr)

test %>%
  pivot_wider(names_from = tb, values_from = values) %>%
  mutate(diff = top - bottom)

#  name    top bottom   diff
#  <chr> <dbl>  <dbl>  <dbl>
#1 q1    2.37   0.894  1.48
#2 q2    0.435  2.51  -2.08
#3 q3    1.36   0.905  0.458
#4 q4    1.63   3.02  -1.39
#5 q5    1.40   0.937  0.467

Another way would be -
test %>%
  arrange(name, tb) %>%
  group_by(name) %>%
  summarise(values = diff(values))

#  name  values
#  <chr>  <dbl>
#1 q1     1.48
#2 q2    -2.08
#3 q3     0.458
#4 q4    -1.39
#5 q5     0.467


text:
Q: How to write a C function that keeps reading a set of line and marks the length of the lines I was trying an exercise in K&R which asks to write a program which reads a set of text line and prints the longest line.
I writing along the lines of something like this;
define a string of characters
write a function that marks the length of line until there's a newline
when encountered newline, the function again repeats
keep copying length to a variable if the length of newline is greater
copy the string (if of greater length) to another string
print the last copied string

I tried writing the function this mark the length which is certainly wrong
int getlength(char str[],int lim)
{
    int length ,c;
    c = getchar();
    while((c=getchar())!= '\n')
    {
        for (length=0; length < lim -1; length++)
            c = str[length];
    }
    return length;
}

Can anyone suggest me how to write the getlength function. I am not asking for the code but instead the psuedocode would be very helpful.

A: With strlen() you can get the length of the string. (I think that it is what you are asking)
https://www.tutorialspoint.com/c_standard_library/c_function_strlen.htm

A: Okay i understood. You want to print the longest line from a text file. Here is your code.
#include<stdio.h>
#include<stdlib.h>
#define LINEMAX 200
int main(){
    FILE * fp = fopen("longestline.in","r");
    char temp1[LINEMAX]={'\0'},temp2[LINEMAX]={'\0'},*selected,*longest,c;
    int longestLength=0,length=0;
    selected = temp1;
    while((c=fgetc(fp))!=EOF){
        while(c!='\n'&&c!=EOF){
            selected[length] =c;
            length++;
            c=fgetc(fp);
        }

        if(length>longestLength){
            longestLength = length;
            selected[length+1] = '\0';
            longest = selected;
            selected = selected == temp1 ?temp2:temp1;
        }
        length =0;

    }
    puts(longest);
return 0;
}

A: Here's what I think you're looking for from reading the post and your comments:
int getlength(char str[],int lim)
{
    int length = 0;
    int c;
    while((c=getchar())!= '\n') //Get a character. If it's a newline, quit. Otherwise, keep going.
    {
        str[length] = c; //Add it to the string
        length++; //Move to the next character
    }
    str[length] = '\0'; //Add the terminating null to the end of the string
    return length;
}

This function will find the length of the first line you give it on stdin.
Here's why your original function did not work:
You had:
int getlength(char str[],int lim)
{
    int length ,c;
    c = getchar();
    while((c=getchar())!= '\n')
    {
        for (length=0; length < lim -1; length++)
            c = str[length];
    }
    return length;
}

First, the character you read with c = getchar(); never gets processed because the while statement overwrites it while checking its condition. Remember, while loops will check the condition at the start of every loop. I think you wanted to use do {...} while(condition);, but if you do that you'll run into bugs because if the user types nothing the first getchar() call will return '\n' and the loop will run anyway and add it to the string.
Second, the inner loop loops over every character in the string you pass it and sets it to the most recently character read. I tried your code with a 100 character string and typed in "abcdef." I got 99 f's - it looped through each character in "abcdef" and set the whole string to the current character, and since 'f' was the last character, it was put in last.
Third, you didn't add a terminating null to the end of the string.


text:
Q: ModIfied Traveling Salesman Given a graph structure that has asymmetric costs on the edges, is there a way to traverse a certain set of nodes at lowest cost if you can visit each node only once? Problem is formulated such that such a path must exist.

A: Brute-force will eventually solve the problem.

A: I would use the A* algorithm.


text:
Q: How to fetch value form ajax formData in laravel 5.1? Here's is my form:
    {!! Form::open(['route' => 'postAddProject', 'id' => 'addProjectForm', 'files' => true]) !!}

            {!! Form::label('name', 'Name') !!}

                {!! Form::text('name', old('name'), ['class' => 'form-control', 'id' => 'name', 'placeholder' => 'Name']) !!}

            {!! Form::label('link', 'Link') !!}

                {!! Form::text('link', old('link'), ['class' => 'form-control', 'id' => 'link', 'placeholder' => 'Link']) !!}

            {!! Form::label('image', 'Image') !!}

            {!! Form::file('image', ['id' => 'image']) !!}

            <button class="btn btn-success" id="project-button">Add</button>

{!! Form::close() !!}

Here's my ajax code:

Here's my form request file:
class ProjectAddRequest extends Request
{
    public function rules()
    {
        return [
            'name' => 'required|max:255',
            'link' => 'required|url|max:255',
            'image' => 'required|image'
        ];
    }
}

Here's my controller:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Requests\ProjectAddRequest;
use App\Http\Controllers\Controller;

class ProjectController extends Controller
{
    public function postAddProject(ProjectAddRequest $request)
    {
        dd($request->input->all());
    }
}

?>

When I submit the form with all the input filled, I get error from form request that the fields are required. It seems that the form request is not getting the form data. And when I use Request and remove ProjectAddRequest in the function, nothing is printed out.

A: Remove the curly braces from the formData when passing to the jquery parameter.


text:
Q: angular5: Type 'true' is not assignable to type 'Observable I am trying to change the login status after the user login
component.ts
isLoggedIn$: Observable<boolean>;

  constructor (private auth:Auth){}

  ngOnInit (){

     this.isLoggedIn$ = this.auth.getUser()

     console.log(this.isLoggedIn$);

  }

Auth.ts
@Injectable()
export class Auth {

    private user:boolean = false;

     setUser(){

        this.user= true;
     }

     getUser(){
        return this.user
     }

    removeUser(){
        this.user = false;
    }

}

But i got the following error

error TS2322: Type 'true' is not assignable to type
  'Observable'

A: If you are mocking http without an actual service, you can wrap the loggedIn status in an Observable as shown below for a quick fix. Take a look at rxjs and understand Observables for a better understanding.
@Injectable()
export class Auth {

    private user:boolean = false;

     setUser(){

        this.user= true;
     }

     getUser(): Observable<boolean>{
        return Observable.of(this.user)
     }

    removeUser(){
        this.user = false;
    }

}

Also: console.log(this.isLoggedIn$) will not work like that.


text:
Q: Calculate time between switching on and switching off I need to calculate the time between switching on and switching off the android device. And also I want to get duration the screen on for one day. Is there some way to do it?

A: Yes, you can. You have to create a Receiver and listen for two intents:

ACTION_BOOT_COMPLETED - for finding out the device boot
ACTION_SHUTDOWN - for finding out when the device is powered off

From there, you can just have a service running in the background that keeps track of the time the device started and saves the time the device was turned on for. You can either log this in a file or a database or shared preferences and retrieve it later.
For calculating how long the screen was on, you will have to have a receiver listening for these two intents:

ACTION_SCREEN_ON
ACTION_SCREEN_OFF

You have to register an IntentFilter for these two intents as opposed to usually declaring them within your manifest (see this link for more details). Then you will have to simply have a flag that turns on when the screen turns on (and then a background service starts the timer or notes the time https://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/) and then the flag turns off when the screen turns off (and the timer stops or the service notes the current time and then calculates the time the screen was on by subtracting the previous time with the current time).
To note the time the screen was on in 24 hours, simply maintain another 24 hour flag that resets when the time period is over.


text:
Q: slim Guzzle to psr http. for slim PhpRenderer view $client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'http://127.0.0.1/slim_project/getall',
        array(
                'headers' => array(
                    'Authorization' => "Bearer fghfghfgh-sdfsdfs-sdfsdf}",
                )
            )
        );

$data = $response->withBody($res->getBody());
return $this->renderer->render($data->getBody(), 'pages/tables.php');

When i run the code. i got this error.
Argument 1 passed to Slim\Views\PhpRenderer::render() must implement interface Psr\Http\Message\ResponseInterface, instance of GuzzleHttp\Psr7\Stream given, called in /var/www/html/slim_project/index.php on line 101 and defined
How Can i convert Guzzle to psr/http\message. That how can i use this.
Thanks in advance.

A: return $this->renderer->render($response, 'pages/tables.php', json_decode($data->getBody(), true));


text:
Q: Compressed video:How to show B and P frames I want to analyze a compressed video (h264).
I'm encoding using this command:
ffmpeg -i in_path -vf scale=340:256,setsar=1:1 -q:v 1 -c:v h264 -f
rawvideo out_path

now I want to see how the P&B frames look like, so I'm using this command in order extract only the b frames:
 ffmpeg -ss 0 -i in_vid -t 2 -q:v 2 -vf
 select="eq(pict_type\,PICT_TYPE_B)" -vsync 0 frameb%03d.jpg

The extraction went well, no errors, and the number of frames extracted makes since by theory.
But, I Don't know how to "show" the image, when I'm doing:
eog frameb001.jpg

I'm getting a normal picture and not what I expected from a B frame, now I understand why doing "eog" won't be good, but I have no idea how to "show" the frame so that it will be meaningful (saw some articles that use HSV to show the frame).
One more thing the fact that I got a meaningful image from the B frames, maybe the extraction wasn't good.
Any help will be great, Thanks a lot!