text:
Q: Performance of Node-Webkit Desktop Applications I need to create a desktop-application that has to handle some animations and a bunch of logic.
I thought about creating it with node-webkit which I never have used before.
Is anybody here who already wrote some desktop-apps and experienced the performance compared to something coded in c++?

A: So there's 2 parts to this question:
1) Speed comparison of Javascript executing under V8 (node-webkit), vs C++ compiled into native code
On most computationally-intensive tasks, you'd expect a 3x to 10x slowdown in execution (depending on the benchmark). An example can be found at http://benchmarksgame.alioth.debian.org/u64/benchmark.php?test=all&lang=v8&lang2=gpp ; if you want more examples search for other v8 benchmarks.
2) Speed comparison of browser-based UI toolkits (based on the DOM and CSS, and perhaps WebGL) as rendered with Chrome's engine, vs whatever desktop UI toolkit (for example, Qt, WxWidgets, etc) and/or 3D-rendering API (DirectX, OpenGL, or various different wrappers around them) that you'd be using with C++.
This unfortunately is rather difficult to benchmark, as there are tons of different UI toolkits out there, each with differing performance characteristics for each type of animation / widget that you might use (depending on how they were implemented). If you're 3D rendering and want to compare Javascript+WebGL on Chrome to C++ with DirectX, see https://www.scirra.com/blog/58/html5-2d-gaming-performance-analysis for an example benchmark (their figures indicate a ~5x slowdown); if you want more examples search for performance benchmarks comparing WebGL to OpenGL and DirectX.
Generally speaking, well-implemented C++ should execute faster than Javascript running under node-webkit, simply because there's fewer layers of abstraction away from the hardware. That said, unless you're building an exceptionally computationally intensive application, the difference will likely not be visible on a modern desktop, and you should be focusing more on ease-of-development rather than performance.
Using node-webkit also gives you advantage of the countless UI libraries built for browsers, which will likely accelerate your development time, especially if you already have experience in frontend web app development. There are also advantages in terms of portability - unless you use a cross-platform UI tookit like Qt with C++, you will need platform-specific UI code, whereas with node-webkit you get cross-platform portability for free.


text:
Q: Cuda demoting double to float error despite no doubles in code I'm writing a kernel using PyCUDA. My GPU device only supports compute capability 1.1 (arch sm_11) and so I can only use floats in my code. I've taken great effort to ensure I'm doing everything with floats, but despite that, there is a particular line in my code that keeps causing a compiler error.
The chunk of code is:
  // Gradient magnitude, so 1 <= x <= width, 1 <= y <= height.
  if( j > 0 && j < im_width && i > 0 && i < im_height){
    gradient_mag[idx(i,j)] = float(sqrt(x_gradient[idx(i,j)]*x_gradient[idx(i,j)] + y_gradient[idx(i,j)]*y_gradient[idx(i,j)]));
  }

Here, idx() is a __device__ helper function that returns a linear index based on pixel indices i and j, and it only works with integers. I use it throughout and it doesn't give errors anywhere else, so I strongly suspect it's not idx(). The sqrt() call is just from the standard C math functions which support floats. All of the arrays involved, x_gradient , y_gradient, and gradient_mag are all float* and they are part of the input to my function (i.e. declared in Python, then converted to device variables, etc.).
I've tried removing the extra cast to float in my code above, with no luck. I've also tried doing something completely stupid like this:
 // Gradient magnitude, so 1 <= x <= width, 1 <= y <= height.
 if( j > 0 && j < im_width && i > 0 && i < im_height){
    gradient_mag[idx(i,j)] = 3.0f; // also tried float(3.0) here
  }

All of these variations give the same error:
 pycuda.driver.CompileError: nvcc said it demoted types in source code it compiled--this is likely not what you want.
 [command: nvcc --cubin -arch sm_11 -I/usr/local/lib/python2.7/dist-packages/pycuda-2011.1.2-py2.7-linux-x86_64.egg/pycuda/../include/pycuda kernel.cu]
 [stderr:
 ptxas /tmp/tmpxft_00004329_00000000-2_kernel.ptx, line 128; warning : Double is not supported. Demoting to float
 ]

Any ideas? I've debugged many errors in my code and was hoping to get it working tonight, but this has proved to be a bug that I cannot understand.
Added -- Here is a truncated version of the kernel that produces the same error above on my machine.
 every_pixel_hog_kernel_source = \
 """
 #include <math.h>
 #include <stdio.h>

 __device__ int idx(int ii, int jj){
     return gridDim.x*blockDim.x*ii+jj;
 }

 __device__ int bin_number(float angle_val, int total_angles, int num_bins){

     float angle1;
     float min_dist;
     float this_dist;
     int bin_indx;

     angle1 = 0.0;
     min_dist = abs(angle_val - angle1);
     bin_indx = 0;

     for(int kk=1; kk < num_bins; kk++){
         angle1 = angle1 + float(total_angles)/float(num_bins);
         this_dist = abs(angle_val - angle1);
         if(this_dist < min_dist){
             min_dist = this_dist;
             bin_indx = kk;
         }
     }

     return bin_indx;
 }

 __device__ int hist_number(int ii, int jj){

     int hist_num = 0;

     if(jj >= 0 && jj < 11){
         if(ii >= 0 && ii < 11){
             hist_num = 0;
         }
         else if(ii >= 11 && ii < 22){
             hist_num = 3;
         }
         else if(ii >= 22 && ii < 33){
             hist_num = 6;
         }
     }
     else if(jj >= 11 && jj < 22){
         if(ii >= 0 && ii < 11){
             hist_num = 1;
         }
         else if(ii >= 11 && ii < 22){
             hist_num = 4;
         }
         else if(ii >= 22 && ii < 33){
             hist_num = 7;
         }
     }
     else if(jj >= 22 && jj < 33){
         if(ii >= 0 && ii < 11){
             hist_num = 2;
         }
         else if(ii >= 11 && ii < 22){
             hist_num = 5;
         }
         else if(ii >= 22 && ii < 33){
             hist_num = 8;
         }
     }

     return hist_num;
 }

  __global__ void every_pixel_hog_kernel(float* input_image, int im_width, int im_height, float* gaussian_array, float* x_gradient, float* y_gradient, float* gradient_mag, float* angles, float* output_array)
  {
      /////
      // Setup the thread indices and linear offset.
      /////
      int i = blockDim.y * blockIdx.y + threadIdx.y;
      int j = blockDim.x * blockIdx.x + threadIdx.x;
      int ang_limit = 180;
      int ang_bins = 9;
      float pi_val = 3.141592653589f; //91

      /////
      // Compute a Gaussian smoothing of the current pixel and save it into a new image array
      // Use sync threads to make sure everyone does the Gaussian smoothing before moving on.
      /////
      if( j > 1 && i > 1 && j < im_width-2 && i < im_height-2 ){

            // Hard-coded unit standard deviation 5-by-5 Gaussian smoothing filter.
            gaussian_array[idx(i,j)] = float(1.0/273.0) *(
            input_image[idx(i-2,j-2)] + float(4.0)*input_image[idx(i-2,j-1)] + float(7.0)*input_image[idx(i-2,j)] + float(4.0)*input_image[idx(i-2,j+1)] + input_image[idx(i-2,j+2)] +
            float(4.0)*input_image[idx(i-1,j-2)] + float(16.0)*input_image[idx(i-1,j-1)] + float(26.0)*input_image[idx(i-1,j)] + float(16.0)*input_image[idx(i-1,j+1)] + float(4.0)*input_image[idx(i-1,j+2)] +
            float(7.0)*input_image[idx(i,j-2)] + float(26.0)*input_image[idx(i,j-1)] + float(41.0)*input_image[idx(i,j)] + float(26.0)*input_image[idx(i,j+1)] + float(7.0)*input_image[idx(i,j+2)] +
            float(4.0)*input_image[idx(i+1,j-2)] + float(16.0)*input_image[idx(i+1,j-1)] + float(26.0)*input_image[idx(i+1,j)] + float(16.0)*input_image[idx(i+1,j+1)] + float(4.0)*input_image[idx(i+1,j+2)] +
            input_image[idx(i+2,j-2)] + float(4.0)*input_image[idx(i+2,j-1)] + float(7.0)*input_image[idx(i+2,j)] + float(4.0)*input_image[idx(i+2,j+1)] + input_image[idx(i+2,j+2)]);
     }
     __syncthreads();

     /////
     // Compute the simple x and y gradients of the image and store these into new images
     // again using syncthreads before moving on.
     /////

     // X-gradient, ensure x is between 1 and width-1
     if( j > 0 && j < im_width){
         x_gradient[idx(i,j)] = float(input_image[idx(i,j)] - input_image[idx(i,j-1)]);
     }
     else if(j == 0){
         x_gradient[idx(i,j)] = float(0.0);
     }

    // Y-gradient, ensure y is between 1 and height-1
    if( i > 0 && i < im_height){
         y_gradient[idx(i,j)] = float(input_image[idx(i,j)] - input_image[idx(i-1,j)]);
    }
    else if(i == 0){
        y_gradient[idx(i,j)] = float(0.0);
    }
    __syncthreads();

    // Gradient magnitude, so 1 <= x <= width, 1 <= y <= height.
    if( j < im_width && i < im_height){

        gradient_mag[idx(i,j)] = float(sqrt(x_gradient[idx(i,j)]*x_gradient[idx(i,j)] + y_gradient[idx(i,j)]*y_gradient[idx(i,j)]));
    }
    __syncthreads();

    /////
    // Compute the orientation angles
    /////
    if( j < im_width && i < im_height){
        if(ang_limit == 360){
            angles[idx(i,j)] = float((atan2(y_gradient[idx(i,j)],x_gradient[idx(i,j)])+pi_val)*float(180.0)/pi_val);
        }
        else{
            angles[idx(i,j)] = float((atan( y_gradient[idx(i,j)]/x_gradient[idx(i,j)] )+(pi_val/float(2.0)))*float(180.0)/pi_val);
        }
    }
    __syncthreads();

    // Compute the HoG using the above arrays. Do so in a 3x3 grid, with 9 angle bins for each grid.
    // forming an 81-vector and then write this 81 vector as a row in the large output array.

    int top_bound, bot_bound, left_bound, right_bound, offset;
    int window = 32;

    if(i-window/2 > 0){
        top_bound = i-window/2;
        bot_bound = top_bound + window;
    }
    else{
        top_bound = 0;
        bot_bound = top_bound + window;
    }

    if(j-window/2 > 0){
        left_bound = j-window/2;
        right_bound = left_bound + window;
    }
    else{
        left_bound = 0;
        right_bound = left_bound + window;
    }

    if(bot_bound - im_height > 0){
        offset = bot_bound - im_height;
        top_bound = top_bound - offset;
        bot_bound = bot_bound - offset;
    }

    if(right_bound - im_width > 0){
        offset = right_bound - im_width;
        right_bound = right_bound - offset;
        left_bound = left_bound - offset;
    }

    int counter_i = 0;
    int counter_j = 0;
    int bin_indx, hist_indx, glob_col_indx, glob_row_indx;
    int row_width = 81;

    for(int pix_i = top_bound; pix_i < bot_bound; pix_i++){
        for(int pix_j = left_bound; pix_j < right_bound; pix_j++){

            bin_indx = bin_number(angles[idx(pix_i,pix_j)], ang_limit, ang_bins);
            hist_indx = hist_number(counter_i,counter_j);

            glob_col_indx = ang_bins*hist_indx + bin_indx;
            glob_row_indx = idx(i,j);

            output_array[glob_row_indx*row_width + glob_col_indx] = float(output_array[glob_row_indx*row_width + glob_col_indx] + float(gradient_mag[idx(pix_i,pix_j)]));

            counter_j = counter_j + 1;
        }
        counter_i = counter_i + 1;
        counter_j = 0;
    }

}
"""

A: Here's an unmistakable case of using doubles:
 gaussian_array[idx(i,j)] = float(1.0/273.0) *

