Search Results

Search found 2155 results on 87 pages for 'mathematical expressions'.

Page 76/87 | < Previous Page | 72 73 74 75 76 77 78 79 80 81 82 83  | Next Page >

  • How to prepare data for display on a silverlight chart using WCF RIA Services + Entity Framework

    - by Banford
    I've used WCF RIA services with Entity Framework to build a simple application which can display and updates data about school courses. This was done by following the Microsoft tutorials. Now I would like to have a chart which shows a count for how many courses are on a key stage. Example: Key Stage 3 - 20 courses Key Stage 4 - 32 courses Key Stage 5 - 12 courses Displayed on any form of chart. I have no problem binding data to the chart in XAML. My problem is that I do not know how to correct way of getting the data into that format. The generated CRUD methods are basic. I have a few thoughts about possible ways, but don't know which is correct, they are: Create a View in SQL server and map this to a separate Entity in the Entity Data Model. Generating new CRUD methods for this automatically. Customise the read method in the existing DomainService using .Select() .Distinct() etc. Don't know this syntax very well labda expressions/LINQ??? what is it? Any good quickstarts on it? Create a new class to store only the data required and create a read method for it. Tried this but didn't know how to make it work without a matching entity in the entity model. Something I am not aware of. I'm very new to this and struggling with the concepts so if there are useful blogs or documentation I've missed feel free to point me towards them. But I'm unsure of the terminology to use in my searches at the moment.

    Read the article

  • Apache friendly urls

    - by HaukurHaf
    Hi everyone. I've got a small CMS system written in PHP and running on Apache. The format of the URLs this CMS system uses/generates is: /display.php?PageID=xxx where xxx is just some integer number. As you can see, those URLs are not very friendly, neither for users nor search engines. I believe that using mod_rewrite (or something like that) and .htaccess files I should be able to configure Apache for URL-rewriting. I have searched for information about this before but I did not find any easy method to do this, it always involved messing with regular expressions, which I'm not very familiar with. Since the website in question is really simple and small, just 5-10 different pages, I would really like to be able to just hard-code the configuration, without any special rules or regexps. I'd just like to map a friendly URL to an actual URL, perhaps like this: /about = /display.php?PageID=44 /products = /display.php?PageID=34 etc. Is it possible to configure the mod_rewrite plugin in a basic way like this? Could someone explain the easiest method to do this? Explain it to me as if I was a child :-) Thanks in advance!

    Read the article

  • Why do people keep parsing HTML using regex? [closed]

    - by polygenelubricants
    As much as I love regular expressions, it's obvious to me that it's not the best tool for parsing HTML, especially given the numerous good HTML parsers out there. And yet there are numerous questions on stackoverflow that attempts to parse HTML using regex. And people would always point out what a bad idea that is in the comments. And the accepted answer would often have a disclaimer how this isn't really the ideal way of doing things. But based on the constant flow of questions, it still seems that people keep parsing HTML using regex, despite the perceived difficulty in reading and maintaining it (and that's putting correctness aside for now). So my question is: why? Is it because it's easy to learn? Is it because it's faster? Is it because it's the industry standard? Is it because there are already so many reusable regexes to build from? Is it because 100% correctness is never really the objective? (90% good enough?) etc... I'd also like to hear from the downvoters why they did so. Is it because: There's absolutely nothing wrong with using regex to parse HTML and asking "Why?" is just dumb? The premise of the question is flawed because the people who are using regex to parse HTML is such a small minority?

    Read the article

  • Javascipt Regular Expression

    - by Ghoul Fool
    Having problems with regular expressions in JavaScript. I've got a number of strings that need delimiting by commas. Unfortunately the sub strings don't have quotes around them which would make life easier. var str1 = "Three Blind Mice 13 Agents of Cheese Super 18" var str2 = "An Old Woman Who Lived in a Shoe 7 Pixies None 12" var str3 = "The Cow Jumped Over The Moon 21 Crazy Cow Tales Wonderful 9" They are in the form of PHRASE1 (Mixed type with spaces") INTEGER1 (1 or two digit) PHRASE2 (Mixed type with spaces") WORD1 (single word mixed type, no spaces) INTEGER2 (1 or two digit) so I should get: result1 = "Three Blind Mice, 13, Agents of Cheese, Super, 18" result2 = "An Old Woman Who Lived in a Shoe, 7, Pixies, None, 12" result3 = "A Cow Jumped Over The Moon, 21, Crazy Cow Tales, Wonderful, 9" I've looked at txt2re.com, but can't quite get what I need and ended up delimiting by hand. But I'm sure it can be done, albeit someone with a bigger brain. There are lots of examples of regEx but I couldn't find any to deal with phrases; so I was wondering if anyone could help me out. Thank you.

    Read the article

  • Efficient (basic) regular expression implementation for streaming data

    - by Brendan Dolan-Gavitt
    I'm looking for an implementation of regular expression matching that operates on a stream of data -- i.e., it has an API that allows a user to pass in one character at a time and report when a match is found on the stream of characters seen so far. Only very basic (classic) regular expressions are needed, so a DFA/NFA based implementation seems like it would be well-suited to the problem. Based on the fact that it's possible to do regular expression matching using a DFA/NFA in a single linear sweep, it seems like a streaming implementation should be possible. Requirements: The library should try to wait until the full string has been read before performing the match. The data I have really is streaming; there is no way to know how much data will arrive, it's not possible to seek forward or backward. Implementing specific stream matching for a couple special cases is not an option, as I don't know in advance what patterns a user might want to look for. For the curious, my use case is the following: I have a system which intercepts memory writes inside a full system emulator, and I would like to have a way to identify memory writes that match a regular expression (e.g., one could use this to find the point in the system where a URL is written to memory). I have found (links de-linkified because I don't have enough reputation): stackoverflow.com/questions/1962220/apply-a-regex-on-stream stackoverflow.com/questions/716927/applying-a-regular-expression-to-a-java-i-o-stream www.codeguru.com/csharp/csharp/cs_data/searching/article.php/c14689/Building-a-Regular-Expression-Stream-Search-with-the-NET-Framework.htm But all of these attempt to convert the stream to a string first and then use a stock regular expression library. Another thought I had was to modify the RE2 library, but according to the author it is architected around the assumption that the entire string is in memory at the same time. If nothing's available, then I can start down the unhappy path of reinventing this wheel to fit my own needs, but I'd really rather not if I can avoid it. Any help would be greatly appreciated!

    Read the article

  • Why is T() = T() allowed?

    - by Rimo
    I believe the expression T() creates an rvalue (by the Standard). However, the following code compiles (at least on gcc4.0): class T {}; int main() { T() = T(); } I know technically this is possible because member functions can be invoked on temporaries and the above is just invoking the operator= on the rvalue temporary created from the first T(). But conceptually this is like assigning a new value to an rvalue. Is there a good reason why this is allowed? Edit: The reason I find this odd is it's strictly forbidden on built-in types yet allowed on user-defined types. For example, int(2) = int(3) won't compile because that is an "invalid lvalue in assignment". So I guess the real question is, was this somewhat inconsistent behavior built into the language for a reason? Or is it there for some historical reason? (E.g it would be conceptually more sound to allow only const member functions to be invoked on rvalue expressions, but that cannot be done because that might break some existing code.)

    Read the article

  • C#. Saving information about events and event handlers and removing handlers using this information

    - by Philipp
    I have an object which is creating several event handlers using lambda expressions, and I need to remove all handlers created in that object in one time. I'm trying to create some unified static object which will 'know' which handler relates to which object and event if event handler was created through this static object. I tried something like code below, but I don't understand how to save events and event handlers objects, to be able remove handlers in one time. class Program { static void Main(string[] args) { var EventSender = new EventSender(); var EventReceiver = new EventReceiver(EventSender); EventSender.Invoke(" some var "); LinkSaver.RemoveEvent(EventReceiver); // ?? Console.ReadKey(); } } public class ObjLink{ public object Event; public object Action; } public static class LinkSaver { public static void SetEvent<T>(object obj, Action<T> Event, T Action) { Event(Action); var objLink = new ObjLink{Event = Event, Action = Action}; if (!Links.ContainsKey(obj)) Links.Add(obj, new List<ObjLink>{objLink}); else Links[obj].Add(objLink); } static Dictionary<object,List<ObjLink>> Links = new Dictionary<object, List<ObjLink>>(); public static void RemoveEvent(object obj){ foreach(var objLink in Links[obj]){ // objLink.Event -= objLink.Action; ??? } } } public class EventReceiver { public EventReceiver(EventSender obj) { LinkSaver.SetEvent<EventSender.TestDelegate>(this, obj.SetEvent, str => Console.WriteLine(str + " test event!")); } } public class EventSender { public void Invoke(string var) { if (eventTest != null) eventTest(var); } public void SetEvent(TestDelegate Action) { eventTest += Action; } public delegate void TestDelegate(string var); private event TestDelegate eventTest; // by the way public void RemoveFromEvent() { foreach (var handler in eventTest.GetInvocationList()) eventTest -= (TestDelegate)handler; } }

    Read the article

  • What does P mean in Sort(Expression<Func<T, P>> expr, ListSortDirection direction)?

    - by Grasshopper
    I am attempting to use the answer in post: How do you sort an EntitySet<T> to expose an interface so that I can sort an EntitySet with a Binding list. I have created the class below and I get the following compiler error: "The type or namespace 'P' could not be found (are you missing a using directive or assembly reference?). Can someone tell me what the P means and which namespace I need to include to get the method below to compile? I am very new to delegates and lamba expressions. Also, can someone confirm that if I create a BindingList from my EntitySet that any modifications I make to the BindingList will be made to the EntitySet? Basically, I have an EntitySet that I need to sort and make changes to. Then, I will need to persist these changes using the original Entity that the BindingList came from. public class EntitySetBindingWrapper<T> : BindingList<T> { public EntitySetBindingWrapper(BindingList<T> root) : base(root) { } public void Sort(Expression<Func<T, P>> expr, ListSortDirection direction) { if (expr == null) base.RemoveSortCore(); MemberExpression propExpr = expr as MemberExpression; if (propExpr == null) throw new ArgumentException("You must provide a property", "expr"); PropertyDescriptorCollection descriptorCol = TypeDescriptor.GetProperties(typeof(T)); IEnumerable<PropertyDescriptor> descriptors = descriptorCol.Cast<PropertyDescriptor>(); PropertyDescriptor descriptor = descriptors.First(pd => pd.Name == propExpr.Member.Name); base.ApplySortCore(descriptor, direction); } }

    Read the article

  • How to start matching and saving matched from exact point in a text

    - by yuliya
    I have a text and I write a parser for it using regular expressions and perl. I can match what I need with two empty lines (I use regexp), because there is a pattern that allows recognize blocks of text after two empty lines. But the problem is that the whole text has Introduction part and some text in the end I do not need. Here is a code which matches text when it finds two empty lines #!/usr/bin/perl use strict; use warnings; my $file = 'first'; open(my $fh, '<', $file); my $empty = 0; my $block_num = 1; open(OUT, '>', $block_num . '.txt'); while (my $line = <$fh>) { chomp ($line); if ($line =~ /^\s*$/) { $empty++; } elsif ($empty == 2) { close(OUT); open(OUT, '>', ++$block_num . '.txt'); $empty = 0; } else { $empty = 0;} print OUT "$line\n"; } close(OUT); This is example of the text I need (it's really small :)) this is file example I think that I need to iterate over the text till the moment it will find the word LOREM IPSUM with regexps this kind "/^LOREM IPSUM/", because it is the point from which needed text starts(and save the text in one file when i reach the word). And I need to finish iterating over the text when INDEX word is fount or save the text in separate file. How could I implement it. Should I use next function to proceed with lines or what? BR, Yuliya

    Read the article

  • complex regular expression task

    - by Don Don
    Hi, What regular expressions do I need to extract section title(s) in a text file? So, in the following sample text, I'd like to extract "Communication and Leadership" "1.Self-Knowledge" "2. Humility" "(3) Clear Thinking". Many thanks. Communication and Leadership True leaders understand that, rather than forcing their followers into a preconceived mold, their job is to motivate and organize followers to collectively accomplish goals that are in everyone's interests. The ability to communicate this to co-workers and followers is critical to the effectiveness of leadership. 1.Self-Knowledge Superior leaders are able to devote their skills and energies to leadership of a group because they have worked through personal issues to the point where they know themselves thoroughly. A high level of self-knowledge is a prerequisite to effective communication skills, because the things that you communicate as a leader are coming from within. 2. Humility This subversion of personal preference requires a certain level of humility. Although popular definitions of leaders do not always see them as humble, the most effective leaders actually are. This humility may not be expressed in self-effacement, but in a total commitment to the goals of the organization. Humility requires an understanding of one's own relative unimportance in comparison to larger systems. (3) Clear Thinking Clarity of thinking translates into clarity of communication. A leader whose goals or personal analysis is muddled will tend to deliver unclear or ambiguous directions to followers, leading to confusion and dissatisfaction. A leader with a clear mind who is not ambivalent about her purposes will communicate what needs to be done in a s traightforward and unmistakable manner.

    Read the article

  • PROLOG - DCG parsing

    - by user2895589
    Hello I am new Prolog and DGC.I want to write a DCG to parse time expressions like 10.20 am or 12 oclock. how can I check 10.20 am is valid expression or not for Olcock I wrote some code. oclock --> digit1,phrase1. digit1 --> [T],{digit1(T)}. digit1(1). digit1(2). digit1(3). digit1(4). digit1(5). digit1(6). digit1(7). digit1(8). digit1(9). digit1(10). digit1(11). digit1(12). phrase1 --> [P],{phrase1(P)}. phrase1(Oclock). i ma checking by query oclock([1,oclock],[]). can someone help me on this.

    Read the article

  • Performance of stored proc when updating columns selectively based on parameters?

    - by kprobst
    I'm trying to figure out if this is relatively well-performing T-SQL (this is SQL Server 2008). I need to create a stored procedure that updates a table. The proc accepts as many parameters as there are columns in the table, and with the exception of the PK column, they all default to NULL. The body of the procedure looks like this: CREATE PROCEDURE proc_repo_update @object_id bigint ,@object_name varchar(50) = NULL ,@object_type char(2) = NULL ,@object_weight int = NULL ,@owner_id int = NULL -- ...etc AS BEGIN update object_repo set object_name = ISNULL(@object_name, object_name) ,object_type = ISNULL(@object_type, object_type) ,object_weight = ISNULL(@object_weight, object_weight) ,owner_id = ISNULL(@owner_id, owner_id) -- ...etc where object_id = @object_id return @@ROWCOUNT END So basically: Update a column only if its corresponding parameter was provided, and leave the rest alone. This works well enough, but as the ISNULL call will return the value of the column if the received parameter was null, will SQL Server optimize this somehow? This might be a performance bottleneck on the application where the table might be updated heavily (insertion will be uncommon so the performance there is not a problem). So I'm trying to figure out what's the best way to do this. Is there a way to condition the column expressions with something like CASE WHEN or something? The table will be indexed up the wazoo as well for read performance. Is this the best approach? My alternative at this point is to create the UPDATE expression in code (e.g. inline SQL) and execute it against the server. This would solve my doubts about performance, but I'd rather leave this in a stored proc if possible.

    Read the article

  • Array's index and argc signedness

    - by tusbar
    Hello, The C standard (5.1.2.2.1 Program startup) says: The function called at program startup is named main. [...] It shall be de?ned with a return type of int and with no parameters: int main(void) { /* ... */ } or with two parameters [...] : int main(int argc, char *argv[]) { /* ... */ } And later says: The value of argc shall be nonnegative. Why shouldn't argc be defined as an unsigned int, argc supposedly meaning 'argument count'? Should argc be used as an index for argv? So I started wondering if the C standard says something about the type of array's index. Is it signed? 6.5.2.1 Array subscripting: One of the expressions shall have type ‘‘pointer to object type’’, the other expression shall have integer type, and the result has type ‘‘type’’. It doesn't say anything about its signedness (or I didn't find it). It is pretty common to see codes using negatives array indexes (array[-1]) but isn't it undefined behavior? Should array's indexes be unsigned?

    Read the article

  • How do I authenticate an ADO.NET Data Service?

    - by lsb
    Hi! I've created an ADO.Net Data Service hosted in a Azure worker role. I want to pass credentials from a simple console client to the service then validate them using a QueryInterceptor. Unfortunately, the credentials don't seem to be making it over the wire. The following is a simplified version of the code I'm using, starting with the DataService on the server: using System; using System.Data.Services; using System.Linq.Expressions; using System.ServiceModel; using System.Web; namespace Oslo.Worker { [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)] public class AdminService : DataService<OsloEntities> { public static void InitializeService( IDataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.SetServiceOperationAccessRule("*", ServiceOperationRights.All); } [QueryInterceptor("Pairs")] public Expression<Func<Pair, bool>> OnQueryPairs() { // This doesn't work!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (HttpContext.Current.User.Identity.Name != "ADMIN") throw new Exception("Ooops!"); return p => true; } } } Here's the AdminService I'm using to instantiate the AdminService in my Azure worker role: using System; using System.Data.Services; namespace Oslo.Worker { public class AdminHost : DataServiceHost { public AdminHost(Uri baseAddress) : base(typeof(AdminService), new Uri[] { baseAddress }) { } } } And finally, here's the client code. using System; using System.Data.Services.Client; using System.Net; using Oslo.Shared; namespace Oslo.ClientTest { public class AdminContext : DataServiceContext { public AdminContext(Uri serviceRoot, string userName, string password) : base(serviceRoot) { Credentials = new NetworkCredential(userName, password); } public DataServiceQuery<Order> Orders { get { return base.CreateQuery<Pair>("Orders"); } } } } I should mention that the code works great with the signal exception that the credentials are not being passed over the wire. Any help in this regard would be greatly appreciated! Thanks....

    Read the article

  • capture text, including tags from string, and then reorder tags with text

    - by Brian
    I have the following text: abcdef<CONVERSION>abcabcabcabc<2007-01-12><name1><2007-01-12>abcabcabcabc<name2><2007-01-11>abcabcabcabc<name3><2007-02-12>abcabcabcabc<name4>abcabcabcabc<2007-03-12><name5><date>abcabcabcabc<name6> I need to use regular expressions in order to clean the above text: The basic extraction rule is: <2007-01-12>abcabcabcabc<name2> I have no problem extracting this pattern. My issue is that within th text I have malformed sequences: If the text doesn't start with a date, and end with a name my extraction fails. For example, the text above may have several mal formed sequences, such as: abcabcabcabc<2007-01-12><name1> Should be: <2007-01-12>abcabcabcabc<name1> Is it possible to have a regular expression that would clean the above, prior to extracting my consistent pattern. In short, i need to find all mal formed patterns, and then take the date tag and put it in front of it, as provided in the example above. Thanks.

    Read the article

  • How to replace auto-implemented c# get body at runtime or compile time?

    - by qstarin
    I've been trying to figure this out all night, but I guess my knowledge of the .Net Framework just isn't that deep and the problem doesn't exactly Google well, but if I can get a nod in the right direction I'm sure I can implement it, one way or another. I'd like to be able to declare a property decorated with a custom attribute as such: public MyClass { [ReplaceWithExpressionFrom(typeof(SomeOtherClass))] public virtual bool MyProperty { get; } } public SomeOtherClass : IExpressionHolder<MyClass, bool> { ... } public interface IExpressionHolder<TArg, TResult> { Expression<Func<TArg, TResult>> Expression { get; } } And then somehow - this is the part I'm having trouble figuring - replace the automatically generated implementation of that getter with a piece of custom code, something like: Type expressionHolderType = LookupAttributeCtorArgTypeInDeclarationOfPropertyWereReplacing(); return ReplaceWithExpressionFromAttribute.GetCompiledExpressionFrom(expressionHolderType)(this); The main thing I'm not sure how to do is replace the automatic implementation of the get. The first thing that came to mind was PostSharp, but that's a more complicated dependency than I care for. I'd much prefer a way to code it without using post-processing attached to the build (I think that's the jist of how PostSharp sinks its hooks in anyway). The other part of this I'm not so sure about is how to retrieve the type parameter passed to the particular instantiation of the ReplaceWithExpressionFrom attribute (where it decorates the property whose body I want to replace; in other words, how do I get typeof(SomeOtherClass) where I'm coding the get body replacement). I plan to cache compiled expressions from concrete instances of IExpressionHolder, as I don't want to do that every time the property gets retrieved. I figure this has just got to be possible. At the very least I figure I should be able to search an assembly for any method decorated with the attribute and somehow proxy the class or just replace the IL or .. something? And I'd like to make the integration as smooth as possible, so if this can be done without explicitly calling a registration or initialization method somewhere that'd be super great. Thanks!

    Read the article

  • python interactive mode module import issue

    - by Jeff
    I believe I have what would be called a scope issue, perhaps name space. Not too sure I'm new to python. I'm trying to make a module that will search through a list using regular expressions. I'm sure there is a better way of doing it but this error that I'm getting is bugging me and I want to understand why. here's my code: class relist(list): def __init__(self, l): list.__init__(self, l) def __getitem__(self, rexp): r = re.compile(rexp) res = filter(r.match, self) return res if __name__ == '__main__': import re listl = [x+y for x in 'test string' for y in 'another string for testing'] print(listl) test = relist(listl) print('----------------------------------') print(test['[s.]']) When I run this code through the command line it works the way I expect it to; however when I run it through python interactive mode I get the error >>> test['[s.]'] Traceback (most recent call last): File "<stdin>", line 1, in <module> File "relist.py", line 8, in __getitem__ r = re.compile(rexp) NameError: global name 're' is not defined While in the interactive mode I do import re and I am able to use the re functions, but for some reason when I'm trying to execute the module it doesn't work. Do I need to import re into the scope of the class? I wouldn't think so because doesn't python search through other scopes if it's not found in the current one? I appreciate your help, and if there is a better way of doing this search I would be interested in knowing. Thanks

    Read the article

  • best REGEXP friendly Text Editors + most powerful REGEXP syntax?

    - by John
    I am fluent with Microsoft Visual 2005 regular expressions and they are a big time saver. I seem to learn them best by having a vaguely organized cheat sheet thrown at me, at which point I read just a little and play with them until I understand what's going on. That learning approach has worked well for me, for now. I would really like to take this to the next level though. Basically -- What is the REGEXP convention that is generally regarded as the most open-ended and powerful? VS2005 Regexps seem kind of gimped, so maybe I'm a kid playing in a sandbox. Are there text editors out there that can perform a highlight all matches, list lines containing string, or some kind of powerful function like that in conjunction with the very strongest REGEXP language? If not I can just use multiple programs and a weird technique but I'd like to avoid that. I wonder if a stronger REGEXP language or a "stronger" regEXP writer might be able to have his search match all results on all lines even by clicking a "find next" by adding some simple criteria to the search. Anyway, please provide advice!

    Read the article

  • C# Linq Select Problem in Method Chain.

    - by Gnought
    Note that the _src inherit IQueryable<U> and V inherit new(); I wrote the following statement, there is no syntax error. IQueryable<V> a = from s in _src where (s.Right - 1 == s.Left) select new V(); But if i re-wrote it as follows, the Visual Studio editor complains an error in the "Select" IQueryable<V> d = _src.Where(s => s.Right - 1 == s.Left).Select(s=> new V()); The Error is: The type arguments cannot be inferred from the usage. Try specifying the type arguments explicitly. Candidates are: System.Collections.Generic.IEnumerable<V> Select<U,V>(this System.Collections.Generic.IEnumerable<U>, System.Func<U,V>) (in class Enumerable) System.Linq.IQueryable<V> Select<U,V>(this System.Linq.IQueryable<U>, System.Linq.Expressions.Expression<System.Func<U,V>>) (in class Queryable) Could anyone explain this phenomenon, and what the solution is to fix the error?

    Read the article

  • ForEach loop in Mathematica.

    - by dreeves
    I'd like something like this: ForEach[i_, {1,2,3}, Print[i] ] Or, more generally, to destructure arbitrary stuff in the list you're looping over, like: ForEach[{i_, j_}, {{1,10}, {2,20}, {3,30}}, Print[i*j] ] (Meta-question: is that a good way to call a ForEach loop, with the first argument a pattern like that?) ADDED: Some answerers have rightly pointed out that usually you want to use Map or other purely functional constructs and eschew a non-functional programming style where you use side effects. I agree! But here's an example where I think this ForEach construct is supremely useful: Say I have a list of options (rules) that pair symbols with expressions, like attrVals = {a -> 7, b -> 8, c -> 9} Now I want to make a hash table where I do the obvious mapping of those symbols to those numbers. I don't think there's a cleaner way to do that than ForEach[a_ -> v_, attrVals, h[a] = v] ADDED: I just realized that to do ForEach properly, it should support Break[] and Continue[]. I'm not sure how to implement that. Perhaps it will need to somehow be implemented in terms of For, While, or Do since those are the only loop constructs that support Break[] and Continue[]. If anyone interested in this wants to ask about that as a separate question, please do!

    Read the article

  • Basic user authentication with records in AngularFire

    - by ajkochanowicz
    Having spent literally days trying the different, various recommended ways to do this, I've landed on what I think is the most simple and promising. Also thanks to the kind gents from this SO question: Get the index ID of an item in Firebase AngularFire Curent setup Users can log in with email and social networks, so when they create a record, it saves the userId as a sort of foreign key. Good so far. But I want to create a rule so twitter2934392 cannot read facebook63203497's records. Off to the security panel Match the IDs on the backend Unfortunately, the docs are inconsistent with the method from is firebase user id unique per provider (facebook, twitter, password) which suggest appending the social network to the ID. The docs expect you to create a different rule for each of the login method's ids. Why anyone using 1 login method would want to do that is beyond me. (From: https://www.firebase.com/docs/security/rule-expressions/auth.html) So I'll try to match the concatenated auth.provider with auth.id to the record in userId for the respective registry item. According to the API, this should be as easy as In my case using $registry instead of $user of course. { "rules": { ".read": true, ".write": true, "registry": { "$registry": { ".read": "$registry == auth.id" } } } } But that won't work, because (see the first image above), AngularFire sets each record under an index value. In the image above, it's 0. Here's where things get complicated. Also, I can't test anything in the simulator, as I cannot edit {some: 'json'} To even authenticate. The input box rejects any input. My best guess is the following. { "rules": { ".write": true, "registry": { "$registry": { ".read": "data.child('userId').val() == (auth.provider + auth.id)" } } } } Which both throws authentication errors and simultaneously grants full read access to all users. I'm losing my mind. What am I supposed to do here?

    Read the article

  • Project Naming Convention Feedback Please

    - by Sam Striano
    I am creating a ASP.NET MVC 3 application using Entity Framework 4. I am using the Repository/Service Pattern and was looking for feedback. I currently have the following: MVC Application (GTG.dll) GTG GTG.Controllers GTG.ViewModels Business POCO's (GTG.Business.dll) This contains all business objects (Customer, Order, Invoice, etc...) EF Model/Repositories (GTG.Data.dll) GTG.Business (GTG.Context.tt) I used the Entity POCO Generator Templates. GTG.Data.Repositories Service Layer (GTG.Data.Services.dll) GTG.Data.Services - Contains all of the service objects, one per aggregate root. The following is a little sample code: Controller Namespace Controllers Public Class HomeController Inherits System.Web.Mvc.Controller Function Index() As ActionResult Return View(New Models.HomeViewModel) End Function End Class End Namespace Model Namespace Models Public Class HomeViewModel Private _Service As CustomerService Public Property Customers As List(Of Customer) Public Sub New() _Service = New CustomerService _Customers = _Service.GetCustomersByBusinessName("Striano") End Sub End Class End Namespace Service Public Class CustomerService Private _Repository As ICustomerRepository Public Sub New() _Repository = New CustomerRepository End Sub Function GetCustomerByID(ByVal ID As Integer) As Customer Return _Repository.GetByID(ID) End Function Function GetCustomersByBusinessName(ByVal Name As String) As List(Of Customer) Return _Repository.Query(Function(x) x.CompanyName.StartsWith(Name)).ToList End Function End Class Repository Namespace Data.Repositories Public Class CustomerRepository Implements ICustomerRepository Public Sub Add(ByVal Entity As Business.Customer) Implements IRepository(Of Business.Customer).Add End Sub Public Sub Delete(ByVal Entity As Business.Customer) Implements IRepository(Of Business.Customer).Delete End Sub Public Function GetByID(ByVal ID As Integer) As Business.Customer Implements IRepository(Of Business.Customer).GetByID Using db As New GTGContainer Return db.Customers.FirstOrDefault(Function(x) x.ID = ID) End Using End Function Public Function Query(ByVal Predicate As System.Linq.Expressions.Expression(Of System.Func(Of Business.Customer, Boolean))) As System.Linq.IQueryable(Of Business.Customer) Implements IRepository(Of Business.Customer).Query Using db As New GTGContainer Return db.Customers.Where(Predicate) End Using End Function Public Sub Save(ByVal Entity As Business.Customer) Implements IRepository(Of Business.Customer).Save End Sub End Class End Namespace

    Read the article

  • Allowing Xform controls for optional XML elements

    - by Cam
    Hi, In designing an XForm interface to an XML database (using eXist and XSLTForms), I'd like to include an input control for an optional element. The XML data records already exist and while some contain the optional element, others don't. To update a record, I'm using the existing XML record as the model instance. The problem is that the form control is not displayed when the optional element is not present, which is logical, but presents a problem when a user wants to add data to the optional element. To be more explicit, here's an example data record, data.xml: <a> <b>content</b> </a> with RNC schema: start = element a { element b { text }, element notes { text }? } XForms model: <xf:model> <xf:instance xmlns="" src="data.xml"/> <xf:submission id="save" method="post" action="update.xq" /> </xf:model> And control: <xf:input ref="/a/notes"> <xf:label>Notes (optional): </xf:label> </xf:input> The problem is that the 'Notes' input control is simply not displayed. An obvious solution is to add a trigger button to allow the user to insert the element if needed, but it is preferable to just have the input control appear, and be empty. My question is: is there some subtle combination of lesser-know attributes/binds/multiple instances/xpath expressions that will cause the control to always be displayed? Thanks

    Read the article

  • Localization of DisplayNameAttribute

    - by PowerKiKi
    Hi, I am looking for a way to localize properties names displayed in a PropertyGrid. The property's name may be "overriden" using the DisplayNameAttribute attribute. Unfortunately attributes can not have non constant expressions. So I can not use strongly typed resources such as: class Foo { [DisplayAttribute(Resources.MyPropertyNameLocalized)] // do not compile string MyProperty {get; set;} } I had a look around and found some suggestion to inherit from DisplayNameAttribute to be able to use resource. I would end up up with code like: class Foo { [MyLocalizedDisplayAttribute("MyPropertyNameLocalized")] // not strongly typed string MyProperty {get; set;} } However I lose strongly typed resource benefits which is definitely not a good thing. Then I came across DisplayNameResourceAttribute which may be what I'm looking for. But it's supposed to be in Microsoft.VisualStudio.Modeling.Design namespace and I can't find what reference I am supposed to add for this namespace. Anybody know if there's a easier way to achieve DisplayName localization in a good way ? or if there is as way to use what Microsoft seems to be using for Visual Studio ?

    Read the article

  • Is there a more concise regular expression to accomplish this task?

    - by mpminnich
    First off, sorry for the lame title, but I couldn't think of a better one. I need to test a password to ensure the following: Passwords must contain at least 3 of the following: upper case letters lower case letters numbers special characters Here's what I've come up with (it works, but I'm wondering if there is a better way to do this): Dim lowerCase As New Regex("[a-z]") Dim upperCase As New Regex("[A-Z]") Dim numbers As New Regex("\d") Dim special As New Regex("[\\\.\+\*\?\^\$\[\]\(\)\|\{\}\/\'\#]") Dim count As Int16 = 0 If Not lowerCase.IsMatch(txtUpdatepass.Text) Then count += 1 End If If Not upperCase.IsMatch(txtUpdatepass.Text) Then count += 1 End If If Not numbers.IsMatch(txtUpdatepass.Text) Then count += 1 End If If Not special.IsMatch(txtUpdatepass.Text) Then count += 1 End If If at least 3 of the criteria have not been met, I handle it. I'm not well versed in regular expressions and have been reading numerous tutorials on the web. Is there a way to combine all 4 regexes into one? But I guess doing that would not allow me to check if at least 3 of the criteria are met. On a side note, is there a site that has an exhaustive list of all characters that would need to be escaped in the regex (those that have special meaning - eg. $, ^, etc.)? As always, TIA. I can't express enough how awesome I think this site is.

    Read the article

< Previous Page | 72 73 74 75 76 77 78 79 80 81 82 83  | Next Page >