Search Results

Search found 1870 results on 75 pages for 'matt mcclellan'.

Page 50/75 | < Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >

  • PHP: Assigning values to a variable inside IF statement

    - by Matt
    Hi guys, I was wondering if i could assign values to a variable inside an IF statement. My code is as follows: <?php if ((count($newArray) = array("hello", "world")) == 0) { // do something } ?> So basically i want assign the array to the $newArray variable, then count newArray and check to see if it is an empty array. I know i can do this on several lines but just wondered if i could do it on one line Thanks M

    Read the article

  • Cocoa class not displaying data in NSWindow

    - by Matt S.
    I have one class that controls one window, and another class that controls a different window in the same xib, however, the second window never displays what it should. In the first class I alloc and init the second class, then pass some information to it. In the second class it displays that data in the table view. Yes, in the .xib I have all the connections set up correctly, I've quadruple checked. Also the code is correct, same with the connections, I've quadruple checked.

    Read the article

  • iphone core data loop array and save each

    - by Matt Facer
    I have a core data model with two tables (meal and ingredients). I am trying to save ONE meal with MANY ingredients. I have the code below which loops through an array of ingredients. I'm trying to save it, but I cannot redeclare the "entity" below. How do I do it? I've tried releasing it, but that didn't work! Thanks for any help. for (x=0;x<ingredients;x++) { NSEntityDescription *entity = [NSEntityDescription insertNewObjectForEntityForName:@"Ingredient" inManagedObjectContext:managedObjectContext]; entity.name = @"test"; } (this method does work saving ONE record out of the loop.. so that's not the problem)

    Read the article

  • How can I optimize retrieving lowest edit distance from a large table in SQL?

    - by Matt
    Hey, I'm having troubles optimizing this Levenshtein Distance calculation I'm doing. I need to do the following: Get the record with the minimum distance for the source string as well as a trimmed version of the source string Pick the record with the minimum distance If the min distances are equal (original vs trimmed), choose the trimmed one with the lowest distance If there are still multiple records that fall under the above two categories, pick the one with the highest frequency Here's my working version: DECLARE @Results TABLE ( ID int, [Name] nvarchar(200), Distance int, Frequency int, Trimmed bit ) INSERT INTO @Results SELECT ID, [Name], (dbo.Levenshtein(@Source, [Name])) As Distance, Frequency, 'False' As Trimmed FROM MyTable INSERT INTO @Results SELECT ID, [Name], (dbo.Levenshtein(@SourceTrimmed, [Name])) As Distance, Frequency, 'True' As Trimmed FROM MyTable SET @ResultID = (SELECT TOP 1 ID FROM @Results ORDER BY Distance, Trimmed, Frequency) SET @Result = (SELECT TOP 1 [Name] FROM @Results ORDER BY Distance, Trimmed, Frequency) SET @ResultDist = (SELECT TOP 1 Distance FROM @Results ORDER BY Distance, Trimmed, Frequency) SET @ResultTrimmed = (SELECT TOP 1 Trimmed FROM @Results ORDER BY Distance, Trimmed, Frequency) I believe what I need to do here is to.. Not dumb the results to a temporary table Do only 1 select from `MyTable` Setting the results right in the select from the initial select statement. (Since select will set variables and you can set multiple variables in one select statement) I know there has to be a good implementation to this but I can't figure it out... this is as far as I got: SELECT top 1 @ResultID = ID, @Result = [Name], (dbo.Levenshtein(@Source, [Name])) As distOrig, (dbo.Levenshtein(@SourceTrimmed, [Name])) As distTrimmed, Frequency FROM MyTable WHERE /* ... yeah I'm lost */ ORDER BY distOrig, distTrimmed, Frequency Any ideas?

    Read the article

  • Is it possible to destroy a CDI scope?

    - by Matt Ball
    I'm working on a Java EE application, primarily JAX-RS with a JSF admin console, that uses CDI/Weld for dependency injection with @ApplicationScoped objects. Minor debugging issues aside, CDI has worked beautifully for this project. Now I need some very coarse-grained control over CDI-injected object lifecycles. I need the ability to: Remove an injected object from the application context, or Destroy/delete/clear/reset/remove the entire application context, or Define my own @ScopeType and implementing Context in which I could provide methods to perform one of the two above tasks. I'm fully aware that this is across, if not against, the grain of CDI and dependency injection in general. I just want to know Is this remotely possible? If yes, what is the easiest/simplest/quickest/foolproofiest way to get the job done?

    Read the article

  • Writing white space to CSV fields in Python?

    - by matt
    When I try to write a field that includes whitespace in it, it gets split into multiple fields on the space. What's causing this? It's driving me insane. Thanks data = open("file.csv", "wb") w = csv.writer(data) w.writerow(['word1', 'word2']) w.writerow(['word 1', 'word2']) data.close() I'll get 2 fields(word1,word2) for first example and 3(word,1,word2) for the second.

    Read the article

  • What interprocess locking calls should I monitor?

    - by Matt Joiner
    I'm monitoring a process with strace/ltrace in the hope to find and intercept a call that checks, and potentially activates some kind of globally shared lock. While I've dealt with and read about several forms of interprocess locking on Linux before, I'm drawing a blank on what to calls to look for. Currently my only suspect is futex() which comes up very early on in the process' execution. Update0 There is some confusion about what I'm after. I'm monitoring an existing process for calls to persistent interprocess memory or equivalent. I'd like to know what system and library calls to look for. I have no intention call these myself, so naturally futex() will come up, I'm sure many libraries will implement their locking calls in terms of this, etc. Update1 I'd like a list of function names or a link to documentation, that I should monitor at the ltrace and strace levels (and specifying which). Any other good advice about how to track and locate the global lock in mind would be great.

    Read the article

  • protect_from_forgery & Unobtrusive Javascript

    - by Matt Grande
    Hi all, I have some javascript making an ajax call in my Rails site: $.ajax({type: "PUT", url: url, data: { dummy: data }, complete: function(data) {}}); When Rails gets it, it throws back an ActionController::InvalidAuthenticityToken Error. I'd like to keep the protect_from_forgery stuff in there, if possible... But I'm at a loss for how can I pass the auth token from a javascript file? Can anyone help me out?

    Read the article

  • Function template overloading: link error

    - by matt
    I'm trying to overload a "display" method as follows: template <typename T> void imShow(T* img, int ImgW, int ImgH); template <typename T1, typename T2> void imShow(T1* img1, T2* img2, int ImgW, int ImgH); I am then calling the template with unsigned char* im1 and char* im2: imShow(im1, im2, ImgW, ImgH); This compiles fine, but i get a link error "unresolved external symbol" for: imShow<unsigned char,char>(unsigned char *,char *,int,int) I don't understand what I did wrong!

    Read the article

  • PHP: best practice. Do i save html tags in DB or store the html entity value?

    - by Matt
    Hi Guys, I was wondering about which way i should do the following. I am using the tiny MCE wysiwyg editor which formats the users data with the right html tags. Now, i need to save this data entered into the editor into a database table. Should i encode the html tags to their corresponding entities when inserting into the DB, then when i get the data back from the table, not have the encode it for XSS purposes but i'd still have to use eval for the html tags to format the text. OR Do i save the html tags into the database, then when i get the data back from the database encode the html tags to their entities, but then as the tags will appear to the user, i'd have to use the eval function to actually format the data as it was entered. My thoughts are with the first option, i just wondered on what you guys thought. Thanks M

    Read the article

  • Why is generated XAML spitting out namespaces that are not asked for?

    - by Matt Holmes
    I have a very simple XAML form, that has one namespace definition. For some reason, when Visual Studio processes that XAML file in to it's component .g.cs, it's sticking a bunch of namespace definitions at the top that I have not asked for in the XAML, or the code behind, and they are namespaces that no longer exist in my project. Thus the project is failing to compile. Why is Visual Studio sticking arbitrary namespace 'using' statements in my generated XAML .g.cs files? It's caused my entire project to break. Not one time did this .xaml file ever reference the namespaces in question, so it's doubly annoying.

    Read the article

  • How to pronounce "std" (C & C++)? [closed]

    - by Matt Blaine
    How do you pronounce "std"? As in: __stdcall stdlib.h stdio.h stdin stdout stderr the namespace std Thank you. Please don't take this as being rude, but if you'd like to close this question, there are many others like it that were allowed to survive. So, if you decide to close any of them, would you kindly close all of them? Thanks.

    Read the article

  • How do I set the dataProvider for an <s:List> component to be an XML file?

    - by Matt Calthrop
    I've got the latest Beta of Adobe Flash Builder 4. I want to use a <s:List> component, and specify the dataProvider as being an XML file. However, after loads of research (including looking at doc links off labs.adobe.com), I still can't figure out how to do it. The XML file will look something like this: <?xml version="1.0" encoding="ISO-8859-1"?> <imageList> <image location="path/to/file1.jpg" /> <image location="path/to/file2.jpg" /> <image location="path/to/file3.jpg" /> </imageList>

    Read the article

  • Can't access font resource in Silverlight class library

    - by Matt
    I have a reasonably large Silveright 3.0 project on the go, and I'm having issues accessing a couple of custom font resources from within one of the assemblies. I've got a working test solution where I have added a custom font as a resource, and can access it fine from XAML using: <TextBlock Text="Test" FontFamily="FontName.ttf#Font Name" /> The test solution consists of the TestProject.Application and the TestProject.Application.Web projects, with all the fun and games obviously in the TestProject.Application project However, when I try this in my main solution, the fonts refuse to show in the correct type face (instead showing in the default font). There's no difference in the way the font has been added to project between the test solution and the main solution, and the XAML is identical. However, there is a solution layout difference. In the main solution, as well as having a MainApp.Application and MainApp.Application.Web project, I also have a MainApp.Application.ViewModel project and a MainApp.Application.Views project, and the problem piece of XAML is the in the MainApp.Application.Views project (not the .Application project like the test solution). I've tried putting the font into either the .Application or .Application.Views project, tried changing the Build Action to Content, Embedded Resource etc, all to no avail. So, is there an issue accessing font resources from a child assembly that I don't know about, or has anyone successfully done this? My long term need will be to have the valid custom fonts being stored as resources in a separate .Application.FontLibrary assembly that will be on-demand downloaded and cached, and the XAML controls in the .Application.Views project will need to reference this FontLibrary assembly to get the valid fonts. I've also tried xcreating this separate font library assembly, and I can't seem to get the fonts from the second assembly. As some additional information, I've also tried the following font referencing approaches: <TextBlock Text="Test" FontFamily="/FontName.ttf#Font Name" /> <TextBlock Text="Test" FontFamily="pack:application,,,/FontName.ttf#Font Name" /> <TextBlock Text="Test" FontFamily="pack:application,,,/MainApp.Application.Views;/FontName.ttf#Font Name" /> <TextBlock Text="Test" FontFamily="pack:application,,,/MainApp.Application.Views;component/FontName.ttf#Font Name" /> And a few similar variants with different assembly references/sub directories/random semi colons. And so far nothing works... anyone struck this (and preferably solved it)?

    Read the article

  • Is it better to comment out unneeded code or delete it?

    - by Matt Connolly
    For web applications under maintenance, assuming you have source control, when you need to remove part of the UI and the associated code, do you delete the code and check in, or do you comment out the old code? Arguments in favor of deleting: cleaner code, can still see deleted code in source control history, no worrying about refactoring code that might be uncommented some day. Arguments in favor of commenting: sometimes you need to add the feature back in and the developer adding it back in may not know to check source control history, sometimes the code represents unique functionality that can be a handy reference, seeing it all in one place can help provide clues to deciphering the active code.

    Read the article

  • SelectedItem in ListView binding

    - by Matt
    I'm new in wfp. In my sample application I'm using a ListView to display contents of property. I don't know how to bind SelectedItem in ListView to property and then bind to TextBlock. Window.xaml <Window x:Class="Exec.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Main window" Height="446" Width="475" > <Grid> <ListView Name="ListViewPersonDetails" Margin="15,12,29,196" ItemsSource="{Binding Persons}" SelectedItem="{Binding CurrentSelectedPerson}"> <ListView.View> <GridView> <GridViewColumn Header="FirstName" DisplayMemberBinding="{Binding FstNamePerson}"/> <GridViewColumn Header="LastName" DisplayMemberBinding="{Binding SndNamePerson}"/> <GridViewColumn Header="Address" DisplayMemberBinding="{Binding AdressPerson}"/> </GridView> </ListView.View> </ListView> <TextBlock Height="23" Name="textFirstNameBlock" FontSize="12" Margin="97,240,155,144"> <Run Text="Name: " /> <Run Text="{Binding CurrentSelectedPerson.FstNamePerson}" FontWeight="Bold" /> </TextBlock> <TextBlock Height="23" Name="textLastNameBlock" FontSize="12" Margin="97,263,155,121"> <Run Text="Branch: " /> <Run Text="{Binding CurrentSelectedPerson.SndNamePerson}" FontWeight="Bold" /> </TextBlock> <TextBlock Height="23" Name="textAddressBlock" FontSize="12" Margin="0,281,155,103" HorizontalAlignment="Right" Width="138"> <Run Text="City: " /> <Run Text="{Binding CurrentSelectedPerson.AdressPerson}" FontWeight="Bold" /> </TextBlock> </Grid> </Window> MainWindow.xaml.cs Tman manager = new Tman(); private List<Person> persons; public List<Person> Persons { get { return this.persons; } set { if (value != null) { this.persons = value; this.NotifyPropertyChanged("Data"); } } } private Person currentSelectedPerson; public Person CurrentSelectedPerson { get { return currentSelectedPerson; } set { this.currentSelectedPerson = value; this.NotifyPropertyChanged("CurrentSelectedItem"); } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(string propertyName) { var handler = this.PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } private void Window_Loaded(object sender, RoutedEventArgs e){ ListViewPersonDetails.ItemsSource= manager.GetPersons(); } Person.cs class Person { public string FirstName { get; set; } public string LastName { get; set; } public string Address { get; set; } } Thanks for any help.

    Read the article

  • In C#, is there any way to try multiple Regexes on string to see which one matches first?

    - by Matt
    Let's say I have an arbitrary list of regexes (IList<Regex> lst; for example). Is there any way to find out which one matches first? Of course there is the straightforward solution of trying each one on the string and seeing which match has the lowest index, but this could be inefficient on long strings. Of course I can go back and pull the strings back out of each regex (Regex.ToString()) and concatenate them all together ("(regex1)|(regex2)|(regex3)"), but I find this to be an ugly solution, especially since it does not even indicate which regex was matched.

    Read the article

  • MongoDB query to return only embedded document

    - by Matt
    assume that i have a BlogPost model with zero-to-many embedded Comment documents. can i query for and have MongoDB return only Comment objects matching my query spec? eg, db.blog_posts.find({"comment.submitter": "some_name"}) returns only a list of comments. edit: an example: import pymongo connection = pymongo.Connection() db = connection['dvds'] db['dvds'].insert({'title': "The Hitchhikers Guide to the Galaxy", 'episodes': [{'title': "Episode 1", 'desc': "..."}, {'title': "Episode 2", 'desc': "..."}, {'title': "Episode 3", 'desc': "..."}, {'title': "Episode 4", 'desc': "..."}, {'title': "Episode 5", 'desc': "..."}, {'title': "Episode 6", 'desc': "..."}]}) episode = db['dvds'].find_one({'episodes.title': "Episode 1"}, fields=['episodes']) in this example, episode is: {u'_id': ObjectId('...'), u'episodes': [{u'desc': u'...', u'title': u'Episode 1'}, {u'desc': u'...', u'title': u'Episode 2'}, {u'desc': u'...', u'title': u'Episode 3'}, {u'desc': u'...', u'title': u'Episode 4'}, {u'desc': u'...', u'title': u'Episode 5'}, {u'desc': u'...', u'title': u'Episode 6'}]} but i just want: {u'desc': u'...', u'title': u'Episode 1'}

    Read the article

  • Python's JSON module doesn't use __get__?

    - by Matt
    When I serialize a list of objects with a custom __get__ method, __get__ is not called and the raw (unprocessed by custom __get__) value from __set__ is used. How does Python's json module iterate over an item? Note: if I iterate over the list before serializing, the correct value returned by __get__ is used.

    Read the article

  • How to select parent row only if has at least one child?

    - by Matt McCormick
    I have a simple one-to-many relationship. I would like to select rows from the parent only when they have at least one child. So, if there are no children, then the parent row is not returned in the result set. Eg. Parent: +--+---------+ |id| text | +--+---------+ | 1| Blah | | 2| Blah2 | | 3| Blah3 | +--+---------+ Children +--+------+-------+ |id|parent| other | +--+------+-------+ | 1| 1 | blah | | 2| 1 | blah2 | | 3| 2 | blah3 | +--+------+-------+ I want the results to be: +----+------+ |p.id|p.text| +----+------+ | 1 | Blah | | 2 | Blah2| +----+------+

    Read the article

  • Generic Any/Attach/Add function for Entity Framework

    - by Matt Thrower
    Looking through my EF classes, they're littered with code that looks like this: if (_myContext.[EntityType].Any(d => d.RowId == dc.RowId)) { _myContext.[EntityType].Attach(dc); _myContext.Entry(dc).State = EntityState.Modified; } else { _myContext.[EntityType].Add(dc); } It's the same thing over and over, and is clearly itching to be handled by a generic function. However, I'm not sure how you'd go about handling the need for it to deal with a variety of unexpected entity types. A good example to get me started would be most appreciated.

    Read the article

  • Relative Paths, etc. on an Apache server

    - by Matt H.
    I'm really stuck here. I have 2 issues at once: First, my site is stored (both on local development and on live server), in a subdirectory.. as I'm working on multiple sites. i.e. /Sites/www.mysite.com/(site files here) When I'm referring to files in my web pages, I want to refer to, say, my /images directory without hard-coding every occurrence as /www.mysite.com/images/myfile.jpg Is there a way to simply redefine how the leading "/" gets interpreted by the server? Question two, concerning PHP mod_rewrite I have this set of rewrite rules. The objective is to turn www.mysite.com/faq into www.mysite.com/index.php?page="faq" RewriteEngine On RewriteCond %{REQUEST_URI} !mysite.com RewriteRule (.*) mysite.com/$1 RewriteRule ^([a-zA-Z0-9_-]+)$ /mysite.com/index.php?site=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ /mysite.com/index.php?site=$1 I don't have a problem when a url gets passed in the 2nd-to-last format (as the example above). However, if the trailing "/" is added: www.mysite.com/faq/, my external script references break: (such as src=js/script.js)...

    Read the article

  • xs:choice unbounded list

    - by Matt
    I want to define an XSD schema for an XML document, example below: <?xml version="1.0" encoding="utf-8"?> <view xmlns="http://localhost/model_data" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost/model_data XMLSchemaView.xsd" path="wibble" id="wibble"> <text name="PageTitle">Homepage</text> <text name="Keywords">home foo bar</text> <image name="MainImage"> <description>lolem ipsum</description> <title>i haz it</title> <url>/images/main-image.jpg</url> <type>image/jpeg</type> <alt>alt text for image</alt> <width>400</width> <height>300</height> </image> <link name="TermsAndConditionsLink"> <url>/tnc.html</url> <title>Terms and Conditions</title> <target>_blank</target> </link> </view> There's a view root element and then an unknown number of field elements (of various types). I'm using the following XSD schema: <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://localhost/model_data" targetNamespace="http://localhost/model_data" id="XMLSchema1"> <xs:element name="text" type="text_field"/> <xs:element name="view" type="model_data"/> <xs:complexType name="model_data"> <xs:choice maxOccurs="unbounded"> <xs:element name="text" type="text_field"/> <xs:element name="image" type="image_field"/> <xs:element name="link" type="link_field"/> </xs:choice> <xs:attribute name="path" type="xs:string"/> <xs:attribute name="id" type="xs:string"/> </xs:complexType> <xs:complexType name="image_field"> <xs:all> <xs:element name="description" type="xs:string"/> <xs:element name="title" type="xs:string"/> <xs:element name="type" type="xs:string"/> <xs:element name="url" type="xs:string"/> <xs:element name="alt" type="xs:string"/> <xs:element name="height" type="xs:int"/> <xs:element name="width" type="xs:int"/> </xs:all> <xs:attribute name="name" type="xs:string"/> </xs:complexType> <xs:complexType name="text_field"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="name" type="xs:string"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:complexType name="link_field"> <xs:all> <xs:element name="target" type="xs:string"/> <xs:element name="title" type="xs:string"/> <xs:element name="url" type="xs:string"/> </xs:all> <xs:attribute name="name" type="xs:string"/> </xs:complexType> </xs:schema> This looks like it should work to me, but it doesn't and I always get the following error: Element <text> is not allowed under element <view>. Reason: The following elements are expected at this location (see below) <text> <image> <link> Error location: view / text Details cvc-model-group: Element <text> unexpected by type 'model_data' of element <view>. cvc-elt.5.2.1: The element <view> is not valid with respect to the actual type definition 'model_data'. I've never really used XSD schemas before, so I'd really appreciate it if someone could point out where I'm going wrong.

    Read the article

< Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >