问:
How to use @angular/cli and non angular script
I just upgraded an application to Angular 5 and wanted to try out @angular/cli because until now I just different webpack configs derived from the angular starter package.

Our build is straight forward with one exception I'm not sure how to handle.

We use adal.js (basically an JS OAuth Library for Micosoft ADFS) and need to create a second html file with a simple Javascript (transpiled from TypesScript) which has nothing to do with Angular.
All it does is handle the GET response from ADFS and redirect to the Angular Application.

So far we just defined multiple entry points in webpack and use the HtmlWebpackPlugin to seperate the chunks like so

```<code>entry: {
            'polyfills': './src/polyfills.ts',
            'main': AOT ? './src/main.browser.aot.ts'
                : './src/main.browser.ts',
            'frameRedirect': './src/frame-redirect.ts'
        },

// under plugins
new HtmlWebpackPlugin({
                template: 'src/frameRedirect.html',
                filename: 'frameRedirect.html',
                chunks: ['frameRedirect'],
                inject: 'head'
            }),
            new HtmlWebpackPlugin({
                template: 'src/index.html',
                metadata: METADATA,
                chunksSortMode: 'manual',
                chunks: ['vendor', 'polyfills', 'main']
            }),
</code>```

Does @angular/cli provide a way to do that?
Defining a second application in angular-cli.json doesn't work because it's not an angular application.

Or do I have to define a second process which compiles, uglifies, minifies etc. my script?

Or stay with standard webpack?

答:
I gave up trying it (don't even know if it even works).

What I do now

compile the ts files (in my case frame-redirect.ts) to javascript with webpack/rollup or whatever you want to use.

include it as assets in .angular-cli.json

```<code>{ "glob": "frame-redirect.js", "input": "../node_modules/a-private-package/dist/libs/", "output": "./" }
</code>```

I decided it's easer and faster to completly rely on angular-cli for my app and have a second/unrelated building process (which has to run before you compile your angular app).

Body:
I just upgraded an application to Angular 5 and wanted to try out @angular/cli because until now I just different webpack configs derived from the angular starter package.

Our build is straight forward with one exception I'm not sure how to handle.

We use adal.js (basically an JS OAuth Library for Micosoft ADFS) and need to create a second html file with a simple Javascript (transpiled from TypesScript) which has nothing to do with Angular.
All it does is handle the GET response from ADFS and redirect to the Angular Application.

So far we just defined multiple entry points in webpack and use the HtmlWebpackPlugin to seperate the chunks like so

entry: {
            'polyfills': './src/polyfills.ts',
            'main': AOT ? './src/main.browser.aot.ts'
                : './src/main.browser.ts',
            'frameRedirect': './src/frame-redirect.ts'
        },

// under plugins
new HtmlWebpackPlugin({
                template: 'src/frameRedirect.html',
                filename: 'frameRedirect.html',
                chunks: ['frameRedirect'],
                inject: 'head'
            }),
            new HtmlWebpackPlugin({
                template: 'src/index.html',
                metadata: METADATA,
                chunksSortMode: 'manual',
                chunks: ['vendor', 'polyfills', 'main']
            }),

Does @angular/cli provide a way to do that?
Defining a second application in angular-cli.json doesn't work because it's not an angular application.

Or do I have to define a second process which compiles, uglifies, minifies etc. my script?

Or stay with standard webpack?

Body:
I gave up trying it (don't even know if it even works).

What I do now

compile the ts files (in my case frame-redirect.ts) to javascript with webpack/rollup or whatever you want to use.

include it as assets in .angular-cli.json

{ "glob": "frame-redirect.js", "input": "../node_modules/a-private-package/dist/libs/", "output": "./" }

I decided it's easer and faster to completly rely on angular-cli for my app and have a second/unrelated building process (which has to run before you compile your angular app).


来源: stackexchange

问:
BufferGeometry create particles z-index
I created two particles with a threejs BufferGeometry， I want to click on each particle shows the corresponding image.

But when I clicked on the particle the image was shown and another particle covered it.

I want to know how to get the particles out of the control of the hierarchy and keep the clicked particles always on top.

code：`

var scene, camera, renderer,controls;
var points;
var shaderMaterial;

var particleCount = 2;

function init () {
      scene = new THREE.Scene();

      camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
      camera.position.x = 15;
      camera.position.y = 16;
      camera.position.z = 35;
      camera.lookAt(scene.position);

      renderer = new THREE.WebGLRenderer();

      renderer.setClearColor(0x000000, 1.0);

      renderer.setSize(window.innerWidth, window.innerHeight);

      var light = new THREE.AmbientLight( 0xcccccc );

      scene.add(light);

      document.body.appendChild(renderer.domElement);

      createParticles();

      createGrid();

      render();

      document.querySelector('canvas').addEventListener( 'click', interactive, false );

  }

function createParticles () {
    var geometry = new THREE.BufferGeometry();
    var positions = new Float32Array( particleCount * 3 );
    var sizes = new Float32Array( particleCount );
    var pop = new Float32Array( particleCount);

     for (var i = 0, i3 = 0; i < particleCount; i ++, i3 += 3) {
         positions[i3 + 0] = i* 10;
         positions[i3 + 1] = 0.1;
         positions[i3 + 2] = 1;

         sizes[i] = 15;
         pop[i] = 0.0;
     }

    geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
    geometry.addAttribute( 'size', new THREE.BufferAttribute( sizes, 1 ) );
    geometry.addAttribute( 'pop', new THREE.BufferAttribute( pop, 1 ) );

    shaderMaterial = new THREE.ShaderMaterial({
        uniforms: {
            'u_time': {type: 'f', value: 1.0},
            'u_texture_0':   { value: new THREE.TextureLoader().load('https://avatars2.githubusercontent.com/u/5829050?s=256&v=4') }},
        vertexShader:   document.getElementById( 'vs' ).textContent,
        fragmentShader: document.getElementById( 'fs' ).textContent,
        // blending:       THREE.AdditiveBlending,
        depthTest:      false,
        transparent:    true
    });
    shaderMaterial.uniforms['u_texture_0'].value.flipY = false;

    points = new THREE.Points(geometry, shaderMaterial);

    scene.add(points);

}
var raycaster = new THREE.Raycaster();
raycaster.params.Points.threshold = 5;

var touch = new THREE.Vector2();
var intersects, INTERSECTED;
var beforeIndex;

function interactive (event) {
    touch.x = ( event.clientX / window.innerWidth ) * 2 - 1;
    touch.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
    points.geometry.computeBoundingSphere();
    camera.updateMatrixWorld();
    var vector = new THREE.Vector3(touch.x, touch.y, 0.5 ).unproject(camera);
    raycaster.set(camera.position, vector.sub(camera.position ).normalize());

    raycaster.setFromCamera( touch, camera );

    intersects = raycaster.intersectObject(points);
    if ( intersects.length > 0 ) {
        if ( INTERSECTED != intersects[ 0 ].index ) {
            INTERSECTED = intersects[ 0 ].index;
            if (beforeIndex != INTERSECTED) {
                points.geometry.attributes.pop.array[ beforeIndex ] = 0.0;
            }
            points.geometry.attributes.pop.array[ INTERSECTED ] = 1.0;

            beforeIndex = INTERSECTED;

        }
    }

    points.geometry.attributes.size.needsUpdate = true;
    points.geometry.attributes.pop.needsUpdate = true;
}

function createGrid () {
    var helper = new THREE.GridHelper( 100, 20, 0x303030, 0x303030 );
    scene.add( helper );
}
 function render () {

    renderer.render(scene, camera);

    requestAnimationFrame(render);
}

init();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
      margin: 0;
      padding: 0;
  }
  html, body {
      width: 100%;
      height: 100%;
      background: #000;
  }
  canvas {
      display: block;
  }</code>```

```

`

答:
You have misunderstanding about how 3D works, therefore, you use wrong concepts and terminology. There is no "Z-Index" in 3D. There is Z-buffer or Depth-buffer (two names, same thing), which reflects object distance from the render's point of view (camera, virtual observer). Naturarly, the purpose of the depth-buffer with depth-testing is to prevent farest objects to be rendered in front of closest ones (this also allow to optimize, by preventing unseen pixels to be computed).

Also, the background to foreground display is not controled by any hierarchy (unless the engine deliberately implements such feature), objects are simply rendered in order they are supplied. If the Depth-testing is disabled, the latest rendered object will be displayed in front of all previously rendered ones. In 3D scene, the hierarchy is relative to transformations, not display order (unless objects are rendered in scene's hierarchy order without depth-testing).

To achieve what you want in robust way, you'll have to disable the depth-desting and manually control the order which of sprites are rendered, to ensure the one which must be in "front", is the last rendered one. This is a pretty low-level manipulation, and unless Three.JS allow you to control that (which I doubt), you'll probably have to changes your tactic, or implements your own WebGL engine.

ContentLicense: CC BY-SA 3.0

Title: BufferGeometry create particles z-index

Body:
I created two particles with a threejs BufferGeometry， I want to click on each particle shows the corresponding image.

But when I clicked on the particle the image was shown and another particle covered it.

I want to know how to get the particles out of the control of the hierarchy and keep the clicked particles always on top.

code：`

var scene, camera, renderer,controls;
var points;
var shaderMaterial;

var particleCount = 2;

function init () {
      scene = new THREE.Scene();

      camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
      camera.position.x = 15;
      camera.position.y = 16;
      camera.position.z = 35;
      camera.lookAt(scene.position);

      renderer = new THREE.WebGLRenderer();

      renderer.setClearColor(0x000000, 1.0);

      renderer.setSize(window.innerWidth, window.innerHeight);

      var light = new THREE.AmbientLight( 0xcccccc );

      scene.add(light);

      document.body.appendChild(renderer.domElement);

      createParticles();

      createGrid();

      render();

      document.querySelector('canvas').addEventListener( 'click', interactive, false );

  }

function createParticles () {
    var geometry = new THREE.BufferGeometry();
    var positions = new Float32Array( particleCount * 3 );
    var sizes = new Float32Array( particleCount );
    var pop = new Float32Array( particleCount);

     for (var i = 0, i3 = 0; i < particleCount; i ++, i3 += 3) {
         positions[i3 + 0] = i* 10;
         positions[i3 + 1] = 0.1;
         positions[i3 + 2] = 1;

         sizes[i] = 15;
         pop[i] = 0.0;
     }

    geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
    geometry.addAttribute( 'size', new THREE.BufferAttribute( sizes, 1 ) );
    geometry.addAttribute( 'pop', new THREE.BufferAttribute( pop, 1 ) );

    shaderMaterial = new THREE.ShaderMaterial({
        uniforms: {
            'u_time': {type: 'f', value: 1.0},
            'u_texture_0':   { value: new THREE.TextureLoader().load('https://avatars2.githubusercontent.com/u/5829050?s=256&v=4') }},
        vertexShader:   document.getElementById( 'vs' ).textContent,
        fragmentShader: document.getElementById( 'fs' ).textContent,
        // blending:       THREE.AdditiveBlending,
        depthTest:      false,
        transparent:    true
    });
    shaderMaterial.uniforms['u_texture_0'].value.flipY = false;

    points = new THREE.Points(geometry, shaderMaterial);

    scene.add(points);

}
var raycaster = new THREE.Raycaster();
raycaster.params.Points.threshold = 5;

var touch = new THREE.Vector2();
var intersects, INTERSECTED;
var beforeIndex;

function interactive (event) {
    touch.x = ( event.clientX / window.innerWidth ) * 2 - 1;
    touch.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
    points.geometry.computeBoundingSphere();
    camera.updateMatrixWorld();
    var vector = new THREE.Vector3(touch.x, touch.y, 0.5 ).unproject(camera);
    raycaster.set(camera.position, vector.sub(camera.position ).normalize());

    raycaster.setFromCamera( touch, camera );

    intersects = raycaster.intersectObject(points);
    if ( intersects.length > 0 ) {
        if ( INTERSECTED != intersects[ 0 ].index ) {
            INTERSECTED = intersects[ 0 ].index;
            if (beforeIndex != INTERSECTED) {
                points.geometry.attributes.pop.array[ beforeIndex ] = 0.0;
            }
            points.geometry.attributes.pop.array[ INTERSECTED ] = 1.0;

            beforeIndex = INTERSECTED;

        }
    }

    points.geometry.attributes.size.needsUpdate = true;
    points.geometry.attributes.pop.needsUpdate = true;
}

function createGrid () {
    var helper = new THREE.GridHelper( 100, 20, 0x303030, 0x303030 );
    scene.add( helper );
}
 function render () {

    renderer.render(scene, camera);

    requestAnimationFrame(render);
}

init();

* {
      margin: 0;
      padding: 0;
  }
  html, body {
      width: 100%;
      height: 100%;
      background: #000;
  }
  canvas {
      display: block;
  }

`


问:
Tkinter Scrollbar
If I call text_area.pack() before scrollbar.pack() (i.e switch them), the scrollbar doesn't show. Why is that? If I am going to create a larger program, I would have absolutely no chance to find out where the problem is.

```<code>from tkinter import *
import tkinter.filedialog

root = Tk()
root.geometry("200x100")
frame = Frame(root,width=150, height=90)
frame.pack()
scrollbar = Scrollbar(frame)
text_area = Text(frame, width=200, height=50,yscrollcommand=scrollbar.set)
scrollbar.config(command=text_area.yview)
scrollbar.pack(side="right", fill="y")
text_area.pack()
root.mainloop()
</code>```

答:
The other 2 answers are really good - I thought I would add an example. Personally, I don't like to use .pack - I like to place things instead like this: self.set_label_logpage.place(x=175, y=100)

Example code:

```<code>faultlogframe_logs = tk.Label(self, textvariable=logging_screen_label, font=Roboto_Normal_Font,
                                   height=180, width=400, background='white', foreground='black')

faultlogframe_logs.place(x=605, y=600)

self.scrollbar = Scrollbar(self, orient=VERTICAL, elementborderwidth=4, width=32)
self.scrollbar.pack(pady=60,padx=0, ipady=4, ipadx=4, side=RIGHT, fill=Y)
self.scrollbar_y = Scrollbar(self, orient=HORIZONTAL, width=12, takefocus=1)
self.scrollbar_y.pack(expand=TRUE, ipady=9, ipadx=9, padx=0, pady=0, side=BOTTOM, fill=X, anchor=S)

self.set_label_logpage = tk.Listbox(self, yscrollcommand=self.scrollbar.set, xscrollcommand=self.scrollbar_y.set)
self.set_label_logpage.config(font=Roboto_Normal_Font, background='white', foreground='black', height=16, width=55) #textvariable=self.label_to_display_log
self.set_label_logpage.place(x=175, y=100)

self.scrollbar_y.config(command=self.set_label_logpage.xview)
self.scrollbar.config(command=self.set_label_logpage.yview)
</code>```

Title: Tkinter Scrollbar

Body:
If I call text_area.pack() before scrollbar.pack() (i.e switch them), the scrollbar doesn't show. Why is that? If I am going to create a larger program, I would have absolutely no chance to find out where the problem is.

from tkinter import *
import tkinter.filedialog

root = Tk()
root.geometry("200x100")
frame = Frame(root,width=150, height=90)
frame.pack()
scrollbar = Scrollbar(frame)
text_area = Text(frame, width=200, height=50,yscrollcommand=scrollbar.set)
scrollbar.config(command=text_area.yview)
scrollbar.pack(side="right", fill="y")
text_area.pack()
root.mainloop()

Body:
The other 2 answers are really good - I thought I would add an example. Personally, I don't like to use .pack - I like to place things instead like this: self.set_label_logpage.place(x=175, y=100)

Example code:

faultlogframe_logs = tk.Label(self, textvariable=logging_screen_label, font=Roboto_Normal_Font,
                                   height=180, width=400, background='white', foreground='black')

faultlogframe_logs.place(x=605, y=600)

self.scrollbar = Scrollbar(self, orient=VERTICAL, elementborderwidth=4, width=32)
self.scrollbar.pack(pady=60,padx=0, ipady=4, ipadx=4, side=RIGHT, fill=Y)
self.scrollbar_y = Scrollbar(self, orient=HORIZONTAL, width=12, takefocus=1)
self.scrollbar_y.pack(expand=TRUE, ipady=9, ipadx=9, padx=0, pady=0, side=BOTTOM, fill=X, anchor=S)

self.set_label_logpage = tk.Listbox(self, yscrollcommand=self.scrollbar.set, xscrollcommand=self.scrollbar_y.set)
self.set_label_logpage.config(font=Roboto_Normal_Font, background='white', foreground='black', height=16, width=55) #textvariable=self.label_to_display_log
self.set_label_logpage.place(x=175, y=100)

self.scrollbar_y.config(command=self.set_label_logpage.xview)
self.scrollbar.config(command=self.set_label_logpage.yview)


问:
angular2 navigate to external URL(not a route url)
I am trying to find a way that I will able to navigate from my Angular2 application to some external URL.

route.navigate\route.navigateByUrl and location.go(common lib) - are set the url in the browser but nothing happened and no navigation occurred.

I dont want to use window.location solution.

also, I was able to achieve this goal by using location.href(lib.es6) but i was not able to mock this solution.

Is there any way that i can navigate to external URL and create unit test for this functionality?
Thanks

答:
I investigated the above issue and found the right way to fix it.
Using location.go(common lib) method can be used only for internal routing navigation and it will not work if we want to redirect to external URL( non Angular route link).

There is no way to mock native DOM elements\attributes ( unlike functions ) like :     window.location OR location.href(lib.es6).

My solution is to configure Location service that has few methods like: go, path and home. Each method should use the lib.es6 location to invoke the required methods.
For example:
LocationService.go(url) will invoke: location.href = url

Note: This service will be used in all places that need external URL redirections.
Mocking location service on .spec files will be handled by:

Declare Location Service:

```<code>const locationSpy: LocationService = new LocationService();
</code>```

Inject Mocked service as a provider:

In the TestBed.configureTestingModule add:

```<code>providers: [
    {provide: LocationService, useValue: locationSpy}
  ]
</code>```

Defined SpyOn on the mocked method that we using:

```<code>spyOn(locationSpy, 'go');
</code>```

Test external redirection call:

```<code>expect(locationSpy.go).toHaveBeenCalledWith('expected URL');
</code>```

Thanks
Eran

Body:
I investigated the above issue and found the right way to fix it.
Using location.go(common lib) method can be used only for internal routing navigation and it will not work if we want to redirect to external URL( non Angular route link).

There is no way to mock native DOM elements\attributes ( unlike functions ) like :     window.location OR location.href(lib.es6).

My solution is to configure Location service that has few methods like: go, path and home. Each method should use the lib.es6 location to invoke the required methods.
For example:
LocationService.go(url) will invoke: location.href = url

Note: This service will be used in all places that need external URL redirections.
Mocking location service on .spec files will be handled by:

Declare Location Service:

const locationSpy: LocationService = new LocationService();

Inject Mocked service as a provider:

In the TestBed.configureTestingModule add:

providers: [
    {provide: LocationService, useValue: locationSpy}
  ]

Defined SpyOn on the mocked method that we using:

spyOn(locationSpy, 'go');

Test external redirection call:

expect(locationSpy.go).toHaveBeenCalledWith('expected URL');

Thanks
Eran


问:
Get state of checkboxes in listctrl
I am trying to figure out how to get the state of each checkbox within an ultimatelistctrl. I also need to be able to check or un-check all boxes.

This is my second attempt at this project, the first didn't use any form of listctrl and, although functional, it is quite ugly. I tried to use the same binding techniques on the new version, but they don't seem to apply here.
Any help appreciated, thanks.

Rightly or wrongly, as this is a new version, I have started a new thread. Here is the previous one:
Previous question/answer

```<code>import sys
import wx
import wx.lib.agw.ultimatelistctrl as ULC

class MyFrame(wx.Frame):

    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "Checkbox grid based on UltimateListCtrl Demo", size=(600,300))
        agwStyle = (ULC.ULC_HAS_VARIABLE_ROW_HEIGHT | wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL)
        self.mylist = mylist = ULC.UltimateListCtrl(self, wx.ID_ANY, agwStyle=agwStyle)

        mylist.InsertColumn(0,"", width=100)

        for col in range(1,25):
            col_num=str(col-1)
            if col==0:col_num=""
            mylist.InsertColumn(col,col_num, width=20)

        self.checkboxes = {}
        self.boxes=[]

        for day in range(7):
            days=["Monday", "Sunday", "Saturday", "Friday", "Thursday", "Wednesday", "Tuesday"]
            index = mylist.InsertStringItem(1, "" + days[day])
            mylist.SetStringItem(index, 1, "")

        for boxes in range(1,25):
            for index in range(7):
                mylist.SetStringItem(index, boxes, "")
                checkBox = wx.CheckBox(mylist, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, 0)
                self.checkboxes[checkBox.GetId()] = index
                mylist.SetItemWindow(index, boxes, checkBox)
                self.boxes.append(self.checkboxes)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(mylist, 1, wx.EXPAND)
        self.SetSizer(sizer)

app = wx.App()
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()
</code>```

答:
You were adding the dict item not the CheckBox and your days were messed up.

```<code>import sys
import wx
import wx.lib.agw.ultimatelistctrl as ULC

class MyFrame(wx.Frame):

    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "Checkbox grid based on UltimateListCtrl Demo", size=(600,300))
        agwStyle = (ULC.ULC_HAS_VARIABLE_ROW_HEIGHT | wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL)
        self.mylist = mylist = ULC.UltimateListCtrl(self, wx.ID_ANY, agwStyle=agwStyle)

        mylist.InsertColumn(0,"", width=100)

        for col in range(1,25):
            col_num=str(col-1)
            if col==0:col_num=""
            mylist.InsertColumn(col,col_num, width=20)

        self.checkboxes = {}
        self.boxes=[]

        for day in range(7):
#            days=["Monday", "Sunday", "Saturday", "Friday", "Thursday", "Wednesday", "Tuesday"]
            days=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
            mylist.InsertStringItem(day, str(days[day]))
            #index = mylist.InsertStringItem(1, "" + days[day])
            #mylist.SetStringItem(index, 1, "")

        for boxes in range(1,25):
            for index in range(7):
                day = days[index]
                hour = boxes-1
                name_of_checkbox = "{day}_{hour}".format(day=day, hour=hour)
                mylist.SetStringItem(index, boxes, "")
                self.checkBox = wx.CheckBox(mylist, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, 0,name=name_of_checkbox)
                #self.checkBox.SetValue(True) #Use this to check all boxes
                self.checkboxes[self.checkBox.GetId()] = index
                mylist.SetItemWindow(index, boxes, self.checkBox)
                self.boxes.append(self.checkBox)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(mylist, 1, wx.EXPAND)
        button = wx.Button(self,-1,"Retrieve Data")
        sizer.Add(button)
        self.Bind(wx.EVT_CHECKBOX, self.OnChecked)
        self.Bind(wx.EVT_BUTTON, self.OnGetData)
        self.SetSizer(sizer)

    def OnChecked(self,event):
        clicked = event.GetEventObject()
        print (clicked.GetName())
        print (event.IsChecked())

    def OnGetData(self,event):
        day_dict = {}
        day_list = []
        for i in self.boxes:
            if i.IsChecked():
                n = i.GetName()
                day_dict[n]="Checked"
                day_list.append((n,"Checked"))
        print (day_dict)
        print (day_list)

app = wx.App()
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()
</code>```

Output:

```<code>Monday_0
True
Tuesday_1
True
Wednesday_2
True
Thursday_3
True
Friday_4
True
Saturday_5
True
Sunday_6
True
Saturday_7
True
Friday_8
True
Thursday_9
True
Wednesday_10
True
Tuesday_12
True
Tuesday_11
True
Tuesday_12
False
Monday_12
True
{'Thursday_3': 'Checked', 'Tuesday_1': 'Checked', 'Saturday_7': 'Checked', 'Monday_12': 'Checked', 'Friday_8': 'Checked', 'Thursday_9': 'Checked', 'Wednesday_10': 'Checked', 'Saturday_5': 'Checked', 'Tuesday_11': 'Checked', 'Friday_4': 'Checked', 'Wednesday_2': 'Checked', 'Sunday_6': 'Checked', 'Monday_0': 'Checked'}

[('Monday_0', 'Checked'), ('Tuesday_1', 'Checked'), ('Wednesday_2', 'Checked'), ('Thursday_3', 'Checked'), ('Friday_4', 'Checked'), ('Saturday_5', 'Checked'), ('Sunday_6', 'Checked'), ('Saturday_7', 'Checked'), ('Friday_8', 'Checked'), ('Thursday_9', 'Checked'), ('Wednesday_10', 'Checked'), ('Tuesday_11', 'Checked'), ('Monday_12', 'Checked')]
</code>```

Title: Get state of checkboxes in listctrl

Body:
I am trying to figure out how to get the state of each checkbox within an ultimatelistctrl. I also need to be able to check or un-check all boxes.

This is my second attempt at this project, the first didn't use any form of listctrl and, although functional, it is quite ugly. I tried to use the same binding techniques on the new version, but they don't seem to apply here.
Any help appreciated, thanks.

Rightly or wrongly, as this is a new version, I have started a new thread. Here is the previous one:
Previous question/answer

import sys
import wx
import wx.lib.agw.ultimatelistctrl as ULC

class MyFrame(wx.Frame):

    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "Checkbox grid based on UltimateListCtrl Demo", size=(600,300))
        agwStyle = (ULC.ULC_HAS_VARIABLE_ROW_HEIGHT | wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL)
        self.mylist = mylist = ULC.UltimateListCtrl(self, wx.ID_ANY, agwStyle=agwStyle)

        mylist.InsertColumn(0,"", width=100)

        for col in range(1,25):
            col_num=str(col-1)
            if col==0:col_num=""
            mylist.InsertColumn(col,col_num, width=20)

        self.checkboxes = {}
        self.boxes=[]

        for day in range(7):
            days=["Monday", "Sunday", "Saturday", "Friday", "Thursday", "Wednesday", "Tuesday"]
            index = mylist.InsertStringItem(1, "" + days[day])
            mylist.SetStringItem(index, 1, "")

        for boxes in range(1,25):
            for index in range(7):
                mylist.SetStringItem(index, boxes, "")
                checkBox = wx.CheckBox(mylist, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, 0)
                self.checkboxes[checkBox.GetId()] = index
                mylist.SetItemWindow(index, boxes, checkBox)
                self.boxes.append(self.checkboxes)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(mylist, 1, wx.EXPAND)
        self.SetSizer(sizer)

app = wx.App()
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()

Body:
You were adding the dict item not the CheckBox and your days were messed up.

import sys
import wx
import wx.lib.agw.ultimatelistctrl as ULC

class MyFrame(wx.Frame):

    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "Checkbox grid based on UltimateListCtrl Demo", size=(600,300))
        agwStyle = (ULC.ULC_HAS_VARIABLE_ROW_HEIGHT | wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL)
        self.mylist = mylist = ULC.UltimateListCtrl(self, wx.ID_ANY, agwStyle=agwStyle)

        mylist.InsertColumn(0,"", width=100)

        for col in range(1,25):
            col_num=str(col-1)
            if col==0:col_num=""
            mylist.InsertColumn(col,col_num, width=20)

        self.checkboxes = {}
        self.boxes=[]

        for day in range(7):
#            days=["Monday", "Sunday", "Saturday", "Friday", "Thursday", "Wednesday", "Tuesday"]
            days=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
            mylist.InsertStringItem(day, str(days[day]))
            #index = mylist.InsertStringItem(1, "" + days[day])
            #mylist.SetStringItem(index, 1, "")

        for boxes in range(1,25):
            for index in range(7):
                day = days[index]
                hour = boxes-1
                name_of_checkbox = "{day}_{hour}".format(day=day, hour=hour)
                mylist.SetStringItem(index, boxes, "")
                self.checkBox = wx.CheckBox(mylist, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, 0,name=name_of_checkbox)
                #self.checkBox.SetValue(True) #Use this to check all boxes
                self.checkboxes[self.checkBox.GetId()] = index
                mylist.SetItemWindow(index, boxes, self.checkBox)
                self.boxes.append(self.checkBox)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(mylist, 1, wx.EXPAND)
        button = wx.Button(self,-1,"Retrieve Data")
        sizer.Add(button)
        self.Bind(wx.EVT_CHECKBOX, self.OnChecked)
        self.Bind(wx.EVT_BUTTON, self.OnGetData)
        self.SetSizer(sizer)

    def OnChecked(self,event):
        clicked = event.GetEventObject()
        print (clicked.GetName())
        print (event.IsChecked())

    def OnGetData(self,event):
        day_dict = {}
        day_list = []
        for i in self.boxes:
            if i.IsChecked():
                n = i.GetName()
                day_dict[n]="Checked"
                day_list.append((n,"Checked"))
        print (day_dict)
        print (day_list)

app = wx.App()
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()

Output:

Monday_0
True
Tuesday_1
True
Wednesday_2
True
Thursday_3
True
Friday_4
True
Saturday_5
True
Sunday_6
True
Saturday_7
True
Friday_8
True
Thursday_9
True
Wednesday_10
True
Tuesday_12
True
Tuesday_11
True
Tuesday_12
False
Monday_12
True
{'Thursday_3': 'Checked', 'Tuesday_1': 'Checked', 'Saturday_7': 'Checked', 'Monday_12': 'Checked', 'Friday_8': 'Checked', 'Thursday_9': 'Checked', 'Wednesday_10': 'Checked', 'Saturday_5': 'Checked', 'Tuesday_11': 'Checked', 'Friday_4': 'Checked', 'Wednesday_2': 'Checked', 'Sunday_6': 'Checked', 'Monday_0': 'Checked'}

[('Monday_0', 'Checked'), ('Tuesday_1', 'Checked'), ('Wednesday_2', 'Checked'), ('Thursday_3', 'Checked'), ('Friday_4', 'Checked'), ('Saturday_5', 'Checked'), ('Sunday_6', 'Checked'), ('Saturday_7', 'Checked'), ('Friday_8', 'Checked'), ('Thursday_9', 'Checked'), ('Wednesday_10', 'Checked'), ('Tuesday_11', 'Checked'), ('Monday_12', 'Checked')]


问:
Align content in the middle of div
I'd like to align the content of my second column in the middle of the div. I did try in a lot of different ways but so far I haven't found how.

I'm using Bootstrap 4.

Could you tell me how to do it ?

```<code><div class="card">
   <div class="card-body">
      <div class="row">
         <div class="col-md-1">
            <img class="rounded-circle img-thumbnail d-inline"
                 src="..."
                 height="65px"
                 width="65px"
                 alt="User image">
         </div>
         <div class="col-md-11">
            <p class="d-inline">...</p>
            <button class="close" type="button"><span class="fa fa-times" aria-hidden="true"></span></button>
         </div>
      </div>
   </div>
</div>
</code>```

I'm sure I miss something very simple but don't know what.

JSFiddle exemple

Thanks for your help :)

