问:
Using a variable for a range
I am writing a macro and am having issues with using a range variable. I think I am setting the range properly, but I cannot do anything with the range. Pseudocode below:

```<code>Dim rng As Range
Set rng = Report(1)      'A function which will be defined below

trackWkbk.Sheets(strFY).rng = 10       <--'THIS IS WHERE I am getting the error.

'trackWbkb is a workbook that is defined properly; I use it elsewhere with no errors.
'strFY is defined and working properly, I use it to call sheets in trackWbkb elsewhere with no errors.
</code>```

The sub function code is:

```<code>Function Report(a) As Range
    Select Case intMonth
        Case intMonth = 7
        Select Case a
            Case a = 1
                Set Report = Range("B2")
        End Select
    End Select
End Function
</code>```

I know my select case statements are gonna get pretty convoluted (this is just a testing sample), but I don't think the issue is there.

Let me know if I should include more code. My code compiles. I think this is something simple that I am missing, but I have been looking online for the past half hour and can't seem to find anything that will resolve this. Does anyone know how to resolve this? Thanks

答:
When you set a range variable you are creating a pointer in memory to a specific range in a specific sheet. It's not storing a cell address, so you can't write

```<code> trackWkbk.Sheets(strFY).rng
</code>```

Either adopt Excelosaurus's solution, or change your function to return a cell address as a string and then use

```<code> trackWkbk.Sheets(strFY).range(rng)
</code>```

Title: Using a variable for a range

Body:
I am writing a macro and am having issues with using a range variable. I think I am setting the range properly, but I cannot do anything with the range. Pseudocode below:

Dim rng As Range
Set rng = Report(1)      'A function which will be defined below

trackWkbk.Sheets(strFY).rng = 10       <--'THIS IS WHERE I am getting the error.

'trackWbkb is a workbook that is defined properly; I use it elsewhere with no errors.
'strFY is defined and working properly, I use it to call sheets in trackWbkb elsewhere with no errors.

The sub function code is:

Function Report(a) As Range
    Select Case intMonth
        Case intMonth = 7
        Select Case a
            Case a = 1
                Set Report = Range("B2")
        End Select
    End Select
End Function

I know my select case statements are gonna get pretty convoluted (this is just a testing sample), but I don't think the issue is there.

Let me know if I should include more code. My code compiles. I think this is something simple that I am missing, but I have been looking online for the past half hour and can't seem to find anything that will resolve this. Does anyone know how to resolve this? Thanks

Body:
When you set a range variable you are creating a pointer in memory to a specific range in a specific sheet. It's not storing a cell address, so you can't write

 trackWkbk.Sheets(strFY).rng

Either adopt Excelosaurus's solution, or change your function to return a cell address as a string and then use

 trackWkbk.Sheets(strFY).range(rng)


来源: stackexchange

问:
Oracle : receiving ORA-06550 and PLS-00905
i have a holiday table which contains the data are

```<code>    HOLIDAYDA DESCRIPTION
   --------- --------------------
   19-JAN-11 to
   17-JAN-11 to
   10-JAN-11 new day
</code>```

Now I want the first business day of the week.  IE: If I pass "12-JAN-2011" as input, I want the o/p as 11-JAN-2011 as the 1st business day because 10-JAN-2011 is holiday.

here is my code :

```<code>create or replace procedure sample as
   l_dStartDay date;
   l_dHolidayDate date;
begin

    select trunc(to_date(sysdate),'Day')
      into l_dStartday
      from dual;

 dbms_output.put_line('first day of the week ');
 dbms_output.put_line(l_dStartDay);

 for i in 2..5 Loop
   select holidaydate
     from holiday
     into l_dHolidayDate
    where holidaydate = (l_dStartDay + i);

  if(l_dHolidaydate is null) then
    dbms_output.put_line(l_dStartDay+i);
  end if;
exit;
end loop;
end;
</code>```

i compiled the above program but with "Procedure created with compilation errors."

Newly Added :
Compliation errors :

```<code> LINE/COL ERROR
 -------- -----------------------------------------------------------------
 9/1      PL/SQL: SQL Statement ignored
 9/33     PL/SQL: ORA-00933: SQL command not properly ended
</code>```

Error:

```<code>BEGIN sample; END;
      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object SYSTEM.SAMPLE is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
</code>```

can any one tell me the reason for the error? if possible tell me the solution?

答:
Aside from the errors already mentioned, try removing the 'EXIT' clause as this loop will iterate a fixed number of times. Also, try specifying the block name when ending the block as in the following:

```<code>    LOOP
    ...
    END LOOP;
END ObjectName;
</code>```

Where ObjectName is your top level program. Here, it would be 'sample', so:

```<code>    LOOP
    ...
    END LOOP;
END sample;
</code>```

ContentLicense: CC BY-SA 2.5

Body:
i have a holiday table which contains the data are

    HOLIDAYDA DESCRIPTION
   --------- --------------------
   19-JAN-11 to
   17-JAN-11 to
   10-JAN-11 new day

Now I want the first business day of the week.  IE: If I pass "12-JAN-2011" as input, I want the o/p as 11-JAN-2011 as the 1st business day because 10-JAN-2011 is holiday.

here is my code :

create or replace procedure sample as
   l_dStartDay date;
   l_dHolidayDate date;
begin

    select trunc(to_date(sysdate),'Day')
      into l_dStartday
      from dual;

 dbms_output.put_line('first day of the week ');
 dbms_output.put_line(l_dStartDay);

 for i in 2..5 Loop
   select holidaydate
     from holiday
     into l_dHolidayDate
    where holidaydate = (l_dStartDay + i);

  if(l_dHolidaydate is null) then
    dbms_output.put_line(l_dStartDay+i);
  end if;
exit;
end loop;
end;

i compiled the above program but with "Procedure created with compilation errors."

Newly Added :
Compliation errors :

 LINE/COL ERROR
 -------- -----------------------------------------------------------------
 9/1      PL/SQL: SQL Statement ignored
 9/33     PL/SQL: ORA-00933: SQL command not properly ended

Error:

BEGIN sample; END;
      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object SYSTEM.SAMPLE is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

can any one tell me the reason for the error? if possible tell me the solution?

Body:
Aside from the errors already mentioned, try removing the 'EXIT' clause as this loop will iterate a fixed number of times. Also, try specifying the block name when ending the block as in the following:

    LOOP
    ...
    END LOOP;
END ObjectName;

Where ObjectName is your top level program. Here, it would be 'sample', so:

    LOOP
    ...
    END LOOP;
END sample;


问:
How to remove the single quotation mark from a list in Python
I am trying to remove the single quotation marks from this list:

```<code>list = ['amazed, 10']
</code>```

and convert it to

```<code>list = ['amazed', 10]
</code>```

I used list= [x.strip('') for x in list] but it does not work.

Is there a workaround?

Thanks in advance!

答:
as it is a single item in the list, u can split the string using split() method.

```<code>list=list[0].split(', ')
</code>```

it will give two separate strings.

ContentLicense: CC BY-SA 3.0

Body:
I am trying to remove the single quotation marks from this list:

list = ['amazed, 10']

and convert it to

list = ['amazed', 10]

I used list= [x.strip('') for x in list] but it does not work.

Is there a workaround?

Thanks in advance!

Body:
as it is a single item in the list, u can split the string using split() method.

list=list[0].split(', ')

it will give two separate strings.


问:
Android button has setOnTouchListener called on it but does not override performClick
When I try to add onTouchListner() to a button, it gets me the

Button has setOnTouchListener called on it but does not override
  performClick

warning. Does anyone know how to fix it?

```<code>btnleftclick.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        return false;
    }
});
</code>```

Error:

Custom view has setOnTouchListener called on it but does not override
  performClick If a View that overrides onTouchEvent or uses an
  OnTouchListener does not also implement performClick and call it when
  clicks are detected, the View may not handle accessibility actions
  properly. Logic handling the click actions should ideally be placed in
  View#performClick as some accessibility services invoke performClick
  when a click action should occur.

答:
Solution:

Create a class that extends Button or whatever view you are using and override performClick()

```<code>class TouchableButton extends Button {

    @Override
    public boolean performClick() {
        // do what you want
        return true;
    }
}
</code>```

Now use this TouchableButton in xml and/or code and the warning will be gone!

ContentLicense: CC BY-SA 4.0

Body:
When I try to add onTouchListner() to a button, it gets me the

Button has setOnTouchListener called on it but does not override
  performClick

warning. Does anyone know how to fix it?

btnleftclick.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        return false;
    }
});

Error:

Custom view has setOnTouchListener called on it but does not override
  performClick If a View that overrides onTouchEvent or uses an
  OnTouchListener does not also implement performClick and call it when
  clicks are detected, the View may not handle accessibility actions
  properly. Logic handling the click actions should ideally be placed in
  View#performClick as some accessibility services invoke performClick
  when a click action should occur.

Body:
Solution:

Create a class that extends Button or whatever view you are using and override performClick()

class TouchableButton extends Button {

    @Override
    public boolean performClick() {
        // do what you want
        return true;
    }
}

Now use this TouchableButton in xml and/or code and the warning will be gone!


问:
Small rotation brings Openlayers map to original position. How to disable this effect?
If I rotate the OpenLayers map (Alt+Shift+Drag by default) by a very small amount and release the mouse, the map rotates back to its original position.

This is default behavior and you can see it here.

How this effect is called and how can I disable it?

答:
Use constrainRotation option for that

Rotation constraint. false means no constraint. true means no
  constraint, but snap to zero near zero. A number constrains the
  rotation to that number of values. For example, 4 will constrain the
  rotation to 0, 90, 180, and 270 degrees. The default is true.


问:
How to fetch data from nested JSON response and pass to next request in postman?
I have a JSON response as below.

```<code>{
    "SearchId": "AD9AD002JKLNLSF7",
    "TanxId": "789456g78udk9",
    "Test": [{
        "Outgoing": [{
            "Identifier": null,
            "AirId": "eff4f689-8b49",
            "Fare": "a0b8ac00-e6ab"
        }]
    }]
}
</code>```

How can I get value of "AirId" and "Fare" from this response and pass to next request?

I tried below but it's not working.

```<code>var FareId = jsonData.Test[0].Outgoing.Fare;
pm.globals.set(“Fareref”, FareId);
</code>```

答:
Here is an example:</p>

```<code>var oJson = JSON.parse('{ "SearchId": "AD9AD002JKLNLSF7", "TanxId": "789456g78udk9", "Test": [{ "Outgoing": [{ "Identifier": null, "AirId": "eff4f689-8b49", "Fare": "a0b8ac00-e6ab" }] }] }');

console.log(oJson.Test[0].Outgoing[0].AirId);
console.log(oJson.Test[0].Outgoing[0].Fare);
</code>```

Body:
I have a JSON response as below.

{
    "SearchId": "AD9AD002JKLNLSF7",
    "TanxId": "789456g78udk9",
    "Test": [{
        "Outgoing": [{
            "Identifier": null,
            "AirId": "eff4f689-8b49",
            "Fare": "a0b8ac00-e6ab"
        }]
    }]
}

How can I get value of "AirId" and "Fare" from this response and pass to next request?

I tried below but it's not working.

var FareId = jsonData.Test[0].Outgoing.Fare;
pm.globals.set(“Fareref”, FareId);

Body:
Here is an example:

var oJson = JSON.parse('{ "SearchId": "AD9AD002JKLNLSF7", "TanxId": "789456g78udk9", "Test": [{ "Outgoing": [{ "Identifier": null, "AirId": "eff4f689-8b49", "Fare": "a0b8ac00-e6ab" }] }] }');

console.log(oJson.Test[0].Outgoing[0].AirId);
console.log(oJson.Test[0].Outgoing[0].Fare);


问:
Fire AJAX jQuery if scroll reach to each div
I want make ajax fire if scroll reach to each div element.

Item div 1

Item div 2 (fire ajax if scroll to this element)

Item div 3 (fire ajax again if scroll to this element)

Item .....N

I use this code, but only fire if scroll to end.

$( window ).scroll( function() {
     if( $( window ).scrollTop() == $( document ).height() - $( window ).height() ) {
      alert('Fire!');
     }
    });```

Please help.

答:
Use $.offset().top instead of heights.

To check all sections you can use $.each(). Since I am guessing you only want to fire the event once, you will need a variable to remember all sections, that already fired.

let firedEvents = [];

$(window).scroll(function() {
  $("div.section").each(function() {
    if (!firedEvents.includes(this) && $(window).scrollTop() > $(this).offset().top) {
      firedEvents.push(this);
      alert("fire " + $(this).data("nr"));
    }
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>div {
  height: 500px;
}</code>```

```

Body:
I want make ajax fire if scroll reach to each div element.

Item div 1

Item div 2 (fire ajax if scroll to this element)

Item div 3 (fire ajax again if scroll to this element)

Item .....N

I use this code, but only fire if scroll to end.

$( window ).scroll( function() {
     if( $( window ).scrollTop() == $( document ).height() - $( window ).height() ) {
      alert('Fire!');
     }
    });

Please help.

Body:
Use $.offset().top instead of heights.

To check all sections you can use $.each(). Since I am guessing you only want to fire the event once, you will need a variable to remember all sections, that already fired.

let firedEvents = [];

$(window).scroll(function() {
  $("div.section").each(function() {
    if (!firedEvents.includes(this) && $(window).scrollTop() > $(this).offset().top) {
      firedEvents.push(this);
      alert("fire " + $(this).data("nr"));
    }
  });
});

div {
  height: 500px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="section" data-nr="0" style="background-color: red;"></div>
<div class="section" data-nr="1" style="background-color: green;"></div>
<div class="section" data-nr="2" style="background-color: blue;"></div>
<div class="section" data-nr="3" style="background-color: yellow;"></div>


问:
How to set date format, timezone and locale using angular 4 date pipe?
I have date value from postgres db without timezone. I want this display in angular 2 template with timezone and locale

```<code>postgres db value : 2017-11-14 09:40:59.753
</code>```

I just displayed date in angular template using {{codeset.created_on}} it will be displayed below like :

```<code>Tue Nov 14 2017 09:40:59 GMT+0530 (IST)
</code>```

But I want display current time based on timezone with locale

I tried like below in angular template :

```<code><span>{{codeset.created_on | date :'dd/MM/yyyy h:mm a' :'+530' :'en-US'}}</span>
</code>```

答:
You can set it globally by providing LOCALE_ID to your app. In your app.module.ts for example:

```<code>import { LOCALE_ID } from '@angular/core';

@NgModule({
  declarations: [ ... ],
  imports: [ ... ],
  providers: [
    ...
    { provide: LOCALE_ID, useValue: 'nl-NL' }
  ],
  bootstrap: [ AppComponent ],
})
</code>```

Body:
I have date value from postgres db without timezone. I want this display in angular 2 template with timezone and locale

postgres db value : 2017-11-14 09:40:59.753

I just displayed date in angular template using {{codeset.created_on}} it will be displayed below like :

Tue Nov 14 2017 09:40:59 GMT+0530 (IST)

But I want display current time based on timezone with locale

I tried like below in angular template :

{{codeset.created_on | date :'dd/MM/yyyy h:mm a' :'+530' :'en-US'}}

Body:
You can set it globally by providing LOCALE_ID to your app. In your app.module.ts for example:

import { LOCALE_ID } from '@angular/core';

@NgModule({
  declarations: [ ... ],
  imports: [ ... ],
  providers: [
    ...
    { provide: LOCALE_ID, useValue: 'nl-NL' }
  ],
  bootstrap: [ AppComponent ],
})


问:
How to partition a list in Rebol 2
How does one partition a listin Rebol 2?  I don't care about final order of partitions.

e.g. I imagined there would be a function something like this:

```<code>lst: [1 5 6 5 5 2 1 3]

probe partition lst  ; Assuming identity function by default
[[1 1] [5 5 5] [6] [2] [3]]

probe partition/by lst even?
[[6 2] [1 5 5 5 1 3]]
</code>```

If there is no such inbuilt function, what is the idiomatic way of constructing it in Rebol?

答:
There are some HOFs on rebol.org/scripts/hof,
e.g. a partition function for your second wish</p>

```<code>partition: func [
    {Partition the series 'xs in two parts,
    'success and 'failure - according to the
    outcome of application of the predicate 'p
    to all elements of 'xs.
        ((a -+ logic) -+ [a] -> [[a] [a]]) }
    p [any-function!]
    xs [series!]
    /local us vs result [block!]
][
    us: copy []
    vs: copy []
    foreach k xs [
        either p :k [
            insert/only tail us :k
        ][
            insert/only tail vs :k
        ]
    ]
    result: copy []
    append/only result us
    append/only result vs
    result
]

>> partition func [a] [even? a] lst
== [[6 2] [1 5 5 5 1 3]]
</code>```

Title: How to partition a list in Rebol 2

Body:
How does one partition a listin Rebol 2?  I don't care about final order of partitions.

e.g. I imagined there would be a function something like this:

lst: [1 5 6 5 5 2 1 3]

probe partition lst  ; Assuming identity function by default
[[1 1] [5 5 5] [6] [2] [3]]

probe partition/by lst even?
[[6 2] [1 5 5 5 1 3]]

If there is no such inbuilt function, what is the idiomatic way of constructing it in Rebol?

Body:
There are some HOFs on rebol.org/scripts/hof,
e.g. a partition function for your second wish

partition: func [
    {Partition the series 'xs in two parts,
    'success and 'failure - according to the
    outcome of application of the predicate 'p
    to all elements of 'xs.
        ((a -+ logic) -+ [a] -> [[a] [a]]) }
    p [any-function!]
    xs [series!]
    /local us vs result [block!]
][
    us: copy []
    vs: copy []
    foreach k xs [
        either p :k [
            insert/only tail us :k
        ][
            insert/only tail vs :k
        ]
    ]
    result: copy []
    append/only result us
    append/only result vs
    result
]

>> partition func [a] [even? a] lst
== [[6 2] [1 5 5 5 1 3]]


问:
Download file from URL throws status code 406
Hi guys I have this sub I want to download a file from URL but everytime when I run it WinHttpReq.Status contains 406.

```<code>Sub DownloadFile()
    Dim myURL As String
    myURL = "https://YourWebSite.com/?your_query_parameters"

    Dim WinHttpReq As Object
    Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
    WinHttpReq.Open "GET", myURL, False, "username", "password"
    WinHttpReq.send

    myURL = WinHttpReq.responseBody
    If WinHttpReq.Status = 200 Then
        Set oStream = CreateObject("ADODB.Stream")
        oStream.Open
        oStream.Type = 1
        oStream.Write WinHttpReq.responseBody
        oStream.SaveToFile "C:\file.csv", 2 ' 1 = no overwrite, 2 = overwrite
        oStream.Close
    End If
