Search Results

Search found 1215 results on 49 pages for 'raphie palefsky smith'.

Page 27/49 | < Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >

  • Does it ever make sense to make a fundamental (non-pointer) parameter const?

    - by Scott Smith
    I recently had an exchange with another C++ developer about the following use of const: void Foo(const int bar); He felt that using const in this way was good practice. I argued that it does nothing for the caller of the function (since a copy of the argument was going to be passed, there is no additional guarantee of safety with regard to overwrite). In addition, doing this prevents the implementer of Foo from modifying their private copy of the argument. So, it both mandates and advertises an implementation detail. Not the end of the world, but certainly not something to be recommended as good practice. I'm curious as to what others think on this issue. Edit: OK, I didn't realize that const-ness of the arguments didn't factor into the signature of the function. So, it is possible to mark the arguments as const in the implementation (.cpp), and not in the header (.h) - and the compiler is fine with that. That being the case, I guess the policy should be the same for making local variables const. One could make the argument that having different looking signatures in the header and source file would confuse others (as it would have confused me). While I try to follow the Principle of Least Astonishment with whatever I write, I guess it's reasonable to expect developers to recognize this as legal and useful.

    Read the article

  • What is the worst real-world macros/pre-processor abuse you've ever come across?

    - by Trevor Boyd Smith
    What is the worst real-world macros/pre-processor abuse you've ever come across (please no contrived IOCCC answers *haha*)? Please add a short snippet or story if it is really entertaining. The goal is to teach something instead of always telling people "never use macros". p.s.: I've used macros before... but usually I get rid of them eventually when I have a "real" solution (even if the real solution is inlined so it becomes similar to a macro). Bonus: Give an example where the macro was really was better than a not-macro solution. Related question: When are C++ macros beneficial?

    Read the article

  • Should I be concerned with infected zip files?

    - by Peter Smith
    I'm writing a ASP.NET application to process user submitted zip files and limiting my extraction of files from it to only the extensions I want. I've heard of infected zip files attached to emails and I was wondering if I should be concerned about extracting data from infected zip files in my application. I don't plan on executing the content inside of the zip file, but will opening and extracting from an infected zip file cause the file to execute a virus even if I'm not executing any content inside of the zip file?

    Read the article

  • SWIG-Lua question on class returning another class

    - by John Smith
    I am concreting a question I had earlier. I have two classes in C++ and I use SWIG to wrap them. A method in one class can return a pointer to the other class. How can I get Lua to see it as more than just a userdata? More concretely: I have class fruit { int numberofseeds; //some other stuff about fruit constructors etc... public: getseedcount() { return numberofseeds; } } class tree { fruit * apple; public: //constructors and whatnot fruit * getfruit() { return apple; } } I wrap these two class with SWIG so I can access them in Lua So I can get in Lua the object x=pomona.tree(grannysmith). My question now is: How can I arrange for things so that when I type y=x:getfruit() I will get a pomona:fruit type object? Where I can write something line y:getseedcount()? At the moment all I get is userdata which not edible.

    Read the article

  • Loading non-RJS javascript via ajax in Rails

    - by David Smith
    I've written a rails module that generates some javascript for a google map. As the user makes changes on the webpage, I use observe_field to call back to the server to regenerate the map's javascript (without updating the whole page). I'm having trouble finding a good way to insert the new javascript into the page. I've tried <div id='my_div_1'>div1</div> <%= update_page_tag do |page| page.replace_html 'my_div_1', "<script>alert('hi');</script>" end %> but it seems that replace_html only works for non-script html. It chokes when the content includes the closing < /script tag. Additional information...here is a page that I think is the root of the problem. http://www.wwco.com/~wls/blog/2007/04/25/using-script-in-a-javascript-literal/

    Read the article

  • Faking a UITableView selection

    - by John Smith
    I have a UITableView where a selection displays some cool stuff in another part of the display. I tried to fake a keypress by writing: NSIndexPath *ip = [NSIndexPath indexPathForRow: 1 inSection:0]; [tableView selectRowAtIndexPath:ip animated:NO scrollPosition:UITableViewScrollPositionTop ]; [self tableView:tableView didSelectRowAtIndexPath:ip]; However it seems the last line is not being run. How can I make it run?

    Read the article

  • PostgreSQL - select only when specific multiple apperance in column

    - by Horse SMith
    I'm using PostgreSQL. I have a table with 3 fields person, recipe and ingredient person = creator of the recipe recipe = the recipe ingredient = one of the ingredients in the recipe I want to create a query which results in every person who whenever has added carrot to a recipe, the person must also have added salt to the same recipe. More than one person can have created the recipe, in which case the person who added the ingredient will be credited for adding the ingredient. Sometimes the ingredient is used more than once, even by the same person. If this the table: person1, rec1, carrot person1, rec1, salt person1, rec1, salt person1, rec2, salt person1, rec2, pepper person2, rec1, carrot person2, rec1, salt person2, rec2, carrot person2, rec2, pepper person3, rec1, sugar person3, rec1, carrot Then I want this result: person1 Because this person is the only one who whenever has added carrot also have added salt.

    Read the article

  • Database Structure for CakePHP Models

    - by Michael T. Smith
    We're building a data tracking web app using CakePHP, and I'm having some issues getting the database structure right. We have Companies that haveMany Sites. Sites haveMany DataSamples. Tags haveAndBelongToMany Sites. That is all set up fine. The problem is "ranking" the sites within tags. We need to store it in the database as an archive. I created a Rank model that is setup like this: rank ( id (int), sample_id (int), tag_id (int), site_id (int), rank (int), total_rows) ) So, the question is, how do I create the associations for tag, site and sample to rank? I originally set them as haveMany. But the returned structures don't get me where I'd like to be. It looks like: [Site] => Array ( [Sample] = Array(), [Tag] = Array() ) When I'm really looking for: [Site] => Array ( [Tag] = Array ( [Sample] => Array ( [Rank] => Array ( ...data... ) ) ) ) I think that I may not be structuring the database properly; so if I need to update please let me know. Otherwise, how do I write a find query that gets me where I need to be? Thanks! Thoughts? Need more details? Just ask!

    Read the article

  • sort associative array PHP

    - by jim smith
    Here's my array, how do I sort it by saleref? Array ( [xml] => Array ( [sale] => Array ( [0] => Array ( [saleref] => 12345 [saleline] => 1 [product] => producta [date] => 19/ 3/10 [manifest] => 0 [qty] => 1 [nextday] => [order_status] => ) [1] => Array ( [saleref] => 12344 [saleline] => 1 [product] => productb [date] => 18/ 3/10 [manifest] => 11892 [qty] => 1 [nextday] => [order_status] => )

    Read the article

  • Do I have to use Stored Procedures to get query level security or can I still do this with Dynamic S

    - by Peter Smith
    I'm developing an application where I'm concerned about locking down access to the database. I know I can develop stored procedures (and with proper parameter checking) limit a database user to an exact set of queries to execute. It's imperative that no other queries other then the ones I created in the stored procedures be allowed to execute under that user. Ideally even if a hacker gained access to the database connection (which only accepts connections from certain computers) they would only be able to execute the predefined stored procedures. Must I choose stored procedures for this or can I use Dynamic Sql with these fine grain permissions?

    Read the article

  • Performance hit from C++ style casts?

    - by Trevor Boyd Smith
    I am new to C++ style casts and I am worried that using C++ style casts will ruin the performance of my application because I have a real-time-critical deadline in my interrupt-service-routine. I heard that some casts will even throw exceptions! I would like to use the C++ style casts because it would make my code more "robust". However, if there is any performance hit then I will probably not use C++ style casts and will instead spend more time testing the code that uses C-style casts. Has anyone done any rigorous testing/profiling to compare the performance of C++ style casts to C style casts? What were your results? What conclusions did you draw?

    Read the article

  • IIS hosting vs Built In Web server that ships with VS 2010

    - by mark smith
    Hi there, I am looking to host a wcf service while i am developing. Is this best with IIS or can i just use the default BUILT IN web server that ships with Visual Studio? I can change the Assign automatic port to specific port so in my client i always ahave a fixed address. I was hoping somebody could advise the best way to go?

    Read the article

  • Planning a requirements gathering session using Agile

    - by Dave Smith
    We are planning on introducing Agile into our development process (a shift from the waterfall we've been using so far). We are leaning towards a hybrid model in whcih the requirements gathering session is comprised of a business analyst, subject matter experts, technical person and a user interface person. The plan is to create user stories that the development team can use in their agile process with 1 month sprints. Has anyone had experience with a hybrid model? How has it worked for you so far?

    Read the article

  • Structs inside #define in C++

    - by Adam Smith
    Being pretty new to C++, I don't quite understand some instructions I encounter such as: #ifndef BOT_H_ #define BOT_H_ #include "State.h" /* This struct represents your bot in the game of Ants */ struct Bot { State state; Bot(); void playGame(); //plays a single game of Ants void makeMoves(); //makes moves for a single turn void endTurn(); //indicates to the engine that it has made its moves }; #endif //BOT_H_ What I don't understand is the "#ifndef BOT_H_" and the "#define -- #endif" From what I gather, it defines a constant BOT_H_ if it's not already defined when the precompiler looks at it. I don't actually get how the struct inside it is a constant and how it is going to let me access the functions inside it. I also don't see why we're doing it this way? I used C++ a while back and I wasn't using .h files, so it might be something easy I'm missing.

    Read the article

  • Matlab help: I am given a second order differential equation.I need to use matlab to find unit step response and impulse response?

    - by Cady Smith
    I have the second order differential equation d^2(y(t))/dt^2+ B1*d(y(t))/dt+ c1*y(t)=A1*x(t) t is in seconds and is greater than 0. A1, B1, C1 are constants that equal: A1= 3.8469x10^6 B1= 325.6907 C1= 3.8469x10^6 This system is linear, time-invariant, and casual. The system is called H1. I want to use Matlab to compute and plot the impulse response function h1(t) and the unit step response function g1(t) of this system.

    Read the article

  • How to manage lifecycle in a ViewGroup-derived class?

    - by Scott Smith
    I had a bunch of code in an activity that displays a running graph of some external data. As the activity code was getting kind of cluttered, I decided to extract this code and create a GraphView class: public class GraphView extends LinearLayout { public GraphView(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.graph_view, this, true); } public void start() { // Perform initialization (bindings, timers, etc) here } public void stop() { // Unbind, destroy timers, yadda yadda } . . . } Moving stuff into this new LinearLayout-derived class was simple. But there was some lifecycle management code associated with creating and destroying timers and event listeners used by this graph (I didn't want this thing polling in the background if the activity was paused, for example). Coming from a MS Windows background, I kind of expected to find overridable onCreate() and onDestroy() methods or something similar, but I haven't found anything of the sort in LinearLayout (or any of its inherited members). Having to leave all of this initialization code in the Activity, and then having to pass it into the view seemed like it defeated the original purpose of encapsulating all of this code into a reusable view. I ended up adding two additional public methods to my view: start() and stop(). I make these calls from the activity's onResume() and onPause() methods respectively. This seems to work, but it feels like I'm using duct tape here. Does anyone know how this is typically done? I feel like I'm missing something...

    Read the article

  • Is locking on the requested object a bad idea?

    - by Quick Joe Smith
    Most advice on thread safety involves some variation of the following pattern: public class Thing { private static readonly object padlock = new object(); private string stuff, andNonsense; public string Stuff { get { lock (Thing.padlock) { if (this.stuff == null) this.stuff = "Threadsafe!"; } return this.stuff; } } public string AndNonsense { get { lock (Thing.padlock) { if (this.andNonsense == null) this.andNonsense = "Also threadsafe!"; } return this.andNonsense; } } // Rest of class... } In cases where the get operations are expensive and unrelated, a single locking object is unsuitable because a call to Stuff would block all calls to AndNonsense, degrading performance. And rather than create a lock object for each call, wouldn't it be better to acquire the lock on the member itself (assuming it is not something that implements SyncRoot or somesuch for that purpose? For example: public string Stuff { get { lock (this.stuff) { // Pretend that this is a very expensive operation. if (this.stuff == null) this.stuff = "Still threadsafe and good?"; } return this.stuff; } } Strangely, I have never seen this approach recommended or warned against. Am I missing something obvious?

    Read the article

  • Why does Apple create it's views this way

    - by John Smith
    In the hope of fixing a bug of mine from another post i would like to know why apple writes this (for it's Elements example) UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; self.containerView = localContainerView; [localContainerView release]; instead of the simpler method: containerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; ?

    Read the article

  • Could someone give me their two cents on this optimization strategy

    - by jimstandard
    Background: I am writing a matching script in python that will match records of a transaction in one database to names of customers in another database. The complexity is that names are not unique and can be represented multiple different ways from transaction to transaction. Rather than doing multiple queries on the database (which is pretty slow) would it be faster to get all of the records where the last name (which in this case we will say never changes) is "Smith" and then have all of those records loaded into memory as you go though each looking for matches for a specific "John Smith" using various data points. Would this be faster, is it feasible in python, and if so does anyone have any recommendations for how to do it?

    Read the article

  • C to Assembly code - what does it mean

    - by Smith
    I'm trying to figure out exactly what is going on with the following assembly code. Can someone go down line by line and explain what is happening? I input what I think is happening (see comments) but need clarification. .file "testcalc.c" .section .rodata.str1.1,"aMS",@progbits,1 .LC0: .string "x=%d, y=%d, z=%d, result=%d\n" .text .globl main .type main, @function main: leal 4(%esp), %ecx // establish stack frame andl $-16, %esp // decrement %esp by 16, align stack pushl -4(%ecx) // push original stack pointer pushl %ebp // save base pointer movl %esp, %ebp // establish stack frame pushl %ecx // save to ecx subl $36, %esp // alloc 36 bytes for local vars movl $11, 8(%esp) // store 11 in z movl $6, 4(%esp) // store 6 in y movl $2, (%esp) // store 2 in x call calc // function call to calc movl %eax, 20(%esp) // %esp + 20 into %eax movl $11, 16(%esp) // WHAT movl $6, 12(%esp) // WHAT movl $2, 8(%esp) // WHAT movl $.LC0, 4(%esp) // WHAT?!?! movl $1, (%esp) // move result into address of %esp call __printf_chk // call printf function addl $36, %esp // WHAT? popl %ecx popl %ebp leal -4(%ecx), %esp ret .size main, .-main .ident "GCC: (Ubuntu 4.3.3-5ubuntu4) 4.3.3" .section .note.GNU-stack,"",@progbits Original code: #include <stdio.h> int calc(int x, int y, int z); int main() { int x = 2; int y = 6; int z = 11; int result; result = calc(x,y,z); printf("x=%d, y=%d, z=%d, result=%d\n",x,y,z,result); }

    Read the article

  • Another Nim's Game Variant

    - by Terry Smith
    Given N binary sequence Example : given one sequence 101001 means player 0 can only choose a position with 0 element and cut the sequence from that position {1,101,1010} player 1 can only choose a position with 1 element ans cut the sequence from that position {null,10,101000} now player 0 and player 1 take turn cutting the sequence, on each turn they can cut any one non-null sequence, if a player k can't make a move because there's no more k element on any sequence, he lose. Assume both player play optimally, who will win ? I tried to solve this problem with grundy but i'm unable to reduce the sequence to a grundy number because it both player don't have the same option to move. Can anyone give me a hint to solve this problem ?

    Read the article

  • Creating "GDP in 1960" variable from GDP variables for different years

    - by Tom Smith
    Hi all, I'm pretty new to stata... I have a set of observations of the form "Country GDP Year". I want to create a new variable GDP1960, which gives the GDP in 1960 of each country for each year: USA $100m 1960 USA $100m 1960 $100m USA $200m 1965 --> USA $200m 1965 $100m Canada $60m 1960 Canada $60m 1960 $60m What's the right syntax to make this happen? (I assume egen is involved in some mysterious way)

    Read the article

< Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >