Search Results

Search found 8083 results on 324 pages for 'total newbie'.

Page 64/324 | < Previous Page | 60 61 62 63 64 65 66 67 68 69 70 71  | Next Page >

  • Need help/suggestions for creating fantasy sports scoring databases and queries

    - by MGumbel
    I'm trying to create a website for my friends and I to keep track of fantasy sports scoring. So far, I've been doing the calculations and storage in Excel, which is very tedious. I'm trying to make it more simplified and automated through a SQL database that I can then wrap a web app around to enter daily stat updates. It's premised on our participation in another commercial site where we trade virtual shares of athletes, and thus acquire an "ownership percentage" in each athlete. For instance, if there are 100 shares of AROD, and I own 10 shares, then I own 10%. It then applies this to traditional baseball rotisserie scoring. So, for instance, if AROD has 1 HR today, then his adjusted HR stat would be 1.10. If he also has 2 RBI's, then his adjusted RBI stat today would be 2.20, based on (2 x 1.10)(1 to normalize the stat, and the .10 to represent the ownership percentage). All the stats for my team would then be summed each day and added to my stat history to come to an aggregated total. After that, points are allocated based on the ranking of each participant in each category at the end of the day. E.g. if there are 10 participants, and I have the highest total aggregate number of Adjusted HR's, then I get 10 pts. The points are then summed across the different stat categories to come up with a total point ranking for that day. An added difficulty is that ownership %'s can change on a daily basis. So far, in playing around with different schema, I don't know that having a separate table for each athlete's stats and each player's ownership %'s is the wisest choice. It seems to me that simply having two tables, one that contains the daily stat information for each athlete, and another that shows the ownership % of each player. My friend suggested using a start and end date for each ownership % to represent the potential daily changes in this category. I'm admittedly new to database development, so any suggestions on query code would be appreciated.

    Read the article

  • Mysql count and sum from two diferent tables

    - by Agent_x
    Hi all, i have a problem with some querys in php and mysql: I have 2 diferent tables with one field in common: table 1 id | hits | num_g | cats | usr_id |active 1 | 10 | 11 | 1 | 53 | 1 2 | 13 | 16 | 3 | 53 | 1 1 | 10 | 22 | 1 | 22 | 1 1 | 10 | 21 | 3 | 22 | 1 1 | 2 | 6 | 2 | 11 | 1 1 | 11 | 1 | 1 | 11 | 1 table 2 id | usr_id | points 1 | 53 | 300 Now i use this statement to sum just the total from the table 1 every id count + 1 too SELECT usr_id, COUNT( id ) + SUM( num_g + hits ) AS tot_h FROM table1 WHERE usr_id!='0' GROUP BY usr_id ASC LIMIT 0 , 15 and i get the total for each usr_id usr_id| tot_h | 53 | 50 22 | 63 11 | 20 until here all is ok, now i have a second table with extra points (table2) I try this: SELECT usr_id, COUNT( id ) + SUM( num_g + hits ) + (SELECT points FROM table2 WHERE usr_id != '0' ) AS tot_h FROM table1 WHERE usr_id != '0' GROUP BY usr_id ASC LIMIT 0 , 15 but it seems to sum the 300 extra points to all users: usr_id| tot_h | 53 | 350 22 | 363 11 | 320 Now how i can get the total like the first try but + the secon table in one statement? because now i have just one entry in the second table but i can be more there. thanks for all the help. =============================================================================== hi thomas thanks for your reply, i think is in the right direction, but im getting weirds results, like usr_id | tot_h 22 | NULL <== i think the null its because that usr_id as no value in the table2 53 | 1033 Its like the second user is getting all the the values. then i try this one: SELECT table1.usr_id, COUNT( table1.id ) + SUM( table1.num_g + table1.hits + table2.points ) AS tot_h FROM table1 LEFT JOIN table2 ON table2.usr_id = table1.usr_id WHERE table1.usr_id != '0' AND table2.usr_id = table1.usr_id GROUP BY table1.usr_id ASC Same result i just get the sum of all values and not by each user, i need something like this result: usr_id | tot_h 53 | 53 <==== plus 300 points on table1 22 | 56 <==== plus 100 points on table2 /////////the result i need //////////// usr_id | tot_h 53 | 353 <==== plus 300 points on table2 22 | 156 <==== plus 100 points on table2 I think the structure need to be something like this Pseudo statements ;) from table1 count all id to get the number of record where the usr_id are then sum hits + num_g and from table2 select the extra points where the usr_id are the same as table1 and get teh result: usr_id | tot_h 53 | 353 22 | 156

    Read the article

  • Having to insert a record, then update the same record warrants 1:1 relationship design?

    - by dianovich
    Let's say an Order has many Line items and we're storing the total cost of an order (based on the sum of prices on order lines) in the orders table. -------------- orders -------------- id ref total_cost -------------- -------------- lines -------------- id order_id price -------------- In a simple application, the order and line are created during the same step of the checkout process. So this means INSERT INTO orders .... -- Get ID of inserted order record INSERT into lines VALUES(null, order_id, ...), ... where we get the order ID after creating the order record. The problem I'm having is trying to figure out the best way to store the total cost of an order. I don't want to have to create an order create lines on an order calculate cost on order based on lines then update record created in 1. in orders table This would mean a nullable total_cost field on orders for starters... My solution thus far is to have an order_totals table with a 1:1 relationship to the orders table. But I think it's redundant. Ideally, since everything required to calculate total costs (lines on an order) is in the database, I would work out the value every time I need it, but this is very expensive. What are your thoughts?

    Read the article

  • Why does the BackgroundWorker in WPF need Thread.Sleep to update UI controls?

    - by user364060
    namespace WpfApplication1 { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { BackgroundWorker bgWorker; Action<int> myProgressReporter; public Window1() { InitializeComponent(); bgWorker = new BackgroundWorker(); bgWorker.DoWork += bgWorker_Task; bgWorker.RunWorkerCompleted += myWorker_RunWorkerCompleted; // hook event to method bgWorker.ProgressChanged += bgWorker_ReportProgress; // hook the delegate to the method myProgressReporter = updateProgress; bgWorker.WorkerReportsProgress = true; } private void myWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { object result; result = e.Result; MessageBox.Show(result.ToString()); progressBar1.Value = 0; button1.IsEnabled = true; } private void bgWorker_ReportProgress(object sender, ProgressChangedEventArgs e) { System.Windows.Threading.Dispatcher disp = button1.Dispatcher; disp.BeginInvoke(myProgressReporter,e.ProgressPercentage); //Dispatcher.BeginInvoke(myProgressReporter, DispatcherPriority.Normal, e.ProgressPercentage); } private void updateProgress(int progressPercentage) { progressBar1.Value = progressPercentage; } private void bgWorker_Task(Object sender, DoWorkEventArgs e) { int total = 1000; for (int i = 1; i <= total; i++) { if (bgWorker.WorkerReportsProgress) { int p = (int)(((float)i / (float)total) * 100); bgWorker.ReportProgress(p); } Thread.Sleep(1); // Without Thread.Sleep(x) the main thread freezes or gives stackoverflow exception, } e.Result = "Completed"; } private void button1_Click(object sender, RoutedEventArgs e) { if(!bgWorker.IsBusy) bgWorker.RunWorkerAsync("This is a background process"); button1.IsEnabled = false; } } }

    Read the article

  • C# Automatic Properties - Still null after +=?

    - by Sam Schutte
    This seems like a bug to me... I accept that automatic properties, defined as such: public decimal? Total { get; set; } Will be null when they are first accessed. They haven't been initialized, so of course they are null. But, even after setting their value through +=, this decimal? still remains null. So after: Total += 8; Total is still null. How can this be correct? I understand that it's doing a (null + 8), but seems strange that it doesn't pick up that it means it should just be set to 8... Addendums: I made the "null + 8" point in my question - but notice that it works with strings. So, it does null + "hello" just fine, and returns "hello". Therefore, behind the scenes, it is initializing the string to a string object with the value of "hello". The behavior should be the same for the other types, IMO. It might be because a string can accept a null as a value, but still, a null string is not an initialized object, correct? Perhaps it's just because a string isn't a nullable...

    Read the article

  • Is there a set based solution for this problem?

    - by NYSystemsAnalyst
    We have a table set up as follows: |ID|EmployeeID|Date |Category |Hours| |1 |1 |1/1/2010 |Vacation Earned|2.0 | |2 |2 |2/12/2010|Vacation Earned|3.0 | |3 |1 |2/4/2010 |Vacation Used |1.0 | |4 |2 |5/18/2010|Vacation Earned|2.0 | |5 |2 |7/23/2010|Vacation Used |4.0 | The business rules are: Vacation balance is calculated by vacation earned minus vacation used. Vacation used is always applied against the oldest vacation earned amount first. We need to return the rows for Vacation Earned that have not been offset by vacation used. If vacation used has only offset part of a vacation earned record, we need to return that record showing the difference. For example, using the above table, the result set would look like: |ID|EmployeeID|Date |Category |Hours| |1 |1 |1/1/2010 |Vacation Earned|1.0 | |4 |2 |5/18/2010|Vacation Earned|1.0 | Note that record 2 was eliminated because it was completely offset by used time, but records 1 and 4 were only partially used, so they were calculated and returned as such. The only way we have thought of to do this is to get all of the vacation earned records in a temporary table. Then, get the total vacation used and loop through the temporary table, deleting the oldest record and subtracting that value from the total vacation used until the total vacation used is zero. We could clean it up for when the remaining vacation used is only part of the oldest vacation earned record. This would leave us with just the outstanding vacation earned records. This works, but it is very inefficient and performs poorly. Also, the performance will just degrade over time as more and more records are added. Are there any suggestions for a better solution, preferable set based? If not, we'll just have to go with this.

    Read the article

  • MySQL subquery and bracketing

    - by text
    Here are my tables respondents: field sample value respondentid : 1 age : 2 gender : male survey_questions: id : 1 question : Q1 answer : sample answer answers: respondentid : 1 question : Q1 answer : 1 --id of survey question I want to display all respondents who answered the certain survey, display all answers and total all the answer and group them according to the age bracket. I tried using this query: SELECT res.Age, res.Gender, answer.id, answer.respondentid, SUM(CASE WHEN res.Gender='Male' THEN 1 else 0 END) AS males, SUM(CASE WHEN res.Gender='Female' THEN 1 else 0 END) AS females, CASE WHEN res.Age < 1 THEN 'age1' WHEN res.Age BETWEEN 1 AND 4 THEN 'age2' WHEN res.Age BETWEEN 4 AND 9 THEN 'age3' WHEN res.Age BETWEEN 10 AND 14 THEN 'age4' WHEN res.Age BETWEEN 15 AND 19 THEN 'age5' WHEN res.Age BETWEEN 20 AND 29 THEN 'age6' WHEN res.Age BETWEEN 30 AND 39 THEN 'age7' WHEN res.Age BETWEEN 40 AND 49 THEN 'age8' ELSE 'age9' END AS ageband FROM Respondents AS res INNER JOIN Answers as answer ON answer.respondentid=res.respondentid INNER JOIN Questions as question ON answer.Answer=question.id WHERE answer.Question='Q1' GROUP BY ageband ORDER BY res.Age ASC I was able to get the data but the listing of all answers are not present. Do I have to subquery SELECT into my current SELECT statement to show the answers? I want to produce something like this: ex: # of Respondents is 3 ages: 2,3 and 6 Question: what are your favorite subjects? Ages 1-4: subject 1: 1 subject 2: 2 subject 3: 2 total respondents for ages 1-4 : 2 Ages 5-10: subject 1: 1 subject 2: 1 subject 3: 0 total respondents for ages 5-10 : 1

    Read the article

  • How to add "missing" columns in a column group in reporting services?

    - by Gimly
    Hello, I'm trying to create a report that displays for each months of the year the quantity of goods sold. I have a query that returns the list of goods sold for each month, it looks something like this : SELECT Seller.FirstName, Seller.LastName, SellingHistory.Month, SUM(SellingHistory.QuantitySold) FROM SellingHistory JOIN Seller on SellingHistory.SellerId = Seller.SellerId WHERE SellingHistory.Year = @Year GOUP BY Seller.FirstName, Seller.LastName, SellingHistory.Month What I want to do is display a report that has a column for each months + a total column that will display for each Seller the quantity sold in the selected month. Seller Name | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Total What I managed to do is using a matrix and a column group (group on Month) to display the columns for existing data, if I have data from January to March, it will display the 3 first columns and the total. What I would like to do is always display all the columns. I thought about making that by adding the missing months in the SQL request, but I find that a bit weird and I'm sure there must be some "cleanest" solution as this is something that must be quite frequent. Thanks. PS: I'm using SQL Server Express 2008

    Read the article

  • How can I read and parse chunks of data into a Perl hash of arrays?

    - by neversaint
    I have data that looks like this: #info #info2 1:SRX004541 Submitter: UT-MGS, UT-MGS Study: Glossina morsitans transcript sequencing project(SRP000741) Sample: Glossina morsitans(SRS002835) Instrument: Illumina Genome Analyzer Total: 1 run, 8.3M spots, 299.9M bases Run #1: SRR016086, 8330172 spots, 299886192 bases 2:SRX004540 Submitter: UT-MGS Study: Anopheles stephensi transcript sequencing project(SRP000747) Sample: Anopheles stephensi(SRS002864) Instrument: Solexa 1G Genome Analyzer Total: 1 run, 8.4M spots, 401M bases Run #1: SRR017875, 8354743 spots, 401027664 bases 3:SRX002521 Submitter: UT-MGS Study: Massive transcriptional start site mapping of human cells under hypoxic conditions.(SRP000403) Sample: Human DLD-1 tissue culture cell line(SRS001843) Instrument: Solexa 1G Genome Analyzer Total: 6 runs, 27.1M spots, 977M bases Run #1: SRR013356, 4801519 spots, 172854684 bases Run #2: SRR013357, 3603355 spots, 129720780 bases Run #3: SRR013358, 3459692 spots, 124548912 bases Run #4: SRR013360, 5219342 spots, 187896312 bases Run #5: SRR013361, 5140152 spots, 185045472 bases Run #6: SRR013370, 4916054 spots, 176977944 bases What I want to do is to create a hash of array with first line of each chunk as keys and SR## part of lines with "^Run" as its array member: $VAR = { 'SRX004541' => ['SRR016086'], # etc } But why my construct doesn't work. And it must be a better way to do it. use Data::Dumper; my %bighash; my $head = ""; my @temp = (); while ( <> ) { chomp; next if (/^\#/); if ( /^\d{1,2}:(\w+)/ ) { print "$1\n"; $head = $1; } elsif (/^Run \#\d+: (\w+),.*/){ print "\t$1\n"; push @temp, $1; } elsif (/^$/) { push @{$bighash{$head}}, [@temp]; @temp =(); } } print Dumper \%bighash ;

    Read the article

  • how to call a js function from loaded jquery

    - by Y.G.J
    the function is in the page loading the ajax but i'm trying to call the function codes: [ajax] $.ajax({ type: "POST", url: "loginpersonal.asp", data: "id=<%=request("id")%>", beforeSend: function() { $("#personaltab").hide(); }, success: function(msg){ $("#personaltab").empty().append(msg); }, complete: function() { $("#personaltab").slideDown(); }, error: function() { $("#personaltab").append("error").slideDown(); } }); [the js function] function GetCount(t){ if(t>0) { total = t } else { total -=1; } amount=total; if(amount < 0){ startpersonalbid(); } else{ days=0;hours=0;mins=0;secs=0;out=""; days=Math.floor(amount/86400);//days amount=amount%86400; hours=Math.floor(amount/3600);//hours amount=amount%3600; mins=Math.floor(amount/60);//minutes amount=amount%60; secs=Math.floor(amount);//seconds if(days != 0){out += days +":";} if(days != 0 || hours != 0){out += hours +":";} if(days != 0 || hours != 0 || mins != 0){out += ((mins>=10)?mins:"0"+mins) +":";} out += ((secs>=10)?secs:"0"+secs) ; document.getElementById('countbox').innerHTML=out; setTimeout("GetCount()", 1000); } } window.onload=function(){ GetCount(<%= DateDiff("s", Now,privatesellstartdate&" "&privatesellstarttime ) %>); so at the end of the loginpersonal.asp from the ajax... if it does what it suppose to do... i'm trying to call the function GetCount() again.

    Read the article

  • How i can fix the increasing order summation code?

    - by user2971559
    I want from the java to reads all numbers from the user as long as the number entered by user is bigger than the previous number. But i could write it for only positive numbers. How i can fix code below if all numbers included. If it is possible please write the solution for beginners because its my first year in computer science in college and I haven't learn a lot yet. import acm.program.*; public class IncreasingOrder extends ConsoleProgram { public void run() { int previousNumber = 0; int total = 0; int count = 0; while(true) { int n = readInt("Enter > "); if (n <= previousNumber) break; total += n; count++; previousNumber = n; } println("You have entered " + count + " numbers in increasing order."); println("Sum of these " + count + " numbers is " + total + "."); } }

    Read the article

  • Know the row with max characters (C)

    - by l_core
    I have wrote a program in C, to find the row with the max number of characters. Here is the code #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int main (int argc, char *argv[]) { char c; /* used to store the character with getc */ int c_tot = 0, c_rig = 0, c_max = 0; /* counters of characters*/ int r_tot = 0; /* counters of rows */ FILE *fptr; fptr = fopen(argv[1], "r"); if (fptr == NULL || argc != 2) { printf ("Error opening the file %s\n'", argv[1]); exit(EXIT_FAILURE); } while ( (c = getc(fptr)) != EOF) { if (c != ' ' && c != '\n') { c_tot++; c_rig++; } if (c == '\n') { r_tot++; if (c_rig > c_max) c_max = c_rig; c_rig = 0; } } printf ("Total rows: %d\n", r_tot); printf ("Total characters: %d\n", c_tot); printf ("Total characters in a row: %d\n", c_max); printf ("Average number of characters on a row: %d\n", (c_tot/r_tot)); printf ("The row with max characters is: %s\n", ??????) return 0; } I can easily find the row with the highest number of characters but how can i print that out? Thank You Folks

    Read the article

  • Dynamic Array of Objects Sans Vector Class

    - by Connor Black
    I am doing a homework assignment for my summer OO class and we need to write two classes. One is called Sale and the other is called Register. I've written my Sale class; here's the .h file: enum ItemType {BOOK, DVD, SOFTWARE, CREDIT}; class Sale { public: Sale(); // default constructor, // sets numerical member data to 0 void MakeSale(ItemType x, double amt); ItemType Item(); // Returns the type of item in the sale double Price(); // Returns the price of the sale double Tax(); // Returns the amount of tax on the sale double Total(); // Returns the total price of the sale void Display(); // outputs sale info private: double price; // price of item or amount of credit double tax; // amount of sales tax double total; // final price once tax is added in. ItemType item; // transaction type }; For the Register class we need to include a dynamic array of Sale objects in our member data. We cannot use the vector class. How is this done? Here's my 'Register' '.h' class Register{ public: Register(int ident, int amount); ~Register(); int GetID(){return identification;} int GetAmount(){return amountMoney;} void RingUpSale(ItemType item, int basePrice); void ShowLast(); void ShowAll(); void Cancel(); int SalesTax(int n); private: int identification; int amountMoney; };

    Read the article

  • How grouping and totaling are done into three tables using JOIN

    - by text
    Here are my tables respondents: field sample value respondentid : 1 age : 2 gender : male survey_questions: id : 1 question : Q1 answer : sample answer answers: respondentid : 1 question : Q1 answer : 1 --id of survey question I want to display all respondents who answered the certain survey, display all answers and total all the answer and group them according to the age bracket. I tried using this query: $sql = "SELECT res.Age, res.Gender, answer.id, answer.respondentid, SUM(CASE WHEN res.Gender='Male' THEN 1 else 0 END) AS males, SUM(CASE WHEN res.Gender='Female' THEN 1 else 0 END) AS females, CASE WHEN res.Age < 1 THEN 'age1' WHEN res.Age BETWEEN 1 AND 4 THEN 'age2' WHEN res.Age BETWEEN 4 AND 9 THEN 'age3' WHEN res.Age BETWEEN 10 AND 14 THEN 'age4' WHEN res.Age BETWEEN 15 AND 19 THEN 'age5' WHEN res.Age BETWEEN 20 AND 29 THEN 'age6' WHEN res.Age BETWEEN 30 AND 39 THEN 'age7' WHEN res.Age BETWEEN 40 AND 49 THEN 'age8' ELSE 'age9' END AS ageband FROM Respondents AS res INNER JOIN Answers as answer ON answer.respondentid=res.respondentid INNER JOIN Questions as question ON answer.Answer=question.id WHERE answer.Question='Q1' GROUP BY ageband ORDER BY res.Age ASC"; I was able to get the data but the listing of all answers are not present. What's wrong with my query. I want to produce something like this: ex: # of Respondents is 3 ages: 2,3 and 6 Question: what are your favorite subjects? Ages 1-4: subject 1: 1 subject 2: 2 subject 3: 2 total respondents for ages 1-4 : 2 Ages 5-10: subject 1: 1 subject 2: 1 subject 3: 0 total respondents for ages 5-10 : 1

    Read the article

  • Same Data Appear only once.

    - by friendishan
    I have the following code which produces following output:- <? $tablaes = mysql_query("SELECT * FROM members where id='$order[user_id]'"); $user = mysql_fetch_array($tablaes); $idsd=$user['id']; $rPaid=mysql_query("SELECT SUM(`price`) AS total FROM order_history WHERE type!='rent_referral' AND date>'" . strtotime($time1) . "' AND date<'" . strtotime($time2) . "'"); $hdPaid = mysql_fetch_array($rPaid); $sPaid=mysql_query("SELECT SUM(`price`) AS total FROM order_history WHERE user_id='$idsd' AND type!='rent_referral' AND date>'" . strtotime($time1) . "' AND date<'" . strtotime($time2) . "'"); while ($hPaid = mysql_fetch_array($sPaid)) { ?> <td><?=$user['username']?></td> <td><?=$hPaid['total']?></td> <? } ?> </tr> It appears like this http://dl.dropbox.com/u/14384295/darrenan.jpg I want same data to appear only once.. Like Username: Vegas and price with him only once.

    Read the article

  • PHP: Trying to come up with a "prev" and "next" link

    - by fwaokda
    I'm displaying 10 records per page. The variables I have currently that I'm working with are.. $total = total number of records $page = whats the current page I'm displaying I placed this at the top of my page... if ( $_GET['page'] == '' ) { $page = 1; } //if no page is specified set it to `1` else { $page = ($_GET['page']); } // if page is specified set it Here are my two links... if ( $page != 1 ) { echo '<div style="float:left" ><a href="index.php?page='. ( $page - 1 ) .'" rev="prev" >Prev</a></div>'; } if ( !( ( $total / ( 10 * $page ) ) < $page ) ) { echo '<div style="float:right" ><a href="index.php?page='. ( $page + 1 ) .'" rev="next" >Next</a></div>'; } Now I guess (unless I'm not thinking of something) that I can display the "Prev" link every time except when the page is '1'. How can make it where the "Next" link doesn't show on the last page though?

    Read the article

  • VB Change Calulator

    - by BlueBeast
    I am creating a VB 2008 change calculator as an assignment. The program is to use the amount paid - the amount due to calculate the total.(this is working fine). After that, it is to break that amount down into dollars, quarters, dimes, nickels, and pennies. The problem I am having is that sometimes the quantity of pennies, nickels or dimes will be a negative number. For example $2.99 = 3 Dollars and -1 Pennies. SOLVED Thanks to the responses, here is what I was able to make work with my limited knowledge. Option Explicit On Option Strict Off Option Infer Off Public Class frmMain Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click 'Clear boxes lblDollarsAmount.Text = String.Empty lblQuartersAmount.Text = String.Empty lblDimesAmount.Text = String.Empty lblNickelsAmount.Text = String.Empty lblPenniesAmount.Text = String.Empty txtOwed.Text = String.Empty txtPaid.Text = String.Empty lblAmountDue.Text = String.Empty txtOwed.Focus() End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click 'Close application' Me.Close() End Sub Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click ' Find Difference between Total Price and Total Received lblAmountDue.Text = Val(txtPaid.Text) - Val(txtOwed.Text) Dim intChangeAmount As Integer = lblAmountDue.Text * 100 'Declare Integers Dim intDollarsBack As Integer Dim intQuartersBack As Integer Dim intDimesBack As Integer Dim intNickelsBack As Integer Dim intPenniesBack As Integer ' Change Values Const intDollarValue As Integer = 100 Const intQuarterValue As Integer = 25 Const intDimeValue As Integer = 10 Const intNickelValue As Integer = 5 Const intPennyValue As Integer = 1 'Dollars intDollarsBack = CInt(Val(intChangeAmount \ intDollarValue)) intChangeAmount = intChangeAmount - Val(Val(intDollarsBack) * intDollarValue) lblDollarsAmount.Text = intDollarsBack.ToString 'Quarters intQuartersBack = CInt(Val(intChangeAmount \ intQuarterValue)) intChangeAmount = intChangeAmount - Val(Val(intQuartersBack) * intQuarterValue) lblQuartersAmount.Text = intQuartersBack.ToString 'Dimes intDimesBack = CInt(Val(intChangeAmount \ intDimeValue)) intChangeAmount = intChangeAmount - Val(Val(intDimesBack) * intDimeValue) lblDimesAmount.Text = intDimesBack.ToString 'Nickels intNickelsBack = CInt(Val(intChangeAmount \ intNickelValue)) intChangeAmount = intChangeAmount - Val(Val(intNickelsBack) * intNickelValue) lblNickelsAmount.Text = intNickelsBack.ToString 'Pennies intPenniesBack = CInt(Val(intChangeAmount \ intPennyValue)) intChangeAmount = intChangeAmount - Val(Val(intPenniesBack) * intPennyValue) lblPenniesAmount.Text = intPenniesBack.ToString End Sub End Class

    Read the article

  • Need help trouble shooting high CPU usage by PHP-fpm

    - by user432506
    There is a problem that is driving me crazy. After the day I tried to fix the CPU usage problem of my VPS, the CPU load has grown from 60% to 150%, and I have no idea what causes the problem. Please help me. I had installed a copy of mediawiki on a Linode 1024. The wiki is running on Niginx + PHP-fpm + MySql. The wiki doesn't have much traffic, only around 4000 requests/day, mostly from Google and Bing bots. It had been using around 60% (of total 400% on the Linode) of the CPU before. I thought it was a bit high, so two day ago, I was trying to fix the problem (not knowing what was waiting for me). I did nothing but added a new empty line to wiki's configure file, which would change the modified time of the configure file, and then all the cached page files would be set invalidated. I had done that before, and that would cause high CPU usage, but normally it would take only hours to let things back to normal again. Not this time, my CPU usage has been around 150% for more than two days. It is php-fpm using most of CPU reassures. Using 100% of three cores is not rare. I hadn't seen that before. There are other sites on the Linode, but it should be the wiki. Because if I offline the wiki, CPU usage will drop back to around 40% soon. The day I also duplicated php-fpm.conf, and opened it, but didn't changed it. I have no idea what I did wrong. I here ask for help to save myself from being crazy!!! It is php-fpm. Is there a way to find out what is it doing? I mean like which scripts are related and what function codes are running? top: top - 06:34:33 up 10 days, 4:23, 2 users, load average: 1.10, 1.24, 1.37 Tasks: 76 total, 4 running, 72 sleeping, 0 stopped, 0 zombie Cpu(s): 61.1%us, 3.1%sy, 0.0%ni, 32.8%id, 2.9%wa, 0.0%hi, 0.0%si, 0.1%st Mem: 1028684k total, 945192k used, 83492k free, 89580k buffers Swap: 524284k total, 18084k used, 506200k free, 530380k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 26721 www-data 20 0 208m 54m 34m R 99 5.4 0:09.07 /opt/php5/sbin/php-fpm --fpm-config /opt/php5/etc/php-fpm.conf 26592 www-data 20 0 207m 45m 26m R 91 4.5 0:12.77 /opt/php5/sbin/php-fpm --fpm-config /opt/php5/etc/php-fpm.conf 26706 www-data 20 0 196m 43m 34m S 47 4.3 0:15.19 /opt/php5/sbin/php-fpm --fpm-config /opt/php5/etc/php-fpm.conf 26583 www-data 20 0 197m 45m 35m S 33 4.5 0:19.08 /opt/php5/sbin/php-fpm --fpm-config /opt/php5/etc/php-fpm.conf 26787 www-data 20 0 206m 36m 18m R 25 3.7 0:00.41 /opt/php5/sbin/php-fpm --fpm-config /opt/php5/etc/php-fpm.conf 26661 www-data 20 0 207m 46m 26m S 13 4.6 0:19.87 /opt/php5/sbin/php-fpm --fpm-config /opt/php5/etc/php-fpm.conf 1971 mysql 20 0 155m 57m 3952 S 8 5.7 383:57.81 /usr/sbin/mysqld 242 root 20 0 0 0 0 S 1 0.0 0:51.36 [kworker/3:1] 5711 root 20 0 139m 95m 580 S 1 9.5 0:41.30 /usr/local/bin/memcached -d -u root -m 128 -p 11211 19463 root 20 0 190m 3984 1284 S 1 0.4 0:02.66 /opt/php5/sbin/php-fpm --fpm-config /opt/php5/etc/php-fpm.conf 29100 www-data 20 0 10928 5540 820 S 1 0.5 4:49.05 nginx: worker process vmstat 30 procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 16912 81456 90784 554172 0 0 4 6 3 2 11 1 87 1 0 0 16912 78036 91000 555356 0 0 38 34 1397 375 12 1 87 0 4 0 16912 31776 91528 557508 0 0 78 42 3197 487 45 1 52 1 1 0 16912 83356 91768 558576 0 0 35 56 2608 449 32 1 67 1 1 0 16912 81548 92040 559720 0 0 41 31 1243 432 8 1 91 1 2 0 16912 53056 92332 562744 0 0 105 33 2013 581 17 1 81 1 2 0 16912 73236 92552 564844 0 0 68 36 1968 615 16 1 82 1 0 0 16912 91612 92904 566676 0 0 69 35 1845 692 13 1 85 1 1 0 16912 71248 93180 568428 0 0 58 33 1952 604 15 1 82 1 1 0 16868 55952 93516 572660 1 0 144 42 1801 637 12 1 86 1 2 0 16868 48324 94416 577844 0 0 189 66 2058 702 17 1 80 2 1 0 16928 58644 94592 578184 0 2 160 49 2578 723 25 1 70 3 5 0 16928 22600 94980 580568 0 0 89 32 1496 361 13 0 85 1 0 0 16988 49256 94500 576396 0 2 41 37 1601 426 14 1 85 0 5 0 18084 24336 86032 502748 0 37 83 68 2989 562 42 1 56 0 1 0 18084 123604 86376 506996 0 0 118 41 2201 573 22 1 76 1 2 0 18084 126984 86752 508876 0 0 64 53 1620 490 13 1 85 1 2 0 18084 103104 87148 510768 0 0 71 37 2757 602 33 1 64 1

    Read the article

  • PHP-FPM High Memory Usage

    - by Ruel
    I have a wordpress blog, that uses WP-SuperCache, and normally I get 100 visitors per day. With nginx + php-fpm it's blazing fast, and I have no regrets. One thing i noticed, php-fpm takes a lot of memory: top - 09:20:43 up 5 days, 15:53, 1 user, load average: 0.00, 0.00, 0.00 Tasks: 26 total, 1 running, 25 sleeping, 0 stopped, 0 zombie Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 1048576k total, 329956k used, 718620k free, 0k buffers Swap: 0k total, 0k used, 0k free, 0k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 10226 www-data 15 0 145m 52m 4584 S 0.0 5.1 0:07.55 php-fpm 10223 www-data 16 0 141m 48m 4692 S 0.0 4.8 0:08.70 php-fpm 20277 www-data 15 0 138m 46m 4368 S 0.0 4.5 0:07.55 php-fpm 20259 www-data 15 0 133m 41m 4600 S 0.0 4.0 0:06.68 php-fpm 12201 www-data 15 0 133m 41m 4632 S 0.0 4.0 0:08.31 php-fpm 11586 www-data 15 0 132m 40m 4292 S 0.0 3.9 0:03.27 php-fpm 29822 www-data 15 0 128m 36m 4356 S 0.0 3.6 0:05.26 php-fpm 28427 mysql 15 0 200m 7300 4764 S 0.0 0.7 0:47.89 mysqld 10202 root 18 0 98.3m 4320 1204 S 0.0 0.4 0:03.80 php-fpm 22524 root 18 0 86064 3396 2652 S 0.0 0.3 0:16.74 sshd 9882 www-data 18 0 42052 2572 804 S 0.0 0.2 0:27.52 nginx 9884 www-data 18 0 42052 2560 804 S 0.0 0.2 0:26.26 nginx 9881 www-data 18 0 42064 2524 804 S 0.0 0.2 0:29.24 nginx 9879 www-data 18 0 42032 2480 804 S 0.0 0.2 0:29.58 nginx 23771 root 15 0 12176 1820 1316 S 0.0 0.2 0:00.08 bash 28344 root 22 0 11932 1416 1184 S 0.0 0.1 0:00.00 mysqld_safe 18167 root 16 0 62628 1208 648 S 0.0 0.1 0:00.55 sshd 25941 root 15 0 12612 1192 928 R 0.0 0.1 0:02.21 top 11573 root 15 0 20876 1168 592 S 0.0 0.1 0:00.67 crond 9878 root 18 0 41000 1112 284 S 0.0 0.1 0:00.00 nginx 21736 root 23 0 21648 936 716 S 0.0 0.1 0:00.00 xinetd 11585 root 18 0 46748 816 428 S 0.0 0.1 0:00.00 saslauthd 14125 root 12 -4 12768 768 452 S 0.0 0.1 0:00.00 udevd 1 root 18 0 10352 728 616 S 0.0 0.1 0:17.93 init 24564 root 15 0 5912 680 544 S 0.0 0.1 0:01.90 syslogd 11618 root 18 0 46748 548 160 S 0.0 0.1 0:00.00 saslauthd Here's my php-fpm config: [global] pid = run/php-fpm.pid error_log = log/php-fpm.log log_level = notice [www] listen = 127.0.0.1:9000 user = www-data group = www-data pm = dynamic pm.max_children = 50 pm.start_servers = 3 pm.min_spare_servers = 3 pm.max_spare_servers = 10 pm.max_requests = 500 Sometimes it goes up to 400MB. And I'm planning to add a new website on my VPS. Is this normal?

    Read the article

  • Server performance worsened after a hardware upgrade: how should I reconfigure the server?

    - by twick
    I'm running a site on an Ubuntu/Apache/Django/PostgreSQL stack. We upgraded our server recently from 1 processor with 2 Gb total RAM (with 0.5 Gb of that RAM assigned to memcached) to a new server that has 2 processors with 4 Gb total RAM (with 2 Gb of that RAM assigned to memcached). However, when I looked at Google Webmaster Tools, I found out that the average page speed has worsened from 5 seconds to 15 seconds. Why would performance get worse with a hardware upgrade? What should I check and tune? Is this more likely to be a problem with memcached, Apache, Django, or PostgreSQL?

    Read the article

  • Error 80073701 when installing Windows 7 Service Pack 1

    - by Wagner Maestrelli
    I tried to install the Windows 7 Service Pack 1 using Windows Update and I got an error (code 80073701 - unknown error). I tried it again, same thing. Rebooted and tried again, same error. Before I tried to install the SP1 I had installed all the previous updates. I have Windows 7 Ultimate 32-bits. Has anyone gone through the same problem? Any ideas of what might be happening? Thanks! UPDATE: I installed the System Update Readiness Tool. Then, I tried to install the SP1 again, but the installation failed again with the same error. As I thought I was running out of options, I downloaded the SP1 package (500+ MB) and tried to install manually. Before that, I reinstalled the SUR Update. Well, the manual installation of the SP1 failed again. Then I learned about the c:\Windows\Logs\CBS\CheckSUR.log file (thanks Patches!). I checked it out. As I installed the SUR Update multiple times, the older logs are kept in the c:\Windows\Logs\CBS\CheckSUR.persist.log file. In the first time the SUR update was installed there was an error, which is said to have been fixed. In the subsequent logs, no errors were detected. The log with the error: ================================= Checking System Update Readiness. Binary Version 6.1.7600.20593 Package Version 7.0 2010-03-19 09:57 Checking Windows Servicing Packages Checking Package Manifests and Catalogs (f) CBS MUM Corrupt 0x800B0100 servicing\Packages\Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~x86~pt-BR~6.1.7600.16385.mum servicing\Packages\Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~x86~pt-BR~6.1.7600.16385.cat Package manifest cannot be validated by the corresponding catalog (fix) CBS MUM Corrupt CBS File Replaced Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~x86~pt-BR~6.1.7600.16385.mum from Cabinet: C:\Windows\CheckSur\v1.0\windows6.1-rtm-client-cab3-x86.cab. (fix) CBS Paired File CBS File also Replaced Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~x86~pt-BR~6.1.7600.16385.cat from Cabinet: C:\Windows\CheckSur\v1.0\windows6.1-rtm-client-cab3-x86.cab. Checking Package Watchlist Checking Component Watchlist Checking Packages Checking Component Store Summary: Seconds executed: 224 Found 1 errors Fixed 1 errors CBS MUM Corrupt Total count: 1 Fixed: CBS MUM Corrupt. Total count: 1 Fixed: CBS Paired File. Total count: 1 It seems it has something to do with the Brazilian Portuguese Language Pack, which happens to be my native language. Problem is I can't uninstall the language pack since it is my system default language. And I haven't found any place to download it so I could reinstall it manually. Well, any ideas? Thanks!

    Read the article

  • Linux Software RAID recovery

    - by Zoredache
    I am seeing a discrepancy between the output of mdadm --detail and mdadm --examine, and I don't understand why. This output mdadm --detail /dev/md2 /dev/md2: Version : 0.90 Creation Time : Wed Mar 14 18:20:52 2012 Raid Level : raid10 Array Size : 3662760640 (3493.08 GiB 3750.67 GB) Used Dev Size : 1465104256 (1397.23 GiB 1500.27 GB) Raid Devices : 5 Total Devices : 5 Preferred Minor : 2 Persistence : Superblock is persistent Seems to contradict this. (the same for every disk in the array) mdadm --examine /dev/sdc2 /dev/sdc2: Magic : a92b4efc Version : 0.90.00 UUID : 1f54d708:60227dd6:163c2a05:89fa2e07 (local to host) Creation Time : Wed Mar 14 18:20:52 2012 Raid Level : raid10 Used Dev Size : 1465104320 (1397.23 GiB 1500.27 GB) Array Size : 2930208640 (2794.46 GiB 3000.53 GB) Raid Devices : 5 Total Devices : 5 Preferred Minor : 2 The array was created like this. mdadm -v --create /dev/md2 \ --level=raid10 --layout=o2 --raid-devices=5 \ --chunk=64 --metadata=0.90 \ /dev/sdg2 /dev/sdf2 /dev/sde2 /dev/sdd2 /dev/sdc2 Each of the 5 individual drives have partitions like this. Disk /dev/sdc: 1500.3 GB, 1500301910016 bytes 255 heads, 63 sectors/track, 182401 cylinders, total 2930277168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00057754 Device Boot Start End Blocks Id System /dev/sdc1 2048 34815 16384 83 Linux /dev/sdc2 34816 2930243583 1465104384 fd Linux raid autodetect Backstory So the SATA controller failed in a box I provide some support for. The failure was a ugly and so individual drives fell out of the array a little at a time. While there are backups, we the are not really done as frequently as we really need. There is some data that I am trying to recover if I can. I got additional hardware and I was able to access the drives again. The drives appear to be fine, and I can get the array and filesystem active and mounted (using read-only mode). I am able to access some data on the filesystem and have been copying that off, but I am seeing lots of errors when I try to copy the most recent data. When I am trying to access that most recent data I am getting errors like below which makes me think that the array size discrepancy may be the problem. Mar 14 18:26:04 server kernel: [351588.196299] dm-7: rw=0, want=6619839616, limit=6442450944 Mar 14 18:26:04 server kernel: [351588.196309] attempt to access beyond end of device Mar 14 18:26:04 server kernel: [351588.196313] dm-7: rw=0, want=6619839616, limit=6442450944 Mar 14 18:26:04 server kernel: [351588.199260] attempt to access beyond end of device Mar 14 18:26:04 server kernel: [351588.199264] dm-7: rw=0, want=20647626304, limit=6442450944 Mar 14 18:26:04 server kernel: [351588.202446] attempt to access beyond end of device Mar 14 18:26:04 server kernel: [351588.202450] dm-7: rw=0, want=19973212288, limit=6442450944 Mar 14 18:26:04 server kernel: [351588.205516] attempt to access beyond end of device Mar 14 18:26:04 server kernel: [351588.205520] dm-7: rw=0, want=8009695096, limit=6442450944

    Read the article

  • mod_fcgid process doesn't respawn

    - by aaronsw
    I have a Python script running on my server as a FastCGI using Apache2 and mod_fcgid. I let it spawn up to five processes. But I soon get messages like these in the Apache logs: [Wed Sep 02 23:16:34 2009] [warn] (103)Software caused connection abort: mod_fcgid: ap_pass_brigade failed in handle_request function [Wed Sep 02 23:16:35 2009] [warn] (103)Software caused connection abort: mod_fcgid: ap_pass_brigade failed in handle_request function and then Apache doesn't seem to recognize that all its processes are dead (I have a max of 5 backends) and refuses to spawn new ones: [Wed Sep 02 23:26:16 2009] [notice] mod_fcgid: /var/www/hacks.og.theinfo.org/picker.fcgi total process count 5 >= 5, skip the spawn request [Wed Sep 02 23:26:17 2009] [notice] mod_fcgid: /var/www/hacks.og.theinfo.org/picker.fcgi total process count 5 >= 5, skip the spawn request at which point it refuses to respond to requests from the outside world. This doesn't seem to happen with my other FastCGIs, which all use the same Apache config: <IfModule mod_fcgid.c> AddHandler fcgid-script .fcgi IPCConnectTimeout 20 MaxProcessCount 5 DefaultMaxClassProcessCount 2 DefaultMinClassProcessCount 1 </IfModule> Any idea what causes it?

    Read the article

  • How to securely generate memorable passwords?

    - by Tim
    Whenever I need new passwords I use some tools to generate those, preferable memorable passwords, but I've been wondering how secure this might actually be. Using The xkcd random number generator is probably pretty bad, cat /dev/random is probably pretty good, but generating memorable passwords seems a bit more tricky. Whenever a program generates a memorable password, it only uses a subset of the total password space available, and it is not clear to me how big this space is. Of course a long password should help in this case, but if the `memorable' part of the program is too predictable, your passwords are not very good in the end. TL;DR: how secure are memorable password generators, given the fact that `memorable' passwords are a subset of total password space? Some tools I know of: pwgen -- seems ok, but passwords are not too memorable Mac Password Assistant - generates memorable passwords but it is unclear to me how this works.

    Read the article

  • Thinking Sphinx index rebuild error on windows xp: searchd is already running

    - by Voldy
    I have Sphinx installed on windows xp system. A I use Thinking Sphinx plug-in within my rails application. I can't rebuild index with Thinking Sphinx rake task after application server starting up even if I stop it: Stopped search daemon (pid 4492). ... bla bla bla ... total 3 reads, 0.000 sec, 1.3 kb/call avg, 0.0 msec/call avg total 9 writes, 0.000 sec, 1.2 kb/call avg, 0.0 msec/call avg WARNING: could not open pipe (GetLastError()=2) rake aborted! searchd is already running. If I reload system, I can rebuild index. What do you think about? p.s: Does this question suited for serverfault.com?

    Read the article

< Previous Page | 60 61 62 63 64 65 66 67 68 69 70 71  | Next Page >