Search Results

Search found 734 results on 30 pages for 'yield'.

Page 16/30 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • JavaScript multithreading

    - by Krzysztof Hasinski
    I'm working on comparison for several different methods of implementing (real or fake) multithreading in JavaScript. As far as I know only webworkers and Google Gears WorkerPool can give you real threads (ie. spread across multiple processors with real parallel execution). I've found the following methods: switch between tasks using yield() use setInterval() (or other non-blocking function) with threads waiting one for another use Google Gears WorkerPool threads (with plugin) use html5 web workers I read related questions and found several variations of the above methods, but most of those questions are old, so there might be a few new ideas. I'm wondering - how else can you achieve multithreading in JavaScript? Any other important methods? UPDATE: As pointed out in comments what I really meant was concurrency. UPDATE 2: I found information that Silverlight + JScript supports multithreading, but I'm unable to verify this. UPDATE 3: Google deprecated Gears: http://code.google.com/apis/gears/api_workerpool.html

    Read the article

  • Tomcat blankpage for default error page

    - by praspa
    First off, I'm using Tomcat 5.5 and my .jsp's live in /webapps/foo/bar/*.jsp. I followed the directions here to set up a default 404 error page. In my TOMCAT_HOME/conf/web.xml I entered: <error-page> <error-code>404</error-code> <location>/error.html</location> </error-page> I dropped copies of a test error.html file into each of the dirs (I wasn't sure where /error.html was referring to): /webapps/ /webapps/foo/ /webapps/foo/bar/ Whenever I attempt to access a non-existent page in a browser at url's /foo/missingpage.html or /foo/bar/missingpage.html I'm redirected to my error page that exists in /foo/error.html. However, attempting to access a non-existent page in a browser at url /missingpage.html yields a blankpage. Or any permutation of /missingDir/missingfile.html will also yield a blank page. Any suggestions? Am I missing some extra configuration? Thanks PR

    Read the article

  • Having difficulty in mapreduce to understand

    - by mahesh
    Hi all, I have seen the below link which is of getting started mapreduce with python http://code.google.com/p/appengine-mapreduce/wiki/GettingStartedInPython But still I am not able to understand how its working. I am executing below code but not able to understand what exactly is happening? mapreduce.yaml mapreduce: - name: Testmapper mapper: input_reader: mapreduce.input_readers.DatastoreInputReader handler: main.process params: - name: entity_kind default: main.userDetail mapreduce/main.py #some code class userDetail(db.Model): name = db.StringProperty() #some code def process(u): u.name="mahesh" yield op.db.Put(u) I am executing this and it gives me status = success in status page. But not able to understand what happend The main thing I want do with mapreduce is to search or count records from entity So anyone can please help me?? Thanks in advance

    Read the article

  • When is JavaScript's eval() not evil?

    - by Richard Turner
    I'm writing some JavaScript to parse user-entered functions (for spreadsheet-like functionality). Having parsed the formula I could convert it into JavaScript and run eval() on it to yield the result. However, I've always shied away from using eval() if I can avoid it because it's evil (and, rightly or wrongly, I've always thought it is even more evil in JavaScript because the code to be evaluated might be changed by the user). Obviously one has to use eval() to parse JSON (I presume that JS libraries use eval() for this somewhere, even if they run the JSON through a regex check first), but when else, other than when manipulating JSON, it is OK to use eval()?

    Read the article

  • Optimizing a Soundex Query for finding similar names

    - by xkingpin
    My application will offer a list of suggestions for English names that "sound like" a given typed name. The query will need to be optimized and return results as quick as possible. Which option would be most optimal for returning results quickly. (Or your own suggestion if you have one) A. Generate the Soundex Hash and store it in the "Names" table then do something like the following: (This saves generating the soundex hash for at least every row in my db per query right?) select name from names where NameSoundex = Soundex('Ann') B. Use the Difference function (This must generate the soundex for every name in the table?) select name from names where Difference(name, 'Ann') = 3 C. Simple comparison select name from names where Soundex(name) = Soundex('Ann') Option A seems like to me it would be the fastest to return results because it only generates the Soundex for one string then compares to an indexed column "NameSoundex" Option B should give more results than option A because the name does not have to be an exact match of the soundex, but could be slower Assuming my table could contain millions of rows, what would yield the best results?

    Read the article

  • Including inline javascript using content_for in rails

    - by TenJack
    I am using content_for and yeild to inject javascript files into the bottom of my layout but am wondering what the best practice is for including inline javascript. Specifically I'm wondering where the put the script type declaration: <% content_for :javascript do %> <script type="text/javascript"> ... </script> <% end %> or <% content_for :javascript do %> ... <% end %> <script type="text/javascript"> <%= yield :javascript %> </script> <% end %> I am using the first option now and wondering if it is bad to include multiple ... declarations within one view. Sometimes I have partials that lead to this.

    Read the article

  • Anybody know why the Output of this program is like this?(using iterator in c#)

    - by Babu
    using System; using System.Collections; namespace Iterator_test { class Day { int days_idx = -1; private String[] days = { "mon", "tue", "wed","thu","fri","sat","sun" }; public IEnumerable getdays() { days_idx++; yield return days[days_idx]; } } class Program { static void Main(string[] args) { Day d = new Day(); foreach (string day in d.getdays()) { Console.WriteLine(day); } } } } Actually the output should be, mon tue wed thu fri sat sun but its printing only "mon" as, mon What will be the reason?

    Read the article

  • Ruby Metaprogramming

    - by VP
    I'm trying to write a DSL that allows me to do Policy.name do author "Foo" reviewed_by "Bar" end The following code can almost process it: class Policy include Singleton def self.method_missing(name,&block) puts name puts "#{yield}" end def self.author(name) puts name end def self.reviewed_by(name) puts name end end Defining my method as class methods (self.method_name) i can access it using the following syntax: Policy.name do Policy.author "Foo" Policy.reviewed_by "Bar" end If i remove the "self" from the method names, and try to use my desired syntax, then i receive an error "Method not Found" in the Main so it could not find my function until the module Kernel. Its ok, i understand the error. But how can i fix it? How can i fix my class to make it work with my desired syntax that?

    Read the article

  • SQL syntax error

    - by Robert
    Im using Microsoft SQL Server which I think is T-SQL or ANSI SQL. I want to search a database with a string. The matches that fit the begging of the string should come first then sort alphabetically. I.e. If the table contains FOO, BAR and RAP a search for the string 'R' should yield: RAP BAR In that order. Here is my attempt: SELECT Name FROM MyTable WHERE (Name LIKE '%' + @name + '%') ORDER BY (IF(Name LIKE @name + '%',1,0)) The error message is: "must declare scalar variable @name"

    Read the article

  • Where am I going wrong? "undefined method 'application' for Sinatra:Module" Sinatra/Passenger/Apache

    - by safetycopy
    Hi, I'm trying to get my first Sinatra app off the ground, but am getting an error page from Passenger: undefined method `application' for Sinatra:Module Here's my Rackup file: require 'rubygems' require 'sinatra' set :env, :production disable :run require 'app' run Sinatra.application And the app itself: #!/usr/bin/env ruby require 'rubygems' require 'sinatra' require 'haml' get '/' do haml :index end get '/hello/:name' do |name| @name = name haml :hello end get '/goodbye/:name' do |name| haml :goodbye, :locals => {:name => name} end __END__ @@layout %html %head %title hello.dev %body =yield @@index #header %h1 hello.dev #content %p This is a test... @@hello %h1= "Hello #{@name}!" @@goodbye %h1= "Goodbye #{name}!" Where am I going wrong?

    Read the article

  • Finding the best folder for all users on a Windows machine

    - by reallyjoel
    We are making a game which will add a level editor feature soon. We want the user to be able to put levels he's downloaded in a folder and then play it in the game, without any hassle. So, we're looking for a folder that anybody can find, open, write, read, and is multiuser. On Windows Vista / 7, the folder /Users/Public/ look like a great candidate. However, It's not listed in the .net enum System.Environment.SpecialFolder. I have went through them all, and checked what they yield on different Windows versions, and none live up to my requirements. I did find Environment.SpecialFolder.CommonApplicationData, that kinda works, but that folder is hidden (C:\ProgramData) and I assume most users don't display hidden folders. As it stands now, it looks like we'll have to settle for the personal documents folder, but we'd really like a multi user folder? Anyone have any tips? (Hard coding c:\Users\Public\ is out of the question, it will only work on english systems)

    Read the article

  • Defining a dd/mm/yyyy field within an abstract table model

    - by Simon Andi
    I have defined an abstract table model but one of the columns should house date values as dd/mm/yyyy format not sure how to do this. I have a external global file and have hard coded the dates as dd/mm/yyyy. How can I define this column within my abstract table model so that to only allow only dates having dd/mm/yyyy format. public class OptraderGlobalParameters { public static boolean DEBUG = true; //Set DEBUG = true for Debugging /*=========================*/ /*Table Array For Dividends*/ /*=========================*/ public static String[] columnNames = {"Date", "Dividend", "Actual", "Yield (%)" }; public static Object[][] data = { {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, }; }

    Read the article

  • Using xsl:key to store result of boolean expression

    - by hielsnoppe
    In my transformation there is an expression some elements are repeatedly tested against. To reduce redundancy I'd like to encapsulate this in an xsl:key like this (not working): <xsl:key name="td-is-empty" match="td" use="not(./node()[normalize-space(.) or ./node()])" /> The expected behaviour is the key to yield a boolean value of true in case the expression is evaluated successfully and otherwise false. Then I'd like to use it as follows: <xsl:template match="td[not(key('td-is-empty', .))]" /> Is this possible and in case yes, how?

    Read the article

  • C#: standard Windows menu bars in Windows Forms

    - by BoltClock
    I noticed that adding a MenuStrip (from the VS Toolbox) to my form design doesn't yield a menu bar like many native Windows applications. Instead I get a menu bar like VS's own. None of the style settings for MenuStrip appear to mimic the much more common native menu bar. Is there a way to add a menu bar to my Windows Forms application that looks the same as the one you see in Notepad, Task Manager, Windows Explorer and others? (Preferably with the designer, but I wouldn't mind adding it programmatically either.)

    Read the article

  • Continuous output in Neural Networks

    - by devoured elysium
    How can I set Neural Networks so they accept and output a continuous range of values instead of a discrete ones? From what I recall from doing a Neural Network class a couple of years ago, the activation function would be a sigmoid, which yields a value between 0 and 1. If I want my neural network to yield a real valued scalar, what should I do? I thought maybe if I wanted a value between 0 and 10 I could just multiply the value by 10? What if I have negative values? Is this what people usually do or is there any other way? What about the input? Thanks

    Read the article

  • How do I return the entire set / array using NSPredicate?

    - by Prairiedogg
    I'm building a carArray and want to filter the contents conditionally, using an NSPredicate, like so: NSPredicate *pred; switch (carType) { case FreeCar: pred = [NSPredicate predicateWithFormat:@"premium = NO"]; break; case PremiumCar: pred = [NSPredicate predicateWithFormat:@"premium = YES"]; break; default: pred = [NSPredicate predicateWithFormat:@"SOME PREDICATE THAT RETURNS EVERYTHING"]; break; } self.carArray = [aCarArrayIGotFromSomewhere filteredArrayUsingPredicate:pred]; My question is, what is the correct syntax for the value I've stubbed in as SOME PREDICATE THAT RETURNS EVERYTHING which returns all of the instances in the array / set? PS - I know the answer and will post it immediately, just sharing it for everyone's reference as an earlier search on SO did not yield the result.

    Read the article

  • GetProperties() to return all properties for an interface inheritance hierarchy

    - by sduplooy
    Assuming the following hypothetical inheritance hierarchy: public interface IA { int ID { get; set; } } public interface IB : IA { string Name { get; set; } } Using reflection and making the following call: typeof(IB).GetProperties(BindingFlags.Public | BindingFlags.Instance) will only yield the properties of interface IB, which is "Name". If we were to do a similar test on the following code, public abstract class A { public int ID { get; set; } } public class B : A { public string Name { get; set; } } the call typeof(B).GetProperties(BindingFlags.Public | BindingFlags.Instance) will return an array of PropertyInfo objects for "ID" and "Name". Is there an easy way to find all the properties in the inheritance hierarchy for interfaces as in the first example?

    Read the article

  • Are any of these quad-tree libraries any good?

    - by Noctis Skytower
    It appears that a certain project of mine will require the use of quad-trees, something that I have never worked with before. From what I have read they should allow substantial performance enhancements than a brute-force attempt at the problem would yield. Are any of these python modules any good? Quadtree 0.1.2 <= No: unable to execute in Python 3.1 QuadTree <= Yes: simple while working with rectangles quadtree.py <= No: no support for needed operations EDIT: Does anyone know of a better implementation that the one presented on the pygame wiki article?

    Read the article

  • Can Ruby Fibers be Concurrent?

    - by Jesse J
    I'm trying to get some speed up in my program and I've been told that Ruby Fibers are faster than threads and can take advantage of multiple cores. I've looked around, but I just can't find how to actually run different fibers concurrently. With threads you can dO this: threads = [] threads << Thread.new {Do something} threads << Thread.new {Do something} threads.each {|thread| thread.join} I can't see how to do something like this with fibers. All I can find is yield and resume which seems like just a bunch of starting and stopping between the fibers. Is there a way to do true concurrency with fibers?

    Read the article

  • Treat multiple IEnumerable objects as a single IEnumerable

    - by MainMa
    Hi, My question seems to be something easy, but I can't figure it out. Let's say I have a "root" IEnumerable of objects. Each object has IEnumerable of strings. How can I obtain a single IEnumerable of those strings? A possible solution is to do: public IEnumerable<string> DoExample() { foreach (var c in rootSetOfObjects) { foreach (var n in c.childSetOfStrings) { yield return n; } } } But maybe there is a magic solution with Linq?

    Read the article

  • Recreating a Dictionary from an IEnumerable

    - by learnerplates
    But some of the callers is the Dictionary's TryGetValue and ContainsKey and so require the result of the method to be a Dictionary, how can I convert the IEnumerable into a Dictionary so that I can use TryGetValue ? I've a method which at present returns an IEnumerable. I want to make it more generic by making it return an IEnumerable. method: public IEnumerable<KeyValuePair<string, ArrayList>> GetComponents() { // ... yield return new KeyValuePair<string, ArrayList>(t.Name, controlInformation); } caller: Dictionary<string, ArrayList> actual = target.GetComponents(); actual.ContainsKey("something");

    Read the article

  • Creating a context in custom shoulda macro does not work.

    - by Honza
    I have a custom should macro in my test_helper.rb which looks like this. def self.should_require_login(actions = [:index]) if (actions.is_a? Symbol) actions = [actions] end context "without user" do actions.each do |action| should "redirect #{action.to_s} away" do get action assert_redirected_to login_path end end end if block_given? context "active user logged in" do setup do @user = Factory.create(:user) @user.register! @user.activate! login_as(@user) end yield end end end I would like to use it like this: should_require_login(:protected_action) do should "do something" do ... end end And I am expecting the "do something" test to run in the "active user logged in" context, but the test executes in the top context, like the "active user logged in" context never existed and I fail to see the reason why.

    Read the article

  • What is the best algorithm to locate a point in an image file?

    - by suugaku
    Hi all, I want to create a mark sheet recognizer. Here is the description: My system uses black and white color scheme. The mark sheet paper has a small black rectangle on each corner and an additional small black rectangle, to determine orientation, near one of the previous rectangles. The paper is scanned to yield an image (in bmp format for example). The first step is to locate these five references in image as eficient as possible. My rough idea is to trace row by row and from left to right for each row. It sounds very slow I think. Is there any better way to do that? Thank you in advance. regards, Suugaku

    Read the article

  • Parallel Assignment operator in Ruby

    - by Bragaadeesh
    Hi, I was going through an example from Programming in Ruby book. This is that example def fib_up_to(max) i1, i2 = 1, 1 # parallel assignment (i1 = 1 and i2 = 1) while i1 <= max yield i1 i1, i2 = i2, i1+i2 end end fib_up_to(100) {|f| print f, " " } The above program simply prints the fibonacci numbers upto 100. Thats fine. My question here is when i replace the parallel assignment with something like this, i1 = i2 i2 = i1+i2 I am not getting the desired output. My question here is, is it advisable to use parallel assignments? (I come from Java background and it feels really wierd to see this type of assignment) One more doubt is : Is parallel assignment an operator?? Thanks

    Read the article

  • Commutative (operational transform) diffs for databases

    - by barrycarter
    What Unix program generates "diff"s between text files (or INSERT/UPDATE/DELETEs for databases) in such a way that the order that the "diff"s are applied in is irrelevant, and the result is the same regardless of order. Etherpad used to do something like this. Example (for a given document or database): % Adam makes a change X, then Bob makes a change Y, then Adam makes another change Z. % However, because of network latency, Adam sees the changes in this order: XZY, while Bob sees them in this order: YXZ. % However, the code/changes are written so that XYZ and YXZ yield the same result. Note: ideally, this can be done without having to do X/Y/Z inverse at any point. I have read http://stackoverflow.com/questions/2043165/operational-transformation-library but I'm not sure this really does what I want.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >