问:
Webpack not generating build.js
I moved my codebase to a dockerformat.

I have a docker-compose file with the command:
command: bash -c "rm -rf node_modules && npm install && npm run dev"

and everything works fine, I use rm -rf node_modules because it gives me some errors of missing packages (from my MAC). Doing that it just gets recreated and it works ok on localhost.

I've also added volumes, so when I change something in my code it gets reflected in my container, this also works fine (apart of the hot-reload, but that's not a big deal).

Now I usually just comment out the line: command: bash -c "rm -rf node_modules && npm install && npm run dev" on my docker-compose file and instead I add:
command: bash -c "rm -rf node_modules && npm install && npm run build" to build my bundle, so that in production I don't have node at all, however this gives me no results.

I'm not sure if it's a problem with volumes, i.e. it gets built in the container but I can't access it from my machine (which I don't think because changing code in my local machine does get reflected in my container) or it doesn't get built at all for some reason.

This is the output of command: bash -c "rm -rf node_modules && npm install && npm run build --verbose"

```<code>NODE     | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
NODE     | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
NODE     |
NODE     | added 115 packages in 11.036s
NODE     | npm info it worked if it ends with ok
NODE     | npm verb cli [ '/usr/local/bin/node',
NODE     | npm verb cli   '/usr/local/bin/npm',
NODE     | npm verb cli   'run',
NODE     | npm verb cli   'build',
NODE     | npm verb cli   '--verbose' ]
NODE     | npm info using npm@5.5.1
NODE     | npm info using node@v9.2.0
NODE     | npm verb run-script [ 'prebuild', 'build', 'postbuild' ]
NODE     | npm info lifecycle frontend@1.0.0~prebuild: frontend@1.0.0
NODE     | npm info lifecycle frontend@1.0.0~build: frontend@1.0.0
NODE     |
NODE     | > frontend@1.0.0 build /code/client
NODE     | > cross-env NODE_ENV=production webpack --progress --hide-modules
NODE     |
NODE     | Hash: cda5e46c2c7f4ba2903b
NODE     | Version: webpack 3.9.1
NODE     | Time: 27298ms
NODE     |        Asset     Size  Chunks                    Chunk Names
NODE     |     build.js  1.29 MB       0  [emitted]  [big]  main
NODE     | build.js.map  7.65 MB       0  [emitted]         main
NODE     | npm verb lifecycle frontend@1.0.0~build: unsafe-perm in lifecycle true
NODE     | npm verb lifecycle frontend@1.0.0~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/code/client/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NODE     | npm verb lifecycle frontend@1.0.0~build: CWD: /code/client
NODE     | npm info lifecycle frontend@1.0.0~postbuild: frontend@1.0.0
NODE     | npm verb exit [ 0, true ]
NODE     | npm info ok
</code>```

And my webpack conf file starts like this:

```<code>var path = require('path')
var webpack = require('webpack')

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, '../static/dist/'),
    publicPath: '/dist/',
    filename: 'build.js'
  },
</code>```

Which at least before worked fine since my app looks like this:

```<code>- manage.py
- static
  - dist
  - others
- client
  - webpack.config.js
</code>```

etc

Why nothing gets build in dist?

Update

I used exec to look inside the container. I can't find the build.js anywhere. I also run touch abc.txt inside /code/static/dist and it gets also created on my localhost, i.e. the volumes work fine.It must be a problem of webpack and not docker.

Update 2

I've also tried the full path like this, still nothing:

```<code>module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, '/code/static/dist'),
    publicPath: '/dist/',
    filename: 'build.js'
  },
</code>```

Edit 3

I've tried to look for build.js I found these files, but I think that those are not my build.js:

```<code>root@0xxxxxx:/code# find . -name build.js
./client/node_modules/node-forge/nodejs/build.js
./client/node_modules/errno/build.js
./client/node_modules/vue-template-compiler/build.js
./client/node_modules/builtin-status-codes/build.js
./client/node_modules/webpack-dev-middleware/node_modules/mime/src/build.js
./client/node_modules/node-gyp/lib/build.js
./client/node_modules/node-sass/scripts/build.js
./client/node_modules/mime/build/build.js
./client/node_modules/npm/node_modules/node-gyp/lib/build.js
./client/node_modules/npm/node_modules/sorted-union-stream/node_modules/from2/node_modules/readable-stream/node_modules/isarray/build/build.js
./client/node_modules/npm/lib/install/action/build.js
./client/node_modules/npm/lib/build.js
</code>```

答:
You are missing var path declaration. But webpack should be crushing without it, so not sure if that's the reason.</p>

```<code>var path = require('path');
</code>```

Title: Webpack not generating build.js

Body:
I moved my codebase to a dockerformat.

I have a docker-compose file with the command:
command: bash -c "rm -rf node_modules && npm install && npm run dev"

and everything works fine, I use rm -rf node_modules because it gives me some errors of missing packages (from my MAC). Doing that it just gets recreated and it works ok on localhost.

I've also added volumes, so when I change something in my code it gets reflected in my container, this also works fine (apart of the hot-reload, but that's not a big deal).

Now I usually just comment out the line: command: bash -c "rm -rf node_modules && npm install && npm run dev" on my docker-compose file and instead I add:
command: bash -c "rm -rf node_modules && npm install && npm run build" to build my bundle, so that in production I don't have node at all, however this gives me no results.

I'm not sure if it's a problem with volumes, i.e. it gets built in the container but I can't access it from my machine (which I don't think because changing code in my local machine does get reflected in my container) or it doesn't get built at all for some reason.

This is the output of command: bash -c "rm -rf node_modules && npm install && npm run build --verbose"

NODE     | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
NODE     | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
NODE     |
NODE     | added 115 packages in 11.036s
NODE     | npm info it worked if it ends with ok
NODE     | npm verb cli [ '/usr/local/bin/node',
NODE     | npm verb cli   '/usr/local/bin/npm',
NODE     | npm verb cli   'run',
NODE     | npm verb cli   'build',
NODE     | npm verb cli   '--verbose' ]
NODE     | npm info using npm@5.5.1
NODE     | npm info using node@v9.2.0
NODE     | npm verb run-script [ 'prebuild', 'build', 'postbuild' ]
NODE     | npm info lifecycle frontend@1.0.0~prebuild: frontend@1.0.0
NODE     | npm info lifecycle frontend@1.0.0~build: frontend@1.0.0
NODE     |
NODE     | > frontend@1.0.0 build /code/client
NODE     | > cross-env NODE_ENV=production webpack --progress --hide-modules
NODE     |
NODE     | Hash: cda5e46c2c7f4ba2903b
NODE     | Version: webpack 3.9.1
NODE     | Time: 27298ms
NODE     |        Asset     Size  Chunks                    Chunk Names
NODE     |     build.js  1.29 MB       0  [emitted]  [big]  main
NODE     | build.js.map  7.65 MB       0  [emitted]         main
NODE     | npm verb lifecycle frontend@1.0.0~build: unsafe-perm in lifecycle true
NODE     | npm verb lifecycle frontend@1.0.0~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/code/client/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NODE     | npm verb lifecycle frontend@1.0.0~build: CWD: /code/client
NODE     | npm info lifecycle frontend@1.0.0~postbuild: frontend@1.0.0
NODE     | npm verb exit [ 0, true ]
NODE     | npm info ok

And my webpack conf file starts like this:

var path = require('path')
var webpack = require('webpack')

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, '../static/dist/'),
    publicPath: '/dist/',
    filename: 'build.js'
  },

Which at least before worked fine since my app looks like this:

- manage.py
- static
  - dist
  - others
- client
  - webpack.config.js

etc

Why nothing gets build in dist?

Update

I used exec to look inside the container. I can't find the build.js anywhere. I also run touch abc.txt inside /code/static/dist and it gets also created on my localhost, i.e. the volumes work fine.It must be a problem of webpack and not docker.

Update 2

I've also tried the full path like this, still nothing:

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, '/code/static/dist'),
    publicPath: '/dist/',
    filename: 'build.js'
  },

Edit 3

I've tried to look for build.js I found these files, but I think that those are not my build.js:

root@0xxxxxx:/code# find . -name build.js
./client/node_modules/node-forge/nodejs/build.js
./client/node_modules/errno/build.js
./client/node_modules/vue-template-compiler/build.js
./client/node_modules/builtin-status-codes/build.js
./client/node_modules/webpack-dev-middleware/node_modules/mime/src/build.js
./client/node_modules/node-gyp/lib/build.js
./client/node_modules/node-sass/scripts/build.js
./client/node_modules/mime/build/build.js
./client/node_modules/npm/node_modules/node-gyp/lib/build.js
./client/node_modules/npm/node_modules/sorted-union-stream/node_modules/from2/node_modules/readable-stream/node_modules/isarray/build/build.js
./client/node_modules/npm/lib/install/action/build.js
./client/node_modules/npm/lib/build.js

Body:
You are missing var path declaration. But webpack should be crushing without it, so not sure if that's the reason.

var path = require('path');


来源: stackexchange

问:
Building Abreviations Dictionary from Text file
I would like to build a dictionary of abreviations.

I have a text file with a lot of abreviations. The text file looks like this(after import)

```<code>with open('abreviations.txt') as ab:
    ab_words = ab.read().splitlines()
</code>```

An extract:

```<code>'ACE',
'Access Control Entry',
'ACK',
'Acknowledgement',
'ACORN',
'A Completely Obsessive Really Nutty person',
</code>```

Now I want to build the dictionnary, where I have every uneven line as a dictionary key and every even line as the dictionary value.

Hence I should be able to write at the end:

```<code>ab_dict['ACE']
</code>```

and get the result:

```<code>'Access Control Entry'
</code>```

Also, How can I make it case-insensitive ?

```<code>ab_dict['ace']
</code>```

should yield the same result

```<code>'Access Control Entry'
</code>```

In fact, it would be perfect, if the output would also be lower case:

```<code>'access control entry'
</code>```

Here is a link to the text file: https://www.dropbox.com/s/91afgnupk686p9y/abreviations.txt?dl=0

答:
Here's another solution based on the pairwise function from this solution:

