text:
Q: conditional state_machine transition with external api call I am wondering what the best way to set this up. Using the state_machine gem for ruby.
Essentially I have a state machine transition that is conditional on an external API call.  Something like:
state_machine initial: :start do
  event :move do
    transition :start => :second, if: :external_is_cool_with_it?
    transition :start => same
  end
end

This works pretty good, as if the external api returns true, it goes to :second, otherwise it fails, goes to the next transition, which stays on the same state. Lets say the API call sends an email.
The only problem is I can't ask:
instance.can_move?

Because that will actually run the if, which calls the external API etc... so when I do something like:
instance.move! if instance.can_move?

or
if instance.can_move?
  puts "Moveable"
  # Form to allow state_event
end

It would call the external API twice (send the email twice).
So I don't think the usage of if is correct in this case, but I also can't really use before/after_transition since I need it to conditionally move to the next transition if the external call fails.
Any suggestions?


text:
Q: Android AlarmManager (sometimes) provides extra notification I am working on an application that uses the AlarmManager to generate a notification for the user at a later date.  The Alarm always arrives (on the devices tested) but one device (Samsung Galaxy Tab3, Android 4.4.2) receives 2 notifications (presumably one from the alarmManager, and one from the broadcast receiver of the app).  The code for both is of course the same, and I haven't seen this issue before.
The code is written in C# for Xamarin, but it is pretty vanilla.  The AlarmManager creates a broadcast with a broadcast filter that will be picked up elsewhere in the app (and that works fine):
private PendingIntent CreateIntent (Models.Notifications.LocalNotificationModel notification, PendingIntentFlags flag)
        {
            if (notification.IsActive) {
                //Create the broadcast intent
                var broadcastIntent = new Intent (BROADCASTFILTER);
            //Add information to the receiver of what should be done about the notification
            var id = notification.Id;
            var message = notification.Message;
            var badgeNumber = notification.BadgeNumber;
            var dateOfEvent = notification.EventDateTime;
            var iconPath = notification.IconPath;
            var isActive = notification.IsActive;
            var isOverride = notification.IsOverride;

            //Needs extra information to create the notification
            broadcastIntent.PutExtra (ID, id);
            broadcastIntent.PutExtra (MESSAGE, message);
            broadcastIntent.PutExtra (DATEOFEVENT, dateOfEvent.ToShortDateString () + " " + dateOfEvent.ToShortTimeString ());

            //Get the broadcast as pending intent
            var source = PendingIntent.GetBroadcast (_context, (int)id, broadcastIntent, flag);

            return source;
        }
        return null;
    }

    public void Add(Models.Notifications.LocalNotificationModel notification)
    {
        if (!_isInitialized)
            throw new ApplicationException("LocalNotificationService is not initialized");

        var source = CreateIntent (notification,PendingIntentFlags.OneShot);

        //Convert the notification to milliseconds since epoch
        var sinceEpoch = notification.EventDateTime.ToUniversalTime() - new DateTime(1970, 1, 1);
        var msSinceEpoch = (long)sinceEpoch.TotalMilliseconds;

        //Assign the pending intent to the alarmmanager
        _alarmManager.Set(AlarmType.RtcWakeup, msSinceEpoch, source);
    }

A: It was an error on my part, there was a proof of concept version of the application on the tablet, it was a different app but used the same bundle ID, and as a result received the same broadcast.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Chat font is too small on mobile On my samsung note 4 the font looks small on the entire https://chat.meta.stackexchange.com. I know this is a taste thing (I personally like bigger fonts) but it is inconsistent with the rest of stack overflow. I was browsing a lot of posts right before I found the chat section and it was jarring enough to make me uncomfortable and immediately exit out.
Note in the screenshot the difference between the text of the loading message and the rest of the site. Maybe it is not picking up on my browser's settings (110% text scaling on chrome dev Android)?


text:
Q: Stack Exchange mobile app push notifications on ANDROID PIE 9 Nokia 6.1+ I have been a constant user of the Stack Exchange mobile app and on my previous mobile Motorolla Droid Turbo 2 it worked fine, and I used to receive the push notifications for all the selected events like tag, message, reply, etc.
I recently bought Nokia 6.1 + with Android 9 and since I installed the app I never received a single notification for the inbox or replies.
Device Info
App Version: 1.0.95
Device Manufacturer: HMD Global
Device Model: Nokia 6.1 Plus
OS Version: 9 (00WW_3_45B)

I checked the notifications checkbox in the settings menu several times, but it never a single time displayed the push notifications. Did anyone else experience a similar issue?


text:
Q: How many sequences of 11 ones and 7 zeroes without consecutive zeroes exist? I've been looking for solutions to such a problem, but only found solutions for any amount of zeroes and ones (without consecutive zeroes).
How many such sequences exist?

A: Take such a sequence and stick a $1$ at the end. You have a sequence
of $12$ ones and $7$ zeroes with each zero followed by a $1$. So you have
seven subwords $01$. Replace each of those by a $2$. You then have a sequence
of $5$ ones and seven twos. There are $\binom{12}5$ of these.
You can reverse the process. So there are $\binom{12}5$ of your sort of sequence.

A: Place the eleven ones out first and leave a bit of space to either side of the ones.
$$\underbrace{~}_{a}1\underbrace{~}_{b}1\underbrace{~}_{c}1\underbrace{~}_{d}1\underbrace{~}_{e}1\underbrace{~}_{f}1\underbrace{~}_{g}1\underbrace{~}_{h}1\underbrace{~}_{i}1\underbrace{~}_{j}1\underbrace{~}_{k}1\underbrace{~}_{\ell}$$
Now, pick which seven of the spaces are used by zeroes and close all the remaining unused spaces.  Choose the spaces simultaneously.  To count this, use binomial coefficients.  We have twelve spaces available (11 + 1) and we want to choose seven of them to be used by zeroes.
The answer then is $$\binom{12}{7}$$
By choosing in this fashion, either zero or one $0$ will be in each space and as a result no $0$ will be next to another $0$.


text:
Q: CakePHP CSV Import with Preview There are many usefull CSV-Importer, but i didn't found one with a "Preview" of the Data to import. So start to make my own: but i stuck on HOW to organise all this in a nice cake-like way (just started programming)
Functions
This importer should be/have/can:

*

*easy attached to every controller (and set a default model, so the tool can be called with /url/controller/csv-importer

*after accessing this csv-importer via URL, you see a pre-defined view of this importer with an upload form for the CSV, next step let you

*choose delimiter, charset, primaryKey to sync with (those options can be preconfigured on loading the importer, so those options (part 3) would be skipped)

*show the PREVIEW of data from the uploaded CSV, which record would be inserted, which record would be changed

*you can select the rows which should be imported and IMPORT, or ABORT and re-upload the csv

Problem
how should a organise this to offer this as a tool, which can easy be accessed by an user from everywhere (where i added this importer)
i don't need code :) it's all about how to organise this.

A: The official Datasource repository contains a CSV Datasource https://github.com/cakephp/datasources/tree/2.0/
Doing this in a component is wrong in the MVC pattern. Data processing is a model task for obvious reasons like re-usability in a shell. And models are easier to unit test.
I don't understand how you intend to use this in every controller. If you need to display the uploaded CSV as a table on every page then simply do a requestAction() simply fetch the CSV data using the datasource I've told you from the model where needed and set it to the view.


text:
Q: Downsides to mixing boost and stl libraries in one project? I was wondering if it would be okay to use both the boost and stl libraries within one project? What are the potential downsides of doing so (besides code size which would obviously be one)? I'm creating a lot of wrapper classes for atomic types and low level data structures such as vectors, so I think that can help with some potential future issues, but I probably won't be wrapping EVERYTHING in my own container classes.

A: Don't loose time with creating wrappers for the sake of it. Also boost is created as a kind of extention to stl, usually future versions of c++ take concepts proven in boost.
Of course, there is always a dissadvantage to using new libs: more api to learn, more dependancies to take care in your build process...
But if it is usefull, why recreate what can be just used. Boost is any way written in stl style.


text:
Q: Android XML SAXParser handling ampersand from URL? I am parsing XML from URL using SAXParser. The XML has some data with ampersand (&) sign. XML data is not read after the ampersand. How would I resolve this issue?
URL website = new URL(FullURL);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
HandlingXMLStuff doingwork = new HandlingXMLStuff();
xr.setContentHandler(doingwork);
xr.parse(new InputSource(website.openStream()));
String information = doingwork.getInformation();

XML tag has data like
<choice>Cat & Dog</choice>

I am getting output as
Cat

A: To have a naked '&' rather than "&" you need to use a CDATA[[]] structure around the "Cat & Dog".


text:
Q: Passing three dimensional arrays into functions in C? What is the best way to pass three dimensional arrays into functions in C?

A: It is required you have all but the left-most dimension to be defined at compile time.
#define DIM 5

void do_something(float array[][DIM][DIM])
{
    array[0][0][0] = 0;
    ...
}

A: typedef is your friend.
#include <stdio.h>
typedef int dimension1[20]; /* define dimension1 as array of 20
                               elements of type int */
typedef dimension1 dimension2[10]; /* define dimension2 as array of 10
                                      elements of type dimension1 */

int foo(dimension2 arr[], size_t siz);

int main(void) {
  dimension2 dimension3[7] = {0}; /* declare dimension3 as an array of 7
                                     elements of type dimension2 */
  dimension3[4][3][2] = 9999;
  dimension3[4][0][12] = 1;
  dimension3[3][8][18] = 42;

  printf("%d\n", foo(dimension3, 7));

  return 0;
}

int foo(dimension2 arr[], size_t siz) {
  int d1, d2, d3;
  int retval = 0;
  for (d3=0; d3<siz; d3++) {
    for (d2=0; d2<sizeof *arr / sizeof **arr; d2++) {
      for (d1=0; d1<sizeof **arr / sizeof ***arr; d1++) {
        retval += arr[d3][d2][d1];
      }
    }
    /* edit: previous answer used definite types for the sizeof argument */
    //for (d2=0; d2<sizeof (dimension2) / sizeof (dimension1); d2++) {
    //  for (d1=0; d1<sizeof (dimension1) / sizeof (int); d1++) {
    //    retval += arr[d3][d2][d1];
    //  }
    //}
  }
  return retval;
}

Edit
I don't like the use of definite types as the argument to sizeof.
I added the way to get the sizes of the (sub-)arrays without directly specifying their types, but rather let the compiler infer the right type from the object definitions.

2nd Edit
As Per Eckman notes typedef-ing "bare" arrays can be dangerous. Note that in the code above, I'm not passing arrays themselves to the function foo. I am passing a pointer to a "lower level" array.
foo(), in the code above, accepts a pointer to an object of type dimension2. The dimension3 object is an array of elements of dimension2 type, not an object of dimension3 type (which isn't even defined).
But remember Per Eckman's note.

A: Pass them as pointers.
Example
int a[N][M][P];

foo( &a[0][0][0]);

where foo is
void foo( int*)

You might need to pass the dimensions as well, so in such case you might need:
void foo( int*, int D1, int D2, int D3)

and call
foo( &a[0][0][0], N, M, P);

A: typedef-ing "bare" arrays can be dangerous.
Try this
#include <stdio.h>

typedef char t1[10];

void foo(t1 a) {
        t1 b;

        printf("%d %d\n", sizeof a, sizeof b);
}

int main(void) {
        t1 a;
        foo(a);
        return 0;
}

One would think that sizeof two variables of the same type would return the same size
but not in this case. For this reason it's a good practice to wrap typedef-ed arrays
in a struct.
typedef struct {
        char x[10];
} t1;


text:
Q: Is the strrev() function not available in Linux? I tried to write code using strrev(). I included <string.h> but still I'm getting an "undefined reference to strrev" error.
I found that strrev() doesn't have man page at all. Why?
Doesn't Linux support strrev()?

A: To accurately answer your question,
Is strrev() not available on Linux?
The functions strrev() available in the string.h library. Functions strrev() including some other string functions such as like strupr(), strlwr(), strrev(), which are only available in ANSI C (Turbo C/C++) and are not available in the standard C-GCC compiler.
It's not about the system. It is about the C compiler you are using.
References:
https://discuss.codechef.com/t/is-strrev-function-not-available-in-standard-gcc-compiler/2449
https://www.csestack.org/undefined-reference-to-strrev/

A: Correct. Use one of the alternative implementations available:
#include <string.h>

char *strrev(char *str)
{
      char *p1, *p2;

      if (! str || ! *str)
            return str;
      for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
      {
            *p1 ^= *p2;
            *p2 ^= *p1;
            *p1 ^= *p2;
      }
      return str;
}

A: #include <string.h>

char *strrev(char *str)
{
    if (!str || ! *str)
        return str;

    int i = strlen(str) - 1, j = 0;

    char ch;
    while (i > j)
    {
        ch = str[i];
        str[i] = str[j];
        str[j] = ch;
        i--;
        j++;
    }
    return str;
}

A: Unfortunately, strrev seems to be absent from glibc's string.h.
Obviously, I'm late to the here's-some-code party, but I like this implementation.
#define MAX_CHARS 10000
// safe_usub -- perform safe unsigned subtraction
size_t safe_usub (size_t x, size_t y) {
  return x > y ? x - y : y - x ;
}

char* str_reverse (const char* const str) {
  if (!str) { return NULL; }

  size_t len = strnlen(str, MAX_CHARS);
  char*  new = malloc( sizeof(char) * len );

  size_t i;
  for (i = 0; i < len; i++) {
    new[i] = str[ safe_usub(i + 1, len) ];
  }

  new[i] = 0;

  return new;
}

A: How about this:
#include <string.h>

char *strrev(char *s)
{
    if (s && *s) {
        char *b = s, *e = s + strlen(s) - 1;
        while (b < e) {
            char t = *b;
            *b++ = *e;
            *e-- = t;
        }
    }
    return s;
}

A: There is no string library function to reverse a string.
strrev() Is not present in GCC compiler in Linux.
Make your own reverse function:
reverse.c:
/*
 * C program to reverse a string using recursion
 */
#include <stdio.h>
#include <string.h>

void reverse(char [], int, int);
int main()
{
    char str1[20];
    int size;

    printf("Enter a string to reverse: ");
    scanf("%s", str1);
    size = strlen(str1);
    reverse(str1, 0, size - 1);
    printf("The string after reversing is: %s\n", str1);
    return 0;
}

void reverse(char str1[], int index, int size)
{
    char temp;

    temp = str1[index];
    str1[index] = str1[size - index];
    str1[size - index] = temp;

    if (index == size / 2)
    {
        return;
    }
    reverse(str1, index + 1, size);
}


text:
Q: chaining and getting the value of an input This code gets the text that's in a certain column of a table row:
var keyA = $(a).children('td').eq(column).text().toUpperCase();

Q: How do I rewrite this to get the value of an input tag that's in the table cell?
var keyA = $(a).children('td').eq(column).('input').val().toUpperCase();

A: Try this:
var keyA = $(a).children('td').eq(column).find('input').val().toUpperCase();

A: Oh! It's:
children('input')


text:
Q: Developer console's CSS Selector returns wrong results Using Firefox's or Chrome's developer console, When I type $('a'), It should return all the links on the page in an array (If I select the wrong frame it won't for example, but that is not the problem now). Please someone enlighten me, why do I get single a result using this CSS selector with both Firefox and Chrome on some sites and an array of a's on others (both sites have more than one a tags)?
This worked before, I don't remember it ever not working like this. For reference let's take http://www.useragentstring.com/pages/useragentstring.php
My Firefox console result:

Chrome:

If I do this on stackoverflow, the CSS Selector works too. The Xpath works on every site.

A: From the Chrome dev tools documentation:

$(selector) returns the reference to the first DOM element with the specified CSS selector. This function is an alias for the document.querySelector() function.

So you get the expected behaviour on useragentstring.com.
On Stackoverflow you get different behaviour because jQuery has been included on the page and the $ variable has been overwritten by the jQuery object which (when called as a function):

Accepts a string containing a CSS selector which is then used to match a set of elements.


text:
Q: Copy data from one oracle database to another with Python I am trying to create a automated way of copying data from a production oracle database to our test system. We only want to get specific data and so can't just do a full DB copy. I have all the SQL to get the data and can do it in toad by running the SQL and exporting as insert statements and then running those in the test system but this is time consuming as about 25 tables are involved.
I want to do it using python and cx_oracle.
Can I have 2 connections to different databases open at the same time? So I can run a select in one and with the results build an insert and run that in the other or do I need to connect, run the select, disconnect and connect to the the other, run the insert and repeat for each statement? Would the multiple connects and disconnects cause issues for the databases? Taking down a production database will not make me popular....
I can't link the databases in any way and the copying needs to be repeatable for different data and simple enough for non technical users to use.

A: Yes, you can have multiple connections open at the same time. Take care of each connection and cursor, of course.
You can find useful CX-OracleTools, a collection of scripts based on cx_oracle for working with Oracle databases. There is a CopyData script very interesting.


text:
Q: Use Transport Theorem to prove equality of angular acceleration vectors. My goal is to show that $\frac{^Bd}{dt}\vec{\omega}^{B/N}$ = $\frac{^Nd}{dt}\vec{\omega}^{B/N}$, where $\vec{\omega}^{B/N}$ is an angulr-velocity vector representing the rotation of frame $B$ with respect to an
inertial reference frame $N$, and $\frac{^Bd}{dt}$ is the time derivative in the $B$ frame (same with $N$ and $\frac{^Nd}{dt}$).
I need to prove this using the Transport Theorem in the form $\frac{^Nd}{dt}\vec{v} = \frac{^Bd}{dt}\vec{v}\ +\ \vec{\omega}^{B/N}\times\vec{v}$, or $\frac{^Bd}{dt}\vec{v} = \frac{^Nd}{dt}\vec{v}\ +\ \vec{\omega}^{N/B}\times\vec{v}$.
It's useful to note that since the frame $B$ is the frame of the object moving with velocity $\vec{v}$, $\frac{^Bd}{dt}\vec{v} = \frac{^Bd}{dt}(\frac{^Bd}{dt}\vec{v}) = 0$, and that $\vec{\omega}^{B/N} = -\vec{\omega}^{N/B}$.
To do this I tried doing all four combinations of two time derivatives. Here are my results:

*

*$\frac{^Nd}{dt}(\frac{^Nd}{dt}\vec{v}) = \frac{^Bd}{dt}\vec{\omega}^{B/N}\times \vec{v} + \vec{\omega}^{B/N}\times(\vec{\omega}^{B/N}\times\vec{v})$

*$\frac{^Bd}{dt}(\frac{^Bd}{dt}\vec{v}) = 0 = \frac{^Nd}{dt}(\frac{^Nd}{dt}\vec{v}) + \frac{^Nd}{dt}\vec{\omega}^{N/B}\times\vec{v} + 2\,\vec{\omega}^{N/B}\times\frac{^Nd}{dt}\vec{v} + \vec{\omega}^{N/B}\times(\vec{\omega}^{N/B}\times\vec{v})$

*$\frac{^Nd}{dt}(\frac{^Bd}{dt}\vec{v}) = 0 = \frac{^Bd}{dt}(\frac{^Nd}{dt}\vec{v}) + \frac{^Bd}{dt}\vec{\omega}^{N/B}\times\vec{v} + \vec{\omega}^{B/N}\times\frac{^Nd}{dt}\vec{v} + \vec{\omega}^{B/N}\times(\vec{\omega}^{N/B}\times\vec{v})$

*$\frac{^Bd}{dt}(\frac{^Nd}{dt}\vec{v}) = \frac{^Nd}{dt}\vec{\omega}^{B/N}\times\vec{v} + \vec{\omega}^{B/N}\times\frac{^Nd}{dt}\vec{v} + \vec{\omega}^{N/B}\times(\vec{\omega}^{B/N}\times\vec{v})$
I haven't been able to use these to prove $\frac{^Bd}{dt}\vec{\omega}^{B/N}$ = $\frac{^Nd}{dt}\vec{\omega}^{B/N}$. I must have done some of the differentiation wrong or messed up with the double Transport Theorem.
Can anyone see any mistake of mine or point me in the right direction?
Thanks.

A: ${}^a \dot{\boldsymbol{\omega}}_{b/a} = {}^b\dot{\boldsymbol{\omega}}_{b/a} + \boldsymbol{\omega}_{b/a} \times \boldsymbol{\omega}_{b/a} = {}^b\dot{\boldsymbol{\omega}}_{b/a}$ where $\bf{v} \times \bf{v} = 0 $. Simple.


text:
Q: Load includes on existing model I'm trying to load includes on an existing model in sequelize. In express we pre check the models to see if they exist in the middleware.
So once we're in the actual "controller" we want to run some includes on that existing model that is passed in.
req.models.item.incude([
    {model: Post, as: 'posts'}
])

Is there any way to accomplish this?
EDIT:
I know we can do something like this.
return req.models.item.getThing()
    .then(function (thing) {
        req.models.item.thing = thing;

        return req.models.item;
    });

But:

*

*My expansions for includes are a dynamic property that come via url parameters, so they are not know ahead of time.

*It I return the above you will not see the "thing" in the response. I need it nicely built as part of the original instance.

Something like a .with('thing', 'other.thing'); notation would be nice. Or in the case of sequelize .with({include: ...}); or .include([{model: ...}]);

A: If the variable req.models.item is already an Instance but without its other related instances ("includes"), then you could include them using something like the following code:
Item.findAll({
  where: req.models.item.where(),
  include: [{
    model: SomeAssociateModel,
  }]
})
.then(function(itemWithAssoc) {
  // itemWithAssoc is an Instance for the same DB record as item, but with its associations
});

See here for some documentation. See here for a script demo'ing this.

Update: Given the instance, how do I just get the associated models?
To do this just use the automatically generated "getAssociation" getter functions, e.g.:
function find_associations_of_instance(instance) {
  return instance.getDetails();
}

I've updated the script to include this as an example. For more information on these functions, see the SequelizeJS docs.


text:
Q: How to fix 'button' interactive role must be focusable I have list of dropdown options which user can select.
optinos in dropdown are made with tag: :
 handleSelect(filter)} role="button">
   {filter.name}

Problem is cus I must add tabIndex="0" or -1, to fix error from Eslint.
But When I add tabIndex=0, my button does not work anymore.
Is there are any other way to fix this error?
This is how looks dropdown component:

    {filterOptions.map((filter) => (
      <li
        key={filter.id}
        defaultChecked={filter.name}
        name={filter.name}
        className={`option option-${filter.selected ? 'selected' : 'unselected'}`}
      >
        <span className={`option-${filter.selected ? 'checked-box' : 'unchecked-box'} `} />

         handleSelect(filter)} role="button">
          {filter.name}

    ))}

A:
Buttons are interactive controls and thus focusable. If the button
  role is added to an element that is not focusable by itself (such as
  ,
 or
) then, the tabindex attribute has to be used to
  make the button focusable.

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#Accessibility_concerns

The HTML attribute tabindex corresponds to the attribute tabIndex in
  React.

https://reactjs.org/docs/dom-elements.html
So I think @S.. answer is correct:
 handleSelect(filter)}
  role="button"
  tabIndex={0}
>
  {filter.name}

A: Add a tabindex:
 handleSelect(filter)} role="button" tabIndex={i}>
    {filter.name}

after first adding an iterator to your map: (filter, i)


text:
Q: TCL Asking User for Multiple Inputs I am trying to ask a user multiple questions so that a machine may make parts according to the inputs. The inputs are to be saved as variables to be called later in the program. I have written the below code and request help in understanding why it does not run. I am getting errors with the puts command as well as the program not waiting for a response after each question. As you can see I am new to this and would be grateful for any pointers you can provide. Thank you in advance.
    #Asks user for diameter of probe
    flush stdout;
    puts "Enter Diameter "
    gets stdin diameter
    #Asks user for Taper Length of probe
    flush stdout;
    puts "Enter Taper Length "
    gets stdin taper
    #Asks user for tip shape of probe
    flush stdout;
    puts "Enter Tip Shape s=sharp, r=radius and f=flat"
    gets stdin shape
    # Prompt for tip size
    flush stdout;
    if {r} {
    puts "Enter Radius Size "
    gets stdin radius
    } elseif {d}{
    puts "Enter Diameter Size"
    gets stdin diameter
    }

A: It was determined that because the quotes were written using MS Word they were the incorrect type which lead to the error. This was rectified by deleting them and adding quotes in Notepad++. The if statement was also corrected using (if {$shape == "r"}) and (elseif {$shape == "f"}). Thank you for your help.


text:
Q: MinGW, linking to a dll on Windows I'm trying to use a library I received from a camera vendor in a sample program. I have a .dll and a .lib file for the library. My compile command is:
g++  -o "Win32App.exe" -L"..\..\SK develop\SK91GigE-WIN\Lib" obj/winmain.o obj/callbacks.o obj/resource.o -s -lcomctl32 -Wl,--subsystem,windows -lSK91GigE_x64

and I get:
obj/winmain.o:winmain.cpp:(.text+0x292): undefined reference to `SK_LOADDLL'
collect2.exe: error: ld returned 1 exit status

having a look on the .lib with nm shows:
BFD: SK91GigE_x64.lib(SK91GigE_x64.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
nm: SK91GigE_x64.dll: File format not recognized

and for the dll it outputs:
nm: SK91GigE_x64.dll: File format not recognized

Any ideas how I can modify that lib to include it?

A: windows path variable pointed to 32 bit MinGW. setting the path to the 64bit version of MinGW solved the problem. I didn't check that


text:
Q: Retain/preserve pom xml structure[element order] while writing pom file using MavenXpp3Reader/MavenXpp3Writer I want to remove only the version number element from dependency as I plan to move that to parent pom. When I do that, entire pom.xml getting rearranged. But, I want to present original pom.xml structure which will help to compare when checked in into git.
I use below code now.
MavenXpp3Reader reader = new MavenXpp3Reader();
pomStream = new FileInputStream(pomF);
Model model = reader.read(pomStream);

       // update properties

model.setProperties(modelProperties);
MavenXpp3Writer writer = new MavenXpp3Writer();
writer.write(new FileWriter(pomF), model);

How to preserve original structure while writing the pom.xml after making changes?

A: You can't do that with these readers, they can only transform XML to Java instances and vice versa. The hard way is implementing the transformation with XLST, but I'd go for the good ol' search and replace with a proper texteditor or IDE.
If you think you'll do this often, consider having a look at https://www.mojohaus.org/versions-maven-plugin/


text:
Q: Sass use classname from other .scss file goodday all,
I am trying to figure out if there is a way to link .scss in a way that they share their classnames.
So here is what I am trying to achieve.
|- theme
|   |- theme_default.scss
|- snippets
|   |-componentA
|   |   |-componentA.js
|   |   |-componentA.scss

In the ComponentA.js file I am attaching a class to the component from ComponentA.scss using the css-loader/CommonJS (I am using a webpack dev-environment if anyone needs to know).
In the theme_default.scss I am trying to apply a theme-style to 'ComponentA'. The default theme-file should be exchangable by other theme-files.
The problem is that the class-names (eventhough identical in the source-files) are hashed when compiled into regular '.css' files, meaning the class-name from the theme cssfile will never match the class-name from the ComponentA cssfile.
So how can I make clear the theme-file should use the same class-names as the Component-file without declaring the styles as global? I tried using @import and @use in the theme-file, but it only copies the rules while the class-names are still not identical.
Any input is welcome, thanks in advance for reading.
EDIT

On request some examples
theme_default.scss
.theme_default {
   .comp_a /* This class should be the same (hashed) as in the componentA.scss */ {
      background-color: red; /* awefull, but just for example sake */
   }
}

componentA.scss
.comp_a {
   display: flex;
   flex-wrap: no-wrap;
   /*.. etc.*/
}

componentA.js
import style from './componentA.scss'

// this is how I set the style, but this class does NOT know about any theme stylesheet. So nothing can be done from here
element.classList.add(style.comp_a);

To apply the theme I set the theme_default class (the hashed version) to a root element and let the browser figure out how to efficiently (re)render it.
I read that the css-loader has a mechanism with compose(s), which might solve this problem. But it seemingly doesn't work with either webpack or vsCode. So in any case someone needs it, here is the snippet from the webpack config file regarding css handling.
webpack.configuration.js
{
    test: /\.s[ac]ss$/i,
    include: [
        path.resolve(__dirname, 'src')
    ],
    exclude: [
            path.resolve(__dirname, 'node_modules'),
            path.resolve(__dirname, 'build'),
            path.resolve(__dirname, 'test'),
    ],
    use: [
        // Creates `style` nodes from JS strings
        isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
        // Translates CSS into CommonJS
        {
            loader: 'css-loader',
            options:
            {
                modules:
                {
                    exportGlobals: true,
                },
                importLoaders: 2,
                sourceMap: isDevelopment,
            }
        },
        // Transform urls
        {
            loader: 'resolve-url-loader',
            options:
            {
                sourceMap: isDevelopment
            }
        },
        // Compiles Sass to CSS
        {

            loader: 'sass-loader',
            options:
            {
                sassOptions:
                {
                    indentWidth: 4,
                    sourceMap: isDevelopment,
                    sourceMapContents: false,
                    outputStyle: 'expanded'
                },
            },
        }
    ],
},

A: Theming is a little bit trickier with the use of CSS Modules, since the intent of it is to create locally-scoped CSS that isn't affected by the CSS cascade.
That being said, there are some options available to you depending on the route you'd like to take.

Argument/Prop Theming
Because CSS Modules don't want to be affected by the cascade, it's quite difficult to change component-level CSS by making use of class names higher in the DOM tree. The CSS-Modules project does have a page on theming, but I think it's a bit of a departure from how you're attempting to implement your styles. I would encourage you to consider it, though.
Their approach is to create a themed stylesheet per component and then import them into said component, switching out which one you're going to use based on a variable. In React, this would be a prop.
dark.css
.button {
  border: 1px solid #333;
}

neon.css
.button {
  border: 1px solid #0f0;
}

Button.js
export default class Button {
  constructor(theme) {
    this.theme = theme;
  }
  render() {
    const theme = this.theme;
    return `<div class="${theme.button}">Hello World</div>`;
  }
}

app.js
import darkTheme from "./dark.css";
import neonTheme from "./neon.css";

import Button from "./button";

// use component
new Button(dark);
new Button(neon);

This approach leans more into the traditional CSS Modules approach in which you'll duplicate some styles in your source, but you make up for it in reducing what you deliver to the client.
Usage with Sass
Since you're using Sass, you can cut down on the duplication and tediousness of changing things in the future by making use of Sass Mixins.
This is particularly helpful if you have a set of CSS properties that are common throughout many components that will consume them (background-color, border-color, etc), and will allow you to centralise these rules into a single file where they can be changed and propagate throughout other files.
themes.scss
@mixin neon {
  background-color: #0f0;
  border: 2px solid #ff0;
  color: #000;
}

button/neon.scss
.button {
  @include neon;
}

// Or, if you're using the latest Dart Sass and its @use rule
@use "themes";

.button {
  @include themes.neon;
}

This still requires you to set up and the theme as an application variable and pass it in as an arg or prop, but should reduce the need for you to duplicate the CSS rules in every file.

CSS Custom Properties
An alternative path available to you, if your browser support allows it, is the use of CSS Custom Properties. This would allow you to control values inside your CSS Module generated classnames from outside.
style.css
.button {
  background-color: var(--button-bg, #900); /* #900 default fallback if --button-bg doesn't exist*/
}

app.css
body {
  --button-bg: #f48024;
}

body.dark {
  --button-bg: #a34d08;
}


text:
Q: How can I convert Java object to Json in spray routing I would like to know if there is any way to return Java object as Json String inside spray routing.
For now, I am converting my Java object (which is returned my UserActor) into Json using Jackson through a util class(JacksonUtil) created by me.
Here is the code snippet for reference :
val route = {
    path("users" / Segment) { id =>
      parameterMap { params =>
        get {
          respondWithMediaType(MediaTypes.`text/plain`) {
            val resource: GetResource = new GetResource
            resource.searchCriteriaList.add(new SearchCriteria("userId", "=", Segment))
            logger.info("Request Received in new route: " + resource)
            onComplete(callUserActor(resource)) {
              case Success(ret: User) => {
                logger.info("Request complete. Success.")
                complete(JacksonUtil.toJson(ret))
              }
              case Failure(error) => {
                logger.info("Request complete. Failure. " + error)
                complete("Error: " + error)
              }
            }
          }
        }
      }
    }
  }

def callUserActor(getResource: GetResource): Future[User] = {
    (userActor ? getResource).mapTo[User]
  }

GetResource is the class which take of query parameters.
For example if client hits GET /users/123, then GetResource will add a searchcriteria as userId = "123"

A: I think you need to do it by yourself like by using Jackson or using LiftJson as per your needs and ease of Use. Spray does not provide such feature by default as it does not have dependencies for this !
You can see the compile dependencies used by spray here : https://mvnrepository.com/artifact/io.spray/spray-routing_2.11/1.3.4
Screenshot :

A: This should work for you, as simple as:
class YourService(implicit val requestTimeout: Timeout)
extends HttpServiceActor with
   Json4sJacksonSupport {

  path("users" / Segment) { id =>
    parameterMap { params =>
      get {
        respondWithMediaType(MediaTypes.`text/plain`) {
          val user : Future[User] = Future { User("name", "90") }
          complete(user)
          }
        }
      }
    }
  }

  implicit def json4sJacksonFormats: Formats = DefaultFormats.lossless
}


text:
Q: Custom 404 works in local but not in deploy environment on Github pages This is my first post here :) so be cool with me please :)
I try to do a custom 404 with create-react-app V.17.0.2 and react-router-dom V.5.2.0.
It works when i try on local server but something is wrong when i deploy on github-pages.
I have only one path='/', and i want all the others redirect to my error404 component.
I made one in an other project lastProject published on Netlify and to fix this i have just create a _redirects file in the public folder and write /*  /index.html  200 inside , it works perfectly.
Here works Netlify
i want to find a same easy solution to published on github-pages. I don't want to change the BrowserRouter by Hashrouter and have a '#' in my URL, and this solution is very difficult to me
My repo if you need it
MyNewProject
EDIT: So now i use hashrouter and wait to see an other easy solution
import React from 'react';
import { Route, Switch } from 'react-router-dom';

import Header from '../Header';
import Main from '../Main';
import Footer from '../Footer';
import Error404 from '../Error404'

function App() {
  return (
    <div className="App" >
      <Switch>
        <Route exact path='/'>
          <Header />
          <Main/>
          <Footer/>
        </Route>
        <Route component={Error404}/>
      </Switch>
    </div>
  );
}

export default App;

A: To do this, you need to configure .htaccess file

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule . /index.html [L]

</IfModule>

https://gist.github.com/alexsasharegan/173878f9d67055bfef63449fa7136042


text:
Q: How can I establish an AVRCP connection from Windows 7 (controller) to phone (target) using L2CAP on Widcomm SDK? I am using the CL2Cap class in the Widcomm SDK on Win7. I am able to successfully establish the L2CAP connection and send the UNIT INFO command but the data returned is incorrect. I suspect that the stack has already established a connection and the AVRCP spec says:

"Only one L2CAP connection shall be established between AVCTP entities. If the connection already exists, the CT/TG shall not initiate the connection request."

Can anyone shed some light on what could be the problem? I have verified that the stack can establish a connection directly and play media on from the phone, but I am unable to do this programmatically.


text:
Q: Setting Text to fields fetching from API I am making a quiz app in which i am displaying the question and the options for it and I want to set text to radio buttons and the textiew after retrieving text from the api,i don't know how to set the text to it warns me do it as i have taken the value Boolean in my model class where i declare it.
Api: http://aptronnoida.com/Aditya_July4/Demo/JAVA_FETCH.php
QuizActivity:
    public class Quiz extends AppCompatActivity {

        public List<QuizModel> quizModels = new ArrayList<>();
        QuizModel quizModel;
        RadioGroup radioGroup;
        RadioButton optionOne,optionTwo,optionThree,optionFour;
        private TextView questionName;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_quiz);

            questionName=(TextView)findViewById(R.id.question_name);
             radioGroup =(RadioGroup)findViewById(R.id.radioGroup);
             optionOne=(RadioButton)findViewById(R.id.answerOne);
            optionTwo=(RadioButton)findViewById(R.id.answerOne);
             optionThree=(RadioButton)findViewById(R.id.answerOne);
            optionFour=(RadioButton)findViewById(R.id.answerOne);
            FetchLists fetchLists =new FetchLists();
            fetchLists.execute(10,0);

        }

        public class FetchLists extends AsyncTask<Integer, Void, List<QuizModel>> {

            @Override
            protected List<QuizModel> doInBackground(Integer... params) {

                int count = params[0];
                int offset = params[1];

                String urlString = "http://aptronnoida.com/Aditya_July4/Demo/JAVA_FETCH.php";
                urlString = urlString + "&count=" + count + "&offset=" + offset;

                try {
                    URL url = new URL(urlString);
                    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                    connection.setRequestMethod("GET");
                    InputStream stream = connection.getInputStream();
                    BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
                    String line = reader.readLine();
                    String response = "";
                    while (line != null) {
                        response += line;
                        line = reader.readLine();
                    }

                    JSONObject object = new JSONObject(response);
                    JSONArray emailLists = object.getJSONArray("data");

                    for (int i = 0; i < emailLists.length(); i++) {
                        JSONObject list = (JSONObject) emailLists.get(i);

                         quizModel.model_question_name= list.getString("Question");
//how to set text for radiobuttons here
                        quizModel.model_answer_one = list.getString("A1");
                        quizModel.model_answer_two = list.getString("A2");
                        quizModel.model_answer_three = list.getString("A3");
                        quizModel.model_answer_four=list.getString("A4");

                        quizModels.add(quizModel);
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
                return quizModels;
            }

            @Override
            protected void onPostExecute(List<QuizModel> result) {
                super.onPostExecute(result);

                Toast.makeText(Quiz.this,"OnPostMethod Called",Toast.LENGTH_SHORT).show();
                Log.d("ashu","OnPostMethod");

            }
        }

    }

QuizModel:
public class QuizModel {

    public String model_question_name;
    public boolean model_answer_one,model_answer_two,model_answer_three,model_answer_four;

    public QuizModel(String model_question_name, boolean model_answer_one, boolean model_answer_two, boolean model_answer_three, boolean model_answer_four) {
        this.model_question_name = model_question_name;
        this.model_answer_one = model_answer_one;
        this.model_answer_two = model_answer_two;
        this.model_answer_three = model_answer_three;
        this.model_answer_four = model_answer_four;
    }
}


text:
Q: Bright-Pixel Policy for MacBook Pro Recently bought a 13" MacBook Pro on Apple Store. I just discovered a "stuck pixel" which shines red when it's supposed to be black.
I can't find any pixel policy on the web page. Do they have such policy? Does anyone have any experience from trying to return / change the product?
(Bought it in Sweden if it matters.)

A: Your Macbook comes with a worldwide one year limited warranty.

Apple [...] warrants this Apple-branded hardware product against defects in materials and workmanship under normal use for a period of ONE (1) YEAR from the date of retail purchase by the original end-user purchaser ("Warranty Period"). If a hardware defect arises and a valid claim is received within the Warranty Period, at its option, Apple will either...

*

*repair the hardware defect at no charge, using new or refurbished replacement parts, or

*exchange the product with a product that is new or which has been manufactured from new or serviceable used parts and is at least functionally equivalent to the original product, or

*refund the purchase price of the product.

See to your preferred Apple-Certified-Reseller with your Macbook and state your claim. You should be proposed a fix at not cost if the defect is due to bad material or workmanship under normal use.

A: What I can tell you from personal experience in working at the Genius Bar is that there is actually a minimum number of pixels that have to have issues in order for them to replace the display. If memory serves, it's 3 or 4 for a 13" machine. However, if you're within 30-90 days of purchase, they will probably make an exception, especially if you mention that it's only 30-90 days old.
Alternatively, if you want to avoid going through Apple you can try running the Flurry screen saver overnight. Make sure you bump up all the settings on it. Any Genius you talk to that has been to Genius Training will try this first, probably overnight or more. Give it a shot.

A: From this OS X Daily article, the official dead/stuck pixel policy (from 2010) is:

Apple's Dead & Stuck Pixel Policy
Here's the breakdown from the leaked Genius chart:

*

*iPod nano, iPod touch, and iPhone screens: repair or replace after 1 or more dead pixels

*iPad: repair or replace after 3 or more dead pixels

*MacBook, MacBook Air, MacBook Pro 13″ and 15″ models: replace after 4 or more bright pixels, 6 or more dark pixels

*MacBook Pro 17″, displays up to 20″: replace after 5 or more bright pixels, 7 or more dark pixels

*iMac 24″ and iMac 27″, Apple Cinema Displays from 22″ to 30″: replace after 9 or more bright pixels, 11 or more dark pixels

However, the article also suggests that real world treatment can be very different:

Apple's Official Dead Pixel Policy vs Real World Experience
While the official guidelines for handling dead pixels seem strict, I
suspect there is a larger policy at the Apple Store for ensuring
customer satisfaction. Speaking from direct experience, Apple can be
far more generous than this support document suggests. Case in point;
I purchased a MacBook Pro 13″ earlier in the year and discovered a
single dead pixel glowing bright red smack in the center of the
screen, you couldn't miss it. I took the Mac back to the Apple Store
and an Apple Genius swapped the machine out immediately, saying he
wanted to be sure I was happy with my purchase. The new MacBook Pro's
screen was flawless, and yes, I was happy.
My advice to anyone who is dissatisfied with either a dead or stuck
pixel is to talk to Apple, at the end of the day customer service
seems to always win out over official policy.

Your best bet is to bring in your machine to be checked out - it's quite likely that the Apple Genius that you're working with will do his/her best to make you a happy customer.


text:
Q: PHP/MYSQL store variables in array or separate fields Premature optimization is the root of all evil...but...
I am allowing users to input data within categories as in favorite players, favorite teams etc.  They can then use these choices to filter results.  I let them input lists separated by commas so after exploding the data I have it in an array.  So how to store.
Method 1: I could  create a table of users, one row per user, with the categories, as in players, teams as fields and save the choices of each users as an array in the respective field.  (userid would link to basic users table.)
Method 2.  Or I could create separate tables for each thing, players, teams, etc, and have a fixed number of fields say 10, break up the array into each individual value, store and place it in its own field.  (Already have this code working.)  (Again userid is primary key.)
The advantage of Method 1 is it's a bit simpler, one table, no limit on number of choices.
Method 2 seems a bit more robust.  The data is more visible and possibly easier to get and retrieve--although maybe not.
Does anyone have experience with this sort of thing and could recommend one over another?
Thanks for any recommendations, suggestions!


text:
Q: SSIS package name which updated table Please help me to get SSIS package details based table name.
Eg: I have a table A which is update based on ssis package. so i would like to name of that package.
Is there any query i can get it from back end.

A: SSIS packages are basically just XML-files, so you can open it in some text editor and then use the editors Find-function to locate references to your table.

A: If there is no Log files, or an audit table created to store these informations, you cannot find the package that updated a specific table.
There is a workaround that you can do, is to search the packages that contains the table name. if you are interested in this approach, you can read my answer @ Automate Version number Retrieval from .Dtsx files


text:
Q: MVC getting a list of music and image into a table I have already plug in the codes for uploading files and its working but the problem is I want upload image to be in image name table, music in music table column.
But the set of codes below is I upload either of them I will get a new column
Here's my table

                Image File

                Image Preview

               MP3 File

                Remove

Here's my razor html - all my files are upload into a directory, is there a code to get the extension of .jpg into image column and mp3 to mp3 column?
      @foreach (var f in Directory.GetFiles(Server.MapPath(@ViewBag.UploadURL)))
        {
            var fileInfo = new FileInfo(f);

            ViewBag.FileNoExtension = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.'));
            ViewBag.FileExtension = fileInfo.Name.Substring(fileInfo.Name.IndexOf('.') + 1);

               @fileInfo.Name
                @* @ViewBag.FileNoExtension	*@

                       // i need the code for this line to populate mp3 files

                    }

                      @Html.ActionLink("Remove", "Remove", new { id = @ViewBag.StoryID, id2 = @ViewBag.FileNoExtension, id3 = @ViewBag.FileExtension })

        }

A: I have assumed you have some form of common naming to relate the images to the names. For this example I have simply assigned the images to the MP3 files in sequence.

*

*Do the messy work in the controller, not your view. Keep views simple.

*Use a View model for the content that is closer to what your view needs.

*Get the controller to do the messy work of converting raw facts into the view model.

*Controller then passes view mode to view to display it.

Your view should be simple like this:
@model IEnumerable<SomeWebApplication.Models.MusicItem>

            Image File
            MP3 File
            Remove

        @foreach (var item in Model)
        {

                <embed src="@item.MusicUrl" />
                @Html.ActionLink("Remove", "Remove", new { id = @item.Id })

        }

...it takes a collection of MusicItems as its View Model
The View Model will look like:
public class MusicItem
{
    ///
    /// Unique id of item
    ///
    public int Id { get; set; }

    ///
    /// URL to image
    ///
    public string ImageUrl { get; set; }

    ///
    /// Url to music
    ///
    public string MusicUrl { get; set; }
}

Your controller should do the heavy lifting:
    public ActionResult Details(int id)
    {
        Story story = db.Stories.Find(id);

        // Use server relative paths for views
        String filepathMusic = "/Upload/story/Music/" + story.FileURL;
        String filepathImage = "/Upload/story/Image/" + story.FileURL;

        // Build a list of MusicItem objects
        List<MusicItem> items = new List<MusicItem>();
        string[] musicFiles = Directory.GetFiles(Server.MapPath("~" + filepathMusic));
        foreach (var musicFile in musicFiles)
        {
            items.Add(new MusicItem()
            {
                Id = id,
                MusicUrl = filepathMusic + "/" + Path.GetFileName(musicFile)
            });
        }

        // This example simply allocates the images in the order found - need to do this properly
        string[] imageFiles = Directory.GetFiles(Server.MapPath("~" + filepathImage));
        int index = 0;
        foreach (var imageFile in imageFiles)
        {
            if (index < items.Count)
            {
                items[index].ImageUrl = filepathImage + "/" + Path.GetFileName(imageFile);
            }
            index++;
        }

        return View(items);
    }

then, assuming you have 2 images and two files in your story...
The end result of the test code above looks like this:


text:
Q: How Do You Disable/Enable 3G Programatically on Android? I'm trying to code an app for android that needs to enable and disable 3G (move between 2g and 3g), but can't find anything about it...is that possible? Can I get a snippet code or some documentation? Thanks in advance

A: No , it is not possible as just in other mobile platforms not possible..

A: Similar question over here from the other side:
Is it possible to force network traffic through Wifi or the TMobile network?
Are you talking about moving between Edge and 3g or turning on and off the Wifi.


text:
Q: Which operating system should I choose for OpenStack? So, soon we will deploy some new developers infrastructure on OpenStack and I have not so much experience in that sphere. First of all which operating system should I use? Mostly I use CentOS maybe it's a good idea to use it?

A: Ubuntu's support of OpenStack is more established than Redhat/CentOS. The OpenStack Community releases are generally supported on Ubuntu first with Redhat support trailing a few days behind.  Either will work though.
OpenStack lists both on their Known Packaged Distributions.
Update: RedHat published a FAQ on their OpenStack support.

A: If you're familiar with CentOS, go for it - Openstack supports it. CentOS is one of the more popular distros to run Openstack on too so resources should be quite good.
Here are the install notes from their Wiki for different distribution versions.


text:
Q: Undefined error while exporting variable in Nodejs This is my managedb.js
var Sequelize = require('sequelize-postgres').sequelize;
var postgres  = require('sequelize-postgres').postgres;

 var db = new Sequelize('test', 'postgres', 'postgres', {
  dialect: 'postgres'
});

var models = [
'user'
];

models.forEach(function(model) {
module.exports[model] = db.import(__dirname + '/' + model);
});

module.exports.db = db;

This is my user.js
var sequelize = require("sequelize");
var seq = require("./managedb");
var db = seq.db;

var Project = db.define('Project', {
  title: sequelize.STRING,
  description: sequelize.TEXT
});

I'm confused why I'm getting this error:
var Project = db.define('Project', {
                 ^
TypeError: Cannot call method 'define' of undefined

Why is this being caused? Am I exporting the variables wrong? Or do I've to add a db.sync() statement to managedb.js?


text:
Q: Nuxt plugin - API call only server side but inject server & client side I have an API call in a plugin and inject the data.
This works the only problem is that the API call is being done on server and on client.
export default async (context, inject) => {
  const api_data = await fetch('data')
  inject('config', api_data)
}

If I wrap it in a conditional or set the mode through nuxt.config.js like so:
// inside plugin
if (process.server) {...}

// OR set the plugins mode in nuxt.config.js
plugins: [{ src: '~/plugins/server-only.js', mode: 'server' }]

Then it is properly injected Server Side but is not longer available on Client Side and breaks.
How can I "cache" the API call from server side and reuse it for client side?


text:
Q: Database schema design: What to do about unverified invitations? I'm not quite sure how to approach this issue:
I am creating a web application that has an invite only registration system. An admin user sends an email invitation to a user, the user clicks the link, and takes them to a page where they can create an account that has been linked to their email address.
My initial idea was to insert a row into my users table, with the verified column marked false. The problem is I have username, and password as required fields and username must be unique. So I can't just insert an empty row to be filled out later.
Should I create a separate table for the invitations? What would be the best way to approach this type of scenario?
Update: The admin will enter the first name, last name, email address, and user role (permissions). So I will need to store all these things in the invitations table. I could also store date sent and update that value if the email ever needed to be re-sent.

A: Yes, you would make a separate table to manage invitations.
Then when an invitation is accepted, you have a few choices.  First you'll want to decide if you need to maintain an association to the original invitation either for tracking or "family tree" or some other historical purposes.
Next, if so, you'll need to decide how you'll do that.  Delete the invitation and store any relevant info w/the user record?  Keep the invitation record and set a foreign key?
I might be able to give some more fine-tuned advice if I know more about the system you intend to create.

A: You have to consider scenarios where invitations get lost, get deleted by accident, or for a host of other reasons, are not usable and have to be re-sent.
Also, an invitation is a separate entity from a registration. I think you should create a separate table to track the invites vs. to see who registered (from which invite)

A: Couple of ways to look at this.  If you go the separate route where you create another table what happens when the evaluation phase is over, do you have to copy those evaluation users over to your real user table?  User names can be defaulted to a specially crafted GUID that you've programmed to handle entry into your users table.

A: I would recommend a separate table for invitations. It seems pretty clear to me that your invitation is basically a token allowing someone to register.

A: A separate table makes the most sense to me.  That would allow you to maintain data integrity in the users table, and would provide a more readable data model.  It is easier to say "invitations go in the invitations table" than "invitations go in the users table but with the verified column set to false".


text:
Q: PDT Eclipse Annoying Bug with Namespaces and external project I recently installed Eclipse PHP (PDT) 64bit; Java 64bit. It loads fine.
Then I imported Handlebars; handlebars.js, two projects from Github. And my own; separate project.
Because it's a new installation since a while, it also came with PHP7 for the first time for me.
It started showing these annoying errors, and I can't get rid of them. Googled about it, to no avail. I could ask on stackoverflow, but Im sure they will complain about 'software specific issue' if I did.
Can someone help me out; is this a project setting that I overlooked (Ie. do I need to add a 'linked project' of Handlebars, etc.). It seems like an easy fix to me, I just dont see the solution.

A:
You need to add those projects as 'included libraries' first.

*

*In the Project Explorer, Right click on your project, click Properties.

*Expand and select PHP > Source Paths > Include Path

*Select the Projects tab.

*Click Add.

*Select the project(s) whose code contains the correct references/namespaces/classes etc.

*Click OK.

*Click Apply and Close.

That should do it, and it worked for me. Hope this will help someone else.


text:
Q: Exponential distribution: waiting time at Post Office using Memoryless property
Here is the background of the question. I am stuck on part b. Here is what I have so far. I would appreciate any help. Thank you!
Let $M = \min(X_1, X_2)$ where $X_1$ represents the exponential process of service time for clerk 1 and $X_2$ is for clerk 2. Then, we have 2 cases: clerk 2 is slower initially and when clerk 1 is slower initially. We then get $P(X_1>X_2\mid M=X_1)P(M=X_1) + P(X_2>X_1\mid M=X_2)P(M=X_2)$. I know how to find $P(M=X_1)$ and $P(M=X_2)$ ($\frac{\lambda_1}{\lambda_1+\lambda_2}$ for $P(M=X_1)$), but I am unsure how to use the memoryless property of exponential distributions to solve the first conditional probability.

A: Recall that exponential distributions are memory-less. Therefore, at the time when the first of Jake and Naomi get done with their service, Paul would go to the server that becomes empty. Say he goes to server 1 at time $t=s$. Then, due to memoryless property, $\mathbb{P}[X_2>t+s|X_2>s] = \mathbb{P}[X_2>t]$. Thus, we are comparing the distributions for $X_1$ and $X_2$ afresh.
Concretely, let $\lambda_1 = \frac{1}{3}, \lambda_2 = \frac{1}{5}$. Then $\lambda_{min(1,2)} = \lambda_1 + \lambda_2 = \frac{8}{15}$ (See linked question)
Thus the expected time at which Paul enters the service is $T_{entry} = \frac{1}{\lambda_{min(1,2)}} = \frac{15}{8}$
Now for part A there are two cases as you have pointed out. $\mathbb{P}[M=X_1] = \frac{\lambda_1}{\lambda_1+\lambda_2}=\frac{5}{8}$ and $\mathbb{P}[M=X_2]=\frac{3}{8}$
If $M=X_1$, then time taken for Paul to finish service in expectation is $\mathbb{E}[T_{total|M=X_1}] = T_{entry} + \frac{1}{\lambda_1} = \frac{15}{8} + 3 = \frac{39}{8}$
Similarly, $\mathbb{E}[T_{total|M=X_2}] = T_{entry} + \frac{1}{\lambda_2} = \frac{15}{8} + 5 = \frac{55}{8}$
Finally we have by iterated expectation, $\mathbb{E}[T_{total}] = \mathbb{E}_M\big[\mathbb{E}_{T|M}[T_{total}|M=X_i]\big] = \frac{5}{8}\cdot\frac{39}{8}+\frac{3}{8}\cdot\frac{55}{8}=\frac{45}{8}$

For part B, we again have two cases. If $M=X_1$ in the first iteration when Paul enters the system, then $M=X_2$ in the second iteration for Paul to finish last. Similarly, if $M=X_2$ in the first iteration, then $M=X_1$ in the second iteration. The total probability of this happening is
$\mathbb{P}(\text{Paul finishes last}) = \frac{\lambda_1}{\lambda_1+\lambda_2}\cdot \frac{\lambda_2}{\lambda_1+\lambda_2}+\frac{\lambda_2}{\lambda_1+\lambda_2}\cdot \frac{\lambda_1}{\lambda_1+\lambda_2} = \frac{2\lambda_1\lambda_2}{(\lambda_1+\lambda_2)^2} = \frac{\frac{2}{15}}{(\frac{8}{15})^2} = \frac{15}{32}$


text:
Q: Expression Output - Unsure how to verify solution Okay - so, I have the expression $5x^2+2x-3$ and have found that odd integers ($2x+1$) output an even number ($2\times integer$). But, how do I know this is the LARGEST set of integers that outputs an even number?

A: When $x$ is even, $5x^2$ is even, $2x$ is even, and $3$ is odd, which means $5x^2 + 2x - 3$ is odd. When $x$ is odd, $5x^2$ is odd, $2x$ is even, and $3$ is odd, which means $5x^2 + 2x - 3$ is even. These are the only two possible cases for $x$.
Thus, for the expression to be even, $x$ must be odd, so the odd numbers are the largest set of integers such that $5x^2 + 2x - 3$ is even.

A: Write it as $n = 5x(x+1) - 3(x+1)$. The first term is even since the product of consecutive integers $x(x+1)$ is always even. Then $n$ will have the same parity as the second term which, given that $3$ is odd, is the parity of $x+1$. So in the end $n$ even $\iff x+1$ even $\iff x$ odd.


text:
Q: Взаимное обтекание 2 колонок Есть простая 2-колоночная вёрстка блока; ширина статичная, float: left|right; в одной - мозаика картинок, в другой - текст; но, разность из высоты различна: может быть больше как картинок, так и текста. Можно ли в рамках CSS заставить одну колонку обтекать другую, если та это позволяет?
A: В голову приходит вариант использования одинаковых float'ов ( left или right) для обеих колонок и тогда обтекание будет, но т.к. у Вас высота заранее не известна, то может быть проверять на JS высоту и делать float в ту сторону где меньше контента. (Если мало картинок то left, много текста - right ).


text:
Q: Tablix in a RDLC report with fixed height I have a tablix inside a rectangle at middle of my report and when it grows in rows, the page grows too and borders fall in another page. How can I set the tablix to fill it's rows just until rectangle's borders?

A: On textboxes on Tablix, Rightclick and goto TextBox Properties, in Sizing Options uncheck Allow height to increase.


text:
Q: How to represent a set of words as a vector in my application? First of all, let me briefly describe my task:
There are about 10^9 sets of words, each sets contains about 10^4 words, which indicates it will be very space consuming to store all those sets in disk. I want to know the number of common words between two sets. However, I don't care what those common words are. I even don't need to know the accurate number which means that an estimated value is enough to me. The key is to find an appropriate representation for these sets so that they could be stored.
A natural idea is to represent a set of words as a vector, and then train a regression NN model whose input are two vectors, which represent two sets, and output is a value which estimates the common words between two input sets. The problem is how to represent these sets as vectors. It's definitely impossible to directly apply the bag of words model, since the dictionary is too big to store. Maybe I can utilize some dimensionality reduction methods on bag of words first to achieve a smaller representation of vector. Or maybe I can apply word embedding to each word, and then sum them up to represent a set. Is there any advice? Or is there any relative work already?


text:
Q: OpenGL4 Multisample Anti-Aliasing and Render To Texture I have a working OpenGL multipass rendering example, and need to add multisampling.
I tried two approaches. Both approaches do not use depth or stencil buffers, but only render colors.
Multisampling during principal rendering
1. Bind Multisampling Fbo
2. Render geometry
3. Blit / resolve multisampling
4. [1..n] Bind normal Fbo and apply post-process

Multisampling at the end
1. Bind normal Fbo
2. Render geometry
3. [1..n] Bind normal Fbo and apply post-process
4. Bind Multisample Fbo
5. Render result texture onto a quad into the multisample fbo
6. Blit / resolve multisampling

Problem
While both approaches seem to work (complete framebuffers etc), I can clearly see hard edges in the second approach. Only using the first approach I actually get antialiased soft edges.
Is there a conceptual problem with the second approach? Are there some specific prerequisites to multisampling so that it won't work as described?
I would greatly prefer using the second approach.

A: Your second approach cannot work. Multisampling uses coverage information to write different values for each sample belonging to a pixel. You lose this information when you draw your geometry into a non-multisample buffer. Rendering the non-multisample buffer into the multi-sample buffer can't recover information which is no longer there (the aliasing has already happened).


text:
Q: Is the average of two endpoint's instantaneous rates of change always the same as the average rate of change of the interval on a parabola? Is the average of two endpoint's instantaneous rates of change always the same as the average rate of change of the interval on a parabola? If not, which additional circumstances would cause it to always be the same?
EDIT: How would you verify this algebraically? Answered
EDIT 2: They both result in the same answer, but do they get their answer from the same line that touches/intercepts the graph, or do they get their answer from different lines (secant, tangent, etc.) that touch/intercept the graph, and because the two lines are always parallel to each other, they result in the same answer?

A: I'll give you a hint, but you need to know some calculus to understand the problem itself.
Recall that average value of a function $f$ on the interval $[a,b]$ is: $$\frac{f(b)-f(a)}{b-a}$$
And the average of the two endpoints instantaneous rate of change is given by:
$$\frac{f'(b) + f'(a)}{2}$$
Where $f'(x)$ is the derivative at some point $x$.
Now think about a polynomial of the form $f(x) = x^2$. How would you go about showing the two expressions above are the same? And then you could do the same kind of algebraic manipulation for any parabola of the form $f(x) = a(x-h)^2 + k$ with $a,h,k$ some constants. It's just more algebra.

A: A parabola is the graph of a quadratic polynomial $f(x)=ax^2+bx+c.$ The average rate of change of $f$ on the interval $[r,s]$ is $\frac{f(s)-f(r)}{s-r}.$ You can check that this computes to $\frac{a(s^2-r^2)+b(s-r)}{s-r} = a(s+r)+b.$ The instantaneous rate of change of a function is its derivative $f'$. In this case $f'(x)=2ax+b,$ so the instantaneous rates at the endpoints are $f'(s)=2as+b$ and $f'(r)=2ar+b.$ The average of these two values is easily seen to be $a(s+r)+b,$ which is what you wanted.


text:
Q: Using D3 with Electron React app I'm building an app using electron with electron-react-boilerplate found here  https://github.com/chentsulin/electron-react-boilerplate.git , it's all working fine.
But when I am trying to use D3, electron always throws me the error zTypeError: Cannot read property 'version' of undefined.  (ie : console.log(d3.version) ).

*

*I followed the instructions found here: Can D3 library be used with the Electron (Atom shell)?, with no result.

*I added script (https://d3js.org/d3.v3.min.js) to index.html, with no result.

*The same issue with <script>var d3 = require("d3")</script>.

My Config:

*

*Electron 1.4.15

*Chromium 53.0.2785.143

*node@6.9.4 | win32 | x64

*react 15.4.2

*d3 4.5.0

I hope someone can help with this issue.

A: I simply use var d3 = require('d3'); at the top of any jsx file that requires d3. This works for both of the electron + d3 based apps that I am currently working on.


text:
Q: Unable to override $theme-color in bootstrap It's bootstrap 4.0 with SASS
My style.scss file contains the following code:
@import "../bootstrap/scss/bootstrap";

@import "colors";
@import "main";

and _colors.scss file contains the following code:
$bg-white : white;

$theme-colors: (
        primary: #333333
)

You can see that I am just trying to override the $theme-color('primary') but the problem is this that it does nothing.
And If I shift @import "colors" in the start of the file style.scss It gives me following error:

error ../bootstrap/scss/_forms.scss (Line 284: $color: null is not a
  color for `rgba')

Actually, the style.scss file compiles to style.css file and that one is linked file.
Question: How I can override the $theme-color in bootstrap-4 when using SASS?
Any help will be appreciated, and Thanks in advance
Cheers.

A: None of the solutions provided work. Some are close and will update the color use on most elements, but not all elements. I have tried them all (and every other alternative I can find on StackOverflow and other websites, but those solutions only affect the elements that are specifically referencing the color property and does not update those using the theme-color function to get the color.
The expected solution (and recommended by others) is
/* import only the necessary Bootstrap files */
@import "../../node_modules/bootstrap/scss/functions";
@import "../../node_modules/bootstrap/scss/variables";

/* -------begin customization-------- */
$colors: (
  "" + blue: #004C9E
);

/* 80 required to bring primary and secondary colors to AAA standards */
$theme-colors: (
  primary: #004C9E
);

// /* -------end customization-------- */

/* finally, import Bootstrap to set the changes! */
@import "../../node_modules/bootstrap/scss/bootstrap";

But this leaves 15 occurences of #007bff (the normal blue/primary color) throughout the generated custom.css. Examples of it occur in the pagination section, e.g.
.page-item.active .page-link {
  z-index: 1;
  color: #fff;
  background-color: #007bff;
  border-color: #007bff;
}

By setting both the $colors and the $theme-colors custom properties after the import of the functions.scss, and placing the statement to import the variables.scss AFTER these changes appears to set the new colors throughout. I presume that by setting these variables specifically, the bootstrap variables cannot override them.
@import "../../node_modules/bootstrap/scss/functions";

/* -------begin customization-------- */
$colors: (
  "" + blue: #004C9E
);

/* 80 required to bring primary color to AAA standards */
$theme-colors: (
  primary: #004C9E
);

@import "../../node_modules/bootstrap/scss/variables";

/* put other customization in here */

// /* -------end customization-------- */

/* finally, import Bootstrap to set the changes! */
@import "../../node_modules/bootstrap/scss/bootstrap";

The may not seem right, but it does appear to work. I'm not a SASS expert, so maybe someone else could explain this better. I hope this helps anyone who may still be struggling to solve this issue.

A: Update 2021 for Bootstrap 5
Per the guidance in the docs...

"Variable overrides must come after our functions are imported, but
before the rest of the imports."

Therefore, overriding the theme-colors in Bootstrap 5 works the same way as 4.x. In order to override the theme-colors, simply change appropriate theme color variable before importing bootstrap.scss
/* custom.scss */
/* change theme colors */
$primary: #362ec4;
$secondary: #8f5325;
$success: #3e8d63;
$info: #7854e4;
$warning: #b8c924;
$danger: #d62518;
/* end custom.scss */

@import '~bootstrap/scss/bootstrap.scss';

Update 2018 for Bootstrap 4.1
To change the primary, or any of the theme colors in Bootstrap 4 SASS, set the appropriate variables before importing bootstrap.scss. This allows your custom scss to override the default value, and will then be set in all the theme-colors loops (btn-primary, bg-primary, text-primary, etc..)...
/* import the necessary Bootstrap files */
@import "bootstrap/functions";
@import "bootstrap/variables";

$theme-colors: (
  primary: #333333;
);

/* finally, import Bootstrap */
@import '~bootstrap/scss/bootstrap.scss';

Demo: https://www.codeply.com/go/lobGxGgfZE

Also see this answer

A:
I'm assuming that you have installed Bootstrap 4 beta using npm and you wish to customize the Bootstrap SCSS without modifying the source in node_modules.
The way I do it is by overriding the Bootstrap variables contained in variables.scss:
app-styles.scss
// Custom SCSS variables I wish to override (see below)
@import 'assets/styles/variables';

// Bootstrap 4 from node_modules
@import '~bootstrap/scss/bootstrap.scss';

variables.scss
$theme-colors: (
    primary: $trump-hair,
    secondary: $gandalf-hat,
    success: $my-favorite-color,
    info: #FBC02D,
    warning: #FF5722,
    danger: $color-of-melena,
    light: #1B5E20,
    dark: $bile-green
);

The way to override bootstrap theme colors is actually due to be changed in the upcoming beta 2. The current requirement is that you have to include the entire theme-colors Sass map when overriding. In the current beta, failure to include the entire Sass map will result in:

Argument $color of darken($color, $amount) must be a color

Please see this Github issue and this Codepen for more information, and an example of how you will be able to override theme colors in beta 2.

A: This got me too.  You need to import functions.scss into your scss file before variables.
@import '../../node_modules/bootstrap/scss/functions';
@import 'assets/styles/variables';
@import '../../node_modules/bootstrap/scss/bootstrap';

Your paths may differ.
This is with Bootstrap 4 Beta 1.


text:
Q: Big Sur 11.3 - clang: error: invalid version number in '-mmacosx-version-min=11.0' On recent Big Sur 11.3, when compiling a simple source like this :
g++-10 -c  -Wall -c -I/usr/local/include -I/usr/local/include/c++/10.2.0 main_gnu.cpp

I get the following error :
clang: error: invalid version number in '-mmacosx-version-min=11.0'

This looks like to the same issue than in '-mmacosx-version-min=11.2'
I removed CLT (CommandLineTools) and reinstall it, same error.
I don't want to install Xcode since up to now, I always worked only with CLT to compile.
I have also tried : export SYSTEM_VERSION_COMPAT=1
I have the following installation :

I have also tried to make the link : MacOSX.sdk -> MacOSX10.15.sdk, without success.
I don't understand why clang is called and where this flag comes from, I just compile with brew g++-10.
What might have happened here?


text:
Q: Apple's advertisingIdentifier vs mac address? What are the differences between Apple's advertisingIdentifier and the mac address? Can it replace the mac address? Can Routers read it? e.g. advertisingIdentifier is in the application layer of the stack.

A: From the Apple documentation on this topic:

Unlike the identifierForVendor property of the UIDevice, the same value is returned to all vendors. This identifier may change—for example, if the user erases the device—so you should not cache it.

If the identifier can change, then there are little chances to be equivalent of the mac address of your device.

If the value is nil, wait and get the value again later. This happens, for example, after the device has been restarted but before the user has unlocked the device.

So Apple computes this value when iOS starts, it might use the mac address when computing the identifier (among other info), however this doesn't guarantee the two are the same.
Routers might see it as part of the network traffic (if you're not using SSL) but they can't know that thats an advertisingIdentifier.


text:
Q: nodejs 6.1.0 install error with - node-pre-gyp I googled many related question and i am lost as i am a beginner to ionic.
My npm version: 6.1.0
My nodejs version: 10.5.0
i cloned a private repo and the first thing i do is npm i to install the packages.
Then i encounter the error when it reach here:
> grpc@1.10.0 install D:\Projects\...\the-project\node_modules\grpc
> node-pre-gyp install --fallback-to-build --library=static_library

And then a bunch of error has been throw:
node-pre-gyp ERR! Tried to download(403): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.10.0/node-v64-win32-x64-unknown.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc@1.10.0 and node@10.5.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.10.0/node-v64-win32-x64-unknown.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for grpc@1.10.0 and node@10.5.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python2.7", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (D:\Program File\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (D:\Program File\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at D:\Program File\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:158:21)
gyp ERR! gypSystem Windows_NT 10.0.16299
 ERR! configure error
gyp gypERR!  commandERR! "D:\\Program File\\nodejs\\node.exe" "D:\\Program File\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=D:\\Projects\\...\\the-project\\node_modules\\grpc\\src\\node\\extension_binary\\node-v64-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--module_path=D:\\Projects\\...\\the-project\\node_modules\\grpc\\src\\node\\extension_binary\\node-v64-win32-x64-unknown" "--python=python2.7" "--msvs_version=2013"
 stackgyp Error: Can't find Python executable "python2.7", you can set the PYTHON env variable.
 gypERR!  ERR!cwd  D:\Projects\...\the-project\node_modules\grpc
stackgyp     at PythonFinder.failNoPython (D:\Program File\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
 gypERR!  ERR!node -v  v10.5.0
stackgyp     at PythonFinder.<anonymous> (D:\Program File\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
 gypERR!  node-gyp -v v3.6.2
gyp ERR!ERR!  stacknot ok     at D:\Program File\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29

gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:158:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "D:\\Program File\\nodejs\\node.exe" "D:\\Program File\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=D:\\Projects\\...\\the-project\\node_modules\\grpc\\src\\node\\extension_binary\\node-v64-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--module_path=D:\\Projects\\...\\the-project\\node_modules\\grpc\\src\\node\\extension_binary\\node-v64-win32-x64-unknown" "--python=python2.7" "--msvs_version=2013"
gyp ERR! cwd D:\Projects\...\the-project\node_modules\grpc
gyp ERR! node -v v10.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not oknode-pre-gyp
 ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'D:\Program File\nodejs\node.exe D:\Program File\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --library=static_library --module=D:\Projects\...\the-project\node_modules\grpc\src\node\extension_binary\node-v64-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=D:\Projects\...\the-project\node_modules\grpc\src\node\extension_binary\node-v64-win32-x64-unknown --python=python2.7 --msvs_version=2013' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (D:\Projects\...\the-project\node_modules\grpc\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:961:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
node-pre-gyp ERR! System Windows_NT 10.0.16299
node-pre-gyp ERR! command "D:\\Program File\\nodejs\\node.exe" "D:\\Projects\\...\\the-project\\node_modules\\grpc\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd D:\Projects\...\the-project\node_modules\grpc
node-pre-gyp ERR! node -v v10.5.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute 'D:\Program File\nodejs\node.exe D:\Program File\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --library=static_library --module=D:\Projects\Projects\...\the-project\node_modules\grpc\src\node\extension_binary\node-v64-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=D:\Projects\...\IONIC\client app\foodNinjaCustomerApp\node_modules\grpc\src\node\extension_binary\node-v64-win32-x64-unknown --python=python2.7 --msvs_version=2013' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.10.0 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.10.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\....\AppData\Roaming\npm-cache\_logs\2018-10-08T10_00_32_262Z-debug.log

I have googled and check many github/stackoverflow post but i am still lost in the middle because all the solution is different and i also don't understand what it is for.
Thus i need help you you, please advise what i have to do.
So far the things i have done is :
1) npm install --msvs_version=2013 -g node-inspector : Error
2) npm config set msvs_version 2013 : no result
3) node-pre-gyp install --fallback-to-build : error 'node-pre-gyp' is not recognized as an internal or external command,
operable program or batch file.

A: The error is stating that python was not found.
gyp ERR! stack Error: Can't find Python executable "python2.7", you can set the PYTHON env variable.
So you should install it (Version 2.7) and add it to the system variables.


text:
Q: EmguCV Image size different from Image.Data size I copy a part of an image to a new one:
bigImage.ROI = SomeRectangle;
Emgu.CV.Image<Emgu.CV.Structure.Rgb, byte> roiImage = bigImage.Copy();

Now roiImage.Cols==roiImage.Width==1 and roiImage.Rows==roiImage.Height==106; however size of roiImage.Data is [106,4,3]. So Width of image is not equal to the second dimension of the data.
Why does that occur?

A: EmguCV requires each row of your image to be aligned by 4 bytes to improve efficiency in fetching data.


text:
Q: How to calculate Bias and Variance to get the MSE value step by step? I want to compute my MSE value for a forecast step by step for  test set.
For me the Bias is:
Bias = mean(predicted values - actual values)
Variance = mean((predicted values- actual values)^2)
MSE = Bias^2 + Variance
When I compare my solution with the solution that i get from the R function MSE i get a wrong number. Do i miss something?

A: $MSE(x_0)\space$ = $\space E_T \left[f(x_0) - \hat{y}_0 \right]^2$
$\quad\quad\quad\quad$ = $\space E_T \left[\hat{y}_0 - E_T(\hat{y}_0)\right]^2 +\left[E_T(\hat{y}_0) - f(x_0)\right]^2$
$\quad\quad\quad\quad$ = $\space Var_T(\hat{y}_0) + Bias^2(\hat{y}_0)$
I think this is what you are looking for. Did you try to square your bias term?


text:
Q: Is there a way to count blank cells, but only if they are between cells with values, in Google Sheets? I am trying to build a google sheet that allows the user to input the shape and size of an array of solar panels, each cell representing a panel, and it outputs the hardware needed to be based on the cells filled in.
For example, between two panels you need two of Widget A. At the end of each row, or where there is an empty space between panels, you need two of Widget B for each panel. This is easy when the array has no empty spaces in a row, as my formula for that is:
Widget A =if(counta(b2:u2)=0, 0, (counta(b2:u2)-1)*2)
Widget B =if(counta(b2:u2)=0, 0, 4)
However, if the row of panels has an empty space in it, these formulas do not see the gap and think that Widget A should go-between rather than actually needing Widget B.
I cannot find a way to find if there is a blank cell between filled cells, and count how many there are.
I have tried varying formulas involving filter, isblank, columns, countblank, index, etc to no luck as they can tell me the value of the first filled cell and the value of the last filled cell, or the number of filled cells, but cannot tell me how many blank cells are in between filled cells in a row.
The below returns the value of the last filled cell:
=INDEX( FILTER( B2:U2 , NOT( ISBLANK( B2:U2 ) ) ) , COLUMNS( FILTER( B2:U2 , NOT( ISBLANK( B2:U2 ) ) ) ) )

and the below find the value of the first filled cell:
=+filter(B2:U2,B2:U2<>"")

But neither allows me to find the blank cell in the middle.
Here is a copy of what I am working on:
https://docs.google.com/spreadsheets/d/1wz3P5giVp0JlneYUZdW6zVPck5tkdohmbnnP_zIfptE/edit?usp=sharing
I would like the count of Widget A to be 12 and the count of Widget B to be 8, but instead, it is 14 and 4 because it does not recognize the gap at H2.

A: =ARRAYFORMULA(COUNTBLANK(INDIRECT(
 ADDRESS(ROW(A2), MATCH("x", A2:U2, 0))&":"&
 ADDRESS(ROW(A2), MAX(IF(A2:U2<>"", COLUMN(A2:U2), ))))))


text:
Q: Is the usage of "if" correct here?
The only way to know you've done the job is if I go in with you.

I guess the sentence describes that only if I go in with you, I can know that you've done the job or not. But is the sentence correct? Can "if" be used like that?

A: I suspect what is troubling you here is the use of an if clause as a nominal.

[SUBJECT The ... way ] ... [VERB (copula) is ] [COMPLEMENT NP if I go in with you. ]

You are right to be troubled. This usage is not yet accepted in formal English, which requires either a) a "canonical" complement clause (preferably one with an infinitive) or b) an adverbial, reflecting the semantics of way:

a) complement clauses
ok The only way to know you've done the job is to go in with you.
ok The only way to know you've done the job is for me to go in with you.
?  The only way to know you've done the job is that I go in with you.
?  The only way to know you've done the job is my going in with you.
b) adverbial: preposition phrase with gerund clause complement
ok The only way to know you've done the job is by going in with you.

However, the if clause used this way is very common in informal English. In fact, there's a corresponding informal use of the if nominal as object of a preposition:

I can't know if you've done the job except if I go in with you.

And note that there is some warrant for it, or at least an analogy, in the entirely acceptable use of if in place of whether to head a free relative nominal:

I can't know if you've done the job.

So it cannot be regarded as a mistake in informal contexts. And it is such a useful construction, simultaneously expressing both means and contingency, that I expect it will become acceptable even in formal contexts within the next generation or so.

A: Yes, it is correct. 'if' is being used here so as the first person can check whether ( if ) the second person does the job. So that's why 'if' is used.
Here are some examples that you can see how 'if' is being used.

A:
The only way to know you've done the job is if I go in with you.

The sentence is correct. If here is the condition that serves the previous clause.
This answers your question. But then...
Do you see something interesting here? It actually emphasizes on whether that person has done the job rather than the status of job i.e. being completed.

The only way to know you've done the job is if I go in with you - If I come with you, then only I see that you are doing the job and not anyone else!

The status of the job (being completed) can be convinced/conveyed in other ways (such as telephone or simply a text) as well. But then here, the job-giver wants to ensure that the job-doer did the job themselves and did not take any assistance!

A: Yes, the sentence is correct. As you see its saying that if the person goes with you then only he can come to know or he can believe that the job is done. So "if" can be used this way also.


text:
Q: Core dump to SAN If an application is installed to a SAN and the process crashes, can a core dump be written to the SAN partition?  I've been trying to track down an issue where our process dies and no core is generated, thus no stack.  Both cases were in two completely separate Solaris environments.  ulimit -c is unlimited, pstack is in the path.  In my initial research I found a statement claiming it is not possible to core dump to a SAN disk.  I have been unable to find this information again, leading me to question its validity.

A: The conditions when no core is generated or listed in core(4), use man core to read the manpage. If the user id nobody is involved, that might happen (or rather, nothing is happening).
You can also use gcore to see if manually obtaining a core dump will help. Check with coreadm, where core dumps go by default -- maybe they are not in the current working directory, but somewhere in /var?
Volker

A: The reference you found to core dumps to a SAN not working is probably referring to core dumps of the kernel itself. (usually called crash dumps on Solaris)
Perhaps the process does not have a useful current directory. Use coreadm to force core dumps to be written somewhere reasonable. See http://developers.sun.com/solaris/articles/manage_core_dump.html
If your process is dying unexpectedly and you have the luxury of destroying its performance, try running it under truss. If this is Solaris 10, dtrace could be quite helpful here.


text:
Q: Why did my arduino program suddenly stop working? So I have a project to make for school in which we had to make an arduino project from scratch. I'm relatively new to arduino and his coding and made a simple, yet fun project. I had the idea of making a sort of safe where you have to enter a key and after that, use a potentiometer to make the right combination to open the safe. I don't know what I did wrong but when I uploaded it to my arduino, the program got to the first lines and stopped after printing the first line to the serial monitor. There the program is stuck and doesn't do anything. The weird thing is that it worked 5 minutes ago but now it just wont. Can anyone help me please? My deadline is in a few hours and I can't fix it... Here is the code and a schematic:
Picture of the setup. The 2 resistors on the left are 1k, the other 2 are 10k.
//variabelen
const int pot = A0;
const int pinA = 6;
const int pinB = 5;
const int pinC = 2;
const int pinD = 3;
const int pinE = 4;
const int pinF = 7;
const int pinG = 8;
const int pinP = 9;
const int enter = 11;
const int reset = 12;
byte enterState = 0;
byte lastEnterState = 0;
byte resetState = 0;
byte lastResetState = 0;
int enterTimer = 0;
String wachtwoord;
String ingegeven = "";

//setup
void setup(){
  pinMode(pinA, OUTPUT);
  pinMode(pinB, OUTPUT);
  pinMode(pinC, OUTPUT);
  pinMode(pinD, OUTPUT);
  pinMode(pinE, OUTPUT);
  pinMode(pinF, OUTPUT);
  pinMode(pinG, OUTPUT);
  pinMode(pinP, OUTPUT);
  pinMode(enter, INPUT);
  pinMode(reset, INPUT);
  Serial.begin(9600);
  Serial.println("Geef een wachtwoord op voor de safe.");
  wachtwoord = Serial.read();
}

//eigen methoden

void dispChar(int getal){
  switch(getal){
    case 0:
      digitalWrite(pinA, LOW);
      digitalWrite(pinB, LOW);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, LOW);
      digitalWrite(pinE, LOW);
      digitalWrite(pinF, LOW);
      digitalWrite(pinG, HIGH);
      break;

    case 1:
      digitalWrite(pinA, HIGH);
      digitalWrite(pinB, LOW);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, HIGH);
      digitalWrite(pinE, HIGH);
      digitalWrite(pinF, HIGH);
      digitalWrite(pinG, HIGH);
      break;

    case 2:
      digitalWrite(pinA, LOW);
      digitalWrite(pinB, LOW);
      digitalWrite(pinC, HIGH);
      digitalWrite(pinD, LOW);
      digitalWrite(pinE, LOW);
      digitalWrite(pinF, HIGH);
      digitalWrite(pinG, LOW);
      break;

    case 3:
      digitalWrite(pinA, LOW);
      digitalWrite(pinB, LOW);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, LOW);
      digitalWrite(pinE, HIGH);
      digitalWrite(pinF, HIGH);
      digitalWrite(pinG, LOW);
      break;

    case 4:
      digitalWrite(pinA, HIGH);
      digitalWrite(pinB, LOW);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, HIGH);
      digitalWrite(pinE, HIGH);
      digitalWrite(pinF, LOW);
      digitalWrite(pinG, LOW);
      break;

    case 5:
      digitalWrite(pinA, LOW);
      digitalWrite(pinB, HIGH);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, LOW);
      digitalWrite(pinE, HIGH);
      digitalWrite(pinF, LOW);
      digitalWrite(pinG, LOW);
      break;

    case 6:
      digitalWrite(pinA, LOW);
      digitalWrite(pinB, HIGH);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, LOW);
      digitalWrite(pinE, LOW);
      digitalWrite(pinF, LOW);
      digitalWrite(pinG, LOW);
      break;

    case 7:
      digitalWrite(pinA, LOW);
      digitalWrite(pinB, LOW);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, HIGH);
      digitalWrite(pinE, HIGH);
      digitalWrite(pinF, HIGH);
      digitalWrite(pinG, HIGH);
      break;

    case 8:
      digitalWrite(pinA, LOW);
      digitalWrite(pinB, LOW);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, LOW);
      digitalWrite(pinE, LOW);
      digitalWrite(pinF, LOW);
      digitalWrite(pinG, LOW);
      break;

    case 9:
      digitalWrite(pinA, LOW);
      digitalWrite(pinB, LOW);
      digitalWrite(pinC, LOW);
      digitalWrite(pinD, LOW);
      digitalWrite(pinE, HIGH);
      digitalWrite(pinF, LOW);
      digitalWrite(pinG, LOW);
      break;
  }
}

//Kijk of enter knop is ingedrukt
void onEnter(){
  enterState = digitalRead(enter);
  if(enterState == HIGH){
    enterTimer++;
    if(enterState != lastEnterState){
      ingegeven += map(analogRead(pot), 0, 1023, 0, 9);
      Serial.println(ingegeven);
      enterTimer = 0;
    }
  }
  delay(50); //Voorkomt bounce.
  if(enterTimer > 50){
    Serial.println("\nRESET");
    enterTimer = 0;
    ingegeven = "";
  }
  lastEnterState = enterState;
  check();
}

bool check(){
  if(ingegeven.equals(wachtwoord)){
    return true;
  } else{
    if(ingegeven.length() > wachtwoord.length()){
      Serial.println("FOUT!");
      ingegeven = "";
      return false;
    }
  }
}

//Kijk of reset knop is ingedrukt
void onReset(){
  resetState = digitalRead(reset);

  if(resetState != lastResetState){
    if(resetState == HIGH){
      ingegeven = "";
      Serial.println("Geef een wachtwoord op voor de safe.");
      wachtwoord = Serial.read();

    }
  }
  delay(50); //Voorkomt bounce.
  lastResetState = resetState;
}

//loop
void loop(){
  while(!check()){
    int getal = map(analogRead(pot), 0, 1023, 0, 9);
    digitalWrite(pinP, HIGH);
    dispChar(getal);
    onEnter();
    onReset();
  }
  Serial.println("CODE CORRECT!")
}

Thanks for the help!!