text:
Q: Logic to show how many times a button is chosen I am currently using excel-vba and I am trying to create a simple question and answer. So far I have a question in my excel sheet that will answer the above question. I have four buttons that when you choose each button a message will appear. I want to find out if I can add some logic to each button to show how many times the button was chosen and also how many times this question was answered?
I have tried researching this but most of the answers show in Java and android programming. None with excel-vba.
Sub Tomatoes()

MsgBox "Correct"
End Sub

Sub Cucumbers()

MsgBox "Wrong Answer, that would be too healthy, Please choose again."
End Sub

Sub Lime()

MsgBox "Incorrect Answer, that ketchup would be exteremely sour."
End Sub

Sub Apples()

MsgBox "Incorrect, Apples with Ketchup would be horrible. "
End Sub

Each button is created so that when chosen it will display a different option. Is there a way to add logic to each button to show how many times it was chosen? and also add logic to show how many times this question was answered?

A: You are using Form controls, which have the advantage that you can point all of them to the same Sub.  So create a new sub like so and point all of your buttons to this.  This sub will increment the counters appropriately on your Sheet2.  Here's what Sheet2 should look like:

Sub btnIngredient_Click()

    Dim wb As Workbook
    Dim wsQuestion As Worksheet
    Dim wsCounts As Worksheet
    Dim rDest As Range

    Set wb = ActiveWorkbook
    Set wsQuestion = wb.ActiveSheet
    Set wsCounts = wb.Worksheets("Sheet2")

    Select Case wsQuestion.Shapes(Application.Caller).TextFrame.Characters.Text
        Case "Cucumbers":   Set rDest = wsCounts.Range("B3")
                            MsgBox "Wrong Answer, that would be too healthy, Please choose again."

        Case "Tomatoes":    Set rDest = wsCounts.Range("B4")
                            MsgBox "Correct"

        Case "Lime":        Set rDest = wsCounts.Range("B5")
                            MsgBox "Incorrect Answer, that ketchup would be exteremely sour."

        Case "Apples":      Set rDest = wsCounts.Range("B6")
                            MsgBox "Incorrect, Apples with Ketchup would be horrible. "

    End Select

    wsCounts.Range("B2").Value = wsCounts.Range("B2").Value + 1 'Increase counter of the total times question answered
    rDest.Value = rDest.Value + 1   'Increase counter of individual button clicked

End Sub

To clear the counters on workbook close, use the Workbook_BeforeClose event (make sure this code is in the ThisWorkbook code module):
Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Me.Worksheets("Sheet2").Range("B2:B6").Value = 0

End Sub

A: The Sub's for each button could track the information you need.  With the addition of some module-level variables, your code could look similar to this:
Private CucumbersPressed As Integer
Private TomatoesPressed As Integer
Private QuestionAnswered As Integer

Private Sub Cucumbers()
   CucumbersPressed = CucumbersPressed + 1
   QuestionAnswered = QuestionAnswered + 1

   MsgBox "Wrong"
End Sub

Private Sub Tomatoes()
   TomatoesPressed = TomatoesPressed + 1
   QuestionAnswered = QuestionAnswered + 1

   MsgBox "Correct"
End Sub

Depending on the number of questions and the number of buttons, this approach could become unwieldy.  In that case, some other mechanism would be needed but the idea would be similar.


text:
Q: Nested list sort How do I append two values to a key in dictionary
It is throwing error str object has no attribute append
score_list={}
for _ in range(int(input())):
    score=float(input())
    name=input()
    if score in score_list:
        score_list[score].append(name)
    else:
        score_list[score]=name
new_list=[]
for score in score_list:
    new_list.append([score,score_list[score]])
new_list.sort()

A: You need to add a list to your dict - not the string directly. Three ways I know of, from worst to best.

You can either use a normal dict and change your code to

score_list={}
for _ in range(int(input())):
    score=float(input())
    name=input()
    if score in score_list:
        score_list[score].append(name)
    else:

        score_list[score] = [name]  # add as 1-elem list

or use dict.setdefault(key,defaultvalue):

score_list={}
for _ in range(int(input())):
    score=float(input())
    name=input()

    k = score_list.setdefault(score,[]) # create key if needed with empty list
    k.append(name)

or use a collections.defaultdict(list).
score_list=defaultdict(list)

for _ in range(int(input())):
    score=float(input())
    name=input()

    score_list[score].append(name)  # defaultdict handles list creation for you

The last method is most performant - setdefault(score,[]) creates lots of empty default-lists that are not used if the key already exists.

If you need a top n result, you can create it directly from the dictionaries item()s:
n = 5
top_n = sorted(score_list.items(), reverse=True) [:n]  # sorts by max score first
# top_n  is a list of tuples:  [ (10000,["a","b","c"]) , (9999, ["b"]), ... ]

A: If I understood correctly, you need to change the line:
score_list[score]=name

to:
score_list[score]=[name]

In your current version you are assigning the string name to score_list[score], so you need to change to a list hence the change.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Having difficulty in moving Nav bar to the left using bootstrap4 Hi everyone i have a code for nav-bar and i want to move it to the left side of
 the form, its staying on the right side of the form,

  <button class="btn btn-secondary dropdown-toggle " type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Dropdown button
  </button>

    Action
    Another action
    Something else here

i have tried using floating to the left and using align-left it's still staying on the right side of the form what alternative can solve this issue?/ Thank you.

A: Kindly update your whole HTML page with navbar code. As running the code you have given is showing on left side of the browser.
 Take a look:


text:
Q: How to make UIPageViewController background translucent? I search on the web and found similar answers like this( How do I make the bottom bar with dots of a UIPageViewController translucent?) but it doesn't solve my problem.
Here is my code
    // PageControl Layout
UIPageControl *pageControl = [UIPageControl appearance];
pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
pageControl.backgroundColor = [UIColor clearColor];
//    pageControl.frame = CGRectMake(5,5,305,400);
pageControl = [UIPageControl appearanceWhenContainedIn:[self class], nil];

indexCurrentPage = 0;
pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
[pageController.view setFrame:[[UIScreen mainScreen] bounds]];
NSLog(@"page controller.fram  is %@", [NSValue valueWithCGRect:[[pageController view] frame]]);
pageController.dataSource = self;

GuidedTourPage *initialViewController = [self viewControllerAtIndex:0];
[[self.pageController view] setFrame:[[initialViewController view] bounds]];
NSLog(@"bound is %@", [NSValue valueWithCGRect:[[initialViewController view] bounds]]);
NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];
[pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:self.pageController];
[self.view addSubview:[pageController view]];
[pageController didMoveToParentViewController:self];

The scrolling function and everything else work fine. Except there is a portion of the image is missing.
I did self.window.backgroundColor = [UIColor whiteColor]; in my "AppDelegate.m" so it's understandable that pageControl.backgroundColor = [UIColor clearColor]; will make the background to be white.
But I want something like this (http://www.appcoda.com/wp-content/uploads/2013/06/UIPageViewController-Tutorial-Screen.jpg), in which the pageControl has a transparent background.
I know the problem lies in the layer. But I don't know how to fix it.
Is there a way to NSLog the layer hierarchy to check it? Or is there any tester software that can help me test the layer problem.
I don't think this will be a very hard problem as long as I can find a way to debug the layers like the 3D-Inspect element function in Firefox.
Thanks in advance

A: Try this:
UIPageControl *pageControl = [UIPageControl appearance];
pageControl.backgroundColor = [UIColor clearColor];

You can play with Alpha too:
[[UIColor alloc] initWithRed:0.0f green:0.0f blue:0.0f alpha:0.7];

So, the statement would become:
pageControl.backgroundColor = [[UIColor alloc] initWithRed:0.0f green:0.0f blue:0.0f alpha:0.7];

A: Something like this should work fine:
[self.pageCont setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0.5]];

A: I have verified this solution,
please subclass UIPageViewController and add this method in implementation.
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    for (UIView *view in self.view.subviews) {
        if ([view isKindOfClass:[NSClassFromString(@"_UIQueuingScrollView") class]]) {
            CGRect frame = view.frame;
            frame.size.height = view.superview.frame.size.height;
            view.frame = frame;
            [self.view sendSubviewToBack:view];
        }
    }
}

This will resolve the issue.
Thanks


text:
Q: Closed form for $(2^1-1)(2^2-1)...(2^k-1)$?
Is there closed form for $\prod_1^{i=k}(2^i-1)$ ?

I found that it is the product of the terms of the following arithmetico-geometric sequence :
$$\{u_1=1,u_{n+1}=2u_n+1\}$$
I found nothing with factorials, but there may be something.
For the story, I want to prove that :
$$\forall n \in \Bbb N, n\gt 3, \exists m \in \Bbb N, 0 \lt m \lt n$$
such as $$\forall k \in \Bbb N, 0 \lt k \lt n^2-m²-2n+1, 2^k \not\equiv 1 \mod (n^2-m^2)$$
and $$2^{n^2-m^2-2n+1} \equiv 1 \mod (n^2-m^2)$$
That's why I tried to make the product.

A: The (Gauss) $q$-analogue of the binomial theorem expresses the product of terms $(1 - q^i)$ as a sum whose terms are (up to some normalization factors) $q$-binomial coefficients.
Formulas are listed at Gaussian binomial coefficients in Wikipedia, for example.

A: In terms of known notations:
Let $u_{n+1} = 2 \, u_{n} + 1$ where $u_{0}=1$, for which $u_{n} = 2^{n}-1$.
Using
$$(x;q)_{n} = \prod_{k=0}^{n-1} (1 - x \, q^{r})$$
leads to
\begin{align}
P_{n} &= \prod_{k=0}^{n-1} \{ u_{k} \} = \prod_{k=1}^{n} \{ 2^{k+1} - 1 \} \\
&= 2^{\binom{n+1}{2}} \, \prod_{k=1}^{n} \left(1 - \frac{1}{2^{k}}\right) \\
&= 2^{\binom{n+1}{2}} \, \left(\frac{1}{2}; \frac{1}{2}\right)_{n}.
\end{align}


