Search Results

Search found 214 results on 9 pages for 'sarah hsl'.

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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • Multiset container appears to stop sorting

    - by Sarah
    I would appreciate help debugging some strange behavior by a multiset container. Occasionally, the container appears to stop sorting. This is an infrequent error, apparent in only some simulations after a long time, and I'm short on ideas. (I'm an amateur programmer--suggestions of all kinds are welcome.) My container is a std::multiset that holds Event structs: typedef std::multiset< Event, std::less< Event > > EventPQ; with the Event structs sorted by their double time members: struct Event { public: explicit Event(double t) : time(t), eventID(), hostID(), s() {} Event(double t, int eid, int hid, int stype) : time(t), eventID( eid ), hostID( hid ), s(stype) {} bool operator < ( const Event & rhs ) const { return ( time < rhs.time ); } double time; ... }; The program iterates through periods of adding events with unordered times to EventPQ currentEvents and then pulling off events in order. Rarely, after some events have been added (with perfectly 'legal' times), events start getting executed out of order. What could make the events ever not get ordered properly? (Or what could mess up the iterator?) I have checked that all the added event times are legitimate (i.e., all exceed the current simulation time), and I have also confirmed that the error does not occur because two events happen to get scheduled for the same time. I'd love suggestions on how to work through this. The code for executing and adding events is below for the curious: double t = 0.0; double nextTimeStep = t + EPID_DELTA_T; EventPQ::iterator eventIter = currentEvents.begin(); while ( t < EPID_SIM_LENGTH ) { // Add some events to currentEvents while ( ( *eventIter ).time < nextTimeStep ) { Event thisEvent = *eventIter; t = thisEvent.time; executeEvent( thisEvent ); eventCtr++; currentEvents.erase( eventIter ); eventIter = currentEvents.begin(); } t = nextTimeStep; nextTimeStep += EPID_DELTA_T; } void Simulation::addEvent( double et, int eid, int hid, int s ) { assert( currentEvents.find( Event(et) ) == currentEvents.end() ); Event thisEvent( et, eid, hid, s ); currentEvents.insert( thisEvent ); }

    Read the article

  • getting html tags from xml and echoing in php?

    - by Whitney Sarah Rogers
    I am trying to echo a result from xml into my html code form expedia. But I ran into a problem. There text is a little messed up: <areaInformation> Distances are calculated in a straight line from the property&apos;s location to the point of interest or attraction, and may not reflect actual travel distance. &lt;br /&gt;&lt;br /&gt; Distances are displayed to the nearest 0.1 mile and kilometre. &lt;p&gt;La Isla Shopping Mall - 0.5 km / 0.3 mi &lt;br /&gt;Yamil Lu&apos;um - 0.5 km / 0.3 mi &lt;br /&gt;Acuario Interactivo - 0.6 km / 0.3 mi &lt;br /&gt;Luxury Avenue - 1.5 km / 0.9 mi &lt;br /&gt;Cancun Golf Club at Pok Ta Pok - 2.2 km / 1.3 mi &lt;br /&gt;Nautilus Diving and Training Center - 2.6 km / 1.6 mi &lt;br /&gt;Cancun Convention Center - 2.8 km / 1.7 mi &lt;br /&gt;Plaza Caracol - 2.8 km / 1.8 mi &lt;br /&gt;Playa Tortuga - 3.1 km / 1.9 mi &lt;br /&gt;Aquaworld - 3.6 km / 2.2 mi &lt;br /&gt;Playa Langosta - 4.1 km / 2.6 mi &lt;br /&gt;Museo de Arte Popular Mexicano - 4.6 km / 2.9 mi &lt;br /&gt;Playa Linda - 5 km / 3.1 mi &lt;br /&gt;Playa Delfines - 6.1 km / 3.8 mi &lt;br /&gt;El Rey Ruins - 6.2 km / 3.8 mi &lt;br /&gt;&lt;/p&gt;&lt;p&gt;The preferred airport for ME Cancun - Complete ME All Inclusive is Cancun, Quintana Roo (CUN-Cancun Intl.) - 14.3 km / 8.9 mi. &lt;/p&gt; </areaInformation> And I echo it in php: <div id="hotelInfo"><?php echo $areaInfo ?></div> And of course I get this in the browser window: Distances are calculated in a straight line from the property's location to the point of interest or attraction, and may not reflect actual travel distance. <br /><br /> Distances are displayed to the nearest 0.1 mile and kilometre. <p>La Isla Shopping Mall - 0.5 km / 0.3 mi <br />Yamil Lu'um - 0.5 km / 0.3 mi <br />Acuario Interac etc. How can I fix this??? Any help would be greatly apreciated! Thanks!

    Read the article

  • How to keep assigned SAS user promts from disappearing after you sign out of SAS?

    - by Sarah Reinke
    I have successfully assigned user prompts by: right clicking on the program - properties - prompts - Prompt Manager and adding what I want the user to edit when the run button is pushed. What I have not yet discovered is how to keep those prompt assignments after I exit SAS. When I reopen the program the prompts are gone/blank. I understand that I need to edit the program file in which I want to use a prompt. The prompt should be added to the code as &prompt-name. But I have not yet found code or examples on how to do this. Can anybody help?

    Read the article

  • [C++] Trouble declaring and recognizing global functions

    - by Sarah
    I've created some mathematical functions that will be used in main() and by member functions in multiple host classes. I was thinking it would be easiest to make these math functions global in scope, but I'm not sure how to do this. I've currently put all the functions in a file called Rdraws.cpp, with the prototypes in Rdraws.h. Even with all the #includes and externs, I'm getting a "symbol not found" error at the first function call in main(). Here's what I have: // Rdraws.cpp #include <cstdlib> using namespace std; #include <cmath> #include "Rdraws.h" #include "rng.h" extern RNG rgen // this is the PRNG used in the simulation; global scope void rmultinom( double p_trans[], int numTrials, int numTrans, int numEachTrans[] ) { // function 1 def } void rmultinom( const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]) { // function 2 def } int rbinom( int nTrials, double pLeaving ) { // function 3 def } // Rdraws.h #ifndef RDRAWS #define RDRAWS void rmultinom( double[], int, int, int[] ); void rmultinom( const double[], const int, int, int[] ); int rbinom( int, double ); #endif // main.cpp ... #include "Rdraws.h" ... extern void rmultinom(double p_trans[], int numTrials, int numTrans, int numEachTrans[]); extern void rmultinom(const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]); extern int rbinom( int n, double p ); ... int main() { ... } I'm pretty new to programming. If there's a dramatically smarter way to do this, I'd love to know.

    Read the article

  • how to scroll table on the click event of some cell in objective c?

    - by Sarah
    Hello friends, I am right now working with one application where i need to take one uitableview with uilable and textfield in each cell.I am able to scroll the table manually once the user starts writing, but what i want is that when i click on the textfield,the table should scroll upward so that the user is able to see what he has entered in the textfield.Same thing i saw once i logged in the iphone facebook. this is the code for manually scrolling the table : - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 250; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { CGRect viewRect = CGRectMake(0, 0, 320, 160); UIView *footerView = [[UIView alloc] initWithFrame:viewRect]; return footerView; } Is there any way around? Thanks in advance.

    Read the article

  • Can the size of a structure change after compiled?

    - by Sarah Altiva
    Hi, suppose you have the following structure: #include <windows.h> // BOOL is here. #include <stdio.h> typedef struct { BOOL someBool; char someCharArray[100]; int someIntValue; BOOL moreBools, anotherOne, yetAgain; char someOthercharArray[23]; int otherInt; } Test; int main(void) { printf("Structure size: %d, BOOL size: %d.\n", sizeof(Test), sizeof(BOOL)); } When I compile this piece of code in my machine (32-bit OS) the output is the following: Structure size: 148, BOOL size: 4. I would like to know if, once compiled, these values may change depending on the machine which runs the program. E.g.: if I ran this program in a 64-bit machine, would the output be the same? Or once it's compiled it'll always be the same? Thank you very much, and forgive me if the answer to this question is obvious...

    Read the article

  • Getting a random element in Django

    - by Sarah
    I just finished the Django tutorial and started work on my own project, however, I seem to have missed something completely. I wanted to get a random slogan from this model: from django.db import models class Slogan(models.Model): slogan = models.CharField(max_length=200) And return it in this view: from django.http import HttpResponse from swarm.sloganrotator.models import Slogan def index(request): return HttpResponse(Slogan.objects.order_by('?')[:1]) However, the view just returns 'Slogan object'. Then I thought, maybe I can access the slogan string itself by simply appending .slogan to the slice, but that gives me an error indicating that the object I have is actually a QuerySet and has no attribute slogan. I've obviously misunderstood something about Django here, but it just doesn't fall into place for me. Any help?

    Read the article

  • How do I recursively define a Hash in Ruby from supplied arguments?

    - by Sarah Beckham
    This snippet of code populates an @options hash. values is an Array which contains zero or more heterogeneous items. If you invoke populate with arguments that are Hash entries, it uses the value you specify for each entry to assume a default value. def populate(*args) args.each do |a| values = nil if (a.kind_of? Hash) # Converts {:k => "v"} to `a = :k, values = "v"` a, values = a.to_a.first end @options[:"#{a}"] ||= values ||= {} end end What I'd like to do is change populate such that it recursively populates @options. There is a special case: if the values it's about to populate a key with are an Array consisting entirely of (1) Symbols or (2) Hashes whose keys are Symbols (or some combination of the two), then they should be treated as subkeys rather than the values associated with that key, and the same logic used to evaluate the original populate arguments should be recursively re-applied. That was a little hard to put into words, so I've written some test cases. Here are some test cases and the expected value of @options afterwards: populate :a => @options is {:a => {}} populate :a => 42 => @options is {:a => 42} populate :a, :b, :c => @options is {:a => {}, :b => {}, :c => {}} populate :a, :b => "apples", :c => @options is {:a => {}, :b => "apples", :c => {}} populate :a => :b => @options is {:a => :b} # Because [:b] is an Array consisting entirely of Symbols or # Hashes whose keys are Symbols, we assume that :b is a subkey # of @options[:a], rather than the value for @options[:a]. populate :a => [:b] => @options is {:a => {:b => {}}} populate :a => [:b, :c => :d] => @options is {:a => {:b => {}, :c => :d}} populate :a => [:a, :b, :c] => @options is {:a => {:a => {}, :b => {}, :c => {}}} populate :a => [:a, :b, "c"] => @options is {:a => [:a, :b, "c"]} populate :a => [:one], :b => [:two, :three => "four"] => @options is {:a => :one, :b => {:two => {}, :three => "four"}} populate :a => [:one], :b => [:two => {:four => :five}, :three => "four"] => @options is {:a => :one, :b => { :two => { :four => :five } }, :three => "four" } } It is acceptable if the signature of populate needs to change to accommodate some kind of recursive version. There is no limit to the amount of nesting that could theoretically happen. Any thoughts on how I might pull this off?

    Read the article

  • C# casting question: from IEnumerable to custom type

    - by Sarah Vessels
    I have a custom class called Rows that implements IEnumerable<Row>. I often use LINQ queries on Rows instances: Rows rows = new Rows { row1, row2, row3 }; IEnumerable<Row> particularRows = rows.Where<Row>(row => condition); What I would like is to be able to do the following: Rows rows = new Rows { row1, row2, row3 }; Rows particularRows = (Rows)rows.Where<Row>(row => condition); However, I get a "System.InvalidCastException: Unable to cast object of type 'WhereEnumerableIterator1[NS.Row]' to type 'NS.Rows'". I do have a Rows constructor taking IEnumerable<Row>, so I could do: Rows rows = new Rows { row1, row2, row3 }; Rows particularRows = new Rows(rows.Where<Row>(row => condition)); This seems bulky, however, and I would love to be able to cast an IEnumerable<Row> to be a Rows since Rows implements IEnumerable<Row>. Any ideas?

    Read the article

  • auto-document exceptions on methods in C#/.NET

    - by Sarah Vessels
    I would like some tool, preferably one that plugs into VS 2008/2010, that will go through my methods and add XML comments about the possible exceptions they can throw. I don't want the <summary> or other XML tags to be generated for me because I'll fill those out myself, but it would be nice if even on private/protected methods I could see which exceptions could be thrown. Otherwise I find myself going through the methods and hovering on all the method calls within them to see the list of exceptions, then updating that method's <exception list to include those. Maybe a VS macro could do this? From this: private static string getConfigFilePath() { return Path.Combine(Environment.CurrentDirectory, CONFIG_FILE); } To this: /// <exception cref="System.ArgumentException"/> /// <exception cref="System.ArgumentNullException"/> /// <exception cref="System.IO.IOException"/> /// <exception cref="System.IO.DirectoryNotFoundException"/> /// <exception cref="System.Security.SecurityException"/> private static string getConfigFilePath() { return Path.Combine(Environment.CurrentDirectory, CONFIG_FILE); } Update: it seems like the tool would have to go through the methods recursively, e.g., method1 calls method2 which calls method3 which is documented as throwing NullReferenceException, so both method2 and method1 are documented by the tool as also throwing NullReferenceException. The tool would also need to eliminate duplicates, like if two calls within a method are documented as throwing DirectoryNotFoundException, the method would only list <exception cref="System.IO.DirectoryNotFoundException"/> once.

    Read the article

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