Search Results

Search found 162 results on 7 pages for 'dustin myers'.

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

  • How can I create a simple message box in Python?

    - by Carson Myers
    I'm looking for the same effect as alert() in JavaScript. I wrote a simple web-based interpreter this afternoon using Twisted.web. You basically submit a block of Python code through a form, and the client comes and grabs it and executes it. I want to be able to make a simple popup message, without having to re-write a whole bunch of boilerplate wxPython or TkInter code every time (since the code gets submitted through a form and then disappears). I've tried tkMessageBox: import tkMessageBox tkMessageBox.showinfo(title="Greetings", message="Hello World!") but this opens another window in the background with a tk icon. I don't want this. I was looking for some simple wxPython code but it always required setting up a class and entering an app loop etc. Is there no simple, catch-free way of making a message box in Python?

    Read the article

  • Rails advanced queries with join and sum calculation

    - by Dustin Brewer
    I have two models: companies and expenses. Companies have many expenses and expenses belong to companies. My expense model has an 'amount' column. I was wondering if there is a way to perform a find based on a date range and the amount column of the expenses. Something like top 3 companies by total expense amounts over a 7 day period. I've tried for the better part of the day to get this to work, I've attempted joins, chaining named scopes, raw sql, etc. and I'm not having any luck. Thanks for the help.

    Read the article

  • JSONResult to String

    - by Dustin Laine
    I have a JsonResult that is working fine, and returning JSON from some POCO's. I want to save the JSON as a string in a DB. public JsonResult GetJSON() { JsonResult json = new JsonResult { Data = GetSomPocos() }; return json; } I need to audit the response, so I want to save the json into a DB. I am having trouble finding a way to get the JSON as a string. Any help is appreciated.

    Read the article

  • Floating Tables Problem Unwanted Space XHTML Strict

    - by Axel Myers
    Hi I have two floating tables side by side. One is set to float left, the other one is set to float right. The problem is when two table are floating, they both are out of flow so next table comes without any spacing. So I add a width attribute clear:both. But now it gave me a lot of unwanted space! it's height set to:0 (the div's) and nothing has changed. So what's the problem ? Website url: http://www.animetr.com/prv/

    Read the article

  • Shortcut to create automatic properties using Visual Studio 2008/2010 or Resharper 5

    - by Piers Myers
    I have a class that contains a load of properties that contain results of some calculations e.g: public class Results { public double Result1 { get; set; } public double Result2 { get; set; } } In a different class I am doing calculations to populate the above properties, e.g: public class Calc { private Results Calc() { Results res = new Results(); res.Result1 = ... some calculation res.Result2 = ... some other calculation res.Result3 = ... // not yet defined in 'Results' class return res; } } When I am writing the Calc class, 'Result3' will be highlighted in red as it is not yet defined in the 'Results' class. Currently I am using the Resharper ALT-Enter shortcut, selecting "Create Property 'Result3'" which will create the following code int the 'Results' class: public double Result3 { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } Which I need to manually change to: public double Result3 { get; set; } Then I use the CTRL-Shift-Backspace shortcut to take me back to the 'Calc' class. How can I easily create automatic properties in the 'Results' class if they are not yet defined directly from the 'Calc' class?

    Read the article

  • mysql eliminate responses under certain condition with join

    - by Dustin
    Forgive me if this is an easy question. I teach classes and want to be able to select those students who have taken one class, but not another class. I have two tables: lessons_slots which is the table for every class such as: -------------------- -ID name slots- -1 basics 10 - -2 advanced 10 - -3 basics 10 - --------------------- The other table is class_roll, which holds enrollment info, such as: -------------------- -sID classid firstname lastname- -1 1 Jo Schmo -2 1 Person Two ... -13 2 Jo Schmo --------------------- What I want to do, I select everyone who has not had the advanced class (for example). I've tried doing SELECT * FROM lessons_slots LEFT JOIN class_roll ON lessons_slots.ID = class_roll.classid WHERE lessons_slots.name != 'advanced' But that doesn't work. Any ideas?

    Read the article

  • How do I handle the messages for a simple web-based live chat, on the server side?

    - by Carson Myers
    I'm building a simple live chat into a web application running on Django, but one thing I'm confused about is how I should store the messages between users. The chat will support multiple users, and a chat "session" is composed of users connected to one user that is the "host." The application is a sort of online document collaboration thing, so user X has a document, and users Y and Z would connect to user X to talk about the document, and that would be one chat session. If user Y disconnected for five minutes, and then signed back in and reconnected to user X, he should not get any of the messages shared between users X and Z while he was away. if users X, Y, and Z can have a chat session about user X's document, then users X and Y can connect to a simultaneous, but separate discussion about user Z's document. How should I handle this? Should I keep each message in the database? Each message would have an owner user and a target user (the host), and a separate table would be used to connect users with messages (which messages are visible to what users). Or should I store each session as an HTML file on the server, which messages get appended to? The problem is, I can't just send messages directly between clients. They have to be sent to the server in a POST request, and then each client has to periodically check for the messages in a GET request. Except I can't just have each message cleared after a client fetches it, because there could be multiple clients. How should I set this up? Any suggestions?

    Read the article

  • accessing private variable from member function in PHP

    - by Carson Myers
    I have derived a class from Exception, basically like so: class MyException extends Exception { private $_type; public function type() { return $this->_type; //line 74 } public function __toString() { include "sometemplate.php"; return ""; } } Then, I derived from MyException like so: class SpecialException extends MyException { private $_type = "superspecial"; } If I throw new SpecialException("bla") from a function, catch it, and go echo $e, then the __toString function should load a template, display that, and then not actually return anything to echo. This is basically what's in the template file <div class="<?php echo $this->type(); ?>class"> <p> <?php echo $this->message; ?> </p> </div> in my mind, this should definitely work. However, I get the following error when an exception is thrown and I try to display it: Fatal error: Cannot access private property SpecialException::$_type in C:\path\to\exceptions.php on line 74 Can anyone explain why I am breaking the rules here? Am I doing something horribly witty with this code? Is there a much more idiomatic way to handle this situation? The point of the $_type variable is (as shown) that I want a different div class to be used depending on the type of exception caught.

    Read the article

  • Preprocessor "macro function" vs. function pointer - best practice?

    - by Dustin
    I recently started a small personal project (RGB value to BGR value conversion program) in C, and I realised that a function that converts from RGB to BGR can not only perform the conversion but also the inversion. Obviously that means I don't really need two functions rgb2bgr and bgr2rgb. However, does it matter whether I use a function pointer instead of a macro? For example: int rgb2bgr (const int rgb); /* * Should I do this because it allows the compiler to issue * appropriate error messages using the proper function name, * not to mention possible debugging benefits? */ int (*bgr2rgb) (const int bgr) = rgb2bgr; /* * Or should I do this since it is merely a convenience * and they're really the same function anyway? */ #define bgr2rgb(bgr) (rgb2bgr (bgr)) I'm not necessarily looking for a change in execution efficiency as it's more of a subjective question out of curiosity. I am well aware of the fact that type safety is neither lost nor gained using either method. Would the function pointer merely be a convenience or are there more practical benefits to be gained of which I am unaware?

    Read the article

  • What is the best way to setup my tables and relationships for this use case?

    - by Dustin Brewer
    1)A user can have many causes and a cause can belong to many users. 2)A user can have many campaigns and campaigns can belong to many users. Campaigns belong to one cause. I want to be able to assign causes or campaigns to a given user, individually. So a user can be assigned a specific campaign. OR a user could be assigned a cause and all of the campaigns of that cause should then be associated with a user. Is that possible? And could I set it up so that the relationships could be simplified like so: User.causes = all causes that belong to a user User.campaigns = all campaigns that belong to user whether through a cause association or campaign association

    Read the article

  • associating a filetype with a batch script, and getting parameters passed to file of that type.

    - by Carson Myers
    Sorry for the cryptic title. I have associated python scripts with a batch file that looks like this: python %* I did this because on my machine, python is installed at C:\python26 and I prefer not to reinstall it (for some reason, it won't let me add a file association to the python interpreter. I can copy the executable to Program Files and it works -- but nothing out of Program Files seems to work). Anyways, I can do this, so far: C:\py django-admin C:\py python "C:\python26\Lib\site-packages\django\bin\django-admin.py" Type 'django-admin.py help' for usage. C:\py django-admin startproject myProj C:\py python "C:\python26\Lib\site-packages\django\bin\django-admin.py" Type 'django-admin.py help' for usage. but the additional parameters don't get passed along to the batch script. This is getting very annoying, all I want to do is run python scripts :) How can I grab the rest of the parameters in this situation?

    Read the article

  • Jquery prettyPhoto and star conflict....DOM not loading?

    - by Dustin
    I'm working on an online ordering system for photography clients: Here. (Forgive the requirement of having to sign in). After signing in, the user is able to rate pictures using the stars listed below each picture, then subsequently view 3 star pics, or 4 star pics, etc. However, when the user clicks on an image, a lightbox expands (prettyPhoto namely) which contains the picture as well as the stars listed below. I want users to be able to star a picture within the lightbox, but the javascript is not being passed after the prettyPhoto lightbox is initialized. Consequently, they can't rate pictures within the lightbox. I've heard of something similar to this, but have no idea about how to go about tackling the problem. Any help would be appreciated. Thanks!

    Read the article

  • Is it acceptable to wrap PHP library functions solely to change the names?

    - by Carson Myers
    I'm going to be starting a fairly large PHP application this summer, on which I'll be the sole developer (so I don't have any coding conventions to conform to aside from my own). PHP 5.3 is a decent language IMO, despite the stupid namespace token. But one thing that has always bothered me about it is the standard library and its lack of a naming convention. So I'm curious, would it be seriously bad practice to wrap some of the most common standard library functions in my own functions/classes to make the names a little better? I suppose it could also add or modify some functionality in some cases, although at the moment I don't have any examples (I figure I will find ways to make them OO or make them work a little differently while I am working). If you saw a PHP developer do this, would you think "Man, this is one shoddy developer?" Additionally, I don't know much (or anything) about if/how PHP is optimized, and I know that usually PHP performace doesn't matter. But would doing something like this have a noticeable impact on the performance of my application?

    Read the article

  • Preprocessor #define vs. function pointer - best practice?

    - by Dustin
    I recently started a small personal project (RGB value to BGR value conversion program) in C, and I realised that a function that converts from RGB to BGR can not only perform the conversion but also the inversion. Obviously that means I don't really need two functions rgb2bgr and bgr2rgb. However, does it matter whether I use a function pointer instead of a macro? For example: int rgb2bgr (const int rgb); /* * Should I do this because it allows the compiler to issue * appropriate error messages using the proper function name, * not to mention possible debugging benefits? */ int (*bgr2rgb) (const int bgr) = rgb2bgr; /* * Or should I do this since it is merely a convenience * and they're really the same function anyway? */ #define bgr2rgb(bgr) (rgb2bgr (bgr)) I'm not necessarily looking for a change in execution efficiency as it's more of a subjective question out of curiosity. I am well aware of the fact that type safety is neither lost nor gained using either method. Would the function pointer merely be a convenience or are there more practical benefits to be gained of which I am unaware?

    Read the article

  • Design RESTful service with multiple ids

    - by Dustin Digmann
    I am designing a RESTful service. It is to list a set of data. The main problem is that the set does not have a reasonable, single identifier. Nor can the specific set be easily calculated within the knowledge of the system. As a result, it does not seem possible to have a GET /items/{identifier} service. I do have the id of each element being requested. My main issue is that it does not seem RESTful to list the ids in the URI (eg GET items/{id1},{id2},...,{idn} ). Right? I could see DELETE having a similar use case - remove multiple items in one request cycle. How would such a use case be satisfied while staying within the REST realm? Is that possible?

    Read the article

  • avoiding code duplication in Rails 3 models

    - by Dustin Frazier
    I'm working on a Rails 3.1 application where there are a number of different enum-like models that are stored in the database. There is a lot of identical code in these models, as well as in the associated controllers and views. I've solved the code duplication for the controllers and views via a shared parent controller class and the new view/layout inheritance that's part of Rails 3. Now I'm trying to solve the code duplication in the models, and I'm stuck. An example of one of my enum models is as follows: class Format < ActiveRecord::Base has_and_belongs_to_many :videos attr_accessible :name validates :name, presence: true, length: { maximum: 20 } before_destroy :verify_no_linked_videos def verify_no_linked_videos unless self.videos.empty? self.errors[:base] << "Couldn't delete format with associated videos." raise ActiveRecord::RecordInvalid.new self end end end I have four or five other classes with nearly identical code (the association declaration being the only difference). I've tried creating a module with the shared code that they all include (which seems like the Ruby Way), but much of the duplicate code relies on ActiveRecord, so the methods I'm trying to use in the module (validate, attr_accessible, etc.) aren't available. I know about ActiveModel, but that doesn't get me all the way there. I've also tried creating a common, non-persistent parent class that subclasses ActiveRecord::Base, but all of the code I've seen to accomplish this assumes that you won't have subclasses of your non-persistent class that do persist. Any suggestions for how best to avoid duplicating these identical lines of code across many different enum models?

    Read the article

  • Detect all changes to a <input type="text"> (immediately) using JQuery

    - by Dustin Boswell
    There are many ways the value of a <input type="text"> can change, including: keypresses copy/paste modified with JavaScript auto-completed by browser or a toolbar I want my JavaScript function to be called (with the current input value) any time it changes. And I want it to be called right away, not just when the input loses focus. I'm looking for the cleanest and most robust way to do this across all browsers (using jQuery preferably). Example use case: On the Twitter Signup page, the username field's value gets shown in the url "http://twitter/username" below it.

    Read the article

  • How should I build a simple database package for my python application?

    - by Carson Myers
    I'm building a database library for my application using sqlite3 as the base. I want to structure it like so: db/ __init__.py users.py blah.py etc.py So I would do this in Python: import db db.users.create('username', 'password') I'm suffering analysis paralysis (oh no!) about how to handle the database connection. I don't really want to use classes in these modules, it doesn't really seem appropriate to be able to create a bunch of "users" objects that can all manipulate the same database in the same ways -- so inheriting a connection is a no-go. Should I have one global connection to the database that all the modules use, and then put this in each module: #users.py from db_stuff import connection Or should I create a new connection for each module and keep that alive? Or should I create a new connection for every transaction? How are these database connections supposed to be used? The same goes for cursor objects: Do I create a new cursor for each transaction? Create just one for each database connection?

    Read the article

  • Need to use query column value in nested subquery

    - by Dustin
    It seems I cannot use a column from the parent query in a sub query. How can I refactor this query to get what I need? dbo.func_getRelatedAcnts returns a table of related accounts (all children from a given account). Events and Profiles are related to accounts. SELECT COUNT(r.reg_id) FROM registrations r JOIN profiles p ON (r.reg_frn_pro_id = p.pro_id) JOIN events e ON (r.reg_frn_evt_id = e.evt_id) WHERE evt_frn_acnt_id NOT IN (SELECT * FROM dbo.func_getRelatedAcnts(p.pro_frn_acnt_id))

    Read the article

  • Codeigniter setting multiple where conditions, how to unset one

    - by Dustin
    I've got a script that is a notify_url from paypal that is supposed to update multiple tables in my database using the following code: //update first table $this-db-where('someid', $somid); $this-db-update('table', $data); ///update second table $this-db-where('somesecondid', $somesecondid) $this-db-update('anothertable', $data2); Then I get the following error: Unknown column 'somesecondid' in 'where clause' UPDATE anothertable SET avail = 0 WHERE someid = '13' AND somesecondid = '199' So codeigniter is combining those where clauses into a single query. Is there a way to unset the first one so it only has "UPDATE anothertable SET avail=0 WHERE somesecondid = 199" ? Thanks!

    Read the article

  • How should I deal with sqlite errors?

    - by Dustin
    I have a long running application written in a mix of C and C++ that stores data in sqlite. While I am confident that committed data will remain available (barring mechanical failure) and uncommitted data will not be, it's not clear to me what I can do with this sort of middle state. I do a large number of inserts in a transaction and then commit it. When an error occurs on a given statement, I can schedule it to be attempted at some point in the future. It sounds like some errors might implicitly rollback my transaction (which would be undesirable if true). A larger problem is what happens when my commit itself fails. Currently, I'm just going to continue to retry it until it works. I would expect that whatever would cause my commit to fail may very well also cause a rollback to fail. What is the recommended mechanism for error handling in such a situation?

    Read the article

  • Adding variably named fields to Python classes

    - by Carson Myers
    I have a python class, and I need to add an arbitrary number of arbitrarily long lists to it. The names of the lists I need to add are also arbitrary. For example, in PHP, I would do this: class MyClass { } $c = new MyClass(); $n = "hello" $c.$n = array(1, 2, 3); How do I do this in Python? I'm also wondering if this is a reasonable thing to do. The alternative would be to create a dict of lists in the class, but since the number and size of the lists is arbitrary, I was worried there might be a performance hit from this. If you are wondering what I'm trying to accomplish, I'm writing a super-lightweight script interpreter. The interpreter walks through a human-written list and creates some kind of byte-code. The byte-code of each function will be stored as a list named after the function in an "app" class. I'm curious to hear any other suggestions on how to do this as well.

    Read the article

  • Decorator Design Pattern Use With Service Objects (wSingleton)

    - by Dustin
    I'm working on a project where I need to add some functionality to a service object and using a decorator to add it in seems like a good fit. However, I've only ever used decorators with simple beans, never on a singleton like a service object. Has anyone ever done this before and what are the pros and cons? In this case I don't think creating a subclass will work so a decorator seems to be a good fit. What are your thoughts on doing this?

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >