Search Results

Search found 1446 results on 58 pages for 'prototype stark'.

Page 51/58 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • Do all C compilers allow functions to return structures?

    - by Jordan S
    I am working on a program in C and using the SDCC compiler for a 8051 architecture device. I am trying to write a function called GetName that will read 8 characters from Flash Memory and return the character array in some form. I know that it is not possible to return an array in C so I am trying to do it using a struct like this: //********************FLASH.h file******************************* MyStruct GetName(int i); //Function prototype #define NAME_SIZE 8 typedef struct { char Name[NAME_SIZE]; } MyStruct; extern MyStruct GetName(int i); // *****************FLASH.c file*********************************** #include "FLASH.h" MyStruct GetName( int i) { MyStruct newNameStruct; //... // Fill the array by reading data from Flash //... return newNameStruct; } I don't have any references to this function yet but for some reason, I get a compiler error that says "Function cannot return aggregate." Does this mean that my compiler does not support functions that return structs? Or am I just doing something wrong?

    Read the article

  • Jquery UI Datepicker disabling wrong days

    - by Nazariy
    I have run in to issue that days that have to be disabled are shifted to the next day. The idea is that day that does not exist in our booking object or have a value less than 1 should be disabled on calendar. here is simplified version of my script and demonstration on jsfiddle: var bookings = { "2012-09-01": 24, "2012-09-03": 31, "2012-09-05": 27, "2012-09-06": 9, "2012-09-07": 18, "2012-09-08": 0, "2012-09-10": 20, "2012-09-12": 19, "2012-09-13": 0, "2012-09-14": 9, "2012-09-15": 24, "2012-09-17": 19, "2012-09-19": 28, "2012-09-20": 15, "2012-09-21": 12, "2012-09-22": 25, "2012-09-24": 19, "2012-09-26": 0, "2012-09-27": 0, "2012-09-28": 0, "2012-09-29": 0 }; function MyEvent(date) { bookings = bookings || {}; this.date = date.toISOString().substr(0, 10); this.display = (typeof bookings[this.date] == 'number' && bookings[this.date] > 0); return this; } MyEvent.prototype.toArray = function () { return [this.display, null, null]; }; $(function () { $('#eventCalendar').datepicker({ dateFormat: "yy-mm-dd", firstDay: 1, defaultDate: "2012-09-24", beforeShowDay: function (date) { return new MyEvent(date).toArray(); } } ); }); Can some one suggest me what am I doing wrong or is it a bug?

    Read the article

  • How can I generate an "unlimited" world?

    - by snowlord
    I would like to create a game with an endless (in reality an extremely large) world in which the player can move about. Whether or not I will ever get around to implement the game is one matter, but I find the idea interesting and would like some input on how to do it. The point is to have a world where all data is generated randomly on-demand, but in a deterministic way. Currently I focus on a large 2D map from which it should be possible to display any part without knowledge about the surrounding parts. I have implemented a prototype by writing a function that gives a random-looking, but deterministic, integer given the x and y of a pixel on the map (see my recent question about this function). Using this function I populate the map with "random" values, and then I smooth the map using a simple filter based on the surrounding pixels. This makes the map dependent on a few pixels outside its edge, but that's not a big problem. The final result is something that at least looks like a map (especially with a good altitude color map). Given this, one could maybe first generate a coarser map which is used to generate bigger differences in altitude to create mountain ranges and seas. Anyway, that was my idea, but I am sure that there exist ways to do this already and I also believe that given the specification, many of you can come up with better ideas. EDIT: Forgot the link to my question.

    Read the article

  • How to find Tomcat's PID and kill it in python?

    - by 4herpsand7derpsago
    Normally, one shuts down Apache Tomcat by running its shutdown.sh script (or batch file). In some cases, such as when Tomcat's web container is hosting a web app that does some crazy things with multi-threading, running shutdown.sh gracefully shuts down some parts of Tomcat (as I can see more available memory returning to the system), but the Tomcat process keeps running. I'm trying to write a simple Python script that: Calls shutdown.sh Runs ps -aef | grep tomcat to find any process with Tomcat referenced If applicable, kills the process with kill -9 <PID> Here's what I've got so far (as a prototype - I'm brand new to Python BTW): #!/usr/bin/python # Imports import sys import subprocess # Load from imported module. if __init__ == "__main__": main() # Main entry point. def main(): # Shutdown Tomcat shutdownCmd = "sh ${TOMCAT_HOME}/bin/shutdown.sh" subprocess.call([shutdownCmd], shell=true) # Check for PID grepCmd = "ps -aef | grep tomcat" grepResults = subprocess.call([grepCmd], shell=true) if(grepResult.length > 1): # Get PID and kill it. pid = ??? killPidCmd = "kill -9 $pid" subprocess.call([killPidCmd], shell=true) # Exit. sys.exit() I'm struggling with the middle part - with obtaining the grep results, checking to see if their size is greater than 1 (since grep always returns a reference to itself, at least 1 result will always be returned, methinks), and then parsing that returned PID and passing it into the killPidCmd. Thanks in advance!

    Read the article

  • Doubt about instance creation by using Spring framework ???

    - by Arthur Ronald F D Garcia
    Here goes a command object which needs to be populated from a Spring form public class Person { private String name; private Integer age; /** * on-demand initialized */ private Address address; // getter's and setter's } And Address public class Address { private String street; // getter's and setter's } Now suppose the following MultiActionController @Component public class PersonController extends MultiActionController { @Autowired @Qualifier("personRepository") private Repository<Person, Integer> personRepository; /** * mapped To /person/add */ public ModelAndView add(HttpServletRequest request, HttpServletResponse response, Person person) throws Exception { personRepository.add(person); return new ModelAndView("redirect:/home.htm"); } } Because Address attribute of Person needs to be initialized on-demand, i need to override newCommandObject to create an instance of Person to initiaze address property. Otherwise, i will get NullPointerException @Component public class PersonController extends MultiActionController { /** * code as shown above */ @Override public Object newCommandObject(Class clazz) thorws Exception { if(clazz.isAssignableFrom(Person.class)) { Person person = new Person(); person.setAddress(new Address()); return person; } } } Ok, Expert Spring MVC and Web Flow says Options for alternate object creation include pulling an instance from a BeanFactory or using method injection to transparently return a new instance. First option pulling an instance from a BeanFactory can be written as @Override public Object newCommandObject(Class clazz) thorws Exception { /** * Will retrieve a prototype instance from ApplicationContext whose name matchs its clazz.getSimpleName() */ getApplicationContext().getBean(clazz.getSimpleName()); } But what does he want to say by using method injection to transparently return a new instance ??? Can you show how i implement what he said ??? ATT: I know this funcionality can be filled by a SimpleFormController instead of MultiActionController. But it is shown just as an example, nothing else

    Read the article

  • Best Practice: Access form elements by HTML id or name attribute?

    - by seth
    As any seasoned JavaScript developer knows, there are many (too many) ways to do the same thing. For example, say you have a text field as follows: <form name="myForm"> <input type="text" name="foo" id="foo" /> There are many way to access this in JavaScript: [1] document.forms[0].elements[0]; [2] document.myForm.foo; [3] document.getElementById('foo'); [4] document.getElementById('myForm').foo; ... and so on ... Methods [1] and [3] are well documented in the Mozilla Gecko documentation, but neither are ideal. [1] is just too general to be useful and [3] requires both an id and a name (assuming you will be posting the data to a server side language). Ideally, it would be best to have only an id attribute or a name attribute (having both is somewhat redundant, especially if the id isn't necessary for any css, and increases the likelihood of typos, etc). [2] seems to be the most intuitive and it seems to be widely used, but I haven't seen it referenced in the Gecko documentation and I'm worried about both forwards compatibility and cross browser compatiblity (and of course I want to be as standards compliant as possible). So what's best practice here? Can anyone point to something in the DOM documentation or W3C specification that could resolve this? Note I am specifically interested in a non-library solution (jQuery/Prototype).

    Read the article

  • jquery for ruby on rails

    - by Cezar
    Hello, I am tying to use this code http://gist.github.com/110410 to dump Prototype in favor of jQuery but I do have a problem. This is my HTML (a link_to generated link): <a onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'Mi6RcR6YDyvg2uNwGrpbeIJutSHa2fYboU37wSDE7AU='); f.appendChild(s);f.submit();return false;" class="post add_to_cart " href="/line_items?product_id=547">Add to cart</a> Issue: Everything works as it should except that the page does a reload. I suspect that the submit gets thru which causes a page reload. Is there an elegant way to prevent that ? return false; doesn't seem to cut it in this case.

    Read the article

  • access settings from whole jquery component

    - by Pacuraru Daniel
    I am trying to develop a jquery component for dialog modals and i dont know how to access the settings from all component functions. I need to access settings,zIndex from open function and it seems to not work. (function($) { var methods = { init: function(options) { var defaults = { bgClass: "fancy-dialog-bg", bgShow: null, zIndex: 100, show: null }; var settings = $.extend(defaults, options); return this.each(function() { var obj = $(this).hide().css("position", "fixed").css("z-index", settings.zIndex).css("left", "300px").css("top", "200px"); }); }, open: function() { // alert(settings.zIndex); not working var tes = $("<div></div>").css("backgroundColor", "#f00").css("position", "fixed").css("z-index", "99").css("width", "50%").css("height", "100%").css("left", "0").css("top", "0"); $('body').append(tes); var obj = $(this); obj.show(); }, close: function() { var obj = $(this); $("#fancy-dialog-bg-" + obj.attr('id')).remove(); obj.hide(); } }; $.fn.fancyDialog = function(method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { return methods.init.apply(this, arguments); } else { $.error('Method ' + method + ' does not exist.'); } }; })(jQuery);

    Read the article

  • How to define a batching routing service in WCF

    - by mattx
    I have designed a custom silverlight wcf channel that I want to leverage to selectively batch calls from the client to the server and possibly to cache on the client and short circuit calls. So far I'm just using this channel as a transport and sending the generic WCF messages that result to the WCF router service example here http://msdn.microsoft.com/en-us/magazine/cc500646.aspx?pr=blog to prototype this on the server side. So my scenario looks like this: IFooClient-MyTransportChannel-IRouterService-IFooService-Return I now need to be able to send more than one message per call through the router and carve them up and service them on the server side. Since this is just an experiment and I'm taking baby steps I will dispatch and service all the messages right away on the server side and return the batch of results. Immediately I noticed that simply making the router interface take Message[] instead of Message doesn't work due to serialization problems. I guess this makes sense. I'm not sure soap envelopes can contain other soap envelopes etc. Is there a simple way to take a collection of WCF Message objects and send them to a single method on a service where they can be split up and forwarded as appropriate? If not I'd love suggestions on how I should approach this. I want to have minimal work to do on the router service side so the goal should be to get as close to being able to "slice and forward" as possible.

    Read the article

  • Sync two SqlExpress using NHibernate

    - by Christian
    Hello, I am creating a simple project management system which uses NHibernate for object storage. The underlying database is SQL express (at least currently for development). The client runs on either the desktop or laptop. I know I could use web-services and store the DB only on the desktop, but this would force the desktop to be available all the time. I am currently thinking about duplicating the DB, having two instances with "different data". To clarify, we are not talking about a productive app here, its a prototype. One way to achieve this very simple would be the following process: Client: Check if desktop DB is available (through web service) Client: If yes, use desktop storage, no problem here Client: If not, use own DB as storage Client: Poll desktop regulary, as soon as it comes on, sync Client: Switch to desktop storage ... Desktop: Do not attempt any DB operation before checking for required sync Desktop: If sync needed, do it... My question is now, how would you sync? Assume 4 or 5 types of objects, all have GUID as identifiers. Would you always manually "lazy load" all objects of a certain type and feed them to the DB. Would you always drop the whole desktop DB in case the client DB may be newer and out of sync? Again, I want to stress out, I am not assuming any conflicts or stale data, I basically just want to "copy the whole DB from the client". Would you use NHibernate for this? Or would you separate the copy process? When I think about it, my questions comes down to this: Is there any function from NHibernate: SyncDBs_SourceWins_(SourceDB, TargetDB) Thanks for help, Chris

    Read the article

  • Font Awesome Not Working In Chrome

    - by Connor Black
    So I'm trying to prototype a marketing page and I'm using bootstrap and the new font awesome file. The problem is when I try to use an icon all that gets rendered on the page in a big square. Here's how I include the files in the head: <head> <title> </title> <link rel="stylesheet" href="css/bootstrap.css"> <link rel="stylesheet" href="css/bootstrap-responsive.css"> <link rel="stylesheet" href="css/font-awesome.css"> <link rel="stylesheet" href="css/app.css"> <!--[if IE 7]> <link rel="stylesheet" href="css/font-awesome-ie7.min.css"> <![endif]--> </head> And here's an example of me trying to use an icon: <i class="icon-camera-retro"></i> But all that gets rendered in a big square. Does anyone know what could be going on?

    Read the article

  • A more effecient millisecond conversion method?

    - by cube
    I am currently using this method to convert milliseconds to min:sec:1/10sec. However it does not seem to be efficient at all. Would anyone know of a faster more efficient and optimized way of accomplishing the same. mills.prototype.formatTime = function(time) { var elapsedTime = (time * 1000); //Minutes var elapsedM = (elapsedTime/60000)|0; var remaining = elapsedTime - (elapsedM * 60000); //add a leading zero if it's a single digit number if (elapsedM < 10) { elapsedM = "0"+elapsedM; } //Seconds var elapsedS = ((remaining/1000)|0); remaining -= (elapsedS*1000); ////add leading zero if (elapsedS<10) { elapsedS = "0"+elapsedS; } //Hundredths var elapsedFractions = ((remaining/10)|0); if (elapsedFractions < 10) { elapsedFractions = "0"+elapsedFractions; } //display results nicely var time_data = elapsedM+":"+elapsedS+":"+elapsedFractions; //return time_data; return[time_data,elapsedM,elapsedS,elapsedFractions] };

    Read the article

  • How to encapsulate a WinAPI application into a C++ class

    - by Semen Semenych
    There is a simple WinAPI application. All it does currently is this: register a window class register a tray icon with a menu create a value in the registry in order to autostart and finally, it checks if it's unique using a mutex As I'm used to writing code mainly in C++, and no MFC is allowed, I'm forced to encapsulate this into C++ classes somehow. So far I've come up with such a design: there is a class that represents the application it keeps all the wndclass, hinstance, etc variables, where the hinstance is passed as a constructor parameter as well as the icmdshow and others (see WinMain prototype) it has functions for registering the window class, tray icon, reigstry information it encapsulates the message loop in a function In WinMain, the following is done: Application app(hInstance, szCmdLIne, iCmdShow); return app.exec(); and the constructor does the following: registerClass(); registerTray(); registerAutostart(); So far so good. Now the question is : how do I create the window procedure (must be static, as it's a c-style pointer to a function) AND keep track of what the application object is, that is, keep a pointer to an Application around. The main question is : is this how it's usually done? Am I complicating things too much? Is it fine to pass hInstance as a parameter to the Application constructor? And where's the WndProc? Maybe WndProc should be outside of class and the Application pointer be global? Then WndProc invokes Application methods in response to various events.

    Read the article

  • Passing an array of structs in C

    - by lelouch
    I'm having trouble passing an array of structs to a function in C. I've created the struct like this in main: int main() { struct Items { char code[10]; char description[30]; int stock; }; struct Items MyItems[10]; } I then access it like: MyItems[0].stock = 10; etc. I want to pass it to a function like so: ReadFile(MyItems); The function should read the array, and be able to edit it. Then I should be able to access the same array from other functions. I've tried heaps of declarations but none of them work. e.g. void ReadFile(struct Items[10]) I've had a look around for other questions, but the thing is they're all done different, with typedefs and asterisks. My teacher hasn't taught us pointers yet, so I'd like to do it with what I know. Any ideas? :S EDIT: Salvatore's answer is working after I fixed my prototype to: void ReadFile(struct Items[9]);

    Read the article

  • Sending a JSON object to an ASP.NET web service using JQUERY ajax function

    - by uzay95
    I want to create object on the client side of aspx page. And i want to add functions to these javascript classes to make easier the life. Actually i can get and use the objects (derived from the server side classes) which returns from the services. When i wanted to send objects from the client by jquery ajax methods, i couldn't do it :) This is my javascript object: function ClassAndMark(_mark, _lesson){ this.Lesson = _lesson; this.Mark = _mark; } function Student(_name, _surname, _classAndMark){ this.Name = _name; this.SurName = _surname; this.ClassAndMark = _classAndMark; } JSClass.prototype.fSaveToDB(){ $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "/WS/SaveObject.asmx/fSaveToDB"), data: ????????????, dataType: "json" }); } Actually i don't know what should be definition of classes and methods on the Server side but i think: class ClassAndMark{ public string Lesson ; public string Mark ; } class Student{ public string Name ; public string SurName ; public ClassAndMark ClassAndMark ; } Web service is below but again i couldn't get what should be instead of the ???? : [WebMethod()] public void fSaveToDB(???? _obj) { // How can i convert input parameter/parameters // of method in the server side object? }

    Read the article

  • jQuery load() problem with html that contain jQuery plugin

    - by Victorgalaxy
    FYI, here is my code: [index.html] <script type="text/javascript" src="js/script.js"></script> [script.js] $(document).ready(function() { $('#buttonEphone').click(function() { $('#apDiv2').load("ePhone.html, #content"); }); }); "ePhone.html" contain some lightbox effect. (making use of code below) [ePhone.html] <script type="text/javascript" src="js/prototype.lite.js"></script> <script type="text/javascript" src="js/moo.fx.js"></script> <script type="text/javascript" src="js/litebox-1.0.js"></script> The Litebox plugin also required to add onload="initLightbox()" within the BODY tag of ePhone.html. From the above code, I can load ePhone.html's content(#content div) to my (apDiv2) of my index.html. However, the lightbox effect is no longer work. I've also try loading the whole html instead of only #content: $('#apDiv2').load('ePhone.html'); but it still doesn't work. Please help, thx

    Read the article

  • setup Qt and PyQt on mac osx so my app can also deployable on windows

    - by hk_programmer
    Hi, I've been coding with Python and C++ and now need to work on building a gui for data visualization purposes. I work on Mac Snow Leopard (intel), python 3.1 using gcc 4.2.1 (from Xcode 3.1) I wanted to first install Qt and then PyQt. And my goals are to be able to: - quickly prototype GUI and the accompanied logic that drives the GUI using PyQt and python - if I decided I need the speed, or if it's fairly easy to translate my GUI into C++ using the Qt tools, I have the options to translate my app into C++ - Be able to deploy my application onto Windows (both the python and c++ version of my app) Give the goals above, what are the correct steps I should take and what issues i should be aware of when setting up Qt and PyQt. Which other deployment tools do I need? From my readings so far, here's what I have: download the Qt source for mac and configure it with -platform macx-g++42 -arch x86_64 -no-framework (i've read somewhere that building as framework causes some trouble in deployment and/or debugging, can't find the article anymore) download latest SIP source and build download latest PyQt and build from source (any special options I should pay attention to?) For deployment, I've read that I would need to use py2exe/cx_freeze for windows, p2app for mac: http://arstechnica.com/open-source/guides/2009/03/how-to-deploying-pyqt-applications-on-windows-and-mac-os-x.ars but seems like what the article describe is deploying an app you build on windows on the windows platform and vice versa. How do you deploy to windows (is it even possible?) if you are writing your Qt app on a mac ? Really appreciate the help

    Read the article

  • Why do Scala maps have poor performance relative to Java?

    - by Mike Hanafey
    I am working on a Scala app that consumes large amounts of CPU time, so performance matters. The prototype of the system was written in Python, and performance was unacceptable. The application does a lot with inserting and manipulating data in maps. Rex Kerr's Thyme was used to look at the performance of updating and retrieving data from maps. Basically "n" random Ints were stored in maps, and retrieved from the maps, with the time relative to java.util.HashMap used as a reference. The full results for a range of "n" are here. Sample (n=100,000) performance relative to java, smaller is worse: Update Read Mutable 16.06% 76.51% Immutable 31.30% 20.68% I do not understand why the scala immutable map beats the scala mutable map in update performance. Using the sizeHint on the mutable map does not help (it appears to be ignored in the tested implementation, 2.10.3). Even more surprisingly the immutable read performance is worse than the mutable read performance, more significantly so with larger maps. The update performance of the scala mutable map is surprisingly bad, relative to both scala immutable and plain Java. What is the explanation?

    Read the article

  • Better language or checking tool?

    - by rwallace
    This is primarily aimed at programmers who use unmanaged languages like C and C++ in preference to managed languages, forgoing some forms of error checking to obtain benefits like the ability to work in extremely resource constrained systems or the last increment of performance, though I would also be interested in answers from those who use managed languages. Which of the following would be of most value? A language that would optionally compile to CLR byte code or to machine code via C, and would provide things like optional array bounds checking, more support for memory management in environments where you can't use garbage collection, and faster compile times than typical C++ projects. (Think e.g. Ada or Eiffel with Python syntax.) A tool that would take existing C code and perform static analysis to look for things like potential null pointer dereferences and array overflows. (Think e.g. an open source equivalent to Coverity.) Something else I haven't thought of. Or put another way, when you're using C family languages, is the top of your wish list more expressiveness, better error checking or something else? The reason I'm asking is that I have a design and prototype parser for #1, and an outline design for #2, and I'm wondering which would be the better use of resources to work on after my current project is up and running; but I think the answers may be useful for other tools programmers also. (As usual with questions of this nature, if the answer you would give is already there, please upvote it.)

    Read the article

  • Prototyping Qt/C++ in Python

    - by tstenner
    I want to write a C++ application with Qt, but build a prototype first using Python and then gradually replace the Python code with C++. Is this the right approach, and what tools (bindings, binding generators, IDE) should I use? Ideally, everything should be available in the Ubuntu repositories so I wouldn't have to worry about incompatible or old versions and have everything set up with a simple aptitude install. Is there any comprehensive documentation about this process or do I have to learn every single component, and if yes, which ones? Right now I have multiple choices to make: Qt Creator, because of the nice auto completion and Qt integration. Eclipse, as it offers support for both C++ and Python. Eric (haven't used it yet) Vim PySide as it's working with CMake and Boost.Python, so theoretically it will make replacing python code easier. PyQt as it's more widely used (more support) and is available as a Debian package. Edit: As I will have to deploy the program to various computers, the C++-solution would require 1-5 files (the program and some library files if I'm linking it statically), using Python I'd have to build PyQt/PySide/SIP/whatever on every platform and explain how to install Python and everything else.

    Read the article

  • What is the simplest way to map a folder on the file system to a url in Tomcat?

    - by Simon
    Here's my problem... I have a small prototype app (happens to be in Grails hosted on AWS) and I want to add the ability of the user to upload a few (max 10) images. I want to persist these images on disk on the server machine, in a folder location which is outside my WAR. I realise that there is probably a super-scalable solution involving more web servers and optimised static asset serving, but for the approximately 100 users I am likely to get, it's really not worth the effort and cost. So, what is the simplest way I can have a virtual folder from my url map to a physical folder on disk? I sort of want... http://myapp.com/static to map to a folder which I can configure e.g. /var/www/static so I can then have in my code... <img src="/static/user1/picture.jpg"/> I don't particularly mind whether the resulting physical folders are directly browsable. Security will eventually be an issue, but it isn't at the start. So, what are my options? I have looked at virtual hosts on the apache site, but it feels more complicated than I need. I don't want to use the Grails static rendering plugins.

    Read the article

  • Alter a function as a parameter before evaluating it in R?

    - by Shane
    Is there any way, given a function passed as a parameter, to alter its input parameter string before evaluating it? Here's pseudo-code for what I'm hoping to achieve: test.func <- function(a, b) { # here I want to alter the b expression before evaluating it: b(..., val1=a) } Given the function call passed to b, I want to add in a as another parameter without needing to always specify ... in the b call. So the output from this test.func call should be: test.func(a="a", b=paste(1, 2)) "1" "2" "a" Edit: Another way I could see doing something like this would be if I could assign the additional parameter within the scope of the parent function (again, as pseudo-code); in this case a would be within the scope of t1 and hence t2, but not globally assigned: t2 <- function(...) { paste(a=a, ...) } t1 <- function(a, b) { local( { a <<- a; b } ) } t1(a="a", b=t2(1, 2)) This is somewhat akin to currying in that I'm nesting the parameter within the function itself. Edit 2: Just to add one more comment to this: I realize that one related approach could be to use "prototype-based programming" such that things would be inherited (which could be achieved with the proto package). But I was hoping for a easier way to simply alter the input parameters before evaluating in R.

    Read the article

  • Need advice on C++ coding pattern

    - by Kotti
    Hi! I have a working prototype of a game engine and right now I'm doing some refactoring. What I'm asking for is your opinion on usage of the following C++ coding patterns. I have implemented some trivial algorithms for collision detection and they are implemented the following way: Not shown here - class constructor is made private and using algorithms looks like Algorithm::HandleInnerCollision(...) struct Algorithm { // Private routines static bool is_inside(Point& p, Object& object) { // (...) } public: /** * Handle collision where the moving object should be always * located inside the static object * * @param MovingObject & mobject * @param const StaticObject & sobject * @return void * @see */ static void HandleInnerCollision(MovingObject& mobject, const StaticObject& sobject) { // (...) } So, my question is - somebody advised me to do it "the C++" way - so that all functions are wrapped in a namespace, but not in a class. Is there some good way to preserve privating if I will wrap them into a namespace as adviced? What I want to have is a simple interface and ability to call functions as Algorithm::HandleInnerCollision(...) while not polluting the namespace with other functions such as is_inside(...) Of, if you can advise any alternative design pattern for such kind of logics, I would really appreciate that...

    Read the article

  • Is it true that in most Object Oriented Programming Languages, an "i" in an instance method always r

    - by Jian Lin
    In the following code: <script type="text/javascript"> var i = 10; function Circle(radius) { this.r = radius; this.i = radius; } Circle.i = 123; Circle.prototype.area = function() { alert(i); } var c = new Circle(1); var a = c.area(); </script> What is being alerted? The answer is at the end of this question. I found that the i in the alert call either refers to any local (if any), or the global variable. There is no way that it can be the instance variable or the class variable even when there is no local and no global defined. To refer to the instance variable i, we need this.i, and to the class variable i, we need Circle.i. Is this actually true for almost all Object oriented programming languages? Any exception? Are there cases that when there is no local and no global, it will look up the instance variable and then the class variable scope? (or in this case, are those called scope?) the answer is: 10 is being alerted.

    Read the article

  • http post request with cross-origin in javascript

    - by Calamarico
    i have a problem with a http post call in firefox. I know that when there are a cross origin, firefox first do a OPTIONS before the POST to know the access-control-allow headers. With this code i dont have any problem: Net.requestSpeech.prototype.post = function(url, data) { if(this.xhr != null) { this.xhr.open("POST", url); this.xhr.onreadystatechange = Net.requestSpeech.eventFunction; this.xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8"); this.xhr.send(data); } } I test this code with a simple html that invokes this function. Everything is ok and i have the response of the OPTIONS and POST, and i process the response. But, i'm trying to integrate this code with an existen application with uses jquery (i dont know if this is a problem), when the send(data) executes in this case, the browser (firefox) do the same, first do a OPTION request, but in this case dont receive the response of the server and puts this message in console: [18:48:13.529] OPTIONS http://localhost:8111/ [undefined 31ms] Undefined... the undefined is because dont receive the response, but the code is the same, i dont know why in this case the option dont receive the response, someone have an idea? i debug my server app and the OPTIONS arrive ok to the server, but it seems like the browser dont wait to the response. edit more later: ok i think that the problem is when i run with a simple html with a SCRIPT tag that invokes the method who do the request run ok, but in this app that dont receive the response, i have a form that do a onsubmit event, i think that the submit event returns very fast and the browser dont have time to get the OPTIONS request. edit more later later: WTF, i resolve the problem make the POST request to sync: this.xhr.open("POST", url, false); The submit reponse very quickly and can't wait to the OPTION response of the browser, any idea to this?

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >