Search Results

Search found 3339 results on 134 pages for 'hash collision'.

Page 124/134 | < Previous Page | 120 121 122 123 124 125 126 127 128 129 130 131  | Next Page >

  • How can I store and access a filehandle in a Perl class?

    - by Haiyuan Zhang
    please look at the following code first. #! /usr/bin/perl package foo; sub new { my $pkg = shift; my $self = {}; my $self->{_fd} = undef; bless $self, $pkg; return $self; } sub Setfd { my $self = shift; my $fd = shift; $self_->{_fd} = $fd; } sub write { my $self = shift; print $self->{_fd} "hello word"; } my $foo = new foo; My intention is to store a file handle within a class using hash. the file handle is undefined at first, but can be initilized afterwards by calling Setfd function. then write can be called to actually write string "hello word" to a file indicated by the file handle, supposed that the file handle is the result of a success "write" open. but, perl compiler just complains that there are syntax error in the "print" line. can anyone of you tells me what's wrong here? thanks in advance.

    Read the article

  • Waiting until one event has happened before moving onto the next.

    - by jaasum
    I currently have a scrolling anchor animation that also adds an "active" class to the anchor clicked. I am trying to fit the below function into the works as well, so say someone clicks "anchor 1", "anchor 1" will get an active class and the window will scroll to that location. But, after that has happened say the user manually begins scrolling down the page, I want the active class to be removed. The problem I am running up against now is that the below function will happen when the scrolling animation from a clicked anchor is taking place. How can I disable this only when the window is being scrolled from a clicked anchor? $(window).scroll(function() { $('a[href^=#]').removeClass('active'); }); Here is the scrolling anchor script I am working with. /******* *** Anchor Slider by Cedric Dugas *** *** Http://www.position-absolute.com *** Never have an anchor jumping your content, slide it. Don't forget to put an id to your anchor ! You can use and modify this script for any project you want, but please leave this comment as credit. *****/ jQuery.fn.anchorAnimate = function(settings) { settings = jQuery.extend({ speed : 500 }, settings); return this.each(function(){ var caller = this $(caller).click(function (event) { event.preventDefault() var locationHref = window.location.href var elementClick = $(caller).attr("href") var destination = $(elementClick).offset().top; $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, 'easeOutCubic', function() { window.location.hash = elementClick }); return false; }) }) } And lastly, my jQuery // Scrolling Anchors $('[href^=#]').anchorAnimate(); // Active Class For Clicked Anchors var anchorscroll = $('a[href^=#]') anchorscroll.click(function(){ var anchorlocation = $(this).attr("href"); anchorscroll.removeClass('active'); $(this).addClass('active'); $('a[href='+anchorlocation+']').addClass('active'); });

    Read the article

  • Best workflow with Git & Github

    - by Tom Schlick
    Hey guys, im looking for some advice on how to properly structure the workflow for my team with git & github. we are recent svn converts and its kind of confusing on how we should best setup our day-to-day workflow. Here is a little background, im comfortable with command line and my team is pretty new to it but can follow use commands. We all are working on the same project with 3 environments (development, staging, and production). We are a mix of developers & designers so some use the Git GUI and some command line. Our setup in svn went something like this. We had a branch for development, staging and production. When people were confident with code they would commit and then merge it into the staging. The server would update itself and on a release day (weekly) we would do a diff and push the changes to the production server. Now i setup those branches and got the process with the server running but its the actual workflow that is confusing the hell out of me. It seems like overkill that every time someone makes a change on a file they would create a new branch, commit, merge, and delete that branch... from what i have read they would be able to do it on a specific commit (using the hash), do i have that right? is this an acceptable way to go about things with git? any advice would be greatly appreciated.

    Read the article

  • twitter streaming api instead of search api

    - by user1711576
    I am using twitters search API to view all the tweets that use a particular hashtag I want to view. However, I want to use the stream function, so, I only get recent ones, and so, I can then store them. <?php global $total, $hashtag; $hashtag = $_POST['hash']; $total = 0; function getTweets($hash_tag, $page) { global $total, $hashtag; $url = 'http://search.twitter.com/search.json?q='.urlencode($hash_tag).'&'; $url .= 'page='.$page; $ch = curl_init($url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE); $json = curl_exec ($ch); curl_close ($ch); echo "<pre>"; $json_decode = json_decode($json); print_r($json_decode->results); $json_decode = json_decode($json); $total += count($json_decode->results); if($json_decode->next_page){ $temp = explode("&",$json_decode->next_page); $p = explode("=",$temp[0]); getTweets($hashtag,$p[1]); } } getTweets($hashtag,1); echo $total; ?> The above code is what I have been using to search for the tweets I want. What do I need to do to change it so I can stream the tweets instead? I know I would have to use the stream url https://api.twitter.com/1.1/search/tweets.json , but what do I need to change after that is where I don't know what to do. Obviously, I know I'll need to write the database sql but I want to just capture the stream first and view it. How would I do this? Is the code I have been using not any good for just capturing the stream?

    Read the article

  • Stopping process in /etc/inittab kills spawned process. Doesn't happen in rc.local.

    - by Paul
    Hi, I'm trying to execute a firmware upgrade while my programming is running in inittab. My program will run 2 commands. One to extract the installer script from the tarball and the other to execute the installer script. In my code I'm using the system() function call. These are the 2 command strings below, system ( "tar zvxf tarball.tar.gz -C / installer.sh 2>&1" ); system( "nohup installer.sh tarball >/dev/null 2>&1 &" ); The installer script requires the tarball to be an argument. I've tried using sudo but i still have the same problem. I've tried nohup with no success. The installer script has to kill my program when doing the firmware upgrade but the installer script will stay alive. If my program is run from the command line or rc.local, on my target device, my upgrade works fine, i.e. when my program is killed my installer script continues. But I need to run my program from /etc/inittab so it can respawn if it dies. To stop my program in inittab the installer script will hash it out and execute "telinit q". This is where my program dies (but thats what I want it to do), but it also kills my installer script. Does anyone know why this is happening and what can I do to solve it? Thanks in advance.

    Read the article

  • Spring security or BCrypt algorithm which one is good for accounts like project?

    - by Ranjith Kumar Nethaji
    I am using spring security for hashing my password.And is it safe ,because am using spring security for first time. my code here <security:http auto-config="true"> <security:intercept-url pattern="/welcome*" access="ROLE_USER" /> <security:form-login login-page="/login" default-target-url="/welcome" authentication-failure-url="/loginfailed" /> <security:logout logout-success-url="/logout" /> </security:http> authentication-failure-url="/loginfailed" /> <security:logout logout-success-url="/logout" /> </security:http> <authentication-manager> <authentication-provider> <password-encoder hash="sha" /> <user-service> <user name="k" password="7c4a8d09ca3762af61e59520943dc26494f8941b" authorities="ROLE_USER" /> </user-service> </authentication-provider> </authentication-manager> .And I havnt used bcrypt algorithm.what is your feedback for both?any recommendation?

    Read the article

  • ForEach loop in Mathematica.

    - by dreeves
    I'd like something like this: ForEach[i_, {1,2,3}, Print[i] ] Or, more generally, to destructure arbitrary stuff in the list you're looping over, like: ForEach[{i_, j_}, {{1,10}, {2,20}, {3,30}}, Print[i*j] ] (Meta-question: is that a good way to call a ForEach loop, with the first argument a pattern like that?) ADDED: Some answerers have rightly pointed out that usually you want to use Map or other purely functional constructs and eschew a non-functional programming style where you use side effects. I agree! But here's an example where I think this ForEach construct is supremely useful: Say I have a list of options (rules) that pair symbols with expressions, like attrVals = {a -> 7, b -> 8, c -> 9} Now I want to make a hash table where I do the obvious mapping of those symbols to those numbers. I don't think there's a cleaner way to do that than ForEach[a_ -> v_, attrVals, h[a] = v] ADDED: I just realized that to do ForEach properly, it should support Break[] and Continue[]. I'm not sure how to implement that. Perhaps it will need to somehow be implemented in terms of For, While, or Do since those are the only loop constructs that support Break[] and Continue[]. If anyone interested in this wants to ask about that as a separate question, please do!

    Read the article

  • A specific data structure

    - by user550413
    Well, this question is a bit specific but I think there is some general idea in it that I can't get it. Lets say I got K servers (which is a constant that I know its size). I have a program that get requests and every request has an id and server id that will handle it. I have n requests - unknown size and can be any number. I need a data structure to support the next operations within the given complexity: GetServer - the function gets the request ID and returns the server id that is supposed to handle this request at the current situation and not necessarily the original server (see below). Complexity: O(log K) at average. KillServer - the function gets as input a server id that should be removed and another server id that all the requests of the removed server should be passed to. Complexity: O(1) at the worst case. -- Place complexity for all the structure is O(K+n) -- The KillServer function made me think using a Union-Find as I can do the union in O(1) as requested but my problem is the first operation. Why it's LogK? Actually, no matter how I "save" the requests if I want to access to any request (lets say it's an AVL tree) so the complexity will be O(log n) at the worst case and said that I can't assume Kn (and probably K Tried thinking about it a couple of hours but I can't find any solution. Known structures that can be used are: B+ tree, AVL tree, skip list, hash table, Union-Find, rank tree and of course all the basics like arrays and such.

    Read the article

  • Not crawling the same content twice

    - by sirrocco
    I'm building a small application that will crawl sites where the content is growing (like on stackoverflow) the difference is that the content once created is rarely modified. Now , in the first pass I crawl all the pages in the site. But next, the paged content of that site - I don't want to re-crawl all of it , just the latest additions. So if the site has 500 pages, on the second pass if the site has 501 pages then I would only crawl the first and second pages. Would this be a good way to handle the situation ? In the end, the crawled content will end up in lucene - creating a custom search engine. So, I would like to avoid crawling multiple times the same content. Any better ideas ? EDIT : Let's say the site has a page : Results that will be accessed like so : Results?page=1 , Results?page=2 ...etc I guess that keeping a track of how many pages there were at the last crawl and just crawl the difference would be enough. ( maybe using a hash of each result on the page - if I start running into the same hashes - I should stop)

    Read the article

  • Variable won't store in session

    - by Mittens
    So I'm trying to store the "rank" of a user when they log in to a control panel which displays different options depending on the given rank. I used the same method as I did for storing and displaying the username, which is displayed on the top of each page and works just fine. I can't for the life of me figure out why it won't work for the rank value, but I do know that it is not saving it in the session. Here is the bit that's not working; $username = ($_POST['username']); $password = hash('sha512', $_POST['password']); $dbhost = 'mysql:host=¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦;dbname=¦¦¦¦¦¦¦¦¦¦¦'; $dbuser = '¦¦¦¦¦¦¦¦¦¦¦'; $dbpassword = '¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦'; try { $db = new PDO($dbhost, $dbuser, $dbpassword); $statement = $db->prepare("select password from users where email = :name"); $statement->execute(array(':name' => $username)); $result = $statement->fetch(); $pass = $result[password]; $rank = $result[rank];} catch(PDOException $e) {echo $e->getMessage();} if ($password == $pass) { session_start(); $_SESSION['username'] = $username; $_SESSION['rank'] = $rank; header('Location: http://¦¦¦¦¦¦¦¦¦.ca/manage.php'); } else{ include'../../includes/head.inc'; echo '<h1>Incorrect username or password.</h1>'; include'../../includes/footer.inc'; } I'm also new to the whole PDO thing, hence why my method of authenticating the password is pretty sketchy.

    Read the article

  • Meaning of NEXT in Linked List creation in perl

    - by seleniumnewbie
    So I am trying to learn Linked Lists using Perl. I am reading "Mastering Algorithms with Perl" by Job Orwant. In the book he explains how to create a linked list I understand most of it, but I just simply fail to understand the command/index/key NEXT in the second last line of the code snippet. $list=undef; $tail=\$list; foreach (1..5){ my $node = [undef, $_ * $_]; $$tail = $node; $tail = \${$node->[NEXT]}; # The NEXT on this line? } What is he trying to do there? Isn $node a scalar, which stores the address of the unnamed array. Also even if we are de-referencing $node, should we not refer to the individual elements by an index number example (0,1). If we do use "NEXT" as a key, is $node a reference to a hash? I am very confused. Something in plain English will be highly appreciated.

    Read the article

  • customized form_for tag in rails

    - by poseid
    I want to make a table within a form by making a new form_tag. The following code in ApplicationHelper fails: module ApplicationHelper class TabularFormBuilder < ActionView::Helpers::FormBuilder # ... code to insert <tr> tags </tr> end def tabular_form_for(name, object = nil, options = nil, &proc) concat("<table>", proc.binding) form_for(name, object, (options||{}).merge(:builder => TabularFormBuilder), &proc) concat("</table>", proc.binding) end end The view I use is: <h1>New project</h1> <% tabular_form_for :project, :builder => ApplicationHelper::TabularFormBuilder do |f| %> <%= f.error_messages %> <%= f.text_field :name %> <%= f.text_area :description %> <%= f.text_field :location %> <%= f.submit 'Create' %> <% end %> The error I get is: NoMethodError in Projects#new Showing app/views/projects/new.html.erb where line #5 raised: undefined method `errors' for {:builder=ApplicationHelper::TabularFormBuilder}:Hash Any ideas how to make this custom tag work?

    Read the article

  • alternative in .Net to building Tables/TR/TD manually?

    - by egrunin
    I've got a pile of code here that looks like this: if (stateTax > 0) { tr = new TableRow(); tbl.Rows.Add(tr); td = new TableCell(); td.CssClass = "stdLabel"; td.Text = "NY State Tax"; tr.Cells.Add(td); td = new TableCell(); td.Text = string.Format("{0:C}", stateTax); td.CssClass = "justRight"; tr.Cells.Add(td); } This is a horrible hash of data and layout, but creating a special class or control every time something like this comes up seems almost as bad. What I usually do is write a helper function, which is concise but ugly: if (stateTax > 0) MakeRow(tbl, "NY State Tax", "stdLabel", string.Format("{0:C}", stateTax), "justRight"); And now I'm thinking: haven't I done this 100 times before? Isn't there a more modern way? Just to be explicit: it's a whole list of miscellaneous labels and values. They don't come from any particular data source, and the rules for when rows should be suppressed vary. This example has only two columns, but I have other places with more.

    Read the article

  • Perl, Net::Traceroute::PurePerl return value

    - by John R
    This is a sub routine that I copied from CPAN. It works fine as it is when I run it from the command line. I have a similar function from Net::Traceroute that also works fine AND allows me to return the string with a SOAP call. The problem comes when I try to return the ~string(?) from the function below with a SOAP call. sub tr { use Net::Traceroute::PurePerl; my $t = new Net::Traceroute::PurePerl( backend => 'PurePerl', # this optional host => 'www.whatever.com', debug => 0, max_ttl => 30, query_timeout => 2, packetlen => 40, protocol => 'udp', # Or icmp ); $t->traceroute; $t->pretty_print; return $t; #print $t; } The output looks like a string except the last part of the string looks like this: 28 * * * 29 * * * 30 * * * Net::Traceroute::PurePerl=HASH(0x11fa6bf0) I don't know what is different about Net::Traceroute::PurePerl that won't allow me to return the value with SOAP since the Net::Traceroute version does allow me to return it with SOAP.

    Read the article

  • Variable wont echo

    - by jonnnnnnnnnie
    I have the following code, where the var $username doesn't echo, when you type in a value. //TODO: SET AUTH TOKEN as random hash, save in session $auth_token = rand(); if (isset($_POST['action']) && $_POST['action'] == 'Login') { $errors = array(); //USED TO BUILD UP ARRAY OF ERRORS WHICH ARE THEN ECHOED $username = $_POST['username']; if ($username = '') { $errors['username'] = 'Username is required'; } echo $username; // var_dump($username) returns string 0 } require_once 'login_form.html.php'; ?> login_form is this: <form method="POST" action=""> <input type="hidden" name="auth_token" value="<?php echo $auth_token ?>"> Username: <input type="text" name="username"> Password: <input type="password" name="password1"> <input type="submit" name="action" value="Login"> </form> The auth token part isn't important, it just when I type in a value in username textbox and press the login button, the username wont echo, var_dump returns string (0) and print_r is just blank.

    Read the article

  • Tracking changed (unsaved) objects

    - by Eric
    I have a class which is serialized to and from an XML file when the user decided to open or save. I'm trying to add the typical functionality where when they try to close the form with un-saved changes the form warns them and gives them the option of saving before closing. I've added a HasUnsavedChanges property to my class, which my form checks before closing. However, it's a little annoying that my properties have changed from something like this .. public string Name { get; set; } to this... private string _Name; public string Name { get { return _Name; } set { this._Name = value; this.HasUnsavedChanges = true; } } Is there a better way to track changes to an instance of a class? For example is there some standard way I can "hash" an instance of a class into a value that I can use to compare the most recent version with the saved version without mucking up every property in the class?

    Read the article

  • Mysql dropping inserts with triggers

    - by user2891127
    Using mysql 5.5. I have two tables. One has a whitelist of hashes. When I insert a new row into the other table, I want to first compare the hash in the insert statement to the whitelist. If it's in the whitelist, I don't want to do the insert (less data to plow through later). The inserts are generated from another program and are text files with sql statements. I've been playing with triggers, and almost have it working: BEGIN IF (select count(md5hash) from whitelist where md5hash=new.md5hash) 0 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Already Whitelisted'; END IF; END But there's a problem. The Signal throwing up the error stops the import. I want to skip that line, not stop the whole import. Some searching didn't find any way to silently skip the import. My next idea was to create a duplicate table definition, and redirect the insert to that dup table. But the old and new don't seem to apply to table names. Other then adding an ignore column to my table then doing a mass drop based on that column after the import, is there any way to achieve my goal?

    Read the article

  • Header redirect and Session start() generating errors

    - by RPK
    I am using following code. I get errors: Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/mc/cpanel/Source/verifylogin.php:11) Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/public_html/mv/cpanel/Source/verifylogin.php:11) Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/public_html/mv/cpanel/Source/verifylogin.php:11) <?php error_reporting(E_ALL^ E_NOTICE); ob_start(); require("../Lib/dbaccess.php"); $inQuery = "SELECT mhuserid, mhusername FROM cpanelusers WHERE mhusername = '". $_POST['UserName'] ."' AND mhpassword = '". hash('sha512', $_POST['Password']) ."'"; try { $Result = dbaccess::GetRows($inQuery); echo $Result; $NumRows = mysql_num_rows($Result); if ($NumRows > 0) { header("Location: http://www.example.com/cpanel/mainwindow.php"); session_start(); } else { header("Location: http://www.example.com/cpanel/"); echo "Last login attempt failed."; exit; } } catch(exception $e) { } ob_clean(); ?>

    Read the article

  • Mystery: How does Google do cross-domain iframe communication?

    - by Shraga
    Hi everyone, When you host Googles web search element on a page, a div is created which incorporates an iframe which points to a Google adsense ads page. However, if there are no ads for the specific query, Google somehow changes the class on YOUR domain to render the div (and iframe) invisible. They are NOT using postMessage, as it also works in IE7. They are also not using the fragment identifier method, as no hash appears in the url. So how do they do it? To check what I'm saying just put the following into a regular html page: <!-- Google Custom Search Element --> <div id="cse" style="width:100%;">Loading</div> <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript"> google.load('search', '1'); google.setOnLoadCallback(function(){ new google.search.CustomSearchControl().draw('cse'); }, true); </script> and then do a search for "cars" (or anything else that will definitely have ads) and then for "wzxv", which has no ads...

    Read the article

  • Retrieving values from a table in HTML using jQuery?

    - by Mo
    Hi i was just wondering whats the best way to retrieve the following labels and values from this HTMl code using jquery and storing them in to a array or hash map of some sort where i have for e.g "DataSet:" : "prod" or ["Dataset", "Prod"]? <table id="metric_summary"> <tbody> <tr class="editable_metrics"> <td><label>DataSet:</label></td> <td><input name="DataSet" value="prod"></td> </tr> <tr class="editable_metrics"> <td><label>HostGroup:</label></td> <td><input name="HostGroup" value="MONITOR-PORTAL-IAD"></td> </tr> <tr class="editable_metrics"> <td><label>Host:</label></td> <td><input name="Host" value="ALL"></td> </tr> <tr class="editable_metrics"> <td><label>Class:</label></td> <td><input name="Class" value="CPU"></td> </tr> <tr class="editable_metrics"> <td><label>Object:</label></td> <td><input name="Object" value="cpu"></td> </tr> <tr class="editable_metrics"> <td><label>Metric:</label></td> <td><input name="Metric" value="CapacityCPUUtilization"></td> </tr> thanks

    Read the article

  • Cryptography for P2P card game

    - by zephyr
    I'm considering writing a computer adaptation of a semi-popular card game. I'd like to make it function without a central server, and I'm trying to come up with a scheme that will make cheating impossible without having to trust the client. The basic problem as I see it is that each player has a several piles of cards (draw deck, current hand and discard deck). It must be impossible for either player to alter the composition of these piles except when allowed by the game rules (ie drawing or discarding cards), nor should players be able to know what is in their or their oppponent's piles. I feel like there should be some way to use something like public-key cryptography to accomplish this, but I keep finding holes in my schemes. Can anyone suggest a protocol or point me to some resources on this topic? [Edit] Ok, so I've been thinking about this a bit more, and here's an idea I've come up with. If you can poke any holes in it please let me know. At shuffle time, a player has a stack of cards whose value is known to them. They take these values, concatenate a random salt to each, then hash them. They record the salts, and pass the hashes to their opponent. The opponent concatenates a salt of their own, hashes again, then shuffles the hashes and passes the deck back to the original player. I believe at this point, the deck has been randomized and neither player can have any knowledge of the values. However, when a card is drawn, the opponent can reveal their salt, allowing the first player to determine what the original value is, and when the card is played the player reveals their own salt, allowing the opponent to verify the card value.

    Read the article

  • Jquery ajax load not working

    - by Slay
    This is my code: test.html <html> <head> <title>test</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script> $(document).ready(function(){ $(window).bind('hashchange', function(){ $('#result').load('test2.html', function(){ alert('Load was performed.'); }); }); }); </script> </head> <body> <a href="#Test1">Test 1</a> <a href="#Test2">Test 2</a> <div id="result"></div> </body> </html> test2.html <h3>This is content from test2.html</h3> I want to detect the specific page to load using window.hash in change. For instance if user go to http://localhost/test.html#test2 The main container(result) in the page will do an ajax load call to test2.html to get the content. I can't manage to get this simple code working. Appreciate if someone can guide me in the right direction. Thanks.

    Read the article

  • What guarantees are there on the run-time complexity (Big-O) of LINQ methods?

    - by tzaman
    I've recently started using LINQ quite a bit, and I haven't really seen any mention of run-time complexity for any of the LINQ methods. Obviously, there are many factors at play here, so let's restrict the discussion to the plain IEnumerable LINQ-to-Objects provider. Further, let's assume that any Func passed in as a selector / mutator / etc. is a cheap O(1) operation. It seems obvious that all the single-pass operations (Select, Where, Count, Take/Skip, Any/All, etc.) will be O(n), since they only need to walk the sequence once; although even this is subject to laziness. Things are murkier for the more complex operations; the set-like operators (Union, Distinct, Except, etc.) work using GetHashCode by default (afaik), so it seems reasonable to assume they're using a hash-table internally, making these operations O(n) as well, in general. What about the versions that use an IEqualityComparer? OrderBy would need a sort, so most likely we're looking at O(n log n). What if it's already sorted? How about if I say OrderBy().ThenBy() and provide the same key to both? I could see GroupBy (and Join) using either sorting, or hashing. Which is it? Contains would be O(n) on a List, but O(1) on a HashSet - does LINQ check the underlying container to see if it can speed things up? And the real question - so far, I've been taking it on faith that the operations are performant. However, can I bank on that? STL containers, for example, clearly specify the complexity of every operation. Are there any similar guarantees on LINQ performance in the .NET library specification?

    Read the article

  • Optional mix of filter parameters in a search the Rails way.

    - by GSP
    I've got a simple list page with a couple of search filters status which is a simple enumeration and a test query which I want to compare against both the title and description field of my model. In my controller, I want to do something like this: def index conditions = {} conditions[:status] = params[:status] if params[:status] and !params[:status].empty? conditions[???] = ["(descr = ? or title = ?)", params[:q], params[:q]] if params[:q] and !params[:q].empty? @items = Item.find(:all, :conditions => conditions) end Unfortunately, it doesn't look like I can mix the two types of conditions (the hash and the paramatized version). Is there a "Rails Way" of doing this or do I simply have to do something awful like this: has_status = params[:status] and !params[:status].empty? has_text = params[:q] and !params[:q].empty? if has_status and !has_text # build paramatized condition with just the status elsif has_text and !has_status # build paramatized condition with just the text query elsif has_text and has_status # build paramatized condition with both else # build paramatized condition with neither end I'm migrating from Hibernate and Criteria so forgive me if I'm not thinking of this correctly... Environment: Rails 2.3.4

    Read the article

  • Jquery Ajax refresh not working in IE.

    - by Probocop
    Hi, I have a <ul> which refreshes every ten seconds to check if there have been any new tweets (its pulling from a twitter feed). This works fine in Firefox and Chrome etc, but it does not work in any version if Internet Explorer. My code is as follows: setInterval(function() { $("#banter .scroll-pane").load(location.href+" #banter .scroll-pane>*",""); }, 10000); My PHP function creating the list is as follows: function showTweets($section, $limit, $class) { $result = mysql_query("SELECT * FROM hash WHERE section = '".$section."' ORDER BY date DESC LIMIT ".$limit); echo '<ul class="scroll-pane '.$class.'">'; while($row = mysql_fetch_array($result)) { echo '<li>'; echo '<p>'.html_entity_decode($row['tweet']).'</p>'; echo '<a href="'.$row['user_url'].'">'.$row['user'].'</a>'; echo '</li>'; } echo '</ul>'; } Any idea what's going wrong? Thanks

    Read the article

< Previous Page | 120 121 122 123 124 125 126 127 128 129 130 131  | Next Page >