text:
Q: Intersection of Rectangles for Java (Freeze Tag) **Edited still not getting the right response **
I am not quite understanding how to figure out the intersection aspect of my project. So far I have determined the top, bottom, left and right but I am not sure where to go from there.
The main driver should call to check if my moving rectangles are     intersecting and if the rectangle is froze the moving one intersecting with it should unfreeze it and change its color. I understand how to unfreeze it and change the color but for whatever the reason it isn't returning the value as true when they are intersecting and I know this code is wrong. Any helpful tips are appreciated.
*CLASS CODE*

import edu.princeton.cs.introcs.StdDraw;
import java.util.Random;
import java.awt.Color;

public class MovingRectangle {
Random rnd = new Random();
private int xCoord;
private int yCoord;
private int width;
private int height;
private int xVelocity;
private int yVelocity;
private Color color;
private boolean frozen;
private int canvas;

public MovingRectangle(int x, int y, int w, int h, int xv, int yv, int canvasSize) {
    canvas = canvasSize;
    xCoord = x;
    yCoord = y;
    width = w;
    height = h;
    xVelocity = xv;
    yVelocity = yv;
    frozen = false;
    int c = rnd.nextInt(5);

    if (c == 0) {
        color = StdDraw.MAGENTA;
    }
    if (c == 1) {
        color = StdDraw.BLUE;
    }
    if (c == 2) {
        color = StdDraw.CYAN;
    }
    if (c == 3) {
        color = StdDraw.ORANGE;
    }
    if (c == 4) {
        color = StdDraw.GREEN;
    }

}

public void draw() {
    StdDraw.setPenColor(color);
    StdDraw.filledRectangle(xCoord, yCoord, width, height);
}

public void move() {
    if (frozen == false) {
        xCoord = xCoord + xVelocity;
        yCoord = yCoord + yVelocity;
    }
    else {
        xCoord +=0;
        yCoord +=0;
    }
    if (xCoord >= canvas || xCoord < 0) {
        xVelocity *= -1;
        this.setRandomColor();
    }

    if (yCoord >= canvas || yCoord < 0) {
        yVelocity *= -1;
        this.setRandomColor();
    }

}

public void setColor(Color c) {
    StdDraw.setPenColor(color);
}

public void setRandomColor() {
    int c = rnd.nextInt(5);

    if (c == 0) {
        color = StdDraw.MAGENTA;
    }
    if (c == 1) {
        color = StdDraw.BLUE;
    }
    if (c == 2) {
        color = StdDraw.CYAN;
    }
    if (c == 3) {
        color = StdDraw.ORANGE;
    }
    if (c == 4) {
        color = StdDraw.GREEN;
    }

}

public boolean containsPoint(double x, double y) {
    int bottom = yCoord - height / 2;
    int top = yCoord + height / 2;
    int left = xCoord - width / 2;
    int right = xCoord + width / 2;

    if (x > left && x < right && y > bottom && y < top) {
        color = StdDraw.RED;
        return true;
    } else {
        return false;
    }

}

public boolean isFrozen() {
    if (frozen) {
        return true;

    } else {
        return false;
    }

}

public void setFrozen(boolean val) {
    frozen = val;

}

public boolean isIntersecting(MovingRectangle r) {
int top = xCoord + height/2;
int bottom = xCoord - height/2;
int right = yCoord + width/2;
int left = yCoord - width/2;

int rTop = r.xCoord + r.height/2;
int rBottom = r.xCoord - r.height/2;
int rRight = r.yCoord + r.width/2;
int rLeft = r.yCoord - r.width/2;

  if(right <= rRight && right >= rLeft || bottom <= rBottom && bottom
   >= rTop){

  return true;

    } else {
        return false;
    }

    }

}

Here is my main driver as well, because I might be doing something wrong here too.
 import edu.princeton.cs.introcs.StdDraw;
 import java.util.Random;

public class FreezeTagDriver {
public static final int CANVAS_SIZE = 800;

public static void main(String[] args) {
    StdDraw.setCanvasSize(CANVAS_SIZE, CANVAS_SIZE);
    StdDraw.setXscale(0, CANVAS_SIZE);
    StdDraw.setYscale(0, CANVAS_SIZE);

    Random rnd = new Random();
    MovingRectangle[] recs;
    recs = new MovingRectangle[5];
    boolean frozen = false;

    for (int i = 0; i < recs.length; i++) {
        int xv = rnd.nextInt(4);
        int yv = rnd.nextInt(4);
        int x = rnd.nextInt(400);
        int y = rnd.nextInt(400);
        int h = rnd.nextInt(100) + 10;
        int w = rnd.nextInt(100) + 10;

        recs[i] = new MovingRectangle(x, y, w, h, xv, yv, CANVAS_SIZE);
    }
    while (true) {
        StdDraw.clear();

        for (int i = 0; i < recs.length; i++) {

            recs[i].draw();
            recs[i].move();

        }

        if (StdDraw.mousePressed()) {

            for (int i = 0; i < recs.length; i++) {
                double x = StdDraw.mouseX();
                double y = StdDraw.mouseY();

                if (recs[i].containsPoint(x, y)) {
                    recs[i].setFrozen(true);
                }
            }
        }

        for (int i = 0; i < recs.length; i++) {
//for 0
        if(recs[0].isFrozen() && recs[0].isIntersecting(recs[1])){
            recs[0].setFrozen(false);
                }

        if(recs[0].isFrozen() && recs[0].isIntersecting(recs[2])){
            recs[0].setFrozen(false);
                }

        if(recs[0].isFrozen() && recs[0].isIntersecting(recs[3])){
            recs[0].setFrozen(false);

                }

 //for 1
        if(recs[1].isFrozen() && recs[1].isIntersecting(recs[2])){
            recs[1].setFrozen(false);

                }
        if(recs[1].isFrozen() && recs[1].isIntersecting(recs[3])){
            recs[1].setFrozen(false);
                }

        if(recs[1].isFrozen() && recs[1].isIntersecting(recs[4])){
            recs[1].setFrozen(false);
                }

//for 2
        if(recs[2].isFrozen() && recs[2].isIntersecting(recs[0])){
            recs[2].setFrozen(false);

                }
        if(recs[2].isFrozen() && recs[2].isIntersecting(recs[1])){
            recs[2].setFrozen(false);
                }

        if(recs[2].isFrozen() && recs[2].isIntersecting(recs[3])){
            recs[2].setFrozen(false);

                }
        if(recs[2].isFrozen() && recs[2].isIntersecting(recs[4])){
            recs[2].setFrozen(false);

                }
//for 3
        if(recs[3].isFrozen() && recs[3].isIntersecting(recs[0])){
            recs[3].setFrozen(false);

                }

        if(recs[3].isFrozen() && recs[3].isIntersecting(recs[1])){
            recs[3].setFrozen(false);
                }

        if(recs[3].isFrozen() && recs[3].isIntersecting(recs[2])){
            recs[3].setFrozen(false);
                }

        if(recs[3].isFrozen() && recs[3].isIntersecting(recs[4])){
            recs[3].setFrozen(false);
                }
//for 4
        if(recs[4].isFrozen() && recs[4].isIntersecting(recs[0])){
            recs[4].setFrozen(false);
                }

        if(recs[4].isFrozen() && recs[4].isIntersecting(recs[1])){
            recs[4].setFrozen(false);
                }

        if(recs[4].isFrozen() && recs[4].isIntersecting(recs[3])){
                recs[4].setFrozen(false);
                }

        if(recs[4].isFrozen() && recs[4].isIntersecting(recs[2]))
                recs[4].setFrozen(false);
                }

        if (recs[0].isFrozen() && recs[1].isFrozen() &&
   recs[2].isFrozen() && recs[3].isFrozen()
                && recs[4].isFrozen()) {
            StdDraw.text(400, 400, "YOU WIN");

        }
        StdDraw.show(20);

    }

}

}

A: Keep in mind you're using the OR operator here. So if right is less than rLeft, your intersector will return true. This isn't how it should work.
You need to check if right is INSIDE the rectangles bounds so to speak.
if(right <= rRight && right >= rLeft || the other checks here)

The above code checks if right is less than the rectangle's right, but also that the right is bigger than rectangle's left, which means it's somewhere in middle of the rectangle's left and right.
If this becomes too complicated you can simply use java's rectangle class, as it has the methods contains and intersects


text:
Q: Lua - XML Parsing with LuaXML I am trying to parse the XML file with LuaXML
function customURLtoSteam64(web, sid)
local xml = require("luaXml")
local xfile = xml.load("http://steamcommunity.com/id/GreenMarineValve?xml=1") --line189
local xscene = xfile:find("steamID64[1]")
return render_front(web, xscene)
end

But I get this error:
.\index.lua:189: attempt to index local 'xml' (a boolean value)
stack traceback:
.\index.lua:189: in function <.\index.lua:186>
(tail call): ?
(tail call): ?.\index.lua:189: attempt to index local 'xml' (a boolean value)
stack traceback:
c:\Lua\LuaRocks/share/lua/5.1/coxpcall.lua:24: in function
(tail call): ?
(tail call): ?
c:\Lua\LuaRocks/share/lua/5.1/orbit.lua:540: in function
(tail call): ?
(tail call): ?

I did not understand what is wrong, how can I correctly do that?

A: The require idiom you have used is the one recommended for Lua 5.2. Although the idiom also works for Lua 5.1, most (but not all) libraries for Lua 5.1 usually defined globals and did not return the value they define via require. In the absence of a return value from a luaopen_xxx function, require returns true, hence the error message you've seen.
So, just use simply require("luaXml"), don't assign it to a local.

redpajama_set_name: RedPajamaStackExchange


text:
Q: pandas: How to applymap in a for loop I have a python script that reads raw data from Provsvar-fixed.xlsx

and pick up columns and save to Provsvar-summary.xlsx.
These concerned columns are defined in config.xlsx something like this:

When writing to Provsvar-summary.xlsx, the cell will be highlighted if a cell value in Provsvar-fixed.xlsx not in the range (LabReference.min, LabReference.Max) (defined in config.xlsx)
The script below works well, but it is ugly, because there are so many boilerplate code .applymap(lambda x: get_style(x, lab_references[1]), subset=[lab_references[1].name]).
If want to add a new line to config.xlsx, I have to add a new line script code .applymap(lambda x: get_style(x, lab_references[23]), subset=[lab_references[23].name]), which is annoying.
import pandas as pd

origin_provsvar = 'Provsvar-fixed.xlsx'
output_file = 'provsvar-summary.xlsx'
config = pd.read_excel("config.xlsx")

class LabReference:
    def __init__(self, name, min, max):
        self.name = name
        self.min = min
        self.max = max

# Provsvar-fixed
provsvar = pd.read_excel(origin_provsvar, sheet_name='Sheet1')

bad_style_low = 'background-color: #FFFB00'
bad_style_high = 'background-color: #FFC7CE'

def get_style(val, lab_reference):
    if not isinstance(val, int) and not isinstance(val, float):
        return ''
    if val < lab_reference.min:
        return bad_style_low
    elif val > lab_reference.max:
        return bad_style_high
    else:
        return ''

lab_references = []
for i, row in config.iterrows():
    '''
    Name                                Min Max
    Datum
    S-ACE (E/L)                         0   70
    P--25-OH Vitamin D2+D3 (nmol/L)     50  250
    S-1,25-OH-Vitamin D (pmol/L)        48  190
    ......

    '''
    lab_item = LabReference(row['Name'], row['Min'], row['Max'])
    lab_references.append(lab_item)

for row in provsvar.index:
    for lab_item in lab_references:
        value = provsvar[lab_item.name].at[row]
        if isinstance(value, str):
            # Fix abnormal cell: "0,33, 0,33", convert "," to "."
            provsvar[lab_item.name].at[row] = float(value.split(", ")[0].replace(",", "."))

headers = list(map(lambda x: x.name, lab_references))

provsvar_new = pd.DataFrame(provsvar, columns=headers)

# ugly code
provsvar_new.style.set_properties(**{'background-color': 'white',
                                     'color': 'black',
                                     'border-color': 'black',
                                     'border-width': '1px',
                                     'border-style': 'solid'}) \
    .applymap(lambda x: get_style(x, lab_references[1]), subset=[lab_references[1].name]) \
    .applymap(lambda x: get_style(x, lab_references[1]), subset=[lab_references[1].name]) \
    .applymap(lambda x: get_style(x, lab_references[2]), subset=[lab_references[2].name]) \
    .applymap(lambda x: get_style(x, lab_references[3]), subset=[lab_references[3].name]) \
    .applymap(lambda x: get_style(x, lab_references[4]), subset=[lab_references[4].name]) \
    .applymap(lambda x: get_style(x, lab_references[5]), subset=[lab_references[5].name]) \
    .applymap(lambda x: get_style(x, lab_references[6]), subset=[lab_references[6].name]) \
    .applymap(lambda x: get_style(x, lab_references[7]), subset=[lab_references[7].name]) \
    .applymap(lambda x: get_style(x, lab_references[8]), subset=[lab_references[8].name]) \
    .applymap(lambda x: get_style(x, lab_references[9]), subset=[lab_references[9].name]) \
    .applymap(lambda x: get_style(x, lab_references[10]), subset=[lab_references[10].name]) \
    .applymap(lambda x: get_style(x, lab_references[11]), subset=[lab_references[11].name]) \
    .applymap(lambda x: get_style(x, lab_references[12]), subset=[lab_references[12].name]) \
    .applymap(lambda x: get_style(x, lab_references[13]), subset=[lab_references[13].name]) \
    .applymap(lambda x: get_style(x, lab_references[14]), subset=[lab_references[14].name]) \
    .applymap(lambda x: get_style(x, lab_references[15]), subset=[lab_references[15].name]) \
    .applymap(lambda x: get_style(x, lab_references[16]), subset=[lab_references[16].name]) \
    .applymap(lambda x: get_style(x, lab_references[17]), subset=[lab_references[17].name]) \
    .applymap(lambda x: get_style(x, lab_references[18]), subset=[lab_references[18].name]) \
    .applymap(lambda x: get_style(x, lab_references[19]), subset=[lab_references[19].name]) \
    .applymap(lambda x: get_style(x, lab_references[20]), subset=[lab_references[20].name]) \
    .applymap(lambda x: get_style(x, lab_references[21]), subset=[lab_references[21].name]) \
    .applymap(lambda x: get_style(x, lab_references[22]), subset=[lab_references[22].name]) \
    .to_excel(output_file, engine='openpyxl', sheet_name='summary', index=False)

# ugly code
print("complete")

I tried to replace the # ugly code by putting the applymap in a for loop like below, but it didn't work at all.

for lab_reference in lab_references:
    print(lab_reference.name, lab_reference.max)
    provsvar_new.style.set_properties(**{'background-color': 'white',
                                         'color': 'black',
                                         'border-color': 'black',
                                         'border-width': '1px',
                                         'border-style': 'solid'}) \
        .applymap(lambda x: get_style(x, lab_reference), subset=[lab_reference.name])

provsvar_new.to_excel(output_file, engine='openpyxl', sheet_name='summary', index=False)

I am new to pandas, hope someone can help me figure out how to simplify the code.

A: You can use Range for your loop like so:
for i in range(0,23):

    provsvar_new.style.set_properties(**{'background-color': 'white',
                                 'color': 'black',
                                 'border-color': 'black',
                                 'border-width': '1px',
                                 'border-style': 'solid'}) \
    .applymap(lambda x: get_style(x, lab_references[i]), subset=[lab_references[i].name])

provsvar_new.to_excel(output_file, engine='openpyxl', sheet_name='summary', index=False)

A:         provsvar_new.style.set_properties(**{'background-color': 'white',
                                         'color': 'black',
                                         'border-color': 'black',
                                         'border-width': '1px',
                                         'border-style': 'solid'}) \
.apply(lambda x: x.map(lambda y: get_style(y, config[config.name == x.name])))

Hope this works. This is shorter and dynamic but, still ugly, i guess.
to improve, you could have the get_style func accept col as arg and iterate over the values.


text:
Q: permission issue in nfs (ubuntu server) on windows 7 I've created nfs-server in ubuntu 14.4 and create share on nfs as below :
$ /etc/exports
/myshare        *(rw,fsid=0,insecure,anonuid=1000,anongid=1000,sync,no_subtree_check,all_squash)

On ubuntu, 1000 id is for admin user and group.
Now Issue is that, If I create file on ubuntu server and open which on windows 7 then it's open as readonly !!
But If I create file from windows 7 then able to change it on ubuntu because in server I've set a  anonuid & anongid, After it's file open as readonly on windows 7 .
In short, How can create public share which can access windows to ubuntu and visevarsa.

