text:
Q: kind of non-visual frequency histogram in C I would like to make a kind of frequency histogram. I have a binary file describing a song with double between -1 and 1 ( like -0.001235 ) and i would like to make a fonction that gives me the number of values between 0.9 and 1 for example. But where it's not easy for, it that the space of interval can change.
It's like, I want 40 or 50 or 100 interval between -1 and 1, and couting the number of double in those interval. Is it all clear ? ^^'
e.g : [-1,-0.9] -> 152 values .... [-0.9,-0.8] -> 34 values ....
I have already an array of 1024 frequency double (*tab)[1024]; thank you for your help :)

A: First you need a function which counts all frequences in an interval in on table:
int countinterval( double *tab, int tabsize, double min, double max )
{
    int count = 0;
    for ( int i = 0; i < tabsize; i ++ )
    {
        if ( tab[i] >= min && tab[i] < max ) // test if frequency is in interval [min,max[
        // if ( tab[i] >= min && tab[i] <= max ) // test if frequency is in interval [min,max]
            count ++;
    }
    return count;
}

Next you need a function which sums the results of each table.
int counttabsinterval( double *tab[], int tabsize, int tabcount, double min, double max )
{
    int count = 0;
    for ( int i = 0; i < tabcount; i ++ )
        count += countinterval( tab[i], tabsize, min, max ); // sums results
    return count;
}

Call the function for each interval where you want to know number of frequencies.
double *tab[1024];
int tabsize = ???; // <- init with size of one table
int count1 = counttabsinterval( tab, tabsize, 1024, -1.0, -0.9 );
int count2 = counttabsinterval( tab, tabsize, 1024, -0.9, -0.8 );

Here is a function which calculates the Quantitative Frequency Distribution for on table tab with lenght of table tabsize ans stores the result in an array distwith length distcount.
void QuantitativeFrequencyDistribution( double *tab, int tabsize, double *dist, int distcount )
{
    int count = 0;
    double intervallAmount = 2.0 / distcount;
    for ( int i = 0; i < distcount; i ++ )
    {
        double min = -1.0 + i*intervallAmount;
        double max = min + intervallAmount;
        dist[i] = countinterval( tab, tabsize, min, max );
    }
}

int sizeOfTab = ?;// <- init with size of table
double *tab; // <- your table
int distcount = 20; // for example
double dist[distcount];
QuantitativeFrequencyDistribution( tab, sizeOfTab, dist, distcount );

If you have different tables with different lengths and you want to know the Quantitative Frequency Distribution over all tables, you have to call QuantitativeFrequencyDistribution for each single table and calculate sum of the results.

A: I made those 2 function. that count the frequence of apparition of values between N interval between -1 and 1
int countInterval(double *tab, double min, double max){
    int i, count = 0;
    for (i = 0; i < POINTS; i++){
        if (tab[i] >= min && tab[i] < max) {
            count++;
        }
    }
    return count;
}

int *countWindow(double *tab){
    // interval +1
    double interv = INTERVALLES;
    int *interval = (int*)malloc(sizeof(INTERVALLES)), i, debug = 0;
    double lb = 2/interv;
    double min = -1;
    double max = min + lb;

    if (debug==1) {
        printf("lb : %f\n",lb);
    }

    for(i = 0; i < INTERVALLES; i++){
        interval[i] = countInterval(tab, min, max);
        if (debug==1) {
            printf("min = %f - max = %f - count = %d\n", min, max, interval[i]);
        }
        min += lb;
        max = min + lb;
    }
    return interval;
}

I give a double *tab (10 for example) :
0.004517
0.030243
0.014862
0.005188
0.002289
0.026917
-0.013641
0.017395
0.032867
0.036072

and i have a result like that :
lb : 0.400000
min = -1.000000 - max = -0.600000 - count = 0
min = -0.600000 - max = -0.200000 - count = 0
min = -0.200000 - max = 0.200000 - count = 10
min = 0.200000 - max = 0.600000 - count = 0
min = 0.600000 - max = 1.000000 - count = 0


text:
Q: Google Play Store APK - Device Compatibility Issue My app APK is uploaded to the Google Play Store. Surprised to see that the supported devices list shown as  0.
I think this got something to do with the manifest setting. It could well be one of the following features or permissions is having the issue with google play filter . I have specified clearly in the Manifest.xml that only SDK 18 or above is able to run the app .
Contacted Google support, still no answer after almost 120 hours past.
I have seen some suggestions that this may well be the ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION setting related issue.
Appreciate any help on this. Thanks.

Features
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
android.hardware.BLUETOOTH
android.hardware.BLUETOOTH_LE
android.hardware.LOCATION
android.hardware.location.GPS
android.hardware.location.NETWORK
android.hardware.screen.PORTRAIT
android.hardware.TOUCHSCREEN

Permission
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_NETWORK_STATE
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission.INTERNET
android.permission.READ_EXTERNAL_STORAGE
android.permission.WAKE_LOCK
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.WRITE_SETTINGS
com.google.android.c2dm.permission.RECEIVE
mypackage.permission.C2D_MESSAGE

A: I think you should setup on the grade file:
Such as
   defaultConfig {
        applicationId "com.."
        minSdkVersion 18
        targetSdkVersion 22
        versionCode 9
        versionName "1.8"
        // Enabling multidex support.
        multiDexEnabled true
    }

It will help you.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to create form or survey with same multiple choice answers I have a need to create a SharePoint questionnaire for building inspections.
These inspections are to be performed weekly by different departments
Each area to be inspected will have a reply of: satisfactory, unsatisfactory, safety hazard, or well maintained.  The questions will be grouped according to departments.
Once all answers are submitted, I need to be able to total the number or satisfactory responses, US responses, etc.
I've tried using the out of the box survey with a lookup to the answer choices, but the export to excel does not give me a good way to total the responses.
Example:
Kitchen Questions
Q: Floor  Answer choices: S, US, SH, WM
Q: Refrigerator  Answer choices: S, US, SH, WM
Warehouse Questions:
Q: Forklift Answer choices: S, US, SH, WM
Q: Storage Shelves  Answer choices: S, US, SH, WM
Once these questions are answered, I will need to total the number of each answer choice according to the departments.
I've also tried using InfoPath with yes/no checkboxes by each answer choice.  Needless to say, this created way too many fields to keep track of.
Any and all ideas are appreciated!

A: I've made something similar once, with around 95 questions that was answered by around 400 people.
My weapon of choice in these situations is InfoPath and promoting the anwser fields to fields in a SharePoint list. You should only end up with one SharePoint field per answer.
Use the choice field in InfoPath to create either lookup choices from SP-lists or type them in manually.
When you need to run analytics on your answers, turn to Excel. Pull all the data from the list into Excel and do your counting and graphs there.
Naming your fields and organizing them in InfoPath is key to keeping everything structured.
Hope it helps.

A: This is not possible out of the box. You will need code or 3rd party tools.
InfoPath would be a good track to follow. If you want to work with surveys a lot, you may want to have a look at the techniques and tools offered by Qdabra Software. They have a few inexpensive (as in: a licence costs less than a day's developer time) tools to help with these scenarios. Qdabra also have many video tutorials on YouTube to help get familiar with their technology.
I am not connected to Qdabra, I am just a very happy user of their tools, which are a chest of nuggets for people like me who don't use code.


text:
Q: What to look at next within the hs_err_pid###.log file? If I see something like the following in the hs_err_pid###.log file, is it a good indication of a leak or memory simply ran out?
The following shows the GC Heap History. There are 250 events and they all look the same with eden space at 100% used and ParOldGen is also maxed out.
GC Heap History (250 events):
Event: 603738.947 GC heap before
{Heap before GC invocations=10735 (full 1042):
 PSYoungGen      total 245248K, used 220160K [0x00000000d5580000, 0x00000000e8680000, 0x0000000100000000)
  eden space 220160K, 100% used [0x00000000d5580000,0x00000000e2c80000,0x00000000e2c80000)
  from space 25088K, 0% used [0x00000000e2c80000,0x00000000e2c80000,0x00000000e4500000)
  to   space 26112K, 0% used [0x00000000e6d00000,0x00000000e6d00000,0x00000000e8680000)
 ParOldGen       total 1398272K, used 1398162K [0x0000000080000000, 0x00000000d5580000, 0x00000000d5580000)
  object space 1398272K, 99% used [0x0000000080000000,0x00000000d5564b30,0x00000000d5580000)
 Metaspace       used 78830K, capacity 83683K, committed 146496K, reserved 1132544K
  class space    used 8021K, capacity 11589K, committed 62824K, reserved 1048576K

Could the following be related to the above? The GC Failed due to a lack of space?
Events (250 events):
Event: 603741.921 Executing VM operation: ParallelGCFailedAllocation
Event: 603742.654 Executing VM operation: ParallelGCFailedAllocation done
Event: 603742.655 Executing VM operation: ParallelGCFailedAllocation

Does the Stack from the file seem to indicate the failure is happening within the JNI layer due to the reference to the libjvm.so file?
Stack: [0x00002b19adbe2000,0x00002b19adce2000],  sp=0x00002b19adce0970,  free space=1018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x687782]
V  [libjvm.so+0x61061d]
V  [libjvm.so+0x474bb6]
V  [libjvm.so+0x612aff]
V  [libjvm.so+0xad56b7]
V  [libjvm.so+0xad3fc8]
V  [libjvm.so+0xad4499]
V  [libjvm.so+0xad48f1]
V  [libjvm.so+0x8beb82]

Here is the siginfo, but it doesn't tell me much :
 siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000040

Based on the above, does this fall into a leak or out of memory error?
What would be the next piece of the log file to research to further diagnose this issue?

A:
Is it a good indication of a leak or memory simply ran out

No. If memory runs out JVM would throw OutOfMemoryError. Does not matter (heap or native). In case of jvm cannot allocate native memory needed via malloc or mmap returning NULL it will by understood be JVM and throw OOME either.
SEGV means a process tried to acess to an invalid memory location (e.g. 0 or a location does not belong to the process).
Without debug symbols of JVM it is difficult to say something specific.


text:
Q: Python video has no sound when sent from whatsapp I have a specific problem while sending my videos from Whatsapp on an iPhone (everything else works: android, web app on windows and mac). Below you can see my code, every time I send my video from the Whatsapp app on iPhone it appears to be without sound on iPhone devices, I will note that if I send the same video through drive for an example it's working fine.
I will add as well that regular mp4 videos do transfer with sound.
Thanks :)
with codecs.open(self.fileName + '.txt', 'r', encoding='utf8') as stampFile:
  for line in stampFile:
      if self.stop:
          return
      self.counter += 1
      time = line.split(";")
      currStart = timeClass.calculateTimeToSec(time[0])
      currEnd = timeClass.calculateTimeToSec(time[1])
      currStart = max(currStart, 0)
      currEnd = max(currEnd, 0)
      if currEnd <= currStart:
          return
      clip = VideoFileClip(self.mediaFilePath)
      if currStart >= clip.duration:
          return
      currStart = min(currStart, clip.duration - 1)
      currEnd = min(currEnd, clip.duration)
      clip = clip.subclip(currStart, min(currEnd, clip.duration))
      path = self.dirName + "\\BBrief-Clips" + "/BBrief-" + str(self.counter) + "-" + self.mediaFileName
        #threading.Thread(target=lambda: clip.write_videofile(path, codec='libx264')).start()
        clip.write_videofile(path, codec='libx264')
        if prevClip is None:
            prevClip = clip
            clip = fadeout(clip, 1)
        else:
            clip = clip.set_start(prevClip.end)
            clip = fadein(clip, 1)
            clip = fadeout(clip, 1)
            prevClip = clip
        clips.append(clip)
        duration += currStart - currEnd

    path = self.dirName + "\\Singel-BBrief" + "/BBrief-" + self.mediaFileName
    CompositeVideoClip(clips).write_videofile(path, codec='libx264')
    T.sleep(1)
    self.counter += 1
    for clip in clips:
        clip.close()

A: I managed to solve this solution by changing the output file to be MOV.
path = self.dirName + "mediaFileName"[:-4]+".MOV"
    CompositeVideoClip(clips).write_videofile(path, codec='libx264')


text:
Q: Mi modulo de busqueda no trae datos Hola es mi primera pregunta en este foro voy a intentar ser breve.
Hice un formulario de busqueda para un sistema escolar en el que estoy trabajando, cree el form, y el codigo en php, pero cuando intento traer los datos no me regresa nada, revise la query y funciona.

            <input type="button" onclick="history.back()" value="Volver" class="button">

Buscar personas en el sistema

            <form action=""  method="POST" class="panel" class="form_search">

                <input type="text" size="40" name="busqueda" id="busqueda" placeholder="Ingresar Documento, Nombre o Apellido">
                <input type="submit" name="enviar" value="Buscar" class="button" style="padding: 10px 10px;">

            </form>

            <?php
            require_once('config.php');
            if(isset($_POST['enviar'])) {
                $busqueda = strtoupper($_POST['busqueda']);
                $registros = $mysql->query("SELECT * FROM persona WHERE persona_AyN LIKE '%busqueda%' OR persona_doc LIKE '%busqueda%'");
                echo '
';
                echo '
Nombre y Apellido	 Documento
';
                while ($reg = $registros->fetch_array()) {
                    echo '
';
                    echo '';
                    echo $reg['persona_doc'];
                    echo '	';
                    echo '';
                    echo $reg['persona_AyN'];
                    echo '	';
                    echo '';
                    echo 'Registrar Alta';
                    echo '	';
                    echo '
';
                }
                echo '
';
            }
            ?>

La base de datos es una base sencilla de prueba con la tabla personas, id,nya,doc y fechanac
Si me pueden ayudar seria genial.

A: El problema es que le estás mandando un string a la consulta SQL y no la variable capturada del POST:
... persona_AyN LIKE '%busqueda%' OR persona_doc LIKE '%busqueda%' ...

Debe ser:
... persona_AyN LIKE '%$busqueda%' OR persona_doc LIKE '%$busqueda%' ...


text:
Q: Importing Multivariate Columns from CSV file to SQL I am trying to import a csv data sheet into Oracle SQL Developer. One of the columns has numerous values, as my database is an organization with many members.
How do I declare a multivariate column in Oracle SQL?
And how do I insert numerous values into a column with the data source coming from Excel? (I know how to import data from Excel, but just not sure how to insert numerous values separated by commas into SQL Developer)
Example: I want a memberID column with numerous values.
     For ID 5, Member ID (column): "123, 442, 245, 847":
ID | memberID
---|---------
5  | 123, 442, 245, 847

Please and thank you!


text:
Q: Expression type '' is ambiguous without more context Here's my test script snippet. I'm getting a compile error on the line where trying to assign a tuple to a constant.
class Test: UIView {
    struct Properties {
        var properties:  (coordinatesXY: CGPoint, radius: CGFloat, group: String, fillingColor: UIColor)

    }

    var circleCollection: [Properties] = []

    private func getProperties() -> [Properties] {
        return circleCollection

    }

    private func getShape(circleProperties properties: Properties) {
        let (coordinatesXY, radius, group, fillingColor) = properties
        //Error: Expression type 'Test.Properties' is ambiguous without more context
    }

    private func drawTheme(circleProperties properties: Properties) {
        getShape(circleProperties: properties)

    }

    private func drawMainTheme () {
        let properties = getProperties()

        for record in 0...properties.count {

            drawTheme(circleProperties: properties[record])

        }
    }

}

Would appreciate any help here, many thanks in advance!


text:
Q: Yii2 change active database based on controller I need to change yii2 active database in controller.
What I have so far:
        Yii::$app->db = new yii\db\Connection([
            'dsn' => 'dblib:host='.$company->host.';port=1433;dbname=Interface',
            'username' => $company->db_user,
            'password' => $company->db_password,
        ]);
        Yii::$app->db->open();
        $users = User::find()->all();

Can I change active database like that and then start using models in new database and how?

A: You can define multiple databases in the config file with both databases referring to different objects. Use the object with the respective database you want to use.
For example:
If you have two databases defined in the config file db and db1.
Then you can just use db1 instead of db wherever you need.


text:
Q: Array Index out of bound in jsp file js file:

why does the size of dropdown1 is coming as 1?

function savethechanges(){
for(var i=0;i<count;i++)
{
    dropdown1[i]=document.getElementById("sel"+i).value;
    kot[i]=document.getElementById("kot"+i).value;
    item[i]=document.getElementById("itemcode"+i).value;
    if(dropdown1[i] == 0){
        document.detailsview.action="BillCB.jsp?method=" + "11" + "&itemcode=" +item[i]+ "&kot=" +kot[i]+ "&itemStatus1=" +dropdown1[i]+ "&billno=" +billno;
    }
    else if(dropdown1[i] == 1){
        document.detailsview.action="BillCB.jsp?method="+"9"+"&itemcode="+item[i]+"&kot="+kot[i]+"&itemStatus1="+dropdown1[i]+ "&billno="+billno;
    }
    else{
        document.detailsview.action= "BillCB.jsp?method="+"10"+"&itemcode="+item[i]+"&kot="+kot[i]+"&itemStatus1="+dropdown1[i]+ "&billno="+billno;
    }
}
}

JSP file:

while retrieving here the dropdown1 length is 1.but for kot and item length is 18
  please provide your solution!

 case 11:
 gotMethod = true;
 billdetails_be.billno = Integer.valueOf(request.getParameter("billno"));
 String[] kotCB2=request.getParameterValues("kot");
 String[] itemCB2=request.getParameterValues("itemcode");
 String[] statCB2=request.getParameterValues("itemStatus1");
 int[] kotarr2=new int[kotCB2.length];
 int[] itemarr2=new int[itemCB2.length];
 int[] statarr2=new int[statCB2.length];
 System.out.println("IN AVAILABLE:length of array is:"+statCB2.length);
 System.out.println("IN AVAILABLE:length of array is:"+kotCB2.length);
 for(int i=1;i<itemarr2.length;i++)
 {
     kotarr2[i]=Integer.parseInt(kotCB2[i]);
 }
 for(int i=1;i<itemarr2.length;i++)
 {
     itemarr2[i]=Integer.parseInt(itemCB2[i]);
 }
 for(int i=1;i<itemarr2.length;i++)
 {
     statarr2[i]=Integer.parseInt(statCB2[i]);
 }
 for(int i=1;i<itemarr2.length;i++)
 {
     int kotint2=kotarr2[i];
     int itemint2=itemarr2[i];
     int statint2=statarr2[i];
     System.out.println( i+"the value of kot in available"+ kotint2);
     int availablebill = websrv.availablebill(billdetails_be.billno, kotint2,   itemint2,statint2);
  }

design page(jsp)
<%
for(int i=0;i<count;i++){
%>

  <input id="itemcode<%=i%>" type="hidden" name="itemcode" value=" <%=billdetails_be.get(i).itemcode%>">
<%=billdetails_be.get(i).itemdescription%>
  <input id="quantity<%=i%>" type="text" name="quantity"  style="width:  30px;" readOnly="readonly" value="<%=billdetails_be.get(i).quantity%>" >
<input type="submit"  id="inc<%=i%>" onclick= "doIt1(1,<%=i%>);"  value="+" style="width:20px; height:20px; border-radius:10px; padding:0 0; " />
<input type="submit"  id="dec<%=i%>" onclick="doIt1(-1,<%=i%>);"   value="-" style="width:20px; height:20px; border-radius:10px; padding:0 0; "/>

  <%=billdetails_be.get(i).price%>
  <%=billdetails_be.get(i).itemstatusdescription%>

<select name="statusi" id="sel<%=i%>">
<option value="0">Available</option>
<option value="1">Unavailable</option>
<option value="2">Delete</option>
</select>

 <input id ="kot<%=i%>" type="text" style="border: 0px solid #000000;" name="kot"   style="cursor: text" readonly="readonly" value="<%=billdetails_be.get(i).kotno%>">
 <input id="myquantity<%=i%>" type="hidden" name="quantity1" value="     <%=billdetails_be.get(i).quantity%>">

<%
}
%>
<input style="width: 150px; " class="btn btn-green btn-large" type="submit" name="save" id="save" value="save"  class="button" onclick="savetheChanges(<%=count%>);">

New changes

1.this is in js file ,from which i am passing the value to BillCB.jsp

 document.detailsview.action="BillCB.jsp?method=" + "11" + "&itemcode=" +itemcode1[i]+ "&kot=" +kot1[i]+ "&itemStatus1=" +selection[i]+ "&billno=" +billno;

2.this is in BillCB.jsp file (method :11)

 String[] statCB2=request.getParameterValues("itemStatus1");
 int[] statarr2=new int[statCB2.length];
 System.out.println("IN AVAILABLE:length of STATUS array is:"+statCB2.length);

In AVAILABLE:length of STATUS array is:1-this is the problem.

A: *

*First, it is a little bit strange that in all your loops you are looping through itemarr2, so i do not understand why don't you have only one loop with all the logic inside.

*Secondly you are looping through itemarr2 and then using the current index of itemarr2 to access and assign values in other arrays. If  any of this arrays has a smaller size than itemarr2 you will get an array indexOutofbound exception.
for(int i=1;i<itemarr2.length;i++)
{
   kotarr2[i]=Integer.parseInt(kotCB2[i]); //If size of itemarr2 is bigger than kotarr2 or is bigger than kotCB2. You will get an array indexOutofbound exception.
}
for(int i=1;i<itemarr2.length;i++)
{
   itemarr2[i]=Integer.parseInt(itemCB2[i]); //If size of itemarr2 is bigger than itemCB2. You will get an array indexOutofbound exception.
}
for(int i=1;i<itemarr2.length;i++)
{
   statarr2[i]=Integer.parseInt(statCB2[i]);  //If size of itemarr2 is bigger than statarr2 or is bigger than statCB2. You will get an array indexOutofbound exception.
}
for(int i=1;i<itemarr2.length;i++)
{
  int kotint2=kotarr2[i];  //If size of itemarr2 is bigger than kotarr2. You will get an array indexOutofbound exception.
  int itemint2=itemarr2[i]; //If size of itemarr2 is bigger than itemarr2. You will get an array indexOutofbound exception.
  int statint2=statarr2[i]; //If size of itemarr2 is bigger than statarr2. You will get an array indexOutofbound exception.
  System.out.println( i+"the value of kot in available"+ kotint2);
  int availablebill = websrv.availablebill(billdetails_be.billno, kotint2, itemint2,statint2);
}

So you must ensure that the size of kotarr2, kotCB2, itemCB2, statarr2, statCB2 is always bigger or equal to the size of itemarr2, and as i said you can pul all that logic insdide of a single loop.
Regarding your Js file we need to see how you set your count, but if the value of your count is bigger than the size of your dropdown1 then You will get an array indexOutofbound exception.
UPDATE:
You said that count = 18, but you do not initialize statarr2 using count. You initialize it using statCB2.length.
     int[] statarr2=new int[statCB2.length];

In turn statCB2.length is also not initialized using count it is initialized using request.getParameterValues("itemStatus1");
      String[] statCB2=request.getParameterValues("itemStatus1");

So i do believe your item status is equal to 1. Especially because on your Js you have the following code.
   ... "&itemStatus1=" +dropdown1[i]+ ...

So itemStatus1 will be equal to the item on dropdown1[i]. Therefore itemStatus1 is not equal to count or to the size of dropdown1. It is only equal to the number of items in dropdown1 at index (i) which i believe is 1; and you can always use alert() or console.log() to test that.
UPDATE:
You said that count = 18, but you do not initialize statarr2 using count. You initialize it using statCB2.length.
     int[] statarr2=new int[statCB2.length];

In turn statCB2.length is also not initialized using count it is initialized using request.getParameterValues("itemStatus1");
      String[] statCB2=request.getParameterValues("itemStatus1");

So i do believe your item status is equal to 1. Especially because on your Js you have the following code.
   ... "&itemStatus1=" +dropdown1[i]+ ...

So itemStatus1 will be equal to the item on dropdown1[i]. Therefore itemStatus1 is not equal to count or to the size of dropdown1. It is only equal to the number of items in dropdown1 at index (i) which i believe is 1; and you can always use alert() or console.log() to test that.

If you want itemStatus1 to be = to the size of the dropdown1 then insted of
     ... "&itemStatus1=" +dropdown1[1]+ ...

you should use
     ... "&itemStatus1=" +dropdown1.length+ ...  or

     ... "&itemStatus1=" +dropdown1.size+ ...   (whichever is correct).

Also the other alternative is not play around with itemStatus1 and instead initialize your statCB2 array using count or dropdown1.length
String[] statCB2= new String[count] or  String[] statCB2= new String[dropdown1.length]

That should do the trick


text:
Q: Requesting font awesome file from nodeJs is sending back wrong data/file my application: When you send a request from a browser to my node server, my node server will request an origin website, download all of its static files (including code) and server them back to the user. Next time you visit my node server it will server all the content back from node instead of requesting the origin.
When i make a request for a font awesome file from node
http://example.com/modules/megamenu/fonts/fontawesome-webfont.woff?v=4.2.0

The file's content is different from when i request the same url with cUrl.
This is causing this error in the browser when i return the file from node back to the browser:
Failed to decode downloaded font: http://nodeDomain.test/modules/megamenu/fonts/fontawesome-webfont.woff?v=4.2.0

If i copy and paste the content from the file i requested via curl into the file stored on my node server, the error disappears and all the font awesome stuff works.
Here are the headers I am sending with the request to the origin server from node.
{
connection: 'keep-alive',
pragma: 'no-cache',
'cache-control': 'no-cache',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
accept: '*/*',
referer: 'http://example.com/modules/megamenu/css/font-awesome.min.css',
'accept-language': 'en-US,en;q=0.8',
cookie: 'PrestaShop-a30a9934ef476d11b.....'

}

I tried to see what headers where being sent when doing the curl request from command line but i cannot figure out how to do it.
______Node code used to fetch file_______
Url: in options is the one stated above
headers: are the browsers request headers

var options = {
url: originRequestPath,
headers: requestHeaders
}

var originPage = rquest(options);
var responseBody = '';
var resHeads = '';

originPage.on('response', function(res)
{
   //store response headers locally
}

originPage.on('data', function(chunk)
{
    responseBody += chunk;
});

originPage.on('end', function()
{
    storeData.storePageData(storeFilePath, responseBody);
});

__________Store Function below________________

exp.storePageData = function(storePath, pageContent)
{
  fs.outputFile(storePath, pageContent, function(err) {
        if(err){ console.log(err)}
  });

}

A: I believe the problem with your code is you are converting your buffer output to utf8 string. since you are adding buffer with empty string responseBody += chunk; that buffer is converted to utf-8 string. Thus you are losing some data for binary files. Try this way:
var originPage = rquest(options);
var chunks = []

originPage.on('response', function(res)
{
   //store response headers locally
}

originPage.on('data', function(chunk)
{
    chunks.push(chunk)
});

originPage.on('end', function()
{
     var data = Buffer.concat(chunks)
    //send data to browser and store content locally
});


text:
Q: Swimming pool filtering problem: Concentration as a function of time I thought of this problem while i was helping clean up a swimming pool from algae:
Let's say we have a swimming pool with capacity $C$ $[\ell]$ and an initial algae concentration of $A_0$ $[Kg/\ell]$.
We also introduce a filter that takes water from the pool and reintroduces it back in after having filtered it, we therefore define an a-dimensional filtering coefficient $k$ (e.g. if $k = 0.8$, $80\%$ of the algae gets removed in the filter) and a pump flow rate $p$ $[\ell/s]$
We want to find the function $A(t)$ ,which defines the concentration of algae in the pool at time $t$, with $A(0) = A_0$
I know a differential equation needs to be solved in order to find $A(t)$, but admittedly i'm rusty on the subject and i don't really know how to set up the differential equation.

A: For the total amount of algae $T(t)$ in grams and a small time interval $\Delta t$, we have
\begin{align}
T(t_0 + \Delta t) - T(t_0) &\approx -(\text{Amount of algae removed per sec}) \cdot \Delta t \\ &= -(\text{Liters filtered per sec}) \cdot (\text{Algae per liter}) \cdot (\text{filter effectiveness}) \cdot  \Delta t \\
&= -p \cdot \frac{T(t_0)}{C} \cdot k \cdot \Delta t.
\end{align}
Dividing by $\Delta t$ we see that we can model the situation with the ODE
$$
T'(t) = -\frac{p\cdot k}{C} T(t),
$$
to which you probably know the solution. (Then dividing the solution by $C$ gives the solution in terms of the algae concentration.)


text:
Q: angular2 - create a new nested object in form I get the following error when rendering a form in my Angular2 web. This component is used to create a new nested object, therefore is an empty form.
The issue occurs in the nested parameters of the object. The departureDate falls right under trip (trip.departureDate), therefore it works in the browser. Because "city" is nested inside "from" (newTrip.from.city) I get the error:

ERROR TypeError: Cannot read property 'city' of undefined
      at Object.eval [as updateDirectives]

html:

NEW TRIP

Departure:

      <input ngui-datetime-picker name="departureDateTime" [(ngModel)]="newTrip.departureDateTime" required>

From:

      City:
      <input type="text"  name="fromcity" [(ngModel)]="newTrip[from].city" required>
      Country:
      <input type="text" name="fromCountry" [(ngModel)]="newTrip[from].country" required>

Arrival:

      <input ngui-datetime-picker name="arrivalDateTime" [(ngModel)]="newTrip.arrivalDateTime" required>

component.ts (I initialize the var "newTrip" with the "Trip" model):
export class NewTripComponent implements OnInit {
   newTrip: Trip = new Trip();
   error: string;

trip model:
    export class Trip {
    _id: string;
    owner: string;
    from: {
        city: string;
        country: string;
        lat: number;
        lng: number;
    };
    to: {
        city: string;
        country: string;
        lat: number;
        lng: number;
    };
    departureDateTime: Date;
    arrivalDateTime: Date;
    bag: {
        restrictions: Array<string>;
        weight: number;
        dimensions: {
            high: number;
            width: number;
        }
    }
  }

A: you have to know that : newTrip[from] is undefined , that's why you can not get the city from it.
as solution you can create a class called Place that contains :
class Place{
    city: string;
    country: string;
    lat: number;
    lng: number;
}

and in your class Trip :
from: Place = new Place();
to : Place = new Place();

Hope it helps you


text:
Q: background image help, JPanel, JFrame, anything? I want to make a background image for a game I'm designing but I cant figure out the right way to get the effect I want, I want a background that can be seen behind text etc. basically having the background cover the whole JFrame / JPanel not just one section of the layout (e.g. BorderLayout.Center) I think it does this anyway but if it does do that how do I make the background for those transparent to see the background which is behind...
Confusing i know but I hope someone here understands what I am trying to do and can help... this is my current code. I have been playing around with the background so dont read to much in how i have written it.
import javax.swing.*;
import javax.swing.border.*;

import java.awt.*;

public class GamePanel extends JPanel {

private JTextPane playertext;
private JTextField wealthstring, currentwealth;

public GamePanel() {

    super();
    setLayout(new BorderLayout());
    setBackground(Game.getBackgroundColor());
    Border raised = BorderFactory.createRaisedBevelBorder();
    Border lowered = BorderFactory.createLoweredBevelBorder();
    setBorder(BorderFactory.createCompoundBorder(new EmptyBorder(4, 4, 4, 4), (BorderFactory.createCompoundBorder(raised, lowered))));
    add(northpanel(), BorderLayout.NORTH);
    add(eastpanel(), BorderLayout.EAST);

}

private JLabel northpanel() {

    Font northfont = new Font("Engravers MT", Font.BOLD, 12);
    ImageIcon banner = new ImageIcon("images/banner.png", "North Background");

    playertext = new JTextPane();
    playertext.setFont(northfont);
    playertext.setEditable(false);
    playertext.setText("Player: \n" + Game.getName());
    playertext.setBackground(Game.getBackgroundColor());
    playertext.setBorder(new EmptyBorder(10,10,10,10));

    wealthstring = new JTextField("Money: ");
    wealthstring.setFont(northfont);
    wealthstring.setEditable(false);
    wealthstring.setHorizontalAlignment(wealthstring.RIGHT);
    wealthstring.setBorder(null);
    wealthstring.setBackground(Game.getBackgroundColor());

    currentwealth = new JTextField();
    currentwealth.setFont(northfont);
    currentwealth.setEditable(false);
    currentwealth.setHorizontalAlignment(wealthstring.RIGHT);
    currentwealth.setBackground(Game.getBackgroundColor());
    currentwealth.setBorder(null);
    String wealthrounded = String.format("%.2f", Game.getMoney());
    currentwealth.setText(wealthrounded);

    JPanel wealthtext = new JPanel();
    wealthtext.setLayout(new GridLayout(2, 1));
    wealthtext.setBackground(Game.getBackgroundColor());
    wealthtext.setBorder(new EmptyBorder(10,10,10,10));
    wealthtext.add(wealthstring);
    wealthtext.add(currentwealth);

    JLabel northpanel = new JLabel();
    northpanel.setLayout(new BorderLayout());
    northpanel.setIcon(banner);
    northpanel.add(new JSeparator(), BorderLayout.PAGE_END);
    northpanel.add(playertext, BorderLayout.WEST);
    northpanel.add(wealthtext, BorderLayout.EAST);
    return northpanel;
}

private JPanel eastpanel() {

    JButton tab1 = new JButton("Tab 1");
    JButton tab2 = new JButton("Tab 2");
    JButton tab3 = new JButton("Tab 3");

    JPanel easttabs = new JPanel();
    easttabs.setLayout(new GridLayout(1, 3));
    easttabs.add(tab1);
    easttabs.add(tab2);
    easttabs.add(tab3);

    JPanel eastpanels = new JPanel();
    eastpanels.setLayout(new BorderLayout());
    eastpanels.setBackground(Game.getBackgroundColor());
    eastpanels.add(easttabs, BorderLayout.NORTH);

    return eastpanels;
}

}

A: Create a class that extends from JPanel and in its paint method draw an image over it.
Now create a class the extends from JFrame and in its constructor set its contentpane to the object of that JPanel class like below. Now you can add components to jframe.
class SimpleTest extends JFrame {

    JButton btn = new JButton("A Game");

    public SimpleTest() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setContentPane(new CPane());
        getContentPane().setBackground(Color.red);
        getContentPane().add(btn, BorderLayout.NORTH);
        setSize(new Dimension(300, 300));
        setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new SimpleTest();
            }
        });
    }
}

class CPane extends JPanel {

    Image back;

    public void paintComponent(Graphics g) {
        super.paintComponent(g);

        try {
            back = ImageIO.read(getClass().getResource("back.jpg"));
        } catch (Exception ex) {
        }
        g.drawImage(back, 0, 0, this);
    }
}

If you want to make a jpanel transparent then do
panel.setOpaque(false);

A: So if you already have a JPanel that has your image as Background and you want to add another panel over it with your components you can use Opacity to achieve this. Only the components added to this panel will be visible. Here's the code :
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;

public class TransparentPane extends JPanel {

    public TransparentPane() {

        setOpaque(false);

    }

    @Override
    protected void paintComponent(Graphics g) {

        super.paintComponent(g);

        Graphics2D g2d = (Graphics2D) g.create();

        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0f));

        g2d.setColor(getBackground());
        g2d.fill(getBounds());

        g2d.dispose();

    }

}


text:
Q: Search all untranslated text strings in PHP and HTML files I have this upcomming task of translating an entire website. The website is partially translated, meaning it utilizes the translation features of ZendFramework (v1).
Translations are stored in array based language files like this: [en.php]
<?php
return array(

// Language Config
'config_LanguageDirection' => 'ltr',

// Site wide translations
'site_name' => 'My site',
'site_slogan' => 'Le slogan',

'site_keywords' => 'key is the words',
'site_description' => 'Yada yada yada',

'header_logo_img_alt' => 'My site',
'fat_footer_company_details' => 'Trivial copyright information',

'company_name' => 'UnoBambino',
);

Is there a script in PHP or Bash/Shell, that can search all directories and find untranslated strings?
I'm thinking

*

*text in html attributes like 'alt' and 'title'

*text between html tags

*text in PHP code, which would usually be between single and double quotes.

*not text that are used in a function _('like this') or _("like this") - which are considered already translated.

*other types that i haven't thought upon

3rd party software would also be of interest, if it gets the job done.


text:
Q: Can't get 3 plots in one picture I'd like to plot 3 function in one picture,but the third can't get,Is there anything with my code?
x = np.arange(-10., 10., 0.2)
simod1=sigmoid(x)
tanh1=tanh1(x)
relu1=relu(x)
pl.figure(num=1, figsize=(8, 6))
pl.title('Plot 1', size=14)
pl.xlabel('x-axis', size=14)
pl.ylabel('y-axis', size=14)

pl.plot(x, simod1, color='b', linestyle='--', marker='o', label='sigmoid')
pl.plot(x, tanh1, color='r', linestyle='-', label='tanh')
pl.plot(x, relu1, color='y', linestyle='*', label='relu')
pl.legend(loc='upper left')
pl.savefig('temp.png', format='png')

A: '*' is not a valid linestyle see the documentation http://matplotlib.org/api/lines_api.html#matplotlib.lines.Line2D.set_linestyle
I think you want to do this instead:
plt.plot(x, simod1, 'o--', color='b', label='sigmoid')
plt.plot(x, tanh1, '-', color='r', label='tanh')
plt.plot(x, relu1, '*', color='y', label='relu')


text:
Q: Azure Stream Analytics timestamp for window end I am running some test jobs on Azure Stream Analytics running this query:
SELECT System.Timestamp AS ts, Collect()
INTO output−queue
FROM input-hub TIMESTAMP BY tapp
GROUP BY HoppingWindow(second , 4 , 2)

and it turns out that, in some cases, the timestamp for the window end is a multiple of the window slide parameter, but sometimes not.
For example, with slide = 2 you get this window closing timestamps:
2016-08-04T10:36:40.0000000Z
2016-08-04T10:36:42.0000000Z
2016-08-04T10:36:44.0000000Z
2016-08-04T10:36:46.0000000Z
2016-08-04T10:36:48.0000000Z

Or, in the case slide = 5:
2016-08-04T14:55:15.0000000Z
2016-08-04T14:55:20.0000000Z
2016-08-04T14:55:25.0000000Z
2016-08-04T14:55:30.0000000Z

This is true even for different slide values (e.g. 2, 3, 4, 6, ...). Moreover, it is always true! No matter when the job has been started.
There are values instead (such as 7, 11) that does not follow this rule.
Can somebody answer why does this happen?
I am wondering how does Azure SA decides when to open the first window.
Thank you so much!

A: There are different kinds of windows (see here for more details).
First, window starts/ends do not depend on the job start time.
Tumbling and Hopping windows are best to think of, logically, as partitioning the timeline itself. For example applying Tumbling window of 1 minute will make results to appear only at time values which are mod of 1 min, i.e. 2:00pm, 2:01pm, etc.
Note that not every 1 minute boundary must have window result, it rather depends on the computation.
Sliding window can produce output at any point on the timeline, and unlike tumbling and hopping windows, does depend on the timestamps of the input events. Best way to think of sliding windows is that window may end at any input event and starts slide amount of time before that event. In other words for each event window will include all events occurred at or up to slide time before it.
Hope this helps.


text:
Q: What is the meaning of minimal, netinstall and bin iso What is the difference between minimal, netinstall and bin iso?
I am confused which ISO image to download.

A: Minimal
The Minimal CD will download packages from online archives at installation time instead of providing them on the install CD itself. Downloading packages at install time reduces the size of the install CD to approximately 5 to 30MB depending on architecture (see below), as well as providing only the packages needed for installation. The download time savings achieved by using a Minimal CD can be significant, as only current packages are downloaded, so there is no need to upgrade packages immediately after installation. The Minimal CD uses a text-based installer like the Alternate CD, making the CD image as compact as possible.
https://help.ubuntu.com/community/Installation/MinimalCD
Netinstall
The network installer lets you install Ubuntu over the network. This is useful, for example, if you have an old machine with a non-bootable CD-ROM or a computer that can't run the graphical interface-based installer, either because they don't meet the minimum requirements for the live CD/DVD or because they require extra configuration before the graphical desktop can be used, or if you want to install Ubuntu on a large number of computers at once.
http://www.ubuntu.com/download/alternative-downloads
Bin ISO
That would then just be the normal one (as far as I understood it)
I'd just go with the normal iso (:


text:
Q: How to apply gradient on whole page in html I'm trying to apply gradient on whole HTML page using the following CSS class that I defined in the "body" tag:
.gradient{
    font-family: Roboto Black;
    background-repeat: no-repeat;
    background-attachment: fixed;
    height: 100%;
    background: #234199;
    background: -webkit-linear-gradient(#234199 0%, #7db9e8 100%);
    background: -o-linear-gradient(#234199 0%, #7db9e8 100%);
    background: linear-gradient(#234199 0%, #7db9e8 100%);
    filter: progid:DXImageTransform.Microsoft.gradient(
    startColorstr='#234199', endColorstr='#7db9e8', GradientType=0 );
}

But there comes a sharp edge where the sidebar exceeds the viewport area, seems like gradient starts repeat itself (as shown in the image).
Can anybody fix the issue?

A: maybe try putting the height to auto instead of 100%?

A: Set height: 100% on the <html> element and it should fill the viewport.
Here's an example: https://codepen.io/anon/pen/JMjYrq

A: You may try using a pseudo element that you stretch to the whole page with fixed position :

.gradient {
  font-family: Roboto Black;
  position: relative;
}
.gradient:before {
  content: "";
  position: fixed;
  z-index:-2;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  background-repeat: no-repeat;
  background: #234199;
  background: -webkit-linear-gradient(#234199 0%, #7db9e8 100%);
  background: -o-linear-gradient(#234199 0%, #7db9e8 100%);
  background: linear-gradient(#234199 0%, #7db9e8 100%);
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#234199', endColorstr='#7db9e8', GradientType=0);
}
<body class="gradient">

</body>


text:
Q: if I type on my input it shows the prev value + my value so he adds two letters not one why my input shows double letters from the prev if I type anything ?
  const [coupon, setCoupon] = useState<ICoupon>({
    name: '',
    percent: '',
    date: {
      from: {
        date: null,
        time: ''
      },
      until: {
        date: null,
        time: ''
      }
    }
  });

  const handleChangeName = (e: string) => setCoupon(prev => ({
    ...prev,
    name: e
  }));

                    <Input
                      placeholder='Name'
                      value={coupon.name}
                      onChangeText={handleChangeName}
                      style={[InputStyles.full_icon]}
                      icon={<Ionicons name="md-newspaper-outline" size={24} style={s.icon} color="#333" />}
                    />

I am very thankful for your help. idk what I am doing wrong


text:
Q: How to deal with long asynchronous stored procedure called from spring server? I use spring-boot, mybatis and I execute an asynchronous stored procedure. It is asynchronous because it is a procedure from SSIS package (catalog schema) - these procedures are asynchronous by default.
The problem is that before executing the stored procedure, I modify some value in the database. Due to the fact that it is asynchronous, annotation @Transactional doesn't help me.
The thing that I am worried about is failure of executing this package (SSIS catalog - start_execution). It this case I should revert the previous value in database (one value, but it doesnt matter here).
However, @Transactional can't help me because as you know spring think that the procedure finished successfully and it accepts the transaction.
How to deal with this problem - I mean rollback in case of failure of execution of a ssis package ?

A: According to this post, you can run a SSIS prodecure synchronously using the right parameter:
[...]
You have to be sure that you add the "SYNCHRONIZED" parameter to the package execution. Before the start_execution procedure:
exec [SSISDB].[catalog].[set_execution_parameter_value] @execution_id,  @object_type=50, @parameter_name=N'SYNCHRONIZED', @parameter_value=1
At this point, you should be able to wait for the completion of the procedure as usual and handle rollback normally.


text:
Q: jackrabbit oak repository integration with spring framework I have a web application running on tomcat and using spring framework. I also have jackrabbit oak libraries embedded in project.
I can get jackrabbit repository with java code like this:
new Jcr(new Oak(ns)).createRepository();

but I want to define my repository in a repository.xml file and then  put it somewhere and instantiate it with spring xml files, so I can customize various things like ExternalIdentityProvider in my repository.
Something like this I think:
<bean id="repository" class="org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl"
references="repository.xml"/>

but I don't know how I should define this repository in spring. any suggestion?

A: just use it like any other library:

*

*put some variables in your application.properties

*use Java config (XML config is not the most robust one)

*access those variables using your favourite way

*build your ns object using those variables

*register the outcome of new Jcr(new Oak(ns)).createRepository() as a Bean that uses the newly created ns object - this should help you

and that should do the trick :)


text:
Q: Why don't I have to use anonymous class' overrode method, but instead just use it's object to reach the overrode method? I am new to Java and want to ask this question: Why don't I have to use anonymous class' overrode method, but instead just use it's object to reach the overrode method?
I hope I made myself clear, but if not, I'd like to refer to the image below:

This is my anonymous class, it's inside a method called instanceMethod();
Here, I test this with my ClassTester.java class

My question is that even though I use System.out.println(demo);, I still get the same result, i.e.,

So this means that I don't need to use System.out.println(demo.toString());
Do you know the reasoning behind this? Does it work like a constructor?
Any help is appreciated.
Best.


text:
Q: Two defnitions of a tensor There are two approaches to define a tensor:  1) As an element of tensor-product space
2) As a multilinear map
So basically there is some correspondence between those definitions.
However, I can't see how it can be done in a proper way.
Question: For example , given multilinear map $T:V^*\times V^*\to \mathbb{R}$ , then how do we construct correspondent $t\in V\otimes V$?
And other way around: given element $t'\in V\otimes V$, how do we construct correspondent $T':V^*\times V^*\to \mathbb{R}$?
My attempt: Let $T:V^*\times V^*\to \mathbb{R}$ be a given map $(dimV<\infty)$.
Using this map we can construct isomorphism $\phi_T:V^*\to V$ as: $$(\omega)\mapsto\phi_T(\omega):=T(\omega,\cdot)$$
Then we can construct isomorphism: $\Phi_T:V^*\times V^*\to V\times V$ as:
$$(\omega,\sigma)\mapsto \Phi_T(\omega,\sigma):=(\phi_T(\omega),\phi_T(\sigma))$$
Thus we have a map: $f:V\times V\to\mathbb{R}$ such that $T=f\circ\Phi_T$, or other way $f=T\circ\Phi^{-1}_T$.
Finally that we have $V\times V$ and map $f$ we can use universal property and construct tensor space $V\otimes V$ with two maps: quotient map $g:V\times V\to V\otimes V$, and map $h:V\otimes V\to \mathbb{R}$, such that $f=h\circ g$ holds.
Given all of this one can see that: $T=h\circ g\circ \Phi_T$.
So for any $\omega,\sigma \in V^*$:
$$T(\omega,\sigma)=(h\circ g)(\phi_T(\omega),\phi_T(\sigma))=h(g(\phi_T(\omega),\phi_T(\sigma)))=h(g(T(\omega,\cdot),T(\sigma,\cdot)))$$
Then we can denote $g(T(\omega,\cdot),T(\sigma,\cdot))\equiv T(\omega,\cdot)\otimes T(\sigma,\cdot)$ and call it tensor generated by map $T$.
Is this construction viable? Also, I'm not really sure how to go other way around and construct bilinear map from the element of tensor product.

A: If $V_1, \ldots , V_k$ are finite dimensional vector spaces, then consider the function $$\phi : V_1^* \times \ldots \times V_k^* \rightarrow L(V_1, \ldots , V_k;\mathbb{R}),$$ $L(V_1, \ldots , V_k;\mathbb{R})$ the space of multilinear functions from $V_1 \times \ldots \times V_k$  to $\mathbb{R}$, such that $$(w_1,\ldots,w_k) \mapsto\phi(w_1,\ldots,w_k)$$ $$\phi(w_1,\ldots,w_k)(v_1,\ldots,v_k) = w_1(v_1)\ldots w_k(v_k)$$ Note that $\phi(w_1,\ldots,w_k) \in L(V_1, \ldots , V_k;\mathbb{R})$ and that $\phi$ is multilinear. Using the Universal Property for Tensor Product Spaces there exists a unique function $$\tilde{\phi}:V_1^* \otimes \ldots \otimes V_k^* \rightarrow L(V_1, \ldots , V_k;\mathbb{R})$$ such that $\tilde{\phi} \circ \pi = \phi$ with $\tilde{\phi}$ linear and $\pi: V_1^* \times \ldots \times V_k^* \rightarrow V_1^* \otimes \ldots \otimes V_k^*$ the projection taking each $(w_1,\ldots,w_k)$ to $w_1 \otimes \ldots \otimes w_k$. Note that $$\tilde{\phi}(w_1 \otimes \ldots \otimes w_k) = \tilde{\phi}(\pi (w_1, \ldots, w_k)) = \phi(w_1,\ldots,w_k) \in L(V_1, \ldots , V_k;\mathbb{R})$$ (notation $w_1 \otimes \ldots \otimes w_k := \phi(w_1,\ldots,w_k)$), thus $$\tilde{\phi}(w_1 \otimes \ldots \otimes w_k) = w_1 \otimes \ldots \otimes w_k.$$
Show that $\tilde{\phi}$ is bijective, thus an isomorphism (the canonical isomorphism between the two constructions).
This book might help you: John M. Lee. $\textit{Introduction to Smooth Manifolds}$. Springer Science & Business Media, 2nd edition, 2012, p.p. 171-179.


text:
Q: ArgumentError rails I have a module that returns an array:
module Module1
  class Class1

    def self.get

      num << 1

      return num

    end

  end
end

But when I call it from the controller like this:
  def index

    @trans = Module1::Class1.get()

    respond_to do |format|
      format.html # index.html.erb
      format.json { render @trans }
    end
  end

Show me the following error:
'1' is not an ActiveModel-compatible object that returns a valid partial path.

But if I do in json:
  def index

    respond_to do |format|
      format.html # index.html.erb
      format.json { render Module1::Class1.get() }
    end
  end

It returns the right result, what am I doing wrong in the first example?

A: Try this
format.json { render :json => @trans }


text:
Q: Use map on a reactjs component From this code, (that works). I use map to render the array named parts.
code in sandbox
import React from 'react'

const Header = (props) => {
  //console.log(props)
  //I pass the whole object (course) as props and use only name
  return (

    {
{props.course.name}
 }

  )
}

  const App = () => {

    const course = {
      id: 1,
      name: 'Half Stack application development',

      parts: [
        {
          name: 'Fundamentals of React',
          exercises: 10,
          id: 1
        },
        {
          name: 'Using props to pass data',
          exercises: 7,
          id: 2
        },
        {
          name: 'State of a component',
          exercises: 14,
          id: 3
        }
      ]

    }

  return (

      {course.parts.map(part =>

            {part.name} {part.exercises}

        )}

  )
}

export default App

I want to define a separate component responsible of rendering the contents of the array parts.
parts: [
        {
          name: 'Fundamentals of React',
          exercises: 10,
          id: 1
        },
        {
          name: 'Using props to pass data',
          exercises: 7,
          id: 2
        },
        {
          name: 'State of a component',
          exercises: 14,
          id: 3
        }

I tried this. I checked for the props with console.log, and they are there. But I get the error
ReferenceError
course is not defined.
There is something I am doing wrong, but I can't figure out what.
code sandbox
import React from 'react'

const Header = (props) => {
  //console.log(props)
  //I pass the whole object (course) as props and use only name
  return (

    {
{props.course.name}
 }

  )
}

const Courses = (props) => {
  console.log(props)
  //I pass the whole object (course) as props
  return (

      {course.parts.map(part =>

            {part.name} {part.exercises}

        )}

  )
}

  const App = () => {

    const course = {
      id: 1,
      name: 'Half Stack application development',

      parts: [
        {
          name: 'Fundamentals of React',
          exercises: 10,
          id: 1
        },
        {
          name: 'Using props to pass data',
          exercises: 7,
          id: 2
        },
        {
          name: 'State of a component',
          exercises: 14,
          id: 3
        }
      ]

    }

    //const Result = course.parts.map(parts =>
{parts.name}
)
    //console.log(Result)

  return (

      <Courses  course={course} />

  )
}

export default App

A: You forgot to include props before course keyword. Code should looks like this:
const Header = (props) => {
  //console.log(props)
  //I pass the whole object (course) as props and use only name
  return
{
{props.course.name}
}
;
};

const Courses = (props) => {
  console.log(props);
  //I pass the whole object (course) as props
  return (

        {props.course.parts.map((part) => (

            {part.name} {part.exercises}

        ))}

  );
};

const App = () => {
  const course = {
    id: 1,
    name: "Half Stack application development",

    parts: [
      {
        name: "Fundamentals of React",
        exercises: 10,
        id: 1
      },
      {
        name: "Using props to pass data",
        exercises: 7,
        id: 2
      },
      {
        name: "State of a component",
        exercises: 14,
        id: 3
      }
    ]
  };

  //const Result = course.parts.map(parts =>
{parts.name}
)
  //console.log(Result)

  return (

      <Courses course={course} />

  );
};

Note that you can use it the way you used it by destructuring the props:
const Courses = ({ course }) => {}
Then you would be able to use it as you did in your code without props keyword beforehand.

A: You didn't destructure your props properly in your Courses component. Check out the Mozilla docs for more information on ES6 destructuring. It will clean up your React code by a lot!
import React from "react";

const Header = ({ course }) => {
  const { name } = course;
  return (

{name}

  );
};

const Courses = ({ course }) => {
  const { parts } = course;
  return (

        {parts.map(({ id, name, exercises }) => (

            {name} {exercises}

        ))}

  );
};

const course = {
  …
};

const App = () => (

    <Courses course={course} />

);

export default App;

You can even destructure two levels deep and use the implicit arrow function return, depending on what you find most readeable.
const Header = ({ course: { name } }) => (

{name}

);

By the way, you don't need to wrap your data in a react component. It can live anywhere in your document, or ideally be imported from a separate json file.

A: Just you are missing the props, you try to call courses from Course component direct, so that when you add the props before, all is work fine..

      {props.course.parts.map(part =>

            {part.name} {part.exercises}

        )}

Full code:
import React from 'react'

const Header = (props) => {
  //console.log(props)
  //I pass the whole object (course) as props and use only name
  return (

    {
{props.course.name}
 }

  )
}

const Courses = (props) => {
  console.log(props)
  //I pass the whole object (course) as props
  return (

      {props.course.parts.map(part =>

            {part.name} {part.exercises}

        )}

  )
}

  const App = () => {

    const course = {
      id: 1,
      name: 'Half Stack application development',

      parts: [
        {
          name: 'Fundamentals of React',
          exercises: 10,
          id: 1
        },
        {
          name: 'Using props to pass data',
          exercises: 7,
          id: 2
        },
        {
          name: 'State of a component',
          exercises: 14,
          id: 3
        }
      ]

    }

    //const Result = course.parts.map(parts =>
{parts.name}
)
    //console.log(Result)

  return (

      <Courses  course={course} />

  )
}

export default App


text:
Q: RedCloth loaderror on ruby 2.0.0 [i386-mingw32] When I upgraded my rails 3.2.13 application (on Win XP) from ruby 1.9.3 to ruby 2.0.0, it crashed due to gem RedCloth (4.2.9 x86-mingw32).
Message: couldn't load 2.0/redcloth_scan (LoadError). In other words: /lib/2.0/redcloth_scan.so does not exist in the gem.
Is there any solution to this problem?
(Unfortunately, RedCloth is the only Ruby tool that handles Textile.)

A: You can try:

*

*Install RedCloth-4.2.9:
gem install RedCloth --platform==ruby -V

*Create this directory:
ruby\lib\ruby\gems\2.0.0\gems\RedCloth-4.2.9\ext\2.0

*Copy all files to that directory from:
ruby\lib\ruby\gems\2.0.0\gems\RedCloth-4.2.9\ext\redcloth_scan
Then you can use RedCloth in Ruby 2.0.  I tried with jekyll 1.12.1, and that works.

A: You might want to stay with 1.9.3 for now, if you must use RedCloth.
RedCloth doesn't seem to support 2.0.0 yet.


text:
Q: Figuring out problematic field name in a view I am selecting fields from a view
select
col1,
col2,
col3,
...
from dbo.vView

View is large, it has several million entries and many columns.
When I run above query it returns this error
Msg 8115, Level 16, State 8, Line 2
Arithmetic overflow error converting numeric to data type numeric.

I understand that there is a problem with a data type somewhere. But how to determine problematic field? Is there any simple way to do so?

A: *

*"Focus" on all the columns.

*Comment the first half of the "focused" columns. Does it produce the error again? If yes, focus now on the non-commented columns. If no, focus now on the commented columns.

*Repeat step 2 until you find the column responsible. It should take no more than log2(number of columns) steps.


text:
Q: How to find Excel column Index By its value using Apache poi Currently i am using apache poi to read the data from Excel file.
I have situvation to get the columnIndex by Value.
I mean , Excel file contains 10000 rows.
Second column contains list of emp names , i want to find the column index by
value.
Means:Emp name "Ra" in 10th Column , I should get column index when i pass value. I need solution without using foreach or iterator.

A: Try this:
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class Search {

    public static void main(String[] args) throws IOException {
        String path = "src/test.xlsx";
        String param = "Ra";
        try (FileInputStream in = new FileInputStream(path);
                XSSFWorkbook w = new XSSFWorkbook(in)) {

            List<Integer> lstStringIndex = new ArrayList<>();
            SharedStringsTable stringsTable = w.getSharedStringSource();
            for (int i = 0; i < stringsTable.getCount(); i++) {
                if (stringsTable.getEntryAt(i).getT().contains(param)) {
                    lstStringIndex.add(i);
                }
            }

            XSSFSheet s = w.getSheetAt(0);
            String xml = s.getCTWorksheet().xmlText();
            for (Integer i : lstStringIndex) {
                Pattern p = Pattern.compile("(?<=<main:c r=\")[A-Z0-9]+(?=\" t=\"s\"><main:v>" + i + "</main:v>)");
                Matcher m = p.matcher(xml);
                if(m.find()) {
                    System.out.println(m.group());
                }
            }
        }
    }
}

The above code will print out the adress of any cell that contain "Ra".
I'm using apache poi 3.14 btw.


text:
Q: allocating four object arrays with one 'new' I have a class with four dynamic arrays like this:
CObjA * objAArray;
CObjB * objBArray;
CObjC * objCArray;
CObjD * objDArray;

and I initialize those like this:
objAArray = new CObjA[numObj];
objBArray = new CObjB[numObj];
objCArray = new CObjC[numObj];
objDArray = new CObjD[numObj];

The problem is that those four memory allocations take a long time - performance is very bad if I have to create 40'000 objects like this.
my question is: is there a way to allocate all four arrays with one new operation?
If I create a new struct:
struct _arrays
{
 CObjA objA;
 CObjB objB;
 CObjC objC;
 CObjD objD;
};

and use one array of that struct instead, I only have to use one new:
_arrays * arr = new _arrays[numObj];

But then the objects are not laid out in memory correctly. They're then in memory as CObjA1-CObjB1-CObjC1-CObjD1-CObjA2-CObjB2.... instead of first all CObjA objects, then all CObjB objects, ...
Is there a way to use one new but still get the correct memory layout of the objects?

A: You can achieve what you need using a single allocation by malloc then use the "placement new" syntax to create objects at their required memory positions.

A: As @RSahu mentioned in his comment on your question, I would be surprised if it wasn't the construction of the object that was causing the performance bottleneck, and was the raw memory allocation itself. That said, one way to do what you want is to allocate one array with a char * type and then assign memory locations to your arrays afterwards, as below:
char* allocations = new char[numObj * (sizeof(CObjA) + sizeof(CObjB) +
                                       sizeof(CObjC) + sizeof(CObjD))];
CObjA * objAArray = reinterpret_cast<CObjA *>(allocations);
CObjB * objBArray = reinterpret_cast<CObjB *>(allocations + numObj * sizeof(CObjA));
CObjC * objCArray = reinterpret_cast<CObjC *>(allocations + numObj * (sizeof(CObjA)
                                                                    + sizeof(CObjB));
CObjD * objDArray = reinterpret_cast<CObjD *>(allocations + numObj * (sizeof(CObjA)
                                                                    + sizeof(CObjB)
                                                                    + sizeof(CObjC));
... //use arrays here
delete [] allocations; //deletes all allocations in one go


text:
Q: Do a loop instead of multiple $http chaining? sorry, i have checked answers, but still dont understand how to make it :
I've got an array :
 var surfaces   = [
     {min:0,max:499},
     {min:500,max:999},
     {min:1000,max:1499},
     {min:1500,max:1999},
     {min:2000,max:2399},
     {min:2400,max:2999},
     {min:3000,max:3999},
     {min:4000,max:5999},
     {min:6000,max:100000}
 ]

And I've got this looong $http chained calls with $q :
 $q.when()
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[0]).success(function(data){
                $scope.normes.push(data);
        })
    })
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[1]).success(function(data){
                $scope.normes.push(data);
        })
    })
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[2]).success(function(data){
                $scope.normes.push(data);
        })
    })
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[3]).success(function(data){
                $scope.normes.push(data);
        })
    })
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[4]).success(function(data){
                $scope.normes.push(data);
        })
    })
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[5]).success(function(data){
                $scope.normes.push(data);
        })
    })
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[6]).success(function(data){
                $scope.normes.push(data);
        })
    })
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[7]).success(function(data){
                $scope.normes.push(data);
        })
    })
    .then(function () {
        $http.post('backend/backend.php?action=get_normes',surfaces[8]).success(function(data){
                $scope.normes.push(data);
        })
    })

