text:
Q: jQuery .bind is being executed more than once? Original code: (can be seen working here: http://sandbox.hokuten.net/jqrpg/)
/* google.setOnLoadCallback(function() { */
$(function() {

jqr = new Object();
jqr.settings = new Object();
jqr.settings.sprite_width = 16;
jqr.settings.sprite_height = 16;
jqr.settings.space = false;

jqr.p = new Object();
function jqrpgResetPlayer() {
    jqr.p.face = 'd';
    jqr.p.x = 3;
    jqr.p.y = 3;
    jqr.p.state = 'map';
}

jqr.map = new Object();
jqr.map.height  = 16;
jqr.map.width   = 16;
jqr.map.terrain = [
 '01','02','03','11','11','11','11','11','11','11','11','11','11','11','11','11',
 '01','01','00','00','11','00','00','11','11','00','00','00','00','00','00','00',
 '01','00','00','00','11','00','00','00','00','11','00','00','00','00','00','00',
 '01','00','00','00','00','00','00','11','00','11','00','00','00','00','00','00',
 '01','00','00','00','00','00','00','11','00','11','11','11','11','00','00','00',
 '00','00','00','00','00','11','11','00','00','00','00','00','11','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','00','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','00','00','00','11','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','11','01','01','01',
 '00','00','00','00','00','00','00','00','00','11','11','11','00','00','00','01',
 '00','00','00','00','00','00','00','00','00','00','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','00','00','00','00','00','00','00',
];
jqr.map.terrain_walkable = [
 '00','01','02',
];

jqr.battle = new Object();

jqrpgBuildMapHtml();
jqrpgUpdateMapClasses();
jqrpgResetPlayer();
jqrpgSetPlayerFace(jqr.p.face);
jqrpgSetPlayer(jqr.p.x, jqr.p.y);
jqrpgBindKeys();

/**
 * only call this once
 */
function jqrpgBuildInterface() {
    $('#jqrpg_wrapper').width($('#jqrpg_screen').width());
}
function jqrpgBuildMapHtml() {
    $('#jqrpg_screen, #jqrpg_wrapper').height(jqr.map.height * jqr.settings.sprite_height)
     .width(jqr.map.width * jqr.settings.sprite_width);
    m = $('#jqrpg_map');
    m.empty();
    for (y = 0; y < jqr.map.height; y++) {
        for (x = 0; x < jqr.map.width; x++) {
            // cti = y * x; // current_tile_index
            // <![CDATA[
            m.append('.');
            // ]]>
        }
    }
}

/**
 * call this whenever enter a new screen
 */
function jqrpgUpdateMapClasses() {
    for (y = 0; y < jqr.map.height; y++) {
        for (x = 0; x < jqr.map.width; x++) {
            cti = y * jqr.map.height + x; // current_tile_index
            ct = $('#jqrpg_map span').eq(cti);
            ct.removeClass()
             .addClass('tile')
             .addClass('tile_x' + x + 'y'+ y)
             .addClass('tile_' + jqr.map.terrain[cti]);
            if (y && x == 0) ct.addClass('tile_row');
        }
    }
    $('#jqrpg_map').fadeIn('slow');
}
function jqrpgSetPlayerFace(new_face) {
    $('#jqrpg_player').removeClass().addClass('face_' + new_face);
}
function jqrpgSetPlayer(new_x, new_y) {
    $('#jqrpg_player').css({
     'left' : new_x * jqr.settings.sprite_width,
     'top' : new_y * jqr.settings.sprite_height
    });
}

/**
 * key binding
 */
function jqrpgBindKeys() {
    $(document).bind('keydown', 'up', function() {
        if (jqr.p.state != 'map') return false;
        jqrpgSetPlayerFace('u');
        return jqrpgMovePlayer(0, -1);
    })
    .bind('keydown', 'Down', function() {
        if (jqr.p.state != 'map') return false;
        jqrpgSetPlayerFace('d');
        return jqrpgMovePlayer(0, 1);
    })
    .bind('keydown', 'Left', function() {
        if (jqr.p.state != 'map') return false;
        jqrpgSetPlayerFace('l');
        return jqrpgMovePlayer(-1, 0);
    })
    .bind('keydown', 'Right', function() {
        if (jqr.p.state != 'map') return false;
        jqrpgSetPlayerFace('r');
        return jqrpgMovePlayer(1, 0);
    })
    .bind('keypress', 'Space', function() {
        // if (console) console.log('space');
        if (jqr.p.state == 'map') return false;
        jqr.settings.space = true;
        if (jqr.p.state == 'battle') jqrpgBattle();
        return true;
    });
}

/**
 * movement
 */
function jqrpgMovePlayer(new_x, new_y) {
    // if (console) console.log('x: ' + jqr.p.x + '  y: ' + jqr.p.y);
    if (jqr.p.x + new_x + 1 > jqr.map.width
     || jqr.p.y + new_y + 1 > jqr.map.height
     || jqr.p.x + new_x + 1 == 0
     || jqr.p.y + new_y + 1 == 0
     || !jqrpgIsTileWalkable(jqr.p.x + new_x, jqr.p.y + new_y)
    ) return;
    jqr.p.x += new_x;   jqr.p.y += new_y;

    $('#jqrpg_player').dequeue().animate({
     left: jqr.p.x * jqr.settings.sprite_width,
     top: jqr.p.y * jqr.settings.sprite_height
    },
    250,
    function() {
        jqrpgGetRandomBattle();
    });
    return true;
}
function jqrpgIsTileWalkable(x, y) {
    return jQuery.inArray(jqr.map.terrain[(y) * 16 + x], jqr.map.terrain_walkable) > -1;
}
/**
 * battle
 */
function jqrpgGetRandomBattle() {
    var likelihood = Math.floor(Math.random() * 6) + 1;
    if (likelihood == 1) {
        jqrpgBattleInit();
    }
}
function jqrpgBattleInit() {
    jqr.p.state = 'battle';
    m = $('#jqrpg_menu');
    m.show();
    // <![CDATA[
    m.html('
Random battle! Press [space] to continue.
');
    // ]]>
    $('#jqrpg_wrapper').css({'border-color' : '#a00'});
}
function jqrpgBattle() {
    if (jqr.settings.space) {
        jqr.settings.space = false;
        jqrpgBattleEnd();
    }
}
function jqrpgBattleEnd() {
    jqr.p.state = 'map';
    $('#jqrpg_wrapper').css({'border-color' : '#000'});
    m.fadeOut('fast');
}

});

My code: (Can be seen working here: http://project-vanquish.co.cc/jQRPG/)
$(function() {

jqr = new Object();
jqr.settings = new Object();
jqr.settings.sprite_width = 16;
jqr.settings.sprite_height = 16;
jqr.settings.space = false;

jqr.p = new Object();
function jqrpgResetPlayer() {
    jqr.p.face = 'd';
    jqr.p.x = 3;
    jqr.p.y = 3;
    jqr.p.state = 'map';
}

jqr.map = new Object();
jqr.map.height  = 16;
jqr.map.width   = 16;
jqr.map.terrain = [
 '01','02','03','11','11','11','11','11','11','11','11','11','11','11','11','11',
 '01','01','00','00','11','00','00','11','11','00','00','00','00','00','00','00',
 '01','00','00','00','11','00','00','00','00','11','00','00','00','00','00','00',
 '01','00','00','00','00','00','00','11','00','11','00','00','00','00','00','00',
 '01','00','00','00','00','00','00','11','00','11','11','11','11','00','00','00',
 '00','00','00','00','00','11','11','00','00','00','00','00','11','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','00','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','00','00','00','11','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','11','00','00','11','01','01','01',
 '00','00','00','00','00','00','00','00','00','11','11','11','00','00','00','01',
 '00','00','00','00','00','00','00','00','00','00','00','00','00','00','00','00',
 '00','00','00','00','00','00','00','00','00','00','00','00','00','00','00','00',
];
jqr.map.terrain_walkable = [
 '00','01','02',
];

jqr.battle = new Object();

jqrpgBuildMapHtml();
jqrpgUpdateMapClasses();
jqrpgResetPlayer();
jqrpgSetPlayerFace(jqr.p.face);
jqrpgSetPlayer(jqr.p.x, jqr.p.y);
jqrpgBindKeys();

/**
 * only call this once
 */
function jqrpgBuildInterface() {
    $('#jqrpg_wrapper').width($('#jqrpg_screen').width());
}
function jqrpgBuildMapHtml() {
    $('#jqrpg_screen, #jqrpg_wrapper').height(jqr.map.height * jqr.settings.sprite_height)
     .width(jqr.map.width * jqr.settings.sprite_width);
    m = $('#jqrpg_map');
    m.empty();
    for (y = 0; y < jqr.map.height; y++) {
        for (x = 0; x < jqr.map.width; x++) {
            // cti = y * x; // current_tile_index
            // <![CDATA[
            m.append('.');
            // ]]>
        }
    }
}

/**
 * call this whenever enter a new screen
 */
function jqrpgUpdateMapClasses() {
    for (y = 0; y < jqr.map.height; y++) {
        for (x = 0; x < jqr.map.width; x++) {
            cti = y * jqr.map.height + x; // current_tile_index
            ct = $('#jqrpg_map span').eq(cti);
            ct.removeClass()
             .addClass('tile')
             .addClass('tile_x' + x + 'y'+ y)
             .addClass('tile_' + jqr.map.terrain[cti]);
            if (y && x == 0) ct.addClass('tile_row');
        }
    }
    $('#jqrpg_map').fadeIn('slow');
}
function jqrpgSetPlayerFace(new_face) {
    $('#jqrpg_player').removeClass().addClass('face_' + new_face);
}
function jqrpgSetPlayer(new_x, new_y) {
    $('#jqrpg_player').css({
     'left' : new_x * jqr.settings.sprite_width,
     'top' : new_y * jqr.settings.sprite_height
    });
}

/**
 * key binding
 */
function jqrpgBindKeys() {
    $(document).bind('keydown', 'up', function() {
        if (jqr.p.state != 'map') return false;
        jqrpgSetPlayerFace('u');
        return jqrpgMovePlayer(0, -1);
    })
    .bind('keydown', 'Down', function() {
        if (jqr.p.state != 'map') return false;
        jqrpgSetPlayerFace('d');
        return jqrpgMovePlayer(0, 1);
    })
    .bind('keydown', 'Left', function() {
        if (jqr.p.state != 'map') return false;
        jqrpgSetPlayerFace('l');
        return jqrpgMovePlayer(-1, 0);
    })
    .bind('keydown', 'Right', function() {
        if (jqr.p.state != 'map') return false;
        jqrpgSetPlayerFace('r');
        return jqrpgMovePlayer(1, 0);
    })
    .bind('keypress', 'Space', function() {
        // if (console) console.log('space');
        if (jqr.p.state == 'map') return false;
        jqr.settings.space = true;
        if (jqr.p.state == 'battle') jqrpgBattle();
        return true;
    });
}

/**
 * movement
 */
function jqrpgMovePlayer(new_x, new_y) {
    // if (console) console.log('x: ' + jqr.p.x + '  y: ' + jqr.p.y);
    if (jqr.p.x + new_x + 1 > jqr.map.width
     || jqr.p.y + new_y + 1 > jqr.map.height
     || jqr.p.x + new_x + 1 == 0
     || jqr.p.y + new_y + 1 == 0
     || !jqrpgIsTileWalkable(jqr.p.x + new_x, jqr.p.y + new_y)
    ) return;
    jqr.p.x += new_x;   jqr.p.y += new_y;

    $('#jqrpg_player').dequeue().animate({
     left: jqr.p.x * jqr.settings.sprite_width,
     top: jqr.p.y * jqr.settings.sprite_height
    },
    250,
    function() {
        jqrpgGetRandomBattle();
    });
    return true;
}
function jqrpgIsTileWalkable(x, y) {
    return jQuery.inArray(jqr.map.terrain[(y) * 16 + x], jqr.map.terrain_walkable) > -1;
}
/**
 * battle
 */
function jqrpgGetRandomBattle() {
    var likelihood = Math.floor(Math.random() * 6) + 1;
    if (likelihood == 1) {
        jqrpgBattleInit();
    }
}
function jqrpgBattleInit() {
    jqr.p.state = 'battle';
    m = $('#jqrpg_menu');
    m.show();
    // <![CDATA[
    m.html('
Random battle! Press [space] to continue.
');
    // ]]>
    $('#jqrpg_wrapper').css({'border-color' : '#a00'});
}
function jqrpgBattle() {
    if (jqr.settings.space) {
        jqr.settings.space = false;
        jqrpgBattleEnd();
    }
}
function jqrpgBattleEnd() {
    jqr.p.state = 'map';
    $('#jqrpg_wrapper').css({'border-color' : '#000'});
    m.fadeOut('fast');
}

});

So, the problem I have is that my player movement executes more than once (seems to be 3 times).

A: The problem is in how they're doing the bindings, with the 1.4.2 event model re-write that approach just doesn't work anymore, but you can write it to work with 1.4.2, like this:
function jqrpgBindKeys() {
    $(document).bind('keydown', function(e) {
        if (jqr.p.state != 'map' && e.which != 32) return false;
        switch(e.which) {
          case 38: //up
            jqrpgSetPlayerFace('u');
            return jqrpgMovePlayer(0, -1);
          case 40: //down
            jqrpgSetPlayerFace('d');
            return jqrpgMovePlayer(0, 1);
          case 37: //left
            jqrpgSetPlayerFace('l');
            return jqrpgMovePlayer(-1, 0);
          case 39: //right
            jqrpgSetPlayerFace('r');
            return jqrpgMovePlayer(1, 0);
          case 32: //space bar
            if (jqr.p.state == 'map') return false;
            jqr.settings.space = true;
            if (jqr.p.state == 'battle') jqrpgBattle();
            return true;
        }
    });
}

You can give it a try (using jQuery 1.4.2) here. You could also do this via an object map, etc...but this is the quick change version to make it work with 1.4.2.

Separate issue:
The problem is in your webhost, well...screwing with your page.  If you look at the source on http://www.project-vanquish.co.cc/jQRPG/ you'll see this at the end (modified to remove real domains):

That script executing after  causes all sorts of craziness around document.ready and will just give problems in general...if at all possible get rid of it, or try and get it inside .  Some webhosts look for a tag to stick it in, e.g.:

I'd see if you have that option :)


text:
Q: Pandas DataFrame - row comparision and isolation problem I have those DataFrame where I have fathers that are their own grandchild.
I want to isolate the corresponding rows to treat them separately.
df = pd.DataFrame({
    'father' : ['a', 'b', 'e', 'f', 'j', 'k'],
    'son' : ['b', 'a', 'f', 'g', 'k', 'j']
})
df
df2 = pd.DataFrame({
    'father' : [1, 2, 4, 11, 10, 5],
    'son' : [2, 1, 5, 10, 11, 6]
})
df2

We can see that in the first one we want to extract the rows where we find the values ab, ba and jk, kj, because 'a' precedes 'b' and 'b' precedes 'a', idem for 'j' and 'k'.
Same thing in the second one with our integrates 1, 2 and 10, 11.
I tried (in majority but not only) to use things like
df[df[['FH', 'REM']].isin(df[['REM', 'FH']])]
or
df[df[['FH', 'REM']]==df[['REM', 'FH']]]
Ineffectively.
My main problem is that I don't understand how to compare rows between them to do this.

A: You can use frozenset to group your rows:
df['group'] = df.apply(frozenset, axis=1)
print(df)

# Output
  father son   group
0      a   b  (a, b)
1      b   a  (a, b)
2      e   f  (e, f)
3      f   g  (g, f)
4      j   k  (j, k)
5      k   j  (j, k)

After, you can use a boolean mask:
m = df.groupby('group')['group'].transform('count') == 2

>>> df[m]
  father son   group
0      a   b  (a, b)
1      b   a  (a, b)
4      j   k  (j, k)
5      k   j  (j, k)

>>> df[~m]
  father son   group
2      e   f  (e, f)
3      f   g  (g, f)

A: This will show all the rows that are their own grandchild in the same dataframe:
import pandas as pd

df = pd.DataFrame({
    'father' : ['a', 'b', 'e', 'f', 'j', 'k'],
    'son' : ['b', 'a', 'f', 'g', 'k', 'j']
})

print(df.loc[(df['father'].isin(df['son'])) & (df['son'].isin(df['father']))])

Result:
  father son
0      a   b
1      b   a
4      j   k
5      k   j

redpajama_set_name: RedPajamaStackExchange


text:
Q: JSF f:ajax tag inside Jquery datepicker onselect event How can I trigger f:ajax event upon jquery datepicker onselect event
Is it possible?
If so how can I do it?

A: No, that is not possible. The f:ajax functionality is added on the server side to a jsf component. The jQuery datepicker works on the client side.
Use the jQuery ajax functions instead, or one of the JSF based component libraries like Primefaces.

A: If you want to execute <f:ajax on onSelect event you need a workaround cause <f:ajax/> is a JSF tag and cannot be conncted to jquery components the same way it does with JSF ones...,
just place
<h:commandButton id="myButton" style="display:none">
    <f:ajax render="..." listener="..." execute="..."/>
</h:commandButton>

and click on it from onSelect event like this
onSelect: function(dateText, inst) {
    $("#myButton").click(); //this will click the hidden button and execute its `<f:ajax `
}

you might be needing a better selector for $("#myButton") (if its inside form without prependId="false" etc... but  guess it wont be a big deal for you...)
B.T.W
primefaces library already integrated datepicker , the call it p:calendar , so take a look...


text:
Q: Circular reference using XML serialization I have found a solution for handling circular reference when using xml serialization. But in my case I have a List:
public class Category
{
    public Category()
    {
        Items = new List<CategoryItem>();
    }

    public string CategoryName { get; set; }

    public List<CategoryItem> Items { get; set; }
}

and:
public class CategoryItem
{

    public string Link { get; set; }

    public Category Category { get; set; }
}

Program:
  private static void Main(string[] args)
    {
        var programmingCategory = new Category {CategoryName = "Programming"};

        var ciProgramming = new CategoryItem
        {
            Link = "www.stackoverflow.com",
            Category = programmingCategory
        };

        var fooCategory = new CategoryItem
        {
            Category = programmingCategory,
            Link = "www.foo.com"
        };
        programmingCategory.Items.Add(ciProgramming);
        programmingCategory.Items.Add(fooCategory);

        var serializer = new XmlSerializer(typeof (Category));
        var file = new FileStream(FILENAME, FileMode.Create);
        serializer.Serialize(file, programmingCategory);
        file.Close();
    }

I always get an

InvalidOperationException

How can I solve this?

A: You just change CategoryItem model
public class CategoryItem
{
    public string Link { get; set; }
}

Modify this code :
private static void Main(string[] args)
    {
        var programmingCategory = new Category {CategoryName = "Programming"};

        var ciProgramming = new CategoryItem
        {
            Link = "www.stackoverflow.com"
        };

        var fooCategory = new CategoryItem
        {
            Link = "www.foo.com"
        };
        programmingCategory.Items.Add(ciProgramming);
        programmingCategory.Items.Add(fooCategory);

        var serializer = new XmlSerializer(typeof (Category));
        var file = new FileStream(FILENAME, FileMode.Create);
        serializer.Serialize(file, programmingCategory);
        file.Close();
    }

i think it's work fine.Please try this code. I just change your model and get this output.
<?xml version="1.0"?>

-<Category xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<CategoryName>Programming</CategoryName>

-<Items>

-<CategoryItem>

<Link>www.stackoverflow.com</Link>

</CategoryItem>

-<CategoryItem>

<Link>www.foo.com</Link>

</CategoryItem>

</Items>

</Category>


text:
Q: How can I use my own AI model for image recognition in Unity with Vuforia? what I want to do is to inject my own trained model for image recognition into Vuforia while using Unity.
All I know is that Vuforia uses a feature points detection algorithm, and that you can train a deep learning model using the Model Target Generator. I looked into the scripts in Unity in case something can be overridden, but did not find anything useful.
Because I do not want to build a whole AR system, but it appears these have their own recognition systems and interfering with the source code seems unideal.
Is there a way to do this ?
Or if you know how to replace the recognition system in Vuforia (or any AR SDK really), it would be delightful of you to share !
Anyway thanks and have a nice day !


text:
Q: How do I find out the IP address of my Crostini container? I'm running a Node.js server on Crostini, and trying to access it from and Android browser running on the same Chrome OS device via localhost:8080 doesn't work.
I've tried penguin.linux.test:8080, but that didn't work either. Looks like the Android container didn't get the right DNS settings.
So how do I get the IP address of the Linux container? ifconfig is not installed and apt install fails to get it.

A: Even easier is just to use hostname -I. This will output the ip address and nothing else

A: ifconfig is deprecated. Use instead:
ip addr show


text:
Q: Define a method that works on arrays of a specific type of object In C# you can write an extension method like this:
public static Debt[] Foo(this Debt[] arr, int num)
{
    // Do something
}

This would allow you to use Foo() on an array of debts: debts.Foo(3)
Can you do this in Ruby? I know you can write a method that will work on arrays:
class Array
  def foo
    # blah
  end
end

but this works on all types of arrays, not just an array of Debts
Thanks in advance.

A: the extend method is adding the instance methods to a particular object. so in you case it would be:
class YourClass
  def foo
    # blah
  end
end

debts.extend(YourClass)
debts.foo # now foo method is instance method of debts object

Actually it creates singleton class for debts object and then add to it the method. But you can't use this class, that's why it called "ghost" class

A: This would be a little tricky because Ruby arrays are not homogeneous. That is, you can store different types of objects inside of an array. That would lead me to a solution where I need to first verify that all objects in the array are of type Debt, and if they are then I can act on the array using foo.
You can continue to open up Array and add the foo method, but maybe you should create a FooArray instead and extend Array. This way you can redefine some methods such as << and push to ensure you only take Debts. Since you know that only Debts can be added to your array, you could call foo() without worry.

A: I believe you can do this by extending Ruby's Array class or better yet defining your own Array-like class and delegating the selected array methods to the native object.
Stack = Array.extract([
  :last,
  :push,
  :pop,
  :size,
  :clear,
  :inspect,
  :to_s
])

Why this is better than the alternative methods is explained here.


text:
Q: How to correctly notify in QQmlListProperty properties? Whenever I was creating a Q_PROPERTY for later use in Qml I always created a notify signal to tell qml that data changed and needs to be reevaluated.
Now having a Q_PROPERTY of the type QQmlListProperty<T> how can I signalize that an item has been modified, added or removed?
Is this even possible?

A: If you have a list there can't be a propertyChanged() signal, because the object reference stored will remain the same.
Within the list there won't be properties, so no signal is emitted.
You could instead use a descendent of QAbstractListModel which is designed to handle this problem, by wrapping the methods to append, insert etc. in own methods, that then will emit a dataChanged signal that carries the information necessary to find the changes.
Of course you could implement something similar yourself by wrapping a QList in another object, that has a signal that will inform you of the data change. However this won't integrate that nicely with QML as a real model, for at least view will update automatically, when the dataChanged signal is received, and they even only update what is necessary.
Not so, if the model of the View is changed directly, as might happen, if you manually call modelChanged(). In this case, the View would miss the information about the changed parts, so it will just recreate itself completely.


text:
Q: An error occurs when using some () in *ngIf There are two lists as follows.
article = [
  {
  "id": 600,
  "components": [
    {
      "kind": "text",
      "text": "texttext",
    },
    {
      "kind": "title",
      "text": "titletile",
    },
  ]
  "categories": [
    {
      "id": 26,
      "name": "restaurant",
    },
    {
      "id": 51,
      "name": "special",
    }
  ],
  }
];

categoryLists = [
 "children" : [
  {
    "id": 19,
    "name": "extreme"
  },
  {
    "id": 31,
    "name": "series"
  },
  {
    "id": 51,
    "name": "special"
  },
 ]
];

I want to display category.name when ngFor handles article.categories and category.id exists in categoryLists.children with ngIf.
I implemented it in the template as follows.

 e.id === category.id)">{{ category.name }}

However, the following error occurred.
Error: Template parse errors:
Parser Error: Bindings cannot contain assignments

Why is this?
Is there a problem with some ()?

The following processing is done without problems, so there should be no problem with the array.

{{ child.name }}

{{ category.name }}

A: @RahulSingh is right, you can wrap your statement in ts file:
function foo(categoryId: number): boolean {
    return categoryLists.children.some(e => e.id === categoryId)
}

and then call it in html template:

{{ category.name }}

A: As the arrow function has to return the computed value of e.id === category.id keep it in the braces as in the following code. Else, it first checks for e => e.id which is not required behaviour.

 (e.id === category.id))">{{ category.name }}

All the best.


text:
Q: Application Exit on Synthesizer.Speak - System.Speech.dll - Non Microsoft Voices I have an issue in that my understanding of the reason for the issue is alluding me and not so much the process to circumvent the issue. I wonder if someone can further explain why I am getting this issue?
I populate a ComboBox with the Local Computer's Installed Voices:
private void getSystemVoices()
{
foreach (InstalledVoice voiceName in synthesizer.GetInstalledVoices())
{
this.voiceComboBox.Items.Add(voiceName.VoiceInfo.Name);
}
}

My Application is running under x86 CPU so all Installed Voices are populated in this ComboBox. I have some Acapela Voices Installed, I believe they are SAPI 5.1 compliant. Lucy, Heather and Ryan.
I am testing this code to use the Voices:
// Initialize a new instance of the SpeechSynthesizer...
SpeechSynthesizer synthesizer = new SpeechSynthesizer();

// Config the audio output...
synthesizer.SetOutputToDefaultAudioDevice();

// Initialize a new instance of the PromptBuilder...
PromptBuilder promptBuilder = new PromptBuilder();

// Config SSML...
promptBuilder.AppendSsmlMarkup("<voice xml:lang=\"en-AU\">");
promptBuilder.StartVoice(this.voiceComboBox.SelectedItem.ToString());
promptBuilder.AppendText("The quick brown fox jumps over the lazy dog.");
promptBuilder.EndVoice();
promptBuilder.AppendSsmlMarkup("</voice>");

// Speak the prompt...
synthesizer.Speak(promptBuilder);

My Problem:
If I have any of the Voices selected other than "Microsoft Anna", my Application Exits. Even if I use Try/Catch statements. I get no error and no debug info to say an error has occurred. This issue does not occur if I don't change the default Voice.
In my understanding Microsoft Speech API was to be backward compatible?
Microsoft Speech
I am using .net4.5, referenced System.Speech.dll V4.0.0.0.
Is anyone able to explain this behaviour?
[EDIT]
Please Note: The code for SPVoice works:
using SpeechLib;

// SAPI 5.1 Speech Config...
SpVoice voice = new SpVoice();
voice.Rate = speechRate.Value;
voice.Volume = speechVolume.Value;
voice.Voice = voice.GetVoices("", "").Item(voiceComboBox.SelectedIndex);
voice.Speak(readerTextBox.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);

Its only with the Microsoft SpeechSynthesizer that the problem occurs.

A: When your .Net application crashes like that, you will usually see an event in the computers application eventlog. You can find the eventlog by doing the following (Windows 7):

*

*Click start

*Right-click computer or my computer

*In the left treeview, Expand Event Viewer

*Expand Windows Logs

*Click on Application
You should see an error icon in the log, with details about the crash.
If you want to crash an application preventing any try-catch blocks from catching an exception, you can do so intentionally by calling Environment.FailFast(); It is not recommended or to do this normally (except for a few common cases where memory is corrupt or tampering is detected). It will have the same effect as some native code's misbehavior, the Mushroomed-SuperMario among exception throwers :-). Though this does not directly answer your question, the way it blasts through your catches indicates that it is probably an error of similar order (corrupt memory, or the voice detects unlicensed use or such).


text:
Q: user Login web service required using prestashop api I am working on prestashop web services for my android app, i searched a lot in google, but i did not find proper document/proper explanation. Can any one please guide me how to do user login/authentication using prestashop web services?.

A: You can make a call to the customer endpoint filtering by the customer's email. The result would have a "passwd" field, which is a hashed password which could either be md5 or bcrypt since Prestashop supports both. You can then hash the customer's password input and compare with the "passwd" field in the response. If the length of the "passwd" field is 32 (md5), you'll need parameter _COOKIE_KEY_ set in /app/config/parameters.php as a salt to generate your hash;
Make the call like this https://yourprestashopurl.com/api/customers?filter[email]=email@email.com&display=full
For md5 (if passwd is 32 characters long):
$hash = md5(_COOKIE_KEY_ . $input_password);
You can then compare $hash with passwd
For bcrypt (if passwd is 60 characters long):
Option 1:
$verify = password_verify($input_password, passwd);
You can accept $input_password when this returns true, otherwise $input_password is invalid
Option 2:
$hash = password_hash($input_password, PASSWORD_BCRYPT);
You can then compare $hash with passwd
Note: password_hash and password_verify are both built-in php functions since PHP 5.5.0

A: Use the PrestaShop webservices and filter with email and password like below:
http://localhost/api/customers/?filter[email]=test@prestashop.com&filter[password]=19910794b7c0b413e80f58298a8d8300

A: For those who are still searching for this answer:
<?php

    if (isset($_GET["email"]) && isset($_GET["password"]))
    {
        $email =  $_GET["email"];
        $password = $_GET["password"];

        $COOKIE_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

        $jsonurl = "https://XXXXXXXXXXXXXXXXXXXX@example.com/api/customers?filter[email]=".$email."&display=[passwd]&output_format=JSON";
        $json = file_get_contents($jsonurl);
        $json_a = json_decode($json, true);

        $loopone = $json_a['customers'];
        $looptwo = $loopone[0];
        $loopthree = $looptwo['passwd'];

        $ZCpassword = md5($COOKIE_KEY . $password);

        if (strcmp($loopthree, $ZCpassword) == 0) {
            echo "sucess";
        } else {
             echo "fail";
        }

    }
    else
    {
        echo "Error";
    }

?>


text:
Q: How can I deploy Qt applications to other systems? I'm new to C++ and Qt but I've managed to make a simple test program and I was wondering how can I deploy it to other operating systems? Right now I'm on a Mac so how can I make it run on my PC? I've tried to find some answers but the only answers I've seen is how to deploy them already on Windows. Thanks for the help.

A: Well, you need a compiler that targets the architecture you'll run on.  Then you need to install the Qt libraries on the target machine.  Then you can install and run a compiled Qt module.
There are a handful of loaders out there than handle the (conditional) library install, based on what your app needs.  Don't offhand have a reference.  But the guys at Qt Centre Forum probably can give you some more info.
(Keep in mind that C++/Qt is not Java -- no bytecodes -- it needs to be compiled for each different architecture where you want it to run.)

A: Easiest way is to run Windows somehow and compile & build a distribution there. You can use a virtual machine (VMWare/Parallells, slow) or dual-boot (faster), or a separate windows PC altogether.
A VM is a good thing to have anyhow when you want to test your deployment, as it's easy to wipe the machine and re-run the installation.
By using Qt's qmake, you'll get the build done easily enough on other OS:es (or use Qt Creator).
There's also the option of using the CMake/CPack tools instead, as these give you build-anywhere files, as well as multi-platform packaging with a single config file.

A: You can do it with cross compilers, but in my experience it's far, far easier to just build it on the target platform, as that way you can test the application within Qt to make sure there's no twitchiness. Cross-platform doesn't always means perfect across platforms.

A: I use Qt SDK under wine to cross-compile my programs for Windows from Linux.
qmake uses target specifications, i.e. "mkspec"s as they call them. So, in theory, it should be possible to use cross-compilers. But unfortunately all my attempts at using mingw cross-compiler with a custom mkspec have failed. I managed to compile an application but the resulting .exe did not run. There are just too many things to do right that you'll always miss one or two.
As others have pointed, probably the easiest way is to install Qt SDK to the target machine, or to wine if Windows is your only concern, and do the compilation there.


text:
Q: Puppeteer is not moving the mouse while using it inside docker container I'm trying to move the mouse with Puppeteer while running it inside a docker container while recording with ffmpeg the screen.
The issue is that every time I record with ffmpeg the mouse cursor is showing in the recording always in the center of the screen.
In order to remove it I tried to move the mouse away with page.mouse.move() and page.mouse.click().
I tried also page.hover() and tried to use in all this cases each combination of headless true and false.
This is how I set up puppeteer (original code without headless option used):
browser = await puppeteer.connect({
            'browserWSEndpoint': endpoint,
            'defaultViewport': null
        });

const pages = await browser.pages();
const page = pages[0];
await page.goto(url);
console.log("Making page active.");
await page.bringToFront();

I add that if I connect to the container with VNC Viewer I'm perfectly able to move the cursor manually.

A: Resolved by installing xdotool with the docker image and then on the script using:
console.log("Hiding mouse")
let xdotool = spawn("xdotool", [
    'mousemove',
    '0',
    '0'
]);


text:
Q: I believe I made an infinite loop and I don't know where it's being created I'm attempting to practice arrays by creating something where a user can create the list of items for a shop. I want the item names to go to a list box and an array that will be parallel to an array that holds the price and quantity of the item. I also want the user to be able to check the price and quantity of the item by selecting the item in the list box and pressing the check item button. The program crashes when I attempt to use the check item button.
Here is the part where the user adds in their item.
Private Sub btnAdd_click(sender As Object, e As EventArgs) Handles btnAdd.Click
    addName = InputBox("What is the name of the product you wish to add?")
    addPrice = InputBox("What is the price of the product?")
    addQuantity = InputBox("What is the quantity in stock of the product?")
    lstStock.Items.Add(addName)
End Sub

I added the items into the array and I hope I set it up to where it will automatically create the array regardless of length. I believe this may be creating an infinite loop that freezes the program.
Public Sub added(ByRef addlist As String, ByRef addPQ As String)
    Dim nameID As Double = lstStock.Items.Count
    Dim lstCount As Double = lstStock.Items.Count
    Dim lstArrayCount As Double = 0
    Dim num As Double
    Dim lstNum As String
    While lstArrayCount < 1
        lstNum = addName
        lstArrayCount = +1
    End While
    While lstArrayCount < lstCount
        lstNum = lstNum & addName & "}, {"
        lstArrayCount = +1
    End While
    Dim priceQuantityCount As Double
    Dim lstPrice As String
    While priceQuantityCount < 1
        lstPrice = lstPrice & addPrice & ", " & addQuantity & "}"
        priceQuantityCount = +1
    End While
    While priceQuantityCount > 1 And priceQuantityCount < lstCount
        lstPrice = lstPrice & ", {" & addPrice & ", " & addQuantity & "}"
        priceQuantityCount = +1
    End While
    Dim List() As String = {lstNum}
    Dim PriceQuantity(,) As String = {{lstPrice}}
    addlist = List.ToString()
    addPQ = PriceQuantity.ToString()
End Sub

everything freezes when the button is pressed. I put this bit in here just in case. Nothing visual happens except the program freezes and the cpu usage jumps up. No error messages or anything like that.
Private Sub btnCheck_Click(sender As Object, e As EventArgs) Handles btnCheck.Click
    Dim check As String = lstStock.SelectedItem.ToString()
    Dim add1 As String
    Dim add2 As String
    added(add1, add2)
    Dim strPrice As String
    Dim strQuantity As String
    Dim PQArray As String
    Dim intIndex As Integer
    PQArray = add2
    intIndex = PQArray.IndexOf("")
    If intIndex <> -1 Then
        strPrice = PQArray.Substring(0, intIndex)
        strQuantity = PQArray.Substring(intIndex + 1)
    End If
    MessageBox.Show("there are " & "quantity" & " " & check & " in stock priced at $" & "price" & " each.")
    MessageBox.Show(strPrice & "  :  " & strQuantity)
End Sub

End Class

A: Let's start with the three arrays.
A Name array. This will be persisted in the list box itself. The ListBox.Items is an array of Object.
A Price array at the Form level. This should be of type Decimal - good to use for money things.
Private PriceArray(10) As Decimal

A Quantity array at the Form level. This should be of type Integer, whole numbers of in stock items.
Private QuantityArray(10) As Integer

Now let's look at your Add method.
Private Sub btnAdd_click(sender As Object, e As EventArgs) Handles btnAdd.Click
    Dim addName = InputBox("What is the name of the product you wish to add?")
    Dim addPrice = InputBox("What is the price of the product?")
    Dim addQuantity = InputBox("What is the quantity in stock of the product?")
    ListBox1.Items.Add(addName)
    PriceArray(CurrentIndex) = CDec(addPrice)
    QuantityArray(CurrentIndex) = CInt(addQuantity)
    CurrentIndex += 1
End Sub

I changed your 3 variables to local variables (added Dim). I changed the name of the listbox so it would work in my test project. I added the Name to the list box just as you did. The first time this button is clicked the name is add to the Items collection at index 0. I added another form level variable, CurrentIndex. This will keep track of where we are in the arrays. The first time through CurrentIndex is initialized by default to 0. We use Current Index as the index where we fill in the inputted value. Next time we add we need to increment CurrentIndex to the next index.
CurrentIndex += 1

I think you tried to do this but you had the syntax a bit wrong. It is += ; you had = +1 which will just assign 1 to the variable.
Let's think where we are. The name in the list box has an index that matches the index in the price array and the quantity array. The arrays are parallel (concurrent).
To get the information back from our arrays I used the SelectedIndexChanged event.
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
    Dim IndexSelected = ListBox1.SelectedIndex
    TextBox1.Text = PriceArray(IndexSelected).ToString("N2")
    TextBox2.Text = QuantityArray(IndexSelected).ToString
End Sub

We can get the index with the .SelectedIndex property. We use that index to find the matching values in the PriceArray and the QuantityArray. The "N2" after .ToString for the PriceArray tells it to display a number with 2 decimal places.


text:
Q: Finding the lowest upper bound of product of two number using Young's inequality Young's inequality for product can be stated as follows:
$ab \leq \frac{1}{p}a^p + \frac{1}{q}b^q$ where a and b are nonnegative real numbers and p and q are positive real numbers such that 1/p + 1/q = 1.
If we fix a and b, find p, q such that $f(p, q) = \frac{1}{p}a^p + \frac{1}{q}b^q$ is minimum.
Currently I am looking at the approach of equating the partial derivatives of f(p, q) w.r.t. q and p to zero, and find solutions for q and p. However, it looks like there is no closed-form solution.
Please kindly advise.

A: Hint: equality in Young's inequality is iff $a^p=b^q \iff a^x=b^{1-x}$ where $x=\dfrac1q$.  Now can you find $x$, and hence $p, q$ ?


text:
Q: Changing numbers in a string r I have a huge data frame. However, I have similar IDs and these were different observations. What I am trying to do is change the last/last two digit(s) in the column ID. So  for ID alnfru_00001 in row 5 should be alnfru_00006 and so on. this sequence is seen right throughout the data frame even with other IDs. Can anyone provide some assistance?
                ID          PFT        area
        1    alnfru_00001 alnfru Yukon_Delta
        2    alnfru_00002 alnfru Yukon_Delta
        3    alnfru_00003 alnfru Yukon_Delta
        4    alnfru_00004 alnfru Yukon_Delta
        5    alnfru_00001 alnfru Yukon_Delta
        6    alnfru_00002 alnfru Yukon_Delta
        7    alnfru_00003 alnfru Yukon_Delta
        8    alnfru_00004 alnfru Yukon_Delta
        9    alnfru_00005 alnfru Yukon_Delta....................................

        18   alnfru_00001 alnfru Yukon_Delta
        19   alnfru_00002 alnfru Yukon_Delta
        20   alnfru_00003 alnfru Yukon_Delta
        21   alnfru_00004 alnfru Yukon_Delta
        22   alnfru_00001 alnfru Yukon_Delta
        23   alnfru_00002 alnfru Yukon_Delta
        24   alnfru_00003 alnfru Yukon_Delta
        25   alnfru_00004 alnfru Yukon_Delta

The data frame should look like this

            ID          PFT        area
    1    alnfru_00001 alnfru Yukon_Delta
    2    alnfru_00002 alnfru Yukon_Delta
    3    alnfru_00003 alnfru Yukon_Delta
    4    alnfru_00004 alnfru Yukon_Delta
    5    alnfru_00005 alnfru Yukon_Delta
    6    alnfru_00006 alnfru Yukon_Delta
    7    alnfru_00007 alnfru Yukon_Delta
    8    alnfru_00008 alnfru Yukon_Delta
    9    alnfru_00009 alnfru Yukon_Delta....................................

    18   alnfru_00010 alnfru Yukon_Delta
    19   alnfru_00011 alnfru Yukon_Delta
    20   alnfru_00012 alnfru Yukon_Delta
    21   alnfru_00013 alnfru Yukon_Delta
    22   alnfru_00014 alnfru Yukon_Delta
    23   alnfru_00015 alnfru Yukon_Delta
    24   alnfru_00016 alnfru Yukon_Delta
    25   alnfru_00017 alnfru Yukon_Delta

A: Assuming you want the trailing number to track the row number (a little unclear from the question) you can do it like this:
dat <- data.frame(PFT = rep("alnfru", 10000))
head(dat)
#>      PFT
#> 1 alnfru
#> 2 alnfru
#> 3 alnfru
#> 4 alnfru
#> 5 alnfru
#> 6 alnfru

Given a column encoding what the ID leads with a solution is:
dat$ID <- paste(dat$PFT, sprintf("%05d", 1:nrow(dat)), sep = "_")
dat[c(1:3, 9997:10000),]
#>          PFT           ID
#> 1     alnfru alnfru_00001
#> 2     alnfru alnfru_00002
#> 3     alnfru alnfru_00003
#> 9997  alnfru alnfru_09997
#> 9998  alnfru alnfru_09998
#> 9999  alnfru alnfru_09999
#> 10000 alnfru alnfru_10000

If in fact all IDs start with the same leading code you can simply do:
dat$ID <- paste("alnfru", sprintf("%05d", 1:nrow(dat)), sep = "_")


text:
Q: How to implement a simple form with validation in a Vue app (with Vuetify.js)? I'm trying to add a contact form with simple validation on a website built with Vue.js using a Vuetify.js example. I'm a newbie, so I'm not sure how it should be implemented in a Vue component.

I want to achieve a simple client side form validation and make it work with a https://getform.org/ form.

UPDATED:
Code | Contact.vue
(taken from Vuetify.js form example)
<v-form v-model="valid">
      <v-text-field
        label="Name"
        v-model="name"
        :rules="nameRules"
        :counter="10"
        required
        name="Name"
      ></v-text-field>

      <v-text-field
        label="E-mail"
        v-model="email"
        :rules="emailRules"
        required
        name="Email"
      ></v-text-field>

      <v-btn
          @click="submit"
          :disabled="!valid"
      >submit</v-btn>
  </v-form>

  <form method="post" action="https://www.getform.org/f/[MY_ID_HERE]" id="nativeForm"></form>

Script

A:

const app = new Vue({
  el:'#app',
  data:{
    errors:[],
    name:null,
    age:null,
    movie:null
  },
  methods:{
    checkForm:function(e) {
      if(this.name && this.age) return true;
      this.errors = [];
      if(!this.name) this.errors.push("Name required.");
      if(!this.age) this.errors.push("Age required.");
      e.preventDefault();
    }
  }
})
input,select {
  margin-left: 10px;
}

<form id="app" @submit="checkForm" action="/something" method="post">

    Please correct the following error(s):

{{ error }}

    Name
    <input type="text" name="name" id="name" v-model="name">

    Age
    <input type="number" name="age" id="age" v-model="age" min="0">

    Favorite Movie
    <select name="movie" id="movie" v-model="movie">
      <option>Star Wars</option>
      <option>Vanilla Sky</option>
      <option>Atomic Blonde</option>
    </select>

    <input type="submit" value="Submit">

</form>

Add some CSS and done.

A: Managed to make it work by using just 1 form:
<v-form method="post" action="https://www.getform.org/f/[YOUR-FORM-ID]" id="nativeForm" v-model="valid">

      <v-text-field
        label="Name"
        v-model="name"
        :rules="nameRules"
        :counter="10"
        required
        name="message"
      ></v-text-field>
      <v-text-field
        label="E-mail"
        v-model="email"
        :rules="emailRules"
        required
        name="mail"
      ></v-text-field>

      <v-btn @click="submit" :disabled="!valid">submit</v-btn>
 </v-form>

script

Don't forget:
To add name attributes. Getform needs them.


text:
Q: Continue to elif after a nested if-statement? If the nested if-statement doesn't fulfill a condition, how do I continue on to the outer if? Eg. I have this (very impractical) example:
a = 2

if( a > 1 ):
    if( a == 3 ):
        print "yes"
elif( a == 2 ):
    print "yes"

I want a == 2 to be checked next. How would I do this?
(I have multiple conditions in that nested if that I need to check so I'd rather not have a huge string of and/or statements in that one outer-if. I also have more than one elif statement so I don't want to mash all the elifs together under that nested one.)
A deeper example:
b = 8

if( a > 1 ):
    if( b == 3 ):
        doSomething()
    elif( b == 4 ):
        doSomethingElse()
    elif( b == 5 ):
        more()
elif( -1 <= a <= 1 ):
    asd()
elif( a < -1 ):
    if( b == 7 ):
        asdfasdf()
    elif( b == 8 ):
        asasdf()

A: combine the conditions and flatten the nesting:
a = 2

if ( a > 1 and a == 3 ):
    print "yes"
elif ( a == 2 ):
    print "yes"

A: Considering the example is just indicative but your original question was to understand nested if-else, association, scoping ....
In Python, unlike Algol-like languages we don't have demarcated blocks (for ex. in C we use '{' to make a block. Here all blocks are via proper white-space indentation. Its like the philosophy, what you read is what you would get. This off-course is to adhere to the design philosophy "Code Readability".
In similar context, whether the subsequent if/else statement would be part of the outer or inner if statement depends on how it was indented.
Your example
a = 2

if( a > 1 ):
    if( a == 3 ):
        print "yes"
elif( a == 2 ):
    print "yes"

Here elif is part of the outer if, because that's what it reads or rather looks and that's how it was indented. Instead the below modified version of your code
a = 2

if( a > 1 ):
    if( a == 3 ):
        print "yes"
    elif( a == 2 ):
        print "yes"

Would make the logic apparently different. More because the indented elif block is now aligned with the inner if.
This is now much easier compared to the following C Code
if (a > 1)
   if (a == 3)
      printf("Hello World\n");
else if (a == 2)
   printf("Yes");

Can you easily say with which if the else if is associated?

A: How do you expect this to be clear to a computer?
if a > 1:
  # ANYTHING
elif a == 2:
  # ANYTHING

by definition will never execute anything in the second block.
I believe your intend might be more along this lines:
def action():
  if a > 1:
    if b == 2:
      doSomething()
      return
    if b == 3:
      doSomethingElse()
      return
 if a == 2: # Note: NO elif!
   doDefaultForA2()
   return
 showError("Unknown command")
 return

There are multiple ways to achieve this behaviour. I like the function+return pattern, because it structures code nicely. Another way is to use a handled flag:
unhandled = True
if a > 1:
  if b == 2:
    doSomething()
    unhandled = False
  if unhandled and b == 3:
    doSomethingElse()
    unhandled = False
if unhandled and a == 2: # Note: NO elif!
  doDefaultForA2()
  unhandled = False
if unhandled:
  showError("Unknown command")

(You can obviously put in a number of shortcuts here by using elif. But using explicit "if unhandled" makes the code more verbose about the logic and easier to add new options.)

A: a = 2
if a > 1:
    if a == 3:
        print "a is 3"
    elif a == 2:
        print "a is 2"

A: What outcomes do you want:

*

*print "yes" when a is 2 or 3

*otherwise do nothing

Translate that into simple code
if a in (2, 3):
    print "yes"

"deeper" example: You don't need some of your nesting. The following simple code is equivalent to yours:
if a == 1:
    if b == 7:
        print "yes 1, 7"
    elif b == 8:
        print "yes 1, 8"
elif a == 2:
    print "yes 2"
elif a == 3:
    print "yes 3"
elif a == 4:
    print "yes 4"
elif a == 5:
    print "yes 5"

By the way, please read PEP 8 and have a look at some of the code written by others... if( foo == 9 ): is an unfamiliar pattern which causes readers to slow down over the speed humps, and possibly avoid that road in future.

A: Another way of writing this to make it easier to read and possibly easier to write would be to put the choices for one of the checks into a dictionary.  This will only work if you actually are checking equality, but may work for you.
#used when a>1
bchoices1 = {}
bchoices1[3] = doSomething
bchoices1[4] = doSomethingElse
bchoices1[5] = more

#used when a==1
bchoices2 = {}
bchoices2[7] = asdfasdf
bchoices2[8] = asdfas

if( a > 1 ):
    bchoices1[b]()
elif( a == 2 ):
    asd()
elif( a == 1 ):
    bchoices2[b]()


text:
Q: SQL Data Compare Tools that compare FileTable data Does anybody have any recommendations for SQL Data Comparison tools that will compare and synchronize FileTable data?
So far I have looked at Visual Studio Data Comparison tool, SQL Delta and SQL Data Compare by Redgate and none of them appear to do it.

A: You can use the xSQL Data Compare to compare the tables and generate synchronization scripts. It should be able to compare and synchronize FileTables.


text:
Q: How to change CSS attributes of an element with JS when element is pulled from a class? I can't figure out how to change the CSS attributes of this object.
$(".slots").html('').get(0)

I am just playing around and this is how I get some data for my JS, perhaps am I doing this wrong? But question still remains the same - how do I alter that elements CSS attributes?

A: Issues was that the code was not wrapped in $() to create the correct reference to the element. Below fixed the issue

$($(".slots").html('').get(0)).css("background-color","blue")


text:
Q: How to remove duplicate source list on Debian 8.7 Am running Debian 8.7, after installing #letsencrypt following the tutorial on Digital Ocean. I couldn't update my operating system any more, If I run sudo apt-get update it displays the following error at the end
W: Duplicate sources.list entry ...ftp.debian.org/debian/ jessie-backports/main amd64 Packages (/var/lib/apt/lists/ftp.debian.org_debian_dists_jessie-backports_main_binary-amd64_Packages)
W: You may want to run apt-get update to correct these problems</code>

In other to view my source lists, I run the following code cat /etc/apt/sources.list /etc/apt/sources.list.d/*
which diplays the following result
deb http://httpredir.debian.org/debian/ jessie main
deb-src http://httpredir.debian.org/debian/ jessie main
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main
deb http://httpredir.debian.org/debian/ jessie-updates main
deb-src http://httpredir.debian.org/debian/ jessie-updates main
deb http://http.debian.net/debian jessie main
deb-src http://http.debian.net/debian jessie main
deb http://ftp.debian.org/debian jessie-backports main
deb http://httpredir.debian.org/debian/ jessie-backports main
deb-src http://httpredir.debian.org/debian/ jessie-backports main
deb http://packages.cloud.google.com/apt cloud-sdk-jessie main
deb http://packages.cloud.google.com/apt google-cloud-compute-jessie main
deb http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-jessie main
deb http://packages.cloud.google.com/apt cloud-sdk-jessie main
deb http://packages.cloud.google.com/apt google-cloud-compute-jessie main
deb http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-jessie main
deb http://ftp.debian.org/debian jessie-backports main
deb http://ftp.debian.org/debian jessie-backports main

Please, guys, which resource should I remove and how what code or process should I take to remove it.
I don't know much about these whole thing, I just follows instructions found on net to do all.

A: The duplicated source list is ...ftp.debian.org/debian/ jessie-backports/main.. You need to remove it. Do a grep jessie-backports /etc/apt/sources.list.d/* and grep jessie-backports /etc/apt/sources.list, see which files have it, open it with a text editor (e.g. nano), remove it and then do apt-get update to refresh apt's cache.

A: According to the DigitalOcean doc you're referring to, my money's on:
rm -f /etc/apt/sources.list.d/backports.list
apt-get update

As you can see, there's two jessie-backports in you cat output, ...

A: If you are able to run python in your system. You can use the following python3 script to make a copy of the file with no duplicates. After which you can replace the older "sources.list" with the new file
import os

l = set()
# remove duplicates by adding all the lines to a set
with open("/etc/apt/sources.list") as f:
    for line in f:
        l.add(line)
# write the new lines to a file in your home folder
with open("/home/brianbrix/sources.list", "w") as f:
    for line in l:
        f.write(line)
        f.write("\n")

# after that you can replace the sources file wwith the new one which has no duplicates


text:
Q: How can I make a Panel change background color while hovering in annotated 7.5 Vaadin? I am working on a Vaadin 7.5.3 project with an annotated servlet configuration.
My main UI class is:
@Title("Forms")
@Theme("valo")
public class FormsUI extends UI {

    Panel container = new Panel();

    @Override
    protected void init(VaadinRequest vaadinRequest) {
        configureComponents();
        buildLayout();
    }

    private void configureComponents() {

    }

    private void buildLayout() {
        setContent(container);
    }

    @WebServlet(urlPatterns = "/*")
    @VaadinServletConfiguration(ui = FormsUI.class, productionMode = false)
    public static class FormsServlet extends VaadinServlet {

    }
}

My POM (not complete) is:
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <vaadin.version>7.5.3</vaadin.version>
        <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
    </properties>

    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>http://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client-compiled</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-themes</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.3.v20140905</version>
            </plugin>
        </plugins>
    </build>

That's pretty much it. So the whole CSS (valo theme) is defined in the vaadin-themes dependency (I believe).
What I want to do is change the background color of a Panel (or, actually ANY component) when my mouse hovers over it.  Super simple in pure CSS.
Every example I find online indicates adding custom CSS classes which I can do.  But where do I define them?  How do I load them?
Suggestions appreciated.
Thanks

A: With the annotation @Theme("valo")in your UI class, you define which theme (read CSS styles) you will be using.
To be able to have your own CSS styles, you inherit it from the valotheme and then there define your own CSS styles in the scss file.
The build process the compiles the scss files into css files.
So you define @Theme("mytheme")instead of the valo theme.
In the VAADIN/themes/mythemefolder you then put your scss files, which inherit from the valo theme.
The book of vaadin has more details on this.

A: For those wondering, I finally solved the issue.  I am not a CSS guy and I know even less about SASS.
Anyway, what I did was extract the vaadin-themes-7.5.3 folder from my target/myapp-1.0-SNAPSHOT (or wherever your exploded war is) and copy it into src/main/webapp.
Then, I created a new folder under ../webapp/VAADIN/themes/mytheme.
Under mytheme, I deleted everything except:
favicon.ico
styles.scss

I then created:
mytheme.scss

Insidestyles.scss, I replaced with:
@import "mytheme.scss";

.mytheme {
    @include mytheme;
}

Inside mytheme.scss, I replaced with:
$v-background-color: #777;

@import "../valo/valo.scss";

@mixin mytheme {
    @include valo;
}

Works great.
I can now at least start adding custom CSS rules.
Hope this helps someone.


text:
Q: Optimizing WCF NetTcp Open time I am using WCF for IPC.
I have very strict performance needs, so the whole operation can take only a few milliseconds. (blocked by 3-4ms I'd say...)
However, WCF open takes approx 10ms. I looked at some performance testings made and I saw I can get much better results, though I wasn't able to do so.
I can just save an open connection, but I would really like to avoid it.
I already tried compiling in release, and removing security etc. (that only lowered it by the tiniest bit...)
This is my configuration (it's defined by code):
NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.Message, false)
        {
            SendTimeout = TimeSpan.FromSeconds(1),
            ReceiveTimeout = TimeSpan.FromSeconds(1),
            OpenTimeout = TimeSpan.FromMilliseconds(500),// FromMinutes(1),
            TransactionFlow = false,
            TransferMode = TransferMode.Buffered,
            TransactionProtocol = TransactionProtocol.OleTransactions,
            HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
            ListenBacklog = ushort.MaxValue,
            MaxBufferPoolSize = 20 * 1024 * 1024,
            MaxBufferSize = 20 * 1024 * 1024,
            MaxConnections = ushort.MaxValue,
            MaxReceivedMessageSize = 20 * 1024 * 1024,
        };

        // Windows authentication
        tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
        tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;

        return tcpBinding;

Can anyone suggest anyway of improving this configuration?
Thanks.


text:
Q: How to Hide parameters in URL in Symfony2 I don't want the user see the parameters in my URL.
Example :
my_route:
    path:     /***/{id}
    defaults: { _controller: MyBundle:Default:myaction}

the route will be generated like this :
***/product/1
i want just see the
***/product

A: As explained in comments, the request needs something to identify the resource you want to fetch. But this has nothing to do with URL rewriting. If you want to display the slug of the resource instead of the id, do the following :
my_route:
    path:     /products/{slug}
    defaults: { _controller: MyBundle:Default:myaction}

Then, in MyBundle/Controller/DefaultController.php :
public function myactionAction(Request $request, $slug)
{
    $product = $this->getDoctrine()->getManager()->getRepository('MyBundle:Product')->findOneBy(["slug" => $slug]);
}

and when you want to create a link to this product, use
link to the product


text:
Q: CRUD update using PUT I am attempting to update variables inside a table of a HSQLDB. When calling the following update, it doesn't seem to go any further than this line of code:
    CloseableHttpResponse response = httpClient.execute(httpPost);

Here is the full update code:
TeamClient.java
    public static void update(String id, String id1, String player1, String player2, String player3, String player4, String player5, String name) throws Exception
{
    URI uri = new URIBuilder().setScheme("http")
            .setHost("localhost")
            .setPort(8080)
            .setPath("/A00196363DonnachaOhA/rest/teams")
            .build();
    System.out.println(uri.toString());
    HttpPut httpPost = new HttpPut(uri);
    httpPost.setHeader("Accept", "text/html");

    CloseableHttpClient httpClient = HttpClients.createDefault();

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
    nameValuePairs.add(new BasicNameValuePair("id", id));
    nameValuePairs.add(new BasicNameValuePair("id1", id1));
    nameValuePairs.add(new BasicNameValuePair("player1", player1));
    nameValuePairs.add(new BasicNameValuePair("player2", player2));
    nameValuePairs.add(new BasicNameValuePair("player3", player3));
    nameValuePairs.add(new BasicNameValuePair("player4", player4));
    nameValuePairs.add(new BasicNameValuePair("player5", player5));
    nameValuePairs.add(new BasicNameValuePair("name", name));

    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)) ;
    System.out.println("Sending request");
    CloseableHttpResponse response = httpClient.execute(httpPost);

}

TeamDAO.java
    public void update(int id, int id2, String player1, String player2, String player3, String player4, String player5, String name) {
  Connection connection = getConnection();
  System.out.println("TRYING");
  try
  {
      System.out.println("TRYING");
      PreparedStatement psmt = connection.prepareStatement("UPDATE TEAMS SET id=?, player1=?, player2=?, player3=?, player4=?, player5=?, name=? WHERE id =?");
      psmt.setInt(1, id);
      psmt.setInt(8, id2);
      psmt.setString(2, player1);
      psmt.setString(3, player2);
      psmt.setString(4, player3);
      psmt.setString(5, player4);
      psmt.setString(6, player5);
      psmt.setString(7, name);
      int rs = psmt.executeUpdate();
  }catch (SQLException e)
  {
       e.printStackTrace();
  }

}
}
TeamResource.java
    @PUT
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("{teamId}")
public void putTeam(@FormParam("id") int id,
        @FormParam("id2") int id2,
        @FormParam("name") String name,
        @FormParam("player1") String player1,
        @FormParam("player2") String player2,
        @FormParam("player3") String player3,
        @FormParam("player4") String player4,
        @FormParam("player5") String player5,
        @Context HttpServletResponse servletResponse) throws IOException {
    System.out.println("PUT id = " + id);
    TeamDAO.instance.update(id, id2, name, player1, player2, player3, player4, player5);
}

A: You appear to have implemented the put method with two form parameters with the same name.
public void putTeam(@FormParam("id") int id,
        @FormParam("id") int id2,

Next problem:
UPDATE TEAMS SET id=?, player1=?, player2=?, player3=?,
                 player4=?, player5=?, name=? WHERE id =?

If the first id and second id are supposed to be the same, then you should be doing this
psmt.setInt(1, id);
psmt.setInt(8, id);

and getting rid of id2.  On the other hand if they are supposed to be different, then the form parameter bug (see above) breaks the query ... because it will cause one of the parameters to be ignored.
Then there is this:
nameValuePairs.add(new BasicNameValuePair("id", id));
nameValuePairs.add(new BasicNameValuePair("id1", id1));

So is the name of the second parameter supposed to be "id1" ... or "id2"?
Finally, I have my doubts that this update is sound from a semantic perspective.  If the id field is a primary key that is a foreign key in some other table, then your update will be breaking the foreign key-based association with other rows.  At the very least, this looks "odd".


text:
Q: How to read Properties file using Jquery and JavaScript I have tried using jQuery.i18n.properties({}); plugin from this reference site but it's not working.
Is there any another way to read properties file in JavaScript or jQuery so that the contents can be loaded on an HTML page?

A: I think including MIME type to IIS will work
Add
'.properties' MIME extension and add type 'text/plain'.

A: Specifically (see previous answer) you can do that in two ways:
1) web.config (recommended) - add the following 2 elements :
<configuration>
...
   <system.webServer>
   ...
      <staticContent>
      ...
         <remove fileExtension="properties" />
         <mimeMap fileExtension="properties" mimeType="text/plain" />

2) IIS - you need to do that every time you deploy to a new IIS

*

*open IIS manager

*select either the machine node or the web site node (usually Default  Web Site)

*In the Features View - locate the "Mime Types" icon under the IIS section.

*add the mime type:

*

*File name extension: ".properties" (make sure you have the dot at the beginning)

*Mime type: "text/plain"


text:
Q: How to use a fast_strtime() in a data.table? I need help to use fast_strptime in a data.table to convert a string in a date format,
I have tried following solutions:
dt<-data.table(Month_Year=c("JAN 2020","FEB 2020", "MAR 2020"), val=c(1:3))
dt[,Date:=as.POSIXct(fast_strptime(Month_Year,format= "%^b %Y"))]
dt$Date<-fast_strptime(dt$Month_Year, format="%b %Y")

None of them work, I appriciate any help!
Thanks in advance!

A: Well I found a work around, not with fast_strptime() function, but it fits my expectations for now:
dt[,Date:=as.Date(paste("01",Month_Year, sep=" "),format = "%d %b %Y")]

I hope it helps others, who face the same issue.
But I am still intressted in how to use fast_striptime in combination with data.table. :)

A: This works fine
dt[,Date:=as.POSIXct(lubridate::fast_strptime(Month_Year, "%b %Y"))]

The issue is that fast_strptime() produces a POSIXlt object rather than a POSIXct one. POSIXlt is basically a list of integers and so data.table gets confused, whereas POSIXct is a single numeric value.
I'd probably use parse_date_time though
dt[,Date:=lubridate::parse_date_time(Month_Year, "my")]


text:
Q: Should a single user be able to vote to both close and re-open a question? I was the original author of this question, which was closed as "subjective and argumentative" shortly after it was written.
I was one of five users who then voted to re-open it (as I thought the subject was appropriate for a "community wiki" question, though not for non-CW.)
Surprisingly I am still able to vote to close it.
I think this conflicts with

*

*The fact that I contributed to the question

*The fact that I previously voted to re-open it.

Is this by design or is it an oversight?

A: I think it's reasonable as people can change their minds, and questions can change too.
As an example, suppose there's a bad question. You vote to close it. It is improved, and you then like it. You answer it, but then others close it. You still like it, so you vote to reopen.
There's no inconsistency there, and nothing nefarious going on.

A: Unless there is a notable, real issue with such application behavior, I don't see a reason to prevent it.  "Permissive until there is a problem" is the philosophy that seems appropriate here.

A: In this situation, it is probably better to offer more flexibility rather than less.  As Jon points out, it allows you the ability to change your mind, or even vote to migrate it to a different site.  Without that option, you might find yourself in a position to earn a Peer Pressure badge with no way to close.


text:
Q: Regular Expression - Java not working I have a line of Java code
System.out.println("...Somtime".matches("^[^a-zA-Z]"));
Which returns false. Why? Can any one help?

A: String#matches matches at both the ends, so your pattern should cover the complete string. And also you don't need to give those anchors (Caret - ^) at the beginning. It is implicit.
Now, since your first three characters matches - [^a-zA-Z], while the later characters matches - [a-zA-Z].
So, probably you want: -
"...Somtime".matches("[^a-zA-Z]{3}[a-zA-Z]+")

A: String.matches("regex")

This method will match the regex against the WHOLE string. If the string matches regex, it will return true and false otherwise
System.out.println("...Somtime".matches("^[^a-zA-Z]{3}[a-zA-Z]+"));

here for three dots you are using {3} and this return true
System.out.println("Somtime".matches("^[^a-zA-Z]"));

it return false


text:
Q: Sorting odd numbers at the beginning of array I want to sort odd numbers at the beginning of the array.
For example:
myArray[8] = {6,3,8,9,6,0,4,7};
>> Output: "3   9   7"
Which type of algorithm should I follow?

A: Use std::stable_partition:
int myArray[] = {6, 3, 8, 9, 6, 0, 4, 7};
const auto first = std::begin(myArray);
const auto last = std::stable_partition(
    std::begin(myArray), std::end(myArray), [](int x) { return x % 2; });

Then the range [first, last) will represent the elements you want.


text:
Q: Conditionally remove header/footer in Magento I have a module page that can be accessed like
www.example.com/module/controller/action/id/10
I want something like this in my controller's action
$page = (int) Mage::app()->getRequest()->getParam('id');
if($page == '12')
{
    $this->getLayout()->unsetBlock('header');
    $this->getLayout()->unsetBlock('footer');
}

But above method doesn't work, I guess I'm passing wrong alias to unsetBlock method.
I know how to hide header/footer via layout xml but here I want to hide them in controller.
So basically I am searching an alternative for
<remove name="header"/>
<remove name="footer"/>

A: I found solution to my own question, sharing because it may help others.
1. Create a new layout handle for the page
// Namespace/Modulename/Model/Observer.php
Class Namespace_Modulename_Model_Observer extends Mage_Core_Model_Abstract
{

    public function addAttributeSetHandle(Varien_Event_Observer $observer)
    {
        $page = (int) Mage::app()->getRequest()->getParam('id');
        $handle = sprintf('modulename_controller_action_id_%s', $page);
        $update = $observer->getEvent()->getLayout()->getUpdate();
        $update->addHandle($handle);
    }
}

2. Enable the observer in module's config.xml
// Namespace/Modulename/etc/config.xml
<frontend>
    <events>
        <controller_action_layout_load_before>
            <observers>
                <attributesethandle>
                    <class>Namespace_Modulename_Model_Observer</class>
                    <method>addAttributeSetHandle</method>
                </attributesethandle>
            </observers>
        </controller_action_layout_load_before>
    </events>
</frontend>

3. And then easily change the layout for the handle modulename_controller_action_id_12 in modules layout xml.
<modulename_controller_action_id_12>
    <remove name="header"/>
    <remove name="footer"/>
    <reference name="root">
        <action method="setTemplate">
            <template>page/1column.phtml</template>
        </action>
    </reference>
