问:
C# Rendering OpenCL-generated image
Problem: I'm trying to render a dynamic Julia fractal in real time. Because the fractal is constantly changing, I need to be able to render at least 20 frames per second, preferably more. What you need to know about a Julia fractal is that every pixel can be calculated independently, so the task is easy parallelizable.

First approach: Because I'm already used to Monogame in C#, I tried writing a shader in HLSL that would do the job, but the compiler kept complaining because I used up more than the allowable 64 arithmetic slots (I need at least a thousand).

Second approach: Using the CPU, it took, as could be expected, about two minutes to generate one frame.

Third approach: I started learning the basics of OpenCL using a wrapper called Cloo. I actually got a quick, nice result by calculating the image data using OpenCL, then getting the data from the GPU, storing the data in a Texture2D and drawing the texture to the screen. For a 1000x1000 image I get about 13 frames a second. This is still not quite what I had hoped for, as the image should be 1920x1080 to fill up my screen, and the frame rate is pretty noticeable. I realised that I'm actually generating the image on the GPU, sending the data to the CPU and then sending it back to the GPU, so this seems like an unnecessary step that, if could be removed, will probably solve my problem. I read on some fora that OpenGL is able to do this, but I haven't been able to find specific information.

Questions: Firstly, is there a simple way to draw the data generated by OpenCL directly without involving CPU (preferably compatible with Monogame)? If this isn't the case, is it possible to implement it using OpenGL and afterwards combine it with Monogame? Secondly, why isn't this possible with a simple HLSL shader? As HLSL and OpenCL both use the GPU, why is HLSL so much more limited when it comes to doing many arithmetic operations?

Edit

I found this site that does roughly what I want, but using a GLSL shader. This again questions my fait in HLSL. Unfortunately, as monogame doesn't support GLSL (yet), my questions remain unanswered.

答:
Sorry I do not use OpenCL nor C# but You can do this fully inside shaders using GLSL (but you might have precision problems as for Julia like fractals is sometimes even 64bit double not enough). Anyway here a simple example of Mandelbrot set I did some years back...

