text:
Q: Notification is not opening Activity onClick I have AlarmNotification in my app and everytime it appeared I want to click on it and open parent Activity/wakeup app from background. Why it doesnt work? It will show notification in certain time so alarm part is working as intended, but It will not do any action on click.
First I have to create notification:
private fun createNotification(){
        val vibrateFreq = longArrayOf(1000, 1000, 1000, 1000, 1000)
        nb = NotificationCompat.Builder(a, channelId)
            .setSmallIcon(R.drawable.logo)
            .setContentTitle(title)
            .setContentText(text)
            .setVibrate(vibrateFreq)
            .setStyle(NotificationCompat.BigTextStyle().bigText(textLong))
            .setAutoCancel(true)
    }

Then I need to register Alarm to show notification in certain time:
private fun createAlarm(){
        val pInt = app.createAlarmPendingIntent(a, nb)
        val cal = Calendar.getInstance()
        cal.add(Calendar.MINUTE, delta)
        app.aManager.set(AlarmManager.RTC_WAKEUP, cal.timeInMillis, pInt)
    }

fun createAlarmPendingIntent(a: Activity, nb: NotificationCompat.Builder?): PendingIntent{
        val nInt = Intent(a, AlarmReceiver::class.java)
        nInt.putExtra(
            AlarmReceiver.NOTIFICATION_ID,
            AlarmNotification.NOTIFICATION_NAME
        )
        nInt.putExtra(AlarmReceiver.NOTIFICATION, nb?.build())

        val pInt = PendingIntent.getBroadcast(
            a,
            0,
            nInt,
            PendingIntent.FLAG_UPDATE_CURRENT
        )
        return pInt
    }

Then It will trigger BroadcastReceiver to open Notification:
class AlarmReceiver: BroadcastReceiver(){

    companion object{
        const val NOTIFICATION_ID = "20288855447-99899"
        const val NOTIFICATION = "alarmNotify"
    }

    override fun onReceive(context: Context?, intent: Intent?) {
        val notificationManager = context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

        val notification: Notification? = intent?.getParcelableExtra(NOTIFICATION)
        val id = intent?.getIntExtra(NOTIFICATION_ID, 0)
        id?.let {
            notificationManager.notify(id, notification)
        }
    }
}

A: First you need to declare an Intent like:
Intent notificationClickIntent = new Intent("intent_id")

Then you need to declare a Pending Intent like this:
PendingIntent pendingIntent = PendingIntent.getActivity(context, REQUEST_CODE, notificationClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);

In your notification builder add set contentIntent:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
                .setSmallIcon(R.drawable.ic_notification)
                .setContentTitle(notificationData.getTitle())
                .setContentText(notificationData.getBody())
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                **.setContentIntent(notificationClickPendingIntent)**
                .addAction(R.drawable.ic_notification, context.getString(R.string.turn_on_alarms), notificationButtonClickPendingIntent)
                .setAutoCancel(true)

In your manifest declare an intent filter on the activity you want to open (as I remember I could not make it work for the launcher activity, maybe it can work, I just gave up).
<activity
        android:name="Activity_name"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar.LightStatusBar">
        <intent-filter>
            <action android:name="intent_id" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

And last but not least, if activity hasn't been opened, notification onClick will trigger the onCreate method, if it has been opened, it will trigger the onNewIntent
hope this helps :)


text:
Q: Using From (subquery) table in another subquery So I have the following :
SELECT bt.CompanyName,
    AcceptedTable.Count AS AcceptedCount,
    CompletedTable.Count AS CompletedCount,
    SkippedTable.Count AS SkippedCount,
    TotalTable.Count AS TotalCount
FROM (
    SELECT uic.*, uic.Id AS UCId, ic.*, ic.Id AS CompanyId, ic.Name AS CompanyName
    FROM UserChallenges iuc
    JOIN Users iu ON iuc.UserId = iu.Id
    JOIN Companies ic ON ic.Id = iu.CompanyId) bt
JOIN (
    SELECT CompanyId AS CompanyId, COUNT(UCId) AS Count
    FROM bt
    GROUP BY CompanyId) TotalTable ON CompletedTable.CompanyId = bt.CompanyId
JOIN (
    SELECT CompanyId AS CompanyId, COUNT(UCId) AS Count
    FROM bt
    WHERE AcceptedAt IS NOT NULL
    GROUP BY CompanyId) AcceptedTable ON CompletedTable.CompanyId = bt.CompanyId
JOIN (
    SELECT CompanyId AS CompanyId, COUNT(UCId) AS Count
    FROM bt
    WHERE DoneStatus IN (1,6)
    GROUP BY CompanyId) CompletedTable ON CompletedTable.CompanyId = bt.CompanyId
JOIN (
    SELECT CompanyId AS CompanyId, COUNT(UCId) AS Count
    FROM bt
    WHERE DoneStatus IN (4)
    GROUP BY CompanyId) SkippedTable ON SkippedTable.CompanyId = bt.CompanyId
GROUP BY bt.CompanyName

The goal is to compute Counts on the same set of data with different WHERE clauses.
I tried the above approach as it simplifies a bit the query instead of having to do JOINs again in each sub queries.
But it seems like it's not possible, it's Common table expression and is not available in mysql 5.7.
What would be a better way to implement this ?
There must be a cleaner way than this super long query.
I could use a temporary table too, although I'm not sure it's a good idea in a View.

A: You cannot refer another Derived Table alias within a different Derived Table's FROM clause, because it is not accessible at that level.
Also, I feel that you can rather solve this problem using Conditional Aggregation:
SELECT bt.CompanyName,
       COUNT(CASE WHEN bt.AcceptedAt IS NOT NULL THEN bt.UCId END) AS AcceptedCount,
       COUNT(CASE WHEN bt.DoneStatus IN (1,6) THEN bt.UCId END) AS CompletedCount,
       COUNT(CASE WHEN bt.DoneStatus IN (4) THEN bt.UCId END) AS SkippedCount,
       COUNT(bt.UCId) AS TotalCount
FROM (
    SELECT uic.*,
           uic.Id AS UCId,
           ic.*,
           ic.Id AS CompanyId,
           ic.Name AS CompanyName
    FROM UserChallenges iuc
    JOIN Users iu ON iuc.UserId = iu.Id
    JOIN Companies ic ON ic.Id = iu.CompanyId) bt
GROUP BY bt.CompanyId, bt.CompanyName

redpajama_set_name: RedPajamaStackExchange


text:
Q: Display text in grid upon mouse click - pygame I am learning pygame and I am trying to create minesweeper. I have the grid all set up and got it so when you click on a grid if there is a mine there it changes the grid square red,if there are no mines around the square it turns the square black(the color of the board), and when there is a mine around the square it doesn't change color but i cannot get it so that when there is a mine around the square it shows how many in that square. my code is below:
import pygame
import random

BLACK = (0,0,0)
WHITE = (255,255,255)
GREEN = (0,255,0)
RED = (255,0,0)
GREY = (200,200,200)

pygame.init()

box = 11

size = (265,265)
screen = pygame.display.set_mode(size)
font = pygame.font.Font(None, 12)
text1 = font.render('1',True, RED)
text2 = font.render('2',True, WHITE)
text3 = font.render('3',True, WHITE)
text4 = font.render('4',True, WHITE)
text5 = font.render('5',True, WHITE)
text6 = font.render('6',True, WHITE)
text7 = font.render('7',True, WHITE)
text8 = font.render('8',True, WHITE)
rect1 = text1.get_rect()
rect2 = text2.get_rect()
rect3 = text3.get_rect()
rect4 = text4.get_rect()
rect5 = text5.get_rect()
rect6 = text6.get_rect()
rect7 = text7.get_rect()
rect8 = text8.get_rect()
width = 23
height = 23
margin = 1

pygame.display.set_caption("My Game")

done = False

clock = pygame.time.Clock()

grid = []
for row in range(box):
    grid.append([])
    for column in range(box):
        grid[row].append(0)

def updatevalue(rn, c, grid):
    # change row above
    if rn-1 > -1:
        r = grid[rn-1]

        if c-1 > -1:
            if not r[c-1] == '*' and not r[c-1] == '!':
                r[c-1]+= 1

        if not r[c] == '*' and not r[c] == '!':
            r[c]+= 1

        if c+1 < 10:
            if not r[c+1] == '*' and not r[c+1] == '!':
                r[c+1]+= 1

    #change same row
    r = grid[rn]

    if c-1 > -1:
        if not r[c-1] == '*' and not r[c-1] == '!':
            r[c-1]+= 1

    if not r[c] == '*' and not r[c] == '!':
        r[c]+= 1

    if c+1 < 10:
        if not r[c+1] == '*' and not r[c+1] == '!':
            r[c+1]+= 1

    #change row below
    if rn+1 < 10:
        r = grid[rn +1]

        if c-1 > -1:
            if not r[c-1] == '*' and not r[c-1] == '!':
                r[c-1]+= 1

        if not r[c] == '*' and not r[c] == '!':
            r[c]+= 1

        if c+1 < 10:
            if not r[c+1] == '*' and not r[c+1] == '!':
                r[c+1]+= 1

for i in range(10):
    r = random.randint(0,10)
    c = random.randint(0,10)
    grid[r][c] = '!'
    updatevalue(r, c, grid)

while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        elif event.type == pygame.MOUSEBUTTONDOWN:
            pos =pygame.mouse.get_pos()
            column = pos[0]//(width+margin)
            row = pos[1]//(height+margin)
            if grid[row][column] == '!':
                grid[row][column] = '*'
            if grid[row][column] == 0:
                grid[row][column] = '_'
            if grid[row][column] == 1:
                grid[row][column] = '1'
                rect1.topleft = (row,column)
            if grid[row][column] == 2:
                grid[row][column] = '2'
            if grid[row][column] == 3:
                grid[row][column] = '3'
            if grid[row][column] == 4:
                grid[row][column] = '4'
            if grid[row][column] == 5:
                grid[row][column] = '5'
            if grid[row][column] == 6:
                grid[row][column] = '6'
            if grid[row][column] == 7:
                grid[row][column] = '7'
            if grid[row][column] == 8:
                grid[row][column] = '8'
            #print('Click ', pos, 'Grid coordinates: (', row,',', column,')')
        if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
            done = True

    for r in range(box):
        for c in range(box):
            num = grid[r][c]
            color = WHITE
            if grid[r][c] == '_':
                color = BLACK
            if grid[r][c] == '*':
                color = RED

            pygame.draw.rect(screen,color,
                             [margin+c*(margin+width),
                              margin +r*(margin+height),width,height])
            if grid[r][c] == '1':
                screen.blit(text1,rect1)

    pygame.display.flip()

    clock.tick(60)

pygame.quit()

A: Your code uses a integer to represent an un-clicked "near-mine" cell.  Then it's converted to a string representation of the same number when clicked.
It's easy to implement the number-drawing by putting all the number-images into a python dictionary, keyed on this string.  So digit_images["8"] gives you the rendered text for the 8.  The other text-numbers were rendered to WHITE, I'm not sure this would show properly on a white background.  This was changed to RED.
When a cell is clicked the number 8 is changed to a string "8".  In the main loop we check the type() of grid[r][c].  If it's a number still, well that means it's un-clicked.  If it's changed into string (meaning it is clicked), use that string to find the correct number-image.  This form of checking also allows the code to have a lot less lines, since we're not checking for 8 different forms of the result.
It might be a better approach to store a list for each cell with a state, rather than using a single string/not-string to determine clicked-ness.  Maybe something like:
grid[row][column] = [ '*', False ]   # content, is-clicked

Or maybe even a class:
class Cell:
    def __init__( self, value ):
        self.value = value
        self.clicked = False

    def isClicked( self ):
        return self.clicked

    def getValue( self ):
        return self.value

Here is the working code:
import pygame
import random

BLACK = (0,0,0)
WHITE = (255,255,255)
GREEN = (0,255,0)
RED   = (255,0,0)
GREY  = (200,200,200)

pygame.init()

box = 11

size = (265,265)
screen = pygame.display.set_mode(size)
font = pygame.font.Font(None, 12)
text1 = font.render('1',True, RED)
text2 = font.render('2',True, RED)
text3 = font.render('3',True, RED)
text4 = font.render('4',True, RED)
text5 = font.render('5',True, RED)
text6 = font.render('6',True, RED)
text7 = font.render('7',True, RED)
text8 = font.render('8',True, RED)
# Dictionary to map the string value to the image
digit_images = { '1':text1, '2':text2, '3':text3, '4':text4,
                 '5':text5, '6':text6, '7':text7, '8':text8  }

width = 23
height = 23
margin = 1

pygame.display.set_caption("My Game")
done = False
clock = pygame.time.Clock()

grid = []
for row in range(box):
    grid.append([])
    for column in range(box):
        grid[row].append(0)

def updatevalue(rn, c, grid):
    # change row above
    if rn-1 > -1:
        r = grid[rn-1]

        if c-1 > -1:
            if not r[c-1] == '*' and not r[c-1] == '!':
                r[c-1]+= 1

        if not r[c] == '*' and not r[c] == '!':
            r[c]+= 1

        if c+1 < 10:
            if not r[c+1] == '*' and not r[c+1] == '!':
                r[c+1]+= 1

    #change same row
    r = grid[rn]

    if c-1 > -1:
        if not r[c-1] == '*' and not r[c-1] == '!':
            r[c-1]+= 1

    if not r[c] == '*' and not r[c] == '!':
        r[c]+= 1

    if c+1 < 10:
        if not r[c+1] == '*' and not r[c+1] == '!':
            r[c+1]+= 1

    #change row below
    if rn+1 < 10:
        r = grid[rn +1]

        if c-1 > -1:
            if not r[c-1] == '*' and not r[c-1] == '!':
                r[c-1]+= 1

        if not r[c] == '*' and not r[c] == '!':
            r[c]+= 1

        if c+1 < 10:
            if not r[c+1] == '*' and not r[c+1] == '!':
                r[c+1]+= 1

for i in range(10):
    r = random.randint(0,10)
    c = random.randint(0,10)
    grid[r][c] = '!'
    updatevalue(r, c, grid)

while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        elif event.type == pygame.MOUSEBUTTONDOWN:
            pos =pygame.mouse.get_pos()
            column = pos[0]//(width+margin)
            row = pos[1]//(height+margin)
            if grid[row][column] == '!':
                grid[row][column] = '*'
            if grid[row][column] == 0:
                grid[row][column] = '_'
            # If the click was an a previously-unclicked area, show the number
            # indicated by converting the number to a string
            if type( grid[row][column] is int ):
                grid[row][column] = str( grid[row][column] )
            #print('Click ', pos, 'Grid coordinates: (', row,',', column,')')

        if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
            done = True

    for r in range(box):
        for c in range(box):
            num = grid[r][c]
            color = WHITE
            if grid[r][c] == '_':
                color = BLACK
            if grid[r][c] == '*':
                color = RED

            pygame.draw.rect(screen,color, [margin+c*(margin+width), margin +r*(margin+height),width,height])

            ### If the cell is a string-digit, is has been clicked
            ### Draw the correct digit-string-image in the cell.
            if ( type( grid[r][c] ) is str and grid[r][c] in '12345678' ):
                screen.blit( digit_images[ grid[r][c] ], [margin+c*(margin+width), margin +r*(margin+height),width,height] )

#            if grid[r][c] == '1':
#                screen.blit(text1,rect1)

    pygame.display.flip()

    clock.tick(60)

pygame.quit()


text:
Q: ADL xapi launch I currently try to understand how the adl launch algorithm works. I've found the great tutorial by ht2labs (https://github.com/LearningLocker/xapi-demos) and the corresponding videos (https://vimeo.com/272792141 and https://vimeo.com/272792152). The tutorial shows which data are required by the launch-server to generate the xAPILaunchKey, but not, how it's generated. Could someone explain, how I can generate a valid xAPILaunchKey?
Thanks in advance


text:
Q: Matlab imcrop returns an image size zero I am trying to take a sample of an image using imcrop, but I am having issues.
patchsize = 35
[sample_width, sample_height] = size(sample);
max_width = sample_width-patchsize;
max_height = sample_height-patchsize;
x = randi([0, max_width]);
y = randi([0, max_height]);
patch = imcrop(sample,[x y patchsize-1 patchsize-1]);

The next part of my code is an attempt to access the pixels in patch, but I get an error : Attempted to access patch(1,1); index out of bounds because size(patch)=[0,0]
so I added,
disp(size(patch))

apparently size of patch is 0 0, but I don't understand why this is the case.  Based on answers to other questions about imcrop on stack overflow, I also tried
patch = imcrop(sample, [x y x+patchsize-1 y+patchsize-1])

This also resulted in patch having size zero
note: The size did not always return zero, in the first case, depending on what the random ints x and y were, patch would sometimes have size patchsize, but it did not happen %100 of the time, and in the second example, it would sometimes have sizes that were all over the board, but I cannot understand where this inconsistency is coming from.
Update: The problem was coming from the part of my code:
[sample_width, sample_height] = size(sample);

should have been:
sample_width, sample_height, depth] = size(sample);

A: The problem with the original code is in:
[sample_width, sample_height] = size(sample);

Should be:
[sample_height, sample_width, sample_depth] = size(sample);

RGB images have 3 dimensions and declaring as above will give sample_height a larger value accounting for the width and the depth


text:
Q: Linker issue while cross compiling for cortex-a8 device I am using VAR-SOM-AM33 board and want to run sample code like hello world run on device and it gives -sh:./test:not found error
Toolchain used for compile code is gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.
Code is as below
#include <stdio.h>
    int main(){
    printf("hello world");
    return 0;
}

for crosscompile file
arm-linux-gnueabihf-gcc test.c -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -o test

output binary is shows as follows
test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31, BuildID[sha1]=2ce1c5b3d97dac2093fe2cd2d340cdaa9989923f, not stripped

After copy that file into hardware and run it shows following error
root@am335x-evm:~# ./test
-sh: ./test: not found

File permission also change by
root@am335x-evm:~# chmod +x test

but result shows same not found error.
Demo file which is running on hardware,its architecture as follows
root@am335x-evm:~# readelf -A /usr/bin/hello
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_VFP_arch: VFPv3
Tag_Advanced_SIMD_arch: NEONv1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align8_needed: Yes
Tag_ABI_align8_preserved: Yes, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP

and file which is cross compiled,its architecture as follows
root@am335x-evm:~# readelf -A test
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_VFP_arch: VFPv3
Tag_Advanced_SIMD_arch: NEONv1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align8_needed: Yes
Tag_ABI_align8_preserved: Yes, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP
Tag_ABI_VFP_args: VFP registers
Tag_CPU_unaligned_access: v6
Tag_unknown_44: 1 (0x1)

Also hardware cpuinfo is as follows
root@am335x-evm:~# cat /proc/cpuinfo
Processor   : ARMv7 Processor rev 2 (v7l)
BogoMIPS    : 718.02
Features    : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x3
CPU part    : 0xc08
CPU revision    : 2

Hardware    : Variscite VAR-SOM-AM33
Revision    : 0000
Serial      : 0000000000000000

I have tried running ldd command on target device.
root@am335x-evm:~# ldd
-sh: ldd: not found

So I suspect that the issue is related to the linker.
If I simply compile the file, without linking it.
arm-linux-gnueabihf-gcc -mtune=cortex-a8 -march=armv7  -O -c test.c -o test

Now if I run this file I get this error.
root@am335x-evm:~# chmod +x test
root@am335x-evm:~# ./test
./test: line 1: syntax error: word unexpected (expecting ")")

please suggest how to resolve this.

A: Thanks for solution, I found error with linker.
existing file has linker ld-linux.so.3 and crosscompiled file has linker ld-linux-armhf.so.3
root@am335x-evm:/usr/bin# readelf -l hello

Elf file type is EXEC (Executable file)
Entry point 0x82fc
There are 8 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  EXIDX          0x00044c 0x0000844c 0x0000844c 0x00008 0x00008 R   0x4
  PHDR           0x000034 0x00008034 0x00008034 0x00100 0x00100 R E 0x4
  INTERP         0x000134 0x00008134 0x00008134 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.3]

crosscompiled file program header
root@am335x-evm:~# readelf -l test

Elf file type is EXEC (Executable file)
Entry point 0x82f9
There are 8 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  EXIDX          0x000450 0x00008450 0x00008450 0x00008 0x00008 R   0x4
  PHDR           0x000034 0x00008034 0x00008034 0x00100 0x00100 R E 0x4
  INTERP         0x000134 0x00008134 0x00008134 0x00019 0x00019 R   0x1
      [Requesting program interpreter: /lib/ld-linux-armhf.so.3]

after chang that linker program runs on target device.
root@am335x-evm:~# cd /lib/
root@am335x-evm:/lib# ls -l ld-linux.so.3
lrwxrwxrwx    1 1000     1000           12 Aug  7  2012 ld-linux.so.3 -> ld-2.12.2.so
root@am335x-evm:/lib# ln -s /li ld-2.12.2.so ld-linux-armhf.so.3
/lib/     /linuxrc
root@am335x-evm:/lib# ln -s /lib/ld-2.12.2.so  ld-linux-armhf.so.3
root@am335x-evm:/lib# ldconfig
root@am335x-evm:/lib# cd
root@am335x-evm:~# ./test
hello worldroot@am335x-evm:~#


text:
Q: Flash10-ActionScript3:Can not connect to socket server I wrote the C# codes have been running on local server side.
System.Net.Sockets.Socket server = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
server.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Any, 4502));
server.Listen(int.MaxValue);
while (true)
{
    System.Net.Sockets.Socket client = server.Accept();
    if (client.Connected)
        client.Send(new byte[1]);
}

then built a swf file embedded in a html file on local web page——127.0.0.1/Socket.htm
public class WebSocket extends flash.display.Sprite
{
    private var Socket:flash.net.Socket = new flash.net.Socket();

    public function WebSocket()
    {
        flash.system.Security.allowDomain("*");
        flash.system.Security.allowInsecureDomain("*");
        flash.system.Security.loadPolicyFile("PolicyFile.xml");
        this.Socket.addEventListener( flash.events.Event.CONNECT, Socket_Connect );
        this.Socket.connect("127.0.0.1",4502);
    }

    private function Socket_Connect(event:Event):void
    {
        this.MyLabel.text= "The socket is now connected..." ;
    }
}

here is the content of the "127.0.0.1/PolicyFile.xml":
<?xml version="1.0" encoding="utf-8"?>
<cross-domain-policy>
    <allow-access-from domain="*" />
</cross-domain-policy>

the codes run without any error, but the CONNECT event is never fired.
Thank you for any help in advance!

A: Socket connections from Flash require a policy file served by the very same host. The Flash Player automatically tries to establish a socket connection to port 843 on the target machine to fetch a policy file. It's not sufficient to load a policy file with an ordinary request.
You can specify a different port like this:
Security.loadPolicyFile("xmlsocket://127.0.0.1:1843");

As you seem to work with .NET, this is a policy server for your platform: http://policyserver.codeplex.com.
You can also implement a policy server yourself. Just listen for connections and the input string <policy-file-request/>\0. After that, output the XML and close the socket. The Flash Player will then proceed with establishing the connection.
Example policy XML:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
 <site-control permitted-cross-domain-policies="master-only"/>
 <allow-access-from domain="*" to-ports="4502" />
</cross-domain-policy>

Please also make sure that you listen for all relevant events on your socket (namely SecurityErrorEvent.SECURITY_ERROR, IOErrorEvent.IO_ERROR, Event.CLOSE, ProgressEvent.SOCKET_DATA).


text:
Q: How to move installed NODE module from one computer to another? I have limited network on one computer but can copy any file/folder to it.
On the second computer I have a full internet access and no restrictions and could successfully install a Node module.
How to bring installation (of one module) from second computer to first?
What folder/files and config needs to be copied in order to work without installation?

A: It's hard to cherry pick one module only especially if it has multiple dependencies. Your best bet is probably copying the whole node_modules folder.
If you need one package only, a workaround would be making a new folder on the PC with internet, install the package and then just copying the node_modules folder to the PC without internet connection. No additional settings are needed (if we aren't talking about global packages).

A: You don't need to copy whole node_module folder bcz it's very big in size.

So the alternate and best option is you just copy your package.json file on second computer and re-install all node module again.

A: Here you don't need to copy all node_modules from one system to another. What you can do is, copy package.json from one system to another and run command npm install.


text:
Q: How do I to load map when page is already loaded? I have a page where I need to load a Map by an address to see the property located at that point. To do this I found the Google Maps API but I cannot do this works yet. I'm trying an example that I saw on documentation but it still doesn't works and does not throws any exception.
Here de documentation.
How could I do this ?
Loading Google Maps API

Script to Load Map By Address
$(document).ready(function () {
    initialize();
    codeAddress();
});

var geocoder;
var map;
function initialize() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var mapOptions = {
        zoom: 8,
        center: latlng
    }
    map = new google.maps.Map(document.getElementById('gmap'), mapOptions);
}

function codeAddress() {
    var address = document.getElementById('myAddress').value;
    geocoder.geocode({ 'address': address }, function (results, status) {
        if (status == 'OK') {
            map.setCenter(results[0].geometry.location);
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });
        } else {
            alert('Geocode was not successful for the following reason: ' + status);
        }
    });
}

HTML

@Html.HiddenFor(model => model.myAddress)

A: I finally solved the problem.
function loadByAddress() {
    var address = $('#myAddress').val();
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({ 'address': address }, function (results, status) {
        if (status == 'OK') {
            var latlng = new google.maps.LatLng(results[0].geometry.location.lat, results[0].geometry.location.lng);
            var myOptions = {
                zoom: 20,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.SATELLITE
            };
            var map = new google.maps.Map(document.getElementById("gmap"), myOptions);
            map.setCenter(results[0].geometry.location);
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });
        } else {
            alert('Geocode was not successful for the following reason: ' + status);
        }
    });
}
google.maps.event.addDomListener(window, "load", loadByAddress);


text:
Q: Fastest path to cover area How do we determine the fastest path to cover an area using an object of some radius r? E.g. a machine that needs to spray a chemical onto a surface. I assume this is some kind of NP-hard problem.

A: Seems to me that the total area painted is (roughly) the area of the brush times the length of the path. So, if two paths cover the same area, without overlaps, then they must have the same length. Time will be wasted if we have to lift the brush from the paper, though, so my argument only applies to continuous paths (with no lifts).
This kind of problem arises in many NC (numerical control) applications, and has been well studied. For example, trying to mill a region with an NC cutter is somewhat the same problem as painting. Here's one paper on the subject.


text:
Q: android-ngn-stack registration issue I am not able to register for android with android-ngn-stack lib.
Below is my code for registration.
 NgnEngine mEngine = NgnEngine.getInstance();
    INgnConfigurationService mConfigurationService
            = mEngine.getConfigurationService();
    mConfigurationService.putString(NgnConfigurationEntry.IDENTITY_IMPI,
            "abcdes"); //username
    mConfigurationService.putString(NgnConfigurationEntry.IDENTITY_IMPU,
            String.format("sip:%s@%s", "sip_username", "sip_domain"));
    mConfigurationService.putString(NgnConfigurationEntry.IDENTITY_PASSWORD,
            "abcdes_abcds");//password
    mConfigurationService.putString(NgnConfigurationEntry.NETWORK_PCSCF_HOST,
            "www.abc.com");
    mConfigurationService.putInt(NgnConfigurationEntry.NETWORK_PCSCF_PORT,
            5060);//port
    mConfigurationService.putString(NgnConfigurationEntry.NETWORK_REALM,
            "www.abc.com"); //domain

// By default, using 3G for calls disabled
    mConfigurationService.putBoolean(NgnConfigurationEntry.NETWORK_USE_3G,
            true);

// You may want to leave the registration timeout to the default 1700 seconds
    mConfigurationService.putInt(NgnConfigurationEntry.NETWORK_REGISTRATION_TIMEOUT,
            3600);
    mConfigurationService.commit();

    // Register broadcast receivers
    initializeManager();

Below is the error I am getting.

12-26 11:30:19.846 29476-29476/drawer.spicedigital.com.sipcalling D/org.doubango.ngn.services.impl.NgnNetworkService: netType=0 and netSubType=13
  12-26 11:30:19.850 29476-30485/drawer.spicedigital.com.sipcalling D/org.doubango.ngn.services.impl.NgnSipService: Stack started
  12-26 11:30:19.851 29476-30485/drawer.spicedigital.com.sipcalling E/org.doubango.ngn.services.impl.NgnSipService: sessionId to be passed is1
  12-26 11:30:19.851 29476-30485/drawer.spicedigital.com.sipcalling E/org.doubango.ngn.services.impl.NgnSipService: OnDialogEvent (Dialog connecting,1)
  12-26 11:30:19.851 29476-30485/drawer.spicedigital.com.sipcalling E/org.doubango.ngn.services.impl.NgnSipService: --connecting--900
  12-26 11:30:19.855 29476-30485/drawer.spicedigital.com.sipcalling E/org.doubango.ngn.services.impl.NgnSipService: sessionId to be passed is1
  12-26 11:30:19.855 29476-30485/drawer.spicedigital.com.sipcalling E/org.doubango.ngn.services.impl.NgnSipService: OnDialogEvent ((un)REGISTER request successfully sent.,1)
  12-26 11:30:19.869 29476-29476/drawer.spicedigital.com.sipcalling E/DEBUG: Trying to register...
  12-26 11:30:19.974 29476-30485/drawer.spicedigital.com.sipcalling E/org.doubango.ngn.services.impl.NgnSipService: sessionId to be passed is1
  12-26 11:30:19.975 29476-30485/drawer.spicedigital.com.sipcalling E/org.doubango.ngn.services.impl.NgnSipService: OnDialogEvent (Not found,1)
  12-26 11:30:19.975 29476-30485/drawer.spicedigital.com.sipcalling E/org.doubango.ngn.services.impl.NgnSipService: terminated903
  12-26 11:30:19.976 29476-29476/drawer.spicedigital.com.sipcalling E/DEBUG: You are now unregistered :)
  12-26 11:30:19.977 29476-30485/drawer.spicedigital.com.sipcalling D/org.doubango.ngn.services.impl.NgnSipService: Stack stopped

I have also tried imsdroid apk but that is also not able to get register.
Please help me with some clue where I am doing wrong. As  have followed the same steps.


text:
Q: What is this graffiti on the walls in Portal 1? I just started playing Portal, and found these scrawls on the wall (somewhat hidden). The first two images were in the first level with turrets, and the second was a couple levels after.

It appears represent the companion cube as a friend (symbolized by hearts around the pictures), and the cake.
What does this graffiti mean (if anything), and who wrote it?

A: The graffiti was written by:

 Doug Rattmann, the only known surviving employee at the Aperture Science Enrichment Center.  He was suspicious of GLaDOS and was prepared when GLaDOS decided to attack the facility.  He survived the attack but was trapped inside the facility.

Meaning of the graffiti:

 Rattmann escaped a neurotoxin attack caused by GLaDOS, but by going into hiding got cut off from his supply of schizophrenia medication. This made him become delusional and unstable.  The graffiti, simply put, is the expression of a madman.  He has an obsession with the Weighted Companion Cube, which he thinks can talk.  The graffiti also foreshadows that GLaDOS is not telling the truth about the tests.


text:
Q: What is the difference between the builder design pattern and using classes that inherit from other? Recently I'm studying design patterns and I've been seeing a pattern called builder that in theory is supposed to encapsulate the complexity of a class, and this is the example I've been practicing:
class ExampleBuilder
{
    static void Main(string[] args)
    {
        Kitchen kit = new Kitchen();

        // One pizza
        kit.NextPizza(new FourCheeseBuilder("Family"));
        kit.PreparePizza();
        var FourCheesePizza = kit.PizzaComplete;

        // Another pizza
        kit.NextPizza(new HawaiianBuilder("Small"));
        kit.PreparePizza();
        var HawaiianPizza = kit.PizzaComplete;
    }
}

// Final Product
public class Pizza
{
    public string Dough { get; set; }
    public string Sauce { get; set; }
    public string Stuff { get; set; }
    public string Size { get; set; }
    public bool BeenFolded { get; set; }

    public Pizza()
    {

    }

    public Pizza(string Size, string Dough, string Sauce, string Stuff, bool BeenFolded) : this()
    {
        this.Size = Size;
        this.Dough = Dough;
        this.Sauce = Sauce;
        this.Stuff = Stuff;
        this.BeenFolded = BeenFolded;
    }
}

// Builder
public abstract class PizzaBuilder
{
    // Protected para que las clases que implementen puedan acceder
    protected Pizza _pizza;
    public string Size { get; set; }

    public Pizza ObtainPizza() { return _pizza; }

    // Un paso para cada una de las propiedades
    public virtual void PrepareDough()
    {

    }

    public virtual void PrepareSauce()
    {

    }

    public virtual void PrepareStuff()
    {

    }

    public virtual void FoldPizza()
    {

    }

}

// BuilderConcrete
public class HawaiianBuilder : PizzaBuilder
{
    public HawaiianBuilder(string size)
    {
        _pizza = new Pizza
        {
            Size = size
        };
    }
    public override void PrepareDough()
    {
        _pizza.Dough = "Soft";
    }

    public override void PrepareSauce()
    {
        _pizza.Sauce = "Sweet";
    }

    public override void PrepareStuff()
    {
        _pizza.Stuff = "pineapple, tomato, ham";
    }
}

// Another BuilderConcrete
public class FourCheeseBuilder : PizzaBuilder
{
    public FourCheeseBuilder(string size)
    {
        _pizza = new Pizza
        {
            Size = size
        };
    }
    public override void PrepareDough()
    {
        _pizza.Dough = "Coocked";
    }

    public override void PrepareSauce()
    {
        _pizza.Sauce = "Roquefort";
    }

    public override void PrepareStuff()
    {
        _pizza.Stuff = "mozzarela, gorgonzola, parmesano, ricotta";
    }
}

// Director
public class Kitchen
{
    private PizzaBuilder _pizzaBuilder;

    public void NextPizza(PizzaBuilder pizzaBuilder)
    {
        _pizzaBuilder = pizzaBuilder;
    }

    public void PreparePizza()
    {
        _pizzaBuilder.PrepareDough();
        _pizzaBuilder.PrepareSauce();
        _pizzaBuilder.PrepareStuff();
    }

    public Pizza PizzaComplete
    {
        get { return _pizzaBuilder.ObtainPizza(); }

    }
}

I had to do all that stuff to define two types of different classes, and I don't understand why is these better than do this:
 class ExampleBuilder
{
    static void Main(string[] args)
    {

        //One Pizza
        var FourCheesePizza2 = new FourCheese2("Family");

        //Another Pizza
        var HawaiianPizza2 = new HawaiianPizza2("Small");
    }
}

// Final product
public abstract class Pizza2
{
    public string Dough { get; set; }
    public string Sauce { get; set; }
    public string Stuff { get; set; }
    public string Size { get; set; }
    public bool BeenFolded { get; set; }

    public Pizza2()
    {

    }

    public Pizza2(string Size, string Dough, string Sauce, string Stuff, bool BeenFolded) : this()
    {
        this.Size = Size;
        this.Dough = Dough;
        this.Sauce = Sauce;
        this.Stuff = Stuff;
        this.BeenFolded = BeenFolded;
    }
}

public class HawaiianPizza2 : Pizza2
{
    public HawaiianPizza2(string size)
    {
        Size = size;
        Dough = "Soft";
        Sauce = "Sweet";
        Stuff = "pineapple, tomato, ham";
        BeenFolded = false;
    }
}

public class FourCheese2 : Pizza2
{
    public FourCheese2(string size)
    {
        Size = size;
        Dough = "Coocked";
        Sauce = "Roquefort";
        Stuff = "mozzarela, gorgonzola, parmesano, ricotta";
        BeenFolded = true;
    }
}

I get the same result but occupying much less lines of code, and that's why I don't know what the pattern builder is really for.


text:
Q: Stuck Partway Through This Laplace Transform "Use a Laplace Transform to solve $x''+x = sin2t$; $x(0) = 0, x'(0) = 0$"
My Work So Far
$x'' = s^2X(s) - sx(0) - x'(0)$
$\therefore $
$s^2X(s) - sx(0) - x'(0) +X(s) = \frac{2}{s^2+4}$
$s^2X(s) +X(s) = \frac{2}{s^2+4}$
$X(s) =\frac{2}{(s^2+4)(s^2+1)}$
From here, though, I'm not sure what the next step would be to come up with a form that can be solved for the inverse transform. Any help moving past this step would be appreciated.

A: $$X(s) =\frac{2}{(s^2+4)(s^2+1)}=\frac{2}{-3}\left(\frac{1}{s^2+4}-\frac{1}{s^2+1}\right)$$
then
$$x(t) =\frac{2}{-3}\left(\frac{1}{2}\sin2t-\sin t\right)$$

A: HINT:
$$\frac{1}{(s^2+1)(s^2+4)}=\frac{1/3}{s^2+1}-\frac{1/3}{s^2+4}$$


text:
Q: android in-app billing sandbox I'm developing a simple in-app billing library. It works with static responses from google, but now I'd like to test this lib with real in-app products.
I have created a test account and I'm trying to buy a product, but google Play is asking me for a credit card. Is there any way to test in-app billing without using a real credit card (a sandbox environment, fake credit card, etc)?
I have read here that the only way to test this is using a real credit card with a test account (so you don't have to pay google taxes) and once you have bought the product, refund it again, but it seems not to be a very 'developer-friendly' way.
Thanks.

A: As of today (or yesterday) Google has finally allowed "sandbox" testing of in app purchases, it goes through all the steps of an in app purchase except the actual charging of the credit card.
Although you will probobly have to wait for the cancelations/refunds like you did before.
More info here and here
Got this info from my developers console.

A: Nope it absolutely SUCKS
You have to use a real credit card, then go into Google Play , select View Merchant Account and hit the individual order then refund to get your money back.
sorry!

A: ... and to add to Blundell's answer, it will take close to 6 hrs for refund to be posted, and then you'll probably want to give it another 6 hours before attempting the purchase.... or else.... Or else, what? Oh, I don't know, something like the "you already own this item" bug/glitch/bane of my existence

A: You can test in-app purchase subscription using testing accounts. For reference please go through the link-
You may use sandbox testing by adding you testers account to play console.
Go to the play console main screen--> setting--> search for license testers--> add your testers email-id there.
Then go to your app release-> go for your beta/alpha release.
Tap on manage testers and share opt-in URL with testers to accept an invite.
https://cheesecakelabs.com/blog/google-play-iap-first-setup-test-sandbox/


text:
Q: Gridview is not displaying data with code-behind sqldatasource I have gridview and its binded with datasource which is created in the code behind file. And I needed to enable sorting and paging in the easiest way so I wrote as following -
In button's click event
SqlDataSource dataSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString, searchQuery);
        dataSource.SelectCommandType = SqlDataSourceCommandType.Text;
        dataSource.SelectCommand = searchQuery;
        if (txtSearchQuery.Text != "")
        {
            dataSource.SelectParameters.Add("searchQuery", txtSearchQuery.Text);
        }
        gridBookings.DataSourceID = dataSource.ID;

However, when the button was clicked, the gridview wasn't populated with data. Any ideas?

A: you forgot to call DataBind on the grid:
gridBookings.DataBind();

A: you must databind
...
gridBookings.DataSourceID = dataSource.ID;
gridBookings.DataBind();

Although I'd prefer this approach
...
gridBookings.DataSource = dataSource;
gridBookings.DataBind();

A: difficult to say without seeing your full page markup and code behind.
In general after associating the DataSource you should also call:
gridBookings.DataBind();


text:
Q: Difference between Google OAuth2 Web Client flow & Desktop Client flow Google's OAuth2 for Desktop Client Documentation says:

Unlike with web clients, the OAuth 2.0 client secret (if used) is assumed not to be confidential.

This makes sense. However, I can't tell any difference between both flows that reflects this assumption: both flows yield an access token and a refresh token (even though the standard OAuth2 philosophy seems to be that you shouldn't hand out refresh tokens to non-confidential clients, and you should use the implicit grant flow instead).
Then what's the difference security-wise between both flows?
(Update: Maybe the latter always prompts for consent, even when the user already gave their consent?)


text:
Q: conditioning issue to locate a group How can I make this regex
(\w|[-zàâçéèêëîïôûùüÿñæœ ])* :((\w|[-zàâçéèêëîïôûùüÿñæœ ])*, [\w]*){1}

separate both tests at the same time to:
test :
Gérant : Jean-Pierre LEVENDEAIN, Associé : Toumiat, Farid
Gérant : Jean-Pierre, LEVENDEAIN, Associé : Toumiat, Farid

Update:
The question is I need 1 regex expression that evaluates both lines and produces these groups:
first case:

*

*Gérant : Jean-Pierre LEVENDEAIN,

*Associé : Toumiat, Farid

second case:

*

*Gérant : Jean-Pierre, LEVENDEAIN

*Associé : Toumiat, Farid

The problem I found, is sometimes I have text with A: B, C, or A: B
and I need both to be matched as a group
Update:
There is a test case I didn't consider

Président : Chateau, Nathalie, nom d'usage : Rudzinski, Directeur
général : Montmirel, Joëlle, nom d'usage : Ciocco, Directeur général
délégué : Rudzinski, Stéphane

A: You can use
([^,\s][^,]*)\s*:\s*(.*?)(?=[^,]*:|$)

See the regex demo. Details:

*

*([^,\s][^,]*) - Group 1: a char other than a comma and whitespace and then zero or more non-comma chars

*\s*:\s* -  a colon enclosed with zero or more whitespaces

