Search Results

Search found 344 results on 14 pages for 'sarah boyd'.

Page 10/14 | < Previous Page | 6 7 8 9 10 11 12 13 14  | Next Page >

  • SQL Server Error: maximum number of prefixes. The maximum is 3.

    - by Ian Boyd
    Trying to run a cross-server update: UPDATE cmslive.CMSFintrac.dbo.lsipos SET PostHistorySequencenNmber = ( SELECT TransactionNumber FROM Transactions WHERE Transactions.TransactionDate = cmslive.CMSFintrac.dbo.lsipos.TransactionDate) Gives the error: Server: Msg 117, Level 15, State 2, Line 5 The number name 'cmslive.CMSFintrac.dbo.lsipos' contains more than the maximum number of prefixes. The maximum is 3. What gives? Note: Rearranging the query into a less readable join form: UPDATE cmslive.CMSFintrac.dbo.lsipos SET PostHistorySequenceNumber = B.TransactionNumber FROM cmslive.CMSFintrac.dbo.lsipos A INNER JOIN Transactions B ON A.TransactionDate = B.TransactionDate does not give an error.

    Read the article

  • Can i change the view without changing the controller?

    - by Ian Boyd
    Pretend1 there is a place to type in a name:     Name: __________________ When the text box changes, the value is absorbed into the controller, who stores it in data model. Business rules require that a name be entered: if there is no text entered the TextBox should be colored something in the view to indicate baddness; otherwise it can be whatever color the view likes. The TextBox contains a String, the controller handles a String, and the model stores a String. Now lets say i want to improve the view. There is a new kind of text box2 that can be fed not only string-based keyboard input, but also an image. The view (currently) knows how to determine if the image is in the proper format to perform the processing required to extract text out of it. If there is text, then that text can be fed to the controller, who feeds it to the data model. But if the image is invalid, e.g.3 wrong file format invalid dimensions invalid bit depth unhandled or unknown encoding format missing or incorrectly located registration marks contents not recognizable the view can show something to the user that the image is bad. But the telling the user that something is bad is supposed to be the job of the controller. i'm, of course, not going to re-write the controller to handle Image based text-input (e.g. image based names). a. the code is binary locked inside a GUI widget4 b. there other views besides this one, i'm not going to impose a particular view onto the controller c. i just don't wanna. If i have to change things outside of this UI improvement, then i'll just leave the UI unimproved5 So what's the thinking on having different views for the same Model and Controller? Nitpicker's Corner 1 contrived hypothetical example 2 e.g. bar code, g-mask, ocr 3 contrived hypothetical reasons 4 or hardware of a USB bar-code scanner 5 forcing the user to continue to use a DateTimePicker rather than a TextBox

    Read the article

  • How to prevent hotlinking of flv files?

    - by Sarah
    How to, using PHP and/or .htaccess prevent hotlinking? There's a site, which is allowed to access the flv files located on my server, however I've noticed that there are many requests from other domains as well... Here's the actual rule: RewriteCond %{HTTP_REFERER} !^http://alloweddomain.com/.*$ [NC] RewriteRule .flv denied.php [NC,L] It's working OK except for Firefox, because FF is not sending referrer info when accessing .flv files...

    Read the article

  • Delphi: How to avoid EIntOverflow underflow when subtracting?

    - by Ian Boyd
    Microsoft already says, in the documentation for GetTickCount, that you could never compare tick counts to check if an interval has passed. e.g.: Incorrect (pseudo-code): DWORD endTime = GetTickCount + 10000; //10 s from now ... if (GetTickCount > endTime) break; The above code is bad because it is suceptable to rollover of the tick counter. For example, assume that the clock is near the end of it's range: endTime = 0xfffffe00 + 10000 = 0x00002510; //9,488 decimal Then you perform your check: if (GetTickCount > endTime) Which is satisfied immediatly, since GetTickCount is larger than endTime: if (0xfffffe01 > 0x00002510) The solution Instead you should always subtract the two time intervals: DWORD startTime = GetTickCount; ... if (GetTickCount - startTime) > 10000 //if it's been 10 seconds break; Looking at the same math: if (GetTickCount - startTime) > 10000 if (0xfffffe01 - 0xfffffe00) > 10000 if (1 > 10000) Which is all well and good in C/C++, where the compiler behaves a certain way. But what about Delphi? But when i perform the same math in Delphi, with overflow checking on ({Q+}, {$OVERFLOWCHECKS ON}), the subtraction of the two tick counts generates an EIntOverflow exception when the TickCount rolls over: if (0x00000100 - 0xffffff00) > 10000 0x00000100 - 0xffffff00 = 0x00000200 What is the intended solution for this problem? Edit: i've tried to temporarily turn off OVERFLOWCHECKS: {$OVERFLOWCHECKS OFF}] delta = GetTickCount - startTime; {$OVERFLOWCHECKS ON} But the subtraction still throws an EIntOverflow exception. Is there a better solution, involving casts and larger intermediate variable types?

    Read the article

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

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

    Read the article

  • handling multiple buttons in a form in struts

    - by sarah
    Hi All, I am facing an issue while handling multiple buttons in a form using struts. I have three buttons add,delete and go .I have made forward as hidden and on click of a button i would get the name of the button. The problem is with go button on click of that i want to call a javascript and then call the action and return to the same page .

    Read the article

  • Coordinating typedefs and structs in std::multiset (C++)

    - by Sarah
    I'm not a professional programmer, so please don't hesitate to state the obvious. My goal is to use a std::multiset container (typedef EventMultiSet) called currentEvents to organize a list of structs, of type Event, and to have members of class Host occasionally add new Event structs to currentEvents. The structs are supposed to be sorted by one of their members, time. I am not sure how much of what I am trying to do is legal; the g++ compiler reports (in "Host.h") "error: 'EventMultiSet' has not been declared." Here's what I'm doing: // Event.h struct Event { public: bool operator < ( const Event & rhs ) const { return ( time < rhs.time ); } double time; int eventID; int hostID; }; // Host.h ... void calcLifeHist( double, EventMultiSet * ); // produces compiler error ... void addEvent( double, int, int, EventMultiSet * ); // produces compiler error // Host.cpp #include "Event.h" ... // main.cpp #include "Event.h" ... typedef std::multiset< Event, std::less< Event > > EventMultiSet; EventMultiSet currentEvents; EventMultiSet * cePtr = &currentEvents; ... Major questions Where should I include the EventMultiSet typedef? Are my EventMultiSet pointers obviously problematic? Is the compare function within my Event struct (in theory) okay? Thank you very much in advance.

    Read the article

  • nullable type and a ReSharper warning

    - by Sarah Vessels
    I have the following code: private static LogLevel? _logLevel = null; public static LogLevel LogLevel { get { if (!_logLevel.HasValue) { _logLevel = readLogLevelFromFile(); } return _logLevel.Value; } } private static LogLevel readLogLevelFromFile() { ... } I get a ReSharper warning on the return statement about a possible System.InvalidOperationException and it suggests I check _logLevel to see if it is null first. However, readLogLevelFromFile returns LogLevel, not LogLevel?, so there is no way the return statement could be reached when _logLevel is null. Is this just an oversight by ReSharper, or am I missing something?

    Read the article

  • Getting a PasteScript error when I try to serve an existing Pylons app.

    - by Sarah
    I'm trying to serve an existing Python 2.5 Pylons application on OS X Snow Leopard. I've already installed Python 2.5 and set it as the default Python installation, installed paster, and installed the version of Pylons the app needs (0.9.6.1) as well as other eggs... but when I cd to the main folder and do "paster serve development.ini" I get the following: File "/usr/local/bin/paster", line 5, in <module> from pkg_resources import load_entry_point File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2603, in <module> File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 666, in require File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 565, in resolve pkg_resources.DistributionNotFound: PasteScript==1.7.3 I definitely have done "easy_install PasteScript==1.7.3" and I still get this error. Is there something really obvious I'm missing? Help? Thanks in advance.

    Read the article

  • Performance hit from C++ style casts?

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

    Read the article

  • Delphi: How to call a method when i click a control?

    - by Ian Boyd
    i have a method: procedure Frob(Sender: TObject); that i want to call when i click a menu item. The method comes to me though an interface: animal: IAnimal; IAnimal = interface procedure Frob(Sender: TObject); end; The question revolves around what to assign to the OnClick event handler of a menu item (i.e. control): var animal: IAnimal; ... begin ... menuItem := TMenuItem.Create(FileMenu) menuItem.Caption := 'Click me!'; menuItem.OnClick := <-------- what to do ... end; The obvious choice, my first attempt, and the wrong answer is: menuItem.OnClick := animal.Frob; So how can i call a method when user clicks a control? See also Why doesn't it work?

    Read the article

  • hql query formation

    - by sarah
    Hi I want to construt a hql query like select PLAN_ID from "GPIL_DB"."ROUTE_PLAN" where ASSIGNED_TO in ('prav','sheet') and END_DATE > todays date I am doing in this way but getting an error in setting parameters s=('a','b'); Query q = getSession().createQuery("select planId from RoutePlan where assignedTo in REG "); if(selUsers != null) { q.setParameter("REG", s); } where i am doing wrong?

    Read the article

  • using yield in C# like I would in Ruby

    - by Sarah Vessels
    Besides just using yield for iterators in Ruby, I also use it to pass control briefly back to the caller before resuming control in the called method. What I want to do in C# is similar. In a test class, I want to get a connection instance, create another variable instance that uses that connection, then pass the variable to the calling method so it can be fiddled with. I then want control to return to the called method so that the connection can be disposed. I guess I'm wanting a block/closure like in Ruby. Here's the general idea: private static MyThing getThing() { using (var connection = new Connection()) { yield return new MyThing(connection); } } [TestMethod] public void MyTest1() { // call getThing(), use yielded MyThing, control returns to getThing() // for disposal } [TestMethod] public void MyTest2() { // call getThing(), use yielded MyThing, control returns to getThing() // for disposal } ... This doesn't work in C#; ReSharper tells me that the body of getThing cannot be an iterator block because MyThing is not an iterator interface type. That's definitely true, but I don't want to iterate through some list. I'm guessing I shouldn't use yield if I'm not working with iterators. Any idea how I can achieve this block/closure thing in C# so I don't have to wrap my code in MyTest1, MyTest2, ... with the code in getThing()'s body?

    Read the article

  • query on display tag

    - by sarah
    Hi, I have the following code to display <display:table name="sessionScope.userList" id="userList" export="false" pagesize="1"> <display:column title="Select" style="width: 90px;"> <input type="checkbox" name="optionSelected" value=""/> </display:column> <display:column property="userName" sortable="false" title="UserName" paramId="userName" style="width: 150px; text-align:center" href="#"/> </display:table> On click of the checkbox i need to get the corresponding row value that is the username how would i get that?

    Read the article

  • scanf a byte then print it out?

    - by Sarah
    I've searched around to see if I can find this answer but I can't seem to (please let me know if I'm wrong). I am trying to use scanf to read in a byte, an unsigned int and a char in one .c file and I am trying to access this byte in a different .c file and print it out. (I have already checked to make sure I have included all the appropriate parameters everywhere) But I keep getting errors. The warnings are: database.c: In function ‘addCitizen’: database.c:23:2: warning: format ‘%hhu’ expects argument of type ‘int’, but argument 2 has type ‘byte *’ [-Wformat] database.c:24:2: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘int *’ [-Wformat] database.c:25:2: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘char *’ [-Wformat] where I'm scanf'ing: // Request loop while (count-- != 0) { while (1){ // Get values from the user int error = scanf ("%79s %hhu %u %c", tname, &tdist, &tyear, &tgender); addCitizen(db, tname, &tdist, &tyear, &tgender); where I'm printing: void addCitizen(Database *db, char *tname, byte *tdist, int *tyear, char *tgender){ //needs to find the right place in memory to put this stuff and then put it there printf("\nName is: %79s\n", tname); printf("District is: %hhu\n", tdist); printf("Year of birth is: %u\n", tyear); printf("Gender is:%c\n", tgender); I'm not sure where I'm going wrong?

    Read the article

  • how to get the image position from pdf file in objective c?

    - by Sarah
    Hello, I am doing something like extracting the pdf text in a string format so as to annotate the text and in the same process i need to find the image positions covered in the same pdf file so as to maintain its position. Now the problem is that i am not getting the exact positions of the images in the same pdf file. Is it possible to use some thing like OCR,if yes,how to use that? Can anybody help me in finding the exact position of the image in the pdf file? I need to implement some pdf reader kind of application for ipad,that's just for the knowledge. Thank you.

    Read the article

  • Multiset of shared_ptrs as a dynamic priority queue: Concept and practice

    - by Sarah
    I was using a vector-based priority queue typedef std::priority_queue< Event, vector< Event >, std::greater< Event > > EventPQ; to manage my Event objects. Now my simulation has to be able to find and delete certain Event objects not at the top of the queue. I'd like to know if my planned work-around can do what I need it to, and if I have the syntax right. I'd also like to know if dramatically better solutions exist. My plan is to make EventPQ a multiset of smart pointers to Event objects: typedef std::multi_set< boost::shared_ptr< Event > > EventPQ; I'm borrowing functions of the Event class from a related post on a multimap priority queue. // Event.h #include <cstdlib> using namespace std; #include <set> #include <boost/shared_ptr.hpp> class Event; typedef std::multi_set< boost::shared_ptr< Event > > EventPQ; class Event { public: Event( double t, int eid, int hid ); ~Event(); void add( EventPQ& q ); void remove(); bool operator < ( const Event & rhs ) const { return ( time < rhs.time ); } bool operator > ( const Event & rhs ) const { return ( time > rhs.time ); } double time; int eventID; int hostID; EventPQ* mq; EventPQ::iterator mIt; }; // Event.cpp Event::Event( double t, int eid, int hid ) { time = t; eventID = eid; hostID = hid; } Event::~Event() {} void Event::add( EventPQ& q ) { mq = &q; mIt = q.insert( boost::shared_ptr<Event>(this) ); } void Event::remove() { mq.erase( mIt ); mq = 0; mIt = EventPQ::iterator(); } I was hoping that by making EventPQ a container of pointers, I could avoid wasting time copying Events into the container and avoid accidentally editing the wrong copy. Would it be dramatically easier to store the Events themselves in EventPQ instead? Does it make more sense to remove the time keys from Event objects and use them instead as keys in a multimap? Assuming the current implementation seems okay, my questions are: Do I need to specify how to sort on the pointers, rather than the objects, or does the multiset automatically know to sort on the objects pointed to? If I have a shared_ptr ptr1 to an Event that also has a pointer in the EventPQ container, how do I find and delete the corresponding pointer in EventPQ? Is it enough to .find( ptr1 ), or do I instead have to find by the key (time)? Is the Event::remove() sufficient for removing the pointer in the EventPQ container? There's a small chance multiple events could be created with the same time (obviously implied in the use of multiset). If the find() works on event times, to avoid accidentally deleting the wrong event, I was planning to throw in a further check on eventID and hostID. Does this seem reasonable? (Dumb syntax question) In Event.h, is the declaration of dummy class Event;, then the EventPQ typedef, and then the real class Event declaration appropriate? I'm obviously an inexperienced programmer with very spotty background--this isn't for homework. Would love suggestions and explanations. Please let me know if any part of this is confusing. Thanks.

    Read the article

  • representing an XML config file with an IXmlSerializable class

    - by Sarah Vessels
    I'm writing in C# and trying to represent an XML config file through an IXmlSerializable class. I'm unsure how to represent the nested elements in my config file, though, such as logLevel: <?xml version="1.0" encoding="utf-8" ?> <configuration> <logging> <logLevel>Error</logLevel> </logging> <credentials> <user>user123</user> <host>localhost</host> <password>pass123</password> </credentials> <credentials> <user>user456</user> <host>my.other.domain.com</host> <password>pass456</password> </credentials> </configuration> There is an enum called LogLevel that represents all the possible values for the logLevel tag. The tags within credentials should all come out as strings. In my class, called DLLConfigFile, I had the following: [XmlElement(ElementName="logLevel", DataType="LogLevel")] public LogLevel LogLevel; However, this isn't going to work because <logLevel> isn't within the root node of the XML file, it's one node deeper in <logging>. How do I go about doing this? As for the <credentials> nodes, my guess is I will need a second class, say CredentialsSection, and have a property such as the following: [XmlElement(ElementName="credentials", DataType="CredentialsSection")] public CredentialsSection[] AllCredentials; Edit: okay, I tried Robert Love's suggestion and created a LoggingSection class. However, my test fails: var xs = new XmlSerializer(typeof(DLLConfigFile)); using (var stream = new FileStream(_configPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (var streamReader = new StreamReader(stream)) { XmlReader reader = new XmlTextReader(streamReader); var file = (DLLConfigFile)xs.Deserialize(reader); Assert.IsNotNull(file); LoggingSection logging = file.Logging; Assert.IsNotNull(logging); // fails here LogLevel logLevel = logging.LogLevel; Assert.IsNotNull(logLevel); Assert.AreEqual(EXPECTED_LOG_LEVEL, logLevel); } } The config file I'm testing with definitely has <logging>. Here's what the classes look like: [Serializable] [XmlRoot("logging")] public class LoggingSection : IXmlSerializable { public XmlSchema GetSchema() { return null; } [XmlElement(ElementName="logLevel", DataType="LogLevel")] public LogLevel LogLevel; public void ReadXml(XmlReader reader) { LogLevel = (LogLevel)Enum.Parse(typeof(LogLevel), reader.ReadString()); } public void WriteXml(XmlWriter writer) { writer.WriteString(Enum.GetName(typeof(LogLevel), LogLevel)); } } [Serializable] [XmlRoot("configuration")] public class DLLConfigFile : IXmlSerializable { [XmlElement(ElementName="logging", DataType="LoggingSection")] public LoggingSection Logging; }

    Read the article

  • What is the MVC version of this code?

    - by Ian Boyd
    i'm trying to wrap my head around how to enterprise up my code: taking a simple routine and splitting it up into 5 or 6 methods in 3 or 4 classes. i quickly came up three simple examples of code how i currently write it. Could someone please convert these into an MVC/MVP obfuscated version? Example 1: The last name is mandatory. Color the text box red if nothing is entered. Color it green if stuff is entered: private void txtLastname_TextChanged(object sender, EventArgs e) { //Lastname mandatory. //Color pinkish if nothing entered. Greenish if entered. if (txtLastname.Text.Trim() == "") { //Lastname is required, color pinkish txtLastname.BackColor = ControlBad; } else { //Lastname entered, remove the coloring txtLastname.BackColor = ControlGood; } } Example 2: The first name is optional, but try to get it. We'll add a bluish tint to this "try to get" field: private void txtFirstname_TextChanged(object sender, EventArgs e) { //Firstname can be blank. //Hint them that they should *try* to get it with a bluish color. //If they do enter stuff: it better be not all spaces. if (txtFirstname.Text == "") { //Nothing there, hint it blue txtFirstname.BackColor = ControlRequired; } else if (txtFirstname.Text.Trim() == "") { //They entered spaces - bad user! txtFirstname.BackColor = ControlBad; } else { //Entered stuff, remove coloring txtFirstname.BackColor = SystemColors.Window; } } Example 3 The age is totally optional. If an age is entered, it better be valid: private void txtAge_TextChanged(object sender, EventArgs e) { //Age is optional, but if entered it better be valid int nAge = 0; if (Int32.TryParse(txtAge.Text, out nAge)) { //Valid integer entered if (nAge < 0) { //Negative age? i don't think so txtAge.BackColor = ControlBad; } else { //Valid age entered, remove coloring txtAge.BackColor = SystemColors.Window; } } else { //Whatever is in there: it's *not* a valid integer, if (txtAge.Text == "") { //Blank is okay txtAge.BackColor = SystemColors.Window; } else { //Not a valid age, bad user txtAge.BackColor = ControlBad; } } } Every time i see MVC code, it looks almost like random splitting of code into different methods, classes, and files. i've not been able to determine a reason or pattern to their madness. Without any understanding of they why it's being one some way, it makes no sense. And using the words model, view, controller and presenter, like i'm supposed to know what that means, doesn't help. The model is your data. The view shows data on screen. The controller is used to carry out the users actions And oranges taste orangy. Here's my attempt at splitting things up in order to make the code more difficult to follow. Is this anywhere close to MVC? private void txtFirstname_TextChanged(object sender, EventArgs e) { FirstnameTextChangedHandler(sender, e); } private void FirstnameTextChangedHandler(sender, e) { string firstname = GetFirstname(); Color firstnameTextBoxColor = GetFirstnameTextBoxColor(firstname); SetFirstNameTextBoxColor(firstnameTextBoxColor); } private string GetFirstname() { return txtFirstname.Text; } private Color GetFirstnameTextBoxColor(string firstname) { //Firstname can be blank. //Hint them that they should *try* to get it with a bluish color. //If they do enter stuff: it better be not all spaces. if (firstname == "") { //Nothing there, hint it blue return GetControlRequiredColor(); } else if (firstname.Trim() == "") { //They entered spaces - bad user! return GetControlBadColor(); } else { //Entered stuff, remove coloring return GetControlDefaultColor(); } } private Color GetControlRequiredColor() { return ControlRequired; } private Color GetControlBadColor() { return ControlBad; } private Color GetControlGoodColor() { return ControlGood; } //am i doin it rite i've obfuscated the code, but it's still altogether. The next step in the MVC obfuscation, i gather, is to hide the code in 3 or 4 different files. It's that next step that i don't understand. What is the logical separation of which functions are moved into what other classes? Can someone translate my 3 simple examples above into full fledged MVC obfuscation? Edit: Not ASP/ASP.NET/Online. Pretend it's on a desktop, handheld, surface, kiosk. And pretend it's language agnostic.

    Read the article

  • How to maintain form state after Post-Redirect-Get in ASP.net?

    - by Ian Boyd
    Imagine a page with a form input: Search Criteria: crackers                   From: [email protected]           To: [email protected]       Subject: How to maintain form state with PRG? Message: Imagine a page with form input:                         Send After the user clicks Send, the server will instruct to client to Redirect, as part of the Post-Redirect-Get pattern. POST /mail/u/compose HTTP/1.1 303 See Other Location: http://stackoverflow.com/mail/u/compose And the client will issue a GET of the new page. The problem is that some elements of the existing form are lost: Search Criteria:                    It gets worse when there are a few drop-downs, and checkboxes. How can i maintain form state in using Post-Redirect-Get in ASP.net, given that the viewstate is then non-existent. Bonus Reading ASP.NET: How to redirect, prefilling form data?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14  | Next Page >