Search Results

Search found 1950 results on 78 pages for 'james watt'.

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

  • C#/.NET Little Wonders: Skip() and Take()

    - by James Michael Hare
    Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. I’ve covered many valuable methods from System.Linq class library before, so you already know it’s packed with extension-method goodness.  Today I’d like to cover two small families I’ve neglected to mention before: Skip() and Take().  While these methods seem so simple, they are an easy way to create sub-sequences for IEnumerable<T>, much the way GetRange() creates sub-lists for List<T>. Skip() and SkipWhile() The Skip() family of methods is used to ignore items in a sequence until either a certain number are passed, or until a certain condition becomes false.  This makes the methods great for starting a sequence at a point possibly other than the first item of the original sequence.   The Skip() family of methods contains the following methods (shown below in extension method syntax): Skip(int count) Ignores the specified number of items and returns a sequence starting at the item after the last skipped item (if any).  SkipWhile(Func<T, bool> predicate) Ignores items as long as the predicate returns true and returns a sequence starting with the first item to invalidate the predicate (if any).  SkipWhile(Func<T, int, bool> predicate) Same as above, but passes not only the item itself to the predicate, but also the index of the item.  For example: 1: var list = new[] { 3.14, 2.72, 42.0, 9.9, 13.0, 101.0 }; 2:  3: // sequence contains { 2.72, 42.0, 9.9, 13.0, 101.0 } 4: var afterSecond = list.Skip(1); 5: Console.WriteLine(string.Join(", ", afterSecond)); 6:  7: // sequence contains { 42.0, 9.9, 13.0, 101.0 } 8: var afterFirstDoubleDigit = list.SkipWhile(v => v < 10.0); 9: Console.WriteLine(string.Join(", ", afterFirstDoubleDigit)); Note that the SkipWhile() stops skipping at the first item that returns false and returns from there to the rest of the sequence, even if further items in that sequence also would satisfy the predicate (otherwise, you’d probably be using Where() instead, of course). If you do use the form of SkipWhile() which also passes an index into the predicate, then you should keep in mind that this is the index of the item in the sequence you are calling SkipWhile() from, not the index in the original collection.  That is, consider the following: 1: var list = new[] { 1.0, 1.1, 1.2, 2.2, 2.3, 2.4 }; 2:  3: // Get all items < 10, then 4: var whatAmI = list 5: .Skip(2) 6: .SkipWhile((i, x) => i > x); For this example the result above is 2.4, and not 1.2, 2.2, 2.3, 2.4 as some might expect.  The key is knowing what the index is that’s passed to the predicate in SkipWhile().  In the code above, because Skip(2) skips 1.0 and 1.1, the sequence passed to SkipWhile() begins at 1.2 and thus it considers the “index” of 1.2 to be 0 and not 2.  This same logic applies when using any of the extension methods that have an overload that allows you to pass an index into the delegate, such as SkipWhile(), TakeWhile(), Select(), Where(), etc.  It should also be noted, that it’s fine to Skip() more items than exist in the sequence (an empty sequence is the result), or even to Skip(0) which results in the full sequence.  So why would it ever be useful to return Skip(0) deliberately?  One reason might be to return a List<T> as an immutable sequence.  Consider this class: 1: public class MyClass 2: { 3: private List<int> _myList = new List<int>(); 4:  5: // works on surface, but one can cast back to List<int> and mutate the original... 6: public IEnumerable<int> OneWay 7: { 8: get { return _myList; } 9: } 10:  11: // works, but still has Add() etc which throw at runtime if accidentally called 12: public ReadOnlyCollection<int> AnotherWay 13: { 14: get { return new ReadOnlyCollection<int>(_myList); } 15: } 16:  17: // immutable, can't be cast back to List<int>, doesn't have methods that throw at runtime 18: public IEnumerable<int> YetAnotherWay 19: { 20: get { return _myList.Skip(0); } 21: } 22: } This code snippet shows three (among many) ways to return an internal sequence in varying levels of immutability.  Obviously if you just try to return as IEnumerable<T> without doing anything more, there’s always the danger the caller could cast back to List<T> and mutate your internal structure.  You could also return a ReadOnlyCollection<T>, but this still has the mutating methods, they just throw at runtime when called instead of giving compiler errors.  Finally, you can return the internal list as a sequence using Skip(0) which skips no items and just runs an iterator through the list.  The result is an iterator, which cannot be cast back to List<T>.  Of course, there’s many ways to do this (including just cloning the list, etc.) but the point is it illustrates a potential use of using an explicit Skip(0). Take() and TakeWhile() The Take() and TakeWhile() methods can be though of as somewhat of the inverse of Skip() and SkipWhile().  That is, while Skip() ignores the first X items and returns the rest, Take() returns a sequence of the first X items and ignores the rest.  Since they are somewhat of an inverse of each other, it makes sense that their calling signatures are identical (beyond the method name obviously): Take(int count) Returns a sequence containing up to the specified number of items. Anything after the count is ignored. TakeWhile(Func<T, bool> predicate) Returns a sequence containing items as long as the predicate returns true.  Anything from the point the predicate returns false and beyond is ignored. TakeWhile(Func<T, int, bool> predicate) Same as above, but passes not only the item itself to the predicate, but also the index of the item. So, for example, we could do the following: 1: var list = new[] { 1.0, 1.1, 1.2, 2.2, 2.3, 2.4 }; 2:  3: // sequence contains 1.0 and 1.1 4: var firstTwo = list.Take(2); 5:  6: // sequence contains 1.0, 1.1, 1.2 7: var underTwo = list.TakeWhile(i => i < 2.0); The same considerations for SkipWhile() with index apply to TakeWhile() with index, of course.  Using Skip() and Take() for sub-sequences A few weeks back, I talked about The List<T> Range Methods and showed how they could be used to get a sub-list of a List<T>.  This works well if you’re dealing with List<T>, or don’t mind converting to List<T>.  But if you have a simple IEnumerable<T> sequence and want to get a sub-sequence, you can also use Skip() and Take() to much the same effect: 1: var list = new List<double> { 1.0, 1.1, 1.2, 2.2, 2.3, 2.4 }; 2:  3: // results in List<T> containing { 1.2, 2.2, 2.3 } 4: var subList = list.GetRange(2, 3); 5:  6: // results in sequence containing { 1.2, 2.2, 2.3 } 7: var subSequence = list.Skip(2).Take(3); I say “much the same effect” because there are some differences.  First of all GetRange() will throw if the starting index or the count are greater than the number of items in the list, but Skip() and Take() do not.  Also GetRange() is a method off of List<T>, thus it can use direct indexing to get to the items much more efficiently, whereas Skip() and Take() operate on sequences and may actually have to walk through the items they skip to create the resulting sequence.  So each has their pros and cons.  My general rule of thumb is if I’m already working with a List<T> I’ll use GetRange(), but for any plain IEnumerable<T> sequence I’ll tend to prefer Skip() and Take() instead. Summary The Skip() and Take() families of LINQ extension methods are handy for producing sub-sequences from any IEnumerable<T> sequence.  Skip() will ignore the specified number of items and return the rest of the sequence, whereas Take() will return the specified number of items and ignore the rest of the sequence.  Similarly, the SkipWhile() and TakeWhile() methods can be used to skip or take items, respectively, until a given predicate returns false.    Technorati Tags: C#, CSharp, .NET, LINQ, IEnumerable<T>, Skip, Take, SkipWhile, TakeWhile

    Read the article

  • Community Programming

    - by James Hill
    Background I just began working for a religious non-profit organization. As with most non-profits, the organization is resource-poor and has no IT department to speak of. In my two months here I've received 20 requests for websites, apps, and internal automation. Many of these 20 requests have merit and would benefit the organization. I'm a .net web developer and as such the open source community is relatively foreign to me... Question For the sake of this question, lets say I'm talking about building a single, large, website. Does software (web based, hopefully) exist that would allow me to post requirements and assets (graphics and CSS) for a site, and then invite programmers to participate in the sites development? As a simple example, I could post the requirements and data for the about us page and an individual would indicate that they could/would fulfill the requirement. Upon completion, they could upload the new source code to the shared repository (github).

    Read the article

  • Pre-built Oracle VirtualBox Images

    - by james.bayer
    I’m thrilled to see that Justin Kestelyn has a post that pre-built Oracle VirtualBox images are now available on OTN.  There are VMs for various Oracle software stacks including one for Database, one for Java with Glassfish, and one for SOA and BPM products that includes WebLogic Server. This is just one example of the synergy of a combined Oracle and Sun delivering improvements for customers.  These VMs make it even more straight-forward to get started with Oracle software in a development environment without having to worry about initial software installation and configuration. I’ve been a bit quiet lately on the blogging front, but I’m currently working on another area leveraging the best of Oracle and Sun.  Oracle is uniquely positioned to deliver engineered systems that optimize the entire stack of software and hardware.  You’ve probably seen the announcements about Exalogic and I’m excited about the potential to deliver major advancements for middleware.  More to come…

    Read the article

  • C#/.NET Little Wonders: Comparer&lt;T&gt;.Default

    - by James Michael Hare
    I’ve been working with a wonderful team on a major release where I work, which has had the side-effect of occupying most of my spare time preparing, testing, and monitoring.  However, I do have this Little Wonder tidbit to offer today. Introduction The IComparable<T> interface is great for implementing a natural order for a data type.  It’s a very simple interface with a single method: 1: public interface IComparer<in T> 2: { 3: // Compare two instances of same type. 4: int Compare(T x, T y); 5: }  So what do we expect for the integer return value?  It’s a pseudo-relative measure of the ordering of x and y, which returns an integer value in much the same way C++ returns an integer result from the strcmp() c-style string comparison function: If x == y, returns 0. If x > y, returns > 0 (often +1, but not guaranteed) If x < y, returns < 0 (often –1, but not guaranteed) Notice that the comparison operator used to evaluate against zero should be the same comparison operator you’d use as the comparison operator between x and y.  That is, if you want to see if x > y you’d see if the result > 0. The Problem: Comparing With null Can Be Messy This gets tricky though when you have null arguments.  According to the MSDN, a null value should be considered equal to a null value, and a null value should be less than a non-null value.  So taking this into account we’d expect this instead: If x == y (or both null), return 0. If x > y (or y only is null), return > 0. If x < y (or x only is null), return < 0. But here’s the problem – if x is null, what happens when we attempt to call CompareTo() off of x? 1: // what happens if x is null? 2: x.CompareTo(y); It’s pretty obvious we’ll get a NullReferenceException here.  Now, we could guard against this before calling CompareTo(): 1: int result; 2:  3: // first check to see if lhs is null. 4: if (x == null) 5: { 6: // if lhs null, check rhs to decide on return value. 7: if (y == null) 8: { 9: result = 0; 10: } 11: else 12: { 13: result = -1; 14: } 15: } 16: else 17: { 18: // CompareTo() should handle a null y correctly and return > 0 if so. 19: result = x.CompareTo(y); 20: } Of course, we could shorten this with the ternary operator (?:), but even then it’s ugly repetitive code: 1: int result = (x == null) 2: ? ((y == null) ? 0 : -1) 3: : x.CompareTo(y); Fortunately, the null issues can be cleaned up by drafting in an external Comparer.  The Soltuion: Comparer<T>.Default You can always develop your own instance of IComparer<T> for the job of comparing two items of the same type.  The nice thing about a IComparer is its is independent of the things you are comparing, so this makes it great for comparing in an alternative order to the natural order of items, or when one or both of the items may be null. 1: public class NullableIntComparer : IComparer<int?> 2: { 3: public int Compare(int? x, int? y) 4: { 5: return (x == null) 6: ? ((y == null) ? 0 : -1) 7: : x.Value.CompareTo(y); 8: } 9: }  Now, if you want a custom sort -- especially on large-grained objects with different possible sort fields -- this is the best option you have.  But if you just want to take advantage of the natural ordering of the type, there is an easier way.  If the type you want to compare already implements IComparable<T> or if the type is System.Nullable<T> where T implements IComparable, there is a class in the System.Collections.Generic namespace called Comparer<T> which exposes a property called Default that will create a singleton that represents the default comparer for items of that type.  For example: 1: // compares integers 2: var intComparer = Comparer<int>.Default; 3:  4: // compares DateTime values 5: var dateTimeComparer = Comparer<DateTime>.Default; 6:  7: // compares nullable doubles using the null rules! 8: var nullableDoubleComparer = Comparer<double?>.Default;  This helps you avoid having to remember the messy null logic and makes it to compare objects where you don’t know if one or more of the values is null. This works especially well when creating say an IComparer<T> implementation for a large-grained class that may or may not contain a field.  For example, let’s say you want to create a sorting comparer for a stock open price, but if the market the stock is trading in hasn’t opened yet, the open price will be null.  We could handle this (assuming a reasonable Quote definition) like: 1: public class Quote 2: { 3: // the opening price of the symbol quoted 4: public double? Open { get; set; } 5:  6: // ticker symbol 7: public string Symbol { get; set; } 8:  9: // etc. 10: } 11:  12: public class OpenPriceQuoteComparer : IComparer<Quote> 13: { 14: // Compares two quotes by opening price 15: public int Compare(Quote x, Quote y) 16: { 17: return Comparer<double?>.Default.Compare(x.Open, y.Open); 18: } 19: } Summary Defining a custom comparer is often needed for non-natural ordering or defining alternative orderings, but when you just want to compare two items that are IComparable<T> and account for null behavior, you can use the Comparer<T>.Default comparer generator and you’ll never have to worry about correct null value sorting again.     Technorati Tags: C#,.NET,Little Wonders,BlackRabbitCoder,IComparable,Comparer

    Read the article

  • C#/.NET Little Wonders: Static Char Methods

    - by James Michael Hare
    Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. Often times in our code we deal with the bigger classes and types in the BCL, and occasionally forgot that there are some nice methods on the primitive types as well.  Today we will discuss some of the handy static methods that exist on the char (the C# alias of System.Char) type. The Background I was examining a piece of code this week where I saw the following: 1: // need to get the 5th (offset 4) character in upper case 2: var type = symbol.Substring(4, 1).ToUpper(); 3:  4: // test to see if the type is P 5: if (type == "P") 6: { 7: // ... do something with P type... 8: } Is there really any error in this code?  No, but it still struck me wrong because it is allocating two very short-lived throw-away strings, just to store and manipulate a single char: The call to Substring() generates a new string of length 1 The call to ToUpper() generates a new upper-case version of the string from Step 1. In my mind this is similar to using ToUpper() to do a case-insensitive compare: it isn’t wrong, it’s just much heavier than it needs to be (for more info on case-insensitive compares, see #2 in 5 More Little Wonders). One of my favorite books is the C++ Coding Standards: 101 Rules, Guidelines, and Best Practices by Sutter and Alexandrescu.  True, it’s about C++ standards, but there’s also some great general programming advice in there, including two rules I love:         8. Don’t Optimize Prematurely         9. Don’t Pessimize Prematurely We all know what #8 means: don’t optimize when there is no immediate need, especially at the expense of readability and maintainability.  I firmly believe this and in the axiom: it’s easier to make correct code fast than to make fast code correct.  Optimizing code to the point that it becomes difficult to maintain often gains little and often gives you little bang for the buck. But what about #9?  Well, for that they state: “All other things being equal, notably code complexity and readability, certain efficient design patterns and coding idioms should just flow naturally from your fingertips and are no harder to write then the pessimized alternatives. This is not premature optimization; it is avoiding gratuitous pessimization.” Or, if I may paraphrase: “where it doesn’t increase the code complexity and readability, prefer the more efficient option”. The example code above was one of those times I feel where we are violating a tacit C# coding idiom: avoid creating unnecessary temporary strings.  The code creates temporary strings to hold one char, which is just unnecessary.  I think the original coder thought he had to do this because ToUpper() is an instance method on string but not on char.  What he didn’t know, however, is that ToUpper() does exist on char, it’s just a static method instead (though you could write an extension method to make it look instance-ish). This leads me (in a long-winded way) to my Little Wonders for the day… Static Methods of System.Char So let’s look at some of these handy, and often overlooked, static methods on the char type: IsDigit(), IsLetter(), IsLetterOrDigit(), IsPunctuation(), IsWhiteSpace() Methods to tell you whether a char (or position in a string) belongs to a category of characters. IsLower(), IsUpper() Methods that check if a char (or position in a string) is lower or upper case ToLower(), ToUpper() Methods that convert a single char to the lower or upper equivalent. For example, if you wanted to see if a string contained any lower case characters, you could do the following: 1: if (symbol.Any(c => char.IsLower(c))) 2: { 3: // ... 4: } Which, incidentally, we could use a method group to shorten the expression to: 1: if (symbol.Any(char.IsLower)) 2: { 3: // ... 4: } Or, if you wanted to verify that all of the characters in a string are digits: 1: if (symbol.All(char.IsDigit)) 2: { 3: // ... 4: } Also, for the IsXxx() methods, there are overloads that take either a char, or a string and an index, this means that these two calls are logically identical: 1: // check given a character 2: if (char.IsUpper(symbol[0])) { ... } 3:  4: // check given a string and index 5: if (char.IsUpper(symbol, 0)) { ... } Obviously, if you just have a char, then you’d just use the first form.  But if you have a string you can use either form equally well. As a side note, care should be taken when examining all the available static methods on the System.Char type, as some seem to be redundant but actually have very different purposes.  For example, there are IsDigit() and IsNumeric() methods, which sound the same on the surface, but give you different results. IsDigit() returns true if it is a base-10 digit character (‘0’, ‘1’, … ‘9’) where IsNumeric() returns true if it’s any numeric character including the characters for ½, ¼, etc. Summary To come full circle back to our opening example, I would have preferred the code be written like this: 1: // grab 5th char and take upper case version of it 2: var type = char.ToUpper(symbol[4]); 3:  4: if (type == 'P') 5: { 6: // ... do something with P type... 7: } Not only is it just as readable (if not more so), but it performs over 3x faster on my machine:    1,000,000 iterations of char method took: 30 ms, 0.000050 ms/item.    1,000,000 iterations of string method took: 101 ms, 0.000101 ms/item. It’s not only immediately faster because we don’t allocate temporary strings, but as an added bonus there less garbage to collect later as well.  To me this qualifies as a case where we are using a common C# performance idiom (don’t create unnecessary temporary strings) to make our code better. Technorati Tags: C#,CSharp,.NET,Little Wonders,char,string

    Read the article

  • Making profit from a social network

    - by James P.
    This follows similar questions but I'd like to see if anything particular comes out of it due to the nature of site. In short, I've taken up the role of webmaster for a small social network site and wish to make it profitable to at least cover the running costs. The site is linked to a commerce and presents are offered to members according to the number of points they've accumulated through various actions. The site is running on shared hosting so it's probably dirt cheap but the presents can be expensive as a whole and some money has already been invested into the project. One idea I have is to seek some sponsors that would be willing to offer presents or special offers in return for publicity. I don't know if this will be easy or not. I'm also looking into adapting hosting to perhaps move static files to a cheaper online storage medium (see Ideas for reducing storage needs and/or costs (lots of images)). Other suggestions are welcome.

    Read the article

  • How to Kill and Alternate X session via cli

    - by L. D. James
    Can someone tell me how to remove dormant X sessions. This question is similar to Logging out other users from the command line, but more specific to controlling X displays which I find hard to kill. I used the command "who -u" to get the session of the other screens: $ who -u Which gave me: user1 :0 2014-08-18 12:08 ? 2891 (:0) user1 pts/26 2014-08-18 16:11 17:18 3984 (:0) user2 :1 2014-08-18 18:21 ? 25745 (:1) user1 pts/27 2014-08-18 23:10 00:27 3984 (:0) user1 pts/32 2014-08-18 23:10 10:42 3984 (:0) user1 pts/46 2014-08-18 23:14 00:04 3984 (:0) user1 pts/48 2014-08-19 04:10 . 3984 (:0) The kill -9 25745 doesn't appear to do anything. I have a workshop where a number of users will use the computer under their own login. After the workshop is over there are a number of logins that are left open. I would prefer to kill the open sessions rather than try to log into each users' screen. Again, this question isn't just about logging users' out. I'm hoping to get clarity also for killing/removing stuck processes that are hard to kill. New Info While still pondering how to kill the process I wrote the following script, which did it: #!/bin/bash results=1 while [[ $results > 0 ]] do sudo kill -9 25745 results=$? echo -ne "Response:$results..." sleep 20 done After a graceful waiting period, if there isn't a better answer I'll mark this as answered with this resolution. This may resolve the problem with other stuck processes I have had in the past.

    Read the article

  • UEFI Boot Failure - Hang after Printing USB Information

    - by James
    I'm experiencing a really weird boot problem. With both 12.10 and 12.04LTS, the vast majority of kernels (and initrds) that I've tried boot, but hang immediately after printing out information about USB devices. This isn't exactly a full "hang" so to speak, as if I plug in a flash drive, I see information and a /dev/sd* entry printed to the screen. Post/pre-init scripts are not run, there is no handoff, nor busybox or VT prompt. Virtual terminals can't be changed (with Ctrl-Alt-Fx). For what I can see, init may have not been executed yet. With certain kernel and OS combinations however, (specifically 3.2.0-29), I get a full boot and am able to use the OS as if there is no problem. After 3.2.0-29, I've been hard pressed to find a kernel that works. Any idea what's happening or how to fix this? Or even a road to take? I've exhausted the first five pages of Google for every search term I can think of. This is a Lenovo Z580 (i5-3210M) with Phoenix SecureCore Tiano firmware, if that helps any.

    Read the article

  • The requested resource is not available

    - by James Pj
    I have written a Java servlet program and run it through local Tomcat 7, But it was showing following error : HTTP Status 404 - /skypark/registration type Status report message /skypark/registration description The requested resource is not available. Apache Tomcat/7.0.33 I don't know what was the reason for it my Html page is <html> <head> <title> User registration </title> </head> <body> <form action="registration" method="post"> <center> <h2><b>Skypark User Registration</b></h2> <table border="0"> <tr><td> First Name </td><td> <input type="text" name="fname"/></br> </td></tr><tr><td> Last Name </td><td> <input type="text" name="lname"/></br> </td></tr><tr><td> UserName </td><td> <input type="text" name="uname"></br> </td></tr><tr><td> Enter Password </td><td> <input type="password" name="pass"></br> </td></tr><tr><td> Re-Type Password </td><td> <input type="password" name="pass1"></br> </td></tr><tr><td> Enter Email ID </td><td> <input type="email" name="email1"></br> </td></tr><tr><td> Phone Number </td><td> <input type="number" name="phone"> </td></tr><tr><td> Gender<br> </td></tr><tr><td> <input type="radio" name="gender" value="Male">Male</input></br> </td></tr><tr><td> <input type="radio" name="gender" value="Female">Female</input></br> </td></tr><tr><td> Enter Your Date of Birth<br> </td><td> <Table Border=0> <tr> <td> Date </td> <td>Month</td> <td>Year</td> </tr><tr> <td> <select name="date"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> . . . have some code . . . </table> <input type="submit" value="Submit"></br> </center> </form> </body> </html> My servlet is : package skypark; import skypark.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class Registration extends HttpServlet { public static Connection prepareConnection()throws ClassNotFoundException,SQLException { String dcn="oracle.jdbc.driver.OracleDriver"; String url="jdbc:oracle:thin:@JamesPJ-PC:1521:skypark"; String usname="system"; String pass="tiger"; Class.forName(dcn); return DriverManager.getConnection(url,usname,pass); } public void doPost(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException { resp.setContentType("text/html"); PrintWriter out=resp.getWriter(); try { String phone1,uname,fname,lname,dob,address,city,state,country,pin,email,password,gender,lang,qual,relegion,privacy,hobbies,fav; uname=req.getParameter("uname"); fname=req.getParameter("fname"); lname=req.getParameter("lname"); dob=req.getParameter("date"); address=req.getParameter("address"); city=req.getParameter("city"); state=req.getParameter("state"); country=req.getParameter("country"); pin=req.getParameter("pin"); email=req.getParameter("email1"); password=req.getParameter("password"); gender=req.getParameter("gender"); phone1=req.getParameter("phone"); lang=""; qual=""; relegion=""; privacy=""; hobbies=""; fav=""; int phone=Integer.parseInt(phone1); Connection con=prepareConnection(); String Query="Insert into regdetails values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; PreparedStatement ps=con.prepareStatement(Query); ps.setString(1,uname); ps.setString(2,fname); ps.setString(3,lname); ps.setString(4,dob); ps.setString(5,address); ps.setString(6,city); ps.setString(7,state); ps.setString(8,country); ps.setString(9,pin); ps.setString(10,lang); ps.setString(11,qual); ps.setString(12,relegion); ps.setString(13,privacy); ps.setString(14,hobbies); ps.setString(15,fav); ps.setString(16,gender); int c=ps.executeUpdate(); String query="insert into passmanager values(?,?,?,?)"; PreparedStatement ps1=con.prepareStatement(query); ps1.setString(1,uname); ps1.setString(2,password); ps1.setString(3,email); ps1.setInt(4,phone); int i=ps1.executeUpdate(); if(c==1||c==Statement.SUCCESS_NO_INFO && i==1||i==Statement.SUCCESS_NO_INFO) { out.println("<html><head><title>Login</title></head><body>"); out.println("<center><h2>Skypark.com</h2>"); out.println("<table border=0><tr>"); out.println("<td>UserName/E-Mail</td>"); out.println("<form action=login method=post"); out.println("<td><input type=text name=uname></td>"); out.println("</tr><tr><td>Password</td>"); out.println("<td><input type=password name=pass></td></tr></table>"); out.println("<input type=submit value=Login>"); out.println("</form></body></html>"); } else { out.println("<html><head><title>Error!</title></head><body>"); out.println("<center><b>Given details are incorrect</b>"); out.println(" Please try again</center></body></html>"); RequestDispatcher rd=req.getRequestDispatcher("registration.html"); rd.include(req,resp); return; } } catch(Exception e) { out.println("<html><head><title>Error!</title><body>"); out.println("<b><i>Unable to process try after some time</i></b>"); out.println("</body></html>"); RequestDispatcher rd=req.getRequestDispatcher("registration.html"); rd.include(req,resp); return; } out.flush(); out.close(); } } And the web.xml file is <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0" metadata-complete="true"> <servlet> <servlet-name>reg</servlet-name> <servlet-class>skypark.Registration</servlet-class> </servlet> <servlet-mapping> <servlet-name>reg</servlet-name> <url-pattern>/registration</url-pattern> </servlet-mapping> This i kept in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\skypark\WEB_INF\web.xml and servlet class in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\skypark\WEB_INF\classes\skypark and registration.html in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\skypark\ if any mistake in this makes above error means please help me.Thanks in advance....

    Read the article

  • Cannot install gnome extensions from gnome site. No switch appearing in firefox or chrome

    - by Andrew James Adams
    I have installed ubuntu 12.04, and installed gnome3 on my system. I am attempting to download the user theme extensions from extensions.gnome.org, but I can't see this "switch" everyone's talking about. I've tried both chromium and firefox browsers on the site. I found a similar subject here at askUbuntu. I followed the directions but I got a warning about gnome common dependencies. I installed gnome-extensions-common without an error but I still cannot install user-themes, and I can't find the mysterious "switch". Any ideas? Thanks in advance.

    Read the article

  • Should I start making connections even if I'm not ready for a job yet?

    - by James
    The first job is always the hardest to get and I'm not exception. I'm 23 years old and I have no college degree but planned on going to college this year if all goes well (CS of course). I'm self-studying java right now. I know most of the topics related to the language besides the more advanced topics and I'm beginning to look at open source projects. I would like to find a job (at least a part time job) after a year or two when I'll gain more experience and learn more about java technologies and other technologies that interest me. Finding a job will be a bit difficult because most of the people (or a lot of them at least) at my current age already have 2 years or more of experience, so I will be somewhat disadvantaged. Should I start building connections and joining websites such as linkedin ? I never bothered to look into it because I'm not much of a social network person. If I start contributing to open source projects and create personal projects for 2 years could I apply for jobs that require 1-2 years of experience? Does this experience count ?

    Read the article

  • How can I cull non-visible isometric tiles?

    - by james
    I have a problem which I am struggling to solve. I have a large map of around 100x100 tiles which form an isometric map. The user is able to move the map around by dragging the mouse. I am trying to optimize my game only to draw the visible tiles. So far my code is like this. It appears to be ok in the x direction, but as soon as one tile goes completely above the top of the screen, the entire column disappears. I am not sure how to detect that all of the tiles in a particular column are outside the visible region. double maxTilesX = widthOfScreen/ halfTileWidth + 4; double maxTilesY = heightOfScreen/ halfTileHeight + 4; int rowStart = Math.max(0,( -xOffset / halfTileWidth)) ; int colStart = Math.max(0,( -yOffset / halfTileHeight)); rowEnd = (int) Math.min(mapSize, rowStart + maxTilesX); colEnd = (int) Math.min(mapSize, colStart + maxTilesY); EDIT - I think I have solved my problem, but perhaps not in a very efficient way. I have taken the center of the screen coordinates, determined which tile this corresponds to by converting the coordinates into cartesian format. I then update the entire box around the screen.

    Read the article

  • Multi option step-by-step walkthrough? [closed]

    - by James Simpson
    I'm looking for a service ideally (but script maybe) that would allow me to create a step-by-step walkthrough, customised by options users choose in earlier steps. It is difficult to describe and if there is a better description I could Google for, please let me know! Basically, I want to start with a few options for a user to click on and then change what comes next based on that click and be able to do this through a whole walk through (explaining how to set a service up). As mentioned earlier, if it was a SAAS I could use (in the vein of desk.com) that would be perfect. Thank you and please ask questions if I've described it poorly!

    Read the article

  • Saint Louis Days of .NET 2012

    - by James Michael Hare
    Hey all, just a quick note to let you know I'll be one of the speakers at the St. Louis Days of .NET this year.  I'll be giving a revamped version of my Little Wonders (going to add some new ones to keep it fresh) -- and hopefully other presentations as well, the session selection process is ongoing.St. Louis Days of .NET is a wonderful conference in the midwest and a bargain to boot (only $175 if you register before July 1st!  Hope to see you there.For more information, visit: http://www.stlouisdayofdotnet.com/2012

    Read the article

  • Setting up collision using a tilemap and cocos2d

    - by James
    I'm building my first platformer using cocos2d and a tilemap. I'm having trouble coming up with a decent way of determining if the character is colliding with an object. More specifically, in which direction is the character colliding with an object. Following the tutorial here, I have made a separate "meta" layer of collidable tiles. The problem is that unless the character is in the tile, you can't detect the collision. Also, there's no way of telling WHERE the collision is occurring. The best solution would be one that could tell me if a character is up against a wall, or walking on top of a platform. However, I can't seem to figure out a good technique for this.

    Read the article

  • Do programmers need a union? [closed]

    - by James A. Rosen
    In light of the acrid responses to the intellectual property clause discussed in my previous question, I have to ask: why don't we have a programmers' union? There are many issues we face as employees, and we have very little ability to organize and negotiate. Could we band together with the writers', directors', or musicians' guilds, or are our needs unique? Has anyone ever tried to start one? If so, why did it fail? (Or, alternatively, why have I never heard of it, despite its success?) later: Keith has my idea basically right. I would also imagine the union being involved in many other topics, including: legal liability for others' use/misuse of our work, especially unintended uses evaluating the quality of computer science and software engineering higher education programs -- unlike many other engineering disciplines, we are not required to be certified on receiving our Bachelor's degrees evangelism and outreach -- especially to elementary school students certification -- not doing it, but working with the companies like ISC(2) and others to make certifications meaningful and useful continuing education -- similar to previous conferences -- maintain a go-to list of organizers and other resources our members can use I would see it less so as a traditional trade union, with little emphasis on: pay -- we tend to command fairly good salaries outsourcing and free trade -- most of use tend to be pretty free-market oriented working conditions -- we're the only industry with Aeron chairs being considered anything like "standard"

    Read the article

  • What exactly is "Web API" in ASP.Net MVC4?

    - by James P. Wright
    I know what a Web API is. I've written API's in multiple languages (including in MVC3). I'm also well practiced in ASP.Net. I just discovered that MVC4 has "Web API" and without going through the video examples I can't find a good explanation of what exactly it IS. From my past experience, Microsoft technologies (especially ASP.Net) have a tendency to take a simple concept and wrap it in a bunch of useless overhead that is meant to make everything "easier". Can someone please explain to me what Web API in MVC4 is exactly? Why do I need it? Why can't I just write my own API?

    Read the article

  • Oracle ??????????? -2012?4??: Composite Patches

    - by James Zhang
      ???????DBA?????????????bundle patches, ??Patch Set Updates(PSU)????????,??oracle??????bundle patches,??PSU,??,??????????????,???????????????????(one-off patch),????overlay patches,???????????????   Oracle?????????,???2012?4???Database PSU 11.2.0.3.2??,??????patch??Composite Patches. Composite Patches ??:    * ?????    * ?????????overlay patches???    ?????????composite patches??,???????????????:Patch Set Update : ??????Cumulative patch(????),????, EM ??????????????????Patch Conflict   : 2??????????????,???????????Cumulative Patch : ????????,?????bug???,????Cumulative Patch?????????Cumulative PatchInterim Patch    : ???????????????Overlay Patch    : ?????????????,????????,????PSU???? ?merge patch??Sub-patch        : ??composite patch??2?????sub-patches?? ???Composite Patches?Composite Patches?????????,???????cumulative patch????composite patch?????Composite Patch?????????????. Composite Patches????????,Composite Patches???PSU??Bundle Patch????????????????????Composite Patches,???Composite Patches??????patch???????????Composite Patches,?????????Composite Patches???????????patches?????????overlay patches?Composite Patches???,???????overlay patches,???????,????overlay patches,???????????Composite Patches??overlay patches. cumulative patch?composite patch??????:* Cumulative Patch1.????Cumulative Patch?,??????????Cumulative Patch.2.???????overlay patches,?????overlay patches,??overlay patches?????cumulative patch??,???????cumulative patch??overlay patches,??????cumulative patch???overlay patches* Composite Patch1.???????????composite Patch,?????????Composite Patches??????2.???????overlay patches???cumulative patch???,???????overlay patches,??????cumulative patch. ????,?????overlay patches,??????cumulative patch??overlay patches? ???????????sub-patches??composite patch????????overlay patches* 11.2.0.3.1, 11.2.0.3.2, 11.2.0.3.3, 11.2.0.3.4 (??????) ??composite patch 11.2.0.3.4(?????)????(sub-patches)?????composite patch?,??sub-patches?????,?????????Composite Patch?????????????,??composite patch??????? * Overlay patches?composite patch(????) ???,?????overlay patch,????????composite patch????overly patch * ???11.2.0.3.4 ?,Overlay patches?composite patch(??????????)??,?????overlay patch,?????11.2.0.3.4 ??overlay patches,????11.2.0.3.4???overaly patches? ???PSU 11.2.0.3.2??????composite??????PSU, ?????composite patch?????,?????????newletter???????????,??????????:    Video - Bundle Patch Improvement - Composite Patching (03:43) [Trouble seeing this video?]    * Note 1376691.1 Composite Patches for Oracle Products (includes the brief informative video above)    * Note 854428.1   Patch Set Updates for Oracle Products    * Note 1299688.1 Patch conflict resolution    * Note 1321267.1 Database Patch conflict resolution

    Read the article

  • Best arguments for/against introducing ORM technology into a companies dev process

    - by james
    I have started using ORM technology in the last few years. My first exposure was NHibernate. I then moved onto Linq 2 Sql, and Entity Framework. The issue I have however is, there are some organisations where I have found strong opposition to introducing ORM tools. They usually have a number of reasons: they have a lot of built up SQL skills in the team, and are worried about the underlying SQL that ORM's generate. they have DBA's who like to be able to see the SQL an app uses in order that can review it for best practice. they are worried about performance (some people have "heard" the ORM's aren't as performant but have no real proof themselves - there may well be some truth in this! :). So, I'm looking for the best or most convincing arguments that you have put forward FOR the use of ORM tools. Equally, I would be interested in the against arguments too. Note: this is NOT a discussion over which ORM I should use.

    Read the article

  • Oracle Applications Guidance for Exalogic

    - by james.bayer
    Exalogic is continuing to help Oracle deliver on the tagline “Hardware and Software – Engineered to Work Together”.  My Oracle Support article ID 1302529.1 was just posted and enumerates various Oracle Applications versions that are recommended for deployment on Exalogic.  Please access the note via My Oracle Support for the details.  These applications currently include: Oracle Applications such as E-Business Suite, Siebel, PeopleSoft Enterprise, and JD Edwards EnterpriseOne Utilities Applications including Mobile Workforce Management, Meter Data Management, and Customer Care and Billing Oracle Retail Applications Merchandising Operations Management and Merchandising Planning & Optimization modules The reference video below offers a great explanation for how Exalogic can be an ideal platform for Oracle software including Oracle Applications.

    Read the article

  • Is there a clean separation of my layers with this attempt at Domain Driven Design in XAML and C#

    - by Buddy James
    I'm working on an application. I'm using a mixture of TDD and DDD. I'm working hard to separate the layers of my application and that is where my question comes in. My solution is laid out as follows Solution MyApp.Domain (WinRT class library) Entity (Folder) Interfaces(Folder) IPost.cs (Interface) BlogPosts.cs(Implementation of IPost) Service (Folder) Interfaces(Folder) IDataService.cs (Interface) BlogDataService.cs (Implementation of IDataService) MyApp.Presentation(Windows 8 XAML + C# application) ViewModels(Folder) BlogViewModel.cs App.xaml MainPage.xaml (Contains a property of BlogViewModel MyApp.Tests (WinRT Unit testing project used for my TDD) So I'm planning to use my ViewModel with the XAML UI I'm writing a test and define my interfaces in my system and I have the following code thus far. [TestMethod] public void Get_Zero_Blog_Posts_From_Presentation_Layer_Returns_Empty_Collection() { IBlogViewModel viewModel = _container.Resolve<IBlogViewModel>(); viewModel.LoadBlogPosts(0); Assert.AreEqual(0, viewModel.BlogPosts.Count, "There should be 0 blog posts."); } viewModel.BlogPosts is an ObservableCollection<IPost> Now.. my first thought is that I'd like the LoadBlogPosts method on the ViewModel to call a static method on the BlogPost entity. My problem is I feel like I need to inject the IDataService into the Entity object so that it promotes loose coupling. Here are the two options that I'm struggling with: Not use a static method and use a member method on the BlogPost entity. Have the BlogPost take an IDataService in the constructor and use dependency injection to resolve the BlogPost instance and the IDataService implementation. Don't use the entity to call the IDataService. Put the IDataService in the constructor of the ViewModel and use my container to resolve the IDataService when the viewmodel is instantiated. So with option one the layers will look like this ViewModel(Presentation layer) - Entity (Domain layer) - IDataService (Service Layer) or ViewModel(Presentation layer) - IDataService (Service Layer)

    Read the article

  • Cant get internet connection at all on Ubuntu 13.04

    - by James Ellis
    I installed Ubuntu 13.04 alongside my Windows Vista, at the start of installation it doesn't connect to the internet to download updates during installation, also during installation towards the end it removes a lot of stuff that i couldn't catch the details of at the time, it won't find my internet connection even though windows does, i tried using the ethernet cable but it wouldn't pick that up either. So i clicked in Ubuntu... System, network-Browse Internet, then Windows Internet and it said "failed to retrieve share list from server:no such file or directory" how can i get Ubuntu to find my internet???

    Read the article

  • How can I validate if a 13.10 update was complete?

    - by James
    I attempted to upgrade Ubuntu 13.04 server to 13.10 tonight via the standard linux text console and it had some trouble. Machine boots and displays 13.10, but I am unsure exactly what or how much was successfully upgraded. Is there some command I can run which will validate that all system has all standard binaries upgraded to the 13.10 release? As for the issue .... everything seemed to be going along ok until the screen displayed some kind of menu option regarding local edits to samba config file. There was a prompt requesting root password or ctrl-d to continue, but it would not take any input. From another terminal screen I tried killing the process displaying this samba message, and then some screen/SCREEN processes. The hard drive activity picked up for a while and then all the processes on that pty were gone. As I said, reboot was OK, but I have no idea if everything was upgraded. The machine seems to be acting like normal, except that the upgrade killed my openpvn process which I'll need to reload. Thanks

    Read the article

  • Direct2D Transform

    - by James
    I have a beginner question about Direct2D transforms. I have a 20 x 10 bitmap that I would like to draw in different orientations. To start, I would like to draw it vertically with a destination rectangle of say: (left, top, right, bottom) (300, 300, 310, 320) The bitmap is wider than it is tall (20 x 10), but when I draw it vertically, it will be appear taller than it is wide (10 x 20). I know that I can use a rotation matrix like so: m_pRenderTarget->SetTransform( D2D1::Matrix3x2F::Rotation( 90.0f, D2D1::Point2F(<center of shape>)) ); But when I use this method to rotate my shape, the destination rectangle is still wider than it is tall. Maybe it would look something like this: (left, top, right, bottom) (280, 290, 300, 300) The destination rectangle is 20 x 10 but the bitmap appears on the screen as 10 x 20. I can't look at the destination rectangle in the debugger and compare it to: (left, top, right, bottom) (300, 300, 310, 320) Is there any simple way to say "I want to rotate it so that the image is rendered to exactly this destination rectangle after the rotation?" In this case, I would like to say "Please rotate the bitmap so that it appears on the screen at this location:" (left, top, right, bottom) (300, 300, 310, 320) If I can't do that, is there any way to find out the 10 x 20 destination rectangle where the bitmap is actually being rendered to the screen?

    Read the article

  • Why does Unity screen blank out over XDMCP?

    - by James
    My XDMCP sessions display fine until I login. I've checked all logs and settings for this and can't find anything wrong, this works fine on other systems so I'm wondering if this has anything to do with the underlying hardware or an application that loads when logging in. System details: - Ubuntu 12.04 (Desktop, installed via Alternate CD for RAID) - 8GB of RAM - Core2Quad CPU @ 2.40GHz - Gigabit Network (Ethernet) Other notes: - Running with the onscreen keyboard enabled - Works fine when logging in locally Pre-login: Once logged in:

    Read the article

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