Search Results

Search found 11153 results on 447 pages for 'count zero'.

Page 156/447 | < Previous Page | 152 153 154 155 156 157 158 159 160 161 162 163  | Next Page >

  • Singelton restricted to instance of dll

    - by codeySmurf
    If I create a singleton class in the context of a dll, the singleton class is instantiated once and used by all instances of the dll. I am using a dll as a plug-in for an application. Now the following thing came to my mind: If I use a singleton Class, it will be shared across multiple instances of the plug-in. However, this makes it difficult to manage the lifetime of the singleton class efficiently. The only way I could think of would be to use a reference count and to make the singleton delete its self when the reference count is 0. Does anyone have any better ideas on that? Is there any good way to restrict the singleton object to one instance of the dll? Language is c++

    Read the article

  • Calling a method on an object a bunch of times versus constructing an object a bunch of times

    - by Ami
    I have a List called myData and I want to apply a particular method (someFunction) to every element in the List. Is calling a method through an object's constructor slower than calling the same method many times for one particular object instantiation? In other words, is this: for(int i = 0; i < myData.Count; i++) myClass someObject = new myClass(myData[i]); slower than this: myClass someObject = new myClass(); for(int i = 0; i < myData.Count; i++) someObject.someFunction(myData[i]); ? If so, how much slower?

    Read the article

  • jQuery .ajax doesn't load Google Adsense

    - by Sahas Katta
    Hey Everyone, Just ran into an odd issue. I have a simple WP loop and instead of regular NEXT/BACK pages, I use a jQuery powered $.ajax get to append the following page to the current page. It works perfectly. However, I choose to insert a Google Adsense unit every 5th story. Unfortunately, the Adsense unit that is brought in with a second, third, or etc page load don't render. Here's my loop: 10 stories per page, Adsense after the 4th one. <?php $count = 0; ?> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php $count++; ?> <div class="card"> <div class="title"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><span><?php the_title(); ?></span></a> </div> </div> <?php if ($count == 4) : ?> <div class="card"> <!-- ADSENSE CODE HERE (Straight from Google Adsense Panel, no tweaks.) --> </div> <?php endif; ?> As for my jQuery script, here's how that looks: $.ajax({ url: nextPageLink, type: 'GET', success: function(data) { $(data).find('#reviews .card').appendTo('#reviews'); }, error: function(xhr, status, error) { $('.loadination').addClass('hidden'); } }); Keep in mind, I just simplified my code to give you guys an example. The code above was just the essentials. All the loading stuff works perfectly. Images, text, links, etc all load just fine. However, the Google Adsense unit doesn't. Any help would be appreciated. Thanks and Happy Holidays!

    Read the article

  • Android FTP seek Bar issue

    - by Androi Developer
    I am trying to Upload & Download file to server using FTP and Download File using HTTP i am able to do this, my problem is when i am trying to show seek bar with Upload status of file using ftp then it's not showing. In this attached image Using HTTP it's showing seekbar with Network spped like this i need to display seek bar & Network sppeed in FTP. Below code i wrote for FTP to upload file into server. Code:-- // Upload System.out.println("upload test is called"); //Toast.makeText(con, "upload FTP test is called", Toast.LENGTH_SHORT).show(); //ContextWrapper context = null; //assetManager= context.getAssets(); assetManager = getResources().getAssets(); input1 = assetManager.open("hello.txt"); final long started = System.currentTimeMillis(); int size = input1.available(); //byte[] buffer = new byte[size]; byte dataByte[] = new byte[1024]; //input1.read(buffer); //String data = "ZK DATA TESTER TEST DATA1sdfsdf"; String data = input1.toString(); System.out.println("dat value is........"+data); final int lenghtOfFile = data.getBytes().length; //final int lenghtOfFile = input1.getBytes().length; System.out.println("length of file....."+lenghtOfFile); ByteArrayInputStream in = new ByteArrayInputStream( data.getBytes()); //toast("Uploading /test.txt"); //Toast.makeText(con,"File Size : " +data.getBytes().length + " bytes",Toast.LENGTH_SHORT).show(); //byte b[] = new byte[1024]; long total = 0; long sleepingTime= 0; System.out.println("started time --"+started); updateUI(status, "Uploading"); while ((count = in.read(dataByte)) != -1) { System.out.println("read value is...."+in.read(dataByte)); while (sleep1) { Thread.sleep(1000); System.out.println("ftp upload is in sleeping mode"); sleepingTime +=1000; } System.out.println("Total count --"+count); total += count; System.out.println("Only Total --"+total); final int progress = (int) ((total * 100) / lenghtOfFile); final long speed = total; //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; boolean result = ObjFtpCon.storeFile("/test.txt", input1); //boolean result = ObjFtpCon.storeFile(map.get("file_address").toString()+"/test.txt", input1); duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; /* runOnUiThread(new Runnable() { public void run() { bar.setProgress(progress); // trans.setText("" + progress); //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; //real_time.setText(duration + " secs"); if (duration != 0) { test_avg.setText((((speed / duration)*1000)*0.0078125) + " kbps"); if (pk <= (speed / duration) / 1024) { pk = (speed / duration) / 1024; } if (pk <= ((speed / duration)*1000)*0.0078125) { pk = (long)(((speed / duration)*1000)*0.0078125); } //peak.setText(pk + " kbps"); } } });*/ //in.close(); if (result) { updateUI(status, "Uploaded"); // toast("Uploading succeeded"); // toast("Uploaded at /test.txt"); //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; System.out.println("curreent time..... "+System.currentTimeMillis()); System.out.println("started time --"+started); System.out.println("sleep tome...."+sleepingTime); System.out.println("duration is....."+duration); runOnUiThread(new Runnable() { public void run() { bar.setProgress(progress); // trans.setText("" + progress); //duration = ((System.currentTimeMillis() - started)-sleepingTime) / 1000; real_time.setText(duration + " secs"); if (duration != 0) { test_avg.setText((speed / duration) / 1024 + " kbps"); if (pk <= (speed / duration) / 1024) { pk = (speed / duration) / 1024; } peak.setText(pk + " kbps"); } } }); } /*while(!result){Thread.sleep(1000);}*/ } in.close();

    Read the article

  • Index is outside the bounds of the array

    - by coffeeaddict
    Ok, I cannot get this. I've looked at it and I don't see why it's out of bounds. I get the error at paypalItems[paypalItems.Length] = new PaymentDetailsItemType PaymentDetailsItemType[] paypalItems = new PaymentDetailsItemType[order.OrderItems.Count]; for (int i = 0; i < order.OrderItems.Count; i++) { paypalItems[i] = new PaymentDetailsItemType { Name = order.OrderItems[i].Name, Amount = ApiUtility.CreateBasicAmount(order.OrderItems[i].Price), Description = order.OrderItems[i].Name, Number = order.OrderItems[i].Sku, }; } if (giftCardsTotal != 0) { // add Coupons & Discounts line item paypalItems[paypalItems.Length] = new PaymentDetailsItemType { Name = "Gift Cards", Amount = ApiUtility.CreateBasicAmount(giftCardsTotal), Description = "Gift Cards" }; }

    Read the article

  • How many Stored Procedures created everyday ( problem in converting Datetime )?

    - by Space Cracker
    I make a query that return to me the count of Stored Procedure that created everyday as follow SELECT convert(varchar, crdate, 103) as Date,Count(*) as Counter FROM sysobjects WHERE (xtype = 'p') AND (name NOT LIKE 'dt%') Group by convert(varchar, crdate, 103) and its already work but dates appear in string format that i can't order it such as below 01/03/2010 3 01/04/2008 4 01/05/2010 5 01/11/2008 1 01/12/2008 4 02/03/2008 1 02/03/2010 2 02/04/2008 4 02/05/2010 2 02/11/2008 2 02/11/2009 2 02/12/2008 4 03/01/2010 1 03/02/2010 2 03/03/2010 2 03/04/2008 2 03/04/2010 2 03/05/2008 1 03/05/2010 2 I want to make that in which date is in datetime format that i can make order by successfully, i tried convert(datetime, crdate, 103) but it show Full date any idea of how to do ?

    Read the article

  • Can a parser tell the lexer to ignore a newline?

    - by chollida
    I'm writing a preprocessor for my language. In the preprocessor I've output a line that wasn't in the source file. This causes any error messages that Anltr creates to be incremented by one line. The Lexer handles the line count so I'm wondering if there is a way for the parser to tell the lexer to decrement the line count, or to ignore a specific newline. I'm also open to other suggestions on how to work around this. The only constraint I have is putting the extra line inline with the existing code. I'd prefer to keep it on it's own line to keep my parsing sane.

    Read the article

  • Improve SQL query performance

    - by Anax
    I have three tables where I store actual person data (person), teams (team) and entries (athlete). The schema of the three tables is: In each team there might be two or more athletes. I'm trying to create a query to produce the most frequent pairs, meaning people who play in teams of two. I came up with the following query: SELECT p1.surname, p1.name, p2.surname, p2.name, COUNT(*) AS freq FROM person p1, athlete a1, person p2, athlete a2 WHERE p1.id = a1.person_id AND p2.id = a2.person_id AND a1.team_id = a2.team_id AND a1.team_id IN ( SELECT id FROM team, athlete WHERE team.id = athlete.team_id GROUP BY team.id HAVING COUNT(*) = 2 ) GROUP BY p1.id ORDER BY freq DESC Obviously this is a resource consuming query. Is there a way to improve it?

    Read the article

  • PHP mySQL query's and PHP Variables

    - by jon
    I'm trying to make an OO Login system for a project I'm working on, and am having trouble with inserting variables into the query strings. In the code below, if I replace "$TBL_NAME" with the actual table name it works. Why isn't $TBL_NAME translating to the value of $TBL_NAME? class UserDB { private $TBL_NAME = "users"; public static function CheckLogin($username, $password) { Database::Connect(); $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT uid FROM $TBL_NAME WHERE username='$username' AND password='$password' "; $result =mysql_query($sql); $count=mysql_num_rows($result); if ($count==1) return true; else return false; } The Query is returning false.

    Read the article

  • How can I put a string and an integer into the same array?

    - by Stelios M
    I have to following code. I want this to return an array e.g. arg[] that contains at arg[0] the number of the rows of my cursor and at arg[1] String(0) of my cursor. Since one is integer and the other is string I have a problem. Any ideas how to fix this? public String[] getSubcategoriesRow(String id){ this.openDataBase(); String[] asColumnsToReturn = new String[] {SECOND_COLUMN_ID,SECOND_COLUMN_SUBCATEGORIES,}; Cursor cursor = this.dbSqlite.query(SECOND_TABLE_NAME, asColumnsToReturn, SECOND_COLUMN_SUBCATEGORIES + "= \"" + id + "\"", null, null, null, null); String string = cursor.getString(0); int count = cursor.getCount(); String arg[] = new String[]{count, string}; cursor.close(); return arg; } The cursor and the results and correct i just need to compine them to an array in order to return that.

    Read the article

  • crontable OR conditions

    - by matt
    Crontable parameters seem to function as 'ands' conditions. So the example 0 9-5 * * 1-5 Runs when the conditions are met "minute is zero AND hour is between 9 and 5 AND day is between monday and friday". What I'd like is an 'or' function, so I can say "run monday to friday OR the 8th day of the month". Does such a thing exist? I realise you could add two entries, but with lots of entries it adds something to forget.

    Read the article

  • error message fix

    - by user1722654
    for (int i = 0; i < dataGridView1.Rows.Count; i++) { //bool sleected = false; if (dataGridView1.Rows[i].Cells[3].Value != null) { selected.Add(i); } } //string donew = ""; // line off error textBox1.Text = ((String)dataGridView1.Rows[1].Cells[2].Value); /* for (int i = 0; i < selected.Count; i++) { textAdded.Add((String)dataGridView1.Rows[0].Cells[2].Value); // donew += (String)dataGridView1.Rows[selected[i]].Cells[2].Value; }*/ I keep getting the error Unable to cast object of type 'System.Double' to type 'System.String' What can I do to overcome this?

    Read the article

  • C#: Select row from DataGridView

    - by Bi
    Hi I have a form with a DataGridView (of 3 columns) and a Button. Every time the user clicks on a button, I want the get the values stored in the 1st column of that row. Here is the code I have: private void myButton_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in ProductsGrid.Rows) { if (this.ProductsGrid.SelectedRows.Count == 1) { // get information of 1st column from the row string value = this.ProductsGrid.SelectedRows[0].Cells[0].ToString(); } } } However when I click on myButton, the this.ProductsGrid.SelectedRows.Count is 0. Also, how do I ensure that the user selects only one row and not multiple rows? Does this code look right?

    Read the article

  • Oracle date / order by question

    - by user561793
    I want to select a date from oracle table formatted like select (to_char(req_date,'MM/YYYY')) but I also want to order the result set on this date format. I want them to be ordered like dates not strings. Like this 09/2009 10/2009 11/2009 12/2009 01/2010 02/2010 03/2010 04/2010 05/2010 06/2010 07/2010 08/2010 09/2010 10/2010 11/2010 12/2010 Not like 01/2010 02/2010 03/2010 04/2010 05/2010 06/2010 07/2010 08/2010 09/2009 09/2010 10/2009 10/2010 11/2009 11/2010 12/2009 12/2010 Any way to do this in sql? full sql is select (to_char(req_date,'MM/YYYY')) as monthYear,count(req_id) as count from REQUISITION_CURRENT t group by to_char(req_date,'MM/YYYY') Thanks

    Read the article

  • How can i merge arrays like a gearwheel

    - by JuKe
    i have 3 arrays like this $a = array( 0 => 'a1', 1 => 'a2', 2 => 'a3' ); $b = array( 0 => 'b1', 1 => 'b2', 2 => 'b3' ); $c = array( 0 => 'c1', 1 => 'c2', 2 => 'c3' ); and i like to have somethink like this: $r = array( 0 => 'a1', 1 => 'b1', 2 => 'c1', 3 => 'a2', 4 => 'b2', 5 => 'c2', 6 => 'a3', .... ... ); how can i do this, with the opinion of more than 3 arrays EDIT: i have tried this: $a = array( 0 => 'a1', 1 => 'a2', 2 => 'a3', 3 => 'a4' ); $b = array( 0 => 'b1', 1 => 'b2', 2 => 'b3' ); $c = array( 0 => 'c1', 1 => 'c2', 2 => 'c3', 3 => 'c3', 4 => 'c3', 5 => 'c3' ); $l['a'] = count($a); $l['b'] = count($b); $l['c'] = count($c); arsort($l); $largest = key($l); $result = array(); foreach ($$largest as $key => $value) { $result[] = $a[$key]; if(array_key_exists($key, $b)) $result[] = $b[$key]; if(array_key_exists($key, $c)) $result[] = $c[$key]; } print_r($result); this work.. but the code isn't nice. so anyone has a better solution?

    Read the article

  • MySQL UPDATE WHERE IN for each listed value separately?

    - by Tom
    Hi, I've got the following type of SQL: UPDATE photo AS f LEFT JOIN car AS c ON f.car_id=c.car_id SET f.photo_status=1 , c.photo_count=c.photo_count+1 WHERE f.photo_id IN ($ids) Basically, two tables (car & photo) are related. The list in $ids contains unique photo ids, such as (34, 87, 98, 12). With the query, I'm setting the status of each photo in that list to "1" in the photo table and simultaneously incrementing the photo count in the car table for the car at hand. It works but there's one snag: Because the list can contain multiple photo ids that relate to the same car, the photo count only ever gets incremented once. If the list had 10 photos associated with the same car, photo_count would become 1 .... whereas I'd like to increment it to 10. Is there a way to make the incrementation occur for each photo individually through the join, as opposed to MySQL overthinking it for me? I hope the above makes sense. Thanks.

    Read the article

  • SUM a pair of COUNTs from two tables based on a time variable

    - by Kevin O.
    Been searching for an answer to this for the better part of an hour without much luck. I have two regional tables laid out with the same column names and I can put out a result list for either table based on the following query (swap Table2 for Table1): SELECT Table1.YEAR, FORMAT(COUNT(Table1.id),0) AS Total FROM Table1 WHERE Table1.variable='Y' GROUP BY Table1.YEAR Ideally I'd like to get a result that gives me a total sum of the counts by year, so instead of: | REGION 1 | | REGION 2 | | YEAR | Total | | YEAR | Total | | 2010 | 5 | | 2010 | 1 | | 2009 | 2 | | 2009 | 3 | | | | | 2008 | 4 | I'd have: | MERGED | | YEAR | Total | | 2010 | 6 | | 2009 | 5 | | 2008 | 4 | I've tried a variety of JOINs and other ideas but I think I'm caught up on the SUM and COUNT issue. Any help would be appreciated, thanks!

    Read the article

  • How to access files on another local Windows 7 computer without using any native Windows features?

    - by user1356682
    I do not want to use any native Windows features, services, nor anything do to this. It needs to be a standalone program, with ZERO Windows dependencies. Just like TeamViewer does not use any native Windows features, so I want to be able to access files and folders in a standalone program. No remote desktop No VNC type programs No Windows File Sharing No Shared Folders in Windows No internet connection required It needs ability to view, edit, transfer files at normal network rates.

    Read the article

  • c permutation of a number

    - by Pkp
    I am writing a program for magic box. As the only way around it is brute force, I wrote a program to compute permutations of a given array using bells algorithm. I wrote in the lines similar to http://programminggeeks.com/c-code-for-permutation/. It does work for array of 3 and 4. It does not work for an arryay of 8 numbers (1,2,3,4,5,6,7,8). I see that the combination 1 2 3 4 5 6 7 8 gets repeated couple of times. Also there are other combinations that gets repeated. I see that certain combinations don't get displayed even. So could someone tell me what is wrong in the program below. Code: include<stdio.h> int len,numperm=1,count=0; display(int a[]){ int i; for(i=0;i<len;i++) printf("%d ",a[i]); printf("\n"); count++; } swap(int *a,int *b){ int temp; temp=*a; *a=*b; *b=temp; } no_of_perm(){ int x; for(x=1;x<=len;x++) numperm=numperm*x; } perm(int a[]){ int x,y; while(count < numperm){ for(x=0;x<len-1;x++){ swap(&a[x],&a[x+1]); display(a); } swap(&a[0],&a[1]); display(a); for(y=len-1;y>0;y--){ swap(&a[y],&a[y-1]); display(a); } swap(&a[len-1],&a[len-2]); display(a); } } main(int argc, char *argv[]){ if(argc<2){ printf("Error\n"); exit(0); } int i,*a=malloc(sizeof(int)*atoi(argv[1])); len=atoi(argv[1]); for(i=0;i<len;i++) a[i]=i+1; no_of_perm(); perm(a); }

    Read the article

  • Problem in populating a dictionary object using Enumerable.Range() (C#3.0)

    - by Newbie
    If I do for (int i = 0; i < appSettings.Count; i++) { string key = appSettings.Keys[i]; euFileDictionary.Add(key, appSettings[i]); } It is working fine. When I am trying the same thing using Enumerable.Range(0, appSettings.Count).Select(i => { string Key = appSettings.Keys[i]; string Value = appSettings[i]; euFileDictionary.Add(Key, Value); }).ToDictionary<string,string>(); I am getting a compile time error The type arguments for method 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly. Any idea? Using C#3.0 Thanks

    Read the article

  • question about adding another column to a sql statement

    - by every_answer_gets_a_point
    i am starting with this table: SELECT [Lab Occurrence Form].[Practice Code], [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)], Count([Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]) AS [CountOf1 0 Preanalytical (Before Testing)] FROM [Lab Occurrence Form] WHERE ((([Lab Occurrence Form].[Occurrence Date]) Between [Forms]![By Number]![Text4] And [Forms]![By Number]![Text2])) GROUP BY [Lab Occurrence Form].[Practice Code], [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)] HAVING ((([Lab Occurrence Form].[Practice Code])<>"") AND ((Count([Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]))<>0)); it selects 3 columns but i need to aggregate the comments and put it in the fourth column where the first two values are the same

    Read the article

  • How to remove row which has one or more empty or null cell ?

    - by Harikrishna
    I have datagridview on my winform. I am displaying records in the datagridview. Now after displaying the records on the datagridview, I want to remove the row from datagridview which has one or more empy cells that is no value in the cell for that row. So for that I am checking each cell for every row if there is any cell empty or null then I remove that rows using RemoveAt() function. My code is : for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { for (int j = 0; j < dataGridView1.Columns.Count; j++) { if (string.IsNullOrEmpty(dataGridView1.Rows[i].Cells[j].Value.ToString())) { dataGridView1.Rows.RemoveAt(i); break; } } }

    Read the article

  • Any idea why this query always returns duplicate items?

    - by Kardo
    I want to get all Images not used by current ItemID. The this subquery but it also always returns duplicate Images: EDITED select Images.ImageID, Images.ItemStatus, Images.UserName, Images.Url, Image_Item.ItemID, Image_Item.ItemID from Images left join (select ImageID, ItemID, MAX(DateCreated) x from Image_Item where ItemID != '5a0077fe-cf86-434d-9f3b-7ff3030a1b6e' group by ImageID, ItemID having count(*) = 1) image_item on Images.imageid = image_item.imageid where ItemID is not null I guess the problem is with the subquery which I can't avoid duplicate rows: select ImageID, ItemID, MAX(DateCreated) x from Image_Item where ItemID != '5a0077fe-cf86-434d-9f3b-7ff3030a1b6e' group by ImageID, ItemID having count(*) = 1 Result: F2EECBDC-963D-42A7-90B1-4F82F89A64C7 0578AC61-3C32-4A1D-812C-60A09A661E71 F2EECBDC-963D-42A7-90B1-4F82F89A64C7 9A4EC913-5AD6-4F9E-AF6D-CF4455D81C10 42BC8B1A-7430-4915-9CDA-C907CBC76D6A CB298EB9-A105-4797-985E-A370013B684F 16371C34-B861-477C-9A7C-DEB27C8F333D 44E6349B-7EBF-4C7E-B3B0-1C6E2F19992C Table: Images ImageID uniqueidentifier UserName nvarchar(100) DateCreated smalldatetime Url nvarchar(250) ItemStatus char(1) Table: Image_Item ImageID uniqueidentifier ItemID uniqueidentifier UserName nvarchar(100) ItemStatus char(1) DateCreated smalldatetime Any kind help is highly appreciated.

    Read the article

  • get value from database based on array in codeigniter

    - by Developer
    I have an array $user = array([0]=>1 [1]=>2 [2]=>3) which contains id's of certain users. I need to get the countries of these users from database. foreach($userid as $user){ $this->db->select('country'); $this->db->where('user_id',$user); $this->db->from('company'); $usercountry = $this->db->get(); $count = $usercountry->row(); $country = $count->country; } Suppose user1 has country ES, user2 has IN, user3 has US, user4 has UK. then if array contains 1,2,3. Then i need to get the countries ES,IN,US.

    Read the article

< Previous Page | 152 153 154 155 156 157 158 159 160 161 162 163  | Next Page >