text:
Q: How can I convert a custom `dayHour` string variable to date format? I have a dataset (original is much larger):
hourly <- structure(list(day = c("Thu", "Thu", "Thu", "Thu", "Thu", "Thu",
"Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu",
"Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu",
"Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri",
"Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri",
"Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Sat", "Sat", "Sat",
"Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat",
"Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat",
"Sat", "Sat", "Sat", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun",
"Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun",
"Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Tue", "Tue", "Tue",
"Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue",
"Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue",
"Tue", "Tue", "Tue", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed",
"Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed",
"Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed",
"Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu",
"Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu",
"Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Fri", "Fri", "Fri",
"Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri",
"Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri",
"Fri", "Fri", "Fri", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat",
"Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat",
"Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat",
"Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun",
"Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun",
"Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue",
"Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue",
"Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue",
"Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed",
"Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed",
"Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Thu", "Thu", "Thu",
"Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu",
"Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu", "Thu",
"Thu", "Thu", "Thu", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri",
"Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri",
"Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri", "Fri",
"Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat",
"Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sat",
"Sat", "Sat", "Sat", "Sat", "Sat", "Sat", "Sun", "Sun", "Sun",
"Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun",
"Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun", "Sun",
"Sun", "Sun", "Sun", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Tue", "Tue",
"Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue",
"Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue", "Tue",
"Tue", "Tue", "Tue", "Tue", "Wed", "Wed", "Wed", "Wed", "Wed",
"Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed",
"Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed", "Wed"), hour = c(0L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 6L, 7L, 8L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L,
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
17L, 18L, 19L, 20L, 21L), totalCalls = c(30L, 28L, 15L, 21L,
11L, 14L, 18L, 35L, 42L, 36L, 37L, 38L, 54L, 45L, 37L, 52L, 40L,
66L, 84L, 69L, 75L, 51L, 39L, 38L, 25L, 21L, 18L, 20L, 7L, 14L,
14L, 28L, 37L, 50L, 46L, 31L, 45L, 45L, 39L, 31L, 48L, 69L, 91L,
117L, 74L, 66L, 60L, 37L, 20L, 31L, 15L, 26L, 18L, 12L, 21L,
42L, 107L, 118L, 138L, 137L, 93L, 109L, 102L, 91L, 102L, 76L,
76L, 70L, 68L, 74L, 55L, 54L, 28L, 19L, 23L, 12L, 16L, 12L, 18L,
39L, 96L, 119L, 111L, 95L, 65L, 81L, 67L, 76L, 64L, 64L, 68L,
71L, 54L, 65L, 51L, 41L, 30L, 16L, 12L, 11L, 13L, 16L, 20L, 41L,
55L, 57L, 46L, 52L, 44L, 55L, 55L, 45L, 53L, 73L, 84L, 72L, 63L,
74L, 52L, 39L, 32L, 27L, 21L, 11L, 15L, 14L, 17L, 36L, 43L, 68L,
55L, 40L, 38L, 50L, 40L, 42L, 57L, 74L, 79L, 76L, 78L, 60L, 49L,
40L, 17L, 24L, 14L, 15L, 10L, 14L, 18L, 31L, 46L, 45L, 37L, 37L,
38L, 34L, 32L, 41L, 45L, 51L, 81L, 91L, 62L, 63L, 49L, 23L, 39L,
30L, 17L, 16L, 9L, 9L, 17L, 33L, 36L, 47L, 44L, 43L, 41L, 56L,
43L, 41L, 40L, 38L, 78L, 99L, 75L, 61L, 59L, 35L, 22L, 10L, 14L,
14L, 18L, 12L, 11L, 27L, 65L, 50L, 59L, 42L, 51L, 37L, 53L, 30L,
38L, 61L, 94L, 88L, 58L, 53L, 33L, 34L, 25L, 23L, 21L, 24L, 21L,
6L, 28L, 42L, 102L, 135L, 133L, 114L, 109L, 103L, 84L, 100L,
93L, 79L, 97L, 63L, 75L, 61L, 64L, 38L, 35L, 23L, 23L, 16L, 22L,
17L, 25L, 53L, 86L, 116L, 99L, 102L, 85L, 73L, 80L, 69L, 69L,
80L, 50L, 68L, 49L, 54L, 45L, 35L, 32L, 31L, 17L, 19L, 8L, 12L,
15L, 27L, 57L, 44L, 58L, 50L, 44L, 43L, 40L, 34L, 43L, 57L, 89L,
76L, 77L, 68L, 48L, 45L, 33L, 24L, 26L, 16L, 14L, 22L, 16L, 26L,
47L, 43L, 54L, 50L, 37L, 41L, 47L, 39L, 45L, 62L, 82L, 66L, 54L,
47L, 49L, 37L, 17L, 24L, 15L, 12L, 10L, 7L, 18L, 25L, 44L, 43L,
38L, 36L, 50L, 39L, 64L, 55L, 50L, 45L, 73L, 75L, 60L, 45L, 46L,
45L, 35L, 24L, 18L, 14L, 18L, 27L, 17L, 29L, 34L, 45L, 45L, 47L,
55L, 34L, 55L, 52L, 47L, 51L, 93L, 76L, 52L, 67L, 44L, 37L, 24L,
20L, 23L, 18L, 9L, 8L, 11L, 23L, 48L, 48L, 47L, 35L, 45L, 49L,
45L, 52L, 65L, 36L, 97L, 107L, 67L, 62L, 58L, 33L, 28L, 23L,
14L, 24L, 18L, 28L, 24L, 45L, 103L, 147L, 131L, 125L, 104L, 98L,
94L, 83L, 98L, 87L, 82L, 84L, 69L, 58L, 61L, 42L, 33L, 29L, 19L,
20L, 19L, 20L, 28L, 53L, 98L, 124L, 120L, 122L, 91L, 92L, 89L,
88L, 63L, 91L, 77L, 74L, 57L, 67L, 55L, 40L, 30L, 16L, 17L, 14L,
7L, 1L, 5L, 10L, 3L, 42L, 37L, 65L, 53L, 47L, 52L, 76L, 106L,
91L, 70L, 71L, 62L, 52L, 24L, 12L, 14L, 17L, 10L, 20L, 21L, 30L,
57L, 49L, 45L, 40L, 51L, 43L, 39L, 56L, 58L, 62L, 95L, 77L, 53L,
54L, 49L, 31L, 23L, 27L, 16L, 8L, 10L, 14L, 32L, 36L, 50L, 37L,
47L, 43L, 44L, 46L, 42L, 39L, 53L, 53L, 89L, 75L, 61L, 56L),
    abandoned = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 2L, 0L, 0L, 0L, 1L,
    4L, 10L, 34L, 13L, 1L, 2L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L,
    0L, 1L, 2L, 4L, 10L, 0L, 1L, 3L, 3L, 8L, 1L, 2L, 4L, 3L,
    5L, 3L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 5L, 4L, 6L, 0L,
    0L, 2L, 0L, 2L, 0L, 0L, 0L, 1L, 1L, 1L, 3L, 3L, 1L, 0L, 1L,
    0L, 0L, 1L, 1L, 0L, 1L, 4L, 1L, 2L, 1L, 1L, 0L, 1L, 0L, 0L,
    3L, 0L, 0L, 2L, 1L, 0L, 3L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
    3L, 1L, 1L, 1L, 1L, 2L, 0L, 1L, 5L, 4L, 0L, 5L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 1L, 1L, 0L, 1L, 0L,
    1L, 1L, 0L, 2L, 7L, 0L, 4L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 2L, 1L, 0L, 0L, 4L, 2L, 0L, 0L, 5L, 19L,
    9L, 3L, 5L, 1L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 5L, 1L, 1L,
    4L, 2L, 1L, 3L, 1L, 1L, 0L, 3L, 4L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 4L, 2L, 6L, 1L, 3L, 5L, 8L, 17L,
    1L, 11L, 0L, 2L, 1L, 4L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L,
    0L, 4L, 4L, 1L, 9L, 4L, 4L, 2L, 1L, 0L, 5L, 0L, 2L, 1L, 0L,
    1L, 1L, 0L, 1L, 0L, 0L, 2L, 0L, 0L, 0L, 1L, 0L, 3L, 2L, 0L,
    0L, 1L, 0L, 0L, 0L, 3L, 0L, 1L, 1L, 0L, 0L, 1L, 2L, 1L, 0L,
    0L, 0L, 0L, 1L, 2L, 1L, 2L, 1L, 0L, 0L, 1L, 2L, 2L, 2L, 4L,
    1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 2L,
    0L, 0L, 4L, 0L, 5L, 5L, 5L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L,
    1L, 0L, 0L, 0L, 4L, 2L, 0L, 0L, 1L, 3L, 2L, 3L, 0L, 3L, 4L,
    1L, 2L, 6L, 2L, 0L, 3L, 3L, 0L, 0L, 0L, 2L, 4L, 0L, 0L, 0L,
    0L, 4L, 1L, 0L, 0L, 2L, 0L, 2L, 3L, 7L, 0L, 10L, 10L, 1L,
    3L, 1L, 0L, 1L, 0L, 0L, 3L, 1L, 2L, 1L, 0L, 0L, 14L, 13L,
    7L, 1L, 1L, 2L, 1L, 6L, 10L, 1L, 7L, 4L, 0L, 3L, 0L, 2L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 4L, 10L, 3L, 1L, 2L, 0L,
    3L, 0L, 5L, 2L, 4L, 2L, 5L, 9L, 5L, 0L, 1L, 0L, 0L, 3L, 0L,
    4L, 5L, 1L, 2L, 0L, 1L, 0L, 0L, 1L, 1L, 18L, 14L, 1L, 0L,
    6L, 7L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 2L, 5L, 1L, 0L, 3L,
    2L, 3L, 3L, 10L, 7L, 22L, 15L, 2L, 0L, 1L, 0L, 0L, 1L, 0L,
    0L, 0L, 0L, 2L, 1L, 6L, 0L, 1L, 4L, 2L, 1L, 1L, 0L, 1L, 1L,
    4L, 4L, 0L, 0L), answeredCalls = c(30L, 28L, 15L, 21L, 11L,
    14L, 18L, 35L, 42L, 36L, 37L, 38L, 54L, 45L, 37L, 51L, 40L,
    66L, 83L, 68L, 74L, 51L, 39L, 38L, 25L, 21L, 18L, 20L, 7L,
    14L, 14L, 28L, 37L, 49L, 46L, 31L, 43L, 45L, 39L, 31L, 47L,
    65L, 81L, 83L, 61L, 65L, 58L, 37L, 20L, 31L, 15L, 25L, 17L,
    12L, 21L, 42L, 106L, 115L, 134L, 127L, 93L, 107L, 97L, 88L,
    94L, 74L, 74L, 66L, 65L, 69L, 52L, 51L, 28L, 19L, 23L, 12L,
    16L, 12L, 17L, 39L, 91L, 115L, 104L, 95L, 65L, 79L, 67L,
    73L, 64L, 64L, 68L, 70L, 53L, 64L, 48L, 38L, 29L, 16L, 11L,
    11L, 13L, 15L, 19L, 41L, 54L, 53L, 45L, 50L, 42L, 54L, 54L,
    44L, 53L, 73L, 81L, 71L, 63L, 72L, 51L, 39L, 29L, 25L, 20L,
    11L, 15L, 14L, 17L, 36L, 43L, 65L, 54L, 39L, 37L, 49L, 38L,
    42L, 56L, 69L, 74L, 76L, 73L, 60L, 49L, 40L, 17L, 24L, 14L,
    15L, 10L, 14L, 18L, 31L, 46L, 42L, 36L, 36L, 38L, 33L, 32L,
    40L, 44L, 51L, 79L, 84L, 62L, 59L, 48L, 23L, 39L, 29L, 17L,
    16L, 9L, 9L, 17L, 33L, 36L, 47L, 41L, 42L, 41L, 55L, 39L,
    39L, 39L, 38L, 73L, 80L, 66L, 58L, 54L, 34L, 22L, 10L, 14L,
    14L, 16L, 12L, 11L, 27L, 60L, 49L, 58L, 38L, 49L, 36L, 50L,
    29L, 37L, 61L, 90L, 84L, 58L, 53L, 33L, 34L, 25L, 23L, 21L,
    24L, 21L, 6L, 28L, 42L, 101L, 131L, 129L, 108L, 108L, 99L,
    78L, 92L, 75L, 78L, 86L, 62L, 73L, 60L, 60L, 38L, 35L, 23L,
    23L, 16L, 20L, 17L, 25L, 53L, 82L, 112L, 96L, 93L, 81L, 69L,
    78L, 67L, 69L, 74L, 50L, 65L, 48L, 54L, 44L, 34L, 32L, 30L,
    17L, 19L, 6L, 12L, 15L, 27L, 56L, 44L, 55L, 48L, 44L, 43L,
    39L, 34L, 43L, 57L, 86L, 75L, 76L, 67L, 48L, 45L, 32L, 22L,
    25L, 16L, 14L, 22L, 16L, 25L, 45L, 42L, 52L, 49L, 37L, 41L,
    46L, 37L, 43L, 60L, 78L, 65L, 54L, 47L, 49L, 37L, 17L, 24L,
    15L, 12L, 10L, 7L, 18L, 25L, 43L, 41L, 38L, 36L, 46L, 39L,
    59L, 50L, 45L, 45L, 72L, 74L, 59L, 45L, 44L, 45L, 34L, 23L,
    18L, 14L, 17L, 23L, 15L, 29L, 34L, 44L, 42L, 44L, 52L, 34L,
    52L, 48L, 46L, 49L, 87L, 74L, 52L, 64L, 41L, 37L, 24L, 20L,
    21L, 14L, 9L, 8L, 11L, 23L, 44L, 47L, 46L, 35L, 42L, 49L,
    43L, 49L, 58L, 36L, 87L, 97L, 66L, 59L, 56L, 33L, 27L, 23L,
    14L, 21L, 17L, 26L, 23L, 45L, 103L, 133L, 118L, 118L, 101L,
    95L, 92L, 80L, 91L, 77L, 81L, 77L, 65L, 58L, 58L, 42L, 31L,
    29L, 19L, 20L, 19L, 20L, 28L, 53L, 98L, 119L, 110L, 119L,
    88L, 90L, 89L, 85L, 63L, 86L, 75L, 70L, 55L, 62L, 46L, 35L,
    30L, 15L, 17L, 14L, 4L, 1L, 1L, 5L, 2L, 40L, 37L, 64L, 53L,
    46L, 51L, 75L, 88L, 77L, 69L, 71L, 56L, 45L, 24L, 12L, 14L,
    16L, 10L, 19L, 21L, 30L, 54L, 44L, 42L, 40L, 48L, 41L, 36L,
    53L, 48L, 55L, 71L, 62L, 51L, 52L, 48L, 31L, 23L, 26L, 16L,
    8L, 10L, 14L, 28L, 35L, 44L, 37L, 46L, 39L, 42L, 45L, 41L,
    39L, 52L, 52L, 84L, 71L, 61L, 56L)), row.names = c(NA, 500L
), class = "data.frame")

Which I have mutated:
hourly$hour <- ifelse(nchar(hourly$hour) == 1, paste0("0", hourly$hour), hourly$hour)

hourly <-
  hourly %>%
  group_by(hour, day) %>%
  summarise(
    offered = mean(totalCalls),
    answered = mean(answeredCalls),
    abandoned = mean(abandoned),
  ) %>%
  mutate(dayHour = paste(day, hour))

The problem I have is arranging dayHour in the correct date order on the X-axis:
ggplot(hourly) +
    geom_line(aes(dayHour, offered, group = 1),
              colour = "red") +
    geom_line(aes(dayHour, answered, group = 1),
              colour = "forestgreen") +
    ggtitle("Hourly Call Volume") +
    theme(axis.text = element_text(angle = 90))

At the moment it is sorted alphabetically (i.e. Monday follows Friday when it should be Saturday and so on).
My question is this: how can I get the dayHour values to be represented as date objects and to be sorted correctly?
The idea is that the X-axis represents an entire week (168 hours in total) and I will later facet this graph, but for the time being I need to sort it by actual day order.

A: ggplot defaults to sorting char-vectors alphabetically. To circumvent this, supply the x-axis as factor with ordered levels:
hourly <- hourly %>%
  group_by(hour, day) %>%
  summarise(
    offered = mean(totalCalls),
    answered = mean(answeredCalls),
    abandoned = mean(abandoned),
  ) %>%
    arrange(factor(day,levels=c("Mon","Tue","Wed","Thu","Fri","Sat","Sun")),desc(day)) %>%
  mutate(dayHour = paste(day, hour))

hourly$dayHour <- factor(hourly$dayHour,levels=hourly$dayHour)

This produces the plot you want ordered by Days:


text:
Q: Cannot Add Background Image in PHP I have used following code to add a background image to my PHP file.
body {
 background-image:url('background.png');
 background-color: #F0F8FF;
}

But I can see the color only changed not the image. Can someone help me to solve this? Does this due to the image resolutions? I exported the image from microsoft powerpoint. Do I need to consider that as well? Are there any method to find whether the issue with my code or my picture.
I have pasted my whole code.
<?php
 session_start();
 ?>
 <!DOCTYPE html>

           <title>Library Management System</title>

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />

Management System

                <?php
                if(isset($_SESSION['username']))
                {

                 ?>

Welcome to Dialog G-Tech Library

                     Logout

                <?php

                }
                else
                {
                ?>

                     <button type="button" class="close" data-dismiss="modal">×</button>

Login

                     Username
                     <input type="text" name="username" id="username" class="form-control" />

                     Password
                     <input type="password" name="password" id="password" class="form-control" />

                     <button type="button" name="login_button" id="login_button" class="btn btn-warning">Login</button>

                <?php
                }
                ?>

                     <button type="button" class="close" data-dismiss="modal">×</button>

Login

                     Username
                     <input type="text" name="username" id="username" class="form-control" />

                     Password
                     <input type="password" name="password" id="password" class="form-control" />

                     <button type="button" name="login_button" id="login_button" class="btn btn-warning">Login</button>

A: Sometimes the cache won't realize that changes have been made to your website. A hard refresh is a way of clearing the browser's cache for a specific page, to force it to load the most recent version of a page. Sometimes, when changes are made to the website, they don't register immediately due to caching. A hard refresh will usually fix this, though occasionally completely clearing the cache is necessary.
Right Click on the refresh button and click on Empty Cache and Hard Reload and check its working or not


text:
Q: API level specific layouts in Mono for Android I would like to use features of API level 11 if available in one of my XML-files within the layout folder. Therefore, I have the folder structure
layout
-- myview.xml
layout-v11
-- myview.xml
where layout/myview.xml contains (within a LinearLayout) a simple

<TextView
           android:id="@+id/value"
           style="@style/MyStyle" />

whereas for API Level >= 11 I would like to add the textIsSelectable attribute in layout-v11/myview.xml:
<TextView
           android:id="@+id/value"
           android:textIsSelectable="true"
           style="@style/MyStyle" />

However, during the build with Target platform set to API Level 8 in MonoDevelop, I get Error: No resource identifier found for attribute 'textIsSelectable' in package 'android'.

A: Use targetSDKVersion(>=11) and minSDKVersion=8 tags in your manifest file to resolve this error.


text:
Q: map python append to a list i am trying to create a csv file in python and map the fields to a pre-existing fields, here is the title fileds of my csv
import_fields = ["ID", "Active (0/1)", "Name *", "Categories (x,y,z...)",
                "Price tax excl. or Price tax incl.", "Tax rules ID", "Wholesale price", "On sale (0/1)",
                "Discount amount", "Discount percent", "Discount from (yyyy-mm-dd)", "Discount to (yyyy-mm-dd)",
                "Reference #", "Supplier reference #", "Supplier", "Manufacturer", "EAN13", "UPC", "Ecotax", "Weight",
                "Quantity", "Short description", "Description", "Tags (x,y,z...)", "Meta-title", "Meta-keywords",
                "Meta-description", "URL rewritten", "Text when in stock", "Text when backorder allowed",
                "Available for order (0 = No, 1 = Yes)", "Product creation date", "Show price (0 = No, 1 = Yes)",
                "Image URLs (x,y,z...)", "Delete existing images (0 = No, 1 = Yes)", "Feature(Name:Value:Position)",
                "Available online only (0 = No, 1 = Yes)", "Condition", "ID / Name of shop"]

so for example:
adm_product = []
for category in breadcrumbs.findAll('li', { "class" : re.compile(r'\bcategory\d')}):
    adm_product.append(category.find('a').renderContents())

product_shop = soup.find('div', attrs={"class": "product-shop"})
product_sku = soup.find('p', attrs={"class": "product-sku"})
if product_sku:
    sku = product_sku.renderContents()
    product_ref = ref(sku)[0]
    adm_product.append(product_ref) # MAP TO REFERENCE

short_description = soup.find('div', attrs={"class": "short-description"})
if short_description:
    short_desc = short_description.find('div', attrs={"class": "std"})
    if short_desc:
        adm_product.append(short_desc.renderContents()) # MAP TO SHORT DESCRIPTION

What is the correct way to map the product_ref to the Reference in the import_fields list with any missing values being left blank or create a csv so that when i append a value it is added to the correct column?

A: Use a csv DictWriter and DictReader
http://docs.python.org/2/library/csv.html#csv.DictWriter


text:
Q: Control AC using FET
Trying to make a AC fan controller using Arduino and FET ST13005A. Instead of pwm with TRIAC or SSR, like to have fine control over the voltage. Voltage 230 V 50 Hz. Please see if the below simulated schematic is okay.
Circuit simulator link

A: Run your simulation and check the power dissipation of the various components - according to a quick check (although I am not familiar with this simulator) I noticed your resistors are dissipating around 11W at peak voltage, and the MOSFETs at least 20W (you would need to check the safe operating area carefully if you plan on operating like this)
So unless you are planning some serious resistors, I think a rethink is probably necessary. The circuir will probably dissipate more power than the fan it's controlling.
Also be aware that 230V is the RMS value, the peaks will be 1.41 times that, ~325V. It seems you have set your AC source to 230V peak to peak.
Why do you want to avoid switching?


text:
Q: Copy the folder along with parent folder I have a simple question, but I am unable to figure out a way to do it. I have a folder called EDSDK and it internally contains sub-folders. Now in my ant itself I wish to copy all those files.
i.e.

EDSDK

*

*headers

*dlls

I wish to copy the whole above (including EDSDK). Doing:
<fx:fileset dir="." type="data" includes="EDSDK/**"/>

copies the internal of EDSDK folder but not EDSDK folder itself. What should I do?
PS: above fx:fileset is similar to fileset

A: Doing:
<fx:fileset dir="." type="data" includes="EDSDK/"/>

does the trick.


text:
Q: HTML-iframe no muestra menu despegable Este es el html que quiero llamar dentro del iframe. Como ven, es un dropdown dentro de una lista que hará de header en varias paginas.
<!DOCTYPE html>

    <title>Janfa</title>
    <link rel="stylesheet" type="text/css" href="css/Dropdown.css">
    <link rel="stylesheet" type="text/css" href="css/header.css">

                <button class="dropdown-btn">
                    menu
                </button>

                    Link 1
                    Link 2
                    Link 3

Janfa

Log in

El siguiente es el html en donde tengo el iframe:
<!DOCTYPE html>

    <title>Janfa</title>
    <link rel="stylesheet" type="text/css" href="main.css">
    <link rel="stylesheet" type="text/css" href="css/Index.css">

y este es el CSS del html index
body{
    background-color: #eee;
    margin: 0;
}

iframe{
    width: 100%;
    height: 59px;
    border-style: none;
    position: relative;
}

El iframe se muestra perfectamente pero al activar el menu desplegable las opciones quedan ocultas dentro del margen del iframe y no se muestran (no adjunto el css del dropdown para no hacer la pregunta demasiado larga. Pero si, si sirve) solo que no se muestra completo cuando lo invoco por medio de el iframe. Alguna sugerencia?

A: La solución que me funcionó en una situacion como la que planteas fue hacerlo alrevez, la pagina contiene el menu desplagable y en el iframe incruste las paginas, para ello utilice javascript reemplazando los href="#"   por onclick( a la funcion de cambio de pagina). No olvides de agregar un id a tu iframe para poder capturarlo con getElementByID(el id ).src=(nueva pagina)


text:
Q: send php variable value via javascript in url I've read this post(how do i send a variable in the url in javascript), but can't get it to work.  I must add that I don't know javascript at all.  I'm trying to open an new "printer friendly" page in php, but in order for that I need to send the userid with the url, my code looks like this:
Page1
<?php
session_start();
$userid = $_SESSION['userid'];
?>
<head>
<script type="text/javascript">
function open_win()
{
window.open("http://www.mysite.com/exams/print.php?uid_print=$userid",'','width=200,height=100')
}
</script>
</head>
<?php
if ($_SESSION['auth']) {
include 'datalogin.php';

echo "<input type='button' value='Print this page' onclick='open_win()' />";

Page2(print.php)
<?php
session_start();
include 'datalogin.php';
$uid_print1 = $_GET['uid_print'];

echo $uid_print1;

But my ouput is:  $userid

A: window.open("http://www.mysite.com/exams/print.php?uid_print=<?php echo $userid; ?>",'','width=200,height=100')

A: Modify your window.open line to looks like this:
window.open("http://www.mysite.com/exams/print.php?uid_print=<?php echo $userid; ?>",'','width=200,height=100');

You have to 'enter' PHP block, and print out $userid variable to HTML (JavaScript) output.

A: This line in your JS script:
window.open("http://www.mysite.com/exams/print.php?uid_print=$userid",'','width=200,height=100')

Outputs '$userid' directly. You need to replace $userid with something like:
<?php echo $userid; ?>

A: Use <?php....?> tags:
...print.php?uid_print=<?php echo $userid;?>

A: Replacing:
window.open("http://www.mysite.com/exams/print.php?uid_print=$userid",'','width=200,height=100')

With:
window.open("http://www.mysite.com/exams/print.php?uid_print=<?php echo $userid; ?>",'','width=200,height=100')

Should probably do the trick.
You can also use the shorthand <?= $userid ?> which, to my eyes is more readable.

A: please concatenate $userid in your javascript.
it can be concatenated like uid_print='.$userid.' and you will get the value in $_GET["uid_print"]
you can also echo the $userid in string like

A: At the moment the variable in your javascript tag is not replaced because it is not enclosed by PHP tags. You can easily do it like this:
window.open("http://www.mysite.com/exams/print.php?uid_print=<?php echo $userid; ?>",'', 'width=200,height=100')


text:
Q: Calculating in quotient ring of $\mathbb{R}[X]$ Part of an old Oxford exam (1992 A1)
We want to find which elements of the quotient ring $\mathbb{R}[X]/(x^3-x^2+x-1)$ are equal to their own square.
Now, we note first that $x^3-x^2+x-1=(x-1)(x^2+1)$
Let $f(x)=(x-1)(x^2+1)$. Clearly we have $[1+(f(x))]^2=[1+(f(x))]$ but I cannot see how to find others. Any guidance would be appreciated.
Thanks.

A: Your previous question concerns generalized CRT. So you know that
$$\frac{{\bf R}[x]}{(x-1)(x^2+1)}\cong\frac{{\bf R}[x]}{(x-1)}\times \frac{{\bf R}[x]}{(x^2+1)}\cong {\bf R}\times{\bf C}$$
Find the idempotents in $\bf R$ and $\bf C$ to find the idempotents in ${\bf R}\times{\bf C}$, then pull them back through the isomorphisms implicit above.

Indeed the idempotents of ${\bf R}\times{\bf C}$ are $(0,0)$, $(0,1)$, $(1,0)$, $(1,1)$. The first and last correspond to $0$ and $1$ in $S={\bf R}[x]/(x-1)(x^2+1)$. To find what the others correspond to, solve e.g.
$$f(x)\equiv\begin{cases}0 & \mod x-1, \\ 1 & \mod x^2+1. \end{cases} $$
without loss of generality with $\deg f(x)\le 2$. Thus we can write $f(x)=(ax+b)(x-1)$ and solve for $a,b$ by distributing out this product, reducing mod $x^2+1$ and setting equal to zero. The other case proceeds in exactly the same way.


text:
Q: Android Lint error : Execution failed for task ':react-native-sensitive-info:lint' I am using react-native-sensitive-info package in my project and I am facing an issue. Build fails with the following error Execution failed for task ':react-native-sensitive-info:lint'.
I looked online and tried adding abortOnError false and also checkReleaseBuilds false but both did not work.
Can any one suggest what I can do to resolve this please.
Thanks
R
[(> Task :react-native-sensitive-info:lint FAILED
Ran lint on variant release: 37 issues found
Ran lint on variant debug: 37 issues found
Wrote HTML report to file:///C:/Development/xxx-Retail-ReactNative/retail-native-app/node_modules/react-native-sensitive-info/android/build/reports/lint-results.html
Wrote XML report to file:///C:/Development/xxx-Retail-ReactNative/retail-native-app/node_modules/react-native-sensitive-info/android/build/reports/lint-results.xml

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-sensitive-info:lint'.
> Lint found errors in the project; aborting build.

  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...

  The first 3 errors (out of 10) were:
  C:\Development\xxx-Retail-ReactNative\retail-native-app\node_modules\react-native-sensitive-info\android\src\main\java\br\com\classapp\RNSensitiveInfo\view\Fragments\FingerprintAuthenticationDialogFragment.java:115: Error: Call requires API level 23 (current min is 18): android.content.Context#getSystemService [NewApi]
                  mActivity.getSystemService(FingerprintManager.class),
                            ~~~~~~~~~~~~~~~~
  C:\Development\xxx-Retail-ReactNative\retail-native-app\node_modules\react-native-sensitive-info\android\src\main\java\br\com\classapp\RNSensitiveInfo\view\Fragments\FingerprintAuthenticationDialogFragment.java:115: Error: Class requires API level 23 (current min is 18): android.hardware.fingerprint.FingerprintManager [NewApi]
                  mActivity.getSystemService(FingerprintManager.class),
                                             ~~~~~~~~~~~~~~~~~~
  C:\Development\xxx-Retail-ReactNative\retail-native-app\node_modules\react-native-sensitive-info\android\src\main\java\br\com\classapp\RNSensitiveInfo\view\Fragments\FingerprintUiHelper.java:35: Error: Class requires API level 23 (current min is 18): android.hardware.fingerprint.FingerprintManager.AuthenticationCallback [NewApi]
  public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallback {
                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 23s

I have added 'abortOnError false' as well.
here is the build.gradle.
 lintOptions {
        abortOnError false
        //checkReleaseBuilds false
    }

subprojects {
        project.configurations.all {
            afterEvaluate {project ->
                if (project.hasProperty("android")) {
                    android {
                        compileSdkVersion rootProject.ext.compileSdkVersion
                        buildToolsVersion rootProject.ext.buildToolsVersion
                    }
                }
            }
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion rootProject.ext.buildToolsVersion
                }
            }
        }
    }

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

ext {
    compileSdkVersion = 28
    buildToolsVersion = "27.0.3"
    minSdkVersion = 18
    targetSdkVersion = 28
}

settings.gradle
include ':react-native-sensitive-info'
project(':react-native-sensitive-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensitive-info/android')

gradle.properties

android.useDeprecatedNdk=true
android.enableAapt2=false
android.enableJetifier=false
android.useAndroidX=false

package.json
"react-native-sensitive-info": "5.4.1",

Could you suggest how to fix this please

A: Based on error 'Error: Class requires API level 23 (current min is 18)' i suggest to change minSdkVersion = 18 to minSdkVersion = 23 in build.gradle.
ext {
    compileSdkVersion = 28
    buildToolsVersion = "27.0.3"
    minSdkVersion = 23
    targetSdkVersion = 28
}


text:
Q: How to set null value to Datetimepicker when load? I have a Datetimepicker1, i want to set it to empty when load, and show value after chose.
I have found a code
        Datetimepicker1.Format = DateTimePickerFormat.Custom
        Datetimepicker1.CustomFormat = " "

but it does not show value after chose.

A: DateTimePickers can't be set to null because DateTime can't be null, but you can set them to DateTime.MinValue which is the default value for an uninitialized DateTime. And then you just check if the dtp.Value = DateTime.MinValue and if so, treat it as null.
However, if you want to really distinguish when no value has been selected, the easiest way is to set DateTimePicker.ShowCheckBox to true, and then you check dtp.Checked and if it's true, you read the value, otherwise you treat it as a null.
Have you try this : for testing purpose
DateTime? myselectedDate = null;

private void DateTimePicker1_ValueChanged(Object sender, EventArgs e) {

   myselectedDate = DateTimePicker1.Value;

}

And
this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
this.dateTimePicker1.CustomFormat = " "; //a string with one whitespace

A: Try this
DateTime? dateSample= null;

A: DatetimePicker can't have no value. Null or default value is DateTime.MinValue. Your code changes the format in order to show nothing.
To show the date again, simply change DateTimePicker.Format again when needed:
DateTimePicker1.Format = DateTimePickerFormat.Long;

A: Because , you formatted your datetimepicker "", you should write the below code in valuechanged event of the datetimepicker;
Datetimepicker1.Format = DateTimePickerFormat.short(type which you need short,long etc..)


text:
Q: Get rid of App Namebar in IntelliJ I want to remove (or hide) the upper name bar that is generated in IntelliJ for android application .... in eclipse it would be if I am not mistaken would be by editing in AndroidManifest.xml
<activity android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">

is it the same for IntelliJ ?

A: I would assume its the same for IntelliJ. I use Android Studio which is built off of IntelliJ and android:theme="@android:style/Theme.Black.NoTitleBar" works for me.

A: Unfortunately this has broken recently (at least in Intellij).  Choosing one of the NoTitle themes will crash the app when you run because the theme needs to be a descendant of AppCompat (at least for lower minimum SDK versions), but it seems there isn't one currently that hides the titlebars.
Here is a working fix for hiding the title bar in both your running app as well as in the layout preview:
1) Set your theme back to 'AppTheme' in the AndroidManifest.xml:
    android:theme="@style/AppTheme"

2) Update the theme style in res/values/styles.xml by adding (to name="AppTheme"):
    <item name="android:windowNoTitle">true</item>

I believe you can also do this with 'android:windowFullscreen' if you also want to hide the action bar.
The above two steps will work when you run the app (emulator or device) but the layout will still show the titlebar.  You can hide that for working on your layout by going to the layout (such as activity_main.xml) and then clicking on the theme (AppTheme) above the preview and changing it to something like Light.NoTitleBar.  It's unfortunate that the preview ignores the theme changes in styles.xml, but hopefully that will get fixed.


text:
Q: p > nullptr: Undefined behavior? The following flawed code for a null pointer check compiles with some compilers but not with others (see godbolt):
bool f()
{
    char c;
    return &c > nullptr;
}

The offensive part is the relational comparison between a pointer and nullptr.
The comparison compiles with

*

*gcc before 11.1

*MSVC 19.latest with /std:c++17, but not with /std:c++20.

But no version of clang (I checked down to 4.0) compiles it.
The error newer gccs produce ("ordered comparison of pointer with integer zero ('char*' and 'std::nullptr_t')"1 is a bit different than the one from clang ("invalid operands to binary expression ('char *' and 'std::nullptr_t')").
The C++20 ISO standard says about relational operators applied to pointers in 7.6.9/3ff:

If both operands are pointers, pointer conversions (7.3.12) [...] are performed to
bring them to their composite pointer type (7.2.2). After conversions, the operands shall have the same type.
The result of comparing unequal pointers to objects is defined in terms of a partial order consistent with the following rules:
(4.1) — If two pointers point to different elements of the same array, or to subobjects thereof, the pointer to the element with the higher subscript is required to compare greater.
(4.2) — If two pointers point to different non-static data members of the same object, or to subobjects of such members, recursively, the pointer to the later declared member is required to compare greater provided the two members have the same access control (11.9), neither member is a subobject of zero size, and their class is not a union.
(4.3) — Otherwise, neither pointer is required to compare greater than the other.

("Pointer to object" in this context means only that the type is not a pointer to function, not that the pointer value refers to an actual object.)
(4.1) and (4.2) clearly don't apply here, which leaves (4.3).  Does (4.3), "neither pointer is required", mean the behavior is undefined, and the code is invalid? By comparison, the 2012 standard contained the wording in 5.9/2 "[...] if only one of [two pointers of the same type p and q] is null, the results
of p<q, p>q, p<=q, and p>=q are unspecified."

1 The wording doesn't seem correct. nullptr_t is not, if I read the standard correctly, an integral type.

A: 7.6.9 states, "The lvalue-to-rvalue ([conv.lval]), array-to-pointer ([conv.array]), and function-to-pointer ([conv.func]) standard conversions are performed on the operands. .... The converted operands shall have arithmetic, enumeration, or pointer type."
None of the specified conversions is applicable to the literal nullptr. Also, it does not have arithmetic, enumeration, or pointer type. Therefore, the comparison is ill-formed.


text:
Q: Pandas series to numpy array conversion error I have a pandas series with foll. value_counts output():
NaN     2741
 197    1891
 127     188
 194      42
 195      24
 122      21

When I perform describe() on this series, I get:
df[col_name].describe()
count    2738.000000
mean      172.182250
std        47.387496
min         0.000000
25%       171.250000
50%       197.000000
75%       197.000000
max       197.000000
Name: SS_D_1, dtype: float64

However, if I try to find minimum and maximum, I get nan as answer:
numpy.min(df[col_name].values)
nan

Also, when I try t convert it to a numpy array, I seem to get an array with only nan's
numpy.array(df[col_name])

Any suggestion on how to convert from pandas series to numpy array succesfully

A: Both the function np.min and the method np.ndarray.min will always return NaN for any array that contains one or more NaN values (this is standard IEE754 floating point behaviour).
You could use np.nanmin, which ignores NaN values when computing the min, e.g.:
np.nanmin(df[col_name].values)

An even simpler option is just to use the pd.Series.min() method, which already ignores NaN values, i.e.:
df[col_name].min()

I have no idea why numpy.array(df[col_name]) would return an array containing only NaNs, unless df[col_name] already contained only NaNs to begin with. I assume this must be due to some other mistake in your code.

A: As of pandas' v 0.24.0 - you can access the backing array of a pandas Series with .array and .to_numpy
pandas 0.24.x release notes
Quote: "Series.array and Index.array have been added for extracting the array backing a Series or Index... We haven't removed or deprecated Series.values or DataFrame.values, but we highly recommend and using .array or .to_numpy() instead
... We recommend using Series.array when you need the array of data stored in the Series, and Series.to_numpy() when you know you need a NumPy array."


text:
Q: In Entity Framework how do I wrap a database call with a call to another service and ensure they're always called together? I have an entity framework model called Employee. Whenever I request a list of all Employee rows I first want to make a soap request to get any new employees from another system and update the sql database with them.
Is there some sort of binding that I could apply to the model or would I just have to add another model that calls both and call it instead.
I'm wanting to make it so that I can't call the employee list from the database directly without refreshing it at each place in the razor pages where I call it.

A: You could try to intercept the DB-Query. This enables you to execute custom code before the database-query is executed.
Check the following link: http://www.entityframeworktutorial.net/EntityFramework6/database-command-interception.aspx
In theory this will work but in my opinion it's a pretty bad way to call a SOAP service, which is completely independent of the DB, in some "random" interceptor.
Instead you should provide a class to your GUI-Models (?) that doesn't give them the EF DataContext itsself but a class that you control. This layer of the application called e.g. dataprovider then decides wether to call the SOAP service and update the db before querying it or not.
This is just a personal opinion of me.

A: Access modifiers and layer segregation.
Access modifiers (public, private, internal, protected) make it possible for you to prevent an external caller from calling inner logic directly, and instead force them to use only the logic you have allowed them to access.
If you abstract your data access logic into a separate project/layer (known as the DAL), then you can achieve what you want.
As a simple example:
internal class MyContext : DbContext
{
    // ...
}

public class EmployeeRepository
{
    public List<Employee> GetEmployees()
    {
        using(var db = new MyContext())
        {
            UpdateEmployeeList(db);

            return db.Employees.ToList();
        }
    }

    private void UpdateEmployeeList(MyContext db)
    {
        var externalEmployeeList = GetExternalEmployeeList();

        foreach(var employee in externalEmployeeList)
        {
            db.Add(employee);
        }

        db.SaveChanges();
    }
}

An external caller can only get at the employee data by doing the following:
var employeeRepository = new EmployeeRepository();
var employees = employeeRepository.GetEmployees();

Therefore, it's impossible for them to bypass the additional SOAP call.
However, this does mean that external callers can't have direct access to MyContext and must always use methods that you've created for them.
In professional codebases, layer segregation is such a common occurrence that this is usually already the case anyway. I would expect any professional codebase to separate its DAL (data acccess layer) into a separate project and not leak its inner dependency (such as EF's DbContext).

While it's technically possible to do things like intercepting queries, this is not going to be easy to develop nor maintain.
What you're effectively asking for is the following:

I want to force external callers to use my logic (= enforcing the additional SOAP call) instead of just using EF directly.

The logical consequence is that you have to create your logic. This is the DAL I was talking about, it's a project that exists specifically to separate the external caller from EF, and instead force the external caller to use the DAL's logic (which will use EF if and when it wants to - the external caller doesn't get to make the decision).


text:
Q: python threads, how to return results generated during the execution of a multithread code I'm tring to learn how to use threads in python to save a list of object.
I'm starting from this code :
import threading
import urllib
from tempfile import NamedTemporaryFile

singlelock = threading.Lock()

class download(threading.Thread):
    def __init__(self, sitecode, lista):
        threading.Thread.__init__(self)
        self.sitecode = sitecode
        self.status = -1

    def run(self):
        url = "http://waterdata.usgs.gov/nwis/monthly?referred_module=sw&site_no="
        url += self.sitecode
        url += "&PARAmeter_cd=00060&partial_periods=on&format=rdb&submitted_form=parameter_selection_list"
        tmp = NamedTemporaryFile(delete=False)
        urllib.urlretrieve(url, tmp.name)
        print "loaded Monthly data for sitecode : ",  self.sitecode
        lista.append(tmp.name)
        print lista

sitecodelist = ["01046500", "01018500", "01010500", "01034500", "01059000", "01066000", "01100000"]
lista = []

for k in sitecodelist:
    get_data = download(k,lista)
    get_data.start()

It just prints out the list generated during the thread execution, while I'm tring to return it.
Trying to read the documentation, I'm looking on how to use threading.Lock() and its methods acquire() and release() that seems to be the solution to my issue ...
but I'm really far to understand how to implement it in my example code.
thanks so much for any hints!

A: First of all we should all quickly review what threads are http://en.wikipedia.org/wiki/Thread_%28computer_science%29.
Ok, so threads share memory.  So this should be easy!  Which is also the good and bad thing about threads, it's easy and dangerous! (also lightweight for the OS).
Now, if using, python with cpython you should familiarize yourself with the global interpreter lock:
http://docs.python.org/glossary.html#term-global-interpreter-lock
Also, from http://docs.python.org/library/threading.html:

CPython implementation detail: Due to the Global Interpreter Lock, in
  CPython only one thread can execute Python code at once (even though
  certain performance-oriented libraries might overcome this
  limitation). If you want your application to make better of use of the
  computational resources of multi-core machines, you are advised to use
  multiprocessing. However, threading is still an appropriate model if
  you want to run multiple I/O-bound tasks simultaneously.

What does this mean?  If your task isn't IO threading won't gain you anything from the OS since any time you do anything with python code, only a single thread will be able to do anything since it has the global lock and no other threads can get it.  With IO bound tasks the OS will schedule other threads since the global lock will be released while waiting for the IO to complete.  There is the caveat though that you could be calling into code that does not fall under the GIL and in that case threading will also perform well (hence the reference to "performance oriented libraries" above.)
Thankfully, python makes managing the shared memory a simple task and there is already good documentation on how to do so, though it took me a small bit to find it.  If you have any further questions let us know.
In [83]: import _threading_local

In [84]: help(_threading_local)
Help on module _threading_local:

NAME
    _threading_local - Thread-local objects.

FILE
    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_threading_local.py

MODULE DOCS
    http://docs.python.org/library/_threading_local

DESCRIPTION
    (Note that this module provides a Python version of the threading.local
     class.  Depending on the version of Python you're using, there may be a
     faster one available.  You should always import the `local` class from
     `threading`.)

    Thread-local objects support the management of thread-local data.
    If you have data that you want to be local to a thread, simply create
    a thread-local object and use its attributes:

      >>> mydata = local()
      >>> mydata.number = 42
      >>> mydata.number
      42

    You can also access the local-object's dictionary:

      >>> mydata.__dict__
      {'number': 42}
      >>> mydata.__dict__.setdefault('widgets', [])
      []
      >>> mydata.widgets
      []

    What's important about thread-local objects is that their data are
    local to a thread. If we access the data in a different thread:

      >>> log = []
      >>> def f():
      ...     items = mydata.__dict__.items()
      ...     items.sort()
      ...     log.append(items)
      ...     mydata.number = 11
      ...     log.append(mydata.number)

      >>> import threading
      >>> thread = threading.Thread(target=f)
      >>> thread.start()
      >>> thread.join()
      >>> log
      [[], 11]

    we get different data.  Furthermore, changes made in the other thread
    don't affect data seen in this thread:

      >>> mydata.number
      42

    Of course, values you get from a local object, including a __dict__
    attribute, are for whatever thread was current at the time the
    attribute was read.  For that reason, you generally don't want to save
    these values across threads, as they apply only to the thread they
    came from.

    You can create custom local objects by subclassing the local class:

      >>> class MyLocal(local):
      ...     number = 2
      ...     initialized = False
      ...     def __init__(self, **kw):
      ...         if self.initialized:
      ...             raise SystemError('__init__ called too many times')
      ...         self.initialized = True
      ...         self.__dict__.update(kw)
      ...     def squared(self):
      ...         return self.number ** 2

    This can be useful to support default values, methods and
    initialization.  Note that if you define an __init__ method, it will be
    called each time the local object is used in a separate thread.  This
    is necessary to initialize each thread's dictionary.

    Now if we create a local object:

      >>> mydata = MyLocal(color='red')

    Now we have a default number:

      >>> mydata.number
      2

    an initial color:

      >>> mydata.color
      'red'
      >>> del mydata.color

    And a method that operates on the data:

      >>> mydata.squared()
      4

    As before, we can access the data in a separate thread:

      >>> log = []
      >>> thread = threading.Thread(target=f)
      >>> thread.start()
      >>> thread.join()
      >>> log
      [[('color', 'red'), ('initialized', True)], 11]

    without affecting this thread's data:

      >>> mydata.number
      2
      >>> mydata.color
      Traceback (most recent call last):
      ...
      AttributeError: 'MyLocal' object has no attribute 'color'

    Note that subclasses can define slots, but they are not thread
    local. They are shared across threads:

      >>> class MyLocal(local):
      ...     __slots__ = 'number'

      >>> mydata = MyLocal()
      >>> mydata.number = 42
      >>> mydata.color = 'red'

    So, the separate thread:

      >>> thread = threading.Thread(target=f)
      >>> thread.start()
      >>> thread.join()

    affects what we see:

      >>> mydata.number
      11

    >>> del mydata

And just in case... an example using your style above.
In [40]: class TestThread(threading.Thread):
    ...:     report = list() #shared across threads
    ...:     def __init__(self):
    ...:         threading.Thread.__init__(self)
    ...:         self.io_bound_variation = random.randint(1,100)
    ...:     def run(self):
    ...:         start = datetime.datetime.now()
    ...:         print '%s - io_bound_variation - %s' % (self.name, self.io_bound_variation)
    ...:         for _ in range(0, self.io_bound_variation):
    ...:             with open(self.name, 'w') as f:
    ...:                 for i in range(10000):
    ...:                     f.write(str(i) + '\n')
    ...:         print '%s - finished' % (self.name)
    ...:         end = datetime.datetime.now()
    ...:         print '%s took %s time' % (self.name, end - start)
    ...:         self.report.append(end - start)
    ...:

And a run of three threads with output.
    In [43]: threads = list()
        ...: for i in range(3):
        ...:     t = TestThread()
        ...:     t.start()
        ...:     threads.append(t)
        ...:
        ...: for thread in threads:
        ...:     thread.join()
        ...:
        ...: for thread in threads:
        ...:     print thread.report
        ...:
    Thread-28 - io_bound_variation - 76
    Thread-29 - io_bound_variation - 83
    Thread-30 - io_bound_variation - 80
    Thread-28 - finished
    Thread-28 took 0:00:08.173861 time
    Thread-30 - finished
    Thread-30 took 0:00:08.407255 time
    Thread-29 - finished
    Thread-29 took 0:00:08.491480 time
    [datetime.timedelta(0, 5, 733093), datetime.timedelta(0, 6, 253811), datetime.timedelta(0, 6, 440410), datetime.timedelta(0, 4, 342053), datetime.timedelta(0, 5, 520407), datetime.timedelta(0, 5, 948238), datetime.timedelta(0, 8, 173861), datetime.timedelta(0, 8, 407255), datetime.timedelta(0, 8, 491480)]
    [datetime.timedelta(0, 5, 733093), datetime.timedelta(0, 6, 253811), datetime.timedelta(0, 6, 440410), datetime.timedelta(0, 4, 342053), datetime.timedelta(0, 5, 520407), datetime.timedelta(0, 5, 948238), datetime.timedelta(0, 8, 173861), datetime.timedelta(0, 8, 407255), datetime.timedelta(0, 8, 491480)]
    [datetime.timedelta(0, 5, 733093), datetime.timedelta(0, 6, 253811), datetime.timedelta(0, 6, 440410), datetime.timedelta(0, 4, 342053), datetime.timedelta(0, 5, 520407), datetime.timedelta(0, 5, 948238), datetime.timedelta(0, 8, 173861), datetime.timedelta(0, 8, 407255), datetime.timedelta(0, 8, 491480)]

You may wonder why report has more then three elements... that is because I ran the above for loop code three times in my interpreter.  If I wanted to fix this "bug", I need to make sure to set the shared variable to an empty list before running.
TestThread.report = list()

Thus illustrates why threads can become unwieldy.

A: This doesn't answer your question directly but this is a workaround using the multiprocessing module instead:
from multiprocessing import Pipe, Process
import urllib
from tempfile import NamedTemporaryFile

def download(conn, sitecodelist):
    lista = []
    for k in sitecodelist:
        url = 'http://waterdata.usgs.gov/nwis/monthly?referred_module=sw&site_no='
        url += k
        url += '&PARAmeter_cd=00060&partial_periods=on&format=rdb&submitted_form=parameter_selection_list'
        tmp = NamedTemporaryFile(delete=False)
        urllib.urlretrieve(url, tmp.name)
        print 'loaded Monthly data for sitecode : ',  k
        lista.append(tmp.name)
    conn.send(lista)

sitecodelist = ['01046500', '01018500', '01010500', '01034500', '01059000', '01066000', '01100000']

parent, child = Pipe()
process = Process(target=download, args=(child, sitecodelist))
process.start()

data = parent.recv()
print 'Data: ', data
process.join()

And just in case, this a question about using multiprocessing or threading in your Python script: multiprocess or threading in python?
Hope that helps!


text:
Q: Problems calling PyQt5 render from a function I have a PyQt5 scraper that has to render a webpage before scraping it, since the webpage has dynamic data. This is the most barebones version of the script, which unfortunately still has several parts.
The only reason the render needs to be called from a function is because sometimes it will freeze up infinitely, so it has a multi threaded timeout on it. Which is all well and good, except the Render won't work properly inside of a function because QApplication isn't properly passed in for some reason. I can define App = QApplication(sys.argv) and put the Render class inside of the ScrapeClockwise function, but that requires defining App within that function as well(It can't be passed in for some reason.) And then if the function times out it'll kick it out without closing QApplication, so the next time the function runs the program will just crash. THIS EVEN HAPPENS IF IT IS DEFINED WITHIN A TRY-EXCEPT STATEMENT, which is extra weird.
As you can see there are a lot of strange interactions here and if anyone could shed some light on any of them I would be incredibly thankful, I've been beating my head against this for a while now.
import sys
from PyQt5.QtCore import *
from PyQt5.QtWebKitWidgets import *
from PyQt5.QtWidgets import *
from bs4 import BeautifulSoup
import threading
import functools
from threading import Thread

def timeout(timeout):
    def deco(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            res = [Exception('function [%s] timeout [%s seconds] exceeded!' % (func.__name__, timeout))]

            def newFunc():
                try:
                    res[0] = func(*args, **kwargs)
                except Exception as e:
                    res[0] = e

            t = Thread(target=newFunc)
            t.daemon = True
            try:
                t.start()
                t.join(timeout)
            except Exception as je:
                print('error starting thread')
                raise je
            ret = res[0]
            if isinstance(ret, BaseException):
                raise ret
            return ret

        return wrapper

    return deco

APP = QApplication(sys.argv)

class SomeClass(QWidget):
    def some_method(self):
        APP.processEvents(QEventLoop.ExcludeUserInputEvents | QEventLoop.ExcludeSocketNotifiers |
QEventLoop.WaitForMoreEvents)

class Render(QWebPage):
    def __init__(self, url):
        QWebPage.__init__(self)
        self.loadFinished.connect(self._loadFinished)
        self.mainFrame().load(QUrl(url))
        APP.exec_()

    def _loadFinished(self, result):
        self.frame = self.mainFrame()
        APP.quit()

def ScrapeClockwise(l):
    url = "https://www.clockwisemd.com/hospitals/" + str(l).zfill(4) + "/appointments/new"
    print(url)
    r = Render(url)
    result = r.frame.toHtml()
    soup = BeautifulSoup(result, 'html.parser')
    info = soup.find_all('h4')
    for i in info:
        print(i.get_text())

l = 0
while True:
    func = timeout(5)(ScrapeClockwise)
    try:
        func(str(l))
    except Exception as e:
        print(e)
        pass  # handle errors here
    l += 1

A: Each technology has its limitations and in the case of Qt, you cannot use a QWebPage in a secondary thread. You must also understand how technology works, many of the elements of Qt need and use an event loop, and that can help solve. In this case a QTimer can be used to measure the elapsed time and if the timeout has been triggered then load a new page.
Using this question I modified to obtain this solution considering the above:
from PyQt5 import QtCore, QtWidgets, QtWebKitWidgets

from bs4 import BeautifulSoup

def create_urls():
    l = 0
    while True:
        yield "https://www.clockwisemd.com/hospitals/{:04d}/appointments/new".format(l)
        l += 1

class WebPage(QtWebKitWidgets.QWebPage):
    def __init__(self):
        super(WebPage, self).__init__()
        self.mainFrame().loadFinished.connect(self.handleLoadFinished)
        self.mainFrame().urlChanged.connect(print)

        self.timer = QtCore.QTimer(
            singleShot=True, interval=10 * 1000, timeout=self.on_timeout
        )

    def start(self, generator):
        self.generator = generator
        self.fetchNext()

    def fetchNext(self):
        url = next(self.generator)
        self.mainFrame().load(QtCore.QUrl(url))
        self.timer.start()

    def processCurrentPage(self):
        html = self.mainFrame().toHtml()
        print("[url]: {}".format(self.mainFrame().url().toString()))

        soup = BeautifulSoup(html, "html.parser")
        info = soup.find_all("h4")
        for i in info:
            print(i.get_text())

    def on_timeout(self):
        print("[Timeout]")
        self.fetchNext()

    def handleLoadFinished(self):
        if self.timer.isActive():
            self.timer.blockSignals(True)
            self.timer.stop()
            self.timer.blockSignals(False)
        self.processCurrentPage()
        self.fetchNext()

if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    webpage = WebPage()
    webpage.start(create_urls())
    sys.exit(app.exec_())


text:
Q: thermal paste on GPU PCIe connector and inside motherboard's PCIe slot I took my pc to the repair shop to change the AIO cooler for my CPU. Apparently the tech dropped some thermal paste on my GPU pins while I wasn't around, amd when I got home I noticed thermal paste on my GPU.
I tried to clean it with alcohol, the GPU pins looks clean but there's still some thermal paste on the motherboard PCI that I couldn't clean
After cleaning it I tried to play some games to test but everything seems normal.
I have images of the GPU below - is there anything that I need to worry about?

A: Be sure to clean the thermal paste thoroughly from the card and the socket.  Use alcohol and wipe it up till its gone.  Use a cotton swab to get into the socket.  If everything is working, you should be fine, but its easier to clean it up while its still wet and not dried and hard.  However, if you leave it there, debris like dust and hair will adhere to it and could cause problems later.


text:
Q: Kafka Streams Fault-tolerance understanding Say, I have following :-

*

*Single Topic with 20 Partitions.

*I have 10 separate instances powering to streams-app(which are consuming from aforesaid topic) And on each Stream-app in configuration, I have added NUM_STREAM_THREADS_CONFIG=5.

Are following understanding correct ?

*

*Then I can have in total 50(10 * 5) logical tasks possible at MAX, but since no of partitions are 20, only 20 Tasks shall be spinned up !!

Also, since partition assignment to Stream-task is even, Would each partition be assigned to each of 20 tasks i.e. Each task gets to work upon a single partition ?
Is it correct going so far ?
Thanks for the reply.

A: Yes, as long as there are 20 partitions, there cannot be more than 20 Kafka consumer tasks.
Since you have configured 50 tasks max across 10 instances, it cannot be guaranteed which instances will start the tasks. It could at worst end up as having 4 instances with 5 tasks each or best as 10 instances with 2 tasks each.


text:
Q: Is it possible to style an html element, so that it won't 'hurt' inner styles I'm building some sort of framework where the content of the page can be edited with ContentTools. A requirement of ContentTools is that the regions must be parents.
If you try this:

Content

It wont work as a region has to contain editable block level elements. A way around this is to wrap the tag like so:

Content

But I just want to make the text editable, so I automatically wrapped the inner elements in a div. This works but it affects the styles.
Is there a way to make a div 'transparent', so it will inherit all styles?
I tried the following code.
To be clear: In this example I don't write the h1 css, so i have no influence over which styles are used.

$("[data-editable]").wrapInner("

");
/* example h1 css, could be anything */
body > h1{
  font-size: 40px;
  color: red;
  font-family: sans-serif;
  border: 3px solid green;
  background-color: blue;
  padding: 5px;
}

.innerWrap{
  all: inherit;
}

Content

As you can see some things work. But things like a border will double.
It has to be no difference with or without the innerWrap.
Is it possible to do this with css? It has to work on every css property.

A: I think you need to wrap the h1 with a div not div with h1.
for eg. .wrapInner() will produce something like

Content

But what you want is

Content

So please try with .wrap() instead of .wrapInner()

$("[data-editable]").wrap("

");
h1{
  font-size: 40px;
  color: red;
  font-family: sans-serif;
  border: 3px solid green;
  background-color: blue;
  padding: 5px;
}

.innerWrap{
  all: inherit;
}

Content

A: .innerWrap{
   all: inherit;  /* remove it*/
}

As a default behaviour, if you not specify css props for ".innerWrap" it will look same as parent only

A: The ability to make an individual element editable standalone as opposed to as part of a collection (e.g in a region) is currently being worked on: https://github.com/GetmeUK/ContentTools/issues/79
There is however a short-term imperfect approach you could try, first change you're HTML as follows:

    Content

This will make the h1 tag the region and tell ContentTools/Edit to treat the inner span element as a h1 (text) element (thanks to the data-ce-tag).
But the next problem is that if the user hit's return you'll end up with a new paragraph tag inside of your h1 - which we don't want. This is where the data-inline attribute comes in, we need to listen for mount events and if the element mounted has the data-inline attribute we'll modify its behaviour so it can't do certain things which might produce undesirable events:
ContentEdit.Root.get().bind('mount', function(elem) {
    // We're only interested in elements that are marked as inline
    if (elem.attr('data-inline') === undefined) {
        return;
    }

    // Change the default behaviour of the element
    elem.can('drag', false);
    elem.can('drop', false);
    elem.can('remove', false);
    elem.can('spawn', false);
});

You can find out more about modifying behaviours here, along with their current limitations here.


text:
Q: How to fix messed up layout on Android studio I'm not a real programmer, I'm learning tho, I know nothing about javascript but once again I'm now studying it from the beginning. I'm studying by that ''development course of android, how to create 15 apps'' so I did download the eclipse and the one recommended by the course ''Android Studio''. I did what it says on the tutorial but by the time I try to run it it's like a mess
This is the image of the messed up running:

A: You are most likely using ConstraintLayout. In ConstraintLayout you need to apply constraints to views (like Button) in order to make them stay where you want them to (to put it simply).
Constraint Layout guides:

When you drop a view into the Layout Editor, it stays where you leave it even if it has no constraints.
However, this is only to make editing easier; if a view has no constraints when you run your layout on a device, it is drawn at position [0,0] (the top-left corner).

You problem might have been solved in ConstraintLayout views in top left corner.


text:
Q: Localstorage selection Javascript - save style CSS I want to make a drop down menu with three selections that change the color of the nav and saves it in local storage, when you update the page the color you picked is still there.
I want to do this in Javascript and not with any help from jQuery.
Here is my HTML:
<nav id="box">
   <select>
      <option value="grey" id="grey">Grey</option>
      <option value="black" id="black">Black</option>
      <option value="green" id="green">Green</option>
   </select>
</nav>

Here is my CSS:
#box {
    height:50px;
    padding: 5px;
    margin:0 auto;
    font-size:25px;
    text-align: center;
}
.grey {
    background-color: rgba(0, 0, 0, 0.5);
    border-color: #FFF;
}
.black {
    background-color: rgba(0, 0, 0, 0.9);
    color: #FFF;
}
.green {
    background-color: rgba(33.3, 46.7, 7.8);
    border-color: #000;
}

Here is my JS:
function setUp() {
   document.getElementById("grey").onclick = setSuccessStyle;
   document.getElementById("black").onclick = setErrorStyle;
   document.getElementById("green").onclick = setInfoStyle;
}

function setSuccessStyle() {
   var messageBox = document.getElementById("box");
   messageBox.className = "grey";
}

function setErrorStyle() {
   var messageBox = document.getElementById("box");
   messageBox.className = "black";
}

function setInfoStyle() {
   var messageBox = document.getElementById("box");
   messageBox.className = "green";
}

I know that I'm not supposed to have onclick as the "action" but I have no idea how to solve this.

A: You have couple of issues in your code.
Basically you need to use onchange on the select but not click on the option.
After the user pick a color, you store it in the localStorage. When the page load, you read it from the localStorage and set the class with it value.
This snippet will not work because of security reason so you can see the result in this bin

function setUp(sel) {
  var messageBox = document.getElementById("box");
  messageBox.className = sel.value;
  localStorage.setItem('color', sel.value);
}

var selectElm = document.querySelector('select');
selectElm.value = localStorage.getItem('color') || selectElm.querySelector('option').getAttribute('value');
selectElm.onchange();
#box{
  height:50px;
  padding: 5px;
  margin:0 auto;
  font-size:25px;
  text-align: center;
}
.grey {
  background-color: rgba(0, 0, 0, 0.5);
  border-color: #FFF;
}
.black {
  background-color: rgba(0, 0, 0, 0.9);
  color: #FFF;
}
.green {
  background-color: rgba(0, 72, 3, 0.47);
  border-color: #000;
}
<nav id="box">
  <select onchange="setUp(this)">
    <option value="grey">Grey</option>
    <option value="black">Black</option>
    <option value="green">Green</option>
  </select>
</nav>

A:

function setUp() {
  document.getElementById("select").addEventListener("change", onChangeSelect);
}

function onChangeSelect() {
  var value = document.getElementById("select").value;
  console.log(value);
  switch (value) {
    case "grey":
      setSuccessStyle();
      break;
    case "black":
      setErrorStyle();
      break;
    case "green":
      setInfoStyle();
      break;
  }
}

function setSuccessStyle() {
  var messageBox = document.getElementById("box");
  messageBox.className = "grey";
}

function setErrorStyle() {
  var messageBox = document.getElementById("box");
  messageBox.className = "black";
}

function setInfoStyle() {
  var messageBox = document.getElementById("box");
  messageBox.className = "green";
}

setUp();
#box{
  height:50px;
  padding: 5px;
  margin:0 auto;
  font-size:25px;
  text-align: center;
}
.grey {
  background-color: rgba(0, 0, 0, 0.5);
  border-color: #FFF;
}
.black {
  background-color: rgba(0, 0, 0, 0.9);
  color: #FFF;
}
.green {
  background-color: rgba(33.3, 46.7, 7.8);
  border-color: #000;
}
<nav id="box">
  <select id="select">
    <option value="grey" id="grey">Grey</option>
    <option value="black" id="black">Black</option>
    <option value="green" id="green">Green</option>
  </select>
</nav>

A: Here's an answer that uses your HTML and CSS as-is. Just replace your setUp function with this and make sure to call setUp on page load.
function setUp() {
    var box = document.getElementById("box").getElementsByTagName('select')[0];
    box.onchange = function(){
            switch(this.value){
                case 'grey':
                    setSuccessStyle();
                    break;
                case 'black':
                    setErrorStyle();
                    break;
                case 'green':
                default:
                    setInfoStyle();
                    break;
            }
            //localStorage part
            localStorage.setItem("box",this.value);     //'box' can be any string key you want
        };
    //load the old value from localStorage
    var selection = localStorage.getItem("box");
    if(selection !== null){
        var items = box.getElementsByTagName("option");
        for(var i=0; i<items.length; i++){
            if(items[i].value == selection){
                box.selectedIndex = i;
                break;
            }
        }
    }
}


text:
Q: How to change get positive value on my weighting Scale? My weighting Scale is working fine when I keep weight after the start. But I am getting stuck when I keep weight before starting my weighing device. When I do this auto-calibrate with available weight.
I am going to explain the whole experiment with pics:

I am sharing my code also:
#include <LiquidCrystal_I2C.h>
#include "HX711.h"

int button1 = 9;
int press1 = 0;

LiquidCrystal_I2C lcd(0x27, 16, 2);

HX711 scale1(4, 5);

#define MAXFLT 8

void setup() {
  //lcd.clear();
  lcd.init();
  lcd.backlight();

  lcd.setCursor(0, 0);
  lcd.print(" Weighing Scale ");
  lcd.setCursor(0, 1);
  lcd.print("----MakerMan----");
  delay(3000);

  lcd.setCursor(0, 0);
  lcd.print("--Place Weight--");
  lcd.setCursor(0, 1);
  lcd.print("   ..... kg      ");

  scale1.set_scale(-56);  // BUG: calibrate the scale (higher number, lower reading)
  scale1.tare();

  pinMode(button1, INPUT);
  digitalWrite(button1, HIGH);

}

void loop() {
  float r;
  char buf[MAXFLT + 1];
  r = scale1.get_units(5);
  Serial.println(dtostrf(r, MAXFLT, 3, buf));
  lcd.setCursor(0, 1);
  lcd.print(dtostrf(r, MAXFLT, 2, buf));

  {
    press1 = digitalRead(button1);
    if (press1 == LOW)
    {
      scale1.tare();
    }
    else {
      ///
    }
  }
}

Here I want that if I placed the weight before starting the machine. and when I start then it should calculate the exact weight. How i do this?
I want to solve this, please help me.

A: You cannot measure the mass with certainty if it is present before power on time.
You can save a zero mass reading but this will only be approximate due to temperature change and the effect of leaving the cell loaded.

A: Commercial weigh scales would use an EEPROM or similar to store the tare reading. On power-up the scales will take the current reading and subtract the EEPROM tare value to display the weight of the object on the scales.
I have enabled tare memory on an industrial scales recently so that we can resume weighing and dispensing after a power-cut. The machine will finish its current task and then tare again before beginning the next cycle.


text:
Q: Como crear un listado de clases diferentes en JACKSON Se me ha presentado el siguiente inconveniente. Tengo una estructura json la cual proceso en java con Jackson.
{
  "conditions": [
    {
      "operator": "AND",
      "conditions": [
        {
          "operator": "IS_DESCENDANT",
          "value": "a"
        },
        {
          "operator": "AND",
          "conditions" [
            {}
          ]
        }
      ]
    }
  ]
}

Por un lado, tengo una clase conditions y por el otro una comparison. El problema se me presenta cuando en una lista quiero representar dos clases diferentes como es el siguiente caso:
"conditions": [
  {
    "operator": "IS_DESCENDANT",
    "value": "a"
  },
  {
    "operator": "AND",
    "conditions" [
      {}
    ]
  }
]

¿Como le indico a Jackson que arme un listado con las dos clases diferentes? Muchas gracias.

A: Yo lo que hago es representarlos como objectos con esta pagina http://pojo.sodhanalibrary.com/
si debe llamarse igual los creo en paquetes diferente
ejemplo:
co.com.startoverflow.request.conditions
co.com.startoverflow.response.conditions


text:
Q: Is there any way to click a bot's menu button which is a web app by Pyrogram I wrote a userbot by Pyrogram to send_message, click bot keyboard with my telegram account.
There's a bot , its menu button is a web app. Can I click its menu button by Pyrogram?
I wrote some code, but it didn't work out.
    raw_bot_peer = await user_bot.resolve_peer('xxx_bot')
    ret = await user_bot.invoke(
        functions.messages.RequestWebView(peer=raw_bot_peer, bot=raw_bot_peer,
                                          platform='android',
                                          from_bot_menu=True,
                                          ))

This code return errors: pyrogram.errors.exceptions.bad_request_400.BotInvalid: Telegram says: [400 BOT_INVALID] - This is not a valid bot (caused by "messages.RequestWebView")
Is there any way to click bot's menu button by Pyrogram code?


text:
Q: Sum of values associated to the same keys in nested associative array I have the array shown below. I would like to have a resultant array where value in the key elements [tv], [tu], [cost], [km] are summed for all the row with same value of [tick_id]. In this example we should sum the value [tv], [tu], [cost], [km] of the array elements 0, 1, 2, … How can I do this?
Array (
    [0] => stdClass Object (
        [id] => 15
        [user_id] => 44
        [name] => inspector1
        [tv] => 0.00
        [tc] => 0.00
        [tu] => 0.00
        [cost] => 0.00
        [kms] => 0
        [date_s] => 2012-03-30
        [notes] =>
        [tick_id] => 11
        [tot_fee] => 5500
    )
    [1] => stdClass Object (
        [id] => 39
        [user_id] => 46
        [name] => Assistant
        [tv] => 10.00
        [tc] => 0.00
        [tu] => 4.50
        [cost] => 0.00
        [kms] => 120
        [date_s] => 2012-03-31
        [notes] =>
        [tick_id] => 15
        [tot_fee] => 0
     )
    [2] => stdClass Object (
        [id] => 35
        [user_id] => 46
        [name] =>
        [tv] => 0.00
        [tc] => 0.00
        [tu] => 0.00
        [cost] => 0.00
        [kms] => 0
        [date_s] => 2012-03-30
        [notes] =>
        [tick_id] => 13
        [tot_fee] => 3200
    )
    …
)

A: It's hard to tell with the way your code is displaying but this should be what you need:
// Create the cost total array
$cost = array();

// Iterate over each object in the given array
foreach ($array as $object)
{

  // If the tick_id has not yet been assigned as a key then do so with a default cost of 0
  if (!isset($cost[$object->tick_id]))
  {
    $cost[$object->tick_id] = 0;
  }

  // Increment the total cost for the given tick_id
  $cost[$object->tick_id] += $object->tv + $object->km + $object->tu + $object->cost;

}

$cost will be an array where the key is the tick_id and the value is the total cost.


text:
Q: javascript objects alternative syntax I have just started scripting for photoshop using javascript
A simple piece of script is
var textItemRef = artLayerRef.textItem
textItemRef.contents = "Hello World"

I understand that artLayerRef.textItem  is a class and object of that class
and that textItemRef.contents is an object and property of that object.
However I am used to using javascript for webpage
so an object might be a div
and its property would be innerHTML
I would write that like this
var A = document.getElementbyID('div id'); var A.InnerHTML = hello
world.

How would I access a DIV object using the same style of code as shown in the Photoshop example - ie without the getElementbyID('div id')

A: you definetely can do it
var d = document.getElementById('myDiv');
d.innerHTML = 'test';

fiddle

*

*don't use spaces in div's id

*you don't need to write var every line, A is already your part of DOM

On a webpage you deal with DOM through document. You can access its' elements using getElementById(), getElementsByName(), getElementsByTagName() or even  document.forms (all forms on page) and document.images (all images)
After that you can access all their properties, use methods, bind events and even create your own stuff.

A: You don't. Using the DOM and one of the getElement* methods like you've described is the right way to get a handle on an element to then manipulate it further.


text:
Q: Running into trouble restarting Apache 2 I am attempting to restart Apache and am getting the following message...

> devil@DEVil:/etc/apache2$ sudo /etc/init.d/apache2 restart  *
> Restarting web server apache2
> AH00558: apache2: Could not reliably determine the server's fully
> qualified domain name, using 127.0.1.1. Set the 'ServerName' directive
> globally to suppress this message

The solution to this problem seems to be to enter ServerName localhost into the apache2.conf file (problem restarting apache2).
When I go into this file try to alter it it won't let me save as apache2.conf is a "read only" file. How can I alter the permissions to make it writable so I can get Apache up and running?

A: You have to edit the file as the root user, which could be achieved by entering the command sudo in front of the command you're using to edit the file (and entering the password for your user if asked for one).
For example if you're using vim the command should be
sudo vim /etc/apache2/apache2.conf

and you could replace vim with mc, nano, pico or whatever you prefer


text:
Q: Es posible conectar Flutter con una base de datos remota? Es fácil encontrar tutoriales de cómo conectarse a una base de datos relacional (Oracle, MySQL, SQLServer) desde lenguajes tales como PHP, Java, Python, entre otros.  Es posible hacerlo desde Flutter, sin requerir otros lenguajes ni frameworks adicionales en el servidor (remoto) que aloja la base de datos?

A: Sí, es posible.
Por ejemplo, para MySQL podes usar el paquete mysql1:
Conectarse a la db:
var settings = new ConnectionSettings(
  host: 'localhost',
  port: 3306,
  user: 'bob',
  password: 'wibble',
  db: 'mydb'
);
var conn = await MySqlConnection.connect(settings);

Hacer una consulta con parámetros:
var userId = 1;
var results = await conn.query('select name, email from users where id = ?', [userId]);

Si googleas "dart mysql" vas a encontrar varios tutoriales.

También podrías crear una API Rest, o usar Firebase.


text:
Q: Order of operands in C Say you have x = exp1 + exp2 in c. It might be evaluated by first evaluating exp1 then exp2 and adding the results however it may evaluate exp2 first.
How do you find out which side is evaluated first? I would like to make x = 1/2 depending on which one was evaluated first.
Any ideas?

A: Okay, you can do it like this:
#include <stdbool.h>
#include <stdio.h>

static int first(int value)
{
  static bool first = false;
  if (!first)
  {
    first = true;
    return value;
  }
  return 0;
}

int main(void)
{
  const int x = first(1) + first(2);
  printf("got %d\n", x);
}

On ideone.com, I got 1.
Note that this proves nothing, since there is no defined behavior here. The C99 draft says (in 6.5 Expressions, paragraph 3):

The grouping of operators and operands is indicated by the
  syntax.72)
  Except as specified later (for the function-call (), &&, ||,
  ?:, and comma operators), the order of evaluation of subexpressions and
  the order in which side effects take place are both unspecified.

A:
How do you find out which side is evaluated first?

Generally this is not specified by the standard. C11 6.5/3:

Except as specified later, side effects and value computations of
  subexpressions are unsequenced. 86)
...
86) In an expression that is evaluated more than once
  during the execution of a program, unsequenced and indeterminately
  sequenced evaluations of its subexpressions need not be performed
  consistently in different evaluations.

"Specified later" refers to a few special cases where the order of evaluation is specified, namely for the following operators: || && ?: ,, which are all guaranteed to be evaluated left-to-right.
As we can see from the cited note, we can't even know if the same program will treat the same expression consistently. This is called unspecified behavior, which means that compiler will behave in one of several well-defined ways but we can never know or assume which way. You should always write your programs so that the order of evaluation does not matter.

If you wish to fool around with code that prints which order the compiler decided to evaluate a particular expression (this time), you could do:
#include <stdio.h>

int func(void)
{
  static int x=0;
  return x++;
}

int main (void)
{
  printf("%d", func() << func());
}

This will either give 0<<1 == 0 (left-to-right) or 1<<0 == 1 (right-to-left). But such code has no practical purpose.