Search Results

Search found 192 results on 8 pages for 'michal niklas'.

Page 7/8 | < Previous Page | 3 4 5 6 7 8  | Next Page >

  • Does "epsilon" really guarantees anything in floating-point computations?!

    - by Michal Czardybon
    To make the problem short let's say I want to compute expression: a / (b - c) on float's. To make sure the result is meaningful, I can check if 'b' and 'c' are inequal: float eps = std::numeric_limits<float>::epsilon(); if ((b - c) > EPS || (c - b) > EPS) { return a / (b - c); } but my tests show it is not enough to guarantee either meaningful results nor not failing to provide a result if it is possible. Case 1: a = 1.0f; b = 0.00000003f; c = 0.00000002f; Result: The if condition is NOT met, but the expression would produce a correct result 100000008 (as for the floats' precision). Case 2: a = 1e33f; b = 0.000003; c = 0.000002; Result: The if condition is met, but the expression produces not a meaningful result +1.#INF00. I found it much more reliable to check the result, not the arguments: const float INF = numeric_limits<float>::infinity(); float x = a / (b - c); if (-INF < x && x < INF) { return x; } But what for is the epsilon then and why is everyone saying epsilon is good to use?

    Read the article

  • named/bind zone file parser in C#

    - by Michal Rogozinski
    Hi, I'm looking for a bind/named zone file parser in .NET C#. If there is anything I could import/convert I would be interested too. Unfortunately there's not much, or I'm having troubles finding it. My goal is to make sure a zone file is syntax-errors-free before I push it to the server. I'd appreciate any help or hints. Thanks

    Read the article

  • When using SQL Compact on Windows Mobile, do you store the sdf file on a storage card?

    - by Michal Drozdowicz
    Having had some Sql Compact db corruption issues in the past and gone through the article on these, I got the idea that storing the database sdf file on a storage card significantly increases the risk of data loss due to db corruption. Do you store the sdf file on a storage card? Have you had any issues caused by it? What should I pay attention to when recommending a particular brand or model of an SD card wrt the stability and security for use with SQL Compact?

    Read the article

  • C# - Thread does not abort on application closing

    - by michal
    Hi, I have an application which does some background task (network listening & reading) in separate Thread. It seems however that the Thread is not being Terminated/Aborted when I close the application (click "x" button on titlebar ;)). Is that because the main Thread routine is while(true) {...} ? What is the solution here? I was looking for some "interruption" flag for the Thread as the condition for "while" loop, but didn't found any ...

    Read the article

  • Does "delegate" mean a type or an object?

    - by Michal Czardybon
    Reading from MSDN: "A delegate is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method." Does then "delegate" mean a type or an object?! ...It cannot be both. It seems to me that the single word is used in two different meanings: a type containing a reference to a method of some specified signature, an object of that type, which can be actually called like a method. I would prefer a more precise vocabulary and use "delegate type" for the first case. I have been recently reading a lot about events and delegates and that ambiguity was making me confused many times. Some other uses of "delegate" word in MSDN in the first meaning: "Custom event delegates are needed only when an event generates event data" "A delegate declaration defines a class that is derived from the class System.Delegate" Some other uses of "delegate" word in MSDN in the second meaning: "specify a delegate that will be called upon the occurrence of some event" "Delegates are objects that refer to methods. They are sometimes described as type-safe function pointers" What do you think? Why did people from Microsoft introduced this ambiguity? Am I the only person to have conceptual problems with different notions being referenced with the same word.

    Read the article

  • C# CodeDom - making project's forms accessible for scripts.

    - by michal
    Hi, I'm learning CodeDom scripting, I started with http://www.c-sharpcorner.com/uploadfile/mgold/codedomcalculator08082005003253am/codedomcalculator.aspx Now I'd like to allow script modify the project's form (for learning purposes only). I suppose I need to create new field for a class I'm generating which refers "this". However I have no idea how can I set a reference for script-accessible object ... ? Or can I directly publish some class member (like "this" or "button1") to a CodeDom script structure?

    Read the article

  • Simple network gaming, client-server architecture planning.

    - by michal
    Hi, I'm coding simple game which I plan to make multiplayer (over the network) as my university project. I'm considering two scenarios for client-server communication: The physics (they're trivial! I should call it "collision tests" in fact :) ) are processed on server machine only. Therefore the communication looks like Client1->Server: Pressed "UP" Server->Clients: here you go, Client1 position is now [X,Y] Client2->Server: Pressed "fire" Server->Clients: Client1 hit Client2, make Client2 disappear! server receives the event and broadcasts it to all the other clients. Client1->Server: Pressed "UP" Server->Clients: Client1 pressed "UP", recalculate his position!! [Client1 receives this one as well!] Which one is better? Or maybe none of them? :)

    Read the article

  • empty() returning TRUE on object's non-empty property

    - by Michal M
    I've got a very weird and unexpected problem. empty() is returning TRUE on a non-empty property for a reason unknown to me. class MyObject { private $_property; public function __construct($property) { $this->_property = $property; } public function __get($name) { $priv_name = "_{$name}"; if (isset($this->$priv_name)) { return $this->$priv_name; } else { return NULL; } } } $obj = new MyObject('string value'); echo $obj->property; // Output 'string value' echo empty($obj->property); // Output 1 (means, that property is empty) Would this mean, that the __get() magic function is not called when using empty()? btw. I'm running PHP version 5.0.4

    Read the article

  • Binding keys from specific device in X.org

    - by Michal Cihar
    I have a remote control for presentations, which generates Next/Prior key events in X.org (Page up/down). I'd like to use these for navigating in playlist (using MPD, but it probably does not matter). The problem is that I want to make this control work all the time (without application having focus) and I don't want to lose Page up/down functionality from normal keyboard. Is there some application which would allow me to bind actions to events from specific keyboard? Or is there simple way to implement such thing on my own?

    Read the article

  • C, reading multiple numbers from single input line (scanf?)

    - by michal
    Hi, I'm writing an app in pure C which expects two line at input: first one, which tells how big an array of int will be, and the second, which contains values, separated by space. So, for the following input 5 1 2 3 4 99 I need to create an array containing {1,2,3,4,99} Now, my question is - what is the fastest (yet easy ;)) way to do so? My problem is "how to read multiple numbers without looping through the whole string checking if it's space or a number" ? Thanks m.

    Read the article

  • C++, WCHAR[] to std::cout and comparision

    - by michal
    Hi, I need to put WCHAR[] to std::cout ... It is a part of PWLAN_CONNECTION_NOTIFICATION_DATA passed from Native Wifi API callback. I tried simply std::cout << var; but it prints out the numeric address of first char. the comparision (var == L"some text") doesn't work either. The debugger returns the expected value, however the comparision returns 0. How can I convert this array to a standard string(std::string)? Thanks in advance

    Read the article

  • How to inflate one view with an layout

    - by Michal Dymel
    Hi, I have a layout defined in XML. It contains also: <RelativeLayout android:id="@+id/item" android:layout_width="fill_parent" android:layout_height="wrap_content" /> I would like to inflate this RelativeView with other XML layout file. I may use different layouts depending on a situation. How should I do it? I was trying different variations of RelativeLayout item = (RelativeLayout) findViewById(R.id.item); item.inflate(...) But none of them worked fine. Heeelp ;)

    Read the article

  • Grammatically correct double-noun identifiers, plural versions

    - by Michal Czardybon
    Consider compounds of two nouns, which in natural English would most often appear in the form "noun of noun", e.g. "direction of light", "output of a filter". When programming we usually write "LightDirection" and "FilterOutput". Now, I have a problem with plural nouns. There are two cases: 1) singular of plural e.g. "union of (two) sets", "intersection of (two) segments" Which is correct, SetUnion and SegmentIntersection or SetsUnion and SegmentsIntersection? 2) plural of plural There are two subcases: (a) Many elements, each having many related elements, e.g. "outputs of filters" (b) Many elements, each having single related element, e.g. "directions of vectors" Shell I use FilterOutputs and VectorDirections or FiltersOutputs and VectorsDirections? I suspect correct is the first version (FilterOutupts, VectorDirections), but I think it may lead to ambiguities, e.g. FilterOutputs - many outputs of a single filter or many outputs of many filters? LineSegmentProjections - projections of many segments or many projections of a single segment?

    Read the article

  • How to overload shutdown function?

    - by Michal M
    I am using Kohana (v3) framework but I believe it's not tied to a particular framework. What I have is basically an app with a front-end, where I want to use Kohana's native Kohana::shutdown_handler(), but I also have a part of the - RESTful API - where I don't want colourful and html-encoded exception reporting. I want a plain text reporting. The way I thought it might work is to register another shutdown function in API's controller abstract class constructor, but then I realised register_shutdown_function() works differently to set_exception_handler() and instead of replacing it adds another function to the shutdown procedure. What's worse PHP doesn't allow "unregistering" shutdown functions and that's where my problem lies. What to do, if you want to use another shutdown function instead of one already registered?

    Read the article

  • Django test client gets 301 redirection when accessing url

    - by Michal Klich
    I am writing unittests for django views. I have observed that one of my views returns redirection code 301, which is not expected. Here is my views.py mentioned earlier. def index(request): return render(request, 'index.html', {'form': QueryForm()}) def query(request): if request.is_ajax(): form = QueryForm(request.POST) return HttpResponse('valid') Below is urls.py. urlpatterns = patterns('', url(r'^$', 'core.views.index'), url(r'^query/$', 'core.views.query') ) And unittest that will fail. def so_test(self): response = self.client.post('/') self.assertEquals(response.status_code, 200) response = self.client.post('/query', {}) self.assertEquals(response.status_code, 200) My question is: why there is status 301 returned?

    Read the article

  • Custom bean instantiation logic in Spring MVC

    - by Michal Bachman
    I have a Spring MVC application trying to use a rich domain model, with the following mapping in the Controller class: @RequestMapping(value = "/entity", method = RequestMethod.POST) public String create(@Valid Entity entity, BindingResult result, ModelMap modelMap) { if (entity== null) throw new IllegalArgumentException("An entity is required"); if (result.hasErrors()) { modelMap.addAttribute("entity", entity); return "entity/create"; } entity.persist(); return "redirect:/entity/" + entity.getId(); } Before this method gets executed, Spring uses BeanUtils to instantiate a new Entity and populate its fields. It uses this: ... ReflectionUtils.makeAccessible(ctor); return ctor.newInstance(args); Here's the problem: My entities are Spring managed beans. The reason for this is to inject DAOs on them. Instead of calling new, I use EntityFactory.createEntity(). When they're retrieved from the database, I have an interceptor that overrides the public Object instantiate(String entityName, EntityMode entityMode, Serializable id) method and hooks the factories into that. So the last piece of the puzzle missing here is how to force Spring to use the factory rather than its own BeanUtils reflective approach? Any suggestions for a clean solution? Thanks very much in advance.

    Read the article

  • Persisting non-entity class that extends an entity (jpa) - example?

    - by Michal Minicki
    The JPA tutorial states that one can have a non-entity that extends entity class: Entities may extend both entity and non-entity classes, and non-entity classes may extend entity classes. - http://java.sun.com/javaee/5/docs/tutorial/doc/bnbqa.html Is it possible to persist such structure? I want to do this: @Entity abstract class Test { ... } class FirstConcreteTest extends Test { ... } // Non-ntity class SecondConcreteTest extends Test { ... } // Non-entity Test test = new FirstConcreteTest(); em.persist(test); What I would like it to do is to persist all fields mapped on abstract Test to a common database table for all concrete classes (first and second), leaving all fields of first and second test class unpersisted (these can contain stuff like EJBs, jdbc pools, etc). And a bonus question. Is it possible to persist abstract property too? @Entity abstract class Test { @Column @Access(AccessType.PROPERTY) abstract public String getName(); } class SecondConcreteTest extends Test { public String getName() { return "Second Concrete Test"; } }

    Read the article

  • VirtualStringTree hide node(s)

    - by michal
    Hi, is that possible to hide specific nodes in VirtualStringTree? I'm implementing "filtering" feature (the VST acts as a list with columns), and I'd like to avoid reloading content each time the filter is changed - instead, much faster would be to tell VST not to render specific items ... any solutions?

    Read the article

  • SQLiteOpenHelper getWritableDatabse() fails with no Exception

    - by Michal K
    I have a very strange problem. It only shows from time to time, on several devices. Can't seem to reproduce it when I want, but had it so many times, that I think I know where I get it. So I have a Loader which connects to sqlite through a singleton SQLiteOpenHelper: try{ Log.i(TAG, "Get details offline / db helper: "+DatabaseHelper.getInstance(getContext())); SQLiteDatabase db=DatabaseHelper.getInstance(this.getContext()).getWritableDatabase(); Log.i(TAG, "Get details offline / db: "+db); //doing some work on the db //... } catch(SQLiteException e){ e.printStackTrace(); return null; } catch(Exception e){ e.printStackTrace(); return null; //trying everything to grab some exception or whatever } My SQLIteOpenHelper looks something like this: public class DatabaseHelper extends SQLiteOpenHelper { private static DatabaseHelper mInstance = null; private static Context mCxt; public static DatabaseHelper getInstance(Context cxt) { //using app context ass suggested by CommonsWare Log.i("DBHELPER1", "cxt"+mCxt+" / instance: "+mInstance); if (mInstance == null) { mInstance = new DatabaseHelper(cxt.getApplicationContext()); } Log.i("DBHELPER2", "cxt"+mCxt+" / instance: "+mInstance); mCxt = cxt; return mInstance; } //private constructor private DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); this.mCxt = context; } @Override public void onCreate(SQLiteDatabase db) { //some tables created here } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { //upgrade code here } It really works great in most cases. But from time to time I get a log similar to this: 06-10 23:49:59.621: I/DBHELPER1(26499): cxtcom.bananout.Bananout@407152c8 / instance: com.bananout.helpers.DatabaseHelper@40827560 06-10 23:49:59.631: I/DBHELPER2(26499): cxtcom.bananout.Bananout@407152c8 / instance: com.bananout.helpers.DatabaseHelper@40827560 06-10 23:49:59.631: I/DetailsLoader(26499): Get event details offline / db helper: com.bananout.helpers.DatabaseHelper@40827560 06-10 23:49:59.631: I/DBHELPER1(26499): cxtcom.bananout.Bananout@407152c8 / instance: com.bananout.helpers.DatabaseHelper@40827560 06-10 23:49:59.651: I/DBHELPER2(26499): cxtcom.bananout.Bananout@407152c8 / instance: com.bananout.helpers.DatabaseHelper@40827560 This line Log.i(TAG, "Get details offline / db: "+db); never gets called! No Exceptions, silence. Plus, the thread with the Loader is not running anymore. So nothing past this line SQLiteDatabase db=DatabaseHelper.getInstance(this.getContext()).getWritableDatabase(); gets executed. What can possibly go wrong on this line?

    Read the article

< Previous Page | 3 4 5 6 7 8  | Next Page >