text:
Q: Query to find top customers in countries with greatest difference in from 2 months lets say theres columns: customer_id, revenue, country, date
what is a query that would show top customers with the highest revenue growth from nov to dec?
what is a query that would show the top 100 customers in each country that has the highest growth in revenue from november in december?

A: Calculating the revenue growth can be using the window function lag():
select customer_id, revenue, date, country,
       revenue - lag(revenue,1,revenue)
                     over (partition by customer_id order by date) as growth
from turnover
where extract(month from date) in (11,12)

lag(revenue,1,0.0) will return the revenue from the previous row. If there is no previous row, it will return the current row's revenue. This results in a growth of 0 for the first row for each customer.
Now with the growth column this turns into a greatest-n-per-group problem which is also typically solved using window functions. However as window functions can't be nested in a single query, you need to use two levels of nested derived tables:
select customer_id, revenue, date, country, diff_to_previous,
       dense_rank() over (order by growth desc nulls last) as rnk
from (
  select customer_id, revenue, date, country
         revenue - lag(revenue,1,0.0) over (partition by customer_id order by date) as growth
  from turnover
  where extract(month from date) in (11,12)
) t1

This assigns a rank for each row based on the growth. However you can't use the rnk alias directly in the where clause and that's why you use the additional level of a derived table.
So the final statement to get the customer with the highest growth is:
select *
from (
  select customer_id, revenue, date, country, growth,
         dense_rank() over (order by growth desc) as rnk
  from (
    select customer_id, revenue, date, country,
           revenue - lag(revenue,1,0.0) over (partition by customer_id order by date) as growth
    from turnover
    where extract(month from date) in (11,12)
  ) t1
) t2
where rnk = 1;

To get the 100 highest growth for each country you just need to change the calculation of the rnk to do it per country:
select *
from (
  select customer_id, revenue, date, country, growth
         dense_rank() over (partition by country order by growth desc) as rnk
  from (
    select customer_id, revenue, date, country,
           revenue - lag(revenue,1,0.0) over (partition by customer_id order by date) as growth
    from turnover
    where extract(month from date) in (11,12)
  ) t1
) t2
where rnk <= 100;

date is a horrible name for a column. Not only because it is a keyword but more importantly it does not document what the column contains. Is that a "start date"? an "end date"? A "purchase date"? A "due date"?


text:
Q: wxWidgets Memory Management standard practice I have started playing around with wxWidgets using c++. I have made a simple hello world application following along with tutorials.
Out of curiosity I ran the complied program through valgrind and had the following result.
==92057== LEAK SUMMARY:
==92057==    definitely lost: 91,768 bytes in 292 blocks
==92057==    indirectly lost: 119,108 bytes in 4,828 blocks
==92057==      possibly lost: 9,238 bytes in 143 blocks
==92057==    still reachable: 4,590,951 bytes in 43,100 blocks
==92057==                       of which reachable via heuristic:
==92057==                         length64           : 13,360 bytes in 199 blocks
==92057==                         newarray           : 2,528 bytes in 78 blocks
==92057==         suppressed: 0 bytes in 0 blocks

should this output be trusted? Is there a standard way to free memory associated with wxWidgets?
For example:
    wxButton *clear = new wxButton(panel, ID_RESET, wxT("Clear"));

should this be deleted in the destructor for its parent object? I am not doing any memory allocations in this project though my own code. Just displaying a window with some controls on via wxWidgets.

A: I presume that you are doing it on Linux?
All those are false positives or leaks coming from system libraries.
In terms of wxWidgets you don't need to delete memory allocated for wx object. The library internally works like a smart pointer.
When you create a main frame it will be deleted when the application object will be destroyed. When you create a panel as parent of the main frame it will be automatically deleted when the main frame will be destroyed which will happen when the application object will be destroyed.
And so forth - just like in the children's poem This is the house that Jack built. You don't have to do anything in the destructor.
However if you allocate memory for any non-wx object, you absolutely have to release it (call delete on the pointer).
[EDIT]
Very important!!
Also, please understand - the very important part - all those controls have to have a parent window as a first parameter to constructor.
Also, when you try to create a modal dialog, that dialog may not have a parent (pass NULL). In this case - DO NOT create it on the heap!! Create it on the stack and when the variable goes out of scope the dialog object will be destroyed. With the same concept of deleting all children automatically.
This is the only exception of heap vs stack creation in wxWidgets.
[/EDIT]

redpajama_set_name: RedPajamaStackExchange


text:
Q: how to Redirect to another page in next.js based on css media query? im brand new to Next.js and i have the following situation. i want to redirect the user to the route /messages if he type route /messages/123 based on css media query so if he is mobile we will not redirect and if he in browser then redirect .
i have tried the following code
import React, { useLayoutEffect } from 'react';
import { useRouter, push } from 'next/router';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import Layout from '../components/Customer/Layout/Layout';
import Chat from '../components/Customer/Chat/Chat';

const Messages = () => {
 const { pathname, push } = useRouter();
 const matches = useMediaQuery('(min-width:1024px)');

 useLayoutEffect(() => {
   console.log('I am about to render!');
   if (matches && pathname === '/messages') {
     console.log('match!');
     push('/');
   }
 }, [matches, pathname, push]);

 return (
   <Layout currentURL={pathname}>
     <Chat />
   </Layout>
 );
};

export default Messages;

the problem is the component render twice before redirect

A: But You should probably be using useEffect since you are not trying to do any DOM manipulations or calculations.

useLayoutEffect: If you need to mutate the DOM and/or DO need to perform measurements
useEffect: If you don't need to interact with the DOM at all or your DOM changes are unobservable (seriously, most of the time you should use this).

You should see immediate action.
Edit:
You can use Next JS getInitialProps to check the request headers and determine if the request if from mobile or desktop then redirect from there.
getInitialProps({ res, req }) {
    if (res) {
      // Test req.headers['user-agent'] to see if its mobile or not then redirect accordingly
      res.writeHead(302, {
        Location: '/message'
      })
      res.end()
    }
    return {}
  }


text:
Q: SELECT IN statement doesn't work properly I'm trying to select with IN from mysql.
I have this query: SELECT id, name FROM country WHERE id IN (2,1)
If I run it from phpmyadmin I get two rows, but when I want to do it in a function I get just one row
This is my function
function search($res) {
    global $pdo;
    $arr = [$res];
    $in  = str_repeat('?,', count($arr) - 1) . '?';
    $sql = "SELECT id, name FROM country WHERE id IN ($in)";
    $stmt = $pdo->prepare($sql);
    $stmt->execute($arr);
    $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
    return $stmt->rowCount();
}

What am I missing?
The problem seems to come from count($arr), gets back as 1.

A: Found the problem
$arr = [$res] -> $arr = explode(',', $res)
I was getting all the elements of the array as the first and only element, I had to explode by comma to get the actual array.


text:
Q: Windows Keeps Losing Wireless Printer - Needs To Be Re-Added Every Day I have a wireless network with a number of laptops and a Deskjet 2540 wireless printer. The laptops are running Windows 7 with one of them running Windows 8. The wireless modem is a Netgear.
If I, through Add Devices and Printers, add a new printer, Windows finds the printer on it's IP address and adds it correctly. A test print works, as well as normal printing. Actually, when doing the search for printers, the wireless printer pops up in the list very quickly within 2 or 3 seconds.
However, once I power down a laptop, the next time I boot it up the printer is marked as unavailable and I cannot print until I go through the Add Printer process again. Re-rebooting the laptop or restarting the printer has no effect. It seems the only way is to re-add the printer.
Is there a way to make sure the printer does not get forgotten? Or should I instead be looking at wiring up the printer to the network instead (which would require a USB to Ethernet adapter)? Would that make it more stable?


text:
Q: Call different set of random images based on screen resolution: PHP? I have a homepage that loads random full-screen background images, but has rendering problems on mobile because of (I believe) the size of the images called.
I'm using PHP script to call the images, is it possible to have the PHP call a different set of images if the screen width is below 1080px?
Here is the page: http://agentboris.com/
The PHP before the html in the html file:
<?php
  $bg = array('bg-01.gif', 'bg-02.gif', 'bg-03.gif', 'bg-04.gif', 'bg-05.gif', 'bg-06.gif', 'bg-07.gif', 'bg-08.gif', 'bg-09.gif', 'bg-10.gif', 'bg-11.gif', ); // array of filenames

  $i = rand(0, count($bg)-1); // generate random number size of the array
  $selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
?>

