w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Short circuit vs non short circuit operators
only place where you shouldn't use non short circuit operator is when you want second statement to be executed, which shouldn't be case in conditional statements generally No, there is no performance with non short circuit, But there is absolutely benefit with short circuit

Categories : Java

The "bag of tasks" concept in C#, enqueue,pause,cancel logical tasks
Yes, you can do that. First, you have a main thread, your application. There you have two workers, represented by threads. The first worker would be a producer and the second worker would be a consumer. When your application starts, you start the workers. Both of them operates on the concurrency collection, the bag. Producer searches for files and puts references to the bag and consumer takes references from the bag and starts a task per reference. When you want to signal pause, simply pause the producer. If you do that, consumer also stops working if there is nothing in the bag. If this is not a desired behaviour, you can simply define that pausing of the producer also clears the bag - backup your bag first and than clear it. This way all running tasks will finish their job and consumer

Categories : C#

SecurityException when enumerating V1 tasks and displaying tasks' info using a DataGrid
This is courtesy of dahall over at codeplex (Thanks a lot dahall) First, try putting brackets in around the scope of your first using statement. You can also do the same with the TaskService instance. You could do this by doing: List<TaskInfo> taskList = new List<TaskInfo>(); using (TaskService ts = new TaskService(REMOTE", "username", "domain", "password", osVer.Contains("2003"))) { EnumFolderTasks(ts.RootFolder, taskList); } DataContext = taskList; I am not sure why this happens only for the V1 calls, but this did solve my problem.

Categories : C#

Are short-circuit operators overloaded?
I am not completely sure what you are asking, but at least the bytecode is different between boolean c = a|b and boolean c = a||b: boolean a = true; boolean b = false; boolean c = a|b; ILOAD 1 ILOAD 2 IOR ISTORE 3 boolean c = a||b; ILOAD 1 IFNE L4 ILOAD 2 IFNE L4 ICONST_0 So the two operators effectively result in different operations on a bytecode level. Most specifically, || only evaluates the second operand if the first operand is false, while | evaluates both operands in any case: public boolean a() { System.out.println(" a"); return true; } public boolean b() { System.out.println(" b"); return false; } public void c() { System.out.println("a() | b()"); boolean r1 = a() | b(); System.out.println(" a() || b()"); boolean r2 = a() || b(); } Output: a

Categories : Java

Why doesn't this if-statement short circuit?
It is not possible that the && operator fails to short-circuit. Were you using & perhaps? If not it means you have made some false assumptions that previous conditions before the last one were false.

Categories : Java

ASP.NET WebForms: Short-circuit validation
Just make a CustomValidator that works on serverside and using if/else statements achieve your behaviour. For example: <telerik:RadTextBox ID="txtMerchMin" runat="server" Text='<%# Bind("MerchandiseMinimumAmount") %>'></telerik:RadTextBox> <asp:RequiredFieldValidator ID="required" runat="server" ErrorMessage="* required" ControlToValidate="txtMerchMin"></asp:RequiredFieldValidator> <asp:CustomValidator runat="server" ID="customValidator" Display="Dynamic" SetFocusOnError="true" ControlToValidate="txtMerchMin"></asp:CustomValidator> In code behind in init method set (you can do this also in markup) customValidator.ServerValidate += new ServerValidateEventHandler(customValidator_ServerValidate); And then in function implement your logi

Categories : Validation

How can I redirect maintenance site in asp.net
Just use app_offline.htm, explained here and here. If you want to keep the site down for a specific time period (or to some other external event, etc.) then you could run a (scheduled) script on the server to create or remove the app_offline.htm file when needed.

Categories : C#

Maintenance page on apache 7
The .htaccess file contains no executable program code to do some activities. If you want to show a webpage then you need a running webserver. If you have no one bad luck. Take a look at this post about the technicel enviroment to reach your goal. Edit: I found another post about this topic, though the same thing is the use of an additional webserver.

Categories : Apache

SQL Maintenance Plan - End Task
Assuming SSIS w/ SQL Server, "SQL Server Agent" -> "Job Activity Monitor". Right-click the job that you don't want running and select "Stop Job" This could be worse than letting the job run. Be warned.

Categories : SQL

Under maintenance page if Heroku goes down
In short `heroku config:set MAINTENANCE_PAGE_URL=http://s3.amazonaws.com/your_bucket/your_maintenance_page.html` Keep in mind that you should host this static page outside of heroku. Reference https://devcenter.heroku.com/articles/maintenance-mode

Categories : Ruby On Rails

jsf page refresh maintenance
You need a <redirect/> in your navigation-case, e.g.: <navigation-case> <from-outcome>admin</from-outcome> <to-view-id>/admin.xhtml</to-view-id> <redirect/> </navigation-case>

Categories : JSF

Short-circuit logic evaluation operators
Keep in mind that a query does not execute imperatively. The query you wrote may run on multiple threads, and therefore a short-circuit operator in the where clause would not result in only one result. Instead, use the LIMIT clause to only return the first row. SELECT * FROM quantitycache WHERE bookstore_id = 1 OR city_id = 1 OR country_id = 1 ORDER BY bookstore_id IS NULL ASC, city_id IS NULL ASC, country_id IS NULL ASC LIMIT 1; To get the best match for all books in a result set, save the results to a temp table, find the best result, then return interesting fields. CREATE TEMPORARY TABLE results (id int, book_id int, match_rank int); INSERT INTO results (id, book_id, match_rank) SELECT id, book_id, -- this assumes that lower numbers are better CASE WH

Categories : Mysql

Is there anyway to 'return false' in a short circuit for Javascript?
No, but you can simply: return !(A && B) You want to return false only if A and B evaluate to true, so there you have it. Now, if you don't necessarily want to return right there at all times, then you're left with: if(A && B) return false; // more code Aside from being impossible due to the basic rules of the language, what you want would make your code slightly harder to understand without providing any benefit. Trust me, this way is better.

Categories : Javascript

Short-circuit OR operator in Lucene/Solr
Strictly speaking, no, there is no short circuiting boolean logic. If a document is found for one term, you can't simply tell it not to check for the other. Lucene is an inverted index, so it doesn't really check documents for matches directly. If you search for A OR B, it finds A and gets all the documents which have indexed that value. Then it gets B in the index, and then list of all documents containing it (this is simplifying somewhat, but I hope it gets the point across). It doesn't really make sense for it to not check the documents in which A is found. Further, for the query provided, all the matches on a document still need to be enumerated in order to acquire a correct score. However, you did mention scores! I suspect what you are really trying to get at is that if one qu

Categories : Solr

Does Python all(list) use short circuit evaluation?
Yes, it short-circuits: >>> def test(): ... yield True ... print 'one' ... yield False ... print 'two' ... yield True ... print 'three' ... >>> all(test()) one False From the docs: Return True if all elements of the iterable are true (or if the iterable is empty). Equivalent to: def all(iterable): for element in iterable: if not element: return False return True So when it returns False, then the function immediately breaks.

Categories : Python

Can compound assignment operators ever short circuit
Operator |= is the compound of operator | not operator ||. The former does not short-circuit. And no operator ||= exists. So the answer to your question is negative. func must be called if it has side effects. If it does not have side effects, then according to the as-if rule the implementation is free to do anything as long as you can't tell the difference.

Categories : C

Is there a way to use a short circuit operator silently in vimscript?
The bar is just a separator, not a boolean operator; and both colorscheme and silent! are commands, not returning any value. This is not bash :) Try this: let v:errmsg = "" silent! colorscheme lucius if v:errmsg == "" LuciusBlackHighContrast endif

Categories : Vim

SQL Server: Database Maintenance Plan
If you want to create a maintenance plan, see the follwing page: Use the Maintenance Plan Wizard Otherwise, you can just create a SQL agent job with various steps in it that run the T-SQL commands that you want, such as backup database and DBCC commands and create a schedule for it. If you cannot use the maintenance plan wizard, you can use commands similar to those detailed in the following page to create the jobs: Create a Maintenance Plan If you can't create agent jobs (for reasons such as you are using a version of SQL server that doesn't support them (SQL Express etc) then you can use OSQL commands that are fired by Windows task scheduler to achieve much the same thing, see the folowing link for a very good description: How to Automate Maintenace Tasks with SQL Server Express

Categories : SQL

Looking for low-maintenance URLs to load jQuery-ui
For whatever reason, there doesn't seem to be a link quite as low-maintenance as the jQuery one in your question. However, there is one that is almost as nice: http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js or "//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" in code to be http/https-agnostic. This will give you the latest 1.x version. When version 2 is release, I assume you could simply update the link to use "2" instead of "1" and be good for a good while longer.

Categories : Jquery

How to draw a circuit diagram to check a 4 bits number is odd or even
You don't really need a circuit for this - bit 0 of the input determines whether the number is odd or even, so you can ignore bits 1 - 3 and just use bit 0 as an odd/even output (it will be 1 for odd, 0 for even). So the circuit, such as it is, would look like this: INPUT OUTPUT bit 3 o------------- N/C bit 2 o------------- N/C bit 1 o------------- N/C bit 0 o------------------------------------o odd/even

Categories : Misc

In Perl - can a short circuit evaluation be disabled if needed?
You could just evaluate every clause to temporary variables, then evaluate the entire expression. For example, to avoid short-circuit evaluation in: if ($x < 10 and $y < 100) { do_something(); } write: $first_requirement = ($x < 10); $second_requirement = ($y < 100); if ($first_requirement and $second_requirement) { do_something(); } Both conditionals will be evaluated. Presumably, you want more complex conditions with side effects, otherwise there's no reason to evaluate the second condition if the first is false.

Categories : Perl

Does Java run each conditional operator or does it short-circuit in If statements?
You're using & instead of &&. The former is bitwise AND and will evaluate both sides always. The latter stands for logical AND and will do short-circuit conditional evaluation. More info: Java Tutorials: Operators Solution for your current problem: use logical AND && instead of bitwise AND &. Similar for your bitwise OR |. if( !currentFragment.getTag().equals(PROFILE) || ( currentFragment.getArguments() != null && currentFragment.getArguments().getInt("authorId") != userId) ) { }

Categories : Java

In Excel, is there an early opt out AND/OR functions (Short Circuit Evaluation)?
What you're calling "early opt out" is more commonly called "short-circuit evaluation," and is generally a feature of languages in the C/C++/C#/Java family (but, notably, not Visual BASIC). For Excel formulas, some logical functions practice short-circuit evaluation but some do not. AND does not, as you've found. Neither does OR--if the first argument in an OR expression is true, Excel will still try to evaluate the subsequent arguments. The solution is to use nested IFs; evaluation of IFs goes step-by-step from outer to inner, branching as necessary, and stopping when there is no further nested formula to be evaluated. This produces the correct short-circuit behavior. So you can write your code above as =IF(FALSE, IF(ISNA(<address of cell to test for the #N/A state>), TRUE),

Categories : Excel

traverse all edges and print nodes in euler circuit
What you need to do is form arbitrary cycles and then connect all cycles together. You seem to be doing only one depth first traversal, which might give you a Eulerian circuit, but it also may give you a 'shortcut' of an Eulerian circuit. That is because in every vertex where the Eulerian circuit passes more then once (i.e., where it crosses itself), when the depth first traversal arrives there for the first time, it may pick the edge that leads directly back to the start of the depth first traversal. Thus, you're algorithm should consist of two parts: Find all cycles Connect the cycles together If done right, you don't even have to check that all vertices have an even degree, instead you can rely on the fact that if step 1 or 2 cannot continue anymore, there exists no Eulerian cycle.

Categories : Algorithm

knockout.js and multiple bindings performance and maintenance
You can certainly use the third argument of the binding handler to access the other bindings on an element. This is what is used for things like optionsText, optionsValue, valueUpdate, etc., as they are not real bindings. So, if you have a binding like: ko.bindingHandlers.draggableGameHandler = { init: function(element, valueAccessor, allBindingsAccessor, data, context) { var allBindings = allBindingsAccessor(); //can access allBindings.draggableCss and allBindings.draggableDrop }, update: function(element, valueAccessor, allBindingsAccessor, data, context) { } }; As far as a performance boost, it kind of depends on what you are doing. If you are repeating logic/work in multiple bindings that you could share in one, then you may see a boost.

Categories : Knockout Js

Where are Scala the compiler api docs from maintenance releases?
I would have said clone the repo, $ git checkout v2.9.3 $ ant docscomp but I'm getting errors (on the order of missing classes and dir; but I'm not in a position ATM to try scrubbing). Good luck! Updated: apm@mara:~/tmp$ whence bigant bigant is aliased to `ANT_OPTS="${DEFAULT_ANT_OPTS}" ant' apm@mara:~/tmp$ echo $DEFAULT_ANT_OPTS -Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=192M -XX:+UseParallelGC I only use bigant; though, since this is my only use of ant these days, I could simplify a bit: apm@mara:~/projects/snytt$ bigant all.clean ; bigant Buildfile: /home/apm/projects/snytt/build.xml [echo] Forking with JVM opts: -Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=192M -XX:+UseParallelGC In case my error helps. I'll update again when I pursue it. (I never build 2.9.) It looks

Categories : Scala

Laravel FrozenNode Administrator run in maintenance mode
I've dug in the core, there's no way you can do it. Laravel checks for a file named down in app/storage/meta folder, if it's there, Laravel won't even call the routes, it'll just show the error page. This is isDownForMaintenance function from laravel: public function isDownForMaintenance() { return file_exists($this['path.storage'].'/meta/down'); } There's no configuration possible. An alternative way to the laravelish "maintenance mode" is to set a new value in config/app.php, add: 'maintenance' => true, Then add this to your before filter: App::before(function($request) { if( Config::get('app.maintenance') && Request::segment(1) != 'admin' // This will work for all admin routes // Other exception URLs ) return Response::make(Vie

Categories : Laravel

When using NginX as a reverse proxy, how can i fallback to a maintenance url?
are you using the free version ? I think what you are looking for is in the non-free version called NGINX Plus. Advanced Load Balancing Application Health Checks

Categories : Nginx

Easy maintenance table of identifier vs. text
You can use a system of macros to help create a single point of identifier update that will also update your strings. However, this scheme converts your identifiers from macros to enumerated constants. I am typing this as I go, so it is untested: #define SYS_FAIL_EXCEPTIONS SYS_FAIL_EXCEP(PREFETCH_ABORT) SYS_FAIL_EXCEP(DATA_ABORT) SYS_FAIL_EXCEP(RESET) SYS_FAIL_EXCEP(UNDEFINED) SYS_FAIL_EXCEP(RESERVED) SYS_FAIL_EXCEP(IRQ_UNVECTORED) enum { #define SYS_FAIL_EXCEP(X) SYS_FAIL_EXCEP_##X, SYS_FAIL_EXCEPTIONS #undef SYS_FAIL_EXCEP }; static const HAL_Map_Text_ID_t system_failure_text_id_map[] = { #define SYS_FAIL_EXCEP(X) { SYS_FAIL_EXCEP_##X, #X }, SYS_FAIL_EXCEPTIONS #undef SYS_FAIL_EXCEP }; If using an enum is not acceptable, and you must

Categories : C

How do you show up the maintenance message while you want to re-deploy a war file?
Ideally, you'll want some kind of hot-deployment support so that your users won't ever notice a service interruption. Common methods of achieving this are: Having multiple instances of the web application behind some kind of load balancer which directs incoming requests to a running instance. If you'd perform a deployment, you wouldn't take all instances offline at once, but sequentially take one instance offline, redeploy, restart, and repeat this sequentially for all other instances. Code-based hot-swapping while the software is running. The Oracle's JVM has limited support for this (HowSwap). A popular commercial tool which enables redeployments (using more sophisticated mechanisms than HotSwap) of Java web apps is LiveRebel.

Categories : Java

how to set maintenance mode for entire website with htaccess
i find out an blog that contains answer for your question please check this site The below examples are taken from the above mentoined site. If you don’t already have an .htaccess file in the root of your domain, create one and add the following code. If you already have an .htaccess file, add the following code in front of everything that might be in there RewriteEngine On # Add all the IP addresses of people that are helping in development # and need to be able to get past the maintenance mode. # One might call this the 'allow people list' RewriteCond %{REMOTE_HOST} !^ RewriteCond %{REMOTE_HOST} !^ # Make sure the maintenance mode only applies to this domain # Example: I am hosting different sites on my server # which could be affected by these

Categories : Htaccess

How to retrieve the return code of a command in a short-circuit expression
Elaborating devnull's approach leads to { c3=0; command3 || c3=$? && false; } && command4 || command5 echo $c3 . Because every command can be replaced by { c=0; command || c=$? && false; } (provided that c is initially unset if executed conditionally), this is easily extensible.

Categories : Bash

pre/post-increment in conditional skipped by short-circuit evaluation
The post-increment is only post evaluation of the statement. Since the statement is never evaluated (it's short circuited) it's skipped. A more visual way to think of it is to imagine the if statement as being nested: if (obj != null) { if (i++ % divisor == 0) { ... } } Here we see immediately that i will not be incremented. Similarly when an if statement is short circuited the behaviour is similar to the above and the post increment is not queued.

Categories : C#

Passing a query string through redirect for maintenance mode
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !maintenance.php RewriteCond %{REQUEST_URI} !(css|assets).*$ RewriteCond %{REMOTE_ADDR} !^XX.XXX.XXX.XXX$ RewriteRule (.*) /maintenance.php [R=302,L] RewriteCond %{REMOTE_ADDR} ^XX.XXX.XXX.XXX$ RewriteRule (.*) $1?mode=maintenance [L,QSA] This works for me, first you have the negation redirect so whoever tries to access without the allowed IP will go to maintenance.php. Then you have the append internal redirect, the GET mode=maintenance will not be visible but will be there. And you can retrieve it with $_GET['mode']. If you want it to visually append to the query string and only to php files you can use: RewriteCond %{REMOTE_ADDR} ^XX.XXX.XXX.XXX$ RewriteCond %{REQUEST_FILENAME} .php$ RewriteCond %{QUERY_STRING} !^mode=mai

Categories : PHP

How do we ensure that bug fixes on maintenance branch are merged back to trunk?
Since there is no way for the VCS to spot the difference between bug fix and ongoing development the short answer is there is no way to be 100% sure, a good tracking system that has a check list for the developers may help but even threatening to fire or shoot offenders does not ensure it doesn't happen. Actually doing so cuts down the repeat offenders though!

Categories : Svn

Uploading new version of a core file on running website without maintenance mode
First let me say that this is probably not a very good idea. Are you running on a Linux server? If so, renaming files is an atomic operation, and the best way to accomplish this is going to be to upload the new file with a different name, then rename it over the old file. If not, renaming it over the old file is probably still a better approach than just uploading it in place, since you will probably get some requests while the file is being written, which will cause errors.

Categories : PHP

FlaggedRevs requires running .../mediawiki/maintenance/update.php from command line
You need to run it using php.exe. If you have it in your PATH, you can use just: php update.php If you don't have it in PATH, you need to specify the whole path yourself: C:path ophp update.php

Categories : PHP

Automatically generate circuits on its own in PLECS (Piece-wise Linear Electrical Circuit Simulation )
You can probably use functions like add_block and add_line to automate the creation of your Simulink model from a library.

Categories : Matlab

Django, optimum wysiwyg editor + file browser combo for quick setup and easy maintenance
I had the same problem 1 day ago... Just go for the django-pagedown. It is simple to install and easy to use. Remember that either you have to fork the project, or also download the pagedown rep (django-pagedown/static/pagedown) It is very easy and fast to start working on.

Categories : Django

Difference between @list.tasks and @list.tasks.all in Rails
When you use @list.tasks it returns tasks belonging to this list and everything is as expected .all is deprecated method all which is just alias for calling find(:all). Thus, in @list.tasks.all you get @list.tasks.find(:all) which returns empty enumerable.

Categories : Ruby On Rails

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