I'd rather do a loop, but have now idea on how to do this !!
EDIT : I've got way bigger problem : data is not in order in $scope.normes ! Its always different ! How could i do to always push in order ? How could the data could be in order ?
I got ng-repeats like this but the information is not well ordered because of $http synchornicity ;

                                 Désignation
                                 Total Magasins
                                 Moy Habitants Zone
                                 Ca Moyen
                                 EO Mini
                                 EO Maxi
                                 Coef Moyen
                                 Pourcent Côtier
                                 Pourcent Urbain
                                 Tx Habituels
                                 Tx fréquentation
                                 Tx fidélisation
                                 Zone Attraction
                                 Revenus Zone
                                 Nb Perso Foyer
                                 Age Moyen

                             Surface 0-499 m²
                             {{::norme.nb_magasins | number:0}}
                             {{::norme.moy_habitants_zone | number:0}}
                             {{::norme.ca_moyen | number:0}}
                             {{::norme.eomin | number:0}}
                             {{::norme.eomax | number:0}}
                             {{::norme.coef_moyen | number:2}}

                             {{::norme.tx_habituels | number:2}}
                             {{::norme.tx_frequentation | number:2}}
                             {{::norme.tx_fidelisation | number:2}}
                             {{::norme.attraction | number:0}}
                             {{::norme.revenus_zone | number:0}}
                             {{::norme.nb_pers_foyer | number:2}}
                             {{::norme.age_moyen | number:2}}

Each time i redo the $q, it comes with a different order ! How could i do ?
EDIT : So I'm now getting standards JSON objects from the Back End so it is simplier(Editied the html table on this post), but with the solutions you gently provided, it doesnt appear yet in the right order. The $http get started in the right order, but it seems that $scope.normes doesnt list as the $http have been started ! (Oh i think i maybe can order with the orderby in the front end... I forgot, but i thought it was possible to order the json objects as they get pushed into the array, but in the view it doesnt appear as when the $http have been called)

A: Try this::
$scope.onAllDone = function() {
    var promises = [];

    angular.forEach(surfaces , function(surface) {
        promises.push($http.post('backend/backend.php?action=get_normes',surface)).then(function(data) {
            $scope.normes.push(data);
            return data;
        });
    });

    return $q.all(promises);
}

USE::

$scope.onAllDone().then(fnSuccess, fnError);

A: Promises and $q.all (doc) are your friends.
In more detail, you will have to make a promise for each call (if the call itself does not return one), push them in an array and call $q.all(promises).then(allFinished).
function callUpdate(x, promises) {
    var d = $q.defer();
    $http.post('backend/backend.php?action=get_normes',x).then(function(resp){
        $scope.normes.push(resp.data);
        d.resolve(resp.data);
    })
    promises.push(d.promise);
}

...
var promises = [];
$scope.normes = [];
for (var i = 0; i < surfaces.length; i++) {
    callUpdate(surfaces[i], promises);
}

$q.all(promises).then(function() {
    // called when all promises have been resolved successully
});

A: Create an array of promises
var promises = [];
surfaces.forEach(function(surface){
    promises.push($http.post('backend/backend.php?action=get_normes',surface));
})

You can use $q.all() and wait for all promises to complete and use Array.concat() to create $scope.normes array.
 $q.all(promises).then(function (results) {
    $scope.normes = [].concat.apply([],results);
});

A: When chaining promises, it is important to return the subsequent promise to the .then method handler function:
var arrayPromise = $q.when([])
    .then(function (dArray) {
        var httpPromise = $http.post('backend/backend.php/action=get_normes',surfaces[0])
        var dPromise = httpPromise.then(function(response) {
            $scope.normes.push(response.data);
            dArray.push(response.data);
            return dArray;
        });
        return dPromise;
    }).then(function(dArray) {
        console.log("one XHR is complete");
        console.log(dArray);
    });

When the code fails to return anything to the handler function, the $q service resolves the promise as undefined and immediately executes the next function. By returning the subsequent promise, the $q service will wait for the promise to resolve before executing the next promise in the chain.

That said. How to create a loop that chains sequential promises?
var arrayPromise = $q.when([]);

for (let n=0; n<surfaces.length; i++) {
    arrayPromise = arrayPromise
      .then(function (dArray) {
        var httpPromise = $http.post(url,surfaces[n]);
        var dPromise = httpPromise.then(function(response) {
            $scope.normes.push(response.data);
            dArray.push(response.data);
            //return dArray to chain
            return dArray;
        });
        return dPromise;
    });
};

arrayPromise.then(function(dArray) {
    console.log("all XHRs are complete");
    console.log(dArray);
}).catch(function(errorResponse) {
    console.log("one of the XHRs failed");
    console.log(errorResponse.status);
    throw errorResponse;
});

Create a variable with a promise for an empty array. Then in the loop simply assign the promise derived from the .then method back to that variable. Each iteration of the loop returns an array that is one item larger than the previous iteration. Also each iteration has the side effect of pushing an item to scope.


text:
Q: Sencha Touch app components not visible until touching My Sencha Touch 2.4.0 app's Viewport config looks like this:
xtype: 'mainviewport',
config: {
    layout: 'card',
    height: '100%',
    width: '100%',
    listeners: {
        painted: function() {
            console.log('xxxxxx viewport painted');
        }
    }
}

I'm adding another view into the Viewport using following controller code:
var vp = Ext.Viewport.down('mainviewport');
vp.add(view);
vp.setActiveItem(view);

The issue is, only on Android JellyBean (4.1 - 4.3), I don't see the view rendered on the screen. But, when I tap once, it get's rendered and its painted method is getting called. I also see that the 'xxxxxx viewport painted' line is printed even before I tapped the screen.
I have tried a lot of options in the past week, including downgrading sencha touch to 2.3.0 but still no luck. Highly appreciate any support.

