text:
Q: Finding position of biggest section of green pixels in numpy I have a program that creates a mask for green pixels in a screenshot (img). I need to get the approximate location of the biggest section of these pixels within the image. What would be the best way to get this info?
The image:

My code for getting the mask (np is numpy, cv2 is OpenCV):
# define the list of color boundaries
boundaries = [
    ([0, 100, 0], [100, 255, 100]), # green
]

# loop over the boundaries
for (lower, upper) in boundaries:
    # create NumPy arrays from the boundaries
    lower = np.array(lower, dtype = "uint8")
    upper = np.array(upper, dtype = "uint8")
    # find the colors within the specified boundaries and apply the mask
    mask = cv2.inRange(img, lower, upper)
    output = cv2.bitwise_and(img, img, mask = mask)

A: You can get the bounding rect of the biggest green area using cv2.findContours combined with cv2.boundingRect
import cv2

img = cv2.imread('game.png')
mask = cv2.inRange(img, (0, 100, 0), (100, 255, 100))

contours, _ = cv2.findContours(mask, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
rects = map(cv2.boundingRect, contours)

# f[2] = width, f[3] = height
biggest = max(rects, key=lambda f: f[2]*f[3])

cv2.rectangle(img, biggest, (255, 0, 0),  2)

Result:


text:
Q: vba common Next without for Error Below is a very simple code with many if statements that gives a "Next without for" error. I know that this error is expected when a statement is not closed, but I check and recheck the code and everything seems fine. The characters you cant identify is just string values in greek.
Thanks in advance for any given help
Sub sygr()
Dim aCell
Dim ThisRng As Range
Set ThisRng = Application.InputBox("Select a range", "Get Range", Type:=8)
For Each aCell In ThisRng
    If ActiveCell.Offset(rowOffset:=0, columnOffset:=-52).Value = "ÂÅ" Then
        If ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "2Á1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "2Á2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "2Á3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "2Á4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á4" Then
            ActiveCell.Value = "2Á5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.3" Then
            ActiveCell.Value = "2Â1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å4" Then
            ActiveCell.Value = "2Â2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á4" Then
            ActiveCell.Value = "2Â3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.3" Then
            ActiveCell.Value = "2Ã1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.3" Then
            ActiveCell.Value = "2Ã2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.3" Then
            ActiveCell.Value = "2Ã3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ. 5" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-7).Value = "Ê.Ï.19.1" Then
            ActiveCell.Value = "2Ã4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ. 5" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.4" Then
            ActiveCell.Value = "2Ã5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.1" Then
            ActiveCell.Value = "2Ã6"
        Else
            ActiveCell.Value = "BE"
        End If
    ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-52).Value = "ÄÕÔ.Å" Then
        If ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "3Á1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "3Á2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á2" Then
            ActiveCell.Value = "3Á3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á4" Then
            ActiveCell.Value = "3Á4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á4" Then
            ActiveCell.Value = "3Á5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á4" Then
            ActiveCell.Value = "3Á5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" Then
            ActiveCell.Value = "3Â1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "3Â2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å2" Then
            ActiveCell.Value = "3Â3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å2" Then
            ActiveCell.Value = "3Â4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å2" Then
            ActiveCell.Value = "3Â5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á2" Then
            ActiveCell.Value = "3Â6"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.3" Then
            ActiveCell.Value = "3Â7"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" Then
            ActiveCell.Value = "3Â8"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å3" Then
            ActiveCell.Value = "3Â9"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å2" Then
            ActiveCell.Value = "3Â10"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å4" Then
            ActiveCell.Value = "3Â11"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á4" Then
            ActiveCell.Value = "3Â12"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.2" Then
            ActiveCell.Value = "3Ã1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.2" Then
            ActiveCell.Value = "3Ã2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ô.Ï.1" Then
            ActiveCell.Value = "3Ã3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-1).Value = "Ð.Ð.×.Ï.1" Then
            ActiveCell.Value = "3Ã4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.2" Then
            ActiveCell.Value = "3Ã5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-7).Value = "Ê.Ï.19.1" Then
            ActiveCell.Value = "3Ã6"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ. 5" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.4" Then
            ActiveCell.Value = "3Ã7"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ. 5" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.4" Then
            ActiveCell.Value = "3Ã8"
        Else
            ActiveCell.Value = "ÄÕÔ.Å"
        End If
    ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-52).Value = "ÊÅ" Then
        If ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "4Á1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "4A2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "4A3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" Then
            ActiveCell.Value = "3Â1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì2" Then
            ActiveCell.Value = "3Â2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á1" Then
            ActiveCell.Value = "3Â3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" Then
            ActiveCell.Value = "3Â4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á4" Then
            ActiveCell.Value = "3Â5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" Then
            ActiveCell.Value = "3Â6"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å1" Then
            ActiveCell.Value = "3Â7"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å1" Then
            ActiveCell.Value = "3Â9"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å1" Then
            ActiveCell.Value = "3Â10"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á1" Then
            ActiveCell.Value = "3Â11"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.2" Then
            ActiveCell.Value = "3Ã1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.2" Then
            ActiveCell.Value = "3Ã2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ô.Ï.1" Then
            ActiveCell.Value = "3Ã3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-1).Value = "Ð.Ð.×.Ï.1" Then
            ActiveCell.Value = "3Ã4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.2" Then
            ActiveCell.Value = "3Ã5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-7).Value = "Ê.Ï.19.1" Then
            ActiveCell.Value = "3Ã6"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ. 5" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.4" Then
            ActiveCell.Value = "3Ã7"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ. 5" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.4" Then
            ActiveCell.Value = "3Ã8"
        Else
            ActiveCell.Value = "ÊÅ"
        End If
    ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-52).Value = "ÍÏÔ.Å" Then
        If ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "5Á1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "5A2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "5A3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" Then
            ActiveCell.Value = "5Â1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì2" Then
            ActiveCell.Value = "5Â2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á1" Then
            ActiveCell.Value = "5Â3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" Then
            ActiveCell.Value = "5Â4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á4" Then
            ActiveCell.Value = "5Â5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" Then
            ActiveCell.Value = "5Â6"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å1" Then
            ActiveCell.Value = "5Â7"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å1" Then
            ActiveCell.Value = "5Â9"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å1" Then
            ActiveCell.Value = "5Â10"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á1" Then
            ActiveCell.Value = "5Â11"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.1" Then
            ActiveCell.Value = "5Ã1"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.1" Then
            ActiveCell.Value = "5Ã2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.3" Then
            ActiveCell.Value = "5Ã3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-47).Value = "ÔÏ3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-1).Value = "Ð.Ð.×.Ï. 3" Then
            ActiveCell.Value = "5Ã4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-7).Value = "Ê.Ï.19.2" Then
            ActiveCell.Value = "5Ã5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.1" Then
            ActiveCell.Value = "5Ã6"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.4" Then
            ActiveCell.Value = "5Ã7"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.1" Then
            ActiveCell.Value = "5Ã8"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-45).Value = "ÕÏ2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-1).Value = "Ð.Ð.×.Ï.1" Then
            ActiveCell.Value = "5Ã9"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.1" Then
            ActiveCell.Value = "5Ã10"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-1).Value = "Ð.Ð.×.Ï.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.1" Then
            ActiveCell.Value = "5Ã11"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-3).Value = "Ð.Ï.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.1" Then
            ActiveCell.Value = "5Ã12"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-7).Value = "Ê.Ï.19.3" Then
            ActiveCell.Value = "5Ã13"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.1" Then
            ActiveCell.Value = "5Ã14"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-40).Value = "ÐË.Ï.ÐÅÑÉÖ. 5" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.4" Then
            ActiveCell.Value = "5Ã15"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-37).Value = "Ï.Ì.2" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-7).Value = "Ê.Ï.19.3" Then
            ActiveCell.Value = "5Ã16"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-37).Value = "Ï.Ì.5" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-6).Value = "Ê.Ï.45.1" Then
            ActiveCell.Value = "5Ã17"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-37).Value = "Ï.Ì.3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-5).Value = "Ê.Ï.60.4" Then
            ActiveCell.Value = "5Ã18"
        Else
            ActiveCell.Value = "ÍÏÔ.Å"
        End If
    ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-52).Value = "ÍÏÔ.Å" Then
        If ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "6Á1"
        If ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "6Á2"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "6Á3"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å4" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "6Á4"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-14).Value = "Á.Á.1" Then
            ActiveCell.Value = "6Á5"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-13).Value = "Â.Á1" Then
            ActiveCell.Value = "6Á6"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-13).Value = "Â.Á1" Then
            ActiveCell.Value = "6Á7"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-13).Value = "Â.Á1" Then
            ActiveCell.Value = "6Á8"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-13).Value = "Â.Á1" Then
            ActiveCell.Value = "6Á9"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Á3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-13).Value = "Â.Á1" Then
            ActiveCell.Value = "6Á10"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-24).Value = "Ä.Ì.1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "6Á11"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-23).Value = "ÔÑ.Å1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "6Á12"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-22).Value = "ÄÅ.Å1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "6Á13"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-21).Value = "ÕÐ.Å1" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á1" Then
            ActiveCell.Value = "6Á14"
        ElseIf ActiveCell.Offset(rowOffset:=0, columnOffset:=-20).Value = "Ä.Á3" And ActiveCell.Offset(rowOffset:=0, columnOffset:=-12).Value = "Ã.Á3" Then
            ActiveCell.Value = "6Á15"
        Else
            ActiveCell.Value = "ÍÇÓ.Å"
        End If
    Else
    'Do nothing
    End If
Next aCell

End Sub

A: You have 2 times "If" right after each other, down in fifth big ElseIf section.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How should I retrieve the data from the code Li? Goal:
Retrieve datatype as a array with data One, two, three and four without using the syntax code "data-id".
Problem:
I tried to find some different solution it didn't go so well. The data can be random.
Info:
This context should be without data-id.

var dataList = $(".list").map(function() {
    return $(this).data("id");
}).get();
console.log(dataList);

One

Two

Three

Four

JS FIDDLE
Thank you!

A: You can do it like following without using data-id.

var dataList = $(".list").map(function() {
    return $(this).text();
}).get();

console.log(dataList.join('|'));

One

Two

Three

Four

A: Return your function
$(this).attr("data-id");

A: I think this is what you're after:
var dataList = [];
$(".list").each(function() {
    dataList.push($(this).text());
});

jsFiddle


text:
Q: Using Redundancy to Simplify Boolean Expression I came across a question which I need to solve using Redundancy:
x'z + x'y + xy'z + yz
Could anyone help me solving this? I must solve it using Redundancy only...

A: Here is one reduction:
$$\begin{align*}
x'z+x'y+xy'z+yz&=x'y+x'z+xy'z+(x+x')yz\\
&=x'y+x'z+\color{crimson}{xy'z+xyz}+x'yz\\
&=x'y+x'z+\color{crimson}{x(y'+y)z}+x'yz\\
&=x'y+\color{blue}{x'z+xz}+x'yz\\
&=x'y+\color{blue}z+x'yz\\
&=x'(y+yz)+z\\
&=x'y+z
\end{align*}$$

A: Here is what I did:
$x'z+x'y+xy'z+yz=$ (Distribution)
$x'z+x'y+(xy'+y)z=$ (Reduction)
$x'z+x'y+(x+y)z=$ (Distribution)
$x'z+x'y+xz+yz=$ (Adjacency)
$z+x'y+yz=$ (Redundancy)
$z+x'y$


text:
Q: Deserialising a JSON response I am trying to deserialize a JSON response.
public class CLiveExMarketPriceHistory{
public String lwin11;   //11227502005
public String lcurrency;    //GBP
public String priceFrom;    //2013-07-12
public cls_prices[] prices;
public class cls_prices {
    public String ldate;    //2013-07-12
    public Decimal marketPrice; //880
}
public static CLiveExMarketPriceHistory parse(String json){
    return (CLiveExMarketPriceHistory) System.JSON.deserialize(json, CLiveExMarketPriceHistory.class);
}

The JSON response is
{"lwin11":"11227502005","currency":"GBP","priceFrom":"2013-07-12","prices":[{"date":"2013-07-12","marketPrice":880.0},{"date":"2013-07-13","marketPrice":880.0},{"date":"2013-07-14","marketPrice":880.0},{"date":"2013-07-15","marketPrice":880.0},{"date":"2013-07-16","marketPrice":880.0},{"date":"2014-01-28","marketPrice":950.0}]}

The issue I am facing is that the JSON has attributes like date and currency which i am not able to use in my class as they are salesforce datatypes. I tried changing the class variables as lcurrency and ldate. But after deserialisation the values for these changed class variables are null as they don't match with the JSON response.
Any thoughts on how i can get values for the date and currency from JSON?

A: You could use JSON.deserializeUntyped
Map<String, Object> m = (Map<String, Object>)
      JSON.deserializeUntyped(jsonInput);

String lcurrency = m.get('currency'));

A: You have two choices: JSON.deserializeUntyped or JSON.createParser. The former returns an object that operates like a map; you can call the get function, passing in a string, to return a value. The latter returns a parser that generates token events that you can use to parse the object.
Map<String, Object> data = (Map<String, Object>)JSON.deserializeUntyped(json);
String lwin11 = (String)data.get('lwin11');
String theCurrency = (String)data.get('currency');
Date priceFrom = Date.valueOf((String)data.get('priceFrom'));
List<Map<String, Object>> prices = (List<Map<String, Object>>)data.get('prices');
for(Map<String, Object> price: prices) {
   ...
}

You may have to play with the precise syntax, but examples are in the documentation.

A: Another option, though it's not necessarily the best performance-wise, would be to "filter" the JSON response through a string-replace? I.e.
jsonInput = jsonInput.replace('"currency":', '"1currency":');


text:
Q: How to call a function when the index for you SegmentedControl is changed I'm trying to call a fucntion "indexChanged" when my UISegmentedControl changes index. I'm using the .addAction function that is apart of this class. I receive this warning: "No method declared with Objective-C selector 'indexChanged:'", yet even when I add a @objc tag next to the "indexChanged" function, I receive more errors.
Is there an alternative way to call a function when the SegementedControl index changes? Some code is below:
let items = ["Donors", "Cars"]
let controller = UISegmentedControl(items: items)
    controller.selectedSegmentIndex = 0

    let frame = UIScreen.main.bounds
    controller.frame = CGRect(x: frame.maxX - 135, y: frame.minY + 10,
                            width: frame.width - 250, height: frame.height*0.03)

    controller.addTarget(self, action: "indexChanged:", for: .valueChanged)

    map.addSubview(customSC) // map is a UIKit Map

func indexChanged(_ sender: UISegmentedControl) {
    if sender.selectedSegmentIndex == 0 {
        print("Select 0")
    } else if sender.selectedSegmentIndex == 1 {
        print("Select 1")
    }
}

Thanks a bunch!

A: You're very close!  You didn't explain the extra errors you got, but I  successfully compiled your code by changing two lines:
  controller.addTarget(self, action: "indexChanged:", for: .valueChanged)

becomes:
    controller.addTarget(self, action: #selector(indexChanged(_:)) , for: .valueChanged)

and
func indexChanged(_ sender: UISegmentedControl) {

needs the @objc to work:
@objc
func indexChanged(_ sender: UISegmentedControl) {


text:
Q: Trying to get image from Spring My HTML file has the following command
<img src="/5/background" alt="" width="192" height="192">

Which I have bound to the following inside a @RestController in a Spring Boot application:
@RequestMapping(value = "/{connector}/background", method = RequestMethod.GET)
public File getConnectorBackgroundImage(@PathVariable("connector") int connector)
{
    File image = new File("folder" + connector + "/myPicture");
    return image;
}

I have done my debugging and I know the method is being entered, and I know the path is correct, but all that shows is the icon in the browser when there is a problem loading a picture.
What else am I missing?

A: Spring does not know how to handle the file that way. If you return a File, the controller will simply show you the path to the file if you call the REST API.
The proper way to do it is to read the file as a byte[]. Using commons-io you could come up with something like this:
File image = new File("folder" + connector + "/myPicture");
FileInputStream input = null;
try {
    input = new FileInputStream(image);
    return IOUtils.toByteArray(input);
} finally {
    IOUtils.closeQuietly(input);
}

Another thing you shouldn't forget is to provide the mimetype. To do that you tweak the @RequestMapping annotation a bit by providing the produces property:
@RequestMapping(value = "/{connector}/background", method = RequestMethod.GET, produces = MediaType.IMAGE_PNG_VALUE)

This should do the trick.
EDIT: Didn't notice the comments, you already fixed it by yourself.


text:
Q: End-to-end testing NestJS with Fastify: "@nestjs/platform-express" package is missing" error I have fresh NestJS application using Fastify. When trying to npm run test:e2e I got the following error:
[Nest] 14894   - 11/19/2021, 10:29:10 PM   [ExceptionHandler] The "@nestjs/platform-express" package is missing. Please, make sure to install this library ($ npm install @nestjs/platform-express) to take advantage of NestFactory.
  ●  process.exit called with "1"

      12 |     }).compile();
      13 |
    > 14 |     app = moduleFixture.createNestApplication();
         |                         ^
      15 |     await app.init();
      16 |   });
      17 |

      at Object.loadPackage (../node_modules/@nestjs/common/utils/load-package.util.js:13:17)
      at TestingModule.createHttpAdapter (../node_modules/@nestjs/testing/testing-module.js:25:56)
      at TestingModule.createNestApplication (../node_modules/@nestjs/testing/testing-module.js:13:43)
      at Object.<anonymous> (app.e2e-spec.ts:14:25)

 RUNS  test/app.e2e-spec.ts

Process finished with exit code 1

Seems odd, because why would platform-express be needed for fastify-based app?

A: Appears that after switching to Fastify we also need to update test/app.e2e-spec.ts accordingly:
import { Test, TestingModule } from '@nestjs/testing';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';

describe('AppController (e2e)', () => {
  let app: NestFastifyApplication;

  beforeEach(async () => {
    const moduleFixture: TestingModule = await Test.createTestingModule({
      imports: [AppModule],
    }).compile();

    app = moduleFixture.createNestApplication<NestFastifyApplication>(new FastifyAdapter());
    await app.init();
    await app.getHttpAdapter().getInstance().ready();
  });

  afterEach(async () => {
    await app.close();
  });

  it('/ (GET)', () => {
    return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!');
  });
});


text:
Q: Open a XML to send to SOAP in Python I am implementing a client for interaction with a SOAP WebService. This WebService has two parameters: a string and an xml.
I am a beginner in development with python but I would like to know how I can get an xml file from my machine to send it to my client.
I Tried :
test = open('LCL.XML')
test = test.read()
print(test)

But it did not work.

return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position
 492: character maps to <undefined>

A: Here is how to read and xml file and get it ready for sending vis SOAP:
import xml.etree.ElementTree
filename = 'whatever.xml'
result = xml.etree.ElementTree.parse(filename).getroot()
xml_str = xml.etree.ElementTree.tostring(result, encoding='utf-8')
Then send xml_str in zeep.Client.service.<your soap call>(..., xml_str, ...)


text:
Q: vba excel internet explorer disable warning https message when loading a website , i get the following Security warning :
do you want to view only the webpage content that was delivered securely.
This popup cause my code to go to error , is there a way to disable it with vba ?
Thanks.
here is the code
    Sub Start()

Dim ie As New InternetExplorer
Dim doc As HTMLDocument

ie.Visible = True

ie.navigate ("https://mywebsite.com")
ie.FullScreen = True
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set doc = ie.document

doc.getElementById("navMenu2").Click

A: The reason for the warning is that you're on an SSL-secured (https protocol) page that is attempting to load non-SSL (http protocol) content.
The best ways to fix this is to either:

*

*Visit your website with http instead of https - ie.navigate ("http://mywebsite.com")

*Fix the security issues in your website (do not load unsecure content when visiting with https)

If you just want to fix it for testing purposes, you can change the settings in your test browser:

*

*Go to Tools -> Internet Options -> Security

*Select the "Security" tab -> Click the "Custom Level" button

*In the "Miscellaneous" section change "Display mixed content" to Enable.


text:
Q: Laravel on shared hosting with Subdomain I Have A shared host and i have made a laravel project and when i upload it to the host
i made a htaccess file to redirect all requests to publc/index.php
and it works very well and laravel project work good
when i create a sub domain and but some files in subdomain's folder and try to access it
i got a 500 Internal Server Error
when i contaced the support they told me that this error because the .htaccess that i made
i need help to solve this problem
 this is the structure of my public_html folder
-public_html
 |-laravelproject
   |- Laravel Projct Files
 |-subdomain
   |-index.php
 |-.htaccess

.htaccess file:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^laravelproject/public
    RewriteRule ^(.*)$ laravelproject/public/$1 [L]
</IfModule>

A: Since subdomain is other installation i think you should add
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^laravelproject/public
    RewriteRule ^(.*)$ laravelproject/public/$1 [L]
    RewriteCond %{REQUEST_URI} !^subdomain/public
    RewriteRule ^(.*)$ subdomain/public/$1 [L]
</IfModule>

But im no .htaccess expert, hope it works!...


text:
Q: Proper way to sleep during a lock with await In my win8 (winrt, c#) application, I need to call a web API which has a very specific limitation:  No more one call to the web service every 2 seconds.
I've attempted to enforce this limit, like so:
class Client
{
    const int Delay = 2000;
    HttpClient m_client = new HttpClient();
    int m_ticks = 0;

    public async Task<string> Get(string url)
    {
        // Multiple threads could be calling, I need to protect access to m_ticks:
        string result = null;
        lock (this)
        {
            int ticks = Environment.TickCount - m_ticks;
            if (ticks < Delay)
                await Task.Delay(Delay - ticks);

            result = await m_client.GetStringAsync(url);

            m_ticks = Environment.TickCount;
        }

        return result;
    }
}

This has run me into a brick wall:

*

*I cannot use the await statement in a lock.

*I cannot fall back to something like WebClient + Thread.Sleep (avoiding the async nonsense) because it doesn't exist in the win8 client profile.

*I cannot avoid this method being "async" because then I cannot await GetStringAsync or Task.Delay without being in an async function.

*I cannot avoid the lock, because multiple threads could be calling into this function, and I need synchronous access to m_ticks.

How in the world would I go about writing something like this?

A: The SemaphoreSlim type was extended in .NET 4.5 to include await-compatible WaitAsync methods. It doesn't have an IDisposable-based Release, but it's not hard to build one:
sealed class SemaphoreSlimReleaser : IDisposable
{
  SemaphoreSlim mutex;
  public SemaphoreSlimReleaser(SemaphoreSlim mutex)
  {
    this.mutex = mutex;
  }

  void Dispose()
  {
    if (mutex == null)
      return;
    mutex.Release();
    mutex = null;
  }
}

Then you can use code very similar to what you already have:
class Client
{
  const int Delay = 2000;
  HttpClient m_client = new HttpClient();
  int m_ticks = 0;
  SemaphoreSlim mutex = new SemaphoreSlim(1);

  public async Task<string> Get(string url)
  {
    // Multiple threads could be calling, I need to protect access to m_ticks:
    string result = null;
    await mutex.WaitAsync();
    using (new SemaphoreSlimReleaser(mutex))
    {
        int ticks = Environment.TickCount - m_ticks;
        if (ticks < Delay)
            await Task.Delay(Delay - ticks);

        result = await m_client.GetStringAsync(url);

        m_ticks = Environment.TickCount;
    }

    return result;
  }
}

P.S. If you're interested, my AsyncEx library has a full suite of async-compatible synchronization primitives inspired by Stephen Toub's blog series.

A: Simple solution:
Use a Concurent queue.
http://msdn.microsoft.com/en-us/library/dd267265.aspx
All the requests to use the web service will be added to the queue.
You will have a thread that will enqueue one object every two seconds use it and return the answer.


text:
Q: pass direct reference or closure Coming from a different language background where passing a method to another object was done differently as demonstrated below (approach A) but I've noticed a style of passing blocks around in Objective-C as well as SWIFT, what's the recommended way in SWIFT and why? (pros and cons any?)
class Messenger {
    private var _method: ((String) -> ())

    init(method: (String -> ())) {
        _method = method
    }
}

class Test {
    init() {
        Messenger(method: self.callback) //approach A

        Messenger({
            message in self.callback(message) //approach B - Wrapper/Block style
        })
    }

    func callback(message: String) {
        println(message)
    }
}

A: Your method A is the way to go.  Method B really doesn't serve a purpose – you are declaring an anonymous function which takes a single parameter and does nothing to it but use it as an argument to another function, callback.  It's essentially like saying this:
func f(arg1: Int) {
    // do nothing but call g
    g(arg1)
}
f(1)        // no different to calling g(1)
takeFunc(f) // no different to passing in g

It's important to realize that a function declared with the closure expression syntax, let f: Int->Bool = { i in etc }, and a function declared with the func keyword, func f(i: Int)->Bool { etc } amount to much the same thing.  There are subtle differences but not fundamental ones.
Re your concerns about strong references – the closure expression in option B doesn't really help the situation.  In option A you pass an implicit reference to self by passing in a pointer to an instance's member function.  In Option B, you declare an anonymous closure that "captures" self, and then pass that, but that anonymous function being stored will keep self alive in just the same way storing self.memfun will, just with an extra level of indirection.  In fact, it's so easy to forget that capturing self via a closure expression can be a risk that Swift will warn you if you do it implicitly by accident and force you to put an explicit self in there (which can be super-annoying sometimes when you know the capture isn't an issue e.g. when referencing self in a call to map or filter).
To write a callback function that didn't capture self, you would have to use a capture list:
    Messenger { [weak self] message in // weak or unowned depending on how Messenger is being used
        self?.callback(message)  // if weak, self needs to be optional
        return // return needed since otherwise it will attempt to return ()?
    }

By the way, the best way to write more Swift-y Swift would be to ditch a lot of the excess brackets :-)
e.g.
// no need to wrap entire function type in (),
// and single argument types (i.e. 1-element tuples)
// don't need () surrounding them:
private var _method: String -> ()

instead of
private var _method: ((String) -> ())

and
Messenger { // closure exprs can be outside the () of functions
            // when they're the last argument (and () can be
            // left out completely when they're the only argument)
    message in self.callback(message)
}

instead of
Messenger({
        message in self.callback(message) //approach B - Wrapper/Block style
})

A: Your approach B will allow you to insert additional statements between message in and self.callback(message). Without such additional statements (as in your verbatim example) I would favor approach A.


text:
Q: Javascript getdate and edit var firstDate = new Date();
firstDate .setMonth(firstDate.getMonth() - 3);

How can i get above date like below in Javascript or Jquery
13.02.2015
It must be dynamic date (according to today) i want to get date and 3 months ago like day.month.year.
Thanks

A:     var date = new Date(), date2 = new Date();
    var todayDate = date.getDate() + '.' +(date.getMonth() +1 ) + '.' +  date.getFullYear();

    date2.setMonth(date2.getMonth()-3);
    var agoDate = date2.getDate() + '.' +(date2.getMonth() +1) + '.' +  date2.getFullYear();

    console.log(todayDate);
    console.log(agoDate);


text:
Q: Web scraping problem : Data does not show when printed So i tried to scrape this website: https://top-1000-sekolah.ltmpt.ac.id/site/page?id=2001
if you inspect element, there's a div with id of tab-1, tab-2,tab-3, tab-4 . So I tried ti scrape each id but somehow only tab-1 data's were grabbed. so what did I do wrong??
pk = driver.find_element_by_xpath("(//div[@id='tab-1'])")
pbm = driver.find_element_by_id('tab-2')
pu = driver.find_element_by_id('tab-3')
ppu = driver.find_element_by_id('tab-4')

The output I expect from tab-2 is :
Kemampuan Kuantitatif
2
Urut Nasional
1
Urut Provinsi
Rerata
640,253
Nilai Tertinggi
721,15
Nilai Terendah
511,14
Standar Deviasi
44,1

and currently tab-2 output is blank( ' ' )

A: Try doing this:
pbm = driver.find_element_by_id('tab-2')
print(pbm.text)

If that doesn't work, I suspect it is because that div class with the id of tab-2 has many child elements. You will need to select those individual child elements directly to get the data you need. Use the XPATH method which you used up top.

            Kemampuan Memahami Bacaan dan Menulis

                    5

Urut Nasional

                    1

Urut Provinsi

Rerata

589,104

Nilai Tertinggi

709,61

Nilai Terendah

371,88

Standar Deviasi

65,96

For example to parse the name Kemampuan Kuantitatif,
name = driver.find_element_by_xpath('//*[@id="tab-2"]/div/div/h3')
print(name)


text:
Q: Empty subclass when base has no virtual destructor - averse effects of delete base pointer? Following up from this question I wonder:
class MyVector : public std::vector<int> {};

std::vector<int>* obj = new MyVector;
delete obj;

Does this have any averse effects?

A: By the letter of the standard, you're invoking Undefined Behaviour, so anything can happen. But I'd guess that in most normal implementations, MyVector's destructor is effectively a no-op (except for calling std::vector's destructor, of course), so you'll be safe in practice.
Another question is why you're allocating a vector (-like class) dynamically in the first place. I'd say that's a rather unusual scenario. And if you actually need dynamic allocation, you could consider forcing ownership in a std::shared_ptr (or roll out your own smart pointer with a type-erased deleter), which is capable of fixing the correct destructor at the time of construction (thanks to @CantChooseUsernames for the suggestion).

A: Even if the class is empty.. it still allocates something (1 byte at least)..
https://ideone.com/CpNlNG
#include <iostream>
#include <vector>

void* operator new(std::size_t count)
{
    std::cout<<"Allocated: "<<count<<" bytes\n";
    return malloc(count);
}

class MyVector : public std::vector<int> {};

class Empty {};

int main()
{
    std::vector<int>* obj = new MyVector;
    delete obj;

    Empty* empty = new Empty;
    delete empty;

    return 0;
}

Results:
Allocated: 12 bytes
Allocated: 1 bytes

This is true even with O3 on. If you don't use the empty class though, it of course gets optimized out.


text:
Q: React+JavaScript: How to erase data fields after a successful 200 code from sign up page and redirect to login? Please find my code below for the SignUp react function, once I receive response of 200 after clicking the Sign up button, I want to erase the text in all three fields and redirect the user back to login page. Very new to web development, any help is appreciated!  There are three fields needed to sign up: firstName, email and password.
 export default function SignUp() {
      const [firstName, setFirstName] = React.useState("");
      const [email, setEmail] = React.useState("");
      const [password, setPassword] = React.useState("");

  let sign = async (event) => {
    event.preventDefault();
    await ApiService.createUser(
      firstName,
      email,
      password
    )
      .then((response) => {
        console.log(response.data);
      })
      .catch((error) => console.log(error));
  };

  return (
    <Container component="main" maxWidth="xs">
      <CssBaseline />
      <div className={classes.paper}>
        <Avatar className={classes.avatar}>
          <LockOutlinedIcon />
        </Avatar>
        <Typography component="h1" variant="h5">
          Sign up
        </Typography>
        <form className={classes.form} noValidate>
          <Grid container spacing={2}>
            <Grid item xs={12} sm={6}>
              <TextField
                autoComplete="fname"
                name="firstName"
                variant="outlined"
                required
                fullWidth
                id="firstName"
                label="First Name"
                autoFocus
                onChange={(event) => setFirstName(event.target.value)}
              />
            </Grid>
            <Grid item xs={12}>
              <TextField
                variant="outlined"
                required
                fullWidth
                id="email"
                label="Email Address"
                name="email"
                autoComplete="email"
                onChange={(event) => setEmail(event.target.value)}
              />
            </Grid>
            <Grid item xs={12}>
              <TextField
                variant="outlined"
                required
                fullWidth
                name="password"
                label="Password"
                type="password"
                id="password"
                autoComplete="current-password"
                onChange={(event) => setPassword(event.target.value)}
              />
            </Grid>
          </Grid>
          <Button
            type="submit"
            fullWidth
            variant="contained"
            color="primary"
            className={classes.submit}
            onClick={sign}
          >
            Sign Up
          </Button>

A: First you need to be controlling the values on those elements.  I'm going to assume that TextField has a property called value (otherwise you'll need to find whatever the property should be called).  Something like this:
<TextField
    value={firstName}   // <-- here
    autoComplete="fname"
    name="firstName"
    variant="outlined"
    required
    fullWidth
    id="firstName"
    label="First Name"
    autoFocus
    onChange={(event) => setFirstName(event.target.value)}
  />

Do this with all of your input fields.  That way React will update those fields with the current state any time that changes.  Then you just need to update state after creating the user:
.then((response) => {
    console.log(response.data);
    setFirstName("");
    setEmail("");
    setPassword("");
})

Basically, don't think of it as "updating the fields", but rather separate the management of state from the display of state.  Use the state to drive the display, and update the state as needed.

A: For the redirection part, you need to inform us which router you are using.
For instance, if you are using react-router, you can use useHistory hook as follow:
import { useHistory } from "react-router-dom"

// in your sign function
let history = useHistory()
history.push("/loginPage") // the string '/loginPage' is an example and depend on your routes implementation

react-router doc : https://reacttraining.com/react-router/web/api/Hooks/usehistory
Also, you most probably don't need to erase the text-fields since the redirection will unmount your component.


text:
Q: Freeze header does not allow to click knockout I have the following html snippet

      Surname

      Name

      Business Title

      Organization

And the following View Model:
function CompanyViewModel()
{
  var list=this;
  list.data=ko.observableArray([
                                    new BusinessMen({id:1,name:"john",surname:"doe",title:"Harem Maker",organization:"Harem Ltd"}),
                                    new BusinessMen({id:2,name:"Alan",surname:"doe",title:"CEO",organization:"Harem Ltd"}),
                                    new BusinessMen({id:1,name:"miss",surname:"piggy",title:"Piug Manager",organization:"Pig Ltd"}),
                                    ....
                                    new BusinessMen({id:1,name:"Bill",surname:"Gates",title:"MIcrosoft's Former CEO",organization:"Microsoft Inc"}),
                                  ]);
  list.whatToSort=ko.observable('surname'); //Tell with what to sort the table
  list.ascending=ko.observable(false); //Tell the order to sort
  /**
  *Callback for sorting
  */
  var sortFunc=function(a,b)
  {
    switch(list.whatToSort())
    {
      case 'name':
      a=a.name;
      b=b.name;
      break;
      case 'title':
      a=a.title;
      b=b.title;
      break;
      case 'organization':
      a=a.organization;
      b=b.organization;
      break;
      case 'surname':
      default:
      a=a.surname;
      b=b.surname;
    }

    if(!list.ascending())//Swap if desceding
    {
      var temp=b;
      b=a;
      a=temp;
    }

    if(typeof a ==='undefined' || typeof b === 'undefined') return 0;
    return ( ( a() == b() ) ? 0 : ( ( a() > b() ) ? 1 : -1 ) );
  };

  list.sortSurname=function()
  {
    list.whatToSort('surname');
    list.ascending(!list.ascending());
  };

  list.sortName=function()
  {
    list.whatToSort('name');
    list.ascending(!list.ascending());
  }
  list.sortOrganization=function()
  {
    list.whatToSort('organization');
    list.ascending(!list.ascending());
  }

  list.sortTitle=function()
  {
    list.whatToSort('title');
    list.ascending(!list.ascending());
  }

  /**
  *Sorted Data depending what we select
  */
  list.sorteddata=ko.pureComputed(function()
  {
    return list.data().sort(sortFunc);
  });

  function BusinessMen(data)
  {
    var buinessman=this;
    data.id=parseInt(data.id);
    data.name=ko.observable(data.name);
    data.surname=ko.observable(data.surname);
    data.title=ko.observable(data.title);
    data.organization=ko.observable(data.organization);
  }
}

And finally the binding Handler:
ko.bindingHandlers.fixedHeader={
    update:function(element, valueAccessor, allBindings, viewModel, bindingContext)
    {
     $(element).freezeHeader({offset : '50px'});
    }
};

The code above displays a fixed header on top of a table using freezeheader.js (https://laertejjunior.github.io/freezeheader/) and knockout.js.
The problem is that when I scroll down and the "frozen" header is displayed  I cannot sort the data, particullary when I click on the header to select a sort key then no item is executed and I do not know why does this happen.
Maybe some help please;

A: The Freezeheader library uses a clone of your data bound DOM element to display the sticky header at the top of your viewport. The way it appends this clone to the DOM is:
tabela.append('
' + obj.header.html() + '
');

(source (line 107))
A cloned HTML element might look similar to its original element, but it looses all connection to event listeners or, in your case, the knockout data-bind context.
jQuery's clone method has an option that lets you copy not just the raw HTML, but also any event listeners attached to it. Use it by passing a true argument: element.clone(true) gives you a copy with copied event listeners. (source)
You're not the first Freezeheader user that encountered this problem. Github user Shafranov issued a pull request that replaces the line of code shown below with jQuery's clone(true) approach.
Before you make this change, please make sure you're not breaking any other data-binds. While jQuery might copy the click listener for you, it'll probably not enable knockout to update texts or values at two locations in the DOM from one viewmodel.


text:
Q: need to make an app that after registering a new user in firebase, it sends a message on whastapp I need to develop for android, using react native or native language, whichever is easier, if anyone knows a repository with these functions.
it needs to have a login screen, user registration, customer registration, customer consultation and mainly, send the message to the entire database for whastaap when a new user is registered with some specific fields
it needs to have a login screen, user registration, customer registration, customer consultation and mainly, send the message to the entire database for whastaap when a new user is registered with some specific fields


text:
Q: Fixed div coming down while scrolling in mobile screen - html / css I'm developing a phone-gap application and testing it on 3 android devices. Some codes are:
Main area:

Welcome

Some css:
.banner
{
    width: 100%;
    min-height:40%;
    max-height:40%;
    position:fixed;
    top:0%;
    display:block;
    background-color:#FF0;

}
#now_play_div
{
    white-space:pre-wrap;
    font-size:1.5em;
    position:fixed;
    height:7%;
    display:block;
    background:#FFF;
    width:100%;
    text-align:center;
    top:30%;
    padding-top:1%;
    -webkit-marquee: auto medium infinite scroll normal;
    overflow-x: -webkit-marquee;

    border-radius:10px;

}
.blank_div
{
    width: 100%;
    min-height:41%;
    max-height:41%;
    margin-left:auto;
    margin-right:auto;
    display:block;

}
.footer_div
{

    color:#FFF;
    position:fixed;
    height:10%;
    display:block;
    background:#46639d;
    width:100%;
    text-align:center;
    bottom:0px;
    padding:1%;
}

Now the banner is fixed. blank_div is used so that my main content doesn't go under the fixed banner. After some work the loading image will be gone and filled with some dynamic content. I can scroll that content but my banner and footer is fixed. another_div is fixed too.
This system works perfectly on Sony ericsson(android version:2.3) and symphony(android version:4.0.4). But fails to work properly on Google nexus 7(Android: 4.3) In nexus while I scroll my main content that is dynamically loaded just under the blank_div the banner started to fall down. WEIRD!!!!!! While my contents go up, banner comes down. But in other 2 devices it works just fine. Does anybody know what's wrong?? Or what I'm missing?

A: I guess no more answer will come. So here is the answer which I found from @Era's comment.
.banner
{
    width: 100%;
    min-height:40%;
    max-height:40%;
    position:fixed;
    top:0%;
    left:0%;
    display:block;
    background-color:#FF0;

}


text:
Q: How do I call overloaded static methods from the .net framework in Powershell? Below is a transcript of what I've tried and what happens.
I'm looking for how to call a specific overload along with an explanation of why the following does not work.  If your answer is "you should use this commandlet instead" or "call it twice" please understand when I don't accept your answer.
PS C:\> [System.IO.Path]::Combine("C:\", "foo")
C:\foo
PS C:\> [System.IO.Path]::Combine("C:\", "foo", "bar")
Cannot find an overload for "Combine" and the argument count: "3".
At line:1 char:26
+ [System.IO.Path]::Combine <<<< ("C:\", "foo", "bar")
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

PS C:\> [System.IO.Path]::Combine(, "C:\", "foo", "bar")
Missing ')' in method call.
At line:1 char:27
+ [System.IO.Path]::Combine( <<<< , "C:\", "foo", "bar")
    + CategoryInfo          : ParserError: (CloseParenToken:TokenId) [], Paren
   tContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

PS C:\> [System.IO.Path]::Combine($("C:\", "foo", "bar"))
Cannot find an overload for "Combine" and the argument count: "1".
At line:1 char:26
+ [System.IO.Path]::Combine <<<< ($("C:\", "foo", "bar"))
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

this is what I do in c#, which works:
var foobar = Path.Combine(@"C:\", "foo", "bar");
Console.WriteLine(foobar);

What Powershell will invoke that specific overload?  Path.Combine has both of these:
public static string Combine (string path1, string path2, string path3);
public static string Combine (params string[] paths);

Is it possible to call both of these, or just one?  Obviously, in this specific case, it's difficult to tell the difference.

A: The Path overloads that accept multiple arguments like that are only available in .NET 4 and up. You need to create a config file to tell Powershell to launch using .NET 4, which will give you access to those methods.
Create a file called "powershell.exe.config" in $pshome with the following contents:
<?xml version="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0.30319"/>
        <supportedRuntime version="v2.0.50727"/>
    </startup>
</configuration>

A: To add, issuing the command:
[System.IO.Path]::Combine.OverloadDefinitions

from your shell, you should get the following output:
static string Combine(string path1, string path2)

As you can see, there are no overloads available.
Issue the command:
$PSVersionTable

and look at the CLRVersion - and you will see you are using a version of .net before 4.0, so there are no overloads for Path.Combine available.

A: You need to create a params array in this case and call the Combine method on it.. The params array can be created as follows: @("C:\", "foo", "bar")
I believe event the following as a parameter "C:\,foo,bar" should call the second method.
I am not sure what you are confused about Path.Combine has two overloaded methods one is combinign two strings and the other a parameter array that accepts a bunch of arguments, the second case in powershell is handled differently than c#.
Hope this answers your question..
FYI, I am a powershell noob..


text:
Q: php delete everything before the character I have following mysql php array result.
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo '
';
echo " {$row['cust']} 	".
     " {$row['manu']} 	".
     " {$row['model']} 	".
     " {$row['serial']} 	".
     " {$row['capacity']} 	".
     " {$row['firmware']} 	".
     " {$row['deviceid']} 	".
     " {$row['ataver']} 	".
     " {$row['ltime']} 	".
     " {$row['date']} 	".
     " {$row['ourref']} 	".
     " {$row['result']} 	";

/**                     foreach($row as $key=>$value) {
                                echo '',$value,'	';
                        }*/
                        echo '
';

" {$row['capacity']} 	". array holds information like
250000000000 bytes [250 GB]
400000000000 bytes [400 GB]
500000000000 bytes [500 GB]

I want to delete everything including bytes.
So the desired output would look like
250 GB
400 GB
500 GB

How can i achieve this using above code?
Thanks well in advance.

A: It's quite simple, look here :
$String = "250000000000 bytes [250 GB]";

$String2 = substr($String, 0, 3); // take the first 3 caracteres

$result = $String2." GB"; // Just add GB after
echo $result;

Just replace " {$row['capacity']} 	". with the fallowing
   "".substr($String, 0, 3)." GB	".

A: You can use regular expressions to achieve this:
preg_match('/\[(.*?)\]/', $row['capacity'], $matches);
if (isset($matches[1])) {
    $row['capacity'] = $matches[1];
}
echo " {$row['capacity']} 	";

A: There are many ways to do this, I'd use a regex to capture everything inbetween the brackets.
$string = '250000000000 bytes [250 GB]
400000000000 bytes [400 GB]
500000000000 bytes [500 GB]';
preg_match_all('~\[(.*?)\]~', $string, $sizes);
print_r($sizes[1]);

Output:
Array
(
    [0] => 250 GB
    [1] => 400 GB
    [2] => 500 GB
)

Regex101 Demo: https://regex101.com/r/zR6pU1/1
The . is any character, the * is zero or more occurrences of any character and the ? stops at the first occurrence of the next character. The + might be a better quantifier so that you are sure that there is something in there. The + is one or more occurrences.
With the + quantifier,
$string = '250000000000 bytes [250 GB]
400000000000 bytes [400 GB]
500000000000 bytes [500 GB]';
preg_match_all('~\[(.+?)\]~', $string, $sizes);
print_r($sizes[1]);

If you wanted to be stricter you could even do:
$string = '250000000000 bytes [250 GB]
400000000000 bytes [400 GB]
500000000000 bytes [500 GB]';
preg_match_all('~\[(\d+ [MKG]B)\]~', $string, $sizes);
print_r($sizes[1]);

Which would match any numbers a space and then KB, MB, or GB. The [] is a character class allowing any of the literal characters inside to be present.

A: You can use:
$str = preg_replace('[[:digit:]]+ Bytes ', "", $str);

https://regex101.com/r/fE7nO5/1
Then str_replace to replace the [] characters.
$str = str_replace('[', ' ', $str);
$str = str_replace(']', ' ', $str);
$str = trim($str);

Edit:
You can also do it with one regex:
$str = preg_replace('[[:digit:]]+ Bytes |\[|\]', "", $str);

https://regex101.com/r/fE7nO5/2


text:
Q: Connectedness criterion for elliptic curve given $j$-invariant
Given an elliptic curve $E$ over a field $k$ with $j$-invariant $j$, what is the criterion on $j$ for $E$ to be connected?

I know that when an elliptic curve is in Wierstrass form $y^2=x^3+px+q$, it is connected if and only if the discriminant of the cubic in $x$ has a negative discriminant.
We have a formula for the $j$-invariant of $E$ as follows:
$$j=1728 \frac{4p^3}{4p^3+27q^2}=1728\frac{4p^3}{-\Delta}$$
So given $j$ and $p$ we can deduce whether or not it is connected. However I imagine that the choice of $p$ should not really matter as contentedness should really only depend on $j$. I therefore tried to express the $j$ invariant for the Legendre form:
$$j=256\frac{(\lambda^2-\lambda + 1)^3}{\lambda^2(\lambda - 1)^2}$$
This should give me at most $6$ choices of $\lambda$. Solving this generally however is a non-trivial task. And then converting this into Weirstrass form is not too easy, I will get a very disgusting expression for $p$.
The only reference for connectedness of $E$ I could find was in terms of the discriminant of the polynomial of the Weirstrass form. Is there a more algebro-geometric criterion for knowing connectedness?
I imagine for curves over $\Bbb C$ something like the betti homology would give the correct answer but I can't see how you can know it just from $j$.

A: Let us work over $\Bbb R$, as that is where connectedness is interesting.
Consider $$j-1728=1728\frac{-27q^2}{-\Delta}.$$
This shares the sign of $\Delta$. So if $j<1728$ then $E$ is connected,
and if $j>1728$ is is not connected. The $j=1728$ case is CM by $\Bbb Z[i]$, and considering $y^2=x^3-x$ and $y^2=x^3+x$ we see that $E$ may
or not be connected.


text:
Q: Get my own IP address If I use getHostByName() I only get "127.0.0.1", because it is written on /etc/host, but this is not useful to me.
However, with the following java code I actually get what I want:
NetworkInterface.getByName(("eth0")).getInetAddresses().nextElement().getHostAddress()

I think that there is a way to get the same ip address also from C?

A: Check out getifaddrs.

A: That indicates the notorious Linux /etc/hosts misconfiguration problem. The hosts file should map 127.0.0.1 to localhost, and your real IP address to your real hostname.


text:
Q: setContentView() inside of a thread I'm making a simple Android game written in Java.
I have my activity...
public class GameName extends Activity{
...
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

Inside the "main" layout I have a button that calls a method called "startTheGame":
public void startTheGame(View v) {
theGame = new Panel(this);
    setContentView(theGame);
}

Here is the panel code (simplified)
class Panel extends SurfaceView implements SurfaceHolder.Callback {
  public GameThread _thread;
    public Panel(Context context) {
      super(context);
      getHolder().addCallback(this);
      setFocusable(true);
    }
  ...
    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        _thread = new GameThread(getHolder(), this);
        _thread.setRunning(true);
        _thread.start();
    }
 ...
 }

So as you can see I have a "GameThread" class that is started... here it is below:
class GameThread extends Thread {
    private SurfaceHolder _surfaceHolder;
    private Panel _panel;
    private boolean _run = false;

    public GameThread(SurfaceHolder surfaceHolder, Panel panel) {
        _surfaceHolder = surfaceHolder;
        _panel = panel;
    }

    public void setRunning(boolean run) {
        _run = run;
    }
            @Override
    public void run() {
        Canvas c;
        while (_run) {
            c = null;

            try {
                    ...

                    if (health <= 0) {
                        _run = false;

                        //change views?
                        setContentView(R.layout.over);

                    }

                    c = _surfaceHolder.lockCanvas(null);
                    synchronized (_surfaceHolder) {
                        _panel.onDraw(c);
                    }

                    ...

                } finally {
                    // do this in a finally so that if an exception is
                    // thrown
                    // during the above, we don't leave the Surface in an
                    // inconsistent state
                    if (c != null) {
                        _surfaceHolder.unlockCanvasAndPost(c);
                    }
                    try {
                        Thread.sleep(60);
                    } catch (Exception e) {
                    }
                }

            }

        }

Hopefully you can see that if the health is <= 0  it stops the thread and I am trying to change to another layout I created called "over".
It just stops the screen from updating (drawing) but I never see the new panel.
I've tried:
GameName cs = ((GameName)getApplicationContext())
cs.setContentView(R.layout.over);

But I'm getting a ClassCastException...
Please Help!

A: I'd recommend looking into using Handlers. It allows you to safely communicate with the UI thread without worrying which thread you're currently on.

A: You cannot cast your ApplicationContext to your main Activity (GameName) because this is not the same object. In a certain way, getApplicationContext() does not correspond to the first lauched Activity but to the app itself.
To me you should try to have distinct activities instead of trying to change the layout and the behaviour of a single Activity. It would be more simple for you and it would avoid the kind of issues you are facing.
Actually, each setContentView() I see in the code should correspond to a switch.
This way, you would have something like:

*

*WelcomeActivity (probably GameName here): select the options of the game and start

*PlayingActivity: the game itself. This is where the actual gameplay is.

*GameOverActivity: displays the score, or anything you would like to show once the game ended

This without knowing which kind of game you are doing, but this skeleton should work well with arcade/action, roleplay/adventure or even maze/god-games.


text:
Q: How to read ppt template and edit it according our need in ReactJS In ReactJS we have one ppt template which we will download on frontend side. How to find the specific slide and replace/insert texts?

A: Following are some links that might help you :
https://www.npmjs.com/package/react-pptx
https://codesandbox.io/examples/package/react-pptx


text:
Q: Maximal ideal of group ring Let $R$ be a finite commutative ring with identity and $G$ an finite abelian group. Is there any more conditions (on $R$ or on $G $) under which we can characterize maximal ideals of group ring $RG $, with maximal ideal of $R$ (the same as the relation between maximal ideals of $R$ and $R [[X]]$)?

A: UPDATE: the question has been changed to say that both $R$ and $G$ are finite, so I have modified my answer accordingly.
Any maximal ideal in $R[G]$ contains the ideal $\text{Nil}(R)$ of nilpotent elements in $R$, and it is standard in this context that $R/\text{Nil}(R)$ is a finite product of finite fields, so we can assume that $R$ itself is a finite field, and of course these are well-understood.
Given a maximal ideal $M<R[G]$, put $H_M=\ker(G\to(R[G]/M)^\times)$.  Recall that any finite subgroup of the multiplicative group of a field is cyclic, so the quotient $C_M=G/H_M$ is cyclic, of order $d$ say.  Now $M$ corresponds to a maximal ideal in
$$ R[C_M]\simeq R[u]/(u^d-1) = R[u]/\prod_{e|d}\varphi_e(u). $$
However, by construction $C_M$ embeds in $R[G]/M$, so $u^e-1$ cannot go to zero for any $e<d$, so we really have a maximal ideal in $R[u]/\varphi_d(u)$.  As $\varphi_d(x)$ and $\varphi'_d(x)$ are coprime, the ring $R[u]/\varphi_d(u)$ is reduced, and so is a finite product of finite field extensions of $R$.


text:
Q: Riemann integrable proof Let $f:[-1,1]$ be Riemann integrable and $\psi(x)=x\ sin(\frac{1}{x})$ for $0<x\leq1$ and $\psi(0)=0$.  Show that $x\mapsto f(\psi(x))$ is Riemann integrable over $[0,1]$.
Also, just curious ... does the same conclusion hold if $\psi$ is changed to $\psi(x)=\sqrt{x}\ sin(\frac{1}{x})$ for $x>0$?
Appreciated for all the help!

A: The answer to both your questions is YES, and richard's comment
shows the way. To expand on this comment : by Lebesgue's criterion
for Riemann integrability, the answer to your question will be YES
whenever $\psi$ has the following property :
$(P_1) \ \psi^{-1}(N) \text{ stays null for any null set } N$
It is easy to see that $(P_1)$ holds whenever
$(P_2) \ \psi \ \text{is a diffeomorphism}$
(in that case, $\psi^{-1}$ is Lipschitz and it is well-known
and easy that the image of a null set by a Lipschitz function is
again a null set)
From this, one sees that $(P_1)$ will also hold whenever
$(P'_2) \text{There is a sequence }
1=a_1 \gt a_2 \gt a_3 \ldots \gt a_n \gt \ldots \gt 0 \ \text{such that}\ \psi
\text{ is a diffeomorphism on each} \ [a_k,a_{k+1}] $
Both your functions $\psi$ have this last property.


text:
Q: Getting industry from Yahoo.Finance for list of stock ticker How can I (preferably using R) get the industry classification for a list of stock tickers from Yahoo.Finance, Google Finance or anything else.
To illustrate, I have a list of tickers, such as
ticker_industy <- data.frame(ticker=ticker_list,industry=rep(NA,length(ticker_list)
head(ticker_industry)
    ticker industry
1      BDX       NA
2      BLL       NA
3       CB       NA
4     CELG       NA
5      CHK       NA
6       CI       NA

Preferably, R fetches the corresponding industry for each ticker.

A: This function should do the work for you...
industry=function(ticker)
{
  url=paste("https://in.finance.yahoo.com/q/in?s=",ticker,sep=',')
  mydata=as.data.frame(readLines(url))
  names(mydata)="text"
  ind=str_match(as.character(mydata$text[117]),'(?:<b>Industry: ?)(.*?)(?:<)')[,2]
  ind=str_replace_all(ind,'&','&')
  return(ind)
}


text:
Q: Is there an easy way to route an entire controller to a site root? I know how to route a page to a site root, and how to individually specify routes for every single page and action, but I feel like I am creating unnecessary work for myself at times by doing this. Is it possible to make it so that example.com/method always equates to some_controller#method?
Something like:
root "some_controller#index"
controller :some_controller do
    get "/:method" => :method
end

instead of
root "some_controller#index"
controller :some_controller do
    get "/" => :index, as: :index
    get "/contact" => :contact, as: :contact
    get "/photos" => :photos, as: :photos
    ...
end

or is that the best way?

A: You're pretty close already:
controller :some_controller do
  get ":controller/:action"
end

:controller/:action will dynamically match the :action segment to a method of that name on the controller referenced by the symbol passed to the controller method.
I would be careful about security here. Take note on what methods your controller inherits from its parent class (probably ApplicationController), as any public methods will be accessible using this routing style.


text:
Q: How to evenly distribute squares in a rectangular area? i need to figure out how can i add given number of squares in a rectangle
i want to create this.
 http://i.stack.imgur.com/MHoda.jpg
The whole scenario is to create a function that take a number and then create a layout of it, for a quick reference i did this with predefined values for rows, columns, x&y scale etc.
The size of the rectangle is fixed and it will always be something predefined, everything else need to be calculated with these values.
Can anybody help me please??

A: The first step is to figure out how many rows $R$ and columns $C$ you want.  If you want N squares, you need $R*C\ge N$.  If you are given the dimensions of the rectangle, say w is the ratio of the width $W$ to the height $H$(presumed $\ge 1$).  Then you probably want $C/R$ to be about this, so $R^2w \ge N$  Now you can round up to get $R$ and divide and round up to get $C$.
To get the coordinates of each square of side $s$, there is some space $t$ between the squares.  So $Cs+(C-1)t\le W$ and $Rs+(R-1)t\le H$ and you lay them out starting at (0,0) if that is top left in increments of $s+t$
Added:  for 34 tiles in 600 wide by 200 high, you can either have a 4x10 or 3x12 layout (with some blanks like you showed in the original question).  If we take the 4x10 option, then you can have, for example, the tiles 45 high, which uses up 180 of the 200.  This leaves 20 units to divide by 3, so the gaps would be 6. But going the other way, 10 tiles would use 450, leaving 50 to divide by 9, so the gaps could only be 5.  Then the top left tile is at (0,0), the next one down is at (50,0), the next at (100,0) and the last at (150,0) with its bottom at 195.  In width they go 0, 50, 100, 150,...450 with the right edge at 495.  Is that what you were looking for?


text:
Q: Runsettings file in Visual Studio 2019 not including everything by default I am expecting runsetting file to include all files for code coverage and I should be able to exclude whatever files I don't need for code coverage. When I refer to the .runsettings while analyzing the code coverage, it's showing 0 coverage % and also no file listed in report.
Example file: actually below I want to exclude test projects & migration folder in API rest include for coverage. Any suggestion how to resolve it?.
<!-- Match assembly file paths: -->
<ModulePaths>
    <!-- <Include>
        <ModulePath>.*\.dll$</ModulePath>
        <ModulePath>.*\.exe$</ModulePath>
    </Include>-->
    <Exclude>
        <ModulePath>.*CPPUnitTestFramework.*</ModulePath>
    </Exclude>
    <!-- Specifies additional list of directories where binaries static native instrumentation should be searched. -->
    <IncludeDirectories>
        <Directory Recursive="true">C:\b59fb11c-1611-4562-9a2b-c35719da65d3</Directory>
    </IncludeDirectories>
</ModulePaths>
<!-- Match fully qualified names of functions: -->
<!-- (Use "\." to delimit namespaces in C# or Visual Basic, "::" in C++.)  -->
<Functions>
    <Include>
        <!--<Function>^AbcService.Api\.Controllers\..*</Function>
        <Function>^AbcService.Api\.Service\..*</Function>
        <Function>^AbcService.Data\.Repositories\..*</Function>
        <Function>^AbcService.Logic\..*</Function>-->
    </Include>
    <Exclude>
        <Function>^AbcService.Test\..*</Function>
        <!--
        <Function>^Microsoft::VisualStudio::CppCodeCoverageFramework::.*</Function>
        <Function>^Microsoft::VisualStudio::CppUnitTestFramework::.*</Function>-->
    </Exclude>
</Functions>


text:
Q: Regular expression to strip everything but words I'm helpless on regular expressions so please help me on this problem.
Basically I am downloading web pages and rss feeds and want to strip everything except plain words. No periods, commas, if, ands, and buts. Literally I have a list of the most common words used in English and I also want to strip those too but I think I know how to do that and don't need a regular expression because it would be really way to long.
How do I strip everything from a chunk of text except words that are delimited by spaces? Everything else goes in the trash.
This works quite well thanks to Pavel .split(/[^[:alpha:]]/).uniq!

A: I think that what fits you best would be splitting of the string into words.  In this case, String::split function would be the better option.  It accepts a regexp that matches substrings, which should split the source string into array elements.
In your case, it should be "some non-alphabetic characters".  Alphabetic character class is denoted by [:alpha:].   So, here's the example of what you need:
irb(main):001:0> "asd, < er >w , we., wZr,fq.".split(/[^[:alpha:]]+/)
=> ["asd", "er", "w", "we", "wZr", "fq"]

You may further filter the result by intersecting the resultant array with array that contains only English words:
irb(main):001:0> ["asd", "er", "w", "we", "wZr", "fq"] & ["we","you","me"]
=> ["we"]

A: try \b\w*\b to match whole words


text:
Q: ListView CellFactory - How to remove cells correctly? I have a ListView that I am working to add a ContextMenu to. I have the ContextMenu working find but have another issue.
My setCellFactory code, used to setup the context menus:
lvAppetites.setCellFactory(lv -> {
    ListCell<Appetite> cell = new ListCell<>();
    ContextMenu contextMenu = new ContextMenu();

    MenuItem editAppetiteMenu = new MenuItem();

    editAppetiteMenu.textProperty().bind(Bindings.format("Edit ..."));
    editAppetiteMenu.setOnAction(event -> {
        // Code to load the editor window
        editAppetite(cell.getItem());
    });
    contextMenu.getItems().add(editAppetiteMenu);

    MenuItem deleteAppetiteMenu = new MenuItem();
    deleteAppetiteMenu.textProperty().bind(Bindings.format("Delete ..."));
    deleteAppetiteMenu.setOnAction(event -> {
        // Code to delete the appetite
    });
    contextMenu.getItems().add(deleteAppetiteMenu);

    contextMenu.getItems().add(new SeparatorMenuItem());

    MenuItem addAppetiteMenu = new MenuItem();
    addAppetiteMenu.textProperty().bind(Bindings.format("Add New ..."));
    addAppetiteMenu.setOnAction(event -> {
        // Code to delete the appetite
    });
    contextMenu.getItems().add(addAppetiteMenu);

    cell.textProperty().bind(cell.itemProperty().asString());

    // If nothing selected, remove the context menu
    cell.emptyProperty().addListener((obs, wasEmpty, isNowEmpty) -> {
        if (isNowEmpty) {
            cell.setContextMenu(null);
        } else {
            cell.setContextMenu(contextMenu);
        }
    });
    return cell;
});

My ListView is searchable through a TextField with a listener; the listener filters the items in the ListView as the user types.
The problem now, is that as the list is filtered, any empty cells now display null.
From reading another question, I'm fairly confident that the ListView is still displaying a graphic for the removed cells.  I know how to handle that within the ListView by overriding the updateItem method, but how would I handle this from within my setCellFactory method instead?
Is that even possible or will I need to refactor my entire ListView?
Thank you, as always, for all your help!

A: The problem arises from the line
cell.textProperty().bind(cell.itemProperty().asString());

When the cell is empty, the item will be null, so the binding will (I believe) evaluate to the string "null".
Try something that tests for the cell being empty or the item being null, e.g.
cell.textProperty().bind(Bindings
    .when(cell.emptyProperty())
    .then("")
    .otherwise(cell.itemProperty().asString()));

or (thanks to @fabian for refining this version)
cell.textProperty().bind(Bindings.createStringBinding(
    () -> Objects.toString(cell.getItem(), ""),
    cell.itemProperty()));


text:
Q: Variance of linear regression estimator Since $\hat{Y}$ is an estimator and given as a linear combination of estimators $\hat{\beta_0}$ and $\hat{\beta_1}$ and X can be treated as a constant in simple linear regression,  is it correct that: $Var(\hat{Y}) = Var(\hat{\beta_0}+\hat{\beta_1}X)=
Var(\hat{\beta_0})+X^2Var(\hat{\beta_1})+2XCov(\hat{\beta_0},\hat{\beta_1})$
-I see many books on Linear Regression talk of the variance of $\hat{Y}$ in the bias-variance discussion, but few texts describe the calculations of these terms.


text:
Q: Downloaded package ImportError I have recently installed python 2.17.14 to use a package which I installed in the command prompt with:
python -m pip install packageName

However, whenever I try to use it with a script provided by the package authors, I get Import Errors:
ImportError: cannot import X from YX
ImportError: attempted relative import with no known parent package.

I don't know what I'm doing wrong, as I am really new to Python. Does anyone have any ideas?
The package is called neurodesign and I downloaded the try out script from the official website "neuropowertools.org"
Best,
Max

A: In case anyone (who is also new to python^^) fails ridiculously at this task as well: I had to manually install all the modules used within this package for it to work as they weren't installed automatically.


text:
Q: Managing project Clearcase Language : Java
IDE :Eclipse
CVS (version control system)
ClearCase (Development & Integration Streams)
We have recently completed our project.
Now, we have two different clients and has to manage the existing project to cater their needs.
We are thinking of creating three integration streams
one forexisting client support
one for client 2
one for client 3
..
However we are unsure of how do we manage the Project in CVS.
Though braching in CVS is an option .However we are dreading  the brach -> root merging issues as the file system will be common  in all the branches and different developers can work on the same file in different branches.
Could you please suggest how do go about this scenario?.
Thanks.

A: Integration  streams are a good option with ClearCase because you can deliver between them, and you can rebase any baseline on them (not just a baseline from the parent stream=
You could then follow the page "Working with CVS and Clearcase", and use ClearCase for those merge, before mirroring the result of those merge back in CVS.


text:
Q: how to add imageview and button in pageradapter I have pager adapter and I used imageview to show in pager but I also want to shoe image and button on pager ...how to implement that please help me out. I am new to android...
my pager class code is below:
public class FullScreenImageActivity extends Activity {
private static int NUM_VIEWS = 5;

private MyPagerAdapter adapter;
private ViewPager pager;
int gotbiscuit;
public String TAG = "hello";

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fullscreen_view);

    Intent i = getIntent();
    int gotbiscuit = i.getExtras().getInt("position");

    adapter = new MyPagerAdapter(this);
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);

}

public class MyPagerAdapter extends PagerAdapter {
    public Integer[] images1 = { R.drawable.i_3, R.drawable.i_4,
            R.drawable.i_6 };
    public Integer[] images2 = { R.drawable.i_8, R.drawable.i_9,
            R.drawable.i_10 };

    public Context mContext;

    public MyPagerAdapter(Context context) {
        super();
        this.mContext = context;
        // TODO Auto-generated constructor stub
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return images1.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        // TODO Auto-generated method stub
        return view == ((ImageView) object);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object view) {
        // TODO Auto-generated method stub
        ((ViewPager) container).removeView((ImageView) view);
    }

    @SuppressWarnings("deprecation")
    @SuppressLint("NewApi")
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        // TODO Auto-generated method stub

        ImageView view1 = new ImageView(FullScreenImageActivity.this);

        view1.setScaleType(ScaleType.CENTER_CROP);

        switch (gotbiscuit) {

        case 0:
            view1.setImageResource(images1[position]);
            break;
        case 1:
            view1.setImageResource(images2[position]);
            break;
        }
        view1.setAdjustViewBounds(true);

        ((ViewPager) container).addView(view1, 0);

        return view1;

    }
}

}

A: *

*inflate a xml resource with parentlayout and inside the image and button or

*dynamic create parentlayout (f.e. linear layout) and addView(image) and (button)

inflating:
    LayoutInflater inflater = LayoutInflater.from(container.getContext());
    View view = inflater.inflate(R.layout.pager,null);
    ((ViewPager) container).addView(view,0);
    return view;


text:
Q: Why is box shadow fade out not working in this case? I have the following example :
HTML

CSS
$height: 28px;
$padding-top: 2px;
$padding-left: 10px;

.progress {
  position: relative;
  display: block;
  height: $height;
}
  .border-right {
    position: absolute;
    right: 0px;
    left: 30px;
    top: 0px;
    height: $height;
  }

  .bar-base {
    position: absolute;
    top: $padding-top;
    bottom: $padding-top;
    left: $padding-left;
    right: $padding-left;
    height: ($height - $padding-top*5);
    border-radius:10px;
    box-shadow:
        0 0 0 1px blue,
        0 0 0 2px blue,
        0 0 0 3px blue,
        0 0 0 4px blue,
        0 0 0 5px #FFFFFF40;
    background: linear-gradient(to right,#BF0882  10%, white 80%);
    width: 200px;
    height: 20px;
  }

https://jsfiddle.net/zlobul/yrm7fLzs/20/
I don't understand why the fade out is working on the div element and not on the shadow box ( blue border) ?
How can I fade out the shadow box too ( blue border from left ( blue ) to the right ( white )  ?

A: Edit
Glad you could clarify your question. To achieve that you can use techniques listed in this  stackoverflow question or in the css-tricks website.

.progress {
  position: relative;
  display: block;
  height: 28px;
}

.border-right {
  position: absolute;
  right: 0px;
  left: 30px;
  top: 0px;
  height: 28px;
}

.bar-base {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 10px;
  right: 10px;
  height: 18px;
  border-radius: 10px;
  background: linear-gradient(to right, #BF0882 10%, white 80%);
  width: 200px;
  height: 20px;
}

.bar-base::before {
  content: '';
  position: absolute;
  inset: -10px; /* this is important */
  z-index: -1;
  border-radius: 17px;
  background: linear-gradient(to right, blue 10%, white 90%);
}

Old answer
If by "fade" you mean the multiple box-shadows in the .bar-base then the code is working correctly. You just can't see it well.
The last shadow in box-shadow has the spread only 1px longer than the others, it's just too hard to see it, also, it is white.
Here's the result if you increase it to 10px and make it blue.

.progress {
  position: relative;
  display: block;
  height: 28px;
}
  .border-right {
    position: absolute;
    right: 0px;
    left: 30px;
    top: 0px;
    height: 28px;
  }

  .bar-base {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 10px;
    right: 10px;
    height: 18px;
    border-radius:10px;
    box-shadow:
        0 0 0 1px blue,
        0 0 0 2px blue,
        0 0 0 3px blue,
        0 0 0 4px blue,
        0 0 0 10px rgba(0, 0, 255, .5);
    background: linear-gradient(to right,#BF0882  10%, white 80%);
    width: 200px;
    height: 20px;
  }

Converted computed SCSS to CSS.


text:
Q: What is prototype in Typescript? In lib.d.ts we can find the following piece of code:
interface Error {
    name: string;
    message: string;
}

interface ErrorConstructor {
    new (message?: string): Error;
    (message?: string): Error;
    prototype: Error;
}

declare var Error: ErrorConstructor;

What is the significance of the prototype property on ErrorConstructor?

A: There is no special significance of a prototype property in TypeScript beyond the normal special significance of the prototype property of JavaScript constructors.
In this code, the prototype property of the ErrorConstructor type/interface is set to ensure that any code that accesses ErrorConstructor.prototype directly will get the correct typing information for that property.
In contrast, the new signature of ErrorConstructor defines what the type of an object created with a new call will be. The new return value of a constructor and the prototype of the constructor are nominally the same types, but JavaScript allows constructors to return values that are not of their own type, so the distinction is necessary for correct typing of all possible JavaScript code.


text:
Q: Constructing a Linear Binary Code I have been reading about residual codes, and showing how to improve upper bounds on the number of codewords for certain types of codes. I've come across one problem that I am having trouble with.
It starts with showing that $B_2(13, 6) \leq 2^4$ by using redisual codes, where $B_2(13, 6)$ is the number of binary linear codewords of length $13$ with a minimum distance of $6$.
Then, it asks to construct a linear binary code that meets this bound.
I am able to show $B_2(13, 6) \leq 2^4$, but I'm having trouble constructing such a code that meets this bound. Can anyone help with this construction? Thanks in advance.

A: Thanks to Dilip in the comments, I was able to come up with a solution. I figured I would post a solution for anyone else interested in the problem.
As mentioned above, consider the first-order binary Reed-Muller code, $\mathcal{R}(1, 4)$. This is a $[2^4, 4+1, 2^{4-1}] = [16, 5, 8]$ code. Then, shorten this code by deleting the over-all parity check bit and taking only the remaining codewords of even weight. By doing this, we we are then left with a $[15, 4, 8]$ (which can be verified by looking at the generator matrix for $\mathcal{R}(1, 4)$).
Now, further shorten this code by deleting a nonzero coordinate. We will be left with a $[14, 4, 7]$ code. By shortening the $[14, 4, 7]$ code by deleting another nonzero coordinate, we will get a $[13, 4, 6]$ code.


text:
Q: how can I color-scrolling in heatmap.2 how can I do color-scrolling for the Color-Key in heat map.2 ?
I mean I want to show the blue-area only.

heatmap.2(mat, Rowv = F, Colv = F, dendrogram = "none", trace = "none",
          col = bluered(100), key = TRUE, key.xlab = "", key.ylab = "")

A: The question here is a bit unclear. It seems like you are asking about how to edit the dendrogram. There should be a reorder parameter that you can edit to get the effect you would want.Link to heatmap.2 function from gplots package


text:
Q: Python - '' string values I have about 1500 rows with no values for a column data that shows up when I run the code below:
df.loc[df['data'] == '']

How do I drop these 1500 rows?
I tried the code below:
df1 = df[df['data'].notna()]
df1

However, this does not seem to work as '' is not a null value by the looks of it.
Thanks in advance.

A: You should first replace empty values rows by nan and the drop these rows.
df['data' ] .replace("", nan_value, inplace=True)

df.dropna(subset = ["data"], inplace=True)


text:
Q: Picture inside .jar file wont work when I export it Picture inside .jar file wont work when I export it.
I made a Java program that displays a picture, and it works perfectly in Eclipse, but when I export it to a .jar file, it wont display the picture. I just started learning Java, and I have no experience with creating Jar files and using files from inside the jar file.
Heres my code:
import javax.swing.*;
class displayPicture{
public static void main(String args[]){

    JFrame frame = new JFrame();
    ImageIcon icon = new ImageIcon("src/img.gif");
    JLabel label = new JLabel(icon);

    //Create the frame
    frame.add(label);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);

}
}

It shows the picture when I run it in Eclipse, but when I export it to a .jar file, it just shows a blank window.

A: Two things...
First
The path src is unlikely to exist once the code is build
Second
ImageIcon(String) assumes the String reference is a reference to a file on the file system.  Resources stored within the context of the application are not files and are treated differently.  They are commonly known as embedded resources.
Instead, try using ImageIcon icon = new ImageIcon(displayPicture.class.getResource("img.gif")); or ImageIcon icon = new ImageIcon(displayPicture.class.getResource("/img.gif"));
I prefer to use ImageIO.read as it throws an IOException when something goes wrong and supports more file formats.
See Reading/Loading an Image for more details.
You should also take the time to have a read through Code Conventions for the Java Programming Language and Initial Threads


text:
Q: Generate classes on module import in JavaScript in browser or Node.js I'm building a client for a home-grown Node.js like backend and I'd like to support dynamic client-side JavaScript class generation. This can happen before or after Webpack but I'd prefer after (if that's doable).
In the end I'm trying to make something like this work:
import {TicTacToeGame} from 'warpdrive-client';
And have TicTacToeGame evaluate to be:
class TicTacToeGame { ... }
Except TicTacToeGame is generated by the import call or the global code in warpdrive-client based on supplied configuration or (if it's possible) an argument passed to the module at import time.
Thanks in advance.


text:
Q: How to install fedora 12 iso file? i downloaded Fedora 12 iso file. how can i create a bookable disc from an iso file and install
Please suggest me how to install Fedora 12 in a machine ?

A: Well on windows, you can use imageburn to burn the iso into a cd. If you have linux, brasero and k3b do the same thing. remember that you want a cd with the iso contents, not a cd with the iso in it.
Alternately assuming you have a USB key and the image is of a livecd, you can use unetbootin or rufus to make a bootable usb to do the install
Oh, and for god's sake, RTFA. I believe fedora should have a guide on how to install it.

A: Try using a Fedora-specific tool for creating live USB drives - Fedora Media Writer (Windows/Mac/Linux). Fedora Media Writer (formerly Fedora Live USB Creator) is a free and opensource tool for easily installing live operating systems onto USB flash drives.
Features

*

*Cross-platform (available for Windows, Mac and Linux)

*There is no need to deal with formatting or partitioning your USB flash drive.

*Automatically detects all removable devices

*Supports automatically downloading various Fedora releases

*Persistent storage creation, to save all documents created and modifications made to the system

*Checksum verification

*Not limited to Fedora releases, supports custom images


text:
Q: Number Abbreviated as "No." followed by a Colon As I understand it, the preferred abbreviation for Number is "No."
If we want to then follow that abbreviation with a colon, like in a form for instance, what does style dictate we do?
Is it:

*

*"No.: 0123456789" (i.e. we preserve the period and add a colon) or;

*"No: 0123456789" (i.e. we remove the period and add a colon) or;

*"No. 0123456789" (i.e. we preserve the period and do not add a colon)
Is there a strict rule one should follow in this scenario?
Which is preferred stylistically?
Does the convention vary between British and American English?
Clarification
It's worth mentioning that I'm interested in how this applies to lists of data that use the following format:

First Name: John
Last Name: Doe
ID No.: 0123456789
ID No: 01223465798
ID No. 0123456789
...

A: Don't abbreviate. Abbreviations are not standardized and don't scale to a worldwide audience. Be explicit in order to be understood.
Just write:

First Name: John
Last Name: Doe
ID Number: 0123456789

Same with acronyms. Don't write "CIA" and assume people will read "Central Intelligence Agency" because CIA also means "Culinary Institute of America" and thousands of other things. So you want to write "Central Intelligence Agency (CIA)" the first time and then "CIA" after that.