答:
Add this css to vertically and horizontally center

```<code>button.close {
    padding: 0;
    background: 0 0;
    border: 0;
    -webkit-appearance: none;
    line-height: 65px;
    text-align: center;
}
.d-inline {
    display: inline!important;
    line-height: 65px;
    text-align: center;
}
</code>```

and text-center class to col-md-11

Title: Align content in the middle of div

Body:
I'd like to align the content of my second column in the middle of the div. I did try in a lot of different ways but so far I haven't found how.

I'm using Bootstrap 4.

Could you tell me how to do it ?

...

            <button class="close" type="button"></button>

I'm sure I miss something very simple but don't know what.

JSFiddle exemple

Thanks for your help :)

Body:
Add this css to vertically and horizontally center

button.close {
    padding: 0;
    background: 0 0;
    border: 0;
    -webkit-appearance: none;
    line-height: 65px;
    text-align: center;
}
.d-inline {
    display: inline!important;
    line-height: 65px;
    text-align: center;
}

and text-center class to col-md-11 <div class="col-md-11 text-center">


问:
Visual issue with css3 animation and jquery (hover flip card)
Read me: --> Im having troubles when I hover the flip card, if you move the cursor while hovering inside the div is triggering continuously and it makes an annoying effect, so here is what I need:

1) I want to hover the flip card and dont trigger animation again even you move the cursor inside while hovering.

2) I also need center p tag vertically in the flip card, margin-top is working and margin:auto is not working, I put the 2 examples in the snippet, check next classes:

```<code>.card .front p {
    margin-top: 100px;
}
.card .back p {
    margin: auto;
}
</code>```

So why is not working margin:auto? I wont use margin-top, need the content at the center. Here is the working snippet code:

Updated question:
  I also need achieve the next: one time you hover the flip card the animation must be completed, even you hover out the div, and then flip to the original position again, I tried next but it doesnt work:

```<code>$(".container").hover(function(){
            $(this).find(".card").toggleClass('flipped')
        }, function(){
            setTimeout(function(){
                $(this).find(".card").toggleClass('flipped')
            }, 1000);
    });
</code>```

$(document).ready(function () {
    $(".card").hover(function(){
            $(this).toggleClass('flipped')
        }, function(){
            $(this).toggleClass('flipped')
    });
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
    width: 200px;
    height: 260px;
    position: relative;
    margin: 0 auto 40px;
    -webkit-perspective: 800px;
    -moz-perspective: 800px;
    -o-perspective: 800px;
    perspective: 800px;
    display: inline-block;
}
#main{
    border: 1px solid black;
}
button{
    width: 30%;
    height: 10%;
    margin-top: 100px;
    cursor: default;
}

.card {
    width: 100%;
    height: 100%;
    position: absolute;
    -webkit-transition: -webkit-transform 1s;
    -moz-transition: -moz-transform 1s;
    -o-transition: -o-transform 1s;
    transition: transform 1s;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -o-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-transform-origin: right center;
    -moz-transform-origin: right center;
    -o-transform-origin: right center;
    transform-origin: right center;
}

.card.flipped {
    -webkit-transform: translateX( -100%) rotateY( -180deg);
    -moz-transform: translateX( -100%) rotateY( -180deg);
    -o-transform: translateX( -100%) rotateY( -180deg);
    transform: translateX( -100%) rotateY( -180deg);
}

.card div {
    height: 100%;
    width: 100%;
    color: white;
    text-align: center;
    font-weight: bold;
    position: absolute;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -o-backface-visibility: hidden;
    backface-visibility: hidden;
    cursor:pointer;
}

.card .front {
    background: red;
}
.card .front p {
    margin-top: 100px;
}
.card .back p {
    margin: auto;
}

.card .back {
    background: blue;
    -webkit-transform: rotateY( 180deg);
    -moz-transform: rotateY( 180deg);
    -o-transform: rotateY( 180deg);
    transform: rotateY( 180deg);
}</code>```

Test

MyBack

```

答:
The problem comes from the fact that because you are transforming the element that has got the hover, the pointer may get out of the box, causing an unwanted change of state from hover to none and back again.

You could catch the hover event on the main div. To align the elements, the simplest way is to use CSS Flexbox. margin: auto will not work since it sets margin-top and margin-bottom to 0 by default.

Here are the changes I've made :

```<code>$(document).ready(function() {
  $(".container").hover(function() {
    $(".card").toggleClass('flipped')
  }, function() {
    $(".card").toggleClass('flipped')
  });
})

.card .back {
  /*no changes*/
  display: flex;
  justify-content: center;
  align-items: center;
}

.card .front {
  /*no changes*/
  display: flex;
  justify-content: center;
  align-items: center;
}
</code>```

And a working example :

$(document).ready(function() {
  $(".container").hover(function() {
    $(".card").toggleClass('flipped')
  }, function() {
    $(".card").toggleClass('flipped')
  });
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>h1 {
  text-align: center;
}

.container {
  width: 200px;
  height: 260px;
  position: relative;
  margin: 0 auto 40px;
  perspective: 800px;
  display: inline-block;
}

#main {
  border: 1px solid black;
}

button {
  width: 30%;
  height: 10%;
  margin-top: 100px;
  cursor: default;
}

.card {
  width: 100%;
  height: 100%;
  position: absolute;
  transition: transform 1s;
  transform-style: preserve-3d;
  transform-origin: right center;
}

.card.flipped {
  transform: translateX( -100%) rotateY( -180deg);
}

.card div {
  height: 100%;
  width: 100%;
  color: white;
  text-align: center;
  font-weight: bold;
  position: absolute;
  backface-visibility: hidden;
  cursor: pointer;
}

.card .front {
  background: red;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card .back p {
  margin: auto;
}

.card .back {
  background: blue;
  transform: rotateY( 180deg);
  display: flex;
  justify-content: center;
  align-items: center;
}</code>```

Test

MyBack

```

How about it ?

Body:
Read me: --> Im having troubles when I hover the flip card, if you move the cursor while hovering inside the div is triggering continuously and it makes an annoying effect, so here is what I need:

1) I want to hover the flip card and dont trigger animation again even you move the cursor inside while hovering.

2) I also need center p tag vertically in the flip card, margin-top is working and margin:auto is not working, I put the 2 examples in the snippet, check next classes:

.card .front p {
    margin-top: 100px;
}
.card .back p {
    margin: auto;
}

So why is not working margin:auto? I wont use margin-top, need the content at the center. Here is the working snippet code:

Updated question:
  I also need achieve the next: one time you hover the flip card the animation must be completed, even you hover out the div, and then flip to the original position again, I tried next but it doesnt work:

$(".container").hover(function(){
            $(this).find(".card").toggleClass('flipped')
        }, function(){
            setTimeout(function(){
                $(this).find(".card").toggleClass('flipped')
            }, 1000);
    });

$(document).ready(function () {
    $(".card").hover(function(){
            $(this).toggleClass('flipped')
        }, function(){
            $(this).toggleClass('flipped')
    });
})

.container {
    width: 200px;
    height: 260px;
    position: relative;
    margin: 0 auto 40px;
    -webkit-perspective: 800px;
    -moz-perspective: 800px;
    -o-perspective: 800px;
    perspective: 800px;
    display: inline-block;
}
#main{
    border: 1px solid black;
}
button{
    width: 30%;
    height: 10%;
    margin-top: 100px;
    cursor: default;
}

.card {
    width: 100%;
    height: 100%;
    position: absolute;
    -webkit-transition: -webkit-transform 1s;
    -moz-transition: -moz-transform 1s;
    -o-transition: -o-transform 1s;
    transition: transform 1s;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -o-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-transform-origin: right center;
    -moz-transform-origin: right center;
    -o-transform-origin: right center;
    transform-origin: right center;
}

.card.flipped {
    -webkit-transform: translateX( -100%) rotateY( -180deg);
    -moz-transform: translateX( -100%) rotateY( -180deg);
    -o-transform: translateX( -100%) rotateY( -180deg);
    transform: translateX( -100%) rotateY( -180deg);
}

.card div {
    height: 100%;
    width: 100%;
    color: white;
    text-align: center;
    font-weight: bold;
    position: absolute;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -o-backface-visibility: hidden;
    backface-visibility: hidden;
    cursor:pointer;
}

.card .front {
    background: red;
}
.card .front p {
    margin-top: 100px;
}
.card .back p {
    margin: auto;
}

.card .back {
    background: blue;
    -webkit-transform: rotateY( 180deg);
    -moz-transform: rotateY( 180deg);
    -o-transform: rotateY( 180deg);
    transform: rotateY( 180deg);
}

Test

MyBack

Body:
The problem comes from the fact that because you are transforming the element that has got the hover, the pointer may get out of the box, causing an unwanted change of state from hover to none and back again.

You could catch the hover event on the main div. To align the elements, the simplest way is to use CSS Flexbox. margin: auto will not work since it sets margin-top and margin-bottom to 0 by default.

Here are the changes I've made :

$(document).ready(function() {
  $(".container").hover(function() {
    $(".card").toggleClass('flipped')
  }, function() {
    $(".card").toggleClass('flipped')
  });
})

.card .back {
  /*no changes*/
  display: flex;
  justify-content: center;
  align-items: center;
}

.card .front {
  /*no changes*/
  display: flex;
  justify-content: center;
  align-items: center;
}

And a working example :

$(document).ready(function() {
  $(".container").hover(function() {
    $(".card").toggleClass('flipped')
  }, function() {
    $(".card").toggleClass('flipped')
  });
})

h1 {
  text-align: center;
}

.container {
  width: 200px;
  height: 260px;
  position: relative;
  margin: 0 auto 40px;
  perspective: 800px;
  display: inline-block;
}

#main {
  border: 1px solid black;
}

button {
  width: 30%;
  height: 10%;
  margin-top: 100px;
  cursor: default;
}

.card {
  width: 100%;
  height: 100%;
  position: absolute;
  transition: transform 1s;
  transform-style: preserve-3d;
  transform-origin: right center;
}

.card.flipped {
  transform: translateX( -100%) rotateY( -180deg);
}

.card div {
  height: 100%;
  width: 100%;
  color: white;
  text-align: center;
  font-weight: bold;
  position: absolute;
  backface-visibility: hidden;
  cursor: pointer;
}

.card .front {
  background: red;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card .back p {
  margin: auto;
}

.card .back {
  background: blue;
  transform: rotateY( 180deg);
  display: flex;
  justify-content: center;
  align-items: center;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container-fluid">
  <div id="main"><br>
    <section class="container">
      <div class="card">
        <div class="front">
          <p>Test</p>
        </div>
        <div class="back">
          <p>MyBack</p>
        </div>
      </div>
    </section>
  </div>
</div>

How about it ?

ContentLicense: CC BY-SA 4.0


问:
Crop saved Image using com.android.camera.action.CROP on android
I have reads many question about this, but I still failed using this code... maybe anyone can corect my code... I want to crop an image from file that i know the location using com.android.camera.action.CROP like this...

```<code>    mImageCaptureUri = Uri.fromFile(f);
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setType("image/*");

    intent.setData(mImageCaptureUri);
    intent.putExtra("crop", true);
    intent.putExtra("outputX", 200);
    intent.putExtra("outputY", 200);
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("scale", true);
    intent.putExtra("return-data", true);

    Bundle extras = intent.getExtras();

    if (extras != null) {
        Bitmap photo = extras.getParcelable("intent");

        tampilan.setImageBitmap(photo);
    }

    File f = new File(mImageCaptureUri.getPath());

    if (f.exists()) f.delete();
</code>```

But when i run the code, nothing hapend... T.T
can anyone help me??

答:
```<code>    try {
        Intent intent = new Intent("com.android.camera.action.CROP");
        intent.setDataAndType(mPhotoUri, "image/*");
        intent.putExtra("crop", "true");
        Integer altura = documento.getAltura();
        Integer largura = documento.getLargura();
        if (altura != null && largura != null) {
            intent.putExtra("aspectY", altura);
            intent.putExtra("aspectX", largura);
        }
        File file = imagemProcessor.getNewFile();
        mCropUri = Uri.fromFile(file);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, mCropUri);
        intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
        startActivityForResult(intent, REQUEST_IMAGE_CROP);
    } catch (ActivityNotFoundException e) {
        Context context = getBaseContext();
        Toast toast = Toast.makeText(context, "Your device doesn't support the crop action!", Toast.LENGTH_SHORT);
        toast.show();
    } catch (IOException e) {
        Context context = getBaseContext();
        Toast toast = Toast.makeText(context, "Fail to create file!", Toast.LENGTH_SHORT);
        toast.show();
    }
</code>```

Body:
I have reads many question about this, but I still failed using this code... maybe anyone can corect my code... I want to crop an image from file that i know the location using com.android.camera.action.CROP like this...

    mImageCaptureUri = Uri.fromFile(f);
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setType("image/*");

    intent.setData(mImageCaptureUri);
    intent.putExtra("crop", true);
    intent.putExtra("outputX", 200);
    intent.putExtra("outputY", 200);
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("scale", true);
    intent.putExtra("return-data", true);

    Bundle extras = intent.getExtras();

    if (extras != null) {
        Bitmap photo = extras.getParcelable("intent");

        tampilan.setImageBitmap(photo);
    }

    File f = new File(mImageCaptureUri.getPath());

    if (f.exists()) f.delete();

But when i run the code, nothing hapend... T.T
can anyone help me??


问:
How to remove the single quotation mark from a list in Python
I am trying to remove the single quotation marks from this list:

```<code>list = ['amazed, 10']
</code>```

and convert it to

```<code>list = ['amazed', 10]
</code>```

I used list= [x.strip('') for x in list] but it does not work.

Is there a workaround?

Thanks in advance!

答:
Try:</p>

```<code>lst = ['amazed, 10']

lst = [int(i) if i.isdigit() else i for i in lst[0].replace(',', '').split()]
</code>```

Body:
I am trying to remove the single quotation marks from this list:

list = ['amazed, 10']

and convert it to

list = ['amazed', 10]

I used list= [x.strip('') for x in list] but it does not work.

Is there a workaround?

Thanks in advance!

Body:
Try:

lst = ['amazed, 10']

lst = [int(i) if i.isdigit() else i for i in lst[0].replace(',', '').split()]


问:
How to format date in React material-ui date-picker?
I'm implementing redux-form with a material-ui date-picker field. Date is perfectly set in field but when I try to send it to the back-end API format of the date is:

BeginDate_1: Tue Nov 14 2017 15:03:43 GMT+0530 (IST)

I'm trying to change this format to 'YYYY-mm-dd' format before sending it to the the back-end API.

I tried momentjs for formatting, but I couldn't get the result I wanted.

Here's what I've tried:

Home.js

```<code>import React, {Component} from 'react';
import {Field, reduxForm} from 'redux-form';
import DatePicker from 'material-ui/DatePicker';
import {connect} from 'react-redux';
import * as moment  from 'moment';

class Home extends Component {

renderCalendarField= ({
                          input,
                          label,
                          meta: {touched, error},
                          children,
                          ...custom
                      }) => (
    <DatePicker
        floatingLabelText={label}
        errorText={touched && error}
        {...input}
        value = {input.value !== ''? new Date(input.value) : null}
        onChange={(event, value) => input.onChange(value)}
        children={children}
        {...custom}
        formatDate={(date) => moment(date).format('YYYY-MM-DD')}

    />

)

render() {

    const startDate = new Date();

    const {handleSubmit} = this.props;

    return (

        <form onSubmit={handleSubmit(this.onSubmit.bind(this))}>

            <div>
                <Field name="BeginDate_1" component={this.renderCalendarField} label="DEPARTURE" minDate={startDate} />
            </div>

            <div>
                <button type="submit">
                    Submit
                </button>
            </div>

        </form>

    );

}

}

const LogInForm = reduxForm({
form: 'MaterialUiForm', // a unique identifier for this form
validate
})(Home);

export default connect(mapStateTOProps, {getCity})(LogInForm);
</code>```

The console output is still:

BeginDate_1:Tue Nov 14 2017 15:03:43 GMT+0530 (IST)

How can I format this date in YYYY-mm-dd format?

答:
formatDate prop on the DatePicker is used to format the Display Date and not the actual value. What you need to do is, format the the value in the onSubmit function using moment

```<code>onSubmit (values) {

   const beginDate = moment(values.BeginDate_1).format('YYYY-MM-DD')
   console.log(beginDate);
   //other things
}
</code>```

According to the material-ui/DatePicker docs:

formatDate: function

This function is called to format the date displayed in the input
  field, and should return a string. By default if no locale and
  DateTimeFormat is provided date objects are formatted to ISO 8601 YYYY-MM-DD.

Signature:

```<code>function(date: object) => any
date: Date object to be formatted.
returns (any): The formatted date.
</code>```

Body:
I'm implementing redux-form with a material-ui date-picker field. Date is perfectly set in field but when I try to send it to the back-end API format of the date is:

BeginDate_1: Tue Nov 14 2017 15:03:43 GMT+0530 (IST)

I'm trying to change this format to 'YYYY-mm-dd' format before sending it to the the back-end API.

I tried momentjs for formatting, but I couldn't get the result I wanted.

Here's what I've tried:

Home.js

import React, {Component} from 'react';
import {Field, reduxForm} from 'redux-form';
import DatePicker from 'material-ui/DatePicker';
import {connect} from 'react-redux';
import * as moment  from 'moment';

class Home extends Component {

renderCalendarField= ({
                          input,
                          label,
                          meta: {touched, error},
                          children,
                          ...custom
                      }) => (
    <DatePicker
        floatingLabelText={label}
        errorText={touched && error}
        {...input}
        value = {input.value !== ''? new Date(input.value) : null}
        onChange={(event, value) => input.onChange(value)}
        children={children}
        {...custom}
        formatDate={(date) => moment(date).format('YYYY-MM-DD')}

    />

)

render() {

    const startDate = new Date();

    const {handleSubmit} = this.props;

    return (

        <form onSubmit={handleSubmit(this.onSubmit.bind(this))}>

                <Field name="BeginDate_1" component={this.renderCalendarField} label="DEPARTURE" minDate={startDate} />

                <button type="submit">
                    Submit
                </button>

        </form>

    );

}

}

const LogInForm = reduxForm({
form: 'MaterialUiForm', // a unique identifier for this form
validate
})(Home);

export default connect(mapStateTOProps, {getCity})(LogInForm);

The console output is still:

BeginDate_1:Tue Nov 14 2017 15:03:43 GMT+0530 (IST)

How can I format this date in YYYY-mm-dd format?

Body:
formatDate prop on the DatePicker is used to format the Display Date and not the actual value. What you need to do is, format the the value in the onSubmit function using moment

onSubmit (values) {

   const beginDate = moment(values.BeginDate_1).format('YYYY-MM-DD')
   console.log(beginDate);
   //other things
}

According to the material-ui/DatePicker docs:

formatDate: function

This function is called to format the date displayed in the input
  field, and should return a string. By default if no locale and
  DateTimeFormat is provided date objects are formatted to ISO 8601 YYYY-MM-DD.

Signature:

function(date: object) => any
date: Date object to be formatted.
returns (any): The formatted date.


问:
Xcode 8 error: this class is not key value coding-compliant for the key enemyTitleLabel
I get the following error message when a user presses a button that uses a "Show" command to present SixthViewController:

2017-08-03 15:19:12.180963-0400 App[5298:1956556] Unknown class
  SixthViewController in Interface Builder file. 2017-08-03
  15:19:12.187793-0400 App[5298:1956556] * Terminating app due to
  uncaught exception 'NSUnknownKeyException', reason:
  '[ setValue:forUndefinedKey:]: this
  class is not key value coding-compliant for the key enemyTitleLabel.'
  * First throw call stack: (0x18a4defe0 0x188f40538 0x18a4deca8 0x18aef468c 0x190974e94 0x190b18c70 0x18a3fffac 0x190b17664
  0x190977e6c 0x1907420b0 0x1906107ac 0x1906106e0 0x190fe25b8
  0x19095d5ec 0x1909819b8 0x1909847e4 0x190701794 0x190987f30
  0x190cc86fc 0x190dd9600 0x190dd9408 0x190978a14 0x10002f10c
  0x10002f184 0x190645c54 0x190645bd4 0x190630148 0x1906454b8
  0x190644fd4 0x19064036c 0x190610f80 0x190e0aa20 0x190e0517c
  0x190e055a8 0x18a48d42c 0x18a48cd9c 0x18a48a9a8 0x18a3bada4
  0x18be25074 0x190675c9c 0x10003f708 0x1893c959c) libc++abi.dylib:
  terminating with uncaught exception of type NSException

I'm able to load SixthViewController as long as none of the UIButton or UILabels are linked to anything; but as soon as I link any of them (not just enemyTextLabel), I get the same error (obviously the key changes depending on which element I linked).

I've already tried unlinking/relinking everything, and making sure that there are no typos in the code, and no matter what, the error persists when the items are relinking.

I've looked at questions reporting the same error and the solution seems to be to double-check for accidental links/typos/mistakes in the code. I've checked over my project multiple times and can't find any of these.

How can I resolve this error?

答:
Open Xcode Select target that you run Code Open build Phase --> Compile Sources.

Add the class (viewController.m) in which "enemyTitleLabel" label is there.

.


问:
Launching Tensorboard: bad interpreter: No such file or directory
I am unable to run tensorboard, and get the message:

```<code>bad interpreter: No such file or directory
</code>```

Steps to reproduce:

Installed TF on Ubuntu, using a virtenv, and pip as per instructions install instructions

Confirmed TF was correctly installed by running the mnist example. Output was as expected

Attempted to run tensorboard using:

```<code>tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries/
</code>```

Checked that this location does contain the summary files within the "test" and "train" directories

Command and error:

```<code>(tensorflow_1_4_0) js@pchome01:~$ tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries/
bash: /home/js/tensorflow_1_4_0/bin/tensorboard: /home/js/tensorflow_1_3/bin/python3: bad interpreter: No such file or directory
</code>```

In my virtenv folder for tensorflow_1_4_0, a tensorboard script exists:

```<code>#!/home/js/tensorflow_1_3/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from tensorboard.main import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
</code>```

When I run the following from the terminal, no errors are reported:

```<code>from tensorboard.main import main
</code>```

Thank you

答:
Just spotted my silly mistake and posting the resolution in case others encounter this.

The meaning of the error message is that the interpreter of the code (in this case python3) cannot be found.
The first line of the tensorboard script:

```<code>#!/home/js/tensorflow_1_3/bin/python3
</code>```

This tells the compiler to look for python3 at this location, however this path is incorrect and the virtual environment is actually called tensorflow_1_4_0.
Therefore changing this line to the following fixed the error:

```<code>#!/home/js/tensorflow_1_4_0/bin/python3
</code>```

Body:
I am unable to run tensorboard, and get the message:

bad interpreter: No such file or directory

Steps to reproduce:

Installed TF on Ubuntu, using a virtenv, and pip as per instructions install instructions

Confirmed TF was correctly installed by running the mnist example. Output was as expected

Attempted to run tensorboard using:

tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries/

Checked that this location does contain the summary files within the "test" and "train" directories

Command and error:

(tensorflow_1_4_0) js@pchome01:~$ tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries/
bash: /home/js/tensorflow_1_4_0/bin/tensorboard: /home/js/tensorflow_1_3/bin/python3: bad interpreter: No such file or directory

In my virtenv folder for tensorflow_1_4_0, a tensorboard script exists:

#!/home/js/tensorflow_1_3/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from tensorboard.main import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

When I run the following from the terminal, no errors are reported:

from tensorboard.main import main

Thank you

Body:
Just spotted my silly mistake and posting the resolution in case others encounter this.

The meaning of the error message is that the interpreter of the code (in this case python3) cannot be found.
The first line of the tensorboard script:

#!/home/js/tensorflow_1_3/bin/python3

This tells the compiler to look for python3 at this location, however this path is incorrect and the virtual environment is actually called tensorflow_1_4_0.
Therefore changing this line to the following fixed the error:

#!/home/js/tensorflow_1_4_0/bin/python3


问:
Add dynamic values for ID, href and aria-controls using Jquery
I want to add the dynamic values for the attributes(href, id, aria-controls), so that i can toggle down the text in multiple places for a single page. Just for your reference i have added "href="#0_read_more", aria-controls="0_read_more", id="0_read_more" in three places in the provided sample code. As well i have increment the values for other two div sections like given in the sample html code. Kindly help me out on this..

Thanks in advance.

                  Read More

                  Read More

                  Read More

```

答:
```<code><!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
for(i=0;i<3;i++)
{$("#mydiv").append("<div class='image-text'><a href='#"+i+"_read_more' data-toggle='collapse' aria-expanded='false' aria-controls='"+i+"_read_more' class='collapsed'>Read More</a><div id='"+i+"_read_more' class='collapse' aria-expanded='false' style='height: 0px;'><div></div>");
}
});
</script>
</head>
<body>
<div id="mydiv"></div>
</body>
</code>```


问:
Sync 2 MySQL databases
I have 2 MySql databases and I want keep them in sync. The problem is that I dont have access to the machine that runs the "master" database, I only have rights to read.

So I created a secondary database and I want to create a cron job to sync with the master one every day at 12:00 (for example).

What is the best way to do this ?

答: The most simple, but possibly the one with the most overhead, would be simply do a mysql-dump and re-import the data into the second database.</p>

ContentLicense: CC BY-SA 2.5

Title: Sync 2 MySQL databases


问:
DocumentReference.set(Object o) changes boolean field names
When using DocumentReference.set(object), boolean fields are changed. Fields with 'is' prefix get changed to normal field value

```<code>class Invitation {
    private boolean isRequested;
    private boolean isValid;
    private boolean isAccepted;
    private String lastName,firstName;
    private long sentOn;
}
</code>```

And when I push this object to the database using set() method the boolean values are changed in this way:

答:
We experienced this issue and we solved like this.

```<code>boolean isPrimary;

public boolean getIsPrimary() {
    return this.isPrimary;
}

public void setIsPrimary(boolean isPrimary) {
    this.isPrimary = isPrimary;
}
</code>```

I know it's weird. It seems Firestore uses the 'getter' method to set object,
because I first changed the 'setter' method and nothing happened. And I changed 'getter' method and it finally worked correctly.

I hope they fix this issue. Because nobody uses the 'getter' method for boolean as 'getIsSomething' in Android.

Body:
When using DocumentReference.set(object), boolean fields are changed. Fields with 'is' prefix get changed to normal field value

class Invitation {
    private boolean isRequested;
    private boolean isValid;
    private boolean isAccepted;
    private String lastName,firstName;
    private long sentOn;
}

And when I push this object to the database using set() method the boolean values are changed in this way:

Body:
We experienced this issue and we solved like this.

boolean isPrimary;

public boolean getIsPrimary() {
    return this.isPrimary;
}

public void setIsPrimary(boolean isPrimary) {
    this.isPrimary = isPrimary;
}

I know it's weird. It seems Firestore uses the 'getter' method to set object,
because I first changed the 'setter' method and nothing happened. And I changed 'getter' method and it finally worked correctly.

I hope they fix this issue. Because nobody uses the 'getter' method for boolean as 'getIsSomething' in Android.


问:
Ehcache 3 logging with log4j in JBoss EAP 7 not working
We have below configuration,
1. Multi module web app based on JSF/Primefaces and Spring 4.2 (separate maven modules for WAR, service JAR etc.)
2. Using Log4j2 as application logging framework
3. Using Ehcache 3 with Spring Cache Abstraction annotations
4. Configured Pom.xml of service module JAR file for Ehcache 3 and java cache-api dependencies
5. Created Ehcache.xml in service module JAR
6. Configured Pom.xml of service WAR with Log4j core and slf4j-log4j12 binding dependencies
7. Configured log4j.xml with  for “org.ehcache”

Versions,
JDK 1.8
Spring 4.2
Ehcache 3.3.1
Log4j 1.2
Slf4j-log4j 1.7.7

Problem we are facing,
With all this configuration in place, when we do “run on server” to WAR file on JBoss EAP 7 configured in Eclipse Neon we can’t see Ehcache related log statements in our log file. We can see our application logs though. We tried with various logging levels starting from ALL,TRACE, DEBUG but no logs in log file. Any pointers will really be helpful, we are trying to get this resolved since last 2 days but no luck.

答:
I believe you have a mismatch in your slf4j bindings. You indicate that you are using Log4j version 2 but have placed slf4j-log4j12on the classpath. However that's the binding for log4j version 1.2.

I believe you need instead the binding for log4j 2.


问:
how to import a theme in liferay 7 workspace?
how to import a theme in liferay 7 workspace?

I added the theme under workspace/themes and I tried to deploy it but did not work. The build type of my Theme is Ant.

The following picture shows the details:

I put the Theme under *sdk\com.liferay.portal.plugins.sdk-1.0.11\themes* and I tried to test it as in Liferay 6. Import-> Liferay Projects from plugins SDK then when adding the SDK I got an error :

app.server.dir is invalid. Please reconfigure Plugins SDK setting:
  app.server.dir=path to liferay portal/tomcat-8.0.32

Then I tried to migrate the theme from the plugins sdk liferay workspace.
I puted the sdk under: liferay-workspace\plugins-sdk\sdk\com.liferay.portal.plugins.sdk-1.0.11

Then I tried this commande C:\Users\User1\workspace2\liferay-workspace>blade convert --themebuilder name_theme she does not return anything.

The structure of the original theme:

The css directory:

I fixed the problem app.server.dir is invalid. by switching the java jdk from 8 to 7 in eclipse.ini file:

```<code>-vm
D:/Program Files/Java/jdk1.7.79/bin/javaw.exe
</code>```

When I did Import-> Liferay Projects from plugins SDK and I puted the SDK path, I got this error:

No available projects can be imported.

Do I need to upgrade it?

Update:

Sorry, I checked the compatibility of Theme. The theme is already compatible with Liferay 7 and no need to upgrade it.

```<code><look-and-feel>
    <compatibility>
        <version>7.0.2+</version>
    </compatibility>
    ...
</look-and-feel>
</code>```

I am trying to import the Theme on Liferay 7.0.0 GA1.

1-  I am using jdk 1.8 for eclipse Neon.3 Release (4.6.3).

Image description:

2-  I updated sdk /build.{ username}.properties

Image description:

3- I putted the Theme under sdk\liferay-plugins-sdk-7.0\themes and I did Import-> Liferay Projects from plugins SDK and I putted the SDK path D:\FormationJEE\Liferay\Liferay7_g1\sdk\liferay-plugins-sdk-7.0. I do not find the theme. I did Refresh and it does not appear.

Image description:

I followed @OlafKock 's instructions:

I declared the compatibility with 7.0.0+ and when I did Import-> Liferay Projects from plugins SDK I did not have the right to put the path of sdk. It is set by default to this: D:\FormationJEE\Liferay\Liferay7_g1\sdk\liferay-plugins-sdk-7.0. I do not find the theme. I did Refresh and it does not appear.

Now, I can not change the path of sdk anymore. It is stuck at D:\FormationJEE\Liferay\Liferay7_g1\sdk\liferay-plugins-sdk-7.0. I can not test the theme on Liferay 7.0 GA5.

I fixed that by creating another workspace but still can not import the theme project.

4- Hello, I tried to migrate the theme from the plugins sdk to workspace using this command:

blade convert --themebuilder [THEME_PROJECT_NAME]

I typed the command and nothing happens.
I followed this link:
MIGRATING A THEME FROM THE PLUGINS SDK TO WORKSPACE

答:
Not sure if this helps, but: Try 7.0 GA5. It might have fixed an issue that you're running into. Also, it might help the mismatch of your stated version and the declared compatibility

```<code><look-and-feel>
    <compatibility>
        <version>7.0.2+</version>
    </compatibility>
    ...
</look-and-feel>
</code>```

7.0.2+ refers to "7.0 GA3 and later", but you state that you're using GA1.
Many issues have been fixed since then. Do a quick try declaring compatibility with 7.0.0+, but, by all means, use the most current version as a long term fix.

Body:
how to import a theme in liferay 7 workspace?

I added the theme under workspace/themes and I tried to deploy it but did not work. The build type of my Theme is Ant.

The following picture shows the details:

I put the Theme under *sdk\com.liferay.portal.plugins.sdk-1.0.11\themes* and I tried to test it as in Liferay 6. Import-> Liferay Projects from plugins SDK then when adding the SDK I got an error :

app.server.dir is invalid. Please reconfigure Plugins SDK setting:
  app.server.dir=path to liferay portal/tomcat-8.0.32

Then I tried to migrate the theme from the plugins sdk liferay workspace.
I puted the sdk under: liferay-workspace\plugins-sdk\sdk\com.liferay.portal.plugins.sdk-1.0.11

Then I tried this commande C:\Users\User1\workspace2\liferay-workspace>blade convert --themebuilder name_theme she does not return anything.

The structure of the original theme:

The css directory:

I fixed the problem app.server.dir is invalid. by switching the java jdk from 8 to 7 in eclipse.ini file:

-vm
D:/Program Files/Java/jdk1.7.79/bin/javaw.exe

When I did Import-> Liferay Projects from plugins SDK and I puted the SDK path, I got this error:

No available projects can be imported.

Do I need to upgrade it?

Update:

Sorry, I checked the compatibility of Theme. The theme is already compatible with Liferay 7 and no need to upgrade it.

<look-and-feel>
    <compatibility>
        <version>7.0.2+</version>
    </compatibility>
    ...
</look-and-feel>

I am trying to import the Theme on Liferay 7.0.0 GA1.

1-  I am using jdk 1.8 for eclipse Neon.3 Release (4.6.3).

Image description:

2-  I updated sdk /build.{ username}.properties

Image description:

3- I putted the Theme under sdk\liferay-plugins-sdk-7.0\themes and I did Import-> Liferay Projects from plugins SDK and I putted the SDK path D:\FormationJEE\Liferay\Liferay7_g1\sdk\liferay-plugins-sdk-7.0. I do not find the theme. I did Refresh and it does not appear.

Image description:

I followed @OlafKock 's instructions:

I declared the compatibility with 7.0.0+ and when I did Import-> Liferay Projects from plugins SDK I did not have the right to put the path of sdk. It is set by default to this: D:\FormationJEE\Liferay\Liferay7_g1\sdk\liferay-plugins-sdk-7.0. I do not find the theme. I did Refresh and it does not appear.

Now, I can not change the path of sdk anymore. It is stuck at D:\FormationJEE\Liferay\Liferay7_g1\sdk\liferay-plugins-sdk-7.0. I can not test the theme on Liferay 7.0 GA5.

I fixed that by creating another workspace but still can not import the theme project.

4- Hello, I tried to migrate the theme from the plugins sdk to workspace using this command:

blade convert --themebuilder [THEME_PROJECT_NAME]

I typed the command and nothing happens.
I followed this link:
MIGRATING A THEME FROM THE PLUGINS SDK TO WORKSPACE

Body:
Not sure if this helps, but: Try 7.0 GA5. It might have fixed an issue that you're running into. Also, it might help the mismatch of your stated version and the declared compatibility

<look-and-feel>
    <compatibility>
        <version>7.0.2+</version>
    </compatibility>
    ...
</look-and-feel>

7.0.2+ refers to "7.0 GA3 and later", but you state that you're using GA1.
Many issues have been fixed since then. Do a quick try declaring compatibility with 7.0.0+, but, by all means, use the most current version as a long term fix.


问:
How does Order by affect assignment when used along with COALESCE
I have a T-SQL variable to which I am assigning a value using SELECT operation. Since the "SELECT" query might return multiple rows therefore I am using COALESCE function which appends all the values separated by a comma. So far all good and query is behaving as intended. But when I try to order my values using order by clause only one row is appended to variable.

Why adding Order By clause in Query 2 produces so different result then Query 1?

[Results 1]:

Ball 1,Ball 2,Bat 3,Bat 1,Bat 2

[Results 2]:

Bat 1

JS Fiddle link : http://sqlfiddle.com/#!6/8dad1/15

[SQL Fiddle][1]

MS SQL Server 2014 Schema Setup:

```<code>CREATE TABLE tbl_Trans
([Id] int, [Instrument] varchar(20), [Trans_Type] int, [Quantity] int);

CREATE TABLE tbl_Trans_Type
([Id] int, [Trans_Type] varchar(20));

INSERT INTO tbl_Trans  ([Id], [Instrument], [Trans_Type], [Quantity])

VALUES
(1,'Ball 1', 121, 50),
(2,'Ball 2', 121, 20),
(3,'Bat 3', 122, 1000),
(4,'Bat 1', 124, 400),
(5,'Bat 2', 121, 300);

INSERT INTO tbl_Trans_Type  ([Id], [Trans_Type])

VALUES
(121,'Buy'),
(122,'Sell'),
(123,'ReSell'),
(124,'Rent')

**Query 1**:

DECLARE @ST VARCHAR(500) = NULL
SELECT @ST = COALESCE(@ST+ ',' , '')+Instrument
FROM tbl_Trans a
LEFT JOIN tbl_Trans_Type b on a.Trans_Type = b.Id

SELECT @ST
</code>```

[Results 1]:

```<code>| Ball 1,Ball 2,Bat 3,Bat 1,Bat 2 |
</code>```

Query 2:

```<code>DECLARE @ST2 VARCHAR(500) = NULL
SELECT  @ST2 = COALESCE(@ST2+ ',' , '')+Instrument
FROM tbl_Trans a
LEFT JOIN tbl_Trans_Type b on a.Trans_Type = b.Id
ORDER BY IIF(b.Trans_Type='Buy',1,2)

SELECT  @ST2
</code>```

[Results 2]:

```<code>| Bat 1 |
</code>```

答:
The behavior you are seeing is by design. Using assignment operations (concatenation in this scenario) in queries with ORDER BY clause has undefined behavior.

use the following query for successful conversion of rows into comma separated values with order by clause

```<code>select stuff((select ','+Instrument
FROM tbl_Trans a
  LEFT JOIN tbl_Trans_Type b on a.Trans_Type = b.Id
ORDER BY IIF(b.Trans_Type='Buy',1,2)
for xml path('')) ,1,1,'')
</code>```

Body:
I have a T-SQL variable to which I am assigning a value using SELECT operation. Since the "SELECT" query might return multiple rows therefore I am using COALESCE function which appends all the values separated by a comma. So far all good and query is behaving as intended. But when I try to order my values using order by clause only one row is appended to variable.

Why adding Order By clause in Query 2 produces so different result then Query 1?

[Results 1]:

Ball 1,Ball 2,Bat 3,Bat 1,Bat 2

[Results 2]:

Bat 1

JS Fiddle link : http://sqlfiddle.com/#!6/8dad1/15

[SQL Fiddle][1]

MS SQL Server 2014 Schema Setup:

CREATE TABLE tbl_Trans
([Id] int, [Instrument] varchar(20), [Trans_Type] int, [Quantity] int);

CREATE TABLE tbl_Trans_Type
([Id] int, [Trans_Type] varchar(20));

INSERT INTO tbl_Trans  ([Id], [Instrument], [Trans_Type], [Quantity])

VALUES
(1,'Ball 1', 121, 50),
(2,'Ball 2', 121, 20),
(3,'Bat 3', 122, 1000),
(4,'Bat 1', 124, 400),
(5,'Bat 2', 121, 300);

INSERT INTO tbl_Trans_Type  ([Id], [Trans_Type])

VALUES
(121,'Buy'),
(122,'Sell'),
(123,'ReSell'),
(124,'Rent')

**Query 1**:

DECLARE @ST VARCHAR(500) = NULL
SELECT @ST = COALESCE(@ST+ ',' , '')+Instrument
FROM tbl_Trans a
LEFT JOIN tbl_Trans_Type b on a.Trans_Type = b.Id

SELECT @ST

[Results 1]:

| Ball 1,Ball 2,Bat 3,Bat 1,Bat 2 |

Query 2:

DECLARE @ST2 VARCHAR(500) = NULL
SELECT  @ST2 = COALESCE(@ST2+ ',' , '')+Instrument
FROM tbl_Trans a
LEFT JOIN tbl_Trans_Type b on a.Trans_Type = b.Id
ORDER BY IIF(b.Trans_Type='Buy',1,2)

SELECT  @ST2

[Results 2]:

| Bat 1 |

Body:
The behavior you are seeing is by design. Using assignment operations (concatenation in this scenario) in queries with ORDER BY clause has undefined behavior.

use the following query for successful conversion of rows into comma separated values with order by clause

select stuff((select ','+Instrument
FROM tbl_Trans a
  LEFT JOIN tbl_Trans_Type b on a.Trans_Type = b.Id
ORDER BY IIF(b.Trans_Type='Buy',1,2)
for xml path('')) ,1,1,'')


问:
How to get the first child node of the root element in xml using DOM parser?
```<code><?xml version="1.0"?>
<catalog>
  <book id="bk101">
    <author>Gambardella</author>
    <title>Horrro story</title>
    <genre>Computer</genre>
    <price>44.95</price>
    <publish_date>2000-10-01</publish_date>
  </book>

  <book id="bk102">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-12-16</publish_date>
  </book>
</catalog>
</code>```

In this I used the following code to get the root element "catalog":

```<code>Node childNode = document.getFirstChild();
System.out.println("child node  "+childNode.getNodeName());
</code>```

I want to print root elements first child element (i.e. "book"). How to get the value of "book"?

答:
You can try this:

```<code>Node childNode = document.getDocumentElement().getFirstChild(); // first book element
</code>```

or

```<code>NodeList childNodes = document.getDocumentElement().getChildNodes(); // all book elements
</code>```

Body:
<?xml version="1.0"?>
<catalog>
  <book id="bk101">
    <author>Gambardella</author>
    <title>Horrro story</title>
    <genre>Computer</genre>
    <price>44.95</price>
    <publish_date>2000-10-01</publish_date>
  </book>

  <book id="bk102">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-12-16</publish_date>
  </book>
</catalog>

In this I used the following code to get the root element "catalog":

Node childNode = document.getFirstChild();
System.out.println("child node  "+childNode.getNodeName());

I want to print root elements first child element (i.e. "book"). How to get the value of "book"?

Body:
You can try this:

Node childNode = document.getDocumentElement().getFirstChild(); // first book element

or

NodeList childNodes = document.getDocumentElement().getChildNodes(); // all book elements


问:
Linking multiple model relationships with views in django
I have a project with a custom user model, users can login and create a company, this all works fine. Now I want everything else in the project linked to the company they created, ie leads for that company. THe first layer linking the user to the company works great, but now combining the third layer seems to be not working. Here is the code and then what I want it to do follows.

The link from my template

```<code><li><a href="{% url 'nodiso:leadlist' pk=company.id %}">Sales</a></li>
</code>```

The URl

```<code>url(r'^leads/(?P<pk>\d+)/$', views.LeadListView.as_view(), name='leadlist'),
</code>```

The View

```<code>class LeadListView(LoginRequiredMixin, generic.ListView):
    login_url = '/scrty/login/'
    template_name = "nodiso/leadslist.html"
    model = models.Leads
    def get_queryset(self):
        return models.Leads.objects.filter(company=self.pk)
</code>```

The Model

```<code>class Leads(models.Model):
    company = models.ForeignKey(Company)
    name = models.CharField(max_length=265)
    email = models.EmailField(max_length=265)
    tel = models.IntegerField()
    dateenq = models.DateField()
</code>```

So basically I am trying the create a list view for leads, but it should only be the leads linked to the company, I also would like to somehow display information regarding the company in the views for leads. Basically linking but also combining bot the views with each other.

Not sure if my approach is correct at all.

答:
I managed to solve the problem by storing values in a session</p>

```<code>def comp_select(request, company_id):
    comp = models.Company.objects.get(id=company_id)
    request.session['company'] = comp.name
    request.session['compid'] = company_id
    return redirect('nodisoapp:working',company_id)
