w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Limit the number of concurrent processes spawned by incrond
You can use the sem utility that comes with parallel: /path/to/dropfolder IN_CLOSE_WRITE sem --gnu --id myjobname -j 4 /path/to/resourceintensivescript.sh $@/$#

Categories : Linux

How to Spawn Child Processes that Don't Die with Parent?
Don't use system(...) it is not multi-threading safe. int pid = fork(); if(pid==0) { int rc = execv("processname", "/path/to/processConfig.xml &"); if(rc == -1) { printf(stderr, "processname failed to start. %d", errno); } ... } else { //continue with the parent }

Categories : C++

How many child processes can a node server spawn?
Two points... If you can cache/memoize results depending on your scenario, do so. I would look into using a generic-pool, to limit your use of sparse resources. By wrapping your controller with a node-pool you can limit yourself to say 10 or 20 active workers at a given time. I wouldn't do more than 2x the number of physical cpus myself, though how many threads you can run really depend on the workers/system. If all the worker processes are the same, it's more predictable.

Categories : Node Js

Twisted suggestion for TCP client spawn processes
It's not really clear what you're asking here. However, one thing I can confirm is that a TCP connection is between exactly two hosts: one client (responsible for "connecting") and one server (responsible for "accepting") (or sometimes simultaneous open where there are two clients and zero servers, but no one actually does that). If you want to connect to three servers, you must create at least three connections.

Categories : Python

Write a program that finds the average of several floats. allow the user to specify how many values that will be entered. limit number count to 20
Several things: You are using an array of string, you should use array of float. If you want average of float then variable total should be float instead of int

Categories : C++

Improving the efficiency of concurrent processes - set CPU limit or something else?
I don't think it is wise to fork new processes for the creation of thumbnails. I guess it is cheaper to use PHP's ImageMagick functions in general and it will not be significantly slower. Have you tested that? Do you use the -thumbnail operator of the convert command?

Categories : C

Using nodejs's spawn causes "unknown option -- " and "[Error: spawn ENOENT]" errors
I think this may be some sort of cygwin gotcha. I'm running Ubuntu 12.04 and tried to duplicate your problem, but it works just fine for me. In short, I don't see anything you are doing wrong. If it is complaining about the option, maybe split it up into multiple options like so: child = spawn("rm", ["-r", "-f", "node_modules"]); That's kind of a hail mary, but that works on my Ubuntu 12.04 as well. You might try to just delete a single file and see if you get the same thing. child = spawn("rm", ["/home/username/Desktop/TestFile"]); If that still fails, then you know you are working against some crazy stuff. You could even try to just execute a command with no parameters like so: child = spawn("ls"); If that still fails, you aren't likely to get spawn to work at all would b

Categories : Node Js

calling the arc4random method to spawn one enemy but two spawn instead
When you call your removeEnemy method, you don't call a corresponding method to remove your child sprite from the scene. Therefore, every time you call that method another CCSprite gets added without one being removed, which is why you are seeing duplicates. Make sure you call removeChild: to remove the CCSprite.

Categories : Objective C

setting up IPC between unrelated processes
I assume that you are in need of a debugging system for your business logic code (I mean application). From my experience, this kind of problem is tackled with below explained system design. (My experience is in C++, I think the same must hold good for the C based system also.) Have a logger system (a separate process). This will contain - logger manager and the logging code - which will take the responsibility of dumping the log into hard disk. Each application instance (process running in Unix) will communicate to this process with sockets. So you can have your own messaging protocol and communicate with the logger system with socket based communication. Later, for each of this application - have a switch which can switch off/on the log.So that you can have a tool - to send signal

Categories : C

how to program so that different processes run on different CPU cores?
If you wish to pin threads/processes to specific CPUs then you have to use the sched_setaffinity(2) system call or the pthread_setaffinity_np(3) library call for that. Each core in Linux has it's own virtual CPU ID. These calls allow you to set the allowed CPU mask. Otherwise it will be up to the digression of the scheduler to run your threads where it feels like running them. Neither will guarantee that your process runs in parallel though. This is something only the scheduler can decide unless you run realtime. Here is some sample code: #include <sched.h> int run_on_cpu(int cpu) { cpu_set_t allcpus; CPU_ZERO(&allcpus); sched_getaffinity(0, sizeof(cpu_set_t), &allcpus); int num_cpus = CPU_COUNT(&allcpus); fprintf(stderr, "%d cpus available f

Categories : C

An algorithm to find number of numbers in a given limit 'l' (0 <= l <= 10^16) with atleast one occurence of a single digit number 'n'?
Assuming you mean 0 <= l < 10^16 (not <= 10^16), all integers in this range have 10 digits (allowing for leading 0s). There are 10^16 total values in this range. I'd write the problem as: Number with digit n = 10^16 - number WITHOUT digit n. So how many ways can we not choose n in the 1's place? 9 ways. How many ways can we not put an 'n' in the 10s OR 1's place? 9*9. Following this logic, there are 9^16 ways of not putting an n in any of the 16 possible slots. So your answer is 10^16 - 9^16. If you actually meant 0 <= l <= 16, that range has only one more number, namely 10^16. The leading digit of this number is 1, so if n = 1 you have exactly 10^16 - 9^16 + 1 values with a 1 in it. If n != 1 then the previous answer holds.

Categories : Algorithm

How can i close all forms and processes(explorer) windows when i quit my program?
Well, technically these windows do not belong to your application, so they should not be closed. EDIT, regarding the comment: the solution provided below won't work, sorry, my mistake :) If you really want to control explorer windows you've opened you can collect the return value of the Start method ( http://msdn.microsoft.com/en-us/library/53ezey2s.aspx ), and then call the Kill method on each of them ( http://msdn.microsoft.com/en-us/library/system.diagnostics.process.kill.aspx ). Remember to check if they still exist as the user might have closed them on their own. Simple example for one window: class Form { //... private Process explorerWindow = null; } //... this.explorerWindow = Process.Start("explorer", String.Format("/select,{0}", t)); //... (in OnFormClosing) if (this.exp

Categories : C#

How many processes does this program create, including the initial parent process?
P1 forks, creating P2. P1 has john = <NOT ZERO>, and P2 has john = 0. Therefore P2 executes the if. It forks, creating P3. Now, P2 and P3 are at the second fork. So they fork, creating P4 and P5. Now P2, P3, P4 and P5 all have one fork left. They fork, creating P6, P7, P8 and P9. Total of nine processes spawned. fork creates an exact copy of the program image of the calling process, except for the fact that it returns 0 to the child and a PID to the parent. And the child will be at the same place as the parent is after the fork.

Categories : C

Set threshold number of processes in Linux
I'll answer the question that I think you are asking. One program can have multiple instances running. Each is a separate process. I'm not aware of any instance count that Linux makes available. So I don't think there is any setting that can be made to get Linux to enforce a maximum number of instances for you. If user access to the program can be forced to come through a shell script or wrapper program, you have some options. 1) To just give a warning to users invoking the program who have reached or exceeded the number of instances, you could do a shell script that does something like ps aux | grep TheProgramFileName > $InstanceCount Then the script would compare to a maximum, and warn the user. But that won't stop anyone. 2) If the goal is to prevent multiple instances, that

Categories : Linux

How to count number of forked (sub-?)processes
You can count the forked processes simply trapping the SIGCHLD signal. If You can edit the script file then You can do this: set -o monitor # or set -m trap "((++fork))" CHLD So fork variable will contain the number of forks. At the end You can print this value: echo $fork FORKS For a 1000 lines input file it will print: 3000 FORKS This code forks for two reasons. One for each expr ... and one for `echo ...|grep...`. So in the reading while-loop it forks every time when a line is read; in the processing while-loop it forks 2 times (one because of expr ... and one for `echo ...|grep ...`). So for a 1000 lines file it forks 3000 times. But this is not exact! It is just the forks done by the calling shell. There are more forks, because `echo ...|grep...` forks to start a bash to ru

Categories : Bash

Setting Text fields Limit
Try this code: <td><input name="Number" type="text" id="Number" value="" required/></td> document.getElementById('Number').onchange = function() { if(this.value.length != 10){ this.value = "Please Check the Ticket Number Again"; } }

Categories : Misc

Setting a feed limit on the Eventbrite API
event_new creates new events...it does not list events. So, you can't be using this API to create a "feed". To list events, there are two API endpoints...user_list_events and organizer_list_events. user_list_events has more controls over the return data, so you should use that one. Since there are not pagination controls on either of those methods, you will need to filter the result set yourself in whatever client library you are using.

Categories : Api

MKMapView setting zoom limit without bouncing
With my knowledge, I don't think it's actually possible to set max zoom or min zoom without making it yourself. But I know that if you use the Google Map SDK, you can actually set a max and a min zoom for the map: https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_map_view

Categories : IOS

dbscan - setting limit on maximum cluster span
DBSCAN indeed does not impose a total size constraint on the cluster. The epsilon value is best interpreted as the size of the gap separating two clusters (that may at most contain minpts-1 objects). I believe, you are in fact not even looking for clustering: clustering is the task of discovering structure in data. The structure can be simpler (such as k-means) or complex (such as the arbitrarily shaped clusters discovered by hierarchical clustering and k-means). You might be looking for vector quantization - reducing a data set to a smaller set of representatives - or set cover - finding the optimal cover for a given set - instead. However, I also have the impression that you aren't really sure on what you need and why. A stength of DBSCAN is that it has a mathematical definition of

Categories : Python

Setting a character limit for a string using Java annotations
Null value for String and empty String are not the same thing. You are passing a null value (not a String of length 0). Check this out: Difference between null and "" Java String Also, you should try out @Size(min=,max=).

Categories : Java

What is causing exceeding of Rate Limit in My Program?
You should read this informative link: https://api.stackexchange.com/docs/throttle Specifically: A dynamic throttle is also in place on a per-method level. If an application receives a response with the backoff field set, it must wait that many seconds before hitting the same method again. So check out the backoff field returned, and wait for that much before doing another request.

Categories : Javascript

Mysql2 strategy for setting local variables for select limit 1
Found the following answer: Ruby / MySQL fetching single row but still using .each? No loop necessary. Just call first on Mysql2::Result local_var = row.first['Path']

Categories : Ruby

How to increase the maximum number of child processes that can be spawned by a windows service -- desktop heap limits
This is a "desktop heap" problem. A very good discussion can be found here: http://blogs.msdn.com/b/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx Note that this only applies to programs that are running as services, because the default desktop heap size for services is so much smaller than that for applications. In our case, we were able to launch about 100 child processes before running out of resources without the change. With the change, this number can be increased considerably. This is the answer we've given to our end users on our knowledgebase: WARNING: this affects the desktop heap of all services! Do not make it larger than necessary or you will push the system to consume more resource and you may bump up against problems in the total available desktop heap size

Categories : Windows

Why does program output redirection make the output of its sub-processes to be out of order?
A terminal generally uses line-buffering, while a pipe would use block buffering. This means that your printf call, which includes a newline, will fill the line buffer, triggering a flush. When redirecting, no flush takes place until the program completes. echo on the other hand, always flushes the buffer it is writing to when it completes. With line buffering (terminal output), the order is: printf() prints a line with newline, buffer is flushed, you see 1. output from printf() being printed. echo writes output, exits, flushes the buffer, you see 2. output from a command called using system() printed. With block buffering, the order is: printf() prints a line with newline, not fully filling the buffer. echo writes output, exits, flushes the buffer, you see 2. output from a comman

Categories : C

Java - limit number between min and max
You do not need an external library for this, try this test case: public class RandomNumber { public static void main(String[] Args) { System.out.println("random = " + randomInRange(5,10)); } public static double randomInRange(double arg1, double arg2) { double my_number = Math.ceil(Math.random() * (arg1 - arg2) + arg2); return my_number; } }

Categories : Java

Limit number of column
<table> <tr> <?php $count = 5; while($report && !$report ->EOF && $count > 0) { echo "<td>$name</td>"; $report ->MoveNext(); $count--; } ?> </tr> </table> Just added a simple counter to the while loop. By increasing the count you can make more columns appear

Categories : PHP

Limit the number of pages
I suppose you can override mpdf class addPage method, and if the number of pages is more then you want, generate EnoughPagesException, catch it up in your code, and there you have the mpdf object with the number of pages you need.

Categories : PHP

Limit number of JSON results
If you don't want to get all the results, don't use each, which does iterate through all the results in the first place. Simple as that. For limited and known number of steps use simple logic as: for (var i = 0; i <= 4; i++) { var item = data.feed.entry[i]; // your other stuff goes here } ...or, as other state correctly, ommit your query by 5 in the first place and then use each freely.

Categories : Javascript

Is there anyway to limit the number of character in UITextfield to 5?
Is the delegate being called? If YES, then just try this: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if ([textField.text length] > 5) { textField.text = [textField.text substringToIndex:5-1]; return NO; } return YES; }

Categories : IOS

Appengine - Limit the number of instances
My app is currently having only litte number of traffic, so paying even a little dollar is a matter to me. After learning and trying so many option on how to optimize the instance class. I found the following setting that gives me a lowest cost on running application with Billing Status Enabled on Google Appengine. I use F1 Class to set Frontend instance. Here i the code in yaml version. instance_class: F1 automatic_scaling: max_idle_instances: 1 # default value min_pending_latency: automatic # default value max_pending_latency: 30ms I use B1 class to set Backend instance. Here i the code in yaml version. instance_class: B1 basic_scaling: max_instances: 1 idle_timeout: 10m And here is the code to put in appeengine.web.xml (if compiling java with maven) <threadsafe&g

Categories : Google App Engine

Highcharts: limit number of markers
AFAIK you can disable markers per point but you have to supply the data as objects, which can be problematic with large quantities of points: series: [{ data: [ { y: 29.9 }, { y: 71.5, marker: { enabled: false } }, { y: 106.4, marker: { enabled: false } }, { y: 129.2 }] }] Documentation here (see third item).

Categories : Javascript

Limit the Number of Posts in Wordpress
There are multiple ways of doing it. But the easiest is to hook into wp_insert_post and prevent it from working. You could force every new post to draft until they delete/unpublish an older one and when they do you can allow them to publish new one.

Categories : PHP

Limit Number of Checkboxes Checked
Try this: jQuery(function(){ var max = 3; var categories = jQuery('label'); // use better selector for categories categories.each(function(){ var checkboxes = $(this).find('input[type="checkbox"]'); checkboxes.change(function(){ var current = checkboxes.filter(':checked').length; checkboxes.filter(':not(:checked)').prop('disabled', current >= max); }); }); });

Categories : Javascript

Limit the number of attempts in Android
As AnujMathur_07 told you can use SharedPreferences which are pretty easy to use, but there is a but, if the user goes to the application data and suppress them, he will be able to send 4 new message etc. So maybe you can use database which is not so easily deleted or, easily you can create a text file where you write something when the user send the last message .

Categories : Java

Limit number of '1' in a string using Regexp
There are possibly better versions, but this seems to do the trick: /^([^1]*1){1,5}[^1]*$/ Broken down: ^ - Start of string [^1]*1 - Zero or more non-1 characters 1 - A '1'. ([^1]*1){1,5} - This pattern occurring between one and five times. [^1]* - Zero or more non-1 characters $ - End of string

Categories : Ruby

Limit the number of posts from Facebook API
Since string.Format(appURL) contains a Graph API request USER_ID/feed, we can add a field that specify the limit: dynamic feed = _facebookClient.Get(string.Format(appURL) + "?limit=10"); You will find more information about LIMIT here.

Categories : Dotnet

How to limit number of accociations in Rails
Besides validations, you could also use a custom method for adding child objects: def add_player(player) if players.count < 2 self.players << player else raise 'Too many players' end end This does enforce the limit when adding players using this method, but not when accessed directly via association, e.g. obj.players << player.

Categories : Ruby On Rails

Limit number of images - Paperclip
For the first part of the problem you have, i would suggest you use rails built-in counter_cache method. Your picture model would thus become: class Picture < ActiveRecord::Base belongs_to :imageable, :polymorphic => true, counter_cache: true has_attached_file :image end Also you would need to add a column called pictures_count to the User model. This way in your controller you could check if the count is upto 5 records and therefore inform them that they have uploaded the maximum allowed. if @user.pictures.size == 5 #sorry no more uploads For the second part of the problem. Is the form action pointed to the new/create action or to your update action. If pointed to the new action a new record would be created but if pointed to the update action then it should change

Categories : Ruby On Rails

Limit the number of rows returned - mysql
[LIMIT {[offset,] row_count | row_count OFFSET offset}] You pass row_count=32. Check manual.

Categories : PHP

Limit the number of google recaptcha characters
There is no way to limit the number of characters of Google ReCaptcha. If the user can't find a captacha because it's too messy, too long, he can ask for another captcha, and that's how it works. Moreover, reducing the number of character would just reduce the effectiveness of ReCaptcha. If you really want something easier, you have to look for something else or create your own captcha system.

Categories : Magento



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