A: I made update in windows 7, by regedit:
 I put, AnonymousGid=1000 and AnonymousUid=1000 in register:
computer->HKEY_LOCAL_MACHINE->SOFTWARE->MICROSOFT->ClientNFS->CurrentVersion-Default
After that i include NFS client by
Turn Windows features on or off and selected:
Service NFS
 - Administrative Tools
 - Client for NFS
Good lock


text:
Q: Adding TwinPrime to my HttpURLConnection TwinPrime is an SDK that supposedly enhances your app's internet connectivity by 100% with a few lines of code (www.twinprime.com).
Apparently all I need to do is place the following code in my MainActivity:
new TwinPrimeSDK(getApplicationContext(), "API_KEY");
try {
    URLConnection httpConn = TPURLConnection.openConnection("your-URL");
} catch (IOException e) {
    e.printStackTrace();
}

Then attach the following wherever there is an HttpConnection:
URLConnection httpConn = TPURLConnection.openConnection("your-URL");

My problem is I have no idea where to attach it. I've contacted their customer support but maybe somebody on SO has had experience with them?
private Bitmap getBitmap(String url) {
        File f = fileCache.getFile(url);

        Bitmap b = decodeFile(f);
        if (b != null) {
            return b;
        }

        // Download Images from the Internet
        try {
            Bitmap bitmap = null;
            URL imageUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
            conn.setConnectTimeout(30000);
            conn.setReadTimeout(30000);
            conn.setInstanceFollowRedirects(true);
            InputStream is = conn.getInputStream();
            OutputStream os = new FileOutputStream(f);
            FeedUtils.CopyStream(is, os);
            os.close();
            conn.disconnect();
            bitmap = decodeFile(f);
            return bitmap;
        } catch (Throwable ex) {
            ex.printStackTrace();
            if (ex instanceof OutOfMemoryError)
                memoryCache.clear();
            return null;
        }
    }

A: This is how I accomplished it.
private Bitmap getBitmap(String url) {
        File f = fileCache.getFile(url);

        Bitmap b = decodeFile(f);
        if (b != null) {
            return b;
        }

        // Download Images from the Internet
        try {
            Bitmap bitmap = null;
            URL imageUrl = new URL(url);
            HttpURLConnection httpConn = (HttpURLConnection) TPURLConnection.openConnection(url);
//            HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
            httpConn.setConnectTimeout(30000);
            httpConn.setReadTimeout(30000);
            httpConn.setInstanceFollowRedirects(true);
            InputStream is = httpConn.getInputStream();
            OutputStream os = new FileOutputStream(f);
            FeedUtils.CopyStream(is, os);
            os.close();
            httpConn.disconnect();
            bitmap = decodeFile(f);
            return bitmap;
        } catch (Throwable ex) {
            ex.printStackTrace();
            if (ex instanceof OutOfMemoryError)
                memoryCache.clear();
            return null;
        }
    }


text:
Q: ¿ cómo corresponder el color de cada categoría consu label en un gráfico de dispersión? Estoy realizando un scatter plot donde relaciono las valoraciones de  libros con su precio, en función del tipo. El tipo, como es una variable categórica, he utilizado LabelEncoder() para asignarle un valor a cada categoría. Luego, al representar el gráfico se ejecuta correctamente, pero el problema viene a la hora de poner la leyenda, pues al ponerla no se asocia cada color del gráfico con el tipo de libro.
Código utilizado:
for y, c in zip(data['Type'].unique(), book_type):
    plt.scatter(data["Rating"], data['Price'], c=book_type, label=y)

plt.xlabel('Valoraciones')
plt.ylabel('Precio')
plt.legend(loc=0)

Adjunto imagen para que se vea el gráfico:

Véase como la variable book_type contiene los valores de cada tipo de libro, data['Rating'] son las valoraciones de los libros y data['Price'] es el precio.
Como ven, hay varios comentarios en el código porque he estado probando varias formas de hacerlo sin éxito. No consigo que la leyenda tenga los colores del gráfico.
Adjunto un print sobre los datos y un print sobre la variable 'book_type':
data

book_type:

Se puede ver que book_type tiene valores, los cuales pertenecen cada uno a cada una de las categorías de data['Type'].
Si alguien me pudiera ayudar lo agradecería mucho.
Un saludo.

A: Te recomiendo usar .plot() propio de Pandas:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
np.random.seed(1970)

num = 20
x, y = np.random.random((2, num))
labels = np.random.choice(['a', 'b', 'c'], num)
df = pd.DataFrame(dict(x=x, y=y, label=labels))

groups = df.groupby('label')

fig, ax = plt.subplots()
ax.margins(0.05)
for name, group in groups:
    ax.plot(group.x, group.y, marker='o', linestyle='', ms=12, label=name)
ax.legend()
plt.show()


text:
Q: Is it possible to show markers from MySQL database with Javascript? I'm interested if it's possible to show markers (latit, longit) from MySQL database with Javascript libraries like Leaflet?

A: yes, it's possible. As long you have the coordinate, then you can display either using OpenLayers or GMap.


text:
Q: Amazon S3 Query String Authentication Invalid Date I found this script for creating links to Amazon S3 resources using the Query String Authentication: https://gist.github.com/1032395
Since I'm not using rails I included the libraries manually.
Everytime I try opening a resource using an URL generated by this script I get an "access denied"-error because of a "Invalid date (should be seconds since epoch): 1349364847"
Any ideas where this could come from?
require 'cgi'
require 'base64'
require 'openssl'

def generate_secure_s3_url(s3_key)
    #
    # s3_key would be a path (including filename) to the file like:  "folder/subfolder/filename.jpg"
    # but it should NOT contain the bucket name or a leading forward-slash
    #
    # this was built using these instructions:
    # http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?S3_QSAuth.html
    # http://aws.amazon.com/code/199?_encoding=UTF8&jiveRedirect=1

    s3_base_url       = '' # i.e. https://mybucket.s3.amazonaws.com
    bucket            = '' # i.e. mybucket
    access_key_id     = '' # your Amazon S3 access key ID
    secret_access_key = '' # your Amazon S3 secret access key
    expiration_date   = Time.now.utc.to_i + (2*24*60*60) # 2 days from now in UTC epoch time (i.e. 1308172844)

    # this needs to be formatted exactly as shown below and UTF-8 encoded
    string_to_sign = "GET\n\n\n#{expiration_date}\n/#{bucket}/#{s3_key}".encode("UTF-8")

    # we have to CGI/URL escape the signature since it would fail if it included / or + characters
    signature = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_access_key, string_to_sign)).gsub("\n",""))

    return "#{s3_base_url}/#{s3_key}?AWSAccessKeyId=#{access_key_id}
                                    &Expires=#{expiration_date}
                                    &Signature=#{signature}"
end

A: I think if you require 'active_support/core_ext' you can use 2.days.from_now.utc.to_i
I wrestled with this for a bit and eventually settled on aws-sdk:
http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/S3Object.html#url_for-instance_method
require 'aws-sdk'

bucket = "bucketname"
resource = "myfile.jpg"
access_key_id = "12345"
secret_access_key = "abcdef"

s3 = AWS::S3.new(:access_key_id => access_key_id, :secret_access_key = secret_access_key)
signed_url = s3.buckets[bucket].objects[resource].url_for(:read).to_s

Note: url_for also takes an :expires option, the default being one hour.


text:
Q: Is registering services/components on Castle Windsor thread-safe? Is registering components on castle windsor thread-safe?
I.e., can multiple threads simultaneously register components on the same container instance?
(For the record, yes I am aware that doing so is probably insane.)

A: It's quite hard to tell whether a complex piece of software like Windsor is thread-safe or not. Windsor has several subsystems and internal services. And each component registration can do lots of stuff (setting up proxies, different lifestyles, custom dependencies...). AFAIK there are no thread-safety specific tests.
However, assuming you're using the default subsystems and your threads don't add custom contributors, subresolvers, etc (i.e. just plain component registration) it should be thread-safe, since the classes involved in component registration look like they're either stateless or properly locked. The DefaultKernel mostly delegates operations to the various subsystems/internal services, and in particular the DefaultNamingSubSystem (the services maps storage subsystem) is properly locked.
I recommend that you ask on the castle-users or castle-dev google groups, that's where the real Castle gurus are.


text:
Q: Problem with content unpublish in Tridion 2013 SP1 HR1 We are having problems with unpublishing the content of any Tridion publication. When we try to unpublish any content, these unpublished elements do not disappear from the application of the front and remain in the file system. After unpublishing the content, we have verified the following actions:

*

*In the Tridion publishing queue, the content has been successfully unpublished, giving Success in the queue.

*It is verified that the icon next to the element that indicates if an element is published, also disappears.

*In the "Where used" tab, it does not appear that the item is published in any target.

*Finally, check that in the Broker the unpublished content has also disappeared.

As we have commented previously, the problem of unpublication occurs with any publication of Tridion, therefore, we discard the problem of advertising or the application in particular. The permissions have also been revised in the front applications are correct.
On the other hand, when we publish any content, it works correctly, updating this published element with the content and the correct date of the publication in the front of the application.
Thanks a lot for you help!!
Andres.


text:
Q: Handle Push Notification Navigation with Activity and Fragment I develop one application with Firebase Push Notification feature.
I created one MainActivity and five fragment A, B, C, D, E.
I want to show Fragment C, when i clicked on Push Notification message, Its works fine when my application is open on screen.
But when I kill app and then push notification comes, I clicked on Push Notification, MainActivity load Fragment A which my initial Fragment with MainActivity.
My App Flow:
Splash Screen -> Login Screen (Silent Login) -> Main Activity -> Load a Specific Fragment

My code:
private void sendNotification(String title, String messageBody, int senderId) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.putExtra(ARG_NOTIFICATION_FOR, ConstantValues.NOTIFICATION_FOR_CHAT_SCREEN);
        intent.putExtra(ARG_SENDER_ID, senderId);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0 /* Request code */, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(title)
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

For MainActivity as below:
if(getIntent() != null)
{
  if (getIntent().hasExtra(ARG_NOTIFICATION_FOR))
  {
    //Load Fragment C
  }
}

When i clicked on Push Notification icon, App opens from Splash Screen with Silent Login -> Main Activity -> Load Fragment A
Main Activity not have hasExtra(ARG_NOTIFICATION_FOR)