</code>```

Body:
I have a project with a custom user model, users can login and create a company, this all works fine. Now I want everything else in the project linked to the company they created, ie leads for that company. THe first layer linking the user to the company works great, but now combining the third layer seems to be not working. Here is the code and then what I want it to do follows.

The link from my template

Sales

The URl

url(r'^leads/(?P<pk>\d+)/$', views.LeadListView.as_view(), name='leadlist'),

The View

class LeadListView(LoginRequiredMixin, generic.ListView):
    login_url = '/scrty/login/'
    template_name = "nodiso/leadslist.html"
    model = models.Leads
    def get_queryset(self):
        return models.Leads.objects.filter(company=self.pk)

The Model

class Leads(models.Model):
    company = models.ForeignKey(Company)
    name = models.CharField(max_length=265)
    email = models.EmailField(max_length=265)
    tel = models.IntegerField()
    dateenq = models.DateField()

So basically I am trying the create a list view for leads, but it should only be the leads linked to the company, I also would like to somehow display information regarding the company in the views for leads. Basically linking but also combining bot the views with each other.

Not sure if my approach is correct at all.

Body:
I managed to solve the problem by storing values in a session

def comp_select(request, company_id):
    comp = models.Company.objects.get(id=company_id)
    request.session['company'] = comp.name
    request.session['compid'] = company_id
    return redirect('nodisoapp:working',company_id)


问:
algolia and React - searchFunction
can anyone helps me to find a solution
I am using React and I have to use Algolia for search events but I don't know how to handle the search event Algolia fire. When the search function fire I want to add something new to the page for example! Any help will be appreciated.

Documentation

I tried

```<code>const search = instantsearch({
  appId: myAppId,
  apiKey: myAPIkey,
  indexName: 'users',
  searchFunction: () => {console.log('hi')}
}: InstantSearchOptions);
</code>```

but it doesn't work! And also I'm not sure if I imported the right module or no!

答:
I just found the solution, if anyone struggle with this problem. The solution is CONNECTORS!
https://community.algolia.com/react-instantsearch/guide/Connectors.html</p>

Title: algolia and React - searchFunction

Body:
can anyone helps me to find a solution
I am using React and I have to use Algolia for search events but I don't know how to handle the search event Algolia fire. When the search function fire I want to add something new to the page for example! Any help will be appreciated.

Documentation

I tried

const search = instantsearch({
  appId: myAppId,
  apiKey: myAPIkey,
  indexName: 'users',
  searchFunction: () => {console.log('hi')}
}: InstantSearchOptions);

but it doesn't work! And also I'm not sure if I imported the right module or no!


答:
There was a problem on server site. We have tested on other account and there was no problem. Restart service sshd and update fix problem.
In all logs that i set there was no errors :/.
Admin said that probally it was some corrupt in package and sftp stopped services at 1GB. More strange is that, if we send by filezilla there was no problem.</p>

Title: Upload big file stop at 1GB gaufrette phpseclinb

Body:
I'm trying simple copy files between server sftp using gaufrette and phpseclib.
Local adapter server no problem sends more than 1GB. If i am trying send remote always stops at 1GB logs look like

    00000fe0  00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00  ................
00000ff0  00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00  ................
00001000  00:00:00:00:00:00:00:00                          ........

<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000  00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00  ............e...
00000010  01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73  .........Success
00000020  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000  00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00  ............e...
00000010  01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73  .........Success
00000020  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000  00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00  ............e...
00000010  01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73  .........Success
00000020  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000  00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00  ............e...
00000010  01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73  .........Success
00000020  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000  00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00  ............e...
00000010  01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73  .........Success
00000020  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000  00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00  ............e...
00000010  01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73  .........Success
00000020  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000  00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00  ............e...
00000010  01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73  .........Success
00000020  00:00:00:00                                      ....

<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0009, network: 0.0008s)
00000000  00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00  ............e...
00000010  01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73  .........Success
00000020  00:00:00:00                                      ....

<- NET_SSH2_MSG_KEXINIT (since last: 0.0001, network: 0s)
00000000  d3:0d:5e:69:3d:0d:7f:e8:13:a6:fd:85:f6:05:3c:02  ..^i=...........
00000010  00:00:00:d4:63:75:72:76:65:32:35:35:31:39:2d:73  ....curve25519-s
00000020  68:61:32:35:36:40:6c:69:62:73:73:68:2e:6f:72:67  ha256@libssh.org
00000030  2c:65:63:64:68:2d:73:68:61:32:2d:6e:69:73:74:70  ,ecdh-sha2-nistp
00000040  32:35:36:2c:65:63:64:68:2d:73:68:61:32:2d:6e:69  256,ecdh-sha2-ni
00000050  73:74:70:33:38:34:2c:65:63:64:68:2d:73:68:61:32  stp384,ecdh-sha2
00000060  2d:6e:69:73:74:70:35:32:31:2c:64:69:66:66:69:65  -nistp521,diffie
00000070  2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:2d:65  -hellman-group-e
00000080  78:63:68:61:6e:67:65:2d:73:68:61:32:35:36:2c:64  xchange-sha256,d
00000090  69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72  iffie-hellman-gr
000000a0  6f:75:70:2d:65:78:63:68:61:6e:67:65:2d:73:68:61  oup-exchange-sha
000000b0  31:2c:64:69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e  1,diffie-hellman
000000c0  2d:67:72:6f:75:70:31:34:2d:73:68:61:31:2c:64:69  -group14-sha1,di
000000d0  66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f  ffie-hellman-gro
000000e0  75:70:31:2d:73:68:61:31:00:00:00:27:73:73:68:2d  up1-sha1...'ssh-
000000f0  72:73:61:2c:65:63:64:73:61:2d:73:68:61:32:2d:6e  rsa,ecdsa-sha2-n
00000100  69:73:74:70:32:35:36:2c:73:73:68:2d:65:64:32:35  istp256,ssh-ed25
00000110  35:31:39:00:00:00:e9:61:65:73:31:32:38:2d:63:74  519....aes128-ct
00000120  72:2c:61:65:73:31:39:32:2d:63:74:72:2c:61:65:73  r,aes192-ctr,aes
00000130  32:35:36:2d:63:74:72:2c:61:72:63:66:6f:75:72:32  256-ctr,arcfour2
00000140  35:36:2c:61:72:63:66:6f:75:72:31:32:38:2c:61:65  56,arcfour128,ae
00000150  73:31:32:38:2d:67:63:6d:40:6f:70:65:6e:73:73:68  s128-gcm@openssh
00000160  2e:63:6f:6d:2c:61:65:73:32:35:36:2d:67:63:6d:40  .com,aes256-gcm@
00000170  6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:63:68:61:63  openssh.com,chac
00000180  68:61:32:30:2d:70:6f:6c:79:31:33:30:35:40:6f:70  ha20-poly1305@op
00000190  65:6e:73:73:68:2e:63:6f:6d:2c:61:65:73:31:32:38  enssh.com,aes128
000001a0  2d:63:62:63:2c:33:64:65:73:2d:63:62:63:2c:62:6c  -cbc,3des-cbc,bl
000001b0  6f:77:66:69:73:68:2d:63:62:63:2c:63:61:73:74:31  owfish-cbc,cast1
000001c0  32:38:2d:63:62:63:2c:61:65:73:31:39:32:2d:63:62  28-cbc,aes192-cb
000001d0  63:2c:61:65:73:32:35:36:2d:63:62:63:2c:61:72:63  c,aes256-cbc,arc
000001e0  66:6f:75:72:2c:72:69:6a:6e:64:61:65:6c:2d:63:62  four,rijndael-cb
000001f0  63:40:6c:79:73:61:74:6f:72:2e:6c:69:75:2e:73:65  c@lysator.liu.se
00000200  00:00:00:e9:61:65:73:31:32:38:2d:63:74:72:2c:61  ....aes128-ctr,a
00000210  65:73:31:39:32:2d:63:74:72:2c:61:65:73:32:35:36  es192-ctr,aes256
00000220  2d:63:74:72:2c:61:72:63:66:6f:75:72:32:35:36:2c  -ctr,arcfour256,
00000230  61:72:63:66:6f:75:72:31:32:38:2c:61:65:73:31:32  arcfour128,aes12
00000240  38:2d:67:63:6d:40:6f:70:65:6e:73:73:68:2e:63:6f  8-gcm@openssh.co
00000250  6d:2c:61:65:73:32:35:36:2d:67:63:6d:40:6f:70:65  m,aes256-gcm@ope
00000260  6e:73:73:68:2e:63:6f:6d:2c:63:68:61:63:68:61:32  nssh.com,chacha2
00000270  30:2d:70:6f:6c:79:31:33:30:35:40:6f:70:65:6e:73  0-poly1305@opens
00000280  73:68:2e:63:6f:6d:2c:61:65:73:31:32:38:2d:63:62  sh.com,aes128-cb
00000290  63:2c:33:64:65:73:2d:63:62:63:2c:62:6c:6f:77:66  c,3des-cbc,blowf
000002a0  69:73:68:2d:63:62:63:2c:63:61:73:74:31:32:38:2d  ish-cbc,cast128-
000002b0  63:62:63:2c:61:65:73:31:39:32:2d:63:62:63:2c:61  cbc,aes192-cbc,a
000002c0  65:73:32:35:36:2d:63:62:63:2c:61:72:63:66:6f:75  es256-cbc,arcfou
000002d0  72:2c:72:69:6a:6e:64:61:65:6c:2d:63:62:63:40:6c  r,rijndael-cbc@l
000002e0  79:73:61:74:6f:72:2e:6c:69:75:2e:73:65:00:00:01  ysator.liu.se...
000002f0  92:68:6d:61:63:2d:6d:64:35:2d:65:74:6d:40:6f:70  .hmac-md5-etm@op
00000300  65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73  enssh.com,hmac-s
00000310  68:61:31:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e  ha1-etm@openssh.
00000320  63:6f:6d:2c:75:6d:61:63:2d:36:34:2d:65:74:6d:40  com,umac-64-etm@
00000330  6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:75:6d:61:63  openssh.com,umac
00000340  2d:31:32:38:2d:65:74:6d:40:6f:70:65:6e:73:73:68  -128-etm@openssh
00000350  2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:32:2d:32  .com,hmac-sha2-2
00000360  35:36:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63  56-etm@openssh.c
00000370  6f:6d:2c:68:6d:61:63:2d:73:68:61:32:2d:35:31:32  om,hmac-sha2-512
00000380  2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d  -etm@openssh.com
00000390  2c:68:6d:61:63:2d:72:69:70:65:6d:64:31:36:30:2d  ,hmac-ripemd160-
000003a0  65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c  etm@openssh.com,
000003b0  68:6d:61:63:2d:73:68:61:31:2d:39:36:2d:65:74:6d  hmac-sha1-96-etm
000003c0  40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61  @openssh.com,hma
000003d0  63:2d:6d:64:35:2d:39:36:2d:65:74:6d:40:6f:70:65  c-md5-96-etm@ope
000003e0  6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:6d:64  nssh.com,hmac-md
000003f0  35:2c:68:6d:61:63:2d:73:68:61:31:2c:75:6d:61:63  5,hmac-sha1,umac
00000400  2d:36:34:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c  -64@openssh.com,
00000410  75:6d:61:63:2d:31:32:38:40:6f:70:65:6e:73:73:68  umac-128@openssh
00000420  2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:32:2d:32  .com,hmac-sha2-2
00000430  35:36:2c:68:6d:61:63:2d:73:68:61:32:2d:35:31:32  56,hmac-sha2-512
00000440  2c:68:6d:61:63:2d:72:69:70:65:6d:64:31:36:30:2c  ,hmac-ripemd160,
00000450  68:6d:61:63:2d:72:69:70:65:6d:64:31:36:30:40:6f  hmac-ripemd160@o
00000460  70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d  penssh.com,hmac-
00000470  73:68:61:31:2d:39:36:2c:68:6d:61:63:2d:6d:64:35  sha1-96,hmac-md5
00000480  2d:39:36:00:00:01:92:68:6d:61:63:2d:6d:64:35:2d  -96....hmac-md5-
00000490  65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c  etm@openssh.com,
000004a0  68:6d:61:63:2d:73:68:61:31:2d:65:74:6d:40:6f:70  hmac-sha1-etm@op
000004b0  65:6e:73:73:68:2e:63:6f:6d:2c:75:6d:61:63:2d:36  enssh.com,umac-6
000004c0  34:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f  4-etm@openssh.co
000004d0  6d:2c:75:6d:61:63:2d:31:32:38:2d:65:74:6d:40:6f  m,umac-128-etm@o
000004e0  70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d  penssh.com,hmac-
000004f0  73:68:61:32:2d:32:35:36:2d:65:74:6d:40:6f:70:65  sha2-256-etm@ope
00000500  6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73:68  nssh.com,hmac-sh
00000510  61:32:2d:35:31:32:2d:65:74:6d:40:6f:70:65:6e:73  a2-512-etm@opens
00000520  73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:72:69:70:65  sh.com,hmac-ripe
00000530  6d:64:31:36:30:2d:65:74:6d:40:6f:70:65:6e:73:73  md160-etm@openss
00000540  68:2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:31:2d  h.com,hmac-sha1-
00000550  39:36:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63  96-etm@openssh.c
00000560  6f:6d:2c:68:6d:61:63:2d:6d:64:35:2d:39:36:2d:65  om,hmac-md5-96-e
00000570  74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68  tm@openssh.com,h
00000580  6d:61:63:2d:6d:64:35:2c:68:6d:61:63:2d:73:68:61  mac-md5,hmac-sha
00000590  31:2c:75:6d:61:63:2d:36:34:40:6f:70:65:6e:73:73  1,umac-64@openss
000005a0  68:2e:63:6f:6d:2c:75:6d:61:63:2d:31:32:38:40:6f  h.com,umac-128@o
000005b0  70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d  penssh.com,hmac-
000005c0  73:68:61:32:2d:32:35:36:2c:68:6d:61:63:2d:73:68  sha2-256,hmac-sh
000005d0  61:32:2d:35:31:32:2c:68:6d:61:63:2d:72:69:70:65  a2-512,hmac-ripe
000005e0  6d:64:31:36:30:2c:68:6d:61:63:2d:72:69:70:65:6d  md160,hmac-ripem
000005f0  64:31:36:30:40:6f:70:65:6e:73:73:68:2e:63:6f:6d  d160@openssh.com
00000600  2c:68:6d:61:63:2d:73:68:61:31:2d:39:36:2c:68:6d  ,hmac-sha1-96,hm
00000610  61:63:2d:6d:64:35:2d:39:36:00:00:00:15:6e:6f:6e  ac-md5-96....non
00000620  65:2c:7a:6c:69:62:40:6f:70:65:6e:73:73:68:2e:63  e,zlib@openssh.c
00000630  6f:6d:00:00:00:15:6e:6f:6e:65:2c:7a:6c:69:62:40  om....none,zlib@
00000640  6f:70:65:6e:73:73:68:2e:63:6f:6d:00:00:00:00:00  openssh.com.....
00000650  00:00:00:00:00:00:00:00                          ........

-> NET_SSH2_MSG_KEXINIT (since last: 0.0001, network: 0s)
00000000  e0:dc:b7:cf:3a:4a:e8:be:96:1e:ec:59:03:39:8e:8e  ....:J.....Y.9..
00000010  00:00:00:7e:64:69:66:66:69:65:2d:68:65:6c:6c:6d  ...~diffie-hellm
00000020  61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31:2c:64  an-group1-sha1,d
00000030  69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72  iffie-hellman-gr
00000040  6f:75:70:31:34:2d:73:68:61:31:2c:64:69:66:66:69  oup14-sha1,diffi
00000050  65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:2d  e-hellman-group-
00000060  65:78:63:68:61:6e:67:65:2d:73:68:61:31:2c:64:69  exchange-sha1,di
00000070  66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f  ffie-hellman-gro
00000080  75:70:2d:65:78:63:68:61:6e:67:65:2d:73:68:61:32  up-exchange-sha2
00000090  35:36:00:00:00:0f:73:73:68:2d:72:73:61:2c:73:73  56....ssh-rsa,ss
000000a0  68:2d:64:73:73:00:00:00:e9:61:72:63:66:6f:75:72  h-dss....arcfour
000000b0  32:35:36:2c:61:72:63:66:6f:75:72:31:32:38:2c:61  256,arcfour128,a
000000c0  65:73:31:32:38:2d:63:74:72:2c:61:65:73:31:39:32  es128-ctr,aes192
000000d0  2d:63:74:72:2c:61:65:73:32:35:36:2d:63:74:72:2c  -ctr,aes256-ctr,
000000e0  74:77:6f:66:69:73:68:31:32:38:2d:63:74:72:2c:74  twofish128-ctr,t
000000f0  77:6f:66:69:73:68:31:39:32:2d:63:74:72:2c:74:77  wofish192-ctr,tw
00000100  6f:66:69:73:68:32:35:36:2d:63:74:72:2c:61:65:73  ofish256-ctr,aes
00000110  31:32:38:2d:63:62:63:2c:61:65:73:31:39:32:2d:63  128-cbc,aes192-c
00000120  62:63:2c:61:65:73:32:35:36:2d:63:62:63:2c:74:77  bc,aes256-cbc,tw
00000130  6f:66:69:73:68:31:32:38:2d:63:62:63:2c:74:77:6f  ofish128-cbc,two
00000140  66:69:73:68:31:39:32:2d:63:62:63:2c:74:77:6f:66  fish192-cbc,twof
00000150  69:73:68:32:35:36:2d:63:62:63:2c:74:77:6f:66:69  ish256-cbc,twofi
00000160  73:68:2d:63:62:63:2c:62:6c:6f:77:66:69:73:68:2d  sh-cbc,blowfish-
00000170  63:74:72:2c:62:6c:6f:77:66:69:73:68:2d:63:62:63  ctr,blowfish-cbc
00000180  2c:33:64:65:73:2d:63:74:72:2c:33:64:65:73:2d:63  ,3des-ctr,3des-c
00000190  62:63:00:00:00:e9:61:72:63:66:6f:75:72:32:35:36  bc....arcfour256
000001a0  2c:61:72:63:66:6f:75:72:31:32:38:2c:61:65:73:31  ,arcfour128,aes1
000001b0  32:38:2d:63:74:72:2c:61:65:73:31:39:32:2d:63:74  28-ctr,aes192-ct
000001c0  72:2c:61:65:73:32:35:36:2d:63:74:72:2c:74:77:6f  r,aes256-ctr,two
000001d0  66:69:73:68:31:32:38:2d:63:74:72:2c:74:77:6f:66  fish128-ctr,twof
000001e0  69:73:68:31:39:32:2d:63:74:72:2c:74:77:6f:66:69  ish192-ctr,twofi
000001f0  73:68:32:35:36:2d:63:74:72:2c:61:65:73:31:32:38  sh256-ctr,aes128
00000200  2d:63:62:63:2c:61:65:73:31:39:32:2d:63:62:63:2c  -cbc,aes192-cbc,
00000210  61:65:73:32:35:36:2d:63:62:63:2c:74:77:6f:66:69  aes256-cbc,twofi
00000220  73:68:31:32:38:2d:63:62:63:2c:74:77:6f:66:69:73  sh128-cbc,twofis
00000230  68:31:39:32:2d:63:62:63:2c:74:77:6f:66:69:73:68  h192-cbc,twofish
00000240  32:35:36:2d:63:62:63:2c:74:77:6f:66:69:73:68:2d  256-cbc,twofish-
00000250  63:62:63:2c:62:6c:6f:77:66:69:73:68:2d:63:74:72  cbc,blowfish-ctr
00000260  2c:62:6c:6f:77:66:69:73:68:2d:63:62:63:2c:33:64  ,blowfish-cbc,3d
00000270  65:73:2d:63:74:72:2c:33:64:65:73:2d:63:62:63:00  es-ctr,3des-cbc.
00000280  00:00:39:68:6d:61:63:2d:73:68:61:32:2d:32:35:36  ..9hmac-sha2-256
00000290  2c:68:6d:61:63:2d:73:68:61:31:2d:39:36:2c:68:6d  ,hmac-sha1-96,hm
000002a0  61:63:2d:73:68:61:31:2c:68:6d:61:63:2d:6d:64:35  ac-sha1,hmac-md5
000002b0  2d:39:36:2c:68:6d:61:63:2d:6d:64:35:00:00:00:39  -96,hmac-md5...9
000002c0  68:6d:61:63:2d:73:68:61:32:2d:32:35:36:2c:68:6d  hmac-sha2-256,hm
000002d0  61:63:2d:73:68:61:31:2d:39:36:2c:68:6d:61:63:2d  ac-sha1-96,hmac-
000002e0  73:68:61:31:2c:68:6d:61:63:2d:6d:64:35:2d:39:36  sha1,hmac-md5-96
000002f0  2c:68:6d:61:63:2d:6d:64:35:00:00:00:04:6e:6f:6e  ,hmac-md5....non
00000300  65:00:00:00:04:6e:6f:6e:65:00:00:00:00:00:00:00  e....none.......
00000310  00:00:00:00:00:00                                ......

i've tested connection like filezilla sftp and no problem sends ober 1GB, any idea? Gaufrette looks like have not many options maybe phpseclib?

Second though it can be SFTP server problem but if is, i think is should be problem in sending  file by filezilla.