And the CSS styling to make it happen (I think!):
<style type="text/css">
<!--
body{
background: url(backgrounds/<?php echo $selectedBg;?>) no-repeat center center fixed;
-webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
-->
</style>

Thanks for your help.

A: You can do it with javascript/jQuery:
Having images with name as:
img-X-Y.gif
X: number relative to resolution, for example 8 will be for around 800px width
Y: number of image (0,1,2,3... up to 9 in the example) for every resolution
<script>
var w = $( window ).width();
image = "img-" + Math.floor(w/100) + "-" + Math.floor(Math.random() * 10) + ".gif";
$('body').css("background-image", "url('/imagePath/" + image + "')");
</script>

So you will need some like:
/imagePath/
   img-0-0.gif   // images from 0 to 299px width
   img-0-1.gif
   img-0-2.gif
   img-0-3.gif
   img-0-4.gif
   img-0-5.gif
   img-1-0.gif   // images from 300 to 599px width
   img-1-1.gif
   img-1-2.gif
   img-1-3.gif
   img-1-4.gif
   img-1-5.gif
   img-2-0.gif   // images from 600 to 899px width
   img-2-1.gif
   img-2-2.gif
   img-2-3.gif
   img-2-4.gif
   img-2-5.gif
   img-3-0.gif   // images from 900 to 1199px width
   img-3-1.gif
   img-3-2.gif
   img-3-3.gif
   img-3-4.gif
   img-3-5.gif
   img-4-0.gif   // images from 1200px width
   img-4-1.gif
   img-4-2.gif
   img-4-3.gif
   img-4-4.gif
   img-4-5.gif

With 6 images (0 to 5) and having a group of images for every 300px of width, the code should be like:
   <script>
    var w = $( window ).width();
    if (w < 1500) {  //for width resolutions lower than 1500px
        widthId = Math.floor(w/300);
    } else {         // for resolutions of 1500 or higher
        widthId = 4
    }
    image = "img-" + widthId + "-" + Math.floor(Math.random() * 6) + ".gif";
    $('body').css("background-image", "url('/imagePath/" + image + "')");
    </script>


text:
Q: Laplacian transform, moments or characteristic function of a random variable Let $Z$ be a real random variable, we define the Laplace transform of $Z$ as follows:
$L_Z(\lambda) = \mathbb{E}(e^{\lambda Z})$ for $\lambda \in \mathbb{R}$.

What links can be shown between the Laplace transform of $Z$ and the moments of $Z$

If $Z$ has a CDF $F_Z$. The moment generating function (mgf) of $Z$ (or $F_Z$ ), denoted by $M_Z(t)$, is $M_Z(t)=\mathrm{E}(e^{t Z})$. Thus $L_Z(\lambda) = \mathbb{E}(e^{\lambda Z}) = M_Z(\lambda)$.

What links can be shown between the Laplace transform of $Z$ and the characteristic function of $Z$

We define the characteristic function of $Z$ as $\varphi_X(t)=\mathrm{E}(e^{i t X})$. Thus $L_Z(i\lambda) = \mathbb{E}(e^{i\lambda Z}) = \varphi_X(\lambda)$.
Is this correct or do I have to change something?


text:
Q: How to run a Azure Powershell cmdlets on a VM when outbound Internet access is restricted I am using Powershell script that resides in a VM to retrieve the list of resources in a subscription. Currently I have the outbound internet enabled on the NSG of the VM. But I would like to restrict the outbound internet access in future.
Is there a way to run the powershell script when internet access is denied ?

A: The Run Command feature can run scripts on your virtual machines remotely by using the VM agent. To function correctly, Run Command requires connectivity (port 443) to Azure public IP addresses. If you're blocking traffic on the virtual machine, you can use service tags to allow traffic to Azure public IP addresses by using the AzureCloud tag.

A: There is no service tag called azurecloud have whitelist azure datacenter IP. Also looking for option to create custom service which is not possible now


text:
Q: count spark's saveAsHadoopFile be executed async? I 'm running spark streaming task , in each batch, I 'll execute saveAsHadoopFile function.
My question is could this function be executed asynchronously?
that is, the io function will not block the next block's processing


text:
Q: Not Recently Used algorithm using map I have a need where I need to implement NRU (Not Recently Free) algorithm.
Current data structure is just simple map, something like
map[string]bool

Basically this is hashmap for string to availability. But
instead of just being bool, I want to include some timestamp so that along
with whether a particular string is avail or not, I also will pick Not Recently Freed (Oldest) string. Wondering about how to modify the Go's
Data structure.
I am thinking of
map[string]bool+timestamp

That way, if let's say highest bit is set, that shows available or not
and timestamp will help me to search through based on time.

A: If you want to store two types in the value part of a map you can do so by creating a new struct type:
type Value struct {
  avail bool
  timestamp time.Time
}

Then you can create a map as follows:
m := map[string] Value{}

And add to the map:
m["some-value"] = Value{avail:true, timestamp: time.Now()}

A: It's a little unusual to want to keep empty slots in a map.  If you want to remove an element from a map, you can delete it, and then you can use the two-result form index expression to test whether something is in the map or not.
m := make(map[string]int)
m["x"] = 1
if _, ok := m["x"]; ok {
        fmt.Printf("x is there")
}
delete(m, "x")
if _, ok := m["x"]; !ok {
        fmt.Printf("x is not there")
}

Usually you need more than just a map of key to value to implement least-recently-used; you need some other side data structure like a doubly-linked list to remember which order they've been used in.  (If you do have some persistent value like a timestamp, a heap would work too.)  You could store pairs of actual values and timestamps in the map values, but then you have to search through the whole list to find the oldest one.
import "container/list"

type CacheValue struct {
        Key string
        Value int
}

type Cache struct {
        values map[string]*list.Element
        lru *list.List
}

func makeCache() *Cache {
        return &Cache{
                values: make(map[string]*list.Element),
                lru: list.New(),
        }
}

func (c *Cache) Put(k string, v int) {
        cv := CacheValue{Key: k, Value: v}
        el := c.lru.PushFront(&cv)
        c.values[k] = el
}

func (c *Cache) Get(k string) int {
        el, ok := c.values[k]
        if ok {
                c.lru.MoveToFront(el)
                return el.Value.(*CacheValue).Value
        }
        return 0
}

func (c *Cache) DeleteOldest() {
        el := c.lru.Back()
        if el != nil {
                delete(c.values, el.Value.(*CacheValue).Key)
                c.lru.Remove(el)
        }
}


text:
Q: Browse product images from server ? I need to know if there is a way to browse product images from server and not upload them. I have several products with the same images and i am uploading the same image several time.

A: If you are having trouble with duplicate product images you could try
http://www.magentocommerce.com/magento-connect/image-clean.html
Made my life easier :)

Sorry, the question was not clear to me, I know that when you upload an image with exactly the same name it overrides it so that won't be an issue. A quick Google for your issue brought me here: http://www.pixelpaul.net/magento-share-images-on-more-products/, I haven't tested it / checked if its best practise but you could give it a shot.


text:
Q: X won't start with Intel on-board graphics + nVIDIA card I run Kubuntu 16.04 (just installed it from the ISO). My computer has on-chip Intel graphics, which is what I use for the display. I also have a GTX 650 Ti Boost card which I DO NOT WANT TO USE for display (just for CUDA work).

*

*When nVIDIA driver 361.62 or 367.35 (the latest) is installed, Xorg loads to a black screen (but when I run binaries which use CUDA run fine).