A: Your pending intent for push notification needs to send a parameter to activity to determine application is opened from icon or notification.
 Intent notificationIntent = new Intent(getApplicationContext(), YourActivity.class);
    notificationIntent.putExtra("FromNotification", true);//or fragment Id
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingNotificationIntent = PendingIntent.getActivity(getApplicationContext(),notificationIndex,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.setLatestEventInfo(getApplicationContext(), notificationTitle, notificationMessage, pendingNotificationIntent);

You should create your custom notification for this purpose. Checkout this link https://developer.android.com/training/notify-user/build-notification.html

Also inside the onCreate method you should receive data from notification.
protected void onCreate(Bundle bundle){
       super.onCreate(bundle);
       //bla bla bla
       boolean fromNotification = getIntent().getBooleanExtra("FromNotification",false);
       if(fromNotification){
            //open fragment c
       }else{
            //open fragment a
       }
}

A: Add a data json to payload of your notification. Inside the data , you can pass additional information.
This information can be retrieved using getIntent().getExtras() inside the activity that launches. Following this, you can decide which fragment to display according to the information contained in the notification.
An example of a payload with data is as follows :-
payload = {
  notification: {
    title: `You have a new like on your post!`,
    click_action : 'HANDLE_NOTIFICATION'

  },
  data : {
        liker_uid : xyz,
        post_id : postId,
    }}


text:
Q: FileUploader in asp.net MVC2 i am using fileuploader, i got its code from
http://www.codeproject.com/KB/aspnet/Implementing_HTTP_File_Up.aspx
and its working fine with small size files but its showing me bellow text when i try to upload a large file. my file size can be of 8-10 mb.:
The connection was reset
The connection to the server was reset while the page was loading.
    *   The site could be temporarily unavailable or too busy. Try again in a few
          moments.
    *   If you are unable to load any pages, check your computer's network
          connection.
    *   If your computer or network is protected by a firewall or proxy, make sure
          that Firefox is permitted to access the Web.

please tell me what should i do.

A: You could try increasing the maximum request length in web.config:
<configuration>
  <system.web>
    <!-- The value is in KB -->
    <httpRuntime maxRequestLength="4096" />
  </system.web>
</configuration>

A: Alongside the answer Darin Dimitrov has given, you might also have to change the setting in iis for your web-application.  If you are using Sharepoint, you need to configure it also in SCA.


text:
Q: objective c: passing a char argument to function crashes the app I wrote a singleton called SomeValues where I initialize a foo NSMutableArray. I then tried to write a function SetBFSV to set the values of this array from different control views.
@interface SomeValues : NSObject {
NSMutableArray *foo;}
+ (SomeValues *) sharedInstance;

@implementation

...

- (void) SetBFSV:(char)lbl ToVal:(long)BFSvl{
NSNumber *ValueBFSvl = [NSNumber numberWithLong:BFSvl];
NSString *Strlbl = [[NSString alloc] stringWithFormat:@"%s",lbl];
[foo setValue:ValueBFSvl forKey:Strlbl];
}

I know that setValue requires a NS object for both the value and the key, but I cannot declare my function as
(void) SetBFSV:(NSString)lbl ToVal:(NSNumber)BFSvl

because it doesn't compile with the error: "Can not use an object as parameter to a method".
In one ControlView I wrote then this piece of code:
SomeValues *myBFSV = [SomeValues sharedInstance];
const unsigned char *Bar = (unsigned char *)[@"Label1" UTF8String];
NSLog(@"The string %s", Bar);
[myBFSV SetBFSV:Bar ToVal:2.5];

When compiling I get a warning on the last line:
warning: passing argument 1 of 'SetBFSV:ToVal:' makes integer from pointer without a cast
Which integer? I'm getting stupid looking around for it. When running I get the print out from the NSLog, but right afterwards the program obviously crashes with this error:
'NSInvalidArgumentException', reason: '-[NSPlaceholderString stringWithFormat:]: unrecognized selector sent to instance 0x4e03280'
Clearly I'm passing something wrong to stringWithFormat but I cannot understand what.
Thanks for any help. Have a nice day!
/luca

A: Possible problems with your code (unless you have typos in it):

*

*- (void) SetBFSV:(char)lbl ToVal:(long)BFSvl function expects char as its 1st parameter but you pass it a char* - your 1st warning probably comes from here

*stringWithFormat is a class method so your code should look either:
NSString *Strlbl = [[NSString alloc] initWithFormat:@"%s",lbl];
[foo setValue:ValueBFSvl forKey:Strlbl]

or
NSString *Strlbl = [NSString stringWithFormat:@"%s",lbl];
[foo setValue:ValueBFSvl forKey:Strlbl]

since you try to use -stringWithFormat instead of +stringWithFormat you get a crash

*If you pass char to a function then correct format specifier for it will be %c, not %s

*You probably must release your Strlbl variable if you create it with alloc/init otherwise it will leak (but you must not release it if you use +stringWithFormat:)

A: For one, you can't use an object as a paramter:
(void) SetBFSV:(NSString)lbl ToVal:(NSNumber)BFSvl

You need to pass them as pointers, using the asterisk.
(void) SetBFSV:(NSString*)lbl ToVal:(NSNumber*)BFSvl

Furthermore, if you need to pass them as (char) and (long) your bit of code:
SomeValues *myBFSV = [SomeValues sharedInstance];
const unsigned char *Bar = (unsigned char *)[@"Label1" UTF8String];
NSLog(@"The string %s", Bar);
[myBFSV SetBFSV:Bar ToVal:2.5];  // in either case, this is a long.  why are you passing a double here?

Passes *Bar as a pointer.  You should really read up on the pointers and objects.  IF you need to pass them in as (const char*) and (long) do it like this:
- (void) SetBFSV:(const char*)lbl ToVal:(long)BFSvl{
NSNumber *ValueBFSvl = [NSNumber numberWithLong:BFSvl];
NSString *Strlbl = [NSString stringWithUTF8String: lbl]; // your old code had a memory leak here.  you need to either create an autorelease object, or release it after adding to `foo`
[foo setValue:ValueBFSvl forKey:Strlbl];
}

My Recommendation is to do the following:
- (void) SetBFSV:(NSString*)key ToVal:(long)val{
    NSNumber *value = [NSNumber numberWithLong:val];
    [foo setValue:value forKey:key];
}

And call it like the following (from your example):
SomeValues *myBFSV = [SomeValues sharedInstance];
NSString *Bar = [NSString stringWithString:@"Label1"];// this may not be necessary...
NSLog(@"The string %@", Bar);
[myBFSV SetBFSV:Bar ToVal:25]; // don't pass a decimal for a (long)


text:
Q: Change the default installation folder programmatically for setup In a standard Setup project for a WinForms app I would like to programmatically change the default installation folder (i.e. do this when the installation happens).
Is there a way to do this? I thought using a custom Installer class might hep me with this but it seems by the time it gets to any custom actions in that class, the install folder has already been selected.

A: I had the same problem. Here Is my solution.
I created an additional project, which called Win msi intaller, and add the TARGETDIR property's value as an argument.
    static void Main()
    {
            Process setupProcess = new Process();
            string msiFilePath = @"c:\path to msi package";
            string targetDir = @"target dir path";
            setupProcess.StartInfo.FileName = @"msiexec.exe /i " + msiFilePath + " TARGETDIR=\"" + targetDir + "\"";
            setupProcess.StartInfo.UseShellExecute = false;
            setupProcess.Start();
   }

Then you should run this program to install your msi package.


text:
Q: Failed to render a widget I am new to hybris e-commerce software and trying to learn with the help of wiki documents provided with it. My boss gave a task to add a custom made widget by my colleague to the backoffice. That widget works fine for older version (6.0), however it doesn't work on newer version(6.4) and most specific, the backoffice failed to render that widget.
Failed to render widget [id='importexportbackoffice-perspective',
definitionId='com.****.widgets.importexportbackofficewidget',
message='null']

Also in the command prompt it throws a NullPointerException at WidgetControllers.initSettings. Probably I am not adding the .zul file in the correct configuration xml. I re-write it, but it is still the same mistake. Also deleted that .zul file to see if there is any change or new exception, but it is still the same old NullPointerException. I am really desperate !
Here is the stack trace:
ERROR [hybrisHTTP13] [WidgetControllers] unable to load widget settings
java.lang.NullPointerException: null
        at com.hybris.cockpitng.util.WidgetControllers.initSettings(WidgetControllers.java:163) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.util.DefaultWidgetController.doBeforeComposeChildren(DefaultWidgetController.java:89) [cockpitframework-6.4.0.0-RC14.jar:?]
        at org.zkoss.zk.ui.impl.UiEngineImpl.doBeforeComposeChildren(UiEngineImpl.java:997) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:937) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:940) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.createComponents(UiEngineImpl.java:1150) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.AbstractExecution.createComponents0(AbstractExecution.java:346) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:307) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.Executions.createComponents(Executions.java:176) [zk-8.0.4.2.jar:3.6.4]
        at com.hybris.cockpitng.engine.impl.DefaultCockpitWidgetEngine.createComponents(DefaultCockpitWidgetEngine.java:473) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.AdminmodeWidgetEngine.createComponents(AdminmodeWidgetEngine.java:207) [cockpitadmin-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.DefaultCockpitWidgetEngine.createWidgetView(DefaultCockpitWidgetEngine.java:212) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.AdminmodeWidgetEngine.createWidgetView(AdminmodeWidgetEngine.java:106) [cockpitadmin-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.components.Widgetslot.updateView(Widgetslot.java:83) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.components.Widgetslot.afterCompose(Widgetslot.java:75) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.AbstractChildrenContainerRenderer.newWidgetslotsAfterCompose(AbstractChildrenContainerRenderer.java:102) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.TabContainerRenderer.render(TabContainerRenderer.java:157) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.DefaultCockpitWidgetEngine.createWidgetView(DefaultCockpitWidgetEngine.java:1502) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.AdminmodeWidgetEngine.createWidgetView(AdminmodeWidgetEngine.java:1121) [cockpitadmin-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.DefaultCockpitWidgetEngine.createWidgetView(DefaultCockpitWidgetEngine.java:1464) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.components.Widgetchildren.updateChildren(Widgetchildren.java:65) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.components.Widgetchildren.afterCompose(Widgetchildren.java:53) [cockpitframework-6.4.0.0-RC14.jar:?]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:946) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:940) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.createComponents(UiEngineImpl.java:1150) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.AbstractExecution.createComponents0(AbstractExecution.java:346) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:307) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.Executions.createComponents(Executions.java:176) [zk-8.0.4.2.jar:3.6.4]
        at com.hybris.cockpitng.engine.impl.DefaultCockpitWidgetEngine.createComponents(DefaultCockpitWidgetEngine.java:473) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.AdminmodeWidgetEngine.createComponents(AdminmodeWidgetEngine.java:207) [cockpitadmin-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.DefaultCockpitWidgetEngine.createWidgetView(DefaultCockpitWidgetEngine.java:212) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.AdminmodeWidgetEngine.createWidgetView(AdminmodeWidgetEngine.java:106) [cockpitadmin-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.components.Widgetslot.updateView(Widgetslot.java:83) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.components.Widgetslot.afterCompose(Widgetslot.java:75) [cockpitframework-6.4.0.0-RC14.jar:?]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:946) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:940) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:940) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.createComponents(UiEngineImpl.java:1150) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.AbstractExecution.createComponents0(AbstractExecution.java:346) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:307) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.Executions.createComponents(Executions.java:176) [zk-8.0.4.2.jar:3.6.4]
        at com.hybris.cockpitng.engine.impl.DefaultCockpitWidgetEngine.createComponents(DefaultCockpitWidgetEngine.java:473) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.AdminmodeWidgetEngine.createComponents(AdminmodeWidgetEngine.java:207) [cockpitadmin-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.DefaultCockpitWidgetEngine.createWidgetView(DefaultCockpitWidgetEngine.java:212) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.engine.impl.AdminmodeWidgetEngine.createWidgetView(AdminmodeWidgetEngine.java:106) [cockpitadmin-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.components.Widgetslot.updateView(Widgetslot.java:83) [cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.components.Widgetslot.afterCompose(Widgetslot.java:75) [cockpitframework-6.4.0.0-RC14.jar:?]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:946) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:940) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:842) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:797) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:461) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:369) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:211) [zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:137) [zk-8.0.4.2.jar:3.6.4]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) [servlet-api.jar:?]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) [servlet-api.jar:?]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) [catalina.jar:7.0.75]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat7-websocket.jar:7.0.75]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.75]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:158) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:158) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:157) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) [spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.75]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.75]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]
        at de.hybris.platform.servicelayer.web.WebAppMediaFilter.doFilter(WebAppMediaFilter.java:140) [coreserver.jar:?]
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.75]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:301) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$StatisticsGatewayFilter.doFilter(AbstractPlatformFilterChain.java:390) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.WebAppMediaFilter.doFilter(WebAppMediaFilter.java:140) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at com.hybris.cockpitng.modules.spring.filter.ExternalModuleContextClassLoaderFilter.doFilter(ExternalModuleContextClassLoaderFilter.java:44) [cockpit-module-aggregator-6.4.0.0-RC14.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.DynamicCatalogVersionActivationFilter.doFilter(DynamicCatalogVersionActivationFilter.java:90) [classes/:?]
        at de.hybris.platform.servicelayer.web.DynamicCatalogVersionActivationFilter$$FastClassBySpringCGLIB$$2d468805.invoke(<generated>) [classes/:?]
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) [spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) [spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) [spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) [spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) [spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at de.hybris.platform.servicelayer.web.DynamicCatalogVersionActivationFilter$$EnhancerBySpringCGLIB$$71b36f4c.doFilter(<generated>) [classes/:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.DataSourceSwitchingFilter.doFilter(DataSourceSwitchingFilter.java:70) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.SessionFilter.doFilter(SessionFilter.java:99) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.RedirectWhenSystemIsNotInitializedFilter.doFilter(RedirectWhenSystemIsNotInitializedFilter.java:101) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.TenantActivationFilter.doFilter(TenantActivationFilter.java:88) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.Log4JFilter.doFilter(Log4JFilter.java:44) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:271) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain.processStandardFilterChain(AbstractPlatformFilterChain.java:201) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain.doFilterInternal(AbstractPlatformFilterChain.java:179) [coreserver.jar:?]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.75]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]
        at de.hybris.platform.servicelayer.web.XSSFilter.processPatternsAndDoFilter(XSSFilter.java:358) [coreserver.jar:?]
        at de.hybris.platform.servicelayer.web.XSSFilter.doFilter(XSSFilter.java:306) [coreserver.jar:?]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.75]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) [catalina.jar:7.0.75]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) [catalina.jar:7.0.75]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) [catalina.jar:7.0.75]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) [catalina.jar:7.0.75]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.75]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.75]
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) [catalina.jar:7.0.75]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) [catalina.jar:7.0.75]
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) [tomcat-coyote.jar:7.0.75]
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) [tomcat-coyote.jar:7.0.75]
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) [tomcat-coyote.jar:7.0.75]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_151]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_151]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.75]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]

