Search Results

Search found 1049 results on 42 pages for 'jon hadley'.

Page 20/42 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • Eliminating code duplication in a single file

    - by Jon
    Sadly, a project that I have been working on lately has a large amount of copy-and-paste code, even within single files. Are there any tools or techniques that can detect duplication or near-duplication within a single file? I have Beyond Compare 3 and it works well for comparing separate files, but I am at a loss for comparing single files. Thanks in advance. Edit: Thanks for all the great tools! I'll definitely check them out. This project is an ASP.NET/C# project, but I work with a variety of languages including Java; I'm interested in what tools are best (for any language) to remove duplication.

    Read the article

  • Easiest way of unit testing C code with Python

    - by Jon Mills
    I've got a pile of C code that I'd like to unit test using Python's unittest library (in Windows), but I'm trying to work out the best way of interfacing the C code so that Python can execute it (and get the results back). Does anybody have any experience in the easiest way to do it? Some ideas include: Wrapping the code as a Python C extension using the Python API Wrap the C code using SWIG Add a DLL wrapper to the C code and load it into Python using ctypes Add a small XML-RPC server to the c-code and call it using xmlrpclib (yes, I know this seems a bit far-out!) Is there a canonical way of doing this? I'm going to be doing this quite a lot, with different C modules, so I'd like to find a way which is least effort.

    Read the article

  • Pair programming: How should the pairs be chosen?

    - by Jon Seigel
    This topic has been covered peripherally in bits and pieces in some of the other pair-programming questions, but I want to (a) consolidate this knowledge into a separate question, and, most importantly, (b) go into much more depth on the subject. From the perspective of being an effective manager, how should pairs be arranged for pair programming to maximize both the happiness and productivity of the overall team? Some ideas to get started: Should two people never be paired (because of personalities, for example)? How much overlap in skillsets is needed? How much disconnect in skillsets is too much to overcome? (No two people will overlap 100%, and a disconnect in skills can be very beneficial to both people.) Should everyone pair with everyone else on a fixed/rotating basis? Should certain pairs be arranged to accomplish specific tasks? How important a role does HR play when growing or reorganizing the team?

    Read the article

  • How to get NHProf reports in TeamCity running MSBUILD

    - by Jon Erickson
    I'm trying to get NHProf reports on my integration tests as a report in TeamCity I'm not sure how to get this set up correctly and my first attempts are unsuccessful. Let me know if there is any more information that would be helpful... I'm getting the following error, when trying to generate html reports with MSBUILD (which is being run by TeamCity) error MSB3073: The command "C:\CI\Tools\NHProf\NHProf.exe /CmdLineMode /File:"E:\CI\BuildServer\RMS-Winform\Group\dev\NHProfOutput.html" /ReportFormat:Html" exited with code -532459699 I tell TeamCity to run MSBUILD w/ CIBuildWithNHProf target The command line parameters that I pass from TeamCity are... /property:NHProfExecutable=%system.NHProfExecutable%;NHProfFile=%system.teamcity.build.checkoutDir%\NHProfOutput.html;NHProfReportFormat=Html The portion of my MSBUILD script that runs my tests is as follows... <UsingTask TaskName="NUnitTeamCity" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)"/> <!-- Set Properties --> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">x86</Platform> <NHProfExecutable></NHProfExecutable> <NHProfFile></NHProfFile> <NHProfReportFormat></NHProfReportFormat> </PropertyGroup> <!-- Test Database --> <Target Name="DeployDatabase"> <!-- ... --> </Target> <!-- Database Used For Integration Tests --> <Target Name="DeployTestDatabase"> <!-- ... --> </Target> <!-- Build All Projects --> <Target Name="BuildProjects"> <MSBuild Projects="..\MySolutionFile.sln" Targets="Build"/> </Target> <!-- Stop NHProf --> <Target Name="NHProfStop"> <Exec Command="$(NHProfExecutable) /Shutdown" /> </Target> <!-- Run Unit/Integration Tests --> <Target Name="RunTests"> <CreateItem Include="..\**\bin\debug\*Tests.dll"> <Output TaskParameter="Include" ItemName="TestAssemblies" /> </CreateItem> <NUnitTeamCity Assemblies="@(TestAssemblies)" NUnitVersion="NUnit-2.5.3"/> </Target> <!-- Start NHProf --> <Target Name="NHProfStart"> <Exec Command="$(NHProfExecutable) /CmdLineMode /File:&quot;$(NHProfFile)&quot; /ReportFormat:$(NHProfReportFormat)" /> </Target> <Target Name="CIBuildWithNHProf" DependsOnTargets="BuildProjects;DeployTestDatabase;NHProfStart;RunTests;NHProfStop;DeployDatabase"> </Target>

    Read the article

  • Performance surprise with "as" and nullable types

    - by Jon Skeet
    I'm just revising chapter 4 of C# in Depth which deals with nullable types, and I'm adding a section about using the "as" operator, which allows you to write: object o = ...; int? x = o as int?; if (x.HasValue) { ... // Use x.Value in here } I thought this was really neat, and that it could improve performance over the C# 1 equivalent, using "is" followed by a cast - after all, this way we only need to ask for dynamic type checking once, and then a simple value check. This appears not to be the case, however. I've included a sample test app below, which basically sums all the integers within an object array - but the array contains a lot of null references and string references as well as boxed integers. The benchmark measures the code you'd have to use in C# 1, the code using the "as" operator, and just for kicks a LINQ solution. To my astonishment, the C# 1 code is 20 times faster in this case - and even the LINQ code (which I'd have expected to be slower, given the iterators involved) beats the "as" code. Is the .NET implementation of isinst for nullable types just really slow? Is it the additional unbox.any that causes the problem? Is there another explanation for this? At the moment it feels like I'm going to have to include a warning against using this in performance sensitive situations... Results: Cast: 10000000 : 121 As: 10000000 : 2211 LINQ: 10000000 : 2143 Code: using System; using System.Diagnostics; using System.Linq; class Test { const int Size = 30000000; static void Main() { object[] values = new object[Size]; for (int i = 0; i < Size - 2; i += 3) { values[i] = null; values[i+1] = ""; values[i+2] = 1; } FindSumWithCast(values); FindSumWithAs(values); FindSumWithLinq(values); } static void FindSumWithCast(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = 0; foreach (object o in values) { if (o is int) { int x = (int) o; sum += x; } } sw.Stop(); Console.WriteLine("Cast: {0} : {1}", sum, (long) sw.ElapsedMilliseconds); } static void FindSumWithAs(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = 0; foreach (object o in values) { int? x = o as int?; if (x.HasValue) { sum += x.Value; } } sw.Stop(); Console.WriteLine("As: {0} : {1}", sum, (long) sw.ElapsedMilliseconds); } static void FindSumWithLinq(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = values.OfType<int>().Sum(); sw.Stop(); Console.WriteLine("LINQ: {0} : {1}", sum, (long) sw.ElapsedMilliseconds); } }

    Read the article

  • update query on multiple tables

    - by jon
    I have a schema like : employees (eno, ename, zip, hdate) customers (cno, cnmae, street, zip, phone) zipcodes (zip, city) where zip is pk in zipcodes and fk in other tables. I have to write an update query which updates all the occurence of zipcode 4994 to 1234 throughout the database. update zipcodes,customers,employees set zip = 0 where customers.zip = zipcodes.zip and employees.zip = zipcodes.zip; but i know i am not doing it right. Is there a way to update all the tables zip ina single update query?

    Read the article

  • Oracle SQL clause evaluation order

    - by jon.johnson
    In Oracle, which clause types get evaluated first? If I had the following ( pretend .... represent valid expressions and relation names ), what would the order of evaluation be? SELECT ... FROM ..... WHERE ........ GROUP BY ........... HAVING ............. ORDER BY ................ I am under the impression that the SELECT clause is evaluated last, but other than that I'm clueless.

    Read the article

  • ByteStrings in Haskell

    - by Jon
    So i am trying to write a program that can read in a java class file as bytecode. For this i am using Data.Binary and Data.ByteStream. The problem i am having is because im pretty new to Haskell i am having trouble actually using these tools. module Main where import Data.Binary.Get import Data.Word import qualified Data.ByteString.Lazy as S getBinary :: Get Word8 getBinary = do a <- getWord8 return (a) main :: IO () main = do contents <- S.getContents print (getBinary contents) This is what i have come up with so far and i fear that its not really even on the right track. Although i know this question is very general i would appreciate some help with what i should be doing with the reading.

    Read the article

  • How do I open an already opened file with a .net StreamReader?

    - by Jon Cage
    I have some .csv files which I'm using as part of a test bench. I can open them and read them without any problems unless I've already got the file open in Excel in which case I get an IOException: System.IO.IOException : The process cannot access the file 'TestData.csv' because it is being used by another process. This is a snippet from the test bench: using (CsvReader csv = new CsvReader(new StreamReader(new FileStream(fullFilePath, FileMode.Open, FileAccess.Read)), false)) { // Process the file } Is this a limitation of StreamReader? I can open the file in other applications (Notepad++ for example) so it can't be an O/S problem. Maybe I need to use some other class? If anyone knows how I can get round this (aside from closing excel!) I'd be very grateful.

    Read the article

  • WPF Validation in an ElementHost control

    - by Jon Mitchell
    I've got a WinForms form that contains an ElementHost control (which contains a WPF UserControl) and a Save button. In the WPF UserControl I've got a text box with some validation on it. Something like this... <TextBox Name="txtSomething" ToolTip="{Binding ElementName=txtSomething, Path=(Validation.Errors).[0].ErrorContent}"> <Binding NotifyOnValidationError="True" Path="Something"> <Binding.ValidationRules> <commonWPF:DecimalRangeRule Max="1" Min="0" /> </Binding.ValidationRules> </Binding> </TextBox> This all works fine. What I want to do however, is disable the Save button while the form is in an invalid state. Any help would be greatly appreciated.

    Read the article

  • Uploadify refuses to upload WMV, FLV and MP4 files

    - by Jon Winstanley
    The uploadify plugin for JQuery seems very good and works for most file types. However, it allows me to upload all file types apart from the ones I need! Namely .WMV, .FLV and .MP4 I have googled the issue and not found anyonw having such difficulties. I have already tried changing the fileExt parameter and also tried removing it altogether. I have testing in Google Chrome, IE7 and Firefox and none work for thes efile types. Is there a known reason for this behaviour?

    Read the article

  • High-Performance In-Browser Networking

    - by Jon Purdy
    (Similar in spirit to but different in practice from this question.) Is there any cross-browser-compatible, in-browser technology that allows a high-performance perstistent network connection between a server application and a client written in, say, Javascript? Think XmlHttpRequest on caffeine. I am working on a visualisation system that's restricted to at most a few users at once, and the server is pretty robust, so it can handle as much as it needs to. I would like to allow the client to have access to video streamed from the server at a minimum of about 20 frames per second, regardless of what their graphics hardware capabilities are. Simply put: is this doable without resorting to Flash or Java?

    Read the article

  • How to export more than 1MB in XML format using sqlcmd and without an input file?

    - by jon
    Hello, In SQL Server 2008, I want to export the result of a stored procedure to a file using sqlcmd utility. Now the end of my stored procedure is a select statement with a "for xml path.." clause at the end. I read on BOL that if I don't want my output truncated when reaching 1MB file size, I have to use this :XML ON command, but it should be placed on its own line, before calling the stored procedure. Does any of you experts know if it is possible to do that without specifying an input file for sqlcmd? (I'm calling sqlcmd like this: exec master..xp_cmdshell 'sqlcmd -Q"exec storedProcedureName @param1=value1, @param2=value2" -o c:\exportResults.xml -h-1 -E', but "storedProcedureName" and its parameters can change, which would mean 1 input file per passed parameters to sqlcmd) Also, it seems that I can't use bcp instead of sqlcmd because my stored procedure is creating a temporary table and performing DML statements on it? Thanks a lot

    Read the article

  • ASP.Net MVC Toggling IsAjaxRequest property based on file upload?

    - by Jon
    I have a form all setup to upload a file and that is working fine. However the way my form is submitted is through AJAX. The button that submits is still a type="submit" in case JS is off. When I save my form the controller determines whether the IsAjaxRequest is true and if so returns some JSON otherwise it does a RedirectToAction. When I don't specify a filepath in my input type="file" it considers IsAjaxRequest as true. If there is a filepath set then it thinks that IsAjaxRequest is false. How is it determining that? My other problem is that when it thinks IsAjaxRequest is false and does a RedirectToAction("Index") I don't actually get sent to the Index view. Thanks

    Read the article

  • How can I convert this PHP script to Ruby? (build tree from tabbed string)

    - by Jon Sunrays
    I found this script below online, and I'm wondering how I can do the same thing with a Ruby on Rails setup. So, first off, I ran this command: rails g model Node node_id:integer title:string Given this set up, how can I make a tree from a tabbed string like the following? <?php // Make sure to have "Academia" be root node with nodeID of 1 $data = " Social sciences Anthropology Biological anthropology Forensic anthropology Gene-culture coevolution Human behavioral ecology Human evolution Medical anthropology Paleoanthropology Population genetics Primatology Anthropological linguistics Synchronic linguistics (or Descriptive linguistics) Diachronic linguistics (or Historical linguistics) Ethnolinguistics Sociolinguistics Cultural anthropology Anthropology of religion Economic anthropology Ethnography Ethnohistory Ethnology Ethnomusicology Folklore Mythology Political anthropology Psychological anthropology Archaeology ...(goes on for a long time) "; //echo "Checkpoint 2\n"; $lines = preg_split("/\n/", $data); $parentids = array(0 => null); $db = new PDO("host", 'username', 'pass'); $sql = 'INSERT INTO `TreeNode` SET ParentID = ?, Title = ?'; $stmt = $db->prepare($sql); foreach ($lines as $line) { if (!preg_match('/^([\s]*)(.*)$/', $line, $m)) { continue; } $spaces = strlen($m[1]); //$level = intval($spaces / 4); //assumes four spaces per indent $level = strlen($m[1]); // if data is tab indented $title = $m[2]; $parentid = ($level > 0 ? $parentids[$level - 1] : 1); //All "roots" are children of "Academia" which has an ID of "1"; $rv = $stmt->execute(array($parentid, $title)); $parentids[$level] = $db->lastInsertId(); echo "inserted $parentid - " . $parentid . " title: " . $title . "\n"; } ?>

    Read the article

  • Cross domain cookie tracking

    - by Jon
    Hi, The company I work for has four domains and I'm trying to set up the cookies, so one cookie can be generated and tracked across all the domains. From reading various posts on here I thought it was possible. I've set up a sub domain on one site, to serve a cookie and 1*1 pixel image to all four sites. But I can't get this working on the other sites. If anyone can clarify that: Its possible? If I'm missing something obvious or a link to a good example? I'm trying to do this server side with PHP. Thanks

    Read the article

  • Fetch data from multiple MySQL tables

    - by Jon McIntosh
    My two tables look like this: TABLE1 TABLE2 +--------------------+ +--------------------+ |field1|field2|field3| and |field2|field4|field5| +--------------------+ +--------------------+ I am already running a SELECT query for TABLE1, and assorting all of the data into variables: $query = "SELECT * FROM TABLE1 WHERE field2 = 2"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if((!is_bool($result) || $result) && $num_rows) { while($row = mysql_fetch_array($result)) { $field1 = $row['field1']; $field2 = $row['field2']; $field3 = $row['field3']; } } What I want to do is get the data from 'field4' on TABLE2 and add it to my variables. I would want to get field4 WHERE field2 = 2

    Read the article

  • Is it possible to populate HTML form field data in an iPhone UIWebView using external accessory fram

    - by Jon Smallberries
    I have an iPhone app where I'd like to load a remotely served HTML form into a UIWebView and then populate that form as data becomes available from an external accessory using the "External Accessory Framework." Right now the data is entered by hand. The proposed flow is: Fetch an HTML page containing a form and put it into a UIWebView When data becomes available from the external accessory, populate the form field(s) Submit the form Is it possible to do this by "injecting" data from the external accessory into the UIWebView when all required data has been retrieved from the external accessory? I cannot seem to find any good examples on how to use the external accessory framework to achieve this.

    Read the article

  • What is the career value in learning ColdFusion?

    - by Jon Cram
    ColdFusion is a language I encounter rather infrequently, however it does turn up from time to time either in job adverts or as .cfm file extensions in URLs. There are possible job opportunities near to where I plan to live for ColdFusion developers. It might be in my interests to have a look at ColdFusion. ColdFusion appears, to me, to be a minority language compared to C#, Java or indeed most popular languages. Don thinks ColdFusion is declining in popularity. Would a ColdFusion position today be more related to the maintenance of legacy code than innovative, creative development, thus less interesting? Is there any long term career value in learning ColdFusion?

    Read the article

  • Tell LINQ Distinct which item to return

    - by Jon
    I understand how to do a Distinct() on a IEnumerable and that I have to create an IEqualityComparer for more advanced stuff however is there a way in which you can tell which duplicated item to return? For example say you have a List<T> List<MyClass> test = new List<MyClass>(); test.Add(new MyClass {ID = 1, InnerID = 4}); test.Add(new MyClass {ID = 2, InnerID = 4}); test.Add(new MyClass {ID = 3, InnerID = 14}); test.Add(new MyClass {ID = 4, InnerID = 14}); You then do: var distinctItems = test.Distinct(new DistinctItemComparer()); class DistinctItemComparer : IEqualityComparer<MyClass> { public bool Equals(MyClass x, MyClass y) { return x.InnerID == y.InnerID;; } public int GetHashCode(MyClassobj) { return obj.InnerID.GetHasCode(); } } This code will return the classes with ID 1 and 3. Is there a way to return the ID matches 2 & 4.

    Read the article

  • Filter entities that match all pairs

    - by Jon
    I have an entity (let's say Person) with a set of arbitrary attributes with a known subset of values. I need to search for all of these entities that match all my filter conditions. For example, my table structures look like this: Person: id | name 1 | John Doe 2 | Jane Roe 3 | John Smith Attribute: id | attr_name 1 | Sex 2 | Eye Color ValidValue: id | attr_id | value_name 1 | 1 | Male 2 | 1 | Female 3 | 2 | Blue 4 | 2 | Green 5 | 2 | Brown PersonAttributes id | person_id | attr_id | value_id 1 | 1 | 1 | 1 2 | 1 | 2 | 3 3 | 2 | 1 | 2 4 | 2 | 2 | 4 5 | 3 | 1 | 1 6 | 3 | 2 | 4 In JPA, I have entities built for all of these tables. What I'd like to do is perform a search for all entities matching a given set of attribute-value pairs. For instance, I'd like to be able to find all males (John Doe and John Smith), all people with green eyes (Jane Roe or John Smith), or all females with green eyes (Jane Roe). I see that I can already take advantage of the fact that I only really need to match on value_id, since that's already unique and tied to the attr_id. But where can I go from there?

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >