问:
How to rewrite the text of buttons that are not separately defined
I have started trying to write a code similar to the game 2048, however the size of the board can have any value depending on what the user inputs. I decided to make the numbers on the board, for style purposes, separate buttons.

This is the current GUI:

How can I make it so that when the buttons: up, down left, or right are pressed each of the button's in the board texts are changed? I know about event listeners I just mean how can I replace the button's in the same grid with different values when I defined the buttons on the board as:

```<code>`for(int i = 2; i < rows + 2; i++) {
  for(int j = 2; j < columns + 2; j++) {
    gbc.gridx = j;
    gbc.gridy = i;
    num = new JButton(board.board[j-2][i-2].getValue()+"");
    num.setFont(new Font("monospaced", Font.PLAIN, screenSize.height/50));
    num.setEnabled(false);
    this.add(num, gbc);
  }
}`
</code>```

The only ideas I've had was to create an array of buttons and then change the button's text in the array of buttons and then replace the old array of buttons with the new one. Also sorry if it has some super simple answer that I just couldn't find, I am just about finished with one semester of coding courses in college.

答:
I don't think you should use Buttons to do such a game button it's something that you can click on it since your are not supposed to click on numbers. If I were you I would use a gamePanel which contains fixed labels since it's easier changing text of label than moving label.
I would add MouseListener to the gamePanel and then fill implemented methods in order to manage when the mouse left button is pressed and move to left and so on.
So create an array of Label.
Create a method which add and move numbers according to the direction of the move. For instance if you make a left to right move you will start to add the numbers of the first column into the second column when they have same values. Next you just have to do it recursively until the last column.
If you need a bit more explainations ,I'll be pleased to help you.</p>

Body:
I have started trying to write a code similar to the game 2048, however the size of the board can have any value depending on what the user inputs. I decided to make the numbers on the board, for style purposes, separate buttons.

This is the current GUI:

How can I make it so that when the buttons: up, down left, or right are pressed each of the button's in the board texts are changed? I know about event listeners I just mean how can I replace the button's in the same grid with different values when I defined the buttons on the board as:

`for(int i = 2; i < rows + 2; i++) {
  for(int j = 2; j < columns + 2; j++) {
    gbc.gridx = j;
    gbc.gridy = i;
    num = new JButton(board.board[j-2][i-2].getValue()+"");
    num.setFont(new Font("monospaced", Font.PLAIN, screenSize.height/50));
    num.setEnabled(false);
    this.add(num, gbc);
  }
}`

The only ideas I've had was to create an array of buttons and then change the button's text in the array of buttons and then replace the old array of buttons with the new one. Also sorry if it has some super simple answer that I just couldn't find, I am just about finished with one semester of coding courses in college.


来源: stackexchange

问:
PHP returns 200 OK status header instead of 404 error over SSL
I have this php script (test.php) which checks whether the page exists in mysql and it should return 404 status header but it returns 200 OK status. This causes soft 404 errors in console.

I tried to fix but it is simply not working. Here is my .htaccess. I migrated my site to SSL few months ago and i am redirecting all traffic to https from port 80.

```<code>RewriteEngine On
ErrorDocument 404 /404.shtml

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

RewriteEngine on
RewriteRule ^([0-9]+)-([0-9]+)-([0-9]+)/pressrelease([0-9]+)\.htm$ test.php?pressid=$4 [L]
</code>```

and here is my test.php

```<code><?php
include_once('dbc.php');

$pid = strip_tags(mysql_real_escape_string($_GET['pressid']));

$rs_dirs = mysql_query("select id,name from categories order by name") or die(mysql_error());

$rs_press = mysql_query("select *
                             from press
                             where id = '$pid'
                             and approved='1'
                             ") or die(mysql_error());;

$total = mysql_num_rows($rs_press);

if (mysql_num_rows($rs_press) == 0) {

header("HTTP/1.1 404 Not Found");
include '404.shtml';
die();
}
</code>```

What is the problem here and how do i fix it?

答:
Use this code in your code:</p>

```<code>if (mysql_num_rows($rs_press) == 0) {
   http_response_code(404);
   //and another staff here
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have this php script (test.php) which checks whether the page exists in mysql and it should return 404 status header but it returns 200 OK status. This causes soft 404 errors in console.

I tried to fix but it is simply not working. Here is my .htaccess. I migrated my site to SSL few months ago and i am redirecting all traffic to https from port 80.

RewriteEngine On
ErrorDocument 404 /404.shtml

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

RewriteEngine on
RewriteRule ^([0-9]+)-([0-9]+)-([0-9]+)/pressrelease([0-9]+)\.htm$ test.php?pressid=$4 [L]

and here is my test.php

<?php
include_once('dbc.php');

$pid = strip_tags(mysql_real_escape_string($_GET['pressid']));

$rs_dirs = mysql_query("select id,name from categories order by name") or die(mysql_error());

$rs_press = mysql_query("select *
                             from press
                             where id = '$pid'
                             and approved='1'
                             ") or die(mysql_error());;

$total = mysql_num_rows($rs_press);

if (mysql_num_rows($rs_press) == 0) {

header("HTTP/1.1 404 Not Found");
include '404.shtml';
die();
}

What is the problem here and how do i fix it?

Body:
Use this code in your code:

if (mysql_num_rows($rs_press) == 0) {
   http_response_code(404);
   //and another staff here
}


问:
Spring Batch - Master failover in remote chunking
I want to scale my batch processing via Remote Chunking mechanism, which I have master for reader, and slaves for processor and writer.

If one of my slave fail, it should be ok since I have another slave. But when the master it self fail, how do I recover? Is there any mechanism to select new master?

Thank you.

答: There is not.  You'd have to restart the job.</p>


问:
Regex ignores second lookahead
I can't understand why second output ignores (?!B) condition and returns 201B instead of 20 x 1B?

My PHP code:

```<code>$s_1 = '20 x 1';
$s_2 = '20 x 1B';

$pattern = '/(?<=\d)[\s]*[xX][\s]*(?=\d)(?!B)/ui';

echo preg_replace($pattern, '', $s_1); // output: 201
echo preg_replace($pattern, '', $s_2); // output: 201B
</code>```

答:
Your last negative lookahead should be nested inside (?=\d):

```<code>(?<=\d)\s*[xX]\s*(?=\d(?!B))
</code>```

RegEx Demo

When (?!B) is outside as in your regex then then zero-width assertion is applied after matching x and a space. That assertion returns true because next position is a digit.

Title: Regex ignores second lookahead

Body:
I can't understand why second output ignores (?!B) condition and returns 201B instead of 20 x 1B?

My PHP code:

$s_1 = '20 x 1';
$s_2 = '20 x 1B';

$pattern = '/(?<=\d)[\s]*[xX][\s]*(?=\d)(?!B)/ui';

echo preg_replace($pattern, '', $s_1); // output: 201
echo preg_replace($pattern, '', $s_2); // output: 201B

Body:
Your last negative lookahead should be nested inside (?=\d):

(?<=\d)\s*[xX]\s*(?=\d(?!B))

RegEx Demo

When (?!B) is outside as in your regex then then zero-width assertion is applied after matching x and a space. That assertion returns true because next position is a digit.


问:
AJAX Permission Denied On IE?
I'm trying to make an ajax call to an external domain that is already allowing external requests by sending Access-Control-Allow-Origin:* header, but i get Permission Denied on the xmlhttp.post() line.

Here is my code:

```<code>var xmlhttp;
try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
        xmlhttp = false;
    }
}

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
        xmlhttp = new XMLHttpRequest();
    } catch (e) {
        xmlhttp = false;
    }
}

xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        alert(xmlhttp.responseText);
    }
}

xmlhttp.open("GET", "http://www.domain.com", true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send();
</code>```

答:
I believe you can only use Ajax with URL's form the same domain as your calling page. It's not the external domain that disallows the request, it's your browser's security. Take a look at Same Origin Policy
This is a way to avoid cross browser scripts - otherwise imagine you have a page where you can enter your credit card info and someone injects a script that sends information you are typing to an external site. Would be a big problem to fight.</p>

ContentLicense: CC BY-SA 2.5

Title: AJAX Permission Denied On IE?

Body:
I'm trying to make an ajax call to an external domain that is already allowing external requests by sending Access-Control-Allow-Origin:* header, but i get Permission Denied on the xmlhttp.post() line.

Here is my code:

var xmlhttp;
try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
        xmlhttp = false;
    }
}

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
        xmlhttp = new XMLHttpRequest();
    } catch (e) {
        xmlhttp = false;
    }
}

xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        alert(xmlhttp.responseText);
    }
}

xmlhttp.open("GET", "http://www.domain.com", true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send();


问:
Python : Cross_val_score - weird scoring results
I use Oython and the "cross_val_score" function to mesure performance of a LogisticRegression modelfor a classification task (Yes/No)
I observe that when using scoring = 'accuracy' and scoring = 'recall_weighted', I have exactly the same results (I made several tests) :

```<code>X = data.iloc[:,0:2]
y = data.iloc[:,2]

model = LogisticRegression(class_weight = {'Y':7,'N':3} )
model.fit(X,y)
scores = cross_val_score(model, X, y, cv=10, scoring = 'recall_weighted')

scores
array([ 0.81818182,  1.        ,  0.90909091,  1.        ,  1.        ,
    1.        ,  1.        ,  1.        ,  0.66666667,  0.33333333])

scores_accuracy = cross_val_score(model, X, y, cv=10, scoring = 'accuracy')
scores_accuracy
array([ 0.81818182,  1.        ,  0.90909091,  1.        ,  1.        ,
    1.        ,  1.        ,  1.        ,  0.66666667,  0.33333333])
</code>```

Have you got the same things with your datasets ?
Can you help me ?

Thanks you,

Regards,

Lionel

答:
I suspect that the weighted recall is turning out out to be mathematically same as accuracy.

This is probably not about the cross validation. You could check other data sets, or same, and compute the scores without using cross_val_score and see if the accuracy is still same as weighted recall

Body:
I use Oython and the "cross_val_score" function to mesure performance of a LogisticRegression modelfor a classification task (Yes/No)
I observe that when using scoring = 'accuracy' and scoring = 'recall_weighted', I have exactly the same results (I made several tests) :

X = data.iloc[:,0:2]
y = data.iloc[:,2]

model = LogisticRegression(class_weight = {'Y':7,'N':3} )
model.fit(X,y)
scores = cross_val_score(model, X, y, cv=10, scoring = 'recall_weighted')

scores
array([ 0.81818182,  1.        ,  0.90909091,  1.        ,  1.        ,
    1.        ,  1.        ,  1.        ,  0.66666667,  0.33333333])

scores_accuracy = cross_val_score(model, X, y, cv=10, scoring = 'accuracy')
scores_accuracy
array([ 0.81818182,  1.        ,  0.90909091,  1.        ,  1.        ,
    1.        ,  1.        ,  1.        ,  0.66666667,  0.33333333])

Have you got the same things with your datasets ?
Can you help me ?

Thanks you,

Regards,

Lionel


问:
Subclass __init__ is not called if superclass __new__ is defined
See the following ipython session:

```<code>$ ipython --no-banner

In [1]: class foo(object):
   ...:     def __new__(self, *args, **kwargs):
   ...:         print 'in superclass __new__'
   ...:         return self
   ...:
   ...: class bar(foo):
   ...:     def __init__(self, *args, **kwargs):
   ...:         print 'in subclass __init__'
   ...:         self.val = 42
   ...:

In [2]: b = bar()
in superclass __new__

In [3]: b.val
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-c55d38c9d4d9> in <module>()
----> 1 b.val

AttributeError: type object 'bar' has no attribute 'val'
</code>```

What is going on here? Why does defining __new__ in foo prevent the __init__ from running in bar?

答:
You are returning an invalid value from __new__.  Quoting the documentation:

If __new__() returns an instance of cls, then the new instance’s __init__() method will be invoked ... If __new__() does not return an instance of cls, then the new instance’s __init__() method will not be invoked.

Note that the first argument to __new__ is a class, not an object. __new__'s job is to allocate the object, often by calling super().__new__.

Try this:

```<code>class foo(object):
    def __new__(cls, *args, **kwargs):
        print 'in superclass __new__'
        return super(foo, cls).__new__(cls, *args, **kwargs)

class bar(foo):
    def __init__(self, *args, **kwargs):
        print 'in subclass __init__'
        self.val = 42

b = bar()
print b
</code>```

Body:
See the following ipython session:

$ ipython --no-banner

In [1]: class foo(object):
   ...:     def __new__(self, *args, **kwargs):
   ...:         print 'in superclass __new__'
   ...:         return self
   ...:
   ...: class bar(foo):
   ...:     def __init__(self, *args, **kwargs):
   ...:         print 'in subclass __init__'
   ...:         self.val = 42
   ...:

In [2]: b = bar()
in superclass __new__

In [3]: b.val
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-c55d38c9d4d9> in <module>()
----> 1 b.val

AttributeError: type object 'bar' has no attribute 'val'

What is going on here? Why does defining __new__ in foo prevent the __init__ from running in bar?

Body:
You are returning an invalid value from __new__.  Quoting the documentation:

If __new__() returns an instance of cls, then the new instance’s __init__() method will be invoked ... If __new__() does not return an instance of cls, then the new instance’s __init__() method will not be invoked.

Note that the first argument to __new__ is a class, not an object. __new__'s job is to allocate the object, often by calling super().__new__.

Try this:

class foo(object):
    def __new__(cls, *args, **kwargs):
        print 'in superclass __new__'
        return super(foo, cls).__new__(cls, *args, **kwargs)

class bar(foo):
    def __init__(self, *args, **kwargs):
        print 'in subclass __init__'
        self.val = 42

b = bar()
print b


问:
Opening URL from link into iframe

I have iframe created and it has no src at the beginning. When I click on a link, for example, the result from Google search, that link should try to open in that iframe. Not in the tab that I am currently browsing.

```<code>$(document).ready(function () {

    $('<div />', {
        id: 'firster',
        style: 'position: fixed; top: 0; bottom: 0; right: 0; max-width: 500px; z-index: 120;'
    }).appendTo('body');

    $('<iframe />', {
            name: 'frame1',
            id: 'frame1',
            src: ''
        })
        .css({
            'height': '100%',
            'width': '450px'
    }).appendTo('#firster');

    $("a").click(function(e) {
        $("#frame1").attr("src", window.location.protocol + '//' + window.location.host +  $(this).attr("href"));
        return false;
    })

});
</code>```

What I expect is to open that url ( I concated the protocol host and url ), it just does not open.

Element status before clicking on link:

And element status after clicking on link:

How to fix this? Any way around it?

Edit part:

This is what im getting periodically in console:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading
  the remote resource at
  https://accounts.google.com/ServiceLogin?passive=1209600&osid=1&continue=https://notifications.google.com/u/0//idv2&followup=https://notifications.google.com/u/0//idv2&authuser=0.
  (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

答:
Kinda worked out what I wanted. For everyone who wants to see its here:

```<code>$(document).ready(function () {

    $('<div />', {
        id: 'firster',
        style: 'position: fixed; top: 0; bottom: 0; right: 0; max-width: 500px; z-index: 120;'
    }).appendTo('body');

    $('<iframe />', {
            name: 'frame1',
            id: 'frame1',
            src: ''
        })
        .css({
            'height': '100%',
            'width': '450px'
    }).appendTo('#firster');

    function loadIframe(iframeName, url) {
        if ( window.frames[iframeName] ) {
            window.frames[iframeName].location = url;
            return false;
        }
        return true;
    }
    $("a").click(function(e) {
        $("#frame1").attr("src", decodeURIComponent($.urlParam('url', $(this).attr("href")))); // no prepend of current URL, just use the href directly

        return false;
    })

    $.urlParam = function (name, urlItself) {
        var results = new RegExp('[\?&]' + name + '=([^&#]*)')
                          .exec(urlItself);

        return results[1] || 0;
    }

   // console.log($.urlParam('url', urlItself)); //registration

});
</code>```

I am sure that this will work on Googles search-result links and not quite sure if it is scalable but it works for my original purpose. Also, big thanks to everyone who contributed on this issue.

Title: Opening URL from link into iframe

Body:
I have iframe created and it has no src at the beginning. When I click on a link, for example, the result from Google search, that link should try to open in that iframe. Not in the tab that I am currently browsing.

$(document).ready(function () {

    $('
', {
        id: 'firster',
        style: 'position: fixed; top: 0; bottom: 0; right: 0; max-width: 500px; z-index: 120;'
    }).appendTo('body');

    $('', {
            name: 'frame1',
            id: 'frame1',
            src: ''
        })
        .css({
            'height': '100%',
            'width': '450px'
    }).appendTo('#firster');

    $("a").click(function(e) {
        $("#frame1").attr("src", window.location.protocol + '//' + window.location.host +  $(this).attr("href"));
        return false;
    })

});

What I expect is to open that url ( I concated the protocol host and url ), it just does not open.

Element status before clicking on link:

And element status after clicking on link:

How to fix this? Any way around it?

Edit part:

This is what im getting periodically in console:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading
  the remote resource at
  https://accounts.google.com/ServiceLogin?passive=1209600&osid=1&continue=https://notifications.google.com/u/0//idv2&followup=https://notifications.google.com/u/0//idv2&authuser=0.
  (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Body:
Kinda worked out what I wanted. For everyone who wants to see its here:

$(document).ready(function () {

    $('<div />', {
        id: 'firster',
        style: 'position: fixed; top: 0; bottom: 0; right: 0; max-width: 500px; z-index: 120;'
    }).appendTo('body');

    $('<iframe />', {
            name: 'frame1',
            id: 'frame1',
            src: ''
        })
        .css({
            'height': '100%',
            'width': '450px'
    }).appendTo('#firster');

    function loadIframe(iframeName, url) {
        if ( window.frames[iframeName] ) {
            window.frames[iframeName].location = url;
            return false;
        }
        return true;
    }
    $("a").click(function(e) {
        $("#frame1").attr("src", decodeURIComponent($.urlParam('url', $(this).attr("href")))); // no prepend of current URL, just use the href directly

        return false;
    })

    $.urlParam = function (name, urlItself) {
        var results = new RegExp('[\?&]' + name + '=([^&#]*)')
                          .exec(urlItself);

        return results[1] || 0;
    }

   // console.log($.urlParam('url', urlItself)); //registration

});

I am sure that this will work on Googles search-result links and not quite sure if it is scalable but it works for my original purpose. Also, big thanks to everyone who contributed on this issue.


问:
Leftover change amount using modulus operator (JavaScript)
I am working on an assignment that requires me to convert any number of pennies into the appropriate amount of Quarters, Dimes, Nickels and remaining pennies.

When I run the program, it is converting the total amount to each respective coin using Math.floor(). This script is running in the head, as is required per the assignment:

```<code><!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Make Change</title>
<meta name="generator" content="Geany 1.29" />

<script>
function convertChange(numberOfQuarters, numberOfDimes, numberOfNickels, numberOfPennies) {

number=parseFloat(document.getElementById("penniesBox").value);
numberOfQuarters = Math.floor(number/25);
numberOfDimes = Math.floor(number/10);
numberOfNickels = Math.floor(number/5);
numberOfPennies = Math.floor(number/1);
    document.getElementById("outputDiv").innerHTML=
        'Quarters: ' + numberOfQuarters + "<br>" +
        'Dimes: ' + numberOfDimes + "<br>" +
        'Nickels: ' + numberOfNickels + "<br>" +
        'Pennies:' + numberOfPennies;

}

</script>
</head>

<body>
<h2>Make Change</h2>
<p>This page will tell you the minimum amount of pennies, nickels, dimes and quarters you need to match the number of pennies entered.</p>
<p>Enter a number of pennies:
<input type="text" id="penniesBox" size=12 value="">
</p>
    <input type="button" value="Show me the money!"
    onclick="convertChange();">

<hr>
<div id="outputDiv"></div>

</body>

</html>
</code>```

How would I go about using the modulus operator in order to get the remaining amount of pennies to display next to the appropriate amount of change?

答:
Use modulus to get the leftover amount that you'll use in later calculations (Math.floor...), overwriting each money with the leftover amount. Also, since you're not passing in the variables to your function in your onclick (notice it's only convertChange()), you should declare your variables within the function using var ....

See updated code here:

function convertChange() {
    var money = parseFloat(document.getElementById("penniesBox").value);
    var numberOfQuarters = Math.floor(money/25);
    money = money%25;
    var numberOfDimes = Math.floor(money/10);
    money = money%25;
    var numberOfNickels = Math.floor(money/5);
    money = money%5;
    var numberOfPennies = money;
        document.getElementById("outputDiv").innerHTML=
            'Quarters: ' + numberOfQuarters + "
" +
            'Dimes: ' + numberOfDimes + "
" +
            'Nickels: ' + numberOfNickels + "
" +
            'Pennies:' + numberOfPennies;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><h2>Make Change</h2>
<p>This page will tell you the minimum amount of pennies, nickels, dimes and quarters you need to match the number of pennies entered.</p>
<p>Enter a number of pennies:
<input type="text" id="penniesBox" size=12 value="">
</p>
    <input type="button" value="Show me the money!"
    onclick="convertChange();">

<hr>
<div id="outputDiv"></div></code>```

Body:
I am working on an assignment that requires me to convert any number of pennies into the appropriate amount of Quarters, Dimes, Nickels and remaining pennies.

When I run the program, it is converting the total amount to each respective coin using Math.floor(). This script is running in the head, as is required per the assignment:

<!DOCTYPE html>

<meta charset="utf-8" />
<title>Make Change</title>
<meta name="generator" content="Geany 1.29" />

Make Change

This page will tell you the minimum amount of pennies, nickels, dimes and quarters you need to match the number of pennies entered.

Enter a number of pennies:
<input type="text" id="penniesBox" size=12 value="">

    <input type="button" value="Show me the money!"
    onclick="convertChange();">

How would I go about using the modulus operator in order to get the remaining amount of pennies to display next to the appropriate amount of change?

Body:
Use modulus to get the leftover amount that you'll use in later calculations (Math.floor...), overwriting each money with the leftover amount. Also, since you're not passing in the variables to your function in your onclick (notice it's only convertChange()), you should declare your variables within the function using var ....

See updated code here:

function convertChange() {
    var money = parseFloat(document.getElementById("penniesBox").value);
    var numberOfQuarters = Math.floor(money/25);
    money = money%25;
    var numberOfDimes = Math.floor(money/10);
    money = money%25;
    var numberOfNickels = Math.floor(money/5);
    money = money%5;
    var numberOfPennies = money;
        document.getElementById("outputDiv").innerHTML=
            'Quarters: ' + numberOfQuarters + "<br>" +
            'Dimes: ' + numberOfDimes + "<br>" +
            'Nickels: ' + numberOfNickels + "<br>" +
            'Pennies:' + numberOfPennies;
}

<h2>Make Change</h2>
<p>This page will tell you the minimum amount of pennies, nickels, dimes and quarters you need to match the number of pennies entered.</p>
<p>Enter a number of pennies:
<input type="text" id="penniesBox" size=12 value="">
</p>
    <input type="button" value="Show me the money!"
    onclick="convertChange();">

<hr>
<div id="outputDiv"></div>


问:
Using Odata enabled ASP.NET Web-API to call a Stored Procedure
All,
Looking for guidance on exposing a Stored Procedure using OData.

I'm modifying an existing WEB-API app that already exposes OData. It currently exposes tables and views from SQL SERVER, and now I'm required to have it also expose Stored procedures. The current Stored Procedure will accept a bunch of parameters, and push changes to a handful of tables on the back-end database.

Here are the packages used by the project:

```<code><packages>
  <package id="EntityFramework" version="6.1.3" targetFramework="net45" />
  <package id="EntityFramework" version="6.0.2" targetFramework="net45" />
  <package id="LinqKit" version="1.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.OData" version="5.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.3" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.3" targetFramework="net45" />
  <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
  <package id="Microsoft.OData.Client" version="6.8.1" targetFramework="net45" />
  <package id="Microsoft.OData.Core" version="6.6.0" targetFramework="net45" />
  <package id="Microsoft.OData.Core" version="6.8.1" targetFramework="net45" />
  <package id="Microsoft.OData.Edm" version="6.6.0" targetFramework="net45" />
  <package id="Microsoft.OData.Edm" version="6.8.1" targetFramework="net45" />
  <package id="Microsoft.Spatial" version="6.6.0" targetFramework="net45" />
  <package id="Microsoft.Spatial" version="6.8.1" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" />
  <package id="Patches.System.Web.OData" version="5.3.0-datetimefixes" targetFramework="net45" />
  <package id="System.Linq.Dynamic" version="1.0.2" targetFramework="net45" />
  <package id="System.Spatial" version="5.6.3" targetFramework="net45" />
</packages>
</code>```

I've worked to follow this guide: Actions and Functions in OData v4 Using ASP.NET Web API 2.2, as I understand that naively supported Stored Procedures is not possible in OData.

I've modified my existing application, adding the model, and the wiring inside of WebApiConfig. On my first run I got the following error:

Goes without saying... There shouldn't be a primary key defined for a stored procedure.

Note that I'm trying to access "vw_tickets_all_tables", and still the error is thrown... inferring that the error breaks the entire application.

Here's the code I have thus far:

MODEL:

```<code>public class InsertUpdateTicketsPJMTickets : DbContext
{
    public InsertUpdateTicketsPJMTickets()
            : base("name=InsertUpdateTicketsPJMTickets")
    {
    }
    public DbSet<InsertUpdateTicketsPJMTicketsBase> InsertUpdateTicketsPJMTickets { get; set; }
}
public partial class InsertUpdateTicketsPJMTicketsBase
{
    string ticketType{set; get;}
    string category{set; get;}
    string title{set; get;}
    string details{set; get;}
    Nullable<bool> isHtml{set; get;}
    // bunches of fields left out for brevity
    string lastUpdateBy{set; get;}
    string createdBy{set; get;}
    string creationName{set; get;}
    string revisionName{set; get;}
}
</code>```

WepApiConfig:

```<code>public static IEdmModel GetUOMSModel()
{
    ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
    builder.ContainerName = "UOMSContext";
    builder.EntityType<Models.UOMS.DBO.InsertUpdateTicketsPJMTickets>()
        .Action("Execute");

    var function = builder.Function("GetParameters");

    function.Parameter<string>("ticketType");
    function.Parameter<string>("category");
    function.Parameter<string>("title");
    function.Parameter<string>("details");
    // bunches of fields left out for brevity
    function.Parameter<int?>("inputTicketId");
    function.Parameter<string>("lastUpdateBy");
    function.Parameter<string>("createdBy");
    function.Parameter<string>("creationName");
    function.Parameter<string>("revisionName");
    function.ReturnsCollectionFromEntitySet<Models.UOMS.DBO.InsertUpdateTicketsPJMTickets>("InsertUpdateTicketsPJMTickets");
}
</code>```

I'll add a CONTROLLER once the "Key" issue is resolved.

Thank you for reading.

答:
Did you add a key for the entity type InsertUpdateTicketsPJMTickets?

Because you try to add a entity type builder.EntityType<Models.UOMS.DBO.InsertUpdateTicketsPJMTickets>()
 and create an entity set named InsertUpdateTicketsPJMTickets.

From OData spec, each entity type is a structural type with key(s).

You can do:

Call Fluent API HasKey

Add attribute [key] on the property that you want to make it as key

Body:
All,
Looking for guidance on exposing a Stored Procedure using OData.

I'm modifying an existing WEB-API app that already exposes OData. It currently exposes tables and views from SQL SERVER, and now I'm required to have it also expose Stored procedures. The current Stored Procedure will accept a bunch of parameters, and push changes to a handful of tables on the back-end database.

Here are the packages used by the project:

<packages>
  <package id="EntityFramework" version="6.1.3" targetFramework="net45" />
  <package id="EntityFramework" version="6.0.2" targetFramework="net45" />
  <package id="LinqKit" version="1.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.OData" version="5.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Cors" version="5.2.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.3" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.3" targetFramework="net45" />
  <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
  <package id="Microsoft.OData.Client" version="6.8.1" targetFramework="net45" />
  <package id="Microsoft.OData.Core" version="6.6.0" targetFramework="net45" />
  <package id="Microsoft.OData.Core" version="6.8.1" targetFramework="net45" />
  <package id="Microsoft.OData.Edm" version="6.6.0" targetFramework="net45" />
  <package id="Microsoft.OData.Edm" version="6.8.1" targetFramework="net45" />
  <package id="Microsoft.Spatial" version="6.6.0" targetFramework="net45" />
  <package id="Microsoft.Spatial" version="6.8.1" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" />
  <package id="Patches.System.Web.OData" version="5.3.0-datetimefixes" targetFramework="net45" />
  <package id="System.Linq.Dynamic" version="1.0.2" targetFramework="net45" />
  <package id="System.Spatial" version="5.6.3" targetFramework="net45" />
</packages>

I've worked to follow this guide: Actions and Functions in OData v4 Using ASP.NET Web API 2.2, as I understand that naively supported Stored Procedures is not possible in OData.

I've modified my existing application, adding the model, and the wiring inside of WebApiConfig. On my first run I got the following error:

Goes without saying... There shouldn't be a primary key defined for a stored procedure.

Note that I'm trying to access "vw_tickets_all_tables", and still the error is thrown... inferring that the error breaks the entire application.

Here's the code I have thus far:

MODEL:

public class InsertUpdateTicketsPJMTickets : DbContext
{
    public InsertUpdateTicketsPJMTickets()
            : base("name=InsertUpdateTicketsPJMTickets")
    {
    }
    public DbSet<InsertUpdateTicketsPJMTicketsBase> InsertUpdateTicketsPJMTickets { get; set; }
}
public partial class InsertUpdateTicketsPJMTicketsBase
{
    string ticketType{set; get;}
    string category{set; get;}
    string title{set; get;}
    string details{set; get;}
    Nullable<bool> isHtml{set; get;}
    // bunches of fields left out for brevity
    string lastUpdateBy{set; get;}
    string createdBy{set; get;}
    string creationName{set; get;}
    string revisionName{set; get;}
}

WepApiConfig:

public static IEdmModel GetUOMSModel()
{
    ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
    builder.ContainerName = "UOMSContext";
    builder.EntityType<Models.UOMS.DBO.InsertUpdateTicketsPJMTickets>()
        .Action("Execute");

    var function = builder.Function("GetParameters");

    function.Parameter<string>("ticketType");
    function.Parameter<string>("category");
    function.Parameter<string>("title");
    function.Parameter<string>("details");
    // bunches of fields left out for brevity
    function.Parameter<int?>("inputTicketId");
    function.Parameter<string>("lastUpdateBy");
    function.Parameter<string>("createdBy");
    function.Parameter<string>("creationName");
    function.Parameter<string>("revisionName");
    function.ReturnsCollectionFromEntitySet<Models.UOMS.DBO.InsertUpdateTicketsPJMTickets>("InsertUpdateTicketsPJMTickets");
}

I'll add a CONTROLLER once the "Key" issue is resolved.

Thank you for reading.


答:
You are not setting the actual status code to 404.

See usage of the header function:

http://php.net/manual/en/function.header.php

```<code>void header ( string $string [, bool $replace = true [, int $http_response_code ]] )
</code>```

Your code should be:

```<code>header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
</code>```

There is also an alternative function:

https://secure.php.net/manual/en/function.http-response-code.php

```<code>http_response_code(404);
</code>```

I prefer to use the above function instead. As it's more verbose as to what your intention way.

Title: PHP returns 200 OK status header instead of 404 error over SSL

Body:
You are not setting the actual status code to 404.

See usage of the header function:

http://php.net/manual/en/function.header.php

void header ( string $string [, bool $replace = true [, int $http_response_code ]] )

Your code should be:

header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);

There is also an alternative function:

https://secure.php.net/manual/en/function.http-response-code.php

http_response_code(404);

I prefer to use the above function instead. As it's more verbose as to what your intention way.


问:
consequences of committing large amount of binary files in git repository
I have just performed a merge in git.
Unfortunately, due to differences in .gitignore settings between branches, a large number of large binary files has been committed and pushed after the merge.

Later, I have removed the files from the folder, committed their delete, added them to .gitignore and copied them back to the folder.

This way I restored the pre-merge situation.
However, the large files created a huge commit (GBs) with super lenghty diff which also shadows the actual merge commits.

Beside polluting the history, is there any other negative consequence of such a dumb action (computationally is this gonna slow down anything)?
How to cleanup this mess in terms of disk resources and clarity of the git logs?

答:
Regarding the consequences: the biggest impact would be on clone operations - which, of course, could be slow due to transferring the large amount of data.  In some circumstances fetch or push could also be affected.  I wouldn't expect much impact on other git operations.  Most things are done locally and hashes are used where possible, so only when the content of one of the large files is actually relevant to an operation would that operation be directly affected by the size of the file.

(I suppose depending on underlying file system, operations on pack files containing the large objects could theoretically be affected, but that sounds like a stretch to me.)

The easiest way to clean up the history is with the BFG Repo Cleaner.  Doing so constitutes a history rewrite, so all the usual caveats about coordinating with other repo users would apply.


问:
Importing blank Excel columns using SSIS
I'm creating an SSIS package to import Excel files (which have different layouts) into a SQL Server table with 150 columns.

The SSIS package has a Foreach Loop Container within which is a Data Flow Task which has an Excel Source component and an OLE DB Destination component.

The Data Flow Task will be ran for each Excel file so the Excel Source component needs to work for every file.

I've set up the Excel Source component with 150 Unicode string columns of length 255, and I've set ValidateExternalMetadata to False, however I'm getting the error: 'Column "F143" cannot be found at the datasource' when testing the package on an Excel file with 142 columns of data.

My question is: How do I get the package to ignore this error and import the columns that exist, or is there another way of dealing with the above situation?

答: Open up the editor for your Excel Source task. In the left pane, select "Error Output". below the columns pane is a line that says "Set this value to selected cells:" with a dropdown next to it. Choose "Ignore failure" from the drop down. Now go to the columns pane and select all the 150 rows under the "Error" column, and then hit the "Apply" but next to the dropdown box. This should set all the Excel columns to "Ignore Error". Hit "Ok" and then you should be good to go.</p>


问:
unexpectedly found nil unexpectedly - struct init? not working
I am working on a demo app to return a list of restaurant with the google places API.

I have a Restaurant class - 1 property is a custom type RestaurantDetails. This is where the challenge is:

Restaurant.swift

```<code>class Restaurant {

    var id:String
    var placeId:String
    var name:String
    var location: Location //Location + address + coordinate + distance
    var phone:String?
    let details : RestaurantDetails

    init(id:String, placeId:String, name:String, location: Location, details: RestaurantDetails) {
        self.id = id
        self.placeId = placeId
        self.name = name
        self.location = location
        self.details = details
    }

    convenience init(dict:[String:Any]) {
        let id = dict["id"] as! String
        let placeId = dict["place_id"] as! String
        let name = dict["name"] as! String
        let address = dict["formatted_address"] as? String
        let location = Location(address: address!, json: dict["geometry"] as! [String : Any])

        if let price = dict["price_level"] as? Double {
            print("price => \(Price(valueDouble: price))")
        }

        if let rating = dict["rating"] as? Double {
            print("rating => \(Rating(valueDouble: rating))")
        }

        self.init(id: id, placeId: placeId, name: name, location: location!, details: RestaurantDetails(json: dict)!)
    }

}
</code>```

the initialization of the details property fails each time
even using the breakpoint does not help to debug the error because the custom init? does not seem to fire. I do not see any syntax error though
I am usually using guard let control flow to parse the JSON format if the value exists. unsuccessful.
the breakpoint does not kick in on the RestaurantDetails.swift file

RestaurantDetails.swift

```<code>enum Price {
    case cheap, expensive, `default`

    init(valueDouble: Double) {
        switch valueDouble {
        case 0..<2: self = .cheap
        case 2..<4 : self = .expensive
        default: self = .default
        }
    }

    var dollarSymbol : String {
        switch self {
        case .cheap: return "$"
        case .expensive: return "$$"
        default: return ""
        }
    }
}

enum Rating {
    case low, fair, good, excellent, `default`

    init(valueDouble: Double) {
        switch valueDouble {
        case 0..<2: self = .low
        case 3..<4: self = .fair
        case 4..<5: self = .good
        case 6 : self = .excellent
        default: self = .default
        }
    }

    var starSymbol : String {
        switch self {
        case .low: return "⭐"
        case .fair: return "⭐⭐"
        case .good: return "⭐⭐⭐"
        case .excellent: return "⭐⭐⭐⭐"
        default: return ""
        }
    }
}

struct RestaurantDetails {
    let price:Price
    let rating:Rating // Rating (enum) (filter)
    let openNow: Bool //(filter)
    let types : [String]?
    let photos : [NSDictionary]?
}

extension RestaurantDetails {

    init?(json: [String: Any]) {

        guard let price = json["price_level"] as? Double,
            let rating = json["rating"] as? Double,
            let openingHours = json["opening_hours"] as? NSDictionary,
            let types = json["types"] as? [String],
            let photos = json["photos"] as? [NSDictionary] else {
            return nil
        }

        print("json details : \(json)")

        self.price = Price(valueDouble: price)
        self.rating = Rating(valueDouble: rating)
        self.openNow = openingHours["open_now"] as! Bool != nil ?? false
        self.types = types
        self.photos = photos
    }
}
</code>```

I also have a Location.swift file that works perfectly

```<code>struct Location {
    var address :String
    var coordinate:(lat:Double, lng:Double)
}

extension Location {
    init?(address: String, json:[String:Any]) {
        guard let latitude = json["location"] as? NSDictionary, let longitude = json["location"] as? NSDictionary else { return nil }

        self.init(address: address, coordinate: (lat: latitude["lat"] as! Double, lng: longitude["lng"] as! Double))
    }
}
</code>```

答:
As vadian described in his comment, the issue causing the crash is that location has a failable initializer, you are forcibly unwrapping it, and since initialization is in fact failing, you have now force-unwrapped a nil value.

The broader questions are: what do you, the developer, want to happen when some or all location data is not available, and what is the best way to go about doing that?

Options for handling incomplete or missing location data

Based on your description of the problem (“a demo app to return a list of restaurant with the google places api”), it is not clear whether or not restaurants without useable location data should enter your model. It is also not clear whether or not there is some location data you could do without. So I see three options:

Discard all restaurants with incomplete location data

Discard some restaurants with incomplete location data while keeping others

Keep all restaurants regardless of location data

To implement these options, you may want to use some common tools for dealing with optionals:

Nil-coalescing operator

a = b ?? c

Set a equal to b, unless b is nil, in which case set a equal to c.

Optional binding in guard and if

guard let a = b else { return }

Set a equal to b unless b is nil, in which case return from the current context. You can do work in the else branch prior to returning.

if let a = b { /* Do work using a */ } else { /* Do other work */ }

If b is not nil, enter the if branch and  set a equal to b; if b is nil, enter the else branch.

How to do it

Discard all restaurants with incomplete location data

In this case, you could make a failable initializer for Restaurant, guarded by location being non-nil:

```<code>/// Initialization fails if `location` is `nil`
convenience init?(id:String, placeId:String, name:String, location: Location?, details: RestaurantDetails) {
    guard let location = location else { return nil }

    self.init(id: id, placeId: placeId, name: name, location: location, details: details)
}
</code>```

Discard some restaurants with incomplete location data while keeping others

You may be able to recover from some kinds of missing location data. For example, it may be the case that you really just need the street address string and the latitude and longitude are inessential. You could rewrite your Location struct to reflect that:

```<code>struct Location {
    var address: String
    var coordinate: (lat: Double, lng: Double)?
}

extension Location {
    init?(address: String, json:[String:Any]) {
        let coordinate: (Double, Double)?
        if let latitude = json["location"] as? NSDictionary, let longitude = json["location"] as? NSDictionary {
            coordinate = (latitude, longitude)
        } else {
            coordinate = nil
        }

        self.init(address: address, coordinate: coordinate)
    }
}
</code>```

Alternative, lat/long might be the important part, but it might sometimes be possible to recover them from the street address using another API:

```<code>struct Location {
    var address: String
    var coordinate: (lat: Double, lng: Double)
}

extension Location {
    init?(address: String, json:[String:Any]) {
        let coordinate: (Double, Double)?
        if let latitude = json["location"] as? NSDictionary, let longitude = json["location"] as? NSDictionary {
            coordinate = (latitude, longitude)
        } else {

            /* An API call that takes an address string and tries to return lat/long but might return nil */

            coordinate = returnedCoordinateFromAPI
        }

        guard let coordinate = coordinate else { return nil }
        self.init(address: address, coordinate: coordinate)
    }
}
</code>```

Keep all restaurants regardless of location data

This is the easiest case. If location is not essential, make it optional:

```<code>class Restaurant {

    var id: String
    var placeId: String
    var name: String
    var location: Location? //Location + address + coordinate + distance
    var phone: String?
    let details: RestaurantDetails

    init(id:String, placeId:String, name:String, location: Location?, details: RestaurantDetails) {

        self.id = id
        self.placeId = placeId
        self.name = name
        self.location = location
        self.details = details
    }

    convenience init?(dict:[String:Any]) {
        guard let id = dict["id"] as? String,
            let placeId = dict["place_id"] as? String,
            let name = dict["name"] as? String else { return nil }

        // Use the address from the dictionary unless it is nil, in which case substitute an empty string
        let address = dict["formatted_address"] as? String ?? ""

        let location = Location(address: address, json: dict["geometry"] as? [String : Any])

        if let price = dict["price_level"] as? Double {
            print("price => \(Price(valueDouble: price))")
        }

        if let rating = dict["rating"] as? Double {
            print("rating => \(Rating(valueDouble: rating))")
        }

        guard let details = RestaurantDetails(json: dict) else { return nil }

        self.init(id: id, placeId: placeId, name: name, location: location, details: details)
    }

}
</code>```

Body:
I am working on a demo app to return a list of restaurant with the google places API.

I have a Restaurant class - 1 property is a custom type RestaurantDetails. This is where the challenge is:

Restaurant.swift

class Restaurant {

    var id:String
    var placeId:String
    var name:String
    var location: Location //Location + address + coordinate + distance
    var phone:String?
    let details : RestaurantDetails

    init(id:String, placeId:String, name:String, location: Location, details: RestaurantDetails) {
        self.id = id
        self.placeId = placeId
        self.name = name
        self.location = location
        self.details = details
    }

    convenience init(dict:[String:Any]) {
        let id = dict["id"] as! String
        let placeId = dict["place_id"] as! String
        let name = dict["name"] as! String
        let address = dict["formatted_address"] as? String
        let location = Location(address: address!, json: dict["geometry"] as! [String : Any])

        if let price = dict["price_level"] as? Double {
            print("price => \(Price(valueDouble: price))")
        }

        if let rating = dict["rating"] as? Double {
            print("rating => \(Rating(valueDouble: rating))")
        }

        self.init(id: id, placeId: placeId, name: name, location: location!, details: RestaurantDetails(json: dict)!)
    }

}

the initialization of the details property fails each time
even using the breakpoint does not help to debug the error because the custom init? does not seem to fire. I do not see any syntax error though
I am usually using guard let control flow to parse the JSON format if the value exists. unsuccessful.
the breakpoint does not kick in on the RestaurantDetails.swift file

RestaurantDetails.swift

enum Price {
    case cheap, expensive, `default`

    init(valueDouble: Double) {
        switch valueDouble {
        case 0..<2: self = .cheap
        case 2..<4 : self = .expensive
        default: self = .default
        }
    }

    var dollarSymbol : String {
        switch self {
        case .cheap: return "$"
        case .expensive: return "$$"
        default: return ""
        }
    }
}

enum Rating {
    case low, fair, good, excellent, `default`

    init(valueDouble: Double) {
        switch valueDouble {
        case 0..<2: self = .low
        case 3..<4: self = .fair
        case 4..<5: self = .good
        case 6 : self = .excellent
        default: self = .default
        }
    }

    var starSymbol : String {
        switch self {
        case .low: return "⭐"
        case .fair: return "⭐⭐"
        case .good: return "⭐⭐⭐"
        case .excellent: return "⭐⭐⭐⭐"
        default: return ""
        }
    }
}

struct RestaurantDetails {
    let price:Price
    let rating:Rating // Rating (enum) (filter)
    let openNow: Bool //(filter)
    let types : [String]?
    let photos : [NSDictionary]?
}

extension RestaurantDetails {

    init?(json: [String: Any]) {

        guard let price = json["price_level"] as? Double,
            let rating = json["rating"] as? Double,
            let openingHours = json["opening_hours"] as? NSDictionary,
            let types = json["types"] as? [String],
            let photos = json["photos"] as? [NSDictionary] else {
            return nil
        }

        print("json details : \(json)")

        self.price = Price(valueDouble: price)
        self.rating = Rating(valueDouble: rating)
        self.openNow = openingHours["open_now"] as! Bool != nil ?? false
        self.types = types
        self.photos = photos
    }
}

I also have a Location.swift file that works perfectly

struct Location {
    var address :String
    var coordinate:(lat:Double, lng:Double)
}

extension Location {
    init?(address: String, json:[String:Any]) {
        guard let latitude = json["location"] as? NSDictionary, let longitude = json["location"] as? NSDictionary else { return nil }

        self.init(address: address, coordinate: (lat: latitude["lat"] as! Double, lng: longitude["lng"] as! Double))
    }
}

Body:
As vadian described in his comment, the issue causing the crash is that location has a failable initializer, you are forcibly unwrapping it, and since initialization is in fact failing, you have now force-unwrapped a nil value.

The broader questions are: what do you, the developer, want to happen when some or all location data is not available, and what is the best way to go about doing that?

Options for handling incomplete or missing location data

Based on your description of the problem (“a demo app to return a list of restaurant with the google places api”), it is not clear whether or not restaurants without useable location data should enter your model. It is also not clear whether or not there is some location data you could do without. So I see three options:

Discard all restaurants with incomplete location data

Discard some restaurants with incomplete location data while keeping others

Keep all restaurants regardless of location data

To implement these options, you may want to use some common tools for dealing with optionals:

Nil-coalescing operator

a = b ?? c

Set a equal to b, unless b is nil, in which case set a equal to c.

Optional binding in guard and if

guard let a = b else { return }

Set a equal to b unless b is nil, in which case return from the current context. You can do work in the else branch prior to returning.

if let a = b { /* Do work using a */ } else { /* Do other work */ }

If b is not nil, enter the if branch and  set a equal to b; if b is nil, enter the else branch.

How to do it

Discard all restaurants with incomplete location data

In this case, you could make a failable initializer for Restaurant, guarded by location being non-nil:

/// Initialization fails if `location` is `nil`
convenience init?(id:String, placeId:String, name:String, location: Location?, details: RestaurantDetails) {
    guard let location = location else { return nil }

    self.init(id: id, placeId: placeId, name: name, location: location, details: details)
}

Discard some restaurants with incomplete location data while keeping others

You may be able to recover from some kinds of missing location data. For example, it may be the case that you really just need the street address string and the latitude and longitude are inessential. You could rewrite your Location struct to reflect that:

struct Location {
    var address: String
    var coordinate: (lat: Double, lng: Double)?
}

extension Location {
    init?(address: String, json:[String:Any]) {
        let coordinate: (Double, Double)?
        if let latitude = json["location"] as? NSDictionary, let longitude = json["location"] as? NSDictionary {
            coordinate = (latitude, longitude)
        } else {
            coordinate = nil
        }

        self.init(address: address, coordinate: coordinate)
    }
}

Alternative, lat/long might be the important part, but it might sometimes be possible to recover them from the street address using another API:

struct Location {
    var address: String
    var coordinate: (lat: Double, lng: Double)
}

extension Location {
    init?(address: String, json:[String:Any]) {
        let coordinate: (Double, Double)?
        if let latitude = json["location"] as? NSDictionary, let longitude = json["location"] as? NSDictionary {
            coordinate = (latitude, longitude)
        } else {

            /* An API call that takes an address string and tries to return lat/long but might return nil */

            coordinate = returnedCoordinateFromAPI
        }

        guard let coordinate = coordinate else { return nil }
        self.init(address: address, coordinate: coordinate)
    }
}

Keep all restaurants regardless of location data

This is the easiest case. If location is not essential, make it optional:

class Restaurant {

    var id: String
    var placeId: String
    var name: String
    var location: Location? //Location + address + coordinate + distance
    var phone: String?
    let details: RestaurantDetails

    init(id:String, placeId:String, name:String, location: Location?, details: RestaurantDetails) {

        self.id = id
        self.placeId = placeId
        self.name = name
        self.location = location
        self.details = details
    }

    convenience init?(dict:[String:Any]) {
        guard let id = dict["id"] as? String,
            let placeId = dict["place_id"] as? String,
            let name = dict["name"] as? String else { return nil }

        // Use the address from the dictionary unless it is nil, in which case substitute an empty string
        let address = dict["formatted_address"] as? String ?? ""

        let location = Location(address: address, json: dict["geometry"] as? [String : Any])

        if let price = dict["price_level"] as? Double {
            print("price => \(Price(valueDouble: price))")
        }

        if let rating = dict["rating"] as? Double {
            print("rating => \(Rating(valueDouble: rating))")
        }

        guard let details = RestaurantDetails(json: dict) else { return nil }

        self.init(id: id, placeId: placeId, name: name, location: location, details: details)
    }

}


问:
Siebel > Empty Column name is being selected when clicked on Button with CopyRecord method
I am trying to copy a record in Siebel and I used venilla method CopyRecord. I placed a button on the applet and called CopyRecord method behind it. On clicking the method I am getting this error on UI:

```<code>SBL-DBC-00105: An error has occurred executing a Sql statement.

Please continue or ask your systems administrator to check your application configuration if the problem persists.
</code>```

I checked in logs and here is the details:

```<code>DBCLog  DBCLogError 1   000000025a2722fc:0  2017-12-06 03:31:01 OCIStmtExecute: SELECT
      T19.CONFLICT_ID,
      T19.LAST_UPD,
      T19.CREATED,
      T19.LAST_UPD_BY,
      T19.CREATED_BY,
      T19.MODIFICATION_NUM,
      T19.ROW_ID,
      T19.ROW_ID,
      T19.LAST_UPD,
      T19.,
      T19.APPEALED_FLG,
      T19.PS_APPL_ID,
      T19.APPR_TEMP_ID,
      T19.EVAL_ASSESS_ID,
      T19.ASGN_USR_EXCLD_FLG,
      T19.AUDIT_EMP_ID,
      T19.X_AUDIT_SERIAL_NUM,
      T16.X_CPC,
      T19.CASE_NUM,
      T16.ATTRIB_44,
      T19.SERIAL_NUM,
      T16.ATTRIB_01,
      T19.CATEGORY_TYPE_CD,
      T19.CITY,
      T19.CLASS_CD,
      T19.CLOSED_DT,
      T16.ATTRIB_42,
      T16.ATTRIB_47,
      T16.ATTRIB_45,
      T19.COUNTRY,
      T16.ATTRIB_44,
      T19.CASE_DT,
      T16.ATTRIB_07,
      T19.DESC_TEXT,
      T19.X_REFER_TO_PROSECUTION_FLG,
      T19.X_ASSIGN_AUTO_MANUAL,
      T16.ATTRIB_04,
      T19.X_REHAB_COURT_PROCEEDING_FLAG,
      T16.ATTRIB_09,
      T19.X_APPLICANT_ID,
      T19.X_CASE_CHARGES,
      T19.X_COURT_SESSION_DT,
      T19.X_COURT_SESSION_DT,
      T7.OCCUR_DT,
      T19.X_CRNT_SESSN_ID,
      T19.X_DIVISION_NAME,
      T10.POSTN_ID,
      T19.X_JOINCASE_FLG,
      T19.X_JOINCASE_ID,
      T16.ATTRIB_26,
      T19.,
      T19.X_OLD_SERIAL_NUM,
      T19.X_ON_BEHALF_ID,
      T19.X_PANEL_ID,
      T13.NAME,
      T19.X_PANEL_SCHED_ID,
      T8.POSTN_ID,
      T19.X_OFFENSE_ID,
      T16.X_POLICE_DIVISION,
      T19.X_POLICE_OTHERS,
      T4.POSTN_TYPE_CD,
      T16.X_REHAB_ARCHIVE_REASON,
      T16.X_REHAB_DESCRIPTION,
      T16.X_DATE_1,
      T19.X_ROOT_ROW_ID,
      T19.X_SR_ID,
      T16.X_REHAB_NOTES,
      T15.OCCUR_DT,
      T19.X_CLOB_02,
      T19.ORG_GROUP_ID,
      T19.CHANGED_FLG,
      T19.X_CASE_NAME,
      T16.X_COURTHOUSE,
      T16.X_DISPOSITION,
      T16.X_DISTRICT_NUM,
      T16.X_INTERPRETER,
      T16.X_JUDGE,
      T16.X_JURISDICTION,
      T16.X_PROSECUTOR,
      T16.X_STATUES,
      T19.X_FILING_APPEAL_DATE,
      T19.TYPE_CD,
      T19.X_BUNDLE_ID,
      T19.X_CM_TYPE,
      T19.X_CASE_DATE,
      T19.X_PARTY_TYPE,
      T16.CATEGORY_CODE,
      T19.X_COMPLEXITY,
      T19.X_CONVICTED,
      T19.X_CONVICTED_ID,
      T19.X_COPY_APPLY_DATE,
      T19.X_COPY_ISSUANCE_DATE,
      T19.X_COPY_JUDGMENT_DT,
      T19.X_COURT_FEE_VALUE,
      T19.X_DAYS_APPLICABLE,
      T16.ATTRIB_24,
      T19.LOCAL_SEQ_NUM,
      T19.X_DIARY_DATE,
      T19.X_DIARY_NUM,
      T16.X_DISABLED_FLAG,
      T19.X_DISTRICT,
      T19.X_JUDGE_ID,
      T19.X_FIR_NUM,
      T19.X_FIR_REGISTRATION_DT,
      T16.X_FAST_TRACK,
      T19.X_FEE_APPLICABLE,
      T19.X_FEE_TO_PAY,
      T16.X_FEMALE_FLAG,
      T16.X_GOVT_OFFICIAL,
      T19.X_IS_APPEAL,
      T19.X_IS_REVISION,
      T19.X_JUDGE_DESIGNATION,
      T19.X_JUDGE_NAME_URDU,
      T19.X_JUDGEMENT_DT,
      T16.X_JUVENILE_FLAG,
      T19.X_LEGAL_TIME_ELASPED,
      T19.X_COUNTY,
      T19.X_OTHER_CATEGORY,
      T16.X_OVERSEAS,
      T14.SERIAL_NUM,
      T14.X_SRL_NUMBER,
      T14.X_CASE_NAME,
      T14.X_SRL_NUMBER,
      T14.STATUS_CD,
      T19.X_QUEUE_NUMBER,
      T16.X_RAPE_CASE,
      T19.X_REASON_OF_URGENCY,
      T19.X_REVIEW_FLG,
      T16.X_SENIOR_CITIZEN_FLAG,
      T19.X_SPECIAL_TAG,
      T16.X_STAY,
      T19.X_SUB_CATEGORY,
      T19.X_SUBJECT_OF_CASE,
      T19.X_YEAR,
      T16.TIME_ELAPSED,
      T19.X_TODAY_FLG,
      T16.ATTRIB_03,
      T19.X_WINDING_UP_CLOSURE,
      T19.X_REF_NUMBER,
      T19.MSTR_CASE_ID,
      T19.NAME,
      T16.ATTRIB_25,
      T16.ATTRIB_06,
      T16.X_ORG_UNIT,
      T16.ATTRIB_07,
      T6.OWNER_PER_ID,
      T16.ATTRIB_41,
      T19.PAR_CASE_ID,
      T16.ATTRIB_46,
      T16.ATTRIB_37,
      T19.X_CLOB_01,
      T19.PR_AGENCY_ID,
      T19.PR_REP_DNRM_FLG,
      T19.PR_REP_MANL_FLG,
      T19.PR_REP_SYS_FLG,
      T19.PR_SGROUP_ID,
      T19.BU_ID,
      T19.PR_PRTNR_ID,
      T19.PR_POSTN_ID,
      T19.PR_PROD_INT_ID,
      T19.PR_SUSPCT_ID,
      T16.ATTRIB_39,
      T19.ASGN_DT,
      T16.X_ATTRIB_DSC_03,
      T16.X_RECVD_FROM_ID,
      T19.REWARD_AMT,
      T19.REWARD_CURCY_CD,
      T19.REWARD_EXCH_DATE,
      T19.X_SRL_NUMBER,
      T19.X_SERIAL_

ObjMgrLog   Error   1   000000025a2722fc:0  2017-12-06 03:31:01 (oracon.cpp (3899)) SBL-DBC-00105: An error has occurred executing a Sql statement.

Please continue or ask your systems administrator to check your application configuration if the problem persists.

SQLParseAndExecute  Execute 5   000000025a2722fc:0  2017-12-06 03:31:01 ORA-01747: invalid user.table.column, table.column, or column specification
</code>```

In the spool, the logs are:

```<code>SELECT
      T19.CONFLICT_ID,
      T19.LAST_UPD,
      T19.CREATED,
      T19.LAST_UPD_BY,
      T19.CREATED_BY,
      T19.MODIFICATION_NUM,
      T19.ROW_ID,
      T19.ROW_ID,
      T19.LAST_UPD,
      T19.,
      T19.APPEALED_FLG,
      T19.PS_APPL_ID,
      T19.APPR_TEMP_ID,
      T19.EVAL_ASSESS_ID,
      T19.ASGN_USR_EXCLD_FLG,
      T19.AUDIT_EMP_ID,
      T19.X_AUDIT_SERIAL_NUM,
      T16.X_CPC,
      T19.CASE_NUM,
      T16.ATTRIB_44,
      T19.SERIAL_NUM,
      T16.ATTRIB_01,
      T19.CATEGORY_TYPE_CD,
      T19.CITY,
      T19.CLASS_CD,
      T19.CLOSED_DT,
      T16.ATTRIB_42,
      T16.ATTRIB_47,
      T16.ATTRIB_45,
      T19.COUNTRY,
      T16.ATTRIB_44,
      T19.CASE_DT,
      T16.ATTRIB_07,
      T19.DESC_TEXT,
      T19.X_REFER_TO_PROSECUTION_FLG,
      T19.X_ASSIGN_AUTO_MANUAL,
      T16.ATTRIB_04,
      T19.X_REHAB_COURT_PROCEEDING_FLAG,
      T16.ATTRIB_09,
      T19.X_APPLICANT_ID,
      T19.X_CASE_CHARGES,
      T19.X_COURT_SESSION_DT,
      T19.X_COURT_SESSION_DT,
      T7.OCCUR_DT,
      T19.X_CRNT_SESSN_ID,
      T19.X_DIVISION_NAME,
      T10.POSTN_ID,
      T19.X_JOINCASE_FLG,
      T19.X_JOINCASE_ID,
      T16.ATTRIB_26,
      T19.,
      T19.X_OLD_SERIAL_NUM,
      T19.X_ON_BEHALF_ID,
      T19.X_PANEL_ID,
      T13.NAME,
      T19.X_PANEL_SCHED_ID,
      T8.POSTN_ID,
      T19.X_OFFENSE_ID,
      T16.X_POLICE_DIVISION,
      T19.X_POLICE_OTHERS,
      T4.POSTN_TYPE_CD,
      T16.X_REHAB_ARCHIVE_REASON,
      T16.X_REHAB_DESCRIPTION,
      T16.X_DATE_1,
      T19.X_ROOT_ROW_ID,
      T19.X_SR_ID,
      T16.X_REHAB_NOTES,
      T15.OCCUR_DT,
      T19.X_CLOB_02,
      T19.ORG_GROUP_ID,
      T19.CHANGED_FLG,
      T19.X_CASE_NAME,
      T16.X_COURTHOUSE,
      T16.X_DISPOSITION,
      T16.X_DISTRICT_NUM,
      T16.X_INTERPRETER,
      T16.X_JUDGE,
      T16.X_JURISDICTION,
      T16.X_PROSECUTOR,
      T16.X_STATUES,
      T19.X_FILING_APPEAL_DATE,
      T19.TYPE_CD,
      T19.X_BUNDLE_ID,
      T19.X_CM_TYPE,
      T19.X_CASE_DATE,
      T19.X_PARTY_TYPE,
      T16.CATEGORY_CODE,
      T19.X_COMPLEXITY,
      T19.X_CONVICTED,
      T19.X_CONVICTED_ID,
      T19.X_COPY_APPLY_DATE,
      T19.X_COPY_ISSUANCE_DATE,
      T19.X_COPY_JUDGMENT_DT,
      T19.X_COURT_FEE_VALUE,
      T19.X_DAYS_APPLICABLE,
      T16.ATTRIB_24,
      T19.LOCAL_SEQ_NUM,
      T19.X_DIARY_DATE,
      T19.X_DIARY_NUM,
      T16.X_DISABLED_FLAG,
      T19.X_DISTRICT,
      T19.X_JUDGE_ID,
      T19.X_FIR_NUM,
      T19.X_FIR_REGISTRATION_DT,
      T16.X_FAST_TRACK,
      T19.X_FEE_APPLICABLE,
      T19.X_FEE_TO_PAY,
      T16.X_FEMALE_FLAG,
      T16.X_GOVT_OFFICIAL,
      T19.X_IS_APPEAL,
      T19.X_IS_REVISION,
      T19.X_JUDGE_DESIGNATION,
      T19.X_JUDGE_NAME_URDU,
      T19.X_JUDGEMENT_DT,
      T16.X_JUVENILE_FLAG,
      T19.X_LEGAL_TIME_ELASPED,
      T19.X_COUNTY,
      T19.X_OTHER_CATEGORY,
      T16.X_OVERSEAS,
      T14.SERIAL_NUM,
      T14.X_SRL_NUMBER,
      T14.X_CASE_NAME,
      T14.X_SRL_NUMBER,
      T14.STATUS_CD,
      T19.X_QUEUE_NUMBER,
      T16.X_RAPE_CASE,
      T19.X_REASON_OF_URGENCY,
      T19.X_REVIEW_FLG,
      T16.X_SENIOR_CITIZEN_FLAG,
      T19.X_SPECIAL_TAG,
      T16.X_STAY,
      T19.X_SUB_CATEGORY,
      T19.X_SUBJECT_OF_CASE,
      T19.X_YEAR,
      T16.TIME_ELAPSED,
      T19.X_TODAY_FLG,
      T16.ATTRIB_03,
      T19.X_WINDING_UP_CLOSURE,
      T19.X_REF_NUMBER,
      T19.MSTR_CASE_ID,
      T19.NAME,
      T16.ATTRIB_25,
      T16.ATTRIB_06,
      T16.X_ORG_UNIT,
      T16.ATTRIB_07,
      T6.OWNER_PER_ID,
      T16.ATTRIB_41,
      T19.PAR_CASE_ID,
      T16.ATTRIB_46,
      T16.ATTRIB_37,
      T19.X_CLOB_01,
      T19.PR_AGENCY_ID,
      T19.PR_REP_DNRM_FLG,
      T19.PR_REP_MANL_FLG,
      T19.PR_REP_SYS_FLG,
      T19.PR_SGROUP_ID,
      T19.BU_ID,
      T19.PR_PRTNR_ID,
      T19.PR_POSTN_ID,
      T19.PR_PROD_INT_ID,
      T19.PR_SUSPCT_ID,
      T16.ATTRIB_39,
      T19.ASGN_DT,
      T16.X_ATTRIB_DSC_03,
      T16.X_RECVD_FROM_ID,
      T19.REWARD_AMT,
      T19.REWARD_CURCY_CD,
      T19.REWARD_EXCH_DATE,
      T19.X_SRL_NUMBER,
      T19.X_SERIAL_ISSUANCE_DATE,
      T19.STATE,
      T19.STATUS_CD,
      T19.STATUS_CD,
      T19.SUB_STATUS_CD,
      T16.ATTRIB_43,
      T19.PR_SUBJECT_ID,
      T19.SUBJECT_NAME,
      T19.SUBJECT_PH_NUM,
      T17.FST_NAME,
      T17.LAST_NAME,
      T19.TERRITORY_TYPE_CD,
      T19.CRIME_TYPE_CD,
      T19.THREAT_LVL_CD,
      T19.CRIME_SUB_TYPE_CD,
      T19.TYPE_CD,
      T19.X_URGENT_CASE_FLG,
      T19.X_VALUE_JURISDICTION,
      T19.BU_ID,
      T19.X_CASE_MODE,
      T16.X_REHAB_TYPE,
      T19.X_RELATIONSHIP,
      T13.X_PANEL_TYPE,
      T19.X_COURT_STAGE,
      T19.PRIORITY_TYPE_CD,
      T16.ATTRIB_05,
      T16.ATTRIB_38,
      T19.X_RECEIVING_METHOD,
      T19.X_REHAB_STATUS,
      T19.SOURCE_CD,
      T19.STAGE_CD,
      T19.SUB_TYPE_CD,
      T5.ROW_ID,
      T11.LOGIN,
      T3.FST_NAME,
      T3.SPOUSE_LAST_NAME,
      T2.FST_NAME,
      T2.SPOUSE_LAST_NAME,
      T16.ROW_ID,
      T16.PAR_ROW_ID,
      T16.MODIFICATION_NUM,
      T16.CREATED_BY,
      T16.LAST_UPD_BY,
      T16.CREATED,
      T16.LAST_UPD,
      T16.CONFLICT_ID,
      T16.PAR_ROW_ID,
      T12.ROW_ID,
      T5.ROW_ID,
      T18.ROW_ID,
      T9.ROW_ID
   FROM
       SIEBEL.S_POSTN T1,
       SIEBEL.S_CONTACT T2,
       SIEBEL.S_CONTACT T3,
       SIEBEL.S_POSTN T4,
       SIEBEL.S_PARTY T5,
       SIEBEL.S_CONTACT T6,
       SIEBEL.S_INCIDENT T7,
       SIEBEL.S_CASE_POSTN T8,
       SIEBEL.S_PARTY T9,
       SIEBEL.S_CASE_POSTN T10,
       SIEBEL.S_USER T11,
       SIEBEL.S_CASE_POSTN T12,
       SIEBEL.S_PROJ T13,
       SIEBEL.S_CASE T14,
       SIEBEL.S_INCIDENT T15,
       SIEBEL.S_CASE_X T16,
       SIEBEL.S_CONTACT T17,
       SIEBEL.S_PARTY T18,
       SIEBEL.S_CASE T19
   WHERE
      T19.AUDIT_EMP_ID = T6.PAR_ROW_ID (+) AND
      T19.X_CRNT_SESSN_ID = T7.ROW_ID (+) AND
      T19.X_PANEL_ID = T13.ROW_ID (+) AND
      T19.ROW_ID = T10.CASE_ID (+) AND T10.X_PANEL_ROLE (+) = 'Head of Bench' AND
      T19.ROW_ID = T8.CASE_ID (+) AND T8.X_PANEL_ROLE (+) = 'Panel Secretary' AND
      T19.PAR_CASE_ID = T14.ROW_ID (+) AND T19.PAR_CASE_ID = T14.ROW_ID (+) AND
      T19.PR_POSTN_ID = T4.PAR_ROW_ID (+) AND
      T19.ROW_ID = T15.X_CASE_ID (+) AND T15.X_STATUS_CD (+) = 'Scheduled' AND
      T19.PR_SUBJECT_ID = T17.ROW_ID (+) AND
      T19.ROW_ID = T16.PAR_ROW_ID (+) AND
      T19.PR_POSTN_ID = T12.POSTN_ID AND T19.ROW_ID = T12.CASE_ID AND
      T12.POSTN_ID = T5.ROW_ID AND
      T12.POSTN_ID = T1.PAR_ROW_ID (+) AND
      T1.PR_EMP_ID = T11.PAR_ROW_ID (+) AND
      T19.X_ON_BEHALF_ID = T18.ROW_ID (+) AND
      T19.X_ON_BEHALF_ID = T3.PAR_ROW_ID (+) AND
      T19.X_APPLICANT_ID = T9.ROW_ID (+) AND
      T19.X_APPLICANT_ID = T2.PAR_ROW_ID (+) AND
      (T19.X_PARTY_TYPE = 'CM') AND
      (T19.PAR_CASE_ID = '1-348TLP')
</code>```

Now from above logs, the problem is T19., is being selected without a column name. I checked and all fields have proper columns. I am not sure how to debug it further.

答:
I found the issue and here is how i did it.

I cloned the same BC disabled all disabled following one by one and kept testing:

Escripts

User properties

Multi-valued fields

Removed the duplicate fields mapping on the same column

Removed the fields with no column / calculated value at all

Inactivated all other fields which

After doing that i was able to use CopyRecord method.

Body:
I am trying to copy a record in Siebel and I used venilla method CopyRecord. I placed a button on the applet and called CopyRecord method behind it. On clicking the method I am getting this error on UI:

SBL-DBC-00105: An error has occurred executing a Sql statement.

Please continue or ask your systems administrator to check your application configuration if the problem persists.

I checked in logs and here is the details:

DBCLog  DBCLogError 1   000000025a2722fc:0  2017-12-06 03:31:01 OCIStmtExecute: SELECT
      T19.CONFLICT_ID,
      T19.LAST_UPD,
      T19.CREATED,
      T19.LAST_UPD_BY,
      T19.CREATED_BY,
      T19.MODIFICATION_NUM,
      T19.ROW_ID,
      T19.ROW_ID,
      T19.LAST_UPD,
      T19.,
      T19.APPEALED_FLG,
      T19.PS_APPL_ID,
      T19.APPR_TEMP_ID,
      T19.EVAL_ASSESS_ID,
      T19.ASGN_USR_EXCLD_FLG,
      T19.AUDIT_EMP_ID,
      T19.X_AUDIT_SERIAL_NUM,
      T16.X_CPC,
      T19.CASE_NUM,
      T16.ATTRIB_44,
      T19.SERIAL_NUM,
      T16.ATTRIB_01,
      T19.CATEGORY_TYPE_CD,
      T19.CITY,
      T19.CLASS_CD,
      T19.CLOSED_DT,
      T16.ATTRIB_42,
      T16.ATTRIB_47,
      T16.ATTRIB_45,
      T19.COUNTRY,
      T16.ATTRIB_44,
      T19.CASE_DT,
      T16.ATTRIB_07,
      T19.DESC_TEXT,
      T19.X_REFER_TO_PROSECUTION_FLG,
      T19.X_ASSIGN_AUTO_MANUAL,
      T16.ATTRIB_04,
      T19.X_REHAB_COURT_PROCEEDING_FLAG,
      T16.ATTRIB_09,
      T19.X_APPLICANT_ID,
      T19.X_CASE_CHARGES,
      T19.X_COURT_SESSION_DT,
      T19.X_COURT_SESSION_DT,
      T7.OCCUR_DT,
      T19.X_CRNT_SESSN_ID,
      T19.X_DIVISION_NAME,
      T10.POSTN_ID,
      T19.X_JOINCASE_FLG,
      T19.X_JOINCASE_ID,
      T16.ATTRIB_26,
      T19.,
      T19.X_OLD_SERIAL_NUM,
      T19.X_ON_BEHALF_ID,
      T19.X_PANEL_ID,
      T13.NAME,
      T19.X_PANEL_SCHED_ID,
      T8.POSTN_ID,
      T19.X_OFFENSE_ID,
      T16.X_POLICE_DIVISION,
      T19.X_POLICE_OTHERS,
      T4.POSTN_TYPE_CD,
      T16.X_REHAB_ARCHIVE_REASON,
      T16.X_REHAB_DESCRIPTION,
      T16.X_DATE_1,
      T19.X_ROOT_ROW_ID,
      T19.X_SR_ID,
      T16.X_REHAB_NOTES,
      T15.OCCUR_DT,
      T19.X_CLOB_02,
      T19.ORG_GROUP_ID,
      T19.CHANGED_FLG,
      T19.X_CASE_NAME,
      T16.X_COURTHOUSE,
      T16.X_DISPOSITION,
      T16.X_DISTRICT_NUM,
      T16.X_INTERPRETER,
      T16.X_JUDGE,
      T16.X_JURISDICTION,
      T16.X_PROSECUTOR,
      T16.X_STATUES,
      T19.X_FILING_APPEAL_DATE,
      T19.TYPE_CD,
      T19.X_BUNDLE_ID,
      T19.X_CM_TYPE,
      T19.X_CASE_DATE,
      T19.X_PARTY_TYPE,
      T16.CATEGORY_CODE,
      T19.X_COMPLEXITY,
      T19.X_CONVICTED,
      T19.X_CONVICTED_ID,
      T19.X_COPY_APPLY_DATE,
      T19.X_COPY_ISSUANCE_DATE,
      T19.X_COPY_JUDGMENT_DT,
      T19.X_COURT_FEE_VALUE,
      T19.X_DAYS_APPLICABLE,
      T16.ATTRIB_24,
      T19.LOCAL_SEQ_NUM,
      T19.X_DIARY_DATE,
      T19.X_DIARY_NUM,
      T16.X_DISABLED_FLAG,
      T19.X_DISTRICT,
      T19.X_JUDGE_ID,
      T19.X_FIR_NUM,
      T19.X_FIR_REGISTRATION_DT,
      T16.X_FAST_TRACK,
      T19.X_FEE_APPLICABLE,
      T19.X_FEE_TO_PAY,
      T16.X_FEMALE_FLAG,
      T16.X_GOVT_OFFICIAL,
      T19.X_IS_APPEAL,
      T19.X_IS_REVISION,
      T19.X_JUDGE_DESIGNATION,
      T19.X_JUDGE_NAME_URDU,
      T19.X_JUDGEMENT_DT,
      T16.X_JUVENILE_FLAG,
      T19.X_LEGAL_TIME_ELASPED,
      T19.X_COUNTY,
      T19.X_OTHER_CATEGORY,
      T16.X_OVERSEAS,
      T14.SERIAL_NUM,
      T14.X_SRL_NUMBER,
      T14.X_CASE_NAME,
      T14.X_SRL_NUMBER,
      T14.STATUS_CD,
      T19.X_QUEUE_NUMBER,
      T16.X_RAPE_CASE,
      T19.X_REASON_OF_URGENCY,
      T19.X_REVIEW_FLG,
      T16.X_SENIOR_CITIZEN_FLAG,
      T19.X_SPECIAL_TAG,
      T16.X_STAY,
      T19.X_SUB_CATEGORY,
      T19.X_SUBJECT_OF_CASE,
      T19.X_YEAR,
      T16.TIME_ELAPSED,
      T19.X_TODAY_FLG,
      T16.ATTRIB_03,
      T19.X_WINDING_UP_CLOSURE,
      T19.X_REF_NUMBER,
      T19.MSTR_CASE_ID,
      T19.NAME,
      T16.ATTRIB_25,
      T16.ATTRIB_06,
      T16.X_ORG_UNIT,
      T16.ATTRIB_07,
      T6.OWNER_PER_ID,
      T16.ATTRIB_41,
      T19.PAR_CASE_ID,
      T16.ATTRIB_46,
      T16.ATTRIB_37,
      T19.X_CLOB_01,
      T19.PR_AGENCY_ID,
      T19.PR_REP_DNRM_FLG,
      T19.PR_REP_MANL_FLG,
      T19.PR_REP_SYS_FLG,
      T19.PR_SGROUP_ID,
      T19.BU_ID,
      T19.PR_PRTNR_ID,
      T19.PR_POSTN_ID,
      T19.PR_PROD_INT_ID,
      T19.PR_SUSPCT_ID,
      T16.ATTRIB_39,
      T19.ASGN_DT,
      T16.X_ATTRIB_DSC_03,
      T16.X_RECVD_FROM_ID,
      T19.REWARD_AMT,
      T19.REWARD_CURCY_CD,
      T19.REWARD_EXCH_DATE,
      T19.X_SRL_NUMBER,
      T19.X_SERIAL_

ObjMgrLog   Error   1   000000025a2722fc:0  2017-12-06 03:31:01 (oracon.cpp (3899)) SBL-DBC-00105: An error has occurred executing a Sql statement.

Please continue or ask your systems administrator to check your application configuration if the problem persists.

SQLParseAndExecute  Execute 5   000000025a2722fc:0  2017-12-06 03:31:01 ORA-01747: invalid user.table.column, table.column, or column specification

In the spool, the logs are:

SELECT
      T19.CONFLICT_ID,
      T19.LAST_UPD,
      T19.CREATED,
      T19.LAST_UPD_BY,
      T19.CREATED_BY,
      T19.MODIFICATION_NUM,
      T19.ROW_ID,
      T19.ROW_ID,
      T19.LAST_UPD,
      T19.,
      T19.APPEALED_FLG,
      T19.PS_APPL_ID,
      T19.APPR_TEMP_ID,
      T19.EVAL_ASSESS_ID,
      T19.ASGN_USR_EXCLD_FLG,
      T19.AUDIT_EMP_ID,
      T19.X_AUDIT_SERIAL_NUM,
      T16.X_CPC,
      T19.CASE_NUM,
      T16.ATTRIB_44,
      T19.SERIAL_NUM,
      T16.ATTRIB_01,
      T19.CATEGORY_TYPE_CD,
      T19.CITY,
      T19.CLASS_CD,
      T19.CLOSED_DT,
      T16.ATTRIB_42,
      T16.ATTRIB_47,
      T16.ATTRIB_45,
      T19.COUNTRY,
      T16.ATTRIB_44,
      T19.CASE_DT,
      T16.ATTRIB_07,
      T19.DESC_TEXT,
      T19.X_REFER_TO_PROSECUTION_FLG,
      T19.X_ASSIGN_AUTO_MANUAL,
      T16.ATTRIB_04,
      T19.X_REHAB_COURT_PROCEEDING_FLAG,
      T16.ATTRIB_09,
      T19.X_APPLICANT_ID,
      T19.X_CASE_CHARGES,
      T19.X_COURT_SESSION_DT,
      T19.X_COURT_SESSION_DT,
      T7.OCCUR_DT,
      T19.X_CRNT_SESSN_ID,
      T19.X_DIVISION_NAME,
      T10.POSTN_ID,
      T19.X_JOINCASE_FLG,
      T19.X_JOINCASE_ID,
      T16.ATTRIB_26,
      T19.,
      T19.X_OLD_SERIAL_NUM,
      T19.X_ON_BEHALF_ID,
      T19.X_PANEL_ID,
      T13.NAME,
      T19.X_PANEL_SCHED_ID,
      T8.POSTN_ID,
      T19.X_OFFENSE_ID,
      T16.X_POLICE_DIVISION,
      T19.X_POLICE_OTHERS,
      T4.POSTN_TYPE_CD,
      T16.X_REHAB_ARCHIVE_REASON,
      T16.X_REHAB_DESCRIPTION,
      T16.X_DATE_1,
      T19.X_ROOT_ROW_ID,
      T19.X_SR_ID,
      T16.X_REHAB_NOTES,
      T15.OCCUR_DT,
      T19.X_CLOB_02,
      T19.ORG_GROUP_ID,
      T19.CHANGED_FLG,
      T19.X_CASE_NAME,
      T16.X_COURTHOUSE,
      T16.X_DISPOSITION,
      T16.X_DISTRICT_NUM,
      T16.X_INTERPRETER,
      T16.X_JUDGE,
      T16.X_JURISDICTION,
      T16.X_PROSECUTOR,
      T16.X_STATUES,
      T19.X_FILING_APPEAL_DATE,
      T19.TYPE_CD,
      T19.X_BUNDLE_ID,
      T19.X_CM_TYPE,
      T19.X_CASE_DATE,
      T19.X_PARTY_TYPE,
      T16.CATEGORY_CODE,
      T19.X_COMPLEXITY,
      T19.X_CONVICTED,
      T19.X_CONVICTED_ID,
      T19.X_COPY_APPLY_DATE,
      T19.X_COPY_ISSUANCE_DATE,
      T19.X_COPY_JUDGMENT_DT,
      T19.X_COURT_FEE_VALUE,
      T19.X_DAYS_APPLICABLE,
      T16.ATTRIB_24,
      T19.LOCAL_SEQ_NUM,
      T19.X_DIARY_DATE,
      T19.X_DIARY_NUM,
      T16.X_DISABLED_FLAG,
      T19.X_DISTRICT,
      T19.X_JUDGE_ID,
      T19.X_FIR_NUM,
      T19.X_FIR_REGISTRATION_DT,
      T16.X_FAST_TRACK,
      T19.X_FEE_APPLICABLE,
      T19.X_FEE_TO_PAY,
      T16.X_FEMALE_FLAG,
      T16.X_GOVT_OFFICIAL,
      T19.X_IS_APPEAL,
      T19.X_IS_REVISION,
      T19.X_JUDGE_DESIGNATION,
      T19.X_JUDGE_NAME_URDU,
      T19.X_JUDGEMENT_DT,
      T16.X_JUVENILE_FLAG,
      T19.X_LEGAL_TIME_ELASPED,
      T19.X_COUNTY,
      T19.X_OTHER_CATEGORY,
      T16.X_OVERSEAS,
      T14.SERIAL_NUM,
      T14.X_SRL_NUMBER,
      T14.X_CASE_NAME,
      T14.X_SRL_NUMBER,
      T14.STATUS_CD,
      T19.X_QUEUE_NUMBER,
      T16.X_RAPE_CASE,
      T19.X_REASON_OF_URGENCY,
      T19.X_REVIEW_FLG,
      T16.X_SENIOR_CITIZEN_FLAG,
      T19.X_SPECIAL_TAG,
      T16.X_STAY,
      T19.X_SUB_CATEGORY,
      T19.X_SUBJECT_OF_CASE,
      T19.X_YEAR,
      T16.TIME_ELAPSED,
      T19.X_TODAY_FLG,
      T16.ATTRIB_03,
      T19.X_WINDING_UP_CLOSURE,
      T19.X_REF_NUMBER,
      T19.MSTR_CASE_ID,
      T19.NAME,
      T16.ATTRIB_25,
      T16.ATTRIB_06,
      T16.X_ORG_UNIT,
      T16.ATTRIB_07,
      T6.OWNER_PER_ID,
      T16.ATTRIB_41,
      T19.PAR_CASE_ID,
      T16.ATTRIB_46,
      T16.ATTRIB_37,
      T19.X_CLOB_01,
      T19.PR_AGENCY_ID,
      T19.PR_REP_DNRM_FLG,
      T19.PR_REP_MANL_FLG,
      T19.PR_REP_SYS_FLG,
      T19.PR_SGROUP_ID,
      T19.BU_ID,
      T19.PR_PRTNR_ID,
      T19.PR_POSTN_ID,
      T19.PR_PROD_INT_ID,
      T19.PR_SUSPCT_ID,
      T16.ATTRIB_39,
      T19.ASGN_DT,
      T16.X_ATTRIB_DSC_03,
      T16.X_RECVD_FROM_ID,
      T19.REWARD_AMT,
      T19.REWARD_CURCY_CD,
      T19.REWARD_EXCH_DATE,
      T19.X_SRL_NUMBER,
      T19.X_SERIAL_ISSUANCE_DATE,
      T19.STATE,
      T19.STATUS_CD,
      T19.STATUS_CD,
      T19.SUB_STATUS_CD,
      T16.ATTRIB_43,
      T19.PR_SUBJECT_ID,
      T19.SUBJECT_NAME,
      T19.SUBJECT_PH_NUM,
      T17.FST_NAME,
      T17.LAST_NAME,
      T19.TERRITORY_TYPE_CD,
      T19.CRIME_TYPE_CD,
      T19.THREAT_LVL_CD,
      T19.CRIME_SUB_TYPE_CD,
      T19.TYPE_CD,
      T19.X_URGENT_CASE_FLG,
      T19.X_VALUE_JURISDICTION,
      T19.BU_ID,
      T19.X_CASE_MODE,
      T16.X_REHAB_TYPE,
      T19.X_RELATIONSHIP,
      T13.X_PANEL_TYPE,
      T19.X_COURT_STAGE,
      T19.PRIORITY_TYPE_CD,
      T16.ATTRIB_05,
      T16.ATTRIB_38,
      T19.X_RECEIVING_METHOD,
      T19.X_REHAB_STATUS,
      T19.SOURCE_CD,
      T19.STAGE_CD,
      T19.SUB_TYPE_CD,
      T5.ROW_ID,
      T11.LOGIN,
      T3.FST_NAME,
      T3.SPOUSE_LAST_NAME,
      T2.FST_NAME,
      T2.SPOUSE_LAST_NAME,
      T16.ROW_ID,
      T16.PAR_ROW_ID,
      T16.MODIFICATION_NUM,
      T16.CREATED_BY,
      T16.LAST_UPD_BY,
      T16.CREATED,
      T16.LAST_UPD,
      T16.CONFLICT_ID,
      T16.PAR_ROW_ID,
      T12.ROW_ID,
      T5.ROW_ID,
      T18.ROW_ID,
      T9.ROW_ID
   FROM
       SIEBEL.S_POSTN T1,
       SIEBEL.S_CONTACT T2,
       SIEBEL.S_CONTACT T3,
       SIEBEL.S_POSTN T4,
       SIEBEL.S_PARTY T5,
       SIEBEL.S_CONTACT T6,
       SIEBEL.S_INCIDENT T7,
       SIEBEL.S_CASE_POSTN T8,
       SIEBEL.S_PARTY T9,
       SIEBEL.S_CASE_POSTN T10,
       SIEBEL.S_USER T11,
       SIEBEL.S_CASE_POSTN T12,
       SIEBEL.S_PROJ T13,
       SIEBEL.S_CASE T14,
       SIEBEL.S_INCIDENT T15,
       SIEBEL.S_CASE_X T16,
       SIEBEL.S_CONTACT T17,
       SIEBEL.S_PARTY T18,
       SIEBEL.S_CASE T19
   WHERE
      T19.AUDIT_EMP_ID = T6.PAR_ROW_ID (+) AND
      T19.X_CRNT_SESSN_ID = T7.ROW_ID (+) AND
      T19.X_PANEL_ID = T13.ROW_ID (+) AND
      T19.ROW_ID = T10.CASE_ID (+) AND T10.X_PANEL_ROLE (+) = 'Head of Bench' AND
      T19.ROW_ID = T8.CASE_ID (+) AND T8.X_PANEL_ROLE (+) = 'Panel Secretary' AND
      T19.PAR_CASE_ID = T14.ROW_ID (+) AND T19.PAR_CASE_ID = T14.ROW_ID (+) AND
      T19.PR_POSTN_ID = T4.PAR_ROW_ID (+) AND
      T19.ROW_ID = T15.X_CASE_ID (+) AND T15.X_STATUS_CD (+) = 'Scheduled' AND
      T19.PR_SUBJECT_ID = T17.ROW_ID (+) AND
      T19.ROW_ID = T16.PAR_ROW_ID (+) AND
      T19.PR_POSTN_ID = T12.POSTN_ID AND T19.ROW_ID = T12.CASE_ID AND
      T12.POSTN_ID = T5.ROW_ID AND
      T12.POSTN_ID = T1.PAR_ROW_ID (+) AND
      T1.PR_EMP_ID = T11.PAR_ROW_ID (+) AND
      T19.X_ON_BEHALF_ID = T18.ROW_ID (+) AND
      T19.X_ON_BEHALF_ID = T3.PAR_ROW_ID (+) AND
      T19.X_APPLICANT_ID = T9.ROW_ID (+) AND
      T19.X_APPLICANT_ID = T2.PAR_ROW_ID (+) AND
      (T19.X_PARTY_TYPE = 'CM') AND
      (T19.PAR_CASE_ID = '1-348TLP')

Now from above logs, the problem is T19., is being selected without a column name. I checked and all fields have proper columns. I am not sure how to debug it further.


问:
How to change form action dynamically with Laravel + VueJS
I have a route setup like this:

```<code>Route::post('subjects/{subject}/{tag}', 'TagController@show');
</code>```

And I have the following form structure, where I am populating the options of a select element by looping through a $tags array:

```<code><form id="tagForm" method="POST"
action="/subjects/{{ $lesson->subject->slug }}/{{ 'selected option will go here' }}">
    {{ csrf_field() }}
   <div class="select">
      <select @change="onTagSelected">
        <option>Tags</option>
        @foreach ($tags as $tag)
                <option value="{{ $tag->id }}">{{ $tag->title }}</option>
        @endforeach
      </select>
    </div>
</form>
</code>```

How can I change the form action according to the currently selected tag from the option?

I am using Vue.js as js framework and I am listening for onchange event:

```<code>onTagSelected: function(event) {
        var tagForm = document.getElementById('tagForm');
// what should I do here to change the action?
        tagForm.submit();
}
</code>```

答:
I had to bind the select tag to a v-model property:

```<code><form id="tagForm" method="POST" action="/subjects/{{ $lesson->subject->slug }}/">
    {{ csrf_field() }}
   <div class="select">
      <select @change="onTagSelected" v-model="selectedTag">
        <option>Tags</option>
        @foreach ($tags as $tag)
            <option value="{{ $tag->id }}">{{ $tag->title }}</option>
        @endforeach
      </select>
    </div>
</form>
</code>```

And in my event listener, I am appending the property to the action and then submitting it:

```<code>onTagSelected: function(event) {
        var tagForm = document.getElementById('tagForm');
        tagForm.action += this.selectedTag;
        // console.log(tagForm.action);
        tagForm.submit();
}
</code>```

Although this solves my problem, but I am not happy with it. I think there is better way to do this. Please feel free to share the best solution for circumstances like this.

Body:
I have a route setup like this:

Route::post('subjects/{subject}/{tag}', 'TagController@show');

And I have the following form structure, where I am populating the options of a select element by looping through a $tags array:

<form id="tagForm" method="POST"
action="/subjects/{{ $lesson->subject->slug }}/{{ 'selected option will go here' }}">
    {{ csrf_field() }}

      <select @change="onTagSelected">
        <option>Tags</option>
        @foreach ($tags as $tag)
                <option value="{{ $tag->id }}">{{ $tag->title }}</option>
        @endforeach
      </select>

</form>

How can I change the form action according to the currently selected tag from the option?

I am using Vue.js as js framework and I am listening for onchange event:

onTagSelected: function(event) {
        var tagForm = document.getElementById('tagForm');
// what should I do here to change the action?
        tagForm.submit();
}

Body:
I had to bind the select tag to a v-model property:

<form id="tagForm" method="POST" action="/subjects/{{ $lesson->subject->slug }}/">
    {{ csrf_field() }}
   <div class="select">
      <select @change="onTagSelected" v-model="selectedTag">
        <option>Tags</option>
        @foreach ($tags as $tag)
            <option value="{{ $tag->id }}">{{ $tag->title }}</option>
        @endforeach
      </select>
    </div>
</form>

And in my event listener, I am appending the property to the action and then submitting it:

onTagSelected: function(event) {
        var tagForm = document.getElementById('tagForm');
        tagForm.action += this.selectedTag;
        // console.log(tagForm.action);
        tagForm.submit();
}

Although this solves my problem, but I am not happy with it. I think there is better way to do this. Please feel free to share the best solution for circumstances like this.

ContentLicense: CC BY-SA 4.0


问:
ActiveAdmin logout button without current_user_method
We are not using devise for auth. The user and session is managed by owned app controller. Just want to show "logout" button in active admin ui - which will call a path.

```<code>config.logout_link_path = :login_logout_path
config.logout_link_method = :get
</code>```

login_logout_path is the correct servlet path needs to be hit for logout. the controller reads all necessary args from session. But setting just above two in initialiser isn't making the "logout" button appear in the ActiveAdmin UI.

I am guessing it is because of no current_user_method - I commented following in the config.

```<code>  #config.current_user_method = :current_admin_user
</code>```

How can we show logout button without current_user_method?

答: So long as you have a method in ApplicationController that will return a truthy value when a user is logged in (eg. by reading from the session), I think that is good enough to use instead of :current_admin_user.

Body:
We are not using devise for auth. The user and session is managed by owned app controller. Just want to show "logout" button in active admin ui - which will call a path.

config.logout_link_path = :login_logout_path
config.logout_link_method = :get

login_logout_path is the correct servlet path needs to be hit for logout. the controller reads all necessary args from session. But setting just above two in initialiser isn't making the "logout" button appear in the ActiveAdmin UI.

I am guessing it is because of no current_user_method - I commented following in the config.

  #config.current_user_method = :current_admin_user

How can we show logout button without current_user_method?


问:
How to parse ant like path
How do I parse paths such as /aaa/bbb/**/*.java as used in ant. I guess I could have looked into the source code. Is there is simple solution.

答: I wonder if you might be able to use ant itself for that.. Check out How to parse and interpret ant's build.xml. It shows how to get the path used by ant. I am not sure what you are looking to do..</p>

Title: How to parse ant like path


问:
Increase AVCapturePhotoOutput's maxBracketedCapturePhotoCount value
I'm trying to take more than 4 images during bracketed capture. Is there a way to edit the maxBracketedCapturePhotoCount from the AVCapturePhotoOutput class?</p>

答:
From ProCam 5 Tutorial

"Exposure bracketing is a photography technique where 3  shots or more (4 brackets on iPhone 5 and later, and 3 brackets on older devices)"

So I guess you are out of luck.


问:
Setting Radio button default value from state
I have a vuejs application, during login, I get all the user's settings in my vuex state.

One of the settings defaultView can have a value of either 1 or 2 depending on the user's selection.

I get this value from the state:

```<code>  ...mapGetters({
      'defaultView'
  })
</code>```

I'm my data hook I have this:

```<code>data () {
   return {
     selected: defaultView ? defaultView : 2
   }
}
</code>```

but selected is always 2, ignoring the value of defaultView.

I have tried using the mounted hook to set the value, but on page refresh, it loses the value.

How do I set the default value of selected from the state object?

答:
Set the value in created.

```<code>created(){
  this.selected = this.defaultView || 2
}
</code>```

Body:
I have a vuejs application, during login, I get all the user's settings in my vuex state.

One of the settings defaultView can have a value of either 1 or 2 depending on the user's selection.

I get this value from the state:

  ...mapGetters({
      'defaultView'
  })

I'm my data hook I have this:

data () {
   return {
     selected: defaultView ? defaultView : 2
   }
}

but selected is always 2, ignoring the value of defaultView.

I have tried using the mounted hook to set the value, but on page refresh, it loses the value.

How do I set the default value of selected from the state object?

Body:
Set the value in created.

created(){
  this.selected = this.defaultView || 2
}


答:
From the datamodel documentation:

If __new__() does not return an instance of cls, then the new instance’s __init__() method will not be invoked.

So, try again like this:

```<code>class foo(object):
    def __new__(cls, *args, **kwargs):
        print 'in superclass __new__'
        return super(foo, cls).__new__(cls, *args, **kwargs)

class bar(foo):
    def __init__(self, *args, **kwargs):
        print 'in subclass __init__'
        self.val = 42
</code>```

Title: Subclass __init__ is not called if superclass __new__ is defined

Body:
From the datamodel documentation:

If __new__() does not return an instance of cls, then the new instance’s __init__() method will not be invoked.

So, try again like this:

class foo(object):
    def __new__(cls, *args, **kwargs):
        print 'in superclass __new__'
        return super(foo, cls).__new__(cls, *args, **kwargs)

class bar(foo):
    def __init__(self, *args, **kwargs):
        print 'in subclass __init__'
        self.val = 42


答:
Another way if the name a,b,... are not required.</p>

```<code>while read line;do
  set -- $line
  echo '$3 = '"$3"' $6 = '"$6"
done< infile
</code>```

Title: Bash script part data in row with regex

Body:
Let say I have file test.txt and it look like this:

14.03.2016  12:01:58    0001039 28,427    0,200     28,427  28,437  28,427
14.03.2016  12:02:28    0001090 28,442    0,200     28,442  28,439  28,444
14.03.2016  12:02:58    0001139 28,469    0,230     28,459  28,469  28,504

I need to parse this with bash script so that I get for each row:

a = 14.03.2016
b = 12:01:58
c = 0001039
d = 0,200

I am not sure how to do this with grep.

Body:
Another way if the name a,b,... are not required.

while read line;do
  set -- $line
  echo '$3 = '"$3"' $6 = '"$6"
done< infile


问:
MailChimp ajax post returns "Recipient has too many recent sign up requests"
I am trying to make an ajax call that adds a new subscriber to my MailChimp list.
I tried the solution on this thread
Mailchimp subscribe using jQuery AJAX?

```<code> $.ajax({
    url: 'http://xxxxx.us#.list-manage.com/subscribe/post-json??u=xxxxx&id=xxxx&c=?',
    type: 'GET',
    data: data,
    dataType: 'jsonp',
    contentType: "application/json; charset=utf-8",
    success: function (data) {
       if (data['result'] != "success") {
            //ERROR
            console.log(data['msg']);
       } else {
           console.log('Hooray');
       }
    }
});
</code>```

However I am getting an error that says

Recipient has too many recent sign up request

I noticed that whenever I add post to the sign-up URL the error appears
Even when opening the sign-up form URL from the browser

答: For me, I had JSON.stringify(data). Once I removed JSON.Stringify() and just passed in the data object, it works.</p>

Body:
I am trying to make an ajax call that adds a new subscriber to my MailChimp list.
I tried the solution on this thread
Mailchimp subscribe using jQuery AJAX?

 $.ajax({
    url: 'http://xxxxx.us#.list-manage.com/subscribe/post-json??u=xxxxx&id=xxxx&c=?',
    type: 'GET',
    data: data,
    dataType: 'jsonp',
    contentType: "application/json; charset=utf-8",
    success: function (data) {
       if (data['result'] != "success") {
            //ERROR
            console.log(data['msg']);
       } else {
           console.log('Hooray');
       }
    }
});

However I am getting an error that says

Recipient has too many recent sign up request

I noticed that whenever I add post to the sign-up URL the error appears
Even when opening the sign-up form URL from the browser


问:
pycharm variable and comment color
For some reason when I declare a variable within a function using PyCharm, the font color is the same as if it were a comment (See picture). Anyone else having this problem? I didn't change any setting it just started happening, very frustrating!

答: This is due to x is not used by any other function or code. If you hover your cursor over it for few second, the warning would tell you what's the reason.</p>

Title: pycharm variable and comment color