Search Results

Search found 1369 results on 55 pages for 'sam baker'.

Page 30/55 | < Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >

  • will paginate, nested routes, ruby, rails

    - by Sam
    I'm trying to get will paginate to link to my nested route instead of the regular posts variable. I know I'm supposed to pass some params to paginate but I don't know how to pass them. Basically there is an array stored in @posts and the other param paginate has access to is category_id. The nested route is /category/1/posts but hitting next and previous on will paginate returns a url like this posts?page=1&category_id=7. <%= will_paginate @most_recent_posts "What do I do here?" %> This is the result of Yannis's answer: In your controller you can do: @posts = @category.posts.paginate And in your view: <%= will_paginate(@post) %> Doing this comes up with the following URL posts?page=2&post_category_id=athlete_management routes.rb #there are more routes but these are the relevant ones map.resources :posts map.resources :post_categories, :has_many => :posts solution map.resources :post_categories do |post_category| post_category.resources :posts end map.resources :posts Had to declare the resource after the block Thanks stephen!

    Read the article

  • wxPython, Threads, and PostEvent between modules

    - by Sam Starling
    I'm relatively new to wxPython (but not Python itself), so forgive me if I've missed something here. I'm writing a GUI application, which at a very basic level consists of "Start" and "Stop" buttons that start and stop a thread. This thread is an infinite loop, which only ends when the thread is stopped. The loop generates messages, which at the moment are just output using print. The GUI class and the infinite loop (using threading.Thread as a subclass) are held in separate files. What is the best way to get the thread to push an update to something like a TextCtrl in the GUI? I've been playing around with PostEvent and Queue, but without much luck. Here's some bare bones code, with portions removed to keep it concise: main_frame.py import wx from loop import Loop class MainFrame(wx.Frame): def __init__(self, parent, title): # Initialise and show GUI # Add two buttons, btnStart and btnStop # Bind the two buttons to the following two methods self.threads = [] def onStart(self): x = Loop() x.start() self.threads.append(x) def onStop(self): for t in self.threads: t.stop() loop.py class Loop(threading.Thread): def __init__(self): self._stop = threading.Event() def run(self): while not self._stop.isSet(): print datetime.date.today() def stop(self): self._stop.set() I did, at one point, have it working by having the classes in the same file by using wx.lib.newevent.NewEvent() along these lines. If anyone could point me in the right direction, that'd be much appreciated.

    Read the article

  • Is there any way to use getaddrinfo() and freeaddrinfo() and still be the program compatible with le

    - by Sam C.
    Hi, in the Winsock2 library getaddrinfo() and freeaddrinfo() was only added in Windows XP and on. I know how to replace them in legacy systems, but a conditional use depending on the Windows version won't help. The application won't start in 9x with a message saying that it was linked to a missing export in WS2_32.dll. I'm using MinGW to compile and link the code and would like to keep using it. Maybe writing those functions by myself? Thank you very much for everything.

    Read the article

  • How to stop nant exec task putting ( ) around command line

    - by Sam
    I have looked through the nant documentation and sourceforge faq and can't find the answer to this question. The exec task in nant puts ( ) around the command line parameters it generates, so for example this task below would generate: mallow ( -1 ) <exec program="${build.tools.wix}\mallow.exe" workingdir="${build.out.xxx}"> <arg value="-1" /> </exec> The other open source tool I'm using - mallow - cannot handle this. Does anyone know of a way to stop nant putting the ( ) around the arguments? Thanks.

    Read the article

  • ruby, rails, railscasts example gone bad

    - by Sam
    If you saw the railscasts on nested forms this is the helper method to create links dynamically. However, after I upgraded to ruby 1.9.2 and rails 3 this doesn't work and I have now idea why. def link_to_add_fields(name, f, association) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(association.to_s.singularize + "_fields", :f => builder) end link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")) end here is the javascript function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g") $(link).up().insert({ before: content.replace(regexp, new_id) }); }

    Read the article

  • Why does Chrome incorrectly determine page is in a different language and offer to translate?

    - by Sam
    The new Google Chrome auto-translation feature is tripping up on one page within one of our applications. Whenever we navigate to this particular page, Chrome tells us the page is in Danish and offers to translate. The page is in English, just like every other page in our app. This particular page is an internal testing page that has a few dozen form fields with English labels. I have no idea why Chrome thinks this page is Danish. Does anyone have insights into how this language detection feature works and how I can determine what is causing Chrome to think the page is in Danish?

    Read the article

  • Should I have different models and views for no user data than for some user data?

    - by Sam Holder
    I'm just starting to learn asp.net mvc and I'm not sure what the right thing to do is. I have a user and a user has a collection of (0 or more) reminders. I have a controller for the user which gets the reminders for the currently logged in user from a reminder service. It populates a model which holds some information about the user and the collection of reminders. My question is should I have 2 different views, one for when there are no reminders and one for when there are some reminders? Or should I have 1 view which checks the number of reminders and displays different things? Having one view seems wrong as then I end up with code in my view which says if (Model.Reminders.Count==0){//do something} else {do something else}, and having logic in the view feels wrong. But if I want to have 2 different views then I'd like to have some code like this in my controller: [Authorize] public ActionResult Index() { MembershipUser currentUser = m_membershipService.GetUser(); IList<Reminder> reminders = m_reminderRepository.GetReminders(currentUser); if (reminders.Count == 0) { var model = new EmptyReminderModel { Email = currentUser.Email, UserName = currentUser.UserName }; return View(model); } else { var model = new ReminderModel { Email = currentUser.Email, UserName = currentUser.UserName, Reminders = reminders }; return View(model); } but obviously this doesn't compile as the View can't take both different types. So if I'm going to do this should I return a specific named view from my controller, depending on the emptiness of the reminders, or should my Index() method redirect to other actions like so: [Authorize] public ActionResult Index() { MembershipUser currentUser = m_membershipService.GetUser(); IList<Reminder> reminders = m_reminderRepository.GetReminders(currentUser); if (reminders.Count == 0) { return RedirectToAction("ShowEmptyReminders"); } else { return RedirectToAction("ShowReminders"); } } which seems nicer but then I need to re-query the reminders for the current user in the ShowReminders action. Or should I be doing something else entirely?

    Read the article

  • Single specific string replace method Objective C

    - by Sam
    Hi guys, I wanted to know if theres a single method or way that will help me replace strings for specific characters. like MALE - M FEMALE - F CHILD - P The longer way out is this.. [str stringByreplacingOccurencesOfString:@"MALE" withString:@"M"]; [str stringByreplacingOccurencesOfString:@"FEMALE" withString:@"F"]; [str stringByreplacingOccurencesOfString:@"CHILD" withString:@"P"]; I was wondering if theres another way in which i can reduce lines of code here, specially when there are alots of things to replace. thanks. this is for iPhone OS.

    Read the article

  • Why does 'localhost' in web references cause SocketExceptions?

    - by Sam
    I have two .net web services deployed to the same IIS server using SSL, one that references the other. If I set that web reference to 'localhost', some calls fail with this exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. --- System.Net.WebException: Unable to connect to the remote server --- System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it If I set it to the actual machine name, it works. Why?

    Read the article

  • WPF WriteableBitmap

    - by Sam
    I'm using WriteableBitmap on an image of type Bgra32 to change the pixel value of certain pixels. I'm setting the value to 0x77CCCCCC. After calling WritePixels, the pixels I set to 0x77CCCCCC show up with a value of 0x77FFFFFF. Why does this happen? How do I make the pixels have the correct value?

    Read the article

  • Filtering by category in Magento 1.4

    - by Sam
    Hi All I have a custom module I made to show featured products on the homepage. I set it up to show products that are in a ‘featured’ category. It works fine in 1.3, but now in 1.4 I get the following error: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘e.category_ids’ in ‘where clause’ Here’s my code: $_productCollection = Mage::getResourceModel('reports/product_collection') ->addAttributeToSelect('*') ->addAttributeToFilter('visibility', $visibility) ->addAttributeToFilter('category_ids',array('finset'=>$featuredcategory)) $_productCollection->load(); The featured category is specified from the admin. Anyone any ideas what might be up?

    Read the article

  • C# windows client get registry value

    - by sam
    I have a c# windows client app packaged using ClickOnce. Using c# how can I programmatically get the registry entry for that application? As I am wanting to write a registry entry for a child app NEAR the same location

    Read the article

  • Get list of users belonging to a role using Authorization Manager (AzMan)

    - by Sam
    Using ASP.NET (C#) I have set up Authorization Manager to allow me to handle roles on a website. Added users to roles is simple Roles.AddUserToRole("DOMAIN\\UserName", "role"). However I want to list the users belonging to a role, but since they are stored as SID's, displaying them would not be that helpful. To get the users, I am thinking XML would have to be used, although is it possible to use COM Interop to both do that and get the user name? Either way, how can I get the users belonging to a role? The table to manage roles would basically be like this: Role User ---- ---- admin DOMAIN\UserName [delete] DOMAIN\UserName2 [delete] [add user text box] news DOMAIN\UserName3 [delete] [add user text box]

    Read the article

  • Converting a Doc object into a string in python

    - by Sam
    I'm using minidom to parse through an xml document. I took the data with yum tags and stored them in a list and calculated the frequency of the words. However, its not storing or reading them as strings in the list. Is there another way to do it? Right now this is what I have: yumNodes = [node for node in doc.getElementsByTagName("yum")] for node in yumNodes: yumlist.append(t.data for t in node.childNodes if t.nodeType == t.TEXT_NODE) for ob in yumlist: for o in ob: if word not in freqDict: freqDict[word] = 1 else: freqDict[word] += 1

    Read the article

  • Line smoothing in Cocoa Touch

    - by Sam Kaplan
    How would I smooth a line (UIBeizerPath) or a set of points? Right now it draws it jagged. I read about spline interpolation, could anyone point me to an implementation of this in cocoa or C or give me an alternate line smoothing algorithm.

    Read the article

  • PlaySystemSound with mute switch on

    - by Sam V
    I know, I have to set the AudioSession to the 'playback' category, which allows audio even when the mute switch is on. This is what I do, but sound still gets muted when switch is on. UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback; AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,sizeof(sessionCategory), &sessionCategory); SystemSoundID soundID; NSString *path = [[NSBundle mainBundle] pathForResource:soundString ofType:@"wav"]; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path],&soundID); AudioServicesPlaySystemSound (soundID);

    Read the article

  • Is there any way to combine transparency and "ajax usability" with HTML templates

    - by Sam
    I'm using HTML_Template_Flexy in PHP but the question should apply to any language or template library. I am outputting a list of relatively complex objects. In the beginning I just iterated over a list of the objects and called a toHtml method on them. When I was about to have my layout designer look over the template I noticed that it was too opaque and that he would have ended up looking through and/or editing many additional php source files to see what really gets generated by the toHtml method. So I extracted most of the HTML strings in the php classes up to the template which made for one clear file where you can see the whole page structure at once. However this causes problems when you want to add an object to the list using javascript. Then I have to keep the old toHtml method and maintain both the main template and the html strings at the same time, so I can output just the HTML for a new object that should be added to the page. So I'm back to the idea of using smaller templates for the objects that make up the page, but I was wondering if there was some easy way of having my cake and eating it too by having one template that shows the whole page but also the mini-templates for smaller objects on the page. Edit: Yes, updating the page is not a problem at all. My concern is with having both maintainability and transparency of the template files. If I have one single template for the whole page, then I must maintain mini-templates of the objects that are shown on the page. If I just have the mini-templates and include them from the higher-level template it becomes more difficult to look at the top-level html and imagine what the end result will look like.

    Read the article

  • Options for non-native form inputs for the web?

    - by Sam Lee
    I'm wondering if there are any good non-native form inputs for web development? I am currently using the built in <input> controls. They work just fine, but for my application they are too big (especially on OS X). I am wondering if there are any libraries that I can drop in as replacements. I am especially interested in ones that: Are a close to native control behavior as possible. Support for tabbing, highlighting current textbox, pressing up/down in <select>, etc. Have something that replicates <select> Look good and are compact I am aware that you can use CSS for some styling, but it's pretty minimal and looks different depending on the browser. Thanks for your help.

    Read the article

  • Locating memory leak in Apache httpd process, PHP/Doctrine-based application

    - by Sam
    I have a PHP application using these components: Apache 2.2.3-31 on Centos 5.4 PHP 5.2.10 Xdebug 2.0.5 with Remote Debugging enabled APC 3.0.19 Doctrine ORM for PHP 1.2.1 using Query Caching and Results Caching via APC MySQL 5.0.77 using Query Caching I've noticed that when I start up Apache, I eventually end up 10 child processes. As time goes on, each process will grow in memory until each one approaches 10% of available memory, which begins to slow the server to a crawl since together they grow to take up 100% of memory. Here is a snapshot of my top output: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1471 apache 16 0 626m 201m 18m S 0.0 10.2 1:11.02 httpd 1470 apache 16 0 622m 198m 18m S 0.0 10.1 1:14.49 httpd 1469 apache 16 0 619m 197m 18m S 0.0 10.0 1:11.98 httpd 1462 apache 18 0 622m 197m 18m S 0.0 10.0 1:11.27 httpd 1460 apache 15 0 622m 195m 18m S 0.0 10.0 1:12.73 httpd 1459 apache 16 0 618m 191m 18m S 0.0 9.7 1:13.00 httpd 1461 apache 18 0 616m 190m 18m S 0.0 9.7 1:14.09 httpd 1468 apache 18 0 613m 190m 18m S 0.0 9.7 1:12.67 httpd 7919 apache 18 0 116m 75m 15m S 0.0 3.8 0:19.86 httpd 9486 apache 16 0 97.7m 56m 14m S 0.0 2.9 0:13.51 httpd I have no long-running scripts (they all terminate eventually, the longest being maybe 2 minutes long), and I am working under the assumption that once each script terminates, the memory it uses gets deallocated. (Maybe someone can correct me on that). My hunch is that it could be APC, since it stores data between requests, but at the same time, it seems weird that it would store data inside the httpd process. How can I track down which part of my app is causing the memory leak? What tools can I use to see how the memory usage is growing inside the httpd process and what is contributing to it?

    Read the article

  • How to modify the attributes by putting dynamic node paths

    - by sam
    I have a code that selects all elements and their child nodes DECLARE @x XML DECLARE @node_no int DECLARE @count int DECLARE @max INT, @i INT EXECUTE return_xml '1', NULL, @x output Declare @temp Table ( id int not null identity(1,1), ParentNodeName varchar(max), NodeName varchar(max), NodeText varchar(max) ) INSERT INTO @temp SELECT t.c.value('local-name(..)', 'varchar(max)') AS ParentNodeName, t.c.value('local-name(.)', 'varchar(max)') AS NodeName, t.c.value('text()[1]', 'varchar(max)') AS NodeText FROM @x.nodes('/booking//*') AS t(c) select * from @temp Now I want to modify the attributs by putting dynamic node paths SET @x.modify (' insert attribute MyId {sql:variable("@i")} as first into (ParentNodeName/NodeName::*[position() = sql:variable("@i")])[1] ') where id = id of temp table any Idea how can I modify my whole xml this way as I am having a untyped xml and have to add an attribute in every node

    Read the article

  • SPPersistedObject and List<T>

    - by Sam
    Hi I want sharepoint to "persist" a List of object I wrote a class SPAlert wich inherit from SPPersistedObject : public class SMSAlert: SPPersistedObject { [Persisted] private DateTime _scheduledTime; [Persisted] private Guid _listId; [Persisted] private Guid _siteID; } Then I wrote a class wich inherit from SPJobDefinition an add a List of my previous object: public sealed class MyCustomJob: SPJobDefinition { [Persisted] private List<SMSAlert> _SMSAlerts; } The problem is : when I call the Update method of y MyCustomJob: myCustomJob.Update(); It throw an exception : message : An object in the SharePoint administrative framework, depends on other objects which do not exist. Ensure that all of the objects dependencies are created and retry this operation. stack at Microsoft.SharePoint.Administration.SPConfigurationDatabase.StoreObject(SPPersistedObject obj, Boolean storeClassIfNecessary, Boolean ensure) at Microsoft.SharePoint.Administration.SPConfigurationDatabase.PutObject(SPPersistedObject obj, Boolean ensure) at Microsoft.SharePoint.Administration.SPPersistedObject.Update() at Microsoft.SharePoint.Administration.SPJobDefinition.Update() at Sigi.Common.AlertBySMS.SmsAlertHandler.ScheduleJob(SPWeb web, SPAlertHandlerParams ahp) inner exception An object in the SharePoint administrative framework depends on other objects which do not exist. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Dependencies1_Objects". The conflict occurred in database "SharePoint_Config, table "dbo.Objects", column 'Id'. The statement has been terminated. Can anyone help me with that??

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >