text:
Q: Set up a home network with different OSs Here's a picture of my current network:

I guess you will need a little bit of explanation here:
I have a router (LevelOne WBR-6005), which receive my WAN signal, provided by my ISP.
The only cable connection is to my Ubuntu server (unless there's a problem with the cable and I should use a USB WLAN adapter). My Ubuntu server is an old PC we had and decided to give it a new life.
My printer/scanner/copier a HP LaserJet 1120 MFP (WITHOUT network interface) is connected with USB 2.0 cable to the server and I need to know how to share it via SAMBA. Also I need to know how to show the server in the network, because it's not always visible (I can see the shared stuff when I type \\server in the address bar, but I don't always see it in the "Network" menu)
I also need to know how to set up a sharing environment for all the computers.
Don't think about the scanner, I already have a web application to scan (I installed xampp on the server).
If you have any questions feel free to ask and I'll try to explain.
So, guys any help would be appreciated. Thanks in advance!

A:
Also I need to know how to show the server in the network, because it's not always visible

In a home network (no Active Directory) Windows is normally looking for other clients with NetBIOS. As an easy alternative you can resolve the names with WINS so you have to change the following line in the [global] section of /etc/samba/smb.conf:
[global]
os level = 99
wins support = yes
name resolve order = wins lmhosts hosts bcast
domain master = yes
preferred master = yes

*

*Open the Properties dialog for the network interface you use to connect to the LAN. In XP, you can do this by hovering over the "Connect To..." option on the Start menu, right-clicking your interface, and clicking "Properties".

*Select "Internet Protocol (TCP/IP)" from the list of protocols used on that interface and click "Properties".

*Click "Advanced".

*In the resulting "Advanced TCP/IP settings" dialog, select the WINS tab and click "Add...". Enter the IP address of your file server. You can probably leave the other settings at their defaults. Click OK on each of the configuration dialogs you have opened.

*Open a DOS command window (Start -> Accessories -> Command Prompt) and enter the following three commands:

*

*ipconfig /release

*ipconfig /renew

*ipconfig /all
The output from the last command should show that your Primary WINS Server has the IP address you entered above.

My printer/scanner/copier a HP LaserJet 1120 MFP (WITHOUT network interface) is connected with USB 2.0 cable to the server and I need to know how to share it via SAMBA

I know two ways to share your Printer:

*

*Make a printer share print$. Well explained example here (I'd prefer this method if you don't want to print from the server itself).

*Install Cups on your Server and share the printer with IPP:
sudo apt-get install cups cups-client cups-bsd hplip hpijs

to install cups and:
sudo cupsctl --share-printers  --remote-admin --remote-printers

to share the printer and administrating cups over http://localhost:631.

*On the Windows computer, go to the printer control panel and choose to "Add a New Printer". Next, choose to give a URL. For the URL, type in the location of the printer: http://host_ip_address:631/printers/printer_name

set up a sharing environment for all the computers

Just add the following lines to /etc/samba/smb.conf:
[public]
path = /media/public
public = yes
writable = yes


text:
Q: Azure Change Feed and Querying based on Partition When we fetch data from Document Db in the change feed, we only want it per partition and have tried adding PatitionKey to the code.
do
        {
            FeedResponse<PartitionKeyRange> pkRangesResponse = await client.ReadPartitionKeyRangeFeedAsync(
                collectionUri,
                new FeedOptions
                {
                    RequestContinuation = pkRangesResponseContinuation,
                    PartitionKey = new PartitionKey("KEY"),
                });

            partitionKeyRanges.AddRange(pkRangesResponse);
            pkRangesResponseContinuation = pkRangesResponse.ResponseContinuation;
        }
        while (pkRangesResponseContinuation != null);

It returns single range and when we go perform the second query
IDocumentQuery<Document> query = client.CreateDocumentChangeFeedQuery(
                collectionUri,
                new ChangeFeedOptions
                {
                    PartitionKeyRangeId = pkRange.Id,
                    StartFromBeginning = true,
                    RequestContinuation = continuation,
                    MaxItemCount = -1,
                });

It returns all the results from all partitions. Is there a way to restrict the results from single partition only?

A: Changefeed works at a PartitionKey Range level.
What are partition key ranges?
Document Db currently has 10 GB Physical partitions.
The partition key that you specify is the Logical Partition Key.
Document Db internally maps this logical partition key to a Physical Partition using a hash.
So its possible that a bunch of logical partitions are sharing the same physical partition.
So a physical partition is assigned for a range of these hashes.
The minimum grain that is allowed to read from changefeed would be Partition key ranges.
So for the you would have to query the partition key range id for the partition that you are interested in. Then query the Changefeed for that range id and filter out the data that is not associated to the partition id.
Note: Document db transparently creates new physical partitions if a particular partition gets full. So the partition key range id for a given logical partition could change over time.
This link explains this in good detail:
https://learn.microsoft.com/en-us/azure/cosmos-db/partition-data#partitioning-in-azure-cosmos-db

redpajama_set_name: RedPajamaStackExchange


text:
Q: Conexión rechazada por el puerto 9000 Tengo el puerto abierto en el router, pero al hacer un nmap o al intentar conectarme por dicho puerto me sale que la conexión la rechaza, tampoco tengo ningún firewall instalado. La máquina es un debian 9 y es servidor web.
Haciendo un netstat no me sale:
# netstat -nan
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:2233            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8200            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN
tcp        0    256 192.168.0.160:2233      79.147.25.10:50490      ESTABLISHED
tcp        0      0 192.168.0.160:50926     82.194.78.250:80        TIME_WAIT
tcp6       0      0 ::1:631                 :::*                    LISTEN
tcp6       0      0 :::2233                 :::*                    LISTEN
tcp6       0      0 :::443                  :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 192.168.0.160:443       79.147.25.10:50561      TIME_WAIT
tcp6       0      0 192.168.0.160:443       79.147.25.10:50598      TIME_WAIT
tcp6       0      0 192.168.0.160:443       79.147.25.10:50593      TIME_WAIT
udp        0      0 0.0.0.0:68              0.0.0.0:*
udp        0      0 0.0.0.0:631             0.0.0.0:*
udp        0      0 192.168.0.160:45696     0.0.0.0:*
udp        0      0 0.0.0.0:33981           0.0.0.0:*
udp        0      0 0.0.0.0:5353            0.0.0.0:*
udp        0      0 239.255.255.250:1900    0.0.0.0:*
udp6       0      0 :::34919                :::*
udp6       0      0 :::5353                 :::*
raw6       0      0 :::58                   :::*                    7


text:
Q: c# How to write to a ini file I would like to know how i should write text to a ini file. The reading of the file is already done. Now i just have to know how to write to the file.
It should look like this when its in the INI file:
[H83052_md7]
Description=H83048 processor mode 7
BootFile=kernel_52.md7
Extension=a20
If you would like to see how i read from the file ask me for the source code please because i could not figure out how i should do this.
I write it like this:
namespace Flashloader

{
    class Controllerlist : List<Controller>
    {
        public Controllerlist FromIniFile()
        {
            StringList input = new StringList().FromFile("Controllers.ini");
        Controller controller = null;

        foreach (var item in input)
        {
            String line = item.Trim();

            if (line.StartsWith("[") && line.EndsWith("]"))
            {
                String name = line.Substring(1, line.Length - 2);

                controller = new Controller(name);
                Add(controller);
            }
            else if (controller != null)
            {
                int index = line.IndexOf('=');
                if (index < 0)
                    continue;

                String key = line.Substring(0, index).Trim();
                String value = line.Substring(index + 1).Trim();

                if (Utils.EqualsIgnoreCase(key, "Description"))
                    controller.Description = value;
                else if (Utils.EqualsIgnoreCase(key, "Bootfile"))
                    controller.Bootfile = value;
                else if (Utils.EqualsIgnoreCase(key, "Extension"))
                    controller.Extension = value;
            }
        }
        return this;
    }

    public Controller FindByName(String name)
    {
        foreach (var item in this)
            if (Utils.EqualsIgnoreCase(item.Name, name))
                return item;
        return null;
    }
}

}

A: Try this class:
public class IniFile
  {
    public string path;

    [DllImport("kernel32")]
    private static extern long WritePrivateProfileString(string section,
      string key,string val,string filePath);

    [DllImport("kernel32")]
    private static extern int GetPrivateProfileString(string section,
      string key,string def, StringBuilder retVal,
      int size,string filePath);

    public IniFile(string INIPath)
    {
      path = INIPath;
    }

    public void IniWriteValue(string Section,string Key,string Value)
    {
      WritePrivateProfileString(Section,Key,Value,this.path);
    }

    public string IniReadValue(string Section,string Key)
    {
      StringBuilder temp = new StringBuilder(255);
      int i = GetPrivateProfileString(Section,Key,"",temp,255, this.path);
      return temp.ToString();
    }
  }

A: This is the best solution to write/read INi file. http://www.blackwasp.co.uk/IniFile.aspx


text:
Q: How to fill an array with smaller arrays in a random way? I've got an array with 225 elements and 15 smaller arrays which their length sum is exactly 225.
The point is that I need to fill the larger array with these smaller arrays but in a random way.
 private final short datosdeNivel[]= new short[225];
 private final short diecinueve[]= {19, 19};
 private final short veintiseis[]= {26, 26, 26};
 private final short dieciocho[]= {18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18};
 private final short veintidos[]= {22, 22};
 private final short veintiuno[]={21, 21, 21, 21, 21, 21, 21, 21, 21, 21};
 private final short cero[]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 private final short diecisiete[]= {17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17};
 private final short dieciseis[]= {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16,16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
 private final short veinte[]= {20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20};
 private final short veinticuatro[]= {24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24};
 private final short veinticinco[]= {25, 25, 25, 25};
 private final short veintiocho[]= {28, 28};
 private final short uno[]= {1, 1, 1, 1, 1, 1, 1};
 private final short nueve[]= {1};
 private final short ocho[]= {9, 9, 9, 9, 9, 9, 9, 9, 9};

How can I establish a random order so every time the program runs the order in which the smaller arrays are placed in the larger array is different?
This would be a way to fill it in order:
int aux;

        aux= diecinueve.length;

        for(int i=0; i<diecinueve.length; i++)
        {
            datosdeNivel[i]= diecinueve[i];
        }
        for(int i=0; i<veintiseis.length; i++)
        {
            datosdeNivel[aux]= veintiseis[i];
            aux++;
        }
        for(int i=0; i<dieciocho.length; i++)
        {
            datosdeNivel[aux]= dieciocho[i];
            aux++;
        }
        for(int i=0; i<veintidos.length; i++)
        {
            datosdeNivel[aux]= veintidos[i];
            aux++;
        }
        for(int i=0; i<veintiuno.length; i++)
        {
            datosdeNivel[aux]= veintiuno[i];
            aux++;
        }
        for(int i=0; i<cero.length; i++)
        {
            datosdeNivel[aux]= cero[i];
            aux++;
        }
        for(int i=0; i<diecisiete.length; i++)
        {
            datosdeNivel[aux]= diecisiete[i];
            aux++;
        }
        for(int i=0; i<dieciseis.length; i++)
        {
            datosdeNivel[aux]= dieciseis[i];
            aux++;
        }
        for(int i=0; i<veinte.length; i++)
        {
            datosdeNivel[aux]= veinte[i];
            aux++;
        }
        for(int i=0; i<veinticuatro.length; i++)
        {
            datosdeNivel[aux]= veinticuatro[i];
            aux++;
        }
        for(int i=0; i<veinticinco.length; i++)
        {
            datosdeNivel[aux]= veinticinco[i];
            aux++;
        }
        for(int i=0; i<veintiocho.length; i++)
        {
            datosdeNivel[aux]= veintiocho[i];
            aux++;
        }
        for(int i=0; i<uno.length; i++)
        {
            datosdeNivel[aux]= uno[i];
            aux++;
        }
        for(int i=0; i<nueve.length; i++)
        {
            datosdeNivel[aux]= nueve[i];
            aux++;
        }
        for(int i=0; i<ocho.length; i++)
        {
            datosdeNivel[aux]= ocho[i];
            aux++;
        }

A: You could try creating an ArrayList, containing all of your smaller arrays:
ArrayList<short[]> arrays = new ArrayList<>();
arrays.add(ocho);
arrays.add(veintiocho);
// ...

and then access indexes randomly, removing from the list each time you add to your large array:
Random rand = new Random();
while (!arrays.isEmpty()) {
    int index = rand.nextInt(array.size());
    short[] s = arrays.get(index);

    for(int i = 0; i < s.length; i++)
    {
        datosdeNivel[aux]= s[i];
        aux++;
    }

    arrays.remove(index);
}

This will add each array to the large array in a random order.

A: In pseudo code:

*

*Put the arrays in a List

*Shuffle the list using Collections.shuffle(list)

*iterate over the list, filling the final array with elements of each array

A: If I were you, I'll give each array an index, then make a bucket of these indexes, then randomly pick up an index from the bucket, do your copy job, and remove this used index from your bucket.


text:
Q: If Statement with Expression inside .map() within React Return() I believe the problem I'm having is because my map function is within the return method within react. Is this not possible to do?
What needs to happen is I'm mapping through survey data.  I need to average the columns for each.  So I'm adding column1 + column2 + column3, and then need to divide by the number of responses given.  I can't just divide by 3, because some people left one of the responses blank.  So I came up with the code below, but it's giving me this error: Expected an assignment or function call and instead saw an expression
render() {

        return (
            <Jumbotron className="text-dark">

                    <Row>
                        <Col>

                                    Client
                                    Name
                                    Score: Consulting
                                    Score: Talent

                                    {
                                    this.state.surveyData.map((client) => {
                                    let consultingScoreDiv = 0;
                                    const consultingScore = client.value1 + client.value2 + client.value3;
                                    if (client.value1 !== ""){ consultingScoreDiv++ };
                                    if (client.value2 !== ""){ consultingScoreDiv++ };
                                    if (client.value3 !== ""){ consultingScoreDiv++ };

                                                {client.orgName}
                                                {client.name}
                                                {consultingScore/consultingScoreDiv}

                                        }

                                    )
                                    }

                        </Col>
                    </Row>

            </Jumbotron>
        )
    }

A: You had few issue:

*

*You are missing the a return in your map.

*You check for empty string, instead of undefined or typeof

*you calculated the total even if there was no value there.

*You did not check division by 0.

Here's how it should look like:
{this.state.surveyData.map((client) => {
  let consultingScoreDiv = 0;
  let consultingScore = 0;
  if (typeof client.value1 === "number") {
    consultingScoreDiv++;
    consultingScore += client.value1;
  }
  if (typeof client.value2 === "number") {
    consultingScoreDiv++;
    consultingScore += client.value2;
  }
  if (typeof client.value3 === "number") {
    consultingScoreDiv++;
    consultingScore += client.value3;
  }

  return (

      {client.orgName}
      {client.name}

        {consultingScoreDiv > 0
          ? consultingScore / consultingScoreDiv
          : 0}

  );
})}


text:
Q: How to organize a javascript object that contains store hours? If I have an object with store information that looks like this.
storeHours:
0:
 day: Sunday
 Open: 9:00am
 close: 6:00pm
0:
 day: Monday
 Open: 8:00am
 close: 10:00pm
0:
 day: Tuesday
 Open: 8:00am
 close: 10:00pm
0:
 day: Wednesday
 Open: 8:00am
 close: 10:00pm
0:
 day: Thursday
 Open: 8:00am
 close: 10:00pm
0:
 day: Friday
 Open: 8:00am
 close: 10:00pm
0:
 day: Saturday
 Open: 9:00am
 close: 6:00pm

What function should I write to get output that would give me
simplestoreHours:
0:
 Days: Monday-Friday
 open: 8:00am
 close: 6:00pm
1:
 Days: Saturday-Sunday
 open: 9:00am
 close: 6:00pm

Also all the times are formatted momentjs objects so it is possible to use momentjs.
My initial thought is to do a loop and have each element checked against each other. If the open and closing times are the same then just connect the days, but I don't think this very clever.

A: reduce Array method can help you.

*

*we have to iterate over initial dates object.

*group days and working hours into 2 helper arrays by key. i used concatenated open and close time

*keep open and close time in ranges sub array

*as we are not sure initial array sorted by day of week i've added day index into days grouped array.

*on last iteration lets come through ranges we have and find days with range key, sort it, create Days property as concationation first and last sorted days array and save combined object.
var groupedObject = obj.reduce(function (memo, item, i, array) {
    var key = item.open+item.close;

    memo.ranges[key] = memo.ranges[key] || {};
    memo.days[key] = memo.days[key] || [];

    memo.ranges[key] = { open: item.open, close: item.open };

    memo.days[key].push({
        index: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'].indexOf(item.day),
        name: item.day
    })

    if (i == array.length-1 ) {
        for (var key in memo.ranges) {
            if (memo.ranges.hasOwnProperty(key)) {

                memo.days[key].sort(function(a,b) { return a.index - b.index });

                memo.grouped.push({
                    Days: [
                        memo.days[key][0].name,
                        memo.days[key][memo.days[key].length-1 ].name
                    ].join('-'),
                    open: memo.ranges[key].open,
                    close: memo.ranges[key].close
                });
            }
        }
    }

  return memo

}, { ranges: {}, days: {}, grouped: [] });

console.log(groupedObject.grouped);

thats it)

A: You could do it this way:
var storeHours = [
    {day: 'Sunday', open: '9:00am', close: '6:00pm' },
    {day: 'Monday', open: '8:00am', close: '10:00pm' },
    {day: 'Tuesday', open: '8:00am', close: '10:00pm' },
    {day: 'Wednesday', open: '8:00am', close: '10:00pm' },
    {day: 'Thursday', open: '8:00am', close: '10:00pm' },
    {day: 'Friday', open: '8:00am', close: '10:00pm' },
    {day: 'Saturday', open: '9:00am', close: '6:00pm' }
];

function sort() {

var daysSorted = [];

for (var dayCounter = 0, length = storeHours.length; dayCounter < length; dayCounter++)     {

    var open = storeHours[dayCounter].open,
        close = storeHours[dayCounter].close,
        name = storeHours[dayCounter].day,
        found = false;

    for (var sortedDayCounter = 0, lengthSorted = daysSorted.length; sortedDayCounter < lengthSorted; sortedDayCounter++) {

        var sortedOpen = daysSorted[sortedDayCounter].open,
            sortedClose = daysSorted[sortedDayCounter].close;

        if (sortedOpen === open && sortedClose == close) {

            daysSorted[sortedDayCounter].day += ', ' + name;
            found = true;

        }

    };

    if (!found) {
        daysSorted.push(storeHours[dayCounter]);
    }

};

return daysSorted;

}

console.log(sort());

Anyway, I recommend that you consider open and close dates as Date types, rather than strings.
Hope this helps,


text:
Q: MsSql finding the maximum value of an Avg value list iv'e just started to work with SQL and to be honest im abit over my head right now...
any way i have a realestate db and i need to show the name of the city, neighborhood and the sales profits from that neighborhood for the most expencive neighborhood untill now.
for some reason the select displays the maximum avrage at the profit column but also displays all of the neighborhoods....
here's what iv'e done:
create view V_Avrage_price as
select 'avgprice'=avg(s.actualprice),c.CityName, n.name
from sale s, Neighborhood n, city c, house h
where n.CityID=c.CityID and h.SaleID=s.SaleID and h.NeighborhoodID=n.NeighborhoodID
group by n.Name, c.CityName

select distinct c.CityName,n.name, avgprice
from V_Avrage_price, city c, Neighborhood n, sale s, house h
where n.CityID=c.CityID and h.SaleID=s.SaleID and h.NeighborhoodID=n.NeighborhoodID
and avgprice=(select max(avgprice) from V_Avrage_price)

A: select 'avgprice'=avg(s.actualprice),c.CityName, n.name
from sale s, Neighborhood n, city c, house h
where n.CityID=c.CityID and h.SaleID=s.SaleID and h.NeighborhoodID=n.NeighborhoodID
group by n.Name, c.CityName

select distinct c.CityName,n.name, avgprice
from V_Avrage_price, city c, Neighborhood n, sale s, house h
where n.CityID=c.CityID and h.SaleID=s.SaleID and  h.NeighborhoodID=n.NeighborhoodID and avgprice=(select max(avgprice) from V_Avrage_price)

A: I think this is enough
select distinct CityName,name, avgprice
from   V_Avrage_price
where avgprice=(select max(avgprice) from V_Avrage_price)


text:
Q: Override default font style android How we can override default font family of entire android device or at least for keyboard programatically.
I have .ttf file,but I am able to find any resource to change the font family of entire device.


text:
Q: Numerical Integration with Unspecified Parameter in C++ I have written a simple code to calculate an integral numerically with both the midpoint and trapezoidal rule. It works fine, but now I would like to modify it so that it can calculate the same integral but with an unspecified parameter. So instead of the integral of e^(-x^2), I would like to calculate the integral of e^(-\alpha*x^2). However, I am stuck here. I tried to just declare a new double alpha without initializing it, but that clearly takes me no where. Is there a way to do such a thing in C++? Thank you in advance.
//=============================================================
// A simple program to numerically integrate a Gaussian over
// the interval a to b
//=============================================================

#include <iostream>
#include <cmath>

using namespace std;

// function implementing the midpoint rule
double midpoint(double a, double b, int n){
    double sum = 0.0;
    double width = (b-a)/n;
    for (int i = 1; i < n; i++){
        sum += exp((-1)*(a+(i+0.5)*width)*(a+(i+0.5)*width))*width;
    }
    return sum;
}

//function implementing the trapezoidal rule
double trapezoidal(double a, double b, int n){
    double width = (b-a)/n;
    double sum = (width/2)*(exp(-a*a)+exp(-b*b));
    for (int i = 1; i < n; i++){
        sum += 2*exp((-1)*(a+i*width)*(a+i*width))*width/2;
    }
    return sum;
}

int main(){
    cout << "THIS IS A SIMPLE PROGRAM TO INTEGRATE A GAUSSIAN OVER A CERTAIN INTERVAL." << endl;
    int n;
    double a, b;
    cout << "Enter the lower and upper limit of integration as doubles" << endl;
    cin >> a >> b;
    cout << "Enter the number of partitions" << endl;
    cin >> n;
    double actual = 0.886207;
    double midRule = midpoint(a,b,n);
    double trapRule = trapezoidal(a,b,n);
    cout << "For the function e^(-x^2) integrated from "<< a << " to " << b <<  endl;
    cout << "The analytic value of the integral is: " << actual << endl;
    cout << "The midpoint value of the integral for " << n << " partitions is: " << midRule << endl;
    cout << "The trapezoidal value of the integral for " << n << " partitions is: " << trapRule << endl;
    cout << "The percent error for the midpoint is: " << (abs(actual-midRule)/actual)*100 << "%" << endl;
    cout << "The percent error for the trapezoidal is: " << (abs(actual-trapRule)/actual)*100 << "%" << endl;
    return 0;
}


text:
Q: Remove assosiation instead of destroying object when :allow_destroy => true When using the new accepts_nested_attributes_for in ActiveRecord, it's possible to use the option :allow_destroy => true. When this option is set, any hash containing nested attributes like {"_delete"=>"1", "id"=>"..."} passed to update_attributes will delete the nested object.
Simple setup:
class Forum < ActiveRecord::Base
  has_many :users
  accepts_nested_attributes_for :users, :allow_destroy => true
end

class User < ActiveRecord::Base
  belongs_to :forum
end

Forum.first.update_attributes("users_attributes"=>{"0"=>{"_delete"=>"1", "id"=>"42"}})
Question: How do I - instead of deleting the nested objects when "_delete" => "1" - just remove the association? (i.e. In the above case set the forum_id on the user to nil)
Bonus question: What if I also want to change the an attribute on the nested object when removing the association? (e.g. like setting a state or a timestamp)

A: Instead of asking for the user to be deleted using "_delete" => '1', can you not just update it using the nested_attributes?:
Forum.first.update_attributes("users_attributes"=> {
  "0" => {
    "id" => "42",
    "forum_id" => "",
    "state" => 'removed'
  }
})


text:
Q: how come this error while trying to fetch firebase data [2023-01-21T10:55:57.037Z]  @firebase/firestore: Firestore (9.15.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=failed-precondition]: The Cloud Firestore API is not available for Firestore in Datastore Mode database projects/reddit-clone-feefd/databases/(default).
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
i want to fetch firebase data


text:
Q: Using React.JS with Materialize v1.0.0 unable to init JS Been trying to convert several of our projects using materialize-css v1.0 using npm into react.js and having a heck of time doing so. I was wondering if anyone else has tried to tackle this as well and maybe came up with some solutions?
I am able to use the css portion just fine using the npm module and referencing it in the Index.js.
The problem I have is initializing the minified js with individual components but having no success. Here is the example one being the Index.js for css entry point and the sidebar component I am trying to get working using minified js. I also provided the App.js configuration in case anyone was curious. The plan was to break each part of this project into individual components but first just wanted to get the functionality of initializing the sidebar js first before doing so.
Index.js
import React from 'react';
import ReactDOM from 'react-dom';
import 'materialize-css/dist/css/materialize.min.css';
import App from './components/App';
ReactDOM.render(<App />, document.getElementById('root'));

App.js
import React, { Component } from 'react';
import { BrowserRouter, Route } from 'react-router-dom';
// import Header from './header/Header';
// import Footer from './Footer';
import Landing from './landing/Landing';
import About from './About';
import Projects from './Projects';
class App extends Component {
 render() {
 return (

 <BrowserRouter>

 {/**/}
 <Route exact path="/" component={Landing} />
 <Route exact path="/about" component={About} />
 <Route exact path="/projects" component={Projects} />
 {/* */}

 </BrowserRouter>

 );
 }
}
export default App;

Landing.js
import React, { Component } from 'react';
import M from 'materialize-css/dist/js/materialize.min.js';
// import { Link } from 'react-router-dom';
import './Landing.css';

class Landing extends Component {
  componentDidMount() {
    console.log(M);
    const sideNav = document.querySelector('.button-collapse');
    console.log(M.Sidenav.init(sideNav, {}));

    M.Sidenav.init(sideNav, {});
  }

  render() {
    return (

                    TEST

                    menu

                      Home

                      About

                      Testimonials

                      Contact

                      Download

          {/* Side Nav: fixed navbars must go right underneath main nav bar */}

TEST

              Home

              About

              Testimonials

              Contact

          {/*-- Showcase */}

You found the...

Right Place To Start

                  To take your business to the next level with our services that
                  have taken companies to the fortune 500

                  Learn More

                    arrow_drop_down_circle

    );
  }
}

export default Landing;

Here are some screen shots I am getting with errors in my console as well regarding the anchor tags (not sure how I work around this if its needed in the side bar). I am getting access to the sidebar as per the console.logs shown below.

Hope someone else has encountered this problem already and can help...
Cheers!
[![enter image description here][3]][3]

A: The trigger button markup is incorrect. It has to be data-target and it has to have the class sidenav-trigger. Also the side nav has to have the classname sidenav. side-nav with a hyphen will not work:

    menu

Also you should always use refs instead of querying the DOM yourself when working with react. Apply a ref callback to the sidenav element and then use it to initialize:
class Landing extends Component {
    onRef = nav => {
        this.nav = nav;
        M.Sidenav.init(nav);
    };

    render() {
        return (
           {/* ... */}

                {/* ... */}

            {/* ... */}
        );
    }
}

Working example with your corrected markup:


text:
Q: How to get the absolute position of a vertex in three.js? As far as I know var point = object.geometry.vertices[i]; will return with the relative position for the x, y and z of the point inside the geometry of the object.
How to get the absolute position, if the object was moved, rotated or scaled?

A: First make sure the object's matrices have been updated.
object.updateMatrixWorld();

The render loop usually calls this for you.
Then, do this:
var vector = object.geometry.vertices[i].clone();

vector.applyMatrix4( object.matrixWorld );

The vector will now contain the position in world coordinates.
You might want to read some CG reference books.

*

*3D math primer for graphics and game development / by Fletcher Dunn and Ian Parberry

*Essential Mathematics for Games and Interactive Applications: A Programmer's Guide
James M. Van Verth and Lars M. Bishop
three.js r69

A: Recent versions of Three.js (v50+) provide this functionality built into the THREE.Object3D class. In particular, to get the world coordinates of a local THREE.Vector3 instance named vector, use the localToWorld method:
object.localToWorld( vector );

Similarly, there is a worldToLocal method for converting world coordinates into local coordinates, which is slightly more complicated, mathematically speaking. To translate a world vector into the objects local coordinate space:
object.worldToLocal( vector );


text:
Q: Does jQuery $.when handles several ajax requests at differents times? function myFunc() {
    console.log('called!');
}

var url = $.get('/api/example.json');

$.when(url).then(function(response) {
    myFunc();
});

How can I make myFunc get called everytime url gets requested?
for (var i = 0; i < 10; i++) {
    // how can I call url and fire myFunc()?
    url();
}

I need it to log:
// called!
// called!
// called!
// called!
// called!
// called!
// called!
// called!
// called!

