Search Results

Search found 2819 results on 113 pages for 'conditional expressions'.

Page 71/113 | < Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >

  • DataMining / Analyzing responses to Multiple Choice Questions in a survey

    - by Shailesh Tainwala
    Hi, I have a set of training data consisting of 20 multiple choice questions (A/B/C/D) answered by a hundred respondents. The answers are purely categorical and cannot be scaled to numerical values. 50 of these respondents were selected for free product trial. The selection process is not known. What interesting knowledge can be mined from this information? The following is a list of what I have come up with so far- A study of percentages (Example - Percentage of people who answered B on Qs.5 and got selected for free product trial) Conditional probabilities (Example - What is the probability that a person will get selected for free product trial given that he answered B on Qs.5) Naive Bayesian classifier (This can be used to predict whether a person will be selected or not for a given set of values for any subset of questions). Can you think of any other interesting analysis or data-mining activities that can be performed? The usual suspects like correlation can be eliminated as the response is not quantifiable/scoreable. Is my approach correct?

    Read the article

  • Logging strategy vs. performance

    - by vtortola
    Hi, I'm developing a web application that has to support lots of simultaneous requests, and I'd like to keep it fast enough. I have now to implement a logging strategy, I'm gonna use log4net, but ... what and how should I log? I mean: How logging impacts in performance? is it possible/recomendable logging using async calls? Is better use a text file or a database? Is it possible to do it conditional? for example, default log to the database, and if it fails, the switch to a text file. What about multithreading? should I care about synchronization when I use log4net? or it's thread safe out of the box? In the requirements appear that the application should cache a couple of things per request, and I'm afraid of the performance impact of that. Cheers.

    Read the article

  • Java - short and casting

    - by chr1s
    Hi all, I have the following code snippet. public static void main(String[] args) { short a = 4; short b = 5; short c = 5 + 4; short d = a; short e = a + b; // does not compile (expression treated as int) short z = 32767; short z_ = 32768; // does not compile (out of range) test(a); test(7); // does not compile (not applicable for arg int) } public static void test(short x) { } Is the following summary correct (with regard to only the example above using short)? direct initializations without casting is only possible using literals or single variables (as long as the value is in the range of the declared type) if the rhs of an assignment deals with expressions using variables, casting is necessary But why exactly do I need to cast the argument of the second method call taking into account the previous summary?

    Read the article

  • What is the right way to initialize a constant in Ruby?

    - by zbrimhall
    I have a simple class that defines some constants, e.g.: module Foo class Bar BAZ = "bof" ... Everything is puppies and rainbows until I tell Rake to run all my Test::Unit tests. When it does, I get warnings: bar.rb:3: warning: already initialized constant BAZ My habit has been to avoid these warnings by making the constant initialization conditional, e.g.: ... BAZ = "bof" unless const_defined? :BAZ ... This seems to solve the problem, but it is a little tedious, and I don't ever see anyone else initializing constants this way. This makes me think I might be Doing It Wrong. Is there a better way to initialize constants that won't generate warnings?

    Read the article

  • Library to parse ERB files

    - by Douglas Sellers
    I am attempting to parse, not evaluate, rails ERB files in a Hpricot/Nokogiri type manner. The files I am attempting to parse contain HTML fragments intermixed with dynamic content generated using ERB (standard rails view files) I am looking for a library that will not only parse the surrounding content, much the way that Hpricot or Nokogiri will but will also treat the ERB symbols, <%, <%= etc, as though they were html/xml tags. Ideally I would get back a DOM like structure where the <%, <%= etc symbols would be included as their own node types. I know that it is possible to hack something together using regular expressions but I was looking for something a bit more reliable as I am developing a tool that I need to run on a very large view code base where both the html content and the erb content are important. For example, content such as: blah blah blah <divMy Great Text <%= my_dynamic_expression %</div Would return a tree structure like: root - text_node (blah blah blah) - element (div) - text_node (My Great Text ) - erb_node (<%=)

    Read the article

  • Boolean Expression Evaluation in Java

    - by Trilok
    Hey everyone, Is there a relatively simpler (when compared with writing a parser) way to evaluate boolean expressions in Java? I do not want to use the JEP library. I have a String expression something like: (x 4 || x < 8 && p 6) [ I will replace the variables with values. Is there a way by which I can evaluate this expression? The problem is, this can be any level deep. So, writing a parser would be really complex. Thanks

    Read the article

  • Prevent SQL injection from form-generated SQL - NO PreparedStmts

    - by Markos Fragkakis
    Hi all, I have a search table where user will be able to filter results with a filter of the type: Field [Name], Value [John], Remove Rule Field [Surname], Value [Blake], Remove Rule Field [Has Children], Value [Yes], Remove Rule Add Rule So the user will be able to set an arbitrary set of filters, which will result essentially in a completely dynamic WHERE clause. In the future I will also have to implement more complicated logical expressions, like Where (name=John OR name=Nick) AND (surname=Blake OR surname=Bourne), Of all 10 fields the user may or may not filter by, I don't know how many and which filters the user will set. So, I cannot use a prepared statement (which assumes that at least we know the fields in the WHERE clause). This is why prepared statements are unfortunately out of the question, I have to do it with plain old, generated SQL. What measures can I take to protect the application from SQL Injection (REGEX-wise or any other way)?

    Read the article

  • How do I insert into a unique key into a table?

    - by Ben McCormack
    I want to insert data into a table where I don't know the next unique key that I need. I'm not sure how to format my INSERT query so that the value of the Key field is 1 greater than the maximum value for the key in the table. I know this is a hack, but I'm just running a quick test against a database and need to make sure I always send over a Unique key. Here's the SQL I have so far: INSERT INTO [CMS2000].[dbo].[aDataTypesTest] ([KeyFld] ,[Int1]) VALUES ((SELECT Max([KeyFld]) FROM [dbo].[aDataTypesTest]) + 1 ,1) which errors out with: Msg 1046, Level 15, State 1, Line 5 Subqueries are not allowed in this context. Only scalar expressions are allowed. I'm not able to modify the underlying database table. What do I need to do to ensure a unique insert in my INSERT SQL code?

    Read the article

  • What useful GDB scripts have you used/written?

    - by nik
    People use gdb on and off for debugging, of course there are lots of other debugging tools across the varied OSes, with and without GUI and, maybe other fancy IDE features. I would like to know what useful gdb scripts you have written and liked. While, I do not mean a dump of commands in a something.gdb file that you source to pull out a bunch of data, if that made your day, go ahead and talk about it. Lets think conditional processing, control loops and functions written for more elegant and refined programming to debug and, maybe even for whitebox testing Things get interesting when you start debugging remote systems (say, over a serial/ethernet interface) And, what if the target is a multi-processor (and, multithreaded) system Let me put a simple case as an example... Say, A script that traversed serially over entries to locate a bad entry in a large hash-table that is implemented on an embedded platform. That helped me debug a broken hash-table once.

    Read the article

  • Are preprocessors obsolete in modern languages?

    - by Earlz
    Hello, I'm making a simple compiler for a simple pet language I'm creating and coming from a C background(though I'm writing it in Ruby) I wondered if a preprocessor is necessary. What do you think? Is a "dumb" preprocessor still necessary in modern languages? Would C#'s conditional compilation capabilities be considered a "preprocessor"? Does every modern language that doesn't include a preprocessor have the utilities necessary to properly replace it? (for instance, the C++ preprocessor is now mostly obsolete(though still depended upon) because of templates.)

    Read the article

  • Efficiently Combine MatchCollections in .Net Regex

    - by Laramie
    In the simplified example, there are 2 Regular Expressions, one case sensitive, the other not. The idea would be to efficiently create an IEnumerable collection (see "combined" below) combining the results. string test = "abcABC"; string regex = "(?<grpa>a)|(?<grpb>b)|(?<grpc>c)]"; Regex regNoCase = new Regex(regex, RegexOptions.IgnoreCase); Regex regCase = new Regex(regex); MatchCollection matchNoCase = regNoCase.Matches(test); MatchCollection matchCase = regCase.Matches(test); //Combine matchNoCase and matchCase into an IEnumerable IEnumerable<Match> combined= null; foreach (Match match in combined) { //Use the Index and (successful) Groups properties //of the match in another operation } In practice, the MatchCollections might contain thousands of results and be run frequently using long dynamically created REGEXes, so I'd like to shy away from copying the results to arrays, etc. I am still learning LINQ and am fuzzy on how to go about combining these or what the performance hits to an already sluggish process will be.

    Read the article

  • Slug ID's with the same name?

    - by James Jeffery
    I want to create slug URL's from a users title in my system. If a user types "The best way's to get slim; period!", then I want the slug to be "the-best-ways-to-get-slim-period". Also, if someone has already created a page with that title I want the slug to be "the-best-ways-to-get-slim-period-1". My question is how can I check the database before a record is created? Ok, obviously I am going to have to perform a check in the database, and then a write. That's 2 queries. Is this the normal way to do it? Also, are there any conventional regular expressions for filtering non alpha/number characters and replacing spaces with hyphens? Any help is much appreciated. Thanks.

    Read the article

  • Using IIRF to redirect to a PDF

    - by Michael Itzoe
    I'm using IIRF to redirect certain URLs to specific PDF files. For instance, for the URL /newsletter/2010/02 I'd like it to redirect to /pdf/newsletters/Feb2010.pdf. I'm not too hot at regular expressions, but I created the following rule: RedirectRule ^/newsletter/2010/01 /pdf/newsletters/Newsletter012010.pdf [I,R=301] and it does redirect, but the address bar doesn't change, and when trying to save the file it wants to save as 01 instead of Feb2010.pdf. I don't presume my users will be savvy enough to enter a PDF extension before saving, and they shouldn't have to. Is there anything I can do about this?

    Read the article

  • Probability Homework Help

    - by Alon
    A child is tasting two types of chocolate. The probability that he will like the first type if he liked the second type is 5/6. The probability that he will like the second type if he liked the first type is 3/8. It is known that the probability that the child won't like the second type of chocolate is doubled than the probability that he won't like the first type. What is the probability that the child like at least one of the two type of chocolates? So I tried: 1-[P(not like the first type AND not like the second type)] which is like: 1-[P(not like the first type)*P(not like first type / not like the second type) + P(not like the second type) which equals: P(not like first type / not like second type) But now, I don't have the data of the conditional probability. In addition, I'd like to see how could it solved using a computer programming language. Any ideas? Thank you.

    Read the article

  • Dynamic query runs directly but not through variable, what could be the reason?

    - by waheed
    Here is my scenario, I'm creating a dynamic query using a select statement which uses functions to generate the query. I am storing it into a variable and running it using exec. i.e. declare @dsql nvarchar(max) set @dsql = '' select @dsql = @dsql + dbo.getDynmicQuery(column1, column2) from Table1 exec(@dsql) Now it produces the many errors in this scenario, like 'Incorrect syntax near ','' and 'Case expressions may only be nested to level 10.' But if i take the text from @dsql and assign it a variable manually like: declare @dsql nvarchar(max) set @dsql = '' set @dsql = N'<Dynamic query text>' exec(@dsql) it runs and generates the result, what could be the reason for that ?? Thanks..

    Read the article

  • Nullable Enum nullable type question

    - by Michael Kniskern
    I get the following compilation error with the following source code: Compilation Error: Type of conditional expression cannot be determined because there is no implicit conversion between '' and 'MyEnum' Source Code public enum MyEnum { Value1, Value2, Value3 } public class MyClass { public MyClass() {} public MyEnum? MyClassEnum { get; set; } } public class Main() { object x = new object(); MyClass mc = new MyClass() { MyClassEnum = Convert.IsDBNull(x) : null ? (MyEnum) Enum.Parse(typeof(MyEnum), x.ToString(), true) }; } How can I resolve this error?

    Read the article

  • Extract / Parse Tags from Mixed Content String

    - by Andreas
    Hello, i want to parse Tags from a mixed Content String. The string goes like this: "<PERSON>yasir arafat</PERSON> , the president of the <LOCATION>palestinian authority</LOCATION> , on the defensive , mr . sharon believes , a government official" I only want to use jaxp. Got anybody an idea for this. May an easy way with Expressions. But i need the Element names as well though. Best Regards Andreas

    Read the article

  • Finding the maximum number of child nodes in a tree

    - by Jiminizer
    First, I should make it clear that this is required for an academic project. I am trying to find the maximum number of child nodes for any node in a tree, using Common Lisp. My current code is shown below - I'm not 100% on the logic of it, but I feel it should work, however it isn't giving me the required result. (defun breadth (list y) (setf l y) (mapcar #'(lambda (element) (when (listp element) (when (> (breadth element (length element)) l) (setf l (breadth element (length element))) ))) list) l) (defun max-breadth(list) (breadth list (length list)) ) As an example, running (max-breadth '(a ( (b (c d)) e) (f g (h i) j))) should return 4. Does anyone have any ideas where I'm going wrong? I suspect it's related to the second conditional, but I'm not sure.

    Read the article

  • WPF - Handling a RoutedEvent in the parent for a specfic control instance

    - by empo
    In my user control I have several textboxes e.g. Textbox1, Textbox2. In the parent I only want to handle KeyDown events raised from Textbox1, not all Textbox I have added a handler in the parent this.AddHandler(TextBox.KeyDownEvent, new RoutedEventHandler(OnTextboxGoToPageKeyDown)); but of course this will handle all KeyDown events which I don't want. Do I have to add some conditional logic in the RoutedEventHandler to check where the event was raised from? or is there a better way? What's the best way to do this? Thanks.

    Read the article

  • Facebook API - Get comments

    - by Simon R
    Our business has a Facebook Fan Page. The fan page doesn't seem to generate any emails to us when updates are made to the page, whether someone adds a new status or someone comments on one of the statuses etc. Currently, we are running a very crude script to grab the content of the page and then use regular expressions to get the information we require. Obviously this is not fool proof and I'm looking into alternatives to this method. I've been looking at the facebook API and wonder if the rest server might be an option. I cannot, however, seem to find out how to return information of fan page statuses and their comments. Is anyone able to direct me how to use the API to retrieve this information. I am an admin of the fan page. The programming language I'm using is PHP. Many thanks.

    Read the article

  • how to strip namespaces with e4x?

    - by SorcyCat
    I have an arbitrary XML document provided by a URL. I also have an xpath-like expressions. var xml = <doc><node1><node2><node3>some value</node3></node2></node1></doc>; var path = "node1.node2.node3"; I need to verify if the above path into the XML is valid. I tried to do this using eval and E4X. var value = eval("xml."+path); However, my actual xml document has namespaces which are getting in the way. I do not know the namespaces ahead of time or care what they are. Is there a way to strip all the namespaces out ahead of time? Is there a better way to do this? Thanks!

    Read the article

  • NHibernate ICriteria with a bag

    - by plunk
    Hi, Just a quick question. If I've got 2 tables that are joined in a 3rd table with a many-to-many relationship, is it possible to write an ICriteria with expressions in one of the tables and the join table? Lets say the mapping file looks something like: <bag name ="Bag" table="JoinTable" cascade ="none"> <key column="Data_ID"/> <many-to-many class="Data2" column="Data2_ID"/> </bag> Is it then possible to write an ICriteria like the following? ICriteria crit = session.CreateCriteria(typeof(Data)); crit.Add(Expression.Eq("Name", name)); crit.Add(Expression.Between("Date", startDate, endDate)); crit.Add(Expression.Eq("Bag", data2IDNumber)); When I try this, it tells me I the expected type is IList, whereas the actual type is Bag. Thanks.

    Read the article

  • php regex expression to get title

    - by 55skidoo
    I'm trying to strip content titles out of the middle of text strings. Could I use regex to strip everything out of this string except for the title (in italics) in these strings? Or is there a better way? Joe User wrote a blog post called The 10 Best Regex Expressions in the category Regex. Jane User wrote a blog post called Regex is Hard! in the category TechProblems. I've tried to come up with a regex expression to cover this, but I think it might need two. The trick is that the text in bold is always the same, so you could search for that, like this: regex: delete everything before and including wrote a blog post called regex: delete in the category and everything after it.

    Read the article

  • htaccess redirect from root to subfolder and then mask the url?

    - by KiwiCoder
    Hello all, Two things: Firstly - I have version 2 of a website located in a folder named v2, and I want to redirect any traffic that is NOT a child of the v2 folder, to www.example.com/v2 The old site located in the root was created in iWeb and has a LOT of subfolders and sub-subfolders. So: www.example.com/v2 = New site www.example.com/Page.html www.example.com/category/Page.html ww.example.com/category/subcategory/Page.html = All generic examples of what I need to redirect. Secondly, and I don't know if this is possible, I want to hide /v2/ in the URL, so that visitors will just see www.example.com/page even though they are actually on www.example.com/v2/page Links are hardcoded to the v2 folder, like so <a href="v2/contact.html" Any help is MOST appreciated. I've spent hours trying to figure this out, but I'm only just learning about htaccess and regular expressions, and am totally confused. Thanks so much!

    Read the article

  • Stochastic calculus library in python

    - by LeMiz
    Hello, I am looking for a python library that would allow me to compute stochastic calculus stuff, like the (conditional) expectation of a random process I would define the diffusion. I had a look a at simpy (simpy.sourceforge.net), but it does not seem to cover my needs. This is for quick prototyping and experimentation. In java, I used with some success the (now inactive) http://martingale.berlios.de/Martingale.html library. The problem is not difficult in itself, but there is a lot non trivial, boilerplate things to do (efficient memory use, variable reduction techniques, and so on). Ideally, I would be able to write something like this (just illustrative): def my_diffusion(t, dt, past_values, world, **kwargs): W1, W2 = world.correlated_brownians_pair(correlation=kwargs['rho']) X = past_values[-1] sigma_1 = kwargs['sigma1'] sigma_2 = kwargs['sigma2'] dX = kwargs['mu'] * X * dt + sigma_1 * W1 * X * math.sqrt(dt) + sigma_2 * W2 * X * X * math.sqrt(dt) return X + dX X = RandomProcess(diffusion=my_diffusion, x0 = 1.0) print X.expectancy(T=252, dt = 1./252., N_simul= 50000, world=World(random_generator='sobol'), sigma1 = 0.3, sigma2 = 0.01, rho=-0.1) Does someone knows of something else than reimplementing it in numpy for example ?

    Read the article

< Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >