Daily Archives

Articles indexed Sunday June 6 2010

Page 4/76 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • rails ajax redirect

    - by badnaam
    Here is my use case I have a search model with two actions search_set and search_show. 1 - A user loads the home page which contains a search_form, rendered via a partial (search_form). 2 - User does a search, and the request goes to search_set, the search is saved and a redirect happens to search_show page which again renders the search_form with the saved search preferences. This search form is different than the one if step1, because it's a remote form being submitted to the same action (search set) 3 - Now the user does another search, and the search form is submitted via ajax to the search_set action. The search is saved and executed and now I need to present the result via rjs templates (corresponding to search_show). I am told that if the request is xhr then I can't redirect to the search_show action? Is that right? If yes, how do I handle this? Here is my controller class http://pastie.org/993460 Thanks

    Read the article

  • Embedded ZXing - what am I missing?

    - by Brian515
    Hi all, Sorry if this has been answered before, but I am trying to make an application that will include the ability to scan barcodes on Android. I'm looking at using ZXing as the library, however, I want to embed the scanner in my application so that the user doesn't have to have the ZXing barcode scanner installed to use my application. From the description of ZXing, it sounds like this is possible. I've gotten as far as building ZXing, linking it into my project in Eclipse, then creating a new reader instance. However, I'm lost when it comes to starting the barcode reader and implementing the callbacks. IMO, this is when the documentation here gets hazy. If someone could explain how to use ZXing properly, that would be of great help. Cheers!

    Read the article

  • Same data being returned by linq for 2 different executions of a stored procedure?

    - by Paul
    Hello I have a stored procedure that I am calling through Entity Framework. The stored procedure has 2 date parameters. I supply different argument in the 2 times I call the stored procedure. I have verified using SQL Profiler that the stored procedure is being called correctly and returning the correct results. When I call my method the second time with different arguments, even though the stored procedure is bringing back the correct results, the table created contains the same data as the first time I called it. dtStart = 01/08/2009 dtEnd = 31/08/2009 public List<dataRecord> GetData(DateTime dtStart, DateTime dtEnd) { var tbl = from t in db.SP(dtStart, dtEnd) select t; return tbl.ToList(); } GetData((new DateTime(2009, 8, 1), new DateTime(2009, 8, 31)) // tbl.field1 value = 45450 - CORRECT GetData(new DateTime(2009, 7, 1), new DateTime(2009, 7, 31)) // tbl.field1 value = 45450 - WRONG 27456 expected Is this a case of Entity Framework being clever and caching? I can't see why it would cache this though as it has executed the stored procedure twice. Do I have to do something to close tbl? using Visual Studio 2008 + Entity Framework. I also get the message "query cannot be enumerated more than once" a few times every now and then, am not sure if that is relevant? FULL CODE LISTING namespace ProfileDataService { public partial class DataService { public static List<MeterTotalConsumpRecord> GetTotalAllTimesConsumption(DateTime dtStart, DateTime dtEnd, EUtilityGroup ug, int nMeterSelectionType, int nCustomerID, int nUserID, string strSelection, bool bClosedLocations, bool bDisposedLocations) { dbChildDataContext db = DBManager.ChildDataConext(nCustomerID); var tbl = from t in db.GetTotalConsumptionByMeter(dtStart, dtEnd, (int) ug, nMeterSelectionType, nCustomerID, nUserID, strSelection, bClosedLocations, bDisposedLocations, 1) select t; return tbl.ToList(); } } } /// CALLER List<MeterTotalConsumpRecord> _P1Totals; List<MeterTotalConsumpRecord> _P2Totals; public void LoadData(int nUserID, int nCustomerID, ELocationSelectionMethod locationSelectionMethod, string strLocations, bool bIncludeClosedLocations, bool bIncludeDisposedLocations, DateTime dtStart, DateTime dtEnd, ReportsBusinessLogic.Lists.EPeriodType durMainPeriodType, ReportsBusinessLogic.Lists.EPeriodType durCompareToPeriodType, ReportsBusinessLogic.Lists.EIncreaseReportType rptType, bool bIncludeDecreases) { ///Code for setting properties using parameters.. _P2Totals = ProfileDataService.DataService.GetTotalAllTimesConsumption(_P2StartDate, _P2EndDate, EUtilityGroup.Electricity, 1, nCustomerID, nUserID, strLocations, bIncludeClosedLocations, bIncludeDisposedLocations); _P1Totals = ProfileDataService.DataService.GetTotalAllTimesConsumption(_StartDate, _EndDate, EUtilityGroup.Electricity, 1, nCustomerID, nUserID, strLocations, bIncludeClosedLocations, bIncludeDisposedLocations); PopulateLines() //This fills up a list of objects with information for my report ready for the totals to be added PopulateTotals(_P1Totals, 1); PopulateTotals(_P2Totals, 2); } void PopulateTotals(List<MeterTotalConsumpRecord> objTotals, int nPeriod) { MeterTotalConsumpRecord objMeterConsumption = null; foreach (IncreaseReportDataRecord objLine in _Lines) { objMeterConsumption = objTotals.Find(delegate(MeterTotalConsumpRecord t) { return t.MeterID == objLine.MeterID; }); if (objMeterConsumption != null) { if (nPeriod == 1) { objLine.P1Consumption = (double)objMeterConsumption.Consumption; } else { objLine.P2Consumption = (double)objMeterConsumption.Consumption; } objMeterConsumption = null; } } } }

    Read the article

  • What does drag lock do in boot camp?

    - by MacBookNewb
    In the control panel for my mac book pro I have an icon called Boot camp. Inside there and inside the trackpad tab I have an option called drag lock. It sounds useful to me as I sometimes find it awkward dragging long distances. I can't figure out how to use it though. Can someone explain how I can find out more info on drag lock? I can't find any references on google. Also even without the dragging option on I can drag.

    Read the article

  • SQL SERVER – Subquery or Join – Various Options – SQL Server Engine knows the Best

    - by pinaldave
    This is followup post of my earlier article SQL SERVER – Convert IN to EXISTS – Performance Talk, after reading all the comments I have received I felt that I could write more on the same subject to clear few things out. First let us run following four queries, all of them are giving exactly same resultset. USE AdventureWorks GO -- use of = SELECT * FROM HumanResources.Employee E WHERE E.EmployeeID = ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- use of in SELECT * FROM HumanResources.Employee E WHERE E.EmployeeID IN ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- use of exists SELECT * FROM HumanResources.Employee E WHERE EXISTS ( SELECT EA.EmployeeID FROM HumanResources.EmployeeAddress EA WHERE EA.EmployeeID = E.EmployeeID) GO -- Use of Join SELECT * FROM HumanResources.Employee E INNER JOIN HumanResources.EmployeeAddress EA ON E.EmployeeID = EA.EmployeeID GO Let us compare the execution plan of the queries listed above. Click on image to see larger image. It is quite clear from the execution plan that in case of IN, EXISTS and JOIN SQL Server Engines is smart enough to figure out what is the best optimal plan of Merge Join for the same query and execute the same. However, in the case of use of Equal (=) Operator, SQL Server is forced to use Nested Loop and test each result of the inner query and compare to outer query, leading to cut the performance. Please note that here I no mean suggesting that Nested Loop is bad or Merge Join is better. This can very well vary on your machine and amount of resources available on your computer. When I see Equal (=) operator used in query like above, I usually recommend to see if user can use IN or EXISTS or JOIN. As I said, this can very much vary on different system. What is your take in above query? I believe SQL Server Engines is usually pretty smart to figure out what is ideal execution plan and use it. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL Joins, SQL Optimization, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Listen to any change in the values of an Object in Actionscript

    - by Ali
    Hi All, I have an Object in actionscript which has a few dozens of properties each of which is defined to be bindable and has its own change event. I would like to listen to any changes made to this object without having to add a listener to all of its properties. Is there a way in actionscript using which I can listen to any change in the values of an Object ? Thanks, -A

    Read the article

  • image_to_function in Rails

    - by FCastellanos
    I have this method on rails so that I have an image calling a javascript function def image_to_function(name, function, html_options = {}) html_options.symbolize_keys! tag(:input, html_options.merge({ :type => "image", :src => image_path(name), :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};" })) end I grabbed this code from the application helper of the redmine source code, the problem I'm having is that when I click on the image it's sending a POST, does some one know how can I stop that? This is how I'm using it <%= image_to_function "eliminar-icon.png", "mark_for_destroy(this, '.task')" %> Thanks alot!

    Read the article

  • OpenGL behaving strangely

    - by Mk12
    OpenGL is acting very strangely for some reason. In my subclass of NSOpenGLView, I have the following code in -prepareOpenGL: - (void)prepareOpenGL { GLfloat lightAmbient[] = { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat lightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat lightPosition[] = { 0.0f, 0.0f, 2.0f }; quality = 0; zCoord = -6; [self loadTextures]; glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.2f, 0.2f, 0.2f, 0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glLightfv(GL_LIGHT1, GL_AMBIENT, lightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, lightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition); glEnable(GL_LIGHT1); gameState = kGameStateRunning; int i = 0; // HERE ******** [NSTimer scheduledTimerWithTimeInterval:0.03f target:self selector:@selector(processKeys) userInfo:nil repeats:YES]; // Synchronize buffer swaps with vertical refresh rate GLint swapInt = 1; [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // Setup and start displayLink [self setupDisplayLink]; } I wanted to assign the timer that processes key input to an ivar so that I could invalidate it when the game is paused (and reinstantiate it on resume), however when I did that (as apposed to leaving it at [NSTimer scheduledTimer…), OpenGL doesn't display the cube I draw. When I take it away, it's fine. So i tried just adding a harmless statement, int i = 0; (maked // HERE *******), and that makes the lighting not work! When I take it away, everything is fine, but when I put it back, everything is dark. Can someone come up with a rational explanation for this? Thanks.

    Read the article

  • how to open jquery ui dialog automatically when the page loads?

    - by rgksugan
    I need my dialog to open when the page is loaded automatically. What is the way to do it using jquery. Without any user interaction to open it. I tried this code but it dint work <script type="text/javascript" src="script/jquery-1.4.2.min.js"></script> <link type="text/css" href="css/jquery-ui-1.8.1.custom.css" rel="stylesheet" /> <script type="text/javascript" src="script/jquery-ui-1.8.1.custom.min.js"></script> <script type="text/javascript" src="script/jquery-ui.dialog.js"></script> <script type="text/javascript" src="script/jquery.bgiframe-2.1.1.js"></script> <script type="text/javaScript"> $(function(){ $('#dialog').dialog({ autoOpen: false, width: 600, buttons: { "Ok": function() { $(this).dialog("close"); } } }); $('#dialog').dialog('open'); }); </script> Please help.

    Read the article

  • Addicted to Oil

    30 years ago, Brazil imported 80% of its oil. With a strong sense of purpose, Brazil invested heavily in bio-fuel technology and refocused its transportation energy towards a resource Brazil could manufacture internallysugar based ethanol. Today, Brazil uses flexible fuel vehicles that can run on gas, ethanol, or any combination of the two. It still has a mandate to be 100% independent of oil in 2011. Yes, Brazil still drills for oil, and they still use it - plenty of it. But at least they've had...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • EEE PC dropbox server running 24/7

    - by microspino
    I'd like to create a mini dropbox and print server on a small soho network of 5 users (all of them use windows XP desktops). The device need to run 24/7 or at least 12/7 (I can accept just workday hours too but the other two options would be better). Dropbox mini server: I mean I will have a 90gb dropbox on every computer on my network LAN syncing with It and the one onto It syncing to the web. Print Server: I have Samsung SCX 4521F (fax/print/scan/copy), Samsung ML2010, HP Laser jet P1006, HP Color Laserjet CP1215, HP Office jet pro K8600, HP Design jet 500. All of them now are connected using little print servers and I want to get rid of them hooking everything to this mini server. The fax/print/scan/copy machine need to stay connected to a PC to make me able to use the software that comes with It. The mini server would save me on this too. Fax/Scan server: since I have the above mentioned fax/print/scan/copy machine I would like to make people use It from/to their computers through the mini server. I thought to a recent EEEBOX machine because I heard good things about ATOM cpus and because It seems that a recent BIOS version could switch It off and on autonomously. I'd like to listen some advice from You. Best of all would be: If You have something similar running for a long time If You disagree with this hardware choice and If You would suggest some other device. If You see any issues with my printing setup Anything else ;) My budget is from Zero (using right sw to build something on top on a old PC) to 500€ max.

    Read the article

  • AjaxControlToolkit 3.0.30930.0 vs System.web.extension

    - by John
    Hi, I recently started to use AjaxControlToolkit v3.0.30930.0 in my application together with System.Web.Extension 3.5. My development environment is Visual Studio 2005, .NET Framework 2.0 and the development language is C#. The Ajax control I used is the ModalPopupExtender. I also used the UpdatePanel and updateprogress controls. Everything is working fine on my development machine. But I got a problem after I deployed the application to a server which does not have System.Web.Extension 3.5 installed, which is understandable. My question is, can the ajax controls I used work without System.Web.Extension 3.5? Say I revert the ajaxcontroltoolkit back to version 1.0.61025.0? I don't have the option to install .NET 3.5 as yet. Thank you for your help. John

    Read the article

  • What's the standard algorithm for syncing two lists of objects?

    - by Oliver Giesen
    I'm pretty sure this must be in some kind of text book (or more likely in all of them) but I seem to be using the wrong keywords to search for it... :( A common task I'm facing while programming is that I am dealing with lists of objects from different sources which I need to keep in sync somehow. Typically there's some sort of "master list" e.g. returned by some external API and then a list of objects I create myself each of which corresponds to an object in the master list. Sometimes the nature of the external API will not allow me to do a live sync: For instance the external list might not implement notifications about items being added or removed or it might notify me but not give me a reference to the actual item that was added or removed. Furthermore, refreshing the external list might return a completely new set of instances even though they still represent the same information so simply storing references to the external objects might also not always be feasible. Another characteristic of the problem is that both lists cannot be sorted in any meaningful way. You should also assume that initializing new objects in the "slave list" is expensive, i.e. simply clearing and rebuilding it from scratch is not an option. So how would I typically tackle this? What's the name of the algorithm I should google for? In the past I have implemented this in various ways (see below for an example) but it always felt like there should be a cleaner and more efficient way. Here's an example approach: Iterate over the master list Look up each item in the "slave list" Add items that do not yet exist Somehow keep track of items that already exist in both lists (e.g. by tagging them or keeping yet another list) When done iterate once more over the slave list Remove all objects that have not been tagged (see 4.) Update Thanks for all your responses so far! I will need some time to look at the links. Maybe one more thing worthy of note: In many of the situations where I needed this the implementation of the "master list" is completely hidden from me. In the most extreme cases the only access I might have to the master list might be a COM-interface that exposes nothing but GetFirst-, GetNext-style methods. I'm mentioning this because of the suggestions to either sort the list or to subclass it both of which is unfortunately not practical in these cases unless I copy the elements into a list of my own and I don't think that would be very efficient. I also might not have made it clear enough that the elements in the two lists are of different types, i.e. not assignment-compatible: Especially, the elements in the master list might be available as interface references only.

    Read the article

  • Rails routing/polymorphism issue - how to model the following

    - by 46and2
    Hi all, I have an app where a 'user' belong to a 'client' or a 'vendor' (and client and vendor has_many users). In the admin namespace, I want to administer these users - so an admin would choose a client or a vendor, then nav to that client's or vendor's users. My question is, short of making the user model polymorphic, how could I model/route this? Here is what I have in terms of routing: map.namespace :admin do |admin| admin.resources :clients admin.resources :vendors end I know I could do something like: map.namespace :admin do |admin| admin.resources :clients do |client| client.resources :users admin.resources :vendors do |vendor| vendor.resources :users end end But the above would definitely need me to treat the User as polymorphic. I'm just wondering what you would recommend or what my options are. Thanks.

    Read the article

  • How do I stub a view in rspec-2

    - by Trey Bean
    I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that stubbing a view helper method has changed in Rspec 2. It looks like instead of doing template.stub!, we're now supposed to do view.stub!, but I can't seem to get this to work on beta 10. I get an "undefined local variable or method `view' for # < RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1:0x106785fd0" error. I see that in this commit David removed the view method, but I can't figure out what it was replaced with. Something in ActionView::TestCase::Behavior? I'm on rails 3.0.0.beta3. Any idea what I'm missing?

    Read the article

  • Can someone give me an overview of ASP.net and how it's different from technologies such as php?

    - by DavidR
    I've been doing the html and css for a site, sending it off to a guy to implement in a web server. I get a call from the designer freaking out about the progress, saying the clients aren't happy. He wants me to personally integrate my css with what's on the site. The site is done in ASP.net, time is short, and I'm a little in over my head. I have an understanding of how php works, but have never worked extensively with it. Looking at the stuff on the ftp, I can't even find equivalent of the index.html file (I know that when I go to the site itself, there is nothing after the base url, i.e., www.site.com/ brings me to the homepage.) Can anyone give me a few tips or links as to what I am to do with this, or where to even being navigating this site?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >