问:
Eclipse ShellEd plugin error
I have downloaded net.sourceforge.shelled-site-2.0.3 from here

and successfully installed in eclipse.

However when I try to open Shell Script Editor.

I have googled around with this error but found no clue.

I am using eclipse 4.4.2

```<code>java.lang.NoSuchMethodError: org.eclipse.core.runtime.ListenerList.iterator()Ljava/util/Iterator;
    at org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider$GlobalAnnotationModelListener.modelChanged(SourceModuleDocumentProvider.java:1011)
    at org.eclipse.jface.text.source.AnnotationModel.addAnnotationModelListener(AnnotationModel.java:462)
    at org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider.createFileInfo(SourceModuleDocumentProvider.java:1279)
    at org.eclipse.ui.editors.text.TextFileDocumentProvider.connect(TextFileDocumentProvider.java:478)
    at org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider.connect(SourceModuleDocumentProvider.java:1506)
    at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4233)
    at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:237)
    at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1480)
    at org.eclipse.dltk.internal.ui.editor.ScriptEditor.internalDoSetInput(ScriptEditor.java:832)
    at org.eclipse.dltk.internal.ui.editor.ScriptEditor.doSetInput(ScriptEditor.java:1138)
    at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3220)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:466)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:374)
    at org.eclipse.ui.internal.WorkbenchWindow$13.run(WorkbenchWindow.java:2157)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2153)
    at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3238)
    at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3265)
    at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:390)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:305)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:888)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:869)
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:120)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:337)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:104)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:73)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:55)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:127)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:983)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:662)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:766)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:737)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:731)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:715)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$1.handleEvent(PartServiceImpl.java:95)
    at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:187)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:156)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:4732)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:218)
    at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:36)
    at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
    at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
    at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
    at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:81)
    at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:59)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
    at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:171)
    at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:488)
    at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:454)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:705)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:392)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1145)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3210)
    at org.eclipse.ui.internal.WorkbenchPage.access$23(WorkbenchPage.java:3125)
    at org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.java:3107)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3102)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3066)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3056)
    at org.eclipse.ui.ide.IDE.openEditor(IDE.java:541)
    at org.eclipse.ui.ide.IDE.openEditor(IDE.java:500)
    at org.eclipse.ui.actions.OpenFileAction.openFile(OpenFileAction.java:99)
    at org.eclipse.ui.actions.OpenSystemEditorAction.run(OpenSystemEditorAction.java:99)
    at org.eclipse.ui.views.navigator.OpenActionGroup.runDefaultAction(OpenActionGroup.java:133)
    at org.eclipse.ui.views.navigator.MainActionGroup.runDefaultAction(MainActionGroup.java:330)
    at org.eclipse.ui.views.navigator.ResourceNavigator.handleOpen(ResourceNavigator.java:787)
    at org.eclipse.ui.views.navigator.ResourceNavigator$6.open(ResourceNavigator.java:499)
    at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
    at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:853)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
    at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:850)
    at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1142)
    at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1249)
    at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:278)
    at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:272)
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:313)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4199)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1467)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1490)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1475)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4042)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3669)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
</code>```

答: The plugin you installed is using a method of the Eclipse ListenerList class which is only in Eclipse 4.6 and later releases. Because of this it won't work in Eclipse 4.4.2

Title: Eclipse ShellEd plugin error

Body:
I have downloaded net.sourceforge.shelled-site-2.0.3 from here

and successfully installed in eclipse.

However when I try to open Shell Script Editor.

I have googled around with this error but found no clue.

I am using eclipse 4.4.2

java.lang.NoSuchMethodError: org.eclipse.core.runtime.ListenerList.iterator()Ljava/util/Iterator;
    at org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider$GlobalAnnotationModelListener.modelChanged(SourceModuleDocumentProvider.java:1011)
    at org.eclipse.jface.text.source.AnnotationModel.addAnnotationModelListener(AnnotationModel.java:462)
    at org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider.createFileInfo(SourceModuleDocumentProvider.java:1279)
    at org.eclipse.ui.editors.text.TextFileDocumentProvider.connect(TextFileDocumentProvider.java:478)
    at org.eclipse.dltk.internal.ui.editor.SourceModuleDocumentProvider.connect(SourceModuleDocumentProvider.java:1506)
    at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4233)
    at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:237)
    at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1480)
    at org.eclipse.dltk.internal.ui.editor.ScriptEditor.internalDoSetInput(ScriptEditor.java:832)
    at org.eclipse.dltk.internal.ui.editor.ScriptEditor.doSetInput(ScriptEditor.java:1138)
    at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3220)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:466)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:374)
    at org.eclipse.ui.internal.WorkbenchWindow$13.run(WorkbenchWindow.java:2157)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2153)
    at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3238)
    at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3265)
    at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:390)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:305)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:888)
    at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:869)
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:120)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:337)
    at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:104)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:73)
    at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:55)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:127)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:983)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:662)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:766)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:737)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:731)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:715)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$1.handleEvent(PartServiceImpl.java:95)
    at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:187)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:156)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:4732)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:218)
    at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:36)
    at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
    at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
    at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
    at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
    at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:81)
    at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:59)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
    at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:171)
    at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:488)
    at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:454)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:705)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:392)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1145)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3210)
    at org.eclipse.ui.internal.WorkbenchPage.access$23(WorkbenchPage.java:3125)
    at org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.java:3107)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3102)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3066)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3056)
    at org.eclipse.ui.ide.IDE.openEditor(IDE.java:541)
    at org.eclipse.ui.ide.IDE.openEditor(IDE.java:500)
    at org.eclipse.ui.actions.OpenFileAction.openFile(OpenFileAction.java:99)
    at org.eclipse.ui.actions.OpenSystemEditorAction.run(OpenSystemEditorAction.java:99)
    at org.eclipse.ui.views.navigator.OpenActionGroup.runDefaultAction(OpenActionGroup.java:133)
    at org.eclipse.ui.views.navigator.MainActionGroup.runDefaultAction(MainActionGroup.java:330)
    at org.eclipse.ui.views.navigator.ResourceNavigator.handleOpen(ResourceNavigator.java:787)
    at org.eclipse.ui.views.navigator.ResourceNavigator$6.open(ResourceNavigator.java:499)
    at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
    at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:853)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:178)
    at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:850)
    at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1142)
    at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1249)
    at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:278)
    at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:272)
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:313)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4199)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1467)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1490)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1475)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4042)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3669)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)


来源: stackexchange

问:
Inserting sumif into all the cells of a column
I would like to insert IF(A2<>"Sub-task",SUMIF(D:D,D2,I:I),"  ") in Cell J2 using vba.  I then want to copy this formula down to every row in column J until the last row of data in Column D</p>

答:
I'm using Excel 2007 and it was giving me an error for </p>

```<code>Range("J2").Value = "=" & "IF(A2<>""Sub-task"",SUMIF(D:D,D2,I:I),"""")"
</code>```

<p>My workaround for this was just slapping the formula on the end of an equals sign and that worked for some reason. To count the rows in D, I just made a while loop with "i" to keep track of the rows. However, this will stop the copying right after it hits an empty cell in D, so if you have blank rows you'll have to loop it differently. </p>

```<code>Sub SumIfSub()
    Dim i As Integer

    Range("J2").Value = "="
    Range("J2").Value = Range("J2").Value & "IF(A2<>""Sub-task"",SUMIF(D:D,D2,I:I),"""")"

    i = 3
    Do While (Range("D" & i).Value <> "")
        Range("J" & i).Value = Range("J2").Value
        i = i + 1
    Loop
End Sub
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I'm using Excel 2007 and it was giving me an error for

Range("J2").Value = "=" & "IF(A2<>""Sub-task"",SUMIF(D:D,D2,I:I),"""")"

My workaround for this was just slapping the formula on the end of an equals sign and that worked for some reason. To count the rows in D, I just made a while loop with "i" to keep track of the rows. However, this will stop the copying right after it hits an empty cell in D, so if you have blank rows you'll have to loop it differently.

Sub SumIfSub()
    Dim i As Integer

    Range("J2").Value = "="
    Range("J2").Value = Range("J2").Value & "IF(A2<>""Sub-task"",SUMIF(D:D,D2,I:I),"""")"

    i = 3
    Do While (Range("D" & i).Value <> "")
        Range("J" & i).Value = Range("J2").Value
        i = i + 1
    Loop
End Sub


问:
ASP.NET 2.5 prefixing ctl00 and ASP.NET 4 not prefixing ctl00
Does anyone know why ASP.NET 4 has dropped the ctl00 prefix on ASP controls?

Is there a setting I have missed?

答:
Not a setting, but a decision by MS to simplify the way IDs of controls within containers are transformed to the client.

Here is a blog post by Scott Guthrie explaining the changes.  The reasoning behind it:

Clean, Standards-Based, CSS-Friendly Markup


问:
Vue.js - Element UI - Form item label slot
I would like to know how to use Form Element Slot with vue.js 2.3 and element-ui. Documentaton here. So I can insert  html for the label of my form.

I tried this on jsfiddle here.

Problem

Unknown custom element: el-form-item-slot

Question

What is the proper way to implement that? The documentation is not clear on this topic

答:
The way to specify content to use in a component's slot is by adding the slot attribute to an element within the tag for that component.

In your case, you want to specify an element to go in the the label slot for the el-form-item component. You could do something like this:

```<code><el-form-item label="temp">
  <span slot="label">Label for the slot</span>
  <el-input v-model="formLabelAlign.name"></el-input>
</el-form-item>
</code>```

Notice, I did have to also provide a label attribute (with value "temp") to the component tag itself. This might be a bug or it might be a required (and poorly documented) fallback value.

Here's a working fiddle.

Body:
The way to specify content to use in a component's slot is by adding the slot attribute to an element within the tag for that component.

In your case, you want to specify an element to go in the the label slot for the el-form-item component. You could do something like this:

<el-form-item label="temp">
  <span slot="label">Label for the slot</span>
  <el-input v-model="formLabelAlign.name"></el-input>
</el-form-item>

Notice, I did have to also provide a label attribute (with value "temp") to the component tag itself. This might be a bug or it might be a required (and poorly documented) fallback value.

Here's a working fiddle.


问:
How to input null-value into specflow step definition table
How can I input a null value in Specflow through a table?

Let's look at an overly simplistic example:

```<code>When a tire is attached to a car
| CarId | TireModel      | FabricationDate | Batch |
| 1     | Nokian Hakka R | 2015-09-1       |       |
</code>```

The empty string in the Batch column is interpreted as text by specflow and as such, empty string. Is there a special syntax to mark that column as null?

答:
You can create your own IValueRetriever and replace default one with yours

public class StringValueRetriver : IValueRetriever
{
    public bool CanRetrieve(KeyValuePair<string, string> keyValuePair, Type targetType, Type propertyType)
    {
        return propertyType == typeof(string);
    }

    public object Retrieve(KeyValuePair<string, string> keyValuePair, Type targetType, Type propertyType)
    {
        return string.IsNullOrEmpty(keyValuePair.Value) ? null : keyValuePair.Value;
    }
}
```

<p>Some where in your scenario steps</p>

<pre class="lang-cs prettyprint-override"><code>[BeforeScenario]
public void BeforeScenario()
{
    Service.Instance.ValueRetrievers.Unregister<TechTalk.SpecFlow.Assist.ValueRetrievers.StringValueRetriever>();
    Service.Instance.ValueRetrievers.Register(new StringValueRetriver());
}
</code>```

older syntax:

[BeforeScenario]
public void BeforeScenario()
{
    var defaultStringValueRetriever = Service.Instance.ValueRetrievers.FirstOrDefault(vr => vr is TechTalk.SpecFlow.Assist.ValueRetrievers.StringValueRetriever);
    if (defaultStringValueRetriever != null)
    {
        Service.Instance.UnregisterValueRetriever(defaultStringValueRetriever);
        Service.Instance.RegisterValueRetriever(new StringValueRetriver());
    }
}
```

Body:
How can I input a null value in Specflow through a table?

Let's look at an overly simplistic example:

When a tire is attached to a car
| CarId | TireModel      | FabricationDate | Batch |
| 1     | Nokian Hakka R | 2015-09-1       |       |

The empty string in the Batch column is interpreted as text by specflow and as such, empty string. Is there a special syntax to mark that column as null?

Body:
You can create your own IValueRetriever and replace default one with yours

public class StringValueRetriver : IValueRetriever
{
    public bool CanRetrieve(KeyValuePair<string, string> keyValuePair, Type targetType, Type propertyType)
    {
        return propertyType == typeof(string);
    }

    public object Retrieve(KeyValuePair<string, string> keyValuePair, Type targetType, Type propertyType)
    {
        return string.IsNullOrEmpty(keyValuePair.Value) ? null : keyValuePair.Value;
    }
}

Some where in your scenario steps

[BeforeScenario]
public void BeforeScenario()
{
    Service.Instance.ValueRetrievers.Unregister<TechTalk.SpecFlow.Assist.ValueRetrievers.StringValueRetriever>();
    Service.Instance.ValueRetrievers.Register(new StringValueRetriver());
}

older syntax:

[BeforeScenario]
public void BeforeScenario()
{
    var defaultStringValueRetriever = Service.Instance.ValueRetrievers.FirstOrDefault(vr => vr is TechTalk.SpecFlow.Assist.ValueRetrievers.StringValueRetriever);
    if (defaultStringValueRetriever != null)
    {
        Service.Instance.UnregisterValueRetriever(defaultStringValueRetriever);
        Service.Instance.RegisterValueRetriever(new StringValueRetriver());
    }
}

ContentLicense: CC BY-SA 4.0


问:
Delete all lines beginning with a # from a file
All of the lines with comments in a file begin with #. How can I delete all of the lines (and only those lines) which begin with #? Other lines containing #, but not at the beginning of the line should be ignored.

答:
you can directly edit your file with

```<code>sed -i '/^#/ d'
</code>```

If you want also delete comment lines that start with some whitespace use

```<code>sed -i '/^\s*#/ d'
</code>```

Usually, you want to keep the first line of your script, if it is a sha-bang, so sed should not delete lines starting with #!. also it should delete lines, that just contain only a hash but no text. put it all together:

```<code>sed -i '/^\s*\(#[^!].*\|#$\)/d'
</code>```

To be conform with all sed variants you need to add a backup extension to the -i option:

```<code>sed -i.bak '/^\s*#/ d' $file
rm -Rf $file.bak
</code>```

Body:
you can directly edit your file with

sed -i '/^#/ d'

If you want also delete comment lines that start with some whitespace use

sed -i '/^\s*#/ d'

Usually, you want to keep the first line of your script, if it is a sha-bang, so sed should not delete lines starting with #!. also it should delete lines, that just contain only a hash but no text. put it all together:

sed -i '/^\s*\(#[^!].*\|#$\)/d'

To be conform with all sed variants you need to add a backup extension to the -i option:

sed -i.bak '/^\s*#/ d' $file
rm -Rf $file.bak


问:
How to get the desktop Rect while using ATL?
I want to get the Rect of the entire desktop from within a dialog, and ATL has overridden the GetWindowRect(HWND hWnd, LPRECT lpRect) to GetWindowRect(LPRECT lpRect) and it assumes the current dialog window so it just fills the lpRect with its own dimensions.

How do I get the desktop window's Rect? I've tried using the GetDesktopWindow(), but it returns a HWND which with I still can't find the Rect from.

答:
I found this snippet on the MSDN page of CWindow that seems to do what you want:

```<code>HWND hWnd  = ::GetDesktopWindow();
CWindow myWindow;
myWindow.Attach(hWnd);
</code>```

After this, you should be able to use

```<code>myWindow.GetWindowRect(lpRect)
</code>```

Body:
I found this snippet on the MSDN page of CWindow that seems to do what you want:

HWND hWnd  = ::GetDesktopWindow();
CWindow myWindow;
myWindow.Attach(hWnd);

After this, you should be able to use

myWindow.GetWindowRect(lpRect)


问:
Selenium finding xPath ID element that changes in Java
I have this xPath: //*[@id="searchpopupSCH_USER_1496689382343"]

but on the backend, the 13 digits are actually a timestamp so it changes everytime you re-test/re-click.

For example,

1st tab, //*[@id="searchpopupSCH_USER_1496689382343"]
2nt tab, //*[@id="searchpopupSCH_USER_1496694868441"]

Is there to target that ID that keeps changing?

I was thinking of using Reg Exp but somehow I am bit block.

```<code>    String frameID = "//*[@id=\"searchpopupSCH_USER_";
    String regExp = "\\d{13}";

    Pattern p = Pattern.compile(frameID + regExp);

    WebElement xPathUserList;
    xPathUserList.findElement(By.xpath(p));  //param of xpath only take String
</code>```

My concern is the WebElement.

How can you target By.Path("//*[@id=\"searchpopupSCH_USER_xxxxxxxxxxxx"

thanks for your inputs.

答:
use contains? or even starts-with

```<code> //*[contains(@id, "searchpopupSCH_USER_")]
 //*[starts-with(@id, "searchpopupSCH_USER_")]
</code>```

Body:
I have this xPath: //*[@id="searchpopupSCH_USER_1496689382343"]

but on the backend, the 13 digits are actually a timestamp so it changes everytime you re-test/re-click.

For example,

1st tab, //*[@id="searchpopupSCH_USER_1496689382343"]
2nt tab, //*[@id="searchpopupSCH_USER_1496694868441"]

Is there to target that ID that keeps changing?

I was thinking of using Reg Exp but somehow I am bit block.

    String frameID = "//*[@id=\"searchpopupSCH_USER_";
    String regExp = "\\d{13}";

    Pattern p = Pattern.compile(frameID + regExp);

    WebElement xPathUserList;
    xPathUserList.findElement(By.xpath(p));  //param of xpath only take String

My concern is the WebElement.

How can you target By.Path("//*[@id=\"searchpopupSCH_USER_xxxxxxxxxxxx"

thanks for your inputs.

Body:
use contains? or even starts-with

 //*[contains(@id, "searchpopupSCH_USER_")]
 //*[starts-with(@id, "searchpopupSCH_USER_")]


答:
For starters, you can do ::GetWindowRect(hWnd, lpRect); if you want to bypass the ATL's CWindow::GetWindowRect(LPRECT) member.

Desktop is not necessarily rectangular as your system might be multi-monitor.

(source: s-msft.com)

If you ignore the multi-monitor aspect, you can use  GetSystemMetrics(SM_CXSCREEN) + GetSystemMetrics(SM_CYSCREEN) (or GetSystemMetrics(SM_CXVIRTUALSCREEN) + GetSystemMetrics(SM_CYVIRTUALSCREEN)), or SystemParametersInfo(SPI_GETWORKAREA, ...) APIs. ATL does not offer any shortcuts, these will have to be direct API calls.

With a multi-monitor system you enumerate monitors and get a work area for every enumerated one. Together they are the desktop:

To enumerate all the devices on the computer, call the EnumDisplayDevices function. The information that is returned also indicates which monitor is part of the desktop.

Title: How to get the desktop Rect while using ATL?

Body:
I want to get the Rect of the entire desktop from within a dialog, and ATL has overridden the GetWindowRect(HWND hWnd, LPRECT lpRect) to GetWindowRect(LPRECT lpRect) and it assumes the current dialog window so it just fills the lpRect with its own dimensions.

How do I get the desktop window's Rect? I've tried using the GetDesktopWindow(), but it returns a HWND which with I still can't find the Rect from.


问:
html email with reference to an image as base64 String
I would like to send an email with the Java Mail API (javax.mail). The message must contain html and inside there is a reference to an image. There is a challenge, because no reference to a physical file on disk is allowed but instead I have created a base64 string (http://www.base64-image.de/step-1.php) for that image and copied that data to a static String variable.
With javax.mail I build a message of type MulitPart with two parts. The first part is the html itself and the second part is the image. The html part reference to the image via .

```<code>Message msg = new MimeMessage(session);
Multipart multipart = new MimeMultipart("related");
BodyPart htmlPart = new MimeBodyPart();
        htmlPart.setContent("<html><body><h2>A title</h2>Some text in here<br/>" +
                "<img src=\"cid:the-img-1\"/><br/> some more text<img src=\"cid:the-img-1\"/></body></html>", "text/html");
multipart.addBodyPart(htmlPart);

public static final String base64logo = "/9j/4AAQSkZJRgABAQEASABIAAD/4QBe…"; // ein ganz langer String erzeugt über http://www.base64-image.de/step-1.php

sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
byte[] imageByte = decoder.decodeBuffer(base64logo);
InternetHeaders header = new InternetHeaders();
BodyPart imgPart=new MimeBodyPart(header, imageByte);
imgPart.setHeader("Content-ID","the-img-1");
imgPart.setDisposition(MimeBodyPart.INLINE);
multipart.addBodyPart(imgPart);
msg.setContent(multipart);
</code>```

Unfortunately the image is missing in the incoming email.

When I point to the file on my disk it is working:

```<code>DataSource ds=new FileDataSource("c:/temp/image001.jpg");
imgPart.setDataHandler(new DataHandler(ds));
</code>```

We are developing with Talend and we cannot reference
to external files because that would make the deployment process
more complicate.

Can you find some wrong doings in my approach?

Kind regards
Hilderich

答:
This has been asked before a long time ago. But I will answer this as I have faced the same issue, from my own answer here.

```<code>byte[] tile = DatatypeConverter.parseBase64Binary(base64logo);
BodyPart messageBodyPart = new MimeBodyPart();
DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(tile, "image/jpeg"));
messageBodyPart.setDataHandler(dataHandler);
messageBodyPart.setHeader("Content-ID", "<the-img-1>");
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);
</code>```

Hope it will help someone.

Body:
I would like to send an email with the Java Mail API (javax.mail). The message must contain html and inside there is a reference to an image. There is a challenge, because no reference to a physical file on disk is allowed but instead I have created a base64 string (http://www.base64-image.de/step-1.php) for that image and copied that data to a static String variable.
With javax.mail I build a message of type MulitPart with two parts. The first part is the html itself and the second part is the image. The html part reference to the image via .

Message msg = new MimeMessage(session);
Multipart multipart = new MimeMultipart("related");
BodyPart htmlPart = new MimeBodyPart();
        htmlPart.setContent("
A title
Some text in here
" +
                "
 some more text", "text/html");
multipart.addBodyPart(htmlPart);

public static final String base64logo = "/9j/4AAQSkZJRgABAQEASABIAAD/4QBe…"; // ein ganz langer String erzeugt über http://www.base64-image.de/step-1.php

sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
byte[] imageByte = decoder.decodeBuffer(base64logo);
InternetHeaders header = new InternetHeaders();
BodyPart imgPart=new MimeBodyPart(header, imageByte);
imgPart.setHeader("Content-ID","the-img-1");
imgPart.setDisposition(MimeBodyPart.INLINE);
multipart.addBodyPart(imgPart);
msg.setContent(multipart);

Unfortunately the image is missing in the incoming email.

When I point to the file on my disk it is working:

DataSource ds=new FileDataSource("c:/temp/image001.jpg");
imgPart.setDataHandler(new DataHandler(ds));

We are developing with Talend and we cannot reference
to external files because that would make the deployment process
more complicate.

Can you find some wrong doings in my approach?

Kind regards
Hilderich

Body:
This has been asked before a long time ago. But I will answer this as I have faced the same issue, from my own answer here.

byte[] tile = DatatypeConverter.parseBase64Binary(base64logo);
BodyPart messageBodyPart = new MimeBodyPart();
DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(tile, "image/jpeg"));
messageBodyPart.setDataHandler(dataHandler);
messageBodyPart.setHeader("Content-ID", "<the-img-1>");
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);

Hope it will help someone.


问:
How to execute main1 when I have main1, main2, and main?
```<code>#include <stdio.h>
#include <string.h>

int main1(void)
{
   printf("Came to main1.\n");
}

int main2(void)
{
   printf("Came to main2.\n");
}

int main(void)
{
   printf("Came to main. \n");
}
</code>```

I have main1, main2, and main. I want to see main1 output, but every time I execute the program, I can only see main output

答:
I think you are just curious as a beginner that you can define multiple mains in your program. Understand that main is a special function. You cannot have several mains in your program. If you define main1 or main2 they are always going to be ordinary functions. And execution of programs will start with main(). Though there are constructors that are called before main and you can explicitly define a function to be one, but in general/default cases main is the entry point of the program.

But if you still want to call main1 before main here's how you can do:

```<code>#include <stdio.h>

int main1(void) __attribute__ ((constructor));// Note this line.

int main2(void) __attribute__ ((constructor));

int main2(void)
{
   printf("Came to main2.\n");
}

int main1(void)
{
   printf("Came to main1.\n");

}

int main(void)
{
   printf("Came to main. \n");
}
</code>```

Also note the order in which main1 and main2 are defined. main1 is defined after main2. Therefore the output is

```<code>Came to main1.
Came to main2.
Came to main.
</code>```

Beware, this is a gcc specific thing.

Body:
#include <stdio.h>
#include <string.h>

int main1(void)
{
   printf("Came to main1.\n");
}

int main2(void)
{
   printf("Came to main2.\n");
}

int main(void)
{
   printf("Came to main. \n");
}

I have main1, main2, and main. I want to see main1 output, but every time I execute the program, I can only see main output

Body:
I think you are just curious as a beginner that you can define multiple mains in your program. Understand that main is a special function. You cannot have several mains in your program. If you define main1 or main2 they are always going to be ordinary functions. And execution of programs will start with main(). Though there are constructors that are called before main and you can explicitly define a function to be one, but in general/default cases main is the entry point of the program.

But if you still want to call main1 before main here's how you can do:

#include <stdio.h>

int main1(void) __attribute__ ((constructor));// Note this line.

int main2(void) __attribute__ ((constructor));

int main2(void)
{
   printf("Came to main2.\n");
}

int main1(void)
{
   printf("Came to main1.\n");

}

int main(void)
{
   printf("Came to main. \n");
}

Also note the order in which main1 and main2 are defined. main1 is defined after main2. Therefore the output is

Came to main1.
Came to main2.
Came to main.

Beware, this is a gcc specific thing.


问:
short circuit Array.reduce in Javascript
A toy example of a pattern I am trying to solve elegantly.  In the below algorithm, I would like to immediately return 0 from reduce when I find an element with a value of 0 without visiting the remaining elements.

```<code>let factors = [2,3,6,0,9,4,4,4];
function product(arr) {
    return arr.reduce((acc, elem) => (acc * elem), 1);
}
</code>```

Is there some way to break out of the reduce iteration?

答:
You can short circuit reduce by mutating the original array.

let factors = [2, 3, 6, 0, 9, 4, 4, 4];

function product(arr) {
  return arr.reduce((acc, elem, i, array) => (array[i] === 0 ? (arr.length = i, elem) : (acc * elem)), 1);

}
console.log(product(factors))```

Body:
A toy example of a pattern I am trying to solve elegantly.  In the below algorithm, I would like to immediately return 0 from reduce when I find an element with a value of 0 without visiting the remaining elements.

let factors = [2,3,6,0,9,4,4,4];
function product(arr) {
    return arr.reduce((acc, elem) => (acc * elem), 1);
}

Is there some way to break out of the reduce iteration?


问:
The 'xmlns' attribute is bound to the reserved namespace 'http://www.w3.org/2000/xmlns/'
I'm using a terminal application a predecessor wrote, using Infragistics to process some SQL data into excel report templates.

It works fine for some sets of data, but it throws the following: The 'xmlns' attribute is bound to the reserved namespace 'http://www.w3.org/2000/xmlns/'

Nowhere in the App config is any xmlns defined, and I'm at a loss. I can share code, please help me figure out what's relevant.

答:
For future reference/searchability, the Xerces error message for this problem is as follows:

[Fatal Error] try.xml:2:47: The prefix "xmlns" cannot be bound to any
  namespace explicitly; neither can the namespace for "xmlns" be bound
  to any prefix explicitly.

To resolve the problem, search the XML document for http://www.w3.org/2000/xmlns/.  Any of the following settings would be a violation:

```<code>xmlns="http://www.w3.org/2000/xmlns/"
xmlns:x="http://www.w3.org/2000/xmlns/"
xmlns:xmlns="anything"
</code>```

possibly with spaces before and/or after the = sign, ' rather than ", etc.

The xmlns namespace name cannot be reused or redefined.  You'll have to correct the default namespace setting (change xmlns= to something else) or remove it.

Body:
For future reference/searchability, the Xerces error message for this problem is as follows:

[Fatal Error] try.xml:2:47: The prefix "xmlns" cannot be bound to any
  namespace explicitly; neither can the namespace for "xmlns" be bound
  to any prefix explicitly.

To resolve the problem, search the XML document for http://www.w3.org/2000/xmlns/.  Any of the following settings would be a violation:

xmlns="http://www.w3.org/2000/xmlns/"
xmlns:x="http://www.w3.org/2000/xmlns/"
xmlns:xmlns="anything"

possibly with spaces before and/or after the = sign, ' rather than ", etc.

The xmlns namespace name cannot be reused or redefined.  You'll have to correct the default namespace setting (change xmlns= to something else) or remove it.


问:
captcha or not?
i hate captcha, do you think there is a better solution </p>

答:
I have a a bogus form input (something like zip, or any other info that bots love to fill out but you really don't need) that has visibility: hidden; position: absolute. The motivation behind this is to get an input that is invisible to the user, but visible to the bot. So, whenever you get a request where that specific input is filled out, you know that it wasn't a human.

I use visibility: hidden; position: absolute so that it still uses up space, but doesn't clutter the design. This is for the bots that use more elaborate techniques to detect hidden inputs since, for JS, something isn't hidden if it takes up any amount space.

I haven't tested this technique on largely successful site as of yet, but it is still worth a try. Beware however that some Browsers (I am looking at you Safari/OSX!) that take info from your contact list and fills out all the input fields automatically (potentially even your hidden inputs) for you so you better check for bugs in that direction.

ContentLicense: CC BY-SA 2.5

Title: captcha or not?


问:
Android: Saving Preferences with multiple editTexts
I am trying to save the values the users put in the 3 editText fiels (editText1, editText2, editText3) so that they show up in the right field after the app restart.
Problem: Only the last value of editText3 gets saved in is filled in into the 3 fields after the restart.
What would be a workaround so that the values of the specific fields get saved and reloaded? </p>

答:
Solved it!</p>

```<code>public class MainActivity extends AppCompatActivity {
int sum = 0;
int ects = 0;
float mark = 0;
NumberFormat numberFormat = new DecimalFormat("0.00");
Button button1;
TextView textView1;
EditText editText1;
EditText editText2;
EditText editText3;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button1 = (Button)findViewById(R.id.button1);
    textView1 = (TextView)findViewById(R.id.textView1);
    editText1 = (EditText)findViewById(R.id.editTextGDI);
    editText2 = (EditText)findViewById(R.id.editTextGDW);
    editText3 = (EditText)findViewById(R.id.editTextProgrammieren1);
    loadSavedPreferences();

    button1.setOnClickListener(
            new Button.OnClickListener() {
                public void onClick(View v){

                    ViewGroup group = (ViewGroup)findViewById(R.id.activity_main);
                    for (int i = 0, count = group.getChildCount(); i < count; ++i) {
                        View view = group.getChildAt(i);
                        if (view instanceof EditText) {
                            if(view.equals(editText1) && !(editText1.getText().toString().matches(""))){ //GDI
                                System.out.println("edittext1");
                                ects += 5;
                                try{ sum += Integer.parseInt(editText1.getText().toString()) *5; } catch(NumberFormatException n){}
                            }
                            else if(view.equals(editText2)&& !(editText2.getText().toString().matches(""))){ //GDW
                                System.out.println("edittext2");
                                ects += 5;
                                try{ sum += Integer.parseInt(editText2.getText().toString()) *5; } catch(NumberFormatException n){}
                            }
                            else if(view.equals(editText3)&& !(editText3.getText().toString().matches(""))){
                                System.out.println("edittext3");
                                ects += 7;
                                try{ sum += Integer.parseInt(editText3.getText().toString()) *7; } catch(NumberFormatException n){}
                            }
                        }
                    }

                    mark = (float)sum / (float)ects;
                    textView1.setText(String.valueOf(numberFormat.format(mark)));
                    savePreferences("1", editText1.getText().toString());
                    savePreferences("2", editText2.getText().toString());
                    savePreferences("3", editText3.getText().toString());

                    sum = 0;
                    ects = 0;
                    mark = 0;
                }
            }
    );
}

private void loadSavedPreferences() {
    SharedPreferences sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(this);
    editText1.setText(sharedPreferences.getString("1", "YourName"));
    editText2.setText(sharedPreferences.getString("2", "YourName"));
    editText3.setText(sharedPreferences.getString("3", "YourName"));
}

private void savePreferences(String key, String value) {
    SharedPreferences sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString(key, value);
    editor.commit();
}
}
</code>```

Body:
Solved it!

public class MainActivity extends AppCompatActivity {
int sum = 0;
int ects = 0;
float mark = 0;
NumberFormat numberFormat = new DecimalFormat("0.00");
Button button1;
TextView textView1;
EditText editText1;
EditText editText2;
EditText editText3;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button1 = (Button)findViewById(R.id.button1);
    textView1 = (TextView)findViewById(R.id.textView1);
    editText1 = (EditText)findViewById(R.id.editTextGDI);
    editText2 = (EditText)findViewById(R.id.editTextGDW);
    editText3 = (EditText)findViewById(R.id.editTextProgrammieren1);
    loadSavedPreferences();

    button1.setOnClickListener(
            new Button.OnClickListener() {
                public void onClick(View v){

                    ViewGroup group = (ViewGroup)findViewById(R.id.activity_main);
                    for (int i = 0, count = group.getChildCount(); i < count; ++i) {
                        View view = group.getChildAt(i);
                        if (view instanceof EditText) {
                            if(view.equals(editText1) && !(editText1.getText().toString().matches(""))){ //GDI
                                System.out.println("edittext1");
                                ects += 5;
                                try{ sum += Integer.parseInt(editText1.getText().toString()) *5; } catch(NumberFormatException n){}
                            }
                            else if(view.equals(editText2)&& !(editText2.getText().toString().matches(""))){ //GDW
                                System.out.println("edittext2");
                                ects += 5;
                                try{ sum += Integer.parseInt(editText2.getText().toString()) *5; } catch(NumberFormatException n){}
                            }
                            else if(view.equals(editText3)&& !(editText3.getText().toString().matches(""))){
                                System.out.println("edittext3");
                                ects += 7;
                                try{ sum += Integer.parseInt(editText3.getText().toString()) *7; } catch(NumberFormatException n){}
                            }
                        }
                    }

                    mark = (float)sum / (float)ects;
                    textView1.setText(String.valueOf(numberFormat.format(mark)));
                    savePreferences("1", editText1.getText().toString());
                    savePreferences("2", editText2.getText().toString());
                    savePreferences("3", editText3.getText().toString());

                    sum = 0;
                    ects = 0;
                    mark = 0;
                }
            }
    );
}

private void loadSavedPreferences() {
    SharedPreferences sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(this);
    editText1.setText(sharedPreferences.getString("1", "YourName"));
    editText2.setText(sharedPreferences.getString("2", "YourName"));
    editText3.setText(sharedPreferences.getString("3", "YourName"));
}

private void savePreferences(String key, String value) {
    SharedPreferences sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString(key, value);
    editor.commit();
}
}


问:
Kendo Grid Export To Excel Currency formatting
I am trying to export my Kendo grid to excel. It works fine except the formatting is missing. I think it is because I am using a template.

The Telerik documentation explicitly states:

To format the cell values during the export of the Grid to Excel, set
  the format option of the cells.

I have tried this and it is not working:

```<code>columns: [
    {
        field: "EntryWage",
        headerTemplate: entryLevelWageColumnHeading + "<span name='EntryWage' class='k-icon k-i-close remove' style='float: right;'></span>",
        width: 125,
        attributes: { style: "text-align:right;" },
        format: "{0:c}",
        template: "#= (EntryWage != null) ? kendo.toString(EntryWage, 'C') : 'N/A' #"
    }];
</code>```

I also have this function (for excel grid defintiion):

```<code>    excelExport: function (e) {
        var sheet = e.workbook.sheets[0];
        var row = sheet.rows[0];
        $("#grid .k-grid-header .k-link").each(function (index) { //for each column header in the grid...
            row.cells[index].value = $(this).text(); //set cell text from grid column text
            row.cells[index].background = "#0070C0"; //set cell to "blue" color
        });
    },
</code>```

Do I need to parse each cell here? Am I doing something wrong? I would think this would be really simple, since the whole Export to Excel is straightforward??

答:
I ended up solving it similarly to Sandman's suggestion. I based my output format on the field name, from each column (input).

I also append the grid's column headers to the Excel column header row. It's a little sad Kendo doesn't already do this.

```<code>excelExport: function (e) {
    var sheet = e.workbook.sheets[0];
    var row = sheet.rows[0];

    //Excel output - create a header row
    $("#grid .k-grid-header .k-link").each(function (index) { //for each column header in the grid...
        row.cells[index].value = $(this).text(); //set cell text from grid column text
        row.cells[index].background = "#0070C0"; //set cell to "blue" color
    });

    //Excel output - column formatting
    var formatMask = null;
    for (var rowIndex = 1; rowIndex < sheet.rows.length; rowIndex++) { //begin on first row (skip header)
        row = sheet.rows[rowIndex];
        for (var cellIndex = 0; cellIndex < row.cells.length; cellIndex++) { //for each row, check each cell by field name
            switch (this.columns[cellIndex].field) {
                case "Field1":
                    formatMask = "###,##0";
                    break;
                case "Field2":
                    formatMask = "$#,##0";
                    break;
                case "Field3":
                    formatMask = "$#,##0";
                    break;
                case "Field4":
                    formatMask = "###,##0";
                    break;
                case "Field5":
                    formatMask = "###,##0";
                    break;
                case "Field6":
                    formatMask = "###,##0";
                    break;
                case "Field7":
                    formatMask = null;
                    row.cells[cellIndex].value = row.cells[cellIndex].value;
                    break;
                case "Field8":
                    formatMask = "###,##0";
                    break;
                case "Field9":
                    formatMask = "###,##0";
                    break;
                case "Field10":
                    formatMask = "###,##0";
                    break;
                case "Field11":
                    formatMask = "###,##0";
                    break;
                case "Field12":
                    if (row.cells[cellIndex].value === false) {
                        row.cells[cellIndex].value = "No";
                    } else {
                        row.cells[cellIndex].value = "Yes";
                    }
                    break;
                default:
                    break;
            }
            row.cells[cellIndex].format = formatMask; //apply column format mask
        }

    }
},
</code>```

Body:
I am trying to export my Kendo grid to excel. It works fine except the formatting is missing. I think it is because I am using a template.

The Telerik documentation explicitly states:

To format the cell values during the export of the Grid to Excel, set
  the format option of the cells.

I have tried this and it is not working:

columns: [
    {
        field: "EntryWage",
        headerTemplate: entryLevelWageColumnHeading + "",
        width: 125,
        attributes: { style: "text-align:right;" },
        format: "{0:c}",
        template: "#= (EntryWage != null) ? kendo.toString(EntryWage, 'C') : 'N/A' #"
    }];

I also have this function (for excel grid defintiion):

    excelExport: function (e) {
        var sheet = e.workbook.sheets[0];
        var row = sheet.rows[0];
        $("#grid .k-grid-header .k-link").each(function (index) { //for each column header in the grid...
            row.cells[index].value = $(this).text(); //set cell text from grid column text
            row.cells[index].background = "#0070C0"; //set cell to "blue" color
        });
    },

Do I need to parse each cell here? Am I doing something wrong? I would think this would be really simple, since the whole Export to Excel is straightforward??

Body:
I ended up solving it similarly to Sandman's suggestion. I based my output format on the field name, from each column (input).

I also append the grid's column headers to the Excel column header row. It's a little sad Kendo doesn't already do this.

excelExport: function (e) {
    var sheet = e.workbook.sheets[0];
    var row = sheet.rows[0];

    //Excel output - create a header row
    $("#grid .k-grid-header .k-link").each(function (index) { //for each column header in the grid...
        row.cells[index].value = $(this).text(); //set cell text from grid column text
        row.cells[index].background = "#0070C0"; //set cell to "blue" color
    });

    //Excel output - column formatting
    var formatMask = null;
    for (var rowIndex = 1; rowIndex < sheet.rows.length; rowIndex++) { //begin on first row (skip header)
        row = sheet.rows[rowIndex];
        for (var cellIndex = 0; cellIndex < row.cells.length; cellIndex++) { //for each row, check each cell by field name
            switch (this.columns[cellIndex].field) {
                case "Field1":
                    formatMask = "###,##0";
                    break;
                case "Field2":
                    formatMask = "$#,##0";
                    break;
                case "Field3":
                    formatMask = "$#,##0";
                    break;
                case "Field4":
                    formatMask = "###,##0";
                    break;
                case "Field5":
                    formatMask = "###,##0";
                    break;
                case "Field6":
                    formatMask = "###,##0";
                    break;
                case "Field7":
                    formatMask = null;
                    row.cells[cellIndex].value = row.cells[cellIndex].value;
                    break;
                case "Field8":
                    formatMask = "###,##0";
                    break;
                case "Field9":
                    formatMask = "###,##0";
                    break;
                case "Field10":
                    formatMask = "###,##0";
                    break;
                case "Field11":
                    formatMask = "###,##0";
                    break;
                case "Field12":
                    if (row.cells[cellIndex].value === false) {
                        row.cells[cellIndex].value = "No";
                    } else {
                        row.cells[cellIndex].value = "Yes";
                    }
                    break;
                default:
                    break;
            }
            row.cells[cellIndex].format = formatMask; //apply column format mask
        }

    }
},


问:
How can I get an LED to light on Google Assistant listening?
After a long research without any results, I'm trying my luck here. I recently got the GA SDK sample to work on my Raspberry Pi 3.

Now I would like to light my connected LED when the Assistant is listening. I know how to do this, but I don't know where to add the code for the LED in the Assistant sample code. The documentation on their website says it's in the grpc code, but I don't know any more than that.

Any advice on where to add the LED code?

答:
Look at the hotword sample here https://github.com/googlesamples/assistant-sdk-python/blob/master/google-assistant-sdk/googlesamples/assistant/library/hotword.py

You can use the events to write your GPIO logic to turn on/off the LED.
Something like this -

```<code>`def process_event(event):
    if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        print()
        GPIO.output(25,True)
    if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        print()
        GPIO.output(25,False)
    if (event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        print()`
</code>```

here's the documentation on the library- https://developers.google.com/assistant/sdk/reference/library/python/

Body:
Look at the hotword sample here https://github.com/googlesamples/assistant-sdk-python/blob/master/google-assistant-sdk/googlesamples/assistant/library/hotword.py

You can use the events to write your GPIO logic to turn on/off the LED.
Something like this -

`def process_event(event):
    if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        print()
        GPIO.output(25,True)
    if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        print()
        GPIO.output(25,False)
    if (event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        print()`

here's the documentation on the library- https://developers.google.com/assistant/sdk/reference/library/python/


问:
Error when I enter vagrant up: Gem::Requirement::BadRequirementError
I'm still too green on Vagrant and I don't know how to fix this error I'm getting when I attempt to do "vagrant up":

```<code>/opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:89:in `parse': Illformed requirement ["puphpet/ubuntu1604-x64"] (Gem::Requirement::BadRequirementError)
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `block in initialize'
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `map!'
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:268:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:268:in `block in find'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:267:in `map'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:267:in `find'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:167:in `block in machine_config'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:200:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:200:in `machine_config'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:45:in `machine'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:669:in `machine'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:177:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:201:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:201:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:183:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:183:in `with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/up/command.rb:131:in `install_providers'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/up/command.rb:85:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/cli.rb:42:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:308:in `cli'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/bin/vagrant:138:in `<main>'
</code>```

This is the Vagrantfile within this directory:

```<code># -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "base"
  config.vm.box_version = "puphpet/ubuntu1604-x64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network "myownnetwork", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "myownnetwork", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end
</code>```

As you see, I chose a box I already had created with puphpet called "puphpet/ubuntu1604-x64", but I also tried with the laravel Homestead box I also have installed. This is the list of my available boxes (vagrant box list):

```<code>hashicorp/precise32    (virtualbox, 1.0.0)
laravel/homestead      (virtualbox, 2.0.0)
puphpet/ubuntu1604-x64 (virtualbox, 20161102)
</code>```

Only thing I edited in Vagrantfile was to uncomment the network lines, and give the network a custom name. The box line was already uncommented because I did this:

```<code>vagrant init --box-version laravel/homestead
</code>```

and I later changed the laravel box for puphpet/ubuntu1604-x64 just to try it out, with same resulting error.

Any help?

答:
You're confusing config.vm.box and config.vm.box_version

You can just go with

```<code>config.vm.box = "puphpet/ubuntu1604-x64"
</code>```

but if you really need to specify a version for this box, you can indicate with the version param. You can read more about box_version in this part of the doc

```<code>config.vm.box_version = "20161102"
</code>```

Body:
I'm still too green on Vagrant and I don't know how to fix this error I'm getting when I attempt to do "vagrant up":

/opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:89:in `parse': Illformed requirement ["puphpet/ubuntu1604-x64"] (Gem::Requirement::BadRequirementError)
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `block in initialize'
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `map!'
    from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/requirement.rb:119:in `initialize'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:268:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:268:in `block in find'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:267:in `map'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/box_collection.rb:267:in `find'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:167:in `block in machine_config'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:200:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:200:in `machine_config'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/vagrantfile.rb:45:in `machine'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:669:in `machine'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:177:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:201:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:201:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:183:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/v2/command.rb:183:in `with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/up/command.rb:131:in `install_providers'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/up/command.rb:85:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/cli.rb:42:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:308:in `cli'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/bin/vagrant:138:in `'

This is the Vagrantfile within this directory:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "base"
  config.vm.box_version = "puphpet/ubuntu1604-x64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network "myownnetwork", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "myownnetwork", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

As you see, I chose a box I already had created with puphpet called "puphpet/ubuntu1604-x64", but I also tried with the laravel Homestead box I also have installed. This is the list of my available boxes (vagrant box list):

hashicorp/precise32    (virtualbox, 1.0.0)
laravel/homestead      (virtualbox, 2.0.0)
puphpet/ubuntu1604-x64 (virtualbox, 20161102)

Only thing I edited in Vagrantfile was to uncomment the network lines, and give the network a custom name. The box line was already uncommented because I did this:

vagrant init --box-version laravel/homestead

and I later changed the laravel box for puphpet/ubuntu1604-x64 just to try it out, with same resulting error.

Any help?

Body:
You're confusing config.vm.box and config.vm.box_version

You can just go with

config.vm.box = "puphpet/ubuntu1604-x64"

but if you really need to specify a version for this box, you can indicate with the version param. You can read more about box_version in this part of the doc

config.vm.box_version = "20161102"


问:
Add new items to a new list
I want to end up here with FAQData being a JSON string. First, I have this simple class:

```<code>public class FAQData
{
    public string FAQQuestion { get; set; }
    public string FAQAnswer { get; set; }
}
</code>```

And then, this is where I'm not sure how to handle it...

```<code>var faqData = JsonConvert.SerializeObject(new List<FAQData>
    {
        {
           FAQQuestion = "Question 1?",
           FAQAnswer = "This is the answer to Question 1."
        },
        {
           FAQQuestion = "Question 2?",
           FAQAnswer = "This is the answer to Question 2."
        },
    })
</code>```

Obviously the above syntax isn't correct.  I've been playing around and trying various google searched, but I can't seem to get there.  What I want is for FAQData JSON string result to look like this:

```<code>[
    {"FAQQuestion": "Question 1?", "FAQAnswer": "This is the answer to Question 1."},
    {"FAQQuestion": "Question 2?", "FAQAnswer": "This is the answer to Question 2."}
]
</code>```

答:
You forgot new FAQData():

```<code>JsonConvert.SerializeObject(new List<FAQData>
{
    new FAQData()
    {
        FAQQuestion = "Question 1?",
        FAQAnswer = "This is the answer to Question 1."
    },
    new FAQData()
    {
        FAQQuestion = "Question 2?",
        FAQAnswer = "This is the answer to Question 2."
    },
});
</code>```

Title: Add new items to a new list

Body:
I want to end up here with FAQData being a JSON string. First, I have this simple class:

public class FAQData
{
    public string FAQQuestion { get; set; }
    public string FAQAnswer { get; set; }
}

And then, this is where I'm not sure how to handle it...

var faqData = JsonConvert.SerializeObject(new List<FAQData>
    {
        {
           FAQQuestion = "Question 1?",
           FAQAnswer = "This is the answer to Question 1."
        },
        {
           FAQQuestion = "Question 2?",
           FAQAnswer = "This is the answer to Question 2."
        },
    })

Obviously the above syntax isn't correct.  I've been playing around and trying various google searched, but I can't seem to get there.  What I want is for FAQData JSON string result to look like this:

[
    {"FAQQuestion": "Question 1?", "FAQAnswer": "This is the answer to Question 1."},
    {"FAQQuestion": "Question 2?", "FAQAnswer": "This is the answer to Question 2."}
]

Body:
You forgot new FAQData():

JsonConvert.SerializeObject(new List<FAQData>
{
    new FAQData()
    {
        FAQQuestion = "Question 1?",
        FAQAnswer = "This is the answer to Question 1."
    },
    new FAQData()
    {
        FAQQuestion = "Question 2?",
        FAQAnswer = "This is the answer to Question 2."
    },
});


问:
Is there a downloadable Scipy file for Python 3.6
I have Python 3.6 and I was wondering if there is a downloadable scipy file for version 3.6. I opened up the command prompt and ran "py -m pip install scipy". And it just gives me an error. I know its not the pip because its already updated. When I did it for nltk and numpy it worked but it doesn't work for scipy. I read somewhere that you have to download and install 3.4 because scipy is not compatible with 3.6. Any answer would be very much appreciated thank you</p>

答:
This is not python 3.6 specific. There are official manylinux1 and macOS wheels on pypi, so pip install should pick them. On Windows, you can use Christoph Gohlke wheels,

http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

Or, as others noted, there are prebuilt packages for python 3.6 in the conda-land.


问:
How to bundle Swagger generated code with webpack
I'm creating a new webApp that needs to communicate with the server using a REST API. I want to use Swagger to define the REST API and to generate the code for the server and the Javascript client (a simple webapp running in a browser).

I was able to implement the server (using a Java servlet) and it works.

I have generated the code for the Javascript client but I'm not able to make it works (I'm a very beginner in Javascript, webpack, nom...).

I want to use webpack to generate a .js file that will be loaded by the webapp, this .js will contain the code generated by swagger and my code to send the query using Swagger (... and a UI!).

Here is my project organisation:

```<code>/
 - package.json
 - node_modules (modules installed with npm)
 - src
   ---> /main.js (code I have written to send the REST API query using Swagger generated code)
   ---> /index.js (code generated by Swagger)
   ---> /ApiClient.js (code generated by Swagger)
   ---> /api (folder that contains code generated by Swagger)
   ---> /model (folder that contains code generated by Swagger)
 - webpack.config.js
 - runTest  ---> - bundle.js (generated by webpack)  ---> - index.html
</code>```

When I execute the webpack command I get some errors:

./node_modules/.bin/webpack --config webpack.config.js

Hash:
  a77095b323ec225f9b17 Version: webpack 2.6.1 Time: 396ms
      Asset     Size  Chunks             Chunk Names bundle.js  6.48 kB       0  [emitted]  main    [0] ./src/index.js 2.61 kB {0} [built]    [1]
  ./src/main.js 212 bytes {0} [built]

ERROR in ./src/index.js Module not found: Error: Can't resolve
  'ApiClient' in
  '/Users/sebastien/Documents/Javascript/Stackoverflow/superagenttest/src'
  @ ./src/index.js 17:4-86  @ ./src/main.js

ERROR in ./src/index.js Module not found: Error: Can't resolve
  'model/Error' in
  '/Users/sebastien/Documents/Javascript/Stackoverflow/superagenttest/src'
  @ ./src/index.js 17:4-86  @ ./src/main.js

My main.js contains the following:

```<code>var MyMetadataApi = require('./index'); // See note below*.
var xxxSvc = new MyMetadataApi.defaultApi(); // Allocate the API class we're going to use.
var zzz = xxxSvc.myFieldsGet(); // Invoke the service.
</code>```

index.js (generated by Swagger contains)

```<code>(function(factory) {
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['ApiClient', 'model/Error', 'model/MyField', 'api/DefaultApi'], factory);
  } else if (typeof module === 'object' && module.exports) {
    // CommonJS-like environments that support module.exports, like Node.
    module.exports = factory(require('./ApiClient'), require('./model/Error'), require('./model/MyField'), require('./api/DefaultApi'));
  }
}(function(ApiClient, Error, MyField, DefaultApi) {
  'use strict';

  /**
   * get_My_fields.<br>
   * The <code>index</code> module provides access to constructors for all the classes which comprise the public API.
   * <p>
   * An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
   * ```
   * var MyMetadataApi = require('index'); // See note below*.
   * var xxxSvc = new MyMetadataApi.XxxApi(); // Allocate the API class we're going to use.
   * var yyyModel = new MyMetadataApi.Yyy(); // Construct a model instance.
   * yyyModel.someProperty = 'someValue';
   * ...
   * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
   * ...
   * ```
   * <em>*NOTE: For a top-level AMD script, use require(['index'], function(){...})
   * and put the application logic within the callback function.</em>
   * </p>
   * <p>
   * A non-AMD browser application (discouraged) might do something like this:
   * ```
   * var xxxSvc = new MyMetadataApi.XxxApi(); // Allocate the API class we're going to use.
   * var yyy = new MyMetadataApi.Yyy(); // Construct a model instance.
   * yyyModel.someProperty = 'someValue';
   * ...
   * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
   * ...
   * ```
   * </p>
   * @module index
   * @version 1.0.0
   */
  var exports = {
    /**
     * The ApiClient constructor.
     * @property {module:ApiClient}
     */
    ApiClient: ApiClient,
    /**
     * The Error model constructor.
     * @property {module:model/Error}
     */
    Error: Error,
    /**
     * The MyField model constructor.
     * @property {module:model/MyField}
     */
    MyField: MyField,
    /**
     * The DefaultApi service constructor.
     * @property {module:api/DefaultApi}
     */
    DefaultApi: DefaultApi
  };

  return exports;
}));
</code>```

How can I make webpack generating a bundle.js that will successfully contain the code generated by Swagger and and my main.js ?

I'm lost with import/require... I have tried to replaced the require() with some import but without any success (or it can read the index.js but then find issues in index.js because it cannot import the ApiClient.js).
What is AMD and CommonJS application are mentioned by the code generated by Swagger?

Any help would be appreciated ;-)
Thanks,

Sebastien

答:
I found a solution, I need to add the following in my webpack.config.js

```<code>module: {
  rules: [
    {
      test: /my_client\/.*\.js$/,
      use: 'imports-loader?define=>false'
    }
  ]
},
node: {
  fs: 'empty'
}
</code>```

I found this fix in the swagger-codegen GitHub repository: https://github.com/swagger-api/swagger-codegen/issues/3336

Body:
I'm creating a new webApp that needs to communicate with the server using a REST API. I want to use Swagger to define the REST API and to generate the code for the server and the Javascript client (a simple webapp running in a browser).

I was able to implement the server (using a Java servlet) and it works.

I have generated the code for the Javascript client but I'm not able to make it works (I'm a very beginner in Javascript, webpack, nom...).

I want to use webpack to generate a .js file that will be loaded by the webapp, this .js will contain the code generated by swagger and my code to send the query using Swagger (... and a UI!).

Here is my project organisation:

/
 - package.json
 - node_modules (modules installed with npm)
 - src
   ---> /main.js (code I have written to send the REST API query using Swagger generated code)
   ---> /index.js (code generated by Swagger)
   ---> /ApiClient.js (code generated by Swagger)
   ---> /api (folder that contains code generated by Swagger)
   ---> /model (folder that contains code generated by Swagger)
 - webpack.config.js
 - runTest  ---> - bundle.js (generated by webpack)  ---> - index.html

When I execute the webpack command I get some errors:

./node_modules/.bin/webpack --config webpack.config.js

Hash:
  a77095b323ec225f9b17 Version: webpack 2.6.1 Time: 396ms
      Asset     Size  Chunks             Chunk Names bundle.js  6.48 kB       0  [emitted]  main    [0] ./src/index.js 2.61 kB {0} [built]    [1]
  ./src/main.js 212 bytes {0} [built]

ERROR in ./src/index.js Module not found: Error: Can't resolve
  'ApiClient' in
  '/Users/sebastien/Documents/Javascript/Stackoverflow/superagenttest/src'
  @ ./src/index.js 17:4-86  @ ./src/main.js

