Search Results

Search found 697 results on 28 pages for 'matthew guay'.

Page 21/28 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Passing Derived Class Instances as void* to Generic Callbacks in C++

    - by Matthew Iselin
    This is a bit of an involved problem, so I'll do the best I can to explain what's going on. If I miss something, please tell me so I can clarify. We have a callback system where on one side a module or application provides a "Service" and clients can perform actions with this Service (A very rudimentary IPC, basically). For future reference let's say we have some definitions like so: typedef int (*callback)(void*); // This is NOT in our code, but makes explaining easier. installCallback(string serviceName, callback cb); // Really handled by a proper management system sendMessage(string serviceName, void* arg); // arg = value to pass to callback This works fine for basic types such as structs or builtins. We have an MI structure a bit like this: Device <- Disk <- MyDiskProvider class Disk : public virtual Device class MyDiskProvider : public Disk The provider may be anything from a hardware driver to a bit of glue that handles disk images. The point is that classes inherit Disk. We have a "service" which is to be notified of all new Disks in the system, and this is where things unravel: void diskHandler(void *p) { Disk *pDisk = reinterpret_cast<Disk*>(p); // Uh oh! // Remainder is not important } SomeDiskProvider::initialise() { // Probe hardware, whatever... // Tell the disk system we're here! sendMessage("disk-handler", reinterpret_cast<void*>(this)); // Uh oh! } The problem is, SomeDiskProvider inherits Disk, but the callback handler can't receive that type (as the callback function pointer must be generic). Could RTTI and templates help here? Any suggestions would be greatly appreciated.

    Read the article

  • Progress bar increment by 1 every 100th of second

    - by Matthew De'Loughry
    I'm trying to get a JProgressBar to increment by 1 every 100th of a second, and at the moment I'm using Thread.sleep(100) inside a while statement like so: try { while (i<=100){ doTime(); } } catch (InterruptedException ex) { Logger.getLogger(SplashScreen.class.getName()).log(Level.SEVERE, null, ex); } public void doTime() throws InterruptedException{ jLabel1.setText("sleeping"); Thread.sleep(100); jLabel1.setText("start"); i++; pb.setValue(i); pb.repaint(); } and If I debug by doing a System.out.println it displays in real time but the swing GUI freezes until it drops out of the while loop can anyone help? thanks matt

    Read the article

  • NSPredicate cause update editing to return NSFetchedResultsChangeDelete not NSFetchedResultsChangeUp

    - by Matthew Weiss
    I have predicate inside of - (NSFetchedResultsController *)fetchedResultsController in a standard way starting from the CoreDataBook example. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"state=%@ && date = %@ && date < %@", @"1",fromDate,toDate]; [fetchRequest setPredicate:predicate]; This works fine however when editing an item, it returns with NSFetchedResultsChangeDelete not Update. When the main view returns, it is missing the item. If I restart the simulator the delete was not saved and the correct editing result is shown the the predicate working correctly. case NSFetchedResultsChangeDelete: [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; break; I can confirm the behavior by commenting out the two predicate lines ONLY and then all works as it should correctly returning with the full set after editing and calling NSFetchedResultsChangeUpdate instead of NSFetchedResultsChangeDelete. I have read http://matteocaldari.it/2009/11/multiple-contexts-controllers-delegates-and-coredata-bug who reports similar behavior but I have not found a work around to my problem. I can

    Read the article

  • Save HashMap data into SQLite

    - by Matthew
    I'm Trying to save data from Json into SQLite. For now I keep the data from Json into HashMap. I already search it, and there's said use the ContentValues. But I still don't get it how to use it. I try looking at this question save data to SQLite from json object using Hashmap in Android, but it doesn't help a lot. Is there any option that I can use to save the data from HashMap into SQLite? Here's My code. MainHellobali.java // Hashmap for ListView ArrayList<HashMap<String, String>> all_itemList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_helloballi); all_itemList = new ArrayList<HashMap<String, String>>(); // Calling async task to get json new getAllItem().execute(); } private class getAllItem extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... arg0) { // Creating service handler class instance ServiceHandler sh = new ServiceHandler(); // Making a request to url and getting response String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET); Log.d("Response: ", "> " + jsonStr); if (jsonStr != null) { try { all_item = new JSONArray(jsonStr); // looping through All Contacts for (int i = 0; i < all_item.length(); i++) { JSONObject c = all_item.getJSONObject(i); String item_id = c.getString(TAG_ITEM_ID); String category_name = c.getString(TAG_CATEGORY_NAME); String item_name = c.getString(TAG_ITEM_NAME); // tmp hashmap for single contact HashMap<String, String> allItem = new HashMap<String, String>(); // adding each child node to HashMap key => value allItem.put(TAG_ITEM_ID, item_id); allItem.put(TAG_CATEGORY_NAME, category_name); allItem.put(TAG_ITEM_NAME, item_name); // adding contact to contact list all_itemList.add(allItem); } } catch (JSONException e) { e.printStackTrace(); } } else { Log.e("ServiceHandler", "Couldn't get any data from the url"); } return null; } } I have DatabasehHandler.java and AllItem.java too. I can put it in here if its necessary. Thanks before ** Add Edited Code ** // looping through All Contacts for (int i = 0; i < all_item.length(); i++) { JSONObject c = all_item.getJSONObject(i); String item_id = c.getString(TAG_ITEM_ID); String category_name = c.getString(TAG_CATEGORY_NAME); String item_name = c.getString(TAG_ITEM_NAME); DatabaseHandler databaseHandler = new DatabaseHandler(this); //error here "The Constructor DatabaseHandler(MainHellobali.getAllItem) is undefined }

    Read the article

  • Qt QTextEdit Qt4.2 Valid HTML String

    - by Matthew Hoggan
    I am trying to generate the correct HTML to render to a QTextEdit Using Qt 4.2 on RHEL 5.3. So far my algorithm generates the following html. I am not an expert web developer, but to me this string seems valid. 319:14:27:22: <font color="rgb(255,0,0)" bgcolor="rgb(255,0,0)">Message</font><br> What needs to change to get the colours to render. Currently it just renders as black text on a white background.

    Read the article

  • php fopen function dies, though I have file permissions set to read and write

    - by Matthew Robert Keable
    I'm following a tutorial on php, and am having difficulty getting this to work. I set the appropriate directory permissions to read and write, but every time I run this, I get the die string. The code is: $ourFileName = "testFile.txt"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); As far as my basic understanding goes, if "testFile.txt" does not exist, fopen should create that file (I have basic knowledge of Python, and remember this same principle in that language). But it...it doesn't. Even if I create the aforementioned file, and put it up, that line of code still returns a die string. My hosting account does not give me permission to execute. Is this a problem? My server runs on Windows. I am using Dreamweaver CS5, on OSX 10.5.8. I've done some searching on this, and see other people having similar issues - but none of them keyed to exactly my range of problems. Being that I'm a beginner, I feel that it might be something I'm overlooking. Thanks!!

    Read the article

  • In WebKitGtk+, how can I access parameters in an event listener?

    - by Matthew
    Here is an example in javascript of what I want to do: function handleDragStart(e) { e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text/plain', 'some data'); } var dragSource = document.querySelector('#dragSource'); dragSource.addEventListener('dragstart', handleDragStart, false, null); But I am having trouble translating this to a GLib-based system. Here is an example in Vala: void on_dragstart(EventTarget event_target) { // How can I access the equivalent of e.dataTransfer? } WebKit.WebView web_view = ... WebKit.DOM.Document document = web_view.get_dom_document(); WebKit.DOM.Element drag_source = document.query_selector('#dragSource'); drag_source.add_event_listener("dragstart", (Callback) on_dragstart, false, null); While I am using Vala, an answer in any language interacting with WebKitGtk+ directly would be helpful.

    Read the article

  • Safari's never-ending loading message when an iframe does not have a src

    - by Matthew Pennell
    I'm using @rem's jQuery :visited plugin to do something with visited links on a page. The plugin works by creating an invisible iframe, injecting the HTML source, and comparing the colour of links to see which have been visited. It works perfectly. The problem I have is that on Safari, the status bar message always hangs on "Loading (X-1) of X items" - i.e. it thinks there is still some resource still needing to be loaded. I've narrowed it down to this plugin, and the fact that it attaches the IFRAME element to the BODY before the src is set (or injected in this case). I've tried rearranging the code to set the src before the append happens, but that breaks the plugin's functionality. Anyone have any ideas how to fix this issue? It's not a major issue as the site still functions perfectly well, but it's an annoying glitch that could be confusing to users.

    Read the article

  • Rotate MapView in Android

    - by Matthew B.
    I am writing an Android app where one of the features is that the map will rotate according to the compass (i.e. if the phone is pointing east, the map will be oriented so that the east side of the map is on top). Previous answers that I have found suggested over writing the onDraw() method in mapView, however, the api changed the method to final so it cannot be overwritten. As a result I have tried to overwrite the dispatchDraw() method like so: Note: -compass is a boolean that if true, rotate the view -bearing is a float variable that has the degrees that the view should rotate protected void dispatchDraw(Canvas canvas) { canvas.save(); if (compass) { final float w = this.getWidth(); final float h = this.getHeight(); final float scaleFactor = (float)(Math.sqrt(h * h + w * w) / Math.min(w, h)); final float centerX = w / 2.0f; final float centerY = h / 2.0f; canvas.rotate(bearing, centerX, centerY); canvas.scale(scaleFactor, scaleFactor, centerX, centerY); } super.dispatchDraw(canvas); canvas.restore(); }

    Read the article

  • Is it worth the time to switch from AjaxControlToolkit to jQuery?

    - by Matthew Jones
    I keep hearing all these things about how awesome jQuery is and how the AjaxControlToolkit sucks. Unfortunately, I only heard about this after I built my entire WebForms site using the toolkit. Now I am considering switching, if not entirely, mostly to jQuery. This is partially for the experience (having never coded in Javascript or used any frameworks) and partially because I think I have more control over jQuery. There is no pressing need to switch, but I'm considering doing it anyway. Is it worth tackling the learning curve for jQuery just to get the experience, of should I leave my working site well enough alone?

    Read the article

  • Refactor custom wizard to reduce flicker

    - by Matthew Brown
    I have implemented a custom wizard control in C# windows forms by creating a base form which has the shared components and then making child forms for each step of the process. I then have a class which hides/shows the child forms when you move from one step to another. The problem is that flickering is bad when moving between forms. Does anyone know a way to either keep this method and reduce the flicker or refactor it to make it use a single form (which should definitely reduce the flicker)?

    Read the article

  • Detect LaTeX class name

    - by Matthew Leingang
    I'm working on a LaTeX package which might need to do some things differently depending on the class that's being used. I'm wondering if there's a way to auto-detect or test the document class. One could certainly look up the class files and test for the existence of a specific macro defined by that class, but is there a smarter way? I looked at the definition of the \ProvidesClass macro and can't see if it saves the class name anywhere except \@currname. I believe \@currname is just the name of the current package or class being read. Basically I want to execute \author{\longauthorname} in the article class but \author[\shortauthorname]{\longauthorname} in the beamer class.

    Read the article

  • Detecting position with drag-and-drop and jQuery?

    - by Matthew Westrik
    Hi, I need to know how to detect the position of a dragged item as opposed to other divs. I need to detect whether an item is dropped outside of two different divs. (I am building a mac dock type start page and I need to know how to do this so I can delete icons by dragging them off the bar.) Any help would be greatly appreciated.

    Read the article

  • Using generics in F# to create an EnumArray type

    - by Matthew
    I've created an F# class to represent an array that allocates one element for each value of a specific enum. I'm using an explicit constructor that creates a dictionary from enum values to array indices, and an Item property so that you can write expressions like: let my_array = new EnumArray<EnumType, int> my_array.[EnumType.enum_value] <- 5 However, I'm getting the following obscure compilation error at the line marked with '// FS0670' below. error FS0670: This code is not sufficiently generic. The type variable ^e when ^e : enum<int> and ^e : equality and ^e : (static member op_Explicit : ^e -> int) could not be generalized because it would escape its scope. I'm at a loss - can anyone explain this error? type EnumArray< 'e, 'v when 'e : enum<int> and 'e : equality and ^e : (static member op_Explicit : ^e -> int) > = val enum_to_int : Dictionary<'e, int> val a : 'v array new() as this = { enum_to_int = new Dictionary<'e, int>() a = Array.zeroCreate (Enum.GetValues(typeof<'e>).Length) } then for (e : obj) in Enum.GetValues(typeof<'e>) do this.enum_to_int.Add(e :?> 'e, int(e :?> 'e)) member this.Item with get (idx : 'e) : 'v = this.a.[this.enum_to_int.[idx]] // FS0670 and set (idx : 'e) (c : 'v) = this.a.[this.enum_to_int.[idx]] <- c

    Read the article

  • jquery simplemodal question (about window overflow)

    - by Matthew Steiner
    I noticed that if the height of the window is too small (meaning that the modal is taller than the window is), then even scrolling up or down won't reveal more of the modal, since it is constantly centering itself to the center of the window. Is there a good way of changing this? I have a tall modal that if someone's using a short monitor it may cause problems. Not to mention just general usability. I would guess that somewhere in the code you can test for if the window height is less than the modal to not worry about centering it vertically? Ideas?

    Read the article

  • Assigned numbers to movie clip to plug in formula... not working

    - by Matthew MlgPro Harding
    So I am attempting to vertically evenly space these movie clips so I came up with a math formula involving n( the button number) but Its not working. var buttonArray:Array = [ side_banner.btn1, side_banner.btn2, side_banner.btn3, side_banner.btn4]; var buttonCount:uint = buttonArray.length; for (var i:uint=0; i< buttonCount; i++) { buttonArray[i].addEventListener(MouseEvent.CLICK, outputNumber); buttonArray[i].theTrigger = [i + 1]; } function outputNumber(e:MouseEvent):void { trace( e.target.theTrigger); buttonArray[i].y = (((stage.stageHeight - 400)/4)*(e.target.theTrigger)) - ((stage.stageHeight - 400)/4)/2 } But apparently each movie clip doesn't actually have a numerical value just a numeric name... how can I get the "n" btn number to use my formula? Thanks

    Read the article

  • How to generate a random but unique number and display that number within the source of my image tag

    - by Matthew
    Hello guys, I have done some searching but really haven't found what I'm looking for. What I would like to do is generate a random BUT unique 5 digit number and push whatever number into an img tag on my page. For example when people come to my page this number would generate and get pushed into this image tag: <img src="http://www.sample.com?randomNUM=12345" height="1" width="1" /> I have a mySQL DB and am looking to do this in PHP. Thank, Matt

    Read the article

  • Confusion on C++ Python extensions. Things like getting C++ values for python values.

    - by Matthew Mitchell
    I'm wanted to convert some of my python code to C++ for speed but it's not as easy as simply making a C++ function and making a few function calls. I have no idea how to get a C++ integer from a python integer object. I have an integer which is an attribute of an object that I want to use. I also have integers which are inside a list in the object which I need to use. I wanted to test making a C++ extension with this function: def setup_framebuffer(surface,flip=False): #Create texture if not done already if surface.texture is None: create_texture(surface) #Render child to parent if surface.frame_buffer is None: surface.frame_buffer = glGenFramebuffersEXT(1) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, c_uint(int(surface.frame_buffer))) glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, surface.texture, 0) glPushAttrib(GL_VIEWPORT_BIT) glViewport(0,0,surface._scale[0],surface._scale[1]) glMatrixMode(GL_PROJECTION) glLoadIdentity() #Load the projection matrix if flip: gluOrtho2D(0,surface._scale[0],surface._scale[1],0) else: gluOrtho2D(0,surface._scale[0],0,surface._scale[1]) That function calls create_texture, so I will have to pass that function to the C++ function which I will do with the third argument. This is what I have so far, while trying to follow information on the python documentation: #include <Python.h> #include <GL/gl.h> static PyMethodDef SpamMethods[] = { ... {"setup_framebuffer", setup_framebuffer, METH_VARARGS,"Loads a texture from a Surface object to the OpenGL framebuffer."}, ... {NULL, NULL, 0, NULL} /* Sentinel */ }; static PyObject * setup_framebuffer(PyObject *self, PyObject *args){ bool flip; PyObject *create_texture, *arg_list,*pyflip,*frame_buffer_id; if (!PyArg_ParseTuple(args, "OOO", &surface,&pyflip,&create_texture)){ return NULL; } if (PyObject_IsTrue(pyflip) == 1){ flip = true; }else{ flip = false; } Py_XINCREF(create_texture); //Create texture if not done already if(texture == NULL){ arglist = Py_BuildValue("(O)", surface) result = PyEval_CallObject(create_texture, arglist); Py_DECREF(arglist); if (result == NULL){ return NULL; } Py_DECREF(result); } Py_XDECREF(create_texture); //Render child to parent frame_buffer_id = PyObject_GetAttr(surface, Py_BuildValue("s","frame_buffer")) if(surface.frame_buffer == NULL){ glGenFramebuffersEXT(1,frame_buffer_id); } glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer)); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, surface.texture, 0); glPushAttrib(GL_VIEWPORT_BIT); glViewport(0,0,surface._scale[0],surface._scale[1]); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //Load the projection matrix if (flip){ gluOrtho2D(0,surface._scale[0],surface._scale[1],0); }else{ gluOrtho2D(0,surface._scale[0],0,surface._scale[1]); } Py_INCREF(Py_None); return Py_None; } PyMODINIT_FUNC initcscalelib(void){ PyObject *module; module = Py_InitModule("cscalelib", Methods); if (m == NULL){ return; } } int main(int argc, char *argv[]){ /* Pass argv[0] to the Python interpreter */ Py_SetProgramName(argv[0]); /* Initialize the Python interpreter. Required. */ Py_Initialize(); /* Add a static module */ initscalelib(); }

    Read the article

  • Where do I put the logic of my MFC program?

    - by Matthew
    I created an application core, in C++, that I've compiled into a static library in Visual Studio. I am now at the process of writing a GUI for it. I am using MFC to do this. I figured out how to map button presses to execute certain methods of my application core's main class (i.e. buttons to have it start and stop). The core class however, should always be sampling data from an external source every second or two. The GUI should then populate some fields after each sample is taken. I can't seem to find a spot in my MFC objects like CDialog that I can constantly check to see if my class has grabbed the data.. then if it has put that data into some of the text boxes. A friend suggested that I create a thread on the OnInit() routine that would take care of this, but that solution isn't really working for me. Is there no spot where I can put an if statement that keeps being called until the program quits? i.e. if( coreapp.dataSampleReady() ) { // put coreapp.dataItem1() in TextBox1 // set progress bar to coreapp.dataItem2() // etc. // reset dataSampleReady }

    Read the article

  • What function does .NET NPV() use? Doesn't match manual calculations

    - by Matthew PK
    I am using the NPV() function in VB.NET to get NPV for a set of cash flows. However, the result of NPV() is not consistent with my results performing the calculation manually (nor the Investopedia NPV calc... which matches my manual results) My correct manual results and the NPV() results are close, within 5%.. but not the same... Manually, using the NPV formula: NPV = C0 + C1/(1+r)^1 + C2/(1+r)^2 + C3/(1+r)^3 + .... + Cn/(1+r)^n The manual result is stored in RunningTotal With rate r = 0.04 and period n = 10 Here is my relevant code: EDIT: Do I have OBOB somewhere? YearCashOutFlow = CDbl(TxtAnnualCashOut.Text) YearCashInFlow = CDbl(TxtTotalCostSave.Text) YearCount = 1 PAmount = -1 * (CDbl(TxtPartsCost.Text) + CDbl(TxtInstallCost.Text)) RunningTotal = PAmount YearNPValue = PAmount AnnualRateIncrease = CDbl(TxtUtilRateInc.Text) While AnnualRateIncrease > 1 AnnualRateIncrease = AnnualRateIncrease / 100 End While AnnualRateIncrease = 1 + AnnualRateIncrease ' ZERO YEAR ENTRIES ListBoxNPV.Items.Add(Format(PAmount, "currency")) ListBoxCostSave.Items.Add("$0.00") ListBoxIRR.Items.Add("-100") ListBoxNPVCum.Items.Add(Format(PAmount, "currency")) CashFlows(0) = PAmount '''' Do While YearCount <= CInt(TxtLifeOfProject.Text) ReDim Preserve CashFlows(YearCount) CashFlows(YearCount) = Math.Round(YearCashInFlow - YearCashOutFlow, 2) If CashFlows(YearCount) > 0 Then OnePos = True YearNPValue = CashFlows(YearCount) / (1 + DiscountRate) ^ YearCount RunningTotal = RunningTotal + YearNPValue ListBoxNPVCum.Items.Add(Format(Math.Round(RunningTotal, 2), "currency")) ListBoxCostSave.Items.Add(Format(YearCashInFlow, "currency")) If OnePos Then ListBoxIRR.Items.Add((IRR(CashFlows, 0.1)).ToString) ListBoxNPV.Items.Add(Format(NPV(DiscountRate, CashFlows), "currency")) Else ListBoxIRR.Items.Add("-100") ListBoxNPV.Items.Add(Format(RunningTotal, "currency")) End If YearCount = YearCount + 1 YearCashInFlow = AnnualRateIncrease * YearCashInFlow Loop

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >