Search Results

Search found 366 results on 15 pages for 'cory walker'.

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

  • LINQ-to-SQL IN/Contains() for Nullable<T>

    - by Craig Walker
    I want to generate this SQL statement in LINQ: select * from Foo where Value in ( 1, 2, 3 ) The tricky bit seems to be that Value is a column that allows nulls. The equivalent LINQ code would seem to be: IEnumerable<Foo> foos = MyDataContext.Foos; IEnumerable<int> values = GetMyValues(); var myFoos = from foo in foos where values.Contains(foo.Value) select foo; This, of course, doesn't compile, since foo.Value is an int? and values is typed to int. I've tried this: IEnumerable<Foo> foos = MyDataContext.Foos; IEnumerable<int> values = GetMyValues(); IEnumerable<int?> nullables = values.Select( value => new Nullable<int>(value)); var myFoos = from foo in foos where nullables.Contains(foo.Value) select foo; ...and this: IEnumerable<Foo> foos = MyDataContext.Foos; IEnumerable<int> values = GetMyValues(); var myFoos = from foo in foos where values.Contains(foo.Value.Value) select foo; Both of these versions give me the results I expect, but they do not generate the SQL I want. It appears that they're generating full-table results and then doing the Contains() filtering in-memory (ie: in plain LINQ, without -to-SQL); there's no IN clause in the DataContext log. Is there a way to generate a SQL IN for Nullable types?

    Read the article

  • IWshShortcut Target Resolution in Windows 7

    - by Dan Walker
    I've got some code to read shortcuts using the Windows Script Host, but it appears to have a problem in Windows 7. When reading shortcuts, if there is an environment variable in the target path, it resolves to the wrong drive. For example, the shortcut to Notepad resolves to D:\Windows\system32\notepad.exe instead of C:\Windows\system32\notepad.exe. The problem is not with my computer's settings, because the shortcut works just fine, and when looking at the value for %SystemRoot%, it shows C:\Windows. Any ideas as to what could be the problem, or alternatively, what a different method of reading shortcuts would be? Thanks, Dan

    Read the article

  • Intersections of 3D polygons in python

    - by Andrew Walker
    Are there any open source tools or libraries (ideally in python) that are available for performing lots of intersections with 3D geometry read from an ESRI shapefile? Most of the tests will be simple line segments vs polygons. I've looked into OGR 1.7.1 / GEOS 3.2.0, and whilst it loads the data correctly, the resulting intersections aren't correct, and most of the other tools available seem to build on this work. Whilst CGAL would have been an alternative, it's license isn't suitable. The Boost generic geometry library looks fantastic, but the api is huge, and doesn't seem to support wkt or wkb readers out of the box.

    Read the article

  • iPhone Twitter Get UserId

    - by Mick Walker
    Hi, I am looking for a way to get a twitter users userid via their username. For example take http://twitter.com/AlySSa_miLAno (yes I know her twitter page off by heart lol) on the right hand side of the page is a link to her RSS feed: feed://twitter.com/statuses/user_timeline/26642006.rss In this context Alyssa's userid would be 26642006. Ideally I would like to avoid reading the full content of the page, as this could be quite expensive on a mobile device, so if anyone knows how to accomplish this using any Twitter/3rd party webservices that would be great.

    Read the article

  • Invalidating ASP.NET FormsAuthentication server side

    - by Rob Walker
    I am experimenting with FormsAuthentication (using ASP.NET MVC2) and it is working fairly well. However, one case I can't work out how to deal with is validating the user identity on the server to ensure it is still valid from the server's perspective. eg. User logs in ... gets a cookie/ticket Out of band the user is deleted on the server side User makes a new request to the server. HttpContext.User.Identity.Name is set to the deleted user. I can detect this fine, but what is the correct way to handle it? Calling FormsAuthentication.SignOut in the OnAuthorization on OnActionExecuting events is too late to affect the current request. Alternatively I would like to be able to calls FormsAuthentication.InvalidateUser(...) when the user is deleted (or database recreated) to invalidate all tickets for a given (or all) users. But I can't find an API to do this.

    Read the article

  • Database-independant SQL String Concatenation in Rails

    - by Craig Walker
    I want to do a database-side string concatenation in a Rails query, and do it in database-independent way. SQL-92 specifies double-bar (||) as the concatenation operator. Unfortunately it looks like MS SQL Server doesn't support it; it uses + instead. I'm guessing that Rails' SQL grammar abstraction has solved the db-specific operator problem already. If it does exist, how do I use it?

    Read the article

  • Transparent Background with a Modal UIViewController

    - by Mick Walker
    I have a dilema, I want to present to the user a semi-transparent view. I found out by experimenting that if I simply pushed the transparent view to the top of my NavigationController's stack, that it would not render the transparency level I wanted. So I decided to simply add the view as a subview of the current view at the top of the stack. This solution works, the view below is still visible, and the View is 'semi-modal'. The problem is, if the parent view inherits from UITableViewController (as mine does), then the view I 'push' onto it, does not cover the navigation bar at the top. I really don't want to get into a situation where I am forced to enable / disable controls on the navigation bar every time I push this view, so I was wondering, if anyone knew of any solutions that I could use so that the view I push onto the UITableViewController will actually 'push over' the navigation bar?

    Read the article

  • First Letter Section Headers with Core Data

    - by Cory Imdieke
    I'm trying to create a list of people sorted in a tableView of sections with the first letter as the title for each section - a la Address Book. I've got it all working, though there is a bit of an issue with the sort order. Here is the way I'm doing it now: NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NSEntityDescription entityForName:@"Contact" inManagedObjectContext:context]]; NSSortDescriptor *fullName = [[NSSortDescriptor alloc] initWithKey:@"fullName" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:fullName, nil]; [request setSortDescriptors:sortDescriptors]; [fullName release]; [sortDescriptors release]; NSError *error = nil; [resultController release]; resultController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:context sectionNameKeyPath:@"firstLetter" cacheName:nil]; [resultController performFetch:&error]; [request release]; fullName is a standard property, and firstLetter is a transient property which returns - as you'd expect - the first letter of the fullName. 95% of the time, this works perfectly. The problem is the result controller expects these two "lists" (the sorted fullName list and the sorted firstLetter list) to match exactly. If I have 2 contacts like John and Jack, my fullName list would sort these as Jack, John every time but my firstLetter list might sort them as John, Jack sometimes as it's only sorting by the first letter and leaving the rest to chance. When these lists don't match up, I get a blank tableView with 0 items in it. I'm not really sure how I should go about fixing this issue, but it's very frustrating. Has anyone else run into this? What did you guys find out?

    Read the article

  • RESTfully Nesting Resource Routes with Single Identifiers

    - by Craig Walker
    In my Rails app I have a fairly standard has_many relationship between two entities. A Foo has zero or more Bars; a Bar belongs to exactly one Foo. Both Foo and Bar are identified by a single integer ID value. These values are unique across all of their respective instances. Bar is existence dependent on Foo: it makes no sense to have a Bar without a Foo. There's two ways to RESTfully references instances of these classes. Given a Foo.id of "100" and a Bar.id of "200": Reference each Foo and Bar through their own "top-level" URL routes, like so: /foo/100 /bar/200 Reference Bar as a nested resource through its instance of Foo: /foo/100 /foo/100/bar/200 I like the nested routes in #2 as it more closely represents the actual dependency relationship between the entities. However, it does seem to involve a lot of extra work for very little gain. Assuming that I know about a particular Bar, I don't need to be told about a particular Foo; I can derive that from the Bar itself. In fact, I probably should be validating the routed Foo everywhere I go (so that you couldn't do /foo/150/bar/200, assuming Bar 200 is not assigned to Foo 150). Ultimately, I don't see what this brings me. So, are there any other arguments for or against these two routing schemes?

    Read the article

  • why to use code generators

    - by Night Walker
    Hi all I have encountered this topic lately and couldn't understand why they are needed ... Can you explain me why i should use them in my projects and how they can ease my life . Examples will be great, and where from i can learn this topic little more . Thanks.

    Read the article

  • Is there a way to undo Mocha stubbing of any_instance in Test::Unit

    - by Craig Walker
    Much like this question, I too am using Ryan Bates's nifty_scaffold. It has the desirable aspect of using Mocha's any_instance method to force an "invalid" state in model objects buried behind the controller. Unlike the question I linked to, I'm not using RSpec, but Test::Unit. That means that the two RSpec-centric solutions there won't work for me. Is there a general (ie: works with Test::Unit) way to remove the any_instance stubbing? I believe that it's causing a bug in my tests, and I'd like to verify that.

    Read the article

  • CSS gradients in IE7 & IE8 is causing text to become aliased

    - by Cory
    I'm attempting to use a CSS gradient in a div containing some text. With Gecko and Webkit, the text displays fine. In IE7 & IE8 the text appears aliased (jaggy). I came across this blog stating: "we decided to disable ClearType on elements that use any DXTransform". IE Blog: http://blogs.msdn.com/ie/archive/2006/08/31/730887.aspx That was back in 2006; 3.5 years later, I assume this bug would be fixed, but it's not. Is there a way to do this in IE8 without resorting to stuffing a repeating background image in the div? Here's an example of what I mean. <style> div { height: 50px; background: -moz-linear-gradient(top, #fff, #ddd); background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd)); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffffff, endColorstr=#ffdddddd); } </style> <div>Hello World</div> <p>Normal text</p> In IE, the text in the div is aliased (jaggy), and the text in the paragraph is not. Any solution that doesn't involve images would be greatly appreciated.

    Read the article

  • Generating code -- is there an easy way to get a proper string representation of nullable type?

    - by Cory Larson
    So I'm building an application that is going to do a ton of code generation with both C# and VB output (depending on project settings). I've got a CodeTemplateEngine, with two derived classes VBTemplateEngine and CSharpTemplateEngine. This question regards creating the property signatures based on columns in a database table. Using the IDataReader's GetSchemaTable method I gather the CLR type of the column, such as "System.Int32", and whether it IsNullable. However, I'd like to keep the code simple, and instead of having a property that looks like: public System.Int32? SomeIntegerColumn { get; set; } or public Nullable<System.Int32> SomeIntegerColumn { get; set; }, where the property type would be resolved with this function (from my VBTemplateEngine), public override string ResolveCLRType(bool? isNullable, string runtimeType) { Type type = TypeUtils.ResolveType(runtimeType); if (isNullable.HasValue && isNullable.Value == true && type.IsValueType) { return "System.Nullable(Of " + type.FullName + ")"; // or, for example... return type.FullName + "?"; } else { return type.FullName; } }, I would like to generate a simpler property. I hate the idea of building a Type string from nothing, and I would rather have something like: public int? SomeIntegerColumn { get; set; } Is there anything built-in anywhere, such as in the VBCodeProvider or CSharpCodeProvider classes that would somehow take care of this for me? Or is there a way to get a type alias of int? from a type string like System.Nullable'1[System.Int32]? Thanks!

    Read the article

  • Populating an association with children in factory_girl

    - by Craig Walker
    I have a model Foo that has_many 'Bar'. I have a factory_girl factory for each of these objects. The factory for Bar has an association to Foo; it will instantiate a Foo when it creates the Bar. I'd like a Factory that creates a Foo that contains a Bar. Ideally this Bar would be created through the :bar factory, and respect the build strategy (create/build) used to create the Foo. I know I could just call the :bar factory and then grab the Foo reference from the new Bar. I'd like to avoid this; in my test case, the important object is Foo; calling the Bar factory seems a bit circuitous. Also, I can see the need for a Foo with multiple Bars. Is this possible in factory_girl? How do you define this relationship in the parent?

    Read the article

  • Fortran intent(inout) v's no intent

    - by Andrew Walker
    Good practice dictates that subroutine arguments in Fortran should each have a specified intent (i.e. intent(in), intent(out) or intent(inout) as described this question): subroutine bar (a, b) real, intent(in) :: a real, intent(inout) :: b b = b + a ... However, not specifying an intent is valid Fortran: subroutine bar (a, b) real, intent(in) :: a real :: b b = b + a ... Are there any real differences beyond compile time checking for an argument specified as intent(inout) and an argument without a specified intent? Is there anything I should worry about if I'm retrofitting intents to older, intent free, code?

    Read the article

  • Nested Object Forms not working as expected

    - by Craig Walker
    I'm trying to get a nested model forms view working. As far as I can tell I'm doing everything right, but it still does not work. I'm on Rails 3 beta 3. My models are as expected: class Recipe < ActiveRecord::Base has_many :ingredients, :dependent => :destroy accepts_nested_attributes_for :ingredients attr_accessible :name end class Ingredient < ActiveRecord::Base attr_accessible :name, :sort_order, :amount belongs_to :recipe end I can use Recipe.ingredients_attributes= as expected: recipe = Recipe.new recipe.ingredients_attributes = [ {:name=>"flour", :amount=>"1 cup"}, {:name=>"sugar", :amount=>"2 cups"}] recipe.ingredients.size # -> 2; ingredients contains expected instances However, I cannot create new object graphs using a hash of parameters as shown in the documentation: params = { :name => "test", :ingredients_attributes => [ {:name=>"flour", :amount=>"1 cup"}, {:name=>"sugar", :amount=>"2 cups"}] } recipe = Recipe.new(params) recipe.name # -> "test" recipe.ingredients # -> []; no ingredient instances in the collection Is there something I'm doing wrong here? Or is there a problem in the Rails 3 beta?

    Read the article

  • iPhone App Minus App Store?

    - by Dan Walker
    I've been looking into iPhone development, but I've been having problems coming up with the answer to a certain question. If I create an application on my Mac, is there any way I can get it to run on an iPhone without going through the app store? It doesn't matter if the iPhone has to be jailbroken, as long as I can still run an application created using the official SDK. For reasons I won't get into, I can't have this program going through the app store. Thanks for any help you can give!

    Read the article

  • Profiling statements inside a User-Defined Function

    - by Craig Walker
    I'm trying to use SQL Server Profiler (2005) to track down some application performance problems. One of the calls being made is to a table-valued user-defined function. This function wraps a select that joins several tables together. In SQL Server Profiler, the call to the UDF is logged. However, the select that underlies the UDF isn't being logged at all. Because of this, I'm not getting useful data on which tables & indexes are being hit. I'd like to feed this info into the Database Tuning Advisor for some indexing advice. Is there any way (short of unwrapping the queries themselves) to log the tables called by UDFs in Profiler?

    Read the article

  • Help me re-center a ModalPopup within an iframe when the iframe's parent window scrolls

    - by Cory Larson
    I have a web page with an iframe in it (I don't like it, but that's the way it has to be). It's not a cross-domain iframe so there's nothing to worry about there. I have written a jQuery extension that does the centering of a ModalPopup (which is called from an overridden AjaxControlToolkit.ModalPopupBehavior._layout method) based on the width and height of the iframe's parent, so that it looks centered even though the iframe is not in the center of the page. It's a lot of tricky stuff, especially since the web page I added the iframe to runs in quirks mode. Now, I've also overridden AjaxControlToolkit.ModalPopupBehavior._attachPopup, so that when the parent window resizes or scrolls, the ModalPopup inside of the iframe recenter's itself relative to the new size of the parent window. However, the same code that attaches the popup to the parent window's resize event does NOT work for the parent window's scroll event. See the code below, and the comments: AjaxControlToolkit.ModalPopupBehavior.prototype._attachPopup = function() { /// <summary> /// Attach the event handlers for the popup to the PARENT window /// </summary> if (this._DropShadow && !this._dropShadowBehavior) { this._dropShadowBehavior = $create(AjaxControlToolkit.DropShadowBehavior, {}, null, null, this._popupElement); } if (this._dragHandleElement && !this._dragBehavior) { this._dragBehavior = $create(AjaxControlToolkit.FloatingBehavior, {"handle" : this._dragHandleElement}, null, null, this._foregroundElement); } $addHandler(parent.window, 'resize', this._resizeHandler); // <== This WORKS $addHandler(parent.window, 'scroll', this._scrollHandler); // <== This DOES NOT work this._windowHandlersAttached = true; } Can anybody explain to me why the resize event works while the scroll event doesn't? Any suggestions or alternatives out there to help me out? I am working with jQuery, so if I can use something besides the $addHandler method from MS that'd be fine. Be aware that I also have to override the _detachPopup function to remove the handler, so I need to take that into account. Thanks!

    Read the article

  • Unique element ID, even if element doesn't have one

    - by Robert J. Walker
    I'm writing a GreaseMonkey script where I'm iterating through a bunch of elements. For each element, I need a string ID that I can use to reference that element later. The element itself doesn't have an id attribute, and I can't modify the original document to give it one (although I can make DOM changes in my script). I can't store the references in my script because when I need them, the GreaseMonkey script itself will have gone out of scope. Is there some way to get at an "internal" ID that the browser uses, for example? A Firefox-only solution is fine; a cross-browser solution that could be applied in other scenarios would be awesome. Edit: If the GreaseMonkey script is out of scope, how are you referencing the elements later? They GreaseMonkey script is adding events to DOM objects. I can't store the references in an array or some other similar mechanism because when the event fires, the array will be gone because the GreaseMonkey script will have gone out of scope. So the event needs some way to know about the element reference that the script had when the event was attached. And the element in question is not the one to which it is attached. Can't you just use a custom property on the element? Yes, but the problem is on the lookup. I'd have to resort to iterating through all the elements looking for the one that has that custom property set to the desired id. That would work, sure, but in large documents it could be very time consuming. I'm looking for something where the browser can do the lookup grunt work. Wait, can you or can you not modify the document? I can't modify the source document, but I can make DOM changes in the script. I'll clarify in the question. Can you not use closures? Closuses did turn out to work, although I initially thought they wouldn't. See my later post. It sounds like the answer to the question: "Is there some internal browser ID I could use?" is "No."

    Read the article

  • Function lfit in numerical recipes, providing a test function

    - by Simon Walker
    Hi I am trying to fit collected data to a polynomial equation and I found the lfit function from Numerical Recipes. I only have access to the second edition, so am using that. I have read about the lfit function and its parameters, one of which is a function pointer, given in the documentation as void (*funcs)(float, float [], int)) with the help The user supplies a routine funcs(x,afunc,ma) that returns the ma basis functions evaluated at x = x in the array afunc[1..ma]. I am struggling to understand how this lfit function works. An example function I found is given below: void fpoly(float x, float p[], int np) /*Fitting routine for a polynomial of degree np-1, with coe?cients in the array p[1..np].*/ { int j; p[1]=1.0; for (j=2;j<=np;j++) p[j]=p[j-1]*x; } When I run through the source code for the lfit function in gdb I can see no reference to the funcs pointer. When I try and fit a simple data set with the function, I get the following error message. Numerical Recipes run-time error... gaussj: Singular Matrix ...now exiting to system... Clearly somehow a matrix is getting defined with all zeroes. I am going to involve this function fitting in a large loop so using another language is not really an option. Hence why I am planning on using C/C++. For reference, the test program is given here: int main() { float x[5] = {0., 0., 1., 2., 3.}; float y[5] = {0., 0., 1.2, 3.9, 7.5}; float sig[5] = {1., 1., 1., 1., 1.}; int ndat = 4; int ma = 4; /* parameters in equation */ float a[5] = {1, 1, 1, 0.1, 1.5}; int ia[5] = {1, 1, 1, 1, 1}; float **covar = matrix(1, ma, 1, ma); float chisq = 0; lfit(x,y,sig,ndat,a,ia,ma,covar,&chisq,fpoly); printf("%f\n", chisq); free_matrix(covar, 1, ma, 1, ma); return 0; } Also confusing the issue, all the Numerical Recipes functions are 1 array-indexed so if anyone has corrections to my array declarations let me know also! Cheers

    Read the article

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