Search Results

Search found 2601 results on 105 pages for 'condition'.

Page 72/105 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • Multiple conditions with will_paginate

    - by user363243
    I am using will_paginate for pagination but I can't seem to use more than one condition at a time. For example, if I want to have a sql query that ends in "Where office_id = 5", then it's pretty straight forward, I can do that. but what if I want to do "Where office_id = 5 AND primary_first = 'Mark'"? I can't do that. I have no idea how to enter multiple conditions. Can you help?? Below is an example of my code: def self.search(search, page, office_id) paginate :per_page => 5, :page => page, :conditions => ['office_id', "%#{office_id}"], # + ' and primary_first like ?', "%#{params[:search]}%"], #:conditions => ['primary_first', "%#{search}%"], :order => 'created_at' end Thank you for your help!

    Read the article

  • How to explicitly terminate http connection from server with no response header

    - by Gagandip
    I am developing a server simulator for one of my client application. I am using GlassFish server. I have to simulate a http connection terminate condition in my server application. Is there a way by which I can explicitly terminate a connection from server side such that client does not receive any response header. Currently I have tried many options like closing the response outputStream. But in every case a http 200 OK message is delivered to the client application. I would like to consume the http-request and do not want to return anything to the client. I am using a simple conrtroller servlet and had overridden doGet() and doPost() functions.

    Read the article

  • Swing: Multiple CellEditors for a column

    - by Luhar
    Hi, In my JTable, I have two editable numeric columns. The editor for both columns extends AbstractCellEditor and uses a JFormattedTextField as an the editing component. The problem is that the format for input depends on the value of another column in the row. If condition X is met, the number of fraction digits should be Y, otherwise they should be Y+2. I attempted to override the getTableCellEditor(..) method to associate a TableCellEditor per row. See this example. However, since I have two editable columns, sharing a single TableCellEditor object per row gives some very odd results. I don't think this is an appropriate solution. Any ideas on how to approach this would be much appreciated! Thank you!

    Read the article

  • how to verify that an old session is really destroyed?

    - by jodeci
    Um, this might sound a bit weird. We were having some problems with a specific browser under a very specific condition, and finally narrowed down the problem to the fact that we were not properly destroying the old sessions after doing session_regenerate_id(). I believe I have solved this problem by doing session_regenerate_id(true) now, but how does one verify that the previous sessions really do not exist any more? Someone suggested cURL but I cannot find my way around their docs. Sadly(?) the boss does not take 'it just works' for an answer so I'd really appreciate any advice!

    Read the article

  • jQuery: use Use filter(), but work with both results

    - by Tomalak
    In jQuery, filter() reduces your result to those elements that fulfill a certain condition. This splits the list in two parts. Working with the "good half" of the elements is easy: $("some selector").filter(function() { // determine result... return result; }).each( /* do something */ ); But how can I work with the "other half" of my elements, too - but without doing the equivalent of this: $("some selector").filter(function() { // determine result... return !result; }).each( /* do something else */ ); Basically, I'd like to feed two separate /* do something */ parts to a single filter. One for those that match, and one for the others - without having to filter twice. Am I missing a jQuery function that does this? P.S.: I guess I could do: $("some selector").each(function() { // determine result... if (result) /* do something */ else /* do something else */ }); But I was hoping for something nicer.

    Read the article

  • How can chunks be allocated in a node.js stream in object mode all at once?

    - by Quentin Engles
    I can see how buffers, and strings can be sent as chunks, but I'm having a problem thinking about how streams can be dealt when working in object mode. Say I have a byte stream from an http request message. I want to take that message, parse, and then transform it into one big object. I already know how to parse the message. What I'm wondering is if the message is big so it has many chunks, but I want to make one object for the output how can I make sure the data event waits for the whole thing? Is this just a matter of not using the push method until the chunked data has finished being sent? That would then restrict the stream data output to a smaller object which I think I'm fine with for now. As an added condition the larger data will be reduced in size after the the transform.

    Read the article

  • how to open alert dialog box for second time without running program 2nd time?

    - by Shahjada Mohsinkhan mohsinkhan
    In my program I have used an alert dialog box on onclick event. But after running my program on event onclick the alert dialog box opens and allows filling information in it. and then on click of ok button alert dialog if condition is matched than data will be submitted and intent will pass otherwise in toast msg it will show something like enter correct password or loginid etc. but when on second click of button on which I have set alertdialogbox the thread msg will appear and it will close the program so what is the solution for this. Hope for your concern. Thanking you

    Read the article

  • How to dynamically write the query in SQL Server 2008?

    - by user1237131
    How to write the dynamically the below query? Table empid designation interestes 1 developer,tester cricket,chess 1 developer chess 1 techlead cricket Condition: IF empid = 1 AND (designation LIKE '%developer%' OR designationLIKE '%techlead%') OR (interests LIKE '%cricket%'). How to write the above query dynamically if designations need to send more than 2,and also same on interstes . please tell me ... EDIT stored procedure code: ALTER PROCEDURE [dbo].[usp_GetDevices] @id INT, @designation NVARCHAR (MAX) AS BEGIN declare @idsplat varchar(MAX) set @idsplat = @UserIds create table #u1 (id1 varchar(MAX)) set @idsplat = 'insert #u1 select ' + replace(@idsplat, ',', ' union select ') exec(@idsplat) Select id FROM dbo.DevicesList WHERE id=@id AND designation IN (select id1 from #u1) END

    Read the article

  • Add multiple IF tags in php

    - by Andy
    Hi , I would like to add this condition : {if $profile.sex == 1 || $profile.sex == 4} {/if} To this code : case 'friendlist': if ( app_Features::isAvailable( 14 ) ) { $_output = '<div class="memhome_link">'; $_output.= '<a href="'.SK_Navigation::href( 'profile_friend_list' ).'" '.$class.'>'.$lang_section->text( 'href_my_friendlist').'</a>'; $_output.= ' ('.app_FriendNetwork::countFriends( SK_HttpUser::profile_id() ).')'; $_output.= '</div>'; } break; Can anybody give me any help , please ? Thanks for all the help .

    Read the article

  • How to pass a reference to a string in JavaScript?

    - by ijjo
    Maybe a closure is my solution? Not exactly sure how to pull it off though. The code is set up like so: var globalVar = ''; var globalVar2 = ''; function func() { if (condition) func2(globalVar) else func2(globalVar2) } In func2() I cache some HTML in a main container into the appropriate global variable that I pass to it. Basically I have a main container that holds different pages depending on what tab they choose. For performance I want to cache the page into global vars so I need to know what tab is active to figure out which global var to assign the HTML to.

    Read the article

  • Does any language have a while-else flow structure?

    - by dotancohen
    Consider this flow structure which I happen to use often: if ( hasPosts() ) { while ( hasPosts() ) { displayNextPost(); } } else { displayNoPostsContent(); } Are there any programming languages which have an optional else clause for while, which is to be run if the while loop is never entered? Thus, the code above would become: while ( hasPosts() ) { displayNextPost(); } else { displayNoPostsContent(); } I find it interesting that many languages have the do-while construct (run the while code once before checking the condition) yet I have never seen while-else addressed. There is precedent for running an N block of code based on what was run in N-1 block, such as the try-catch construct. I wasn't sure whether to post here or on programmers.SE. If this question is more appropriate there, then please move it. Thanks.

    Read the article

  • Re-ordering C++ template functions

    - by DeadMG
    In C++, I have a certain template function that, on a given condition, calls a template function in another class. The trouble is that the other class requires the full definition of the first class to be implemented, as it creates the second class and stores them and manages them in similar fashions. The trouble is that naturally, they fall as one class, and thus have some tight interop, except that I need them to be two classes for threading reasons. A sort of, master for all threads, one child per thread, system. Any advice on how this can be implemented?

    Read the article

  • Adding code to the beginning / end of methods in runtime dynamically

    - by Irchi
    I know instrumentation is a technique to add trace code dynamically into the methods to enable tracing and debugging. I was wondering if this is only a "Trace" option, hard coded into the CLR to add only trace code, or is there the ability to add any code to the methods? For example, I want to check for a condition in the beginning of every single method call in a certain class (say for permissions). Can I do this via adding dynamic code to the beginning of the methods in execution time? I'm not sure how this trace "instrumentation" thing works, but I'm wondering if this can be used for other goals too, or not.

    Read the article

  • Install the proper bitness Visual C++ Runtime Library via a Setup project

    - by chiru_valentin
    Hi all! The context: I have a solution that contains amongh other C# projects, a VC++ project that suports compiling only as x64 or Win32 (but not Any CPU). In order for the application (which in fact is a macro for a third party application) to run, it requires Visual C++ Runtime libraries (x86) or (x64) (The macro will run on both x64 and x86 operating systems.) The problem: I want to create a Visual Studio setup project that would install the macro on both x86 and x64 operating systems, and the problem I have is to specify what Visual C++ Runtime library to use a prerequisite. If both are selected (x64 and x86) than I have a runtime error message when running the setup.exe, as on x86 operating systems you cannot run x64 executables like the Visual C++ Runtime libraries (x64) kit is...(which the setup calls in the back). So I would need a bitness condition, or something like that to tell the setup what bitness version of the Visual C++ Runtime library to try to install...I'm not sure if this is possible, or even where such a code should be placed in the setup. Thank you for the support, Vali

    Read the article

  • Does the order of conditions in a WHERE clause affect MySQL performance?

    - by Greg
    Say that I have a long, expensive query, packed with conditions, searching a large number of rows. I also have one particular condition, like a company id, that will limit the number of rows that need to be searched considerably, narrowing it down to dozens from hundreds of thousands. Does make any difference to MySQL performance whether I do this: SELECT * FROM clients WHERE (firstname LIKE :foo OR lastname LIKE :foo OR phone LIKE :foo) AND (firstname LIKE :bar OR lastname LIKE :bar OR phone LIKE :bar) AND company = :ugh or this: SELECT * FROM clients WHERE company = :ugh AND (firstname LIKE :foo OR lastname LIKE :foo OR phone LIKE :foo) AND (firstname LIKE :bar OR lastname LIKE :bar OR phone LIKE :bar)

    Read the article

  • Use a function in a conditions hash

    - by Pierre
    Hi, I'm building a conditions hash to run a query but I'm having a problem with one specific case: conditions2 = ['extract(year from signature_date) = ?', params[:year].to_i] unless params[:year].blank? conditions[:country_id] = COUNTRIES.select{|c| c.geography_id == params[:geographies]} unless params[:geographies].blank? conditions[:category_id] = CATEGORY_CHILDREN[params[:categories].to_i] unless params[:categories].blank? conditions[:country_id] = params[:countries] unless params[:countries].blank? conditions['extract(year from signature_date)'] = params[:year].to_i unless params[:year].blank? But the last line breaks everything, as it gets interpreted as follows: AND ("negotiations"."extract(year from signature_date)" = 2010 Is there a way to avoid that "negotiations"." is prepended to my condition? thank you, P.

    Read the article

  • regular expression not behaving as expected - Python

    - by philippe
    I have the following function which is supposed to read a .html file and search for <input> tags, and inject a <input type='hidden' > tag into the string to be shown into the page. However, that condition is never met:( e.g the if statement is never executed. ) What's wrong with my regex? def print_choose( params, name ): filename = path + name f = open( filename, 'r' ) records = f.readlines() print "Content-Type: text/html" print page = "" flag = True for record in records: if re.match( '<input*', str(record) ) != None: print record page += record page += "<input type='hidden' name='pagename' value='psychology' />" else: page += record print page Thank you

    Read the article

  • Shuffling a list with a constraint

    - by 500
    Preparing a new psychophysic experiment, I have 48 original stimuli displayed 4 times (4 conditions). Resulting in 192 trials. Trying to randomize the order of presentation during the experiment, I need to maximize the distance between the 4 display of the same original stimuli. Please Consider : Table[{j, i}, {j, Range[48]}, {i, Range[4]}] Where j is the original stimuli number and i the condition Output Sample : {{1, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, ... {47, 1}, {47, 2}, {47, 3},{47, 4}, {48, 1}, {48, 2}, {48, 3}, {48, 4}} How could I shuffle the order of presentation of those 192 items, maximizing the distance between identical item with regard to j the original stimuli number ?

    Read the article

  • Compare a DateTime to the current date

    - by looloobs
    Hi I am trying to use a condition on events when the start_at DateTime is equal to or greater than Today's date. I want to list upcoming events, but clearly they are not upcoming if they have already passed. I have: @appointments = Event.find(:all, :conditions => ['move_id = ? AND start_at = ?', @move.id, Date.today]) I think I may be comparing apples and oranges here. It doesn't throw and error, just doesn't do what it is supposed to. Help! Thanks in advance.

    Read the article

  • How to change the background color of a h:inputText control inside a rich:Panel

    - by kiransri
    I need to change the background color of some h:inputText controls inside a rich panel based on a condition. This is to distinguish these controls as readonly. I tried using styleClass and style properties but both did not work. styleClass is ignored and style colors only half of the textbox. 1) styleClass code : In css : .readonlycontrol { background-color: #C0C0C0; } In .xhtml page: <rich:panel styleClass="inputpanel"> <f:facet name="header" > <h:outputText value= "#{cardreqmsg.apptinfo}"/> </f:facet> <h:panelGrid columns="4" cellpadding="2" border="0"> <h:inputText id ="name" styleClass="readonlycontrol" readonly="true"/> ......... 2) style code: <h:inputText id ="name" readonly="true" style="background-color:#C0C0C0"/> Any help would be greatly appreciated

    Read the article

  • Building an array of arrays

    - by iFloh
    I am trying to get the following loop working to fill an array of arrays: while (condition) { [itemsArray fillFromDB]; if (! [checkArray containsObject:checkFlag]) { // Add existing itemsArray to myArray if (itemsArray.count) { // add the itemsArray to myArray and create a new instance of itemsArray [myArray addObject:itemsArray]; [itemsArray release]; NSMutableArray *itemsArray = [[NSMutableArray alloc] init]; } [itemsArray addObject:myObject]; [checkArray addObject:checkFlag]; } else { [itemsArray addObject:tmpEvent]; } } However I try to shape this loop it falls over the release of itemsArray when I use release (as above), the array does not re-initialise as a new instance with alloc. Whilst expecting emptyness, the next Object is added to the old array. when I use removeAllObjects, my Array is emptied and so is the array attached to myArray. Where am I going in the wrong direction?

    Read the article

  • what is a good way to do countif in python

    - by tolomea
    I want to count how many members of an iterable meet a given condition. I'd like to do it in a way that is clear and simple and preferably reasonably optimal. My current best ideas are: sum(meets_condition(x) for x in my_list) and len([x for x in my_list if meets_condition(x)]) The first one being iterator based is presumably faster for big lists. And it's the same form as you'd use for testing any and all. However it depends on the fact that int(True) == 1, which is somewhat ugly. The second one seems easier to read to me, but it is different from the any and all forms. Does anyone have any better suggestions? is there a library function somewhere that I am missing?

    Read the article

  • check compiler with break point

    - by KareemSaad
    When I tried to focus on compiler in code i made break point on code if (!IsPostBack) { using (SqlConnection Con = Connection.GetConnection()) { if (Request.QueryString["Category_Id"] != null && DDlProductFamily.SelectedIndex < 0) { SqlCommand Com = new SqlCommand("SelectAllCtageories_Front", Con); Com.CommandType = CommandType.StoredProcedure; Com.Parameters.Add(Parameter.NewInt("@Category_Id", Request.QueryString["Category_Id"])); SqlDataAdapter DA = new SqlDataAdapter(Com); DA.Fill(dt); DataList1.DataSource = dt; DataList1.DataBind(); } but I cannot check condition although I had the value of query string List item

    Read the article

  • fetch some data from two tables

    - by user1753971
    i have site like imdb and we provide movie information sin site..and our website have option to rate all movies for every users. I have two tables 1 . imdb (its for store movie details) id,name,actors,vote 2. ratings (its for store users rating details) id,rating_id(its same as id from first table),rating_num,IP now what am doing is..when anyone rating a movie take the avg of that movie rating by using rating tables (total ratings/number of ratings) and insert that value into "vote" column in first table..my demands this..thats why done like this.. Now my problem is..i want to fetch top rated movies..i mean in vote column which movie have top rating which want to list and one more condition is that that movie should rated by 10 users(use ratings table for that) thanks in advance

    Read the article

  • Trigger Event after values have been commited for validation purposes

    - by www.jefferyfernandez.id.au
    I have a Flex component with a form and on creationComplete, I load some data onto the form textInputs. After the Form TextInputs have got their values, I want to trigger an event so the Parent of the component can validate the values on the TextInputs and based on the validation results, I perform some enable/disable of other interfaces. I have the following dispatch code: this.dispatchEvent(new PersonalDetailsEvent(PersonalDetailsEvent.LOADED_DATA_EVENT)); The event is dispatched and is captured by the parent. But upon performing the validation, some TextInputs always fail the validation. I thought it could be because of a race condition and so I used callLater() with same results. So in the end I am now using a timer to dispatch the event which is not ideal. Does anyone have a solution to this problem. It is really annoying that a timer needs to be used for this scenario.

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >