Search Results

Search found 5942 results on 238 pages for 'total starnger'.

Page 194/238 | < Previous Page | 190 191 192 193 194 195 196 197 198 199 200 201  | Next Page >

  • pagination and url encoding help

    - by Sufyan
    <?php $name=$_POST['name']; ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="text" name="name"> <input type="submit" value="GO" name="submit"> </form> <?php include ('db.php'); if(isset($_POST['submit'])) { mysql_query ("INSERT INTO example (name) VALUES('$name')") or die(mysql_error()); } if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) { $startrow = 0; } else { $startrow = (int)$_GET['startrow']; } $query = "SELECT * FROM example ORDER BY id DESC LIMIT $startrow, 20"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<li>"; echo $row['name'] ." "." <a href= 'like.php?quote=" . urlencode( $row['name'] ) . "'>Click Here</a>"; echo "</li>"; } echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>'; ?> I want to make my page links hidden , how can i make then hidden so that a user cant edit it. 2nd question, currently i am showing total 10 records on each page and then a next page button , but the next button is keep showing even when there is no more records...! how to remove a next page button when records ended. ?? line number 28 is the link to pages which can be easyily editable by any user, i wnat to make them secure (using ID) and line 35 is n'next' page link , this link should not be appear when number of records ended

    Read the article

  • String or binary data would be truncated -- Heisenberg problem

    - by harpo
    When you get this error, the first thing you ask is, which column? Unfortunately, SQL Server is no help here. So you start doing trial and error. Well, right now I have a statement like: INSERT tbl (A, B, C, D, E, F, G) SELECT A, B * 2, C, D, E, q.F, G FROM tbl ,othertable q WHERE etc etc Note that Some values are modified or linked in from another table, but most values are coming from the original table, so they can't really cause truncation going back to the same field (that I know of). Eliminating fields one at a time eventually makes the error go away, if I do it cumulatively, but — and here's the kicker — it doesn't matter which fields I eliminate. It's as if SQL Server is objecting to the total length of the row, which I doubt, since there are only about 40 fields in all, and nothing large. Anyone ever seen this before? Thanks. UPDATE: I have also done "horizontal" testing, by filtering out the SELECT, with much the same result. In other words, if I say WHERE id BETWEEN 1 AND 100: Error WHERE id BETWEEN 1 AND 50: No error WHERE id BETWEEN 50 AND 100: No error I tried many combinations, and it cannot be limited to a single row.

    Read the article

  • Newbie C# Question about float/int/text type formatting

    - by user563501
    Hey everybody, I'm a total C# newb with a light (first year CS) background in Python. I wrote a console program in Python for doing marathon pace running calculations and I'm trying to figure out the syntax for this in C# using Visual Studio 2010. Here's a chunk of what I've got so far: string total_seconds = ((float.Parse(textBox_Hours.Text) * 60 * 60) + (float.Parse(textBox_Minutes.Text) * 60) + float.Parse(textBox_Seconds.Text)).ToString(); float secs_per_unit = ((float)(total_seconds) / (float)(textBox_Distance.Text)); float mins_per_unit = (secs_per_unit / 60); string pace_mins = (int)mins_per_unit.ToString(); string pace_secs = (float.Parse(mins_per_unit) - int.Parse(mins_per_unit) * 60).ToString(); textBox_Final_Mins.Text = pace_mins; textBox_Final_Secs.Text = pace_mins; Imagine you have a running pace of 8 minutes and 30 seconds per mile. secs_per_unit would be 510, mins_per_unit would be 8.5. pace_mins would simply be 8 and pace_secs would be 30. In Python I'd just convert variables from a float to a string to get 8 instead of 8.5, for example; hopefully the rest of the code gives you an idea of what I've been doing. Any input would be appreciated.

    Read the article

  • Refactoring - Speed increase

    - by Michael G
    How can I make this function more efficient. It's currently running at 6 - 45 seconds. I've ran dotTrace profiler on this specific method, and it's total time is anywhere between 6,000ms to 45,000ms. The majority of the time is spent on the "MoveNext" and "GetEnumerator" calls. and example of the times are 71.55% CreateTableFromReportDataColumns - 18, 533* ms - 190 calls -- 55.71% MoveNext - 14,422ms - 10,775 calls What can I do to speed this method up? it gets called a lot, and the seconds add up: private static DataTable CreateTableFromReportDataColumns(Report report) { DataTable table = new DataTable(); HashSet<String> colsToAdd = new HashSet<String> { "DataStream" }; foreach (ReportData reportData in report.ReportDatas) { IEnumerable<string> cols = reportData.ReportDataColumns.Where(c => !String.IsNullOrEmpty(c.Name)).Select(x => x.Name).Distinct(); foreach (var s in cols) { if (!String.IsNullOrEmpty(s)) colsToAdd.Add(s); } } foreach (string col in colsToAdd) { table.Columns.Add(col); } return table; }

    Read the article

  • "Subforms" associated with tree view in VB

    - by knomdeguerre
    I am using VB Express 2008 to demonstrate my ideas for an improved UI for an existing product for my colleagues at work. The current UI has a certain page with ten tabs, allowing the user to define up to ten "things". The available choices for each of the ten "things" are all the same. On each of the ten tabs, there is a checkbox to enable that definition. Generally, a user will never use more than 5 or 6 unique definitions, the rest will remain disabled. So far, my prototype has a tree view control with one branch to contain this list of definitions, Add and Delete buttons. My idea is: there is one sub-branch to start with (corresponding to the first tab in the current UI); if the user wants addtional definitions, they click Add and other branches are added to the tree view, up to maximum of ten. I think I should be able to create a "class" that has a sub-UI (like a sub-form in Access) along with behavior code, that can be instantiated with each press of the Add button; each instantiation's settings can be set independently and is displayed in the main UI form )in a panel or frame) when selected in the tree view. For example, suppose the user Adds to make a total of three definitions: the tree view now has three sub-branches, each of which presents the same sub-UI with settings that can be set specific to the selected sub-branch. I'm sure it's possible but not sure how to do it. I know a comprehensive "answer" might be complicated and long, but I may just need some quick hints to get underway - don't be shy! Thanks in advance!

    Read the article

  • SQL Server 2005 - Enabling both Named Pipes & TCP/IP protocols?

    - by Clinemi
    We have a SQL Server 2005 database, and currently all our users are connecting to the database via the TCP/IP protocol. The SQL Server Configuration Manager allows you to "enable" both Named Pipes, and TCP/IP connections at the same time. Is this a good idea? My question is not whether we should use named pipes instead of TCP/IP, but are there problems associated with enabling both? One of our client's IT guys, says that enabling database communication with both protocols will limit the bandwidth that either protocol can use - to like 50% of the total. I would think that the bandwidth that TCP/IP could use would be directly tied (inversely) to the amount of traffic that Named Pipes (or any of the other types of traffic) were occupying on the network at that moment. However, this IT person is indicating that the fact that we have enabled two protocols on the server, artificially limits the bandwidth that TCP/IP can use. Is this correct? I did Google searches but could not come up with an answer to this question. Any help would be appreciated.

    Read the article

  • What are the advantages of a query using a derived table(s) over a query not using them?

    - by AspOnMyNet
    I know how derived tables are used, but I still can’t really see any real advantages of using them. For example, in the following article http://techahead.wordpress.com/2007/10/01/sql-derived-tables/ the author tried to show benefits of a query using derived table over a query without one with an example, where we want to generate a report that shows off the total number of orders each customer placed in 1996, and we want this result set to include all customers, including those that didn’t place any orders that year and those that have never placed any orders at all( he’s using Northwind database ). But when I compare the two queries, I fail to see any advantages of a query using a derived table ( if nothing else, use of a derived table doesn't appear to simplify our code, at least not in this example): Regular query: SELECT C.CustomerID, C.CompanyName, COUNT(O.OrderID) AS TotalOrders FROM Customers C LEFT OUTER JOIN Orders O ON C.CustomerID = O.CustomerID AND YEAR(O.OrderDate) = 1996 GROUP BY C.CustomerID, C.CompanyName Query using a derived table: SELECT C.CustomerID, C.CompanyName, COUNT(dOrders.OrderID) AS TotalOrders FROM Customers C LEFT OUTER JOIN (SELECT * FROM Orders WHERE YEAR(Orders.OrderDate) = 1996) AS dOrders ON C.CustomerID = dOrders.CustomerID GROUP BY C.CustomerID, C.CompanyName Perhaps this just wasn’t a good example, so could you show me an example where benefits of derived table are more obvious? thanx

    Read the article

  • How to calculate commision based on referred memebrs?

    - by RAJKISHOR SAHU
    Hello everybody, I am developing a small software in C# WPF for a consultancy which does chain system business. I have coded tree structure to show who referred whom. Now it has commission depending on level. If 1 referred 2 & 3 then 1 will get level-1 commission. If 2 referred 4, 5 & 3 referred 6, 7 then 1 will receive level-2 commission. This chain will go on to certain total number. My problem is how I would implement this logic; I am able to calculate who has referred how many members via UDF written for adding TreeViewItem to TreeView. Or tell me how I can count items in treeview in certain level? Node adding UDF: public void AddNodes(int uid, TreeViewItem tSubNode) { string query = "select fullname, id from members where refCode=" + uid + ";"; MySqlCommand cmd = new MySqlCommand(query, db.conn); MySqlDataAdapter _DA = new MySqlDataAdapter(cmd); DataTable _DT = new DataTable(); tSubNode.IsExpanded = true; _DA.Fill(_DT); foreach (DataRow _dr in _DT.Rows) { TreeViewItem tNode = new TreeViewItem(); tNode.Header = _dr["fullname"].ToString()+" ("+_dr["id"].ToString()+")"; tSubNode.Items.Add(tNode); if (db.HasMembers(Convert.ToInt32(_dr["id"].ToString()))) { AddNodes(Convert.ToInt32(_dr["id"]), tNode); } } //This line tracks who has referred how many members Console.WriteLine("Tree node Count : "+tSubNode.Items.Count.ToString()+", UID "+uid); } Help me PLEASE!!!!

    Read the article

  • Mapkit +closest annotation

    - by danskcollignon
    Hi all, I am trying to devellopp an app showing the nearest poi to the users location. My app is now capable of: showing a map (Mapkit) with 110 annotations and the user's location. Furthermore, I have a TableView at the bottom of my screen, to choose between the different annotations. However, they're listed by number, and not by proximity to the user's location, which is my wish. My research have led me to think that I should use CLLocation for getting the user's location. I then have really no idea on how to do it next, using getDistancefrom. My annotations are stored on SecondViewController.m, using this form: -(void)loadOurAnnotations { CLLocationCoordinate2D workingCoordinate; workingCoordinate.latitude = XX.XXXXX; workingCoordinate.longitude = XX.XXXXX; SecondViewAnnotation *POI1 = [[SecondViewAnnotation alloc] initWithCoordinate:workingCoordinate]; [POI1 setTitle:@"POI"]; [POI1 setSubtitle:@"StreetName"]; [POI1 setAnnotationType:SecondViewAnnotationTypePOI1]; [mapView addAnnotation:POI1]; , and so on to POI110. Could someone please give me a clue? I'm a total newbie! Thank you in advance for your help,

    Read the article

  • Regular expression to match HTML table row ( <tr> ) NOT containing a specific value

    - by user1821136
    I'm using Notepad++ to clean up a long and messy HTML table. I'm trying to use regular expressions even if I'm a total noob. :) I need to remove all the table rows that doesn't contain a specific value (may I call that substring?). After having all the file contents unwrapped, I've been able to use the following regular expression to select, one by one, every table row with all its contents: <tr>.+?</tr> How can I improve the regular expression in order to select and replace only table rows containing, somewhere inside a part of them, that defined substring? I don't know if this does matter but the structure of every table row is the following (I've put there every HTML tag, the dots stand for standard content/values) <tr> <td> ... </td> <td> ... </td> <td> <a sfref="..." href="...">!! SUBSTRING I HAVE TO MATCH HERE !!</a> </td> <td> <img /> </td> <td> ... </td> <td> ... </td> <td> ... </td> <td> ... </td> </tr> Thanks in advance for your help!

    Read the article

  • adb doesn't get phone's device name/number

    - by Dona Hertel
    Okay, I have a strange problem I haven't seen listed anywhere. I'm developing an android app and I would like to run it on my Huawei Ascend. I have set up a file in /etc/udev/90-android.rules with the line: SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", MODE="0666" where '12d1' is the correct vendor ID for this phone (I verified this with 'lsusb' command). When I plug in the phone (it does have debugging on) and restart the adb server I get a connection but the name field does not get set. The output to 'adb devices' is: List of devices attached \n ???????????? device Plugging and unplugging the cable doesn't resolve this. Neither does restarting the adb server. Nor does a total reboot of both my computer or the phone. This is fine as I can get logs and a shell. The problem is that in the eclipse plugin, the device's name is list as "????????????" and so when it tries connect, it quits with an error message of 'device not found' even though the device is listed and 'online'. Is there something else I need to do? Do I need to set the name of the device somehow? cocofan P.S.: The app has 'debuggable' set to true in the manifest file.

    Read the article

  • css layout for footer at bottom with dynamic ajax content changing height of page

    - by m42
    [Update] I actually compromised on this problem for now by foregoing the fixed footer design. It seems that there is no problem with dynamic content moving the footer and resizing containers appropriately unless the footer is fixed to the browser bottom initially. I hope others will eventually provide a great solution that encompasses the best of both worlds. I spent all day trying to get the footer to move down the page to accommodate dynamically added (via ajax) content. I really need some pointers or links because I haven't found anything that helps. Basically: My site has some pages that begin with only a text box and a button so that the total height of the content area is only a few inches beneath the header area. I don't have any problem getting the sticky footer working so that the footer appears at the bottom of the browser window even when there is very little content on screen. That same css layout works fine for other pages that have content that extends beneath the browser window. The catch: The content has to be rendered and passed to the browser with the initial load. The Problem: Any content that is added to the page via AJAX after the initial load paints down the page correctly -- but the footer remains in its initial location. Please tell me there is a fix for this. I can't post the css until checking with my boss first - if possible - and if needed, I will later - but it's just a very basic version of the many sticky footer css solutions floating around the web. Thanks.

    Read the article

  • jQuery pagination without all the rows of data before hand

    - by Aaron Mc Adam
    Hi guys, I'm trying to find a solution for paginating my search results. I have a built the links and everything works without jQuery. I've also got AJAX working for the links, but I just need a way of tidying up the list of links, as some search results return up to 60 pages and the links spread to two rows in my template. I am searching the Amazon API, and can only return 10 results at a time. Upon clicking the pagination links, the next 10 results are returned. I have access to the total results number from the XML, but not all the data at once, so I can't put all the data into a "hiddenResults" div that the jQuery Pagination plugin needs. Here is the jQuery I have for the pagination: var $pagination = $("#pagination ul"); $pagination.delegate('.pagenumbers', 'click', function() { var $$this = $(this); $$this.closest('li').addClass('cached'); $pagination.find("#currentPage").removeAttr('id').wrapInner($('<a>', {'class':'pagenumbers', 'href':'book_data.php?keywords='+keywords})); $$this.closest('li').attr('id','currentPage').html( $$this.text() ); $.ajax({ type : "GET", cache : false, url : "book_data.php", data : { keywords : keywords, page : $$this.text() }, success : show_results }); return false; }); function show_results(res) { $("#searchResults").replaceWith($(res).find('#searchResults')).find('table.sortable tbody tr:odd').addClass('odd'); detailPage(); selectForm(); if ( ! ( $pagination.find('li').hasClass('cached') ) ) { $.get("book_data.php", { keywords : keywords, page : ( $pagination.find("#currentPage").text() + 1 ) } ); } }

    Read the article

  • MVC3 custom validation attribute for an "at least one is required" situation

    - by Pricey
    Hi I have found this answer already: MVC3 Validation - Require One From Group Which is fairly specific to the checking of group names and uses reflection. My example is probably a bit simpler and I was just wondering if there was a simpler way to do it. I have the below: public class TimeInMinutesViewModel { private const short MINUTES_OR_SECONDS_MULTIPLIER = 60; //public string Label { get; set; } [Range(0,24, ErrorMessage = "Hours should be from 0 to 24")] public short Hours { get; set; } [Range(0,59, ErrorMessage = "Minutes should be from 0 to 59")] public short Minutes { get; set; } /// <summary> /// /// </summary> /// <returns></returns> public short TimeInMinutes() { // total minutes should not be negative if (Hours <= 0 && Minutes <= 0) { return 0; } // multiplier operater treats the right hand side as an int not a short int // so I am casting the result to a short even though both properties are already short int return (short)((Hours * MINUTES_OR_SECONDS_MULTIPLIER) + (Minutes * MINUTES_OR_SECONDS_MULTIPLIER)); } } I want to add a validation attribute either to the Hours & Minutes properties or the class itself.. and the idea is to just make sure at least 1 of these properties (Hours OR minutes) has a value, server and client side validation using a custom validation attribute. Does anyone have an example of this please? Thanks

    Read the article

  • Algorithm for assigning a unique series of bits for each user?

    - by Mark
    The problem seems simple at first: just assign an id and represent that in binary. The issue arises because the user is capable of changing as many 0 bits to a 1 bit. To clarify, the hash could go from 0011 to 0111 or 1111 but never 1010. Each bit has an equal chance of being changed and is independent of other changes. What would you have to store in order to go from hash - user assuming a low percentage of bit tampering by the user? I also assume failure in some cases so the correct solution should have an acceptable error rate. I would an estimate the maximum number of bits tampered with would be about 30% of the total set. I guess the acceptable error rate would depend on the number of hashes needed and the number of bits being set per hash. I'm worried with enough manipulation the id can not be reconstructed from the hash. The question I am asking I guess is what safe guards or unique positioning systems can I use to ensure this happens.

    Read the article

  • Programming help Loop adding

    - by Deonna
    I know this probably really simple but Im not sure what im doing wrong... The assignment states: For the second program for this lab, you are to have the user enter an integer value in the range of 10 to 50. You are to verify that the user enters a value in that range, and continue to prompt him until he does give you a value in that range. After the user has successfully entered a value in that range, you are to display the sum of all the integers from 1 to the value entered. I have this so far: #include <iostream.h> int main () { int num, sum; cout << "do-while Loop Example 2" << endl << endl; do { cout << "Enter a value from 10 to 50: "; cin >> num; if (num < 10 || num > 50) cout << "Out of range; Please try again..." << endl; } while (num < 10 || num > 50); { int i; int sum = 0; for (num = 1; num <= 50; num ++) sum = sum + num; } cout << endl << "The sum is " << sum << endl; return 0; } Im just not sure exactly what i'm doing wrong... I keep getting the wrong sum for the total...

    Read the article

  • Displaying rectangles in game window with XNA

    - by blerh
    I want to divide my game grid into an array of rectangles. Each rectangle is 40x40 and there are 14 rectangles in every column, with a total of 25 columns. This covers a game area of 560x1000. This is the code I have set up to make the first column of rectangles on the game grid: Rectangle[] gameTiles = new Rectangle[15]; for (int i = 0; i <= 15; i++) { gameTiles[i] = new Rectangle(0, i * 40, 40, 40); } I'm pretty sure this works, but of course I cannot confirm it because rectangles do not render on the screen for me to physically see them. What I would like to do for debugging purposes is to render a border, or fill the rectangle with color so I can see it on the game itself, just to make sure this works. Is there a way to make this happen? Or any relatively simple way I can just make sure that this works? Thank you very much.

    Read the article

  • MySQL get point in time totals from related tables

    - by batfastad
    Hi everyone We have an order book and invoicing system and I've been tasked with trying to output monthly rolling totals from these tables. But I don't know really where to start with this. I think there's some SQL syntax that I don't even know about yet. I'm familiar with INNER/LEFT/JOINS and GROUP BY etc but grouping by date is confusing since I don't know how to limit the data to only the current date that's being grouped by at that point. I think this will involve joining the tables to themselves or possibly a sub-select. I always thought it best to avoid sub-selects apart from when absolutely necessary. Basically the system has 3 tables orders: order_id, currency, order_stamp orders_lines: order_line_id, invoice_id, order_id, price invoices: invoice_id, invoice_stamp order_stamp and invoice_stamp are UTC unix timestamps stored as integers, not MySQL timestamps. I'm trying to get a listing by year/month showing the total of current unbilled orders (sum of price), at that point in time. Current orders are ones where order_stamp is less than or equal to 00:00 on the 1st of the month. Unbilled orders are ones where invoice_stamp is null or invoice_stamp is greater than 00:00 on the 1st of the month. At that point in time there may not be a related invoice yet and invoice_id might be null. Anyone got any suggestions on what I should join to what and what I need to group by? Cheers, B

    Read the article

  • Out of memory while iterating through rowset

    - by Phliplip
    Hi All, I have a "small" table of 60400 rows with zipcode data. I wan't to iterate through them all, update a column value, and then save it. The following is part of my Zipcodes model which extends My_Db_Table that a totalRows function that - you guessed it.. returns the total number of rows in the table (60400 rows) public function normalizeTable() { $this->getAdapter()->setProfiler(false); $totalRows = $this->totalRows(); $rowsPerQuery = 5; for($i = 0; $i < $totalRows; $i = $i + $rowsPerQuery) { $select = $this->select()->limit($i, $rowsPerQuery); $rowset = $this->fetchAll($select); foreach ($rowset as $row) { $row->{self::$normalCityColumn} = $row->normalize($row->{self::$cityColumn}); $row->save(); } unset($rowset); } } My rowClass contains a normalize function (basicly a metaphone wrapper doing some extra magic). At first i tried a plain old $this-fetchAll(), but got a out of memory (128MB) right away. Then i tried splitting the rowset into chunks, only difference is that some rows actually gets updated. Any ideas on how i can acomplish this, or should i fallback to ye'olde mysql_query()

    Read the article

  • How to output multicolumn html without "widows"?

    - by user314850
    I need to output to HTML a list of categorized links in exactly three columns of text. They must be displayed similar to columns in a newspaper or magazine. So, for example, if there are 20 lines total the first and second columns would contain 7 lines and the last column would contain 6. The list must be dynamic; it will be regularly changed. The tricky part is that the links are categorized with a title and this title cannot be a "widow". If you have a page layout background you'll know that this means the titles cannot be displayed at the bottom of the column -- they must have at least one link underneath them, otherwise they should bump to the next column (I know, technically it should be two lines if I were actually doing page layout, but in this case one is acceptable). I'm having a difficult time figuring out how to get this done. Here's an example of what I mean: Shopping Link 3 Link1 Link 1 Link 4 Link2 Link 2 Link 3 Link 3 Cars Link 1 Music Games Link 2 Link 1 Link 1 Link 2 News As you can see, the "News" title is at the bottom of the middle column, and so is a "widow". This is unacceptable. I could bump it to the next column, but that would create an unnecessarily large amount of white space at the bottom of the second column. What needs to happen instead is that the entire list needs to be re-balanced. I'm wondering if anyone has any tips for how to accomplish this, or perhaps source code or a plug in. Python is preferable, but any language is fine. I'm just trying to get the general concept down.

    Read the article

  • OUTPUT DID NOT REDIRECT TO THE INTENDED FILE OPENED FOR..

    - by rockyurock
    HELLO ALL, I USED THE BELOW CODE FOR CAPTURING THE OUTPUT (BELOW IN lines) IN A FILE "my_output.txt" BUT FAILED TO CAPTURE. **************output*************** inside value loop ------------------------------------------------------------ Server listening on UDP port 5001 Receiving 1470 byte datagrams UDP buffer size: 108 KByte (default) ------------------------------------------------------------ [ 3] local 192.168.16.2 port 5001 connected with 192.168.16.1 port 3189 [ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams [ 3] 0.0- 5.0 sec 2.14 MBytes 3.61 Mbits/sec 0.369 ms 0/ 1528 (0%) inside value loop3 clue1 clue2 inside value loop4 one iperf completed *************************************** however when i enabled the local *STDOUT; in below code then i could see the above output on command prompt display (ofcourse server is sending some data). could anybody suggest me how can i capture the o/p in a file intended? below is the code i am using .. my $file = 'my_output.txt'; use Win32::Process; print"inside value loop\n"; # redirect stdout to a file #local *STDOUT; open STDOUT, '>', $file or die "can't redirect STDOUT to <$file> $!"; Win32::Process::Create(my $ProcessObj, "D:\\IOT_AUTOMATION_UTILITY\\_SATURDAY_09-04-10\\adb_cmd.bat", "adb shell /data/app/iperf -u -s -p 5001", 0, NORMAL_PRIORITY_CLASS, ".") || die ErrorReport(); #$alarm_time = $IPERF_RUN_TIME+10; #20sec #$ProcessObj->Wait(40); #print"inside value loop2\n"; #sleep $alarm_time; sleep 40; $ProcessObj->Kill(0); sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } /rocky

    Read the article

  • How to give points for each indices of list

    - by Eric Jung
    def voting_borda(rank_ballots): '''(list of list of str) -> tuple of (str, list of int) The parameter is a list of 4-element lists that represent rank ballots for a single riding. The Borda Count is determined by assigning points according to ranking. A party gets 3 points for each first-choice ranking, 2 points for each second-choice ranking and 1 point for each third-choice ranking. (No points are awarded for being ranked fourth.) For example, the rank ballot shown above would contribute 3 points to the Liberal count, 2 points to the Green count and 1 point to the CPC count. The party that receives the most points wins the seat. Return a tuple where the first element is the name of the winning party according to Borda Count and the second element is a four-element list that contains the total number of points for each party. The order of the list elements corresponds to the order of the parties in PARTY_INDICES.''' #>>> voting_borda([['GREEN','NDP', 'LIBERAL', 'CPC'], ['GREEN','CPC','LIBERAL','NDP'], ['LIBERAL','NDP', 'CPC', 'GREEN']]) #('GREEN',[4, 6, 5, 3]) list_of_party_order = [] for sublist in rank_ballots: for party in sublist[0]: if party == 'GREEN': GREEN_COUNT += 3 elif party == 'NDP': NDP_COUNT += 3 elif party == 'LIBERAL': LIBERAL_COUNT += 3 elif party == 'CPC': CPC_COUNT += 3 for party in sublist[1]: if party == 'GREEN': GREEN_COUNT += 2 elif party == 'NDP': NDP_COUNT += 2 elif party == 'LIBERAL': LIBERAL_COUNT += 2 elif party == 'CPC': CPC_COUNT += 2 for party in sublist[2]: if party == 'GREEN': GREEN_COUNT += 1 elif party == 'NDP': NDP_COUNT += 1 elif party == 'LIBERAL': LIBERAL_COUNT += 1 elif party == 'CPC': CPC_COUNT += 1 I don't know how I would give points for each indices of the list MORE SIMPLY. Can someone please help me? Without being too complicated. Thank you!

    Read the article

  • Django: Determining if a user has voted or not

    - by TheLizardKing
    I have a long list of links that I spit out using the below code, total votes, submitted by, the usual stuff but I am not 100% on how to determine if the currently logged in user has voted on a link or not. I know how to do this from within my view but do I need to alter my below view code or can I make use of the way templates work to determine it? I have read http://stackoverflow.com/questions/1528583/django-vote-up-down-method but I don't quite understand what's going on ( and don't need any ofjavascriptery). Models (snippet): class Link(models.Model): category = models.ForeignKey(Category, blank=False, default=1) user = models.ForeignKey(User) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) url = models.URLField(max_length=1024, unique=True, verify_exists=True) name = models.CharField(max_length=512) def __unicode__(self): return u'%s (%s)' % (self.name, self.url) class Vote(models.Model): link = models.ForeignKey(Link) user = models.ForeignKey(User) created = models.DateTimeField(auto_now_add=True) def __unicode__(self): return u'%s vote for %s' % (self.user, self.link) Views (snippet): def hot(request): links = Link.objects.select_related().annotate(votes=Count('vote')).order_by('-created') for link in links: delta_in_hours = (int(datetime.now().strftime("%s")) - int(link.created.strftime("%s"))) / 3600 link.popularity = ((link.votes - 1) / (delta_in_hours + 2)**1.5) if request.user.is_authenticated(): try: link.voted = Vote.objects.get(link=link, user=request.user) except Vote.DoesNotExist: link.voted = None links = sorted(links, key=lambda x: x.popularity, reverse=True) links = paginate(request, links, 15) return direct_to_template( request, template = 'links/link_list.html', extra_context = { 'links': links, }) The above view actually accomplishes what I need but in what I believe to be a horribly inefficient way. This causes the dreaded n+1 queries, as it stands that's 33 queries for a page containing just 29 links while originally I got away with just 4 queries. I would really prefer to do this using Django's ORM or at least .extra(). Any advice?

    Read the article

  • New desktop GUI developer; can choose any platform...

    - by alexantd
    I'm planning a client-server product for a tiny, low-volume, high-cost vertical market. One of the components of the product will be a desktop application, simple to moderate in complexity, for data entry and uploading to a central server from remote PCs and/or Macs via SOAP. The server is a Java web app. Customers will be choosing their platform (Windows or Mac) based on what the client app runs on, so my options are wide-open here. However, I will be developing on a Mac and have a strong allergy to MS-specific technologies (sorry). The app will not need to run on any non-desktop-computer devices and I have total freedom to say it will support X but not Y or Z without any negative consequences (quite the luxury, to be sure). I have a lot of experience in server-side development but very little in desktop GUI stuff, and am evaluating my options on the client - basically what do I want to commit to learning over the next 6+ months. I have server-side Java experience as well as a brief dabble in iPhone development, which went OK. Overall I'm looking for: Ease of learning & development IDE support Healthy surrounding ecosystem (libraries, tools, help, etc.) Quality documentation My options as I see them, in rough order of how I'm currently mentally ranking them: Java Swing Cocoa Java SWT JavaFX Adobe AIR XULRunner Am I leaving anything out?

    Read the article

  • Document management, SCM ?

    - by tsunade
    Hello, This might not be a hard core programming question, but it's related to some of the tools used by programmers I suspect. So we're a bunch of people each with a bunch of documents and a bunch of different computers on a bunch of operating systems (well, only 2, linux and windows). The best way these documents can be stored/managed is if they were available offline (the laptop might not always be online) but also synchronized between all the machines. Having a server with extra reliable storage be a "base repository" seems like a good idea to me. Using a SCM comes to my mind and I've tried Subversion, and it seems to be a good thing that it uses a centralized repository - but: When checking out the total size of the checkout is roughly double the original size. Big files or big repositories seem to slow it down. Also I've tried rsync, which might work - but it's a bit rough when it comes to the potential conflict. Finally I've tried Unison (which is a wrapping of rsync, I think) and while it works it becomes horribly slow for the big directories we have here since it has to scan everything. So the question is - is there a SCM tool out there that is actually practial to use for a big bunch of both small and big files? If thats a NO - does anyone know other tools that do this job? Thanks for reading :)

    Read the article

< Previous Page | 190 191 192 193 194 195 196 197 198 199 200 201  | Next Page >