</modulename_controller_action_id_12>


text:
Q: why the explicit conversion function of derived class return type is not a candidate in the context of direct-initialization Given the following example:
#include <iostream>
struct A{
    A() = default;
    A(A const&){}
};
struct B:A{};
struct C{
    explicit operator B(){
        return B{};
    }
};

int main(){
   C c;
   A a(c);  // #1
}

GCC and Clang both report that c cannot be converted to const A&.  However, there's a relevant rule in the standard says, explicit operator B() should be a candidate function in this context. That is:
over.match.copy#1.2

When initializing a temporary to be bound to the first parameter of a constructor where the parameter is of type "reference to possibly cv-qualified T" and the constructor is called with a single argument in the context of direct-initialization of an object of type "cv2 T", explicit conversion functions are also considered. Those that are not hidden within S and yield a type whose cv-unqualified version is the same type as T or is a derived class thereof are candidate functions.

Moreover, in the current standard, the relevant rule still has the same meaning:
over.match.copy#1.2

When the type of the initializer expression is a class type "cv S", conversion functions are considered. The permissible types for non-explicit conversion functions are T and any class derived from T. When initializing a temporary object ([class.mem]) to be bound to the first parameter of a constructor where the parameter is of type "reference to cv2 T" and the constructor is called with a single argument in the context of direct-initialization of an object of type "cv3 T", the permissible types for explicit conversion functions are the same; otherwise there are none.

Regardless of c++17 standard or the current standard, they all say that in the context likes #1, the explicit conversion function that has the return type of class T or any class derived from T is also a candidate.
In my example, The object a of type A is direct-initialized by the single initializer c, which is the single argument in the invocation of constructor, the copy constructor of A has a parameter A const&.  In this case, c should be used to initialize a temporary object to be bound to the first parameter. Hence, in this case explicit operator B() should be considered as a candidate function. However, GCC and Clang both reject this example.  GCC obviously report a dignosis information that make no sense.
Is it a bug of these compilers? Or, I misunderstand something?


text:
Q: How do you fit an image in react native? // How do you set the image on the top of the screen without losing the aspect ration?
[![import React, { Component } from 'react';
    import { AppRegistry, View, Image, StyleSheet } from 'react-native';
    export default class DisplayAnImageWithStyle extends Component {
      render() {
        return (
          <View style={{flex:1}}>
            <Image
              resizeMode="contain"
              style={{flex:1}}
              source={{uri: 'https://i.pinimg.com/originals/ba/84/1c/ba841cc07934b508458a7faea62141a8.jpg'}}
            />
          </View>
        );
      }
    }

    // Skip these lines if you are using Create React Native App.
    AppRegistry.registerComponent(
      'DisplayAnImageWithStyle',
      () => DisplayAnImageWithStyle
    );][1]][1]

// Here the liked image shows that it is not fitting well... it is not showing from the top... do you have any idea how I can set the image without any padding?
      [1]: https://i.stack.imgur.com/LYNKn.png

A: So you might wanna use resizeMode: 'cover' with a height and width.
<Image
  resizeMode="contain"
  style={{ width: 200, height:220, resizeMode: 'cover'}}
  source={{uri: 'https://i.pinimg.com/originals/ba/84/1c/ba841cc07934b508458a7faea62141a8.jpg'}}
 />

Here's an example https://snack.expo.io/HJTFg9tU4
Let me know if this works for you.


text:
Q: Oracle JDBC Custom Collection Type and SQLOutput writeString I created a type in Oracle DB:
 create or replace TYPE client_type AS OBJECT
  (
  NMB NUMBER(7,0),
  TITLE VARCHAR2(30),
  );

After that I created a corresponding class in Java;
public class Client implements SQLData {

    private int nmb;
    private String title;

    public int getNmb() {
        return ncst;
    }
    public void setNmb(int nmb) {
        this.nmb = nmb;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public String getSQLTypeName() throws SQLException {
        return "CLIENT_TYPE";
    }
    @Override
    public void readSQL(SQLInput stream, String typeName) throws SQLException {
         setNmb(stream.readInt());
         setTitle(stream.readString());
    }
    @Override
    public void writeSQL(SQLOutput stream) throws SQLException {
        stream.writeInt(getNmb());
        stream.writeString(getTitle());
    }
}

Then I call a procedure to insert new data:
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("P_INSERTCLIENT");
jdbcCall.declareParameters(new SqlParameter("P_CLIENT", OracleTypes.STRUCT, "CLIENT_TYPE"));
Map in = Collections.singletonMap("P_CLIENT", customer);
jdbcCall.execute(in);

NMB gets inserted in table and TITLE value is set to null...
I tried to change my client_type, added a DATE and it also gets inserted correctly.
What am I doing wrong with string -> varchar fields?


text:
Q: apply animation to UI component via actionscript in flex issue Here is my entire application. Pretty easy stuff.
I have two panels that have a click event on them. However, both call the same function for some reason. When I have only one panel visible the animation works correctly. However if I add another to the stage on the click event both panels animate at the same time.
I just dont get what I'm doing wrong. My function is looking for only the current target but apparently I must not be doing that correctly because it's animating both panels and not just the panel the I clicked. My expected result is to animate only the clicked panel.
Any help would be really appreciated.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955"
               minHeight="600"
               applicationComplete="application1_applicationCompleteHandler(event)"
               left="20">

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    <!--<s:Sequence id="EffectsHide">-->
        <!--<s:Rotate id="rotatein" target="{panel1}"  angleBy="90"/>-->

        <mx:Parallel id="EffectsHide">
        <s:Rotate3D angleYFrom="0" angleYTo="360"  duration="1000"  />
        <s:Resize id="shrink" duration="1000"  heightBy="-170" />
        <s:Move3D  id="MoveIn"   yBy="{_applicationHeighth-30}" duration="1000"/>
        </mx:Parallel>
<!--    </s:Sequence>-->

    <s:Sequence id="EffectsShow">
        <s:Rotate id="rotateOut" target="{panel1}"  angleBy="-90"/>
        <s:Move id="MoveOUt"  target="{panel1}" xBy="-30"/>
        <s:Resize id="grow" target="{panel1}" duration="2000" widthBy="{_applicationWidth}" heightBy="{_applicationHeighth}"/>
    </s:Sequence>

    </fx:Declarations>

    <fx:Script>

        <![CDATA[
            import mx.effects.Effect;
            import mx.effects.Parallel;
            import mx.events.FlexEvent;
            private var myParallel:Parallel = new Parallel();
            private var myParallelReverse:Parallel = new Parallel();

            [Bindable]
            public var _applicationWidth:Number = new Number();
            [Bindable]
            public var _applicationHeighth:Number = new Number();
            [Bindable]
            public var Maximized :Boolean = true;
            public var minimized :Boolean = false;

            public  function rotateTarget(event:Event):void{

                //define the rotate effect
                /*
                var myRotated3d:Rotate3D= new Rotate3D(event.currentTarget);
                myRotated3d.angleYFrom = 0;
                myRotated3d.angleYTo=360;
                myRotated3d.duration=1000;
                */

            if(Maximized == true)
            {
            //EffectsHide.target(_target);

            //EffectsHide.stop();
            //EffectsHide.play();
                //var myRotated3d:Rotate3D= new Rotate3D(event.currentTarget);
                //myRotated3d.angleYFrom = 0;
                //myRotated3d.angleYTo=360;
                //myRotated3d.duration=1000

                var myResize:Resize = new Resize(event.currentTarget);
                myResize.heightBy = -160;
                myResize.duration = 500;

                var myMove3D:Move= new Move(event.currentTarget);
                myMove3D.yTo=_applicationHeighth-30;
                myMove3D.duration=500;

                //myParallel.addChild(myRotated3d);
                myParallel.addChild(myResize);
                myParallel.addChild(myMove3D);
                //this.invalidateDisplayList();
                //this.validateNow();
                //this.panel1.validateProperties();

            minimized= true;
            Maximized = false;
            myParallel.stop();
            myParallel.play();
            trace('tried to run')
            }

            else if (Maximized == false){

            trace(numElements)
            //trace(getElementIndex(panel1));

            //var myRotated3drever:Rotate3D= new Rotate3D(event.currentTarget);
            //myRotated3drever.angleYFrom = 0;
            //myRotated3drever.angleYTo=-360;
            //myRotated3drever.duration=1000;

            var myResizerever:Resize = new Resize(event.currentTarget);
            myResizerever.heightTo= 200;
            myResizerever.duration =500;

            var myMove3Drever:Move = new Move(event.currentTarget);
            myMove3Drever.yTo=(0);
            myMove3Drever.duration=500;

            myParallelReverse.addChild(myMove3Drever);
            myParallelReverse.addChild(myResizerever);
            //myParallelReverse.addChild(myRotated3drever);

            myParallelReverse.play();
            Maximized = true;

            }

    }

            protected function application1_applicationCompleteHandler(event:FlexEvent):void
            {
                _applicationWidth = stage.width;
                _applicationHeighth = stage.height;

            }

            protected function _butt_clickHandler(event:MouseEvent):void
            {
                trace(panel1.x);
                trace(panel1.y);
                trace(panel1.height);

            }

        ]]>
    </fx:Script>

    enter code here
<mx:Canvas>

<mx:Panel id="panel1" title="Label1" x="400" y="0" width="200"  height="200" click="rotateTarget(event)"/>
<mx:Panel id="panel2" title="Label2" x="0" y="0" width="200"  height="200" click="rotateTarget(event)"/>

</mx:Canvas>
    <!--<s:Panel id="panel2" y="240" title="Label2" width="200"  height="200" click="rotateTarget(event)"/>
-->
<!--</s:VGroup>-->
<s:Button x="250" id="_butt" click="_butt_clickHandler(event)"/>
<s:Button x="250" y="20" id="_butt2" click="rotateTarget(event)"/>

</s:Application>

A: My two best guess without the full code (the bit with the panels):

*

*You should be using event.target rather than event.currentTarget.

*You bound the 'EffectsHide' (all IDs should be lowercase by the way) parallel directly to 'panel1' so whenever it gets plays that is the component it is going to target.
*I see now that you keep adding new animation effects created in the rotatetarget function to the parallel 'myParallel'.  You do not however remove them at any given point so it just keeps on playing all the effects you ever added to it  each time it get's played.  You should just add them once on application setup and then just play them.


text:
Q: ¿Por qué no continúa el push? ¿por qué no continúa el push al master?
Antes me dio un error y decidí cambiar el buffer de git del por defect 1MiB a 500MiB. No funcionó y le puse 1 GiB y ahora no continúa (antes tampoco).


text:
Q: Call SharePoint on-premises Data from a web application I've developed a web application that interacts with Sharepoint Online sites via Microsoft Graph API, and everythings are going fine.
Recently, I received a request from a client telling me that he has Sharepoint on-premise and needs to consume my web app. Actually, I didn't know how to interact with a local Sharepoint. After much research, I discovered that Microsoft has many ways to interact with on-premise Sharepoint server like CSOM, JSOM, REST API, and many more.
The problem is all of them either are injected into Sharepoint like add-ins, or attached directly to the server, so no need for authentication.
Suppose I need to consume the Rest API. my case here resides in how to obtain the access token. How my online web app would interact with the local Sharepoint Server?
Thanks in advance


text:
Q: Google Chart for a List I am trying to deploy Google Charts on my share Point Page and it is based on the list in my site.
I am new to Google Charts and i am not aware of how to get the data from the list and show it in the Charts.
Could anyone help me out and guide me in the right direction.
Thank you

A: You can use JQuery and SPServices code to achieve your requirement as below:
Read data from a list:
function ReadData(){

     $().SPServices({
             operation: "GetListItems",
             async: false,
             listName: "Phone",
             CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='People_x0020_using' /></ViewFields>",
             completefunc: function (xData, Status) {
                 $(xData.responseXML).SPFilterNode("z:row").each(function () {

                     var title = $(this).attr("ows_Title");
                     var people = $(this).attr("ows_People_x0020_using");

                     //Converting decimal number to whole number, for example ->3.000 to 3
                     people = Math.floor(people);

                     //creating json Object to save the values
                     var jsonObj_Values = {};

                     jsonObj_Values["Title"] = title;
                     jsonObj_Values["People"] = people;

                     //Adding jsonObj_Values to main json
                     jsonObj_Chart[title] = jsonObj_Values;
             })
             }
         });
 }

Generate the Chart:
function GenerateChart(){

google.charts.setOnLoadCallback(drawChart);
     function drawChart() {

           var data = google.visualization.arrayToDataTable([
             ["Phone", "No. of ppl"],
             ["iPhone", 100],
             ["Samsung", 150],
             ["BlackBerry", 50],
             ["mi", 130]
           ]);

       var data = new google.visualization.DataTable();
       data.addColumn('string', 'Phone');
       data.addColumn('number', 'No. of ppl');

       $.each(jsonObj_Chart, function(key, value) {
         data.addRow([value.Title, value.People]);
       });

         var options = {
           chart: {
             title: 'Phone',
             subtitle: 'No. of ppl usage',
           }
         };

       var chart = new google.charts.Bar(document.getElementById("Barchart_Phone"));
       chart.draw(data, options);
   }

 }

Detailed information check the post: Google Charts in SharePoint

A: You need to just use this


text:
Q: C++ ofstream line break This is my code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ifstream ifile ("input.dat", ios::in);
    ofstream ofile ("output.dat",ios::out);

    int num;
    ifile >> num;
    ofile << num;
    ofile << endl;
    ofile << "Did we go to new line?";
    ofile << endl;

    return 0;
}

The problem is, everything in output.dat is on the same line. How can I resolve this?
Thanks!
EDIT: I was using Windows to see the files and Linux to compile. This is why I was running into this issue. Using cat output.dat on the Linux side to see the file contents would have revealed that Windows vs. Linux line breaks are different at the time.

A: Replace std::endl with "\r\n" to get CRLF instead of just LF.

A: std::endl already inserts a linebreak, so you have linebreaks in your file. I assume you are generating your file on a LF system (Linux or other UNIX-like) and viewing it on a CRLF system. In this case, your linebreak won't show in the text editor as a linebreak. unix2dos is your friend.


text:
Q: React Native - Check the render method of `TabBarIcon` I got this issue when render createBottomTabNavigator in my app.
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `TabBarIcon`.

My code
import React from "react";
import { createStackNavigator, createBottomTabNavigator, createAppContainer } from "react-navigation";
import { FontAwesome } from "react-native-vector-icons";

import SignUp from "./screens/SignUp";
import SignIn from "./screens/SignIn";
import Home from "./screens/Home";
import Profile from "./screens/Profile";

export const SignedOutNavigator = createStackNavigator({
  SignUp: {
    screen: SignUp,
    navigationOptions: {
      title: "Sign Up"
    }
  },
  SignIn: {
    screen: SignIn,
    navigationOptions: {
      title: "Sign In"
    }
  }
});

export const SignedInNavigator = createBottomTabNavigator({
  Home: {
    screen: Home,
    navigationOptions: {
      tabBarLabel: "Home",
      tabBarIcon: ({ tintColor }) => (
        <FontAwesome name="home" size={30} color={tintColor} />
      )
    }
  },
  Profile: {
    screen: Profile,
    navigationOptions: {
      tabBarLabel: "Profile",
      tabBarIcon: ({ tintColor }) => (
        <FontAwesome name="user" size={30} color={tintColor} />
      )
    }
  }
});

export const SignedOut = createAppContainer(SignedOutNavigator);
export const SignedIn = createAppContainer(SignedInNavigator);

Reference: https://github.com/datomnurdin/auth-reactnative

A: There seems to be an issue with the FontAwesome icon that is being imported. The library doesn't seem to have named export for FontAwesome as a default.
Instead import it as
import FontAwesome from "react-native-vector-icons/FontAwesome";

A: If you did not see your icon, on android, run command
cd android && ./gradlew