Search Results

Search found 1725 results on 69 pages for 'andrew stacey'.

Page 5/69 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to scan an array for certain information

    - by Andrew Martin
    I've been doing an MSc Software Development conversion course, the main language of which is Java, since the end of September. We have our first assessed practical coming and I was hoping for some guidance. We have to create an array that will store 100 integers (all of which are between 1 and 10), which are generated by a random number generator, and then print out ten numbers of this array per line. For the second part, we need to scan these integers, count up how often each number appears and store the results in a second array. I've done the first bit okay, but I'm confused about how to do the second. I have been looking through the scanner class to see if it has any methods which I could use, but I don't see any. Could anyone point me in the right direction - not the answer, but perhaps which library it comes from? Code so far: import java.util.Random; public class Practical4_Assessed { public static void main(String[] args) { Random numberGenerator = new Random (); int[] arrayOfGenerator = new int[100]; for (int countOfGenerator = 0; countOfGenerator < 100; countOfGenerator++) arrayOfGenerator[countOfGenerator] = numberGenerator.nextInt(10); int countOfNumbersOnLine = 0; for (int countOfOutput = 0; countOfOutput < 100; countOfOutput++) { if (countOfNumbersOnLine == 10) { System.out.println(""); countOfNumbersOnLine = 0; countOfOutput--; } else { System.out.print(arrayOfGenerator[countOfOutput] + " "); countOfNumbersOnLine++; } } } } Thanks, Andrew

    Read the article

  • facebook with openid

    - by Stacey
    Referencing http://stackoverflow.com/questions/1827997/is-facebook-an-openid-provider here. This is kind of an additional question based on it. I have also read the article at : http://stackoverflow.com/questions/2264266/what-is-the-openid-url-of-facebook - but I am still pretty confused on the whole ordeal. The goal is for people who use facebook to easily login to our website, not to neccessarily integrate with facebook and add things to it (yet). I have read the documentation on facebook connect and am still having trouble grasping exactly what we need to do to accomplish this. I notice that it says that facebook accepts openid logins - so in theory someone with a facebook account could login to a site that took other openid logins, correct? Or do I have to code a separate 'facebookconnect' system just to accept logins from facebook accounts?

    Read the article

  • Eclipse won't believe I have Maven 2.2.1

    - by Andrew Clegg
    I have a project (built from an AppFuse template) that requires Maven 2.2.1. So I upgraded to this (from 2.1.0) and set my path and my M2_HOME and MAVEN_HOME env variables. Then I ran mvn eclipse:eclipse and imported the project into Eclipse (Galileo). However, in the problems list for the project (and at the top of the pom.xml GUI editor) it says: Unable to build project '/export/people/clegg/data/GanymedeWorkspace/funcserve/pom.xml; it requires Maven version 2.2.1 (Please ignore 'GanymedeWorkspace', I really am using Galileo!) This persists whether I set Eclipse to use its Embedded Maven implementation, or the external 2.2.1 installation, in the Preferences - Maven - Installations dialog. I've tried closing and reopening the project, reindexing the repository, cleaning the project, restarting the IDE, logging out and back in again, everything I can think of! But Eclipse still won't believe I have Maven 2.2.1. I just did a plugin update so I have the latest version of Maven Integration for Eclipse -- 0.9.8.200905041414. Does anyone know how to convince Eclipse I really do have the right version of Maven? It's like it's recorded the previous version somewhere else and won't pay any attention to my changes :-( Many thanks! Andrew.

    Read the article

  • Get all but first from an array

    - by Stacey
    Is there a one-line easy linq expression to just get everything from a simple array except the first element? for (int i = 1; i <= contents.Length - 1; i++) Message += contents[i]; I just wanted to see if it was easier to condense.

    Read the article

  • git doesn't show where code was removed.

    - by Andrew Myers
    So I was tasked at replacing some dummy code that our project requires for historical compatibility reasons but has mysteriously dropped out sometime since the last release. Since disappearing code makes me nervous about what else might have gone missing but un-noticed I've been digging through the logs trying to find in what commit this handful of lines was removed. I've tried a number of things including "git log -S'add-visit-resource-pcf'", git blame, and even git bisect with a script that simply checks for the existence of the line but have been unable to pinpoint exactly where these lines were removed. I find this very perplexing, particularly since the last log entry (obtained by the above command) before my re-introduction of this code was someone else adding the code as well. commit 0b0556fa87ff80d0ffcc2b451cca1581289bbc3c Author: Andrew Date: Thu May 13 10:55:32 2010 -0400 Re-introduced add-visit-resource-pcf, see PR-65034. diff --git a/spike/hst/scheduler/defpackage.lisp b/spike/hst/scheduler/defpackage.lisp index f8e692d..a6f8d38 100644 --- a/spike/hst/scheduler/defpackage.lisp +++ b/spike/hst/scheduler/defpackage.lisp @@ -115,6 +115,7 @@ #:add-to-current-resource-pcf #:add-user-package-nickname #:add-value-criteria + #:add-visit-resource-pcf #:add-window-to-gs-params #:adjust-derived-resources #:adjust-links-candidate-criteria-types commit 9fb10e25572c537076284a248be1fbf757c1a6e1 Author: Bob Date: Sun Jan 17 18:35:16 2010 -0500 update-defpackage for Spike 33.1 Delivery diff --git a/spike/hst/scheduler/defpackage.lisp b/spike/hst/scheduler/defpackage.lisp index 983666d..47f1a9a 100644 --- a/spike/hst/scheduler/defpackage.lisp +++ b/spike/hst/scheduler/defpackage.lisp @@ -118,6 +118,7 @@ #:add-user-package-nickname #:add-value-criteria #:add-vars-from-proposal + #:add-visit-resource-pcf #:add-window-to-gs-params #:adjust-derived-resources #:adjust-links-candidate-criteria-types This is for one of our package definition files, but the relevant source file reflects something similar. Does anyone know what could be going on here and how I could find the information I want? It's not really that important but this kind of things makes me a bit nervous.

    Read the article

  • Equality Comparison with Multiple Instances/IEqualityComparer problems in LINQ

    - by Stacey
    This is similar to my last question; but from a different angle. http://stackoverflow.com/questions/2792393/see-if-item-exists-once-in-enumerable-linq Given the following set of items, and lists containing them... Item 1 Item 2 Item 3 Item 4 Item 5 class Item { string Name { get; set; } } List<Item> available = new List<Item>() { Item 1 Item 1 Item 2 Item 3 Item 5 } List<Item> selected = new List<Item>() { Item 1 Item 2 Item 3 } I need to make a third List that has everything from "available", except what is in "selected". However 'Item 1' is in 'available' twice, but only in 'selected' once. Since they are instances of the same item, I am having trouble figuring out the appropriate logic to accomodate this. The final array should look like... List<Item> selectable = new List<Item>() { Item 1 Item5 }

    Read the article

  • How do I remove (or apply) transparency on a gdk-pixbuf?

    - by Andrew Stacey
    I have a c++ program in which a gdk-pixbuf is created. I want to output it as an image, so I call gdk_pixbuf_save_to_stream(pixbuf,stream,type,NULL,&err,NULL). This works fine when "type" is png or tiff, but with jpeg or bmp it just produces a black square. The original pixbuf consists of black-on-transparent (and gdk_pixbuf_get_has_alpha returns true) so I'm guessing that the problem is with the alpha mask. GdkPixbuf has a function to add an alpha channel, but I can't see one that removes it again, or (which might be as good) to invert it. Is there a simple way to get the jpeg and bmp formats to work properly? (I should say that I'm very new to proper programming like this.)

    Read the article

  • Predicate<T> through jQuery with ASP.NET MVC

    - by Stacey
    One of my co-workers wrote an ActionResult that accepts a Predicate as its input parameter. We need to call this method through jQuery - but obviously that doesn't work. Is there any way to pass a query through a method in jQuery that it will accept? public ActionResult List(Predicate<TModel> expression) { // ... } $('#item').load('/list', //... ??? )

    Read the article

  • Threading Practice with Polling.

    - by Stacey
    I have a C# application that has to constantly read from a program; sometimes there is a chance it will not find what it needs, which will throw an exception. This is a limitation of the program it has to read from. This frequently causes the program to lock up as it tries to poll. So I solved it by spawning the 'polling' off into a separate thread. However watching the debugger, the thread is created and destroyed each time. I am uncertain if this is typical or not; but my question is, is this good practice, or am I using the threading for the wrong purpose? ProgramReader { static Thread oThread; public static void Read( Program program ) { // check to see if the program exists if ( false ) oThread = new ThreadStart(program.Poll); if(oThread != null || !oThread.IsAlive ) oThread.Start(); } } This is my general pseudocode. It runs every 10 seconds or so. Is this a huge hit to performance? The operation it performs is relatively small and lightweight; just repetitive.

    Read the article

  • LINQ Join on Dictionary<K,T> where only K is changed.

    - by Stacey
    Assuming type TModel, TKey, and TValue. In a dictionary where KeyValuePair is declared, I need to merge TKey into a separate model of KeyValuePair where TKey in the original dictionary refers to an identifier in a list of TModel that will replace the item in the Dictionary. public TModel { public Guid Id { get; set; } // ... } public Dictionary<Guid, TValue> contains the elements. TValue relates to the TModel. The serialized/stored object is like this.. public SerializedModel { public Dictionary<Guid,TValue> Items { get; set; } } So I need to construct a new model... KeyValueModel { public Dictionary<TModel, TValue> { get; set; } } KeyValueModel kvm = = (from tModels in controller.ModelRepository.List<Models.Models>() join matchingModels in storedInformation.Items on tModels.Id equals matchingModels select tModels).ToDictionary( c => c.Id, storedInformation.Items.Values ) This linq query isn't doing what I'm wanting, but I think I'm at least headed in the right direction. Can anyone assist with the query? The original object is stored as a KeyValuePair. I need to merge the Guid Keys in the Dictionary to their actual related objects in another object (List) so that the final result is KeyValuePair. And as for what the query is not doing for me... it isn't compiling or running. It just says that "Join is not valid".

    Read the article

  • [MySQL/PHP] Avoid using RAND()

    - by Andrew Ellis
    So... I have never had a need to do a random SELECT on a MySQL DB until this project I'm working on. After researching it seems the general populous says that using RAND() is a bad idea. I found an article that explains how to do another type of random select. Basically, if I want to select 5 random elements, I should do the following (I'm using the Kohana framework here)? If not, what is a better solution? Thanks, Andrew <?php final class Offers extends Model { /** * Loads a random set of offers. * * @param integer $limit * @return array */ public function random_offers($limit = 5) { // Find the highest offer_id $sql = ' SELECT MAX(offer_id) AS max_offer_id FROM offers '; $max_offer_id = DB::query(Database::SELECT, $sql) ->execute($this->_db) ->get('max_offer_id'); // Check to make sure we're not trying to load more offers // than there really is... if ($max_offer_id < $limit) { $limit = $max_offer_id; } $used = array(); $ids = ''; for ($i = 0; $i < $limit; ) { $rand = mt_rand(1, $max_offer_id); if (!isset($used[$rand])) { // Flag the ID as used $used[$rand] = TRUE; // Set the ID if ($i > 0) $ids .= ','; $ids .= $rand; ++$i; } } $sql = ' SELECT offer_id, offer_name FROM offers WHERE offer_id IN(:ids) '; $offers = DB::query(Database::SELECT, $sql) ->param(':ids', $ids) ->as_object(); ->execute($this->_db); return $offers; } }

    Read the article

  • Use html files from another project in ASP.NET MVC

    - by Stacey
    I know that I can use normal html files in ASP.NET MVC; however I have a situation where several (above 20) html files are needed for static display. This is fine and good, but I really don't want it cluttering the MVC project since none of them will have controller actions. Is there any way to load up a second project and use static html files from it, within ASP.NET MVC?

    Read the article

  • How to tie a Hudson job to a user who has access to run MSIExec

    - by Andrew
    Hi All, I have a batch file that calls "MSIExec /X {MyGUID} /qn". This runs successfully when run with my admin user. When I run it as a Window Batch command from a Hudson job it fails with "T?h?e? ?i?n?s?t?a?l?l?a?t?i?o?n? ?s?o?u?r?c?e? ?f?o?r? ?t?h?i?s? ?p?r?o?d?u?c?t? ?i?s? ?n?o?t? ?a?v?a?i?l?a?b?l?e?.? ? ?V?e?r?i?f?y? ?t?h?a?t? ?t?h?e? ?s?o?u?r?c?e? ?e?x?i?s?t?s? ?a?n?d? ?t?h?a?t? ?y?o?u? ?c?a?n? ?a?c?c?e?s?s? ?i?t?.? " I am inclined to think that the issue is that the job is started by the "anonymous" user rather than my admin user. How in hudson do I "tie" the job to be run under the admin user? Thanks in advance. Regards, Andrew

    Read the article

  • Classes to Entities; Like-class inheritence problems

    - by Stacey
    Beyond work, some friends and I are trying to build a game of sorts; The way we structure some of it works pretty well for a normal object oriented approach, but as most developers will attest this does not always translate itself well into a database persistent approach. This is not the absolute layout of what we have, it is just a sample model given for sake of representation. The whole project is being done in C# 4.0, and we have every intention of using Entity Framework 4.0 (unless Fluent nHibernate can really offer us something we outright cannot do in EF). One of the problems we keep running across is inheriting things in database models. Using the Entity Framework designer, I can draw the same code I have below; but I'm sure it is pretty obvious that it doesn't work like it is expected to. To clarify a little bit; 'Items' have bonuses, which can be of anything. Therefore, every part of the game must derive from something similar so that no matter what is 'changed' it is all at a basic enough level to be hooked into. Sounds fairly simple and straightforward, right? So then, we inherit everything that pertains to the game from 'Unit'. Weights, Measures, Random (think like dice, maybe?), and there will be other such entities. Some of them are similar, but in code they will each react differently. We're having a really big problem with abstracting this kind of thing into a database model. Without 'Enum' support, it is proving difficult to translate into multiple tables that still share a common listing. One solution we've depicted is to use a 'key ring' type approach, where everything that attaches to a character is stored on a 'Ring' with a 'Key', where each Key has a Value that represents a type. This works functionally but we've discovered it becomes very sluggish and performs poorly. We also dislike this approach because it begins to feel as if everything is 'dumped' into one class; which makes management and logical structure difficult to adhere to. I was hoping someone else might have some ideas on what I could do with this problem. It's really driving me up the wall; To summarize; the goal is to build a type (Unit) that can be used as a base type (Table per Type) for generic reference across a relatively global scope, without having to dump everything into a single collection. I can use an Interface to determine actual behavior so that isn't too big of an issue. This is 'roughly' the same idea expressed in the Entity Framework.

    Read the article

  • RegisterClientScriptInclude doesn't work for some reason...

    - by Andrew
    Hey, I've spent at least 2 days trying anything and googling this...but for some reason I can't get RegisterClientScriptInclude to work the way everyone else has it working? First off, I am usting .NET 3.5 Ajax,...and I am including javascript in my partial page refreshes...using this code: ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "MyClientCode", script, true); It works perfectly, my javascript code contained in the script variable is included every partial refresh. The javascript in script is actually quite extensive though, and I would like to store it in a .js file,..so logically I make a .js file and try to include it using RegisterClientScriptInclude ...however i can't for the life of my get this to work. here's the exact code: ScriptManager.RegisterClientScriptInclude(this, typeof(Page), "mytestscript", "/js/testscript.js"); the testscript.js file is only included in FULL page refreshes...ie. when I load the page, or do a full postback....i can't get the file to be included in partial refreshes...have no idea why..when viewing the ajax POST in firebug I don't see a difference whether I include the file or not.... both of the ScriptManager Includes are being ran from the exact same place in "Page_Load"...so they should execute every partial refresh (but only the ScriptBlock does). anyways,..any help or ideas,..or further ways I can trouble shoot this problem, would be appreciated. Thanks, Andrew

    Read the article

  • Character Set Issues when Upgrading from Symfony 2.0.* to Symfony 2.1.*?

    - by Adam Stacey
    I have recently upgraded my staging test site to the latest version of Symfony and updated all the vendors using composer as instructed in the upgrade document that comes with the download. Everything has all updated fine, but I have noticed now that some bits of HTML are not displaying in the Twig templates. I did a comparison with the current live site and it appears to be a character set issue. As an example I had a drop down list that had the following value in: Kitchen Ducting > Ducting Kits > Ducting Kit 4” / 100mm In the updated site the drop-down list item just appeared blank. When I used Twig's raw function it then displayed the item again, but with the dreaded question mark in a black diamond. Kitchen Ducting > Ducting Kits > Ducting Kit 4? / 100mm Things that you should know that may help: The staging test site and live site are both on the same server. In my httpd.conf file I have 'AddDefaultCharset utf-8'. In my php.ini file I have 'default_charset = "utf-8"'. The HTML file served has the Content-Type meta tag 'content="text/html; charset=utf-8"' My database is InnoDB and uses 'utf8' as the default character set and 'utf8_general_ci' as default collation. All tables in the database also use the defaults. I looked into BOM with UTF8, but could not work out if that was a problem or not?

    Read the article

  • CRONTAB doesn't finish svndump

    - by Andrew
    I just discovered that the automated dumps I've been creating of my SVN repository have been getting cut off early and basically only half the dump is there. It's not an emergency, but I hate being in this situation. It defeats the purpose of making automated backups in the first place. The command I'm using is below. If I execute it manually in the terminal, it completes fine; the output.txt file is 16 megs in size with all 335 revisions. But if I leave it to crontab, it bails at the halfway mark, at around 8.1 megs and only the first 169 revisions. # m h dom mon dow command 18 00 * * * svnadmin dump /var/svn/repos/myproject > /home/andrew/output.txt I actually save to a dated gzipped file, and there's no shortage of space on the server, so this is not a disk space issue. It seems to bail after two seconds, so this could be a time issue, but the file size is the same every single time for the past month, so I don't think it's that either. Does crontab execute within a limited memory space?

    Read the article

  • Is there such a thing as too many tables?

    - by Stacey
    I've been searching stackoverflow for about an hour now and couldn't find any topics related, so I apologize if this is a duplicate question. My inquery is this. Is there a point at which there are too many tables in a database? Even if the structure is well organized, thought out, and perfectly facilitates the design intent? I have a database that is quickly approaching 40 tables - about 10 main ones, and over 30 ancillary tables (junction tables, 'enumeration' tables, etc). Am I just a bad developer - or should I be trying something different? It seems like so many to me, I'm really afraid at how it will impact the performance of the project. I have done a lot of condensing where possible, grouped similar things where possible, etc. The database is built in MS-SQL 2008.

    Read the article

  • Adding items to Model Collection in ASP.NET MVC

    - by Stacey
    In an ASP.NET MVC application where I have the following model.. public class EventViewModel { public Guid Id { get; set; } public List<Guid> Attendants { get; set; } } passed to a view... public ActionResult Create(EventViewModel model) { // ... } I want to be able to add to the "Attendants" Collection from the View. The code to add it works just fine - but how can I ensure that the View model retains the list? Is there any way to do this without saving/opening/saving etc? I am calling my addition method via jQuery $.load. public void Insert(Guid attendant) { // add the attendant to the attendees list of the model - called via $.load } I would also like to add there is no database. There is no storage persistence other than plain files.

    Read the article

  • Return ActionResult to a Dialog. ASP.NET MVC

    - by Stacey
    Given a method.. public ActionResult Method() { // program logic if(condition) { // external library // external library returns an ActionResult } return View(viewname); } I cannot control the return type or method of the external library. I want to catch its results and handle that in a dialog on the page - but I cannot figure out how to get back to the page to execute the jQuery that would be responsible for it. Any ideas?

    Read the article

  • Reflect and Load code at design time in Visual Studio

    - by Stacey
    I have an XML file that lists a series of items, and the items are often referenced by their name in code. Is there any way to use reflection within Visual Studio to make this list 'accessible' sort of like intellisence? I've seen it done before - and I'm pretty sure it's ridiculously difficult, but I figure it can't hurt to at least ask.

    Read the article

  • Select CSS based on multiple classes

    - by Stacey
    I have a style rule I want to apply to a tag when it has TWO styles. Is there any way to perform this without javascript? In other words.. <li class='left ui-class-selector'> I want to select only if the li has both 'left' and 'ui-class-selector' classes applied.

    Read the article

  • See if item exists once in Enumerable (Linq)

    - by Stacey
    Given a list... class Item { public Name { get; set; } } List<Item> items = new List<Item> { new Item() { Name = "Item 1" }, new Item() { Name = "Item 1" }, new Item() { Name = "Item 2" }, new Item() { Name = "Item 3" } } List<Item> listing = new List<Item> { new Item() { Name = "Item 1" }, new Item() { Name = "Item 2" }, new Item() { Name = "Item 3" } new Item() { Name = "Item 4" } } etc. I need to create a third array that will cancel out double instances between the two; however items with "Name 1" are both the same, but different 'instances'. So the third List should have 1 instance of Item 1, since 'items' had 2 instances. Any ideas of how this can be done through Linq?

    Read the article

  • Really lost with OpenID and ASP.NET MVC

    - by Stacey
    I'm attempting to implement OpenID with ASP.NET MVC (Yeah, we haven't heard that one before I'm sure!) That really isn't the big problem, though. My huge problem is that I am exceedingly confused about how to do this alongside an application that will need to store a lot of information about the logged in users (profiles, histories, etc) It seems to me that OpenID takes away the site-centric logic and makes it, well, open. This is all well and good if you just make an authentication ticket to be seen as a 'validated' user - but in all seriousness I am completely lost. Is it possible to implement OpenID such that logging in with it will allow users to 'exist' on my own application as if they had gone through normal registration?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >