text:
Q: How to get attributes from a dynamic element? I have this dynamic element:

I'm trying to get class, data-sub and  from this code.
js:
$('body').on('click', 'li', function(i){
    rel = i.currentTarget.className;
    img = i.currentTarget.innerHTML;
    sub = $(this).attr('data-sub');

    console.log(rel, img, sub);
});

The class and  are returning, but data-sub is returning undefined.
I also tried console.log( this.attr('data-sub') ) but it's not working.
When I use console.log(i), it returns me the object, that's why I'm using i.currentTarget, but custom data attribute doesn't seem to be created there.
Some help would be appreciated

A: Use this instead (HTML is the same):
$('body').on('click', 'li', function() {
    var rel = $(this).attr('class');
    var img = $(this).html();
    var sub = $(this).data('sub'); //CREDIT TO jrummell

    console.log(rel, img, sub);
});

fiddle: http://jsfiddle.net/edbdohf3/2/

*

*I removed the i and i.currentTarget. You can just use $(this) everywhere to reference the clicked li. (I translated .className and .innerHTML into jQuery accordingly.)

*I changed .attr('data-sub') to .data('sub') (credit to jrummell). The first seems to work too, but the latter is apparently the better way to go.

*I added var before each of the variables in the function. If you only need those variables inside the function, use var, otherwise you will unnecessarily create global variables. If you also need the variables outside of the function, you obviously do need global variables, in which case you should not add var before the variables inside the function. (But here I can't see whether you already declared those variables earlier in your script.)

If this still doesn't work, try changing

$('body').on('click', 'li', function() {
to
$('li').on('click', function() {
This links the li elements directly, instead of delegating through body. This ensures that $(this) unquestionably references the clicked li element.
In theory there shouldn't be any difference, but it can never hurt to try..


text:
Q: javascript: cannot access object properties I need to get the username by using Meteor.user(). And it gives me the proper object with the username property which I cannot access.
My code:

class Dashboard extends TrackerReact(Component){
    constructor(){
        super();
        //some code
    }

    render() {
        let user = Meteor.user();
        console.log(user);
        //cannot access user.username eventhough it is there
        return (
            //some code
        );
    }
}

What should I do?

A: Try putting the user object on state

class Dashboard extends TrackerReact(Component){
    constructor(){
        super();
        state = {
          user: null,
        }
    }

    componentDidMount() {
     this.setState({user: Meteor.user()});
    }

    render() {
        console.log(this.state.user);
        return (
            //some code
        );
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: From an XML String to a dynamic "LIST" Output Good afternoon,
I'm looking for tips on this one. Finally, I'm getting close to the output I desire.
import groovy.xml.XmlSlurper

String XML = '''
    <results>
  <result>
    <Firstname>Marco</Firstname>
    <Surname>Alves</Surname>
    <Age>33</Age>
    <Address>Lisbon</Address>
    <ALIAS>Valentino Rossi</ALIAS>
  </result>
  <result>
    <Firstname>André</Firstname>
    <Surname>Vieira</Surname>
    <Age>31</Age>
    <Address>Lisbon</Address>
  </result>
  <result>
    <FirstName>Pedro</FirstName>
    <Surname>Kuclo</Surname>
  </result>
  <result>
    <Address>Lisbon</Address>
    <Surname>Kuclo</Surname>
  </result>
</results>
'''

def people = new XmlSlurper().parseText(XML)
people.result.findAll { m ->
    m.Firstname.toString().contains("Marco")
}.each { m ->
    println(m)
}

This is the current OUTPUT:
MarcoAlves33LisbonValentino Rossi

Anyone have an idea to achieve this output?
List { "Marco", "Alves", "33", "Lisbon", "Valentino Rossi }

The output must be dynamic, let's say, without define the "{m.Firstname} \n${m.Surname}"
What I tried so far:
// println("\n${m.Firstname} \n${m.Surname} \n${m.Address} \n${m.age}\n${m.ALIAS}")

But this way I have to define the output and I want it to dynamic.

A: If you would like to return a List containing specific properties or properties in a different order, you can use the collect method to collect the elements for each matching entry however you see fit and return that as a List:
String XML = '''
    <results>
  <result>
    <Firstname>Marco</Firstname>
    <Surname>Alves</Surname>
    <Age>33</Age>
    <Address>Lisbon</Address>
    <ALIAS>Valentino Rossi</ALIAS>
  </result>
  <result>
    <Firstname>André</Firstname>
    <Surname>Vieira</Surname>
    <Age>31</Age>
    <Address>Lisbon</Address>
  </result>
  <result>
    <FirstName>Pedro</FirstName>
    <Surname>Kuclo</Surname>
  </result>
  <result>
    <Address>Lisbon</Address>
    <Surname>Kuclo</Surname>
  </result>
</results>
'''

def people = new XmlSlurper().parseText(XML)
def results = people.result.findAll { m ->
    m.Firstname.toString().contains("Marco")
}.collect{ it ->
   [it.Firstname, it.Surname, it.Age, it.Address, it.ALIAS]
}

println results

Which generates the output:

[[Marco, Alves, 33, Lisbon, Valentino Rossi]]

You can easily modify what is collected to achieve the results you want.
If what you want is to take the matching results and convert each result, including all properties of the result to Json, you can instead do this:
def people = new XmlSlurper().parseText(XML)
def results = people.result.findAll { person ->
    person.Firstname.toString().contains("Marco")
}.collect{ result -> result.children().collectEntries{ child -> [(child.name()) , child.text()]} }

results = groovy.json.JsonOutput.toJson(results)
println results

Which will yield these results:
[
  {
    "Firstname":"Marco",
    "Surname":"Alves",
    "Age":"33",
    "Address":"Lisbon",
    "ALIAS":"Valentino Rossi"
  }
]


text:
Q: unable to restore mysql database, getting ERROR 1153 (08S01) trying to restore pressflow database and getting this error, I even tried it with --max_allowed_packet, still getting same error:
[root@6shdbm01 tmp]# mysql --max_allowed_packet=1024M pressflow < pressflow.sql
ERROR 1153 (08S01) at line 786: Got a packet bigger than 'max_allowed_packet' bytes
[root@6shdbm01 tmp]#

A: The max_allowed_packet variable must be set on both the client and the server. If the server's value is lower than the client's value, this error occurs.
You will need to set max_allowed_packet in the [mysqld] section of /etc/my.cnf to complete the operation.
For more information, see the MySQL documentation.


text:
Q: Set up an Ubuntu 15.04 based mini-pc as WiFi router I am wondering if there is a way to set up a Ubuntu mini-pc with a WiFi adapter as a WiFi router, so that I can use my laptop to scp some files from it wirelessly.

A: Yes, this can be done with hostapd. The Ubuntu documentation might be of help for you:
https://help.ubuntu.com/community/WifiDocs/WirelessAccessPoint


text:
Q: ag-grid: How to select the all the rows on click of header checkbox for multiple pages with server side pagination in the ag-grid table I would like to select the ids of all the rows on click of header checkbox for ag-grid table with server-side pagination enabled. Currently I am able to retain only the active page table rows ids but I want to select ids of multiple pages with ag-grid server-side pagination.
I tried with getSelectedNodes() and getSelectedRows() apis of rowSelected events of ag-grid but it gives me only the current page data not the multiple page data.
Please let me know how can I get the data from multiple pages rows selection with server side pagination.

A: When you are using the server-side row model, then only the rows in the current page exist on the client side. That's the whole point of the server-side row model.
So, in your case, the grid doesn't have any data about the rows that are not in the current page.
The only way to know the ids of all of the rows is to ask the server (presumably via an api call).
In this mode, I'm not sure what you expect as far as "selecting" rows that aren't actually in the grid, but if you want your UI to act like you are using the client-side row model with respect to selection, you are going to have to manage that yourself, by having your component maintain a list of all row ids, and  which are 'selected', and then using the grid's api to select rows in the current page that you have in your 'selected row' list whenever a new page gets loaded.