See the double literals being divided?
But really, use float literals instead of double literals cast to floats - the casts are ugly, and I suggest they will hide bugs like this.
-------Edit 1/Dec---------
Firstly, thanks @CygnusX1, constant folding would prevent that calculation - I didn't even think of it.
I've tried to reproduce the environment of the error: I installed the CUDA SDK 3.2 (That @EMS has mentioned they seem to use in the lab), compiling the truncated kernel version above, and indeed nvopencc did optimize the above calculation away (thanks @CygnusX1), and indeed it didn't use doubles anywhere in the generated PTX code. Further, ptxas didn't give the error received by @EMS. From that, I thought the problem is outside of the every_pixel_hog_kernel_source code itself, perhaps in PyCUDA. However, using PyCUDA 2011.1.2 and compiling with that still does not produce a warning like in @EMS's question. I can get the error in the question, however it is by introducing a double calculation, such as removing the cast from gaussian_array[idx(i,j)] = float(1.0/273.0) *
To get to the same python case, does the following produce your error:
import pycuda.driver as cuda
from pycuda.compiler import compile

x=compile("""put your truncated kernel code here""",options=[],arch="sm_11",keep=True)

It doesn't produce an error in my circumstance, so there is a possibility I simply can't replicate your result.
However, I can give some advice. When using compile (or SourceModule), if you use keep=True, python will print out the folder where the ptx file is being generated just before showing the error message.
Then, if you can examine the ptx file generated in that folder and looking where .f64 appears it should give some idea of what is being treated as a double - however, deciphering what code that is in your original kernel is difficult - having the simplest example that produces your error will help you.

A: Your problem is here:
angle1 = 0.0;

0.0 is a double precision constant. 0.0f is a single precision constant.

A: (a comment, not an answer, but it is too big to put it as a comment)
Could you provide the PTX code around the line where the error occurs?
I tried compiling a simple kernel using the code you provided:
__constant__ int im_width;
__constant__ int im_height;

__device__ int idx(int i,int j) {
    return i+j*im_width;
}

__global__ void kernel(float* gradient_mag, float* x_gradient, float* y_gradient) {
    int i = threadIdx.x;
    int j = threadIdx.y;
  // Gradient magnitude, so 1 <= x <= width, 1 <= y <= height.
  if( j > 0 && j < im_width && i > 0 && i < im_height){
    gradient_mag[idx(i,j)] = float(sqrt(x_gradient[idx(i,j)]*x_gradient[idx(i,j)] + y_gradient[idx(i,j)]*y_gradient[idx(i,j)]));
  }
}

using:
nvcc.exe   -m32 -maxrregcount=32  -gencode=arch=compute_11,code=\"sm_11,compute_11\"   --compile -o "Debug\main.cu.obj" main.cu
got no errors.
Using the CUDA 4.1 beta compiler

Update
I tried compiling your new code (I am working within CUDA/C++, not PyCUDA, but this shouldn't matter). Didn't catch the error either! Used CUDA 4.1 and CUDA 4.0.
What is your version of CUDA installation?
C:\>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2011 NVIDIA Corporation
Built on Wed_Oct_19_23:13:02_PDT_2011
Cuda compilation tools, release 4.1, V0.2.1221

redpajama_set_name: RedPajamaStackExchange


text:
Q: Django not saving the data to database I have a very basic knowledge of Django and having come across a problem, it has rendered me totally confused.
I am trying to construct a 3D plotter. Everything is rendering properly but when I click Submit, it never saves to the database except the specified default value that I have provided.
My models.py
from django.db import models

class Value(models.Model):
    eq_input = models.CharField(max_length=20, default='x**2 + y**2')
    color = models.CharField(max_length=20, default='Magma')

My forms.py
from django import forms
from .models import Value

class ViewForm(forms.ModelForm):
    Equation = forms.CharField(max_length=20, label='Equation')
    Color = forms.CharField(max_length=20,label='Color')
    class Meta:
        model = Value
        fields = {
            'Equation',
            'Color'
         }

My views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import Value
from .forms import ViewForm

def home_view(request):
    if request.method == "POST":
        form = ViewForm(request.POST)
        if form.is_valid():
            form.save()
    else:
       form = ViewForm()
     context = {
           'form': form
        }
   return render(request, "home.html", context)

My home.html
<!DOCTYPE html>

   <meta charset="utf-8">
   <title>3D Graph Plotter</title>

This is a 3D plotter

     <form action="." method="POST">{% csrf_token %}
         {{ form.as_p }}
    <input type="submit" name="Save" />
        </form>

and my urls.py
from django.contrib import admin
from django.urls import path, include
from equation.views import eq, home_view

urlpatterns = [
          path('admin/', admin.site.urls),
          path('', home_view, name='hv')
     ]

Can you point out the problem to me?

A: Put {{ form.errors }} {{ form.non_field_errors }} in your home.html and see if there are any errors in the data that the temp posts to the view. Maybe the data is not valid, too common password or something else.
<!DOCTYPE html>

   <meta charset="utf-8">
   <title>3D Graph Plotter</title>

This is a 3D plotter

    <form action="." method="POST">{% csrf_token %}
         {{ form.as_p }}
         {{ form.errors }}
         {{ form.non_field_errors }}
    <input type="submit" name="Save" />
        </form>


text:
Q: MS SQL Server sleeping transactions lock I have a problem with sleeping transaction locks on MS SQL Server 2008.
Sometimes it's not really sleeping or when transaction is not completed and there is real lock. But this is not my case.
We have tomcat 6 and java app on it. When I'm doing any update in java and then I'm trying to select updated records - no luck.
If I use with (nolock) - it helps, I see the correct changed rows, but then, after some period of time this updated is rolled back.
If I do update through Studio - then it works fine, immediate result.
Similar situation I have in many places of my application.
For example I have nightly job which is doing recalculation of big chunks of data into bitfields. And at the end it removes old bitfields and copies new bitfields inside. But when job is completed - rollback happens. I tried to save these bitfields manually in tmp tables and then I replaced old with new one through Studio - it worked.
All statements and connections are closed. I verified. And I tried to do all these changes in scope of one transaction.
This application was running for a long period of time without any troubles, but now something happened.
I tried to find out the reason and used sp_who, sp_who2, different scripts which shows locking queries, also I did massive monitoring with SQL server profiler and I tried to find any solution on the Internet. I found only
 Error: 1222, Severity: 16, State: 18
which is the result of this problem, not the cause. May be I'm moving in wrong direction. For me it looks like something changed in SQL server configuration and now, for some reason, it holds connection and all changes, which were made in scope of it for ever. When this connection is killed - everything rolled back.
If you have any ideas I would appreciate it.
Thanks in advance for any help.
UPDATE: I've searched and found one article:https://support.microsoft.com/en-us/kb/137983
and there is an option like:
If the Windows NT Server computer has successfully closed the connection, but the client process still exists on the SQL Server as indicated by sp_who, then it may indicate a problem with SQL Server's connection management. In this case, you should work with your primary support provider to resolve this issue.
May be this is mine option. I will investigate it further.


text:
Q: Unable to make pkg-config When I try to make pkg-config, I get an error. I want to install a bioinformatic tool on my mac. I am fairly new to this so I might be making a fatal mistake. Would appreciate any help! thanks!
make logs
/Library/Developer/CommandLineTools/usr/bin/make all-recursive
Making all in glib
/Library/Developer/CommandLineTools/usr/bin/make all-recursive
Making all in .
Making all in m4macros
/Library/Developer/CommandLineTools/usr/bin/make all-am
make[5]: Nothing to be done for all-am'. Making all in glib GEN glibconfig-stamp config.status: executing glib/glibconfig.h commands config.status: glib/glibconfig.h is unchanged /Library/Developer/CommandLineTools/usr/bin/make all-recursive Making all in libcharset /Library/Developer/CommandLineTools/usr/bin/make all-am make[7]: Nothing to be done forall-am'.
Making all in .
echo > glib-public-headers.txt.tmp && mv glib-public-headers.txt.tmp glib-public-headers.txt
Making all in .
CCLD pkg-config
Undefined symbols for architecture x86_64:
"_CFRelease", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFStringGetCString", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFStringGetCStringPtr", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFStringGetLength", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFURLCopyFileSystemPath", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_CFURLCreateFromFSRef", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_FSFindFolder", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
"_kCFAllocatorSystemDefault", referenced from:
_find_folder in libglib-2.0.a(libglib_2_0_la-gutils.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [pkg-config] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

A: I guess you're trying to build pkg-config with option --with-internal-glib enabled. If so, then you'll have to add the following linker (in LDFLAGS) options to the configure script -framework CoreFoundation and -framework Carbon, so you will build glib static and then pgk-config can make use of it.
In resume: env LDFLAGS="-framework CoreFoundation -framework Carbon" ./configure --with-internal-glib.
PS: Considere to edit your problem description and insert more context to your problem.
PPS: Pkg-Config version 0.29.1 has fixed this problem.


text:
Q: What is lacking in my geometric calculation below? The objective is to align the baseline of a label with the bisector. I want to summarize 4 possible tricks as follows. Let me know if there is another trick beyond my consideration.
The first trick:
Here I use \rput{(B)}(0,0){\mylabel} and the objective is well done.

\documentclass[pstricks,border=3pt,multi,12pt]{standalone}
\usepackage{pst-eucl}
\psset
{
    saveNodeCoors,
    CurveType=polyline,
    PointName=none,
    PointSymbol=none,
    MarkAngleRadius=1.6,
    LabelSep=1,
}

\newcommand{\mylabel}{$\scriptscriptstyle180^\circ-\theta$}

\begin{document}

\begin{pspicture}(6,6)
    \pstGeonode(1,1){A}(5,5){B}(4,1){C}
    \pstMarkAngle{A}{B}{C}{\rput{(B)}(0,0){\mylabel}}
    \rput(3,5.5){\tiny rput\{(B)\}}
\end{pspicture}

\end{document}

The second trick:
I use \rput{!\psGetNodeCenter{B} B.y B.x atan}(0,0){\mylabel} and the objective is also well done.

\documentclass[pstricks,border=3pt,multi,12pt]{standalone}
\usepackage{pst-eucl}
\psset
{
    saveNodeCoors,
    CurveType=polyline,
    PointName=none,
    PointSymbol=none,
    MarkAngleRadius=1.6,
    LabelSep=1,
}

\newcommand{\mylabel}{$\scriptscriptstyle180^\circ-\theta$}

\begin{document}

\begin{pspicture}(6,6)
    \pstGeonode(1,1){A}(5,5){B}(4,1){C}
    \pstMarkAngle{A}{B}{C}{\rput{!\psGetNodeCenter{B} B.y B.x atan}(0,0){\mylabel}}
    \rput(3,5.5){\tiny rput\{!psGetNodeCenter\{B\} B.y B.x atan\}}
\end{pspicture}

\end{document}

The third trick:
I use the numerical literal of node B, \rput{!5 5 atan}(0,0){\mylabel} and I failed.

\documentclass[pstricks,border=3pt,multi,12pt]{standalone}
\usepackage{pst-eucl}
\psset
{
    saveNodeCoors,
    CurveType=polyline,
    PointName=none,
    PointSymbol=none,
    MarkAngleRadius=1.6,
    LabelSep=1,
}

\newcommand{\mylabel}{$\scriptscriptstyle180^\circ-\theta$}

\begin{document}

\begin{pspicture}(6,6)
    \pstGeonode(1,1){A}(5,5){B}(4,1){C}
    \pstMarkAngle{A}{B}{C}{\rput{!5 5 atan}(0,0){\mylabel}}
    \rput(3,5.5){\tiny rput\{!5 5 atan\}}
\end{pspicture}

\end{document}

The fourth trick:
I use the saved coordinates of node B, \rput{!N-B.y N-B.x atan}(0,0){\mylabel} and I failed.

\documentclass[pstricks,border=3pt,multi,12pt]{standalone}
\usepackage{pst-eucl}
\psset
{
    saveNodeCoors,
    CurveType=polyline,
    PointName=none,
    PointSymbol=none,
    MarkAngleRadius=1.6,
    LabelSep=1,
}

\newcommand{\mylabel}{$\scriptscriptstyle180^\circ-\theta$}

\begin{document}

\begin{pspicture}(6,6)
    \pstGeonode(1,1){A}(5,5){B}(4,1){C}
    \pstMarkAngle{A}{B}{C}{\rput{!N-B.y N-B.x atan}(0,0){\mylabel}}
    \rput(3,5.5){\tiny rput\{!N-B.y N-B.x atan\}}
\end{pspicture}

\end{document}

Question:
Herbert had said that there is an inverse transformation that I have to think about when working with \rput and \psGetNodeCenter. I forgot the exact statement and the link.
Shortly speaking, what is lacking in my PostScript expression for the 3rd and 4th tricks?

A: In both instances, you're only calculating the angle relative to (0,0) which, for B (or (5,5)) is @ 45 degrees. That's why the angle mark is lighting up with the 45 degree line segment AB. Here are the ways to correctly implement options #3 and #4:
The third trick:

\documentclass[pstricks,border=3pt,multi,12pt]{standalone}
\usepackage{pst-eucl}% http://ctan.org/pkg/pst-eucl
\psset
{
    saveNodeCoors,
    CurveType=polyline,
    PointName=none,
    PointSymbol=none,
    MarkAngleRadius=1.6,
    LabelSep=1,
}

\newcommand{\mylabel}{$\scriptscriptstyle180^\circ-\theta$}

\begin{document}

\begin{pspicture}(6,6)
    \pstGeonode(1,1){A}(5,5){B}(4,1){C}
    \pstMarkAngle{A}{B}{C}{\rput{!5 5 atan 5 1 sub 5 4 sub atan add 2 div}(0,0){\mylabel}}
    \rput(3,5.5){\tiny rput\{!5 5 atan\}}
\end{pspicture}

\end{document}

The fourth trick:

\documentclass[pstricks,border=3pt,multi,12pt]{standalone}
\usepackage{pst-eucl}% http://ctan.org/pkg/pst-eucl
\psset
{
    saveNodeCoors,
    CurveType=polyline,
    PointName=none,
    PointSymbol=none,
    MarkAngleRadius=1.6,
    LabelSep=1,
}

\newcommand{\mylabel}{$\scriptscriptstyle180^\circ-\theta$}

\begin{document}

\begin{pspicture}(6,6)
    \pstGeonode(1,1){A}(5,5){B}(4,1){C}
    \pstMarkAngle{A}{B}{C}{\rput{!N-B.y N-B.x atan N-B.y N-C.y sub N-B.x N-C.x sub atan add 2 div}(0,0){\mylabel}}
    \rput(3,5.5){\tiny rput\{!N-B.y N-B.x atan\}}
\end{pspicture}

\end{document}

In essence, both methods calculate the average angle between the two line segments AB and CB:

*

*Line segment AB (relative to the origin (0,0)) is @ angle 45 (or 5 5 atan);

*Line segment BC (relative to the origin (0,0)) is @ angle arctan (5-1)/(5-4) = arctan 4/1 (or 4 1 arctan).

In method four, a more symbol approach is used, namely the saved node coordinates. Both methods and with an average of the two angles between line segment AB and BC, hence the use of add 2 div.


text:
Q: Wagtail > add gallery_images to multiple apps (page model instances) I followed the tutorial https://docs.wagtail.io/en/v2.6.2/getting_started/tutorial.html
and added to my blog app class BlogPageGalleryImage(Orderable): then def main_image(self): to the class BlogPage(Page): which worked.
But I have two more apps (projects and events) with page instances similar to blog and cannot add galleries to them the same way.
Should I implement the gallery into the Page class itself?
I have 4 apps (blog, about, events, projects) and in the model definitions *IndexPage, *Page, *PageGalleryImages respectively.
For example in the events app's models.py I defined
class EventPageGalleryImages(Orderable):
    page = ParentalKey(EventPage, on_delete=models.CASCADE, related_name='gallery_images')
    image = models.ForeignKey( 'wagtailimages.Image', on_delete=models.CASCADE, related_name='+' )
    caption = models.CharField(blank=True, max_length=250)
    panels = [ ImageChooserPanel('image'), FieldPanel('caption'), ]

but I get an error by makemigrations:
(ma_env) ➜  ma_app git:(0.15) ✗ ./manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/DEV/ma_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/DEV/ma_env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/DEV/ma_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
    raise _exception[1]
  File "/home/DEV/ma_env/lib/python3.6/site-packages/django/core/management/__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "/home/DEV/ma_env/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/home/DEV/ma_env/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/DEV/ma_env/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/home/DEV/ma_env/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/DEV/ma_app/events/models.py", line 24, in <module>
    class EventPage(Page):
  File "/home/DEV/ma_app/events/models.py", line 53, in EventPage
    class EventPageGalleryImages(Orderable):
  File "/home/DEV/ma_app/events/models.py", line 54, in EventPageGalleryImages
    page = ParentalKey(EventPage, on_delete=models.CASCADE, related_name='gallery_images')
NameError: name 'EventPage' is not defined

A: From the last few lines of the stack trace, it looks like you've defined EventPageGalleryImages inside the definition of EventPage:
class EventPage(Page):
    # ...

    class EventPageGalleryImages(Orderable):
        page = ParentalKey(EventPage, on_delete=models.CASCADE, related_name='gallery_images')
        # ...

This is failing because you refer to EventPage in the ParentalKey definition, but the definition of EventPage hasn't been completed yet. Removing the indent from the second class definition should fix it.


text: Q: Ubuntu 20.4 .cache tracker is taking my space I have 200 gb of space in my portion and the .cache tracker meta.db-wal took 140gb of that space and I don't know how to clear it. I saw that you can disable the tracker but without actually informing me how to clear or clean it to get the space back. someone also suggested deleting the tracker file but because I had Ubuntu issues before and I am afraid of deleting files that I might need in the future.


text:
Q: Outer Div not expanding with Inner Div I am developing the follow page:
The problem i'm having is the tabular structure. The outer div, my container is not expanding with the alternating heights of the tabs. See image of problem:

I would like the container to extend to the tabs heights.
HTML:

        name

               <input type="radio" id="tab-4" name="tab-group-2" checked>
               1

1

1

1

1

1

1

1

1

                <input type="radio" id="tab-5" name="tab-group-2">
                2

                            2

               <input type="radio" id="tab-6" name="tab-group-2">
               3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

3

               <input type="radio" id="tab-7" name="tab-group-2">
               4

                            4

The CSS used for this particular page is:
#a_extra_info, #a_evidence, #a_comments, #a_supporters{
padding:30px;
}

#a_extra_info{
background-color: #E29FA4;
}

#a_evidence{
background-color: #B98489;
}

#a_comments{
background-color: #845F64;
}

#a_supporters{
background-color: #5E4549;
}

#a_extra_info_inner, #a_evidence_inner, #a_comments_inner, #a_supporters_inner{
background-color: #FFF;
/*padding: 10px;*/
}

#a_extra_info_inner span, #a_extra_info_inner label, #a_evidence_inner span, #a_evidence_inner label, #a_comments_inner span, #a_comments_inner label, #a_supporters_inner span, #a_supporters_inner label{
color: #000;
}

.tabs {
position: relative;
min-height: 276px; /* This part sucks */
clear: both;
}
.tab {
float:left;
width: 25%;
}
.tab > label {
text-align: center;
position: relative;
height:30px;
line-height: 30px;
font-weight: normal;
font-size: 100%;
cursor: pointer;
margin:0;
}
.tab [type=radio] {
display: none;
}
.tab_content {
position: absolute;
top: 28px;
left: 0;
right: 0;
bottom: 0;
}
[type=radio]:checked ~ label {
z-index: 2;
}
[type=radio]:checked ~ label ~ .tab_content {
    z-index: 1;
}

#a_tab_one{
background-color: #E29FA4;
color:#000;
}
#a_tab_two{
background-color: #B98489;
color:#000;
}
#a_tab_three{
background-color: #845F64;
}
#a_tab_four{
background-color: #5E4549;
}

Is there a solution for this? Please see the link for a better view of the problem.
Thanks

A: set this style on your outer div id or class whatever you have
#ambition_container{
    background-color: #461f20;
    padding:20px 10px 10px 10px;
    position:relative;
    height:100%;
    overflow-y:auto;
    display:block
}

A: you must change like this
for tabs

css of tabs
.tabs {
    clear: both;
    height: 30px;
    position: relative;
}

and place content after tabs in content div

Place Content of tab 1

Place Content of tab 2

A: #ambition_container, #tabs{
overflow:hidden;
}

Add this rules on your CSS stuff.


text:
Q: FOR EACH STATEMENT trigger example I've been looking at the documentation of postgresql triggers, but it seems to only show examples for row-level triggers, but I can't find an example for a statement-level trigger.
In particular, it is not quite clear how to iterate in the update/inserted rows in a single statement, since NEW is for a single record.

A: OLD and NEW are null or not defined in a statement-level trigger. Per documentation:

NEW
Data type RECORD; variable holding the new database row for INSERT/UPDATE operations in row-level triggers. This variable is
null in statement-level triggers and for DELETE operations.

OLD
Data type RECORD; variable holding the old database row for UPDATE/DELETE operations in row-level triggers. This variable is null in statement-level triggers and for INSERT operations.

Bold emphasis mine.
Up to Postgres 10 this read slightly different, much to the same effect, though:

... This variable is unassigned in statement-level triggers. ...

While those record variables are still of no use for statement level triggers, a new feature very much is:
Transition tables in Postgres 10+
Postgres 10 introduced transition tables. Those allow access to the whole set of affected rows. The manual:

AFTER triggers can also make use of transition tables to inspect the entire set of rows changed by the triggering statement.
The CREATE TRIGGER command assigns names to one or both transition
tables, and then the function can refer to those names as though they
were read-only temporary tables. Example 43.7 shows an example.

Follow the link to the manual for code examples.
Example statement-level trigger without transition tables
Before the advent of transition tables, those were even less common. A useful example is to send notifications after certain DML commands.
Here is a basic version of what I use:
-- Generic trigger function, can be used for multiple triggers:
CREATE OR REPLACE FUNCTION trg_notify_after()
  RETURNS trigger
  LANGUAGE plpgsql AS
$func$
BEGIN
   PERFORM pg_notify(TG_TABLE_NAME, TG_OP);
   RETURN NULL;
END
$func$;

-- Trigger
CREATE TRIGGER notify_after
AFTER INSERT OR UPDATE OR DELETE ON my_tbl
FOR EACH STATEMENT
EXECUTE PROCEDURE trg_notify_after();
For Postgres 11 or later use the equivalent, less confusing syntax:
...
EXECUTE FUNCTION trg_notify_after();

See:

*

*Trigger function does not exist, but I am pretty sure it does

A: Well, here are some examples of statement-level triggers.
Table:
CREATE TABLE public.test (
    number integer NOT NULL,
    text   character varying(50)
);

Trigger function:
OLD and NEW are still NULL
The return value can also be always left NULL.
CREATE OR REPLACE FUNCTION public.tr_test_for_each_statement()
   RETURNS trigger
   LANGUAGE plpgsql
AS
$$
DECLARE
    x_rec record;
BEGIN
    raise notice '=operation: % =', TG_OP;
    IF (TG_OP = 'UPDATE' OR TG_OP = 'DELETE') THEN
        FOR x_rec IN SELECT * FROM old_table LOOP
            raise notice 'OLD: %', x_rec;
        END loop;
    END IF;
    IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
        FOR x_rec IN SELECT * FROM new_table LOOP
            raise notice 'NEW: %', x_rec;
        END loop;
    END IF;

    RETURN NULL;
END;
$$;

Settings statement-level triggers
Only AFTER and only one event is supported.
CREATE TRIGGER tr_test_for_each_statement_insert
   AFTER INSERT ON public.test
   REFERENCING NEW TABLE AS new_table
   FOR EACH STATEMENT
   EXECUTE PROCEDURE public.tr_test_for_each_statement();

CREATE TRIGGER tr_test_for_each_statement_update
   AFTER UPDATE ON public.test
   REFERENCING NEW TABLE AS new_table OLD TABLE AS old_table
   FOR EACH STATEMENT
   EXECUTE PROCEDURE public.tr_test_for_each_statement();

CREATE TRIGGER tr_test_for_each_statement_delete
   AFTER DELETE ON public.test
   REFERENCING OLD TABLE AS old_table
   FOR EACH STATEMENT
   EXECUTE PROCEDURE public.tr_test_for_each_statement();

Examples:
INSERT INTO public.test(number, text) VALUES (1, 'a');

=operation: INSERT =
NEW: (1,a)

INSERT INTO public.test(number, text) VALUES (2, 'b'),  (3, 'b');

=operation: INSERT =
NEW: (2,b)
NEW: (3,b)

UPDATE public.test SET number = number + 1 WHERE text = 'a';

=operation: UPDATE =
OLD: (1,a)
NEW: (2,a)

UPDATE public.test SET number = number + 10 WHERE text = 'b';

=operation: UPDATE =
OLD: (2,b)
OLD: (3,b)
NEW: (12,b)
NEW: (13,b)

DELETE FROM public.test;

=operation: DELETE =
OLD: (2,a)
OLD: (12,b)
OLD: (13,b)


text:
Q: MS Access cannot connect to SAP "Cannot load LibRfc32.dll" error - VBA - SAP NOTE: StackOverflow should allow more links in the question part.  This is a rabbit hole with a rabbit hole question for a 25 year old technology.  None of the technologies have been supported for over 10 years.  Including comprehensive list of links with short summary of each one is appropriate as most will be removed within a few years. It's short-sited of StackOverflow users to ignore the "StackOverflow limits the number of links in a question and just delete the extra links provided in responses.
At 60+ hours into working this issue, I wanted to provide the next unlikely person the best set of information for resolving the problem.
How to fix librfc32.dll cannot be loaded error when calling from Microsoft Access 365?
I've tried the common troubleshooting steps found on the net as listed below and need help.
Note: This is a 25 year old complex large application and I cannot upgrade to a newer version than SAP GUI 7.40 as it is required for other applications.  I cannot rewrite the web service call inside Access VBA as it is specifically excluded from my project.  This is an Access 10 to Access 365 update project and has no time allocated for rewriting.
Note: This is a server machine and I cannot install DependencyWalker, Visual Studio or other diagnostic tools.
I get this error in Microsoft Access 365 when trying to send data to SAP using librfc32.dll:

Unable to load DLL 'librfc32.dll'  The specified module could not be found.(Exception from HRESULT 0x8007007E)

The error is that librfc32.dll or one of the DLLs it depends on cannot be loaded.
Platform:

*

*Windows Server 2016, 64 bit

*Microsoft Access 365 32 bit

*SAP GUI 7.40 patch level 13 front end tools application - SAP NetWeaver v7400.3.13.1130 - build 1756678 - patch level 13

*Librfc32.dll is part of the SAP 7.40 GUI front end tools application

Notes:

*

*We can't upgrade to SAP GUI 7.5 or later because it is used by other applications on the same machine

*The MSAccess application is just upgraded from MSAccess 2010

*The MSAccess application does not have any dependencies set for SAP DLLs or OCX files

*Librfc32.dll depends on these other DLLs base on "dumpbin.exe /dependents  librfc32.dll". Dumpbin.exe is part of Visual Studio 2019.  Visual Studio 2019 is not installed on the machine having the cannot load DLL error.

*Librfc32.dll dependencies - All of them are in C:\Windows\SysWow64. ole32.dll, RPCRT4.dll, OLEAUT32.dll, KERNEL32.dll, ADVAPI32.dll, USER32.dll, WS2_32.dll, IPHLPAPI.DLL, NETAPI32.dll, SHELL32.dll, dbghelp.dll, VERSION.dll, MSVCR110.dll

What we have tried so far and all gave the same cannot load DLL error:

*

*Trial 1 - Run MSAccess application before SAP GUI 7.40 is installed

*Trial 2 - Install SAP GUI 7.40

*Trial 3 - In MSAccess application, add reference to C:\Windows\SysWow64\librfc32.dll

*Trial 4 - Register librfd32.dll using "regsvr32 librfc32.dll"

*Trial 5 - In MSAccess application, add references to the following DLLs from the SAP GUI application. This is from a similar Access 2010 SAP GUI 7.20 question from 2009 here
and all of the DLLs exist on the machine having the error: https://answers.sap.com/questions/6537228/access-calls-sap-rfc-function-modules.html

*

*regsvr32 c:\program files (x86)\sap\frontend\sapgui\wdobapi.ocx

*regsvr32 c:\program files (x86)\common files\sap shared\wdtlog.ocx

*regsvr32 c:\windows\SysWOW64\librfc32.dll

*regsvr32 c:\program files (x86)\sap\frontend\sapgui\wdtaocx.ocx

*regsvr32 c:\program files (x86)\sap\frontend\sapgui\wdtfuncs.ocx

*Trial 6 - Examine the Windows event logs.  Run the MSAccess application and produce the error message. Examine the Windows event logs again.  No messages were found related to this error

*Trial 7 - Copy librfc32.dll and librfc32u.dll to the Microsoft Office executable directory where MSAccess.exe is located

*Trial 8 - Add C:\Windows\SysWow64 to PATH environment variable did not work. Start DOS, "SET PATH=%PATH%;C:\Windows\SysWow65; and then run MSAccess from the DOS command line

*Trial 9 - Verified that msvcr110.dll, msvcp110.dll, MFC*.dll are in C:\Windows\SysWow64. Dumpbin.exe shows v110 of these DLLs as needed by librfc32.dll. This was referenced by https://answers.sap.com/questions/3505999/librfc32dll-not-found-on-windows-server-2003.html
Related reference links to similar problems with librfc32.dll.  Note that these are up to 15 years old and many of the suggestions are for out of date applications.

*

*Access calls SAP-RFC-function modules – September 23, 2009 - https://answers.sap.com/questions/6537228/access-calls-sap-rfc-function-modules.html
This is about registering DLLs and OCXs

*https://docs.oracle.com/cd/E28280_01/doc.1111/e16597/app_librfc.htm#SAPBW222

*https://pocketprograms.com/kb/when-i-connect-to-sap-i-get-the-error-librc32-dll-not-found/

*https://www.google.com/search?source=hp&ei=83KQX6iiAoXYsAW5-p64DQ&q=librfc32.dll&oq=librfc32.dll&gs_lcp=CgZwc3ktYWIQAzIFCAAQyQMyAggAMgIIADICCAAyBAgAEB4yBAgAEB4yBAgAEB4yBAgAEB4yBAgAEB4yBAgAEB46DgguELEDEMcBEKMCEJMCOgUIABCxAzoICC4QxwEQowI6BQguELEDOgsILhCxAxDHARCjAjoICC4QsQMQgwE6AgguOggIABCxAxDJAzoFCAAQkgM6CAgAELEDEIMBOgQIABAKOgoIABCxAxDJAxAKOgcIABCxAxAKOgoIABCxAxCDARAKUE1Y5Bxgih9oAHAAeACAAbYBiAGCCJIBBDExLjGYAQCgAQGqAQdnd3Mtd2l6&sclient=psy- ab&ved=0ahUKEwjo5_PvncbsAhUFLKwKHTm9B9cQ4dUDCAg&uact=5

*Sap Logon Control - SAP Q&A - https://answers.sap.com/questions/13152769/sap-logon-control-2.html

*https://answers.sap.com/questions/913490/librfc32dll.html?childToView=915447#comment-915447
I posted on StackOveflow after trying many many workarounds and reviewing over 50 web pages.  I'd like to include some of the more close to this question links in this question but am limited with a too many links error.

A: librfc32.dll is the classic RFC library which was also part of the classic RFC SDK. It was also shipped with former SAP GUI releases and other products.
But meanwhile the classic RFC library and the classic RFC SDK is out of maintenance and support at SAP. You won't get new releases or updates of this library anymore.
Which Visual C runtime libraries are required for this library depends on the SAP release which the librfc32.dll originates from and the bit width of the library (32-bit vs. 64-bit). Note that you always need the same bit width for all dynamically loaded libraries which must fit to the bit width of your main program that loads these libraries. So check if your MS Access executables are 32-bit or 64-bit programs.
Despite its name the librfc32.dll exists as 32-bit library and also as 64-bit library.
In Windows directory SysWOW64 you will usually find 32-bit libraries whereas in directory system32 of a 64-bit Windows installation you will find the 64-bit libraries [Thank you Microsoft for that naming convention]. :)
Anyhow you do not need the librfc32u.dll which is the Unicode version of this library. You cannot use both in one process. Either your code is compiled for Unicode or it is not, and since you try to load librfc32.dll it seems to be compiled for a non-Unicode runtime.


text:
Q: How to make a column from index? I have a list called partylist which prints the following.
Index(['AAAP', 'AABHAP', 'AACP', 'AAHPty', 'AAM', 'AAPP', 'ABD', 'ABEP',
       'ABGP', 'ABHM',
       ...
       'kajp', 'mimm', 'pjdl', 'rajpt', 'ravp', 'rpsn', 'skd', 'ssrd', 'svjn',
       'swbi'],
      dtype='object', name='PARTY', length=671)

I tried using reset_index
newlist = partylist.reset_index(level=['PARTY'], inplace=True)

but got an error

AttributeError                            Traceback (most recent call
last)
/var/folders/l9/6n1gmxmx515cfndb3gm2cyv40000gn/T/ipykernel_12124/2959807225.py
in
----> 1 newlist = partylist.reset_index(level=['PARTY'], inplace=True)
AttributeError: 'Index' object has no attribute 'reset_index'

How can I solve it and make a column list of the partylist?

A: Looks like you ran this line at some point:
df = df.set_index('PARTY')

Since the name='PARTY' bit is there you can make the index a column again with:
df = df.reset_index()

If you want to rename the index (say to 'PARTYLIST') and move it to a column try:
df = df.reset_index().rename(columns={df.index.name:'PARTYLIST'})

The above assumes your dataframe is called df - change as required.

A: I think your error is reproducible with this code
df = pd.DataFrame({1: [1,2,3]})
df.index = ['A', 'B', 'C']
df.index.reset_index()

You are calling reset_index() on an Index object - as the error says it doesn't have that attribute. That's because this method is for dataframes as per the docs.
To create a column containing the index object contained in your partylist variable, you need to first convert it to a list and then assign it to a column with this syntax:
df['your_column'] = list(partylist)


text:
Q: Select data of all datetimes I currently have two queries, one which displays all data (regardless of time), another which considers a time frame. I'm trying to condense these together and was wondering if mysql has something for dateTimes which acts as an "allTime" variable, that is when plugged into:
select count(*) from table where (color = "red") and (dateMade between "allTime" and "allTime");
would display the row count of where color is red, for all rows in the table. A solution I thought of was to just use a minimum date of 0000-01-01 00:00:00 and some large end bound date, but if there already exists something to solve this I thought I might as well use that.
EDIT: This would be used on more than just the example query above, with most being much longer and more complex. The purpose is to combine this with node to make functions simpler and not have to consider a special case of all data, rather just use the time frame query and return all data based on the bounds given as arguments

A: Fill the variables @from and/or @to with NULL, if you don't want to restrict the data. Use IFNULL to check if the restriction is to be applied or not.
select count(*)
from table
where color = @color
and datemade between ifnull(@from, datemade) and ifnull(@to, datemade);

A: For cases when you don't need the date range you could make part of the where clause a true-ish noop:
select ...
from tablename
where date_created between $start and $end or $start = $end

Then, if you need the unbounded query, just pass the same $start and $end to it.

A: Don't pass the data twice unless you really have to, you could use a "conditional aggregation" instead, e.g.
select
    count(*) all_count
  , count(case when dateMade between @start and @end then id end) period_count
from table
where (color = "red")

To get "all time" you simply do not filter by date range in the where clause.
Note too that COUNT() function increments for any non-null value it encounters, so for the case expression it should return a column that will always be present in a row such as the primary key.
An alternative is to use SUM() instead, like this
select
    count(*) all_count
  , sum(case when dateMade between @start and @end then 1 else 0 end) period_count
from table
where (color = "red")


text:
Q: How to highlight specific
* element? i am trying to learn react at the moment and i can't find a solution for following problem:
I am fetching some .json data which look like that:
[ {
"answerOptions": [
  "Answer A",
  "Answer B",
  "Answer C",
  "Answer D",
],
"correctAnswer": 1
},
{
"answerOptions": [
  "Answer A",
  "Answer B",
  "Answer C",
  "Answer D",
  "Answer E",
  "Answer F",
],
"correctAnswer": 4
}, {..}, {..} ]

Now i want to highlight the correct answer (i.e bold) but i don't know how to tell react what li element should be highlighted....

 {
    props.answerOptions.map((answer) => (
       <AnswerDetails
          key={answer}
          answerOptions={answer}
        />
    ))
  }

import './AnswerDetails.css';

const AnswerDetails = (props) => {

    return (

       {props.answerOptions}

     );
 }

export default AnswerDetails;

Maybe someone of you has a small hint for me :)
Greetz

A: you can alse add corrent into props.

 {
    props.answerOptions.map((answer, index) => (
       <AnswerDetails
          key={answer}
          answer={answer}
          index={index}
          corrent={props.correctAnswer}
        />
    ))
  }

