Search Results

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

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

  • Elegant way to aggregate multi-demensional array by index key

    - by Stephen J. Fuhry
    How can I recursively find the total value of all children of an array that looks something like this? [0] => Array ( [value] => ? // 8590.25 + 200.5 + 22.4 [children] => Array ( [0] => Array ( [value] => ? // 8590.25 + 200.5 [children] => Array ( [0] => Array ( [value] => 8590.25 // leaf node ) [1] => Array ( [value] => 200.05 // leaf node ) ) ) [1] => Array ( [value] => 22.4 // leaf node ) ) )

    Read the article

  • Extreamely fast way to clone the values of an array into a second array?

    - by George
    I am currently working on an application that is responsible for calculating random permutations of a multidemensional array. Currently the bulk of the time in the application is spent copying the array in each iteration (1 million iterations total). On my current system, the entire process takes 50 seconds to complete, 39 of those seconds spent cloning the array. My array cloning routine is the following: public static int[][] CopyArray(this int[][] source) { int[][] destination = new int[source.Length][]; // For each Row for (int y = 0; y < source.Length; y++) { // Initialize Array destination[y] = new int[source[y].Length]; // For each Column for (int x = 0; x < destination[y].Length; x++) { destination[y][x] = source[y][x]; } } return destination; } Is there any way, safe or unsafe, to achieve the same effect as above, much faster?

    Read the article

  • Rolling back a git tree, fully or partially (single file) how to?

    - by Tzury Bar Yochay
    On a given server, I have a set of daemons each of which has its own configuration file. I would like to use git to manage the configuration files editing during time and always have the option to rollback to the "factory defaults" in regards to all files or a specific one. For instance, given the following structure: $ ls -l total 0 -rw-r--r-- 1 tzury tzury 0 2011-01-05 06:36 bar.conf -rw-r--r-- 1 tzury tzury 0 2011-01-05 06:36 baz.conf -rw-r--r-- 1 tzury tzury 0 2011-01-05 06:36 foo.conf Assuming all those .conf files are stored in a git repository, I want to be able to restore all files into their original shape (that would be the first git commit). Yet, I would also like to be able to rollback a specific file to the factory defaults, while others remain up to date.

    Read the article

  • Can anyone help me with a complex sum, 3 table join mysql query?

    - by Scarface
    Hey guys I have a query and it works fine, but I want to add another table to the mix. The invite table I want to add has two fields: username and user_invite. Much like this site, I am using a point system to encourage diligent users. The current query which is displayed below adds the up votes and down votes based on the user in question: $creator. I want to count the number of entries for that same user from the invite table, and add 50 for each row it finds to the current output/sum of my query. Is this possible with one query, or do I need two? "SELECT *, SUM(IF(points_id = \"1\", 1,0))-SUM(IF(points_id = \"2\", 1,0)) AS 'total' FROM points LEFT JOIN post ON post.post_id=points.points_id WHERE post.creator='$creator'"

    Read the article

  • Why does my git push hang after successfully pushing?

    - by John
    On a newly set up ssh git repo, whenever I push, I get normal output like this: ? git push Counting objects: 15, done. Delta compression using up to 4 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 989 bytes, done. Total 9 (delta 7), reused 0 (delta 0) It happens very quickly, and the changes are immediately available on the server repo. But the output hangs there for about a minute, and then finishes with: To [email protected]:baz.git c8c391c..1de5e80 branch_name -> branch_name If I control-c before it finishes, everything seems to continue to be normal and healthy, locally and remotely. What is it doing while hanging? Is something configured incorrectly on the server side?

    Read the article

  • How can we compute the LAST page with JPA?

    - by Kevin
    I would like to implement pagination in my Servlet/EJB/JPA-Hibernate project, but I can't figure out how only one page from the query and know the number of pages I must display I use setFirstResult(int first) ; setMaxResults(int max) ; and that's working alright, but how can I know how many pages I will have in total? (Hibernate is my JPA provider, but I would prefer using only JPA if possible) UPDATE: COUNT() seems to be the better/easiest solution; but what can be the cost of SELECT COUNT(*) FROM ... in comparison with executeQuery("SELECT * FROM ...).getListResult().size() ?

    Read the article

  • Is it possible to select data with max value for a column using Criteria in Hibernate?

    - by Palo
    Lets say I have the following mapping: <hibernate-mapping package="mypackage"> <class name="User" table="user"> <id name="id" column="id"> <generator class="native"></generator> </id> <property name="name" /> <property name="age" /> </class> </hibernate-mapping> Is it possible to select the oldest user (that is age is maximal) using Criteria in Hibernate? I can imagine that i could do this with 2 selects. (first select total number of users and then order the entries descending by age and select the first entry). But is it possible with a single select? Thank you Palo

    Read the article

  • Client validate non-model bound checkbox while using MVC 2 jQuery Validation

    - by Justin Saraceno
    Have: Using ASP.NET MVC 2, DataAnnotationsModel based server validation, and client validation with jQuery. Anything in my model is validated perfectly on the client with jQuery based validation (jQuery.validate and MicrosoftMvcJQueryValidation.js). Need: Adding an additional HTML <input type="checkbox" id="terms" /> to my form. I need jQuery validation to require that this checkbox is checked AND somehow hook it in with whatever jQuery client script MVC is automagically controlling. Yes, I know it won't validate on the server side, but I don't need or want it to. Seems like it should be simple but I'm new to MVC, a total beginner at jQuery, and my searches have been coming up blank. Any help would be appreciated!

    Read the article

  • iPhone view architecture question

    - by Joe
    So I have (for instance) three views: A: root view B: a view functionally identical to root C: a data entry view which collects a few piece of info What I'm trying to do is reuse C to supply the data it collects to either A or B. It should supply the data to whichever of the two it is pushed onto. The data for A is similar, but functionally distinct, to what collects for B. Right now, I'm passing data from C to A or B via a singleton class. What I'm trying to avoid is having two instances of C, one to supply data to A and B (because, in actuality, the program will have 5 total views like C. Does the question make sense?

    Read the article

  • How to add values accordingly of the first indices of a dictionary of tuples of a list of strings? Python 3x

    - by TheStruggler
    I'm stuck on how to formulate this problem properly and the following is: What if we had the following values: {('A','B','C','D'):3, ('A','C','B','D'):2, ('B','D','C','A'):4, ('D','C','B','A'):3, ('C','B','A','D'):1, ('C','D','A','B'):1} When we sum up the first place values: [5,4,2,3] (5 people picked for A first, 4 people picked for B first, and so on like A = 5, B = 4, C = 2, D = 3) The maximum values for any alphabet is 5, which isn't a majority (5/14 is less than half), where 14 is the sum of total values. So we remove the alphabet with the fewest first place picks. Which in this case is C. I want to return a dictionary where {'A':5, 'B':4, 'C':2, 'D':3} without importing anything. This is my work: def popular(letter): '''(dict of {tuple of (str, str, str, str): int}) -> dict of {str:int} ''' my_dictionary = {} counter = 0 for (alphabet, picks) in letter.items(): if (alphabet[0]): my_dictionary[alphabet[0]] = picks else: my_dictionary[alphabet[0]] = counter return my_dictionary This returns duplicate of keys which I cannot get rid of. Thanks.

    Read the article

  • iphone - Images (slide show) and audio snychronization

    - by Qaiser
    I have 20 images and some audio. I would like to show a single image at a time and change the images at (unequal) intervals. For example, I want to show image 1 for 1.44 seconds and image 2 for 1.67 seconds and so on. Can someone suggest how to go about doing this please? What I have seen are examples that show how to setup an array of images with one field that denotes total time. This causes the images to show for an equal amount of time (each). ... and that not what I am looking for ...

    Read the article

  • Why are regular expressions such a complicated, cryptic mess?

    - by steffenj
    Often when I see regular expressions, I only see a total mess of characters. Why does it have to be this way? I guess what I really want to know is: are there alternatives to regular expressions that basically do the same thing but are implemented in a human readable language? [UPDATE] Thanks for all the great responses and inspiration! I wanted to highlight this particular link which shows how a (working) alternative would look like, which may also be a good starting point for learning or "simple" regex expressions. But you also quickly get a feel for the verbosity tradeoff.

    Read the article

  • Is it possible to get download progress of video/image in HTML5 ?

    - by Janusz
    Hello, Almost every flash player has an option to display how much of buffer (or % of total video) is downloaded to the client. At the moment I don't see it in any implementation of html5 video player. The real problem I am trying to solve is to have a way of knowing % of downloaded asset (image/swf/video whatever). In flash its easy by using MovieClipLoader and bytesLoaded property. Is there any way of doing it in HTML/HTML5/Javascript (without relying on Flash) ? Thanks!

    Read the article

  • MySQL GROUP BY with three tables

    - by Psaniko
    I have the following tables: posts (post_id, content, etc) comments (comment_id, post_id, content, etc) posts_categories (post_category_id, post_id, category_id) and this query: SELECT `p`.*, COUNT(comments.comment_id) AS cmts, posts_categories.*,comments.* FROM `posts` AS `p` LEFT JOIN `posts_categories` ON `p`.post_id = `posts_categories`.post_id LEFT JOIN `comments` ON `p`.post_id = `comments`.post_id GROUP BY `p`.`post_id` There are three comments on post_id=1 and four in total. In posts_categories there are two rows, both assigned to post_id=1. I have four rows in posts. But if I query the statement above I get a result of 6 for COUNT(comments.comment_id) at post_id=1. How is this possible? I guess the mistake is somewhere in the GROUP BY clause but I can't figure out where. Any suggestions?

    Read the article

  • How should I best store these files?

    - by Triton Man
    I have a set of image files, they are generally very small, between 5k and 100k. They can be any size though, upwards of 50mb but this is very rare. When these images are put into the system they are not ever modified. There is about 50 TB of these images total. They are currently chunked and stored in BLOBs in Oracle, but we want to change this since it requires special software to extract them. These images are access sometimes at a rate of over 100 requests per second among about 10 servers. I'm thinking about Hadoop or Cassandra, but I really don't know which would be best or how best to index them.

    Read the article

  • list of all commits SHA1_HASH

    - by dorelal
    git init echo 'I am foo' > foo.txt git add foo.txt # this woould create a git commit object echo ' I am foo2' > foo.txt git add foo.txt # this would create another git commit object git commit -m 'doe' # this would create two git # objects: one commit object and one tree object How do I get a list of all 4 commits SHA1_HASH ? cd .git/objects ls (master)$ ls -al total 0 drwxr-xr-x 8 nsingh staff 272 Mar 27 16:44 . drwxr-xr-x 13 nsingh staff 442 Mar 27 16:44 .. drwxr-xr-x 3 nsingh staff 102 Mar 27 16:44 37 drwxr-xr-x 3 nsingh staff 102 Mar 27 16:43 a2 drwxr-xr-x 3 nsingh staff 102 Mar 27 16:44 e1 drwxr-xr-x 3 nsingh staff 102 Mar 27 16:42 e6 drwxr-xr-x 2 nsingh staff 68 Mar 27 16:42 info drwxr-xr-x 2 nsingh staff 68 Mar 27 16:42 pack I can find the list of all 4 commits by looking at file here but there must be a better way.

    Read the article

  • structure in .NET

    - by redpaladin
    My problem is very simple.. My problem is to send a structure beetween a program in C to a C# program.. I made a struct in C#: public struct NetPoint { public float lat; // 4 bytes public float lon; // 4 bytes public int alt; // 4 bytes public long time; // 8 bytes } Total size of the struct must be 20 bytes When i do a sizeof() of this struct System.Diagnostics.Debug.WriteLine("SizeOf(NetPoint)=" + System.Runtime.InteropServices.Marshal.SizeOf(new NetPoint())); The debug console show : SizeOf(NetPoint)=24 But i expected to have 20 bytes ? Why do I have a difference ? Thank you in advance

    Read the article

  • Will an IO blocked process show 100% CPU utilization in 'top' output?

    - by Alex Stoddard
    I have an analysis that can be parallelized over a different number of processes. It is expected that things will be both IO and CPU intensive (very high throughput short-read DNA alignment if anyone is curious.) The system running this is a 48 core linux server. The question is how to determine the optimum number of processes such that total throughput is maximized. At some point the processes will presumably become IO bound such that adding more processes will be of no benefit and possibly detrimental. Can I tell from standard system monitoring tools when that point has been reached? Would the output of top (or maybe a different tool) enable me to distinguish between a IO bound and CPU bound process? I am suspicious that a process blocked on IO might still show 100% CPU utilization.

    Read the article

  • How to take some values and + them together with PHP.

    - by Kyle Sevenoaks
    Hi, I am having a problem. I have some prices in a checkout displayed, they are "discount prices." How can I get these values from my page and add them together to display in a new div? I have two prices for two products 1000 and 2000, I want to be able to add these together to make 3000 and display it as a total in a new div. Example of what I'm going for here. Thanks :) (Also, is there a php site similar to JSfiddle?)

    Read the article

  • how to adjust sliding of scroll according to the value calculated by me?

    - by cng
    I am working on scroll. I have made a program wherein if the scroll box is in particular range of the panel then it automatically moves to a particular position in the slider. For eg, I have a panel of size 500. the scroll has height of 100. Now the total intervals are 5. Now if i slide the scroll box at a position 225 then i want that it automatically slides to the start of that interval that is at position 200. or if i slide to position 450 then instead of staying there it goes to position 400. Is it possible?

    Read the article

  • wanted to get all dates in mysql result

    - by PankajK
    I have mysql table called user(id, name, join_on) join on is a date field what I want is to show in each day how many uses has been created I can use group by but it will only give me the dates when users get added like if date 4/12/10 5 users added 4/13/10 2 users added 4/15/10 7 users added here date 4/14/10 is missing and I want listing of all dates in one month. I have one solution for it by creating another table only for adding date and that table will left join my users table on join_on and will give total result but I don't want to do that as for creating that I need to create and add entries in date table please suggest the different approach for doing so. Thank you.

    Read the article

  • strategy to allocate/free lots of small objects

    - by aaa
    hello I am toying with certain caching algorithm, which is challenging somewhat. Basically, it needs to allocate lots of small objects (double arrays, < 256 elements), with objects accessible through mapped value, map[key] = array. time to initialized array may be quite large, generally more than 10 thousand cpu cycles. By lots I mean around gigabyte in total. objects may need to be popped/pushed as needed, generally in random places, one object at a time. lifetime of an object is generally long, minutes or more, however, object may be subject to allocation/deallocation several times during duration of program. What would be good strategy to avoid memory fragmentation, while still maintaining reasonable allocate deallocate speed? I am using C++, so I can use new and malloc. Thanks. I know there a similar questions on website, http://stackoverflow.com/questions/2156745/efficiently-allocating-many-short-lived-small-objects, are somewhat different, thread safety is not immediate issue for me.

    Read the article

  • LINQ to Entites: Doing a count over one-to-many relationships

    - by chris
    I have a couple of tables where there are one to many relationships. Let's say I have a Country table, a State table with a FK to Country, and a City table with a FK to State. I'd like to be able to create a count of all Cities for a given country, and also a count of cities based on a filter - something like: foreach( var country in Model.Country ) { total = country.State.All().City.All().Count() ; filtered = country.State.All().City.Any(c=>c.field == value).Count(); } Obviously, this doesn't work - is there any way to do this?

    Read the article

  • one-liner if statements...

    - by snickered
    Total noob here so be gentle. I've looked everywhere and can't seem to find the answer to this. How do I condense the following? if (expression) { return true; } else { return false; } I can't get it to work since it's returning something vs. setting something. I've already seen things like this: somevar = (expression) ? value1 : value2; Like I said, please be gentle :)

    Read the article

  • sql count function

    - by suryll
    Hi I have three tables and I want to know how much jobs with the wage of 1000 an employee has had The first SQL query gives me the names of all the employees that has recieved 1000 for a job SELECT distinct first_name FROM employee, job, link WHERE job.wage = 1000 AND job.job_id = link.job_id and employee.employee_id = link.employee_id; The second SQL query gives me the total number for all employees of how much jobs they have made for 1000 SELECT count(wage) FROM employee, job, link WHERE job.wage = 1000 AND job.job_id = link.job_id and employee.employee_id = link.employee_id; I was wondering if there was a way of joining both queries and also making the second for each specific employee???

    Read the article

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