Daily Archives

Articles indexed Wednesday June 27 2012

Page 13/19 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • regexp to match string with (comma-separated) number at start and to split into number and rest?

    - by mix
    Given a string such as: 23,234,456 first second third How can I split string this into two parts, where part 1 contains the number at the beginning and part 2 contains the rest---but only if the string STARTS with a number, and the number can be comma-separated or not? In other words, I want two results: 23,234,456 and first second third. If there's a number in that string that isn't part of the first number then it should be in the second result. My best stab at this so far, to grab the number at the beginning, is something like this: ^[0-9]+(,[0-9]{3})* Which seems to grab a comma-separated or non-comma-separated number that starts the line. However, when I run this in the Javascript console I get not only the full number, but also a match on just the last 3 digits with their preceeding ,. (e.g. 23,234,456 and ,456). As for getting the rest into another var I'm having trouble. I tried working with \b, etc., but I think I must be missing something fundamental about grabbing the rest of the line. I'm doing this in Javascript in case it matters. More examples of what to match and what not to match. 2 one two three should return 2 and one two three 2345 one two three should return 2345 and one two three 2 one 2 three should return 2 and one 2 three 2,234 one two 3,000 should return 2,234 and one two 3,000 The space between parts 1 and two could be included in the beginning of part 2.

    Read the article

  • How to retain XML string as a string field during XML deserialization

    - by detale
    I got an XML input string and want to deserialize it to an object which partially retain the raw XML. <SetProfile> <sessionId>A81D83BC-09A0-4E32-B440-0000033D7AAD</sessionId> <profileDataXml> <ArrayOfProfileItem> <ProfileItem> <Name>Pulse</Name> <Value>80</Value> </ProfileItem> <ProfileItem> <Name>BloodPresure</Name> <Value>120</Value> </ProfileItem> </ArrayOfProfileItem> </profileDataXml> </SetProfile> The class definition: public class SetProfile { public Guid sessionId; public string profileDataXml; } I hope the deserialization syntax looks like string inputXML = "..."; // the above XML XmlSerializer xs = new XmlSerializer(typeof(SetProfile)); using (TextReader reader = new StringReader(inputXML)) { SetProfile obj = (SetProfile)xs.Deserialize(reader); // use obj .... } but XMLSerializer will throw an exception and won't output < profileDataXml 's descendants to "profileDataXml" field in raw XML string. Is there any way to implement the deserialization like that?

    Read the article

  • Can't create admin user on Heroku

    - by Nick5a1
    I am new to rails and I have gone through Kevin Skoglund's Ruby on Rails 3 Essential Training course on Lynda.com. Through the course you set up a simple cms, which I did. It doesn't cover Git or deployment but I've pushed my simple cms to github (https://github.com/nick5a1/Simple_CMS) and deployed to Heroku (http://nkarrasch.herokuapp.com/). In order to deploy to Heroku I followed the Heroku setup guide (https://devcenter.heroku.com/articles/rails3) and switched my database from MySQL to PostgreSQL. As instructed I changed gen'mysql2' to gen 'sqlite3' in my Gemfile and ran bundle install before pushing. I then ran heroku run rake db:migrate. I'm running into 2 problems. When I try to log in (http://nkarrasch.herokuapp.com/access) I get an error "We're sorry, but something went wrong". I should instead be getting a flash message with invalid username/password combination. This is what I'm getting on my test environment on my local machine. Secondly, when I log into the Heroku console to create and create an admin user, when I try to save that user I get the following error: irb(main):004:0> user.save (1.2ms) BEGIN AdminUser Exists (1.9ms) SELECT 1 AS one FROM "admin_users" WHERE "admin_users"."username" = 'Nick5a1' LIMIT 1 (1.7ms) ROLLBACK => false Any advice on how to troubleshoot would be greatly appreciated :). Thanks very much, Nick EDIT: Here are my Heroku logs: 2012-06-27T20:36:44+00:00 heroku[slugc]: Slug compilation started 2012-06-27T20:37:34+00:00 heroku[api]: Add shared-database:5mb add-on by [email protected] 2012-06-27T20:37:34+00:00 heroku[api]: Release v2 created by [email protected] 2012-06-27T20:37:34+00:00 heroku[api]: Add RAILS_ENV, LANG, PATH, RACK_ENV, GEM_PATH config by [email protected] 2012-06-27T20:37:34+00:00 heroku[api]: Release v3 created by [email protected] 2012-06-27T20:37:34+00:00 heroku[api]: Release v4 created by [email protected] 2012-06-27T20:37:34+00:00 heroku[api]: Deploy 1d82839 by [email protected] 2012-06-27T20:37:35+00:00 heroku[slugc]: Slug compilation finished 2012-06-27T20:37:36+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 45450` 2012-06-27T20:37:40+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5) 2012-06-27T20:37:40+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5) 2012-06-27T20:37:40+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5) 2012-06-27T20:37:44+00:00 app[web.1]: => Rails 3.2.6 application starting in production on http://0.0.0.0:45450 2012-06-27T20:37:44+00:00 app[web.1]: => Call with -d to detach 2012-06-27T20:37:44+00:00 app[web.1]: => Booting WEBrick 2012-06-27T20:37:44+00:00 app[web.1]: Connecting to database specified by DATABASE_URL 2012-06-27T20:37:44+00:00 app[web.1]: => Ctrl-C to shutdown server 2012-06-27T20:37:44+00:00 app[web.1]: [2012-06-27 20:37:44] INFO WEBrick 1.3.1 2012-06-27T20:37:44+00:00 app[web.1]: [2012-06-27 20:37:44] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux] 2012-06-27T20:37:44+00:00 app[web.1]: [2012-06-27 20:37:44] INFO WEBrick::HTTPServer#start: pid=2 port=45450 2012-06-27T20:37:45+00:00 heroku[web.1]: State changed from starting to up 2012-06-27T20:39:44+00:00 heroku[run.1]: Awaiting client 2012-06-27T20:39:44+00:00 heroku[run.1]: Starting process with command `bundle exec rake db:migrate` 2012-06-27T20:39:44+00:00 heroku[run.1]: State changed from starting to up 2012-06-27T20:39:51+00:00 heroku[run.1]: Process exited with status 0 2012-06-27T20:39:51+00:00 heroku[run.1]: State changed from up to complete 2012-06-27T20:41:05+00:00 heroku[run.1]: Awaiting client 2012-06-27T20:41:05+00:00 heroku[run.1]: Starting process with command `bundle exec rails console` 2012-06-27T20:41:05+00:00 heroku[run.1]: State changed from starting to up 2012-06-27T20:46:09+00:00 heroku[run.1]: Process exited with status 0 2012-06-27T20:46:09+00:00 heroku[run.1]: State changed from up to complete

    Read the article

  • Monads with Join() instead of Bind()

    - by MathematicalOrchid
    Monads are usually explained in turns of return and bind. However, I gather you can also implement bind in terms of join (and fmap?) In programming languages lacking first-class functions, bind is excruciatingly awkward to use. join, on the other hand, looks quite easy. I'm not completely sure I understand how join works, however. Obviously, it has the [Haskell] type join :: Monad m = m (m x) - m x For the list monad, this is trivially and obviously concat. But for a general monad, what, operationally, does this method actually do? I see what it does to the type signatures, but I'm trying to figure out how I'd write something like this in, say, Java or similar. (Actually, that's easy: I wouldn't. Because generics is broken. ;-) But in principle the question still stands...) Oops. It looks like this has been asked before: Monad join function Could somebody sketch out some implementations of common monads using return, fmap and join? (I.e., not mentioning >>= at all.) I think perhaps that might help it to sink in to my dumb brain...

    Read the article

  • What is the difference between "render a view" and send the response using the Response's method "sendResponse()"?

    - by Green
    I've asked a question about what is "rendering a view". Got some answers: Rendering a view means showing up a View eg html part to user or browser. and So by rendering a view, the MVC framework has handled the data in the controller and done the backend work in the model, and then sends that data to the View to be output to the user. and render just means to emit. To print. To echo. To write to some source (probably stdout). but don't understand then the difference between rendering a view and using the Response class to send the output to the user using its sendResponse() method. If render a view means to echo the output to the user then why sendResponse() exists and vise versa? sendResponse() exactly sends headers and after headers outputs the body. They solve the same tasks but differently? What is the difference?

    Read the article

  • Getting JSON object from php authentication objective c

    - by iError
    I am trying to authenticate using the below code NSString *urlAsString =[NSString stringWithFormat:@"http://www.myurl.com/abc/authenticate.php"]; NSURL *url = [NSURL URLWithString:urlAsString]; NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; [urlRequest setTimeoutInterval:30.0f]; [urlRequest setHTTPMethod:@"POST"]; [urlRequest addValue:@"test" forHTTPHeaderField:@"m_username" ]; [urlRequest addValue:@"123" forHTTPHeaderField:@"m_password" ]; [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self]; NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response,NSData *data, NSError *error) { if ([data length] >0 && error == nil){ html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"HTML = %@", html); receivedData = [NSMutableData data]; } else if ([data length] == 0 && error == nil){ NSLog(@"Nothing was downloaded."); } else if (error != nil){ NSLog(@"Error happened = %@", error); } }]; // Start loading data NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self]; if (theConnection) { // Create the NSMutableData to hold the received data receivedData = [NSMutableData data]; } else { // Inform the user the connection failed. } My username password is correct, I think I am not making the proper call thats why I dont get the desired results and the web service is receiving the null parameters. What can be the issue? Any help appreciated.

    Read the article

  • In .NET MVC, is there an easy way to check if I'm on the home page?

    - by Hairgami_Master
    I need to take a particular action if a user logs in from the home page. In my LogOnModel, I have a hidden field: @Html.Hidden("returnUrl", Request.Url.AbsoluteUri) In my Controller, I need to check if that value is the Home page or not. In the example below, I'm checking to see if the user is on a particular page ("Account/ResetPassword"). Is there a way to check to see if they're on the home page without resorting to regular expressions? [HttpPost] public ActionResult LogOnInt(LogOnModel model) { if (model.returnUrl.Contains("/Account/ResetPassword")) { return Json(new { redirectToUrl = @Url.Action("Index","Home")}); } Any ideas? A million thanks!

    Read the article

  • Carousel stopped working

    - by DenMed
    I can't get why, but suddenly my Bootstrap Carousel stopped working. I want it starts onload. Error from Chrome Console: Uncaught TypeError: Object [object Object] has no method 'carousel' :3000/assets/application.js?body=1:18 (anonymous function) :3000/assets/application.js?body=1:18 jQuery.Callbacks.fire jquery-1.7.2.js:1076 jQuery.Callbacks.self.fireWith jquery-1.7.2.js:1194 jQuery.extend.ready jquery-1.7.2.js:436 DOMContentLoaded jquery-1.7.2.js:950 In my application.js: $('.carousel').carousel({ interval: 2000 }) In my layout: <%= javascript_include_tag 'jquery-1.7.2', 'jquery.validate.min','application' %> Where is problem ?

    Read the article

  • impress.js Navigation with active class

    - by ArtGoddess
    I would like to use impress.js in order to make a website, with a navigation bar. In each slide, the corresponding anchor or div must have an "active" class, in order to achieve a different link appearance. I have followed all instructions provided here: https://github.com/Ralt/impress.js/commit/f88feb8cae704ce27bd2168bdb77768f516ac2da#L2R605 but the "active" class on the correct menu must be added. This is the code that generates the menu items. How can I add for example the "active" class in the first link? /* ************************ MENU ***************************** */ // Capitalize first letter of string // @see http://stackoverflow.com/a/1026087/851498 var capitalize = function( str ) { return str.charAt(0).toUpperCase() + str.slice(1); } // `showMenu` API function creates the menu // It defines the names of each entry by the id capitalized. var showMenu = function() { // Create the menu wrapper and the element that will be cloned // for each entry. var menu = document.createElement('div'), el = document.createElement('div'); // Apply some classes menu.className = 'menu'; el.className = 'menu-item'; // Create an element that will be the "button" and append it // to the menu var button = document.createElement('div'); button.className = 'menu-button'; button.textContent = 'Menu'; menu.appendChild(button); // Now, for each div in #impress, add an entry to the menu [].forEach.call(byId('impress').firstElementChild.children, function( child, index ) { var newEl = el.cloneNode(), i = index + 1, text = i + '. ' + capitalize(child.id); // Set the text of the new element newEl.textContent = text; // Add an onclick event to the new element // We need to use a closure to make sure the index is correct (function( index ) { newEl.addEventListener('click', function() { goto(index); }); }( index )); // And append the new element to the menu menu.appendChild(newEl); }); // And append the menu to #impress document.body.appendChild(menu); }; Then, in each click it must be removed the active class on the current, and add it to the clicked element. // Remove the active class from the current active document.querySelector( '.active' )[ 0 ].classList.remove( 'active' ); // And add it to the clicked index byId('impress').firstElementChild.children[ index ].classList.add( 'active' ); Where do I have to apply this code? Thank you!

    Read the article

  • Haskell Monad bind currying

    - by Chime
    I am currently in need of a bit of brain training and I found this article on Haskell and Monads I'm having trouble with exercise 7 re. Randomised function bind. To make the problem even simpler to experiment, I replaced the StdGen type with an unspecified type. So instead of... bind :: (a -> StdGen -> (b,StdGen)) -> (StdGen -> (a,StdGen)) -> (StdGen -> (b,StdGen)) I used... bind :: (a -> c -> (b,c)) -> (c -> (a,c)) -> (c -> (b,c)) and for the actual function impelemtation (just straight from the exercise) bind f x seed = let (x',seed') = x seed in f x' seed' and also 2 randomised functions to trial with: rndf1 :: (Num a, Num b) => a -> b -> (a,b) rndf1 a s = (a+1,s+1) rndf2 :: (Num a, Num b) => a -> b -> (a,b) rndf2 a s = (a+8,s+2) So with this in a Haskell compiler (ghci), I get... :t bind rndf2 bind rndf2 :: (Num a, Num c) => (c -> (a, c)) -> c -> (a, c) This matches the bind curried with rndf2 as the first parameter. But the thing I don't understand is how... :t bind rndf2 . rndf1 Suddenly gives bind rndf2 . rndf1 :: (Num a, Num c) => a -> c -> (a, c) This is the correct type of the composition that we are trying to produce because bind rndf2 . rndf1 Is a function that: takes the same parameter type(s) as rndf1 AND takes the return from rndf1 and pipes it as an input of rndf2 to return the same type as rndf2 rndf1 can take 2 parameters a -> c and rndf2 returns (a, c) so it matches that a composition of these function should have type: bind rndf2 . rndf1 :: (Num a, Num c) => a -> c -> (a, c) This does not match the naive type that I initially came up with for bind bind f :: (a -> b -> (c, d)) -> (c, d) -> (e, f) Here bind mythically takes a function that takes two parameters and produces a function that takes a tuple in order that the output from rndf1 can be fed into rndf2 why the bind function needs to be coded as it is Why the bind function does not have the naive type

    Read the article

  • Is catching NumberFormatException a bad practice?

    - by integeruser
    I have to parse a String that can assume hex values or other non-hex values 0xff, 0x31 or A, PC, label, and so on. I use this code to divide the two cases: String input = readInput(); try { int hex = Integer.decode(input); // use hex ... } catch (NumberFormatException e) { // input is not a hex, continue parsing } Can this code be considered "ugly" or difficult to read? Are there other (maybe more elegant) solutions? EDIT : I want to clarify that (in my case) a wrong input doesn't exist: i just need to distinguish if it is a hex number, or not. And just for completeness, i'm making a simple assebler for DCPU-16.

    Read the article

  • Generate "Finder.h" for a SIMBL plugin

    - by user1204395
    I'm trying to create a SIMBL plugin for Finder to add icon overlay over some files. I have this code: @implementation NSObject (FAIconOverlay) - (void)FAIconOverlay_TIconAndTextCell_drawIconWithFrame:(struct CGRect)arg1 { [self FAIconOverlay_TIconAndTextCell_drawIconWithFrame:arg1]; if (![self respondsToSelector:@selector(node)]) { return; } NSLog(@"%@", [[[NSClassFromString(@"FINode") nodeWithFENode:[(TNodeIconAndNameCell *)self node]] fullPath] lastPathComponent]); // Draw the icon overlay } - (void)FAIconOverlay_TDesktopIcon_drawIconInContext:(struct CGContext *)arg1 { [self FAIconOverlay_TDesktopIcon_drawIconInContext:arg1]; } @end I can draw the icon overlay but, when I try to get the path of the file I get a "Use of undeclared identifier TNodeIconAndNameCell". Looking this link < How to Write OS X Finder plugin I see that is neccessary to generate a Finder.h file... My question is: How to generate this file?? I tried running "class-dump -H Finder.app" but I get too more compiling errors Thank you very much!

    Read the article

  • "Outward" border-radius in css?

    - by MaxMackie
    Currently, the links at the top of my website look like this: However, I am trying to "round" the bottom edges of the buttons to make it look like they are coming out of the page and into the ribbon at the top. I am aware that you can hack it and add a "separator" div with rounded corners between each entry, but this would be difficult to do seeing at the borders used are not all from the same div. Also, it wouldn't be easy seeing as my buttons are very close to each other. The css for the "button": .button { border-top: 3px solid #A1C1BE; border-left: 3px solid #A1C1BE; border-right: 3px solid #A1C1BE; border-bottom: 0px; padding: 5px 8px 5px 8px; margin: 0 0 -9px 0; border-radius: 5px 5px 0 0; font-size: 12px; font-family: 'PT Sans', sans-serif; background-color: #f8f8ff; color: #484848; } css for the "ribbon": #top-wrapper { border-bottom: 5px solid #A1C1BE; width: 100%; background-color: #59554E; padding: 10px 0 0 0; color: #C0C0A8; } As you can see, the thicker border belongs to the ribbon which stretches the length of the webpage, whereas the thinner blue border is part of the button.

    Read the article

  • POP Forums v10 beta posted for ASP.NET MVC 4

    - by Jeff
    Finally got some momentum and replaced the beta formerly known as v9.3. You can get it here, where you’ll find the information below. You can also read my previous post on why I ditched jQuery Mobile. This is the beta for POP Forums v10, with the mobile special sauce. It requires ASP.NET MVC 4 RC, which you can download here. Of course, feel free to submit bugs to the issue tracker. See a live demo here: http://popforums.com/Forums What's new? Uses a very light weight CSS and Javascript package to provide a touch-friendly interface for mobile devices. Numbers are formatted (sensitive to culture) when 1,000 or higher. CSS is more integration friendly, and specific to the ForumContainer element. Mail delivery from queue is now parallel, so you can specify a sending interval, and the number of messages to process on each interval. Background "services" refactored, and will only run with a call on app start to PopForumsActivation.StartServices(). This is partly to facilitate future use in Web farms/multiple Web roles. Update to jQuery v1.7.1. Replaced use of .live() with .on() in script, pursuant to jQuery update, which deprecates .live(). FIX: Bug in topic repository around caching keys for single-server data layer. FIX: Pager links on recent topics pointed to incorrect route. FIX: Deleting a post didn't update last user/post time. FIX: Ditched attempt at writing to event log with super failures, since almost no one has permission in production. FIX: Bug in grayed-out fields in admin mail setup. FIX: Weird color profiles would break loading of images for resize. FIX: TOS text on account sign-up was double encoded. Known issues None yet, but ditching jQuery Mobile from the previous beta turned out to be a good decision.

    Read the article

  • Interview questions about ASP.NET Web services.

    - by Jalpesh P. Vadgama
    I have seen there are lots of myth’s about asp.net web services in fresher level asp.net developers. So I decided to write a blog post about asp.net web services interview questions. Because I think this is the best way to reach fresher asp.net developers. Followings are few questions about asp.net web services. 1) What is asp.net web services? Ans: Web services are used to support http requests that formatted using xml,http and SOAP syntax. They interact with through standards xml messages through Soap. They are used to support interoperability. It has .asmx extension and .NET framework contains http handlers for web services to support http requested directly. 2) What kind of data can be returned web services web methods? Ans: It supports all the primitive data types and custom data types that can be encoded and serialized by xml. You can find more information about that from the following link. http://msdn.microsoft.com/en-us/library/bb552900.aspx 3) Is web services are only written in asp.net? Ans: No, It can be written by Java and PHP languages also. 4) Explain web method attributes in web services Ans: Web method attributes are added to a public class method to indicate that this method is exposed as a part of XML web services. You can have multiple web methods in a class. But it should be having public attributes as it will be exposed as xml web service part. You can find more information about web method attributes from following link. http://msdn.microsoft.com/en-us/library/byxd99hx(v=vs.71).aspx 5) What is SOA? Ans: SOA stands for “Services Oriented Architecture”. It is kind of service oriented architecture used to support different kind of computing platforms and applications. Web services in asp.net are one of the technologies that supports that kind of architecture.  You can call asp.net web services from any computing platforms and applications. 6) What is SOAP,WDSL and UDDI? Ans: SOAP stands “Simple Object Access protocol”. Web services will be interact with SOAP messages written in XML. SOAP is sometimes referred as “data wrapper” or “data envelope”.Its contains different xml tag that creates a whole SOAP message.  WSDL stand for “Web services Description Language”.  It is an xml document which is written according to standard specified by W3c. It is a kind of manual or document that describes how we can use and consume web service. Web services development software processes the WSDL document and generates SOAP messages that are needed for specific web service. UDDI stand for “Universal Discovery, Description and Integration”. Its is used for web services registries. You can find addresses of web services from UDDI.

    Read the article

  • .NET development on a “Retina” MacBook Pro

    - by Jeff
    The rumor that Apple would release a super high resolution version of its 15” laptop has been around for quite awhile, and one I watched closely. After more than three years with a 17” MacBook Pro, and all of the screen real estate it offered, I was ready to replace it with something much lighter. It was a fantastic machine, still doing 6 or 7 hours after 460 charge cycles, but I wanted lighter and faster. With the SSD I put in it, I was able to sell it for $750. The appeal of higher resolution goes way back, when I would plug into a projector and scale up. Consolas, as it turns out, is a nice looking font for code when it’s bigger. While I have mostly indifference for iOS, I have to admit that a higher dot pitch on the iPhone and iPad is pretty to look at. So I ordered the new 15” “Retina” model as soon as the Apple Store went live with it, and got it seven days later. I’ve been primarily using Parallels as my VM of choice from OS X for about five years. They recently put out an update for compatibility with the display, though I’m not entirely sure what that means. I figured there would have to be some messing around to get the VM to look right. The combination that seems to work best is this: Set the display in OS X to “more room,” which is roughly the equivalent of the 1920x1200 that my 17” did. It’s not as stunning as the text at the default 1440x900 equivalent (in OS X), but it’s still quite readable. Parallels still doesn’t entirely know what to do with the high resolution, though what it should do is somehow treat it as native. That flaw aside, I set the Windows 7 scaling to 125%, and it generally looks pretty good. It’s not really taking advantage of the display for sharpness, but hopefully that’s something that Parallels will figure out. Screen tweaking aside, I got the base model with 16 gigs of RAM, so I give the VM 8. I can boot a Windows 7 VM in 9 seconds. Nine seconds! The Windows Experience Index scores are all 7 and above, except for graphics, which are both at 6. Again, that’s in a VM. It’s hard to believe there’s something so fast in a little slim package like that. Hopefully this one gets me at least three years, like the last one.

    Read the article

  • Bundling in visual studio 2012 for web optimization

    - by Jalpesh P. Vadgama
    I have been writing a series of posts about Visual Studio 2012 features. This series describes what are the new features in the Visual Studio 2012. This post will also be part of Visual Studio 2012 feature series. As we know now days web applications or site are providing more and more features and due to that we have include lots of JavaScript and CSS files in our web application.So once we load site then we will have all the JavaScript  js files and CSS files loaded in the browsers and If you have lots of JavaScript files then its consumes lots of time when browser request them. Following images show the same situation over there.   Here you can see total 25 files loaded into the system and it's almost more than 1MB of total size. As we need to have our web application of site very responsive and need to have high performance application/site, this will be a performance bottleneck to our site. In situation like this, the bundling feature of Visual Studio 2012 and ASP.NET 4.5 comes very handy. With the help of this feature we do optimization there and we can increase performance of our application. To enable this feature in Visual Studio 2012 we just made debug=”false” in web.config of our application like following. Now once you enable this feature and run this application in the browser to see your traffic it will have less items like following. As you can see in the above image there are only 8 items. So after enabling bundling it will automatically convert all js and css files into the one request. Isn’t that cool feature? This feature will surely going to have great impact on performance. Hope you like it. Stay tuned for more.. Till then happy programming!!

    Read the article

  • Exit Infragistics, Enter Telerik

    - by Anthony Trudeau
    Today I made the purchase of the Premium Collection of components from Telerik.  This follows an evaluation I’ve been doing to replace the Infragistics components we currently use for Windows Forms, ASP.NET MVC, and WPF. It was not a formal evaluation.  I had already decided to move the company away from Infragistics.  That decision was mostly born out of frustration with support over using the Infragistics components in my first production MVC application. One such issue was a simple scenario where you have a model that has a scalar property that can be one value out of a list.  The built-in combobox does this, but I was told by Infragistics support that they didn’t support it – and it took them several emails and days of waiting between responses to determine that.  I implemented this in Telerik in a minute not including the several minutes it took me to get a rudimentary understanding for the component and its API. Here’s the code using the built-in combobox:@Html.DropDownListFor(x => x.VendorId, new SelectList(ViewBag.Vendors, "VendorId", "VendorName", Model.VendorId), "Select Id") Here’s the code using the Telerik combobox:@(Html.Telerik().ComboBoxFor(model => model.VendorId) .AutoFill(true) .BindTo(new SelectList(ViewBag.Vendors, "VendorId", "VendorName", Model.VendorId)) )   I chose Telerik over other competitors based on the professional appearance of their website, and how easy it was to find information.  I’d like to say I had time to evaluate other Infragistics competitors.  Due to time constraints I had to make an initial decision based on superficial, but still important things. I picked Telerik with the plan to only look further at other companies if my evaluation didn’t meet my expectations.  Luckily they did, because I didn’t relish the thought of carving out more time to evaluate another set of components. Overall my experience with Telerik has been superior to Infragistics in every way.  The installation was easy using their control panel installer application.  Getting up to speed has been easy.  And the communication from Telerik has met my expectations.  And we’ll continue to be good as long as I don’t start getting email messages from a sales rep saying that they want to talk to me about training and consulting – I’m looking at you Infragistics.

    Read the article

  • WiX, MSDeploy and an appealing configuration/deployment paradigm

    - by alexhildyard
    I do a lot of application and server configuration; I've done this for many years and have tended to view the complexity of this strictly in terms of the complexity of the ultimate configuration to be deployed. For example, specific APIs aside, I would tend to regard installing a server certificate as a more complex activity than, say, copying a file or adding a Registry entry.My prejudice revolved around the idea of a sequential deployment script that not only had the explicit prescription to apply a specific server configuration, but also made the implicit presumption that the server in question was in a good known state. Scripts like this fail for hundreds of reasons -- the Default Website didn't exist; the application had already been deployed; the application had already been partially deployed and failed to rollback fully, and so on. And so the problem is that the more complex the configuration activity, the more scope for error in any individual part of that activity, and therefore the greater the chance the server in question will not end up at exactly the desired configuration level.Recently I was introduced to a completely different mindset, which, for want of a better turn of phrase, I will call the "make it so" mindset. It's extremely simple both to explain and to implement. In place of the head-down, imperative script you used to use, you substitute a set of checks -- much like exception handlers -- around each configuration activity, starting with a check of the current system state. Thus the configuration logic becomes: "IF these services aren't started then start them, and IF XYZ website doesn't exist then create it, and IF these shares don't exist then create them, and IF these shares aren't permissioned in some particular way, then permission them so." This works. Really well, in my experience. Scenario 1: You want to get a system into a good known state; it's already in a good known state; you quickly realise there is nothing to do.Scenario 2: You want to get the system into a good known state; your script is flawed or the system is bust; it cannot be put into that state. You know exactly where (at least part of) the problem is and why.Scenario 3: You want to get the system into a good known state; people are fiddling around with the system just now. That's fine. You do what you can, and later you come back and try it againScenario 4: No one wants to deploy anything; they want you to prove that the previous deployment was successful. So you re-run the deployment script with the "-WhatIf" flag. It reports that there was nothing to change. There's your proof.I mentioned two technologies in the title -- MSI and MSDeploy. I am thinking specifically of the conversation that took place here. Having worked with both technologies, I think Rob Mensching's response is appropriately nuanced, and in essence the difference is this: sometimes your target is either to achieve a specific new server state, or to rollback to a known good one. Then again, your target may be to configure what you can, and to understand what you can't. Implicitly MSDeploy's "rollback" is simply to redeploy the previous version, whereas a well-crafted MSI will actively put your system into that state without further intervention. Either way, if all goes well it will leave you with a system in one of two states, whereas MSDeploy could leave your system in one of many states. The key is that MSDeploy and MSI are complementary technologies; which suits you best depends as much on Operational guidance as your Configuration remit.What I wanted to say was that I have always been for atomic, transactional-based configuration, but having worked with the "make it so" paradigm, I have been favourably impressed by the actual results. I'm tempted to put a more technical post up on this in due course.

    Read the article

  • Why is Double.Parse so slow?

    - by alexhildyard
    I was recently investigating a bottleneck in one of my applications, which read a CSV file from disk using a TextReader a line at a time, split the tokens, called Double.Parse on each one, then shunted the results into an object list. I was surprised to find it was actually the Double.Parse which seemed to be taking up most of the time.Googling turned up this, which is a little unfocused in places but throws out some excellent ideas:It makes more sense to work with binary format directly, rather than coerce strings into doublesThere is a significant performance improvement in composing doubles directly from the byte stream via long intermediariesString.Split is inefficient on fixed length recordsIn fact it turned out that my problem was more insidious and also more mundane -- a simple case of bad data in, bad data out. Since I had been serialising my Doubles as strings, when I inadvertently divided by zero and produced a "NaN", this of course was serialised as well without error. And because I was reading in using Double.Parse, these "NaN" fields were also (correctly) populating real Double objects without error. The issue is that Double.Parse("NaN") is incredibly slow. In fact, it is of the order of 2000x slower than parsing a valid double. For example, the code below gave me results of 357ms to parse 1000 NaNs, versus 15ms to parse 100,000 valid doubles.            const int invalid_iterations = 1000;            const int valid_iterations = invalid_iterations * 100;            const string invalid_string = "NaN";            const string valid_string = "3.14159265";            DateTime start = DateTime.Now;                        for (int i = 0; i < invalid_iterations; i++)            {                double invalid_double = Double.Parse(invalid_string);            }            Console.WriteLine(String.Format("{0} iterations of invalid double, time taken (ms): {1}",                invalid_iterations,                ((TimeSpan)DateTime.Now.Subtract(start)).Milliseconds            ));            start = DateTime.Now;            for (int i = 0; i < valid_iterations; i++)            {                double valid_double = Double.Parse(valid_string);            }            Console.WriteLine(String.Format("{0} iterations of valid double, time taken (ms): {1}",                valid_iterations,                ((TimeSpan)DateTime.Now.Subtract(start)).Milliseconds            )); I think the moral is to look at the context -- specifically the data -- as well as the code itself. Once I had corrected my data, the performance of Double.Parse was perfectly acceptable, and while clearly it could have been improved, it was now sufficient to my needs.

    Read the article

  • Liskov Substitution Principle and the Oft Forgot Third Wheel

    - by Stacy Vicknair
    Liskov Substitution Principle (LSP) is a principle of object oriented programming that many might be familiar with from the SOLID principles mnemonic from Uncle Bob Martin. The principle highlights the relationship between a type and its subtypes, and, according to Wikipedia, is defined by Barbara Liskov and Jeanette Wing as the following principle:   Let be a property provable about objects of type . Then should be provable for objects of type where is a subtype of .   Rectangles gonna rectangulate The iconic example of this principle is illustrated with the relationship between a rectangle and a square. Let’s say we have a class named Rectangle that had a property to set width and a property to set its height. 1: Public Class Rectangle 2: Overridable Property Width As Integer 3: Overridable Property Height As Integer 4: End Class   We all at some point here that inheritance mocks an “IS A” relationship, and by gosh we all know square IS A rectangle. So let’s make a square class that inherits from rectangle. However, squares do maintain the same length on every side, so let’s override and add that behavior. 1: Public Class Square 2: Inherits Rectangle 3:  4: Private _sideLength As Integer 5:  6: Public Overrides Property Width As Integer 7: Get 8: Return _sideLength 9: End Get 10: Set(value As Integer) 11: _sideLength = value 12: End Set 13: End Property 14:  15: Public Overrides Property Height As Integer 16: Get 17: Return _sideLength 18: End Get 19: Set(value As Integer) 20: _sideLength = value 21: End Set 22: End Property 23: End Class   Now, say we had the following test: 1: Public Sub SetHeight_DoesNotAffectWidth(rectangle As Rectangle) 2: 'arrange 3: Dim expectedWidth = 4 4: rectangle.Width = 4 5:  6: 'act 7: rectangle.Height = 7 8:  9: 'assert 10: Assert.AreEqual(expectedWidth, rectangle.Width) 11: End Sub   If we pass in a rectangle, this test passes just fine. What if we pass in a square?   This is where we see the violation of Liskov’s Principle! A square might "IS A” to a rectangle, but we have differing expectations on how a rectangle should function than how a square should! Great expectations Here’s where we pat ourselves on the back and take a victory lap around the office and tell everyone about how we understand LSP like a boss. And all is good… until we start trying to apply it to our work. If I can’t even change functionality on a simple setter without breaking the expectations on a parent class, what can I do with subtyping? Did Liskov just tell me to never touch subtyping again? The short answer: NO, SHE DIDN’T. When I first learned LSP, and from those I’ve talked with as well, I overlooked a very important but not appropriately stressed quality of the principle: our expectations. Our inclination is to want a logical catch-all, where we can easily apply this principle and wipe our hands, drop the mic and exit stage left. That’s not the case because in every different programming scenario, our expectations of the parent class or type will be different. We have to set reasonable expectations on the behaviors that we expect out of the parent, then make sure that those expectations are met by the child. Any expectations not explicitly expected of the parent aren’t expected of the child either, and don’t register as a violation of LSP that prevents implementation. You can see the flexibility mentioned in the Wikipedia article itself: A typical example that violates LSP is a Square class that derives from a Rectangle class, assuming getter and setter methods exist for both width and height. The Square class always assumes that the width is equal with the height. If a Square object is used in a context where a Rectangle is expected, unexpected behavior may occur because the dimensions of a Square cannot (or rather should not) be modified independently. This problem cannot be easily fixed: if we can modify the setter methods in the Square class so that they preserve the Square invariant (i.e., keep the dimensions equal), then these methods will weaken (violate) the postconditions for the Rectangle setters, which state that dimensions can be modified independently. Violations of LSP, like this one, may or may not be a problem in practice, depending on the postconditions or invariants that are actually expected by the code that uses classes violating LSP. Mutability is a key issue here. If Square and Rectangle had only getter methods (i.e., they were immutable objects), then no violation of LSP could occur. What this means is that the above situation with a rectangle and a square can be acceptable if we do not have the expectation for width to leave height unaffected, or vice-versa, in our application. Conclusion – the oft forgot third wheel Liskov Substitution Principle is meant to act as a guidance and warn us against unexpected behaviors. Objects can be stateful and as a result we can end up with unexpected situations if we don’t code carefully. Specifically when subclassing, make sure that the subclass meets the expectations held to its parent. Don’t let LSP think you cannot deviate from the behaviors of the parent, but understand that LSP is meant to highlight the importance of not only the parent and the child class, but also of the expectations WE set for the parent class and the necessity of meeting those expectations in order to help prevent sticky situations.   Code examples, in both VB and C# Technorati Tags: LSV,Liskov Substitution Principle,Uncle Bob,Robert Martin,Barbara Liskov,Liskov

    Read the article

  • BizTalk 2010 - BAM Portal - No Views to Display

    - by Stuart Brierley
    Our latest BizTalk Server 2010 development project is utilising BizTalk as the integration ring around a new and sizable implementaion of Dynamics AX 2012. With this project we have decided to use BAM to monitor the processes within our various new applications.Although I have been specialising in BizTalk for around 9 years, this is my first time using BAM so it is an interesting process to be going through.Recently when deploying a solution I was attempting to check the BAM Portal to see that the View that I had created was properly deployed and that the Activity I was populating was being surfaced in the Portal as expected. Initially I was presented with the message "No view to display" in the "My Views" area of the BAM Portal landing page.This was because you need to set the permissions on the views that you want to see from the command line using the bm.exe tool:bm.exe add-account -AccountName:YourServerOrDomain\YourUsername -View:YourViewThis tool can be found in the BAM folder at the BizTalk installation location:C:\Program Files (x86)\Microsoft BizTalk Server 2010\Tracking

    Read the article

  • Reverse SSH tunnel: how can I send my port number to the server?

    - by Tom
    I have two machines, Client and Server. Client (who is behind a corporate firewall) opens a reverse SSH tunnel to Server, which has a publicly-accessible IP address, using this command: ssh -nNT -R0:localhost:2222 [email protected] In OpenSSH 5.3+, the 0 occurring just after the -R means "pick an available port" rather than explicitly calling for one. The reason I'm doing this is because I don't want to pick a port that's already in use. In truth, there are actually many Clients out there that need to set up similar tunnels. The problem at this point is that the server does not know which Client is which. If we want to connect back to one of these Clients (via localhost) then how do we know which port refers to which client? I'm aware that ssh reports the port number to the command line when used in the above manner. However, I'd also like to use autossh to keep the sessions alive. autossh runs its child process via fork/exec, presumably, so that the output of the actual ssh command is lost in the ether. Furthermore, I can't think of any other way to get the remote port from Client. Thus, I'm wondering if there is a way to determine this port on Server. One idea I have is to somehow use /etc/sshrc, which is supposedly a script that runs for every connection. However, I don't know how one would get the pertinent information here (perhaps the PID of the particular sshd process handling that connection?) I'd love some pointers. Thanks!

    Read the article

  • mod_rewrite to redirect to specific WP page

    - by djdy
    The goal is to redirect all requests coming to Wordpress from IE 6 and 7, to a specific Wordpress page using mod_rewrite. My confusion comes from multiple conditions that are needed for the rewrite not entering an endless loop once on the specific Wordpress page. So the condition must be: (IE 6 or 7) and request is not the same as the page we are sending them to. I've tried things along the lines of: RewriteCond %{HTTP_USER_AGENT} MSIE\ ([67])\. RewriteCond %{REQUEST_URI} !iepage RewriteRule .* /iepage/ [R] In IE 6 and 7, I get page cannot be displayed errors. Could it really mean too many redirects, because the 2nd condition isn't working?

    Read the article

  • Justification of Amazon EC2 Performance

    - by Adroidist
    I have a .jar file that represents a server which receives over TCP an image in bytes (of size at most 500 kb) and writes it file. It then sobels this image and sends it over TCP socket to the client side. I ran it on my laptop and it was very fast. But when I put it on Amazon EC2 server m1.large instance, i found out it is very slow - around 10 times slower. It might be the inefficiency in the code algorithm but in fact my code is nothing but receive image (like any byte file) run the sobel algorithm and send. I have the following questions: 1- Is it normal performance of Amazon EC2 server- I have read the following links link1 and link2 2- Even if the code is not that efficient, the server is finally handling a very low load (just one client), does the "inefficient" code justify such performance? 3- My laptop is dual core only...Why would the amazon ec2 server have worse performance that my laptop? How is this explained? Excuse me for my ignorance.

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19  | Next Page >