ERROR [hybrisHTTP3] [DefaultCockpitWidgetEngine] Could not create widget view
java.lang.NullPointerException: null
        at com.hybris.cockpitng.util.DefaultWidgetController.getModel(DefaultWidgetController.java:144) ~[cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.util.DefaultWidgetController.initDragAndDropAwareness(DefaultWidgetController.java:357) ~[cockpitframework-6.4.0.0-RC14.jar:?]
        at com.hybris.cockpitng.util.DefaultWidgetController.doBeforeComposeChildren(DefaultWidgetController.java:91) ~[cockpitframework-6.4.0.0-RC14.jar:?]
        at org.zkoss.zk.ui.impl.UiEngineImpl.doBeforeComposeChildren(UiEngineImpl.java:997) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:937) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:940) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:895) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:777) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:740) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.UiEngineImpl.createComponents(UiEngineImpl.java:1150) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.AbstractExecution.createComponents0(AbstractExecution.java:346) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:307) ~[zk-8.0.4.2.jar:3.6.4]
        at org.zkoss.zk.ui.Executions.createComponents(Executions.java:176) ~[zk-8.0.4.2.jar:3.6.4]


text:
Q: C# - Save text into variable I want to save an e-mail-address out of a .txt-file into a string variable. This is my code:
String path = "C:\\Users\\test.txt";
string from;

var fro = new Regex("from: (?<fr>)");

using (var reader = new StreamReader(File.OpenRead(@path)))
{
    while (true)
    {
        var nextLine = reader.ReadLine();
        if (nextLine == null)
            break;

        var matchb = fro.Match(nextLine);

        if (matchb.Success)
        {
            from = matchb.Groups["fr"].Value;
            Console.WriteLine(from);
        }
    }
}

I know that matchb.Success is true, however from won't be displayed correctly. I'm afraid it has something to do with the escape sequence, but I was unable to find anything helpful on the internet.
The textfile might look like this:

LOG 00:01:05 processID=123456-12345 from: test@test.org
  LOG 00:01:06 processID=123456-12345 OK

A: Your (?<fr>) pattern defines a named group "fr" that matches an empty string.
To fill the group with some value you need to define the group pattern.
If you plan to match the rest of the line, you may use .*. To match a sequence of non-whitespace chars, use \S+. To match a sequence of non-whitespace chars that has a @ inside, use \S+@\S+. All the three approaches will work for the current scenario.
In C#, it will look like
var fro = new Regex(@"from: *(?<fr>\S+@\S+)");

Note that @"..." is a verbatim string literal where a single backslash defines a literal backslash, so you do not have to double it. I also suggest using the * quantifier to match 0 or more spaces before the email. You might want to use \s* (to match any 0+ whitespace chars) or [\p{Zs}\t]* (to match only horizontal whitespace chars) instead.


text:
Q: Profile pages throwing 500 error across few sites in the network When I click on the "profile" tab of a user profile, it leads to 500 error along with the "Oops! Something Bad Happened" error message.

The issue seems to be present on MSE, MSO, SO and a few other sites.


text:
Q: On Change Function In Class Swift I created a DropDownMenu class, but I need to know when the value changed in the ViewController. Like a UIScrollView didScroll, but for the value change in my class.
func scrollViewDidScroll(_ scrollView: UIScrollView)

I need something like that, but for the class!
Here is the class...
class DropDownMenu: UIStackView {

    var options: [String]! = [] // Labels for all of the options
    var titleButton: UIButton! = UIButton() // The Main Title Button
    var target: UIViewController! // The target to get the main view. Maybe remove and automatically do it later
    var textColor: UIColor! = UIColor.black // The Color of the text of the options
    var bgColor: UIColor! = UIColor.clear
    var borderWidth: CGFloat! = 0.0
    var borderColor: CGColor! = UIColor.black.cgColor
    var uiBorderColor: UIColor? = nil
    var cornerRadius: CGFloat! = 0.0
    var font: UIFont! = UIFont.systemFont(ofSize: 18)
    var images: [UIImage]? = nil
    var imageInsets: [UIEdgeInsets]? = nil
    var imageInset: UIEdgeInsets? = nil

    var value: String! {
        get {
            return currentSelected
        }
        set {
            currentSelected = newValue
        }
    }

    private var currentSelected: String! = ""

    init(options: [String]) {
        self.options = options

        super.init(frame: CGRect.zero)

        self.translatesAutoresizingMaskIntoConstraints = false
        self.axis = .vertical
    }

    init(titleButton: UIButton) {
        self.titleButton = titleButton

        super.init(frame: CGRect.zero)

        self.translatesAutoresizingMaskIntoConstraints = false
        self.axis = .vertical
    }

