Search Results

Search found 29841 results on 1194 pages for 'random number generator'.

Page 107/1194 | < Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >

  • in Python find number of same elements in 2 lists

    - by John
    Hi, In Python if I have 2 lists say: l1 = ['a', 'b', 'c', 'd'] l2 = ['c', 'd', 'e'] is there a way to find out how many elements they have the same. In the case about it would be 2 (c and d) I know I could just do a nested loop but is there not a built in function like in php with the array_intersect function Thanks

    Read the article

  • limit number of characters entered in textarea

    - by Abu Hamzah
    here is the script does what i want but not exactly, my question is, how can i stop user entering text once it reached the lmit of 255 characters? var limit = 255; var txt = $('textarea[id$=txtPurpose]'); $(txt).keyup(function() { var len = $(this).val().length; if (len > limit) { //this.value = this.value.substring(0, 50); $(this).addClass('goRed'); $('#spn').text(len - limit + " characters exceeded"); return false; } else { $(this).removeClass('goRed'); $('#spn').text(limit - len + " characters left"); } }); if there is a better way please let me know.

    Read the article

  • css got number at the last url

    - by every
    <link href="/stylesheets/blueprint/screen.css?1268721265" media="screen, projection" rel="stylesheet" type="text/css" /> <link href="/stylesheets/blueprint/print.css?1268721265" media="print" rel="stylesheet" type="text/css" /> why the css got 1268721265 ? any idea?thanks

    Read the article

  • Parallel Haskell in order to find the divisors of a huge number

    - by Dragno
    I have written the following program using Parallel Haskell to find the divisors of 1 billion. import Control.Parallel parfindDivisors :: Integer->[Integer] parfindDivisors n = f1 `par` (f2 `par` (f1 ++ f2)) where f1=filter g [1..(quot n 4)] f2=filter g [(quot n 4)+1..(quot n 2)] g z = n `rem` z == 0 main = print (parfindDivisors 1000000000) I've compiled the program with ghc -rtsopts -threaded findDivisors.hs and I run it with: findDivisors.exe +RTS -s -N2 -RTS I have found a 50% speedup compared to the simple version which is this: findDivisors :: Integer->[Integer] findDivisors n = filter g [1..(quot n 2)] where g z = n `rem` z == 0 My processor is a dual core 2 duo from Intel. I was wondering if there can be any improvement in above code. Because in the statistics that program prints says: Parallel GC work balance: 1.01 (16940708 / 16772868, ideal 2) and SPARKS: 2 (1 converted, 0 overflowed, 0 dud, 0 GC'd, 1 fizzled) What are these converted , overflowed , dud, GC'd, fizzled and how can help to improve the time.

    Read the article

  • Find the highest number of occurences in a column in SQL

    - by Ronnie
    Given this table: Order custName description to_char(price) A desa $14 B desb $14 C desc $21 D desd $65 E dese $21 F desf $78 G desg $14 H desh $21 I am trying to display the whole row where prices have the highest occurances, in this case $14 and $21 I believe there needs to be a subquery. So i started out with this: select max(count(price)) from orders group by price which gives me 3. after some time i didn't think that was helpful. i believe i needed the value 14 and 21 rather the the count so i can put that in the where clause. but I'm stuck how to display that. any help?

    Read the article

  • binary number in c++

    - by baash05
    In c++ 0x10 is the way to represent a hex value. if I leave off the 0x then it's dec. Is there a way to define a binary? Not that I can't derive 0x0003 is 11, but it would be cool if I could use 0b0011. It would just make the code a little more obvious.

    Read the article

  • Wordpress - Get Post Number in a Category

    - by Rfvgyhn
    Is there a way for me to get a pseudo-ID of a post from the category it belongs to? Let's say I have these posts post_id | post_title | post_cat --------+------------+--------- 0 | a post | cat1 1 | a post1 | cat2 2 | a post2 | cat1 3 | a post3 | cat2 ... 57 | a post57 | cat2 I want the posts from cat2 and the posts' ids to be relative to the category they were posted in. Something like post_id | post_title | post_cat | cat_post_id --------+------------+----------+-------- 1 | a post1 | cat2 | 1 3 | a post3 | cat2 | 2 57 | a post57 | cat2 | 3

    Read the article

  • Appending Comment Number Anchors to Comments

    - by John
    Hello, I am using a PHP file called comments.php that has a query that enters values into a mySQL table called "comment." As the query does this, it auto-generates a field called "commentid", which is set to auto_increment in MySQL. The file also contains a loop what echoes out all comments for a given submission. It all works fine and dandy, but I want to simultaneously pull this "commentid" and turn it into a hashtag / anchor that when appended to the end of the URL makes that comment at the top of the user's browser. Someone said on another question that in order to do this one thing I should do is create an anchor on the row where the comment is being printed out. How can I do this? Thanks in advance, John The query that inserts comments into the MySQL table "comment": $query = sprintf("INSERT INTO comment VALUES (NULL, %d, %d, '%s', NULL)", $uid, $subid, $comment); mysql_query($query) or die(mysql_error()); The fields in the table "comment": commentid loginid submissionid comment datecommented The row in a loop where the comments are echoed out: echo '<td rowspan="3" class="commentname1">'.stripslashes($row["comment"]).'</td>';

    Read the article

  • sorting, average and finding the lowest number from a static array Java

    - by user3701322
    i'm trying to input students and input their results for course work and exams and what i'm having trouble with is finding the average total score, the lowest total score and printing all students in order of total scores highest - lowest import java.util.*; import java.text.*; public class Results { static String[] name = new String[100]; static int[] coursework = new int[100]; static int[] exam = new int[100]; static int count = 0; public static void main(String[] args) { Scanner input = new Scanner(System.in); boolean flag = true; while(flag) { System.out.println( "1. Add Student\n" + "2. List All Students\n" + "3. List Student Grades\n" + "4. Total Score Average\n" + "5. Highest Total Score\n" + "6. Lowest Total Score\n" + "7. List all Students and Total Scores\n" + "8. Quit\n"); System.out.print("Enter choice (1 - 8): "); int choice = input.nextInt(); switch(choice) { case 1: add(); break; case 2: listAll(); break; case 3: listGrades(); break; case 4: average(); break; case 5: highestTotal(); break; case 6: lowestTotal(); break; case 7: order(); break; case 8: flag = false; break; default: System.out.println("\nNot an option\n"); } DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date date = new Date(); System.out.println(dateFormat.format(date)); } System.out.println("\n\nHave a nice day"); }//end of main static void add() { Scanner input = new Scanner(System.in); System.out.println("Insert Name: "); String names = input.nextLine(); System.out.println("Insert Coursework: "); int courseworks = input.nextInt(); System.out.println("Insert Exam: "); int exams = input.nextInt(); name[count] = names; coursework[count] = courseworks; exam[count] = exams; count++; } static void listAll() { for(int i=0;i<count;i++) { System.out.printf("%s %d %d\n", name[i], coursework[i], exam[i]); } } static void listGrades() { for(int i=0;i<count;i++){ if(coursework[i] + exam[i] > 79) { System.out.println(name[i] + " HD"); } else if(coursework[i] + exam[i] > 69) { System.out.println(name[i] + " DI"); } else if(coursework[i] + exam[i] > 59) { System.out.println(name[i] + " CR"); } else if(coursework[i] + exam[i] > 49) { System.out.println(name[i] + " PA"); } else { System.out.println(name[i] + " NN"); } } } static void average() { } static void highestTotal() { int largest=exam[0]; String student=name[0]; for(int i=0; i<exam.length; i++){ if(exam[i]>largest){ largest = exam[i] + coursework[i]; student = name[i]; } } System.out.printf(student + ": "+ largest + "\n" ); } static void lowestTotal() { int min = 0; for(int i=0; i<=exam[i]; i++){ for(int j =0; j<=exam[i]; j++){ if(exam[i]<=exam[j] && j==exam[j]){ min = exam[i] + coursework[i]; } else{ continue; } } } System.out.printf(name + ": "+ min + "\n" ); } static void order() { } }

    Read the article

  • Populating a Datagrid with variable number of columns and rows in Flex

    - by Rie Mino
    I am trying to figure out how to manage a Datagrid based on an XML object like this: <matrix rows="5" columns="5"> <column> <row>0.5</row> <row>0.21</row> </column> <column> <row>0.6</row> <row>0.9</row> </column> <column> <row>0.5</row> <row>0.5</row> </column> <column> <row>0.8</row> <row>0.4</row> </column> </matrix> I will need to populate the Datagrid column names based on a different XML object and use the above XML to populate each of the column's rows. I currently am able to create the Datagrid and populate its column headers but I am unsure as to how to how to add the rows for each column. The above XML will be update with new row and column elements added and deleted. This, of course, will be bound to the Datagrid to show updates. Thanks in advanced for your help.

    Read the article

  • Send file FTP over SSL with custom port number

    - by JM4
    I have asked the question before but in a different manner. I am trying taking form data, compiling into a temporary CSV file and trying to send over to a client via FTP over SSL (this is the only route I am interested in hearing solutions for unless there is a workaround to doing this, I cannot make changes). I have tried the following: ftp_connect - nothing happens, the page just times out ftp_ssl_connect - nothing happens, the page just times out curl library - same thing, given URL it also gives error. I am given the following information: FTPS Server IP Address TCP Port (1234) Username Password Data Directory to dump file FTP Mode: Passive very, very basic code (which I believe should initiate a connection at minimum): Code: <?php $ftp_server = "00.000.00.000"; //masked for security $ftp_port = "1234"; // masked but not 990 $ftp_user_name = "username"; $ftp_user_pass = "password"; // set up basic ssl connection $conn_id = ftp_ssl_connect($ftp_server, $ftp_port, "20"); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); echo ftp_pwd($conn_id); // / echo "hello"; // close the ssl connection ftp_close($conn_id); ?> When I run this over a SmartFTP client, everything works just fine. I just can't get it to work using PHP (which is a necessity). Has anybody had success doing this in the past? I would be very interested to hear your approach.

    Read the article

  • Approximate Number of CPU Cycles for Various Operations

    - by colordot
    I am trying to find a reference for approximately how many CPU cycles various operations require. I don't need exact numbers (as this is going to vary between CPUs) but I'd like something relatively credible that gives ballpark figures that I could cite in discussion with friends. As an example, we all know that floating point division takes more CPU cycles than say doing a bitshift. I'd guess that the difference is that the division is around 100 cycles, where as a shift is 1 but I'm looking for something to cite to back that up. Can anyone recommend such a resource?

    Read the article

  • Wordpress show next 3 x number adjacent custom posts from existing

    - by user2463284
    On a single/detail Custom Post Page I would like to display a custom nav of li's or divs in a sidebar that displays both title, excerpt and permalink for the next 3 posts within the custom post series. So if we are on custom post 3 then it would show 4, 5, 6 in the sidebar. The closest I've found to this is :-= global $post; $current_post = $post; // remember the current post for($i = 1; $i <= 3; $i++){ $post = get_previous_post(); // this uses $post->ID setup_postdata($post); // do your stuff here the_title(); } $post = $current_post; // restore Problem is this only shows the first next post and I need to show 3. Thanks Glennyboy

    Read the article

  • fullcalendar, how to limit the number of events per day in the month view

    - by VNE_Hess
    I have many events on a day, and it works as expected but now looking at the month view, my calendar grid is much taller that expected. I'd like to hide some of these events from the month view, like a summary with a visual que that there are more on this day than can be shown. I can use eventRender and return false, but i would like to know how many events are on a given day, so i can limit the rendering to about 4, then perhaps i would add an event that says " more ... " So the question may be : how to count the events on a given date ? or is this more like a feature request to expose a max counter for month view ? thanks

    Read the article

  • iPhone SDK - Number of days between day and today

    - by Hankweb
    I need help on how to find out how many days it has been (seven day weeks, MSTimezone) since May 6th, 2009 [NSDate *m62009 = [NSDate dateWithTimeIntervalSinceReferenceDate:231638400]; [m62009 setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"MST"]; (to help you - 231638400 seconds from 1/1/2001)

    Read the article

  • PostgreSQL: keep a certain number of records in a table

    - by Alexander Farber
    Hello, I have an SQL-table holding the last hands received by a player in card game. The hand is represented by an integer (32 bits == 32 cards): create table pref_hand ( id varchar(32) references pref_users, hand integer not NULL check (hand > 0), stamp timestamp default current_timestamp ); As the players are playing constantly and that data isn't important (just a gimmick to be displayed at player profile pages) and I don't want my database to grow too quickly, I'd like to keep only up to 10 records per player id. So I'm trying to declare this PL/PgSQL procedure: create or replace function pref_update_game(_id varchar, _hand integer) returns void as $BODY$ begin delete from pref_hand offset 10 where id=_id order by stamp; insert into pref_hand (id, hand) values (_id, _hand); end; $BODY$ language plpgsql; but unfortunately this fails with: ERROR: syntax error at or near "offset" because delete doesn't support offset. Does anybody please have a better idea here? Thank you! Alex

    Read the article

  • Best practices for displaying large number of images as thumbnails in c#

    - by andySF
    I got to a point where it's very difficult to get answers by debugging and tracing object, so i need some help. What I'm trying to do: A history form for my screen capture pet project. The history must list all images as thumbnails (ex: picasa). What I've done: I created a HistoryItem:UserControl. This history item has a few buttons, a check box, a label and a picture box. The buttons are for delete/edit/copy image. The check box is used for selecting one or more images and the label is for some info text. The picture box is getting the image from a public property that is a path and a method creates a proportional thumbnail to display it when the control has been loaded. This user control has two public events. One for deleting the image and one for bubbling the events for mouse enter and mouse leave trough all controls. For this I use EventBroadcastProvider. The bubbling is useful because wherever I move the mouse over the control, the buttons appear. The dispose method has been extended and I manually remove the events. All images are loaded by looping a xml file that contains the path of all images. For each image in this XML I create a new HitoryItem that is added (after a little coding to sort and limit the amount of images loaded) to a flow layout panel. The problem: When I lunch the history form, and the flow layout panel is populated with my HistoryItem custom control, my memory usage increases drastically.From 14Mb to around 100MB with 100 images loaded. By closing the history form and disposing whatever I could dispose and even trying to call GC.Collect() the memory increase remain. I search for any object that could not be disposed properly like an image or event but wherever I used them they are disposed. The problem seams to be from multiple sources. One is that the events for bubbling are not disposing properly, and the other is from the picture box itself. All of this i could see by commenting all the code to a limited version when only the custom control without any image processing and even events is loaded. Without the events the memory consumption is reduced by axiomatically 20%. So my real question is if this logic, flow layout panels and custom controls with picture boxes, is the best solution for displaying large amounts of images as thumbnails. Thank you!

    Read the article

< Previous Page | 103 104 105 106 107 108 109 110 111 112 113 114  | Next Page >