Search Results

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

Page 151/238 | < Previous Page | 147 148 149 150 151 152 153 154 155 156 157 158  | Next Page >

  • Accessing items from a dictionary using pickle efficiently in Python

    - by user248237
    I have a large dictionary mapping keys (which are strings) to objects. I pickled this large dictionary and at certain times I want to pull out only a handful of entries from it. The dictionary has usually thousands of entries total. When I load the dictionary using pickle, as follows: from cPickle import * # my dictionary from pickle, containing thousands of entries mydict = open(load('mypickle.pickle')) # accessing only handful of entries here for entry in relevant_entries: # find relevant entry value = mydict[entry] I notice that it can take up to 3-4 seconds to load the entire pickle, which I don't need, since I access only a tiny subset of the dictionary entries later on (shown above.) How can I make it so pickle only loads those entries that I have from the dictionary, to make this faster? Thanks.

    Read the article

  • Methods in the namespace System.Security.Cryptography take 2 minutes to perform when service is hosted in IIS

    - by Asaf Saf
    I built an ASP.NET web-service that uses the System.Security.Cryptography namespace when it handles its requests. When I hosted the service in ASP.NET Development Server, everything worked fine. Then I moved the service into IIS, still using localhost addresses, and surprisingly, each time the service calls a method from the specified namespace, it takes 2 minutes to complete! If a single request requires the service to call 3 methods of the specified namespace, then the request takes total of 6 minutes to complete! The traces show that the request has been received on time, and they show an interval of around 2 minutes upon each call to the specified namespace. Did anyone see this strange behavior elsewhere? Any speculation would be appreciated!

    Read the article

  • Resizing the Camera Preview

    - by uday
    I have implemented a camera application, which will show the preview in the entire screen of the device. But my requirement is to show the Camera preview in a small screen. My device resolution is 800x480(WxH) i.e, Nexus one. I can able to show the preview in the entire screen without scale down the preview. Its coming perfectly, but when i try show the preview in small screens(part of my total mobile screen), the preview is getting stretched and not looking good. Is there any way to show the preview correctly in a small screen. I think we need to scale down the image preview. But when i try to scale down the image preview, the android system itself doesn't allowing to set the scaled preview size. Could any one please help me how to scale the image preview in small screen.

    Read the article

  • PHP split string into integer element and string

    - by David19801
    Hello, I have a string say: Order_num = "0982asdlkj" How can I split that into the 2 variables, with the number element and then another variable with the letter element in php? The number element can be any length from 1 to 4 say and the letter element fills the rest to make every order_num 10 characters long in total. I have found the php explode function...but don't know how to make it in my case because the number of numbers is between 1 and 4 and the letters are random after that, so no way to split at a particular letter. Please help as specifically as possible!

    Read the article

  • svn revert or merge 80 revisions

    - by sharp
    Hi All, Let me explain my scenarios I have branch called ca-dev and its pretty stable,now I have to revert about 100 revisions (ca-dev has about 400 revisions checked in total after it branched out )from different users which were checked in over 4 months before I am branching new branch called agile-dev.Can any body help me best way to do... I tried using tortise svn some got reverted some I got conflicts and I resolved my self blindly so build is breaking. (ofcourse I made a agile-dev-temp) .. any tool better than tortisesvn easily I can view myself and clearly explains. Or who should do it Individual developer? Thanks

    Read the article

  • Grails - showing page processing/render debug information in development mode

    - by ovokinder
    I've been experimenting with Grails for the past two days and, so far, I'm really happy with it. Coming from Rails, the only thing I've really been missing here is the dev-mode debug information shown after the page has been served. This is what I mean: Processing UsersController#show (for 127.0.0.1 at 2010-06-14 10:28:44) [GET] Parameters: {"id"=>"2"} User Load (0.0ms) SELECT * FROM "users" WHERE ("users"."id" = 2) Rendering template within layouts/users Rendering users/show Completed in 24ms (View: 5, DB: 0) | 200 OK [http://localhost/users/2] Is there any way to get something similar in Grails? I've tried the "debug" plugin but its not very useful as it only shows the total processing time. I know it's not hard too roll something of my own (except for that database stats part), I just wanted to make sure I wasn't unnecessarily reinventing the wheel.

    Read the article

  • Using methods on 2 input files - 2nd is printing multiple times - Java

    - by Aaa
    I have the following code to read in text, store in a hashmap as bigrams (with other methods to sort them by frequency and do v. v. basic additive smoothing. I had it working great for one language input file (english) and then I want to expand it for the second language input file (japanese - doens;t matter what it is I suppose) using the same methods but the Japanese bigram hashmap is printing out 3 times in a row with diff. values. I've tried using diff text in the input file, making sure there are no gaps in text etc. I've also put print statements at certain places in the Japanese part of the code to see if I can get any clues but all the print statements are printing each time so I can't work out if it is looping at a certain place. I have gone through it with a fine toothcomb but am obviously missing something and slowly going crazy here - any help would be appreciated. thanks in advance... package languagerecognition2; import java.lang.String; import java.io.InputStreamReader; import java.util.*; import java.util.Iterator; import java.util.List.*; import java.util.ArrayList; import java.util.AbstractMap.*; import java.lang.Object; import java.io.*; import java.util.Enumeration; import java.util.Arrays; import java.lang.Math; public class Main { /** public static void main(String[] args) { //training English ----------------------------------------------------------------- File file = new File("english1.txt"); StringBuffer contents = new StringBuffer(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String test = null; //test = reader.readLine(); // repeat until all lines are read while ((test = reader.readLine()) != null) { test = test.toLowerCase(); char[] charArrayEng = test.toCharArray(); HashMap<String, Integer> hashMapEng = new HashMap<String, Integer>(bigrams(charArrayEng)); LinkedHashMap<String, Integer> sortedListEng = new LinkedHashMap<String, Integer>(sort(hashMapEng)); int sizeEng=sortedListEng.size(); System.out.println("Total count of English bigrams is " + sizeEng); LinkedHashMap<String, Integer> smoothedListEng = new LinkedHashMap<String, Integer>(smooth(sortedListEng, sizeEng)); //print linkedHashMap to check values Set set= smoothedListEng.entrySet(); Iterator iter = set.iterator ( ) ; System.out.println("Beginning English"); while ( iter.hasNext()) { Map.Entry entry = ( Map.Entry ) iter.next ( ) ; Object key = entry.getKey ( ) ; Object value = entry.getValue ( ) ; System.out.println( key+" : " + value); } System.out.println("End English"); }//end while }//end try catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { e.printStackTrace(); } } //End training English----------------------------------------------------------- //Training japanese-------------------------------------------------------------- File file2 = new File("japanese1.txt"); StringBuffer contents2 = new StringBuffer(); BufferedReader reader2 = null; try { reader2 = new BufferedReader(new FileReader(file2)); String test2 = null; //repeat until all lines are read while ((test2 = reader2.readLine()) != null) { test2 = test2.toLowerCase(); char[] charArrayJap = test2.toCharArray(); HashMap<String, Integer> hashMapJap = new HashMap<String, Integer>(bigrams(charArrayJap)); //System.out.println( "bigrams stage"); LinkedHashMap<String, Integer> sortedListJap = new LinkedHashMap<String, Integer>(sort(hashMapJap)); //System.out.println( "sort stage"); int sizeJap=sortedListJap.size(); //System.out.println("Total count of Japanese bigrams is " + sizeJap); LinkedHashMap<String, Integer> smoothedListJap = new LinkedHashMap<String, Integer>(smooth(sortedListJap, sizeJap)); System.out.println( "smooth stage"); //print linkedHashMap to check values Set set2= smoothedListJap.entrySet(); Iterator iter2 = set2.iterator(); System.out.println("Beginning Japanese"); while ( iter2.hasNext()) { Map.Entry entry2 = ( Map.Entry ) iter2.next ( ) ; Object key = entry2.getKey ( ) ; Object value = entry2.getValue ( ) ; System.out.println( key+" : " + value); }//end while System.out.println("End Japanese"); }//end while }//end try catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader2 != null) { reader2.close(); } } catch (IOException e) { e.printStackTrace(); } } //end training Japanese--------------------------------------------------------- } //end main (inner)

    Read the article

  • Building a user subscription application

    - by Tristan O'Neil
    Hello, I'm trying to come up with the best way to handle user subscription and management for our magazine website. What I want to happen is a user purchases a subscription and they are granted online access of a certain membership role for a certain amount of time depending on how many years they subscribed for. I would also like the system to be able to send out emails when a subscription is almost up. I've seen some third party projects to help accomplish this but I'd prefer to write this from scratch as I want total control over how it works. Any suggestions would be helpful. The main thing I can't figure out is how to have an expiring membership. You must keep track of when the user signed up and how long until they should expire.

    Read the article

  • How do I break a huge WordPress multi-site database up into separate MySQL databases ?

    - by Faith McNulty
    How do I break a huge WordPress multi-site database up into separate MySQL databases? I have 24 WordPress MU-or- multi-site sites, holding over 20K users in total. My Server says I must break them into smaller or separate databases But I am at a loss as to how this is accomplished ? I seem to remember somewhere in the original install a option setting asking if wp should use separate data bases True or False and it was set to false by default ? but Now I can't seem to find it ? Please help !

    Read the article

  • Who owes who money optimisation problem

    - by Francis
    Say you have n people, each who owe each other money. In general it should be possible to reduce the amount of transactions that need to take place. i.e. if X owes Y £4 and Y owes X £8, then Y only needs to pay X £4 (1 transaction instead of 2). This becomes harder when X owes Y, but Y owes Z who owes X as well. I can see that you can easily calculate one particular cycle. It helps for me when I think of it as a fully connected graph, with the nodes being the amount each person owes. Problem seems to be NP-complete, but what kind of optimisation algorithm could I make, nevertheless, to reduce the total amount of transactions? Doesn't have to be that efficient, as N is quite small for me.

    Read the article

  • Validating parameters to a bash script

    - by nickf
    I'm a total newbie to doing any bash scripting, but I came up with a basic one to help automate the process of removing a number of folders as they become unneeded. #!/bin/bash rm -rf ~/myfolder1/$1/anotherfolder rm -rf ~/myfolder2/$1/yetanotherfolder rm -rf ~/myfolder3/$1/thisisafolder This is evoked like so: ./myscript.sh <{id-number}> The problem is that if you forget to type in the id-number (as I did just then), then it could potentially delete a lot of things that you really don't want deleted. Is there a way you can add any form of validation to the command line parameters? In my case, it'd be good to check that a) there is one parameter, b) it's numerical, and c) that folder exists; before continuing with the script.

    Read the article

  • I can't Distinct, Sum, or Count from 3 tables with group clauses

    - by Rio Inggit Dharmawangsa
    I'm still learning linq, now i'm getting confused. I need data for report from 3 tables, I get the result, but it's duplicate. I have used distinct but it's not working, n I need data to be sum still not working. Here is my query, can somebody explain what's wrong? var report= (from u in myDb.TBL_TRANSAKSI_MKN_MNMs.AsEnumerable() where u.TGL_TRANSAKSI.Value.Date.Equals(dateTimePicker1.Value.Date) join l in myDb.TBL_DETAIL_TRANSAKSIs.AsEnumerable() on u.ID_NOTA equals l.ID_NOTA join m in myDb.TBL_MKN_MNMs.AsEnumerable() on l.ID_MKN_MNM equals m.ID_MKN_MNM group new { u, l, m } by new { m.NAMA_MKN_MNM, m.HARGA_JUAL, u.TGL_TRANSAKSI, l.ID_MKN_MNM, u.USERNAME, l.Jumlah } into grp select new { MakanMinum = grp.Key.NAMA_MKN_MNM, HargaJual = grp.Key.HARGA_JUAL, Stok = grp.Sum(groupedthing => groupedthing.l.Jumlah), Tanggal = grp.Key.TGL_TRANSAKSI, Jumlah =(grp.Key.HARGA_JUAL * grp.Sum(groupedthing => groupedthing.l.Jumlah)), Total = grp.Sum(grouptotal => grp.Key.HARGA_JUAL * grp.Sum(groupedthing => groupedthing.l.Jumlah)), Username = grp.Key.USERNAME }).Distinct();

    Read the article

  • Glassfish module deploy fails with "In-place deployment" error message

    - by iamanapprentice
    It was my first time to use Java EE and I am having an error everytime I run my html file. This is the error I am seeing: In-place deployment at C:\Documents and Settings\scybermonde\My Documents\NetBeansProjects\Exercises\build\web deploy?path=C:\Documents and Settings\scybermonde\My Documents\NetBeansProjects\Exercises\build\web&name=Exercises&force=true failed on GlassFish Server 3 C:\Documents and Settings\scybermonde\My Documents\NetBeansProjects\Exercises\nbproject\build-impl.xml:683: The module has not been deployed. BUILD FAILED (total time: 1 second) What was wrong if I am receiving an error like this? I also tried to deployed it referring to what it said in the later part "The module has not been deployed" but still the same error appears... please help... thanks in advance :)

    Read the article

  • Problem with loop MATLAB

    - by Jessy
    no time scores 1 10 123 2 11 22 3 12 22 4 50 55 5 60 22 6 70 66 . . . . . . n n n Above a the content of my txt file (thousand of lines). 1st column - number of samples 2nd column - time (from beginning to end ->accumulated) 3rd column - scores I wanted to create a new file which will be the total of every three sample of the scores divided by the time difference of the same sample. e.g. (123+22+22)/ (12-10) = 167/2 = 83.5 (55+22+66)/(70-50) = 143/20 = 7.15 new txt file 83.5 7.15 . . . n so far I have this code: fid=fopen('data.txt') data = textscan(fid,'%*d %d %d') time = (data{1}) score= (data{2}) for sample=1:length(score) ..... // I'm stucked here .. end ....

    Read the article

  • Paging To The End Of A Data View Web Part

    - by ForNow
    Hi all! Hopefully you can help me with this. I've displayed an Announcement web part on a page with 20 items. I opened up SharePoint Designer 2007 and set the paging to 6 items. I've added a little bit of (OOB) functionality so that I have buttons for START, PREVIOUS, and NEXT. These work well without any problems but I'm wondering how do I get END to work? I tried using the $LastRow & $RealLastRow values supplied by the web part but those just give me the number of how many items are in the current view, not the total items in the list. Little help!

    Read the article

  • How to research unmanaged memory leaks in .NET?

    - by Brandon
    I have a WCF service running over MSMQ. Memory gradually increases over time, indicating that there is some sort of memory leak. I ran the service locally and monitored some counters using PerfMon. Total CLR memory managed heap bytes remains relatively constant, while the process' private bytes increases over time. This leads me to believe that there is some sort of unmanaged memory leak. Assuming that unmanaged memory leak is the issue, how do I address the issue? Are there any tools I could use to give me hints as to what is causing the unmanaged memory leak? Also, all my service is doing is reading from the transactional queue and writing to a database, all as part of a DTC transaction (handled under the hood by requiring a transaction on the service contract). I am not doing anything explicitly with COM or DllImports. Thanks in advance!

    Read the article

  • iOS Downloading Videos and saving in Application Support folder

    - by Satyam svv
    In my application, i've to download videos around 10 to my application and play accordingly. Each video is around 50 MB. I'm using following code and then after downloading the video, i'm saving it to Application support folder to avoid icloud sync. But the problem is that when downloading the videos its crashing. [NSURLConnection sendAsynchronousRequest:req queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *rcvdDat, NSError * err) { . . . } What I'm thinking is that, while downloading the video, it resides in memory and so the total memory occupying by the app is increasing. Finally iOS is making the app to close. I would like to download the video and when ever a stream of data received, write to temp file and when completes move it to application support folder. Can some one help me on how to write it to file and save it at the end? I cannot use 3rd party libraries (unless its small) due to legal issues.

    Read the article

  • SQL Query taking too long

    - by user345426
    I am trying to optimize the SQL query listed below. It is basically a search engine code that retrieves products based on the products name. It also checks products model number and whether or not it is enabled. This executes in about 1.6 seconds when I run it directly through the phpMyAdmin tool but takes about 3 seconds in total to load in conjunction with the PHP file it is placed in. I need to add a category search functionality and now that is crashing the MySQL server, HELP! SELECT DISTINCT p.products_id , p.products_image , p.products_price , s.specials_new_products_price, p.products_weight , p.products_unit_quantity , pd.products_name , pd.products_img_alt , pd.products_affiliate_url FROM products AS p LEFT JOIN vendors v ON v.vendors_id = p.vendors_id LEFT JOIN specials AS s ON s.products_id = p.products_id AND s.status = 1, categories AS c , products_description AS pd , products_to_categories AS p2c WHERE ( ( pd.products_name LIKE '%cleaning%' AND pd.products_name LIKE '%supplies%' ) OR ( p.products_model LIKE '%cleaning%' AND p.products_model LIKE '%supplies%' ) OR p.products_id = 'cleaning supplies' OR v.vendors_prefix = 'cleaning supplies' OR CONCAT( CAST(v.vendors_prefix AS CHAR), '-', CAST(p.products_id AS CHAR) ) = 'cleaning supplies' ) AND p.products_status = '1' AND c.categories_status = '1' AND p.products_id = pd.products_id AND p2c.products_id = pd.products_id AND p2c.categories_id = c.categories_id ORDER BY pd.products_name

    Read the article

  • naming a method - using set() when *not* setting a property?

    - by user151841
    Is setX() method name appropriate for only for setting class property X? For instance, I have a class where the output is a string of an html table. Before you can you can call getTable, you have to call setTable(), which just looks at a other properties and decides how to construct the table. It doesn't actually directly set any class property -- only causes the property to be set. When it's called, the class will construct strHtmlTable, but you can't specify it. So, calling it setTable breaks the convention of get and set being interfaces for class properties. Is there another naming convention for this kind of method? Edit: in this particular class, there are at least two ( and in total 8 optional ) other methods that must be called before the class knows everything it needs to to construct the table. I chose to have the data set as separate methods rather than clutter up the __construct() with 8 optional parameters which I'll never remember the order of.

    Read the article

  • PHP and Java interoperablity

    - by Jack
    I am working on windows using tomcat 6 and PHP/Java Bridge. I know how to access a Java file from PHP but how do we do it the other way i.e accessing PHP from Java <?php require_once("java\Java.inc"); $systemInfo = new Java("java.lang.System"); print "Total seconds since January 1, 1970: ".$systemInfo->currentTimeMillis(); ?> Also how do I access Java classes that are created by me. Do I write a CLASSPATH env variable or change the php.ini config file?

    Read the article

  • Convert PHP array into Key => Value Array

    - by Feature
    Total PHP Noob and I couldn't find an answer to this specific problem. Hope someone can help! $myvar is an array that looks like this: Array ( [aid] = Array ( [0] = 2 [1] = 1 ) [oid] = Array( [0] = 2 [1] = 1 ) ) And I need to set a new variable (called $attributes) to something that looks like this: $attributes = array($myvar['aid'][0] => $myvar['oid'][0], $myvar['aid'][1] => $myvar['oid'][1], etc...); And, of course, $myvar may contain many more items... How do I iterate through $myvar and build the $attributes variable?

    Read the article

  • How can I find out how much memory an instance of a C++ class consumes?

    - by Shadow
    Hi, I am developing a Graph-class, based on boost-graph-library. A Graph-object contains a boost-graph, so to say an adjacency_list, and a map. When monitoring the total memory usage of my program, it consumes quite a lot (checked with pmap). Now, I would like to know, how much of the memory is exactly consumed by a filled object of this Graph-class? With filled I mean when the adjacency_list is full of vertices and edges. I found out, that using sizeof() doesn't bring me far. Using valgrind is also not an alternative as there is quite some memory allocation done previously and this makes the usage of valgrind impractical for this purpose. I'm also not interested in what other parts of the program cost in memory, I want to focus on one single object. Thank you.

    Read the article

  • How do I change the number of thumbnails seen in the Android sample Home application?

    - by Todd
    I am working with the sample Home application project on http://developer.android.com/resources/samples/Home/index.html I've added another value to the THUMBS_IDS and IMAGE_IDS Integer arrays in the Wallpaper class for a total of four wallpaper options. When I run the application with Device API version 7, Skin: HVGA, hw.lcd.density: 160, in portrait layout, the fourth wallpaper option is not shown. I need to use the directional keys in the emulator to see the 4th wallpaper option, because the first option is centered. I have modified only the wallpaper.xml file with a variety of android:layout_* options with no success at this point. How do I show all four of my wallpaper options?

    Read the article

  • User's Post count from specific category [Wordpress]

    - by morningglory
    Hello, I want to show user's post count from specific category. Currently, I can only be able to query all posts. My code is like this <?php $userpost_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type ='post' AND post_author = '".$curauth->ID."'");?> <?php echo "<span>Total post: </b></span>".$userpost_count.""?> I know that, I need to join two table which is post table and term_relationships, but i don't know how to get it. Please kindly help me with that. Thank you.

    Read the article

  • how to access child instances in a vector in c++

    - by tsubasa
    I have a parent class and child class (inherited from parent). In the child class, I have a member function named function_blah(); I used vector<parent*> A to store 5 parent instances, 3 child instances. So the total number of elements in the vector is 8. I can easily access to member functions of element A[0] to A[4], which are parent instances. But whenever I try to have access to member functions of element A[5] to A[7], the compiler complains that class parent has no member named 'function_blah' The way I access to elements is using index. e.x A[i] with i = 0..7. Is it correct? if not, how?

    Read the article

< Previous Page | 147 148 149 150 151 152 153 154 155 156 157 158  | Next Page >