Do I need to initialize a $.Deferred object?
How can I do that?

A: I believe you could just do it like this:
function myFunc() {
    console.log('called!');
}

for (var i = 0; i < 10; i++) {
    $.get('/api/example.json').done(myFunc); // get your file, and when it's done, call myFunc.
}

Hope this helps!


text:
Q: How to fix "bower ENOTFOUND" I'm trying to install https://github.com/catarse/catarse script on VPS(on my local machine works fine) and I have an error when I enter the command bower install:
bower checkout      catarse_admin#master
bower resolved      https://github.com/catarse/catarse_admin.git#3151581f33
bower ENOTFOUND     Package option not found

bower.json
{
  "name": "catarse",
  "version": "1.0.0",
  "homepage": "https://github.com/catarse/catarse",
  "description": "The first open source crowdfunding platform for creative projects in the world!",
  "license": "MIT",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "vendor/assets/components",
    "test",
    "tests"
  ],
  "dependencies": {
    "jquery": "~2.1.4",
    "backbone": "~1.2.0",
    "underscore": "~1.8.3",
    "jquery-sticky": "~1.0.1",
    "jquery-smooth-scroll": "~1.5.5",
    "jquery-typewatch": "~2.2.1",
    "store": "~2.3.0",
    "jQuery-Mask-Plugin": "~1.11.4",
    "jquery-ui": "~1.11.4",
    "jquery-ujs": "~1.0.3",
    "jquery.fixedmask": "~1.0.0",
    "mithril": "~0.2.0",
    "catarse_admin": "https://github.com/catarse/catarse_admin.git#master"
  }
}

A: So shame.. I entered bower install --allow-root option instead of bower install --allow-root


text:
Q: How many int. values of n will the expression be greater than 1 How would I solve this problem:

How many integer values of n will the expression $4n+7$ be an integer greater than 1 and less than 200 a)48 b)49 c)50 d)51 e)52 ? Ans 50

I am trying to solve this by using inequalities and doing something like this
$200 > 4n + 7 > 1$
$193 > 4n > -6 $
$\frac{193}{4} > n > \frac{-6}{4}$
However this just gives me the range. How do i get the number of integers 50 ?

A: We can work with inequalities as you did. We want
$$1\lt 4n+7 \lt 200,$$
which can be rewritten as
$$-6 \lt  4n \lt 193,$$
and then as
$$\frac{-6}{4} \lt n \lt \frac{193}{4}.$$
Note that $\,\frac{-6}{4}=-1.5\,$ and $\,\frac{193}{4}=48.25\,$
So all integers from $-1$ to $48$ inclusive work, and no others. There are $\,50
\,$ of them: the integers $-1$ and $0$, plus the $48$ integers from $1$ to $48$.

A: n is (as you said) an integer. So for $\frac{193}{4} > n > \frac{-6}{4}$, it follows $48 > n > -1 $.
So for $n \in \{-1, ... , 48\}$ the inequalties hold true. Those are exactly 50 integers.

A: In general, there are exactly $b-a$ integers between $a$ and $b$, including $b$ but not $a$. For example, there are exactly $10-0=10$ integers between 0 and 10, including 10 but not 0.
If you include both ends, add 1 to the total; if you include neither, subtract 1.
You have:
$$-\frac64 < n < \frac{193}4$$
which is:
$$-1\frac12 < n < 48\frac14$$
So $n$ can be any integer between $-1$ and $48$, inclusive; there are $48 - (-1) + 1 = 50$ such.

A: $\rm 2 \le 4n\!+\!7 \le 199\! \iff\! 3 \le 4(n\!+\!2) \le 200.\:$ The map $\rm\:n\to 4(n\!+\!2)\:$ bijects all solutions $\rm\:n\:$ with all multiples of $4$ that are $\ge 3$ and $\le 200$, of which there are $\lfloor 200/4\rfloor = 50$.


text:
Q: Wrong projection of raster using R I have a raster layer with the following structure:
ncols 4320
nrows 2160
xllcorner -180.0
yllcorner -90.0
cellsize 0.0833333
NODATA_value -9999.0
-9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0

If I then try to read it and project, it does not appear:
library(raster)
library(tmap)

r <- raster("baseline/baseline/zip/1870AD_pop/popc_1870AD.asc")
crs(r) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

tmap_mode("view")
tm_shape(r)+tm_raster("red")

For some reason, I'm unable to display it properly, even with the added crs.
plot(r) does give me an expected output:

However, when trying to plot it on another map, it fails to do it correctly.
summary(r) gives the following output:
> summary(r)
         popc_1870AD
Min.    0.000000e+00
1st Qu. 0.000000e+00
Median  7.089942e+00
3rd Qu. 1.621315e+02
Max.    1.331152e+05
NA's    7.092085e+06
Warnmeldung:
In .local(object, ...) :
  summary is an estimate based on a sample of 1e+05 cells (1.07% of all cells)

The file can be downloaded here:
http://www.filedropper.com/popc1870ad

A: Your data goes up/down to 90N/S. On a Mercator projection, like on most web mapping software, this goes to +Infinity/-Infinity.
tmap seems to have even tighter limits on what it can display. If I crop to +/-50 I can see your data within that latitude band:
> rc50 = crop(r,extent(c(-180,180,-50,50)))
> tm_shape(rc50) + tm_raster()

but if I change it to -51 and 51, I see nothing!
If you reproject the data to the web mercator projection, then you can display more, but you still have to crop it first because otherwise you go off to infinity:
> rc = crop(r,extent(c(-180,180,-80,85)))
> rp = projectRaster(rc, crs="+init=epsg:3857")

It doesn't matter if you set the CRS like you do or not, since you are using the default CRS anyway (but its a Good Thing to set it anyway).


text:
Q: NSFetchedResultsController doesn't show updates from a different context I have an NSFetchedResultsController and a few operations updates managed objects on separate threads via NSOperationQueue.
The FRC (with its predicate) looks like this:
- (NSFetchedResultsController*)fetchedResultsController
{
    if(fetchedResultsController) return fetchedResultsController;

    NSManagedObjectContext* mainContext = [self managedObjectContext];

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    [fetchRequest setEntity:[NSEntityDescription entityForName:@"Check" inManagedObjectContext:mainContext]];
    [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"isSync == %@", [NSNumber numberWithBool:NO]]];
    [fetchRequest setFetchBatchSize:10];

    fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:mainContext sectionNameKeyPath:nil cacheName:nil];
    fetchedResultsController.delegate = self;

    [fetchRequest release], fetchRequest = nil;

    return fetchedResultsController;
}

The main thread and the threaded operation have their own managed object contexts. They only share the same coordinator.
Within the threaded operation I change the isSync property from NO to YES. To know what is Check entity to update, the main context passes to the threaded one a NSManagedObjectID.
The threaded operation retrieves the managed object like the following:
-(void)main
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSManagedObjectContext *exportContext = [[NSManagedObjectContext alloc] init];
    [exportContext setPersistentStoreCoordinator:[self persistentStoreCoordinator]];

    //...

    Check* check = (Check*)[exportContext existingObjectWithID:objID error:&error];
    check.isSync = [NSNumber numberWithBool:YES];

    //...

    [exportContext save:&error];

    [pool release], pool = nil;
}

When the thread operation calls a save the mergeChangesFromContextDidSaveNotification notification is called and the main context merges the changes.
- (void)contextChanged:(NSNotification*)notification
{
    if ([notification object] == [self managedObjectContext]) return;

    if (![NSThread isMainThread]) {
        [self performSelectorOnMainThread:@selector(contextChanged:) withObject:notification waitUntilDone:YES];
        return;
    }

    [[self managedObjectContext] mergeChangesFromContextDidSaveNotification:notification];
}

Logging the description of the notification leads to verify that changes are performed correctly.
My problem
Delegates methods of NSFetchedResultsControllerDelegate are not called.
This is quite strange since dealing with the same context, the main one, allows to listen for changes and delegates methods are called, e.g. deleting a row object in the UITableView.
I've found some topics on SO with the same problem. I've tried all the workarounds but I cannot find a valuable solution:

*

*NSFetchedResultsController not showing updates from other contexts

*NSFetchedResultsController not firing delegate method after merging update from background thread

*NSFetchedResultsController with predicate ignores changes merged from different NSManagedObjectContext
Thank you in advance.
Edit
The code above was working in a previous model. Then I created a new model copying (and pasting) entities from the previous one and now it doesn't work anymore.
Suggestions?
Edit 2
This is the predicate I'm using in NSFetchedResultsController getter. It's my fault, but when I wrote the post I didn't copy it.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"insertionDate" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

// previous code here
[fetchRequest setSortDescriptors:sortDescriptors];

Now, about Jody last comment

In the main() of your NSOperation, you are loading new objects, and in
  there it looks like you are setting isSync to YES for each new object.
  The predicate you use for the fetchedResultsController is looking only
  for objects that have isSync == NO.

I expecting that when the property isSync is set to YES, the NSFetchedResultsController observes that changes and removes rows that not match the predicate. Am I wrong?
Remember that when merging changes from the background to the main thread, I'm able to see that few objects have updated their isSync property.

A: I just had the same problem, which I solved with parent/child contexts.
Here is the problem I had.
I was updating my Core Data object graph in a background thread which had its own managedObjectContext (which is mandatory), and my fetchedResultsController was not able to pick up the changes done to the database.
After I solved it I took some notes:
ManagedObjectContexts are not thread safe, which means that a managedObjectContext cannot be shared with other threads. If a thread needs to use a managedObjectContext, then it will initialize its own managedObjectContext.
To initialize a managedObjectContext there are two ways:

*

*alloc/init then set its persistentStoreCoordinator property

*alloc/init then set a parentContext property instead of a persistentStoreCoordinator property
note: one cannot set both the persistentStoreCoordinator and the parentContext property of a managedObjectContext.
Using parent/child contexts is needed when the a context is run on a background thread that is "linked to controllers and UI objects that are required to be used only on the main thread"(core data documentation).
Here are the requirements needed for the parent/child contexts:

*

*the parent context lives in the main thread

*the child context lives in the background thread

*both contexts need to be initialized with an initWithConcurrencyType:NSMainQueueConcurrencyType method.

*when the batch of changes has been done in the child context, both contexts need to perform a save operation. These save operations need to be nested in performBlock methods, i.e:
childContext performBlock:^{
    [childContext save:nil];
    [self.parentContext performBlock:^{
        [self.parentContext save:nil];
    }];
}];

EDIT: The code above is actually a bad idea for 2 reasons:
1) It works without saving the parent context.
2) The main thread is blocked if the parent context runs on it.
I hope it helped !
EDIT: Here is a stackoverflow thread which helped me greatly: Does a Core Data parent ManagedObjectContext need to share a concurrency type with the child context?

A: You have the basic idea, so there is probably a bug somewhere in your code...
Double check that you are properly registering to receive the notification from the background MOC.
Register to receive all notifications from all objects.  In that method, log the event, and all its data.  When the object is a MOC, dump all its properties (especially the lists of registered, inserted, updated, and deleted objects).
Put a log statement right before and after the save call, and in the notification handler for merging the notification.
Also, you omitted a lot of code so it's hard to know what you are actually doing, but the code sample you included looks like it is hard setting isSync to YES for all objects being loaded, but your fetch request only wants those with isSync set to NO.  None of those new objects will pass that predicate.
Finally, double check your model definition and make sure you are using the right number type.  This can be a big source of problems.
EDIT
Oh yeah, I forgot... your fetch request does not have a sort descriptor.  When you create a FRC, your fetch request must contain at least one sort descriptor... if you have multiple sections, the first sort descriptor is used to group the objects into sections.
To follow up on Alexsander's comment... I alluded to it at the beginning of my post, but you certainly do not want to listen to notifications from a MOC unless it is well known as one of yours (unless, of course, you are just logging for debugging purposes).  You should know about the MOC you are using.
Furthermore, I would suggest using parent/child MOCs for this type of processing, but what you are doing should work if done properly.
Parent (private concurrency type)
Main (main concurrency type)
Then, with your background MOCs, just have them set the main moc as their parent.  When they save, their objects get injected directly into the main MOC.  The main MOC can then issues saves at later times to put them onto disk.
Or, you can parent you background MOC to the "parent" and then the "main" MOC can just reissue the fetch to get the data from the parent.


text:
Q: best practice phonegap architecture I'm trynig to work on a phonegap applicaion but I don't know realy how to build the architecture.
I try a kind of MVC model with a big js for a controller, a js file with ajax request to get infos from the server (model) .
For the views I use a main layout with a header and a head.
I update my content using load in JQuery.
I have some problems using this system for exemple the previous button close the application because I always using the same page. When I rotate my screen I come back to the first screen because the page is refresh.
I'd like to know if you have some solutions or some code sample to begin with good bases
Thanks

A: It depends how much do you want to change your current project.
In case you don't mind doing complete app revamp think about using Phonegap with jQuery Mobile + Backbone.js or Phonegap with Kendo UI. You already stated that jQuery is used for content loading so jump to jQuery Mobile is not going to be that problematic.
You can still use MVC doctrine with backbone.js and jQuery Mobile will handle page handling/transitions/UI. Only problem with this solution is possible performance issues in case you create too complex app. But this will happen to you no matter are you creating everything from the scratch or because you are using UI frameworks.
If you are willing to give it a try take a look at my other answers on related questions:

*

*Frameworks and little something about them: https://stackoverflow.com/a/14166593/1848600

*Phonegap + jQuery Mobile tutorials: https://stackoverflow.com/a/14375842/1848600
While Phonegap + jQuery Mobile is far from perfect combination it is still one of the best there is and it will save you a lot of time.
EDIT :
As you are using jQuery Mobile you can have a persistent header and footer if you use:
...data-position="fixed" data-id="footer"...

in both of them.
Here's my "how to" article on this question: https://stackoverflow.com/a/14417307/1848600
And here's a working example: http://jsfiddle.net/Gajotres/Beq4H/


text:
Q: Prevent scrolling when in portrait mode android I have an xml which uses linear layout and weights to equally distribute space on the screen to a few buttons and such. When I rotate screen to landscape mode, the buttons all get compressed. Could someone tell me how to make the buttons take equal space, non scrollable, when in portrait, and the whole screen scrollable when in landscape. Presently I am not using any scrollview and the layout is looking good, with the table and buttons taking the right amount of space, but when i rotate the screen to landscape, everything gets compressed. I tried enclosing the Linear Layout inside a scrollview but that caused the Linear Layout to move out of the screen, so when in portrait mode, i have to scroll to see whole content. Here is my xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:id="@+id/linear"
    android:orientation="vertical"
    android:background="#bf000000"
    tools:context=".MainActivity"
    android:layout_above="@+id/imageView">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/txtReceive1"
        android:visibility="gone"/>

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/table"
        android:background="#fff3f3f2"
        android:stretchColumns="*"
        android:shrinkColumns="*"
        >
        <TableRow>

            <TextView
                android:text="CH"
                android:gravity="center"

                android:padding="8dip"
                android:layout_width="wrap_content" />
            <TextView
                android:text="kWh"
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content" />
            <TextView
                android:text="Load"
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content" />
            <TextView
                android:text="Date"
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content" />
        </TableRow>
        <TableRow >
            <TextView
                android:padding="8dip" android:layout_width="wrap_content"
                android:gravity="center"
                android:id="@+id/t11"
                android:text="1" />
            <TextView
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t12" />
            <TextView
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t13" />
            <TextView
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t14" />
        </TableRow>

        <TableRow>
            <TextView
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t21"
                android:text="2" />
            <TextView
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t22" />
            <TextView
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t23" />
            <TextView
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t24" />
        </TableRow>
        <TableRow>
            <TextView

                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t31"
                android:text="3" />
            <TextView

                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t32" />
            <TextView

                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content" />
            <TextView

                android:gravity="center"
                android:padding="8dip"
                android:layout_width="wrap_content"
                android:id="@+id/t34" />
        </TableRow> <TableRow>
        <TextView

            android:gravity="center"
            android:padding="8dip" android:layout_width="wrap_content"
            android:id="@+id/t41"
            android:text="4" />
        <TextView
            android:gravity="center"
            android:padding="8dip" android:layout_width="wrap_content"
            android:id="@+id/t42" />
        <TextView

            android:gravity="center"
            android:padding="8dip" android:layout_width="wrap_content"
            android:id="@+id/t43" />
        <TextView

            android:gravity="center"
            android:padding="8dip" android:layout_width="wrap_content"
            android:id="@+id/t44" />
    </TableRow>
        <TableRow >
            <TextView
                android:padding="8dip" android:layout_width="wrap_content"

                android:gravity="center"
                android:id="@+id/t51"
                android:text="5" />
            <TextView
                android:gravity="center"

                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t52" />
            <TextView
                android:gravity="center"

                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t53" />
            <TextView
                android:gravity="center"
                android:padding="8dip" android:layout_width="wrap_content"
                android:id="@+id/t54" />
        </TableRow>
    </TableLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ff8c00"
        android:padding="6dip"
        android:id="@+id/txtReceive"
        android:layout_below="@+id/table"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/lin2"
        android:visibility="visible"
        android:paddingTop="5dp"
        android:weightSum="2">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1"
            android:visibility="visible"
            android:weightSum="4"
            android:id="@+id/rel">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <Button
                    android:layout_height="fill_parent"
                    android:id="@+id/imageButton1"
                    android:layout_width="fill_parent"
                    android:background="@drawable/btn_01_small"
                    android:textColor="#ffa5ff45"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Channel"
                    android:textSize="22sp"
                    android:id="@+id/textView3"
                    android:layout_alignTop="@+id/imageButton1"
                    android:layout_centerHorizontal="true" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="0"
                    android:textColor="#ffa5ff45"
                    android:id="@+id/textView9"
                    android:textSize="22sp"
                    android:layout_alignBottom="@+id/imageButton1"
                    android:layout_centerHorizontal="true" />

            </RelativeLayout><RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1">
            <Button
                android:layout_height="match_parent"
                android:layout_width="fill_parent"
                android:id="@+id/imageButton2"
                android:background="@drawable/btn_02"
                android:textColor="#ffa5ff45"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="kWh"
                android:textSize="22sp"
                android:id="@+id/textView6"
                android:layout_alignTop="@+id/imageButton2"
                android:layout_centerHorizontal="true" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="000.0"
                android:textColor="#ffa5ff45"
                android:id="@+id/textView10"
                android:textSize="22sp"
                android:layout_alignBottom="@+id/imageButton2"
                android:layout_centerHorizontal="true" />
        </RelativeLayout><RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1">
            <Button
                android:layout_height="match_parent"
                android:layout_width="fill_parent"
                android:id="@+id/imageButton3"
                android:background="@drawable/btn_03"
                android:textColor="#ffa5ff45"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Load"
                android:id="@+id/textView7"
                android:textSize="22sp"
                android:layout_alignTop="@+id/imageButton3"
                android:layout_centerHorizontal="true" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="000"
                android:textColor="#ffa5ff45"
                android:id="@+id/textView11"
                android:textSize="22sp"
                android:layout_alignBottom="@+id/imageButton3"
                android:layout_centerHorizontal="true" />
        </RelativeLayout><RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1">
            <Button
                android:layout_height="match_parent"
                android:layout_width="fill_parent"
                android:id="@+id/imageButton4"
                android:background="@drawable/btn_04_small" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Days"
                android:id="@+id/textView8"
                android:textSize="22sp"
                android:layout_alignTop="@+id/imageButton4"
                android:layout_centerHorizontal="true" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="000"
                android:textColor="#ffa5ff45"
                android:id="@+id/textView12"
                android:textSize="22sp"
                android:layout_alignBottom="@+id/imageButton4"
                android:layout_centerHorizontal="true" />

        </RelativeLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="1"
            android:layout_alignParentRight="true"
            android:visibility="visible"
            android:weightSum="4"
            android:layout_below="@+id/txtReceive"
            android:id="@+id/rel2">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <Button
                    android:layout_height="fill_parent"
                    android:id="@+id/imageButton12"
                    android:layout_width="fill_parent"
                    android:background="@drawable/btn_01_small"
                    android:textColor="#ffa5ff45"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Auto ON"
                    android:id="@+id/textView32"
                    android:textSize="22sp"
                    android:layout_alignTop="@+id/imageButton12"
                    android:layout_centerHorizontal="true" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="00:00"
                    android:textColor="#ffa5ff45"
                    android:id="@+id/textView92"
                    android:textSize="22sp"
                    android:layout_alignBottom="@+id/imageButton12"
                    android:layout_centerHorizontal="true" />

            </RelativeLayout><RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1">
            <Button
                android:layout_height="match_parent"
                android:layout_width="fill_parent"
                android:id="@+id/imageButton22"
                android:background="@drawable/btn_04_small"
                android:textColor="#ffa5ff45"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Auto OFF"
                android:textSize="22sp"
                android:id="@+id/textView62"
                android:layout_alignTop="@+id/imageButton22"
                android:layout_centerHorizontal="true" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="00:00"
                android:textColor="#ffa5ff45"
                android:id="@+id/textView102"
                android:textSize="22sp"
                android:layout_alignBottom="@+id/imageButton22"
                android:layout_centerHorizontal="true" />

        </RelativeLayout><RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1">
            <Button
                android:layout_height="match_parent"
                android:layout_width="fill_parent"
                android:id="@+id/imageButton31"
                android:layout_marginTop="7dp"
                android:layout_marginBottom="-14dp"
                android:background="@drawable/send_btn_01"
                android:textSize="22sp"
                android:text="SET TIME" />
        </RelativeLayout>

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <Button
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:scaleType="matrix"
                    android:layout_marginBottom="-7dp"
                    android:id="@+id/imageButton32"
                    android:padding="0dp"
                    android:background="@drawable/send_btn_01"
                    android:textSize="22sp"
                    android:text="RECHARGE" />
            </RelativeLayout>

        </LinearLayout>
    </LinearLayout>

</LinearLayout>

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/imageView"
    android:src="@drawable/base_irya_left1"
    android:background="#bf000000"
    android:adjustViewBounds="true"
    android:layout_alignParentBottom="true" />

<!-- </RelativeLayout> -->

A: Did you consider using Fragments in Android. Here is a tutorial.
How to support different screensizes with fragments(See here)
It is possible to define in the layout file of an activity that it contains fragments (static definition) or to modify the fragments of an activity at runtime (dynamic definition).
To display differnet fragments in your activities based on the actual available space you can:
Use one activity, which displays two fragments for tablets and on handset devices. In this case change at runtime the fragments displayed by the activity whenever necessary. In this scenario you typically define instances of the FrameLayout class as placeholder in your layout and add the fragments at runtime to them.
Use separate activities to host each fragment on a handset. For example, when the tablet UI uses two fragments in an activity, use the same activity for handsets, but supply an alternative layout that includes just one fragment. If the detailed fragment is there, the main activity tells the fragment that it should update itself. If the detail fragment is not available, the main activity starts the detailed activity.
Which option to select depends on the use case, typical the dynamic contribution is more flexible bit a bit harder to implement.

A: Creating two xmls, one for landscape and one for portrait, will fix the issue. Portrait goes into res/layout folder and landscape goes into res/layout-land. The two should have identical names for this to work.


text:
Q: How to change the pin type in Lattice Radiant I'm using IP-core with slave-device clock in Lattice Radiant. On the Device Constraint Editor this pin determinated as clock-pin and I can't place it on correct pin on FMC.
This question is similar to How does lattice determine signal type? but I use Lattice Radiant

A: In this case I'm catching this error:
ERROR - par: ldc_set_location of clock driver 'rx_clk' at an illegal pin 'W13'. Unable to reach a CIB entry point for general route clock rx_clk_c in the minimum required distance of 1 PLC.
Please check if the pin is a legal clock pin by
1) Opening 'Tools->Device Constraint Editor' on the top
2) Choosing 'Pin Assgnments' tab in the middle
3) Checking 'Dual Function' column (PCLK*, GR*, etc.) for the pin

I'm solve this problem by edit: Project -> Active Strategy -> Place and Route Design -> Command Line Options add: "-exp WARNING_ON_PCLKPLC1=1".
I hope it will be useful to someone.


text:
Q: How can I load resources from another app? I'm developing an Android app for which we will be selling separate content in the Android Market.  Since Android lacks an in-app purchasing model as iOS has, I have come to understand that this is the ideal way of selling additional content (but NOT functionality) for Android apps.
So the question is, how do I actually load raw resources from other Android apps, assuming that I know the exact name of the resource, app ID, etc.?

A: Content Providers are the standard way for apps to make their content available to others.


text:
Q: use Button to get text in EditText and Spinner I want to get the text from a EditText and Spinner at the same time, but when I choose a type other than All types, it changes to All types itself.
My question is why Feature Flim changes to All Types by itself after I click send Button, is not how to get selected item in spinner.
strings.xml:
<string-array name="country_arrays">
<item>All Types</item>
<item>Feature Flim</item>
<item>TV Series</item>
<item>Video Games</item>
</string-array>

activity_main.xml:
<Spinner
    android:id="@+id/spinner1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:entries="@array/country_arrays"
     />

<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/button_send"
    android:onClick="sendMessage"/>

here is the function sendMessage in MainActicity.java:
public void sendMessage(View view) {

    final Spinner spinner = (Spinner) findViewById(R.id.spinner1);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.country_arrays, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            Toast.makeText(getBaseContext(),
                "You have selected the book: " + String.valueOf(spinner.getSelectedItem()),
                Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });

    Intent intent = new Intent(this, DisplayMessageActivity.class);
    EditText editText = (EditText) findViewById(R.id.edit_message);
    String message = editText.getText().toString() + String.valueOf(spinner.getSelectedItem());
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
}

and DisplayMessageActivity.java:
public class DisplayMessageActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get the message from the intent
    Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

    // Create the text view
    TextView textView = new TextView(this);
    textView.setTextSize(40);
    textView.setText(message);

    // Set the text view as the activity layout
    setContentView(textView);

}

I choose feature flim:

after I click send

finally it shows:

Why it change to All types by itself? How to fix it?

A: You are setting the adapter and data within sendMessage. So, every time you click "Send", the Spinner is being repopulated, and thus ends up at position 0 again.
Instead, do the following:
First, place the following line in your class declaration:
private Spinner spinner = null;

Second, move these to onCreate() (or wherever you call setContentView()):
spinner = (Spinner) findViewById(R.id.spinner1); // Do not re-declare
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.country_arrays, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        Toast.makeText(getBaseContext(),
            "You have selected the book: " + String.valueOf(spinner.getSelectedItem()),
            Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onNothingSelected(AdapterView<?> arg0) {
    }
});

Third and finally, leave the following in your sendMessage() method:
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString() + String.valueOf(spinner.getSelectedItem());
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);

A: Try getting the text in another way:
spinner.geItemAtPosition(arg2).toString();

A: To get the selected item of Spinner do as below:
Spinner mySpinner=(Spinner)findViewById(R.id.Spinner_Id);
mySpinner.getSelectedItem().toString();


text:
Q: Markov Chains: Expected Return Time (Stochastic Process) I am given a matrix with space {0,1,2,3,4}.
I already calculated the invariable probability vector.
However, the question asks to give the expected number of steps:
-given Xo=0 to go back to state "0".
-given Xo=0 to go back to state "3".
For Xo=0 --> state 0, I just used $$1/pi(0)$$
However to figure out the other question, I think I need to create state 3 as an absorption state, so I rearranged my matrix, with state 3 as the top left corner with probability 1.
then I tried to use the theory where (I-Q)inverse * S
$$
        \begin{matrix}
        P & 0 \\
        S & Q \\
                \end{matrix}
$$
then rearranged to
$$
        \begin{matrix}
        p(3,3)=1 & 0 \\
        S & Q \\
                \end{matrix}
$$
However, I realized this will only give me that, there is a 100% chance to land back at this spot if I force it to be an absorption state. (I get the column vector [1; 1; 1; 1])
If anyone can help me, I would greatly appreciate it.
The theory is mainly important, but here's the matrix itself to make things clear. I tried reading the textbook, but it is extremely unclear, and offers no more help.
$$
        \begin{matrix}
        0 & 1/2 & 1/2 & 0 & 0\\
        0 & 0 & 0& 1/5 & 4/5\\
 0 & 0 & 0& 2/5 & 3/5\\
1 & 0& 0 & 0 & 0\\
1/2 & 0 &0 & 0 & 1/2\\
                \end{matrix}
$$


text:
Q: Trying to convert text into hex by calling a function within my batch file, but the hex code never gets returned to the Main batch function @echo off

goto :main

:strg2hex
setlocal EnableDelayedExpansion

rem Store the string in chr.tmp file
set /P "=%~1" < NUL > chr.tmp

rem Create zero.tmp file with the same number of Ascii zero characters
for %%a in (chr.tmp) do fsutil file createnew zero.tmp %%~Za > NUL

rem Compare both files with FC /B and get the differences
set "hex="
for /F "skip=1 tokens=2" %%a in ('fc /B chr.tmp zero.tmp') do set "hex=!hex!%%a"

del chr.tmp zero.tmp
echo The string to hex is %hex%

set %~1=%hex%

goto :eof

:main

     echo This is the main function!

     ::This interprets "tiger" as a string.
     ::This will convert text "tiger" into hex with the above function.
     call :strg2hex tiger
     Echo this is text "tiger" converted into hex: %hex%

Pause

goto :eof

A: in place of
set %~1=%hex%

use
endlocal&set "%~1=%hex%"&SET "hex=%hex%"

Because you are executing a setlocal, when you goto :eof, the local environment containing your changes is deleted and the original, unchanged environment is restored.
This statement works because batch parses, substitutes and then executes the command, so what is actually executed is
 endlocal&set "tiger=7469676572"&SET "hex=7469676572"

so the local environment is deleted, then the values are set.

@ECHO OFF
SETLOCAL
goto :main

:strg2hex
setlocal EnableDelayedExpansion

rem Store the string in chr.tmp file
set /P "=%~1" < NUL > chr.tmp

rem Create zero.tmp file with the same number of Ascii zero characters
for %%a in (chr.tmp) do DEL zero.tmp>nul&fsutil file createnew zero.tmp %%~Za > NUL

rem Compare both files with FC /B and get the differences
set "hex="
for /F "skip=1 tokens=2" %%a in ('fc /B chr.tmp zero.tmp') do set "hex=!hex!%%a"

rem del chr.tmp zero.tmp
echo The string to hex is %hex%

endlocal&SET "hex=%hex%"

goto :eof

:main
u:
     echo This is the main function!

     ::This interprets "tiger" as a string.
     ::This will convert text "tiger" into hex with the above function.
     call :strg2hex tiger
     Echo this is text "tiger" converted into hex: %hex%

IF "%*" neq "" FOR %%z IN (%*) DO  ECHO %%z&     call :strg2hex %%z

rem response to comment

SET "strng=Lion"
CALL :strg2hex %strng%
ECHO This variable "strng" has been converted into %hex%
ECHO This variable "strng" value "%strng%" has been converted into %hex%

GOTO :EOF

Well - a couple of surprises on testing more thoroughly...
First, I use U: for testing - that's why that has appeared at the start of main.
Next, I've added a new line,
IF "%*" neq "" FOR %%z IN (%*) DO  ECHO %%z&     call :strg2hex %%z

This looks at the command-line "tail" (the data after the program name on the command line) or parameters %* and assigns each one in turn to %%z (parameters may be space-separated or comma-separated), then echoes the parameter and calls the routine. Thus if we execute
q72120539 elephant lion zebra giraffe

we get the result
elephant
The string to hex is 656C657068616E74
lion
The string to hex is 6C696F6E
zebra
The string to hex is 7A65627261
giraffe
The string to hex is 67697261666665

in addition to the tiger folderol. q72120539 is my name for this program.
I had converted the del  of the two temporary files to a remark, so the files were not deleted and I could see them...
Unfortunately, the resultant display was not what I expected.
Despite its description (or implications), fsutil file createnew does NOT create a new file if there is an existing file - it leaves it as-is. Consequently, the code did not change the file after the first name (tiger) had been processed and the file remained at 5 bytes.
I cured that by deliberately deleting the zero file before the fsutil command was executed.
So - all fixed now, but I've left the del for the temporary files "remmed-out" so that will not be deleted when the routine ends. Probably good practice to remove the rem  keyword and  turn the clean-up back on.
I've also removed the set "%~1=%hex%" because leaving it would set variables named tiger , elephant , lion , zebra , giraffe each to their hex-value strings.

Edited to include example from OP.
Result is extra
This variable "strng" has been converted into 4C696F6E
This variable "strng" value "Lion" has been converted into 4C696F6E

There is no such thing as a "function" in batch, at least, not in the sense that it is used in Pascal, for instance. The "return value" simply gets assigned to a known variable, as in this case.
It is possible to have the call return the value in a any variable by using this:
call :function fred 5 6 7

...

:function
set /a %1=%2+%3+%4
goto :eof

which would set the value of fred to 18


text:
Q: Importing multiple py files in pyspark I have the below folder structure in hdfs.
/home/myid
-main.py
-test1.py
-test2.py
In main.py I am trying to import both test1 and test2.
from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession
sc=SparkContext('local')
spark= SparkSession(sc)
from test1 import test_function
from test2 import new_function

test_function()
new_function()

All 3 files are in same folder.
Test1.py
def test_function():
    print("test1")

Test2.py
def new_function():
    print("test2")

When I try to execute main.py using
spark-submit main.py, it says cannot import new_function.
It is able to import test1.py but not test2.py
I also tried with sc.addPyFile before import. Didn't work.
Tried by giving --py-files along with spark submit and it didn't  work either.
Tried zipping both the test1 and test2 and added it along with spark context. It didn't work either.
Trying to understand why it's not working and how to resolve this.

A: Option 1
Try giving with these syntax using spark-submit, make sure you are using comma
--py-files test1.py,test2.py

Option 2:
moreover you can zip them and include like this
First put them in a directory for instance myfiles/ ( In addition make empty __init__.py file at root level in this directory like myfiles/__init__.py )
From outside this directory,make a zip of it (for example myfiles.zip)
Now include this zip with sc.addPyFilefunction
sc.addPyFile("myfiles.zip")

Considering your have __init__.py , test1.py and test2.py in myfiles.zip
You can now use them as
from myfiles.Test1 import test_function
from myfiles.Test2 import new_function


text:
Q: Webconfig transform not working when publish package due to *.SetParameters.xml How can I avoid these settings when i package my web app.
I can see following entries are added and I have no idea from where these are coming I want to stop them here.
2>Adding declared parameter 'IIS Web Application Name'.
2>Adding declared parameter 'AD_APPIDUri'.
2>Adding declared parameter 'AD_MetadataUrl'.
2>Adding declared parameter 'AD_RealmAppSetting'.
2>Adding declared parameter 'AD_AudienceUriAppSetting'.
2>Adding declared parameter 'AD_Domain'.
2>Adding declared parameter 'AD_Issuer'.

I have read docs about SetParameters.xml and parameters.xml files, there was no parameters.xml under my solution files I added an empty one myself but still I can still see the following actions. These actions are messing my project.SetParameters.xml which is leading to incorrect webconfig transforms when I publish it.
do note that transform preview is showing me what I really wanted but some publishing package turns it into a mess.
I'm using VS2015 and ASP.NET MVC 5 web project

A: When you build and package a web application, the Web Publishing Pipeline will automatically parameterize these things:

*

*The destination IIS web application path and name.

*Any connection strings in your web.config file.

*Connection strings for any databases you add to the Package/Publish SQL tab in the project property pages.

'IIS Web Application Name' is automatically add to parameters collection. For other AD parameters, please check your configuration files, have you define them in connectionStrings section? If yes, they also will be automatically added to package parameters collection. To avoid adding these parameters, you could move them to appSettings section.

I don't want it to be added automatically

To disable the automatically connection string parameters, you could use msbuild.exe to deploy your web application and add [/p:AutoParameterizationWebconfigConnectionstrings=False] parameter to msbuild command. Sample command below is for your reference.
msbuild WebApplication1.csproj /p:DeployOnBuild=true /p:PublishProfile=yourProfileName /p:AutoParameterizationWebconfigConnectionstrings=False


text:
Q: bash: ./sublime_text: No such file or directory After installing Sublime Text 3 on Ubuntu 14.04 by coping the extracted files to /opt, I tried running Sublime Text using ./sublime_text.
However it is giving an error No such file or directory when though ls tells us that it exists! What's going on?
x@x-ubuntu:/opt/sublime_text_3$ ls -l
total 11660
-rw-rw-r-- 1 x x    4696 Dec 16 22:28 changelog.txt
-rwxrwxr-x 1 x x  171056 Dec 16 22:28 crash_reporter
drwxrwxr-x 7 x x    4096 Dec 16 22:28 Icon
drwxrwxr-x 2 x x    4096 Dec 16 22:28 Packages
-rwxrwxr-x 1 x x 4172952 Dec 16 22:28 plugin_host
-rw-rw-r-- 1 x x 2582934 Dec 16 22:28 python3.3.zip
-rw-rw-r-- 1 x x   18883 Dec 16 22:28 sublime_plugin.py
-rw-rw-r-- 1 x x   30672 Dec 16 22:28 sublime.py
-rwxrwxrwx 1 x x 4932736 Dec 21 21:57 sublime_text
-rw-rw-r-- 1 x x     532 Dec 16 22:28 sublime_text.desktop

x@x-ubuntu:/opt/sublime_text_3$ ./sublime_text
bash: ./sublime_text: No such file or directory

A: You are getting this error because you are trying to run a 32-bit binary on a 64-bit system. If you download the proper package for your system, it should work. If you don't know if your computer is 32-bit or 64-bit, try running
getconf LONG_BIT

(actually this checks if you're running 32-bit or 64-bit Ubuntu, to actually check if your hardware is 32-bit or 64-bit run:
grep -o -w 'lm' /proc/cpuinfo | sort u

and if one of the flags listed is 'lm' you have a 64-bit processor.)


text:
Q: How does the area affect the integral? Let $\Omega\subset\mathbb{R}^n$ a open bounded set. For any $r>0$ consider the integral:
$$J_\Omega(r)=\int_{\Omega}\frac{|x^s|dx}{r^c+\sum_{i=1}^m|x^{p_i}|r^{d_i}},$$
where $s,p_i\in\mathbb{N}^n$ and $c,d_i\in\mathbb{N}$. (In fact, integrating other function may meet the same problem below). It's easy to show for any open bounded $\Omega$ and $\Omega'$ containing the origin, one has
$$J_\Omega(r)\asymp J_{\Omega'}(r)\asymp J_{(-1,1)^n}(r)\asymp J_{(0,1)^n}(r),$$
where $f\asymp g$ means $0<c_1f\leq g\leq c_2f$ when $r\rightarrow 0^+$.
Problem: For given open bounded set $\Omega$ such that $0\in\partial\overline{\Omega}$, does
$$J_{\Omega}(r)\asymp J_{(0,1)^n}(r)$$
hold?
Hint and Attempt: It's easy $J_\Omega(r)\leq C J_{(-1,1)^n}(r)$ but difficult in the converse. And for example:
$$J_{W}(r)=\int_{W}\frac{dxdy}{|x|+|y|+r}$$
where $W=\{(x,y)|x<y<2x,0<x<1\}$. Change the coordinate $(u,uw)=(x,y)$ one has
$$J_W(r)=\int_{(0,1)\times(1,2)}\frac{ududw}{u+wu+r}\asymp J_{(0,1)^n}(r)\asymp 1$$


text:
Q: background push notification in ionic3 I have completed an e-commerce app in ionic3. The problem is I want user to be notified when new offers or deals are added in our inventory. This should be a backend process, whether or not the app is open or close.
Note: There is no firebase involved.

A: If you want to use to get notification in same device then you can try Local notification native plugin for notification and if you want to send notification to other device then you have to use Push or FCM or Onesignal and yes this all required firebase to send push notification to generate device id/key.


text:
Q: Each GROUP BY expression must contain columns that are not outer references Have been messing with this for a while now, but can't seem to get closer to it working.
Project InvoiceNbr, InvoiceDt and TotalPrice for all invoices where the TotalPrice is greater than the average TotalPrice. Sort on InvoiceNbr descending.
This is what I have come up with:
SELECT  I.InvoiceNbr AS Invoice#,
        I.InvoiceDt AS Date,
        I.TotalPrice AS Amount
FROM INVOICE AS I
WHERE I.TotalPrice IN
    (SELECT AVG(I.TotalPrice)
    FROM INVOICE
    GROUP BY I.InvoiceDt, I.InvoiceNbr, TotalPrice
    HAVING I.TotalPrice > AVG(I.TotalPrice));
GO

Keep getting the error:

Each GROUP BY expression must contain at least one column that is not an outer reference.

A: You are off on the logic.  You want to return the average, either using a join in the from or a subquery.  You've started with the subquery, so let's go down that route:
SELECT  I.InvoiceNbr AS Invoice#,
        I.InvoiceDt AS Date,
        I.TotalPrice AS Amount
FROM INVOICE I
WHERE I.TotalPrice > (SELECT AVG(I2.TotalPrice)
                      FROM INVOICE I2
                     );


text:
Q: Using Lindeberg's Condition together with the Central Limit Theorem I have the following problem:

Problem. Let $ (X_{n})_{n \in \mathbb{N}} $ be a sequence of independent random variables such that
  $$
  \mathbf{Pr} \! \left( X_{n} = \sqrt{n} + 1 \right)
= \mathbf{Pr} \! \left( X_{n} = - \sqrt{n} - 1 \right)
= \frac{1}{2 (\sqrt{n} + 1)^{2}}
$$
  and
  $$
\mathbf{Pr} \! \left( X_{n} = 0 \right) = 1 - \frac{1}{(\sqrt{n} + 1)^{2}}.
$$
  Then prove that the random variable $ \dfrac{\sum_{i = 1}^{n} X_{i}}{\sqrt{n}} $ converges in distribution to one with a standard normal distribution.

I have to use Lindeberg's Condition together with the Central Limit Theorem in order to solve this, but I'm stuck. Any assistance would be greatly appreciated. Thanks!

A: We want to check that for a fixed positive $\varepsilon$, the convergence
$$\lim_{n\to\infty}\frac 1{s_n^2}\sum_{j=1}^n\mathbb E[X_j^2\mathbf 1\{ |X_j|\gt \varepsilon s_n \}] =0     $$
takes place, with $s_n^2=\sum_{j=1}^n \operatorname{Var}(X_j)=n$ in order to apply Lindeberg-Lévy-Feller theorem.
We thus have to prove that
$$\tag{*} \lim_{n\to\infty}\frac 1n \sum_{j=1}^n\mathbb E[X_j^2\mathbf 1\{ |X_j|\gt \varepsilon \sqrt n \}]=0.$$
If $j$ is such that $\sqrt j +1\leqslant \varepsilon\sqrt n$, then $\mathbb E[X_j^2\mathbf 1\{ |X_j|\gt \varepsilon \sqrt n \}]=0$ and if $j$ is such that $\sqrt j +1\gt \varepsilon\sqrt n$, then $\mathbb E[X_j^2\mathbf 1\{ |X_j|\gt \varepsilon \sqrt n \}]=1$, hence
$$\frac 1n \sum_{j=1}^n\mathbb E[X_j^2\mathbf 1\{ |X_j|\gt \varepsilon \sqrt n \}]=\frac 1n\sum_{j\gt(\varepsilon\sqrt n-1)^2}^n1, $$
which does not converge to $0$.
By Theorem 2.1. page 331 of the book Probability: A Graduate Course by Allan Gut, since $\max_{1\leqslant j\leqslant n}\frac{\operatorname{Var}(X_j)}{s_n^2}\to 0$, the sequence $\left(n^{-1/2}\sum_{j=1}^nX_j    \right)_{n\geqslant 1}  $ cannot converge to a standard normal distribution.


text:
Q: Redirect subdirectory to root subdirectory without changing url PHP https://example.com/app1
This is my subdirectory and it has one index.html file running on apache server.
I need to redirect all the requests to this directory like https://example.com/app1/* to https://example.com/app1 without changing the URL.
If user access to https://example.com/app1/test it should be redirected to https://example.com/app1 but URL should remain same as
https://example.com/app1/test

A: You can use this rule in your public_html/. htaccess :
RewriteEngine on

RewriteRule ^app1/((?!index\.html).+)$  /app1/ [NC,L]

A: Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]*)$ index.php [nc,qsa]
This one worked for me.
Thanks to all.


text:
Q: How can we make the searchBar remain active until user search something or press cancel button hello I have a UISearchBar on NavigationBar. If I type something in the searchBar it shows the cancel button on right and placeholder moves to the left. So at this stage If I tap somewhere else it comes back to original stage where there is no cancel button. So I want it to remain active until user types something or press cancel button. I mean it shouldn't do anything if a user taps somewhere else. I am confused what should I do. I have tried different things like below but they are not working.
func searchBarTextDidEndEditing(searchBar: UISearchBar) {
        self.searchController?.searchBar.becomeFirstResponder()
        self.searchController?.active = true
        }


text: Q: ERROR: InnoDB: Attempted to open a previously opened tablespace - how to avoid that? I had no problems before, it was all fine, even when watchdog worked and restarted the device, everything worked fine. Until after one of such reboots something happened with partitioning, fixed that with fsck. It threw a bunch of errors, but at least it booted again. After that, I had to recreate the database, it would run only in innodb_force_recovery=5. Since then, like almost every time, when watchdog reboots the device, server won't run again, and I am getting [ERROR] InnoDB: Attempted to open a previously opened tablespace ... message in error log. Then I have to run the server again with innodb_force_recovery=1 and restart it after. Every time! This is annoying! Any ideas how to fix that? Or at least run the database like with innodb_force_recovery=1 but in normal mode with write permissions?


text:
Q: how do I create vendor login page and access it through a special URL in magento I am new in magento. I wanted to add multi vendor website in magento. how can I add multiple stores in magento and where do I can create a login form for vendors
 and also how can I add a URL for vendor login..for e.g.- abc.com/vendor instead of abc.com/admin

A: You can create stores by following this link.
and for second question, you can create multiple users by going through System->Permission->Users and click on Create User. You can restrict the access to the menu for the different users through by creating different roles to them through system->Permission-> roles and all of them ca be accessed through the same link


text:
Q: Over a finite field, which square matrices produce a zero quadratic form? For which matrices $A \in (\mathbb{F}_p)^{n \times n}$ do we have
$x^T A x=0$ for all $x \in (\mathbb{F}_p)^n$?

Obviously, this is the case if $A=B-B^T$ for some $B$ (which is equivalent to saying that $A$ is anti-symmetric if $p\neq 2$). Is this if an iff?
I think for $\mathbb{R}$ instead of $\mathbb{F}_p$, this is true since matrices of the form $xx^T$ span the whole space of symmetric matrices. Does that still hold for $\mathbb{F}_p$?

A: $A$ is anti-symmetric if $A^t=-A$. However
$a_{ii}=e_i^tAe_i=0$
(Here $\{e_i\}$ is the standard basis )
Then
$$(e_i-e_j)^tA(e_i-e_j)=-e_i^tAe_j-e_j^tAe_i=-a_{ij}-a_{ji}=0$$
And so $a_{ij}=-a_{ji}$
So your statement holds for any field, except for $\mathbb{F}_2$, as you can see in the comments below.

A: Oh, I see it now; it's an iff, and the argument isn't really different for $\mathbb{R}$ or $\mathbb{F}_p$. We have
$$ (e_1+e_2) (e_1+e_2)^T-e_1e_1^T - e_2e_2^T = e_1e_2^T+e_2e_1^T$$
for any pair of basis vectors $e_1,e_2$, so vectors of the form $xx^T$ do span the space of symmetric matrices. Since
$$x^T A x = Tr(A xx^T)\;,$$
$A$ must have zero overlap with the space of symmetric matrices and thus be anti-symmetric.


text:
Q: Including interaction terms without main effects in rms::cph I need to retain an interaction term but excluding main effects in a Cox model with rms::cph.
With survival::coxph i usually do

coxph(Surv(time, death)~a:b) instead of coxph(Surv(time, death)~a*b)

but this is not working with Harrel's rms::cph.
Any suggestion?

A: rms does not support this and I would not recommend it in general.  If you need a special model fitted where you have paid enormous attention to the zero origin of each variable you can create product terms before passing to cph.