Search Results

Search found 3440 results on 138 pages for 'returning'.

Page 45/138 | < Previous Page | 41 42 43 44 45 46 47 48 49 50 51 52  | Next Page >

  • When should one use "out" parameters?

    - by qegal
    In Objective-C, there are several methods like initWithContentsOfFile:encoding:error: where one passes in a reference to an NSError object for the error: parameter. In this example, the value of the NSError object passed in can change based on what goes on at runtime when the method is being called and whether the body of the method was executed in a certain way successfully. In a way I think of this NSError object as sort of like a second return value from the method, and only differs from an object anObject in the statement return anObject; in that when this statement is called, execution leaves the method. So my question is, not only in the context of error handling in Objective-C, but in general, when should one use an "out" parameter in place of returning said value in a return statement?

    Read the article

  • Avoiding null in a controller

    - by Kevin Burke
    I'm trying to work through how to write this code. def get(params): """ Fetch a user's details, or 404 """ user = User.fetch_by_id(params['id']) if not user: abort(404) # Render some template for the user... What's the best way to handle the case where the lookup fails? One principle says you should avoid returning null values from functions. These lead to mistakes and AttributeErrors etc. later on in the file. Another idea is to have fetch_by_id raise a ValueError or similar if no user exists with that id. However there's a general principle that you shouldn't use exceptions for control flow, either, which doesn't help much. What could be done better in this case?

    Read the article

  • How do I convert matrices intended for OpenGL to be compatible for DirectX?

    - by gardian06
    I have finished working through the book "Game Physics Engine Development 2nd Ed" by Millington, and have got it working, but I want to adapt it to work with DirectX. I understand that D3D9+ has the option to use either left handed, or right handed convention, but I am unsure about how to return my matrices to be usable by D3D. The source code gives returning OpenGL column major matrices (the transpose of the working transform matrix shown below), but DirectX is row major. For those unfamiliar for the organization of the matrices used in the book: [r11 r12 r13 t1] [r21 r22 r23 t2] [r31 r32 r33 t3] [ 0 0 0 1] r## meaning the value of that element in the rotation matrix, and t# meaning the translation value. So the question in short is: How do I convert the matrix above to be easily usable by D3D? All of the documentation that I have found simply states that D3D is row major, but not where to put what elements so that it is usable by D3D in terms of rotation, and translation elements.

    Read the article

  • Getting the front buffer into a gfx mem surface (Dx9)

    - by lapin
    I'm using DirectX 9 to acquire the frontbuffer. There are a couple of ways I know of to get at the front buffer: GetRenderTargetData() GetFrontBufferData() The MSDN page on both of these API calls state that the data is copied from device memory to system memory. I'd like to copy the front buffer surface directly to another graphics memory surface, as I have other manipulations to perform on the acquired surface before returning it to system memory. I'm creating a D3DUSAGE_DYNAMIC texture (gfx mem texture) and calling GetFrontBufferData() to write the front buffer to my textures surface0. Is this valid? Will the operation remain in gfx memory, or will it need to move to system memory and then back to graphics memory? If this is the case, is what I'm trying to achieve possible?

    Read the article

  • Do I need the 'w' component in my Vector class?

    - by bobobobo
    Assume you're writing matrix code that handles rotation, translation etc for 3d space. Now the transformation matrices have to be 4x4 to fit the translation component in. However, you don't actually need to store a w component in the vector do you? Even in perspective division, you can simply compute and store w outside of the vector, and perspective divide before returning from the method. For example: // post multiply vec2=matrix*vector Vector operator*( const Matrix & a, const Vector& v ) { Vector r ; // do matrix mult r.x = a._11*v.x + a._12*v.y ... real w = a._41*v.x + a._42*v.y ... // perspective divide r /= w ; return r ; } Is there a point in storing w in the Vector class?

    Read the article

  • URL parameter names being changed by user agents

    - by Mike Deck
    In reviewing one of our site's web logs I'm seeing instances where we are returning a 404 to requests because we're expecting an id parameter to be sent, but instead we're seeing a di parameter. The resource in question is an image but which image file actually gets served is dependent on the id parameter. The expected url is something like http://images.mysite.com/photo.gif?id=123&width=200&height=300 What I'm seeing in the logs is requests for http://images.mysite.com/photo.gif?di=123&width=200&height=300 The only case where we are seeing this on the id parameter. It seems unlikely that this is due to a server side or JavaScript bug since it seems to be only effecting a small percentage of our traffic. We are seeing this across a wide variety of user agents (both mobile and desktop) and IPs. Has anyone else seen this? Is there a browser plugin or other software you're aware of that could be causing this, and if so is there a good way to work around the issue?

    Read the article

  • Not enough space left in the hard drive. How to proceed?

    - by jimbobjgr
    Where do I begin... I can hardly do anything on Ubuntu 12.04. I am very close to removing and returning to Windows. First I could not load it because the graphics appeared to be running low but somehow that stopped happening and I could log on. Now I can not download anything or I get this message Cannot write: No space left on device. I tried trouble shooting this issue but every time I try and fix the problem I am blocked by this message E: Write error - write (28: No space left on device) E: Can't mmap an empty file E: Failed to truncate file - ftruncate (9: Bad file descriptor) E: The package lists or status file could not be parsed or opened. $ OLD=$(ls -tr /boot/vmlinuz-* | head -n -2 | cut -d- -f2- | awk '{print "linux-image-" $0}') Ubuntu is also running incredibly slow and I cant get anything done! Please help this is driving me mad!

    Read the article

  • Let a model instance choose appropriate view class using category. Is it good design?

    - by Denis Mikhaylov
    Assume I have abstract base model class called MoneySource. And two realizations BankCard and CellularAccount. In MoneysSourceListViewController I want to display a list of them, but with ListItemView different for each MoneySource subclass. What if I define a category on MoneySource @interface MoneySource (ListItemView) - (Class)listItemViewClass; @end And then override it for each concrete sublcass of MoneySource, returning suitable view class. @implementation CellularAccount (ListItemView) - (Class)listItemViewClass { return [BankCardListView class]; } @end @implementation BankCard (ListItemView) - (Class)listItemViewClass { return [CellularAccountListView class]; } @end so I can ask model object about its view, not violating MVC principles, and avoiding class introspection or if constructions. Thank you!

    Read the article

  • Calculating angle between 2 vectors

    - by Error 454
    I am working on some movement AI where there are no obstacles and movement is restricted to the XY plane. I am calculating 2 vectors: v - the direction of ship 1 w - the vector pointing from the position of ship 1 to ship 2 I am then calculating the angle between these two vectors using the standard formula: arccos( v . w / ( |v| |w| ) ) The problem I'm having is the nature of arccos only returning values between 0 and 180. This makes it impossible to determine whether I should turn left or right to face the other ship. Is there a better way to do this?

    Read the article

  • How to write loosely coupled classes in node.js

    - by lortabac
    I am trying to understand how to design node.js applications, but it seems there is something I can't grasp about asynchronous programming. Let's say my application needs to access a database. In a synchronous environment I would implement a data access class with a read() method, returning an associative array. In node.js, because code is executed asynchronously, this method can't return a value, so, after execution, it will have to "do" something as a side effect. It will then contain at least 1 line of extraneous code which has nothing to do with data access. Multiply this for all methods and all classes and you will very soon have an unmanageable "code soup". What is the proper way to handle this problem? Am I approaching it the wrong way?

    Read the article

  • Passing class names or objects?

    - by nischayn22
    I have a switch statement switch ( $id ) { case 'abc': return 'Animal'; case 'xyz': return 'Human'; //many more } I am returning class names,and use them to call some of their static functions using call_user_func(). Instead I can also create a object of that class, return that and then call the static function from that object as $object::method($param) switch ( $id ) { case 'abc': return new Animal; case 'xyz': return new Human; //many more } Which way is efficient? To make this question broader : I have classes that have mostly all static methods right now, putting them into classes is kind of a grouping idea here (for example the DB table structure of Animal is given by class Animal and so for Human class). I need to access many functions from these classes so the switch needs to give me access to the class

    Read the article

  • Design pattern: static function call with input/output containers?

    - by Pavlo Dyban
    I work for a company in software research department. We use algorithms from our real software and wrap them so that we can use them for prototyping. Every time an algorithm interface changes, we need to adapt our wrappers respectively. Recently all algorithms have been refactored in such a manner that instead of accepting many different inputs and returning outputs via referenced parameters, they now accept one input data container and one output data container (the latter is passed by reference). Algorithm interface is limited to a static function call like that: class MyAlgorithm{ static bool calculate(MyAlgorithmInput input, MyAlgorithmOutput &output); } This is actually a very powerful design, though I have never seen it in a C++ programming environment before. Changes in the number of parameters and their data types are now encapsulated and they don't change the algorithm callback. In the latest algorithm which I have developed I used the same scheme. Now I want to know if this is a popular design pattern and what it is called.

    Read the article

  • How to work around the home directory changing to /root when using sudo?

    - by Nathanel Titane
    Hello everybody! With Natty coming out soon, I've been at work updating my deployment and self-config script to make my desktop on 11.04 run and look the way I want it to. One bummer is that dbus seems to have changed and does not permit, in the same manner Lucid and Maverick did, the authentication of the current user by terminal call using grep and cat. Ideally, to run the script, I would sudo -s and then launch it as # chmod +x install && ./install Instead of returning my user name.. it now returns root and applies changes to the root profile and aborts whenever paths do not correspond. Here is my script header: #!/bin/bash ON_USER=$(echo ~ | awk -F'/' '{ print $1 $2 $3 }' | sed 's/home//g') export $(grep -v "^#" ~/.dbus/session-bus/`cat /var/lib/dbus/machine-id`-0) if sudo -u $ON_USER test -z "$DBUS_SESSION_BUS_ADDRESS" ; then eval `sudo -u $ON_USER dbus-launch --sh-syntax --exit-with-session` fi RELEASE=$(lsb_release -cs) How could I make it return the actual user now that natty is coming? Thanks for the help

    Read the article

  • Get/Post Controller Logic Best Practice

    - by Brian Mains
    In an ASP.NET MVC project (Razor), I have a Get request, which loads two properties on a model, dependent on the property passed into the action method. So if the parameter has a value, the Group property is supplied data. But if not, the Groups collection property is supplied data. In the post action method, when I process the data, to repopulate the view, I have to provide similar logic, and could getaway with returning Action(param) (the get response) to the caller. My question is, based on experience, is that a good practice to get into? I see some downsides to doing that, but adds the lack of code redundancy. Or is there a better alternative?

    Read the article

  • Black screen with blinking cursor after dual boot install 14.04

    - by chillstream
    I have just installed Ubuntu 14.04 on my toshiba laptop along side Windows 7. When the menu comes up to choose which OS to boot into, I can easily boot into Windows 7. I cannot successfully boot into Ubuntu. All I get is a blinking cursor on a black/purple screen. I attempted the nomodeset trick, which was a bit more successful. I got a screen with a lot of code, but then it stopped with a blinking cursor at the bottom and wouldn't load anymore. As a last resort, would returning my laptop to factory settings get rid of linux and the partitions made to the drive? I already did this to my laptop when it was just windows, which is why I thought I might as well try to add Ubuntu. But it's a lengthy process, and if it won't get rid of the partitions and ubuntu, I won't bother. I appreciate any help ~many thanks

    Read the article

  • cannot install ubuntu 12.04 using wubi

    - by vicky
    I recently installed windows 7 on my pc and I have been unsuccessfully trying to install ubuntu 12.04 on it. I used to have dual boot system before both with windows and linux. I changed my hard drive from ide to ahci (default option) burned the ubuntu cd properly (not the .iso file) using the ubuntu 12.04 distribution I downloaded from the official site, set boot priority to cd/dvd but.. Nothing. It tries to boot from the cd, doesn't manage and turn to boot from the hard drive. I also tried wubi. I opened it through windows, got the window that asks me to choose "demo and installation" or "more on ubuntu" (something like that), I choose the first option, reboot manually my computer and it keeps returning on windows mode and doesn't boot from the cd. What can I do? Thanks!

    Read the article

  • sprite group doesn't support indexing

    - by user3956
    I have a sprite group created with pygame.sprite.Group() (and add sprites to it with the add method) How would I retrieve the nth sprite in this group? Code like this does not work: mygroup = pygame.sprite.Group(mysprite01) print mygroup[n].rect It returns the error: group object does not support indexing. For the moment I'm using the following function: def getSpriteByPosition(position,group): for index,spr in enumerate(group): if (index == position): return spr return False Although working, it just doesn't seem right... Is there a cleaner way to do this? EDIT: I mention a "position" and index but it's not important actually, returning any single sprite from the group is enough

    Read the article

  • implementing a high level function in a script to call a low level function in the game engine

    - by eat_a_lemon
    In my 2d game engine I have a function that does pathfinding, find_shortest_path. It executes for each time step in the game loop and calculates the next coordinate pair in the series of coordinates to reach the destination object. Now I want to call this function in a scripting language and have it only return the last coordinate pair result. I want the game engine to go about the business of rendering the incremental steps but I don't want the high level script to care about the rendering. The high level script is only for ai game logic. Now I know how to bind a method from C to python but how can I signal and coordinate the wait time between the incremental steps without the high level function returning until its time for the last step?

    Read the article

  • When trying running Ubuntu 12.10 off a usb drive, I encounter an error while prevent me from doing anything else

    - by Nil
    The details are that I used Universal USB Installer version 1.9.1.8 from pendrivelinux.com to install ubuntu 12.10 onto a 4gb pendrive as per instruction on Ubuntu's website. However, after I boot with drive I am met with the following message: "The system is running in low-graphics mode. Your screen, graphics card, and input device settings could not be detected correctly. You will need to configure these yourself." Pressing Ctrl Alt F1 doesn't allow me access and the options on the dialog box either send me through a loop returning me to the previous dialog or just leave me dead in the water. Pressing Ctrl Alt Del does however restart the computer if I am dead in the water, so ubuntu isn't COMPLETELY unresponsive... I feel I should mention that I'm trying to run this distribution on my netbook. I can't install it directly to the harddrive since I need my current Windows distribution for certain programs that don't quite agree with WINE yet.

    Read the article

  • Xubuntu - Apps Become Unresponsive Intermittently

    - by Levinaris
    Possibly Relevant Information: XUbuntu 12.04 LTS (precise) XFCE 4.8 AMD Graphics (Kernel driver in use: fglrx_pci, Kernel modules: fglrx, radeon) The primary symptom of this issue has been my active rdesktop session to stop responding while everything else appears to work normally. I have been killing rdesktop and re-launching it, with it freezing after a seemingly random time period. The fastest was within seconds. The longest was a couple hours, although it's usually within a few minutes. That being said, I have occasionally seen the terminal and web browsers also become unresponsive to keyboard input. They respond to clicks and will accept middle clicks (to paste text) without issue while remaining unresponsive to the keyboard input. I have been able to restore all functionality, including rdesktop, by switching workspaces and typing on the other workspace, then returning to the original workspace. What is being reset when I do this? What does this work-around/solution indicate may be the problem?

    Read the article

  • Best Way to Handle Meta Information in a SQL Database

    - by danielhanly.com
    I've got a database where I want to store user information and user_meta information. The reason behind setting it up in this way was because the user_meta side may change over time and I would like to do this without disrupting the master user table. If possible, I would like some advice on how to best set up this meta data table. I can either set it as below: +----+---------+----------+--------------------+ | id | user_id | key | value | +----+---------+----------+--------------------+ | 1 | 1 | email | [email protected] | | 2 | 1 | name | user name | | 3 | 1 | address | test address | ... Or, I can set it as below: +----+---------+--------------------+--------------------+--------------+ | id | user_id | email | name | address | +----+---------+--------------------+--------------------+--------------+ | 1 | 1 | [email protected] | user name | test address | Obviously, the top verison is more flexible, but the bottom version is space saving and perhaps more efficient, returning all the data as a single record. Which is the best way to go about this? Or, am I going about this completely wrong and there's another way I've not thought of?

    Read the article

  • How to get a good picture of the health of a level-based game from analytics?

    - by ADB
    I am designing a level-based game where the user completes the level 1, then 2, 3 and so on. There are 200 levels and each is rather short: 60-ish seconds. I am tracking Each played, completed (cleared for the first time), failed and cleared level Milestones: number of players to reach level 1, 5, 10, etc. Also for number of failed and played levels. Separate new players from returning ones. However, I still find it difficult to get a clear picture of what is going on from the stats. So what are the best practices for determining where I am losing players?

    Read the article

  • T-SQL: @@IDENTITY, SCOPE_IDENTITY(), OUTPUT and other methods of retrieving last identity

    - by Terrapin
    I have seen various methods used when retrieving the value of a primary key identity field after insert. declare @t table ( id int identity primary key, somecol datetime default getdate() ) insert into @t default values select SCOPE_IDENTITY() --returns 1 select @@IDENTITY --returns 1 Returning a table of identities following insert: Create Table #Testing ( id int identity, somedate datetime default getdate() ) insert into #Testing output inserted.* default values What method is proper or better? Is the OUTPUT method scope-safe? The second code snippet was borrowed from SQL in the Wild

    Read the article

  • Separate Query for Count

    - by Anraiki
    Hello, I am trying to get my query to grab multiple rows while returning the maximum count of that query. My query: SELECT *, COUNT(*) as Max FROM tableA LIMIT 0 , 30 However, it is only outputting 1 record. I would like to return multiple record as it was the following query: SELECT * FROM tableA LIMIT 0 , 30 Do I have to use separate queries?

    Read the article

  • HTTP Referrer and IE7 and IE8

    - by cocacola09
    Hi i've tried the following to find the referrer in MSIE / IE7 and IE8 but its returning blank each time; PHP: <? echo $_SERVER['HTTP_REFERER']; ?> JAVASCRIPT: document.write('Thanks for visiting from ' + document.referrer); Does any know what the issue could be I'm referering using document.location from a page on another domain and work fine with all other browsers minus MSIE. Any help would be great!

    Read the article

< Previous Page | 41 42 43 44 45 46 47 48 49 50 51 52  | Next Page >