logic

Help with SQL query

I've got the next SQL query: SELECT FIRST_NAME, LAST_NAME FROM MYTABLE WHERE STATUS = 1 AND VARIABLE IN ( 'PR', 'AR' ) AND SPECIAL = 1; SPECIAL is an aditional condition which is added if I previously selected 'PR' (checkbox) in my form. The thing is, with this query, I'm no longer getting rows where VARIABLE is 'AR'. Now, the idea i...

what is the most efficient way to calculate the least common multiple of two integers

what is the most efficient way to calculate the least common multiple of two integers I just came up with this, it definitely leaves something to be desired int n = 7, m = 4, n1=n, m1=m; while (m1 != n1) { if (m1 > n1)n1 += n; else m1 += m; } System.out.println("lcm is " + m1); ...

Why isn't this DirectoryInfo comparison working?

var dirUserSelected = new DirectoryInfo(Path.GetDirectoryName("SOME PATH")); var dirWorkingFolder = new DirectoryInfo(Path.GetDirectoryName("SAME PATH AS ABOVE")); if (dirUserSelected == dirWorkingFolder) { //this is skipped } if (dirUserSelected.Equals(dirWorkingFolder)) { //this is skipped } Whilst debugging, I can examin...

Need help with logic (C)

I need to swap first n elements from two non repeating sequences(arrays), where n is a random integer. Seq1: 1 4 5 6 9 8 2 3 7 Seq2: 3 9 1 2 8 7 4 5 6 If n = 4 Seq1: 3 9 1 2 | 9 8 2 3 7 Seq2: 1 4 5 6 | 8 7 4 5 6 Now i need to repair the sequence by replacing the repeated numbers after '|'. How to do this? This is my effort.. for...

Tunneling two or more objects

Hey, I have two separate objects, a main and a "child". Its physically not a real child object, because I add the whole parent through the constructor to the child. Like this: class core { public function __get($class) { $this->load($class); } public function load($class, $file = null, $lib = true) { ...

Setting expriy date. for windows application.

Created one windows applcation. now i would like to give licence for it by keeping expiry date. am planning to keep expiry date in registries. the porblem is.. how can i get the actaul date. ie; when user changes the system date also- this should not change.(i meran expiry date.) Am looking for logics to acheive this..!! ...

Can I simplify this conditional statement, which uses the logical negation operator?

Sorry if this is a "Logical Operators 101" kind of question. I've been staring at my screen for 15 minutes trying to wrap my head around it, but I'm stuck. Is there a more concise/elegant way to phrase the following (this is JavaScript syntax, but it's not a language-dependent question): if (!something && !something_else) { // do som...

Check time interval using SQL condition

I'm storing some intervals in the SQL, example: id INT from DATE to DATE How can I check, using only one condition (if possible) if a NEW interval conflict with a existing one? Examples: |-----------| (from 1 to 5) |-----------| (from 2 to 6) |--| (from 3 to 4) |--| (from 7 to 8) Every interval (in th...

Logic in the Model or in the Controller with CodeIgniter?

Hi! I'm relatively new to CodeIgniter and the MVC philosophy in general, so I'm trying to clarify this before I make any bad habits. I have an application that registers. Users. Currently, the flow is like this: User navigates to the "somewebpage/register", which loads the "register" function of the controller Controller checks to se...

How to accomplish a logical exclusive OR in bash

I'd like to have a command only execute if the preceding command's exit status was not 0. i.e. Command 1 ^ Command 2 where Command 2 is only executed when Command 1 fails. ...

Large binary shifts in 8086 assembly?

I have a binary chunk of data 512 bytes long, I was wondering what the most efficient way would be if I wanted to shift it once to the right. My best guess right now (very new to assembly) would be that I would have to first check a chunk (probably int) to see what it would shift out, shift, then carry in whatever the previous int would...

Using regular expression for validating data is correct or not?

Hi, I have been finding some articles and post which suggest not to use the regular expression to validate user data. I am not sure of all the things but i usually find it in case of email address verification. So i want to be clear whether using regular expression for validating user input is good or not? if it is good then what is b...

Reason for "all" and "any" result on empty lists

In Python, the built-in functions all and any return True and False respectively for empty iterables. I realise that if it were the other way around, this question could still be asked. But I'd like to know why that specific behaviour was chosen. Was it arbitrary, ie. could it just as easily have been the other way, or is there an underl...

Does HTML understand "if-else"?

Let's say I have Flash-version of and non-Flash version of my website. When a user comes to my website, is there any way to create the following logic: if (user has flash-plugin installed) { load flash website } else { load non-flash website } While we are here. Can I do the same for the bandwidth control? Let's say a Cable customer ...

Message boxes (VBA): how can I include/use them in my Excel Macros?

I'm teaching myself (read hacking) through some old Excel Macros that are quite long. However, as I change quite a few lines I want to be sure that I know when and where my new and re-hashed elements are occuring - or not. So my question/s is: How do I insert a simple message box function that will pop up when a loop/procedure/event ha...

Adding logic to a data bound property to initiate animations in WPF

I feel like this is a very simple question, but I can't really find any examples on the internet of anyone who wants to do something like this. What I have right now is a half circle gauge control that I made in WPF. I have a RotateTransform that has data bound to its angle so as the data comes in it shows the angle visually. The problem...

Messed up method - if/then structure and string manipulation problems

I have a method that gets called any time a control on my view changes and should update a UILabel. It has two UITextFields and two UISliders. First I check to see if either of the UITextFields are empty and if so, advise that they need to be filled in. Otherwise I get the difference between the UITextFields' values and generate a cou...

Trouble with jQuery event refreshing

Hi, I am using jQuery to make a custom carousel. After delivering a jCarousel implementation as part of a project, the test team have raised a lot of bugs and so I decided to write my own as I always find it difficult to find a plug-in that does exactly what I want (need) it to do. My current problem is that I can get it to scroll onc...

Need to create a "choose your own adventure" type guide - best approach to use

Basically need to ask user a set of questions and gather information along the way. Each question could have impacts on different questions down the road. Another example would be turbo tax's web interface, answering yes on some ?s may trigger future questions. Seems like this would be a fairly common problem in software so I guess ...

how can i create a DLL of a program written in c program..?

how can i create a DLL of a program written in c program..?(am using turbo c compiler) the same program i could use with c# or VB program as- DLL reference.. http://support.microsoft.com/kb/106553 check out this link(i didn't understand this..) ...