ERROR in ./src/index.js Module not found: Error: Can't resolve
  'model/Error' in
  '/Users/sebastien/Documents/Javascript/Stackoverflow/superagenttest/src'
  @ ./src/index.js 17:4-86  @ ./src/main.js

My main.js contains the following:

var MyMetadataApi = require('./index'); // See note below*.
var xxxSvc = new MyMetadataApi.defaultApi(); // Allocate the API class we're going to use.
var zzz = xxxSvc.myFieldsGet(); // Invoke the service.

index.js (generated by Swagger contains)

(function(factory) {
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['ApiClient', 'model/Error', 'model/MyField', 'api/DefaultApi'], factory);
  } else if (typeof module === 'object' && module.exports) {
    // CommonJS-like environments that support module.exports, like Node.
    module.exports = factory(require('./ApiClient'), require('./model/Error'), require('./model/MyField'), require('./api/DefaultApi'));
  }
}(function(ApiClient, Error, MyField, DefaultApi) {
  'use strict';

  /**
   * get_My_fields.

   * The index module provides access to constructors for all the classes which comprise the public API.
   *

   * An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
   *

   * var MyMetadataApi = require('index'); // See note below*.
   * var xxxSvc = new MyMetadataApi.XxxApi(); // Allocate the API class we're going to use.
   * var yyyModel = new MyMetadataApi.Yyy(); // Construct a model instance.
   * yyyModel.someProperty = 'someValue';
   * ...
   * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
   * ...
   *

   * *NOTE: For a top-level AMD script, use require(['index'], function(){...})
   * and put the application logic within the callback function.
   *

   *

   * A non-AMD browser application (discouraged) might do something like this:
   *

   * var xxxSvc = new MyMetadataApi.XxxApi(); // Allocate the API class we're going to use.
   * var yyy = new MyMetadataApi.Yyy(); // Construct a model instance.
   * yyyModel.someProperty = 'someValue';
   * ...
   * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
   * ...
   *

   *

   * @module index
   * @version 1.0.0
   */
  var exports = {
    /**
     * The ApiClient constructor.
     * @property {module:ApiClient}
     */
    ApiClient: ApiClient,
    /**
     * The Error model constructor.
     * @property {module:model/Error}
     */
    Error: Error,
    /**
     * The MyField model constructor.
     * @property {module:model/MyField}
     */
    MyField: MyField,
    /**
     * The DefaultApi service constructor.
     * @property {module:api/DefaultApi}
     */
    DefaultApi: DefaultApi
  };

  return exports;
}));

How can I make webpack generating a bundle.js that will successfully contain the code generated by Swagger and and my main.js ?

I'm lost with import/require... I have tried to replaced the require() with some import but without any success (or it can read the index.js but then find issues in index.js because it cannot import the ApiClient.js).
What is AMD and CommonJS application are mentioned by the code generated by Swagger?

Any help would be appreciated ;-)
Thanks,

Sebastien

Body:
I found a solution, I need to add the following in my webpack.config.js

module: {
  rules: [
    {
      test: /my_client\/.*\.js$/,
      use: 'imports-loader?define=>false'
    }
  ]
},
node: {
  fs: 'empty'
}

I found this fix in the swagger-codegen GitHub repository: https://github.com/swagger-api/swagger-codegen/issues/3336


问:
I want to change a column of month numbers in a dataframe to month name (pyspark)
I have a column of month numbers in a dataframe and want to change it to month name, so I used this:

```<code>df['monthName'] = df['monthNumber'].apply(lambda x: calendar.month_name[x])
</code>```

But it throws me the following error:

TypeError: 'Column' object is not callable

Please suggest me what are the ways to resolve this. I am new to python and spark

Edit1: I m using Spark 2.1.1 and Python 2.7.6

This is my code for Airline data Analysis.

```<code>df_withDelay = df_mappedCarrierNames.filter(df_mappedCarrierNames.ArrDelay > 0)
sqlContext.registerDataFrameAsTable(df_withDelay,"SFO_ArrDelayAnalysisTable")
df_SFOArrDelay = sqlContext.sql \
                      ("select sfo.Month, sum(sfo.ArrDelay) as TotalArrivalDelay \
                      from SFO_ArrDelayAnalysisTable sfo \
                      where (sfo.Dest = 'SFO') \
                      group by sfo.Month")
</code>```

I am trying to plot a graph with Month vs ArrDelay. From the above code I am getting Month as number. So I tried with the below option

```<code>udf = UserDefinedFunction(lambda x: calendar.month_abbr[int(x)], StringType())
new_df_mappedCarrierNames = df_mappedCarrierNames.select(*[udf(column).alias(name) if column == name else column for column in df_mappedCarrierNames.columns])
</code>```

it works but, in my graph it's not in sorted order. whereas if I use the month numbers, it is in sorted order. My issue is in finding out how to map month numbers to month names in sorted order from Jan to dec.
Thanks in advance for the replies.

答:
Here is the clean solution:

```<code>from pyspark.sql.functions import UserDefinedFunction
from pyspark.sql.types import StringType

#1
month_lst = ['January', 'Feburary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
#2
df = sqlContext.createDataFrame( [(1, "a", 23.0), (3, "B", -23.0)], ("x1", "x2", "x3"))

name = 'x1'
#3
udf = UserDefinedFunction(lambda x: month_lst[int(x%12) - 1], StringType())
new_df = df.select(*[udf(column).alias(name) if column == name else column for column in df.columns])
</code>```

1

You build a dictionary

2

Define a dataframe and select the column
3
month_lst[int(x%12) - 1] This Is the important part, where i only assume the input is a float, and return a value from the list

If you need more help, pleas add a comment,

Body:
I have a column of month numbers in a dataframe and want to change it to month name, so I used this:

df['monthName'] = df['monthNumber'].apply(lambda x: calendar.month_name[x])

But it throws me the following error:

TypeError: 'Column' object is not callable

Please suggest me what are the ways to resolve this. I am new to python and spark

Edit1: I m using Spark 2.1.1 and Python 2.7.6

This is my code for Airline data Analysis.

df_withDelay = df_mappedCarrierNames.filter(df_mappedCarrierNames.ArrDelay > 0)
sqlContext.registerDataFrameAsTable(df_withDelay,"SFO_ArrDelayAnalysisTable")
df_SFOArrDelay = sqlContext.sql \
                      ("select sfo.Month, sum(sfo.ArrDelay) as TotalArrivalDelay \
                      from SFO_ArrDelayAnalysisTable sfo \
                      where (sfo.Dest = 'SFO') \
                      group by sfo.Month")

I am trying to plot a graph with Month vs ArrDelay. From the above code I am getting Month as number. So I tried with the below option

udf = UserDefinedFunction(lambda x: calendar.month_abbr[int(x)], StringType())
new_df_mappedCarrierNames = df_mappedCarrierNames.select(*[udf(column).alias(name) if column == name else column for column in df_mappedCarrierNames.columns])

it works but, in my graph it's not in sorted order. whereas if I use the month numbers, it is in sorted order. My issue is in finding out how to map month numbers to month names in sorted order from Jan to dec.
Thanks in advance for the replies.

Body:
Here is the clean solution:

from pyspark.sql.functions import UserDefinedFunction
from pyspark.sql.types import StringType

#1
month_lst = ['January', 'Feburary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
#2
df = sqlContext.createDataFrame( [(1, "a", 23.0), (3, "B", -23.0)], ("x1", "x2", "x3"))

name = 'x1'
#3
udf = UserDefinedFunction(lambda x: month_lst[int(x%12) - 1], StringType())
new_df = df.select(*[udf(column).alias(name) if column == name else column for column in df.columns])

1

You build a dictionary

2

Define a dataframe and select the column
3
month_lst[int(x%12) - 1] This Is the important part, where i only assume the input is a float, and return a value from the list

If you need more help, pleas add a comment,