End Sub
</code>```

答:
The 406 status code means that, although the server understood and processed the request, the response is of a form the client cannot understand. A client sends, as part of a request, headers indicating what types of data it can use, and a 406 error is returned when the response is of a type not in that list.

Eg. If you ask the server to send a GIF picture, but it can only send plain text and PNG pictures you will receive a 406 status code meaning your server understood your question but cannot fulfill it.

So you should include an Accept header specifying which type of media you want your server to send to your client (your VBA), and that type should be a type that your server can actually deliver.

Example how to send headers:

```<code>WinHttpReq.SetRequestHeader "Content-Type", "text/xml;charset=utf-8"
WinHttpReq.SetRequestHeader "Accept", "text/xml"
</code>```

Of course nobody can tell you which media type is the correct because we don't know your server and which type of media it can provide.

Body:
Hi guys I have this sub I want to download a file from URL but everytime when I run it WinHttpReq.Status contains 406.

Sub DownloadFile()
    Dim myURL As String
    myURL = "https://YourWebSite.com/?your_query_parameters"

    Dim WinHttpReq As Object
    Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
    WinHttpReq.Open "GET", myURL, False, "username", "password"
    WinHttpReq.send

    myURL = WinHttpReq.responseBody
    If WinHttpReq.Status = 200 Then
        Set oStream = CreateObject("ADODB.Stream")
        oStream.Open
        oStream.Type = 1
        oStream.Write WinHttpReq.responseBody
        oStream.SaveToFile "C:\file.csv", 2 ' 1 = no overwrite, 2 = overwrite
        oStream.Close
    End If
End Sub

Body:
The 406 status code means that, although the server understood and processed the request, the response is of a form the client cannot understand. A client sends, as part of a request, headers indicating what types of data it can use, and a 406 error is returned when the response is of a type not in that list.

Eg. If you ask the server to send a GIF picture, but it can only send plain text and PNG pictures you will receive a 406 status code meaning your server understood your question but cannot fulfill it.

So you should include an Accept header specifying which type of media you want your server to send to your client (your VBA), and that type should be a type that your server can actually deliver.

Example how to send headers:

WinHttpReq.SetRequestHeader "Content-Type", "text/xml;charset=utf-8"
WinHttpReq.SetRequestHeader "Accept", "text/xml"

Of course nobody can tell you which media type is the correct because we don't know your server and which type of media it can provide.


问:
Regex match string with whitespace if search query has no whitespace
edit to clarify: oneword is a searchquery a user might use. I need to match both oneword, one word or word one with this regex

how to match a string with or without whitespace in any given order?

This is my current query /^(?=.*one)(?=.*word).*$/i
credits: http://www.rubular.com/r/QFEfj9lMn3

So given the text
oneword one word word one and the searchquery /^(?=.*one)(?=.*word).*$/i matches all three, but /^(?=.*oneword).*$/i only matches the first part of the text.

Are there better ways to fix this than by adding one optional character in front of every single letter?

thanks

答:
Try this simple regex generation

function showMatches(sampleInput, searchInput) {
  console.log(sampleInput, searchInput);
  if (sampleInput.length && searchInput.length) {
    var regexStr = searchInput.split(" ").join("\\\s*") + "|" + searchInput.split(" ").reverse().join("\\\s*");
    var regex = new RegExp(regexStr, "gi");
    //console.log(regex);
    console.log(sampleInput.match(regex))
  }
}
showMatches("one word word one oneword", "one word");```

Explanation

Split the input by space to get words.

Join them by \\\s*

Repeat the same for reversed words

Combine both "|"

Note - You may also want to escape special regular expression characters from search inputs using an approach shown here.

Body:
Try this simple regex generation

function showMatches(sampleInput, searchInput) {
  console.log(sampleInput, searchInput);
  if (sampleInput.length && searchInput.length) {
    var regexStr = searchInput.split(" ").join("\\\s*") + "|" + searchInput.split(" ").reverse().join("\\\s*");
    var regex = new RegExp(regexStr, "gi");
    //console.log(regex);
    console.log(sampleInput.match(regex))
  }
}
showMatches("one word word one oneword", "one word");

Explanation

Split the input by space to get words.

Join them by \\\s*

Repeat the same for reversed words

Combine both "|"

Note - You may also want to escape special regular expression characters from search inputs using an approach shown here.


问:
Swift 3 build array (Don't know how to describe)
First of all, sorry for the unclear title, but I don't know how to describe my problem or how to search for it. (Still a beginner)

So I have an array where I need to put values in.

```<code>let heliosDataArray:String = "[{\"timestamp\":\"\(timestamp)\",\"uv\":\"\(uvIndex!)\",\"light\":\"\(lightvalue!)\"}]"
</code>```

So in this "template" I need to add 3 values: timestamp, uvIndex and lightValue. So far so good. Now I have a lot of values and for an API call I need to to chain this array multiple times in to 1 array, kind of like a master array. What is the most practical way of doing this? The amount of data is variable, and comes from CoreData. Probably going to put the values first in arrays. What should I be searching for? I was thinking a loop but like more advanced?

Thanks in advance

答:
You can do this in many ways. One of them is shown below
let say you have three values from coredata timestamp, uvIndex and lightvalue

Seems what you are asking is a array of dictionaries, first you need is a dictionary of the values you got from CoreData, let call them dayItem

```<code>var dayItem = ["timestamp": timestamp,
               "uv": uvIndex,
               "light": lightValue]
</code>```

Now create an array of values

```<code>var dayArray: [[String: Any]] = []
dayArray.append(dayItem)
</code>```

Every time you want to append new items just use the append method of array

Body:
First of all, sorry for the unclear title, but I don't know how to describe my problem or how to search for it. (Still a beginner)

So I have an array where I need to put values in.

let heliosDataArray:String = "[{\"timestamp\":\"\(timestamp)\",\"uv\":\"\(uvIndex!)\",\"light\":\"\(lightvalue!)\"}]"

So in this "template" I need to add 3 values: timestamp, uvIndex and lightValue. So far so good. Now I have a lot of values and for an API call I need to to chain this array multiple times in to 1 array, kind of like a master array. What is the most practical way of doing this? The amount of data is variable, and comes from CoreData. Probably going to put the values first in arrays. What should I be searching for? I was thinking a loop but like more advanced?

Thanks in advance

Body:
You can do this in many ways. One of them is shown below
let say you have three values from coredata timestamp, uvIndex and lightvalue

Seems what you are asking is a array of dictionaries, first you need is a dictionary of the values you got from CoreData, let call them dayItem

var dayItem = ["timestamp": timestamp,
               "uv": uvIndex,
               "light": lightValue]

Now create an array of values

var dayArray: [[String: Any]] = []
dayArray.append(dayItem)

Every time you want to append new items just use the append method of array


问:
Linking one field of a model to another by queryset
I have a session variable that stores the ID of a model. I would now like to filter query sets by the name of the model instead of the id. Currently it only filter by the ID that it compares to the name. How can I get it to use the name instead of ID.

Template link

```<code><td><a class="btn btn-info" href="{% url 'nodisoapp:select' company.id  %}">Working Page</a></td>
</code>```

Urls

```<code>url(r'^select/(?P<company_id>\d+)/$', views.comp_select, name='select'),
</code>```

view1

```<code>def comp_select(request, company_id):
    request.session['company'] = company_id
    return redirect('nodisoapp:working',company_id)
</code>```

Filter View

```<code>class LeadListView(LoginRequiredMixin, generic.ListView):
     login_url = '/scrty/login/'
        template_name = "nodiso/leadslist.html"
        model = models.Leads
        def get_context_data(self, **kwargs):
            ctx = super(LeadListView, self).get_context_data(**kwargs)
            ctx['company']= models.Company.objects.all()
            return ctx
        def get_queryset(self):
            return models.Leads.objects.filter(company=self.request.session['company'])
</code>```

Parent Model

```<code>class Company(models.Model):
    user = models.ManyToManyField(settings.AUTH_USER_MODEL)
    name = models.CharField(max_length=265, blank=True)
    tel = models.IntegerField(blank=True, null=True)
    email = models.EmailField(max_length=265,blank=True)
    address = models.TextField(blank=True)
    postal = models.TextField(blank=True)
    regno = models.CharField(max_length=265,blank=True)
    vatno = models.CharField(max_length=265,blank=True)

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('nodisoapp:home')
</code>```

Child Model

```<code>class Leads(models.Model):
    company = models.ForeignKey(Company)
    user = models.ManyToManyField(settings.AUTH_USER_MODEL)
    name = models.CharField(max_length=265)
    email = models.EmailField(max_length=265)
    tel = models.IntegerField()
    dateenq = models.DateField(blank=True,null=True)

    def get_absolute_url(self):
        return reverse('nodisoapp:leadlist')

    def __str__(self):
        return self.name
</code>```

答:
I found the solution</p>

```<code>def comp_select(request, company_id):
    comp = models.Company.objects.get(id=company_id)
    request.session['company'] = comp.name
    request.session['compid'] = company_id
    return redirect('nodisoapp:working',company_id)
</code>```

Body:
I have a session variable that stores the ID of a model. I would now like to filter query sets by the name of the model instead of the id. Currently it only filter by the ID that it compares to the name. How can I get it to use the name instead of ID.

Template link

Working Page

Urls

url(r'^select/(?P<company_id>\d+)/$', views.comp_select, name='select'),

view1

def comp_select(request, company_id):
    request.session['company'] = company_id
    return redirect('nodisoapp:working',company_id)

Filter View

class LeadListView(LoginRequiredMixin, generic.ListView):
     login_url = '/scrty/login/'
        template_name = "nodiso/leadslist.html"
        model = models.Leads
        def get_context_data(self, **kwargs):
            ctx = super(LeadListView, self).get_context_data(**kwargs)
            ctx['company']= models.Company.objects.all()
            return ctx
        def get_queryset(self):
            return models.Leads.objects.filter(company=self.request.session['company'])

Parent Model

class Company(models.Model):
    user = models.ManyToManyField(settings.AUTH_USER_MODEL)
    name = models.CharField(max_length=265, blank=True)
    tel = models.IntegerField(blank=True, null=True)
    email = models.EmailField(max_length=265,blank=True)
    address = models.TextField(blank=True)
    postal = models.TextField(blank=True)
    regno = models.CharField(max_length=265,blank=True)
    vatno = models.CharField(max_length=265,blank=True)

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('nodisoapp:home')

Child Model

class Leads(models.Model):
    company = models.ForeignKey(Company)
    user = models.ManyToManyField(settings.AUTH_USER_MODEL)
    name = models.CharField(max_length=265)
    email = models.EmailField(max_length=265)
    tel = models.IntegerField()
    dateenq = models.DateField(blank=True,null=True)

    def get_absolute_url(self):
        return reverse('nodisoapp:leadlist')

    def __str__(self):
        return self.name

Body:
I found the solution

def comp_select(request, company_id):
    comp = models.Company.objects.get(id=company_id)
    request.session['company'] = comp.name
    request.session['compid'] = company_id
    return redirect('nodisoapp:working',company_id)


问:
Mocha change timeout for afterEach
I am writing a node application with mocha and chai. Some of the tests call an external API for integration tests, which might take up to 90sec to perform the action.

In order to cleanup properly, I defined an afterEach()-block, which will delete any generated remote resources, in case an expect fails and some resources weren't deleted.

The tests themselves have an increased timeout, while the rest of the tests should retain their default and small timeout:

```<code>it('should create remote resource', () => {...}).timeout(120000)
</code>```

However, I can't do the same with afterEach().timeout(120000), because the function does not exist - nor can I use the function ()-notation due to the unknown resource names:

```<code>describe('Resources', function () {
  beforeEach(() => {
    this._resources = null
  })

  it('should create resources', async () => {
    this._resources = await createResources()
    expect(false).to.equal(true)   // fail test, so...
    await deleteResources()        // will never be called
  })

  afterEach(async() => {
    this._resources.map(entry => {
      await // ... delete any created resources ...
    })
  }).timeout(120000)
})
</code>```

Any hints? Mocha is version 4.0.1, chai is 4.1.2

答:
The rules are same for all Mocha blocks.

timeout can be set for arrow functions in Mocha 1.x with:

```<code>  afterEach((done) => {
    // ...
    done();
  }).timeout(120000);
</code>```

And for 2.x and higher it, beforeEach, etc. blocks are expected to be regular functions in order to reach spec context. If suite context (describe this) should be reached, it can be assigned to another variable:

```<code>describe('...', function () {
  const suite = this;

  before(function () {
    // common suite timeout that doesn't really need to be placed inside before block
    suite.timeout(60000);
  });
  ...
  afterEach(function (done) {
    this.timeout(120000);
    // ...
    done();
  });
});
</code>```

Mocha contexts are expected to be used like that, since spec context is useful, and there are virtually no good reasons to access suite context inside specs.

And done parameter or promise return are necessary for asynchronous blocks.

Title: Mocha change timeout for afterEach

Body:
I am writing a node application with mocha and chai. Some of the tests call an external API for integration tests, which might take up to 90sec to perform the action.

In order to cleanup properly, I defined an afterEach()-block, which will delete any generated remote resources, in case an expect fails and some resources weren't deleted.

The tests themselves have an increased timeout, while the rest of the tests should retain their default and small timeout:

it('should create remote resource', () => {...}).timeout(120000)

However, I can't do the same with afterEach().timeout(120000), because the function does not exist - nor can I use the function ()-notation due to the unknown resource names:

describe('Resources', function () {
  beforeEach(() => {
    this._resources = null
  })

  it('should create resources', async () => {
    this._resources = await createResources()
    expect(false).to.equal(true)   // fail test, so...
    await deleteResources()        // will never be called
  })

  afterEach(async() => {
    this._resources.map(entry => {
      await // ... delete any created resources ...
    })
  }).timeout(120000)
})

Any hints? Mocha is version 4.0.1, chai is 4.1.2

Body:
The rules are same for all Mocha blocks.

timeout can be set for arrow functions in Mocha 1.x with:

  afterEach((done) => {
    // ...
    done();
  }).timeout(120000);

And for 2.x and higher it, beforeEach, etc. blocks are expected to be regular functions in order to reach spec context. If suite context (describe this) should be reached, it can be assigned to another variable:

describe('...', function () {
  const suite = this;

  before(function () {
    // common suite timeout that doesn't really need to be placed inside before block
    suite.timeout(60000);
  });
  ...
  afterEach(function (done) {
    this.timeout(120000);
    // ...
    done();
  });
});

Mocha contexts are expected to be used like that, since spec context is useful, and there are virtually no good reasons to access suite context inside specs.

And done parameter or promise return are necessary for asynchronous blocks.


问:
Typo3 get parameters from link-wizard
I have a link-wizard in my fluid template to let the user select a page or an external link in the T3-tree.

```<code><flux:field.input name="myLink" label="Select-Link">
    <flux:wizard.link/>
</flux:field.input>
</code>```

This ends up in a DB-entry that looks like this:

```<code>http://example.com _blank link-class link-title
</code>```

How do I extract the target, class and link-title using a view-helper (or any other means)?

I tried using {myLink.parameter.extTarget} or {myLink.extTarget} - nothing works.

Is there a way to get these variables?

答:
I suppose this refers to to some Frontend input/output.

First, i would do some <f:debug inline="1">mylink</f:debug>to see if any output is available at all.

In General, If you want to access your DB values in Fluid, you need an Extension which provides you with the corresponding Doman/Model and Domain/Repository

You will end up with something like this:

```<code><?php
linkspace MyVendor\MyExt\Domain\Model;

class Whatever {

    /**
    * @var string The link of whatever
    */
    protected $link;

    public function setLink($link) {
        $this->link = $link;
    }

    public function getLink() {
        return $this->link;
    }
}
</code>```

When your ext is working, you should be able to access your values via fluid with no viewhelper at all.

Have a look at https://docs.typo3.org/typo3cms/ExtbaseFluidBook/5-Domain/2-implementing-the-domain-model.html - this will provide you with the some information on this topic.

Title: Typo3 get parameters from link-wizard

Body:
I have a link-wizard in my fluid template to let the user select a page or an external link in the T3-tree.

<flux:field.input name="myLink" label="Select-Link">
    <flux:wizard.link/>
</flux:field.input>

This ends up in a DB-entry that looks like this:

http://example.com _blank link-class link-title

How do I extract the target, class and link-title using a view-helper (or any other means)?

I tried using {myLink.parameter.extTarget} or {myLink.extTarget} - nothing works.

Is there a way to get these variables?

Body:
I suppose this refers to to some Frontend input/output.

First, i would do some <f:debug inline="1">mylink</f:debug>to see if any output is available at all.

In General, If you want to access your DB values in Fluid, you need an Extension which provides you with the corresponding Doman/Model and Domain/Repository

You will end up with something like this:

<?php
linkspace MyVendor\MyExt\Domain\Model;

class Whatever {

    /**
    * @var string The link of whatever
    */
    protected $link;

    public function setLink($link) {
        $this->link = $link;
    }

    public function getLink() {
        return $this->link;
    }
}

When your ext is working, you should be able to access your values via fluid with no viewhelper at all.

Have a look at https://docs.typo3.org/typo3cms/ExtbaseFluidBook/5-Domain/2-implementing-the-domain-model.html - this will provide you with the some information on this topic.


问:
Assign a value to an array in Java?
I'm currently working on a text editor. I have an entire GUI working, and now I'm trying to add usability to it.

For some reason, when I try to create an array called symbols, NetBeans is fine with it -- when I try to assign a value to the array, NetBeans won't compile my program, and will instead give an error and suggest it make a new class for the array.

Example code:

```<code>String[] symbols = new String[42]; symbols[0] = "∑"; // Error line!
</code>```

Here's an image: http://img401.imageshack.us/img401/4844/examplegx.png

Does anyone know the solution to fix this or has this happened to you? If I need to provide more detail, let me know.

答:
You're trying to put an arbitrary statement directly in your class declaration, instead of in a method, constructor or initializer block. You can't do that.

Some options:

Do it in the constructor:

```<code>public GUI()
{
    symbols[0] = "∑";
}
</code>```

Do it in an initializer block:

```<code>String[] symbols = new String[42];
{
    symbols[0] = "∑";
}
</code>```

Do it in a method called by the initializer:

```<code>String[] symbols = getDefaultSymbols();

private static String[] getDefaultSymbols()
{
    String[] ret = new String[42];
    ret[0] = "∑";
    return ret;
}
</code>```

Use an array initializer:

```<code>String[] symbols = { "∑", null, null, null, ... };
</code>```

Note that your question is phrased as if Netbeans were to blame. It's not Netbeans - it's the Java language rules. Your code wouldn't be valid under Eclipse, javac, IntelliJ etc.

Title: Assign a value to an array in Java?

Body:
I'm currently working on a text editor. I have an entire GUI working, and now I'm trying to add usability to it.

For some reason, when I try to create an array called symbols, NetBeans is fine with it -- when I try to assign a value to the array, NetBeans won't compile my program, and will instead give an error and suggest it make a new class for the array.

Example code:

String[] symbols = new String[42]; symbols[0] = "∑"; // Error line!

Here's an image: http://img401.imageshack.us/img401/4844/examplegx.png

Does anyone know the solution to fix this or has this happened to you? If I need to provide more detail, let me know.

Body:
You're trying to put an arbitrary statement directly in your class declaration, instead of in a method, constructor or initializer block. You can't do that.

Some options:

Do it in the constructor:

public GUI()
{
    symbols[0] = "∑";
}

Do it in an initializer block:

String[] symbols = new String[42];
{
    symbols[0] = "∑";
}

Do it in a method called by the initializer:

String[] symbols = getDefaultSymbols();

private static String[] getDefaultSymbols()
{
    String[] ret = new String[42];
    ret[0] = "∑";
    return ret;
}

Use an array initializer:

String[] symbols = { "∑", null, null, null, ... };

Note that your question is phrased as if Netbeans were to blame. It's not Netbeans - it's the Java language rules. Your code wouldn't be valid under Eclipse, javac, IntelliJ etc.


问:
How do I a retrieve specific value from JSON output in Python 2.7?
I have a Python 2.7 script that looks like this:

```<code>import requests

    url = "https://example.net/rest/v1/m/4513452615415"

    querystring = {"client":"wzas"}

    payload = "{\r\n              \"sss\" : \""+msse+"\",\r\n\"VisitorId\":\""+mcid+"\",\r\n              \"thirdPartyId\": \""+tracking_id+"\",\r\n              \"contentAsJson\": \"true\",\r\n                             \"mbssParameters\": \r\n                             {        \r\n                             \"mboxMCGLH\": \"6\"     \r\n                             }\r\n}\r\n"
    headers = {
        'content-type': "application/json",
        'cache-control': "no-cache",
        'postman-token': "289f645d-1543-e6df-87fb-1cef88f110c5"
        }

    response = requests.request("POST", url, data=payload, headers=headers, params=querystring)

    return (response.text)
</code>```

The output is sent to a CSV file and looks like this:

```<code>{"thirdPartyId":"559yZDIIs3XvFpLPhvjexK7/jYlT7ZwJXBpNc/ZS4A1saWdodG5pbmdzZWVkcw==","marketingId":"89137879111811717593914206190290951066814","edgeHost":"mrdge21.example.net","content":{"tnsVal":"931113:4:0","contentName":"examplecontent","revenue":14},"sessionId":"4513452615415"}
</code>```

How would I only output the contentName and tnsVal ?

Thanks in advance
Nick

答:
Since it's pretty clear you're getting a JSON back, try the following line:</p>

```<code>import json
response_json = json.loads(response.text)
print(response_json['content']['contentName'], response_json['content']['tnsVal'])
</code>```

Body:
I have a Python 2.7 script that looks like this:

import requests

    url = "https://example.net/rest/v1/m/4513452615415"

    querystring = {"client":"wzas"}

    payload = "{\r\n              \"sss\" : \""+msse+"\",\r\n\"VisitorId\":\""+mcid+"\",\r\n              \"thirdPartyId\": \""+tracking_id+"\",\r\n              \"contentAsJson\": \"true\",\r\n                             \"mbssParameters\": \r\n                             {        \r\n                             \"mboxMCGLH\": \"6\"     \r\n                             }\r\n}\r\n"
    headers = {
        'content-type': "application/json",
        'cache-control': "no-cache",
        'postman-token': "289f645d-1543-e6df-87fb-1cef88f110c5"
        }

    response = requests.request("POST", url, data=payload, headers=headers, params=querystring)

    return (response.text)

The output is sent to a CSV file and looks like this:

{"thirdPartyId":"559yZDIIs3XvFpLPhvjexK7/jYlT7ZwJXBpNc/ZS4A1saWdodG5pbmdzZWVkcw==","marketingId":"89137879111811717593914206190290951066814","edgeHost":"mrdge21.example.net","content":{"tnsVal":"931113:4:0","contentName":"examplecontent","revenue":14},"sessionId":"4513452615415"}

How would I only output the contentName and tnsVal ?

Thanks in advance
Nick

Body:
Since it's pretty clear you're getting a JSON back, try the following line:

import json
response_json = json.loads(response.text)
print(response_json['content']['contentName'], response_json['content']['tnsVal'])


问:
How to automatically reconnect a DataSource connection in Spring?
Problem: when my spring application is running, and meanwhile the database server is stopped/restarted, then then db connection is lost and never restored.

I tested as follows:

execute query: OK

service mysql stop

execute query: exception:

Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.

service mysql start

execute query: still exception!

Question: how can I tell spring DataSource to automatically reconnect after connection has been lost?

This is my configuration:

```<code>spring.datasource.url=jdbc:mysql://localhost/tablename?useSSL=false
spring.datasource.username=root
spring.datasource.password=rootpw
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.tomcat.validation-query=SELECT 1
spring.datasource.tomcat.validation-query-timeout=5000
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.test-on-connect=true
</code>```

答: My bad, I had a misconfiguration. The config above is all that's needed for auto reconnect.</p>

Body:
Problem: when my spring application is running, and meanwhile the database server is stopped/restarted, then then db connection is lost and never restored.

I tested as follows:

execute query: OK

service mysql stop

execute query: exception:

Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.

service mysql start

execute query: still exception!

Question: how can I tell spring DataSource to automatically reconnect after connection has been lost?

This is my configuration:

spring.datasource.url=jdbc:mysql://localhost/tablename?useSSL=false
spring.datasource.username=root
spring.datasource.password=rootpw
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.tomcat.validation-query=SELECT 1
spring.datasource.tomcat.validation-query-timeout=5000
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.test-on-connect=true


问:
Wicket one form with two submit buttons with the same validation
I use wicket 7.x. I have a form with two submit buttons. The two button do different things on submit event but they have the same field validation. I override the AjaxButton onSubmit in one of them to separate the different behavior but i couldn't pass into the same validation method.

```<code>button = new AjaxButton("id",this.getRootForm()) {
    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form){...}
}
button.setDefaultFormProcessing(false);

@Override
protected void onValidate() {...}

@Override
protected void onSubmit() {...}
</code>```

How could i pass through the same validation method with alle the forms?

Edited Answer

```<code>this.getRootForm().add(new IFormValidator() {

     @Override
     public void validate(Form<?> form) {
           doValidate(form);
     }
     @Override
     public FormComponent<?>[] getDependentFormComponents() {
         FormComponent<?>[] c = new FormComponent<?>[6];
         c[0] = nome;
         c[1] = email;
         c[2] = cognome;
         c[3] = indirizzo;
         c[4] = telefono;
         c[5] = captcha;
         return c;
      }
});

protected void doValidate(Form<?> form) {...}

button = new AjaxButton("id",this.getRootForm()) {
    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form){
        doValidate(form);
        if (!form.hasError()) {
            ...
        } else{
            target.add(feedbackPanel);
        }
    }
}
button.setDefaultFormProcessing(false);
</code>```

答:
You can add own IFormValidator to form and recall your code.

make your own validate method.

```<code>void doValidate(Form<?> form) {
   your validation code here for form.
}

this.getRootForm().add(new IFormValidator() {

    void validate(Form<?> form) {
        doValidate(form);
    }
});

@Override
protected void onValidate() {
   doValidate(this);
}
</code>```

Body:
I use wicket 7.x. I have a form with two submit buttons. The two button do different things on submit event but they have the same field validation. I override the AjaxButton onSubmit in one of them to separate the different behavior but i couldn't pass into the same validation method.

button = new AjaxButton("id",this.getRootForm()) {
    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form){...}
}
button.setDefaultFormProcessing(false);

@Override
protected void onValidate() {...}

@Override
protected void onSubmit() {...}

How could i pass through the same validation method with alle the forms?

Edited Answer

this.getRootForm().add(new IFormValidator() {

     @Override
     public void validate(Form<?> form) {
           doValidate(form);
     }
     @Override
     public FormComponent<?>[] getDependentFormComponents() {
         FormComponent<?>[] c = new FormComponent<?>[6];
         c[0] = nome;
         c[1] = email;
         c[2] = cognome;
         c[3] = indirizzo;
         c[4] = telefono;
         c[5] = captcha;
         return c;
      }
});

protected void doValidate(Form<?> form) {...}

button = new AjaxButton("id",this.getRootForm()) {
    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form){
        doValidate(form);
        if (!form.hasError()) {
            ...
        } else{
            target.add(feedbackPanel);
        }
    }
}
button.setDefaultFormProcessing(false);

Body:
You can add own IFormValidator to form and recall your code.

make your own validate method.

void doValidate(Form<?> form) {
   your validation code here for form.
}

this.getRootForm().add(new IFormValidator() {

    void validate(Form<?> form) {
        doValidate(form);
    }
});

@Override
protected void onValidate() {
   doValidate(this);
}


答:
You cannot place code outside a method or initializer block. What you can do is;

```<code>String[] symbols = new String[42]; { symbols[0] = "∑"; }
</code>```

You can also define your symbols this way

```<code>String[] symbols = "∑,+,-,/,*,^".split(",");
</code>```

Title: Assign a value to an array in Java?

Body:
You cannot place code outside a method or initializer block. What you can do is;

String[] symbols = new String[42]; { symbols[0] = "∑"; }

You can also define your symbols this way

String[] symbols = "∑,+,-,/,*,^".split(",");


问:
Remove duplicates in array separated by double commas in JavaScript
I have an array in JavaScript like this

```<code>var data = [,A_1_VII,VII,V2,,A_1_VII,VII,V2,,A_1_VII,VII,V2,,B_1_XIV,XIV,V3,,B_2_XVI,XVI,V3]
</code>```

when I alert in JavaScript it gives as below

,A_1_VII,VII,V2

,A_1_VII,VII,V2

,A_1_VII,VII,V2

,B_1_XIV,XIV,V3

,B_2_XVI,XVI,V3

But I want like this which is duplicates removed array

```<code>var unique_data = [,A_1_VII,VII,V2,,B_1_XIV,XIV,V3,,B_2_XVI,XVI,V3]
</code>```

On alert it should give like this

,A_1_VII,VII,V2

,B_1_XIV,XIV,V3

,B_2_XVI,XVI,V3

答:
You can create your unique function to remove duplicate entry and empty value from array like this.

var data =[,"A_1_VII,VII","V2,,A_1_VII","VII","V2",,"A_1_VII","VII","V2",,"B_1_XIV,XIV","V3",,"B_2_XVI,XVI,V3"]
var unique_data = uniqueList(data);
alert(unique_data);
function uniqueList(list) {
  var uniqueResult = [];
  $.each(list, function(i, e) {
    if ($.inArray(e, uniqueResult) == -1 &&$.inArray(e, uniqueResult)!="")// chech for unique value and empty value
      uniqueResult.push(e);
  });
  return uniqueResult ;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script></code>```

Body:
I have an array in JavaScript like this

var data = [,A_1_VII,VII,V2,,A_1_VII,VII,V2,,A_1_VII,VII,V2,,B_1_XIV,XIV,V3,,B_2_XVI,XVI,V3]

when I alert in JavaScript it gives as below

,A_1_VII,VII,V2

,A_1_VII,VII,V2

,A_1_VII,VII,V2

,B_1_XIV,XIV,V3

,B_2_XVI,XVI,V3

But I want like this which is duplicates removed array

var unique_data = [,A_1_VII,VII,V2,,B_1_XIV,XIV,V3,,B_2_XVI,XVI,V3]

On alert it should give like this

,A_1_VII,VII,V2

,B_1_XIV,XIV,V3

,B_2_XVI,XVI,V3

Body:
You can create your unique function to remove duplicate entry and empty value from array like this.

var data =[,"A_1_VII,VII","V2,,A_1_VII","VII","V2",,"A_1_VII","VII","V2",,"B_1_XIV,XIV","V3",,"B_2_XVI,XVI,V3"]
var unique_data = uniqueList(data);
alert(unique_data);
function uniqueList(list) {
  var uniqueResult = [];
  $.each(list, function(i, e) {
    if ($.inArray(e, uniqueResult) == -1 &&$.inArray(e, uniqueResult)!="")// chech for unique value and empty value
      uniqueResult.push(e);
  });
  return uniqueResult ;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


问:
How to build Xcode project from the command line?
I've tried reading the Xcode Tools documentation Apple provides, so that I can use the Terminal to build a .app file and run the resulting app on the Simulator. Essentially what I want to do is do the same thing as Cmd + R does on Xcode.

So far I've attempted to build my .xcodeproj like this:

```<code>xcodebuild -configuration Debug build
</code>```

However, when I install & run it on the Simulator I get an app w/ a black screen:

```<code>// Boot device
xcrun simctl boot "iPhone 7"
// Install app
xcrun simctl install "iPhone 7" "/Users/.../MyApp/build/Debug-iphoneos/MyApp.app"
// Open simulator
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
// Launch app using its bundle id
xcrun simctl launch booted "com.example.apps.MyApp"
</code>```

Not to mention the xcrun simctl launch booted "com.example.apps.MyApp" line never terminates and on the Simulator it keeps trying to open and reopen the app, but the app only ever shows a black screen.

If anyone could tell me what I'm doing wrong with the building of the.xcodeproj that would be great!

答:
After having a working configuration in Xcode, open a shell and navigate to the directory, where your <NAME>.xcodeproj resides.

After running:

```<code>xcodebuild -list -project <NAME>.xcodeproj/
</code>```

you see a list of Schemes.

Copy the desired scheme name and run:

```<code>xcodebuild -workspace <WORKSPACE NAME> -scheme <SCHEME NAME> build
</code>```

You can install [ios-deploy][1] i.e. via:

```<code>npm install -g ios-deploy
</code>```

Copy the app path from the end of the xcodebuild output and run:

```<code>ios-deploy --debug --bundle <APP PATH>
</code>```

Now the app should be launched on i.e. a connected device.
[1]: https://github.com/phonegap/ios-deploy

Body:
I've tried reading the Xcode Tools documentation Apple provides, so that I can use the Terminal to build a .app file and run the resulting app on the Simulator. Essentially what I want to do is do the same thing as Cmd + R does on Xcode.

So far I've attempted to build my .xcodeproj like this:

xcodebuild -configuration Debug build

However, when I install & run it on the Simulator I get an app w/ a black screen:

// Boot device
xcrun simctl boot "iPhone 7"
// Install app
xcrun simctl install "iPhone 7" "/Users/.../MyApp/build/Debug-iphoneos/MyApp.app"
// Open simulator
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
// Launch app using its bundle id
xcrun simctl launch booted "com.example.apps.MyApp"

Not to mention the xcrun simctl launch booted "com.example.apps.MyApp" line never terminates and on the Simulator it keeps trying to open and reopen the app, but the app only ever shows a black screen.

If anyone could tell me what I'm doing wrong with the building of the.xcodeproj that would be great!

Body:
After having a working configuration in Xcode, open a shell and navigate to the directory, where your <NAME>.xcodeproj resides.

After running:

xcodebuild -list -project <NAME>.xcodeproj/

you see a list of Schemes.

Copy the desired scheme name and run:

xcodebuild -workspace <WORKSPACE NAME> -scheme <SCHEME NAME> build

You can install [ios-deploy][1] i.e. via:

npm install -g ios-deploy

Copy the app path from the end of the xcodebuild output and run:

ios-deploy --debug --bundle <APP PATH>

Now the app should be launched on i.e. a connected device.
[1]: https://github.com/phonegap/ios-deploy


问:
Angular 2 - Check if image url is valid or broken
I am fetching a large number of image URLs from an API and display them in a angular 2 web application. Some of the URLs are broken and i want to replace them with a default picture that is stored locally on my webserver. Does anyone have a suggestion how to test the urls and in the case of status code 404 replace the broken image?

Thanks!

答:
My example on angular 4

```<code><img [src]="img" (error)="img.src = errorImg" #img>
</code>```

Where img - path to image;

error - error emmit

errorImg - path to default img

#img - link to img object

Body:
My example on angular 4

<img [src]="img" (error)="img.src = errorImg" #img>

Where img - path to image;

error - error emmit

errorImg - path to default img

#img - link to img object


问:
In PHP & MySQL Display date in day month Year Format from database
I've insert some dates in database & select these dates from the database using PHP & MySQL Code and display these dates in month wise format. Am using the following code:-

I Got the result like:-

```<code>2017-01-16 January
2017-01-26 January
2017-01-27 January
2017-02-02 February
2017-03-21 March
2017-03-22 March
</code>```

I want to display month dates in that format:-

```<code> January
    2017-01-16
    2017-01-26
    2017-01-27
February
    2017-02-02
March
    2017-03-21
    2017-03-22
</code>```

Please help.

答:
```<code>$mo1 = "";
$qry = "SELECT DISTINCT ac_date FROM calender";
$exe = mysql_query($qry);
while ($row = mysql_fetch_array($exe)) {
     $ac_date = $row['ac_date'];
     $dateElements = explode('/', $ac_date);
     switch ($dateElements[0]){

        case '01'    :  $mo = "January"; break;
        case '02'    :  $mo = "February"; break;
        case '03'    :  $mo = "March"; break;
        case '04'    :  $mo = "April"; break;
        case '05'    :  $mo = "May"; break;
        case '06'    :  $mo = "June"; break;
        case '07'    :  $mo = "July"; break;
        case '08'    :  $mo = "August"; break;
        case '09'    :  $mo = "September"; break;
        case '10'    :  $mo = "October"; break;
        case '11'    :  $mo = "November"; break;
        case '12'    :  $mo = "December"; break;
     }
     if ($mo1 != $mo) {
          $activity.="<tr>
                      <td>$mo</td>
                      </tr>";
     }
     $activity.="<tr>
                 <td>$ac_date </td>
                 </tr>";
     $mo1=$mo;
}
</code>```

Body:
I've insert some dates in database & select these dates from the database using PHP & MySQL Code and display these dates in month wise format. Am using the following code:-

I Got the result like:-

2017-01-16 January
2017-01-26 January
2017-01-27 January
2017-02-02 February
2017-03-21 March
2017-03-22 March

I want to display month dates in that format:-

 January
    2017-01-16
    2017-01-26
    2017-01-27
February
    2017-02-02
March
    2017-03-21
    2017-03-22

Please help.


问:
Plot line of average values in the current view port for high stock
I am wanting to implement something that is very similar to the following chart

http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/stock/demo/yaxis-plotlines/

```<code>Sorry I do not have any code
</code>```

But I would like to create a plot line that moves with the current view port of data. So as you drag or resize the view in Highstock I would like to see an average (a single line) for the entire view port.

I have not seen any samples that do this. Can anyone point me to something like this?

答:
When navigator moves the extremes on x axis change. You can catch this event using this code:

```<code>yAxis: {
    events: {
    afterSetExtremes: function() {
        console.log(this.series[0].points);
    }
  }
}
</code>```

points array contains all the points visible in view port - use them to compute the value for your plot line. Then update the chart like this (in afterSetExtremes event):

```<code>this.xAxis[0].update({plotLines: [{
 // new value here
}]});
</code>```

API references:

https://api.highcharts.com/highstock/xAxis.events.afterSetExtremes

https://api.highcharts.com/class-reference/Highcharts.Axis#update

Body:
I am wanting to implement something that is very similar to the following chart

http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/stock/demo/yaxis-plotlines/

Sorry I do not have any code

But I would like to create a plot line that moves with the current view port of data. So as you drag or resize the view in Highstock I would like to see an average (a single line) for the entire view port.

I have not seen any samples that do this. Can anyone point me to something like this?

Body:
When navigator moves the extremes on x axis change. You can catch this event using this code:

yAxis: {
    events: {
    afterSetExtremes: function() {
        console.log(this.series[0].points);
    }
  }
}

points array contains all the points visible in view port - use them to compute the value for your plot line. Then update the chart like this (in afterSetExtremes event):

this.xAxis[0].update({plotLines: [{
 // new value here
}]});

API references:

https://api.highcharts.com/highstock/xAxis.events.afterSetExtremes

https://api.highcharts.com/class-reference/Highcharts.Axis#update


问:
How do I write and read data in txt file in the form of rows and columns?
How do I write and read data in txt file in the form of rows and columns?  Also, how do I store many files like this in a folder for a particular name? The idea is just like a Table for a particular person who has many rows and columns.</p>

答:
In addition to Jeremy's post

Use opencsv to create the csv file

Use CsvJdbc to use JDBC to query against those files. This makes the future transition to DB in future and you will be working with a known API for searching against the file


答:
You can try:</p>

```<code>>>> import json
>>> data = json.loads(response.text)
>>> data["content"]["tnsVal"]
'931113:4:0'
>>> data["content"]["contentName"]
'examplecontent'
</code>```

Title: How do I a retrieve specific value from JSON output in Python 2.7?

Body:
You can try:

>>> import json
>>> data = json.loads(response.text)
>>> data["content"]["tnsVal"]
'931113:4:0'
>>> data["content"]["contentName"]
'examplecontent'


问:
How to remove the single quotation mark from a list in Python
I am trying to remove the single quotation marks from this list:

```<code>list = ['amazed, 10']
</code>```

and convert it to

```<code>list = ['amazed', 10]
</code>```

I used list= [x.strip('') for x in list] but it does not work.

Is there a workaround?

Thanks in advance!

答:
First you need to split your list to two elements. Next, strip white space and than convert the second element (a string of number) to number (Iv'e converted it to integer but you can convert to float or whatever). </p>

```<code>ll = ['amazed, 10']
ll = ll[0].split(",")
ll[1] = int(ll[1].strip())
</code>```

Body:
I am trying to remove the single quotation marks from this list:

list = ['amazed, 10']

and convert it to

list = ['amazed', 10]

I used list= [x.strip('') for x in list] but it does not work.

Is there a workaround?

Thanks in advance!

Body:
First you need to split your list to two elements. Next, strip white space and than convert the second element (a string of number) to number (Iv'e converted it to integer but you can convert to float or whatever).

ll = ['amazed, 10']
ll = ll[0].split(",")
ll[1] = int(ll[1].strip())


答:
You can approach with object-oriented logic: </p>

```<code>struct Data {

    var timestamp: Double?
    var lightValue: Double?
    var uvIndex: Int?
}

let data1 = Data(timestamp: 13.4, lightValue: 3.4, uvIndex: 4)
let data2 = Data(timestamp: 12.4, lightValue: 2.4, uvIndex: 3)
let data3 = Data(timestamp: 11.4, lightValue: 1.4, uvIndex: 2)

var dataArray = Array<Data>() // or-> var data = [Data]()

dataArray.append(data1)
dataArray.append(data2)
dataArray.append(data3)
</code>```

Title: Swift 3 build array (Don't know how to describe)

Body:
First of all, sorry for the unclear title, but I don't know how to describe my problem or how to search for it. (Still a beginner)

So I have an array where I need to put values in.

let heliosDataArray:String = "[{\"timestamp\":\"\(timestamp)\",\"uv\":\"\(uvIndex!)\",\"light\":\"\(lightvalue!)\"}]"

So in this "template" I need to add 3 values: timestamp, uvIndex and lightValue. So far so good. Now I have a lot of values and for an API call I need to to chain this array multiple times in to 1 array, kind of like a master array. What is the most practical way of doing this? The amount of data is variable, and comes from CoreData. Probably going to put the values first in arrays. What should I be searching for? I was thinking a loop but like more advanced?

Thanks in advance

Body:
You can approach with object-oriented logic:

struct Data {

    var timestamp: Double?
    var lightValue: Double?
    var uvIndex: Int?
}

let data1 = Data(timestamp: 13.4, lightValue: 3.4, uvIndex: 4)
let data2 = Data(timestamp: 12.4, lightValue: 2.4, uvIndex: 3)
let data3 = Data(timestamp: 11.4, lightValue: 1.4, uvIndex: 2)

var dataArray = Array<Data>() // or-> var data = [Data]()

dataArray.append(data1)
dataArray.append(data2)
dataArray.append(data3)


问:
MySQL how to do an if exist increment in a single query
I just wish to have a table to store a number of events by day.

Given a table:

```<code>create table totals (
    entryday date,
    total int(11) default 0 not null,
    primary key (entryday) );
</code>```

How can I write a simple query which increments, but creates an necessary?

I tried this - but it is not incrementing (it remains at 1):

```<code>REPLACE totals SET total = total + 1, entryday = "08-01-11"
</code>```

Obviously this could be done in 2 queries quite simply, but it's through JDBC calls and may be called many times, so 1 query would be better.

答:
I'm not sure I understand your question, but maybe this query is your answer :</p>

```<code>update totals set total = total + 1 where entryday = "08-01-11"
</code>```

Body:
I just wish to have a table to store a number of events by day.

Given a table:

create table totals (
    entryday date,
    total int(11) default 0 not null,
    primary key (entryday) );

How can I write a simple query which increments, but creates an necessary?

I tried this - but it is not incrementing (it remains at 1):

REPLACE totals SET total = total + 1, entryday = "08-01-11"

Obviously this could be done in 2 queries quite simply, but it's through JDBC calls and may be called many times, so 1 query would be better.

Body:
I'm not sure I understand your question, but maybe this query is your answer :

update totals set total = total + 1 where entryday = "08-01-11"


问:
how to detect when android app in background and foreground to handle some code
I need to know when user send my android app to background and then bring it back to foreground

when user send app to background I should perform server call and when back to foreground I have to clear some data

I have implemented it in the following way

```<code>public class MyApplication implements Application.ActivityLifecycleCallbacks {

@Override
    public void onActivityStopped(final Activity activity) {

// my logic goes here
}
}
</code>```

but this way make a lot of ANRs in background, and when I put my logic inside AsyncTask it does not work and also it close app in background

can any one advice me how to meet my requirement in another way without generating ANR's

答:
Use :

```<code>@Override
    public void onStop()
    {
        super.onStop();
        // Do your stuff here when you are stopping your activity
    }

@Override
    public void onResume()
    {
        super.onResume();
        // Do your stuff here when comes back to activity
    }
</code>```

This can also work when you lock your device onStop is called and when you reopen onResume is called.

Body:
I need to know when user send my android app to background and then bring it back to foreground

when user send app to background I should perform server call and when back to foreground I have to clear some data

I have implemented it in the following way

public class MyApplication implements Application.ActivityLifecycleCallbacks {

@Override
    public void onActivityStopped(final Activity activity) {

// my logic goes here
}
}

but this way make a lot of ANRs in background, and when I put my logic inside AsyncTask it does not work and also it close app in background

can any one advice me how to meet my requirement in another way without generating ANR's

Body:
Use :

@Override
    public void onStop()
    {
        super.onStop();
        // Do your stuff here when you are stopping your activity
    }

@Override
    public void onResume()
    {
        super.onResume();
        // Do your stuff here when comes back to activity
    }

This can also work when you lock your device onStop is called and when you reopen onResume is called.


问:
Fire AJAX jQuery if scroll reach to each div
I want make ajax fire if scroll reach to each div element.

Item div 1

Item div 2 (fire ajax if scroll to this element)

Item div 3 (fire ajax again if scroll to this element)

Item .....N

I use this code, but only fire if scroll to end.

$( window ).scroll( function() {
     if( $( window ).scrollTop() == $( document ).height() - $( window ).height() ) {
      alert('Fire!');
     }
    });```

Please help.

答:
I took the liberty of writing a simple html that will fullfil your needs.
In my example scroll happens via button click; u can change it with your usecase; Hope this helps; here's the fiddle https://jsfiddle.net/39z82axt/

html

```<code><div id="wrapper">
<div class="divel">Element 1</div>
<div class="divel">Element 2</div>
<div class="divel">Element 3</div>
<div class="divel">Element 4</div>
<div class="divel">Element 5</div>
</div>
<button id="scrollButton">
Click to Scroll
</button>
</code>```

css

```<code> .divel {
  height:80px;
}
#wrapper {
  height: 100px;
  overflow:scroll;
}
</code>```

js

```<code>let crossedFirstDiv = false,
    crossedSecondDiv = false;

document.getElementById('scrollButton').onclick = function() {
   document.getElementById("wrapper").scrollTop += 10;
   let scrollLocation = scrollPosition("wrapper");
   if (scrollLocation > 10 && scrollLocation <20 && crossedFirstDiv == false) {
   alert("crossing div 1");
   crossedFirstDiv = true;
   }
   else if (scrollLocation > 20 && scrollLocation <30 && crossedSecondDiv == false) {
   crossedSecondDiv = true;
   alert("crossing div 2");
   }

   // and so on..
}

function scrollPosition(elementId) {
  let a = document.getElementById(elementId).scrollTop;
   let b = document.getElementById(elementId).scrollHeight - document.getElementById(elementId).clientHeight;
   let c = a / b;
   return Math.floor(c * 100);
}
</code>```

Body:
I want make ajax fire if scroll reach to each div element.

Item div 1

Item div 2 (fire ajax if scroll to this element)

Item div 3 (fire ajax again if scroll to this element)

Item .....N

I use this code, but only fire if scroll to end.

$( window ).scroll( function() {
     if( $( window ).scrollTop() == $( document ).height() - $( window ).height() ) {
      alert('Fire!');
     }
    });

Please help.

Body:
I took the liberty of writing a simple html that will fullfil your needs.
In my example scroll happens via button click; u can change it with your usecase; Hope this helps; here's the fiddle https://jsfiddle.net/39z82axt/

html

<div id="wrapper">
<div class="divel">Element 1</div>
<div class="divel">Element 2</div>
<div class="divel">Element 3</div>
<div class="divel">Element 4</div>
<div class="divel">Element 5</div>
</div>
<button id="scrollButton">
Click to Scroll
</button>

css

 .divel {
  height:80px;
}
#wrapper {
  height: 100px;
  overflow:scroll;
}

js

let crossedFirstDiv = false,
    crossedSecondDiv = false;

document.getElementById('scrollButton').onclick = function() {
   document.getElementById("wrapper").scrollTop += 10;
   let scrollLocation = scrollPosition("wrapper");
   if (scrollLocation > 10 && scrollLocation <20 && crossedFirstDiv == false) {
   alert("crossing div 1");
   crossedFirstDiv = true;
   }
   else if (scrollLocation > 20 && scrollLocation <30 && crossedSecondDiv == false) {
   crossedSecondDiv = true;
   alert("crossing div 2");
   }

   // and so on..
}

function scrollPosition(elementId) {
  let a = document.getElementById(elementId).scrollTop;
   let b = document.getElementById(elementId).scrollHeight - document.getElementById(elementId).clientHeight;
   let c = a / b;
   return Math.floor(c * 100);
}


问:
Watch and reaload for polymer serve / polyserve?
I'm trying to figure out a way to make polyserve / polymer-cli to reload my browser each time a "watched" file changes but I haven't found anything apart of adding Livereload to the HTMLs files that I think is going to be a mess due that when developing web components I load separate HTML files.</p>

答:
For auto reloading using Polymer CLI as a server in your project you should have node / yarn installed. Then you need to install browser-sync locally.

npm install -D browser-sync

or

yarn add browser-sync --dev

Your package.json file will need to look something like:

```<code>{
  "name": "MY-ELEMENT",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "npm run serve | npm run watch",
    "serve": "polymer serve --port 8080",
    "test": "polymer test",
    "watch": "browser-sync start --proxy localhost:8080 --open --startPath \"components/MY-ELEMENT\" --files \"**/*.html\""
  },
  "devDependencies": {
    "browser-sync": "^2.18.13"
  }
}
</code>```

(If its a regular Polymer app you should remove the --startPath argument as that is for Polymer component development)

Body:
For auto reloading using Polymer CLI as a server in your project you should have node / yarn installed. Then you need to install browser-sync locally.

npm install -D browser-sync

or

yarn add browser-sync --dev

Your package.json file will need to look something like:

{
  "name": "MY-ELEMENT",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "npm run serve | npm run watch",
    "serve": "polymer serve --port 8080",
    "test": "polymer test",
    "watch": "browser-sync start --proxy localhost:8080 --open --startPath \"components/MY-ELEMENT\" --files \"**/*.html\""
  },
  "devDependencies": {
    "browser-sync": "^2.18.13"
  }
}

(If its a regular Polymer app you should remove the --startPath argument as that is for Polymer component development)


问:
Difference between Ctrl K + D and Ctrl k + F
What is the difference between the Visual Studio shortcuts "Ctrl K + D"
   and "Ctrl K + F" ?</p>

答:
Ctrl K+D    :   Format document to code formatting settings

Ctrl K+F    :   Format selection to code formatting settings

To find complete list of shortcuts,refer to this link
https://shortcutworld.com/Visual-Studio/win/Visual-Studio_2015_Shortcuts

Hope This helps !!


问:
Matlab- split cell array column by delimiter
I have many 33213168x1 cell arrays, where each cell contains an 85 x 1 column.

Each cell in the column is in the form

```<code>[0.55;0.25;0.75]

[0.33;0.66;0.99]
</code>```

I want to split up this single column by the semi-colon delimiter so that each cell in the cell array is 85x3, like:

```<code>[0.55][0.25][0.75]

[0.33][0.66][0.99]
</code>```

I've tried numerous techniques to solve this, but most commonly get the errors 'cell elements must be character arrays' or 'input must be a string.'

Some of the approaches I've tried:

```<code>splitcells = strsplit(regress_original_053108,';');
splitcells = cellfun(@(x) strsplit(regress_original_053108, ';'),regress_original_053108 , 'UniformOutput',0);
splitcells = regexp(regress_original_053108, ';', 'split');
splitcells = textscan(regress_original_053108, 'delimiter', ';');
</code>```

Etc. Any feedback about how to do this would be appreciated.

答:
Each cell you have is not a string, hence you can't use strsplit. Use this approach:

```<code>for ii = length(X) % Here X denotes your 33213168x1 cell array
    X{ii} = cell2mat(cellfun(@(y) y.', X{ii}, 'UniformOutput', false));
end
</code>```

Body:
I have many 33213168x1 cell arrays, where each cell contains an 85 x 1 column.

Each cell in the column is in the form

[0.55;0.25;0.75]

[0.33;0.66;0.99]

I want to split up this single column by the semi-colon delimiter so that each cell in the cell array is 85x3, like:

[0.55][0.25][0.75]

[0.33][0.66][0.99]

I've tried numerous techniques to solve this, but most commonly get the errors 'cell elements must be character arrays' or 'input must be a string.'

Some of the approaches I've tried:

splitcells = strsplit(regress_original_053108,';');
splitcells = cellfun(@(x) strsplit(regress_original_053108, ';'),regress_original_053108 , 'UniformOutput',0);
splitcells = regexp(regress_original_053108, ';', 'split');
splitcells = textscan(regress_original_053108, 'delimiter', ';');

Etc. Any feedback about how to do this would be appreciated.

Body:
Each cell you have is not a string, hence you can't use strsplit. Use this approach:

for ii = length(X) % Here X denotes your 33213168x1 cell array
    X{ii} = cell2mat(cellfun(@(y) y.', X{ii}, 'UniformOutput', false));
end