enumerate

C# - how enumerate all classes with custom class attribute?

Question based on MSDN example: http://msdn.microsoft.com/en-us/library/aa288454(VS.71).aspx Let's say we have some C# classes with HelpAttribute in standalone desktop application. Is it possible to enumerate all classes with such attribute? Does it make sense to recognize classes this way? Custom attribute would be used to list possibl...

Enumerate printers for a specific Terminal Server session

I am looking for a way to see what printers a specific user has mapped into his or her TS session. How can I achieve this with WMI (via PowerShell) or VB-Script? Is there a built-in way I'm not aware of? EDIT: In our construct mapping of local printers by the RDP-Client is disabled. Users get their printers created during login via VBS...

Enumerating tables used in mysql query?

Is there any way to enumerate tables used in mysql query? Lets say I have query : SELECT * FROM db_people.people_facts pf INNER JOIN db_system.connections sm ON sm.source_id = pf.object_id INNER JOIN db_people.people p ON sm.target_id = p.object_id ORDER BY pf.object_id DESC And i want in return array: $tables = array( [0] => 'db...

Program Control-Flow in Python

I have some data that I have stored in a list and if I print out the list I see the following: . . . 007 A000000 Y 007 B000000 5 007 C010100 1 007 C020100 ACORN FUND 007 C030100 N 007 C010200 2 007 C020200 ACORN INTERNATIONAL 007 C030200 N 007 C010300 3 007 C020300 ACORN USA 007 C030300 N 007 C010400 4 . . . The dots before and a...

Objective-C: Reading a file line by line

What is the appropriate way of dealing with large text files in Objective-C? Let's say I need to read each line separately and want to treat each line as an NSString. What is the most efficient way of doing this? One solution is using the NSString method: + (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding...

How can I keep track of (enumerate) all classes that implement an interface

I have a situation where I have an interface that defines how a certain class behaves in order to fill a certain role in my program, but at this point in time I'm not 100% sure how many classes I will write to fill that role. However, at the same time, I know that I want the user to be able to select, from a GUI combo/list box, which con...

How to enumerate all webs and data in a SharePoint site collection

What is the best way to enumerate all SPWebs in an SPSite and also to enumerate folders within document libraries within each of the SPWebs? (essentially I want to find out the urls of all SPWebs, and the number of folders and amount of data being stored in each). I have achieved the above in C# using the SharePoint API but that takes a...

Programmatically move registry keys...

Hello, Does anyone know how I can programmaically move a registry from HKEY_LOCAL_MCAHINE to HKEY_CURRENT_USER? I wrote a recursive function that uses RegEnumKeyEx and RegEnumValue, but it appears that RegEnumValue returns all of the values under the top level key. For example, if the key is HKEY_LOCAL_MACHINE\SOFTWARE\MyApp\KeyName1 ...

Changing the numberings of nested lists in an Enumerate environment, in LaTeX

I want to produce the following in LaTeX: 1. Item 2. Item 3a. Item 3b. Item 4. Item 5. Item Basically I have already tried using nested enumerate environments, but I have a problem with implementing the different numberings. How can I do the above in LaTeX? ...

Is it possible to use SharePoint web services to retrieve all items in a folder with a given ID?

I'm using the GetListItems method of the SharePoint List web service. I would like to get all items in a given folder, with a given ID (not path). The method allows you to pass in QueryOptions xml, which lets you set the Folder path. However, since paths can change, this is not that useful to me, and it would be much better to be able to...

pylint: Using possibly undefined loop variable 'n'

Pylint say W: 6: Using possibly undefined loop variable 'n' with this code: iterator = (i*i for i in range(100) if i % 3 == 0) for n, i in enumerate(iterator): do_something(i) print n because if the iterator is empty (for example []) n is undefined, ok. But I like this trick. How to use it in a safe way? I think that usin...

C# class scanning

Hi all, In Java there are methods to go about scanning the classpath/all classes/within a package and enumerating the classes therein. e.g. spring component scanning uses something like this to scan all classes and find those with an interesting annotation. If there any similar technique for C# and if so what are the APIs to use? ...

Cocoa - Enumerate mutable array, removing objects

Hey there, I have a mutable array that contains mutable dictionaries with strings for the keys latitude, longitude and id. Some of the latitude and longitude values are the same and I want to remove the duplicates from the array so I only have one object per location. I can enumerate my array and using a second enumeration review each...

Is there a way of recover from an Exception in Directory.EnumerateFiles ?

In .NET 4, there's this Directory.EnumerateFiles() method with recursion that seems handy. However, if an Exception occurs within a recursion, how can I continue/recover from that and continuing enumerate the rest of the files? try { var files = from file in Directory.EnumerateFiles("c:\\", "*.*", SearchOpti...

Enumerate Dictionary Within ASP.NET Web Page

I have a ASP.NET (C#) web page in which I want to enumerate a dictionary in a code render block: <% foreach (Dictionary<string, string> record in parsedData) { %> <div>...Some HTML Code...</div> <% } %> But I get an error like: Compiler Error Message: CS0246: The type or namespace name 'Dictionary' could not be found (are...

python dict function on enumerate object

Hi, If I have an enumerate object x, why does doing the following: dict(x) clear all the items in the enumerate sequence? ...

Ruby get nth item from massive range

Suppose I have this range: ("aaaaa".."zzzzz") How would I get the Nth item from the range without generating the entire thing before hand/each time? ...

pythonic way to associate list elements with their indices

Hello Everybody, I have a list of values and I want to put them in a dictionary that would map each value to it's index. I can do it this way: >>> t = (5,6,7) >>> d = dict(zip(t, range(len(t)))) >>> d {5: 0, 6: 1, 7: 2} this is not bad, but I'm looking for something more elegant. I've come across the following, but it does the opp...

Any way to enumerate class members?

I have a class instance, and I want to enumerate its members. How can this be done? ...

Specifying a no-indent for a list, with LaTeX

I have the following: This is just normal text... \begin{enumerate} \item First Item ?\\\\ This is the text of the first item \item Second Item ?\\\\ This is the text of the second item \end{enumerate} Which renders the following: This is just normal text... 1. First Item ? This is the text of the first item 2. Second Item ? ...