Tuesday, 8 April 2014

Python: check if a twine contains during slightest one of a strings in a list

I'm perplexing to do a relating controlling python.I have a list of twine
(len~3000), and a file, and we wish to check if for any line in a file, it
has during slightest one of a strings in a list.The many loyal
disrespectful proceed is to check one by one, though it takes time (not
that prolonged though).Is there a proceed that we can hunt that faster?For
example:list = ["aq", "bs", "ce"]if a line is "aqwerqwerqwer" -> loyal
(since has "aq" in it)if a line is "qweqweqwe" -> fake (has zero of "aq",
"bs" or "ce")

Friday, 4 April 2014

Emgu.CV.CvInvoke' threw an exception

I am perplexing to use EMGUCV for C#. Currently i have hallowed Visual
Studio 2010 demonstrate Edition. When perplexing to govern some
rudimentary commands a Emgu.CV.CvInvoke threw an difference came out so i
put a unmanaged formula in a exe folder. But still it continued to give me
a error. So i attempted adding a unmanaged formula to fortitude
path-finder and still it is giving me this error. Is there anything else
that i can do so i can finally use emguCV?The difference is
System.TypeInitializationException was unhandled Message=The form
initializer for 'Emgu.CV.CvInvoke' threw an exception.having smoke-stack
trace: during Emgu.CV.CvInvoke.cvCreateCameraCapture(Int32 index)
during Emgu.CV.Capture..ctor(Int32 camIndex) in C:\Program Files
(x86)\Emgu\libemgucv-windows-x64-2.2.1.1150\Emgu.CV\Capture\Capture.cs:line
105 during Emgu.CV.Capture..ctor() in C:\Program Files
(x86)\Emgu\libemgucv-windows-x64-2.2.1.1150\Emgu.CV\Capture\Capture.cs:line
93 during cameraWorks.Form1.camButton_Click(Object sender, EventArgs e)
in C:\Users\Adrian\documents\visual studio
2010\Projects\cameraWorks\cameraWorks\Form1.cs:line 38 during
System.Windows.Forms.Control.OnClick(EventArgs e) during
System.Windows.Forms.Button.OnClick(EventArgs e) during
System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) during
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,
Int32 clicks) during System.Windows.Forms.Control.WndProc(Message& m)
during System.Windows.Forms.ButtonBase.WndProc(Message& m) during
System.Windows.Forms.Button.WndProc(Message& m) during
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
during System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m) during System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) during
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
during
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData) during
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) during
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context) during
System.Windows.Forms.Application.Run(Form mainForm) during
cameraWorks.Program.Main() in C:\Users\Adrian\documents\visual studio
2010\Projects\cameraWorks\cameraWorks\Program.cs:line 18 during
System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[]
args) during System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args) during
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() during
System.Threading.ThreadHelper.ThreadStart_Context(Object state) during
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state, Boolean ignoreSyncCtx) during
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state) during
System.Threading.ThreadHelper.ThreadStart()InnerException:
InnerException: System.BadImageFormatException Message=An try was
finished to bucket a way with an crude format. (Exception from HRESULT:
0x8007000B) Source=Emgu.CV StackTrace: during
Emgu.CV.CvInvoke.cvRedirectError(CvErrorCallback errorHandler, IntPtr
userdata, IntPtr prevUserdata) during
Emgu.CV.CvInvoke..cctor() in C:\Program Files
(x86)\Emgu\libemgucv-windows-x64-2.2.1.1150\Emgu.CV\PInvoke\CvInvoke.cs:line
50I am wholly executing some rudimentary formula being:public biased
category Form1 : Form{ private Capture capture; private bool
captureInProgress; open Form1() { InitializeComponent(); }
private vacant ProcessFrame(Object sender, EventArgs args ) {
Image ImageFrame = capture.QueryFrame(); CamImageBox1.Image =
ImageFrame; } private vacant camButton_Click(object sender,
EventArgs e) { if (capture == null) { try
{ constraint = new Capture(); }
locate (NullReferenceException excpt) {
MessageBox.Show(excpt.Message); } } if (capture
!= null) { if (captureInProgress) {
camButton.Text = "start"; } else {
camButton.Text = "stop"; Application.Idle +=
ProcessFrame; } captureInProgress =
!captureInProgress; } } private vacant ReleaseData() {
if (capture != null) { capture.Dispose(); }
}The examples of emguCV work on my computer.Thanks Alot Adrian

Tuesday, 1 April 2014

JAX-RS jersey 2.6 usign FormDataMultiPart throws exception

My server formula throws java.lang.IllegalStateException: Stream
already closedat
org.jvnet.mimepull.DataHead$ReadMultiStream.fetch(DataHead.java:232)at
org.jvnet.mimepull.DataHead$ReadMultiStream.read(DataHead.java:207)at
sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)at
sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)at
sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)Truncated. see record
record for finish stacktraceserver formula
@PUT@Consumes(MediaType.MULTIPART_FORM_DATA)public vacant
updateCI(FormDataMultiPart formParams){ FormDataBodyPart f =
formParams.getField("myfile");
handleInputStream(f.getValueAs(InputStream.class)); ..... private
vacant handleInputStream(InputStream is) { BufferedReader br = null;
StringBuilder sb = new StringBuilder(); String line; try { br
= new BufferedReader(new InputStreamReader(is)); while ((line =
br.readLine()) != null) { sb.append(line); } } locate
(IOException e) { e.printStackTrace(); } finally { if (br
!= null) { try { br.close(); } locate
(Exception e) { e.printStackTrace(); } }
} System.out.println("File Content");
System.out.println(sb);client formula final FileDataBodyPart
filePart = new FileDataBodyPart("myfile",
new File("C:\\testing.txt")) final FormDataMultiPart multipart =
new FormDataMultiPart().field("xml", "xmlstring");
multipart.bodyPart(filePart); Response response = target.request()
.put(Entity.entity(multipart, multipart.getMediaType()));I am
controlling jersey2.6, jersey-media-multipart 2.6, mimepull 1.9.4 (alse
attempted with 1.9.3)Servlet enclosing 2.5. JDK 1.6I have registerd in
ResourceConfig register(MultiPartFeature.class)Am we blank
something?