Search Results

Search found 4755 results on 191 pages for 'scripting dictionary'.

Page 13/191 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • python: a way to get an exhaustive, sorted list of keys in a nested dictionary?

    - by saidimu
    exhaustive: - all keys in the dictionary, even if the keys are in a nested dictionary that is a value to a previous-level dictionary key. sorted: - this is to ensure the keys are always returned in the same order The nesting is arbitrarily deep. A non-recursive algorithm is preferred. level1 = { 'a' : 'aaaa', 'level2_1' : {'b': 'bbbbb', 'level3': {'c': 'cccc', 'd': 'dddddd'} }, 'level2_2' : { 'z': 'zzzzzzz' } }

    Read the article

  • Is there an open source immutable dictionary for C#, with fast 'With/Without' methods?

    - by Strilanc
    I'm looking for a proper C# immutable dictionary, with fast update methods (that create a partial copy of the dictionary with slight changes). I've implemented one myself, using zippers to update a red-black tree, but it's not particularly fast. By 'immutable dictionary' I don't just mean readonly or const. I want something that has reasonably fast 'With' and 'Without', or equivalent, methods that return a thing with slight modifications without modifying the original. An example from another language is map in Scala

    Read the article

  • How to close all, or only some, tabs in Safari using AppleScript?

    - by Form
    I have made a very simple AppleScript to close all tabs in Safari. The problem is, it works, but not completely. The problem is that only a couple of tabs are closed. Here's the code: tell application "Safari" repeat with aWindow in windows repeat with aTab in tabs of aWindow if [some condition is encountered] then aTab close end if end repeat end repeat end tell I've also tried this script: tell application "Safari" repeat with i from 0 to the number of items in windows set aWindow to item i of windows repeat with j from 0 to the number of tabs in aWindow set aTab to item j of tabs of aWindow if [some condition is encountered] then aTab close end if end repeat end repeat end tell ... but it does not work either (same behavior). I tried that on my system (MacBook Pro jan 2008), as well as on a Mac Pro G5 under Tiger and the script fails on both, albeit with a much less descriptive error on Tiger. Running the script a few times closes a few tab each time until none is left, but always fails with the same error after closing a few tabs. Under Leopard I get an out of bounds error. Since I am using fast enumeration (not using "repeat from 0 to number of items in windows") I don't see how I can get an out of bounds error with this... My goal is to use the Cocoa Scripting Bridge to close tabs in Safari from my Objective-C Cocoa application but the Scripting Bridge fails in the same manner. The non-deletable tabs show as NULL in the Xcode debugger, while the other tabs are valid objects from which I can get values back (such as their title). In fact I tried with the Scripting Bridge first then told myself why not try this directly in AppleScript and I was surprised to see the same results. I must have a glaring omission or something in there... (seems like a bug in Safari AppleScript support to me... :S) I've used repeat loops and Obj-C 2.0 fast enumeration to iterate through collections before with zero problems, so I really don't see what's wrong here. Anyone can help? Thanks in advance!

    Read the article

  • Can't get a List(Of <my class>) from a Dictionary in .NET?

    - by magsto
    I have a Dictionary with key of type UInteger and the value is List(Of Session) where the (Public) class Session contains a couple of variables and a constructor (Public Sub New(...)). Some of the variables in my Session class is: Private count As Integer Private StartDate As Date Private Values As List(Of Integer) and a couple of methods like: Friend Sub Counter(ByVal c as Integer) count += c End Sub There is no problem to add values to the Dictionary: Dim Sessions As New List(Of Session) Dim dict As New Dictionary(Of Integer, Sessions) then some code to fill up a couple of Session objects in Sessions (not shown here) and then: dict.Add(17, Sessions) 'No problem Sessions.Clear() Sessions = dict(17) 'This doesn't return anything! The Sessions object is empty even if the code doesn't returned any error. Is my class Session to compex to be stored in a Dictionary?

    Read the article

  • how to create english language dictionary application with python (django)?

    - by sintaloo
    Hi All, I would like to create an online dictionary application by using python (or with django). It will be similar to http://dictionary.reference.com/. My question is (1) Are there any existing open source python package or modules or application which implements this functionality that I can use or study from? (2) If the answer to the first question is NO. which algorithm should I follow to create such web application? Can I simply use the python built-in dictionary object for this job? so that the dictionary object's key will be the english word and the value will be the explanation. is this OK in term of performance? OR Do I have to create my own Tree Object to speed up the search? or any existing package which handles this job properly? Thank you very much.

    Read the article

  • Dictionary as DataMember in WCF after installing .NET 4.5 [migrated]

    - by Mauricio Ulate
    After installing .NET Framework 4.5 with Visual Studio 2012, whenever I want to obtain the reference from a WCF service, my dictionaries are changed into arrays. For example, Dictionary<int, double> is changed into ArrayOfKeyValueOfintdoubleKeyValueOfintdouble. This happens in both Visual Studio 2012 and 2010 (both Express). I've reviewed my configuration and the dictionary data type in the service reference configuration is System.Collection.Generic.Dictionary. Changing this doesn't make a difference. Reverting to just using Visual Studio 2010 and .NET 4.0 is not an option.

    Read the article

  • iTorque for a simple arcade game

    - by Herfus
    I have a basic understanding of programming, but I am no programmer. I've had a couple of a semesters with java programming, so we're talking pretty basic here. I have some scripting experience with game editors where I've created a few (simple) encounters, boss AI, abilities, events and so on. I've mostly done level design with UDK, Source and several other toolsets for a few years now, but I'd like to divert some of the focus to iphone-development. I've participated in a few development projects (source, udk, daot) where I've had a variety of roles (yet never beyond simple scripting). I have just finished prototyping an Iphone game (using game maker) and begun a bit more precise planning on what I'll have to do for the real version. The game is fairly simple, perhaps the best comparison in scope and complexity would be Doodlejump for iPhone. The reason I created the prototype was not just to answer a few questions about the gameplay, but to get some insight into what kind of problems I might face when trying to develop the real thing. I've been looking for engines that I can use for this. iTorque looks, so far, like the best option with a scripting language and WYSIWYG-editor. However the price is fairly steep and I'd like to prepare myself as much as possible before jumping into this, which is why I'm going to ask a few questions here. What kind of difficulties do you think I might run into, considering what you've read so far? Not just with torque, but development in general. I'm making this question mostly to have someone to reality check me. I usually achieve to do what I'm trying to do with scripting, but something tells me there's a very big difference between scripting an AI or an event and creating game logic. Will it be too much of a leap? Just how simple is it to use the Torque scripting language? Obviously I don't expect to be prepared, I expect it to be a learning process. However, I'd still like to be at least a bit confident on the time I'll have to dedicate to this first.

    Read the article

  • Scriptable user-interfaces/frameworks for automated UI testing

    - by AareP
    I'm planning on using scripting for automated UI testing. Main application is written in c#, and I want it to be scriptable, so I can do everything end-user can do, but programmatically. What do you think of software that provides an interface for scripting, like VBA macros in Excel? Can this be future of all programming, big and small? What is the best way to build such an interface for your own application, dll-based or by parsing own scripting language?

    Read the article

  • Best Practices for serializing/persisting String Object Dictionary entities

    - by Mark Heath
    I'm noticing a trend towards using a dictionary of string to object (or sometimes string to string), instead of strongly typed objects. For example, the new Katana project makes heavy use of IDictionary<string,object>. This approach avoids the need to continually update your entity classes/DTOs and the database tables that persist them with new properties. It also avoids the need to create new derived entity types to support new types of entity, since the Dictionary is flexible enough to store any arbitrary properties. Here's a contrived example: class StorageDevice { public int Id { get; set; } public string Name { get; set; } } class NetworkShare : StorageDevice { public string Path { get; set; } public string LoginName { get; set; } public string Password { get; set; } } class CloudStorage : StorageDevice { public string ServerUri { get; set } public string ContainerName { get; set; } public int PortNumber { get; set; } public Guid ApiKey { get; set; } } versus: class StorageDevice { public IDictionary<string, object> Properties { get; set; } } Basically I'm on the lookout for any talks, books or articles on this approach, so I can pick up on any best practices / difficulties to avoid. Here's my main questions: Does this approach have a name? (only thing I've heard used so far is "self-describing objects") What are the best practices for persisting these dictionaries into a relational database? Especially the challenges of deserializing them successfully with strongly typed languages like C#. Does it change anything if some of the objects in the dictionary are themselves lists of strongly typed entities? Should a second dictionary be used if you want to temporarily store objects that are not to be persisted/serialized across a network, or should you use some kind of namespacing on the keys to indicate this?

    Read the article

  • bitwise XOR a string in Bash

    - by ricky2002
    Hi. I am trying to accomplish a work in Bash scripting. I have a string which i want to XOR with my key. #!/bin/sh PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH teststring="abcdefghijklmnopqr" Now how do i XOR the value of teststring and store it in a variable using bash? Any help will be appreciated.

    Read the article

  • How to Get Dictionary<int, string> from Linq to XML Anonymous Object?

    - by DaveDev
    Currently I'm getting a list of HeaderColumns from the following XML snippet: <HeaderColumns> <column performanceId="12" text="Over last month %" /> <column performanceId="13" text="Over last 3 months %" /> <column performanceId="16" text="1 Year %" /> <column performanceId="18" text="3 Years % p.a." /> <column performanceId="20" text="5 Years % p.a." /> <column performanceId="22" text="10 Years % p.a." /> </HeaderColumns> from which I create an object as follows: (admitedly similar to an earlier question!) var performancePanels = new { Panels = (from panel in doc.Elements("PerformancePanel") select new { HeaderColumns = (from column in panel.Elements("HeaderColumns").Elements("column") select new { PerformanceId = (int)column.Attribute("performanceId"), Text = (string)column.Attribute("text") }).ToList(), }).ToList() }; I'd like if HeaderColumns was a Dictionary() so later I extract the values from the anonymous object like follows: Dictionary<int, string> myHeaders = new Dictionary<int, string>(); foreach (var column in performancePanels.Panels[0].HeaderColumns) { myHeaders.Add(column.PerformanceId, column.Text); } I thought I could achieve this with the Linq to XML with something similar to this HeaderColumns = (from column in panel.Elements("HeaderColumns").Elements("column") select new Dictionary<int, string>() { (int)column.Attribute("performanceId"), (string)column.Attribute("text") }).ToDictionary<int,string>(), but this doesn't work because ToDictionary() needs a Func parameter and I don't know what that is / how to implement it, and the code's probably wrong anyway! Could somebody please suggest how I can achieve the result I need? Thanks.

    Read the article

  • Save and Load Dictionary from encrypted or unreadable or binary format ?

    - by Prix
    I have a dictionary like the follow: public Dictionary<int, SpawnList> spawnEntities = new Dictionary<int, SpawnList>(); The class being used is as follow: public class SpawnList { public int NpcID { get; set; } public string Name { get; set; } public int Level { get; set; } public int TitleID { get; set; } public int StaticID { get; set; } public entityType Status { get; set; } public int TypeA { get; set; } public int TypeB { get; set; } public int TypeC { get; set; } public int ZoneID { get; set; } public int Heading { get; set; } public float PosX { get; set; } public float PosY { get; set; } public float PosZ { get; set; } } /// <summary>Entity type enum.</summary> public enum entityType { Ally, Enemy, SummonPet, NPC, Object, Monster, Gatherable, Unknown } How could I save this Dictionary to either a binary or encrypted format so I could later Load it again into my application ? My limitation is .Net 3.5 can't use anything higher.

    Read the article

  • LINQ to XML - How to get Dictionary from Anonymous Object?

    - by DaveDev
    Currently I'm getting a list of HeaderColumns from the following XML snippet: <PerformancePanel> <HeaderColumns> <column performanceId="12" text="Over last month %" /> <column performanceId="13" text="Over last 3 months %" /> <column performanceId="16" text="1 Year %" /> <column performanceId="18" text="3 Years % p.a." /> <column performanceId="20" text="5 Years % p.a." /> <column performanceId="22" text="10 Years % p.a." /> </HeaderColumns> </PerformancePanel> from which I create an object as follows: (admitedly similar to an earlier question!) var performancePanels = new { Panels = (from panel in doc.Elements("PerformancePanel") select new { HeaderColumns = (from column in panel.Elements("HeaderColumns").Elements("column") select new { PerformanceId = (int)column.Attribute("performanceId"), Text = (string)column.Attribute("text") }).ToList(), }).ToList() }; I'd like if HeaderColumns was a Dictionary() so later I extract the values from the anonymous object like follows: Dictionary<int, string> myHeaders = new Dictionary<int, string>(); foreach (var column in performancePanels.Panels[0].HeaderColumns) { myHeaders.Add(column.PerformanceId, column.Text); } I thought I could achieve this with the Linq to XML with something similar to this HeaderColumns = (from column in panel.Elements("HeaderColumns").Elements("column") select new Dictionary<int, string>() { (int)column.Attribute("performanceId"), (string)column.Attribute("text") }).ToDictionary<int,string>(), but this doesn't work because ToDictionary() needs a Func parameter and I don't know what that is / how to implement it, and the code's probably wrong anyway! Could somebody please suggest how I can achieve the result I need? Thanks.

    Read the article

  • Using a Predicate as a key to a Dictionary

    - by Tom Hines
    I really love Linq and Lambda Expressions in C#.  I also love certain community forums and programming websites like DaniWeb. A user on DaniWeb posted a question about comparing the results of a game that is like poker (5-card stud), but is played with dice. The question stemmed around determining what was the winning hand.  I looked at the question and issued some comments and suggestions toward a potential answer, but I thought it was a neat homework exercise. [A little explanation] I eventually realized not only could I compare the results of the hands (by name) with a certain construct – I could also compare the values of the individual dice with the same construct. That piece of code eventually became a Dictionary with the KEY as a Predicate<int> and the Value a Func<T> that returns a string from the another structure that contains the mapping of an ENUM to a string.  In one instance, that string is the name of the hand and in another instance, it is a string (CSV) representation of of the digits in the hand. An added benefit is that the digits re returned in the order they would be for a proper poker hand.  For instance the hand 1,2,5,3,1 would be returned as ONE_PAIR (1,1,5,3,2). [Getting to the point] 1: using System; 2: using System.Collections.Generic; 3:   4: namespace DicePoker 5: { 6: using KVP_E2S = KeyValuePair<CDicePoker.E_DICE_POKER_HAND_VAL, string>; 7: public partial class CDicePoker 8: { 9: /// <summary> 10: /// Magical construction to determine the winner of given hand Key/Value. 11: /// </summary> 12: private static Dictionary<Predicate<int>, Func<List<KVP_E2S>, string>> 13: map_prd2fn = new Dictionary<Predicate<int>, Func<List<KVP_E2S>, string>> 14: { 15: {new Predicate<int>(i => i.Equals(0)), PlayerTie},//first tie 16:   17: {new Predicate<int>(i => i > 0), 18: (m => string.Format("Player One wins\n1={0}({1})\n2={2}({3})", 19: m[0].Key, m[0].Value, m[1].Key, m[1].Value))}, 20:   21: {new Predicate<int>(i => i < 0), 22: (m => string.Format("Player Two wins\n2={2}({3})\n1={0}({1})", 23: m[0].Key, m[0].Value, m[1].Key, m[1].Value))}, 24:   25: {new Predicate<int>(i => i.Equals(0)), 26: (m => string.Format("Tie({0}) \n1={1}\n2={2}", 27: m[0].Key, m[0].Value, m[1].Value))} 28: }; 29: } 30: } When this is called, the code calls the Invoke method of the predicate to return a bool.  The first on matching true will have its value invoked. 1: private static Func<DICE_HAND, E_DICE_POKER_HAND_VAL> GetHandEval = dh => 2: map_dph2fn[map_dph2fn.Keys.Where(enm2fn => enm2fn(dh)).First()]; After coming up with this process, I realized (with a little modification) it could be called to evaluate the individual values in the dice hand in the event of a tie. 1: private static Func<List<KVP_E2S>, string> PlayerTie = lst_kvp => 2: map_prd2fn.Skip(1) 3: .Where(x => x.Key.Invoke(RenderDigits(dhPlayerOne).CompareTo(RenderDigits(dhPlayerTwo)))) 4: .Select(s => s.Value) 5: .First().Invoke(lst_kvp); After that, I realized I could now create a program completely without “if” statements or “for” loops! 1: static void Main(string[] args) 2: { 3: Dictionary<Predicate<int>, Action<Action<string>>> main = new Dictionary<Predicate<int>, Action<Action<string>>> 4: { 5: {(i => i.Equals(0)), PlayGame}, 6: {(i => true), Usage} 7: }; 8:   9: main[main.Keys.Where(m => m.Invoke(args.Length)).First()].Invoke(Display); 10: } …and there you have it. :) ZIPPED Project

    Read the article

  • CVE-2011-1937 Cross-site scripting (XSS) vulnerability in Webmin

    - by chandan
    CVE DescriptionCVSSv2 Base ScoreComponentProduct and Resolution CVE-2011-1937 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability 4.3 Webmin Solaris 10 SPARC: 145006-03 X86: 145007-03 This notification describes vulnerabilities fixed in third-party components that are included in Sun's product distribution.Information about vulnerabilities affecting Oracle Sun products can be found on Oracle Critical Patch Updates and Security Alerts page.

    Read the article

  • CVE-2009-0781 Cross-site Scripting vulnerability in Sun Java System Application Server Example Application

    - by chandan
    CVE DescriptionCVSSv2 Base ScoreComponentProduct and Resolution CVE-2009-0781 Cross-site Scripting vulnerability 4.3 Example Calendar Application Sun Java System Application Server EE 8.1 SPARC: 119169-35, 119166-42, 119173-35 X86: 119167-42, 119170-35, 119174-36 Linux: 119171-35, 119168-42, 119175-35 Windows: 119172-35,119176-35 Sun Java System Application Server EE 8.2 SPARC: 124679-16, 124672-17, 124675-16 X86:124680-16, 124673-17, 124676-16 Linux: 124681-16,124677-16, 124674-17 Windows: 124682-16 This notification describes vulnerabilities fixed in third-party components that are included in Sun's product distribution.Information about vulnerabilities affecting Oracle Sun products can be found on Oracle Critical Patch Updates and Security Alerts page.

    Read the article

  • PHP - A Widely-Used Scripting Language

    Typified as interpreted script language, PHP - a recursive acronym for Hypertext Preprocessor - is a widely used general purpose scripting or programming language. Hypertext Preprocessor is suited for web development in particular as it can be embedded into HTML.

    Read the article

  • How to bind a complex dictionary to a Gridview in asp.net?

    - by Mehdi
    I've used an early binding of a dictionary<string, string> to a gridview to show Urls Text and its HRef as key-value and it works like a charm. But since I want to replace the dictionary with this one : dictionary<string, LinkInfo> the binding goes wrong! Should I handle some events like as onItemDataBound or something? and the LinkInfo structure is: public struct LinkInfo{ public string href; public bool Enabled; }

    Read the article

  • In C#: How to declare a generic Dictionary with a type as key and an enumeration of that type as val

    - by Marcel
    Hi all, I want to declare a dictionary that stores typed IEnumerable's of a specific type, with that exact type as key, like so: (Edited to follow johny g's comment) private IDictionary<Type, IEnumerable<T>> _dataOfType where T: BaseClass; //does not compile! The concrete classes I want to store, all derive from BaseClass, therefore the idea to use it as constraint. The compiler complains that it expects a semicolon after the member name. If it would work, I would expect this would make the later retrieval from the dictionary simple like: IEnumerable<ConcreteData> concreteData; _sitesOfType.TryGetValue(typeof(ConcreteType), out concreteData); How to define such a dictionary?

    Read the article

  • .NET: efficient way to produce a string from a Dictionary<K,V> ?

    - by Cheeso
    Suppose I have a Dictionary<String,String>, and I want to produce a string representation of it. The "stone tools" way of doing it would be: private static string DictionaryToString(Dictionary<String,String> hash) { var list = new List<String> (); foreach (var kvp in hash) { list.Add(kvp.Key + ":" + kvp.Value); } var result = String.Join(", ", list.ToArray()); return result; } Is there an efficient way to do this in C# using existing extension methods? I know about the ConvertAll() and ForEach() methods on List, that can be used to eliminate foreach loops. Is there a similar method I can use on Dictionary to iterate through the items and accomplish what I want?

    Read the article

  • Which method of adding items to the ASP.NET Dictionary class is more efficient?

    - by ahmd0
    I'm converting a comma separated list of strings into a dictionary using C# in ASP.NET (by omitting any duplicates): string str = "1,2, 4, 2, 4, item 3,item2, item 3"; //Just a random string for the sake of this example and I was wondering which method is more efficient? 1 - Using try/catch block: Dictionary<string, string> dic = new Dictionary<string, string>(); string[] strs = str.Split(','); foreach (string s in strs) { if (!string.IsNullOrWhiteSpace(s)) { try { string s2 = s.Trim(); dic.Add(s2, s2); } catch { } } } 2 - Or using ContainsKey() method: string[] strs = str.Split(','); foreach (string s in strs) { if (!string.IsNullOrWhiteSpace(s)) { string s2 = s.Trim(); if (!dic.ContainsKey(s2)) dic.Add(s2, s2); } }

    Read the article

  • How to delete a Dictionary row that is a Double by using an Int?

    - by Richard Reddy
    Hi, I have a Dictionary object that is formed using a double as its key values. It looks like this: Dictionary<double, ClassName> VariableName = new Dictionary<double, ClassName>(); For my project I have to have the key as the double as I require values like 1.1,1.2,2.1,2.2,etc in my system. Everything in my system works great except when I want to delete all the keys in a group eg all the 1 values would be 1.1,1.2, etc. I can delete rows if I know the full value of the key eg 1.1 but in my system I will only know the whole number. I tried to do the following but get an error: DictionaryVariable.Remove(j => Convert.ToInt16(j.Key) == rowToEdit).OrderByDescending(j => j.Key); Is there anyway to remove all rows per int value by converting the key? Thanks, Rich

    Read the article

  • In C#: How to declare a generic Dictionary whose key and value types have a common constraint type?

    - by Marcel
    Hi all, I want to declare a dictionary that stores typed IEnumerable's of a specific type, with that exact type as key, like so: private IDictionary<T, IEnumerable<T>> _dataOfType where T: BaseClass; //does not compile! The concrete classes I want to store, all derive from BaseClass, therefore the idea to use it as constraint. The compiler complains that it expects a semicolon after the member name. If it would work, I would expect this would make the later retrieval from the dictionary simple like: IEnumerable<ConcreteData> concreteData; _sitesOfType.TryGetValue(typeof(ConcreteType), out concreteData); How to define such a dictionary?

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >