Search Results

Search found 376 results on 16 pages for 'enumerate'.

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

  • ASP.NET: Enumerating header elements from codebehind

    - by JamesBrownIsDead
    On Page_Load() in the codebehind, I'd like to enumerate all the <link> tags. The purpose being I want want to add a <link> to a CSS file if it isn't specified in the Page's markup. How can I do this? I'm thinking I should be able to use LINQ on the collection of elements in the header, no? Here's my pseudocode: var pageAlreadyContainsCssLink = false; foreach(var control in this.Header.Controls) { if (control.TagName == "link" && control.Attributes["href"] == "my_css_file.css") { pageAlreadyContainsCssLink = true; break; } } if (pageAlreadyContainsCssLink) { // Don't add <link> element return; } // Add the <link> to the CSS this.AddCssLink(...);

    Read the article

  • Cheat sheet exhibiting bash shell stdout/stderr redirection behavior

    - by SetJmp
    Is there a good cheat sheet demonstrating the many uses of BASH shell redirection? I would love to give such a thing to my students. Some examples I'd like to see covered: cmd > output_file.txt #redirect stdout to output_file.txt cmd 2> output_file.txt #redirect stderr to output_file.txt cmd >& outpout_file.txt #redirect both stderr and stdout to output_file.txt cmd1 | cmd2 #pipe cmd1 stdout to cmd2's stdin cmd1 2>&1 | cmd2 #pipe cmd1 stdout and stderr to cmd2's stdin cmd1 | tee result.txt #print cmd1's stdout to screen and also write to result.txt cmd1 2>&1 | tee result.txt #print stdout,stderr to screen while writing to result.txt (or we could just make this a community wiki and enumerate such things here) Thanks! SetJmp

    Read the article

  • How to get all possible values for SPFieldLookup

    - by Anton Polyakov
    Hello! I have a lookup field in sharepoint which just references another list. I wonder how do I programatically enumerate all possible values for this field? For example, my lookup field "Actual City" refers list "Cities" and column "Title", I have 3 cities there. In code I would like to get list of all possible values for field "Actual City", smth like (metacode, sorry): SPFieldLookup f = myList["Actual City"]; Collection availableValues = f.GetAllPossibleValues(); //this should return collection with all cities a user might select for the field

    Read the article

  • Ivy: Publishing all artefacts in a directory

    - by Dave Flowers
    I'm looking to move to Apache Ivy for dependency management on one of our existing projects. The project publishes many artefacts, and the artefacts it produces are likely to change in the future, so I don't want to enumerate all of the publications in the ivy.xml file -- I'd like Ivy to just publish all the files in a given directory. I considered auto-generating a list of the files built and using XSLT to insert it into the ivy.xml, but that seems a little cumbersome for what I'd expect to be a reasonably common requirement. Is there a better way to do this? Can Ivy pick up all the files in a directory and ignore the publications in the Ivy file? Or is there some way to get Ivy to use different files for publication and for fetching, so I can avoid having to use XSLT to merge the files.

    Read the article

  • Is there a general concrete implementation of a KeyedCollection?

    - by CodeSavvyGeek
    The System.Collections.ObjectModel.KeyedCollection class is a very useful alternative to System.Collections.Generic.Dictionary, especially when the key data is part of the object being stored or you want to be able to enumerate the items in order. Unfortunately, the class is abstract, and I am unable to find a general concrete implementation in the core .NET framework. The Framework Design Guidlines book indicates that a concrete implementation should be provided for abstract types (section 4.4 Abstract Class Design). Why would the framework designers leave out a general concrete implementation of such a useful class, especially when it could be provided by simply exposing a constructor that accepts and stores a Converter from the item to its key: public class ConcreteKeyedCollection : KeyedCollection { private Converter getKeyForItem = null; public GenericKeyedCollection(Converter getKeyForItem) { if (getKeyForItem == null) { throw new ArgumentNullException("getKeyForItem"); } this.getKeyForItem = getKeyForItem; } protected override TKey GetKeyForItem(TItem item) { return this.getKeyForItem(item); } }

    Read the article

  • get all domain names on network

    - by user175084
    i need to get the list of domain names on my network... but i am only getting the domain name with which i log into... so for example there are 2 domains "xyz" and "xyz2" but i get only the domain with which i log into.... here is my code: if (!IsPostBack) { StringCollection adDomains = this.GetDomainList(); foreach (string strDomain in adDomains) { DropDownList1.Items.Add(strDomain); } } } private StringCollection GetDomainList() { StringCollection domainList = new StringCollection(); try { DirectoryEntry en = new DirectoryEntry("LDAP://"); // Search for objectCategory type "Domain" DirectorySearcher srch = new DirectorySearcher("objectCategory=Domain"); SearchResultCollection coll = srch.FindAll(); // Enumerate over each returned domain. foreach (SearchResult rs in coll) { ResultPropertyCollection resultPropColl = rs.Properties; foreach (object domainName in resultPropColl["name"]) { domainList.Add(domainName.ToString()); } } } catch (Exception ex) { Trace.Write(ex.Message); } return domainList; }

    Read the article

  • Strange thing about .NET 4.0 filesystem enumeration functionality

    - by codymanix
    I just read a page of "Whats new .NET Framework 4.0". I have trouble understanding the last paragraph: To remove open handles on enumerated directories or files Create a custom method (or function in Visual Basic) to contain your enumeration code. Apply the MethodImplAttribute attribute with the NoInlining option to the new method. For example: [MethodImplAttribute(MethodImplOptions.NoInlining)] Private void Enumerate() Include the following method calls, to run after your enumeration code: * The GC.Collect() method (no parameters). * The GC.WaitForPendingFinalizers() method. Why the attribute NoInlining? What harm would inlining do here? Why call the garbage collector manually, why not making the enumerator implement IDisposable in the first place? I suspect they use FindFirstFile()/FindNextFile() API calls for the imlementation, so FindClose() has to be called in any case if the enumeration is done.

    Read the article

  • How to get a list of all domains?

    - by AngryHacker
    I'm trying to get all domains that are available in the Windows Login dialog (in the Domain dropdown). I've tried the following code but it only returns the domain I am logged into. Am I missing something? StringCollection domainList = new StringCollection(); try { DirectoryEntry en = new DirectoryEntry("LDAP://"); // Search for objectCategory type "Domain" DirectorySearcher srch = new DirectorySearcher("objectCategory=Domain"); SearchResultCollection coll = srch.FindAll(); // Enumerate over each returned domain. foreach (SearchResult rs in coll) { ResultPropertyCollection resultPropColl = rs.Properties; foreach( object domainName in resultPropColl["name"]) { domainList.Add(domainName.ToString()); } } } catch (Exception ex) { Trace.Write(ex.Message); } return domainList;

    Read the article

  • Getting error on inserting tuple values in postgreSQL table using python

    - by rahman.bd
    Hello, I want to keep last.fm's user recent music tracks list to postgresql database table using pylast interface.But when I tried to insert values to the table it shows errors.Code example: for i, artist in enumerate(recent_tracks): for key in sorted(artist): cur.execute(""" INSERT INTO u_recent_track(Playback_date,Time_stamp,Track) VALUES (%s,%s)""", (key, artist[key])) conn.commit() cur.execute("SELECT * FROM u_recent_track;") cur.fetchone() for row in cur: print ' '.join(row[1:]) cur.close() conn.close() Here "recent_tracks" tuple have the values for example: artist 0 - playback_date : 5 May 2010, 11:14 - timestamp : 1273058099 - track : Brian Eno - Web I want to store these value under u_recent_track(Tid,Playback_date,Time_stamp,Track).Can anybody have idea how to sort out this problem? when I tried to run, it shows error: Traceback (most recent call last): File "F:\JavaWorkspace\Test\src\recent_track_database.py", line 50, in <module> VALUES (%s,%s,%s)""", (key, artist[key])) IndexError: tuple index out of range Thanks in advanced!

    Read the article

  • Python: Trying to get index of an intersection

    - by user1620716
    I have the following line of code: for i in [i for i,x in enumerate(catdate) if x == set(NNSRCfile['datetimenew']).intersection(catdate)]: print i I am trying to find the index of the intersection for the two components above. Both are lengthy lists that have several commonalities. The intersection part works perfectly; however, the for loop seems to output nothing. (ie: there is nothing that is printed). Python outputs no error, and when I run the code in IPython, I notice that i is equivalent to to the very last element in the list "catdate", instead of listing the indices of "catdate" that are equivalent to the intersection values. Any help is greatly appreciated!

    Read the article

  • What are the common programming mistakes in Python?

    - by Paul McGuire
    I was about to tag the recent question in which the OP accidentally shadowed the builtin operator module with his own local operator.py with the "common-mistakes" tag, and I saw that there are a number of interesting questions posted asking for common mistakes to avoid in Java, Ruby, Scala, Clojure, .Net, jQuery, Haskell, SQL, ColdFusion, and so on, but I didn't see any for Python. For the benefit of Python beginners, can we enumerate the common mistakes that we have all committed at one time or another, in the hopes of maybe steering a newbie or two clear of them? (In homage to "The Princess Bride", I call these the Classic Blunders.) If possible, a little supporting explanation on what the problem is, and the generally accepted resolution/workaround, so that the beginning Pythoner doesn't read your answer and say "ok, that's a mistake, how do I fix it?"

    Read the article

  • Looping an executable to get the result from Python script

    - by fx
    In my python script, I need to call within a for loop an executable, and waiting for that executable to write the result on the "output.xml". How do I manage to use wait() & how do I know when one of my executable is finished generating the result to get the result? How do I close that process and open a new one to call again the executable and wait for the new result? import subprocess args = ("bin/bar") popen = subprocess.Popen(args) I need to wait for the output from "bin/bar" to generate the "output.xml" and from there, read it's content. for index, result in enumerate(results): myModule.callSubProcess(index) #this is where the problem is. fileOutput = open("output.xml") parseAndStoreInSQLiteFileOutput(index, file)

    Read the article

  • ASP.NET MVC: Route to URL

    - by JamesBrownIsDead
    What's the easiest way to get the URL (relative or absolute) to a Route in MVC? I saw this code here on SO but it seems a little verbose and doesn't enumerate the RouteTable. Example: List<string> urlList = new List<string>(); urlList.Add(GetUrl(new { controller = "Help", action = "Edit" })); urlList.Add(GetUrl(new { controller = "Help", action = "Create" })); urlList.Add(GetUrl(new { controller = "About", action = "Company" })); urlList.Add(GetUrl(new { controller = "About", action = "Management" })); With: protected string GetUrl(object routeValues) { RouteValueDictionary values = new RouteValueDictionary(routeValues); RequestContext context = new RequestContext(HttpContext, RouteData); string url = RouteTable.Routes.GetVirtualPath(context, values).VirtualPath; return new Uri(Request.Url, url).AbsoluteUri; } What's a better way to examine the RouteTable and get a URL for a given controller and action?

    Read the article

  • overlay text on some else's window - HUD

    - by taglius
    I am interested in writing an app that overlays a small heads up display (HUD) over another application, in VB.NET. Does anyone have an example of this? I will need to enumerate all open windows to find the window that I want, and then overlay some text in a specific position on the window. If the user moves that window, my text will need to follow. (I will probably be painting the text in a loop over and over). Edit: nobody answered my original query - I added C# to the keywords to see if any of gurus in that language might have an answer. thanks.

    Read the article

  • Local Data Cache - How do I refresh the local db when I add fields to remote db?

    - by Chu
    I'm using a Local Data Cache in an ASP.NET 3.5 environment. I made a change in my main database by adding a new field. I double click on my .SYNC file in my project to startup the Local Data Cache wizard again. The wizard starts and I click OK with the hopes that it'll re-query my database and add the new field to the local database file. Instead, I get an error saying "Synchronizing the databae failed with the message: Unable to enumerate changes at the DbServerSyncProvider..." The only way I know to get things working again is to delete the .SYNC file along with the local database and start it from scratch. There's got to be an easier way... anyone know it?

    Read the article

  • Python nested dict comprehension with sets

    - by Jasie
    Can someone explain how to do nested dict comprehensions? >> l = [set([1, 2, 3]), set([4, 5, 6])] >> j = dict((a, i) for a in s for i, s in enumerate(l)) >> NameError: name 's' is not defined I would have liked: >> j >> {1:0, 2:0, 3:0, 4: 1, 5: 1, 6: 1} I just asked a previous question about a simpler dict comprehension where the parentheses in the generator function were reduced. How come the s in the leftmost comprehension is not recognized?

    Read the article

  • Using unmanaged code, how can I find a type that has a given custom attribute assigned to it?

    - by Andrew
    I had thought I could enumerate the types using IMetaDataImport.EnumTypeDefs and for each of the tokens returned, call IMetaDataImport.EnumCustomAttributes. This works, in so much as I get an array of mdCustomAttribute tokens. Using these tokens I can get a metadata token representing the Type of the returned custom attribute, by calling IMetaDataImport.GetCustomAttributeProps. Comparing my results against ILDASM, I can see that this matches the "CustomAttribute Type" that ILDASM reports. However, I cannot work out how to determine the "CustomAttributeName" that ILDASM reports. This is what I really want! While I would be interested in knowing how to get the CustomAttributeName, I would settle for an alternate approach to solving the problem.

    Read the article

  • Find next lower item in a sorted list

    - by Sebastian
    Hey guys, let's say I have a sorted list of Floats. Now I'd like to get the index of the next lower item of a given value. The usual for-loop aprroach has a complexity of O(n). Since the list is sorted there must be a way to get the index with O(log n). My O(n) approach: index=0 for i,value in enumerate(mylist): if value>compareValue: index=i-1 Is there a datatype for solving that problem in O(log n)? best regards Sebastian

    Read the article

  • How to build a test group in watir?

    - by karlthorwald
    I have some single watir.rb scripts that use IE and are written in a standard watir way. How do I create a test group that combines them? I want all of them be executed by executing the main script. Is it possible to auto include single test files into a test group by subidr? Is it possible to enumerate the files that should be included in the test group? Can I cascade (include other watir test groups in a watir test group)?

    Read the article

  • PyParsing: Is this correct use of setParseAction()?

    - by Rosarch
    I have strings like this: "MSE 2110, 3030, 4102" I would like to output: [("MSE", 2110), ("MSE", 3030), ("MSE", 4102)] This is my way of going about it, although I haven't quite gotten it yet: def makeCourseList(str, location, tokens): print "before: %s" % tokens for index, course_number in enumerate(tokens[1:]): tokens[index + 1] = (tokens[0][0], course_number) print "after: %s" % tokens course = Group(DEPT_CODE + COURSE_NUMBER) # .setResultsName("Course") course_data = (course + ZeroOrMore(Suppress(',') + COURSE_NUMBER)).setParseAction(makeCourseList) This outputs: >>> course.parseString("CS 2110") ([(['CS', 2110], {})], {}) >>> course_data.parseString("CS 2110, 4301, 2123, 1110") before: [['CS', 2110], 4301, 2123, 1110] after: [['CS', 2110], ('CS', 4301), ('CS', 2123), ('CS', 1110)] ([(['CS', 2110], {}), ('CS', 4301), ('CS', 2123), ('CS', 1110)], {}) Is this the right way to do it, or am I totally off? Also, the output of isn't quite correct - I want course_data to emit a list of course symbols that are in the same format as each other. Right now, the first course is different from the others. (It has a {}, whereas the others don't.)

    Read the article

  • Select a data template by item type programatically in WPF

    - by Michael Stoll
    Hi all, unfortunately the WPF ToolbarTray does not support binding to a collection of ToolbarViewModels (Correct me, if I'm wrong). Thus I want to create the Toolbars programmatically. So there are two tasks, which I don't know how to do: Select the data template based on the item type. Instantiate the data template as toolbar Both should do the same as WPF does, when we use ItemsControl with an enumerable content and empty template. I used reflector to anaylse what WPF does. Task 1 is done by FrameworkElement.FindTemplateResourceInternal, but this is internal, and I couldn't find any public methods to acomplish the task. Of course one could enumerate all resources and match the data template data type property, but this seems sub-optimal. Who know's how to acomplish these tasks?

    Read the article

  • ValueError: too many values to unpack in a tuple

    - by falosi
    Please put some light on why am getting a too many to unpack (ValueError in my for loop).Have tried deb naislist = [('CONTROL FILE', '0', '0', '0'), ('REDO LOG', '0', '0', '0'), ('ARCHIVED LOG', '.69', '.59', '3'), ('BACKUP PIECE', '46.54', '0', '192'), ('IMAGE COPY', '0', '0', '0'), ('FLASHBACK LOG', '10.15', '6.31', '82'), ('FOREIGN ARCHIVED LOG', '0', '0', '0')] print "size of naislist is ",len((naislist)) heading = ('MAIN MENU', 'LEVELS', 'LEVEL2', 'LEVEL3') rearrange = dict(zip((0, 1, 2, 3), (len(str(x)) for x in heading))) for tu, x in naislist: rearrange.update((i, max(rearrange[i], len(str(el)))) for i, el in enumerate(tu)) rearrange[4] = max(rearrange[4], len(str(x))) forkit = '|'. join('%%-%ss' % rearrange[i] for i in xrange(0, 4)) print '\n'.join((forkit % heading, '-|-'.join(rearrange[i] * '-' for i in xrange(4)), '\n'.join(forkit % (a, b, c, d) for (a, b, c), d in naislist)))

    Read the article

  • pywinauto: taking more than one app windows

    - by Denis Barmenkov
    I have a GUI application which can create many similar windows on desktop. All windows have same title. I have to enumerate all dialogs with same title and make some tests against each of such dialogs. If I call: dialog = app['Window Name'] pywinauto returns a WindowSpecification object which is useful along with accessing controls by name. When I call: dialogs = app.windows_(title='Window Name') pywinauto returns me a list of HwndWrapper instances which are not so useful. How to obtain a list of windows with specified title but as WindowSpecification objects?

    Read the article

  • DataTable linq query iteration

    - by Ravi
    Hi, I want to Enumerate Linq Query. Below i specified example. EX: DataTable _slidingDataTable = new DataTable("test"); for(int i=0; i<5;i++) { DataRow row = _slidingDataTable.NewRow(); startPosition = DateTime.Now; for(int i=0; i<5;i++) { _slidingDataTable.Columns.Add("TransferTime"); row[columnName] = startPosition ; _slidingDataTable.Columns.Add("TransferData"); row[columnName] = "Test"+i; } _slidingDataTable.Rows.Add(row); } var query1 = from myRow in _slidingDataTable.AsEnumerable() where myRow.Field<DateTime>("TransferTime") == startPosition select myRow; This query output should be collection of rows. How to get collection row & iterate.

    Read the article

  • tkinter python entry not being displayed

    - by user1050619
    I have created a Form with labels and entries..but for some reason the entries are not being created, peoplegui.py from tkinter import * from tkinter.messagebox import showerror import shelve shelvename = 'class-shelve' fieldnames = ('name','age','job','pay') def makewidgets(): global entries window = Tk() window.title('People Shelve') form = Frame(window) form.pack() entries = {} for (ix, label) in enumerate(('key',) + fieldnames): lab = Label(form, text=label) ent = Entry(form) lab.grid(row=ix, column=0) lab.grid(row=ix, column=1) entries[label] = ent Button(window, text="Fetch", command=fetchRecord).pack(side=LEFT) Button(window, text="Update", command=updateRecord).pack(side=LEFT) Button(window, text="Quit", command=window.quit).pack(side=RIGHT) return window def fetchRecord(): print('In fetch') def updateRecord(): print('In update') if __name__ == '__main__': window = makewidgets() window.mainloop() When I run it the labels are created but not the entries.

    Read the article

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