```<code>from requests.structures import CaseInsensitiveDict

def pairwise(iterable):
    "s -> (s0, s1), (s2, s3), (s4, s5), ..."
    a = iter(iterable)
    return zip(a, a)

with open('abreviations.txt') as reader:
    abr_dict = CaseInsensitiveDict()
    for abr, full in pairwise(reader):
        abr_dict[abr.strip()] = full.strip()
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I would like to build a dictionary of abreviations.

I have a text file with a lot of abreviations. The text file looks like this(after import)

with open('abreviations.txt') as ab:
    ab_words = ab.read().splitlines()

An extract:

'ACE',
'Access Control Entry',
'ACK',
'Acknowledgement',
'ACORN',
'A Completely Obsessive Really Nutty person',

Now I want to build the dictionnary, where I have every uneven line as a dictionary key and every even line as the dictionary value.

Hence I should be able to write at the end:

ab_dict['ACE']

and get the result:

'Access Control Entry'

Also, How can I make it case-insensitive ?

ab_dict['ace']

should yield the same result

'Access Control Entry'

In fact, it would be perfect, if the output would also be lower case:

'access control entry'

Here is a link to the text file: https://www.dropbox.com/s/91afgnupk686p9y/abreviations.txt?dl=0

Body:
Here's another solution based on the pairwise function from this solution:

from requests.structures import CaseInsensitiveDict

def pairwise(iterable):
    "s -> (s0, s1), (s2, s3), (s4, s5), ..."
    a = iter(iterable)
    return zip(a, a)

with open('abreviations.txt') as reader:
    abr_dict = CaseInsensitiveDict()
    for abr, full in pairwise(reader):
        abr_dict[abr.strip()] = full.strip()


问:
Subtract rows then sum values
I have this dataframe where I would like to perform some calculations.

```<code>aa = c (1,3,1,0,0,1,6,1,14,3,0)
bb = c (0,0,5,0,0,1,6,0,2,15,1)
ee = rbind( aa,bb)
df = as.data.frame (ee)
</code>```

First I would like to subtract from the first value in the row aa the first value in the row bb ... 1 - 0 ... then the result add to the second value in the row aa ... 1 + 3 = 4 ... then 4 - 0 ... and in aa 4 + 1 = 5 and so on ...

The desired outcome is:

```<code>cc = c (1,4,5,0,0,1,6,1,15,16,1)
ff = rbind( cc,bb)
df1 = as.data.frame(ff)
</code>```

Any ideas really appreciated !

答:
You want to perform a difference of cumulative sums:

```<code>cc <- cumsum(aa) - cumsum(c(0, bb[-length(bb)]))
</code>```

I added a 0 at the beginning and dropped the last elment of bb. Because you want at the ith element the result before substracting the ith bb

I test it:

```<code>aa = c (1,3,1,0,0,1,6,1,14,3,0)
bb = c (0,0,5,0,0,1,6,0,2,15,1)
cc <- cumsum(aa) - cumsum(c(0, bb[-length(bb)]))
cc
[1]  1  4  5  0  0  1  6  1 15 16  1
</code>```

Edit:
Another way to do it (thanks to lmo) is:

```<code>cc <- cumsum(aa - c(0, head(bb, -1)))
</code>```

Title: Subtract rows then sum values

Body:
I have this dataframe where I would like to perform some calculations.

aa = c (1,3,1,0,0,1,6,1,14,3,0)
bb = c (0,0,5,0,0,1,6,0,2,15,1)
ee = rbind( aa,bb)
df = as.data.frame (ee)

First I would like to subtract from the first value in the row aa the first value in the row bb ... 1 - 0 ... then the result add to the second value in the row aa ... 1 + 3 = 4 ... then 4 - 0 ... and in aa 4 + 1 = 5 and so on ...

The desired outcome is:

cc = c (1,4,5,0,0,1,6,1,15,16,1)
ff = rbind( cc,bb)
df1 = as.data.frame(ff)

Any ideas really appreciated !

Body:
You want to perform a difference of cumulative sums:

cc <- cumsum(aa) - cumsum(c(0, bb[-length(bb)]))

I added a 0 at the beginning and dropped the last elment of bb. Because you want at the ith element the result before substracting the ith bb

I test it:

aa = c (1,3,1,0,0,1,6,1,14,3,0)
bb = c (0,0,5,0,0,1,6,0,2,15,1)
cc <- cumsum(aa) - cumsum(c(0, bb[-length(bb)]))
cc
[1]  1  4  5  0  0  1  6  1 15 16  1

Edit:
Another way to do it (thanks to lmo) is:

cc <- cumsum(aa - c(0, head(bb, -1)))


问:
Host files or stream data on a self-hosted WCF (non-IIS) service that uses HTTP?
Is it possible to host custom data on self-hosted HTTP-configured WCF services, such as custom HTML or XML files, without involving IIS? I’m speaking of a ServiceHost instance that instantiates its own EndPoints/listeners.

I have an app that uses a self-hosted WCF service and it has a Windows Forms client but I’m looking at adding a lightweight Silverilght interface as well, but I don’t want to use IIS for the same reason as I didn’t want to use full-blown SQL Server -- I'm trying to make the whole thing self-packaged without IIS dependencies. (Yes, I know that not involving IIS isn’t best practice as it will make it somewhat less reliable and less flexible, but this feature isn’t a major part of this.)

If this is not possible, I’ll have to choose between full-blown IIS on the server or full-blown WPF on the client, I was just curious if anyone had uncovered this before.

Thanks,

Jon

答: Have you looked into either System.Net.HttpListener, or even Cassini?  Perhaps either of those might provide you with what you need?</p>

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Fabian Steeg

OwnerDisplayName: Christian Nunciato


问:
Not receiving GCM notifications once app is killed on Xiaomi and Lenovo devices in Android
Can anyone help me to receive notifications on Xiaomi and Lenovo devices even after the app is killed(no more in the background)?

Edit 1

I added GCM broadcast receiver. Here is the code

inside AndroidManifest.xml

```<code> <receiver
       android:name="com.don.offers.broadcast_receiver.GcmBroadcastReceiver"
       android:permission="com.google.android.c2dm.permission.SEND" >
       <intent-filter>
           <!-- Receives the actual messages. -->
           <action android:name="com.google.android.c2dm.intent.RECEIVE" />
           <category android:name="com.google.android.gcm.demo.app" />
       </intent-filter>
   </receiver>
</code>```

GcmBroadcastReceiver.java

```<code>public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        ComponentName comp = new ComponentName(context.getPackageName(),
                RegistrationIntentService.class.getName());
        // Start the service, keeping the device awake while it is launching.
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }
}
</code>```

It solved my problem on MI device but not on Lenovo devices.

Thanks

答:
On devices with MIUI you can ask user to add your app in the autostart list of the phone using this:

```<code> private void addAppToAutoStartList() {
  AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
  alertDialogBuilder.setTitle("Warning!");
  alertDialogBuilder.setMessage("Please add this app to the Auto Start list of your device for better performance.");
  alertDialogBuilder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
   @Override public void onClick(DialogInterface dialogInterface, int i) {
    dialogInterface.dismiss();
    try {
     AppPreferences.getInstance(HomeActivity.this).setMiSpecialSetting(true);
     Intent intent = new Intent();
     intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
     startActivity(intent);
    } catch (Exception e) {
     Toast.makeText(HomeActivity.this, "Unable to add!", Toast.LENGTH_SHORT).show();
    }
   }
  });
  alertDialogBuilder.setNegativeButton("Ignore", new DialogInterface.OnClickListener() {
   @Override public void onClick(DialogInterface dialog, int arg1) {
    dialog.dismiss();
   }
  });
  AlertDialog alertDialog = alertDialogBuilder.create();
  alertDialog.show();
 }
</code>```

And call this method by checking for manufacturer like

```<code>if(android.os.Build.MANUFACTURER.equalsIgnoreCase("xiaomi")) { addAppToAutoStartList();
}
</code>```

Conclusion:
1. In this way ff user adds your app to autostart list then your app will be able to get push notifications without any problem.
2. If you have any scheduled job to run then you will be able to run your job even after one key clean but there is a limitation, your job will run but not according to your time and flex, it will get called anytime after 1 day and next call might come after 2 days so there is no guarantee of periodic call. But this is the only way I can see as of now for MIUI like custom OS. And I have tested this in many Xiaomi devices having android 5 to 7 and every where the results are same.

Body:
Can anyone help me to receive notifications on Xiaomi and Lenovo devices even after the app is killed(no more in the background)?

Edit 1

I added GCM broadcast receiver. Here is the code

inside AndroidManifest.xml

 <receiver
       android:name="com.don.offers.broadcast_receiver.GcmBroadcastReceiver"
       android:permission="com.google.android.c2dm.permission.SEND" >
       <intent-filter>

           <action android:name="com.google.android.c2dm.intent.RECEIVE" />
           <category android:name="com.google.android.gcm.demo.app" />
       </intent-filter>
   </receiver>

GcmBroadcastReceiver.java

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        ComponentName comp = new ComponentName(context.getPackageName(),
                RegistrationIntentService.class.getName());
        // Start the service, keeping the device awake while it is launching.
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }
}

It solved my problem on MI device but not on Lenovo devices.

Thanks

Body:
On devices with MIUI you can ask user to add your app in the autostart list of the phone using this:

 private void addAppToAutoStartList() {
  AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
  alertDialogBuilder.setTitle("Warning!");
  alertDialogBuilder.setMessage("Please add this app to the Auto Start list of your device for better performance.");
  alertDialogBuilder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
   @Override public void onClick(DialogInterface dialogInterface, int i) {
    dialogInterface.dismiss();
    try {
     AppPreferences.getInstance(HomeActivity.this).setMiSpecialSetting(true);
     Intent intent = new Intent();
     intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
     startActivity(intent);
    } catch (Exception e) {
     Toast.makeText(HomeActivity.this, "Unable to add!", Toast.LENGTH_SHORT).show();
    }
   }
  });
  alertDialogBuilder.setNegativeButton("Ignore", new DialogInterface.OnClickListener() {
   @Override public void onClick(DialogInterface dialog, int arg1) {
    dialog.dismiss();
   }
  });
  AlertDialog alertDialog = alertDialogBuilder.create();
  alertDialog.show();
 }

And call this method by checking for manufacturer like

if(android.os.Build.MANUFACTURER.equalsIgnoreCase("xiaomi")) { addAppToAutoStartList();
}

Conclusion:
1. In this way ff user adds your app to autostart list then your app will be able to get push notifications without any problem.
2. If you have any scheduled job to run then you will be able to run your job even after one key clean but there is a limitation, your job will run but not according to your time and flex, it will get called anytime after 1 day and next call might come after 2 days so there is no guarantee of periodic call. But this is the only way I can see as of now for MIUI like custom OS. And I have tested this in many Xiaomi devices having android 5 to 7 and every where the results are same.


问:
Bash-shell grammar issue about Ternary operator and printf function
```<code>cat file
chenghuanghuijia jidianzhong 100 E20128
pannybudaqiu gujihuihenwan -1
shuijiao buxihuan 20 E20138
huijiakan babamama 10
</code>```

I want get the result that when the line contains E2[0-9]*$ , the end of the line will be printed, if the line not contain E2[0-9]*$, the end of the line will be printed NULL or \n.

Here is my code:

```<code>awk '{printf("%s\n",($NF~/E2[0-9]*$/? "E2.*$" : NULL))}' file
</code>```

The output as below:

```<code>E2.*$

E2.*$
</code>```

but I want to print E20128 & E20138, So I verified my code with deleting " "

```<code>awk '{printf("%s\n",($NF~/E2[0-9]*$/? E2.*$ : NULL))}' file
</code>```

Then it comes the error:

```<code>awk: cmd. line:1: {printf("%s\n",($NF~/E2[0-9]*$/? E2.*$ : NULL))}
awk: cmd. line:1:                                    ^ syntax error
awk: cmd. line:1: {printf("%s\n",($NF~/E2[0-9]*$/? E2.*$ : NULL))}
awk: cmd. line:1:                                               ^ syntax error
awk: cmd. line:1: {printf("%s\n",($NF~/E2[0-9]*$/? E2.*$ : NULL))}
awk: cmd. line:1:                                                ^ syntax error
</code>```

So I think is the grammar issue of Ternary operator( _?x:y) or printf function.
please support me .

答:
You can try this awk</p>

```<code>awk '{$0=$NF}!/E2[0-9]*$/{$0=""}1' infile

{$0=$NF} : for each line replace the complete line by the last field.

!/E2[0-9]*$/ if the line not match the regex

{$0=""} : substitute the complete line by nothing

1 : print each line
</code>```

Body:
cat file
chenghuanghuijia jidianzhong 100 E20128
pannybudaqiu gujihuihenwan -1
shuijiao buxihuan 20 E20138
huijiakan babamama 10

I want get the result that when the line contains E2[0-9]*$ , the end of the line will be printed, if the line not contain E2[0-9]*$, the end of the line will be printed NULL or \n.

Here is my code:

awk '{printf("%s\n",($NF~/E2[0-9]*$/? "E2.*$" : NULL))}' file

The output as below:

E2.*$

E2.*$

but I want to print E20128 & E20138, So I verified my code with deleting " "

awk '{printf("%s\n",($NF~/E2[0-9]*$/? E2.*$ : NULL))}' file

Then it comes the error:

awk: cmd. line:1: {printf("%s\n",($NF~/E2[0-9]*$/? E2.*$ : NULL))}
awk: cmd. line:1:                                    ^ syntax error
awk: cmd. line:1: {printf("%s\n",($NF~/E2[0-9]*$/? E2.*$ : NULL))}
awk: cmd. line:1:                                               ^ syntax error
awk: cmd. line:1: {printf("%s\n",($NF~/E2[0-9]*$/? E2.*$ : NULL))}
awk: cmd. line:1:                                                ^ syntax error

So I think is the grammar issue of Ternary operator( _?x:y) or printf function.
please support me .

Body:
You can try this awk

awk '{$0=$NF}!/E2[0-9]*$/{$0=""}1' infile

{$0=$NF} : for each line replace the complete line by the last field.

!/E2[0-9]*$/ if the line not match the regex

{$0=""} : substitute the complete line by nothing

1 : print each line


问:
Load shared object in Rcpp package
I want to include ./libdynamic/dynamic.h to my package with Rcpp. Directory libdynamic is nested in the project's folder src.
While I am trying to build a R package, I face dyn.load error.

```<code>Error in dyn.load(file, DLLpath = DLLpath, ...) :
      unable to load shared object
</code>```

Sources structure.

```<code>.:
total 60K
-rw-rw-r-- 1 1.2K Dec 29 10:17 essential.h
drwxrwxr-x 3 4.0K Dec 28 19:24 libdynamic
-rw-rw-r-- 1 1.8K Dec 28 18:34 main.cpp
-rw-rw-r-- 1   45 Dec 29 09:59 Makevars
-rw-rw-r-- 1 1.1K Dec 28 20:17 RcppExports.cpp
-rw-rw-r-- 1    0 Dec 28 12:12 README
-rw-rw-r-- 1 4.6K Dec 29 09:49 Rulib.cpp
-rw-rw-r-- 1  335 Dec 28 13:55 structs.cpp
-rw-rw-r-- 1  22K Dec 28 19:24 structs.o

./libdynamic:
total 8.0K
drwxrwxr-x 2 4.0K Dec 28 15:49 dynamic
-rw-rw-r-- 1  453 Dec 29 10:12 dynamic.h

./libdynamic/dynamic:
total 60K
-rw-rw-r-- 1 2.1K Dec 28 15:49 buffer.c
-rw-rw-r-- 1  746 Dec 28 15:49 buffer.h
-rw-rw-r-- 1 5.4K Dec 28 15:49 cfarmhash.c
-rw-rw-r-- 1  136 Dec 28 15:49 cfarmhash.h
-rw-rw-r-- 1 4.1K Dec 28 15:49 mapi.c
-rw-rw-r-- 1 1.7K Dec 28 15:49 mapi.h
-rw-rw-r-- 1 5.1K Dec 28 15:49 maps.c
-rw-rw-r-- 1 1.5K Dec 28 15:49 maps.h
-rw-rw-r-- 1 3.7K Dec 28 15:49 string.c
-rw-rw-r-- 1 1.2K Dec 28 15:49 string.h
-rw-rw-r-- 1 2.3K Dec 28 15:49 vector.c
-rw-rw-r-- 1 1016 Dec 28 15:49 vector.h
</code>```

I have made successful compilation in Eclipse with Rcpp.h and R.h:

```<code>gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/string.o ../libdynamic/dynamic/string.c
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/cfarmhash.o ../libdynamic/dynamic/cfarmhash.c
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/mapi.o ../libdynamic/dynamic/mapi.c
../libdynamic/dynamic/mapi.c: In function ‘mapi_rehash’:
../libdynamic/dynamic/mapi.c:212:7: warning: implicit declaration of function ‘aligned_alloc’ [-Wimplicit-function-declaration]
       nm.objects = (char *) aligned_alloc(64, MAPI_ROUNDUP(c * nm.object_size, 64));
       ^
../libdynamic/dynamic/mapi.c:212:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       nm.objects = (char *) aligned_alloc(64, MAPI_ROUNDUP(c * nm.object_size, 64));
                    ^
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/maps.o ../libdynamic/dynamic/maps.c
g++ -D__cplusplus=201103L -I/home/cracs/workspace/R-ulib-wrapper/libdynamic -I/usr/local/lib/R/site-library/Rcpp/include -I/usr/share/R/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o structs.o ../structs.cpp
g++ -D__cplusplus=201103L -I/home/cracs/workspace/R-ulib-wrapper/libdynamic -I/usr/local/lib/R/site-library/Rcpp/include -I/usr/share/R/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o main.o ../main.cpp
g++ -D__cplusplus=201103L -I/home/cracs/workspace/R-ulib-wrapper/libdynamic -I/usr/local/lib/R/site-library/Rcpp/include -I/usr/share/R/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o Rulib.o ../Rulib.cpp
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/vector.o ../libdynamic/dynamic/vector.c
g++ -D__cplusplus=201103L -I/home/cracs/workspace/R-ulib-wrapper/libdynamic -I/usr/local/lib/R/site-library/Rcpp/include -I/usr/share/R/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o RcppExports.o ../RcppExports.cpp
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/buffer.o ../libdynamic/dynamic/buffer.c
g++ -L/usr/local/lib/R/site-library/Rcpp/libs -L/usr/lib/R/lib -o R-ulib-wrapper structs.o main.o libdynamic/dynamic/vector.o libdynamic/dynamic/string.o libdynamic/dynamic/maps.o libdynamic/dynamic/mapi.o libdynamic/dynamic/cfarmhash.o libdynamic/dynamic/buffer.o Rulib.o RcppExports.o -lR
</code>```

R CMD check

```<code>* installing *source* package ‘Rulib’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -I../src/libdynamic -std=c++0x  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -I../src/libdynamic -std=c++0x  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c Rulib.cpp -o Rulib.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -I../src/libdynamic -std=c++0x  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c main.cpp -o main.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -I../src/libdynamic -std=c++0x  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c structs.cpp -o structs.o
g++ -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o Rulib.so RcppExports.o Rulib.o main.o structs.o -L/usr/lib/R/lib -lR
installing to /home/cracs/src/Rulib.Rcheck/Rulib/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/home/cracs/src/Rulib.Rcheck/Rulib/libs/Rulib.so':
  /home/cracs/src/Rulib.Rcheck/Rulib/libs/Rulib.so: undefined symbol: maps_begin
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/cracs/src/Rulib.Rcheck/Rulib’
</code>```

Makevars:

```<code>PKG_CPPFLAGS+=-I../src/libdynamic -std=c++0x
</code>```

Question:

Looks like when R building package it doesn't link previously compiled stuff.
How I can force R to compile everything in nested folders and link it?

答:
As mentioned by @dirk-eddelbuettel:

Keep all files in src and everything works automatically.

Title: Load shared object in Rcpp package

Body:
I want to include ./libdynamic/dynamic.h to my package with Rcpp. Directory libdynamic is nested in the project's folder src.
While I am trying to build a R package, I face dyn.load error.

Error in dyn.load(file, DLLpath = DLLpath, ...) :
      unable to load shared object

Sources structure.

.:
total 60K
-rw-rw-r-- 1 1.2K Dec 29 10:17 essential.h
drwxrwxr-x 3 4.0K Dec 28 19:24 libdynamic
-rw-rw-r-- 1 1.8K Dec 28 18:34 main.cpp
-rw-rw-r-- 1   45 Dec 29 09:59 Makevars
-rw-rw-r-- 1 1.1K Dec 28 20:17 RcppExports.cpp
-rw-rw-r-- 1    0 Dec 28 12:12 README
-rw-rw-r-- 1 4.6K Dec 29 09:49 Rulib.cpp
-rw-rw-r-- 1  335 Dec 28 13:55 structs.cpp
-rw-rw-r-- 1  22K Dec 28 19:24 structs.o

./libdynamic:
total 8.0K
drwxrwxr-x 2 4.0K Dec 28 15:49 dynamic
-rw-rw-r-- 1  453 Dec 29 10:12 dynamic.h

./libdynamic/dynamic:
total 60K
-rw-rw-r-- 1 2.1K Dec 28 15:49 buffer.c
-rw-rw-r-- 1  746 Dec 28 15:49 buffer.h
-rw-rw-r-- 1 5.4K Dec 28 15:49 cfarmhash.c
-rw-rw-r-- 1  136 Dec 28 15:49 cfarmhash.h
-rw-rw-r-- 1 4.1K Dec 28 15:49 mapi.c
-rw-rw-r-- 1 1.7K Dec 28 15:49 mapi.h
-rw-rw-r-- 1 5.1K Dec 28 15:49 maps.c
-rw-rw-r-- 1 1.5K Dec 28 15:49 maps.h
-rw-rw-r-- 1 3.7K Dec 28 15:49 string.c
-rw-rw-r-- 1 1.2K Dec 28 15:49 string.h
-rw-rw-r-- 1 2.3K Dec 28 15:49 vector.c
-rw-rw-r-- 1 1016 Dec 28 15:49 vector.h

I have made successful compilation in Eclipse with Rcpp.h and R.h:

gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/string.o ../libdynamic/dynamic/string.c
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/cfarmhash.o ../libdynamic/dynamic/cfarmhash.c
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/mapi.o ../libdynamic/dynamic/mapi.c
../libdynamic/dynamic/mapi.c: In function ‘mapi_rehash’:
../libdynamic/dynamic/mapi.c:212:7: warning: implicit declaration of function ‘aligned_alloc’ [-Wimplicit-function-declaration]
       nm.objects = (char *) aligned_alloc(64, MAPI_ROUNDUP(c * nm.object_size, 64));
       ^
../libdynamic/dynamic/mapi.c:212:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       nm.objects = (char *) aligned_alloc(64, MAPI_ROUNDUP(c * nm.object_size, 64));
                    ^
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/maps.o ../libdynamic/dynamic/maps.c
g++ -D__cplusplus=201103L -I/home/cracs/workspace/R-ulib-wrapper/libdynamic -I/usr/local/lib/R/site-library/Rcpp/include -I/usr/share/R/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o structs.o ../structs.cpp
g++ -D__cplusplus=201103L -I/home/cracs/workspace/R-ulib-wrapper/libdynamic -I/usr/local/lib/R/site-library/Rcpp/include -I/usr/share/R/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o main.o ../main.cpp
g++ -D__cplusplus=201103L -I/home/cracs/workspace/R-ulib-wrapper/libdynamic -I/usr/local/lib/R/site-library/Rcpp/include -I/usr/share/R/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o Rulib.o ../Rulib.cpp
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/vector.o ../libdynamic/dynamic/vector.c
g++ -D__cplusplus=201103L -I/home/cracs/workspace/R-ulib-wrapper/libdynamic -I/usr/local/lib/R/site-library/Rcpp/include -I/usr/share/R/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -o RcppExports.o ../RcppExports.cpp
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o libdynamic/dynamic/buffer.o ../libdynamic/dynamic/buffer.c
g++ -L/usr/local/lib/R/site-library/Rcpp/libs -L/usr/lib/R/lib -o R-ulib-wrapper structs.o main.o libdynamic/dynamic/vector.o libdynamic/dynamic/string.o libdynamic/dynamic/maps.o libdynamic/dynamic/mapi.o libdynamic/dynamic/cfarmhash.o libdynamic/dynamic/buffer.o Rulib.o RcppExports.o -lR

R CMD check

* installing *source* package ‘Rulib’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -I../src/libdynamic -std=c++0x  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -I../src/libdynamic -std=c++0x  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c Rulib.cpp -o Rulib.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -I../src/libdynamic -std=c++0x  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c main.cpp -o main.o
g++ -I/usr/share/R/include -DNDEBUG -I/usr/local/lib/R/site-library/Rcpp/include -I../src/libdynamic -std=c++0x  -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c structs.cpp -o structs.o
g++ -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o Rulib.so RcppExports.o Rulib.o main.o structs.o -L/usr/lib/R/lib -lR
installing to /home/cracs/src/Rulib.Rcheck/Rulib/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/home/cracs/src/Rulib.Rcheck/Rulib/libs/Rulib.so':
  /home/cracs/src/Rulib.Rcheck/Rulib/libs/Rulib.so: undefined symbol: maps_begin
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/cracs/src/Rulib.Rcheck/Rulib’

Makevars:

PKG_CPPFLAGS+=-I../src/libdynamic -std=c++0x

Question:

Looks like when R building package it doesn't link previously compiled stuff.
How I can force R to compile everything in nested folders and link it?


问:
AQjmsFactory issue with Point-to-Point
I should connect to an Oracle AQ single consumer Point-to-Point queue by the AQjmsFactory.getConnectionFactory API (as stated by the Oracle documentation) using Spring/Camel frameworks.

The following error stack shows me that it tries to create a topic connection.

Could anybody tell me why?

Thank you so much!

```<code>org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is oracle.jms.AQjmsException: JMS-243: Argomento MY_QUEUE non trovato; nested exception is oracle.jms.AQjmsException: JMS-142: È necessario creare largomento JMS nelle tabelle di coda attivate per più consumatori
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487)
    at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:469)
    at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:414)
    at org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:368)
    at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:154)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
    at org.apache.camel.component.dataset.DataSetConsumer.sendMessages(DataSetConsumer.java:89)
    at org.apache.camel.component.dataset.DataSetConsumer$1.run(DataSetConsumer.java:70)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: oracle.jms.AQjmsException: JMS-243: Argomento MY_QUEUE non trovato
    at oracle.jms.AQjmsError.throwEx(AQjmsError.java:374)
    at oracle.jms.AQjmsSession.createTopic(AQjmsSession.java:2723)
    at org.springframework.jms.support.destination.DynamicDestinationResolver.resolveTopic(DynamicDestinationResolver.java:72)
    at org.springframework.jms.support.destination.DynamicDestinationResolver.resolveDestinationName(DynamicDestinationResolver.java:55)
    at org.springframework.jms.support.destination.JmsDestinationAccessor.resolveDestinationName(JmsDestinationAccessor.java:114)
    at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.access$000(JmsConfiguration.java:458)
    at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate$1.doInJms(JmsConfiguration.java:471)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:484)
    ... 15 common frames omitted
Caused by: oracle.jms.AQjmsException: JMS-142: È necessario creare largomento JMS nelle tabelle di coda attivate per più consumatori
    at oracle.jms.AQjmsError.throwEx(AQjmsError.java:313)
    at oracle.jms.AQjmsSession.getTopic(AQjmsSession.java:5899)
    at oracle.jms.AQjmsSession.createTopic(AQjmsSession.java:2716)
    ... 21 common frames omitted
</code>```

答: I solved on my own debugging the camel source code (due to an inherited legacy sources): it was an error on ActiveMQ component addressing "oracleaq:topic:MY_QUEUE" in place of "oracleaq:MY_QUEUE".</p>

Title: AQjmsFactory issue with Point-to-Point

Body:
I should connect to an Oracle AQ single consumer Point-to-Point queue by the AQjmsFactory.getConnectionFactory API (as stated by the Oracle documentation) using Spring/Camel frameworks.

The following error stack shows me that it tries to create a topic connection.

Could anybody tell me why?

Thank you so much!

org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is oracle.jms.AQjmsException: JMS-243: Argomento MY_QUEUE non trovato; nested exception is oracle.jms.AQjmsException: JMS-142: È necessario creare largomento JMS nelle tabelle di coda attivate per più consumatori
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487)
    at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:469)
    at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:414)
    at org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:368)
    at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:154)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
    at org.apache.camel.component.dataset.DataSetConsumer.sendMessages(DataSetConsumer.java:89)
    at org.apache.camel.component.dataset.DataSetConsumer$1.run(DataSetConsumer.java:70)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: oracle.jms.AQjmsException: JMS-243: Argomento MY_QUEUE non trovato
    at oracle.jms.AQjmsError.throwEx(AQjmsError.java:374)
    at oracle.jms.AQjmsSession.createTopic(AQjmsSession.java:2723)
    at org.springframework.jms.support.destination.DynamicDestinationResolver.resolveTopic(DynamicDestinationResolver.java:72)
    at org.springframework.jms.support.destination.DynamicDestinationResolver.resolveDestinationName(DynamicDestinationResolver.java:55)
    at org.springframework.jms.support.destination.JmsDestinationAccessor.resolveDestinationName(JmsDestinationAccessor.java:114)
    at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.access$000(JmsConfiguration.java:458)
    at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate$1.doInJms(JmsConfiguration.java:471)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:484)
    ... 15 common frames omitted
Caused by: oracle.jms.AQjmsException: JMS-142: È necessario creare largomento JMS nelle tabelle di coda attivate per più consumatori
    at oracle.jms.AQjmsError.throwEx(AQjmsError.java:313)
    at oracle.jms.AQjmsSession.getTopic(AQjmsSession.java:5899)
    at oracle.jms.AQjmsSession.createTopic(AQjmsSession.java:2716)
    ... 21 common frames omitted


问:
Trigger jQuery UI autocomplete at minLength = 3 but 1 when only digits
I have an autocomplete input field, and I want it to search on objects with a label (text) and an id (integer).

The autocomplete must allow users to search either on the textual label or the id. The server part is ok, but on the client part, I would like to trigger the search at minLength=3 when the user enters at least one letter, but at the first character when there is only digits (if not, it misses all ids <=99).

Code:

```<code>$("#my_input").autocomplete({
    minLength : 1,
    delay:200,  source: function(request,response){
       ...
} });
</code>```

How to prevent the autocomplete to trigger when less then 3 characters if there is at least 1 letter ?

答:
You can use the search property to add additional checks before performing a search.

```<code> search: function( event, ui ) {
    var value = document.getElementById('my_input').value;

    // If not a number and less than three chars, cancel search.
    if(isNaN(value) && value.length < 3){
      event.preventDefault();
    }
</code>```

See a full working example here

Body:
I have an autocomplete input field, and I want it to search on objects with a label (text) and an id (integer).

The autocomplete must allow users to search either on the textual label or the id. The server part is ok, but on the client part, I would like to trigger the search at minLength=3 when the user enters at least one letter, but at the first character when there is only digits (if not, it misses all ids <=99).

Code:

$("#my_input").autocomplete({
    minLength : 1,
    delay:200,  source: function(request,response){
       ...
} });

How to prevent the autocomplete to trigger when less then 3 characters if there is at least 1 letter ?

Body:
You can use the search property to add additional checks before performing a search.

 search: function( event, ui ) {
    var value = document.getElementById('my_input').value;

    // If not a number and less than three chars, cancel search.
    if(isNaN(value) && value.length < 3){
      event.preventDefault();
    }

See a full working example here


问:
select -option for colors and hover behavior
trying to make a selec-tor where the user can chose a color so ofc I just changed background color for every -option- the problem is that when I hover it the background is changed to blue which I don't want to happen -look the pictures for clearification

I googled a bit and what I understand is that it's not possible to overide that behavior with css
that code didn not work for me :

```<code>select.decorated option:hover {
box-shadow: 0 0 10px 100px #1882A8 inset;
</code>```

}

-how can I solve that problem  - I'm using angular 5 with bootstrap

答:
Probably the easiest way here is to rebuild a whole select with for example ul li, like this example:
https://codepen.io/marijoha/pen/zKjvEw

I just added inlinestyles for the

```<code>background-color:xxx;
</code>```

as a example:

https://codepen.io/anon/pen/MORwQd

Body:
trying to make a selec-tor where the user can chose a color so ofc I just changed background color for every -option- the problem is that when I hover it the background is changed to blue which I don't want to happen -look the pictures for clearification

I googled a bit and what I understand is that it's not possible to overide that behavior with css
that code didn not work for me :

select.decorated option:hover {
box-shadow: 0 0 10px 100px #1882A8 inset;

}

-how can I solve that problem  - I'm using angular 5 with bootstrap

Body:
Probably the easiest way here is to rebuild a whole select with for example ul li, like this example:
https://codepen.io/marijoha/pen/zKjvEw

I just added inlinestyles for the

background-color:xxx;

as a example:

https://codepen.io/anon/pen/MORwQd


问:
How to change font size in iOS Alert Message Box Title and Message with Swift
I would like to change the font size of Message box title and message with Swift.

I don't want font color or font family. I just only want to change the font size and line height.

```<code>let attributedString = NSAttributedString(string: "Title", attributes: [
NSFontAttributeName : UIFont.systemFontOfSize(15) //your font here,
NSForegroundColorAttributeName : UIColor.redColor()])
let alert = UIAlertController(title: "", message: "",  preferredStyle: .Alert)

alert.setValue(attributedString, forKey: "attributedTitle")
let cancelAction = UIAlertAction(title: "Cancel",
style: .Default) { (action: UIAlertAction!) -> Void in
}

presentViewController(alert,
animated: true,
completion: nil)
</code>```

答:
You need to change key for it

Please check below code:

```<code> let alert = UIAlertController(title: "Test Title", message: "Custom Fonts in Alert Controller", preferredStyle: .actionSheet)
    let strAction = NSMutableAttributedString(string: "Presenting the great...")
    strAction.addAttribute(NSAttributedStringKey.font, value: UIFont.systemFont(ofSize: 30), range: NSMakeRange(24, 11))
    alert.setValue(action, forKey: "attributedMessage")// change key name if you want to change title font with attributedTitle

    let action = UIAlertAction(title: "Some title", style: .default, handler: nil)
    alert.addAction(action)
    present(alert, animated: true, completion: nil)
</code>```

Body:
I would like to change the font size of Message box title and message with Swift.

I don't want font color or font family. I just only want to change the font size and line height.

let attributedString = NSAttributedString(string: "Title", attributes: [
NSFontAttributeName : UIFont.systemFontOfSize(15) //your font here,
NSForegroundColorAttributeName : UIColor.redColor()])
let alert = UIAlertController(title: "", message: "",  preferredStyle: .Alert)

alert.setValue(attributedString, forKey: "attributedTitle")
let cancelAction = UIAlertAction(title: "Cancel",
style: .Default) { (action: UIAlertAction!) -> Void in
}

presentViewController(alert,
animated: true,
completion: nil)

Body:
You need to change key for it

Please check below code:

 let alert = UIAlertController(title: "Test Title", message: "Custom Fonts in Alert Controller", preferredStyle: .actionSheet)
    let strAction = NSMutableAttributedString(string: "Presenting the great...")
    strAction.addAttribute(NSAttributedStringKey.font, value: UIFont.systemFont(ofSize: 30), range: NSMakeRange(24, 11))
    alert.setValue(action, forKey: "attributedMessage")// change key name if you want to change title font with attributedTitle

    let action = UIAlertAction(title: "Some title", style: .default, handler: nil)
    alert.addAction(action)
    present(alert, animated: true, completion: nil)


问:
How to compute OneDrive XOrHash in C#
We wish to compute the XOrHash the same way that OneDrive does so we can detect any changes needed to sync with the OD4B backend.

I have the current implementation for the XOrHash Algorithm used which can be found here https://learn.microsoft.com/en-us/onedrive/developer/code-snippets/quickxorhash

However there is nothing to suggest how I can compute the same hash in our code to match the hash that OD4B provides us with.

We Use the XOrHash Algorithm provided in the link above to give us the byte array for the hash which has a typical length of 20 bytes.

```<code>public static byte[] ComputeHash(string filePath)
{
    using (var quickXor = XOrHash.Create())
    {
        using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
        {
            return quickXor.ComputeHash(stream);
        }
    }
}

 public static string ConvertHexToString(this byte[] bytes)
 {
     return Convert.ToBase64String(bytes);
 }

returns "4FPisLqvTiuaxUVVz6Zk+RxMClE=" OD4B tells us the hash is "LmpqMT5KKX4ATcd372ZTyVr3gIk="
</code>```

Clearly we are mismatching and are unable to find any documentation on this other than the following page which suggests to use that the hash is a base64 string https://learn.microsoft.com/en-us/onedrive/developer/rest-api/resources/hashes

Any example code or hints as to how we should be computing the hash and then returning the string would be much appreciated.

Link to example file: https://dnqa-my.sharepoint.com/:p:/g/personal/autoslave10_dnqauk_co_uk/EcPZl9l2eXNImfD0paFXKyoBHdZwt5mCMRemLKU9wNYIYg?e=63c7632212d948238dd9696c90a11963

OD4B json

```<code>{"@odata.context":"omitted","@odata.type":"#oneDrive.item","@odata.id":"omitted","@odata.etag":"\"{D997D9C3-7976-4873-99F0-F4A5A1572B2A},2\"","@odata.editLink":"omitted","createdDateTime":"2017-12-04T17:07:40Z","id":"omitted","lastModifiedDateTime":"2017-12-04T17:07:40Z","name":"pptx001.pptx","file":{"hashes":{"quickXorHash":"LmpqMT5KKX4ATcd372ZTyVr3gIk="},"mimeType":"application/vnd.openxmlformats-officedocument.presentationml.presentation"},"size":29765}
</code>```

答:
By doing this:

```<code>XOrHash.Create()
</code>```

you are not actually using your quick xor algorithm. Create() is static method of HashAlgorithm class, which creates some default hash algorithm instance (SHA1 as I remember). So what you are actually calling is:

```<code>HashAlgorithm.Create()
</code>```

Instead, do it like this:

```<code>using (var quickXor = new XOrHash())
</code>```

Title: How to compute OneDrive XOrHash in C#

Body:
We wish to compute the XOrHash the same way that OneDrive does so we can detect any changes needed to sync with the OD4B backend.

I have the current implementation for the XOrHash Algorithm used which can be found here https://learn.microsoft.com/en-us/onedrive/developer/code-snippets/quickxorhash

However there is nothing to suggest how I can compute the same hash in our code to match the hash that OD4B provides us with.

We Use the XOrHash Algorithm provided in the link above to give us the byte array for the hash which has a typical length of 20 bytes.

public static byte[] ComputeHash(string filePath)
{
    using (var quickXor = XOrHash.Create())
    {
        using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
        {
            return quickXor.ComputeHash(stream);
        }
    }
}

 public static string ConvertHexToString(this byte[] bytes)
 {
     return Convert.ToBase64String(bytes);
 }

returns "4FPisLqvTiuaxUVVz6Zk+RxMClE=" OD4B tells us the hash is "LmpqMT5KKX4ATcd372ZTyVr3gIk="

Clearly we are mismatching and are unable to find any documentation on this other than the following page which suggests to use that the hash is a base64 string https://learn.microsoft.com/en-us/onedrive/developer/rest-api/resources/hashes

Any example code or hints as to how we should be computing the hash and then returning the string would be much appreciated.

Link to example file: https://dnqa-my.sharepoint.com/:p:/g/personal/autoslave10_dnqauk_co_uk/EcPZl9l2eXNImfD0paFXKyoBHdZwt5mCMRemLKU9wNYIYg?e=63c7632212d948238dd9696c90a11963

OD4B json

{"@odata.context":"omitted","@odata.type":"#oneDrive.item","@odata.id":"omitted","@odata.etag":"\"{D997D9C3-7976-4873-99F0-F4A5A1572B2A},2\"","@odata.editLink":"omitted","createdDateTime":"2017-12-04T17:07:40Z","id":"omitted","lastModifiedDateTime":"2017-12-04T17:07:40Z","name":"pptx001.pptx","file":{"hashes":{"quickXorHash":"LmpqMT5KKX4ATcd372ZTyVr3gIk="},"mimeType":"application/vnd.openxmlformats-officedocument.presentationml.presentation"},"size":29765}

Body:
By doing this:

XOrHash.Create()

you are not actually using your quick xor algorithm. Create() is static method of HashAlgorithm class, which creates some default hash algorithm instance (SHA1 as I remember). So what you are actually calling is:

HashAlgorithm.Create()

Instead, do it like this:

using (var quickXor = new XOrHash())


问:
JS cant find out how to code multiple options in form so there will be different outcomes
For a school assignment I have to create a form with 4 options of exchange rates. But I cant really find out how to calculate this. I have tried alot of different things but they all didnt give me the outcome i wanted.

this is the code I have so far

function euro_dollarkoers() {
  return (1.36);
}

function dollar_eurokoers() {
  return (0.74);
}

function euro_rublekoers() {
  return (48.40);
}

function ruble_eurokoers() {
  return (0.02);
}

function dollar_naar_euro(dollars) {
  return (dollars * dollar_eurokoers());
}

function euro_naar_dollar(euro) {
  return (euro * euro_dollarkoers());
}

function exchange() {
  if (document.getElementById('dollar/euro').selected == True) {
    dollar_naar_euro(document.form.bedrag.value).toFixed(2);
  } else if (document.getElementById('euro/dollar').selected == True) {
    euro_naar_dollar(document.form.bedrag.value).toFixed(2);
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="nl">

<head>
  <meta charset="UTF-8">
  <title>Lab 10</title>
</head>

<body>
  <script src="lab10.js"></script>

  <form name="form">
    <input type="text" name="bedrag" placeholder="Vul bedrag in">
    <select name="koersen">
      <option value="dollar/euro">dollar/euro</option>
      <option value="euro/dollar">euro/dollar</option>
      <option value="ruble/euro">ruble/euro</option>
      <option value="euro/ruble">euro/ruble</option>
    </select>
    <input type="button" name="conversie" value="converteren" onclick="document.write('Conversie: ' + dollar_naar_euro(document.form.bedrag.value).toFixed(2))">
  </form>
</body>

</html></code>```

答:
There are too many mistakes in your logic, e.g.

using value property as id value

using document.write

You need to simplify your logic to

```<code>var functions = {
  "euro/dollar": 1.36,
  "dollar/euro": 0.74,
  "euro/ruble" : 48.40,
  "ruble/euro": 0.02
};

function exchange() {
  var optValue = document.getElementById( "koersen" ).value;
  var currValue = +document.getElementById( "bedrag" ).value;
  console.log( ( functions[optValue] * currValue ).toFixed(2) );
}
</code>```

var functions = {
  "euro/dollar": 1.36,
  "dollar/euro": 0.74,
  "euro/ruble" : 48.40,
  "ruble/euro": 0.02
};

function exchange() {
  var optValue = document.getElementById( "koersen" ).value;
  var currValue = +document.getElementById( "bedrag" ).value;
  console.log( ( functions[optValue] * currValue ).toFixed(2) );
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="text" id="bedrag" placeholder="Vul bedrag in">
<select id="koersen">
    <option value = "dollar/euro">dollar/euro</option>
    <option value = "euro/dollar">euro/dollar</option>
    <option value = "ruble/euro">ruble/euro</option>
    <option value = "euro/ruble">euro/ruble</option>
</select>
<input type="button" name="conversie" value="converteren" onclick="exchange()"></code>```

Body:
For a school assignment I have to create a form with 4 options of exchange rates. But I cant really find out how to calculate this. I have tried alot of different things but they all didnt give me the outcome i wanted.

this is the code I have so far

function euro_dollarkoers() {
  return (1.36);
}

function dollar_eurokoers() {
  return (0.74);
}

function euro_rublekoers() {
  return (48.40);
}

function ruble_eurokoers() {
  return (0.02);
}

function dollar_naar_euro(dollars) {
  return (dollars * dollar_eurokoers());
}

function euro_naar_dollar(euro) {
  return (euro * euro_dollarkoers());
}

function exchange() {
  if (document.getElementById('dollar/euro').selected == True) {
    dollar_naar_euro(document.form.bedrag.value).toFixed(2);
  } else if (document.getElementById('euro/dollar').selected == True) {
    euro_naar_dollar(document.form.bedrag.value).toFixed(2);
  }
}

<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>Lab 10</title>

  <form name="form">
    <input type="text" name="bedrag" placeholder="Vul bedrag in">
    <select name="koersen">
      <option value="dollar/euro">dollar/euro</option>
      <option value="euro/dollar">euro/dollar</option>
      <option value="ruble/euro">ruble/euro</option>
      <option value="euro/ruble">euro/ruble</option>
    </select>
    <input type="button" name="conversie" value="converteren" onclick="document.write('Conversie: ' + dollar_naar_euro(document.form.bedrag.value).toFixed(2))">
  </form>

Body:
There are too many mistakes in your logic, e.g.

using value property as id value

using document.write

You need to simplify your logic to

var functions = {
  "euro/dollar": 1.36,
  "dollar/euro": 0.74,
  "euro/ruble" : 48.40,
  "ruble/euro": 0.02
};

function exchange() {
  var optValue = document.getElementById( "koersen" ).value;
  var currValue = +document.getElementById( "bedrag" ).value;
  console.log( ( functions[optValue] * currValue ).toFixed(2) );
}

var functions = {
  "euro/dollar": 1.36,
  "dollar/euro": 0.74,
  "euro/ruble" : 48.40,
  "ruble/euro": 0.02
};

function exchange() {
  var optValue = document.getElementById( "koersen" ).value;
  var currValue = +document.getElementById( "bedrag" ).value;
  console.log( ( functions[optValue] * currValue ).toFixed(2) );
}

<input type="text" id="bedrag" placeholder="Vul bedrag in">
<select id="koersen">
    <option value = "dollar/euro">dollar/euro</option>
    <option value = "euro/dollar">euro/dollar</option>
    <option value = "ruble/euro">ruble/euro</option>
    <option value = "euro/ruble">euro/ruble</option>
</select>
<input type="button" name="conversie" value="converteren" onclick="exchange()">


问:
ClickOnce Deployment with a Database as a Prerequisite
I have a Winforms application that I want to publish using ClickOnce. This application comes with an initial database, which must be installed once on a per-machine basis. After much ado, I have landed on the idea of using a custom pre-requisite to install the .sdf file. I have used Bootstrapper Manifest Generator (BMG) to create a package for the .cmd file I want to run, and I have included the .sdf file as an "additional file."

My expectation was that the two files would end up in the same directory, and I would be able to copy the .sdf file to the place where I want it (They do end up in the same directory.) The pre-requisite shows up in Visual Studio just fine. It get's deployed to the client system just fine, and the setup program kicks off the prerequisite just fine.

The only problem is that the current working directory that the .cmd file is executing is C:\Documents and Settings\\Desktop!

Neither of the two files (.cmd or .sdf) are located there - they were downloaded elsewhere, e.g., "C:\Documents and Settings\drogers\Local Settings\Temp\VSD5A.tmp". So, although I know where to xcopy to, I have no idea where to xcopy from.

How can I resolve this?

Here is the .cmd file:

```<code>REM Modify this file to reflect your manufacturer name [FHCRC] and product name [ClickOnceSharedDataDemo].
SET TargetBase=%ALLUSERSPROFILE%
IF NOT "%TargetBase%"=="C:\ProgramData" SET TargetBase=%ALLUSERSPROFILE%\Application Data
REM We only want to do this copy for the first user!
if exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" GOTO EXIT
if not exist "%TargetBase%\FHCRC" mkdir "%TargetBase%\FHCRC"
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo" mkdir "%TargetBase%\FHCRC\ClickOnceSharedDataDemo"
CACLS "%TargetBase%\FHCRC\ClickOnceSharedDataDemo" /E /T /C /G "Users":C
xcopy shareddata.sdf "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\"
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" PAUSE
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" exit /B -1
:EXIT
PAUSE
exit /B 0
</code>```

Thanks,
David

答:
Well, I am not altogether happy with this solution, but it works. I now have two prerequisites. the first is just the command file which runs the CACLS commands to set permissions. It is basically a shortened version of the above:

```<code>REM Modify this file to reflect your manufacturer name [Manufacturer] and product name [ProductName].
SET TargetBase=%ALLUSERSPROFILE%
IF NOT "%TargetBase%"=="C:\ProgramData" SET TargetBase=%ALLUSERSPROFILE%\Application Data
REM We only want to do this copy for the first user!
if exist "%TargetBase%\Manufacturer\ProductName\shareddata.sdf" GOTO EXIT
if not exist "%TargetBase%\Manufacturer" mkdir "%TargetBase%\Manufacturer"
if not exist "%TargetBase%\Manufacturer\ProductName" mkdir "%TargetBase%\Manufacturer\ProductName"
CACLS "%TargetBase%\Manufacturer\ProductName" /E /T /C /G "Users":C
:EXIT
ECHO exit /B 0
</code>```

The second prerequisite is an "all users = true" setup project which has a custom folder located at default location:
    "[CommonAppDataFolder][Manufacturer][ProductName]".
Into this folder I put the sdf file.

Finally, I used Bootstrapper Manifest Generator to make packages for both, making the second dependent on the first. I copied the packages to the appropriate VS2010 directory, included them as prerequisites, and published.

I now have per-machine .sdf files published to both WinXP and Win7. Why does this have to be so difficult!?!?

I'm still looking for less complicated solutions, that will install to both Windows 7 and Windows XP.

Body:
I have a Winforms application that I want to publish using ClickOnce. This application comes with an initial database, which must be installed once on a per-machine basis. After much ado, I have landed on the idea of using a custom pre-requisite to install the .sdf file. I have used Bootstrapper Manifest Generator (BMG) to create a package for the .cmd file I want to run, and I have included the .sdf file as an "additional file."

My expectation was that the two files would end up in the same directory, and I would be able to copy the .sdf file to the place where I want it (They do end up in the same directory.) The pre-requisite shows up in Visual Studio just fine. It get's deployed to the client system just fine, and the setup program kicks off the prerequisite just fine.

The only problem is that the current working directory that the .cmd file is executing is C:\Documents and Settings\\Desktop!

Neither of the two files (.cmd or .sdf) are located there - they were downloaded elsewhere, e.g., "C:\Documents and Settings\drogers\Local Settings\Temp\VSD5A.tmp". So, although I know where to xcopy to, I have no idea where to xcopy from.

How can I resolve this?

Here is the .cmd file:

REM Modify this file to reflect your manufacturer name [FHCRC] and product name [ClickOnceSharedDataDemo].
SET TargetBase=%ALLUSERSPROFILE%
IF NOT "%TargetBase%"=="C:\ProgramData" SET TargetBase=%ALLUSERSPROFILE%\Application Data
REM We only want to do this copy for the first user!
if exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" GOTO EXIT
if not exist "%TargetBase%\FHCRC" mkdir "%TargetBase%\FHCRC"
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo" mkdir "%TargetBase%\FHCRC\ClickOnceSharedDataDemo"
CACLS "%TargetBase%\FHCRC\ClickOnceSharedDataDemo" /E /T /C /G "Users":C
xcopy shareddata.sdf "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\"
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" PAUSE
if not exist "%TargetBase%\FHCRC\ClickOnceSharedDataDemo\shareddata.sdf" exit /B -1
:EXIT
PAUSE
exit /B 0

Thanks,
David

Body:
Well, I am not altogether happy with this solution, but it works. I now have two prerequisites. the first is just the command file which runs the CACLS commands to set permissions. It is basically a shortened version of the above:

REM Modify this file to reflect your manufacturer name [Manufacturer] and product name [ProductName].
SET TargetBase=%ALLUSERSPROFILE%
IF NOT "%TargetBase%"=="C:\ProgramData" SET TargetBase=%ALLUSERSPROFILE%\Application Data
REM We only want to do this copy for the first user!
if exist "%TargetBase%\Manufacturer\ProductName\shareddata.sdf" GOTO EXIT
if not exist "%TargetBase%\Manufacturer" mkdir "%TargetBase%\Manufacturer"
if not exist "%TargetBase%\Manufacturer\ProductName" mkdir "%TargetBase%\Manufacturer\ProductName"
CACLS "%TargetBase%\Manufacturer\ProductName" /E /T /C /G "Users":C
:EXIT
ECHO exit /B 0

The second prerequisite is an "all users = true" setup project which has a custom folder located at default location:
    "[CommonAppDataFolder][Manufacturer][ProductName]".
Into this folder I put the sdf file.

Finally, I used Bootstrapper Manifest Generator to make packages for both, making the second dependent on the first. I copied the packages to the appropriate VS2010 directory, included them as prerequisites, and published.

I now have per-machine .sdf files published to both WinXP and Win7. Why does this have to be so difficult!?!?

I'm still looking for less complicated solutions, that will install to both Windows 7 and Windows XP.


问:
Segmentation fault for git commit command (Windows)
I have started to work with project, which I cloned from bitbucket.
I use as Git Bash, as SourceTree.
I changed one file and try to commit my change.
I can execute the command "add", but when I try to execute the command "commit" (git commit -m "for testing"), I get the following error:
Segmentation fault.

I got an error in SourceTree too.
But if I create my new folder & file, the commit happens successfully

How I can fix the problem situation?
Thanks in advance.

答:
Running git 2.15.1.windows.2 on Windows 10 x64 v1709

For me the problem was caused by a faulty index. To resolve I ran the following from the project directory:

rm .git/index

git reset

As you can see from the image in this link, I didn't loose any changes by performing a reset.


问:
Add new element in for-loop with jQuery
In this table I would like to add a new table cell with jQuery.

```<code><table cellspacing="0" cellpadding="2" class="table">
  <tr class="dataTableHeadingRow">
    <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
    <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
  </tr>
  <?php
  for ($i = 0, $n = sizeof($order->products); $i < $n; $i ++) {
    echo '<tr class="dataTableRow">';
    echo '  <td class="dataTableContent txta-r">' . $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . '</td>';
    echo '  <td class="dataTableContent txta-r">' . $order->products[$i]['model'] . '</td>';
    /* here should the new table cell be */
    echo '</tr>';
  }
  ?>
</table>
<?php include changes.php; ?>
</code>```

The file changes.php is necessary in this CMS to change code without changing the original code.
The new tableheading isn't a problem.

```<code>$new_th = '<td class="dataTableHeadingContent">' . TABLE_NEW_CELL . '</td>';
?>
<script>
  $(document).ready(function() {
    $("td:contains('<?php echo TABLE_HEADING_PRODUCTS_MODEL; ?>')" ).after('<?php echo $new_th; ?>');
  });
</script>
</code>```

But how can I add a new table cell in this for-loop?

答:
```<code>echo "<td id='". $i ."' class="dataTableContent txta-r"> </td>"
</code>```

this will add an empty cell with id starts from 0 to array size.

then in the jquery you can add the data to this cell by making a for loop from 0 to the same array size.

Title: Add new element in for-loop with jQuery

Body:
In this table I would like to add a new table cell with jQuery.

    <?php echo TABLE_HEADING_PRODUCTS; ?>
    <?php echo TABLE_HEADING_PRODUCTS_MODEL; ?>

  <?php
  for ($i = 0, $n = sizeof($order->products); $i < $n; $i ++) {
    echo '
';
    echo '  ' . $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . '	';
    echo '  ' . $order->products[$i]['model'] . '	';
    /* here should the new table cell be */
    echo '
';
  }
  ?>

<?php include changes.php; ?>

The file changes.php is necessary in this CMS to change code without changing the original code.
The new tableheading isn't a problem.

$new_th = '' . TABLE_NEW_CELL . '	';
?>

But how can I add a new table cell in this for-loop?

Body:
echo "<td id='". $i ."' class="dataTableContent txta-r"> </td>"

this will add an empty cell with id starts from 0 to array size.

then in the jquery you can add the data to this cell by making a for loop from 0 to the same array size.


Title: Subtract rows then sum values

Body:
I have this dataframe where I would like to perform some calculations.

aa = c (1,3,1,0,0,1,6,1,14,3,0)
bb = c (0,0,5,0,0,1,6,0,2,15,1)
ee = rbind( aa,bb)
df = as.data.frame (ee)

First I would like to subtract from the first value in the row aa the first value in the row bb ... 1 - 0 ... then the result add to the second value in the row aa ... 1 + 3 = 4 ... then 4 - 0 ... and in aa 4 + 1 = 5 and so on ...

The desired outcome is:

cc = c (1,4,5,0,0,1,6,1,15,16,1)
ff = rbind( cc,bb)
df1 = as.data.frame(ff)

Any ideas really appreciated !

Body:
You can do like this

for(i in 1:10){
  aa[i+1] <- (aa[i] - bb[i]) + aa[i+1]
}

aa

[1]  1  4  5  0  0  1  6  1 15 16  1


问:
protractor-jasmine2-html-reporter doesn't create html report
I have the following configuration in protractor config.js, but it is generating only the screenshots in the specified folder not the HTML report.

I have gone through the steps followed here

https://www.npmjs.com/package/protractor-jasmine2-html-reporter

```<code>var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');

onPrepare() {

    jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
            savePath: './test/reports/',
            fileName: 'MyReportName'
        }));
  }
</code>```

Can someone specify where I'm missing or is there any version specific issue?

I'm using
Protractor Version 5.2.0,
Node v6.11.2

答: I'm using protractor-html-reporter, provides pie charts also and is way better than protractor jasmine2html reporter. </p>

Body:
I have the following configuration in protractor config.js, but it is generating only the screenshots in the specified folder not the HTML report.

I have gone through the steps followed here

https://www.npmjs.com/package/protractor-jasmine2-html-reporter

var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');

onPrepare() {

    jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
            savePath: './test/reports/',
            fileName: 'MyReportName'
        }));
  }

Can someone specify where I'm missing or is there any version specific issue?

I'm using
Protractor Version 5.2.0,
Node v6.11.2


问:
How to change default color of progress bar?
I am using a circular ProgressBar in my Activty.My Problem is this it is not visible properly on my page because my page's BG color is same as ProgressBar .So how can I change the color of ProgressBar to make it properly Visible?
Please Help

答:
You can also change the color of your progressbar programmatically in your activities oncreate or your fragments onViewCreated()

```<code>pBar.getIndeterminateDrawable().setColorFilter(0xFFFF0000, android.graphics.PorterDuff.Mode.MULTIPLY);
</code>```

Here the color applied is "0xFFFF0000" which is red. You can change it according to your needs

Body:
You can also change the color of your progressbar programmatically in your activities oncreate or your fragments onViewCreated()

pBar.getIndeterminateDrawable().setColorFilter(0xFFFF0000, android.graphics.PorterDuff.Mode.MULTIPLY);

Here the color applied is "0xFFFF0000" which is red. You can change it according to your needs


问:
JSON from php to js
What is the best way to parse a php-variable with json data to js?
On the php-site I have the following:

```<code>  $pdo = new PDO('mysql:host=localhost;dbname=test', 'homedbuser', 'homedbuser');
    $sqlQuery ="SELECT `serie`, `abtrag` FROM `testem`";

    $q = $pdo->query($sqlQuery);

    $result = $q->fetch(PDO::FETCH_ASSOC);

    $rowcount = $q->rowCount();

    $data = array();

    for($x=0; $x < $rowcount-1;$x++){

    $data[]  = $q->fetch(PDO::FETCH_ASSOC);

    $myJson = json_encode($data);

    echo $myJson;

The Output looks like this:

  [
  {"serie":"KK718X","abtrag":"71"},
  {"serie":"KK712X","abtrag":"337"},
  {"serie":"LK719X","abtrag":"93"},
  {"serie":"KK790Y","abtrag":"78"}
 ]
</code>```

Now I want to put the data into a js-variable.

What kind of variable do I have to choose ?
I tried it with axaj / xmlhttp request but that did not work for jet.
Can some one tell, how to do this the right way?

```<code>var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        var myObj = JSON.parse(this.responseText);
        document.getElementById("show").innerHTML = "myObject[1].serie";
    }
};
xmlhttp.open("GET", "demo_file_array.php", true);
xmlhttp.send();``
</code>```

答:
with jQuery you can use the following syntax:

```<code>$.get(url, function(data) { your code; }, 'json');
</code>```

You will automatically get an javascript conform array in the data variable.

Grtngs
Dustin

Title: JSON from php to js

Body:
What is the best way to parse a php-variable with json data to js?
On the php-site I have the following:

  $pdo = new PDO('mysql:host=localhost;dbname=test', 'homedbuser', 'homedbuser');
    $sqlQuery ="SELECT `serie`, `abtrag` FROM `testem`";

    $q = $pdo->query($sqlQuery);

    $result = $q->fetch(PDO::FETCH_ASSOC);

    $rowcount = $q->rowCount();

    $data = array();

    for($x=0; $x < $rowcount-1;$x++){

    $data[]  = $q->fetch(PDO::FETCH_ASSOC);

    $myJson = json_encode($data);

    echo $myJson;

The Output looks like this:

  [
  {"serie":"KK718X","abtrag":"71"},
  {"serie":"KK712X","abtrag":"337"},
  {"serie":"LK719X","abtrag":"93"},
  {"serie":"KK790Y","abtrag":"78"}
 ]

Now I want to put the data into a js-variable.

What kind of variable do I have to choose ?
I tried it with axaj / xmlhttp request but that did not work for jet.
Can some one tell, how to do this the right way?

var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        var myObj = JSON.parse(this.responseText);
        document.getElementById("show").innerHTML = "myObject[1].serie";
    }
};
xmlhttp.open("GET", "demo_file_array.php", true);
xmlhttp.send();``

Body:
with jQuery you can use the following syntax:

$.get(url, function(data) { your code; }, 'json');

You will automatically get an javascript conform array in the data variable.

Grtngs
Dustin


问:
What is the meaning of the "?" in this statement in php
```<code>function countproduct(){
        $count = 0;
        $cart = isset($_SESSION['cart']) ? $_SESSION['cart']:array();
        foreach($cart as $row):
            if($row['qty']!=0){
                $count = $count + 1;
            }
        endforeach;

        return $count;
</code>```

i want to know whats the meaning of ? after the isset($_SESSION['cart'])

答:
It's a ternary operator, these line:

```<code>$cart = isset($_SESSION['cart']) ? $_SESSION['cart']:array();
</code>```

Can be transformed to:

```<code>if (isset($_SESSION['cart'])) {
    $cart = $_SESSION['cart'];
} else {
    $cart = array();
}
</code>```

For more information you can check php operations documentation

Body:
function countproduct(){
        $count = 0;
        $cart = isset($_SESSION['cart']) ? $_SESSION['cart']:array();
        foreach($cart as $row):
            if($row['qty']!=0){
                $count = $count + 1;
            }
        endforeach;

        return $count;

i want to know whats the meaning of ? after the isset($_SESSION['cart'])

Body:
It's a ternary operator, these line:

$cart = isset($_SESSION['cart']) ? $_SESSION['cart']:array();

Can be transformed to:

if (isset($_SESSION['cart'])) {
    $cart = $_SESSION['cart'];
} else {
    $cart = array();
}

For more information you can check php operations documentation


问:
What's the rationale of using properties instead of fields within the File model of django-filer
I tried to do filtering for the extension field, which is actually not a field at all as the following example suggests. For the sake of this example, let's imagine we have a running Django with django-filer installed and some file already uploaded.

```<code>>>> from filer.models import File
>>> File.objects.all()[0].extension
'some_ext' # just as example
</code>```

But when trying to filter:

```<code>>>> File.objects.filter(extension='pdf')
django.core.exceptions.FieldError: Cannot resolve keyword 'extension'
into field. Choices are: _file_size, clipboarditem, description,
downloadfilemodel, file, filer_image_file, folder, folder_id,
has_all_mandatory_data, id, in_clipboards, is_public, modified_at,
name, news_attachment, original_filename, owner, owner_id,
polymorphic_ctype, polymorphic_ctype_id, sha1, uploaded_at
</code>```

This is because extension are not stored with the model but in fact are computed properties.

My question: What's the rationale of not storing this meta data in the File Model.

Update: I do not complain about the implementation. I ask for the possible motivation of the implementation.

答:
The extension is not a very important meta since we are storing the file name. If you look at the source code:

```<code>@property
def extension(self):
    filetype = os.path.splitext(self.file.name)[1].lower()
    if len(filetype) > 0:
        filetype = filetype[1:]
    return filetype
</code>```

You can see storing extension would mean we are duplicating the data that we already have. Hence the decision to make it a property.

Body:
I tried to do filtering for the extension field, which is actually not a field at all as the following example suggests. For the sake of this example, let's imagine we have a running Django with django-filer installed and some file already uploaded.

>>> from filer.models import File
>>> File.objects.all()[0].extension
'some_ext' # just as example

But when trying to filter:

>>> File.objects.filter(extension='pdf')
django.core.exceptions.FieldError: Cannot resolve keyword 'extension'
into field. Choices are: _file_size, clipboarditem, description,
downloadfilemodel, file, filer_image_file, folder, folder_id,
has_all_mandatory_data, id, in_clipboards, is_public, modified_at,
name, news_attachment, original_filename, owner, owner_id,
polymorphic_ctype, polymorphic_ctype_id, sha1, uploaded_at

This is because extension are not stored with the model but in fact are computed properties.

My question: What's the rationale of not storing this meta data in the File Model.

Update: I do not complain about the implementation. I ask for the possible motivation of the implementation.

Body:
The extension is not a very important meta since we are storing the file name. If you look at the source code:

@property
def extension(self):
    filetype = os.path.splitext(self.file.name)[1].lower()
    if len(filetype) > 0:
        filetype = filetype[1:]
    return filetype

You can see storing extension would mean we are duplicating the data that we already have. Hence the decision to make it a property.


问:
Run failed in Netbeans 8.2, c++ "No such file or directory" (Beginner)

I'm setting up the Netbeans IDE, and i downloaded Cygwin for the compiler, make and debugger (Windows 8.1). The problem is that when i try to debug or run, this error happens.
</p>

```<code>C:\\cygwin64\\bin\\bash: exec /cygdrive/C/Users/MyName/Documents/NetBeansProjects/Pi_1/dist/Serial/Cygwin-Windows/pi_1.exe: No such file or directory

RUN FAILED (exit value 127, total time: 90ms)
</code>```

<p>
I don't know if i'm missing something to install or if i used wrong versions of g++, make, etc...
</p>

答: I had experienced a similar problem on other IDEs (haven't used Netbeans). It turned that the anti-virus was quarantining the executable generated after compilation. I just "whitelisted" (prevent anti-virus from scanning in future) the directory where i saved my programs, and that solved the problem.</p>

Body:
I'm setting up the Netbeans IDE, and i downloaded Cygwin for the compiler, make and debugger (Windows 8.1). The problem is that when i try to debug or run, this error happens.

C:\\cygwin64\\bin\\bash: exec /cygdrive/C/Users/MyName/Documents/NetBeansProjects/Pi_1/dist/Serial/Cygwin-Windows/pi_1.exe: No such file or directory

RUN FAILED (exit value 127, total time: 90ms)

I don't know if i'm missing something to install or if i used wrong versions of g++, make, etc...


答:
In the following you are using a literal string and not a reference to an object identifier

```<code>document.getElementById("show").innerHTML = "myObject[1].serie"
</code>```

Maybe change that to

```<code>document.getElementById("show").innerHTML = myObj[1].serie;
</code>```

Title: JSON from php to js

Body:
In the following you are using a literal string and not a reference to an object identifier

document.getElementById("show").innerHTML = "myObject[1].serie"

Maybe change that to

document.getElementById("show").innerHTML = myObj[1].serie;


答:
```<code>public static <T> List<T> toList(String json, Class<T> clazz) {
    if (null == json) {
        return null;
    }
    Gson gson = new Gson();
    return gson.fromJson(json, new TypeToken<T>(){}.getType());
}
</code>```

sample call:

```<code>List<Consultation > objects = GsonUtils.toList(response, Consultation .class);
</code>```

Title: GSON can't deserialize an array

Body:
I'm facing a problem with Gson. I'm fetching Json data formatted. Here is the syntax :

I/Reponse-Json: [{"consultation_id":281,"plageconsult_id":76,"patient_id":116,"heure":"11:04:00","duree":1,"motif":null,"secteur1":0,"secteur2":0,"rques":null,"chrono":"32","annule":"0","patient_date_reglement":null,"examen":null,"traitement":null,"histoire_maladie":null,"conclusion":null,"premiere":"0","derniere":"0","tarif":null,"patient_mode_reglement":null,"arrivee":"2017-11-22 11:04:00","codes_ccam":null,"banque_id":null,"categorie_id":null,"adresse":"0","valide":"0","total_amc":null,"total_amo":null,"total_assure":null,"du_patient":0,"sejour_id":252,"du_tiers":0,"tiers_mode_reglement":null,"tiers_date_reglement":null,"date_at":null,"concerne_ALD":"0","facture":"0","adresse_par_prat_id":null,"si_desistement":"0","fin_at":null,"pec_at":null,"reprise_at":null,"type":"classique","grossesse_id":null,"at_sans_arret":"0","arret_maladie":"0","factureconsult_id":null,"brancardage":null,"sianesthesique":0},{"consultation_id":282,"plageconsult_id":77,"patient_id":116,"heure":"16:31:00","duree":1,"motif":null,"secteur1":0,"secteur2":0,"rques":"RAS","chrono":"64","annule":"0","patient_date_reglement":null,"examen":null,"traitement":"HUILE DE PARAFINE FL DE 1 LITRE\n","histoire_maladie":null,"conclusion":null,"premiere":"0","derniere":"0","tarif":null,"patient_mode_reglement":null,"arrivee":"2017-11-22 16:31:00","codes_ccam":null,"banque_id":null,"categorie_id":null,"adresse":"0","valide":"0","total_amc":null,"total_amo":null,"total_assure":null,"du_patient":0,"sejour_id":252,"du_tiers":0,"tiers_mode_reglement":null,"tiers_date_reglement":null,"date_at":null,"concerne_ALD":"0","facture":"0","adresse_par_prat_id":null,"si_desistement":"0","fin_at":null,"pec_at":null,"reprise_at":null,"type":"classique","grossesse_id":null,"at_sans_arret":"0","arret_maladie":"0","factureconsult_id":null,"brancardage":null,"sianesthesique":0}]

And here is the code used to deserialized

    Log.i("Reponse-Json", response);
    List<Consultation> consultations = Arrays.asList(gson.fromJson(response, Consultation[].class));
    Log.i("ConsultActivity", consultations.size()+" consultations loaded");
    for (Consultation c : consultations) {
        Log.i("ConsultActivity", ""+c.getConsultationId());
    }

And here is the error:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 72
                                                                  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
                                                                  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
                                                                  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
                                                                  at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
                                                                  at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
                                                                  at com.google.gson.Gson.fromJson(Gson.java:803)
                                                                  at com.google.gson.Gson.fromJson(Gson.java:768)
                                                                  at com.google.gson.Gson.fromJson(Gson.java:717)
                                                                  at com.google.gson.Gson.fromJson(Gson.java:689)
                                                                  at org.cfrtmbk.www.elaafi.ConsultActivity$1.onResponse(ConsultActivity.java:69)
                                                                  at org.cfrtmbk.www.elaafi.ConsultActivity$1.onResponse(ConsultActivity.java:65)
                                                                  at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
                                                                  at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
                                                                  at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
                                                                  at android.os.Handler.handleCallback(Handler.java:751)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                  at android.os.Looper.loop(Looper.java:154)
                                                                  at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                               Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 72
                                                                  at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:374)
                                                                  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory

I have try to use a solution similar to :

Type collectionType = new TypeToken<Collection<channelSearchEnum>>(){}.getType();
Collection<channelSearchEnum> enums = gson.fromJson(yourJson, collectionType);

but having the same issue
Please help me

Body:
public static <T> List<T> toList(String json, Class<T> clazz) {
    if (null == json) {
        return null;
    }
    Gson gson = new Gson();
    return gson.fromJson(json, new TypeToken<T>(){}.getType());
}

sample call:

List<Consultation > objects = GsonUtils.toList(response, Consultation .class);


问:
Same image getting uploaded for all the options
I have a dynamic website. I want to accept the details of different items including their image. The js is working but only for one item. The moment I add another item and I try to upload a different pic, either it does not open the dialog or it will take the same image for all the items. For single item, the code is working fine.
This is my fiddle.

```<code>$(".file-upload").on('change', function(){
    readURL(this);
});
$(".upload-button").on('click', function() {
    $(".file-upload").click();
});
$("#additem").click( function () {
    $(".grid").append('<div class="cell" style="overflow: hidden; visibility:;"><form><fieldset style="color:white;"><legend>Item Details</legend><img class="profile-pic" src="" /><div class="upload-button" style="cursor:pointer;">Upload Image</div></br><input class="file-upload" type="file" accept="image/*"/></br><p><input type="text" placeholder="Item name"/></br><p><input type="text" placeholder="Item category"/></br><p><input type="number" placeholder="Number of items"/></br><p><input id="itemsubmit" type="submit" class="btn" value="Add Item"/></br></fieldset></form></div>');
});
</code>```

I feel that my js is working for only one item. If somebody can tell me where am I going wrong. Thanks in advance.

答:
```<code>$(document).on('click','.upload-button', function(){
    $(this).closest(".cell").find('.file-upload').click();
})
</code>```

try with changing this code hope it will work

finally, I got the issue. You don't need readUrl function actually this function puts the same src in every profile-pic class instead of that I am having an alternate solution which is as below.

```<code>$("body").on('change', '.file-upload', function() {
    var profile = $(this).closest('.cell').find('.profile-pic');
       if (this.files && this.files[0]) {
           var reader = new FileReader();
           reader.onload = function (e) {
           $(profile).attr('src', e.target.result);
       }

       reader.readAsDataURL(this.files[0]);
    }
});
</code>```

Change on change code with above code and it will give you the same output as you required.

Also, you can minimize the code by using clone method instead of writing HTML in append.

```<code>$("#additem").click( function () {
    var clone = $('.grid .cell:first-child').clone();
    $(".grid").append(clone);
})
</code>```

Body:
I have a dynamic website. I want to accept the details of different items including their image. The js is working but only for one item. The moment I add another item and I try to upload a different pic, either it does not open the dialog or it will take the same image for all the items. For single item, the code is working fine.
This is my fiddle.

$(".file-upload").on('change', function(){
    readURL(this);
});
$(".upload-button").on('click', function() {
    $(".file-upload").click();
});
$("#additem").click( function () {
    $(".grid").append('
<form><fieldset style="color:white;"><legend>Item Details</legend>
Upload Image

<input class="file-upload" type="file" accept="image/*"/>

<input type="text" placeholder="Item name"/>

<input type="text" placeholder="Item category"/>

<input type="number" placeholder="Number of items"/>

<input id="itemsubmit" type="submit" class="btn" value="Add Item"/>
</fieldset></form>
');
});

I feel that my js is working for only one item. If somebody can tell me where am I going wrong. Thanks in advance.

Body:
$(document).on('click','.upload-button', function(){
    $(this).closest(".cell").find('.file-upload').click();
})

try with changing this code hope it will work

finally, I got the issue. You don't need readUrl function actually this function puts the same src in every profile-pic class instead of that I am having an alternate solution which is as below.

$("body").on('change', '.file-upload', function() {
    var profile = $(this).closest('.cell').find('.profile-pic');
       if (this.files && this.files[0]) {
           var reader = new FileReader();
           reader.onload = function (e) {
           $(profile).attr('src', e.target.result);
       }

       reader.readAsDataURL(this.files[0]);
    }
});

Change on change code with above code and it will give you the same output as you required.

Also, you can minimize the code by using clone method instead of writing HTML in append.

$("#additem").click( function () {
    var clone = $('.grid .cell:first-child').clone();
    $(".grid").append(clone);
})


问:
Why is the path to a shader in my application nil?
When I try to load a GLSL shader from my iPhone application bundle, the path to it is being reported as nil.  This shader is in my Xcode project.

Pictures are be best way to describe this:

答: did you set the file to copy to the application bundle? it may not be copied. Check the preference, I do not remember, select the file and hit "CTRL-i"</p>