Search Results

Search found 7086 results on 284 pages for 'explain'.

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

  • Please explain this delete top 100 SQL syntax

    - by Patrick
    Basically I want to do this: delete top( 100 ) from table order by id asc but MS SQL doesn't allow order in this position The common solution seems to be this: DELETE table WHERE id IN(SELECT TOP (100) id FROM table ORDER BY id asc) But I also found this method here: delete table from (select top (100) * from table order by id asc) table which has a much better estimated execution plan (74:26). Unfortunately I don't really understand the syntax, please can some one explain it to me? Always interested in any other methods to achieve the same result as well. EDIT: I'm still not getting it I'm afraid, I want to be able to read the query as I read the first two which are practically English. The above queries to me are: delete the top 100 records from table, with the records ordered by id ascending delete the top 100 records from table where id is anyone of (this lot of ids) delete table from (this lot of records) table I can't change the third one into a logical English sentence... I guess what I'm trying to get at is how does this turn into "delete from table (this lot of records)". The 'from' seems to be in an illogical position and the second mention of 'table' is logically superfluous (to me).

    Read the article

  • oracle using index even though there is no filter criteeria specified

    - by Kaushik
    In this query: SELECT WTTEMPLATE.TEMPLATEuID, MAX (WTTRX.VALUEDATE) AS template_last_use_date FROM wttemplate, wttrx WHERE WTTEMPLATE.TEMPLATEID = WTTRX.TEMPLATEID(+) AND WTTEMPLATE.CUSTID = WTTRX.CUSTID GROUP BY WTTEMPLATE.TEMPLATEuID The explain plan shows:index fast full scan using indexes on WTTEMPLATE.TEMPLATEID and (WTTRX.TEMPLATEID,WTTRX.CUSTID). My question is this: I have not specified any filter criteria , so how can it use indexes? It should do full scan...right?

    Read the article

  • MySQL Query performance - huge difference in time

    - by Damo
    I have a query that is returning in vastly different amounts of time between 2 datasets. For one set (database A) it returns in a few seconds, for the other (database B)....well I haven't waited long enough yet, but over 10 minutes. I have dumped both of these databases to my local machine where I can reproduce the issue running MySQL 5.1.37. Curiously, database B is smaller than database A. A stripped down version of the query that reproduces the problem is: SELECT * FROM po_shipment ps JOIN po_shipment_item psi USING (ship_id) JOIN po_alloc pa ON ps.ship_id = pa.ship_id AND pa.UID_items = psi.UID_items JOIN po_header ph ON pa.hdr_id = ph.hdr_id LEFT JOIN EVENT_TABLE ev0 ON ev0.TABLE_ID1 = ps.ship_id AND ev0.EVENT_TYPE = 'MAS0' LEFT JOIN EVENT_TABLE ev1 ON ev1.TABLE_ID1 = ps.ship_id AND ev1.EVENT_TYPE = 'MAS1' LEFT JOIN EVENT_TABLE ev2 ON ev2.TABLE_ID1 = ps.ship_id AND ev2.EVENT_TYPE = 'MAS2' LEFT JOIN EVENT_TABLE ev3 ON ev3.TABLE_ID1 = ps.ship_id AND ev3.EVENT_TYPE = 'MAS3' LEFT JOIN EVENT_TABLE ev4 ON ev4.TABLE_ID1 = ps.ship_id AND ev4.EVENT_TYPE = 'MAS4' LEFT JOIN EVENT_TABLE ev5 ON ev5.TABLE_ID1 = ps.ship_id AND ev5.EVENT_TYPE = 'MAS5' WHERE ps.eta >= '2010-03-22' GROUP BY ps.ship_id LIMIT 100; The EXPLAIN query plan for the first database (A) that returns in ~2 seconds is: +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+------------------------------+------+----------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+------------------------------+------+----------------------------------------------+ | 1 | SIMPLE | ps | range | PRIMARY,IX_ETA_DATE | IX_ETA_DATE | 4 | NULL | 174 | Using where; Using temporary; Using filesort | | 1 | SIMPLE | ev0 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_PROD.ps.ship_id,const | 1 | | | 1 | SIMPLE | ev1 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_PROD.ps.ship_id,const | 1 | | | 1 | SIMPLE | ev2 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_PROD.ps.ship_id,const | 1 | | | 1 | SIMPLE | ev3 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_PROD.ps.ship_id,const | 1 | | | 1 | SIMPLE | ev4 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_PROD.ps.ship_id,const | 1 | | | 1 | SIMPLE | ev5 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_PROD.ps.ship_id,const | 1 | | | 1 | SIMPLE | psi | ref | PRIMARY,IX_po_shipment_item_po_shipment1,FK_po_shipment_item_po_shipment1 | IX_po_shipment_item_po_shipment1 | 4 | UNIVIS_PROD.ps.ship_id | 1 | | | 1 | SIMPLE | pa | ref | IX_po_alloc_po_shipment_item2,IX_po_alloc_po_details_old,FK_po_alloc_po_shipment1,FK_po_alloc_po_shipment_item1,FK_po_alloc_po_header1 | FK_po_alloc_po_shipment1 | 4 | UNIVIS_PROD.psi.ship_id | 5 | Using where | | 1 | SIMPLE | ph | eq_ref | PRIMARY,IX_HDR_ID | PRIMARY | 4 | UNIVIS_PROD.pa.hdr_id | 1 | | +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+------------------------------+------+----------------------------------------------+ The EXPLAIN query plan for the second database (B) that returns in 600 seconds is: +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+--------------------------------+------+----------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+--------------------------------+------+----------------------------------------------+ | 1 | SIMPLE | ps | range | PRIMARY,IX_ETA_DATE | IX_ETA_DATE | 4 | NULL | 38 | Using where; Using temporary; Using filesort | | 1 | SIMPLE | psi | ref | PRIMARY,IX_po_shipment_item_po_shipment1,FK_po_shipment_item_po_shipment1 | IX_po_shipment_item_po_shipment1 | 4 | UNIVIS_DEV01.ps.ship_id | 1 | | | 1 | SIMPLE | ev0 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_DEV01.psi.ship_id,const | 1 | | | 1 | SIMPLE | ev1 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_DEV01.psi.ship_id,const | 1 | | | 1 | SIMPLE | ev2 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_DEV01.ps.ship_id,const | 1 | | | 1 | SIMPLE | ev3 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_DEV01.psi.ship_id,const | 1 | | | 1 | SIMPLE | ev4 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_DEV01.psi.ship_id,const | 1 | | | 1 | SIMPLE | ev5 | ref | IX_EVENT_ID_EVENT_TYPE | IX_EVENT_ID_EVENT_TYPE | 36 | UNIVIS_DEV01.ps.ship_id,const | 1 | | | 1 | SIMPLE | pa | ref | IX_po_alloc_po_shipment_item2,IX_po_alloc_po_details_old,FK_po_alloc_po_shipment1,FK_po_alloc_po_shipment_item1,FK_po_alloc_po_header1 | IX_po_alloc_po_shipment_item2 | 4 | UNIVIS_DEV01.ps.ship_id | 4 | Using where | | 1 | SIMPLE | ph | eq_ref | PRIMARY,IX_HDR_ID | PRIMARY | 4 | UNIVIS_DEV01.pa.hdr_id | 1 | | +----+-------------+-------+--------+----------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+---------+--------------------------------+------+----------------------------------------------+ When database B is running I can look at the MySQL Administrator and the state remains at "Copying to tmp table" indefinitely. Database A also has this state but for only a second or so. There are no differences in the table structure, indexes, keys etc between these databases (I have done show create tables and diff'd them). The sizes of the tables are: database A: po_shipment 1776 po_shipment_item 1945 po_alloc 36298 po_header 71642 EVENT_TABLE 1608 database B: po_shipment 463 po_shipment_item 470 po_alloc 3291 po_header 56149 EVENT_TABLE 1089 Some points to note: Removing the WHERE clause makes the query return < 1 sec. Removing the GROUP BY makes the query return < 1 sec. Removing ev5, ev4, ev3 etc makes the query get faster for each one removed. Can anyone suggest how to resolve this issue? What have I missed? Many Thanks.

    Read the article

  • How can I explain object-oriented programming to someone who's only coded in Fortran 77? [closed]

    - by Zonedabone
    Possible Duplicate: How can I explain object-oriented programming to someone who’s only coded in Fortran 77? My mother did her college thesis in Fortran, and now (over a decade later) needs to learn c++ for fluids simulations. She is able to understand all of the procedural programming, but no matter how hard I try to explain objects to her, it doesn't stick. (I do a lot of work with Java, so I know how objects work) I think I might be explaining it in too high-level ways, so it isn't really making sense to someone who's never worked with them at all and grew up in the age of purely functional programming. Is there any simple way I can explain them to her that will help her understand? Thanks for the help in advance.

    Read the article

  • Explain difference in SQLIO numbers for RAID 0 versus RAID 5 over 6 disks

    - by markn
    When using the SQLIO benchmark tool on a 4-core Dell server with 6 15k 450GB (fast) drives, RAID 0, we found the max throughput was 2MB per second. But when configured as RAID 5, we get 30 MB per second. It seems that the RAID controller, Dell Perc 5i integrated controller, is maxing out the throughput per disk. With RAID 5, I expect to get a bump due to stripping, but not a 15x difference. Like good programmers, we suspect the hardware , but we could be missing something. This is predominately write traffic.

    Read the article

  • Please explain some of Paul Graham's points on LISP

    - by kunjaan
    I need some help understanding some of the points from Paul Graham's article http://www.paulgraham.com/diff.html A new concept of variables. In Lisp, all variables are effectively pointers. Values are what have types, not variables, and assigning or binding variables means copying pointers, not what they point to. A symbol type. Symbols differ from strings in that you can test equality by comparing a pointer. A notation for code using trees of symbols. The whole language always available. There is no real distinction between read-time, compile-time, and runtime. You can compile or run code while reading, read or run code while compiling, and read or compile code at runtime. What do these points mean How are they different in languages like C or Java? Do any other languages other than LISP family languages have any of these constructs now?

    Read the article

  • Please Explain Drupal schema and drupal_write_record

    - by Aaron
    Hi. A few questions. 1) Where is the best place to populate a new database table when a module is first installed, enabled? I need to go and get some data from an external source and want to do it transparently when the user installs/enables my custom module. I create the schema in {mymodule}_schema(), do drupal_install_schema({tablename}); in hook_install. Then I try to populate the table in hook_enable using drupal_write_record. I confirmed the table was created, I get no errors when hook_enable executes, but when I query the new table, I get no rows back--it's empty. Here's one variation of the code I've tried: /** * Implementation of hook_schema() */ function ncbi_subsites_schema() { // we know it's MYSQL, so no need to check $schema['ncbi_subsites_sites'] = array( 'description' => 'The base table for subsites', 'fields' => array( 'site_id' => array( 'description' => 'Primary id for site', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), // end site_id 'title' => array( 'description' => 'The title of the subsite', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), //end title field 'url' => array( 'description' => 'The URL of the subsite in Production', 'type' => 'varchar', 'length' => 255, 'default' => '', ), //end url field ), //end fields 'unique keys' => array( 'site_id'=> array('site_id'), 'title' => array('title'), ), //end unique keys 'primary_key' => array('site_id'), ); // end schema return $schema; } Here's hook_install: function ncbi_subsites_install() { drupal_install_schema('ncbi_subsites'); } Here's hook_enable: function ncbi_subsites_enable() { drupal_get_schema('ncbi_subsites_site'); // my helper function to get data for table (not shown) $subsites = ncbi_subsites_get_subsites(); foreach( $subsites as $name=>$attrs ) { $record = new stdClass(); $record->title = $name; $record->url = $attrs['homepage']; drupal_write_record( 'ncbi_subsites_sites', $record ); } } Can someone tell me what I'm missing?

    Read the article

  • Explain BFS and DFS in terms of backtracking

    - by HH
    Wikipedia about DFS Depth-first search (DFS) is an algorithm for traversing or searching a tree, tree structure, or graph. One starts at the root (selecting some node as the root in the graph case) and explores as far as possible along each branch before backtracking. So is BFS? "an algorithm that choose a starting node, checks all nodes -- backtracks --, chooses the shortest path, chose neighbour nodes -- backtracks --, chose the shortest path -- finally finds the optimal path because of traversing each path due to continuos backtracking. Regex, find's pruning -- backtracking? The term backtracking confuseses due to its variety of use. UNIX find's pruning an SO-user explained with backtracking. Regex Buddy uses the term "catastrophic backtracking" if you do not limit the scope of your Regexes. It seems to be too wide umbrella-term. So: how do you define "Backtracking" GRAPH-theoretically? what is "backtracking" in BFS and DFS?

    Read the article

  • Can't explain why not redirecting after login using RedirectFromLogin

    - by Blankman
    I am using ASP.NET MVC, on my login action I am doing: [AcceptVerbs("POST")] public ActionResult Login(FormCollection form) { User validatedUser = // tests username/pwd here. FormsAuthentication.RedirectFromLoginPage( validatedUser.ID.ToString(), rememberMe); if(String.IsNullOrEmpty(Request["ReturnUrl"])) string redirectUrl = Request["ReturnUrl"]; if (!String.IsNullOrEmpty(Request.QueryString["ReturnUrl"])) string redirectUrl = Request["ReturnUrl"]; } My url looks like this when I am on the login page: http://localhost:56112/user/login?ReturnUrl=/admin/settings Does anything look wrong here? My web.config: <authentication mode="Forms"> <forms loginUrl="/user/login" protection="All" timeout="30" name="SomeCookie" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" />

    Read the article

  • Explain Python extensions multithreading

    - by Checkers
    Python interpreter has a Global Interpreter Lock, and it is my understanding that extensions must acquire it in a multi-threaded environment. But Boost.Python HOWTO page says the extension function must release the GIL and reacquire it on exit. I want to resist temptation to guess here, so I would like to know what should be GIL locking patterns in the following scenarios: Extension is called from python (presumably running in a python thread). And extension's background thread calls back into Py_* functions. And a final question is, why the linked document says the GIL should be released and re-acquired?

    Read the article

  • please explain NHibernate HiLo

    - by Ben
    I'm struggling to get my head round how the HiLo generator works in NHibernate. I've read the explanation here which made things a little clearer. My understanding is that each SessionFactory retrieves the high value from the database. This improves performance because we have access to IDs without hitting the database. The explanation from the above link also states: For instance, supposing you have a "high" sequence with a current value of 35, and the "low" number is in the range 0-1023. Then the client can increment the sequence to 36 (for other clients to be able to generate keys while it's using 35) and know that keys 35/0, 35/1, 35/2, 35/3... 35/1023 are all available. How does this work in a web application as don't I only have one SessionFactory and therefore one hi value. Does this mean that in a disconnected application you can end up with duplicate (low) ids in your entity table? In my tests I used these settings: <id name="Id" unsaved-value="0"> <generator class="hilo"/> </id> I ran a test to save 100 objects. The IDs in my table went from 32768 - 32868. The next hi value was incremented to 2. Then I ran my test again and the Ids were in the range 65536 - 65636. First off, why start at 32768 and not 1, and secondly why the jump from 32868 to 65536? Now I know that my surrogate keys shouldn't have any meaning but we do use them in our application. Why can't I just have them increment nicely like a SQL Server identity field would. Finally can someone give me an explanation of how the max_lo parameter works? Is this the maximum number of low values (entity ids in my head) that can be created against the high value? This is one topic in NHibernate that I have struggled to find documentation for. I read the entire NHibernate in action book and it still doesn't go into how this works in any detail. Thanks Ben

    Read the article

  • Please explain JSONP

    - by Cheeso
    I don't understand jsonp. I understand JSON. I don't understand JSONP. Wikipedia is the top search result for JSONP. It says JSONP or "JSON with padding" is a JSON extension wherein a prefix is specified as an input argument of the call itself. Huh? What call? That doesn't make any sense to me. JSON is a data format. There's no call. The 2nd search result is from some guy named Remy, who writes JSONP is script tag injection, passing the response from the server in to a user specified function. I can sort of understand that, but it's still not making any sense. What is JSONP, why was it created (what problem does it solve), and why would I use it? Addendum: I've updated Wikipedia with a clearer and more thorough description of JSONP, based on jvenema's answer. Thanks, all.

    Read the article

  • How do I explain this to potential employers?

    - by ReferencelessBob
    Backstory: TL;DR: I've gained a lot of experience working for 5 years at one startup company, but it eventually failed. The company is gone and the owner MIA. When I left sixth-form college I didn't want to start a degree straight away, so when I met this guy who knew a guy who was setting up a publishing company and needed a 'Techie' I thought why not. It was a very small operation, he sent mailings to schools, waited for orders to start arriving, then ordered a short run of the textbooks to be printed, stuck them in an envelope posted them out. I was initially going to help him set up a computerized system for recording orders and payments, printing labels, really basic stuff and I threw it together in Access in a couple of weeks. He also wanted to start taking orders online, so I set up a website and a paypal business account. While I was doing this, I was also helping to do the day-to-day running of things, taking phone orders, posting products, banking cheques, ordering textbooks, designing mailings, filing end of year accounts, hiring extra staff, putting stamps on envelopes. I learned so much about things I didn't even know I needed to learn about. Things were pretty good, when I started we sold about £10,000 worth of textbooks and by my 4th year there we sold £250,000 worth of text books. Things were looking good, but we had a problem. Our best selling product had peaked and sales started to fall sharply, we introduced add on products through the website to boost sales which helped for a while, but we had simply saturated the market. Our plan was to enter the US with our star product and follow the same, slightly modified, plan as before. We setup a 1-866 number and had the calls forwarded to our UK offices. We contracted a fulfillment company, shipped over a few thousand textbooks, had a mailing printed and mailed, then sat by the phones and waited. Needless to say, it didn't work. We tried a few other things, at home and in the US, but nothing helped. We expanded in the good times, moving into bigger offices, taking on staff to do administrative and dispatch work, but now cashflow was becoming a problem and things got tougher. We did the only thing we could and scaled things right back, the offices went, the admin staff went, I stopped taking a wage and started working from home. Nothing helped. The business was wound up about about 2 years ago. In the end it turned out that the owner had built up considerable debt at the start of business and had not paid them off during good years, which left him in a difficult position when cashflow had started to dry up. I haven't been able to contact the owner since I found out. It took me a while to get back on my feet after that, but I'm now at University and doing a Computer Science degree. How do I show the experience I have without having to get into all the gory details of what happened?

    Read the article

  • Can somebody explain this Objective C method declaration syntax

    - by Doug R
    I'm working through an iPhone development book* without really knowing Objective C. For the most part I'm able to follow what's going on, but there are a few method declarations like the one below that I'm having a bit of trouble parsing. For example: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section { return [self.controllers count]; //controllers is an instance variable of type NSArray in this class } It looks this is a method called numberOfRowsInSection, and it returns an NSInteger, and takes an NSInteger as a parameter which is locally called 'section'. But I don't understand all the references to tableView, or why this takes a parameter when it is not used within the method. Can somebody clarify this? Thanks. *p. 258, Beginning iPhone 3 Development, by Mark and LaMarche, published by Apress

    Read the article

  • Can somebody explain in a few sentences how these technologies relate: Flex, Flash, Air, ActionScrip

    - by SimpaCar
    I've read about each of these but I still don't understand how they all inter-operate, which are competing technologies, or even really what each of them is distinctly. Flash, Air, Flex... Are these all "containers"/JVM-like runtime environments, in which ActionScript code runs? SWF,FLV,AIR... Are these competing file formats which a Flash, Air or Flex runtime environment executes? ActionScript is a C-like language which compiles to SWF, FLV or AIR files? Sorry, with all the marketing around these terms, some of which are used interchangeably, I am quite lost. Suppose I wanted to write an AIR application... what would that entail? Writing ActionScript, compiling it to a SWF, and then installing the AIR runtime to execute it? How's that different than Flash? If I want to play AIR applications do I need a separate AIR runtime or does Flash execute AIR apps?

    Read the article

  • IoC / Dependency Injection - please explain code versus XML

    - by steve.macdonald
    I understand basically how IoC frameworks work, however one thing I don't quite get is how code-based config is supposed to work. With XML I understand how you could add a new assembly to a deployed application, then change the config in XML to include it. If the application is already deployed (i.e., compiled in some form) then how can code changes be made without recompiling? Or is that what people do, just change config in code and recompile?

    Read the article

  • can anyone explain this code to me???

    - by Abed
    //shellcode.c char shellcode[] = "\x31\xc0\x31\xdb\xb0\x17\xcd\x80" "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b" "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd" "\x80\xe8\xdc\xff\xff\xff/bin/sh"; int main() { int *ret; //ret pointer for manipulating saved return. ret = (int *)&ret + 2; //setret to point to the saved return //value on the stack. (*ret) = (int)shellcode; //change the saved return value to the //address of the shellcode, so it executes. } can anyone give me a better explanation

    Read the article

  • Can someone here explain constructors and destructors in python - simple explanation required - new

    - by rgolwalkar
    i will try to see if it makes sense :- class Person: '''Represnts a person ''' population = 0 def __init__(self,name): //some statements and population += 1 def __del__(self): //some statements and population -= 1 def sayHi(self): '''grettings from person''' print 'Hi My name is %s' % self.name def howMany(self): '''Prints the current population''' if Person.population == 1: print 'i am the only one here' else: print 'There are still %d guyz left ' % Person.population rohan = Person('Rohan') rohan.sayHi() rohan.howMany() sanju = Person('Sanjivi') sanju.howMany() del rohan # am i doing this correctly --- ? i need to get an explanation for this del - destructor O/P:- Initializing person data ****************************************** Initializing Rohan ****************************************** Population now is: 1 Hi My name is Rohan i am the only one here Initializing person data ****************************************** Initializing Sanjivi ****************************************** Population now is: 2 In case Person dies: ****************************************** Sanjivi Bye Bye world there are still 1 people left i am the only one here In case Person dies: ****************************************** Rohan Bye Bye world i am the last person on earth Population now is: 0 If required i can paste the whole lesson as well --- learning from :- http://www.ibiblio.org/swaroopch/byteofpython/read/

    Read the article

  • Explain to me how the Method Profiler works in the DDMS, I get heap space error

    - by Pentium10
    I start the Method Profiler for a process, then leave it run for about 5-10 secs, then I stop it. I see a progress that a file is pulled from the sdcard, than I get this Exception [2010-05-23 18:45:42] Traceview: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space [2010-05-23 18:45:42] Traceview: at java.util.Arrays.copyOf(Unknown Source) [2010-05-23 18:45:42] Traceview: at java.util.Arrays.copyOf(Unknown Source) [2010-05-23 18:45:42] Traceview: at java.util.ArrayList.toArray(Unknown Source) [2010-05-23 18:45:42] Traceview: at java.util.Collections.sort(Unknown Source) [2010-05-23 18:45:42] Traceview: at com.android.traceview.TimeLineView.setData(TimeLineView.java:370) [2010-05-23 18:45:42] Traceview: at com.android.traceview.TimeLineView.<init>(TimeLineView.java:316) [2010-05-23 18:45:42] Traceview: at com.android.traceview.MainWindow.createContents(MainWindow.java:95) [2010-05-23 18:45:42] Traceview: at org.eclipse.jface.window.Window.create(Window.java:431) [2010-05-23 18:45:42] Traceview: at org.eclipse.jface.window.Window.open(Window.java:790) [2010-05-23 18:45:42] Traceview: at com.android.traceview.MainWindow.run(MainWindow.java:60) [2010-05-23 18:45:42] Traceview: at com.android.traceview.MainWindow.main(MainWindow.java:224) What I am doing wrong?

    Read the article

  • Can someone explain me implicit parameters in Scala?

    - by Oscar Reyes
    And more specifically how does the BigInt works for convert int to BigInt? In the source code it reads: ... implicit def int2bigInt(i: Int): BigInt = apply(i) ... How is this code invoked? I can understand how this other sample: "Date literals" works. In. val christmas = 24 Dec 2010 Defined by: implicit def dateLiterals(date: Int) = new { import java.util.Date def Dec(year: Int) = new Date(year, 11, date) } When int get's passed the message Dec with an int as parameter, the system looks for another method that can handle the request, in this case Dec(year:Int) Q1. Am I right in my understanding of Date literals? Q2. How does it apply to BigInt? Thanks

    Read the article

  • Explain the Peak and Flag Algorithm

    - by Isaac Levin
    EDIT Just was pointed that the requirements state peaks cannot be ends of Arrays. So I ran across this site http://codility.com/ Which gives you programming problems and gives you certificates if you can solve them in 2 hours. The very first question is one I have seen before, typically called the Peaks and Flags question. If you are not familiar A non-empty zero-indexed array A consisting of N integers is given. A peak is an array element which is larger than its neighbours. More precisely, it is an index P such that 0 < P < N - 1 and A[P - 1] < A[P] A[P + 1] . For example, the following array A: A[0] = 1 A[1] = 5 A[2] = 3 A[3] = 4 A[4] = 3 A[5] = 4 A[6] = 1 A[7] = 2 A[8] = 3 A[9] = 4 A[10] = 6 A[11] = 2 has exactly four peaks: elements 1, 3, 5 and 10. You are going on a trip to a range of mountains whose relative heights are represented by array A. You have to choose how many flags you should take with you. The goal is to set the maximum number of flags on the peaks, according to certain rules. Flags can only be set on peaks. What's more, if you take K flags, then the distance between any two flags should be greater than or equal to K. The distance between indices P and Q is the absolute value |P - Q|. For example, given the mountain range represented by array A, above, with N = 12, if you take: two flags, you can set them on peaks 1 and 5; three flags, you can set them on peaks 1, 5 and 10; four flags, you can set only three flags, on peaks 1, 5 and 10. You can therefore set a maximum of three flags in this case. Write a function that, given a non-empty zero-indexed array A of N integers, returns the maximum number of flags that can be set on the peaks of the array. For example, given the array above the function should return 3, as explained above. Assume that: N is an integer within the range [1..100,000]; each element of array A is an integer within the range [0..1,000,000,000]. Complexity: expected worst-case time complexity is O(N); expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments). Elements of input arrays can be modified. So this makes sense, but I failed it using this code public int GetFlags(int[] A) { List<int> peakList = new List<int>(); for (int i = 0; i <= A.Length - 1; i++) { if ((A[i] > A[i + 1] && A[i] > A[i - 1])) { peakList.Add(i); } } List<int> flagList = new List<int>(); int distance = peakList.Count; flagList.Add(peakList[0]); for (int i = 1, j = 0, max = peakList.Count; i < max; i++) { if (Math.Abs(Convert.ToDecimal(peakList[j]) - Convert.ToDecimal(peakList[i])) >= distance) { flagList.Add(peakList[i]); j = i; } } return flagList.Count; } EDIT int[] A = new int[] { 7, 10, 4, 5, 7, 4, 6, 1, 4, 3, 3, 7 }; The correct answer is 3, but my application says 2 This I do not get, since there are 4 peaks (indices 1,4,6,8) and from that, you should be able to place a flag at 2 of the peaks (1 and 6) Am I missing something here? Obviously my assumption is that the beginning or end of an Array can be a peak, is this not the case? If this needs to go in Stack Exchange Programmers, I will move it, but thought dialog here would be helpful. EDIT

    Read the article

  • can you explain this jquery method from jquery.js

    - by mrblah
    Trying to understand how jquery works under the covers, what's the difference between: jQuery.fn and jQuery.prototype jQuery = window.jQuery = window.$ = function( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init( selector, context ); }, and then: jQuery.fn = jQuery.prototype = { init: function( selector, context ) {

    Read the article

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