A: You might take a look at the bug fixes for Chrome 43 which have been recently added to Touch 2.4.2. Since this is a problem affecting Android, I would imagine the Chromium updates could be to blame.


text:
Q: Left join if value is NULL, otherwise inner join I want a join on two tables that replicates left join behaviour if a value is NULL, and inner join behaviour if the value is NOT NULL. For example, for the tables:
t1(val) AS (VALUES (NULL)),
t2(val) AS (VALUES ('a'), ('b'))

The join would return a single row with values (NULL,NULL) (as per a left join). For the tables:
t1(val) AS (VALUES ('c')),
t2(val) AS (VALUES ('a'), ('b'))

No rows would be returned (as per an inner join). For the tables:
t1(val) AS (VALUES ('a')),
t2(val) AS (VALUES ('a'), ('b'))

A single row with values ('a','a') would be returned (as per either type of join).
What is the most efficient way to do this?
EDIT: As part of maximising efficiency, I'm looking for a query that doesn't post-filter (i.e. use the WHERE clause).

A: You could use this:
SELECT t1.val, t2.val
FROM t1
LEFT JOIN t2
ON t1.val = t2.val
WHERE t1.val IS NULL OR t1.val = t2.val;

Or:
SELECT NULL AS val1, NULL AS val2
FROM t1
WHERE val IS NULL
UNION ALL
SELECT t2.val, t2.val
FROM t2
INNER JOIN t1 ON t1.val = t2.val;


text:
Q: "Friendly iFrame" detection: How can I find my nested iframe in the top page? I've come across a challenging iFrame detection problem in a "friendly iframe" environment. I need to identify from window.top which foreign domain iframe element in window.top.document loads inside of itself yet another iframe with the same domain, protocol, and port as window.top.
So here's the central question: On Page A, how can you determine in JavaScript that iFrame B contains iFrame C? Again, Page A and iFrame C are of the same domain, protocol and port and can communicate with each other. iFrame B is on a different domain. I want to find the DOMElement that is associated with iFrame C on Page A.
Possible things that have been tried that have not worked:

*

*document.referrer matching. Page A matches the src attribute of all iframes on Page A to the document.referrer property in iFrame C. Unfortunately, this doesn't work if multiple iframes on Page A load content with the same src on iframe B. It also doesn't work if the src attribute of iframe B is about:blank or javascript:something.

*window.location.hash communication by looking at the src attributes of iframes. Page A can't get the window.location.hash of iFrame B, so no luck there.

*This has to work in IE 6 and 7, so there is no window.postMessage support. Sorry.

Additional information:
This is a  configuration called "Friendly iFrames". Friendly iFrames (FIF) are common in the advertising industry. Here's how they work:
A page on publisher site, say Page A foo.com, injects iframe B from some-random-ad-server.com. Then inside of iframe B on some-random-ad-server.com, another iframe C is loaded from foo.com. So:

*

*I have access (i.e. DOM manipulation) to Page A from iFrame C. Page A has access to iFrame C.

*Nothing on the Page A or iFrame C has access to iFrame B.

A: I realize this is old, but I was curious about client side solutions and ran across this post. I'm using server-side to handle this, why not use server side as last resort? Granted referrer is sketchy on server side, however when dealing with iframed pages, the referrer is pretty reliable and can be compared against the host of the local application and the referring application.
Here is how I've done it in ASP.NET/C# (same thing can be done in PHP, etc)
// set referrer
if (Request.UrlReferrer != null && Request.Url.Host != Request.UrlReferrer.Host)
{
    Session["Referrer"] = Request.UrlReferrer.OriginalString;
}


text:
Q: How do I use a socket proxy in C# webbrowser? How do I point a socket to the proxy ip/port using the winforms webbrowser control? The standard web browser that comes with Visual C#.NET.
Please help in Visual C#.NET.

A: The WebBrowser control is just a wrapper around IE. So to set proxy settings, you could change the registry key entries.
Something like this:
string serverName = ""; // your proxy server name
string port = ""; // your proxy port

var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
key.SetValue("ProxyServer", serverName + ":" + port);
key.SetValue("ProxyEnable", 1);

A: WebBrowser is just an interface over IE.  To set the IE proxy settings, you can hack the registry!
        string key = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
        string serverName = "";//your proxy server name;
        string port = ""; //your proxy port;
        string proxy = serverName + ":" + port;

        RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(key, true);
        RegKey.SetValue("ProxyServer", proxy);
        RegKey.SetValue("ProxyEnable", 1);


text:
Q: RestKit valueTransformer not being called I am using RestKit to talk to my JSON endpoints. The endpoint returns a UNIX timestamp in 'number of milliseconds'. But RestKit's default transformer assumes that it is 'number of seconds' and I get a wrong value in NSDate.
So I looked around, and found that I need to use a custom valueTransformer to tell RestKit how to transform my timestamp. Here's the code I have.
+ (RKBlockValueTransformer*) timeIntervalInMillisecondsSince1970TwoWayTransformer {

    return [RKBlockValueTransformer valueTransformerWithValidationBlock:^BOOL(__unsafe_unretained Class sourceClass, __unsafe_unretained Class destinationClass) {
        // This transformer handles `NSNumber` <-> `NSDate` transformations
        NSLog(@"checking new transformer");
        return (([sourceClass isSubclassOfClass:[NSNumber class]] && [destinationClass isSubclassOfClass:[NSDate class]]) ||
                ([sourceClass isSubclassOfClass:[NSDate class]] && [destinationClass isSubclassOfClass:[NSNumber class]]));
    } transformationBlock:^BOOL(id inputValue, __autoreleasing id *outputValue, __unsafe_unretained Class outputValueClass, NSError *__autoreleasing *error) {
        NSLog(@"transforming");
        RKValueTransformerTestInputValueIsKindOfClass(inputValue, (@[ [NSNumber class], [NSDate class] ]), error);
        RKValueTransformerTestOutputValueClassIsSubclassOfClass(outputValueClass, (@[ [NSNumber class], [NSDate class] ]), error);
        if ([outputValueClass isSubclassOfClass:[NSDate class]]) {
            if ([inputValue isKindOfClass:[NSNumber class]]) {
                *outputValue = [NSDate dateWithTimeIntervalSince1970:[inputValue doubleValue] / 1000];
            }
        } else if ([outputValueClass isSubclassOfClass:[NSNumber class]]) {
            *outputValue = @((NSInteger)[inputValue timeIntervalSince1970] * 1000);
        }
        return YES;
    }];
}

Then I am adding this transformer to RestKit's default transformer.
RKValueTransformer* transformer = [self timeIntervalInMillisecondsSince1970TwoWayTransformer];
[[RKValueTransformer defaultValueTransformer] addValueTransformer:transformer];

But, my transformer never gets called. The NSLog statement I wrote in it never gets executed!

So then I tried this -- writing a transformer on the attributeMapping like this:
RKValueTransformer* transformer = [self timeIntervalInMillisecondsSince1970TwoWayTransformer];
RKAttributeMapping *tokenExpiryMapping = [RKAttributeMapping attributeMappingFromKeyPath:@"access_token_expiration" toKeyPath:@"accessTokenExpirationDate"];
tokenExpiryMapping.valueTransformer = transformer;
[userMapping addPropertyMapping:tokenExpiryMapping];

But the code doesn't compile when I do this. It says "Property valueTransformer not found on object of type 'RKAttributeMapping *'". I don't understand this. All the examples I have seen on the internet, including the one with RestKit's documentation say the same thing. All examples set the valueTransformer property of the AttributeMapping object. Even the RestKit Class Reference says that I can set it. But then why doesn't it compile?

A: So I managed to finally figure out what the problem was.
My podfile was configured to use RestKit 0.20.3. And then I had added RKValueTransformers as another Pod. However, RestKit 0.20.3 and earlier come with their own version of RKValueTransformer (.h and .m) files. And those older versions of RestKit doesn't support adding your own Transformers, because it doesn't make use of the newer RKValueTransformers library.
When I upgraded my RestKit version to the newest version (actually anything above 0.21.0 would work), things started working fine. I didn't need to add the pod RKValueTransformers, because it gets added automatically as a dependency of RestKit.

A: Look at using insertValueTransformer:atIndex: instead of addValueTransformer: so that you can add it at the start of the list rather than the end.

A: In swift I could successfully create a value transformer.
Its purpose is to just add a timestamp downloadedOn to my model, so I don't use the inputValue at all:
let downloadedMapping = RKAttributeMapping(fromKeyPath: "@self", toKeyPath: "downloadedOn")
downloadedMapping.valueTransformer = RKBlockValueTransformer(validationBlock: nil){ _, outputValue, _, error -> Bool in
        outputValue.memory = NSDate()
        return true

}
myMapping.addPropertyMapping(downloadedMapping)

The biggest caveat for me was how I should write the value to the outputValue pointer until I figured out that I don't have to use an  inout parameter but rather access the memory property of the outputValue parameter.
Note: I am using a generic keyPath of @self for the other side of my property mapping, so that I can use this mapping for various classes that have the downloadedOn property.


text:
Q: Use of cell.value vs cell.internal_value for openpyxl's iter_rows() method I'm working on a piece of code from two computers.  I use openpyxl to read data from an excel sheet, with load_workbook keyword arguments data_only=True and use_iterators=True.  Depending on which computer I'm using, I need to use either cell.value or cell.internal_value.  Why is this the case?
Here's the read:
raw_rows = []
for row in openpyxl_sheet.iter_rows():
    #  raw_rows.append([cell.internal_value for cell in row])
    raw_rows.append([cell.value for cell in row])
return raw_rows

As a temporary workaround, I've been swapping between lines 3 and 4.
On one computer, cell.value gives me the cell data and cell.internal_value throws the following attribute error:
AttributeError: 'RawCell' object has no attribute 'value'

On the other computer, both cell.value and cell.internal_value give me data, but only cell.internal_value gives the correct data.
From what I can tell from reading other questions on the site, I should be using cell.internal_value for both.  I've used Anaconda to install openpyxl on both computers.

A: I was using a different version of openpyxl on each computer.  I had thought they'd be the same since I used Anaconda to install each.  The issues was fixed with conda update openpyxl.  After updating, using cell.value works for both.
I'll leave the question up in case another user can identify a solution that doesn't assume that you're able to change the version of openpyxl.


text:
Q: How to align String on console output I've to write code for:

I'd written the code:
public class tables {
    public static void main(String[] args) {
        //int[][] table = new int[12][12];
        String table="";
        for(int i=1; i<13; i++){
            for(int j=1; j<13; j++){
                //table[i-1][j-1] = i*j;
                table+=(i*j)+" ";
            }
            System.out.println(table.trim());
            table="";
        }
    }
}

But the problem is with the output format. I need the output in a matrix like fashion, each number formatted to a width of 4 (the numbers are right-aligned and strip out leading/trailing spaces on each line). I'd tried google but not find any good solution to my problem. Can anybody help me out?

A: You can use format() to format your output according to your need..
    for(int i=1; i<13; i++){
        for(int j=1; j<13; j++){

           System.out.format("%5d", i * j);
        }
        System.out.println();  // To move to the next line.
    }

Or, you can also use: -
System.out.print(String.format("%5d", i * j));

in place of System.out.format..
Here's is the explanation of how %5d works: -

*

*First, since we are printing integer, we should use %d which is format specifier for integers..

*5 in %5d means the total width your output will take.. So, if your value is 5, it will be printed to cover 5 spaces like this: - ****5

*%5d is used to align right.. For aligning left, you can use %-5d. For a value 5, this will print your output as: -      5****

A: In my example the array contains character string's with different length and due to that I was unable to arrange string and other strings of different arrays were mis-match on console. with a different concept I could arrange those
arrays on console my codes are as below.
package arrayformat;

 /**
 *
 * @author Sunil
 */
 public class ArrayFormat {

  /**
  * @param args the command line arguments
  */

  public static void main(String[] args) {

  int[] productId = new int[]
 {1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,};
   String[] productName= new String[]{"Pepsi","kissan jam","Herbal
 oil","Garnier man's","Lays chips","biscuits","Bournvita","Cadbury","Parker
 Vector","Nescafe",};
   String[] productType = new String[]{"Cold Drink","Jam","Oil","Face
 wash","chips","Biscuits","Health
 Supplement","Chocolate","Stationary","Coffee",};
    float[] productPrice = new float[]{24,65,30,79,10,20,140,20,150,80,};

       int productNameMaxlength=0;
   int productTypeMaxlength=0;

    for (String productName1 : productName) {
        if (productNameMaxlength < productName1.length()) {
            productNameMaxlength = productName1.length();
        }
    }

    for (String productType1 : productType) {
        if (productTypeMaxlength < productType1.length()) {
            productTypeMaxlength = productType1.length();
        }
    }

   for(int i=0;i<productType.length;i++)

   {
              System.out.print(i);

      System.out.print("\t");

              System.out.print(productId[i]);

              System.out.print("\t");

              System.out.print(productName[i]);

       for(int j=0;j<=productNameMaxlength-productName[i].length
     ();j++)

       {

        System.out.print(" ");

       }

       System.out.print("\t");

       System.out.print(productType[i]);

       for(int j=0;j<=productTypeMaxlength-productType[i].length
    ();j++)

       {
           System.out.print(" ");
       }

               System.out.print("\t");

       System.out.println(productPrice[i]);
          }
      }

    }
   and output is--
  Sr.No  ID     NAME            TYPE               PRICE
   0    1001    Cadbury         Chocolate           20.0
   1    1002    Parker Vector   Stationary          150.0
   2    1003    Nescafe         Coffee              80.0
   3    1004    kissan jam      Jam                 65.0
   4    1005    Herbal oil      Oil                 30.0
   5    1006    Garnier man's   Face wash           79.0
   6    1007    Lays chips      chips               10.0
   7    1008    biscuits        Biscuits            20.0
   8    1009    Bournvita       Health Supplement   140.0
   9    1010    Pepsi           Cold Drink          24.0

Since I am unable to answer my question where I have ask my question because of block to ask question and answer I am quoting my answer and this was a different kind of array format I feel.

A: Formatting of output can be  done using the System.out.format("","") method this method contain two  input parameter  first define the formatting style and second  define value to be print.  Let us assume you want to the  n digit value right align. you will pass the first parameter "%4d".
For the left align use -ve %-nd
For right align use +ve %nd
 for(int i=1; i<13; i++){
       for(int j=1; j<13; j++){
            System.out.format("%4d", i * j);  //each number formatted to a width of 4 so use %4d in the format method.
    }
    System.out.println();  // To move to the next line.
}


text:
Q: Normal Operators: Polar Decomposition (Rudin) On page 332 theorem 12.35b) of Rudin functional analysis is show that if T is normal then it has a polar decomposition $T=UP$. Does he mean that $P=|T|$? He's a bit ambiguous as to how he defines polar decomposition in whether $P$ is simply positive or whether $P=|T|$.

A: Note that Rudin requires the $U$ in the polar decomposition to be a unitary. In that case, if $T=UP$, then
$$
T^*T=PU^*UP=P^2,
$$
and indeed $P=|T|$. So there is no ambiguity.

A: Let $X$ be a complex Hilbert space. For any $T\in\mathcal{L}(X)$ (normal or not), there is a unique $P\in\mathcal{L}(X)$ such that $P \ge 0$ and $P^{2}=T^{\star}T$. So your question is confusing. If you define $|T|$ to be a positive square root of $T^{\star}T$, then any $P \ge 0$ for which $P^{2}=T^{\star}T$ must be $|T|$.

A: Rudin restricts to normals as...
Definition
Given a Hilbert space $\mathcal{H}$.
Consider selfadjoint operators:
$$H:\mathcal{D}H\subseteq\mathcal{H}\to\mathcal{H}:\quad H=H^*$$

Define positivity by:*
  $$H\geq0:\iff\sigma(H)\geq0$$

*(They may be unbounded!)
Positive Operators
Given a Hilbert space $\mathcal{H}$.
Consider positive operators:
$$P^{(\prime)}:\mathcal{D}P^{(\prime)}\subseteq\mathcal{H}\to\mathcal{H}:\quad P^{(\prime)}\geq0$$
By functional calculus:
$$P^2=P'^2\implies P=P'$$
That gives uniqueness.
Closed Operators
Given two Hilbert spaces $\mathcal{H}$ and $\mathcal{K}$.
Consider a closed operator:
$$A:\mathcal{D}A\subseteq\mathcal{H}\to\mathcal{K}:\quad A=A^{**}$$
By closedness one obtains:
$$|A|:\mathcal{D}|A|\subseteq\mathcal{H}\to\mathcal{H}:\quad |A|:=\sqrt{A^*A}\geq0$$
By functional calculus:*
$$\mathcal{D}:=\mathcal{D}A=\mathcal{D}|A|$$
By square root lemma:*
$$\|A\varphi\|=\||A|\varphi\|\quad(\varphi\in\mathcal{D})$$
Thus one can find:
$$J\in\mathcal{B}(\mathcal{H},\mathcal{K}):\quad A=J|A|$$
By above and boundedness:
$$\varphi\in\overline{\mathcal{R}|A|}:\quad\|J\varphi\|_\mathcal{K}=\|\varphi\|_\mathcal{H}$$
Concluding closed operators.
Normal Operators
Given one Hilbert space $\mathcal{H}$.
Consider a normal operator:
$$N:\mathcal{D}N\subseteq\mathcal{H}\to\mathcal{H}:\quad N^*N=NN^*$$
Then it is closed:
$$N^*N=NN^*\implies N=N^{**}$$
So the above applies:
$$J\in\mathcal{B}(\mathcal{H}):\quad N=J|N|$$
And it is isometric on:
$$\varphi\in\overline{\mathcal{R}|N|}:\quad\|J\varphi\|_\mathcal{H}=\|\varphi\|_\mathcal{H}$$
By above and normality:**
$$\left(\overline{\mathcal{R}|N|}\right)^\perp=\mathcal{N}|N|=\mathcal{N}N=\mathcal{N}(N^*N)\\
=\mathcal{N}(NN^*)=\mathcal{N}N^*=\left(\overline{\mathcal{R}N}\right)^\perp$$
So it can be chosen unitary.
Partial Isometry
Given one Hilbert space $\ell^2(\mathbb{N})$.
Consider the right shift:
$$A:\ell^2(\mathbb{N})\to\ell^2(\mathbb{N}):\quad A:=R$$
Its modulus is the unit:
$$A^*A=LR=1\implies|A|=1$$
Thus partial isometry is:
$$A=J|A|\implies J=R$$
But it is not unitary:
$$\mathcal{R}J=\mathcal{R}R\neq\ell^2(\mathbb{N})$$
Concluding partial isometry.
(Note it was even isometric!)
*See the thread: Square Root
**See the thread: Kernel


text: Q: Bottom Scroll Bar, View Selection, and Refresh/Pause Missing Admins might at first think this is a repeat question, but it isn't. The other question similar to this issue specifies that the bottom scroll bar goes missing in layout view. This problem is occurring in both layout and data view. I have gone to the View menu > Scroll Bars and made sure it is selected. I've even tried deselecting and reselecting it, to no avail. However, if I go into the View menu and select Layout View, the scroll bar appears. Usually, it will remain, but it sometimes will disappear again after a period of time. I'm using ArcMap 10.5.1 on an enterprise system.


text:
Q: SQL code not running , getting a "permission denied for schema public" error message CREATE TABLE student
(
    student_id INT PRIMARY KEY,
    nam VARCHAR (20),
    major VARCHAR (20)
);

I'm just running this code and I keep getting a permission denied for schema public message. What does this mean and how can I fix it.?

A: I see you are asking this in reference to the freeCodeCamp's SQL course by the looks of it.
You need to create your own database and you should be good to go, see the steps below:

*

*Open mySQL command line and create a new database CREATE DATABASE TestDB

*Open PopSQL > File > Preferences > Connections > Add New Connection > MySQL

*Connection name: any name

*Hostname/Port: localhost | 3306 (3306 is default port number, maybe you used/have different port during MySQL installation)

*Database: TestDB

*Username: root | Password: (this is what you set when you installed MySQL)

*Connection Type: turn this ON, you want to "Connect directly from my computer"

Test connection, if successful, save.
Also, please note this is working on MySQL Server 5.7.20, it may be different on other versions.

A: It means you are using POPsql sample data. Click on manage connections and add a connection to your own database.

A: Please make sure you are using the right database, in the popSQL the "PopSQL Sample Data" database is selected by default.
you can change it as mentioned below

A: You need to add your own new connection instead of running it on POPsql sample data private connection

A: just delete the other sample server from the list of connections and add your own.

A: I see you are asking this in reference to the freeCodeCamp's SQL course as the same with me, what you really need to do is make sure you follow all of his instructions and after that make sure you change the connection to MySQL after add the new connections.
enter image description here


text:
Q: Validation based in async Validators Hello im using async Validators to check if a email exist in my database, and it checks well, it gives me the correct http request, it works fine using for example in a first time registration, it will check to see if the user exist in my database. The problem is for example when i use to recover the password. The documentation says:
"if $http is used then it is important that the server returns a success HTTP response code
 * in order to fulfill the validation and a status level of 4xx in order to reject the validation"
So what is happening to me is when the user insert the email in the recover password page, it gives a response of '400 - Bad request' and makes the form/input invalid. I need to change this beavihour, for when the 400 request is given to make the validation true and if the response is 200 make the validation false.
Example code Js:
return {
    restrict: 'A',
    require: 'ngModel',
    link: function (scope, element, attribute, controller) {
        controller.$asyncValidators.uniqueEmail = function (email) {
            return $http
                .post('/api/email/availability', {value: email})
                then(function(response) {
                        //username exists, this means validation fails
                        return $q.reject('exists');
                      }, function(response) {
                        //username does not exist, therefore this validation passes
                        return true;
                })
        };
    }
}

A: check the response object you get in the $http callback, it contains the status code.
$http docs
function(response) {
    if (response.status == 200) { return true; }
}


text:
Q: How to make
* scrolling like parallax? What is the best way to make 'li' tags also scroll like parallax?

Invest in Azerbaijan

Total Area:  86,600 km2

Water (%): 1.6

GDP   (PPP):   $168.4 billion

Time zone:   AZT (UTC+04)

Population:   9,754,830

A: Try this
First put this:
.parallax {
    background-image: *image URL*;

    height: 100%;

    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

And then put your div down at HTML but make sure you added this code before and after the div

Should look like:

  Whatever