CPU side app C++/OpenGL/GLSL/VCL code::

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h" // VCL window header
#include "gl\\OpenGL3D_double.cpp" // my GL engine
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
OpenGLscreen scr;
GLSLprogram shd;
float mx=0.0,my=0.0,mx0=0.0,my0=0.0,mx1=0.0,my1=0.0;
TShiftState sh0,sh1;
int xs=1,ys=1;
int txrmap=-1;
float zoom=1.000;
unsigned int queryID[2];
//---------------------------------------------------------------------------
void gl_draw()
    {
    float x,y,dx,dy;
    scr.cls();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // matrix for old GL rendering
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();

    // GLSL uniforms
    shd.bind();
    shd.set1i("txrmap",0);      // texture unit
    shd.set2f("p0",mx,my);      // pan position
    shd.set1f("zoom",zoom);     // zoom

    // issue the first query
    // Records the time only after all previous
    // commands have been completed
    glQueryCounter(queryID[0], GL_TIMESTAMP);

    // QUAD covering screen
    scr.txrs.bind(txrmap);
    glColor3f(1.0,1.0,1.0);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0,0.0); glVertex2f(-1.0,+1.0);
    glTexCoord2f(0.0,1.0); glVertex2f(-1.0,-1.0);
    glTexCoord2f(1.0,1.0); glVertex2f(+1.0,-1.0);
    glTexCoord2f(1.0,0.0); glVertex2f(+1.0,+1.0);
    glEnd();
    shd.unbind();
    scr.txrs.unbind();

    // issue the second query
    // records the time when the sequence of OpenGL
    // commands has been fully executed
    glQueryCounter(queryID[1], GL_TIMESTAMP);

    // GL driver info and GLSL log
    scr.text_init_pix(1.0);
    glColor4f(0.0,0.2,1.0,0.8);
    scr.text(glGetAnsiString(GL_VENDOR));
    scr.text(glGetAnsiString(GL_RENDERER));
    scr.text("OpenGL ver: "+glGetAnsiString(GL_VERSION));
    glColor4f(0.4,0.7,0.8,0.8);
    for (int i=1;i<=shd.log.Length();) scr.text(str_load_lin(shd.log,i,true));
    scr.text_exit();

    scr.exe();
    scr.rfs();

    // wait until the results are available
    int e;
    unsigned __int64 t0,t1;
    for (e=0;!e;) glGetQueryObjectiv(queryID[0],GL_QUERY_RESULT_AVAILABLE,&e);
    for (e=0;!e;) glGetQueryObjectiv(queryID[1],GL_QUERY_RESULT_AVAILABLE,&e);
    glGetQueryObjectui64v(queryID[0], GL_QUERY_RESULT, &t0);
    glGetQueryObjectui64v(queryID[1], GL_QUERY_RESULT, &t1);
    Form1->Caption=AnsiString().sprintf("Time spent on the GPU: %f ms\n", (t1-t0)/1000000.0);
    }
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner):TForm(Owner)
    {
    scr.init(this);

    OpenGLtexture txr;
    txr.load      ("gradient.jpg");
    txrmap=scr.txrs.add(txr);

    shd.set_source_file("","","","Mandelbrot_set.glsl_vert","Mandelbrot_set.glsl_frag");

    glGenQueries(2, queryID);
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
    {
    scr.exit();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
    {
    scr.resize();
    xs=ClientWidth;
    ys=ClientHeight;
    gl_draw();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
    {
    gl_draw();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X,int Y)
    {
    bool q0,q1;
    mx1=1.0-divide(X+X,xs-1);
    my1=divide(Y+Y,ys-1)-1.0;
    sh1=Shift;
    q0=sh0.Contains(ssLeft);
    q1=sh1.Contains(ssLeft);
    if (q1)
        {
        mx-=(mx1-mx0)*zoom;
        my-=(my1-my0)*zoom;
        }
    mx0=mx1; my0=my1; sh0=sh1;
    gl_draw();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,TShiftState Shift, int X, int Y)
    {
    FormMouseMove(Sender,Shift,X,Y);
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,TShiftState Shift, int X, int Y)
    {
    FormMouseMove(Sender,Shift,X,Y);
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseWheelDown(TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled)
    {
    zoom*=1.2;
    gl_draw();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseWheelUp(TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled)
    {
    zoom/=1.2;
    gl_draw();
    }
//---------------------------------------------------------------------------
```

<p>You can ignore most of the code the important stuff is <code>gl_draw()</code> rendering single <code>QUAD</code> covering whole screen and passing <code>zoom</code> and <code>pan</code> position. This code uses old style <code>glBegin/glEnd</code> and default nVidia locations so it may not work on different vendor gfx drivers. The mesh should be in VAO/VBO so the layout locations will match to see how to do it take a look at the link on the end of answer or port the shaders to compatibility profile.</p>

<p><strong>Vertex:</strong></p>

<pre class="lang-cpp prettyprint-override"><code>// Vertex
#version 420 core
layout(location=0) in vec2 pos;     // glVertex2f <-1,+1>
out smooth vec2 p;                  // texture end point <0,1>
void main()
    {
    p=pos;
    gl_Position=vec4(pos,0.0,1.0);
    }
</code>```

Fragment:

// Fragment
#version 420 core
uniform sampler2D txrmap;           // texture unit for light map
uniform vec2 p0=vec2(0.0,0.0);      // mouse position <-1,+1>
uniform float zoom=1.000;           // zoom [-]
in smooth vec2 p;
out vec4 col;
void main()
    {
    int i,n;
    vec2 pp;
    float x,y,q,xx,yy;
    pp=(p*zoom)-p0;         // y (-1, 1)
    pp.x=(1.75*pp.x)-0.75;  // x (-2.5, 1)
    for (x=0.0,y=0.0,xx=0.0,yy=0.0,i=0,n=200;(i<n)&&(xx+yy<4.0);i++)
        {
        q=xx-yy+pp.x;
        y=(2.0*x*y)+pp.y;
        x=q;
        xx=x*x;
        yy=y*y;
        }
    q=float(i)/float(n);
    col=texture2D(txrmap,vec2(q,0.5));
//  col=vec4(q,q,q,1.0);
    }
```

using this texture as gradient:

Here result screenshot:

In case you need to get started with GLSL (to replace my gl engine stuff) see:

simple complete GL+VAO/VBO+GLSL+shaders example in C++

but I am sure there must be tons of tutorials for this in C# so google

If you are interested in color enhancing see:

Mandelbrot Set - Color Spectrum Suggestions?

Title: C# Rendering OpenCL-generated image

Body:
Sorry I do not use OpenCL nor C# but You can do this fully inside shaders using GLSL (but you might have precision problems as for Julia like fractals is sometimes even 64bit double not enough). Anyway here a simple example of Mandelbrot set I did some years back...

CPU side app C++/OpenGL/GLSL/VCL code::

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h" // VCL window header
#include "gl\\OpenGL3D_double.cpp" // my GL engine
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
OpenGLscreen scr;
GLSLprogram shd;
float mx=0.0,my=0.0,mx0=0.0,my0=0.0,mx1=0.0,my1=0.0;
TShiftState sh0,sh1;
int xs=1,ys=1;
int txrmap=-1;
float zoom=1.000;
unsigned int queryID[2];
//---------------------------------------------------------------------------
void gl_draw()
    {
    float x,y,dx,dy;
    scr.cls();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // matrix for old GL rendering
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();

    // GLSL uniforms
    shd.bind();
    shd.set1i("txrmap",0);      // texture unit
    shd.set2f("p0",mx,my);      // pan position
    shd.set1f("zoom",zoom);     // zoom

    // issue the first query
    // Records the time only after all previous
    // commands have been completed
    glQueryCounter(queryID[0], GL_TIMESTAMP);

    // QUAD covering screen
    scr.txrs.bind(txrmap);
    glColor3f(1.0,1.0,1.0);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0,0.0); glVertex2f(-1.0,+1.0);
    glTexCoord2f(0.0,1.0); glVertex2f(-1.0,-1.0);
    glTexCoord2f(1.0,1.0); glVertex2f(+1.0,-1.0);
    glTexCoord2f(1.0,0.0); glVertex2f(+1.0,+1.0);
    glEnd();
    shd.unbind();
    scr.txrs.unbind();

    // issue the second query
    // records the time when the sequence of OpenGL
    // commands has been fully executed
    glQueryCounter(queryID[1], GL_TIMESTAMP);

    // GL driver info and GLSL log
    scr.text_init_pix(1.0);
    glColor4f(0.0,0.2,1.0,0.8);
    scr.text(glGetAnsiString(GL_VENDOR));
    scr.text(glGetAnsiString(GL_RENDERER));
    scr.text("OpenGL ver: "+glGetAnsiString(GL_VERSION));
    glColor4f(0.4,0.7,0.8,0.8);
    for (int i=1;i<=shd.log.Length();) scr.text(str_load_lin(shd.log,i,true));
    scr.text_exit();

    scr.exe();
    scr.rfs();

    // wait until the results are available
    int e;
    unsigned __int64 t0,t1;
    for (e=0;!e;) glGetQueryObjectiv(queryID[0],GL_QUERY_RESULT_AVAILABLE,&e);
    for (e=0;!e;) glGetQueryObjectiv(queryID[1],GL_QUERY_RESULT_AVAILABLE,&e);
    glGetQueryObjectui64v(queryID[0], GL_QUERY_RESULT, &t0);
    glGetQueryObjectui64v(queryID[1], GL_QUERY_RESULT, &t1);
    Form1->Caption=AnsiString().sprintf("Time spent on the GPU: %f ms\n", (t1-t0)/1000000.0);
    }
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner):TForm(Owner)
    {
    scr.init(this);

    OpenGLtexture txr;
    txr.load      ("gradient.jpg");
    txrmap=scr.txrs.add(txr);

    shd.set_source_file("","","","Mandelbrot_set.glsl_vert","Mandelbrot_set.glsl_frag");

    glGenQueries(2, queryID);
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
    {
    scr.exit();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
    {
    scr.resize();
    xs=ClientWidth;
    ys=ClientHeight;
    gl_draw();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
    {
    gl_draw();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X,int Y)
    {
    bool q0,q1;
    mx1=1.0-divide(X+X,xs-1);
    my1=divide(Y+Y,ys-1)-1.0;
    sh1=Shift;
    q0=sh0.Contains(ssLeft);
    q1=sh1.Contains(ssLeft);
    if (q1)
        {
        mx-=(mx1-mx0)*zoom;
        my-=(my1-my0)*zoom;
        }
    mx0=mx1; my0=my1; sh0=sh1;
    gl_draw();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,TShiftState Shift, int X, int Y)
    {
    FormMouseMove(Sender,Shift,X,Y);
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,TShiftState Shift, int X, int Y)
    {
    FormMouseMove(Sender,Shift,X,Y);
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseWheelDown(TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled)
    {
    zoom*=1.2;
    gl_draw();
    }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseWheelUp(TObject *Sender, TShiftState Shift, TPoint &MousePos, bool &Handled)
    {
    zoom/=1.2;
    gl_draw();
    }
//---------------------------------------------------------------------------

You can ignore most of the code the important stuff is gl_draw() rendering single QUAD covering whole screen and passing zoom and pan position. This code uses old style glBegin/glEnd and default nVidia locations so it may not work on different vendor gfx drivers. The mesh should be in VAO/VBO so the layout locations will match to see how to do it take a look at the link on the end of answer or port the shaders to compatibility profile.

Vertex:

// Vertex
#version 420 core
layout(location=0) in vec2 pos;     // glVertex2f <-1,+1>
out smooth vec2 p;                  // texture end point <0,1>
void main()
    {
    p=pos;
    gl_Position=vec4(pos,0.0,1.0);
    }

Fragment:

// Fragment
#version 420 core
uniform sampler2D txrmap;           // texture unit for light map
uniform vec2 p0=vec2(0.0,0.0);      // mouse position <-1,+1>
uniform float zoom=1.000;           // zoom [-]
in smooth vec2 p;
out vec4 col;
void main()
    {
    int i,n;
    vec2 pp;
    float x,y,q,xx,yy;
    pp=(p*zoom)-p0;         // y (-1, 1)
    pp.x=(1.75*pp.x)-0.75;  // x (-2.5, 1)
    for (x=0.0,y=0.0,xx=0.0,yy=0.0,i=0,n=200;(i<n)&&(xx+yy<4.0);i++)
        {
        q=xx-yy+pp.x;
        y=(2.0*x*y)+pp.y;
        x=q;
        xx=x*x;
        yy=y*y;
        }
    q=float(i)/float(n);
    col=texture2D(txrmap,vec2(q,0.5));
//  col=vec4(q,q,q,1.0);
    }

using this texture as gradient:

Here result screenshot:

In case you need to get started with GLSL (to replace my gl engine stuff) see:

simple complete GL+VAO/VBO+GLSL+shaders example in C++

but I am sure there must be tons of tutorials for this in C# so google

If you are interested in color enhancing see:

Mandelbrot Set - Color Spectrum Suggestions?


来源: stackexchange

问:
Limit animation space inside view
I have tableView cell. When I add cell to table view, simple animation of scaling of cell element is fired

```<code> UIView.animate(withDuration: 1, animations: {
            self.quantityBackround.transform = CGAffineTransform(scaleX: 0.05, y: 0.05)
        }) { (success) in
            UIView.animate(withDuration: 0.1) {
                self.quantityBackround.transform = CGAffineTransform.identity
            }
        }
</code>```

Looks like this

The problem is that when circle expands it doesn't respect bottom border of cell and expands above it. What I want is to limit animation so it will be visible only inside cell space. (Like top part of circle - it is limited by top border of cell and is not seen)

How can I do this ?

答:
You should set the clipsToBounds property for the view's superview.

```<code>view.clipsToBounds = true
</code>```

ContentLicense: CC BY-SA 3.0

Title: Limit animation space inside view

Body:
I have tableView cell. When I add cell to table view, simple animation of scaling of cell element is fired

 UIView.animate(withDuration: 1, animations: {
            self.quantityBackround.transform = CGAffineTransform(scaleX: 0.05, y: 0.05)
        }) { (success) in
            UIView.animate(withDuration: 0.1) {
                self.quantityBackround.transform = CGAffineTransform.identity
            }
        }

Looks like this

The problem is that when circle expands it doesn't respect bottom border of cell and expands above it. What I want is to limit animation so it will be visible only inside cell space. (Like top part of circle - it is limited by top border of cell and is not seen)

How can I do this ?

Body:
You should set the clipsToBounds property for the view's superview.

view.clipsToBounds = true


问:
Export multiple classes in ES6 modules
I'm trying to create a module that exports multiple ES6 classes. Let's say I have the following directory structure:

```<code>my/
└── module/
    ├── Foo.js
    ├── Bar.js
    └── index.js
</code>```

Foo.js and Bar.js each export a default ES6 class:

```<code>// Foo.js
export default class Foo {
  // class definition
}

// Bar.js
export default class Bar {
  // class definition
}
</code>```

I currently have my index.js set up like this:

```<code>import Foo from './Foo';
import Bar from './Bar';

export default {
  Foo,
  Bar,
}
</code>```

However, I am unable to import. I want to be able to do this, but the classes aren't found:

```<code>import {Foo, Bar} from 'my/module';
</code>```

What is the correct way to export multiple classes in an ES6 module?

答:
Hope this helps:</p>

```<code>// Export (file name: my-functions.js)
export const MyFunction1 = () => {}
export const MyFunction2 = () => {}
export const MyFunction3 = () => {}

// if using `eslint` (airbnb) then you will see warning, so do this:
const MyFunction1 = () => {}
const MyFunction2 = () => {}
const MyFunction3 = () => {}

export {MyFunction1, MyFunction2, MyFunction3};

// Import
import * as myFns from "./my-functions";

myFns.MyFunction1();
myFns.MyFunction2();
myFns.MyFunction3();

// OR Import it as Destructured
import { MyFunction1, MyFunction2, MyFunction3 } from "./my-functions";

// AND you can use it like below with brackets (Parentheses) if it's a function
// AND without brackets if it's not function (eg. variables, Objects or Arrays)
MyFunction1();
MyFunction2();
</code>```

Title: Export multiple classes in ES6 modules

Body:
I'm trying to create a module that exports multiple ES6 classes. Let's say I have the following directory structure:

my/
└── module/
    ├── Foo.js
    ├── Bar.js
    └── index.js

Foo.js and Bar.js each export a default ES6 class:

// Foo.js
export default class Foo {
  // class definition
}

// Bar.js
export default class Bar {
  // class definition
}

I currently have my index.js set up like this:

import Foo from './Foo';
import Bar from './Bar';

export default {
  Foo,
  Bar,
}

However, I am unable to import. I want to be able to do this, but the classes aren't found:

import {Foo, Bar} from 'my/module';

What is the correct way to export multiple classes in an ES6 module?

Body:
Hope this helps:

// Export (file name: my-functions.js)
export const MyFunction1 = () => {}
export const MyFunction2 = () => {}
export const MyFunction3 = () => {}

// if using `eslint` (airbnb) then you will see warning, so do this:
const MyFunction1 = () => {}
const MyFunction2 = () => {}
const MyFunction3 = () => {}

export {MyFunction1, MyFunction2, MyFunction3};

// Import
import * as myFns from "./my-functions";

myFns.MyFunction1();
myFns.MyFunction2();
myFns.MyFunction3();

// OR Import it as Destructured
import { MyFunction1, MyFunction2, MyFunction3 } from "./my-functions";

// AND you can use it like below with brackets (Parentheses) if it's a function
// AND without brackets if it's not function (eg. variables, Objects or Arrays)
MyFunction1();
MyFunction2();

ContentLicense: CC BY-SA 4.0


问:
Building a dynamic component loader with Angular CLI
Basically i want to create a dynamic plugin system. I need to be able to deploy new plugins without having to redeploy the main plugin system.

Basically if I was to use SystemJS i could just do something like

```<code>System.import(url).then(plugin => {
  this.createComponent(plugin.default);
});
</code>```

url being the dynamic thing - could read this from a db or config, etc.

The above could would work - except i use the Angular CLI, which uses Webpack. Using the CLI is a choice made to simply the whole project - so I'm stuck with Webpack and the CLI.

Since the Angular CLI does a lot of abstraction, I can't modify the webpack config (well I can, but then i have to maintain it manually, which again would break the simplicity).

Webpack is not a module loading, but a bundler - meaning it is supposed to know these modules beforehand, and i can't just drop a new module somewhere and update the config for it to load it dynamically.

What would my options be here?

EDIT: Webpack has its own System.import, but it has some checking to see if the url is static or dynamic. I could live with passing a static folder and having to drop plugins into that folder - that just doesn't seem to work from anywhere but inside the application itself.

答:
Unfortunately, as far as I know, at the end of the day you need to add your dynamic component to the entryComponents of the current module, otherwise Angular won't let you load it dynamically and it will complain.

So either way, you've got to load the component statically and put it inside the entryComponents, so not much point in using SystemJS or Something else, you could just create a dictionary and use it when ever you want :

import {MyComponentClass} from 'somewhere';

```<code>const dictionary = {
    component1  = MyComponentClass
}

 this.createComponent(dictionary[urlOrName]);
</code>```

The other possible solution would be to create a module for each component that you're going to load dynamically and then add that component to the entryComponents of that module, that way, you could be able to import/download that module dynamically but I'm not sure if you could add that dynamic module to the root module dynamically or not ( the way router is doing it when lazyLoading !~~).

Angular used to be much simpler regarding the dynamic components before they introduced AOT, they honestly killed the simplicity with introducing AOT

Body:
Basically i want to create a dynamic plugin system. I need to be able to deploy new plugins without having to redeploy the main plugin system.

Basically if I was to use SystemJS i could just do something like

System.import(url).then(plugin => {
  this.createComponent(plugin.default);
});

url being the dynamic thing - could read this from a db or config, etc.

The above could would work - except i use the Angular CLI, which uses Webpack. Using the CLI is a choice made to simply the whole project - so I'm stuck with Webpack and the CLI.

Since the Angular CLI does a lot of abstraction, I can't modify the webpack config (well I can, but then i have to maintain it manually, which again would break the simplicity).

Webpack is not a module loading, but a bundler - meaning it is supposed to know these modules beforehand, and i can't just drop a new module somewhere and update the config for it to load it dynamically.

What would my options be here?

EDIT: Webpack has its own System.import, but it has some checking to see if the url is static or dynamic. I could live with passing a static folder and having to drop plugins into that folder - that just doesn't seem to work from anywhere but inside the application itself.

Body:
Unfortunately, as far as I know, at the end of the day you need to add your dynamic component to the entryComponents of the current module, otherwise Angular won't let you load it dynamically and it will complain.

So either way, you've got to load the component statically and put it inside the entryComponents, so not much point in using SystemJS or Something else, you could just create a dictionary and use it when ever you want :

import {MyComponentClass} from 'somewhere';

const dictionary = {
    component1  = MyComponentClass
}

 this.createComponent(dictionary[urlOrName]);

The other possible solution would be to create a module for each component that you're going to load dynamically and then add that component to the entryComponents of that module, that way, you could be able to import/download that module dynamically but I'm not sure if you could add that dynamic module to the root module dynamically or not ( the way router is doing it when lazyLoading !~~).

Angular used to be much simpler regarding the dynamic components before they introduced AOT, they honestly killed the simplicity with introducing AOT


问:
Issuu, how to write issuu.documents.list request correctly?
I want to use issuu.documents.list to list my document from issuu, It work fine. But when I add two more parameters startIndex and pageSize, it doesn't work.
Here is my signing request:

[apiSecret]accessprivateactionissuu.documents.listapiKey[apiKey]startIndex0pageSize20formatxmlresponseParamstitle,documentId

and My request url:

http://api.issuu.com/1_0?action=issuu.documents.list&apiKey=[apiKey]&access=private&startIndex=0&pageSize=20&format=xml&responseParams=title%2CdocumentId&signature=[signature]

So, may you show me what's wrong in my syntax with startIndex and pageSize parameters?
Many thanks,

答:
All requests to the issuu api have to be signed (as you know). Before creating an md5 hash of your signature, you must first order all the keys alphabetically.

WRONG

[apiSecret]accessprivateactionissuu.documents.listapiKey[apiKey]startIndex0pageSize20formatxmlresponseParamstitle,documentId

CORRECT

[apiSecret]accessprivateactionissuu.documents.listapiKey[apiKey]pageSize20formatxmlresponseParamstitle,documentIdstartIndex0

So in your example, you have startIndex positioned before responseParams when it really should go after it.

Alphabetically ordering the keys in your signature is a requirement of Issuu's API as documented here. http://issuu.com/services/api/signingrequests.html

ContentLicense: CC BY-SA 2.5


问:
"Click" effect on a customized button
I was looking over internet for an arrow shaped button. I found this solution:

```<code> <Button HorizontalAlignment="Center" Click="Button_Click">
         <Button.Template>
             <ControlTemplate TargetType="Button">
                 <Grid>
                     <StackPanel Orientation="Horizontal">
                         <Rectangle Width="100" Height="25" Stroke="Orange" Fill="Orange" VerticalAlignment="Center"/>
                         <Polygon  Points= "0,0 30,25, 0,50" Stroke="Orange" Fill="Orange" VerticalAlignment="Center"/>
                     </StackPanel>
                     <ContentPresenter HorizontalAlignment="Left" Margin="45,0,0,0" VerticalAlignment="Center" Content="Login"/>
                 </Grid>
             </ControlTemplate>
         </Button.Template>
 </Button>
</code>```

The problem with this is that, while this is a button that can be clicked, i "lost" the button click effect (i.e the effect that you have when you press the button). Do you know if there is a way to solve my problem?

答:
You need to define this effect yourself in your custom template.

Add an IsPressed trigger that changes some properties of the elements in your template:

```<code><Button.Template>
    <ControlTemplate TargetType="Button">
        <Grid>
            <StackPanel Orientation="Horizontal">
                <Rectangle x:Name="rect" Width="100" Height="25" Stroke="Orange" Fill="Orange" VerticalAlignment="Center"/>
                <Polygon x:Name="pol"  Points= "0,0 30,25, 0,50" Stroke="Orange" Fill="Orange" VerticalAlignment="Center"/>
            </StackPanel>
            <ContentPresenter HorizontalAlignment="Left" Margin="45,0,0,0" VerticalAlignment="Center" Content="Login"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsPressed" Value="true">
                <Setter Property="Fill" TargetName="rect" Value="Red"/>
                <Setter Property="Fill" TargetName="pol" Value="Blue"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
</Button.Template>
</code>```

Title: "Click" effect on a customized button

Body:
I was looking over internet for an arrow shaped button. I found this solution:

 <Button HorizontalAlignment="Center" Click="Button_Click">
         <Button.Template>
             <ControlTemplate TargetType="Button">
                 <Grid>
                     <StackPanel Orientation="Horizontal">
                         <Rectangle Width="100" Height="25" Stroke="Orange" Fill="Orange" VerticalAlignment="Center"/>
                         <Polygon  Points= "0,0 30,25, 0,50" Stroke="Orange" Fill="Orange" VerticalAlignment="Center"/>
                     </StackPanel>
                     <ContentPresenter HorizontalAlignment="Left" Margin="45,0,0,0" VerticalAlignment="Center" Content="Login"/>
                 </Grid>
             </ControlTemplate>
         </Button.Template>
 </Button>

The problem with this is that, while this is a button that can be clicked, i "lost" the button click effect (i.e the effect that you have when you press the button). Do you know if there is a way to solve my problem?

Body:
You need to define this effect yourself in your custom template.

Add an IsPressed trigger that changes some properties of the elements in your template:

<Button.Template>
    <ControlTemplate TargetType="Button">
        <Grid>
            <StackPanel Orientation="Horizontal">
                <Rectangle x:Name="rect" Width="100" Height="25" Stroke="Orange" Fill="Orange" VerticalAlignment="Center"/>
                <Polygon x:Name="pol"  Points= "0,0 30,25, 0,50" Stroke="Orange" Fill="Orange" VerticalAlignment="Center"/>
            </StackPanel>
            <ContentPresenter HorizontalAlignment="Left" Margin="45,0,0,0" VerticalAlignment="Center" Content="Login"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsPressed" Value="true">
                <Setter Property="Fill" TargetName="rect" Value="Red"/>
                <Setter Property="Fill" TargetName="pol" Value="Blue"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
</Button.Template>


问:
edit iframe name with imacro js
I have a code that simply edits the name of the frame, in normal page its working:
https://www.google.com/recaptcha/api2/demo?invisible=true
or any single page with recaptcha.

but on this site have 3 frames with recaptcha:
http://multytabrailblocks.tk/

the code does not change the name of the frame, Because it's frame inside frame.
I need help to fix it please

```<code>FRAME F=2
URL GOTO=javascript:((function(){var%20a=window.content.document.getElementsByTagName('iframe');var%20k='';for(var%20x=0;x<a.length;x++)if(a[x].src.includes('https://www.google.com/recaptcha/api2/bframe')){a[x].setAttribute("name","newname")}}))()
FRAME NAME="newname"
'frame name still not "newname"
</code>```

答:
My idea is following:

```<code>iimPlayCode("URL GOTO=https://www.yahoo.com/");
// there's no "newname" yet
alert(iimPlayCode("FRAME name=newname"));

for (i = 0; i < window.frames.length; i++) {
    try {
        window.frames[i].document.getElementsByTagName("iframe")[0].setAttribute("name","newname");
    } catch(e) {
    }
}

// now it should be alright
iimPlayCode("FRAME name=newname" + "\n" + "TAG POS=1 TYPE=* ATTR=* EXTRACT=HTM");
alert(iimGetExtract());
</code>```

Try it under 'iMacros for Firefox' v.8.9.7 and adjust this script for your issue.

I assume that you know the basics of JavaScript.

Title: edit iframe name with imacro js

Body:
I have a code that simply edits the name of the frame, in normal page its working:
https://www.google.com/recaptcha/api2/demo?invisible=true
or any single page with recaptcha.

but on this site have 3 frames with recaptcha:
http://multytabrailblocks.tk/

the code does not change the name of the frame, Because it's frame inside frame.
I need help to fix it please

FRAME F=2
URL GOTO=javascript:((function(){var%20a=window.content.document.getElementsByTagName('iframe');var%20k='';for(var%20x=0;x<a.length;x++)if(a[x].src.includes('https://www.google.com/recaptcha/api2/bframe')){a[x].setAttribute("name","newname")}}))()
FRAME NAME="newname"
'frame name still not "newname"

Body:
My idea is following:

iimPlayCode("URL GOTO=https://www.yahoo.com/");
// there's no "newname" yet
alert(iimPlayCode("FRAME name=newname"));

for (i = 0; i < window.frames.length; i++) {
    try {
        window.frames[i].document.getElementsByTagName("iframe")[0].setAttribute("name","newname");
    } catch(e) {
    }
}

// now it should be alright
iimPlayCode("FRAME name=newname" + "\n" + "TAG POS=1 TYPE=* ATTR=* EXTRACT=HTM");
alert(iimGetExtract());

Try it under 'iMacros for Firefox' v.8.9.7 and adjust this script for your issue.

I assume that you know the basics of JavaScript.


问:
Xamarin forms Rest Client
Anybody suggest me a good Rest client that i can use for my xamarin forms cross platform application ?

(Android and Windows Phone)

Thanks in advance.

答:
You can you Microsoft HTTP Client Libraries.

Then, you define a RestService class that contains a HttpClient instance:

```<code>public class RestService : IRestService
{
    HttpClient client;

    public RestService()
    {
        client = new HttpClient();
        client.MaxResponseContentBufferSize = 256000;
    }

    // example for GET request
    public async Task<List<TodoItem>> RefreshDataAsync()
    {
        var uri = new Uri(string.Format(Constants.RestUrl, string.Empty));
        var response = await client.GetAsync(uri); // make a GET request
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            // handle response here
        }
    }
}
</code>```

You should follow this article:
https://developer.xamarin.com/guides/xamarin-forms/cloud-services/consuming/rest/

Title: Xamarin forms Rest Client

Body:
You can you Microsoft HTTP Client Libraries.

Then, you define a RestService class that contains a HttpClient instance:

public class RestService : IRestService
{
    HttpClient client;

    public RestService()
    {
        client = new HttpClient();
        client.MaxResponseContentBufferSize = 256000;
    }

    // example for GET request
    public async Task<List<TodoItem>> RefreshDataAsync()
    {
        var uri = new Uri(string.Format(Constants.RestUrl, string.Empty));
        var response = await client.GetAsync(uri); // make a GET request
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            // handle response here
        }
    }
}

You should follow this article:
https://developer.xamarin.com/guides/xamarin-forms/cloud-services/consuming/rest/


问:
Select records matching concat value of two fields in mongodb
Is there a way to do something like this on MongoDB?

select * from table where concat(field1, field2) = 'value'
```

<p>To clarify, I have an array of full names, but the documents have firstname and lastname separate, so I want to do something like:</p>

<pre class="lang-sql prettyprint-override"><code>select * from table where concat(firstname, lastname) in ([ARRAY OF NAMES])
</code>```

答:
In Mongoose you can like that

```<code>let clause =  [
            { $project: { name: { $concat: ["$first_name"," ","$last_name"]}}},
            { $match: { name: new RegExp("ab", 'i')}}
         ];
Model.aggregate(clause)
</code>```

OutPut will be like that

```<code>[
{
    "_id": "5911db2b9235272052fdd2e1",
    "name": "Ali Abbas"
},
{
    "_id": "5912f7dd8bdbc24aa37b5239",
    "name": "Ali Abad"
},
{
    "_id": "59229e0322abdb311818e419",
    "name": "Syed Ali Abbas Shah"
},
{
    "_id": "592837da188fa969cc135ddc",
    "name": "Abu Akbar"
}
</code>```

]

Body:
Is there a way to do something like this on MongoDB?

select * from table where concat(field1, field2) = 'value'

To clarify, I have an array of full names, but the documents have firstname and lastname separate, so I want to do something like:

select * from table where concat(firstname, lastname) in ([ARRAY OF NAMES])

Body:
In Mongoose you can like that

let clause =  [
            { $project: { name: { $concat: ["$first_name"," ","$last_name"]}}},
            { $match: { name: new RegExp("ab", 'i')}}
         ];
Model.aggregate(clause)

OutPut will be like that

[
{
    "_id": "5911db2b9235272052fdd2e1",
    "name": "Ali Abbas"
},
{
    "_id": "5912f7dd8bdbc24aa37b5239",
    "name": "Ali Abad"
},
{
    "_id": "59229e0322abdb311818e419",
    "name": "Syed Ali Abbas Shah"
},
{
    "_id": "592837da188fa969cc135ddc",
    "name": "Abu Akbar"
}

]


问:
Can't select credential kind when creating Jenkins credentials inside folder
I'm trying to create a new credential inside a Jenkins folder called Playground but for some reason the Kind field where I'm supposed to be able to select the type of credential I want only shows a fixed option Username with password

However, if I step outside of the folder and to go the Jenkins root and try to create a credential there, then I do get the combo with all the available options for the Kind field:

Note that when I do this inside a folder there's a message just below the ID field saying ERROR. When I display the error I see this:

Here's the full stack trace:

```<code>java.lang.NullPointerException
    at com.cloudbees.plugins.credentials.impl.BaseStandardCredentials$BaseStandardCredentialsDescriptor.doCheckId(BaseStandardCredentials.java:203)
    at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source)
    at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
    at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117)
    at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:129)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
Caused: javax.servlet.ServletException
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:765)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
    at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135)
    at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:138)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:86)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
    at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:92)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
    at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
    at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.Server.handle(Server.java:564)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
    at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:278)
    at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:148)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
    at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
    at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
    at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
</code>```

Here's the info on the plugin versions I'm using:

Credentials: 2.1.13

Credentials binding: 1.11

Folders: 6.0.4

Has anyone encountered and issue such as this before?

答:
After much searching I found the source of the problem. By mistake I had added a restriction to the types of credentials allowed in a folder.

By going to Jenkins>Manage Jenkis>Configure Credentials - http://$JENKINS_URL/configureCredentials/ and deleting the restriction I'm now able to create any type of credential inside a folder.

Body:
I'm trying to create a new credential inside a Jenkins folder called Playground but for some reason the Kind field where I'm supposed to be able to select the type of credential I want only shows a fixed option Username with password

However, if I step outside of the folder and to go the Jenkins root and try to create a credential there, then I do get the combo with all the available options for the Kind field:

Note that when I do this inside a folder there's a message just below the ID field saying ERROR. When I display the error I see this:

Here's the full stack trace:

java.lang.NullPointerException
    at com.cloudbees.plugins.credentials.impl.BaseStandardCredentials$BaseStandardCredentialsDescriptor.doCheckId(BaseStandardCredentials.java:203)
    at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source)
    at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
    at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117)
    at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:129)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
Caused: javax.servlet.ServletException
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:765)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:845)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
    at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135)
    at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:138)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:86)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
    at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:92)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
    at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
    at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.eclipse.jetty.server.Server.handle(Server.java:564)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
    at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:278)
    at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:148)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
    at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
    at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
    at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Here's the info on the plugin versions I'm using:

Credentials: 2.1.13

Credentials binding: 1.11

Folders: 6.0.4

Has anyone encountered and issue such as this before?


问:
VL_SLIC MATLAB Output for VL_FEAT
I am using the VL_SLIC function in MATLAB and I am following the tutorial for the function here: http://www.vlfeat.org/overview/slic.html

This is the code I have written so far:

```<code>im = imread('slic_image.jpg');
regionSize = 10 ;
regularizer = 10;
vl_setup;
segments = vl_slic(single(im), regionSize, regularizer);
imshow(segments);
</code>```

I just get a black image and I am not able to see the segmented image with the superpixels. Is there a way that I can view the result as shown in the webpage?

答:
While I want to take nothing away from ~ rayryeng's ~ beautiful answer.
This could also help.
http://www.vlfeat.org/matlab/demo/vl_demo_slic.html

Available in: toolbox/demo

Title: VL_SLIC MATLAB Output for VL_FEAT

Body:
I am using the VL_SLIC function in MATLAB and I am following the tutorial for the function here: http://www.vlfeat.org/overview/slic.html

This is the code I have written so far:

im = imread('slic_image.jpg');
regionSize = 10 ;
regularizer = 10;
vl_setup;
segments = vl_slic(single(im), regionSize, regularizer);
imshow(segments);

I just get a black image and I am not able to see the segmented image with the superpixels. Is there a way that I can view the result as shown in the webpage?


问:
Interesting Applications of Interfaces
Why are interfaces useful?

Actually, I have a [small] idea of why interfaces are useful/necessary but...

What are [interesting or realistic] applications of interfaces?

答:
Interfaces are interesting because you can allow 2 classes to implement the same methods. Lets look at an example.

Say I have a base class called Animal. All animals breathe, and communicate. Now lets say I have 3 classes, called Dolphin, Human, and Tiger. All of theses animals breathe and communicate. But I want to implement a walking method for the Human and Tiger. Dolphins cant walk. So I inherit the IWalk method for the latter two, and when I compile the class, I HAVE to implement the methods specified in the interface, or it won't compile. It's a contract saying, "If I want to implement this class, I have to implement these methods."

OwnerDisplayName: koldfyre

Title: Interesting Applications of Interfaces

OwnerDisplayName: Bbetances


问:
Is it possible to send SILENT LOCAL notification on iOS
My app wakes up from suspended mode on silent remote notification from a server, exactly as I want. This server sends a push notification with "content-available:1", which does the job.

Now I want to do this without the help of a server and so I want to send silent local notifications (from the app) at a time in the future (like after 15 min.), but can't find a way to set "content-available:1". So I end up getting local notification that doesn't wake up my app, as I can with remote notification.

I've searched for information and all I can find are examples of interactive notifications and how to set title, body, alert and triggers (based on location, date and so on.). But nothing about how to set content-available property.

So, is possible to set content-available for local notifications?

答:
I think it is not really possible to wake up app without user intervention on local notifications.
Background fetch could be the possible solution for your case.

```<code>application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
</code>```

This UIApplicationDelegate method gets called when iOS decides a background fetch can happen:

```<code>func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
</code>```

Body:
I think it is not really possible to wake up app without user intervention on local notifications.
Background fetch could be the possible solution for your case.

application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)

This UIApplicationDelegate method gets called when iOS decides a background fetch can happen:

func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)


问:
Firebase invalid path in call to update() database ref javascript
I am using the Firebase node.js admin sdk to create user accounts via a csv importer with custom uids. This all works fine. On succesfull creation of the account I would like to update a database reference. However whenever the function loops through to create the entries in the db it fails with the message

Uncaught Error: Firebase.child failed: First argument was an invalid path: "contractors/jk116734s". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"

as you can see in the logged message above the path doesn't contain any of those unwanted characters and the path is not empty. Strangely it does update one record in the db but all the others fail. The path "contractors/jk116734s" I am also logging all the paths and none are undefined or containing invalid characters. The jk***** part of the urls are all unique fyi.

Here is my function that gets called on each succesfull account creation.

```<code>function createDbEtnryForUser(index, contractorData) {

    var ni = contractorData.ni;
    var path = "contractors/" + ni
    console.log(path);
    databaseRoot.ref(path).update(contractorData);

    databaseRoot.ref(path).once('value',function(snapshot) {

        $('#row-'+index).css({"background-color":"green", "color":"white"});

    });

}
</code>```

also you can see one entry is getting created but the rest are not.

Weirdly if I don't use the custom uid and use the auto uids created by firebase all works fine. What I don't understand though is that all the accounts do get created with the custom uid and as you can see logged I am getting the custom uid back to use in the call to update.

答:
It looks like there may be invisible characters in the value of ni. See this answer - stackoverflow.com/a/12793237/782358 - to display those characters:

You can use encodeURI for showing the hidden stuffs.

Body:
I am using the Firebase node.js admin sdk to create user accounts via a csv importer with custom uids. This all works fine. On succesfull creation of the account I would like to update a database reference. However whenever the function loops through to create the entries in the db it fails with the message

Uncaught Error: Firebase.child failed: First argument was an invalid path: "contractors/jk116734s". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"

as you can see in the logged message above the path doesn't contain any of those unwanted characters and the path is not empty. Strangely it does update one record in the db but all the others fail. The path "contractors/jk116734s" I am also logging all the paths and none are undefined or containing invalid characters. The jk***** part of the urls are all unique fyi.

Here is my function that gets called on each succesfull account creation.

function createDbEtnryForUser(index, contractorData) {

    var ni = contractorData.ni;
    var path = "contractors/" + ni
    console.log(path);
    databaseRoot.ref(path).update(contractorData);

    databaseRoot.ref(path).once('value',function(snapshot) {

        $('#row-'+index).css({"background-color":"green", "color":"white"});

    });

}

also you can see one entry is getting created but the rest are not.

Weirdly if I don't use the custom uid and use the auto uids created by firebase all works fine. What I don't understand though is that all the accounts do get created with the custom uid and as you can see logged I am getting the custom uid back to use in the call to update.


问:
Can a single EBS be shared across multiple Amazon Docker Containers?
I want to copy some data from S3 to EBS when the FIRST Docker Container spins off. For subsequent spawned Docker Containers, I want to share the data I copied on the EBS. I do not want data to be duplicated for every Docker Container.

Can anyone tell me if a single EBS can be shared across multiple Amazon Docker Containers ?

答:
Yes, multiple docker containers can share data located on an EBS volume attached to an EC2 instance if they are running on that EC2 instance. </p>

<p>This is not possible with ECS as several EC2 instances would be involved. </p>

Body:
Yes, multiple docker containers can share data located on an EBS volume attached to an EC2 instance if they are running on that EC2 instance.

This is not possible with ECS as several EC2 instances would be involved.