import './AnswerDetails.css';
import classNames from 'classnames';

const AnswerDetails = (props) => {
  return

   {props.answerOptions}

;
};

export default AnswerDetails;

A: Just loop over the items in the array and map them to styled
 elements.

const { useState } = React;

const answers = [{
  "answerOptions": [
    "Answer A",
    "Answer B",
    "Answer C",
    "Answer D",
  ],
  "correctAnswer": 1
}, {
  "answerOptions": [
    "Answer A",
    "Answer B",
    "Answer C",
    "Answer D",
    "Answer E",
    "Answer F",
  ],
  "correctAnswer": 4
}];

const AnswerDetails = ({ answerOptions, correctAnswer }) => (

      {answerOptions.map((answerOption, index) => (

          {answerOption}

      ))}

)

const Answers = ({ answers }) => (

    {answers.map(({ answerOptions, correctAnswer }, index) => (
      <AnswerDetails
        key={JSON.stringify(answerOptions)+correctAnswer}
        correctAnswer={correctAnswer}
        answerOptions={answerOptions}
      />
    ))}

);

const App = () => (

    <Answers answers={answers} />

);

ReactDOM
  .createRoot(document.getElementById("root"))
  .render(<App />);
.question { list-style-type: decimal-leading-zero; }
.answers { list-style-type: upper-alpha; }
.answers { margin-bottom: 1em; }
.correct { font-weight: bold; color: green; }

A: Remember javascript arrays are zero-based indexed. Assuming "correctAnswer" corresponds to the ordered-list of "answerOptions", you can write it like this.
answers.json

{
  "answers": [
    {
      "answerOptions": ["Answer A", "Answer B", "Answer C", "Answer D"],
      "correctAnswer": 1
    },
    {
      "answerOptions": [
        "Answer A",
        "Answer B",
        "Answer C",
        "Answer D",
        "Answer E",
        "Answer F"
      ],
      "correctAnswer": 4
    }
  ]
}

import json from "./answers.json";

const { answers } = json;

export default function App() {
  return (

      <AnswerDetails answers={answers} />

  );
}

const AnswerDetails = (props) => {
  return (

      {props.answers.map(({ answerOptions, correctAnswer }, index) => (
        <AnswerComponent
          key={index}
          options={answerOptions}
          correctAnswer={correctAnswer}
        />
      ))}

  );
};

const AnswerComponent = (props) => {
  return (

      {props.options.map((option, index) => (

          {option}

      ))}

  );
};


text:
Q: Creating Date Object by parsing select_date form helper only works sometimes Here is the relevant part in the form:
<%= select_date(@end_date, {order: [:month, :day, :year], start_year: 2009, end_year: Time.now.year, prefix: "end_date"},{class: "form-control date-select"} ) %>

Here is what is passed through the params when the form is submitted:
=> {"utf8"=>"✓",
 "authenticity_token"=>"123",
 "end_date"=>{"month"=>"8", "day"=>"25", "year"=>"2014"},
 "commit"=>"Submit",
 "controller"=>"some_controller",
 "action"=>"some_action"}

And in the controller here is how I create the date object from the params:
Date.parse params["end_date"].values.join("-")

The odd thing is that it only works sometimes.  For example, when the user selects the date above (August 25th, 2015), It comes up with the following error:
invalid date

And it highlights the area where I am parsing the date:
Date.parse params["end_date"].values.join("-")

A: So, this expression:
params["end_date"].values.join("-")

Will give you string '8-25-2014'. When parsing date, ruby is trying to guess the format you are using, and in this case it uses dd-mm-yyyy. That means that what you think is 10th of November will be read by Ruby as 11th of October (which is even worse than an exception while getting 25th month).
Best solution - do not use parse. You already know the values, why give a parser opportunity to make a mistake?
Date.new *params[:end_date].values_at(:year, :month, :day).map(&:to_i)

Note: You will still need to wrap the code above in begin rescue as your users can (and will) pick dates like 31 of Feb.


text:
Q: Remove Parent Element with Child Element I am trying to remove a div when a user clicks on the remove button, but as of now it only removes the button, how can I make it remove the entire div that it is held in? I have added my attempt below, as you can see I remove the button and attempt to remove the entire div that it is held in but I have not been able to. I have tried to remove the parentElement but that did not work either, I am not sure what I have done wrong.

var noteCount = 0;

function addNote(style) {

  const notesBox = document.getElementById('notesBox');
  var noteBoxes = document.createElement('div');
  textarea = document.createElement('textarea'),
    remove = document.createElement('button'),
    today = new Date(),
    txt = document.createTextNode('' + today.toLocaleDateString() + ' ' + today.getHours() + ':' + today.getMinutes());

  notesBox.appendChild(noteBoxes);

  noteBoxes.setAttribute('class', style);
  noteBoxes.className = 'noteBoxes';
  noteBoxes.setAttribute('id', style);
  noteBoxes.id = 'note box ' + noteCount;
  noteBoxes.appendChild(textarea);
  noteBoxes.appendChild(remove);

  textarea.appendChild(txt);
  textarea.setAttribute('class', style);
  textarea.className = 'notesE';
  textarea.setAttribute('id', style);
  textarea.id = 'note' + noteCount;

  remove.setAttribute('class', style);
  remove.className = 'removeNote';
  remove.setAttribute('id', style);
  remove.id = '-Note' + noteCount;
  remove.onclick = function() {
    this.parentElement.removeChild(this);
    this.noteBoxes.removeChild(this.noteBoxes);
  }
  noteCount++;
  console.log(textarea.id);

}

Notes

  <button class="options" onclick="addNote()" style="margin-bottom: 10px;">add</button>

        <textarea class="notesE"></textarea>
        <button class="removeNote"></button>

A: You need to use this line of code:
this.parentElement.remove();

instead of
this.parentElement.removeChild(this);
this.noteBoxes.removeChild(this.noteBoxes);

What are you doing wrong?
You're selecting the current element's parent's child which is itself (the button you're clicking). That's why it is removing the button instead of it's parent that is the div container.

var noteCount = 0;

function addNote(style) {

  const notesBox = document.getElementById('notesBox');
  var noteBoxes = document.createElement('div');
  textarea = document.createElement('textarea'),
    remove = document.createElement('button'),
    today = new Date(),
    txt = document.createTextNode('' + today.toLocaleDateString() + ' ' + today.getHours() + ':' + today.getMinutes());

  notesBox.appendChild(noteBoxes);

  noteBoxes.setAttribute('class', style);
  noteBoxes.className = 'noteBoxes';
  noteBoxes.setAttribute('id', style);
  noteBoxes.id = 'note box ' + noteCount;
  noteBoxes.appendChild(textarea);
  noteBoxes.appendChild(remove);

  textarea.appendChild(txt);
  textarea.setAttribute('class', style);
  textarea.className = 'notesE';
  textarea.setAttribute('id', style);
  textarea.id = 'note' + noteCount;

  remove.setAttribute('class', style);
  remove.className = 'removeNote';
  remove.setAttribute('id', style);
  remove.id = '-Note' + noteCount;
  remove.onclick = function() {
    this.parentElement.remove();
  }
  noteCount++;
  console.log(textarea.id);

}

Notes

  <button class="options" onclick="addNote()" style="margin-bottom: 10px;">add</button>

        <textarea class="notesE"></textarea>
        <button class="removeNote">Remove</button>

A: Create a new attribute to the button and set its value as the parent div. On click of the button get this value. Since this value is same as the id of the parent , use it to remove from the dom.Also not the id of each element need to be unique

var noteCount = 0;

function addNote(style) {

  const notesBox = document.getElementById('notesBox');
  var noteBoxes = document.createElement('div');
  textarea = document.createElement('textarea'),
    remove = document.createElement('button'),
    today = new Date(),
    txt = document.createTextNode('' + today.toLocaleDateString() + ' ' + today.getHours() + ':' + today.getMinutes());

  notesBox.appendChild(noteBoxes);

  noteBoxes.setAttribute('class', style);
  noteBoxes.className = 'noteBoxes';
  noteBoxes.setAttribute('id', style);
  noteBoxes.id = 'noteBoxes' + noteCount;
  noteBoxes.appendChild(textarea);
  noteBoxes.appendChild(remove);

  textarea.appendChild(txt);
  textarea.setAttribute('class', style);
  textarea.className = 'notesE';
  textarea.setAttribute('id', style);
  textarea.id = 'note' + noteCount;

  remove.setAttribute('class', style);
  remove.className = 'removeNote';
  remove.setAttribute('id', style);
  remove.id = '-Note' + noteCount;
  // adding a new attribute to data-parent-id
  remove.setAttribute('data-parent-id', 'noteBoxes' + noteCount);

  remove.onclick = function() {
    // get the id of the parent on click
    var getParentId = this.getAttribute('data-parent-id')
    document.getElementById(getParentId).remove();
  }
  noteCount++;
  console.log(textarea.id);

}

Notes

  <button class="options" onclick="addNote()" style="margin-bottom: 10px;">add</button>

        <textarea class="notesE"></textarea>
        <button class="removeNote"></button>


text:
Q: Resize image width and scale height accordingly I'm coding an uploading script, and I'm currently using a way of resizing images with gd which works good in general. The only issue is that when users upload portrait images, they align to center and the parts outside the canvas gets cut off. I've added a check to identify if the image is portait or not, but now I need to adjust some code to manipulate the portait images to the way I need them.
For instance, if I upload an image with a resolution of 2000x3000 pixels, I need the following to be done:

*

*Automaticly scale the width to 800px.

*Scale the height accordingly to the new width, keeping the original ratio.

I've managed to scale it, but it just keeps the original resolution, which is not the wanted effect. Maybe someone here could help me out?
Thanks in advance //
Jonathan
EDIT: I managed to solve it by using my old technique, and just change the dimensions when the uploaded image orientation was portait. Thanks for your answers!

A: simple scaling function
function img_scale($source,$width,$height,$extra='border=0')
{
     $w=$width;
     $h=$height;
     $size = @getimagesize($abu_source);
    if($w > $size[0] && $h > $size[1] )
    {
        $neww = $size[0];//$w;
        $newh = $size[1];//$h;
    }
    else if( $w < $size[0] && $h > $size[1] )
    {
        $diff=$size[0]-$w;
        $dec_per=(100*$diff)/$size[0];
        $neww=$size[0]-(($size[0]*$dec_per)/100);
        $newh=$size[1]-(($size[1]*$dec_per)/100);
    }
    else if( $w > $size[0] && $h < $size[1] )
    {
        $diff=$size[1]-$h;
        $dec_per=(100*$diff)/$size[1];
        $newh=$size[1]-(($size[1]*$dec_per)/100);
        $neww=$size[0]-(($size[0]*$dec_per)/100);
    }
    else//( $w < $size[0] && $h < $size[0] )
    {
        if( ($size[0]-$w) >= ($size[1]-$h))
        {
            $diff=$size[0]-$w;
            $dec_per=(100*$diff)/$size[0];
            $neww=$size[0]-(($size[0]*$dec_per)/100);
            $newh=$size[1]-(($size[1]*$dec_per)/100);
            $cc='w';
        }
        else
        {
            $diff=$size[1]-$h;
            $dec_per=(100*$diff)/$size[1];
            $newh=$size[1]-(($size[1]*$dec_per)/100);
            $neww=$size[0]-(($size[0]*$dec_per)/100);
            $cc='h';
        }
    }
    return "<img src='".$source."' width='".$neww."' height='".$newh."'  ".$extra." >";
}


text:
Q: What does 'rich user interface' mean? What exactly is meant by the term "rich user interface"?
Does it mean the same thing when referring to user-interfaces as it does when referring to, say, communications frameworks?
Does it imply that a user-interface can be "poor"? (as in the opposite of rich, not as in poorly designed)

A: From Wiktionary.

(computing) Elaborate, having complex formatting, multimedia, or depth of interaction.

A: rich | not so rich
Note: "rich" is not necessarily the same as "better".

A: Looking at the current browser Netflix User Interface (May of 2016 version), I would consider this a rich user interface due to several characteristics.

It is a pretty good front end to an elaborate database of information about movies and television shows. The UI allows a user to select a particular resource, movie or television show, and to then see information about the resource. This screen shot shows the result of looking for additional information about a particular show. The bright white links of cast member names and the categories that Netflix uses gives the opportunity to find other resources by the cast members or other resources categorized similarly.
The resource can be started by clicking the standard play icon, right pointed triangle surrounded by a circle, or you can click on the EPISODES link to pick a particular episode.
Netflix remembers where you left off, at least in most cases (I have seen it want to start with Season 1 again when a new season is added), so the video player will pick the current or next episode, in the case of a TV show, or pickup at the last point of viewing in the case of a movie.
When viewing a resource near the end of the footage, Netflix will automatically queue up the next episode or will present some suggestions.
The mechanism to arrive at the presentation of the details of a show is reused in a couple of places within the user interface though in some cases, such as the list from MORE LIKE THIS, it does not seem to be used and clicking on the movie/show image from the MORE LIKE THIS list starts the resource.
The major characteristic that I see here is that a large and complex database that contains various video resources is presented in a way that allows a person to find a particular resource by using the search or by browsing around. A person can look around in the database and travel along various semantic connections between resources. So you can look for other resources by the same cast members or director/producer or you can look for other resources in categories associated with a particular resource.
It seems that the Netflix UI provides access the the library of resources using fairly standard web page affordances.
My only dislike for the Netflix browser UI is that it is heavily mouse based. The result is that people with poor hand eye coordination such as the elderly can have a difficult time positioning the mouse and doing clicks.
I have seen people have difficulty using the UI as it requires moving the mouse over a particular resource image and holding it there to activate the zoom in effect which then provides access to the down arrow affordance for accessing information about the resource. Moving the mouse precisely and holding it steady and then doing a click without moving the mouse cursor can be difficult for people with shaky hands and poor motor skills.

A:

A: In my understanding, it generally implies that the UI can do "heavy" things.
Compare clicking a link, waiting, and getting a full-screen refresh containing new information, to clicking a link, and having the new information pop up, perhaps even animate into view, right there.
More features, faster responses, and more "eye candy" are some of the things I associate with the term.

A: A "rich" user interface is a web term which describes the next generation of Web interfaces. In the old days, HTML Web Pages were static bodies of text with some images and not a whole lot of interactivity.
The Web today is completely different...with pages providing different levels of interactivity. A "rich" user interface strives to provide the user with a highly interactive, highly stylized, highly usable interface whereas a traditional web application might have been clunky and required numerous page refreshes to complete a task.


text:
Q: Using a for-each loop to return largest value in arraylist I'm having trouble writing a for-each loop that searches the arraylist and returns the county's name within the continent that has the highest gdp. Here's my code for it right now. (ElementsList is the original ArrayList)
public Country highestGdp(String continent) {
    boolean flag;
    for (Country cont : ElementsList) {
        if (cont.getContinent().equals(continent)) {
            ArrayList<Country> TMP1 = new ArrayList<Country>();
            TMP1.add(cont);
            for (Country gdp : TMP1) {
                double max = 0;

                if (max < gdp.getGDP()) {
                    max = gdp.getGDP();

                }
                if (gdp.getGDP() == max) {
                    ArrayList<Country> TMP2 = new ArrayList<Country>();
                    TMP2.add(gdp);
                }
                return gdp;
            }
        }
    }
    return null;
}

A: Each time you find a country in the right continent, you can check to see if it is greater than the max so far. Don't need to loop through all of them each time.
public Country highestGdp(String continent) {
    boolean flag;
    Country maxCountry = null;
    for (Country cont : ElementsList) {
        if (cont.getContinent().equals(continent)) {
            if (maxCountry == null) maxCountry = cont;
            if (maxCountry.getGDP() < gdp.getGDP()) {
                maxCountry = cont;
            }
        }
    }
    return maxCountry;
}

A: Sorry for saying it but Your code is a little messy ;)
To shortly solve Your problem, try to move max declaration before the loop like this:
[...]
double max = 0;
for(Country gdp : TMP1){
[...]

We can see that TMP2 is completely useless, remove it:
 // ArrayList<Country> TMP2 = new ArrayList<Country>();
 // TMP2.add(gdp);

You create TMP1 list always with only 1 element and then iterate over it. This is also useless, You can do the code directly on the element You are adding to the list.
First iteration over ElementList is a list of Country elements, but the element You iterate is called cont (=continent) which is a Continent and not the Country. Is it intended to use Country class to cover both: Countries and Continents? Do You plan to have a tree structure like "Continents contains many Countries"?
Final code to solve problem from Your original question should be like this:
 public Country highestGdp(String continent){
    Country countryWithMaxGdp = null;
        for(Country cont: ElementsList ){
        if(cont.getContinent().equals(continent)){
           if(countryWithMaxGdp == null || countryWithMaxGdp.getGDP() < cont.getGDP()){
             countryWithMaxGdp = cont;
            }
        }
    }
    return countryWithMaxGdp;
 }


text:
Q: Java Rock Paper Game Loops Too Many Times I had to make a rock paper scissors game, where you play against the computer. 1,2,3 are used for rock, paper, scissors.It loops 5 times, and shows the amount of computer wins and player wins. I got everything to work, except for the looping. When you put a number higher than 3, it's suppose to say "Invalid" and loop until you play 5 valid games. However if you you put an odd amount of wrong answers, it makes you play 6 games, and if you put an even amount of wrong answers, it makes you play 5 games. I need it to make you play 5 games regardless of odd and even amounts wrong. Please help.
public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    int player = 0, computer = 0;
    int computerScore = 0, playerScore = 0;
    int loops = 0;

    int rock = 1;
    int paper = 2;
    int scissors = 3;

    for (int i = 1; i < 6; i++) {

        computer = (int) (Math.random() * 3) + 1;
        System.out.println("Enter 1 for Rock, 2 for Paper, 3 for Scissors");
        player = reader.nextInt();

        if (player > scissors) {
            System.out.println("Not a valid response");
            System.out.println("Enter 1 for Rock, 2 for Paper, 3 for Scissors");
            player = reader.nextInt();
            i--;

        }

        if (player == computer) {
            System.out.println("Tie");
        } else if (player == rock) {

            if (computer == paper) {
                System.out.println("Player picked Rock, Computer picked Paper, Computer wins");
                computerScore++;
            } else if (computer == scissors) {
                System.out.println("Player picked Rock, Computer picked Scissors, Player wins");
                playerScore++;
            }
        } else if (player == paper) {

            if (computer == rock) {
                System.out.println("Player picked Paper, Computer picked Rock , Player wins");
                playerScore++;
            } else if (computer == scissors) {
                System.out.println("Player picked Paper, Computer picked Scissors, Computer wins");
                computerScore++;
            }
        } else if (player == scissors) {
            if (computer == rock) {
                System.out.println("Player picked Scissors, Computer picked Rock , Computer wins");
                computerScore++;
            } else if (computer == paper) {
                System.out.println("Player picked Scissors, Computer picked Paper, Player wins");
                playerScore++;
            }

        }

    }
    System.out.println("");
    System.out.println("Computer Wins " + computerScore);
    System.out.println("Player Wins " + playerScore);

}

A: To make things easier, I suggest using a while loop.
E.G:
Scanner reader = new Scanner (System.in);
int computerScore = 0, playerScore = 0;

int rock = 1;
int paper = 2;
int scissors = 3;
int numberOfPlayerTurns = 0;

final int MAX_PLAYER_TURNS = 5;
while (numberOfPlayerTurns < MAX_PLAYER_TURNS)
{
    int computer = (int) (Math.random() * 3) + 1;
    int player = reader.nextInt();
    System.out.println("Enter 1 for Rock, 2 for Paper, 3 for Scissors");

    // invalid
    if (player > scissors || player <= 0)
    {
        System.out.println("Not a valid response");
    }
    else
    {
        numberOfPlayerTurns++;

        if (player == computer)
        {
            System.out.println("Tie");
        }
        else if (player == rock )
        {
            if(computer == paper)
            {
                System.out.println ("Player picked Rock, Computer picked Paper, Computer wins");
                computerScore++;
            }
            else
            {
                System.out.println ("Player picked Rock, Computer picked Scissors, Player wins");
                playerScore++;
            }
        }
        else if (player == paper)
        {
            if(computer == rock)
            {
                System.out.println ("Player picked Paper, Computer picked Rock , Player wins");
                playerScore++;
            }
            else
            {
                System.out.println ("Player picked Paper, Computer picked Scissors, Computer wins");
                 computerScore++;
            }
        }
        // scissors
        else
        {
            if(computer == rock)
            {
                System.out.println ("Player picked Scissors, Computer picked Rock , Computer wins");
                computerScore++;
            }
            else
            {
                System.out.println ("Player picked Scissors, Computer picked Paper, Player wins");
                playerScore++;
            }
        }
    }
}
System.out.println("");
System.out.println("Computer Wins " + computerScore);
System.out.println("Player Wins " + playerScore);


text:
Q: Logging out and in on OS X takes 4-5 minutes? I've got a 3.4 GHz i7 iMac (8 cores) with 24 GB of RAM. (2 16 GB chips plus 2 4 GB chips.) I know this amount of RAM is "officially unsupported" which is why I mention it.
Lately logging out (to restart into boot camp) takes 4 or 5 minutes, and logging back in does as well. When logging out, the Finder disappears and it goes to the gray screen that you see just before it restarts... but then sits there for 4-5 minutes. When logging in, you see the "enter user name / password" screen with the spinning progress indicator... which again takes 4-5 minutes.
Is it copying all 24GB of RAM to disk, and restoring it, to re-open windows in saved states or something like that? If not what? I reboot into boot camp fairly often for work and this is ridiculous.
Posting console log from when I think I logged in this morning:
6/4/13 11:19:59.491 AM WindowServer[277]: Created shield window 0x12 for display 0x003f003d
6/4/13 11:19:59.491 AM WindowServer[277]: handle_will_sleep_auth_and_shield_windows: no lock state data
6/4/13 11:19:59.491 AM WindowServer[277]: Created shield window 0x13 for display 0x003f003e
6/4/13 11:19:59.491 AM WindowServer[277]: handle_will_sleep_auth_and_shield_windows: no lock state data
6/4/13 11:19:59.491 AM WindowServer[277]: Created shield window 0x14 for display 0x003f003f
6/4/13 11:19:59.491 AM WindowServer[277]: handle_will_sleep_auth_and_shield_windows: no lock state data
6/4/13 11:19:59.501 AM WindowServer[277]: Created shield window 0x15 for display 0x003f0040
6/4/13 11:19:59.501 AM WindowServer[277]: handle_will_sleep_auth_and_shield_windows: no lock state data
6/4/13 11:19:59.000 AM kernel[0]: The USB device Dell USB Keyboard (Port 3 of Hub at 0xfa100000) may have caused a wake by issuing a remote wakeup (3)
6/4/13 11:19:59.000 AM kernel[0]: HID tickle 247 ms
6/4/13 11:20:00.000 AM kernel[0]: AppleBCM5701::selectMedium - autoselect, any duplex, EEE allowed, flow control allowed
6/4/13 11:20:00.000 AM kernel[0]: Ethernet [AppleBCM5701Ethernet]: Link down on en0
6/4/13 11:20:00.475 AM hidd[46]: MultitouchHID: device bootloaded
6/4/13 11:20:00.950 AM mDNSResponderHelper[7757]: do_mDNSInterfaceAdvtIoctl: ioctl call SIOCGIFINFO_IN6 failed - error (22) Invalid argument
6/4/13 11:20:00.951 AM mDNSResponderHelper[7757]: do_mDNSInterfaceAdvtIoctl: ioctl call SIOCGIFINFO_IN6 failed - error (22) Invalid argument
6/4/13 11:20:04.000 AM kernel[0]: Ethernet [AppleBCM5701Ethernet]: Link up on en0, 1-Gigabit, Full-duplex, Asymmetric Receiving flow-control, Debug [796d,2301,0de1,0300,c9e1,3800]
   6/4/13 11:20:06.612 AM digest-service[7212]: digest-request: uid=0
6/4/13 11:20:06.612 AM digest-service[7212]: digest-request: init request
6/4/13 11:20:06.613 AM digest-service[7212]: digest-request: init return domain: CSMC server: AWMA047LB
 6/4/13 11:20:06.616 AM configd[17]: network changed: v4(en0+:10.223.233.133) DNS+ Proxy+ SMB+
6/4/13 11:20:06.624 AM configd[17]: setting hostname to "vernmac.csmc.edu"
6/4/13 11:20:07.314 AM nsupdate[7767]: krb5_sendto_context is called on main thread, its a blocking api
6/4/13 11:20:07.438 AM nsupdate[7772]: krb5_sendto_context is called on main thread, its a blocking api
 6/4/13 11:20:07.720 AM SymMissedTask - parent[258]: sleeptime recorded: Tue Jun  4 03:31:00 2013
6/4/13 11:20:07.720 AM SymMissedTask - parent[258]: waketime is: Tue Jun  4 11:20:07 2013
6/4/13 11:20:07.721 AM prl_naptd[301]: Reloading configuration...
6/4/13 11:20:07.741 AM prl_naptd[301]: vnic0: DHCP/NAT for 10.211.55.1-10.211.55.254 netmask 255.255.255.0
6/4/13 11:20:07.741 AM prl_naptd[301]: vnic1: DHCP for 10.37.129.1-10.37.129.254 netmask 255.255.255.0
6/4/13 11:20:08.619 AM mDNSResponderHelper[7757]: do_mDNSInterfaceAdvtIoctl: ioctl call SIOCGIFINFO_IN6 failed - error (22) Invalid argument
6/4/13 11:20:08.620 AM mDNSResponderHelper[7757]: do_mDNSInterfaceAdvtIoctl: ioctl call SIOCGIFINFO_IN6 failed - error (22) Invalid argument
6/4/13 11:20:10.295 AM SecurityAgent[314]: User info context values set for jensenv
6/4/13 11:20:10.556 AM configd[17]: network changed: v4(en0:10.223.233.133) DNS! Proxy SMB
6/4/13 11:20:10.657 AM awacsd[56]: Connecting AWACS client: 1462471710.p14.members.btmm.icloud.com.
6/4/13 11:20:10.685 AM SecurityAgent[314]: Login Window login proceeding
6/4/13 11:20:11.000 AM kernel[0]: Sandbox: kcm(7797) deny mach-lookup com.apple.networkd
6/4/13 11:20:12.000 AM kernel[0]: utun_ctl_connect: creating interface utun1
6/4/13 11:20:12.100 AM acvpnagent[62]: Function: if_get_interfaces File: Utility/if_unix.cpp Line: 186 Invoked Function: ioctl Return Code: -1 (0xFFFFFFFF) Description: unknown (SIOCGIFDSTADDR) for interface "utun1"
6/4/13 11:20:12.000 AM kernel[0]: utun1: attached with 0 suspended link-layer multicast membership(s)
6/4/13 11:20:12.861 AM nsupdate[7806]: krb5_sendto_context is called on main thread, its a blocking api
6/4/13 11:20:13.568 AM ntpd[232]: unable to create socket on utun1 (32) for fd00:6587:52d7:10c1:21df:f66e:e232:369a#123
6/4/13 11:20:14.422 AM netbiosd[147]: name servers down?
6/4/13 11:20:14.498 AM CVMServer[178]: Check-in to the service com.apple.cvmsCompAgent_x86_64 failed. This is likely because you have either unloaded the job or the MachService has the ResetAtClose attribute specified in the launchd.plist. If present, this attribute should be removed.
6/4/13 11:20:14.503 AM loginwindow[41]: Login Window - Returned from Security Agent
6/4/13 11:20:14.522 AM CVMServer[178]: Check-in to the service com.apple.cvmsCompAgent_x86_64 failed. This is likely because you have either unloaded the job or the MachService has the ResetAtClose attribute specified in the launchd.plist. If present, this attribute should be removed.
6/4/13 11:20:14.543 AM loginwindow[41]: ERROR | ScreensharingLoginNotification | Failed sending message to screen sharing GetScreensharingPort, err: 1102
6/4/13 11:20:15.119 AM nsupdate[7853]: krb5_sendto_context is called on main thread, its a blocking api
6/4/13 11:20:15.793 AM com.apple.launchd[1]: (com.apple.smb.preferences) Throttling respawn: Will start in 1 seconds
6/4/13 11:20:15.793 AM com.apple.launchd[1]: (com.apple.smb.preferences) Throttling respawn: Will start in 1 seconds
6/4/13 11:20:15.904 AM com.apple.launchd[1]: (com.apple.smb.preferences) Throttling respawn: Will start in 1 seconds
6/4/13 11:20:16.909 AM digest-service[7212]: digest-request: uid=0
6/4/13 11:20:16.909 AM digest-service[7212]: digest-request: init request
6/4/13 11:20:16.910 AM digest-service[7212]: digest-request: init return domain: CSMC server: AWMA047LB
6/4/13 11:20:18.458 AM nsupdate[7871]: krb5_sendto_context is called on main thread, its a blocking api
6/4/13 11:20:20.193 AM nsupdate[7883]: krb5_sendto_context is called on main thread, its a blocking api
6/4/13 11:20:25.989 AM netbiosd[147]: name servers down?
6/4/13 11:20:27.728 AM NortonMissedTask - Child #0[7919]: About to launch child 0
6/4/13 11:20:34.699 AM apsd[58]: Unable to bootstrap_lookup connection port for 'com.apple.CalendarAgent.push': Unknown service name
6/4/13 11:20:34.699 AM apsd[58]: Unable to bootstrap_lookup connection port for 'com.apple.syncdefaultsd.push': Unknown service name
6/4/13 11:20:34.699 AM apsd[58]: Unable to bootstrap_lookup connection port for 'com.apple.safaridavclient.push': Unknown service name
6/4/13 11:20:34.699 AM apsd[58]: Unable to bootstrap_lookup connection port for 'com.apple.ubd.system-push': Unknown service name
6/4/13 11:20:34.700 AM apsd[58]: Unable to bootstrap_lookup connection port for 'com.apple.AddressBook.PushNotification': Unknown service name
6/4/13 11:20:34.700 AM apsd[58]: Unable to bootstrap_lookup connection port for 'com.apple.AOSPushRelay.push': Unknown service name
6/4/13 11:20:37.721 AM com.apple.backupd-helper[7780]: Not starting scheduled Time Machine backup - time machine destination not resolvable.
6/4/13 11:22:11.562 AM netbiosd[147]: name servers down?
6/4/13 11:23:29.894 AM loginwindow[41]: USER_PROCESS: 41 console
6/4/13 11:23:30.023 AM com.apple.launchd[1]: (com.realvnc.vncserver_agent[419]) Exited with code: 4
6/4/13 11:23:30.108 AM com.apple.launchd.peruser.573771919[622]: (com.spotify.webhelper) Unknown key: SpotifyPath
6/4/13 11:23:30.108 AM com.apple.launchd.peruser.573771919[622]: (com.apple.gamed) Ignored this key: UserName
6/4/13 11:23:30.108 AM com.apple.launchd.peruser.573771919[622]: (com.apple.gamed) Ignored this key: GroupName
6/4/13 11:23:30.109 AM com.apple.launchd.peruser.573771919[622]: (com.apple.ReportCrash) Falling back to default Mach exception handler. Could not find: com.apple.ReportCrash.Self
6/4/13 11:23:30.112 AM loginwindow[41]: Connection with distnoted server was invalidated
6/4/13 11:23:30.320 AM loginwindow[41]: lwMountWithArrayOfPaths: Skipping mount, final urlString was NULL
6/4/13 11:23:31.190 AM blued[55]: kBTXPCUpdateUserPreferences gConsoleUserUID = 573771919
6/4/13 11:23:32.272 AM WindowServer[277]: **DMPROXY** (2) Found `/System/Library/CoreServices/DMProxy'.
6/4/13 11:23:32.563 AM WindowServer[277]: Display 0x042801c0: MappedDisplay Unit 0; ColorProfile { 2, "iMac"}; TransferFormula (1.000000, 1.000000, 1.000000)
6/4/13 11:23:33.353 AM com.apple.launchd.peruser.573771919[622]: (com.apple.afpstat-qfa[8767]) Exited with code: 2
6/4/13 11:23:33.975 AM prl_naptd[8770]: Starting Parallels Network Daemon
6/4/13 11:23:34.000 AM kernel[0]: CODE SIGNING: cs_invalid_page(0x1000): p=8773[GoogleSoftwareUp] clearing CS_VALID
6/4/13 11:23:35.880 AM talagent[8734]: _LSSetApplicationInformationItem(kLSDefaultSessionID, asn, _kLSApplicationIsHiddenKey, hidden ? kCFBooleanTrue : kCFBooleanFalse, NULL) produced OSStatus -50 on line 623 in TCApplication.m
6/4/13 11:23:35.880 AM talagent[8734]: _LSSetApplicationInformationItem(kLSDefaultSessionID, asn, TAL_kLSIsProxiedForTALKey, kCFBooleanTrue, NULL) produced OSStatus -50 on line 626 in TCApplication.m
6/4/13 11:23:38.010 AM ScanNotification[8780]: /Library/Preferences/com.symantec.schedScanResults not found as directory.
6/4/13 11:23:38.015 AM SymSecondaryLaunch[8781]: launch for id = 2      event = oapp result = 0
6/4/13 11:23:38.016 AM com.apple.launchd.peruser.573771919[622]: (com.apple.mrt.uiagent[8757]) Exited with code: 255
6/4/13 11:23:41.440 AM UserEventAgent[8719]: cannot find fw daemon port 1102
6/4/13 11:23:42.790 AM WindowServer[277]: CGXDisableUpdate: UI updates were forcibly disabled by application "SystemUIServer" for over 1.00 seconds. Server has re-enabled them.
6/4/13 11:23:43.667 AM appleprofilepolicyd[8807]: appleprofilepolicyd: profiling drivers not loaded, loading
6/4/13 11:23:43.867 AM WindowServer[277]: reenable_update_for_connection: UI updates were finally reenabled by application "SystemUIServer" after 2.08 seconds (server forcibly re-enabled them after 1.00 seconds)
6/4/13 11:23:44.436 AM sudo[8811]:     root : TTY=unknown ; PWD=/ ; USER=jensenv ; COMMAND=/bin/launchctl load /Library/LaunchAgents/com.parallels.vm.prl_pcproxy.plist
6/4/13 11:23:44.000 AM kernel[0]: NTFS volume name LACIEWIN, version 3.1.
6/4/13 11:23:44.942 AM NetworkBrowserAgent[8817]: Starting NetworkBrowserAgent
6/4/13 11:23:45.121 AM sudo[8823]:     root : TTY=unknown ; PWD=/ ; USER=jensenv ; COMMAND=/bin/launchctl start com.parallels.vm.prl_pcproxy
6/4/13 11:23:52.787 AM netbiosd[147]: name servers down?
6/4/13 11:23:52.989 AM mdmclient[8758]: [Agent:573771919] Processing server request: ProfileList  for: <User: 573771919>
6/4/13 11:24:05.094 AM LKDCHelper[8897]: Starting (uid=573771919)
6/4/13 11:24:14.638 AM com.apple.time[8719]: Interval maximum value is 946100000 seconds (specified value: 9223372036854775807).
6/4/13 11:24:14.639 AM com.apple.time[8719]: Interval maximum value is 946100000 seconds (specified value: 9223372036854775807).
6/4/13 11:24:14.936 AM com.apple.backupd[8783]: Starting automatic backup
6/4/13 11:24:21.691 AM com.apple.backupd[8783]: Backing up to: /Volumes/TimeMachine/Backups.backupdb
6/4/13 11:24:23.776 AM CalendarAgent[8764]: [com.apple.calendar.store.log.exchange.queue] [error = Error Domain=CalExchangeErrorDomain Code=-4 "Calendar can't save the event "Developer Meeting" to the Exchange server." UserInfo=0x7fcf5bd07490 {NSLocalizedFailureReason=The account "Cshs" currently can't be modified. To discard your changes and continue using the version of your calendars that's on the server, click Revert to Server., CalFailedOperationKey=<CalExchangeUpdateCalendarItemOperation: 0x7fcf5bb6b800>, NSLocalizedDescription=Calendar can't save the event "Developer Meeting" to the Exchange server.}]
6/4/13 11:24:25.280 AM CalendarAgent[8764]: [com.apple.calendar.store.log.exchange.queue] [error = Error Domain=CalExchangeErrorDomain Code=-4 "Calendar can't save the event "Developer Meeting" to the Exchange server." UserInfo=0x7fcf59461010 {NSLocalizedFailureReason=The account "Cshs" currently can't be modified. To discard your changes and continue using the version of your calendars that's on the server, click Revert to Server., CalFailedOperationKey=<CalExchangeUpdateCalendarItemOperation: 0x7fcf5bb6b800>, NSLocalizedDescription=Calendar can't save the event "Developer Meeting" to the Exchange server.}]
6/4/13 11:24:30.288 AM KernelEventAgent[43]: tid 00000000 received event(s) VQ_LOWDISK, VQ_VERYLOWDISK (516)
6/4/13 11:24:30.000 AM kernel[0]: HFS: Vol: Google Chrome 27.0.1453.93-27.0.1453.110 Update Very Low Disk: freeblks: 0, dangerlimit: 13
6/4/13 11:24:30.507 AM DiskMountedNotifier[8779]: Try #0, for     , result = -600
6/4/13 11:24:31.000 AM kernel[0]: CODE SIGNING: cs_invalid_page(0x1000): p=8935[ksadmin] clearing CS_VALID
6/4/13 11:24:32.000 AM kernel[0]: CODE SIGNING: cs_invalid_page(0x1000): p=8938[ksadmin] clearing CS_VALID
6/4/13 11:24:32.000 AM kernel[0]: CODE SIGNING: cs_invalid_page(0x1000): p=8940[ksadmin] clearing CS_VALID
6/4/13 11:24:32.508 AM DiskMountedNotifier[8779]: Try #1, for     , result = 0
6/4/13 11:24:32.508 AM DiskMountedNotifier[8779]: launch for id = 0      event = Mscn result = 0
6/4/13 11:24:33.396 AM com.apple.backupd[8783]: Using file event preflight for Macintosh HD
6/4/13 11:24:33.550 AM defaults[8944]:
The domain/default pair of (/Applications/Google Chrome.app/Contents/Info, KSBrandID) does not exist
6/4/13 11:24:47.684 AM Mail[9635]: Using V2 Layout
6/4/13 11:24:53.307 AM librariand[9662]: MMe quota status changed: under quota
6/4/13 11:24:55.846 AM com.apple.launchd[1]: System: Bug: 12E27: launchd + 80370 [7DCC9489-2DF5-3807-83FA-EF5666EE8078]: 0x0
6/4/13 11:24:55.846 AM com.apple.launchd[1]: System: This API can only be used by a process running within an Aqua session.
6/4/13 11:24:55.846 AM osascript[9809]: spawn_via_launchd() failed, errno=5 label=[0x0-0x1e61e6].com.apple.systemevents path=/System/Library/CoreServices/System Events.app/Contents/MacOS/System Events flags=0
6/4/13 11:24:55.846 AM osascript[9809]: spawn_via_launchd() failed, errno=5 label=[0x0-0x1e61e6].com.apple.systemevents path=/System/Library/CoreServices/System Events.app/Contents/MacOS/System Events flags=0
6/4/13 11:25:01.744 AM netbiosd[147]: name servers down?
6/4/13 11:25:03.637 AM com.apple.SecurityServer[15]: Session 100013 created
6/4/13 11:25:07.760 AM com.apple.time[8719]: Interval maximum value is 946100000 seconds (specified value: 9223372036854775807).
6/4/13 11:25:12.268 AM LiveUpdate[8791]: Cannot create Symantec.keychain: Permission denied.
6/4/13 11:25:12.275 AM LiveUpdate[8791]: Cannot create Symantec.keychain: Permission denied.
6/4/13 11:25:15.000 AM kernel[0]: AppleBCM5701Ethernet:        0        1 BCM5701Enet::replaceOrCopyPacket worked after N tries

Since I'm limited in how much I can post, I edited out a lot of acvpnagent entries such as this one:
6/4/13 11:20:00.007 AM acvpnagent[62]: Function: if_get_interfaces File: Utility/if_unix.cpp Line: 186 Invoked Function: ioctl Return Code: -1 (0xFFFFFFFF) Description: unknown (SIOCGIFDSTADDR) for interface "utun0"

I think this is related to some stuff work installed on my machine before I got it, but there are lots of these messages prior to attempting to log in, so I think they're unrelated.
UPDATE 1:
I tried the solution proposed here:
http://www.techsmog.com/index.php/2011/02/23/fixing-the-slow-loginlogoutauthentication-issue-in-osx-snow-leopard/
but this did not help.

A: Okay, found the solution. Not sure which of these did the trick as I did both at once:
1) Shut down computer, unplug power cord and wait 15 seconds. Plug cord back in and wait 5 seconds, then turn on.
2) Immediately after turning on (before gray screen appears but after chime) hold down Command-Option-P-R all at once to zap PRAM. Keep holding until computer restart.
Now shutting down takes only 30 seconds, and logging in takes only 15. Soooooo much better!

A: Had similar issues, this helped - although may not apply to your case...
After getting some errors on my macbook pro Console.
Error:
com.apple.kextd: Can't create kext cache under / - owner not root.
The solution for this is
sudo chown root:admin /
in terminal.
Reboot speed then back to normal.

A: Apple really does publish good tech info and instructions.
See About NVRAM and PRAM


text:
Q: antlr4 - get left and right sibling of rule context An easy question, on which I cannot find something useful in the API docs: is there a way to get the left and right sibling of a ParserRuleContext?
Say I have in my .g4:
identifiers : identifier (',' identifier)*;

When handling a IdentifierContext, I would like to get a reference to the left and the right IdentifierContext.

A: I've found a relevant getRightSibling() method here.
Here is my C# port:
    /// <summary>
    /// Returns the right sibling of the parse tree node.
    /// </summary>
    /// <param name="context">A node.</param>
    /// <returns>Right sibling of a node, or null if no sibling is found.</returns>
    public static IParseTree GetRightSibling(this ParserRuleContext context)
    {
        int index = GetNodeIndex(context);

        return index >= 0 && index < context.Parent.ChildCount - 1
            ? context.Parent.GetChild(index + 1)
            : null;
    }

    /// <summary>
    /// Returns the node's index with in its parent's children array.
    /// </summary>
    /// <param name="context">A child node.</param>
    /// <returns>Node's index or -1 if node is null or doesn't have a parent.</returns>
    public static int GetNodeIndex(this ParserRuleContext context)
    {
        RuleContext parent = context?.Parent;

        if (parent == null)
            return -1;

        for (int i = 0; i < parent.ChildCount; i++)
        {
            if (parent.GetChild(i) == context)
                return i;
        }

        return -1;
    }

A: To get the index of the current child node:
int indexOfCurrentChildNode = ctx.getParent().children.indexOf(ctx);

Then you can get its right/left sibling by:
ctx.parent.getChild(indexOfCurrentChildNode +/- 1)

A:
[...] is there a way to get the left and right sibling of a ParserRuleContext?

No, alas, there is no direct way to do so in the core API of ANTLR4.
You  could go with infomehdi's answer, but will have to guard against index-oUt-of-bound exceptions when (trying to) retrieve the left- or right node.


text:
Q: How to find all matches for every string in collection using Spring data I have got a collection of strings. I need to find in database all file names that contains this string. Like a full matching "LIKE(%KEYWORD%)";
Here is my method
  Page<FilePdf> getByFileNameContainingInAndExtension(Collection<String> fileNames, String extension, Pageable pageable);

But it gives me an exception

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property containing found for type String! Traversed path: FilePdf.fileName.

UPDATE
Here is my repository
 public interface FilePdfRepository extends JpaRepository<FilePdf, Long> {
    Page<FilePdf> getByFileNameContainingInAndExtension(Collection<String> fileNames, String extension, Pageable pageable);
}

And here is my entity
@Entity
@Table(name = "dlfileentry")
public class FilePdf {
    @Id
    @Column(name = "uuid_")
    private String id;
    @Column(name = "fileentryid")
    private Integer fileEntryId;
    @Column(name = "groupid")
    private Integer groupId;
    @Column(name = "filename")
    private String fileName;
    @Column(name = "folderid")
    private Integer folderId;
    @Column(name = "extension")
    private String extension;
}

A: use findBy instead of getBy
using in keyword
 public interface FilePdfRepository extends JpaRepository<FilePdf, Long> {
        Page<FilePdf> findByFileNameInAndExtension(Collection<String> fileNames, String extension, Pageable pageable);
    }

see Docs : https://docs.spring.io/spring-data/jpa/docs/1.11.6.RELEASE/reference/html/

A: The root cause of the problem is that the ContainingIn keyword does not belong to the Spring Data JPA.
The Containing keyword does support only a single value, not a collection.
Consider updating the repository as follows:
public interface FilePdfRepository extends JpaRepository<FilePdf, Long> {
    Page<FilePdf> getByFileNameContainingAndExtension(String fileName, String extension, Pageable pageable);
}

A: If you want to query using querydsl, the JPAQuery can be formed in the following manner :
Predicate finalPredicate(StringPath sp, List<String> filterValues) {
        BooleanBuilder bb = new BooleanBuilder();
        String value;
        for (Iterator arg2 = filterValues.iterator(); arg2
                .hasNext(); bb = bb.or(sp.containsIgnoreCase(value.trim().toLowerCase()))) {
            value = (String) arg2.next();
        }
        return bb;
    }


text:
Q: How can I speed up this view which sums a load of quote line rows? I am writing a view to show quote totals based on summing the values in a quote line table. I need to restrict the view to only show quotes for customers of a particular 'pricetype'. However when I do this the view slows down a lot.
SQL to sum the prices
SELECT dbo.quoteline.qid, SUM((dbo.pricelist.listprice - dbo.quoteline.voff) * dbo.quoteline.quantity) AS total
FROM dbo.quoteline LEFT OUTER JOIN dbo.pricelist ON dbo.quoteline.prodcode = dbo.pricelist.prodcode GROUP BY dbo.quoteline.qid

SQL once 'pricetype' constraint is added
SELECT     dbo.quoteline.qid, SUM((dbo.pricelist.listprice - dbo.quoteline.voff) * dbo.quoteline.quantity) AS total
FROM         dbo.pricelist RIGHT OUTER JOIN
                      dbo.client RIGHT OUTER JOIN
                      dbo.quote ON dbo.client.cid = dbo.quote.cid RIGHT OUTER JOIN
                      dbo.quoteline ON dbo.quote.qid = dbo.quoteline.qid ON dbo.pricelist.prodcode = dbo.quoteline.prodcode
WHERE     (dbo.client.pricetype = 'V')
GROUP BY dbo.quoteline.qid

Maybe its late and I am having a moment but any help here would be gratefully appreciated.

A: Two things: First, can you put an index on the dbo.client.pricetype column without it interfering with inserts/updates?  Secondly, inner joins are generally faster than outer joins and since your results and where clause depend on the other tables, I suspect you will want to do inner joins anyways unless there are NULL records you need back from your view.  Try this following query to see if it gets you the results you need:
SELECT dbo.quoteline.qid, SUM((dbo.pricelist.listprice - dbo.quoteline.voff) * dbo.quoteline.quantity) AS total
FROM dbo.quoteline
INNER JOIN dbo.pricelist ON dbo.quoteline.prodcode = dbo.pricelist.prodcode
INNER JOIN dbo.quote ON dbo.quote.qid = dbo.quoteline.qid
INNER JOIN dbo.client ON dbo.client.cid = dbo.quote.cid
WHERE     (dbo.client.pricetype = 'V')
GROUP BY dbo.quoteline.qid

A: What does happen if you do it like this :
SELECT     dbo.quoteline.qid, SUM((dbo.pricelist.listprice - dbo.quoteline.voff) * dbo.quoteline.quantity) AS total
FROM         dbo.pricelist RIGHT OUTER JOIN
                      dbo.client ON dbo.client.pricetype = 'V' RIGHT OUTER JOIN
                      dbo.quote ON dbo.client.cid = dbo.quote.cid RIGHT OUTER JOIN
                      dbo.quoteline ON dbo.quote.qid = dbo.quoteline.qid AND dbo.pricelist.prodcode = dbo.quoteline.prodcode
GROUP BY dbo.quoteline.qid


text:
Q: More Than One Activity I need more than one activity, more than one layout. So how do I write my XML?

A: Read the Android Documentation on Activity's.

A: You should take a look at the Notepad application provided with the android sdk. In this application there is multiple activities (NoteEditor and NotesList for example) and multiple layouts (note_editor.xml, ...).
If this doesn't help, feel free to ask for a more specific question (for instance what XML are you talking about).