*(.*?) - Group 2: any zero or more chars other than line break chars as few as possible

*(?=[^,]*:|$) - a positive lookahead that matches a location that is immediately followed with

*

*[^,]*: - zero or more non-commas and then a : char

*| - or

*$ - end of string.

JavaScript demo:

const re = /([^,\s][^,\n]*)\s*:\s*(.*?)(?=[^,\n]*:|$)/gm
const text = `Gérant : Jean-Pierre LEVENDEAIN, Associé : Toumiat, Farid
Gérant : Jean-Pierre, LEVENDEAIN, Associé : Toumiat, Farid
Président : Chateau, Nathalie, nom d'usage : Rudzinski, Directeur général : Montmirel, Joëlle, nom d'usage : Ciocco, Directeur général délégué : Rudzinski, Stéphane.`
const matches = Array.from(text.matchAll(re), x => [x[1].trim(), x[2].trim()])
for (const x of matches) {
  console.log(x)
}


text:
Q: How to add a class to the sibling ul of a anchor tag depending on the current window url? I am working on a dynamic sidebar on Drupal 8. I made a function to get the href of an anchor tag and if matches the window.location.href, it adds a class to the anchor tag. However, I need to add that class the sibling ul of a anchor tag.
I have try to add the class to the ul with jquery using the siblings(), next(), find() methods but I haven't been able to add the class to sibling ul of the a tag.
HTML

   Menu Link 1

   <a href="" data-drupal-link-system-path="<front>" class="sidebar-link--opened">Submenu-sidebar 1

   <a href="" data-drupal-link-system-path="<front>" class="sidebar-link--opened">Submenu-sidebar 2

   Menu Link 2

    <a href="" data-drupal-link-system-path="<front>" class="sidebar-link--opened">Submenu-sidebar 3

   Menu Link 3

   Menu Link 4

   Menu Link 5

     test link

Javascript
var sideBarUl = $('.aside--sidebar ul li');
        sideBarUl.each(function(){
            if($(this).children("ul").length) {
                $(this).find('a').addClass('sidebarlink-with--content');
            }
        });

        $(function(){
            var sideBarLinkContent = $('.sidebarlink-with--content');
            var currentWindowUrl = window.location.href;

            for ( var i = 0; i < sideBarLinkContent.length; i++) {
                if(sideBarLinkContent[i].href == currentWindowUrl){
                    sideBarLinkContent[i].className = 'sidebar-link--opened';
                }
            }
        });

I am just to add class to the current anchor tag that matches with window url but I an to add the class to its sibling ul to change the display to block.

A: There is a few errors in your js but it mostly right.
ok here is what i found first in the first each function where you check if li has children should
        // not if($(this).children("ul").length) but
         if($(this).children("ul").length> 0) {
            $(this).find('a:not([href=""])').addClass('sidebarlink-with--content');
        }

second is when you validate the href is also wrong.
what your are doing is checking if
(relative) /en/services-prehospitaliers ==(full) www.xxx.com/en/services-prehospitaliers

which is wrong becouse the href contain the full url where sideBarLinkContent[i].href contain only the relative part it should be
             for ( var i = 0; i < sideBarLinkContent.length; i++) {
                if(currentWindowUrl.indexOf( sideBarLinkContent[i].href) != -1){
                    sideBarLinkContent[i].className = 'sidebar-link--opened';
                }
            }


text:
Q: If we create object with const constructor in dart the object is created at compile time? I know the const behavior this is compile time constant if we make variable const but what will be if object is const?

A: const in Dart is very useful as it guarantees a few useful things:

*

*no extra memory allocation for equal instances, as the memory required to allocate the object is interned.

*the object is deeply immutable.

The first ensures that you can compare two consts very efficiently, as two equal instances will also be identical, and that you save some memory at runtime by avoiding allocating memory for several identical objects (hence why in Flutter, it's very common to use const for style data, for example).
The second ensures that even mutable data structures cannot be mutated. For example, this would throw an error at runtime:
const myLanguages = ['dart', 'js', 'java', 'rust', 'lisp', 'erlang'];

void main () {
    myLanguages.add('haskell'); // can't change at runtime!
}

Error:
Unsupported operation: addError: Unsupported operation: add

That means anything created with const behaves exactly as a primitive value. You can't change it and it doesn't require extra memory allocation.
const is transitive as well! So, you can always feel safe that if you declare something const, nothing can accidentally "break" it.

const myBelongings = <String, List<String>>{
  'fruit': ['apple', 'pineapple'],
  'shoes': ['nike', 'puma'],
  'houses': [],
};

void main () {
    myBelongings['houses']?.add('new house'); // can't change at runtime!
}

Error:
Unsupported operation: addError: Unsupported operation: add

The only problem is that there are a few limitations to what can be made const as a consequence of the need for the compiler to be able to verify these invariants, but in many cases, the limitations are not a blocker.
Example:
const otherConstant = 'world';

// OK
const myString = 'hello ' + otherConstant;

String getConst() => myString;

// NOT OK, Dart doesn't know when a function is "pure" or "const"
const notValid = getConst();

This won't compile:
Error: Method invocation is not a constant expression.
const notValid = getConst();
                 ^^^^^^^^

This example could be fixed with const functions which may become a Dart feature in the future!


text:
Q: Advanced Optimization google closure I am facing issues in advanced Optimization mode of closure compiler.
My code worked fine when I had used basic optimizations, but after i removed all the warnings in advanced mode, it is giving me errors in external library files such as Kineticjs. It is either unable to find the methods in external library file(kinetic.js) or has renamed it to something else during advanced compilation mode.
What are the considerations that i should make so that i can move ahead and stop closure renaming the methods in external library file, specially i am having difficult time debugging the code in advanced mode.
my config file is as
{
    "id": "development",
    "inputs": "src/js/application.js",
    "paths": "src",
    "output-file": "development-compiled.js",
    "externs": "kinetic-externs.js",
    "level": "VERBOSE",
    "mode": "ADVANCED",
    "optimize": "closure",
     "closure": {
        "CompilerOptions": {
            "prettyPrint": true
          }
    }
}

A: Use the  @export annotation:
@export kinectic

and run it with the --generate_exports flag.

Code that uses the @export annotation must either

*

*include closure/base.js, or,

*define both goog.exportSymbol and goog.exportProperty with the same method signature in their own codebase.

References

*

*Annotating JavaScript for the Closure Compiler: @export

*Use @public tag to prevent compression of symbol names


text:
Q: Close a single tab in browser using windows application c# /vb.net I am trying to open an URL in browser from my windows application using Process.start(). Instead of close the whole browser window, I only want to close the tab that created by my windows application.
I tried Process.Kill() but it closes the whole browser window.
Is there any way of doing this?
Thanks

A: Unfortunatly, there is no way of closing a specific tab in the browser using VB.NET or C# (or any server side code for that matter). The only way of doing this is using Javascript in your opened web page. If you created this page, you can write a client side command which closes the tab. Once you launched a website using server side code, controls is passed to the browser itself. The only thing you can do is close the browser process completely.
As a side note, Some browsers, like Google Chrome, keep a speprate windows process for each tab. So you could track which process was opened, and close it by its PID. But this solution would not work for other browsers. If you want to force the user to launch your website via Google Chrome, you could launch chrome.exe with a start argument of the URL you are targeting.

A:
Nothing is impossible, everything is extremely complex.

Generally speaking, there is no way of closing a specific tab of a browser.
However a "never to do" way of do this could be:

*

*Open the URL with a specific browser (Chrome, for example);

*Make the browser (the <browser>.exe process) the active Window (using WinAPI);

*Send a key combination to select the desidered tab (it should already be selected);

*Send a key combination to close the tab (CTRL + W, for example)

Just an idea..


text:
Q: android Listview button I am trying to add a button in my list view. But the button is not showing up. I am using json parsing to take data from my server. I am using hashmap and listviews. Moreover i cannot adda button in the list view too. Here's my code:
package acb.xiynove;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.res.Resources;
import android.net.ParseException;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class ImgJsonActivity extends ListActivity
{
    TestServiceActivity obj = new TestServiceActivity();
    String newString;
    int len;
    Button btn,btn1;

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn=(Button)findViewById(R.id.btn);
        btn1=(Button)findViewById(R.id.btn1);

        newString=obj.readTwitterFeed();
        // define the list which holds the information of the list
        List<Map<String, Object>> resourceNames =
            new ArrayList<Map<String, Object>>();

        // define the map which will hold the information for each row
        Map<String, Object> data;

        // hard coded numbers retrieved from
        // http://code.google.com/android/reference/android/R.drawable.html
        try {

           JSONArray rootArray = new JSONArray(newString);
           len = rootArray.length();
//         List<String> listContents = new ArrayList<String>(len);

          for(int i=0;i<len;i++)
          {
             data = new HashMap<String, Object>();
            String x="";

            JSONObject post = rootArray.getJSONObject(i);
            x+= " " + post.getString("u")+ " " + post.getString("s") + " " + post.getString("e") + " on " + post.getString("pd") + " with " + post.getInt("a") + " ";
        data.put("line1", x);
            data.put("img", R.drawable.boy);

            data.put("btn", btn);
            data.put("btn1", btn1);
            resourceNames.add(data);
            //   listContents.add(x);

          }
//        myListView.setAdapter(new ArrayAdapter<String>(this, R.layout.listviewfont, listContents));

           }
           catch (Exception e)
           {
           }

          SimpleAdapter notes = new SimpleAdapter(
                    this,
                    resourceNames,
                    R.layout.row,
                    new String[] { "line1", "img", "btn", "btn1" },
                    new int[] { R.id.text1, R.id.img, R.id.btn, R.id.btn1} );

                setListAdapter(notes);

    }
}

Here's the row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/vw1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageView android:id="@+id/img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView android:id="@+id/text1"
            android:textSize="12sp"
            android:textStyle="bold"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

    </LinearLayout>

        <Button android:id="@+id/btn"
        android:text="Show Interest"
        android:layout_width= "wrap_content"
        android:layout_height= "wrap_content" />

        <Button android:id="@+id/btn1"
        android:text="Ask Query"
        android:layout_width= "wrap_content"
        android:layout_height= "wrap_content" />
</LinearLayout>

Main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ListView
    android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
    android:drawSelectorOnTop="false"/>

    <TextView
        android:id="@id/android:empty"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="No data"/>

</LinearLayout>

