Daily Archives

Articles indexed Monday May 10 2010

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

  • C# Find and Replace a section of a string with wildcard type search using RegEx (while retaining som

    - by fraXis
    Hello, I am trying to replace some text in a string with different text while retaining some of the text and I am having trouble doing it. My code is: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); /Replace M2 with M3 (this works fine) content = Regex.Replace(content, "M2", "M3"); I want to replace a string that contains this: Z0.1G0H1E1 and turn it into: G54G43Z.1H1M08 (Note the Z value and the H value contain the same numeric value before the text change) The trouble I am having is that when I replace the values, I need to retain the H value and the Z value from the first set of text. For example, Z0.5G0H5E1 I need to add the new text, but also add the H5 and Z0.5 back into the text such as: G54G43Z0.5H5M08 But the Z values and H values will be different every time, so I need to capture those values and reinsert them back into the string when add the new G54G43 values. Can someone please show me how to do this using Regex.Replace? Thanks so much, Shawn

    Read the article

  • How do I access data from local XML files in a webOS application on the Palm Pre?

    - by Brijesh Patel
    I am new at Mojo framework and Palm webOS. I want to just retrieve data from XML files using xmlhttprequest (Ajax). I am trying to get data from following script. this.items = []; var that = this; var request = new Ajax.Request("first/movies.xml", { method: 'get', evalJSON: 'false', onSuccess:function(transport){ var movieTags = transport.responseXML.getElementsByTagName('movie'); for( var i = 0; i < movieTags.length; i++ ){ var title = movieTags[i].getAttribute('title'); that.items.push({text: title}); } }, onFailure: function(){ alert('Something went wrong...') } }); My XML files are in the first/movies.xml folder. From that I am trying to access and retrieve data. but not display anything in the screen of Palm Pre emulator. So can anyone is having idea about this issue? Please give a link where can I find the source code for getting data from XML files in webOS.

    Read the article

  • Python: split a list based on a condition?

    - by Parand
    What's the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of: good = [x for x in mylist if x in goodvals] bad = [x for x in mylist if x not in goodvals] is there a more elegant way to do this? Update: here's the actual use case, to better explain what I'm trying to do: # files looks like: [ ('file1.jpg', 33L, '.jpg'), ('file2.avi', 999L, '.avi'), ... ] IMAGE_TYPES = ('.jpg','.jpeg','.gif','.bmp','.png') images = [f for f in files if f[2].lower() in IMAGE_TYPES] anims = [f for f in files if f[2].lower() not in IMAGE_TYPES]

    Read the article

  • "filter" json through ajax (jquery)

    - by Hyung Suh
    I'm trying to filter the json array through ajax and not sure how to do so. { posts: [{"image":"images/bbtv.jpg", "group":"a"}, {"image":"images/grow.jpg", "group":"b"}, {"image":"images/tabs.jpg", "group":"a"}, {"image":"images/bia.jpg", "group":"b"}]} i want it so that i can only show items in group A or group B. how would i have to change my ajax to filter through the content? $.ajax({ type: "GET", url: "category/all.js", dataType: "json", cache: false, contentType: "application/json", success: function(data) { $('#folio').html("<ul/>"); $.each(data.posts, function(i,post){ $('#folio ul').append('<li><div class="boxgrid captionfull"><img src="' + post.image + '" /></div></li>'); }); initBinding(); }, error: function(xhr, status, error) { alert(xhr.status); } }); Also, how can I can I make each link process the filter? <a href="category/all.js">Group A</a> <a href="category/all.js">Group B</a> Sorry for all these questions, can't seem to find a solution.. Any help in the right direction would be appreciated. Thanks!

    Read the article

  • Rotate two dimensional array 90 degrees clockwise

    - by user69514
    I have a two dimensional array that I need to rotate 90 degrees clockwise, however I keep getting arrayindexoutofbounds... public int[][] rorateArray(int[][] arr){ //first change the dimensions vertical length for horizontal length //and viceversa int[][] newArray = new int[arr[0].length][arr.length]; //invert values 90 degrees clockwise by starting from button of //array to top and from left to right int ii = 0; int jj = 0; for(int i=0; i<arr[0].length; i++){ for(int j=arr.length-1; j>=0; j--){ newArray[ii][jj] = arr[i][j]; jj++; } ii++; } return newArray; }

    Read the article

  • PyQt: Get the position of QGraphicsWidgets in a QGraphicsGridLayout

    - by Chris Phillips
    I have a fairly simple PyQt application in which I'm placing instances of a QGraphicsWidget in a QGraphicsGridLayout and want to connect the widgets with lines drawn with a QGraphicsPath. Unfortunately, no matter what I try, I always get (0, 0) back as the position for both the start and end widgets. I'm constructing the graph with a recursive function that adds widgets to the scene and layout. Once the recursive function is complete, the layout is added to a new widget, which is added to the scene to show everything. The edges are added to the scene as widgets are created. How do I get a non-zero position of any of the widgets in the grid layout?

    Read the article

  • Rails migration for change column

    - by b_ayan
    We have script/generate migration add_fieldname_to_tablename fieldname:datatype syntax for adding new columns to a model. On the same line, do we have a script/generate for changing the datatype of a column? Or should I write sql directly into my vanilla migration? I want to change a column from datetime to date. Thanks

    Read the article

  • Async BinaryWriter ?

    - by blez
    I found implementation of async BinaryWriter here: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/11f6aa76-1383-4cab-8693-29dcb25bbf2e But I can't really use it. I change all my types to AsyncBinaryWriter and I use .Write, but no data is written to the stream. Is that the proper way for using it ?

    Read the article

  • Remove redundant SQL code

    - by Dave Jarvis
    Code The following code calculates the slope and intercept for a linear regression against a slathering of data. It then applies the equation y = mx + b against the same result set to calculate the value of the regression line for each row. Can the two separate sub-selects be joined so that the data and its slope/intercept are calculated without executing the data gathering part of the query twice? SELECT AVG(D.AMOUNT) as AMOUNT, Y.YEAR * ymxb.SLOPE + ymxb.INTERCEPT as REGRESSION_LINE, Y.YEAR as YEAR, MAKEDATE(Y.YEAR,1) as AMOUNT_DATE FROM CITY C, STATION S, YEAR_REF Y, MONTH_REF M, DAILY D, (SELECT ((avg(t.AMOUNT * t.YEAR)) - avg(t.AMOUNT) * avg(t.YEAR)) / (stddev( t.AMOUNT ) * stddev( t.YEAR )) as CORRELATION, ((sum(t.YEAR) * sum(t.AMOUNT)) - (count(1) * sum(t.YEAR * t.AMOUNT))) / (power(sum(t.YEAR), 2) - count(1) * sum(power(t.YEAR, 2))) as SLOPE, ((sum( t.YEAR ) * sum( t.YEAR * t.AMOUNT )) - (sum( t.AMOUNT ) * sum(power(t.YEAR, 2)))) / (power(sum(t.YEAR), 2) - count(1) * sum(power(t.YEAR, 2))) as INTERCEPT FROM ( SELECT AVG(D.AMOUNT) as AMOUNT, Y.YEAR as YEAR, MAKEDATE(Y.YEAR,1) as AMOUNT_DATE FROM CITY C, STATION S, YEAR_REF Y, MONTH_REF M, DAILY D WHERE $X{ IN, C.ID, CityCode } AND SQRT( POW( C.LATITUDE - S.LATITUDE, 2 ) + POW( C.LONGITUDE - S.LONGITUDE, 2 ) ) < $P{Radius} AND S.STATION_DISTRICT_ID = Y.STATION_DISTRICT_ID AND Y.YEAR BETWEEN 1900 AND 2009 AND M.YEAR_REF_ID = Y.ID AND M.CATEGORY_ID = $P{CategoryCode} AND M.ID = D.MONTH_REF_ID AND D.DAILY_FLAG_ID <> 'M' GROUP BY Y.YEAR ) t ) ymxb WHERE $X{ IN, C.ID, CityCode } AND SQRT( POW( C.LATITUDE - S.LATITUDE, 2 ) + POW( C.LONGITUDE - S.LONGITUDE, 2 ) ) < $P{Radius} AND S.STATION_DISTRICT_ID = Y.STATION_DISTRICT_ID AND Y.YEAR BETWEEN 1900 AND 2009 AND M.YEAR_REF_ID = Y.ID AND M.CATEGORY_ID = $P{CategoryCode} AND M.ID = D.MONTH_REF_ID AND D.DAILY_FLAG_ID <> 'M' GROUP BY Y.YEAR Question How do I execute the duplicate bits only once per query, instead of twice? The duplicate bit is the WHERE clause: $X{ IN, C.ID, CityCode } AND SQRT( POW( C.LATITUDE - S.LATITUDE, 2 ) + POW( C.LONGITUDE - S.LONGITUDE, 2 ) ) < $P{Radius} AND S.STATION_DISTRICT_ID = Y.STATION_DISTRICT_ID AND Y.YEAR BETWEEN 1900 AND 2009 AND M.YEAR_REF_ID = Y.ID AND M.CATEGORY_ID = $P{CategoryCode} AND M.ID = D.MONTH_REF_ID AND D.DAILY_FLAG_ID <> 'M' Related http://stackoverflow.com/questions/1595659/how-to-eliminate-duplicate-calculation-in-sql Thank you!

    Read the article

  • How does the iPhone know which OpenGL ES context to use between 1.1 and 2.0?

    - by Moshe
    I've been digging around the net recently and noticed some video tutorials show an older template (pre SDK 3.2) with one OpenGL ES context. Now there are two of them, which, I've gleaned are the two versions of OpenGL ES available on the newer iMobile devices. Can I just use the older one or do I need to do everything twice? How do I tell the iPhone to use the older context, or will it do so automatically?

    Read the article

  • Can't compare the norm of a vector to 1 in matlab

    - by Ian
    I'm trying to find out wether a matrix is orthonormal. I begin by checking if the vectors are normal by doing for j=1:2; if norm(S:,j) ~= 1; return; % Not normal vector end end But when norm returns 1.0000 comparing that to 1 is true and the function returns, which is not what i want. Any ideas? Thx

    Read the article

  • Stop doxygen (in some directories) for recursive input

    - by ncohen
    Hi everyone, I've used this tuto (http://www.duckrowing.com/2010/03/18/documenting-objective-c-with-doxygen-part-ii/) to create my documentation... I would like to run doxygen in some directories and not in others! The problem is that I don't want to reorganize all the directories! Is it possible to put a file in the directories I don't want doxygen to run into? Thanks in advance!

    Read the article

  • Making the user change the time in Android

    - by Casebash
    Android doesn't appear to provide a way for a user application to change the system time. What I would like to do instead is to get the user to change the time. It is easy to open up the Date & Time settings: startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS)); What I would like to know is: Is it possible to link directly to the set time option? Is it possible to check that the user set the time correctly? I am aware of the TIME_CHANGED broadcast message, but I can't find any documentaion on it

    Read the article

  • "System cannot find the file specified" trying to reinstall network driver.

    - by Justin Love
    After uninstalling Symantec Enpoint Protection (manually) one computer (Windows XP) has an inoperative NIC; it shows up in device manager as conflicted. I tried doing a windows repair from CD, which did not improve the situation. When I went to reinstall the drivers, driver installation failed with: Cannot install this hardware The system cannot find the file specified I've deleted the NIC in device manager without improvement.

    Read the article

  • Advice on moving a machine room to a new location?

    - by MikeJ
    Our company is moving to new offices in a couple of months, and I am responsible for looking after the move of the development servers in the company. most of the dev equipment is in 5, 42U cabinets + rack for switching/routing equipment. How do most people do this sort of thing? Move the cabinent whole or extract the indvidual components and move the racks empty. any advise on prep and shutdown before the move would be welcome

    Read the article

  • How to fix Emacs client *ERROR*: Arithmetic error

    - by nocash
    GNU Emacs 23.1.1 I've noticed that if I run Emacs and M-x server-start, I can use the emacsclient program as usual, but if if I start Emacs using emacs --daemon and then try to use emacsclient the new frame locks up and the shell outputs *ERROR*: Arithmetic error. This issue doesn't happen if I use the -t flag to force terminal mode when running emacsclient. Has anyone run into this before? Anyone know what's going on and/or how to fix it?

    Read the article

  • CodePlex Daily Summary for Sunday, May 09, 2010

    CodePlex Daily Summary for Sunday, May 09, 2010New ProjectsArtificial Spy: ASPX, C#, XML, This is big project for creation application for: People Search. People connection. Background check. Crime Prevention. Socia...Chef Framework: CHEF: CSS, HTML, Events, & Functions. Is a collection of libraries to help build concerns separated websites.Crabit Full File Manger: File manager SystemEPiMVC - EPiServer CMS with ASP.NET MVC: A framework for using EPiServer CMS with ASP.NET MVC.Fimyid IX: all My projects In ONE!Hosting Folder Sizes: When you run a hosting environment with the ability to upload files, and you're charging per gigabyte per month, you need quick statistics about di...Let's Up: A tool that breaks you every 50 minutes to protect your health.MediaXenter: MediaXenterMSClub BY: Microsoft community web-site projectOrbisArca: Windows Mobile gameSpatial Gateway: A common and standardized way of accessing spatial data stored in different datastores. This also includes functionality for replication across dif...Squiggle - A Free open source Lan Messenger: Squiggle is a free lan messenger that does not require a server. Just download and run it and you're ready to talk to everyone on your lan. Squi...Video Downloader: Video Downloader makes it easier for developers to generate download links for videos from You-Tube. You'll no longer have to search through source...ViewModelSupport: This is not an MVVM framework. It is just the base class I use to reduce the friction when writing ViewModels. Making it public to share my ideas.WPF CCTV Surveillance Control with IP Cameras.: Integracion de Video IP en WPF. IP Camera. WPF dinamic Control and Events in Video System. Surveillance system. CCTV system. .NetNew Releases.NET Extensions - Extension Methods Library: Release 2010.07: Added some extension methods for ICollection<T> and IList<T> for demonstrating the differences between both interfaces: - ICollection<T>.AddRangeU...bitly.net: bitly.dll: This is a .net DLL that works with the on-line URL shortening service bit.ly Compiled using .net 4.0 but the source code should run with version 2 ...Crabit Full File Manger: Crabit V1.0: Firts file manager system previewCSharp Intellisense: V1.9: this is a major release that was focus on bug fix, tooltip support and styling.Fimyid IX: fimyid ix 1.0: New Liscence!Gherkin editor: Beta: Added support for i18n (all languages supported by Gherkin/Cucumber are suported). Removed auto-completion of statements like As a user and followi...Grunty OS: GruntyOSAlphaSC: Grunty os sourceHKGolden Express: HKGoldenExpress (Build 201005081830): New features: Users can post new message or reply to a message. Special thanks for help from members 劉佳偉 (ID: 179892) and Maize. (ID: 142974). Bu...iLove SharePoint: Lookup Field with Picker 2010: Just forget the fuc**** dropdowns! Requirements: SharePoint Foundation 2010 Features * Single- and multi-Selection Mode * Search in pick...LazyNet: LazyNet Beta 2: Refresh Network Bug fixed.LazyNet: LazyNEt_Beta3: Beta 3 Release, Better Network RefreshingLazyNet: LazyNetBeta3_SRC: Refresh NetworkLet's Up: 1.0 (Build 100509): This is the first versionLive Distributed Objects: Windows Installer r48444 (2010-05-08): current development snapshotMDownloader: MDownloader-0.15.12.58576: Fixed presenting Hotfile's captcha. Fixed FilesTube searching. Fixed determining Rapidshare postpone period. Fixed minor bugs.NSIS Autorun: NSIS Autorun 0.1.7: This release includes source code, executable binaries and example materials.SharpDevelop: SharpDevelop 3.2: Release notes: http://community.sharpdevelop.net/forums/t/11165.aspxSilverlight SDK for Bing: Silverlight SDK for Bing 1.4: Build for Visual Studio 2010 and Silverlight 4 Issues Addressed10337 10342 10367 10804 10805 10806 10807 DownloadsSilverlight SDK For B...sqwarea: Sqwarea 0.0.252.0 (alpha): This release corrects a critical bug in Persistence.GameProvider.GetNextKingId. We strongly recommend you to upgrade to this version.Stratosphere: Stratosphere 1.0.5.1: Added many features to Amazon Web Services Shell (AwsSh) Improved scalable table reader for SimpleDB multi-valued attributes Added more functio...TechEdOneNoter: TechEdOneNoter verison 2010.5.9.2010: TechEdOneNoter is a utility to create OneNote Pages based on sessions selected in the TechEd North America 2010 Session Builder. This is the first...Video Downloader: Version 1.0: Version 1.0 See Home Page for usage and more information. Please remember changes at You-Tube can prevent this software from working.Visual Studio - Lua Language Support: May 8th Update: Release NotesThis release adds collapsible functions and tables. What's new:Collapsible functions and tables Using latest version of Irony Maj...WPF CCTV Surveillance Control with IP Cameras.: Hungry Foxx CCTV Preview: Este release, corresponde a una muestra del programa completo. La idea es poder contar con una solucion para los integradores de sistemas CCTV o d...XsltDb - DotNetNuke XSLT module: 01.01.08: Bugs fixed: 17204 17203 Many new features, but undocumented yet. I'm going to update docs in a week or two, but...Most Popular ProjectsWBFS ManagerRawrAJAX Control ToolkitMicrosoft SQL Server Product Samples: DatabaseSilverlight ToolkitWindows Presentation Foundation (WPF)patterns & practices – Enterprise LibraryMicrosoft SQL Server Community & SamplesASP.NETPHPExcelMost Active Projectspatterns & practices – Enterprise LibraryRawrThe Information Literacy Education Learning Environment (ILE)AJAX Control FrameworkCaliburn: An Application Framework for WPF and SilverlightMirror Testing SystemjQuery Library for SharePoint Web Servicespatterns & practices - UnityBlogEngine.NETTweetSharp

    Read the article

  • Use Struct as a Ptr/class? Need a fix .NET

    - by acidzombie24
    I wrote a bunch of code and i would like to fix it the fastest way possible. I'll describe my problem in a easier way. I have apples and oranges, they are both Point and in the list apples, oranges. I create a PictureBox and draw the apple/oranges on screen and move them around and update the Point via Tag. The problem now is since its a struct the tag is a copy so the original elements in the list are not update. So, how do i update them? I consider using Point? But those seem to be readonly. So the only solution i can think of is Clear the list, iterate through all the controls then check the picturebox property to check if the image is a apple or orange then add it to a list I really only thought of this solution typing this question, but my main question is, is there a better way? Is there some List<Ptr<Point>> class i can use so when i update the apples or oranges through the tag the element in the list will update as a class would?

    Read the article

  • What C++ library do I need to get this program to compile

    - by Phenom
    When I try to compile my program I get these errors: btio.c:19: error: ‘O_RDWR’ was not declared in this scope btio.c:19: error: ‘open’ was not declared in this scope btio.c: In function ‘short int create_tree()’: btio.c:56: error: ‘creat’ was not declared in this scope btio.c: In function ‘short int create_tree(int, int)’: btio.c:71: error: ‘creat’ was not declared in this scope what library do I need to include to fix these errors?

    Read the article

  • Rotate array clockwise

    - by user69514
    I have a two dimensional array that I need to rotate 90 degrees clockwise, however I keep getting arrayindexoutofbounds... public int[][] rorateArray(int[][] arr){ //first change the dimensions vertical length for horizontal length //and viceversa int[][] newArray = new int[arr[0].length][arr.length]; //invert values 90 degrees clockwise by starting from button of //array to top and from left to right int ii = 0; int jj = 0; for(int i=0; i<arr[0].length; i++){ for(int j=arr.length-1; j>=0; j--){ newArray[ii][jj] = arr[i][j]; jj++; } ii++; } return newArray; }

    Read the article

  • Perl - How to get the number of elements in an anonymous array, for concisely trimming pathnames

    - by NXT
    Hi Everyone, I'm trying to get a block of code down to one line. I need a way to get the number of items in a list. My code currently looks like this: # Include the lib directory several levels up from this directory my @ary = split('/', $Bin); my @ary = @ary[0 .. $#ary-4]; my $res = join '/',@ary; lib->import($res.'/lib'); That's great but I'd like to make that one line, something like this: lib->import( join('/', ((split('/', $Bin)) [0 .. $#ary-4])) ); But of course the syntax $#ary is meaningless in the above line. Is there equivalent way to get the number of elements in an anonymous list? Thanks! PS: The reason for consolidating this is that it will be in the header of a bunch of perl scripts that are ancillary to the main application, and I want this little incantation to be more cut & paste proof. Thanks everyone There doesn't seem to be a shorthand for the number of elements in an anonymous list. That seems like an oversight. However the suggested alternatives were all good. I'm going with: lib->import(join('/', splice( @{[split('/', $Bin)]}, 0, -4)).'/lib'); But Ether suggested the following, which is much more correct and portable: my $lib = File::Spec->catfile( realpath(File::Spec->catfile($FindBin::Bin, ('..') x 4)), 'lib'); lib->import($lib);

    Read the article

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