    func createDropDownMenu() {
        currentSelected = titleButton.titleLabel?.text
        let mainFrame = titleButton.frame
        print("Frame: \(mainFrame)")
        print("StackView frame: \(self.frame), axis: \(self.axis)")

        if uiBorderColor != nil {
            borderColor = uiBorderColor!.cgColor
        }

        self.widthAnchor.constraint(equalToConstant: mainFrame.width).isActive = true
        self.leftAnchor.constraint(equalTo: titleButton.leftAnchor).isActive = true
        self.topAnchor.constraint(equalTo: titleButton.bottomAnchor, constant: self.spacing).isActive = true

        var y: CGFloat = 0
        var place = 0

        for title in self.options {
            let button = UIButton(frame: CGRect(x: 0, y: y, width: mainFrame.width, height: mainFrame.height))
            button.setTitle(title, for: .normal)
            button.setTitleColor(textColor, for: .normal)
            button.backgroundColor = bgColor
            button.addTarget(self, action: #selector(dropDownOptionClicked(_:)), for: .touchUpInside)
            button.layer.cornerRadius = cornerRadius
            button.layer.borderWidth = borderWidth
            button.layer.borderColor = borderColor
            button.titleLabel?.font = font

            if images != nil {
                button.setBackgroundImage(images![place], for: .normal)
                if imageInsets != nil {
                    button.imageEdgeInsets = imageInsets![place]
                } else if imageInsets == nil && imageInset != nil{
                    button.imageEdgeInsets = imageInset!
                } else {
                    button.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
                }
            }

            print("Button: \(button), Title: \(String(describing: button.titleLabel?.text)), Target: \(button.allTargets)")

            button.isHidden = true
            button.alpha = 0

            self.addArrangedSubview(button)

            button.translatesAutoresizingMaskIntoConstraints = false
            button.widthAnchor.constraint(equalToConstant: mainFrame.width).isActive = true
            button.heightAnchor.constraint(equalToConstant: mainFrame.height).isActive = true

            print("Subviews: \(self.arrangedSubviews)")

            y += mainFrame.height
            place += 1
            print("y: \(y)")
        }
    }

    @objc func openDropDown(_ sender: UIButton) {
        print("Open DropDownMenu")
        self.arrangedSubviews.forEach { (button) in
            UIView.animate(withDuration: 0.7) {
                button.isHidden = !button.isHidden
                button.alpha = button.alpha == 0 ? 1 : 0
                self.target.view.layoutIfNeeded()
            }
        }
    }

    @objc private func dropDownOptionClicked(_ sender: UIButton) {
        let text = sender.titleLabel?.text
        print(text as Any)

        currentSelected = text
        print("Value: \(String(describing: value))")

        titleButton.setTitle(text, for: .normal)
        openDropDown(sender)
    }

    init() {
        super.init(frame: CGRect.zero)

        self.translatesAutoresizingMaskIntoConstraints = false
        self.axis = .vertical
    }

    required init(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

Here is the creation in ViewController...
let titleButton = UIButton(frame: CGRect(x: 50, y: 290, width: 100, height: 40))
titleButton.backgroundColor = UIColor.white
titleButton.setTitle("Grade", for: .normal)
titleButton.setTitleColor(UIColor.black, for: .normal)
titleButton.layer.borderWidth = 2
titleButton.layer.cornerRadius = 10

let dp = DropDownMenu(options: ["1", "Freshman", "Sophomore", "Junior", "Senior", "College"])
dp.titleButton = titleButton
dp.target = self
dp.borderWidth = 2
dp.spacing = 5
dp.cornerRadius = 10
dp.bgColor = UIColor.white

titleButton.addTarget(dp, action: #selector(dp.openDropDown(_:)), for: .touchUpInside)

infoBox.addSubview(titleButton)
infoBox.addSubview(dp)
dp.createDropDownMenu()

The class works as expected.
I really need help on this. No answer is a bad one. This is all of my code.

A: You usually do that with a delegate:
class DropDownMenu: UIStackView {
    weak var delegate: DropDownMenuDelegate?

    var value: String! {
        get {
            return currentSelected
        }
        set {
            if currentSelected != newValue {
                currentSelected = newValue
                self.delegate?.valueDidChange(self)
            }
        }
    }
}

protocol DropDownMenuDelegate: class {
    func valueDidChange(_ menu: DropDownMenu)
}

Then in your View Controller:
let dp = DropDownMenu(options: ["1", "Freshman", "Sophomore", "Junior", "Senior", "College"])
dp.delegate = self

(typing this in the blind as I'm away from Xcode so there may be syntax errors)


text:
Q: Navigation to child route gives me: "Error: Cannot match any routes" (Angular 6) The first example works (but it's bad writing).
const FooProcessingRoutes: Routes = [{
  path: '',
  pathMatch: 'full',
  redirectTo: '/foo-processing/list',
}, {
  path: 'list',
  component: FooListComponent,
}, {
  path: 'another-list',
  component: FooAnotherListComponent,
}, {
  path: 'another-list/:id/details',
  component: FooAnotherListComponent,
  children: [{
    path: '',
    component: FooAnotherListDetailsComponent,
    outlet: 'details-view',
  }]
}];

export { FooProcessingRoutes };

The second example should work (in my opinion) and I want to have it that way:
const FooProcessingRoutes: Routes = [{
  path: '',
  pathMatch: 'full',
  redirectTo: '/foo-processing/list',
}, {
  path: 'list',
  component: FooListComponent,
}, {
  path: 'another-list',
  component: FooAnotherListComponent,
  children: [{
    path: ':id/details',
    outlet: 'details-view',
    component: FooAnotherListDetailsComponent,
  }],
}];

export { FooProcessingRoutes };

I need the :id/details to be a child of another-list. Both examples link to the same path in my browser (ie. http://localhost:4200/#/foo-processing/another-list/1/details).
However, the second example gives me Error: Cannot match any routes. URL Segment: 'foo-processing/another-list/1/details' in Chrome/Firefox.
Am I missing something there or is that a bug?

A: it should be:
{
  path: 'another-list',
  component: FooAnotherListComponent,
  children: [{
    path: ':id/details',
    component: FooAnotherListDetailsComponent,
    outlet: 'details-view',
  }


text:
Q: Problem about program code included in LaTeX
*

*I have some Matlab code which I
would like to include in my LaTeX
document.
I use fancyvrb package, based on
which I define a new environment
called code. An complete and minimum
example is:
\documentclass[12pt,letterpaper]{article}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{code}{Verbatim}{fontsize=\small}
\DefineVerbatimEnvironment{example}{Verbatim}{fontsize=\small}

\begin{document}
\begin{code}
addpath('~/plot');
\end{code}
\end{document}

However, in the created pdf file, if
I copy the code and
paste it in Matlab command window,
Matlab will complaint about the
single quote is not the one used in
Matlab. I was wondering why and how
to solve the problem?

*To generalize, I also hope to know
if there may possibly be other
characters besides single quote that
can cause such error? Not only in
Matlab but also other programming
languages?

*Also, I was wondering if my way of including code in LaTeX by using fancyvrb is the best? Do you have other nice ways to recommend?

Thanks and regards!

A: A few years ago I wrote a book about the use Matlab, and I used the listings package for all included code.  This allows lots of options: escape to (La)TeX, coloured backgrounds, frames etc.
I set up my listings with
\lstset{language={},
  keepspaces=true,
  xleftmargin=\parindent,
  xrightmargin=\parindent,
  basicstyle=\ttfamily,
  frame=single,
  framesep=2mm,
  framerule=0pt,
  columns=flexible,
  backgroundcolor=\color[gray]{0.9}}

and then called it with
\begin{lstlisting}
function sc(n)

for i = 1:n
    disp([i, i^2, i^3])
end
\end{lstlisting}

I have also been using it for student notes.


text:
Q: libGDX Null Pointer Exception thrown when attempting to render a particle system So I'm attempting to use a Particle Effect in my game, however, when I run it, it throws the following exception:

06-16 15:10:46.585 9136-10049/pt.bluecover.wearable3d
  E/AndroidRuntime: FATAL EXCEPTION: GLThread 78458
                                                                          Process: pt.bluecover.wearable3d, PID: 9136
                                                                          java.lang.NullPointerException: Attempt to read from field
  'com.badlogic.gdx.graphics.g3d.particles.ParallelArray
  com.badlogic.gdx.graphics.g3d.particles.ParticleController.particles'
  on a null object reference
                                                                              at
  com.badlogic.gdx.graphics.g3d.particles.emitters.Emitter.end(Emitter.java:33)
                                                                              at
  com.badlogic.gdx.graphics.g3d.particles.ParticleController.end(ParticleController.java:184)
                                                                              at
  com.badlogic.gdx.graphics.g3d.particles.ParticleController.reset(ParticleController.java:176)
                                                                              at
  com.badlogic.gdx.graphics.g3d.particles.ParticleEffect.reset(ParticleEffect.java:64)
                                                                              at com.mygdx.game.WristPlotter.create(WristPlotter.java:126)
                                                                              at
  com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:290)
                                                                              at
  android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1550)
                                                                              at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1278)

However, I'm currently following this tutorial, and I believe I've everything identical: 3D Particle Systems - LibGDX
So, what might be wrong? Here's the code:
@Override
    public void create() {

        (...)

        //particle system stuff
        particleSystem = ParticleSystem.get();
        pointSpriteBatch = new PointSpriteParticleBatch();
        pointSpriteBatch.setCamera(cam);
        particleSystem.add(pointSpriteBatch);

        assets = new AssetManager();
        ParticleEffectLoader.ParticleEffectLoadParameter loadParam =
                new ParticleEffectLoader.ParticleEffectLoadParameter(particleSystem.getBatches());
        ParticleEffectLoader loader = new ParticleEffectLoader(new InternalFileHandleResolver());
        assets.setLoader(ParticleEffect.class, loader);
        assets.load(PARTICLE_PATH, ParticleEffect.class, loadParam);
        assets.finishLoading();

        ParticleEffect originalEffect = assets.get(PARTICLE_PATH);
        particles = originalEffect.copy();
        particles.init();
        particleSystem.add(particles);

    }

    @Override
    public void render() {

        (...)

        int width = Gdx.graphics.getWidth();
        int height = Gdx.graphics.getHeight();

        Gdx.gl.glViewport(0, 0, width, height);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

        modelBatch.begin(cam);
        modelBatch.render(instancesMap.values(), environment);
        renderParticleEffects();
        modelBatch.end();

    }

    /**
     * Renders our particle effects.
     * Must be used between modelBatch.begin and modelBatch.end
     */
    private void renderParticleEffects() {
        particleSystem.update(); // technically not necessary for rendering
        particleSystem.begin();
        particleSystem.draw();
        particleSystem.end();
        modelBatch.render(particleSystem);
    }

Anyways, thanks in advance!
EDIT: Someone tagged this as a duplicate of "What is a Null Pointer Exception and how do I fix it". Well, this isn't. That question made a general approach on Null Pointer Exceptions. This one refers to the usage of this particular library, libGDX, and where am I failing to add something that could cause the data structure that stores the particles in a particle system to not have the particle effects I loaded previously...


text:
Q: At child Activity finish prevent screen lock I have one activity (a) that launches another activity (b).  When the "b" activity finishes a timed event it closes.   All good there - the issue is that both are set to keep the screen on all the time, but when "b" closes and the time for screen lock-out has passed, the screen locks, i,e, "a" never gets the chance to reassert its "screen-on" command.  I've also tried setting android:keepScreenOn="true" in the manifest but doesn't work either...
Perhaps related when debugging and in screen "b" (the "child" activity), if I terminate the app from within the debugger, only screen "b" closes... shouldn't it kill the whole app?

A: Figured it out... the WakeLock was unregistering at screen "a" close - which it needs to do if the whole app is unloading of course.  So I put a bool flag in screen "a", then in the onclick to open child "b" set the flag to true.  Then in the onActivityResult set the flag back to false.  Finally any close in "a" would would only unregister the wakelock if the flag was set to false...


text:
Q: How can I get the current state of element in react for rendering progress bar? handlePercent=()=>{
    if (this.state.phone!=="") {
        this.setState(() => ({
            percent: this.state.percent + 20,
        }));
    } else if(this.state.website!==""){
        this.setState(() => ({
            percent: this.state.percent + 20,
        }));
    }
    return this.state.percent;
};

I have the above function for handling the percent state, but even if the state of object, for example phone is not null it does not give me the right state. I checked phone state for example with console log and it s empty.
Bellow is there I call the percent object. I have used "react-sweet-progress"

Your profile is {this.state.percent}% complete:

        <Progress percent={this.handlePercent()}/>

A: You should use prevState in setState instead of using this.state
handlePercent = () => {
    if (this.state.phone !== "") {
        this.setState(prevState=> ({
            percent: prevState.percent + 20,
        }))
    } else if(this.state.website!==""){
        this.setState(prevState=> ({
            percent: prevState.percent + 20,
        }))
    }
    // don't return state
}

And pass this.state.percent to Progress
<Progress percent={this.state.percent}/>

And call handlePercent in some other place in the code.
The reason for don't return state is that when you call this.setState it will rerender the component and make this.state.percent the correct percent. If you return this.state.percent, it will return the wrong data.
Please add the full logic of the component for more understanding of how to do what you want.


text:
Q: Annihilator for another Annihilator Let X be a Banach Space, $ Y\subset X $ a closed subspace, $X^*$ is the dual space to  X and  $N_Y$  = {$f\in X^* | f(Y)=0$ for any y∈ Y } ( The set $N_Y$ is called annulator for Y). Prove that
Y={y∈ X | f(y)=0 for any  f ∈ $ N_Y $} , i.e that Y is annulator for $N_Y$.
I did it till this :
If $f, g ∈ N_Y $ and λ ∈ R, then (f + g)(y) = 0 and (λf)(y) = 0 for
all x ∈ Y, so $ f + g ∈ N_Y $ and $λf ∈ N_Y$. It follows that $N_Y $is a vector
space. If $f_n → f$ in norm and $f_n ∈ N_Y$, then
$f(x) = limn→∞f_n(y) = 0$ for every y ∈ Y,
so f ∈ $N_Y$, meaning that $N_Y$ is closed.
I don't know it ok or not. What Next ?

A: This is an application of Hahhn Banach, if the annihilator of $N_Y$ contains $x$ which is not in $Y$, $M=N\oplus Vect(x)$ is closed and the linear function defined on $M$ by $f(x)=1, f(Y)=0$ is continuous since its kernel is closed, it can be extended to $X$ by Hahn Banach, denote by $g$ this extension, $g\in N_Y$ contradiction since $g(x)\neq 0$. This implies that  the annihilator of $N_Y$ is contained in $Y$, $Y$ is contained in the annihilator of $N_Y$ by definition.


text:
Q: Update UIViewController when Core Data objects are updated I want binding the dataSource and view controller
I use Core Data, and the dataSource is the an collection of NSManagedObject, when receive web socket notification, I update the data in Core Data, How can I let the view controller update UI automatically.

A: You can use NSFetchedResultsController if you are using a UITableView.
Else, you can use NSNotificationCenter. Demo use :
In your ViewController,
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateUI:) name:@"updateUI" object:nil];

Post a notification to after updating the data
 [[NSNotificationCenter defaultCenter] postNotificationName:@"updateUI" object:nil];

Then in the method updateUI, you can do your UI updating stuff.

A: One option is to use NSFetchResultsController, if your controller looks like a list of items.
The other option is to listen to the web socket notification, and just reload the UI whenever you get an answer.


text:
Q: CocosSharp + Xamarin.forms + Carousel Page I'm working on game in Xamarin.forms. I'm using CocosSharp as my graphic engine and it is great, but I have an question. My game is suppose to have 3 diffrent tabs/pages, so I used an Carousel Pages to do that. And now my question can I have multiple CCScenes on diffrent pages or can I use one CCScane but places CCLayers on those Pages?
I will be gratefull for all responses


text:
Q: self click on a  element inside function I have to download a file from server and I have this function.
private function downloadFile($dir,$file,$alias)
{
    $path=$dir.$file;
    $name=$alias.".pptx";
    $size = filesize($path);
    header("Content-Type: application/force-download");
    header("Content-Disposition: attachment; filename='$name'");
    header("Content-Transfer-Encoding: BINARY");
    header("Content-Length: " . $size);
    // Descargar archivo
    readfile($path);
    Yii::$app->session->setFlash("errordownload");
    exit;

But I would like to know if its possible use a self-click  html element instead of headers.
Something like this
private function downloadFile($dir,$file,$alias)
{
    echo 'Descargar Archivo';

    echo''

}

I want to do it through  because otherwise I get some errors when I try to open the file. The file in server opens with no errors.


text:
Q: keeping relative position of pictureBox when resizing form In Window Forms, I've put a pictureBox as a background image. Then, I've made it so that if I resize the window, the image stretches and gets bigger as I resize it, and that the entire picture is always filling the entire form. For this, I've used the following code:
     image.Dock = DockStyle.Fill;
     image.Anchor = AnchorStyles.Top | AnchorStyles.Left;
     image.SizeMode = PictureBoxSizeMode.StretchImage;
I had no problems with that whatsoever simply because the image is filling in the entire window.
What I want to do now, however, is to put on another (smaller) pictureBox, that's going to be exactly 20 px above the center of the Form, and will also stretch appropriately as I resize the window, and will always stay slightly above the center of the Form, no matter how much I resize it.
The thing is that I cannot set the Location property of the pictureBox, because then the position is absolute and the image will not stretch and stay in the center as I resize the window, but will remain where it is, according to the x and y coordinates of the window. What I want is for the picture to stretch and move according to how I stretch and move the window, just like I've managed to do with the image I have in background.

A: Position your imagebox on the form where you want it, then set the Anchor proprety to top, bottom, right, and left.  By pinning it to all four sides, it will stretch and shrink as the form resizes.
Use these in conjunction with the MinimumSize and MaximumSize properties to keep the image from getting too small or too large.


text:
Q: How to remove functions from object javascript In my app, I'm using angular.js.
I need to send (through PUT request) an object with 3 properties, like this:
var item = {
  a: 1,
  b: 2,
  c: 3
}

But when I do console.log(item), it shows a lot of information I don't need, such as $delete, $get, and so on. Like this:
 {
   ...
   $delete: function (params, success, error),
   $get: function (params, success, error),
   ...
   a: 1,
   b: 2,
   c: 3
}

I think it's because is a javascript promise or something.
Is there any way to get only a, b and c? Maybe with lodash?

My Solution:
I used lodash like this:
 var valuesToPick = ['title', 'languageCode', 'jobTitle', 'location','economySegment', 'companyDescription' ...];

 var item = _.pick( vm.form, valuesToPick );

A: Plain Javascript
var objectFunctionLess=JSON.parse(JSON.stringify(objectWithFunctions))

A: They are inherit from Object, not owned by item.
If you want to iterate over own properties, use a for...in loop.
for (property in item) {
    item[property];
}

A: I used lodash _.pick like this:
 var valuesToPick = ['title', 'languageCode', 'jobTitle', 'location','economySegment', 'companyDescription' ...];

 var item = _.pick( vm.form, valuesToPick );

Items is now free of functions, just your info.

A: This is not a perfect solution but it should work:
Instead of:
submitFunction(object, function () {})

do the:
submitFunction(JSON.parse(angular.toJson(object)), function () {})

you can split it into:
var cleanObject = JSON.parse(angular.toJson(object))
submitFunction(cleanObject, function () {})