w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
How do I attach a second process when the debugger starts?
I did find an answer to this, it's a hacky solution methinks, but if someone comes along with a better answer I'd love to hear it. In essence you attach the debugger before the debugger actually starts running. Consider: internal class DebugEventMonitor { // DTE Events are strange in that if you don't hold a class-level reference // The event handles get silently garbage collected. Cool! private DTEEvents dteEvents; public DebugEventMonitor() { // Capture the DTEEvents object, then monitor when the 'Mode' Changes. dteEvents = DTE.Events.DTEEvents; this.dteEvents.ModeChanged += dteEvents_ModeChanged; } void dteEvents_ModeChanged(vsIDEMode LastMode) { // Attach to the process when the mode changes (but before th

Categories : C#

echo starts a sub-shell in a parallel process?
You got a race condition here. tail -100 | tee $STDERR is created, but most probably sleeps on the fifo (since it is still empty then). You programs writes to fifo ('something') but the fifo has buffers, so it writes all and continues. Then at some unspecific time the tail/tee is woken up - sometimes too late: That means $STDERR is still empty when cat reads it. How to fix it: You can't easily synchronize on tee/tail having finished. Use { something; } 2>&1 | tail ... | tee You need some other way to telegraf $? out of {something}. I'll come back on this. One way is, to set set -o pipefail so that every failing component in the pipline sets the exit status of the pipeline. Another way is to query the array PIPESTATUS (see bash(1)). Hope this helps

Categories : Linux

Block of code that I need to run everytime my servlet container starts up
I would suggest following: Put this code in the init() of a Servlet. Configure this servlet in web.xml. You can decide the order of loading (<load-on-startup/>) this servlet relative to other servlets. When the container loads, it initializes the servlet and calls its init() method executing the initialization code.

Categories : Java

I want to replace content inside a String which starts with # if it starts with !# it must skip it
Use a negative lookbehind? String test = "Hello #Admin Welcome this is Your welcome page !#Admin This is #Admin"; String out = test.replaceAll("(?<!!)#Admin", "MyAdministrator"); System.out.println("OutPut: "+out); The lookbehind is (?<!!).

Categories : Java

part-1 persistent foreGround android service that starts by UI, works at sleep mode too, also starts at phone restart
If you start a service with startService(), it will keep running even when the Activity closes. It will only be stopped when you call stopService(), or if it ever calls stopSelf() (or if the system kills your process to reclaim memory). To start the service on boot, make a BroadcastReceiver that just starts the service: public class MyReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Intent service = new Intent(context, MyService.class); context.startService(service); } } Then add these to your manifest: <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <application ... > <receiver android:name="MyReceiver" android:enabled="false" > <intent-filter>

Categories : Android

part-2 persistent foreGround android service that starts by UI, works at sleep mode too, also starts at phone restart
If you only need to run this code every 15 minutes. then you really don't need to keep the service running 24/7. Really, don't do it, it is bad idea. what you need to do is this: Use AlarmManager to schedule an alarm every 15 minutes. this alarm is then catched with a BroadcastReceiver. This alarm HAS TO BE RTC_WAKE_UP so that it wakes the phone up if it is in deep sleep and it has to be real time since it will use the deep sleep timer. Broadcast receiver will have to start a service. now this call to the service has to be done like this: 2.1 get a wakelock in the BroadcastReceiver and acquire() it. 2.2 start a IntenetService (This type of services start and end themselves after work is done) 2.3 release the wakelock in the service There is a good example of how to implement this he

Categories : Android

Windows Service starts then immediately stops (code issue?)
Enable WCF tracing to see detail about issue. <configuration> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true"> <listeners> <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "c:logTraces.svclog" /> </listeners> </source> </sources> </system.diagnostics> </configuration> For detail on WCF configuration see MSDN. EDIT based on new info: it is not able to find WCF service endpoint configuration in App.Config file, see http://msdn.microsoft.com/

Categories : C#

This JavaScript code is executed every time Chrome starts up. My antivirus says it's a trojan. What is it doing?
This code adds the following script tag to your document. Beware it is indeed a site with malicious software. <script src="http://disable-instant-search.com/js/disable.js?type=live&amp;user-agent=.....;gsu=...."></script> And it does not relate Chrome Update Manager. If something is in your chrome directory, that does not mean it actually belongs to Google or Chrome. It may have been put there but other viruses on you machine

Categories : Javascript

App starts when Windows starts but can't access a file?
Actually, you not checking and not opening the same file (you're passing absolute path to File.Exists and relatively path to File.ReadAllLines), if the current directory is different from Path.GetDirectoryName(Application.ExecutablePath), which is the case when you start your program on boot (I guess it should be %WINDIR%System32, but I am not sure - however, it is definitively not your application folder). String savepath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), SaveFile); if (File.Exists(savepath)) LoadState(); String[] lines = File.ReadAllLines(SaveFile); should be String savepath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), SaveFile); if (File.Exists(savepath)) LoadState(); String[] lines = File.ReadAllLines(savepath); It will

Categories : C#

Python - multi-process code returns results to a queue successfully, but the code stops
This code is an infinite loop: l=[] while True: try: l+=outputQueue.get() # Code seems to stick here after about 3-4 iterations except: break The calls to get() are blocking, i.e. it will wait until you send in something. In your case, when the processes end the loop does another call to get() that never returns. Since you know the number of processes you can simply do that number of get()s: l = sum((outputQueue.get() for _ in range(t)), []) If a process can push a variable number of results, then you can send a sentinel value when the worker finishes(e.g. None). The process that collects the output can count how many sentinel it has received, and eventually stop querying the queue.

Categories : Python

code is executed long time when app starts first time
You probably can't rollback Windows. A better alternative would be to use VMware or another virtual machine software, and just keep recopying the disk file. If you start up a process which uses a lot of RAM and CPU (something like Prime95) you will be able to really slow down your machine. You are basically loading a bunch of separate DLLs in this function. To make it appear faster, create and run this function on a background thread. This will initialize all the classes. Then, when the user needs it, all of the DLLs will already be loaded into memory, making the function feel much faster.

Categories : Dotnet

PHP process the code without decode it
OK. After I referring to this post, I understand it is PHP string type. http://www.php.net/language.types.string Escaped characters in double quote [0-7]{1,3} : the sequence of characters matching the regular expression is a character in octal notation x[0-9A-Fa-f]{1,2} : the sequence of characters matching the regular expression is a character in hexadecimal notation hexadecimal can refer from here: http://www.ascii.cl/

Categories : PHP

Anyway to run C# code in remote process(E.g. IIS)
If it's a web application and you're dealing with unhandled exceptions, you can add logging into global.asax; it may or may not help but seems like it will give you more insight than what you have so far. Now, technically speaking, one can argue that modifying global.asax is modifying production code, but I took your question to mean that you don't want to go and modify hundreds of places in production code, etc.

Categories : C#

How do I get Process ID from HWND using managed VB.net code?
No, this isn't wrapped by .NET. But there's absolutely nothing wrong with calling the native API functions. That's what the framework does internally, and that's why P/Invoke was invented, to make it as simple as possible for you to do this yourself. I'm not really sure why you're seeking to avoid it. Of course, I would recommend using the new-style declaration, which is the more idiomatic way of doing things in .NET (rather than the old VB 6 way): <DllImport("user32.dll", SetLastError:=True)> _ Private Shared Function GetWindowThreadProcessId(ByVal hWnd As IntPtr, _ ByRef lpdwProcessId As Integer) As Integer End Function Your other option, if you absolutely cannot get over the irrational compulsion to stay with managed code, is to make use of the Process class. This can be u

Categories : Vb.Net

Ruby MRI 1.8.7: Spawn process directly in code?
fork is the only way to do this. However, on Linux at least, and I think on OSX too, fork is implemented as copy on write, meaning that until an area of memory is written to in the child process, it points directly to the area of the old parent process. So, no problem. Edit: Nevermind. The above is wrong. Here's what I would do: code = "puts 'hi'" result = nil popen("ruby") do |pipe| pipe.puts code pipe.close_write result = pipe.read end

Categories : Ruby

Which of code will process faster PHP comments? Ideas?
A comment is eliminated at lexing time, and thus their contents are irrelevant, especially in your benchmark above. If two multi-line comments in a file are the same amount of bytes in total, they'll have the exact same effect on PHP. A comment that's larger will take more time to be processed in full, and then discarded, but still, we're talking about the lexing phase, which is so fast that you'll need a single comment that's gigabytes in size vs. a few bytes comment to notice a difference. If you use an op-code cache (or simply run PHP 5.5+ as an Apache module or FCGI, where there's now a built in op-code cache), you'll see zero difference, since the idea of an op-code cache is to make it so that lexing and parsing is done only once. If you insist on doing a test, at least do it from

Categories : PHP

when java jvm compiles bytecode, where does that code go in process space?
Firstly, what you are describing is JIT - specifically how it works in Hotspot To answer your question about where the code is saved at runtime - it's in the process heap and the pointers to the method code in the object's Klass file is updated to point to it. There's also something called OSR (on stack replacement) for compiling long running loops directly on the stack.

Categories : Java

Windows Code-Signing process & alternative to MS signtool.exe?
There is kSign, and their blog also has an article about how to integrate with Inno Setup. It is not a complete replacement for signtool (i.e. it won't sign .cat and .sys files involved in signing driver packages) but it will will digitally sign EXE,DLL,COM,CAB and OCX files.

Categories : Misc

Process generated DOM code using jquery after $http Angular.js
I suggest you use $timeout like this: $timeout(function(){ console.log($player.find('li').length); }); This will basically make your call happen only once Angular has finished generating the new DOM structure. Also $timeout has to be injected in the controller just like $http so your controller declaration should lokk like: function Player($scope, $http, $timeout) {

Categories : Javascript

Titanium 3.1.0 - Emulator process exited with code 1 - Can't compile APK
Did you read System Requirements? From Documentation: For Windows, the 32-bit version of Java JDK is required regardless of whether Titanium is running on a 32-bit or 64-bit system. Try to install additional 32bit version of Java (without removing the 64bit) and set the system variable. May be this will help you.

Categories : Android

Integrating MaltParser into java code, without using a separate process
I found a rudimentary solution to 2. I noticed that on http://www.maltparser.org/userguide.html#api it directs one to a listing of example files. I took this snippet out of one of those files: /** * @author Johan Hall */ public static void main(String[] args) { try { MaltParserService service = new MaltParserService(); // Inititalize the parser model 'model0' and sets the working directory to '.' and sets the logging file to 'parser.log' service.initializeParserModel("-c model0 -m parse -w . -lfi parser.log"); // Creates an array of tokens, which contains the Swedish sentence 'Grundavdraget upphör alltså vid en taxerad inkomst på 52500 kr.' // in the CoNLL data format. String[] tokens = new String[11]; tokens[0] = "1 Grunda

Categories : Java

Waiting until a process is complete to execute a line of code
You could change GetCurrentCity().execute(); into a Thread. If so, you could: Thread blah= GetCurrentCity(); blah.run(); blah.join(); if(!(strReturnedAddress == null)){ test.setText(strReturnedAddress); } But that would be self-defeating (like the comments indicate)

Categories : Java

Rails + Ajax: How to process a JS code after clicking on an element?
Could anyone give me some tips how to do that? If you want the server side to be aware of what the client side is doing, then you need to make the client side send the server side a message. You can do that with ajax. So after your filepicker.remove() line, insert a jquery ajax call.

Categories : Javascript

how shared libraries reduces the space used by process ( data, code, etc)?
I believe that in the first case the linker is statically linking the libraries into the executable, and thus making it larger. An advantage of this, however, is that users of your program will not need to have to make sure that they have certain libraries that your program uses, since the libraries are packaged in your compiled binary. In your second case, it is using shared libraries, and so the libraries don't have to be packaged in the executable. Your program tries to find the libraries when it starts.

Categories : C

Child process in node.js mysteriously exiting between lines of synchronous code
You are missing a } after finally, but I very seriously doubt that has anything to do with it and was probably just a copy past error. It looks to me like you might possibly be exiting the program before stdout can be flushed. There used to be a flush call you could explicitly make in older node versions, but not anymore. Read this thread where people are having very similar issues to yours: https://github.com/joyent/node/issues/1669 This seems hard to believe based on the fact you are doing a readFileSync call after that, but I suppose it's still possible. One thing you could do to test it is to simply set a timeout before both your writes for something ridiculous like 5 seconds. This will keep the program alive for 5 seconds, more than enough time for any console logs to get flushe

Categories : Node Js

how do I process dynamically generated javascript code with PHP and send the result as an email?
1- Add a <form> tag before #p_scents so all the new <input type="text" ... are inside the form. Close the tag after #p_scents with ` and add a submit button or javascript function. In the form action you can add the same name of the file you are in (assuming it can handle php), otherwise create a php file. 2- Then you need to create a foreach loop in the php file to search for all the inputs. Colect them with $_POST. You can do this way: When you add new fields you can just keep them identicall and serialize them. Use name="p_scnt[]" in all input fields. The one already in the html and identical for all the generated by javascript. This will serialize them. In the php file use: foreach($_POST["p_scnt"] as $value) { … }, inside the { } you can writhe your php code. 3- About

Categories : PHP

Exit code when a process is invoked by "START" command and is killed by TASKKILL
Simply don't use START. Launch the child process directly. Execution in the parent will block until the child is finished. Prefer IPC::System::Simple over the built-in core function system.

Categories : Windows

Is it possible to do the "right-click, add, new-item" process in Visual Studio 2012's solution explorer, exclusively through code?
Try using Dynamic compiling and another article.

Categories : C#

How to structure the code to process multiple variables from mulitple form elements in JavaScript and remember the choices?
Maybe use jquery.form.js? http://malsup.com/jquery/form/ It's a great plugin, just structure the form like it was a normal redirection form, add array in name of checkboxes <input type="checkbox" name="types[]" value="21" />Beachfront Add target URL to the form, and then... When u want to submit the form just do $('searchform').ajaxSubmit({ success: function() { // callback } ) Trigger this on checkboxes change, dropdown change etc. To make the code clean, use one selector $('#country, #s, #color input').on('change', sendAjaxForm);

Categories : Javascript

Delayed_job background process not sending mails while executing mail related code with delay option
user_mailer.rb contains the following code: class UserMailer < ActionMailer::Base def author_notification(user,nfication) @recipients = user.creator.email @site_url = get_site_url(user.creator.organization) @from = "admin@#{@site_url}" @body[:body_template] = eval('"'+nfication.body+'"') @subject = eval('"'+nfication.subject+'"') content_type "text/html" end end

Categories : Ruby On Rails

Using the ion_auth login process and using a templated process to render the login process
There is no need to use ion_auth views or controllers. they are just for reference. we have to use their function as they have define in model for login/logout/register etc... just simply put his model,library and config file to the respective folder of codeigniter in your project and just use their function as they have shown in demo

Categories : Codeigniter

MongoDB errors: mongodb-10gen E: Sub-process /usr/bin/dpkg returned an error code (1)
This is due to some corruption within the package manager dpkg itself, this thread from Ask Ubuntu: http://askubuntu.com/questions/195950/package-system-broken-e-sub-process-usr-bin-dpkg-returned-an-error-code-1 lists some solutions, more specifically the editing of the status file has been noted as one that always works.

Categories : Linux

How can I lock UI while running the long running process in the main UI Thread in WPF (code in C#)
I would do it this way: Make a "global" (seen for UI thread and background thread) object of one of concurrent types. You can make it as singleton or pass an object to both threads All the long running thread does is reading data from concurrent object and process them. If main thread (or any other) need to do anything in background simply adds it to the concurrent collection. This kind of approach in concurrent programming is called Producer-consumer problem

Categories : C#

cross memory attach. How do I get the remote address from a child process to a parent process
The system calls process_vm_readv and process_vm_writev are meant for fast data transfer between processes. They are supposed to be used in addition to some traditional way of interprocess communication. For example, you may use a regular pipe or fifo to transfer the required addresses between your processes. Then you may use those addresses to establish faster process_vm_ communication. The simpliest way to transfer something between forked processes should be the pipe() function (man 2 pipe has a good example of its usage). There are many other ways to do so of course, like using sockets or messages. You can even write an address to a file and let the other process read it.

Categories : C

How do I deal with cases when Process.Kill() yields "access denied" because the process is terminating?
Use the command line C# to kill the task, for example Taskkill /F /IM ExeName.exe. If you do not have a persmission to kill the task than also force kill will not help. More info Please check http://www.c-sharpcorner.com/UploadFile/8ea152/kill-process-from-the-command-prompt-in-windows-8/ here an example how to run command line in C# Run Command Prompt Commands Greetings

Categories : C#

FileMode and FileAccess and IOException: The process cannot access the file 'filename' because it is being used by another process
You need to release control of the file from Program A. Try closing or disposing the streamwriter when you finish. Or you might attempt using as is described in the answer to this question: Releasing access to files

Categories : C#

Symfony2 Process component - unable to create pipe and launch a new process
The file handles are not being garbage collected, so they eventually fill up (os limit or php limit, not sure), but you can fix it by adding an explicit garbage collection call: gc_collect_cycles(); usleep($sleep * 1000000); Also, be forwarned that garbage collection doesn't work very well inside a foreach loop because of the way that php maps the temporary $foo as $bar => $var array variables into memory. If you need it in that part of the code you could switch it to something like this instead, which I think should allow for garbage collection inside the for loop: $processes[] = new Process("ls > /dev/null", null, null, null, 2); $processes[] = new Process("date > /dev/null", null, null, null, 2); $sleep = 0; do { $count = count($processes); for($i = 0; $i < $co

Categories : PHP

How to create a new process with command line arguments and give the PID to the parent process?
You can use createprocess() function in windows. Its signature is below BOOL WINAPI CreateProcess( _In_opt_ LPCTSTR lpApplicationName, _Inout_opt_ LPTSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCTSTR lpCurrentDirectory, _In_ LPSTARTUPINFO lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation ); Example: STARTUPINFO si; PROCESS_INFORMATION pi; //This structure has process id ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); if( argc != 2 ) { printf("Usage: %s [

Categories : C++

multiprocess in python: cross process to process watch-kill-restart
I've enabled Debug functions, and tried to kill and restart child processes from the parent. I've turned A and B in classes and added a shutdown method that kill the failing process, after this, if I try A.start() or A.run() this error appear 'cannot start a process twice'.What this means? the process is dead, there aren't others running. If I call multiprocessing.active_childre() the process aren't restarted but got this output: <Process(SyncManager-2, started)>, <Process(SyncManager-1, started)>, <Process(SyncManager-3, started)>] [INFO/MainProcess] process shutting down [DEBUG/MainProcess] running all "atexit" finalizers with priority >= 0 [SUBDEBUG/MainProcess] calling <Finalize object, callback=_decref, args=(Token(typeid='Value', address='/tmp/pymp-2ObnP1

Categories : Python

The process cannot access the file 'x' because it is being used by another process while deleting saved image by application
This is explained in the documentation for Image.FromFile: The file remains locked until the Image is disposed.

Categories : Vb.Net



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.