A: if you want buttons inside list items, put a button in the list_item.xml .
make a custom adapter :
class CustomAdapter extends BaseAdapter implements OnClickListener {
 .
 .
 .
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
       convertView = inflater.inflate(R.layout.list_item,
                    parent, false);
       holder = new ViewHolder();
       holder.button = (Button) convertView.findViewById(R.id.listButton);
       //find and assign other views here...
       convertView.setTag(holder);
   }else{
       holder = (ViewHolder) convertView.getTag();
   }
  // assign values to all view elements..
  holder.button.setTag(position);
  holder.button.setOnClickListener(this);
  }  //end of getView

public void onClick(View v) {
    int postition=(Integer)v.getTag(); // now you know wich button in list was clicked.
//do whatever you want. cheers!
}
}


text:
Q: How can I make sure I never forget. I am currently refreshing my Elementary Algebra using Schaum's Outlines.  I find them useful as they are choc full of exercises (Which I now realize is the only way to master algebra). I am worried though that I will forget a lot of what I have learnt in a year or two as I move onto more advanced Math.
Do Mathematicians constantly practice by doing exercises to prevent them from forgetting? Or is there a point where you just know how to do Algebra similar to riding a bike or driving? I enjoy doing the exercises but I don't want to have to keep going back to basics every few years.

A: Be sure to aim for understanding why versus emphasizing automaticity with respect to the strategies and techniques you are learning.
Why do they accomplish what they do?
What justifies their use?
What are the foundations from which the "rules" follow?
Can this be generalized to other contexts?
Asking and understanding these sorts of things, finding connections as you progress in your studies (connections between what you know and what you're newly encountered), and of course, practice!, will all help to guarantee a much more solid mastery of the processes and how to derive those techniques  than will simply drilling to the point of robotic "automaticity" ...

One practical pointer or suggestion: if you have the opportunity to tutor or teach students with respect to any material/subject areas that you've mastered, even if only tutoring an hour or two a week, take it. Doing so will both aid you to more deeply understand the material, and provides an opportunity to review, use and in doing so, retain/maintain your learning.

A: Don't worry too much. It is much like riding a bike, you don't forget.
Just make sure you try out a range of different exercises, don't get stuck with one source only. The problems for math olympiads are quite challenging, and cover a wide range of techniques and ideas. Look at their preparation materials.
It is a fine line between "I handle this well" and "automatic for me", don't go too far (you need time to look into other, more intellectually challenging, stuff too).
Look at William Chen's lecture notes and the texts by the Trillia Group, check out Pólya's classic "How to solve it".


text:
Q: JSF 1.2 h:commandLink not working, mojarra is not defined I got a problem with JSF 1.2 on websphere 7.
I'm trying to implement a navigation with JSF.
I'm also using RichFaces.
In the console of the browser I got this error: Uncaught ReferenceError: mojarra is not defined
I have seen other with this problem and they solved it with adding <h:head> but this didn't work for me.
Thank you for helping
My navigation.xhtml
<?xml version="1.0" ?>

<ui:composition>
    <h:form>

               <h:commandLink action="#{navigation.toHome}" value="#{messages.elsi_dg_navigation_home}" />

                <h:commandLink action="#{navigation.toHistory}" value="#{messages.elsi_dg_navigation_history}" />

    </h:form>
</ui:composition>

The NavigationBean.java
@Controller("navigation")
@Scope("session")
@ManagedBean
public class NavigationBean {

private String lastSite = "home";

public String toHome() {
    return this.processOutcome("home");
}

public String toHistory() {
    return this.processOutcome("history");
}

public String toCurrentPage() {
    return this.lastSite;
}

private String processOutcome(String outcome) {
    this.lastSite = outcome;
    return outcome;
}
}

HTML output:

<form id="j_id19" name="j_id19" method="post" action="/elsi-dg/xhtml/home.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_id19" value="j_id19">

Home

History

<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="3428583661652779493:-8865896015881316410" autocomplete="off">
</form>

UPDATE
<a4j:commandLink> works without problems..

A: Maybe the problem is with the tag ui:compostion
 <ui:composition template="./template/template.xhtml">

It normally needs a template file.
Are you using one?
If you aren't, try to remove the <ui:composition> tag.


text:
Q: Receiving parameters from a generic method I'm trying to receive parameters in runtime from some random method that is invoked on my class. Before arm64 (on armv7 and armv7s) it can be done with following code:
@interface MyClass
// It does not matter what method, we declare it for compiler only
- (id)methodWithFirstParameter:(id)firstParam secondParameter:(id)secondParam;
@end

@implementation MyClass

+ (BOOL)resolveInstanceMethod:(SEL)sel {
    [self addDynamicCallForSelector:sel];
    return YES;
}

+ (void)addDynamicCallForSelector:(const SEL)selector {
    const char *encoding;
    IMP implementation;
    implementation = [self instanceMethodForSelector:@selector(dynamicMethod:)];
    Method newMethod = class_getInstanceMethod([self class], @selector(dynamicMethod:));
    encoding = method_getTypeEncoding(newMethod);
    class_addMethod([self class], selector, implementation, encoding);
}

- (id)dynamicMethod:(id)obj1, ... {
    int parameterCount = [[NSStringFromSelector(_cmd) componentsSeparatedByString:@":"] count] - 1;
    NSMutableArray *parameterList = [[NSMutableArray alloc] initWithCapacity:parameterCount];
    va_list arguments;
    va_start(arguments, obj1);
    for (int i = 0; i < parameterCount; i++) {
        id parameter = (i == 0) ? obj1 : va_arg(arguments, id);
        if (!parameter) {
            parameter = [NSNull null];
        }
        [parameterList addObject:parameter];
    }
    va_end(arguments);
    return parameterList;
}

It's pretty easy and clean. We just pass all incoming invocation to one single implementation that can gather parameters from it and return them.
In arm64 however, va_list works good, but in such context, the first parameter from va_arg(arguments, id) is current instance of class (self). After second call it's stopped with EXC_BAD_ACCESS. So I think it did not even find first parameter (with va_start(arguments, obj1)).
Also notice that va_list functionality works fine on arm64 in case I invoke dynamicMethod: directly (and manually set number of arguments). My wild guess that it does not work because of wrong method encoding (it does not magically convert one method into another with different number of parameters on arm64 like it was before).
You can look all code here, it's basically web service part of this solution.

A: The reason your code is failing is likely because the calling convention between arm (32bit) and arm64 is different.  That is to say, different rules are being applied as to how parameters are passed to the function, and how values are returned.
There was no "magic conversion" going on before.  You got lucky that the calling convention for variadic functions was the same as for non-variadic - at least in your use cases.
See the Parameter Passing sections in both the ARM Procedure Call Standard for arm64 and ARM Procedure Call Standard (non-64 bit).
Good luck solving this; you'll likely have to have two separate code paths.
EDIT
I believe the "correct" way to achieve what you're after is to implement a number of functions with all of the possible permutations of arguments you expect to handle, and resolve to those dynamically based on the selector signature.  JSCocoa does this using what they call a "Burks Pool" (I believe named for Tim Burks)
Also check out libffi for iOS:  https://github.com/roupam/Objective-C-NuREPL-for-iOS/tree/master/Remote/libffi
Lastly, a related post:  -[NSInvocation getReturnValue:] with double value produces 0 unexpectedly

A: Unexpectedly, I've got decent solution from PR on Github so all credits go to @sandor-gazdag. Here's solution:
- (void)forwardInvocation:(NSInvocation *)inv {
    NSUInteger n = [[inv methodSignature] numberOfArguments];

    NSMutableArray *parameterList = [[NSMutableArray alloc] init];
    for (NSUInteger i = 0; i < n - 2; i++) {
        id __unsafe_unretained arg;
        [inv getArgument:&arg atIndex:(int)(i + 2)];
        if (!arg) {
            arg = [NSNull null];
        }
        [parameterList addObject:arg];
    }
    [self dynamicWebServiceCallWithArguments:parameterList forInvocation:inv];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
    NSUInteger numArgs = [[NSStringFromSelector(aSelector) componentsSeparatedByString:@":"] count] - 1;
    return [NSMethodSignature signatureWithObjCTypes:[[@"@@:@" stringByPaddingToLength:numArgs + 3 withString:@"@" startingAtIndex:0] UTF8String]];
}

- (void)dynamicWebServiceCallWithArguments:(NSMutableArray *)parameterList forInvocation:(NSInvocation *)invocation {
   ...
   id result = [self executeDynamicInstanceMethodForSelector:invocation.selector parameters:parameterList prepareToLoadBlock:prepareToLoadBlock success:successBlock failure:failureBlock];
   [invocation setReturnValue:&result];
}

So simple and still so powerful. Works for any processor architecture, because it's high-level solution. I blame myself that I've not find it myself=)

A: A found another way of dynamically invoking of a function. Have a look at this piece of code:
- (void)requestSucceeded
{
    NSLog(@"requestSucceeded");
    id owner = [fbDelegate class];
    SEL selector = NSSelectorFromString(@"OnFBSuccess");
    NSMethodSignature *sig = [owner instanceMethodSignatureForSelector:selector];
    _callback = [NSInvocation invocationWithMethodSignature:sig];
    [_callback setTarget:owner];
    [_callback setSelector:selector];
    [_callback retain];       // <------ See the partial doc attached

    [_callback invokeWithTarget:fbDelegate];
}

A part from NSInvocation document:

This class does not retain the arguments for the contained invocation
  by default. If those objects might disappear between the time you
  create your instance of NSInvocation and the time you use it, you
  should explicitly retain the objects yourself or invoke the
  retainArguments method to have the invocation object retain them
  itself.

Also, the arguments you passes would get indices 2 or greater, see why: (same above link)

Indices 0 and 1 indicate the hidden arguments self and _cmd,
  respectively; these values can be retrieved directly with the target
  and selector methods. Use indices 2 and greater for the arguments
  normally passed in a message.

For a completed running exmaple, if have already added a facebook invite friend code in this thread.
This code dynamically calls the delegate function by reading it from the delegate's interface and invoked with/without arguments.
The idea behind this solution is that it does not required any external reference of Encoding, plus you should retain your _callback to avoid EXC_BAD_ACCESS and yes it is a bit simpler.
Hope it helps!


text:
Q: XSL Binding error I am using mule to perform some xsl translations
my input xml is :
<root>
  <Items>
    <Item line="line1"> Item1 </Item>
    <Item line="line2"> Item2 </Item>
    <Item line="line3"> Item3 </Item>
  </Items>
</root>

my xsl logic is
<xsl: for-each select="//root/Items/Item>

  <xsl:element name="test">
       <xsl:value-of select="//@line"/>
  </xsl:element>

</xsl: for-each>

I expect my result to be
<test>line1</test>
<test>line2</test>
<test>line3</test>

but I get
 <test>line1 line2 line3</test>
  <test>line1 line2 line3</test>
  <test>line1 line2 line3</test>

What am I doing wrong?

A:    <xsl:value-of select="//@line"/>

selects every attribute named line in the entire document, regardless of which element the attribute belongs to. If you just want the line attribute of the element you are currently looking at in the for-each then remove the leading slashes and say simply select="@line".


text:
Q: jQuery DataTables Ordering By 2 columns I am using jQuery DataTables to style and give functionality to one of my tables:

My Goal
Order by whether or not the type of funding is active or not.. which is what it is doing currently as you can see.  Now, I would like to order the Funding column alphabetically.. so my wanted outcome should be:
Funding One
Funding Two
Funding Three
Funding Four
Alpha
Beta
Charlie
Test
test2

Here is what I have so far my datatables script:
var codeFundingTable = $("#Code-Funding-Table").DataTable({
    "bPaginate": false,
    "bFilter": false,
    "aoColumnDefs": [
        { "bSortable": false, "aTargets": [2] },
        { "bSearchable": false, "aTargets": [2] }
    ],
    "columns": [
        { "orderData": [1] },
        { "orderData": [0] }
    ]
});

So I am first ordering by column 1 (Active, 0-based) then by column 0 (Funding) but it is not doing it alphabetically.
How can I make this happen?

A: It is a guess since we have no sample data. For example, what is the value of "active" (besides a checkbox is rendered)? But I believe you can just do
var table = $('#example').DataTable({
  order: [[1, 'asc'], [0, 'asc']]
})

*

*active column is sorted first, if values is 0 and 1 asc should be used

*first column is secondly sorted alpha, with respect of second column order

Here is a demo -> http://jsfiddle.net/0f9Ljfjr/949/ position is sorted first, then name is sorted within each position "type".

A: Try this on for size
"columns": [
    { "orderData": [1,0] },

https://datatables.net/examples/basic_init/multi_col_sort.html

A: In my case, what helped me is this.
I used data-order attribute to sort my tables.
data-order="[[ 0, "asc" ], [ 1, "asc" ]]


text:
Q: Reading multiple inputs Is there a way to read multiple inputs that are passed through Command Line from user?
I want to access each one of them  and process an operation upon each.
For ex:
Enter Your Inputs:
11111
22222
33333
44444
55555
66666
77777

Now, I want to access each of the inputs from "11111" to "77777". If any of you knows any method, pls share.


text:
Q: I cant send correctly the body Im using an app (nodeJS) which need catch email and password in the body of request to drop a token.
Im using react in frontEnd to make the post using fetch but, when i made the post using a onClick event, and i watch the console of API, the body is not correctly formed.

{
'{"email":"johndoe@gmail.com","password":"Johnismyname"}': '   '
}

The problem isn't the API because i tested it with postman and works correctly.
The problem is in the react code i guess because im still learning.
This is the code in react:
    import { Link } from "react-router-dom"
    import { useRef, useState } from 'react';
    export default function Login() {
    const [token, setToken] = useState('')
    const LOGIN_API_URL = "http://localhost:3010/api/v1/users/login"
    const GET_USER_API_URL = "http://localhost:3010/api/v1/users/getuser"
    const userEmail = useRef();
    const userPassword = useRef();
    async function apiCall(email, password, tokenUrl, userUrl) {
        const body = JSON.stringify({
            email: email,
            password: password
        });
        const fetchConfig = {
            method: "POST",
            headers: {
                "Accept": "application/json",
                "Content-Type": "application/x-www-form-urlencoded"
            },
            body
        }
        const response = await fetch(tokenUrl, fetchConfig)
        const data = await response.json()
        console.log(data);
        return setToken(data.token)
    }
    return (

Login

                <input ref={userEmail} type="email" name="email" id="email" placeholder="email"/>
                <input ref={userPassword }type="password" name="password" id="password" placeholder="password" />

 {
                        apiCall(userEmail.current.value, userPassword.current.value, LOGIN_API_URL, GET_USER_API_URL)
                    }}
                >
                    Join

<Link className="register hover-expands" to="/register">Register</Link>

    )
}

A: This is due to the incorrect Content-Type you have provided in the header. Substitute application/x-www-form-urlencoded with application/json to get the desired result.
const fetchConfig = {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
  },
  body,
};

A: Change this line of code "Content-Type": "application/x-www-form-urlencoded" to "Content-Type": "application/json"


text:
Q: Understanding XML/RSS ... why won't a local copy of RSS feed display in browser? If I visit the feed at

http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topalbums/sf=143444/limit=10/xml

with Firefox, it displays the feed as I would expect. But if I copy the source (view source) of this display and save it into a file like feed.xml on my local machine - it will not render the file but gives error:

XML Parsing Error: not well-formed
  Location:
  file:///C:/Program%20Files/xampp/htdocs/feed.xml
  Line Number 27, Column 48: 7.99

I can't understand why the exact same source will not work locally.

A: When the feed is request from the web server a MIME type (in this case application/xml) is sent with the file which helps the browser to know how to display it.
When you load the file off disk, that information is not there, hence it will be displayed differently.
This doesn't explain your parsing error, but does explain why the feed is displayed differently.


text:
Q: cannot get remote repository refs in eclipse Introduction:
Main Repo: Repo1.
After forking it, my repo is : ForkedRepo1
In Eclipse-Git, I cloned my ForkedRepo1.
Until Thursday, I was able to commit & push without any issue.
Then suddenly, on Thursday, I got the error:
Cannot get remote repository refs
Reason:
ssh://<forkedrepo1: session.connect:
java.netSocketTimeoutException: Read timed out

I have a SSH key.
Nothing as altered in my system, so I am not sure what happened.
To make matters worse, I deleted my Remote(origin) in eclipse-git and when I try to add it back, I get the same error - java.net.SockettimeoutException: Read timed out.
However, via git bash, I can commit a file and push it to the local branch in GitHub.
I hope this info is enough to give me some idea.
FYI: I am working on a existing project, so when I push a file up for review, it worked successfully. It is just that I cannot now do it in eclipse.

A: Then try, as described here, to switch to an HTTPs URL.

You can then cache your GitHub credentials (GitHub username/password) in a credential helper, generally already configured (see git config credential.helper)

A: It is probably caused by the removal of weak cryptographic standards.
You need a recent Java 8 revision (i.e. 1.8.0_161), a recent version of EGit (such as 4.10.0.201712302008-r) and you probably need also to restart (just once) Eclipse with the -clean parameter.


text:
Q: What the primed quantities really are in this context? In this definition:

The set of $N$ quantities $V_j$ is said to be the components of an $N$-dimensional vector $\mathbf{V}$ if and only if their values relative to the rotated coordinate axes are given by
$$V_i'= \sum_{i=1}^N a_{ij}V_j, \quad i=1,2,\dots,N$$
As before, $a_{ij}$ is the cosine of the angle between $x_i'$ and $x_j$. Often the upper limit $N$ and the corresponding range of $i$ will not be indicated. It is taken for granted that you know how many dimensions your space has.

a vector is characterized as a set of components $\{V_j\}$ such that relative to some other coordinate system these components are given by that formula.
This extends to covectors and tensors of all ranks.
The problem is: I believe this definition assumes we have $V_j$, we have $V_i'$ and we can judge whether or not the relation holds. If it holds, $V_j$ are the components of a vector.
But how on earth are $V_i'$ being defined if not by that equation?
What I learned in linear algebra was: given a vector space $V$ and a vector $v\in V$ if we have a basis $\{e_i\}$ we can write uniquely $v = \sum V_i e_i$. This gives the $V_i$.
If we have another basis $\{f_i\}$ we can also write uniquely $v = \sum V_i'f_i$ and this is equivalent to saying
$$v = \sum V_i e_i = \sum V_i a_{ij} f_j$$
and again by uniquenes we have $V_j' = \sum V_i a_{ij}$.
But wait a minute, this means that $V_j'$ is equal to that by definition. In other words, given $V_i$, there is no other option for $V_j'$. This would mean that given any set of components there could be no way to fail this condition.
But I'm obviously missing the point. If the quantities $V_i'$ were defined like this for all sets of components $V_i$ there would be no reason to check if the transformation law is obeyed.
In that context: given a set of numbers $V_i$ how the primed quantities $V_i'$ are defined in order to check that $V_i$ is a vector? Given components $V_i$, what physicists mean by $V_i'$?

A: Following up my comment, I would like to present an example. Consider a basis $(e_1, \dots, e_n )$ and also a basis $(f_1,\dots , f_n) $. Then there is a unique set of numbers such that $f_i=T^j_i e_j$. If using summation convention some vector $V=v^i e_i=w^jf_j$ then as you pointed out $$v^i e_i=w^j T^i_j e_i $$ and hence $v^i=T^i_j w^j $ by linear independence. This is the ttansformation rule for vector components. Now let's apply the definition above. Suppose $\{a^i \}$ and $\{b^i\} $ are components of vectors. Then by your definition $X^i:=a^i+3b^i $ are also the components of a vector (I know it's stupid but as long as you don't have derivatives of vector-FIELDS this is about the most general thing you can do).
The proof:
Transform constituents: $$a'^i+3b'^i=T^i_j a^j+3T^i_j b^j=T^i_j (a^j+3 b^j)=T^i_j X^j=X'^j $$
Hence transforming the individual constituents of the expression and transforming the whole thing as a vector component give the same answer.
Not-Example:
$Y^i:=a^i\cdot a^i $ are not the components of a vector. (in your terminology; surely there is still the possibility to malliciously misunderstand this and counter "Any numbers define a vector, what are you talking about?")
Proof:
Transform constituents $$a'^i a'^i=\sum_{j,k} T^i_j a^j T^i_k a^k\neq T^i_j Y^j. $$
As I said, this only gets interesting if you start talking about vector fields and their derivatives. Exercise: Show that the cross product of two vectors is not a vector, if one is allowed to consider coordinate transformations including reflection (I don't see why your definition would restrict to rotations in the first place)


text:
Q: Why the image does not fade in on top of existing image I have the following code:
HTML CODE:

CSS CODE:
#spnMain {
    background: url("theImages/searchButton.png") no-repeat;
    background-position: 0px 0px;
    width: 28px;
    display: block;
    height: 28px;
    cursor: pointer;
}
#spnMain span {
    background: url("theImages/searchButton.png");
    display: block;
    height: 50px;
    background-position: 0px -56px;
}

JS CODE:
$(document).ready(function () {

     $("#spnMain").wrapInner("");
     $("#spnMain span").css({
         "opacity": 0
     });

     $("#spnMain").hover(function () {
         $(this).children("span").animate({
             "opacity": 1
         }, 400);

     }, function () {

         $(this).children("span").animate({
             "opacity": 0
         }, 400);

     });
 });

Produces the following (the top is onload and the bottom when mouse is hovered:

How can I make the green button fade in on top of the purple button so it hides it?

A: #spnMain {
    position: relative;
    /* ... same as before ... */
}
#spnMain span {
    position: absolute;
    top: 0;
    right: 0;
    /* ... same as before */
}

A: I know you ask for a javascript solution but you can do the same thing with css only (if you want to)
Way 1, sprites, no animation though: http://jsfiddle.net/NicoO/WBjS5/
Way 2, two images, css transition (a bit hacky):  http://jsfiddle.net/NicoO/WBjS5/6/
#spnMain
{
    display: block;
    height: 28px;
    width: 28px;
    background-image: url(**url to green button image**);
    background-position: 0% 0%;
    position: relative;
}

#spnMain:after
{
   position: absolute;
   width: inherit;
   height: inherit;
   top: 0;
   left: 0;
   content:"";
   transition-duration: 0.4s;
   visibility: hidden;
   opacity: 0;
   background-image: url(**url to red button image**);
}

#spnMain:hover:after
{
    visibility: visible;
    opacity: 1;
}

Update the visibility property helps for IE8 support- no transition will occur, but the image will be swapped on mouse over. What should be good enough of a fallback for old "browsers".

A: And your answer is:
Fiddle link: http://jsfiddle.net/LNQq3/4/
CSS Code:
#spnMain {
    background: url("http://s18.postimg.org/balg05zj9/gogo.gif?noCache=1393616120") no-repeat;
    background-position: 0px -5px;
    width: 28px;
    display: block;
    height: 28px;
    cursor: pointer;
}
#spnMain:hover {
    background-position: -37px -5px;
}

A: Have you tried using an absolute positioned element within a relative positioned element (http://css-tricks.com/absolute-positioning-inside-relative-positioning/)?
I have put together a quick jsfiddle demonstrating this: http://jsfiddle.net/9xENQ/
I just grabbed a quick GO/STOP image sprite and didn't take the time to really look into the necessary background-position to make it line up perfectly. Just wanted to convey the concept.
The HTML:

    Hi here is a bunch of text with a padding right to keep it from bleeding into the image.

The CSS:
.button-container {
    position: relative;
    padding-right: 160px;
    width: 158px;
    height: 163px;
    border: 1px solid black;
}

#spnMain {
    background: url("https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQ2m3WvngUNXOeQ4oItfopBO5VSA3OP7hhaHsjMrwHLlzYR4KeZPA") no-repeat;
    background-position: 0px 0px;
    width: 158px;
    display: block;
    height: 163px;
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: -158px;
}
#spnMain span {
    background: url("https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQ2m3WvngUNXOeQ4oItfopBO5VSA3OP7hhaHsjMrwHLlzYR4KeZPA");
    display: block;
    width: 158px;
    height: 163px;
    background-position: -158px 0px;
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: -158px;
}

Your JavaScript (as is):
$(document).ready(function() {

    $("#spnMain").wrapInner("");
    $("#spnMain span").css({"opacity" : 0});

    $("#spnMain").hover(function(){

        $(this).children("span").animate({"opacity" : 1}, 400);

    }, function(){

        $(this).children("span").animate({"opacity" : 0}, 400);

    });

});


text:
Q: ASP.NET Web API return data every second first of all I am sorry for my poor question title, but I can't think of everything better right now.
What I want to do seems quite simpel. I want my API to return, for example, a simple string every second for like 10 times.
Is there any way to achive this with ASP.NET?
And yes, obviously the actual usecase is different. My API is scraping some data and returning it after that. The problem is the scraping takes like 70 seconds. I would like it to return the data in smaller packages, so my application can start processing the data earlier.
But the way to achive this - if there is any - should be the same.
At least thats how I think of it.
Thanks for any help.

A: this is not possible with http.
you must do long pooling on client side or You can create a socket connection between client and server. package signalr is a great choice.


text:
Q: Python `tempfile.gettempdir()` does not respect TMPDIR I am using a shared linux cluster and want my temporary directory to be /tmp/username rather than the default /tmp.
According to the tempfile docs, gettempdir() should use the $TMPDIR environment variable to determine the temporary directory.
However, this does not seem to be the case?!
$ export TMPDIR='/tmp/username'
$ python -c "\
import os
import tempfile
print(os.environ['TMPDIR'])
print(tempfile.gettempdir())"
/tmp/username
/tmp

Any suggestions?

A: Does the directory exist?  Is it writable by the user?  If not, it won't work and Python will fallback to other locations.  You can see the code here, reproduced here for reference:
def _get_default_tempdir():
    """Calculate the default directory to use for temporary files.
    This routine should be called exactly once.

    We determine whether or not a candidate temp dir is usable by
    trying to create and write to a file in that directory.  If this
    is successful, the test file is deleted.  To prevent denial of
    service, the name of the test file must be randomized."""

    namer = _RandomNameSequence()
    dirlist = _candidate_tempdir_list()
    flags = _text_openflags

    for dir in dirlist:
        if dir != _os.curdir:
            dir = _os.path.normcase(_os.path.abspath(dir))
        # Try only a few names per directory.
        for seq in xrange(100):
            name = namer.next()
            filename = _os.path.join(dir, name)
            try:
                fd = _os.open(filename, flags, 0o600)
                try:
                    try:
                        with _io.open(fd, 'wb', closefd=False) as fp:
                            fp.write(b'blat')
                    finally:
                        _os.close(fd)
                finally:
                    _os.unlink(filename)
                return dir
            except (OSError, IOError) as e:
                if e.args[0] == _errno.EEXIST:
                    continue
                if (_os.name == 'nt' and e.args[0] == _errno.EACCES and
                    _os.path.isdir(dir) and _os.access(dir, _os.W_OK)):
                    # On windows, when a directory with the chosen name already
                    # exists, EACCES error code is returned instead of EEXIST.
                    continue
                break # no point trying more names in this directory
    raise IOError, (_errno.ENOENT,
                    ("No usable temporary directory found in %s" % dirlist))


text:
Q: how to fix build.gradle for map application on android I am developing a basic map example but I'm in trouble with android studio.
I got this error :
Error:(9, 0) Cause: startup failed:build file 'C:\Users\Tugrul\AndroidStudioProjects\ServiceTextSender\build.gradle': 9: expecting '}', found ':' @ line 9, column 31.
    compile 'com.android.support:appcompat-v7:+'1 error

And here an error resource from my build.gradle file(dependencies :
dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:3.1.36′

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

How can I fix this? Could you help me please? I'm in trouble with Android Studio. I'm in trouble with this error.

A: I think your problem is character error. ' and ' are different.
Try change this :
classpath 'com.android.tools.build:gradle:1.3.0'
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:3.1.36′

to this
classpath 'com.android.tools.build:gradle:1.3.0'
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:3.1.36'

Edit:
These are gradle Files:

You need to add your
dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:3.1.36'
}

lines to Module Specific build.gradle file shown as above.

A: Regarding the error:
Looks like you are adding this to the wrong gradle file, should be added to the app's gradle file (the one in the app's folder), not the module (the top one). The top one specifies the gradle plugin to use and as you have it listed here, I'm assuming you are editing the wrong build-gradle file.
If you instead check in the same directory that contains the src-folder (not inside src) you will find the app's dependencies section where you can add that line.
And/Or you are just using the wrong characters should be ' and not '.
Suggested easier solution:
Create a new Google Map Activity using the template when starting a new project, or right click in your project package and choose (in the popup menu):
New -> Google -> Google Maps Activity

And everything will be set up for you.


text:
Q: Script to kill/restart rdpclip? We use remote desktop a lot (XP to Server 2003), and people are having trouble with the clipboard randomly not working. After ensuring that all drives were selected for the remote connection, and rdpclip was killed/restarted, the clipboard works again.
I'm wondering if there's a way I can automate this process for the users so I don't have to manually kill and restart rdpclip every time it stops working for someone. Could I write a batch file that would kill rdpclip and restart it only for the current user? Is there a better solution?

A: To restart it in a .bat:
taskkill /f /im rdpclip.exe /fi "username eq %USERNAME%"
start rdpclip.exe
exit

A: I would recommend to make it(batch) wait a second between taskkill and start. Without it i faced a problem several times: system had not yet killed the proccess by the time the start command came in. So the new proccess didn't start, and the old got killed. Result: no rdpclip.exe at all =(
cls
taskkill /F /FI "USERNAME eq %username%" /IM rdpclip.exe
ping -n 1 -w 1000 1.1.1.1>nul
start rdpclip.exe

Save as .bat.

A: taskkill /f /im rdpclip.exe /fi "username eq %USERNAME%" && rdpclip


text:
Q: What happens if Flink job restarts between two checkpoints? This question is basically similar to the one asked here: Apache Flink fault tolerance.
i.e. what happens if a job restarts between two checkpoints? Will it reprocess the records that were already processed after the last checkpoint?
Take for example I have two jobs, job1 and job2. Job1 consumes records from Kafka, processes them and again produces them to second Kafka topic. Job2 consumes from this second topic and processes the records (in my case its updating values in aerospike using AerospikeClient).
Now from the answer to this question Apache Flink fault tolerance, I can somehow believe that if job1 restarts, it will not produce duplicates records in the sink. I am using FlinkKafkaProducer011 which extends TwoPhaseCommitSinkFunction (https://flink.apache.org/features/2018/03/01/end-to-end-exactly-once-apache-flink.html). Please explain how it will prevent reprocessing (ie duplicate production of records to Kafka).
According to Flink doc, flink restarts a job from last successful checkpoint. So if job2 restarts before completing the checkpoint, it will restart from last checkpoint and the records that were already processed after that last checkpoint will be reprocessed (ie multiple updations in aerospike).
Am I right or is there something else in Flink (& aerospike) that prevents this reprocessing in job2?

A: In such a scenario, Flink will indeed reprocess some events. During recovery the input partitions will have their offsets reset to the offsets in the most recent checkpoint, and events that had been read after that checkpoint will be re-ingested.
However, the FlinkKafkaProducer uses Kafka transactions that are committed when checkpoints are completed. When a job fails, whatever output it has produced since the last checkpoint is protected by transactions that are never committed. So long as that job's consumers are configured to use read_committed as their isolation.level, they won't see any duplicates.
For more details, see Best Practices for Using Kafka Sources/Sinks in Flink Jobs.