*When the nVIDIA driver is not installed, Xorg loads fine; it loads the nouveau modules (even though supposedly I don't need them) - but CUDA apps don't run.

The Xorg error with the nVIDIA driver installed is:
(EE) NOUVEAU(G0): [XvMC] Failed to initialize extension.
...
(EE) Failed to initialize GLX extension (Compatible NVIDIA X driver not found)

If I uninstall the nVIDIA driver, X works properly again (will quote some log messages here soon).
How can I get both X working and CUDA installed (i.e. drivers installed and functioning)?
Due disclosure: I had asked about the same question regarding Debian Stretch on unix.SX, but deleted it since I just switched to Kubuntu.

Update:
So I uninstalled Nouveau completely to explore this further. When I generate an xorg.conf, I get (clipped input-device-related and files lines and sections):
Section "ServerLayout"
       Identifier     "X.org Configured"
       Screen      0  "Screen0" 0 0
       Screen      1  "Screen1" RightOf "Screen0"
EndSection

Section "Module"
       Load  "glx"
EndSection

section "Monitor"
        Identifier   "Monitor0"
        VendorName   "Monitor Vendor"
        ModelName    "Monitor Model"
EndSection

Section "Monitor"
       Identifier   "Monitor1"
       VendorName   "Monitor Vendor"
       ModelName    "Monitor Model"
EndSection

Section "Device"
        Identifier  "Card0"
        Driver      "fbdev"
        BusID       "PCI:0:2:0"
EndSection

Section "Device"
       Identifier  "Card1"
       Driver      "fbdev"
       BusID       "PCI:2:0:0"
EndSection

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        SubSection "Display"
                Viewport   0 0
                Depth     24
        EndSubSection
EndSection

Section "Screen"
       Identifier "Screen1"
       Device     "Card1"
       Monitor    "Monitor1"
       SubSection "Display"
               Viewport   0 0
               Depth     24
       EndSubSection
EndSection

(note that PCI 2:0:0 is the nVIDIA card and 0:2:0 is the on-chip graphics.)
Now,

*

*If I use this configuration with the nVDIAI drivers - blank screen.

*If I comment-out the sections regarding the nVIDIA card (card 1, monitor 1) and change the ServerLayout section - blank screen.

*If I disable the loading of the GLX module(s), which produce errors in the log - blank screen (and it's not clear the module loading is the issue)

*I even went into the /usr/lib/xorg/modules, removing nvidia's libglx.so and/or restoring the non-nvidia libglx.so - still, blank screen.

I do get differet error messages though. With the most extensive subset of the above, I have:
[  1952.022] (==) Log file: "/var/log/Xorg.0.log", Time: Wed Aug 10 10:07:20 2016
[  1952.022] (==) Using config file: "/etc/X11/xorg.conf"
[  1952.022] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[  1952.022] (==) ServerLayout "X.org Configured"
[  1952.022] (**) |-->Screen "Screen0" (0)
[  1952.022] (**) |   |-->Monitor "Monitor0"
[  1952.022] (**) |   |-->Device "Card0"
[  1952.022] (**) |-->Input Device "Mouse0"
[  1952.022] (**) |-->Input Device "Keyboard0"
[  1952.022] (==) Automatically adding devices
[  1952.022] (==) Automatically enabling devices
[  1952.022] (==) Automatically adding GPU devices
...
  1952.024] (II) xfree86: Adding drm device (/dev/dri/card1)
[  1952.024] (II) xfree86: Adding drm device (/dev/dri/card0)
[  1952.026] (--) PCI:*(0:0:2:0) 8086:0162:1565:110f rev 9, Mem @ 0xf7400000/4194304, 0xd0000000/268435456, I/O @ 0x0000f000/64
[  1952.026] (--) PCI: (0:2:0:0) 10de:11c2:19da:1281 rev 161, Mem @ 0xf6000000/16777216, 0xe0000000/134217728, 0xe8000000/33554432, I/O @ 0x0000e000/128, BIOS @ 0x????????/524288
[  1952.026] (II) LoadModule: "glx"
[  1952.026] (II) Loading /usr/lib/xorg/modules/extensions-nvidia-leave-me-alone/libglx.so
[  1952.026] (II) Module glx: vendor="X.Org Foundation"
[  1952.026]    compiled for 1.18.3, module version = 1.0.0
[  1952.026]    ABI class: X.Org Server Extension, version 9.0
[  1952.026] (==) AIGLX enabled
[  1952.026] (II) LoadModule: "fbdev"
[  1952.027] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
[  1952.027] (II) Module fbdev: vendor="X.Org Foundation"
[  1952.027]    compiled for 1.18.1, module version = 0.4.4
[  1952.027]    Module class: X.Org Video Driver
[  1952.027]    ABI class: X.Org Video Driver, version 20.0
[  1952.027] (II) FBDEV: driver for framebuffer: fbdev
[  1952.033] (II) Loading sub module "fbdevhw"
[  1952.033] (II) LoadModule: "fbdevhw"
[  1952.033] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[  1952.033] (II) Module fbdevhw: vendor="X.Org Foundation"
[  1952.033]    compiled for 1.18.3, module version = 0.0.2
[  1952.033]    ABI class: X.Org Video Driver, version 20.0
[  1952.033] (**) FBDEV(0): claimed PCI slot 0@0:2:0
[  1952.033] (II) FBDEV(0): using default device
[  1952.033] (==) FBDEV(0): Depth 24, (==) framebuffer bpp 32
[  1952.033] (==) FBDEV(0): RGB weight 888
[  1952.033] (==) FBDEV(0): Default visual is TrueColor
[  1952.033] (==) FBDEV(0): Using gamma correction (1.0, 1.0, 1.0)
[  1952.033] (II) FBDEV(0): hardware: inteldrmfb (video memory: 8100kB)
[  1952.033] (II) FBDEV(0): checking modes against framebuffer device...
[  1952.033] (II) FBDEV(0): checking modes against monitor...
[  1952.033] (--) FBDEV(0): Virtual size is 1920x1080 (pitch 1920)
[  1952.033] (**) FBDEV(0):  Built-in mode "current"
[  1952.033] (==) FBDEV(0): DPI set to (96, 96)
[  1952.033] (II) Loading sub module "fb"
[  1952.033] (II) LoadModule: "fb"
[  1952.033] (II) Loading /usr/lib/xorg/modules/libfb.so
[  1952.034] (II) Module fb: vendor="X.Org Foundation"
[  1952.034]    compiled for 1.18.3, module version = 1.0.0
[  1952.034]    ABI class: X.Org ANSI C Emulation, version 0.4
[  1952.034] (**) FBDEV(0): using shadow framebuffer
[  1952.034] (II) Loading sub module "shadow"
[  1952.034] (II) LoadModule: "shadow"
[  1952.034] (II) Loading /usr/lib/xorg/modules/libshadow.so
[  1952.034] (II) Module shadow: vendor="X.Org Foundation"
[  1952.034]    compiled for 1.18.3, module version = 1.1.0
[  1952.034]    ABI class: X.Org ANSI C Emulation, version 0.4
[  1952.034] (==) Depth 24 pixmap format is 32 bpp
[  1952.079] (==) FBDEV(0): Backing store enabled
[  1952.080] (EE) FBDEV(0): FBIOPUTCMAP: Invalid argument
... repeated many times
[  1952.082] (==) FBDEV(0): DPMS enabled
[  1952.082] (==) RandR enabled
[  1952.087] (II) SELinux: Disabled on system
[  1952.087] (II) AIGLX: Screen 0 is not DRI2 capable
[  1952.087] (EE) AIGLX: reverting to software rendering
[  1952.101] (EE) AIGLX error: dlopen of /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so failed (/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so: undefined symbol: _glapi_tls_Dispatch)
[  1952.101] (EE) GLX: could not load software renderer
[  1952.101] (II) GLX: no usable GL providers found for screen 0
...
[  2201.199] (II) config/udev: removing GPU device /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/drm/card1 /dev/dri/card1
[  2201.199] xf86: remove device 0 /sys/devices/pci0000:00/0000:00:01.1/0000:02:00.0/drm/card1

*

*I also tried forcing the use of the "intel" driver. This works when the nVIDIA drivers are not installed, but it's the same old blank screen when they are.

A: Interestingly enough, this problem is not solvable since it's not really the problem: In fact, X is not blank-screening; it is the X display manager Kubuntu defaults to - sddm.
If you replace sddm with, say, lxdm, you'll see the login screen (at least - using the intel driver and the edited xorg.conf; probably even without it), and you'll be able to login.
This is not the end of your troubles, though. If you start a KDE session, Plasma will crash unceremoniously. The session will still "work" in the sense that restored apps will come up and function properly, and Alt+F2 for launching will work too.
If, however, you install another desktop environment (e.g. LXDE) and start that - it should work.
Annoying.

A: I just installed CUDA on Ubuntu 16.04 successfully, and using only intel skylake gpu for display.
The official installation document is better now, really helpful. You chould take a look at advanced setup and Faq. That fix my problem.
I choosed Runfile installation.(section 4.2) Followings are my tips:

*

*Remove noveou driver first; check with lsmod |grep noveou

*stop X, run cuda-xx.run --no-opengl-libs

*copy the "device node verification" script and make it a startup script (I copy it into /etc/rc*.d/ ,care of the naming rule)

*source the previous script, check with ls /dev/nvidia*. If all things are fine, cuda should work.

*now edit xorg.conf, removing the nVIDIA video card.

if you see [drm] failed to open drm device for null, check and fix with step 4.
Since I use intel skylake, I install drm, guc firmware from 01.org.
(check with lsmod | grep intel) or lspci -k | grep -A 2 VGA
In xorg.conf,
Section "Device"
        Identifier  "Card0"
        Driver      "intel"
        BusID       "PCI:0:2:0"
EndSection


text:
Q: Show total no. rows for in HTML  I need your help in displaying the total number of rows for the available tables in the appropriate span. There are 3 tables and I want the below code to show the total no. of rows in the first table in span1 & the total no. of rows for the second table in span2.
The JavaScript is:
function count() {
    var tables = document.getElementsByClassName("tablesorter");
    var rows;
    var span = Array();

    for (var i = 0; i < tables.length; i++) {
        rows = tables[i].rows.length-1;
        alert(rows);
        alert(span[i]);
        span[i].innerHTML = rows;
    }

}

However, span[i] is not picking up the value and print it in the HTML span.
The HTML code is:

I am looking forward your assistant and help.

A: Use this function instead:
function count() {

    var tables = document.getElementsByClassName("tablesorter");

    var rows;

    for (var i = 0; i < tables.length; i++) {

        rows = tables[i].rows.length-1;

        alert(rows);

        document.getElementById("span" + (i + 1)).innerHTML = rows;

    }
}

You are never referring to the span, so that is why I used
document.getElementById("span" + (i + 1)).innerHTML = rows;


text:
Q: Arrays in Java? so i need to find a way to get my program to hold a string of names that the user is going to input. the array will hold a total of five names and is going to output all the information back to the user with their entered names. I am using a single main class.
so far this is what i have:
import java.util.Scanner;
public class Names {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here

    Scanner input = new Scanner (System.in);
     String [] name = new String [5];

     for (int i = 0; i < 5; i++){
        System.out.println("Enter name: ");
        String UserNames = input.nextLine();
         name[i] = UserNames;

       }
    }
}

I need to know if this is storing the names correctly in the array? I am very new to java and need some insight from the pros. Also if i want to get the names to repeat back to them will it look like this
{
System.out.println(" The names you entered are:" + UserNames );
}

Thanks for any help I can get.

A:
i need to know if this is storing the names correctly in the array?

So, print the array once you've filled it with Arrays.toString()

A: It seems you're doing it right.
To print them, you need to loop through the array.
for (int i = 0; i < name.length; i++){
    System.out.println(name[i]);
}

A: as suggested by Kepani you can try Arrays.toString(arrayVarName)
public static void main(String[] args)
{
     String [] arx = {"alpha", "beta", "gamma", "penta", "quad"};
     System.out.println(arx); // returns object hashcode and not the strings stored
     System.out.println(Arrays.toString(arx));
}

in case you do not know whether you will be getting 5 inputs or more you can try arraylist
public static void main(String[] args)
{
    ArrayList<String> strList = new ArrayList<String>();
    strList.add("alpha");//Construct would be strList.add(input)
    strList.add("beta");
    strList.add("gamma");
    strList.add("penta");
    strList.add("quad");

    System.out.println(strList);
    System.out.println(strList.toString());
}

as you would realize due to the use of generics ArrayList.toString() return the complete list of strings store


text:
Q: How to send back to client custom response in the case of an exception from a Spring filter? What is the proper way to send back to client custom response in the case of an exception from a Spring filter? OR Is it possible at all?
I tried:
this @ControllerAdvice and @ExceptionHandler are out of rich with Filters
this  response.sendError(status, msg); just does nothing
this  absolutely no effect from these
and many many many other..
My security config:
@EnableWebSecurity
public class SecurityConfig {

    @Bean
    public SecurityFilterChain mySecurity(HttpSecurity http) throws Exception {
        http.requestMatchers((requests) -> requests.antMatchers("/**"))
                .authorizeHttpRequests((authorize) -> authorize.anyRequest().permitAll());
        http.csrf().disable();
        return http.build();
    }
}

The filter:
@Component
public final class MyFilter extends OncePerRequestFilter {

    private TypeA typeA;
    private TypeB typeB;

    public MyFilter(TypeA typeA, TypeB typeB) {
        this.typeA = typeA;
        this.typeB = typeB;
    }

    @Override
    public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
                                                                                throws ServletException, IOException {
        if (request instanceof HttpServletRequest) {
            if (typeA.getCount() > 500 && typeB.getCount() > 400) {
                filterChain.doFilter(request, response);
            } else {
//                response.getWriter().write("some err");
//                response.sendError(HttpStatus.UNAUTHORIZED.value(), "Unauthorized attempt.");
//                response.setStatus(HttpStatus.UNAUTHORIZED.value(), "Unauthorized .");
                throw new AccessDeniedException("Unauthorized attempt.");
            }
        }

    }

So - None of the above changes the default response:
{
    "timestamp": "2022-09-28T14:04:39.657+00:00",
    "status": 403,
    "error": "Forbidden",
    "path": "/api/some/path"
}

Is it possible to send back to client custom error message? I see a lot of people suggest Controller Exception Handling mechanisms, but they get in action only after the filter chain, when there is an exception from A CONTROLLER.
EDIT:
PS: Please, do not mark my question as duplicate - there are tens of such questions - the answers are not working for me.


text:
Q: Assign color to lines ggplot2 I would like to do a line plot with 5 different line using ggplot2. I used the following code.
plot <- ggplot() +
  geom_line(data=MS, aes(x=date, y=MSCI.World.PI, color='MS')) +
  geom_line(data=S, aes(x=date, y=SandP.TR, color='S')) +
  geom_line(data=BR, aes(x=date, y=MSCI.BRIC.PI, color='BR')) +
  geom_line(data=HF, aes(x=date, y=HFRX, color='HF')) +
  geom_line(data=LP, aes(x=date, y=LPX50.TR, color='LP')) +
  scale_color_manual(values = c("red", "blue", "green", "yellow", "violet" )) +
  labs(color="Indices") +
  xlab('Time') +
  ylab('Price')
plot

The result is the following plot:

The "wrong" part is, that the colors did not get sorted as was intended, meaning the first line ("MS") is not assigned to the first color ("red"). It seems like the line get assigned to the colors alphabetically.
Is there any way that I can change the assignment in such way that the first line is assingned to the first color ins the scale_color_manuel statement, the second line to the second color and so forth?

A: Specifying the colours as a named vector does the trick, and makes the mapping explicit:
scale_color_manual(
      values = c(
           MS="red",
           S="blue",
          BR="green",
          HF="yellow",
          LP="violet" ))


text:
Q: DigitalOcean - cap staging deploy error on precompiling assets When I run cap staging deploy:check it succeeds. When I run cap staging deploy it succeeds until deploy:assets:precompile at which I get this error:
 01 ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
 01 rake aborted!
 01 ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "links" does not exist
 01 LINE 1: SELECT "links".* FROM "links"

After googling, I believe the problem is that it is trying to create the relations before creating the tables. I have since tried many solutions including placing config.assets.initialize_on_precompile = false in application.rb but none of them work.
I desperately need help. Thank you!

A: The problem is that the asset:precompile task boots up the full Rails environment. Do you have any initializers or something that use Link model?
Dirty workaround:
ssh to the staging server, go to :deploy_path you've set in capistrano's config and then in last release folder. After that manually run RAILS_ENV=staging bundle exec rake db:migrate.


text:
Q: How to run a command without hitting Enter Key? Accidently I mapped Enter via xkbset to Pointer_button2.
Now every time I hit Enter some gibberish text appears.
I thought of a workaround involving remapping it back, but that means I will have to run a command xmodmap -e "keycode 135 = Pointer_Button2" (or any other keycode but that of Enter). But I'm not able to run this command in terminal, without hitting Enter.
How do I do so?
I'm running Ubuntu 12.04.

A: CTRL+O is another option. With bash it executes the command and moves to the next most recent in history, it is useful to cycle back through a chain of previously executed commands.

A: Run the command from a non-X terminal.
CTRL+ALT+F2 should get you to a normal console.  Login as your normal user, and then run the command there.
xmodmap only affects X sessions so it needs DISPLAY to work outside the X server, like this:
DISPLAY=:0 xmodmap

A: If you have a mouse then just copy this -> "
"
and paste next to your command and then paste entire command in the terminal.
Like

A: You could put it into a script (.sh) and then double click it. Most modern desktop environments give the option of running a script instead of opening it in a text file.

A: You can use CTRL+J or CTRL+M as an alternative to Enter. They are the control characters for linefeed (LF) and carriage return (CR).

A: If you have a mouse and graphical display you can copy the end of a previous line in your terminal and paste it onto the end of your command.


text:
Q: How to access nested resources in API I have a Ember app that uses a Rails API.  I have a teams table and a referees table, both link to another table called refereeTeamStats.  I am trying to get all the refereeTeamStats for a team and include the referee resource so I can get the referee's name.  In short, I need my Ember app to call /teams/:team_id/refereeTeamStats?include=referee
Initially I had my app get the refereeTeamStats through the route by doing this:
model() {
  return this.modelFor('teams/show').get('refereeTeamStats');
}

This will call /teams/:team_id/refereeTeamStats however, this will not include the referee resource.  What is the best way that I can get the refereeTeamStats with including a resource (referee) on a nested resource (refereeTeamStats)?

A: Your refereeTeamStats serializer could implement the DS.EmbeddedRecordsMixin, and define
attrs: {
  referee: { embedded: 'always' }
}

So that if your API returns the referee key in the refereeTeamStats payload, ember will deserialize it to the correct object.

A: I ended up going about this a different way. Since I was using the JSONAPI::Resources gem, I was able to do /refereeTeamStats?filter[team_id]=:team_id&include=referee instead. To do that, I did this:
model() {
  const team = this.modelFor('teams/show');
  return this.store.query('refereeTeamStat', {filter: {team_id: team.get('id')}, include: 'referee'});
}


text:
Q: Animate generated tables cells when div container is partially visible on screen I have a code to generate tables of 0's and 1's within specific div containers across the page and they work simply fine. The new challenge I'm trying to achieve is to animate these 0's and 1's appended to this div containers whenever the div is partially visible on the screen, the idea is to flip the numbers for at least 1 sec? change them constantly until the second completes and leave the new number there. I have the trigger code to verify whenever this div is visible on screen but not sure how to update the created and appended cells with 0's and 1's to each independent div container.

var min = 0;
var max = 1;

function drawTable(divElement, totalRows, cellsInRow) {
    // get the reference for the body
    var randomNumbers = document.querySelector(divElement);

    var observer = new IntersectionObserver(function(entries) {
      // isIntersecting is true when element and viewport are overlapping
      // isIntersecting is false when element and viewport don't overlap
      if(entries[0].isIntersecting === true)
    // for now I can render this on console log but how to animate the cells (0's and 1's) during a sec for that specific container or divElement?
        console.log(divElement + ' is visible now');
    }, { threshold: [0] });

observer.observe(document.querySelector(divElement));

    // creates a
 element
    var tbl = document.createElement("table");
    tbl.style.width = '100%';
    tbl.style.height = '100%';

    // creating rows
    for (var r = 0; r < totalRows; r++) {
        var row = document.createElement("tr");

        // create cells in row
        for (var c = 0; c < cellsInRow; c++) {
            var cell = document.createElement("td");
            getRandom = Math.floor(Math.random() * (max - min + 1)) + min;
            var cellText = document.createTextNode(Math.floor(Math.random() * (max - min + 1)) + min);
            cell.appendChild(cellText);
            row.appendChild(cell);
        }

        tbl.appendChild(row);
    }

    randomNumbers.appendChild(tbl);
}
window.onload = (event) => {
    drawTable(".randomNumbers2", 8, 8);
    drawTable(".randomNumbers3", 16, 16);
    drawTable(".randomNumbers4", 8, 8);
    drawTable(".randomNumbers5", 24, 24);
};
.randomNumbers2 {
  width: 150px;
  height: 150px;
  background-color: red;
  position: relative;
  float: left;
  }

.randomNumbers3 {
  width: 300px;
  height: 300px;
  background-color: blue;
  position: relative;
  float: right;
  margin-top: 900px;
  }

.randomNumbers4 {
  width: 150px;
  height: 150px;
  background-color: green;
  position: relative;
  float: left;
  margin-top: 1750px;
  }

.randomNumbers5 {
  width: 450px;
  height: 450px;
  background-color: purple;
  position: relative;
  float: right;
  margin-top: 2500px;
  }


text:
Q: CSS Footer W/ Gradient - Not Sticky What my designer wants and what I'm trying to code is a footer that begins at the bottom of dynamic content (actually, they want the footer to start beneath the content area up about 20px - but that's something else).  The thing is, they have a gradient that they want down there that expands as the browser window does.
Due to the gradient I can't just cheat and declare the window color as black and if I set the size of the footer to the height of the gradient, I end up with the scroll bar.  I feel I must be missing something incredibly obvious, but I've been staring at it so long I just am seeing cross-eyed.

            I am ze content area (for now)

        I AM THA FOOTAH
 So much cooler than the header these days

body
{
    background-color: grey;
    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
    margin: 0px;
    padding: 0px;
}

div
{
    display: block;
}

#page
{
    background-color: white;
    margin: 0px auto;
    padding: 0px;
}

#header
{
    background: url("http://kjunek.com/images/header_background.png") repeat-x;
    color: yellow;
    height: 240px;
}

#content
{
    background-color: white;
}

#footer
{
    background: #030a19 url("http://kjunek.com/images/footer_background.png") repeat-x 50% 0%;
    height: 626px;
    overflow: hidden;
    color: white;
}

Kind of like http://roughtech.com/t/oppsticky.html from  Doing the opposite of CSS Sticky Footer only I want the red to continue down to the bottom of a window with a gradient that fades to black.
Thanks!

A: Deleted my last answer - it does not work either. In standards compliant modes the only content that can not be scrolled to is content inside a parent which is hidden. And except for bugs it is not shown. What I was looking at was a IE bug.
Sorry no can do in CSS as it stands today.
If you need to do a calc today you would need to use jquery to get the heights of the elements then calculate the height needed for the footer; And, use CSS gradients http://robertnyman.com/2010/02/15/css-gradients-for-all-web-browsers-without-using-images/ so you can go from your shade of navy to your shade of black. I would discourage this approach as when you start to consider all of the possible resolution situations the calculation it will become rather complex and I assume they may want to redesign the heights depending on different resolutions.


text:
Q: How to use mail_to tag in rails 4 using haml? I want to use mailto with my rails 4 in haml, that too with rails i8n. I tried doing it this way
%a{href: Content.email, mailto: true, target: '_blank'}
= t :footer_email_us

But, in this way when I click on the link, I get the wrong email id attached in the to field.

A: I have found the correct way to do it, using the internationalization text.
= mail_to Content.email, t('footer_email_us')


text:
Q: If statement which determines which React element to be rendered, weird behaviour I created a Sprite component which takes in 'icon' as a prop and determines which svg to render but I'm experiencing some weird behaviour.
I've had to resort to this method because I haven't been able to find a way to work with svg's (how to change their fill color!)
const Sprite: React.SFC<ISpriteProps> = (props: ISpriteProps) => {

const color = props.color || '#ACACAC'

let icon

if (props.icon === 'pin') {
    icon = <Pin color={color} />
} else if (
    props.icon === 'profile'
) {
    icon = <Profile color={color} />
}

return (
    <React.Fragment>
        {icon}
    </React.Fragment>
)

}

export default Sprite

Using the <Sprite/> in my <Navigation/> component like so

    <ProfileIcon onClick={this.onProfileSelected}>
    <Sprite icon='profile'
    color={this.state.viewing === 'profile' ? '#5A4DB2' : ''} />
    </ProfileIcon>
    <LogoIcon onClick={this.onLogoSelected}>

    </LogoIcon>
    <MessagesIcon>

    </MessagesIcon>

and in my <CardBlock/> component like so
const Card: React.SFC<{}> = (place) => {
  return (
    <CardOuter>
        <CardPhoto>

                <Sprite icon='pin' color='#fff' />Fitzroy
        </CardPhoto>
        <CardDetails>

Vegie bar

7:00pm

            <ProfileIcons />
        </CardDetails>
    </CardOuter>
  )
}

For some reason the icon prop I choose to pass in to the Navigation component Sprite is determining what is rendered for the Sprite's in CardBlock as well.
E.g if I make it 'profile' in Navigation it will make all sprites render the profile icon for Sprite as well even though I specifically pass in 'pin'. If I switch it to 'pin' in Navigation, all CardBlock sprites will render the pin icon.
I don't understand, is this some weird React render quirk?
EDIT: So I thought it was something to do with stateless functional component rendering so I changed Sprite to a Component
class Sprite extends React.Component<ISpriteProps, {}> {
public render() {

    const color = this.props.color || '#ACACAC'

    const icons = {
        'profile': Profile,
        'pin': Pin
    }
    const ActiveIcon = icons[this.props.icon]

    return (
        <ActiveIcon color={color} />
    )
}
}

Still no love, it's rendering ALL of them as profile icons if I pass 'profile' as icon prop to Sprite in Navigation component.
EDIT: Solved. It was something wrong with the svg's

A: you could use classnames library to select what class should be added to React element, including svg. And in css you give fill rule that you want. https://github.com/JedWatson/classnames


text:
Q: My server has available memory but my zope process seems to be "capping" at 3GB. Increasing cache-size is not helping anymore The screenshot below shows the change in cache related state of my zope instance over time (3 months so far).
We've increased the cache size several times over the period from 3000 all the way up to 6000000. With the exception of one recent blip, we have hit a ceiling of 30 Million (not sure what parameter that is) (see the 'by year' graph). This happened at a cache size of about 1000000, after which, changes to the cache size seemed to have no effect on the cached objects or memory usage of zope.
The zope/plone process moved from using about 500 MB of memory to using 3GB (we have 8GB on this server).
What I expected was that sliding the cache size upwards would allow zope to take advantage of more of the available server memory, but it is stuck at 3GB (out of a potential 8GB on the server).
Is there another setting that might be "capping" things at 3GB?

A: At a guess, your OS is limiting per-process memory size.
In a bash shell, check ulimit -v to see if a virtual memory limit is set. See man bash for the full list of options for that command.
See Limit memory usage for a single Linux process for more information on how to use ulimit.

A: I don't know what's going on with the memory of your server but you are doing this the wrong way: you simply can't have 6 million objects on memory, that's impossible: on a typical installation in Plone 4.x you should need somewhere in between  50 GB and 150 GB of memory for that.
to solve this we need more information: which Plone version are you using? how many objects do you have in your database? how many threads? what's the architecture of your server, 32 or 64-bit?
second, be sure to install the latest version of the munin.zope plugin to collect reliable information about your server (hat tip to Leo Rochael).
third, read this thread on the core developers list to understand how to calculate a more realistic number for your cache size (hat tip to Hanno Schlichting).
fourth, move the number up slowly and take time to monitor the results; check for total number of objects in memory and avoid memory swaps at any cost. You can stop increasing cache size if you see the number of objects is below your goal value. remember: you're never gonna have all the objects in memory, that's quite difficult because people tend to visit mostly only a subset of your content.
fifth, if you are in Plone 4.x test DateTime 3.0.3 (on a staging server before put it in production) this could decrease further your memory consumption by up to 40% (somebody told me it now works also in Plone 3.x, but I haven't check it my self).
sixth, share your result on the Plone setup list!
good night and good luck!

A: A 32-bit platform -- don't know if this is limited to Intel -- is limited to 3GB per process. That is because it can only address up to 4GB per process, and the bottom 1GB is used by the kernel. Of course PAE allows you to access up to 64GB, but there are certain per process limitations which you are running into here. You really cannot run a high-traffic plone site on a 32-bit platform anymore. Quite often the simplest solution is to upgrade your OS to the 64-bit version, because unless you have seriously ancient hardware, it should already be capable of running x86-64.


text:
Q: Use "set timing on" in Unix shell script I am using the below syntax in a shell script to execute few procedures in parallel:
#!/usr/bin/bash
echo"exec procedure_1"|sqlplus USR/PASS@TNS & >> $LogFile
echo"exec procedure_2"|sqlplus USR/PASS@TNS & >> $LogFile

I need the execution timing in the log file but SET TIMING ON is not working if used as below:
#!/usr/bin/bash
echo"SET TIMING ON exec procedure_1"|sqlplus USR/PASS@TNS & >> $LogFile
echo"SET TIMING ON exec procedure_2"|sqlplus USR/PASS@TNS & >> $LogFile

What am I doing wrong and how would I go about this?


text:
Q: Select input with Laravel Collective {!! Form::select('country',['1' => 'Albania','2'=>'Kosovo','3'=>'Germany','4'=>'France'],null, ['class'=>'form-control','placeholder'=>'Select Country']) !!}

This type of input doesn't take the values of the array but instead, it takes the pre-default value of option inside select.enter code here

A: According to the Form Collective documentation, the first argument of the Form::select() is the name of the select box, the second is an array of the input values while the third is the default value (this could be set to null). The fourth is an optional array of attributes/values.
This should work for you.
{!! Form::select('country',['Albania' => 'Albania','Kosovo'=>'Kosovo','Germany'=>'Germany','France'=>'France'],'Kosovo',['class'=>'form-control','placeholder'=>'Select Country']) !!}

A: {!! Form::select('country', [null => 'Select Country'] + ['Albania' => 'Albania','Kosovo'=>'Kosovo','Germany'=>'Germany','France'=>'France'], null, ['class' => 'form-control']) !!}

For more information : https://laravel.com/docs/4.2/html#drop-down-lists


text:
Q: Solving $\beta - \frac{1}{\sqrt{3}}\sec{\beta}=2$ for $180^\circ\leq\beta\leq 270^\circ$ I am required to solve this equation:

Solve
$$\beta - \frac{1}{\sqrt{3}}\sec{\beta}=2$$
for $180^\circ\leq\beta\leq 270^\circ$.

I am aware that I can convert $\sec{\beta}=\frac{1}{\cos{\beta}}$.
So,
$$\beta - \frac{1}{\sqrt{3}}\sec{\beta}=2$$
$$\sqrt{3}\beta - \sec{\beta}=2\sqrt{3}$$
$$\sqrt{3}\beta - \frac{1}{\cos{\beta}}=2\sqrt{3}$$
$$\sqrt{3}\beta \cos{\beta} - 1=2\sqrt{3} \cos{\beta}$$
$$\sqrt{3}\beta \cos{\beta} - 2\sqrt{3} \cos{\beta}=1$$
$$(\beta-2)\sqrt{3} \cos{\beta} =1$$
.. I stuck here.
If anyone can explain to me how to achieve this I would be very grateful.


text:
Q: predict seasonality and trend combined, better approach? The nature of my problem combines seasonality (yearly repeated) and trend (over all data). I have one observation per month. To simplify, let's say I have this:

Which can be perceived as this:

So far, I observed that trying any type of linear regression (also including support vector regression) on all data does not give me any acceptable results.
So I changed to a different approach:

*

*Learning seasonality using entire years as units to train (here I learn the curvy shape in one year)

*Learning the trend by simple linear regression on all data

I combine results from 1 and 2 in order to magnify shape learned in 1 by trend increase in 2. So far, it gives me acceptable results, but my humble intuition (my experience is mostly related to classification problems) is that there must be a better approach which is specifically suited for this kind of problem.
Actually I have two questions related to the problem:

*

*Is there a better approach?

*Let's say I want to predict a whole year, what's best: to include predicted data to predict further months in a more informed way OR to avoid it and predict strictly based on training data (taking into account that predicted data might be missleading)?

A: There are several methods and models for this kind of analysis, for example: exponential smoothing, ARIMA time series models or structural time series models. The topic is too broad to be covered here. Below, I give some examples in R just for illustration. For further details, you may start for example looking at this online textbook (Forecasting: principles and practice by R. Hyndman and G. Athanasopoulos).
As regards your second question, my recommendation is in line with Winks's answer. I would stick to fit a model using the sample data and then apply one-step ahead forecasts. If any, you can remove the last year from the sample and get forecasts for that year upon different methods or models. Then, you can choose the model with the best performance according to some accuracy measure such as the Mean Absolute Error (minimum MAE).

The monthly totals of airline passengers (1949 to 1960) is a common
example used to illustrate time series models and methods (this series has also some resemblance to the patterns that you show).
In R, you can obtain one-year-ahead forecasts (blue line) by means of the Holt and Winters filter as follows:
x <- log(AirPassengers)
res1 <- HoltWinters(x)
pred1 <- predict(res1, 12)
plot(cbind(x, pred1), plot.type = "single", ylab = "", col = c("black", "blue"))

Obtaining confidence intervals for the forecasts is easier by means of parametric methods. An ARIMA model can be used to obtain forecasts and 95% confidence intervals (red dotted lines) as follows:
require("forecast")
res2 <- auto.arima(x)
pred2 <- predict(res2, 12)
plot(cbind(x, pred2$pred, pred2$pred + 1.96 * pred2$se, pred2$pred - 1.96 * pred2$se),
  plot.type = "single", ylab = "", col = c("black", "blue", "red", "red"), lty = c(1,1,2,2))

The basic structural time series model is suited for the kind of components that you describe. In addition to forecasts and confidence intervals, an estimate of the trend and seasonal components is also obtained (this post gives an example that includes forecasts for the components):
require("stsm")
mod <- stsm.model(model = "BSM", y = x, transPars = "StructTS")
res3 <- maxlik.td.optim(mod, KF.version = "KFKSDS",
  KF.args = list(P0cov = TRUE), method = "L-BFGS-B", gr = "numerical")
pred3 <- predict(char2numeric(res3$model), x, n.ahead = 12)
plot(cbind(x, pred3$pred, pred3$pred + 1.96 * pred3$se, pred3$pred - 1.96 * pred3$se),
  plot.type = "single", ylab = "", col = c("black", "blue", "red", "red"), lty = c(1,1,2,2))

A: If your data are simple, and you are just toying around, the decomposition into seasonal and overall trend should already be pretty good. But if you want to dig deeper, there is a more formal approach: Using Kernels to define the relations between your points.
The best exemple I have seen of this kind of task is on the Mauna Loa CO2 concentration dataset (Wikimedia Commons illustration)

A possible model for this dataset is shown in Gaussian Processes for Machine Learning, by Rasmussen & Williams (Second edition available online), in section 5.4.3.
Warning: Gaussian Processes (Wikipedia) are not easy to understand, especially if you do not have a background in Kernels. In a very simplified way, it is like doing Nearest Neighbour regression (a point has the value of close points), but using Kernels (Wikipedia) to encode prior knowledge about the data and the form of the function. What kernels allow you to do is specify how "related" two points are.
In this case, you can build a kernel that defines "relatedness" by how close in month we are, and how close in years, such that 12/2015 is related to 01/2016 and 12/2014, but not so much related to 06/2015 and not to 06/2004.
Since you mention Support Vector Regression, you could probably do something similar using such a Kernel there.
Considering your second question, it would be best to leave predicted data outside of your training data. Doing this does not add information, and if your model is biased, the predicted data will only reinforce this bias and lead to poorer prediction. This is true for all methods.


text:
Q: Running Google Chrome on Ubuntu 12.04 64 bit I have successfully installed right version of Chrome from here:
https://www.google.com/intl/en/chrome/browser/
However, when I am trying to open it via the terminal I get the following error:
labsPC:~$ google-chrome-stable
[26712:26712:0916/155253:ERROR:process_singleton_posix.cc(264)] Failed to create /home/invictuslabs/.config/google-chrome/SingletonLock: File exists
[26712:26712:0916/155253:ERROR:chrome_browser_main.cc(1155)] Failed to create a ProcessSingleton for your profile directory. This means that running multiple instances would start multiple browser processes rather than opening a new window in the existing process. Aborting now to avoid profile corruption.
What should I do? Thanks.


text:
Q: Cakephp, Retrieve Data for HABTM Models using conditional find There are 2 Models: Project & Category that are bind with HABTM relationship.
I would like to perform a search from projects controller that can do the following:
FIND all DISTINCT Project.scedule WHERE Category.slug != 'uncategorised'

Apologies for the syntax, I'm no sequel expert.
What I have managed to do is to retrieve all projects that do not belong to Category uncategorised into an array however I'm not sure as to how to search again the array result for DISTINCT Project.schedule values (needed to fill out a form drop down)

A: Before answer this question,again I suggest you to read the HABTM in cookbook of CAKEPHP carefully,then you can finish jobs like this yourself.
$this->Project->bindModel(array(
'hasOne' => array(
    'CategorysProject',
    'FilterCategory' => array(
        'className' => 'Category',
        'foreignKey' => false,
        'conditions' => array('FilterCategory.id = CategorysProject.category_id')
))));
$this->Project->find('all', array(
    'fields' => array(DISTINCT (Project.scedule)),
    'conditions'=>array('FilterCategory.slug !='=>'uncategorised')
));


text:
Q: Gulp not creating JS files on live server I have gulp installed on my project.
Locally, everything works fine when I run gulp scripts:dev it creates the file bin/min.js.
However, when I run the same task on the production server it doesn't create the bin/min.js file, but when running the whole gulp it successfully creates bin/min.css.
I have the same version of gulp, node and npm locally and on the server.
Here is my task :
gulp.task('scripts:dev', ['cleanJs'], function() {
    return browserify({ entries: './scripts/main.js', debug: true })
        .transform(babelify, {"presets": ["es2015"], "sourceMaps": true})
        .on('error', handleErrors)
        .bundle()
        .on('error', handleErrors)
        .pipe(source('min.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init({ loadMaps: true }))
        .pipe(uglify())
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest('./bin/'))
        .pipe(gulpif(global.livereload, livereload()));;
});

Here is my scripts:prod task that is also not working (the one I actually want but that is not creating the file either.)
gulp.task('scripts:prod', ['cleanJs'], function() {
    return browserify({ entries: './scripts/main.js', debug: false })
        .transform(babelify, {"presets": ["es2015"]})
        .bundle().on('error', handleErrors)
        .pipe(source('min.js'))
        .pipe(buffer())
        .pipe(uglify())
        .pipe(gulp.dest('./bin/'));
});


text:
Q: System.InvalidOperationException due to collection modification on call to Application.Exit() I've got this really, really weird error that I've never been able to pin down (it happens very rarely). Basically, I have a C# application that was randomly throwing an unknown exception on exit. I've managed to catch it in the debugger this time, and it turns out that calling Application.Exit() is throwing a System.InvalidOperationException with the following message:

A first chance exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
Additional information: Collection was modified; enumeration operation may not execute.

I'm not sure what this collection that has been allegedly modified is, or who it was that modified it.
The stack trace isn't very helpful:

mscorlib.dll!System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
  + 0x13f bytes  System.Windows.Forms.dll!System.Windows.Forms.Application.ExitInternal()
  + 0x112 bytes  System.Windows.Forms.dll!System.Windows.Forms.Application.Exit(System.ComponentModel.CancelEventArgs
  e) + 0x65 bytes

Any idea how I can find out which ArrayList it is that has been modified? I don't think it's anything I'm doing explicitly, more likely an action I'm doing that's modifying the underlying state of the .NET framework during the middle of an operation that MS wasn't expecting..

A: Unusual, never seen this before.  The Application.ExitInternal() method iterates the Application.OpenForms collection.  Clearly this collection is getting modified while it is doing so.  There are few possible causes for this, I can only come up with one.  One of your forms has overridden the OnFormClosing() method or subscribed the FormClosing event.  And is doing something that modifies the OpenForms collection.  Could be disposing the form object or creating a new form instance or modifying a form property that causes the window to be re-created, like ShowInTaskbar.
You won't find this code back in the call stack.  Review your On/FormClosing code.  Comment code out if you can't find it quickly.

A: We just spent days on this problem too... where we got the 'System.InvalidOperationException' exception, and the app (in this case using a twain library from DynamSoft).  Apparently we should not have been calling the CLOSE() after calling application.exit.  Commenting out the Close made the exception go away, and made the app end normally. Visually, the app would display a weird message box from Microsoft saying "would you like to submit more information about this problem" - WHAT PROBLEM?  it didn't display anything before this, so off we went digging through stack traces.
                Utils.Logger.Info("", "AsystScanner/dynamicDotNetTwain2_OnPostAllTransfers");
                Utils.Logger.Info("Closing down application!", "AsystScanner/dynamicDotNetTwain2_OnPostAllTransfers");

                // caller should close down app, added 3/3/15
                dynamicDotNetTwain2.CloseSource();
                dynamicDotNetTwain2.CloseSourceManager();

                System.Windows.Forms.Application.Exit();
no no!  don't do a close here.
                //try
                //{
                //    Close();
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message + "  Routine=dynamicDotNetTwain2_OnPostAllTransfers/Close() statement failed. [EJS1503031630]");
                //}
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "  Routine=dynamicDotNetTwain2_OnPostAllTransfers [EJS1503031631]");
            }


text:
Q: Default using statements in Xamarin Studio I want to add a default using statement to my Xamarin Studio project.  Specifically, instead of the default
using System;

I want every new file to start with
using System;
using System.Collections.Generic;

Can I do that?
EDIT: I'm on a mac.

A: This may be of some help:  Default using directives in new C# files
They are part of the template. You can amend the new class template.  This should be of some help as well:  http://blogs.msdn.com/b/steve/archive/2007/04/10/changing-the-default-using-directives-in-visual-studio.aspx
In case the links die, here is a snippet:  "if you open %Program Files%\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033\Class.zip, you can modify the class.cs file within that's used to generate all new C# source files"


text:
Q: Sample PDF with embedded flash video? Does anyone know where i can view a sample PDF that has an embedded flash video? I know it's silly to ask because you would think any tech-oriented user should be able to find one using Google but I really could not.
Another question I have is, how hard would it be to embed a flash video into a PDF file using an API in C#? One possible requirement I may have is to generate a PDF on the fly with all required content available at hand (ie: text, images and potentially video).

A: Here from Technology Review, TR 35
http://www.technologyreview.com/TR35/Profile.aspx?trid=688
http://www.technologyreview.com/files/20747/TR35_Dries_Buytaert.pdf?download&track

A: AlivePDF is worth a look if you're working with PDF's in flash http://alivepdf.bytearray.org/

A: You could use pdflatex to generate the pdf's on the fly and using the movie15 package embed the flash video (or other types of video). An example with embedded video is here.
iText is Java library with C# port for pdf generation and it appears possible to embed flash.


text:
Q: Generic interface with generic elements and constraints I would like to define a generic library containing generic elements :
public interface ILibrary<T>

My generic elements are defined like this :
interface ILibElement<T, IVersion<T>>

I would like to add the constraint saying that elements in the Library must implement ILibElement. So I thought I could change my definition of the ILibrary like this :
public interface ILibrary<T> where T : ILibElement<T, IVersion<T>>

But I must add type parameters.
So I thought doing something like :
public interface ILibrary<ILibElement<T, IVersion<T>>>

But T is undefined.
I could not find the right syntax. How could I express such a constraint ?

A: I believe you're just looking to do this:
where T : ILibElement<T, IVersion<T>>

since ILibElement is expressed as ILibElement<T, IVersion<T>> you just need to specifically implement that interface with the T that you're implementing.

A: I think you can try a logic like this
public interface ILibrary<T,V> where T:ILiBelement<T,V> where T:ILiBelement<T,V>
    where V:IVersion<V>
{

}
interface ILiBelement<T,V> where V:IVersion<T>
{

}
interface IVersion<T>
{

}

hope this help

A: Generic type parameters must be specified as identifiers; the constraints may use more complex nested formulations, but the parameters themselves must not.  If one wanted a generic method which took a parameter of some type Nullable<T>, one wouldn't specify it as:
void ThisWontWork<Nullable<T>>(T it) where T:struct {...}

but instead as:
void ThisWillWork<T>(Nullable<T> it) where T:struct {...}

If your collection may be holding further-qualified generic things which will all be of one type, you may wish to add that type as a type parameter for your collection:
class ListOfLists<T,U> where T:IList<U>

If your collection will be holding things that implement a generic interface with a variety of  generic types, but you'll only need to use members which do not involve such types, then you should if possible have the members which don't care about the generic type segregated into their own interface, which could be inherited by the full generic.  For example, although Microsoft didn't design their IDictionary this way, it could have been defined as something like (in part:)
interface ICheckIfContained
  { bool Contains(object it); }

interface ICheckIfContained<in T> : ICheckIfContained
  { bool Contains(T it); }

interface IDictionary<in TKey, out TValue> : ICheckIfContained<TKey> ...

If one wants to hold a collection of references to dictionaries purely for the purpose of scanning the keys keys in them, without regard for what those keys would map to, a generic parameter constrained to ICheckIfContained could serve such a purpose.


text:
Q: iOS Layer Rendering Queue I ran into a behavior I don't understand yet. My code basically does this:

*

*Create view with some custom UIView content (Views with drawRect), this view has no superview yet, so the Quartz subsytem dosen't call it's [layer display].

*Then i do a renderInContext of the view.

*The problem is that sometime the view is rendered perfectly, sometimes it does not render the subviews and it does not call their drawRect.
Why does it happen? I'm missing something. I actually know that the same layer can't be rendered simultaneously. But this view is not rendered on the main thread since it doesn't have a superview.
Thank you much

A: Well interesting, without seen the source code is almost impossible to understand, but I got few tips that you could use.

*

*add the view to a superview setting it's alpha to 0

*try to add it out of bounds of the superview

*try to call -setNeedsDiplay on that view

I don't know if they works, rendering system isn't a simple task, but I will give a shot.Ther one thing I didn't get, usually subviews are added as subviews, but you say that you do something with them inside the drawrect. Don't add subviews in drawRect drawRect and addSubview: custom drawing affects which views?


text:
Q: Windows Media Player Web Interface & Remote Video I'm using MPC web interface to control the player through a web page.
calling
http://127.0.0.1:13579/browser.html?path=C:\path\to\video.mp4

in a browser loads a video in MPC
http://127.0.0.1:13579/command.html?wm_command=889

plays the video currently loaded
Now my problem is that I want to load a video located on the network, something like:
http://127.0.0.1:13579/browser.html?path=http://path/to/video.mp4

And that doesn't work, I'm just redirected to the browser root
If in MPC I do File>Open File... and type the exact same video address (http://path/to/video.mp4) it is properly loaded and read.
Any idea how to make this work would be welcome


text:
Q: Adding a transition animation to a RadioGroup and Radiobutton I have a RadioGroup with four check buttons. I'd like to create a "slide" transition animation so that if the user clicks the bottom most radiobuttom while the topmost is currently checked, my custom checkbox graphic would slide from the top position to the bottom. Any ideas? I'd like this to work on Android 2.0 and above.

A: If I am imagining the same thing as you (which I might not be) you're going to need 2 Animations. One to scoot the disabled buttons down, and one to scoot the chosen button up to the top.
You are going to use TranslateAnimation. You can find some more info about view Animations here
You'll want to define your TranslateAnimations in xml or in java then you can call radioBtn.startAnimation(myAnim); you pass it the Animation object that you create or that you inflate from xml.
Edit: Unfortunately I think it is going to end up being a fairly complex process to make it work that way. I can think of two ways to achieve that effect. But neither is particularly straight forward.
Make yourself an ImageView that contains the CHECKED_ON graphic as its picture. Set its position over top of whatever is currently selected. when something new is selected use TranslateAnimation to move the ImageView to the position of the newly selected item. If you are going this route I think you'll have to change your CheckBox graphic to use the CHECKED OFF image in both states (on and off) otherwise as soon as you click on a new one its going to change to ON, even though the graphic will be in the process of flying toward the newly selected one.
Another potential solution would be make a vertical seek bar object and hook up the Label names to set the seek bar to the correct position when they are touched. To get an animated effect you could use a for loop and just increase/decrease the seek bar position by some small amount over and over until you arrive at your destination. The logic could work the same as check boxes, they would just be considered CHECKED_ON whenever the seekbar position is in line with them and off otherwise. This approach might actually end up being simpler to implement than using Animations to achieve it.
although I've only pondered it briefly I would probably lean towards the second option. I have used TranslateAnimations in the past to simulate drag & drop actions on some custom Views that I made for a game. This was one of the most difficult things I worked on related to that game.


text:
Q: Placeholders are not displaying in IE8 for Bootstrap I am using Bootstrap for my project. The placeholders are displaying fine for all browsers except in Internet Explorer 8 and below.
Are there any solutions to get placeholder support in IE8?

A: you can use this plugin
https://github.com/mathiasbynens/jquery-placeholder
Even works in IE6

A: you can use jquery watermark plugin for that
https://code.google.com/p/jquery-watermark/

A: It should'nt be to hard to figure this out without a plugin, I'm guessing something close to this will do the trick:
var test = document.createElement('input');
if (!('placeholder' in test)) {
    $('input').each(function () {
        if ($(this).attr('placeholder') != "" && this.value == "") {
            $(this).val($(this).attr('placeholder'))
                   .css('color', 'grey')
                   .on({
                       focus: function () {
                         if (this.value == $(this).attr('placeholder')) {
                           $(this).val("").css('color', '#000');
                         }
                       },
                       blur: function () {
                         if (this.value == "") {
                           $(this).val($(this).attr('placeholder'))
                                  .css('color', 'grey');
                         }
                       }
                   });
        }
    });
}

A: Adding on from Rubens answer there is a demo here
http://mathiasbynens.be/demo/placeholder

A: IE9 and below doesn't support the placeholder attribute. See this
You can use EZPZ hints to supplement it though. Just load the script if the browser is IE
 <!--[if lt IE 10]>
      <script src="PATHTOFILE"></script>
    <![endif]-->

EZPZ hints allows you to continue to use placeholder for modern browsers.
Example:
<input type="text" id="search" placeholder="Search" />

$("input[type=text]").ezpz_hint();


text:
Q: Slick.js carousel with Knockout custom binding I wanted to use the awesome slick carousel (http://kenwheeler.github.io/slick/) with Knockout. After looking at some of the other questions (https://stackoverflow.com/questions/26368176/slick-js-carousel-not-working-with-knockout-template-binding) it seems like the way to go would be to use a custom binding, but I'm having trouble getting it to load properly - it seems like the slick carousel is initializing before the DOM has completely loaded so it doesn't connect the last slide to the first slide. I also looked at knockout js custom binding called after internal dom elements rendered and am trying to use child binding contexts to have the custom binding force the child elements to bind first.
Here is the html markup:

        <result-thumbnail params="result:$data"></result-thumbnail>

result-thumbnail is a separate knockout component that formats the data I wanted to present in the carousel. In the custom bindings file:
ko.bindingHandlers.slick = {
init: function(element, valueAccessor, allBindingsAccessor, data, bindingContext) {
    var options = {
        infinite:true,
        slidesToShow: 3,
        slidesToScroll: 1,
    };

    var childBindingContext = bindingContext.createChildContext(
        bindingContext.$rawData,
        null,
        function(context) {
            ko.utils.extend(context, valueAccessor());
        });
    ko.applyBindingsToDescendants(childBindingContext, element);

    var local = ko.utils.unwrapObservable(valueAccessor());
    ko.utils.extend(options, local);
    $(element).slick(options);
    return { controlsDescendantBindings: true };
},
update: function(element, valueAccessor, allBindingsAccessor, data, context) {
  }
};

A few things I was considering:
- Should I move the slick initialization to the update function?
- Does the slick custom binding I wrote need to be bound to a different element?
- If I were changing the value of the results observable, would I need to update slick by destroying then recreating the carousel?
Any help would be appreciated! I am still learning about custom bindings and if any one has had experience with getting the slick carousel to work with Knockout that would be great to hear about too.

A: Disclaimer: I have never used slick.js.
You're right in thinking that the carousel is initializing before the DOM has completely loaded.
If you search on stackoverflow you'll find many options on how to call a function when all elements have finished rendering - the one I like best is described here: https://stackoverflow.com/a/19941134/3620458.
Once you have such a callback you can use it to set an observable in your main viewModel to true, like this:
var allElementsRendered = ko.observable(false);
var yourAfterRenderFunction = function () {
    allElementsRendered(true);
}

You can then pass that observable as a parameter to your 'slick' binding, like this:

Whenever the allElementsRendered() observable changes, the 'update' function in your custom binding will be called - so just move the initialization logic there, like this:
    update: function(element, valueAccessor, allBindingsAccessor, data, context) {
        var shouldInit = ko.unwrap(valueAccessor());

        if (shouldInit) {
            var options = {
                infinite:true,
                slidesToShow: 3,
                slidesToScroll: 1,
            };

            $(element).slick(options);
        } else {
            $(element).slick("unslick");
        }
    }

Handling updating the results observableArray may require some additional work - what you can do is subscribe to it and set the allElementsRendered() to false any time it changes, like this:
var resultsSubscription = results.subscribe(function(newValue){
    allElementsRendered(false);
})

This, combined with the above-mentioned afterRenderFunction should hopefully keep your carousel updated.


text:
Q: Mondrian all cube measures are empty I am using the Saiku plugin on Pentaho to analize a cube. Although all demension and measurement fields are visible, there are no facts being displayed, all cells are empty. (If the "Non Empty" option is selected in the toolbar, Saiku returns "No result", when the option is not selected, a table listing all the members correctly in the columns and rows are displayed - just no cell values). Because the member values in the columns and rows are correct, I know Saiku is reading the cube xml file and MySQL data source correctly. I think there might be some issue with the specified measurements, but I cannot find any error (No errors in console or logs that I can see). Note that I get this issue no matter what dimensions I select when cubing in Saiku. This is the Mondrian schema file i created with schema workbench.
<Schema name="Test Small4">
<Cube name="Policy Cube" caption="A small test" visible="true" description="Policy data description" cache="true" enabled="true">

<Dimension type="StandardDimension" visible="true" foreignKey="deductable_id" highCardinality="false" name="Deductable" caption="Caption: deductable">
  <Hierarchy visible="true" hasAll="false">

    <Level name="Deductable Type" visible="true" column="type" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
    </Level>
    <Level name="Deductable Limit" visible="true" column="deductable_limit" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
    </Level>
    <Level name="Deductable Cap" visible="true" column="cap" type="Numeric" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
    </Level>
  </Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" foreignKey="endorsement_id" highCardinality="false" name="Endorsement" caption="Caption: Endorsement">
  <Hierarchy visible="true" hasAll="true">

    <Level name="Endorsement Type" visible="true" column="type" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
    </Level>
    <Level name="Endorsement Number" visible="true" column="number" type="Numeric" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
    </Level>
    <Level name="Endorsement Effective Date Regular" visible="true" column="effective_date" type="Date" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
    </Level>
  </Hierarchy>
</Dimension>
<Measure name="Quantity Unique Rate" column="rate" datatype="Numeric" aggregator="distinct-count" visible="true">
</Measure>
<Measure name="Average Rate" column="rate" datatype="Numeric" aggregator="avg" visible="true">
</Measure>
<Measure name="Average Premium" column="premium" datatype="Numeric" formatString="#,###" aggregator="avg" visible="true">
</Measure>
<Measure name="Num Rates" column="rate" datatype="Integer" aggregator="distinct-count" visible="true">
</Measure>
<Measure name="String test" column="rate" datatype="String" aggregator="distinct count" visible="true">
</Measure>
<Measure name="Sum test" column="system_id" datatype="Integer" aggregator="sum" visible="true">
</Measure>
<Measure name="Test" column="system_id" datatype="Integer" formatString="Standard" aggregator="count" visible="true">
</Measure>
<CalculatedMember name="Premium Rate dif" formula="[Measures].[Average Rate]-[Measures].[Average Premium]" dimension="Measures" visible="true">
</CalculatedMember>

Any idea why this might be? How can I go about debugging this issue?

A: You're missing the primaryKey attribute on the hierarchy. The Dimension element has the foreignKey attribute correctly identifying the column from the fact table, but the Hierarchy element doesn't specify a primaryKey from the dimension table to perform the join.
As such, all joins will return 0 rows. (I had no idea Mondrian would even accept such a schema, as I would expect the join condition to be malformed while testing the schema)


text:
Q: Как раскрыть панель навигации? При уменьшении окна браузера панель навигации сворачивается, но раскрыть её обратно не получается, хотелось бы чтобы при нажатии на кнопку список раскрывался. Как решить данную проблему?
<!DOCTYPE html>

        <meta charset="utf-8" />
    <title>Simple landing page</title>
    <link href="css/bootstrap.min.css" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/css?family=Merienda:700" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet" type="text/css">
    <link href="css/style.css" rel="stylesheet" />

                Landy

Home

About

Screenshots

Features

Download

A:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

                Landy

Home

About

Screenshots

Features

Download

A: Ошибка была в том, что я вместо data-toggle написал data-toogle

Предыдущий вариант отправленный Павелом Игоревичем тоже неожиданно заработал.