Search Results

Search found 1486 results on 60 pages for 'counter'.

Page 1/60 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Try a sample: Using the counter predicate for event sampling

    - by extended_events
    Extended Events offers a rich filtering mechanism, called predicates, that allows you to reduce the number of events you collect by specifying criteria that will be applied during event collection. (You can find more information about predicates in Using SQL Server 2008 Extended Events (by Jonathan Kehayias)) By evaluating predicates early in the event firing sequence we can reduce the performance impact of collecting events by stopping event collection when the criteria are not met. You can specify predicates on both event fields and on a special object called a predicate source. Predicate sources are similar to action in that they typically are related to some type of global information available from the server. You will find that many of the actions available in Extended Events have equivalent predicate sources, but actions and predicates sources are not the same thing. Applying predicates, whether on a field or predicate source, is very similar to what you are used to in T-SQL in terms of how they work; you pick some field/source and compare it to a value, for example, session_id = 52. There is one predicate source that merits special attention though, not just for its special use, but for how the order of predicate evaluation impacts the behavior you see. I’m referring to the counter predicate source. The counter predicate source gives you a way to sample a subset of events that otherwise meet the criteria of the predicate; for example you could collect every other event, or only every tenth event. Simple CountingThe counter predicate source works by creating an in memory counter that increments every time the predicate statement is evaluated. Here is a simple example with my favorite event, sql_statement_completed, that only collects the second statement that is run. (OK, that’s not much of a sample, but this is for demonstration purposes. Here is the session definition: CREATE EVENT SESSION counter_test ON SERVERADD EVENT sqlserver.sql_statement_completed    (ACTION (sqlserver.sql_text)    WHERE package0.counter = 2)ADD TARGET package0.ring_bufferWITH (MAX_DISPATCH_LATENCY = 1 SECONDS) You can find general information about the session DDL syntax in BOL and from Pedro’s post Introduction to Extended Events. The important part here is the WHERE statement that defines that I only what the event where package0.count = 2; in other words, only the second instance of the event. Notice that I need to provide the package name along with the predicate source. You don’t need to provide the package name if you’re using event fields, only for predicate sources. Let’s say I run the following test queries: -- Run three statements to test the sessionSELECT 'This is the first statement'GOSELECT 'This is the second statement'GOSELECT 'This is the third statement';GO Once you return the event data from the ring buffer and parse the XML (see my earlier post on reading event data) you should see something like this: event_name sql_text sql_statement_completed SELECT ‘This is the second statement’ You can see that only the second statement from the test was actually collected. (Feel free to try this yourself. Check out what happens if you remove the WHERE statement from your session. Go ahead, I’ll wait.) Percentage Sampling OK, so that wasn’t particularly interesting, but you can probably see that this could be interesting, for example, lets say I need a 25% sample of the statements executed on my server for some type of QA analysis, that might be more interesting than just the second statement. All comparisons of predicates are handled using an object called a predicate comparator; the simple comparisons such as equals, greater than, etc. are mapped to the common mathematical symbols you know and love (eg. = and >), but to do the less common comparisons you will need to use the predicate comparators directly. You would probably look to the MOD operation to do this type sampling; we would too, but we don’t call it MOD, we call it divides_by_uint64. This comparator evaluates whether one number is divisible by another with no remainder. The general syntax for using a predicate comparator is pred_comp(field, value), field is always first and value is always second. So lets take a look at how the session changes to answer our new question of 25% sampling: CREATE EVENT SESSION counter_test_25 ON SERVERADD EVENT sqlserver.sql_statement_completed    (ACTION (sqlserver.sql_text)    WHERE package0.divides_by_uint64(package0.counter,4))ADD TARGET package0.ring_bufferWITH (MAX_DISPATCH_LATENCY = 1 SECONDS)GO Here I’ve replaced the simple equivalency check with the divides_by_uint64 comparator to check if the counter is evenly divisible by 4, which gives us back every fourth record. I’ll leave it as an exercise for the reader to test this session. Why order matters I indicated at the start of this post that order matters when it comes to the counter predicate – it does. Like most other predicate systems, Extended Events evaluates the predicate statement from left to right; as soon as the predicate statement is proven false we abandon evaluation of the remainder of the statement. The counter predicate source is only incremented when it is evaluated so whether or not the counter is incremented will depend on where it is in the predicate statement and whether a previous criteria made the predicate false or not. Here is a generic example: Pred1: (WHERE statement_1 AND package0.counter = 2)Pred2: (WHERE package0.counter = 2 AND statement_1) Let’s say I cause a number of events as follows and examine what happens to the counter predicate source. Iteration Statement Pred1 Counter Pred2 Counter A Not statement_1 0 1 B statement_1 1 2 C Not statement_1 1 3 D statement_1 2 4 As you can see, in the case of Pred1, statement_1 is evaluated first, when it fails (A & C) predicate evaluation is stopped and the counter is not incremented. With Pred2 the counter is evaluated first, so it is incremented on every iteration of the event and the remaining parts of the predicate are then evaluated. In this example, Pred1 would return an event for D while Pred2 would return an event for B. But wait, there is an interesting side-effect here; consider Pred2 if I had run my statements in the following order: Not statement_1 Not statement_1 statement_1 statement_1 In this case I would never get an event back from the system because the point at which counter=2, the rest of the predicate evaluates as false so the event is not returned. If you’re using the counter target for sampling and you’re not getting the expected events, or any events, check the order of the predicate criteria. As a general rule I’d suggest that the counter criteria should be the last element of your predicate statement since that will assure that your sampling rate will apply to the set of event records defined by the rest of your predicate. Aside: I’m interested in hearing about uses for putting the counter predicate criteria earlier in the predicate statement. If you have one, post it in a comment to share with the class. - Mike Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it!

    Read the article

  • how to restrict a jsp hit counter?

    - by user261002
    I am writing a hot counter in jsp, for my coursework. I have write the code, and there is not error and its working, but the problem is that: if the user have open the website and try to user different page, when ever that the user get back to the home page the counter still is adding a number , how can I restrict this part??? shall restrict it with session?? this is my code : The current count for the counter bean is: <% counter.saveCount(); int _numberofvisitors=counter.getVisitorsNumber(); out.println(_numberofvisitors); % Bean: package counter; import java.sql.*; import java.sql.SQLException; public class CounterBean implements java.io.Serializable { int coun = 0; public CounterBean() { database.DatabaseManager.getInstance().getDatabaseConnection(); } public int getCoun() { return this.coun; } public void setCoun(int coun) { this.coun += coun; } public boolean saveCount() { boolean _save = false; database.SQLUpdateStatement sqlupdate = new database.SQLUpdateStatement("counter", "hitcounter"); sqlupdate.addColumn("hitcounter", getCoun()); if (sqlupdate.Execute()) { _save = true; } return _save; } public int getVisitorsNumber() throws SQLException { int numberOfVisitors = 0; if (database.DatabaseManager.getInstance().connectionOK()) { database.SQLSelectStatement sqlselect = new database.SQLSelectStatement("counter", "hitcounter", "0"); ResultSet _userExist = sqlselect.executeWithNoCondition(); if (_userExist.next()) { numberOfVisitors = _userExist.getInt("hitcounter"); } } return numberOfVisitors; } }

    Read the article

  • Simple Counter issue

    - by TechyDude
    I want to make a very simple counter that increases the value when you click a button. When I click the add button the first time, the number doesn't increase, however I console log the value which increases the result everytime. Any ideas? The fiddle: http://jsfiddle.net/techydude/H63As/ $(function() { var //valueCount = $("counter").value(), counter = $("#counter"), addBtn = $("#add"), value = $("#counter").html(); addBtn.on("click", function() { counter.html(value ++); console.log(value); return }); });

    Read the article

  • Daily, Weekly and Monthly Page View Counter

    - by Jens Fahnenbruck
    I'm building a website with user generated content. On the home page I want to show a list of all created items, and I want to be able to sort them by a view counter. That's sound easy, but I want multiple counters. I want to know which was the most visited item in the last day, last week or last months or overall. My first Idea was to create 4 counter columns in the item's DB-Table. One for each of daily, weekly, monthly and overall, and the create a cron job, that clears the daily counter every 24 hours, the weekly counter every 7 days and so on. But my problem with this is, what happens if I want to know which was the most viewed item of the week, just after the weekly counter got cleared? What I need is an efficient way to create a continous counter, which got reduced for every page view that is too old, and increased for every new page view. Right now I'm thinking of a solution with the redis server, but I have no solution yet. I'm just looking for a general idea here, but FYI I'm developing this application in Ruby on Rails.

    Read the article

  • jQuery Character Counter Inside Newly Created Tooltip

    - by Dodinas
    Hello all, I'm having a difficult time figuring this one out. I'm attempting to have a user open a tooltip (using jQuery qTip). What this does is create a "new" tooltip element on the page; it takes it from an existing hidden HTML div on the webpage. Once this new tooltip is created, it has a character counter that is supposed to dynamically update as the user types in the textbox (which is inside the tooltip). The "Max Length Character Counter" script can be found here. However, the "counter" portion is not working inside the newly created tooltip. Any ideas how I can bind this max length character counter to the tooltip? Here's what I'm working with so far: function load_qtip(apply_qtip_to) { $(apply_qtip_to).each(function(){ $(this).qtip({ content: $(".tooltip-contents"), //this is a DIV in the HTML show: 'click', hide: 'unfocus' }); }); } $(document).ready(function() { load_qtip(".tooltip"); $('.my_textbox').maxlength({ 'feedback' : '.my_counter' }); }); And here's what the HTML basically looks like (remember, though, this entire div is "replicated" into a new tooltip): <div class="tooltip_contents"> <form> <div class="my_counter" id="counter">55</div> <textarea class="my_textbox" maxlength="55" id="textbox"></textarea> <input type="button" value="Submit"> </form> </div> Any direction/suggestions on this would be great, as I am completely lost. Thanks very much!

    Read the article

  • IE error with jquery counter plugin

    - by Mankey
    I've implemented a jquery counter script (count up from say 50 to 100 with different increments) that I found from this question: jQuery counter to count up to a target number The scripts works great except for in Internet Explorer 8 (and possibly other IE versions?). Here's an error message from IE with the URL to the creator of the script's demo. Message: 'undefined' is null or not an object Line: 32 Char: 17 Code: 0 URI: http://www.ulmanen.fi/stuff/counter.php I'm just wondering if anyone know how this can be fixed. I'm guessing it has to do with el.html() not finding any data but I can't really figure this out. Thanks for any help ^^ I would reply to that post if I could but I can't seem to find any way of doing so (I'm new to stackoverflow, I think I lack privileges).

    Read the article

  • Mouse button and keypress counter for Windows XP

    - by Yuval F
    I am trying to kick the habit of using a mouse where I could use keyboard shortcuts, for ergonomic reasons. I believe that if I see some statistics of my use of both input devices, I could reduce my use of mouse clicks. Do you know of any free software I can install on my Windows XP machine that counts keypresses and mouse button presses and displays an hourly/daily report? No fancy GUI is needed - just two summary lines.

    Read the article

  • Kinect Click counter function

    - by Sweta Dwivedi
    So i have the following kinect click function which will check if the hand is within the bounds then it will click with a counter . . however there is a slight problem . .the first few button clicks work fine.. but after it clicks one of the buttons it changes the game state and immediately clicks the other button without the counter reaching 200. . . Kinect click is a method in the button class. . .and each button inside a list can access the Kinect click method. . . public bool KinectClick(int x,int y) { if ((x >= position.X && x <= position.X + position.Width) && (y >= position.Y && y <= position.Y + position.Height)) { counter++; if (counter > 200) { counter = 0; return true; } } else { counter = 0; } return false; } I call to check if this property is true in the Game update method to act as a button click. . foreach(Button g_t in Game_theme) { if ((g_t.KinectClick(x_c, y_c) == true || g_t.ButtonClicked() == true) && g_t.name == "animoe") { Selected_anim = true; currentGameState = GameState.InGame; } if ((g_t.KinectClick(x_c, y_c) == true || g_t.ButtonClicked() == true) && g_t.name == "planet") { Selected_planet = true; currentGameState = GameState.InGame; }

    Read the article

  • Understanding packet flows over RVI

    - by choco-loo
    I'm trying to get a full grasp of firewall filters and how to apply them on a Juniper EX4200 switch - to be able to block ports, police traffic and shape traffic. The network architecture is as follows internet >-< vlan4000 >-< vlan43 vlan4000 is a public "routed" block (where all the IPs are routed to and the internet gw is) vlan43 is a vlan with public IPs with devices (servers) attached There are static routes and RVI's on the EX4200 to send all traffic via vlan4000's gateway to reach the internet. I've set up filters on both input and output of the respective RVI's and VLAN's - with simple counters, to measure traffic flow from a server inside of vlan43 and a server on the internet. Using a combination of iperf for UDP and TCP tests and fping for ICMP tests - I observed the following, icmp vlan43>internet internet>vlan43 unit4000-counter-in 0 0 unit4000-counter-out 0 0 unit43-counter-in 100 100 unit43-counter-out 0 0 vlan4000-counter-in 6 4 vlan4000-counter-out 107 104 vlan43-counter-in 101 100 vlan43-counter-out 100 100 tcp vlan43>internet internet>vlan43 unit4000-counter-in 0 0 unit4000-counter-out 0 0 unit43-counter-in 73535 38480 unit43-counter-out 0 0 vlan4000-counter-in 7 8 vlan4000-counter-out 73543 38489 vlan43-counter-in 73535 38481 vlan43-counter-out 38938 75880 udp vlan43>internet internet>vlan43 unit4000-counter-in 0 0 unit4000-counter-out 0 0 unit43-counter-in 81410 1 unit43-counter-out 0 0 vlan4000-counter-in 18 7 vlan4000-counter-out 81429 8 vlan43-counter-in 81411 1 vlan43-counter-out 1 85472 My key goals are to set up a few filters and policers, as there will be many more VLANs - that all need protecting from each other and the internet. Then globally limit/police all outbound traffic to the internet Block inbound ports to vlan43 (eg. 22) Limit outbound traffic from vlan43 (to the internet) Limit outbound traffic from vlan43 (to other vlans) Limit outbound traffic from vlan4000 (to the internet from all vlans) Route traffic from vlans via specific routing instances (FBF) The question What I want to understand is why there isn't ever any activity on unit4000 or vlan4000 inbound or outbound counter - is this because there isn't a device on this VLAN - and that the traffic is only traversing it? And with regards to the TCP test - why is there twice as many packets on unit43-counter-in, vlan4000-counter-out and vlan43-counter-in - is this counting both the inbound and outbound traffic?

    Read the article

  • advance click counter mysql or flat file

    - by jay
    Hi, First of all Thank You for looking. whats the best method for make an advance click counter (eg. order by views [today] | [yesterday] [this week] [last week] [this month] [last month] [all time] ). Is it better to use a flat file or mysql?. This is the MYSQL Structure i came up with. id (type: int(11)) link_id (type: int(11)) date (type: date) counter (type: int(11)) please can you advice me on whats the most effective way of doing this.

    Read the article

  • SQL SERVER – What is Page Life Expectancy (PLE) Counter

    - by pinaldave
    During performance tuning consultation there are plenty of counters and values, I often come across. Today we will quickly talk about Page Life Expectancy counter, which is commonly known as PLE as well. You can find the value of the PLE by running following query. SELECT [object_name], [counter_name], [cntr_value] FROM sys.dm_os_performance_counters WHERE [object_name] LIKE '%Manager%' AND [counter_name] = 'Page life expectancy' The recommended value of the PLE counter is 300 seconds. I have seen on busy system this value to be as low as even 45 seconds and on unused system as high as 1250 seconds. Page Life Expectancy is number of seconds a page will stay in the buffer pool without references. In simple words, if your page stays longer in the buffer pool (area of the memory cache) your PLE is higher, leading to higher performance as every time request comes there are chances it may find its data in the cache itself instead of going to hard drive to read the data. Now check your system and post back what is this counter value for you during various time of the day. Is this counter any way relates to performance issues for your system? Note: There are various other counters which are important to discuss during the performance tuning and this counter is not everything. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL Optimization, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQLServer, T SQL, Technology

    Read the article

  • Inaccurate performance counter timer values in Windows Performance Monitor

    - by krisg
    I am implementing instrumentation within an application and have encountered an issue where the value that is displayed in Windows Performance Monitor from a PerformanceCounter is incongruent with the value that is recorded. I am using a Stopwatch to record the duration of a method execution, then first i record the total milliseconds as a double, and secondly i pass the Stopwatch's TimeSpan.Ticks to the PerformanceCounter to be recorded in the Performance Monitor. Creating the Performance Counters in perfmon: var datas = new CounterCreationDataCollection(); datas.Add(new CounterCreationData { CounterName = name, CounterType = PerformanceCounterType.AverageTimer32 }); datas.Add(new CounterCreationData { CounterName = namebase, CounterType = PerformanceCounterType.AverageBase }); PerformanceCounterCategory.Create("Category", "performance data", PerformanceCounterCategoryType.SingleInstance, datas); Then to record i retrieve a pre-initialized counter from a collection and increment: _counters[counter].IncrementBy(timing); _counters[counterbase].Increment(); ...where "timing" is the Stopwatch's TimeSpan.Ticks value. When this runs, the collection of double's, which are the milliseconds values for the Stopwatch's TimeSpan show one set of values, but what appears in PerfMon are a different set of values. For example... two values recorded in the List of milliseconds are: 23322.675, 14230.614 And what appears in PerfMon graph are: 15.546, 9.930 Can someone explain this please?

    Read the article

  • HIt counter in JSF

    - by Hari kanna
    hi expertise... i want 2 add small module hit counter in my web app like in PHP we can use external text file to store number which icrement and write it on webpage but how to use in JSF my app is full of developing JSF...

    Read the article

  • Searching for a good PHP based Web Counter

    - by hkda150
    hi, I am running a php based web application and within that application I am using bbclone to count visitors and site activity. Unfortunately it doesn't work that nice as expected because bbclone counts a lot of robots and therefor my statistic is not that accurate as it should be. So do you know any good php based web application counter? It would be nice to have the following overviews in it: - user agents - timeline Thanks a lot.

    Read the article

  • File counter adds 2 instead of 1

    - by Derk
    I made a simple counter, but it increments by 2 instead of 1. $handle = fopen('progress.txt', 'r'); $pro = fgets($handle); print $pro; // incremented by 2, WTF? fclose($handle); $handle = fopen('progress.txt', 'w'); fwrite($handle, $pro); fclose($handle); Everytime I read the file it has been incremented by 2, instead of 1.

    Read the article

  • jQuery counter to count up to a target number

    - by Matt Huggins
    I'm trying to find out if anyone knows about an already existing jQuery plugin that will count up to a target number at a specified speed. For example, take a look at Google's number of MB of free storage on the Gmail homepage, under the heading that reads "Lots of space". It has a starting number in a <span> tag, and slowly counts upward every second. I'm looking for something similar, but I'd like to be able to specify: The start number The end number The amount of time it should take to get from start to end. A custom callback function that can execute when a counter is finished.

    Read the article

  • fread how to Count total from Counter text

    - by snikolov
    hey i have a counter text here and i need to know how to calculate the total this is my information $filename = "data.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); $expode = explode("\n",$contents); /** output 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 */ I i need to calculate the total by exploding "\n" so i will output 12288 need to understand how to do this i have done this foreach ($expode as $v) { $total = $total + $v; echo $total; } i did not get good results with this

    Read the article

  • Create a Counter within a For-Loop?

    - by Todd Hartman
    I am a novice programmer and apologize upfront for the complicated question. I am trying to create a lexical decision task for experimental research, in which respondents must decide if a series of letters presented on the screen make a "word" or "not a word". Everything works reasonably well except for the bit where I want to randomly select a word (category A) or nonword (category B) for each of 80 trials from a separate input file (input.txt). The randomization works, but some elements from each list (category A or B) are skipped because I have used "round.catIndex = j;" where "j" is a loop for each successive trial. Because some trials randomly select from Category A and other from Category B, "j" does not move successively down the list for each category. Instead, elements from the Category A list may be selected from something like 1, 2, 5, 8, 9, 10, and so on (it varies each time because of the randomization). To make a long story short(!), how do I create a counter that will work within the for-loop for each trial, so that every word and nonword from Category A and B, respectively, will be used for the lexical decision task? Everything I have tried thus far does not work properly or breaks the javascript entirely. Below is my code snippet and the full code is available at http://50.17.194.59/LDT/trunk/LDT.js. Also, the full lexical decision task can be accessed at http://50.17.194.59/LDT/trunk/LDT.php. Thanks! function initRounds() { numlst = []; for (var k = 0; k<numrounds; k++) { if (k % 2 == 0) numlst[k] = 0; else numlst[k] = 1; } numlst.sort(function() {return 0.5 - Math.random()}) for (var j = 0; j<numrounds; j++) { var round = new LDTround(); if (numlst[j] == 0) { round.category = input.catA.datalabel; } else if (numlst[j] == 1) { round.category = input.catB.datalabel; } // pick a category & stimulus if (round.category == input.catA.datalabel) { round.itemtype = input.catA.itemtype; round.correct = 1; round.catIndex = j; } else if (round.category == input.catB.datalabel) { round.itemtype = input.catB.itemtype; round.correct = 2; round.catIndex = j; } roundArray[i].push(round); } return roundArray; }

    Read the article

  • The counter doesnt seem to increase when ever the edittext changes

    - by Mabulhuda
    Im using Edit-texts and i need when ever an edit-text is changed to increment a counter by one but the counter isnt working , I mean the app starts and everything but the counter doesnt seem to change please help here is the code public class Numersys extends Activity implements TextWatcher { EditText mark1 ,mark2, mark3,mark4,mark5,mark6 , hr1 ,hr2,hr3,hr4,hr5,hr6; EditText passed, currentavg; TextView tvnewavg ; Button calculate; double marks , curAVG , NewAVG ; String newCumAVG; int counter , hrs , curHr , NewHr; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.numersys); mark1=(EditText)findViewById(R.id.mark1n); mark2=(EditText)findViewById(R.id.mark2n); mark3=(EditText)findViewById(R.id.mark3n); mark4=(EditText)findViewById(R.id.mark4n); mark5=(EditText)findViewById(R.id.mark5n); mark6=(EditText)findViewById(R.id.mark6n); hr1=(EditText)findViewById(R.id.ethour1); hr2=(EditText)findViewById(R.id.ethour2); hr3=(EditText)findViewById(R.id.ethour3); hr4=(EditText)findViewById(R.id.ethour4); hr5=(EditText)findViewById(R.id.ethour5); hr6=(EditText)findViewById(R.id.ethour6); passed=(EditText)findViewById(R.id.etPassCn); currentavg=(EditText)findViewById(R.id.etCavgn); tvnewavg=(TextView)findViewById(R.id.tvcAVGn); mark1.addTextChangedListener(this); mark2.addTextChangedListener(this); mark3.addTextChangedListener(this); mark4.addTextChangedListener(this); mark5.addTextChangedListener(this); mark6.addTextChangedListener(this); calculate=(Button)findViewById(R.id.bAvgCalcn); @Override public void onClick(View arg0) { // TODO Auto-generated method stub switch(arg0.getId()) { case 0: break; case 1: hrs=Integer.valueOf(hr1.getText().toString()); marks=Double.valueOf(mark1.getText().toString())*Integer.valueOf(hr1.getText().toString()); curHr=Integer.valueOf(passed.getText().toString()); curAVG=Double.valueOf(currentavg.getText().toString())*curHr; NewHr= curHr+hrs; NewAVG= (marks+curAVG)/NewHr; break; case 2: hrs=Integer.valueOf(hr1.getText().toString())+Integer.valueOf(hr2.getText().toString()); marks=Double.valueOf(mark1.getText().toString())*Integer.valueOf(hr1.getText().toString()) +Double.valueOf(mark2.getText().toString())*Integer.valueOf(hr2.getText().toString()); curHr=Integer.valueOf(passed.getText().toString()); curAVG=Double.valueOf(currentavg.getText().toString())*curHr; NewHr= curHr+hrs; NewAVG= (marks+curAVG)/NewHr; break; case 3: hrs=Integer.valueOf(hr1.getText().toString())+Integer.valueOf(hr2.getText().toString()) +Integer.valueOf(hr3.getText().toString()); marks=Double.valueOf(mark1.getText().toString())*Integer.valueOf(hr1.getText().toString()) +Double.valueOf(mark2.getText().toString())*Integer.valueOf(hr2.getText().toString()) +Double.valueOf(mark3.getText().toString())*Integer.valueOf(hr3.getText().toString()); curHr=Integer.valueOf(passed.getText().toString()); curAVG=Double.valueOf(currentavg.getText().toString())*curHr; NewHr= curHr+hrs; NewAVG= (marks+curAVG)/NewHr; break; case R.id.bAvgCalcn: newCumAVG=String.valueOf(NewAVG); tvnewavg.setText(newCumAVG); } } }); } @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub if(mark1.hasFocus()) { counter = counter+1; } if(mark2.hasFocus()) { counter = counter+1; } if(mark3.hasFocus()) { counter = counter+1; } if(mark4.hasFocus()) { counter = counter+1; } if(mark5.hasFocus()) { counter = counter+1; } if(mark6.hasFocus()) { counter = counter+1; } }

    Read the article

  • How can I implement a proper counter bean with EJB 3.0?

    - by Aaron Digulla
    I have this entity bean: import javax.persistence.*; @Entity public class CounterTest { private int id; private int counter; @Id public int getId() { return id; } public void setId(int id) { this.id = id; } public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; } } and this stateful bean to increment a counter: import java.rmi.RemoteException; import javax.ejb.*; import javax.persistence.*; @Stateful public class CounterTestBean implements CounterTestRemote { @PersistenceContext(unitName = "JavaEE") EntityManager manager; public void initDB() { CounterTest ct = new CounterTest(); ct.setNr(1); ct.setWert(1); manager.persist(ct); } public boolean testCounterWithLock() { try { CounterTest ct = manager.find(CounterTest.class, 1); manager.lock(ct, LockModeType.WRITE); int wert = ct.getWert(); ct.setWert(wert + 1); manager.flush(); return true; } catch (Throwable t) { return false; } } } When I call testCounterWithLock() from three threads 500 times each, the counter gets incremented between 13 and 1279 times. How do I fix this code so that it is incremented 1500 times?

    Read the article

  • Accessing ruby counter cache

    - by Julian
    Hi all, I'm playing around with a fork of acts_as_taggable_on_steroids as a learning exercise. The version I'm looking at does some stuff I don't understand to calculate Tag counts. So I thought I'd do a version using PORC (Plain Old Rails Counters): class Tagging < ActiveRecord::Base #:nodoc: belongs_to :tag, :counter_cache => "tagging_counter_cache" ... I thought tagging_counter_cache was transparently accessed when I access tag.taggings.count but apparently not? Do I really have to access tag.tagging_counter_cache explicitly? >> tag.taggings.count SQL (0.7ms) SELECT count(*) AS count_all FROM `taggings` WHERE (`taggings`.tag_id = 16) Same for size. It's cool if that's the case but just wanted to check.

    Read the article

  • How to implement a Counter Cache in Rails?

    - by yuval
    I have a posts controller and a comments controller. Post has many comments, and comments belong to Post. The associate is set up with the counter_cache option turned on as such: #Inside post.rb has_many :comments #Inside comment.rb belongs_to :post, :counter_cache => true I have a comments_count column in my posts table that is defaulted to zero, as such: add_column :posts, :comments_count, :integer, :default => 0 In the create action of my comments controller, I have the following code: def create @posts = Post.find(params[:post_id]) @comment = @post.comments.build(params[:comment]) if @comment.save redirect_to root else render :action => 'new' end end My problem: when @comment.save is called, I get the following error: ArgumentError in CommentsController#create wrong number of arguments (2 for 0) Removing :counter_cache => true from comment.rb completely solves the problem, so I'm assuming that it is the cause of this vague error. What am I missing here? How can I save my comment and still have rails take care of my counter_cache for my post? Thanks!

    Read the article

  • Stored Procedure Hit Counter

    - by Tyler
    I have a table with 3 column's in a table on a MS SQL 2008 Database ID ToolID Count Can someone toss me a script that will create a stored procedure that accepts the param ToolID and increases its value by 1? All of my efforts have failed.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >