Search Results

Search found 97 results on 4 pages for 'bobobobo'.

Page 4/4 | < Previous Page | 1 2 3 4 

  • Is it kEatSpeed or kSpeedEat?

    - by bobobobo
    I have a bunch of related constants that are not identical. What's the better way to name them? way #1 kWalkSpeed kRunSpeed kEatSpeed kDrinkSpeed Or, way #2 kSpeedWalk kSpeedRun kSpeedEat kSpeedDrink If we evaluate these based on readability understandability not bug prone with subtle errors due to using wrong variable name I think way #1 wins readability, they tie for understandability, and way #2 wins for not bug prone. I'm not sure how often it happens to others, but when variable names like this get long, then its easy to write kSpeedEatingWhenInAHurry when you really meant kSpeedEatingWhenInHome, especially when using autocomplete. Any perspectives?

    Read the article

  • Make floating element "maximally wide"

    - by bobobobo
    I have some floating elements on a page. What I want is the div that is floated left to be "maximally wide" so that it is as wide as it possibly can be without causing the red div ("I go at the right") to spill over onto the next line. An example is here: The width:100%; doesn't produce the desired effect! ** I don't want the green element ("I want to be as wide as possible") to go "under" the red element. Its very important that they both stay separate i.e. .. I think they must both be floated! <div class="container"> <div class="a1">i go at the right</div> <div class="a2">i want to be as wide as possible,</div> <div class="clear"></div> </div> <style> div { border: solid 2px #000; background-color: #eee; margin: 8px; padding: 8px; } div.a1 { float:right; background-color: #a00; border: solid 2px #f00; margin: 12px; padding: 6px; } div.a2 { float: left; /*width: 100%;*/ /*this doens't produce desired effect!*/ background-color: #0b0; border: solid 2px #0f0; margin: 12px; padding: 14px; } .clear { border: none; padding: 0 ; margin: 0; clear:both; } </style>

    Read the article

  • SQL concatenate rows query

    - by bobobobo
    Say we have a table table posts +---------+-----------+--------------------------------+ | postId | title | status | bodyText | +---------+-----------+--------------------------------+ | 1 | Hello! | deleted | A deleted post! | | 2 | Hello 2! | deleted | Another one! | Can we, in SQL, retrieve a concatenation of a field across rows, by issuing a single query, not having to do the join up in a loop in our back-end code? Something like select title from posts group by status ; Should give "Hello!, Hello 2!"

    Read the article

  • MySQL function return more than 1 row

    - by bobobobo
    I'd like to write a MySQL stored function that returns multiple rows of data. Is this possible? It seems to be locked at 1 row -- can't even return 0 rows. For example DELIMITER // create function go() RETURNS int deterministic NO SQL BEGIN return null ; -- this doesn't return 0 rows! it returns 1 row -- return 0 ; END // DELIMITER ; Returning null from a MySQL stored proc though, doesn't return 0 rows.. it returns 1 row with the value null in it. Can I return 0, or more than 1 row from a MySQL function, how?

    Read the article

  • DirectX text at (x,y,z)

    - by bobobobo
    In OpenGL, you can actually draw text with an XYZ position, and it will appear at that location, but in a fixed size. If anyone's played MechWarrior 2, they used it there for nav points. The text had a 3d position, but it always appeared a fixed size. The nav point was actually a bit of text at that exact point in space. Other than that the ability to place 3d text was pretty much useless.. you'd always want text to be 2d, righT? I'm finally in a position where I want this feature. I have these points in space that I need to assign text information to, i.e. I need to draw text at a fixed size but with a 3d position. Can this be done from DirectX?

    Read the article

  • The ** idiom in C++ for object construction

    - by bobobobo
    In a lot of C++ API'S (COM-based ones spring to mind) that make something for you, the pointer to the object that is constructed is usually required as a ** pointer (and the function will construct and init it for you) You usually see signatures like: HRESULT createAnObject( int howbig, Object **objectYouWantMeToInitialize ) ; -- but you seldom see the new object being passed as a return value. Besides people wanting to see error codes, what is the reason for this? Is it better to use the ** pattern rather than a returned pointer for simpler operations such as: wchar_t* getUnicode( const char* src ) ; Or would this better be written as: void getUnicode( const char* src, wchar_t** dst ) ; The most important thing I can think of is to remember to free it, and the ** way, for some reason, tends to remind me that I have to deallocate it as well.

    Read the article

  • Function naming: sendCharacter or receiveCharacter?

    - by bobobobo
    I'm trying to name a function that runs when a character is received by the object. For the caller, it should be named sendCharacter, so that it can call: object->sendCharacter( character ) ; That looks nice for the caller.. but for the receiver, it implements a method /// Called when this object is do something /// with a character /// from the caller void sendCharacter( char c ) ; So for the recipient class, it looks like this method will actually send a character out, not receive one. So then, I could call the function receiveCharacter /// Called when this object is do something /// with a character /// from the caller void receiveCharacter( char c ) ; But now the caller does this: object->receiveCharacter( character ) ; Which just looks odd. How can I better name this function?

    Read the article

  • Importing a C DLL's functions into a C++ program

    - by bobobobo
    I have a 3rd party library that's written in C. It exports all of its functions to a DLL. I have the .h file, and I'm trying to load the DLL from my C++ program. The first thing I tried was surrounding the parts where I #include the 3rd party lib in #ifdef __cplusplus extern "C" { #endif and, at the end #ifdef __cplusplus } // extern "C" #endif But the problem there was, all of the DLL file function linkage looked like this in their header files: a_function = (void *)GetProcAddress(dll, "a_function"); While really a_function had type int (*a_function) (int *). Apparently MSVC++ compiler doesn't like this, while MSVC compiler does not seem to mind. So I went through (brutal torture) and fixed them all to the pattern typedef int (*_a_function) (int *); _a_function a_function ; Then, to link it to the DLL code, in main(): a_function = (_a_function)GetProcAddress(dll, "a_function"); This SEEMS to make the compiler MUCH, MUCH happier, but it STILL complains with this final set of 143 errors, each saying for each of the DLL link attempts: error LNK2005: _a_function already defined in main.obj main.obj Multiple symbol definition errors.. sounds like a job for extern! SO I went and made ALL the function pointer declarations as follows: function_pointers.h typedef int (*_a_function) (int *); extern _a_function a_function ; And in a cpp file: function_pointers.cpp #include "function_pointers.h" _a_function a_function ; ALL fine and dandy.. except for linker errors now of the form: error LNK2001: unresolved external symbol _a_function main.obj Main.cpp includes "function_pointers.h", so it should know where to find each of the functions.. I am bamboozled. Does any one have any pointers to get me functional? (Pardon the pun..)

    Read the article

  • MSVC++ enum underlying type

    - by bobobobo
    MSDN has enum [tag] [: type] {enum-list} [declarator]; // for definition of enumerated type SO it looks like you can specify the type of an enum in MSVC++, but it doesn't seem to work for me: // want "underlying type" of this enum to be char. enum MyCharEnum : char { Val1 ='A', Val2 ='B', Val9 ='X' } ;

    Read the article

  • A good way to write unit tests

    - by bobobobo
    So, I previously wasn't really in the practice of writing unit tests - now I kind of am and I need to check if I'm on the right track. Say you have a class that deals with math computations. class Vector3 { public: // Yes, public. float x,y,z ; // ... ctors ... } ; Vector3 operator+( const Vector3& a, const Vector3 &b ) { return Vector3( a.x + b.y /* oops!! hence the need for unit testing.. */, a.y + b.y, a.z + b.z ) ; } There are 2 ways I can really think of to do a unit test on a Vector class: 1) Hand-solve some problems, then hard code the numbers into the unit test and pass only if equal to your hand and hard-coded result bool UnitTest_ClassVector3_operatorPlus() { Vector3 a( 2, 3, 4 ) ; Vector3 b( 5, 6, 7 ) ; Vector3 result = a + b ; // "expected" is computed outside of computer, and // hard coded here. For more complicated operations like // arbitrary axis rotation this takes a bit of paperwork, // but only the final result will ever be entered here. Vector3 expected( 7, 9, 11 ) ; if( result.isNear( expected ) ) return PASS ; else return FAIL ; } 2) Rewrite the computation code very carefully inside the unit test. bool UnitTest_ClassVector3_operatorPlus() { Vector3 a( 2, 3, 4 ) ; Vector3 b( 5, 6, 7 ) ; Vector3 result = a + b ; // "expected" is computed HERE. This // means all you've done is coded the // same thing twice, hopefully not having // repeated the same mistake again Vector3 expected( 2 + 5, 6 + 3, 4 + 7 ) ; if( result.isNear( expected ) ) return PASS ; else return FAIL ; } Or is there another way to do something like this?

    Read the article

  • Metaprogramming on web server

    - by bobobobo
    From time to time, I find myself writing server code that produces JavaScript code as the output result. I can point out why it is really bad: Inextricable tie between server code and client code. Can render client code un-reusable. But sometimes, it just seems to make sense. And isn't it kinda sorta interesting? I guess the question is, is writing server code that produces JavaScript code a really bad practice, or "does everyone do it"?

    Read the article

  • Where do you hang your semantic information, html?

    - by bobobobo
    Well, I keep putting semantic information about what an element means for the page logically in the class attribute <li class="phone-number">555-5555</li> It seems to work for this dual purpose of hanging semantic information and a pointer to how to style it. I'm not sure if this is the best idea, I'm trying to see if others have other ways of doing it. I also started to use a hidden input: <li>555-5555 <input class="semantics" type="hidden" value="phone-number" /></li> inside an element, so with jQuery, I can retrieve additional information about the element using li.find( '.semantics' ).val() To get an element's semantics from JavaScript

    Read the article

  • Have macro 'return' a value

    - by bobobobo
    I'm using a macro and I think it works fine - #define CStrNullLastNL(str) {char* nl=strrchr(str,'\n'); if(nl){*nl=0;}} So it works to zero out the last newline in a string, really its used to chop off the linebreak when it gets left on by fgets. So, I'm wondering if I can "return" a value from the macro, so it can be called like func( CStrNullLastNL( cstr ) ) ; Or will I have to write a function

    Read the article

  • How does make_pair know the types of its args?

    - by bobobobo
    The definition for make_pair in the MSVC++ "utility" header is: template<class _Ty1, class _Ty2> inline pair<_Ty1, _Ty2> make_pair(_Ty1 _Val1, _Ty2 _Val2) { // return pair composed from arguments return (pair<_Ty1, _Ty2>(_Val1, _Val2)); } I use make_pair all the time though without putting the argument types in angle brackets: map<string,int> theMap ; theMap.insert( make_pair( "string", 5 ) ) ; Shouldn't I have to tell make_pair that the first argument is std::string and not char* ? How does it know?

    Read the article

  • C++ code visualization

    - by bobobobo
    A sort of follow up/related question to this. I'm trying to get a grip on a large code base that has hundreds and hundreds of classes and a large inheritance hierarchy. I want to be able to see the "main veins" of the inheritance hierarchy at a glance - not all the "peripheral" classes that only do some very specific / specialized thing. Visual Studio's "View Class Diagram" makes something that looks like a train and its sprawled horizontally across the screen and isn't very organized. You can't grok it easily. I've just tried doxygen and graphviz but the results are .. somewhat similar to Visual Studio. I'm getting sweet looking call graphs but again too much detail for what I'm trying to get. I need a quick way to generate the inheritance hierarchy, in some kind of collapsible view.

    Read the article

  • Visual Studio scratch disk behavior

    - by bobobobo
    I don't know if this feature exists, but I'd like a way to control Visual Studio 2010's scratch disk behavior (other than completely turning off intellisense). Right now it creates a massive .sdf file in the project folder (50MB+), and then it goes and creates an IPCH folder with 60MB+ of precompiled headers. All that's well and good while VS is running, but after it exits, I really would like the disk back. Is there a way to configure vs 2010 to Use the same location (%AppData%\VSScratch) for scratch disk files (so its easier to blow it away?) Automatically delete .sdf /ipch on exit? I know they don't delete them because its faster to startup.. but if you delete them yourself, startup time isn't that much increased..

    Read the article

  • operator[][] C++

    - by bobobobo
    I'd like to overload operator[][] to give internal access to a 2D array of char in C++. Right now I'm only overloading operator[], which goes something like class Object { char ** charMap ; char* operator[]( int row ) { return charMap[row] ; } } ; It works ok.. Is it possible to override operator[][] though?

    Read the article

  • Reading function pointer syntax

    - by bobobobo
    Everytime I look at a C function pointer, my eyes glaze over. I can't read them. From here, here are 2 examples of function pointer TYPEDEFS: typedef int (*AddFunc)(int,int); typedef void (*FunctionFunc)(); Now I'm used to something like: typedef vector<int> VectorOfInts ; Which I read as typedef vector<int> /* as */ VectorOfInts ; But I can't read the above 2 typedefs. The bracketing and the asterisk placement, it's just not logical. Why is the * beside the word AddFunc..?

    Read the article

  • Do more specific css rules load better?

    - by bobobobo
    You can do this: .info { padding: 5px ; } Or, if you know it will be a div, you can do this div.info { padding: 5px ; } So, when there's a nested list.. you can do this.. div.info ul.navbar li.navitem a.sitelink { color: #f00; } Or you can do this a.sitelink { color: #f00; } Readability aside, which is better for the browser to parse/run?

    Read the article

  • Largest sphere inside a frustum

    - by Will
    How do you find the largest sphere that you can draw in perspective? Viewed from the top, it'd be this: Added: on the frustum on the right, I've marked four points I think we know something about. We can unproject all eight corners of the frusum, and the centres of the near and far ends. So we know point 1, 3 and 4. We also know that point 2 is the same distance from 3 as 4 is from 3. So then we can compute the nearest point on the line 1 to 4 to point 2 in order to get the centre? But the actual math and code escapes me. I want to draw models (which are approximately spherical and which I have a miniball bounding sphere for) as large as possible. Update: I've tried to implement the incircle-on-two-planes approach as suggested by bobobobo and Nathan Reed : function getFrustumsInsphere(viewport,invMvpMatrix) { var midX = viewport[0]+viewport[2]/2, midY = viewport[1]+viewport[3]/2, centre = unproject(midX,midY,null,null,viewport,invMvpMatrix), incircle = function(a,b) { var c = ray_ray_closest_point_3(a,b); a = a[1]; // far clip plane b = b[1]; // far clip plane c = c[1]; // camera var A = vec3_length(vec3_sub(b,c)), B = vec3_length(vec3_sub(a,c)), C = vec3_length(vec3_sub(a,b)), P = 1/(A+B+C), x = ((A*a[0])+(B*a[1])+(C*a[2]))*P, y = ((A*b[0])+(B*b[1])+(C*b[2]))*P, z = ((A*c[0])+(B*c[1])+(C*c[2]))*P; c = [x,y,z]; // now the centre of the incircle c.push(vec3_length(vec3_sub(centre[1],c))); // add its radius return c; }, left = unproject(viewport[0],midY,null,null,viewport,invMvpMatrix), right = unproject(viewport[2],midY,null,null,viewport,invMvpMatrix), horiz = incircle(left,right), top = unproject(midX,viewport[1],null,null,viewport,invMvpMatrix), bottom = unproject(midX,viewport[3],null,null,viewport,invMvpMatrix), vert = incircle(top,bottom); return horiz[3]<vert[3]? horiz: vert; } I admit I'm winging it; I'm trying to adapt 2D code by extending it into 3 dimensions. It doesn't compute the insphere correctly; the centre-point of the sphere seems to be on the line between the camera and the top-left each time, and its too big (or too close). Is there any obvious mistakes in my code? Does the approach, if fixed, work?

    Read the article

< Previous Page | 1 2 3 4