FAQ Database Discussion Community


How to save counter of entries in str and show it in Text field?

python,tkinter,scope,counter
Using such example i want to count number of entries. And represent string with number of entries in Text field. Like, for example: 1: number of entries(1) 21: number of entries(2) ... Where should i put my counter variable? import random from tkinter import * class MyApp(Frame): def __init__(self, master):...

Jquery's if statement for a css file

jquery,variables,animation,if-statement,counter
As you see in the code, I have a variable which is supposed to be incremented by 1 on every click, and then, a scenario will run based on the value of variable. Sadly, it seems like something goes definitely wrong. All 5 scenarios are running on first click. $(document).ready(function(){...

How to delete duplicate entries in a nested container

python,list,dictionary,collections,counter
I've got a data structure like these: [{'remote': '1', 'quantity': 1.0, 'timestamp': 1}, {'remote': '2', 'quantity': 1.0, 'timestamp': 2}, {'remote': '2', 'quantity': 1.0, 'timestamp': 3}, ...] a list of dictionaries. My task is to find duplicate entries regarding the remote value. If i found entries with the same remote value...

Making a counter with angular and timout

javascript,angularjs,html5,timeout,counter
hey i'm trying to build a simple counter that shows in my html. it kind of works but it doesn't listen to the timeout and gives a bunch of errors. This is the error i'm getting TypeError: fn is not a function This is the javascript function and object: $scope.funFacts...

Put counter into a frequency ordered list

python,list,counter
I have a counter with the following information: Counter({'red': 3, 'blue': 2, 'green': 1}) and I wish to convert it to a list, ordered from least to greatest number of frequency like this: list = ['green', 'blue', 'red'] Every time I iterate over the counter, it seems to put it...

While loop counter increasing “exponentially” in spite of using ++

javascript,while-loop,counter,nested-function
Background information I am setting up a function which creates a date array based on a start date and an end date. The function will receive start and end dates, which have first been formatted to year-month-dayT12:00:00:00 format and then converted into milliseconds with .getTime() format. My script I have...

Counter list python 2.7

python,list,python-2.7,counter
I have list like this: Pasang = [0, 4, 4, 5, 1, 7, 6, 7, 5, 7, 4, 9, 0, 10, 1, 10,...., 23, 9, 23, 7, 23] I count item from that list: satuan = Counter(pasang) then I get : Counter({5: 10, 6: 7, 0: 5, 1: 5, 7:...

Hits counter in txt file count visitors when open page simultaneously

php,count,counter
I am using this to count the hits to my website: $counter_name = "counter.txt"; $f = fopen($counter_name,"r"); $counterVal = fread($f, filesize($counter_name)); fclose($f); $counterVal++; $f = fopen($counter_name, "w"); fwrite($f, $counterVal); fclose($f); I want to ask you if there could be a problem when 2 or more visitors opens the page at...

How to set a value at moduleEN - VHDL

vhdl,counter
I've this code: library IEEE; use IEEE.std_logic_1164.all; entity Controller is port ( CLK : in std_logic; OutENABLE : out std_logic_vector (2 downto 0); ModuleRESET : in std_logic; ModuleENABLE : in std_logic ); end Controller; architecture Controller_archi of Controller is signal Counter : integer range 0 to 4200 := 0; begin...

Accessing a signal in both structural and behavioural architecture

architecture,signals,vhdl,counter
I have defined the structural architecture of a module e.g. architecture structural of my_entity is signal counter : integer := 0; begin MODULE port map(......count => counter.....); --this is an inout port end structural; I would like to implement a counter which is incremented based on a change in an...

How to “sample” a value in VHDL?

case,vhdl,counter
So I have a modulo counter going from 1->15, then looping back around constantly in a seperate entity. I would like to, in a case statement depending on some outputs, sample this value on the rising_edge of a clock, but only do it once, otherwise the value will be constantly...

PowerShell file rename and counter issue

powershell,rename,counter
I have made a very simple ps1 script that rename my txt files with an "ID" number like Card.321.txt This works for simple lines, but I need a mass rename of lines, so I need something different. $i = 1 Get-ChildItem *.txt | %{Rename-Item $_ -NewName ('Card.{0:D3}.txt' -f $i++)} But...

Start increment column at begining of month

python,datetime,pandas,counter,timedelta
thank you in advance for your assistance. Want set 'Counter' to 1 whenever there is change in month, and increment by 1 until month changes again, and repeat. Like so: A Month Counter 2015-10-30 -1.478066 10 21 2015-10-31 -1.562437 10 22 2015-11-01 -0.292285 11 1 2015-11-02 -1.581140 11 2 2015-11-03...

Reset counter in select after 5 rows

sql,sql-server,sql-server-2008,select,counter
Table Id SomeValue 1 Header1 4 Header9 7 Header5 8 Header2 9 Header5 12 Header4 13 Header9 14 Header7 Expected output Id SomeValue Counter 1 Header1 1 4 Header9 2 7 Header5 3 8 Header2 4 9 Header5 5 12 Header4 1 13 Header9 2 14 Header7 3 Current output:...

How to find a row in an Excel sheet using Excel Macro VBA?

excel,vba,indexing,counter
My code for now is: Set RecT = gConnect.Execute("SELECT [Volume] FROM [Output$] WHERE ((([Facilities])=""IDK"") AND (([Detail_1])=""BPL"" Or ([Detail_1])=""SI"")) ORDER BY [Detail_1];") Worksheets("Results").Cells(52, 4).CopyFromRecordset RecT First, with Set Rect I look for the value I want in another sheet, and then I copy it in the 4th column of the...

Set counter per element in jQuery plugin

jquery,loops,jquery-plugins,counter
When you set a counter in a jQuery plugin it will be set per instance of the plugin. For instance $.myPlugin(".one"); $.myPlugin(".two"); $.myPlugin = function (el) { var counter = 0; $(el).click(function () { counter++; console.log(counter); }); }; Will initiate two counters. (Try it here) However, I'd like to have...

Why do I have to make a seperate variable to correct this loop? (Javascript Basics)

javascript,arrays,loops,counter
I am currently learning Javascript so I will try my best with my choice of words. In the following code below. I want the variable "allFoods" to display all the different variations. Although, I have found a loophole, I like to understand the logic and why things are done rather...

In Cassandra, if I run a query that increments a counter, then selects from that counter is that atomic?

cassandra,counter,cql,unique-key
If I run a query that increments a counter, then selects from that counter is that atomic? I am wanting to generate smaller (integer) numbers using Cassandra. The usage will likely be generating fewer than 1000 Ids/day, but definitely needs to be non-conflicting, and would prefer minimal chance of waste...

How to loop each array for Counter function inside a list using Python?

python,arrays,loops,counter
I want to use counter function to count for the occurrences of the value 0 for each array inside a list. from collections import Counter [Counter(x) for x in a] [Counter(x)[0] for x in a] Using the above code it only applies to example like: a = [array([-2, 0, 0]),...

Using Foreach for website. I want a hit counter using PHP & MSQL

php,counter,hit,hitcounter
So I'm creating a piano library website for my younger cousin. Currently I use the foreach function to display all the data from my database. Now, this works great and I managed to get a few features working, but one I'm having trouble with is a "counter". Super easy concept,...

procedure doesn't work for evey pattern in prolog

prolog,counter
I try to find how many children a person have. Created my sample space and in find procedure i should count the numbers of children and print the value. sample input/output: ?- find(joe,Result). false. i tried to change find(X,R) like that: find(X,R) :- R is 0 . R is R+1...

Java Multithreading - Threadsafe Counter

java,multithreading,thread-safety,counter
I'm starting off with a very simple example in multithreading. I'm trying to make a threadsafe counter. I want to create two threads that increment the counter intermittently to reach 1000. Code below: public class ThreadsExample implements Runnable { static int counter = 1; // a global counter public ThreadsExample()...

Python - How to add column elements to a list with a counter

python,split,counter
in a text file with two columns, I have some rows like the following: N 20 CA 20 C 20 O 20 CB 20 CG 20 CD 20 CE 20 NZ 20 N 21 CA 21 C 21 O 21 CB 21 SG 21 I created a nested dictionary in...

Python how to use Counter on objects according to attributes

python,sorting,object,attributes,counter
I have a class named record, which stores information of log record; class Record(): def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) And examples of this record can be: r1 = Record(uid='001',url='www.google.com',status=200) r2 = Record(uid='002',url='www.google.com',status=404) r3 = Record(uid='339',url='www.ciq.com', status=200) ... What I want is to count how...

Counter grouped by category, author and date in Redis

redis,bigdata,counter,hyperloglog
I am implementing a system that store a large amount of data in a relational DB. Data can be classified into categories and have an author. I want to get the number of items grouped by date, category and author and the sum of all items of each category grouped...

Keep strings that occur N times or more

python,python-2.7,counter
I have a list that is mylist = ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'd'] And I used Counter from collections on this list to get the result: from collection import Counter counts = Counter(mylist) #Counter({'a': 3, 'c': 2, 'b': 2, 'd': 1}) Now I want to subset this...

Making a simple counter that increments every second on android. What wrong am I doing?

android,multithreading,counter
Im writing code to display a counter that increments by 1 every second. The app is getting forced closed before running with the error - thread exiting with uncaught exception and No package identifier when getting value for resource number public class MainActivity extends Activity { Handler hand = new...

How to count unique data in php mysql?

php,mysql,counter
i have some data like this.. and i want to make a table that count every unique row like this.. Ruang | Tipe_Px | Count1 | Count2 Anggrek |ASKES PNS |4 |3 Anggrek |JAMKESMAS |1 |2 Dahlia |TNI |2 |1 Dahlia |ASKES |5 |1 Dahlia |ASKES BLUE |1 |0 to...

Python Counter class: add or increment single item

python,counter
To increment a single item in collections.Counter, you have to add it to a list to use Counter.update: c = Counter() for item in something: if item.has_some_property: c.update([item.property]) # can add and subtract item-specific logic here during development # when first exploring unknown objects # and you may not want...

How to make int counter go down when answer is wrong

java,int,counter
Im making a player 2 guesses player 1's number game. Ive made an int counter thats == 10 and is meant to go down everytime player 2 gets answer wrong. I cant get it to work and i need help on how to make this. Youll see what i mean......

Wrap outputs of a Wordpress query every second item

php,wordpress,counter
I think I am pretty close to the solution but I cannot figure out the logic for where I should close the last div. I have a wordpress query which requests four posts. I want to wrap every two items in <section class="sponsor-row"> So I have implemented a counter in...

Illegal conversion exception?

java,arrays,int,double,counter
I am getting an error message on my code to find the total salary of employee's who are payed $200 + the commission amount. Once all the employee's gross sales are input it is supposed to print out the amount of employee's that fell into each different pay category. Here...

Creating a matrix of multiple counters in R

r,counter,apply
So, my goal is to take an input vector and to make an output matrix of different counters. So every time a value appears in my inputs, I want to find that counter and iterate it by 1. I understand that I'm not good at explaining this, so I illustrated...

Is it possible to include loop counter in name of array when declaring it? (in C)

c,arrays,for-loop,counter,naming
I have this loop which creates a certain number of array depending on a value input by the user. I want to include the counter of the array at the end of the array name such that it is: array1[], array2[], array3[] and so on, one for each iteration. Would...

Counting consecutive alphabets and hyphens and encode them as run length

python,python-2.7,collections,counter
How do I encode my hyphenated fasta format string to group all consecutive Nucleotide and hyphens and encode them as run length. Consider my sequence as "ATGC----CGCTA-----G---". The string has sequence of Nucleotide followed by sequence of hyphens. I am trying to group all consecutive Nucleotide as the letter M...

Issues with .TPL file with Smarty

php,smarty,counter
I use PHP Melody on my site and I don't know how can I make one thing. I have this code to print on index 30 post: Code: {get_advanced_video_list assignto="new_videos" limit="30"} {foreach from=$new_videos key=k item=video_data} I need after 5 post to put a div (div class="thumb-holder") So there should be:...

Loop through folder using array to find lastest version (count) with VBA?

arrays,vba,excel-vba,counter
I have attached a code, however, this will only find the files that is present in the folder. What I want to have is an incremental counter for the files. Thing is that sometimes the version will start something else than 0 or 1, e.g. 3. Amesto non AN suppliers...

JavaScript function to automatically count consecutive letters in a string

javascript,arrays,string,counter,concat
I am attempting (unsuccessfully) to write JavaScript function LetterCount to count the consecutive letters in a string (and not the total number). Ideally: LetterCount("eeeeeoooohhoooee") = [["e", 5],["o",3],["h",2],["o",3],["e",2]] The following code attempts to count the number of consecutive letters in a string only when I already know what they are: function...

What does the ++counter mean? [duplicate]

java,counter
This question already has an answer here: ++someVariable Vs. someVariable++ in Javascript 4 answers I don't consider myself to be bad at programming, but there's been something troubling me since the past few days. int counter = 3; ++counter; Is the following code above the same as counter++;....

SAS identify combinations of two variables using count

sas,counter
I have the following dataset data input; input Row$ A B; datalines; 1 1 2 2 1 2 3 1 1 4 1 1 5 2 3 6 2 3 7 2 3 8 2 2 9 2 2 10 2 1 ; run; My goal is only to keep...

removing least common elements from Counter

python,counter
Is there any "faster way" to remove key, value pairs from Counter where value is less than certain value? I've done the following: counter_dict = {k:v for k, v in counter_dict.items() if v > 5} ...

Counter not working after jumps - assembly language

loops,assembly,counter,increment
For some reason, when i switch to mouse input switch back to keyboard input for my program, increasing and decreasing the counter has no effect. It works perfectly in the first loop where we input characters. Here is the program guys, any advice? look at whatspeed jump for reference after...

Add an index (or counter) to a dataframe by group in R

r,indexing,counter,plyr,seq
I have a df like ProjectID Dist 1 x 1 y 2 z 2 x 2 h 3 k .... .... I want to add a third column such that we have an incrementing counter for each ProjectID: ProjectID Dist counter 1 x 1 1 y 2 2 z 1...

Counting to 100,000 and writing that to a file

python,file,counter,writing
I haven't used Python for a while but I decided to create a program today to help me with some work I am trying to do. I am trying to create a program that writes the numbers 1-100,000 with the symbol | after each but can't seem to strip the...

How do I input multiple units of data and utilize a counter in Java

java,if-statement,while-loop,printf,counter
Hello everyone I am trying to get it so my program is able to take multiple users worth of data, and then print all of that data once the while loop is finished (I have the counter set at 1 so one new set of information can be entered after...

no Errors but no Result

ruby,regex,counter
I need to find each occurrence of "$" and change it to a number using a count. eg str = "foo $ bar $ foo $ bar $ * run code here * => "foo 1 bar 2 foo 3 bar 4 It feels like this should be a lot...

Cumulative Summation in intervals - MATLAB

matlab,counter,reset,cumsum
Suppose I have 2 input vectors x and reset of the same size x = [1 2 3 4 5 6] reset = [0 0 0 1 0 0] and an output y which is the cumulative sum of the elements in x. Whenever the value of resets corresponds to...

How to save the highest integer in UILabel

objective-c,counter
I have one label, named pointLabel, two buttons, named increases and decrease. When you click "increase" button, it will increase the point in pointLabel. and you click "decrease" button, it will reduce the point. It will end when it reaches 0 point in pointLabel. While the point is being increased...

Simple javascript counter no frills, just count

javascript,persistence,counter
I have the number 3,453,500 it needs to increase by +1 every 4 seconds. Need to keep the formatting the same (commas in the right place) (also is there a way that this can count continuously without the refreshing to the lowest number on page refresh?)...

How do I count the occurences of characters of a partition in python?

python,list,counter,partition
I have a large file containing sequences; I want to analyze only the last set of characters, which happen to be of variable length. In each line I would like to take the first character and last character of each set in a text file and count the total instances...

Writing a counter to count the number of clicks

javascript,jquery,counter
I have two buttons on my website. Next and previous. I want to write a code to increase the value each time next is clicked and decrease the value each time previous is clicked. I want the value to be shown in an input. But the value shown in input...

why after looping there's a newline

c,newline,counter,scanf
so i'm trying to make a penalty kick scorekeeper. i set it to be 5 rounds at first, and when the scores are tied, it will repeat another 5 rounds. the problem is there's seem to be a newline appeared after it. #include <stdio.h> int main() { int penalty2=0,penalty1=0,i=0; char...

jQuery counter insert commas to break up string

javascript,jquery,string,counter
I have a counter that increments every x seconds, here's my code: var counter=22000000000; if(typeof(localStorage.getItem('counts'))!='object') { counter=parseInt(localStorage.getItem('counts')); } $(".count").html(counter); setInterval(function () { $(".count").html(counter); ++counter; localStorage.setItem('counts',counter); }, 18000); Because the starting number is so high it doesn't read well, see it here: http://jsfiddle.net/vpju4cpr/1/ Ideally instead of outputting 22000000000 I'd like it...

Is there an elegant, Pythonic way to count processed data? [duplicate]

python,loops,counter
This question already has an answer here: Loop through list with both content and index [duplicate] 6 answers I often have time consuming processing steps that occur within a loop. The following method is how I keep track of where the processing is at. Is there a more elegant,...

Base 36 counter without I or O

counter,base36
we have a requirement to make our serial numbers Base 36 (0-9,A-Z). My initial thought was store the counter in decimal and convert to hex only when required for display. This makes the counting simple, however there is another requirement to not use I or O because it'll be confused...

AngularJS text input validation with counter

angularjs,forms,validation,counter,ng-maxlength
I'm developing an app containing a form which has a text input with ng-model="description". Now I want to validate this text input using ng-maxlength="50" and required. This works fine, but I also want to add a character counter (like 67/50) shown at all times. I'm using the following code to...

implementing a counter that counts requests with django

python,django,counter
I'm just trying with Django, how can i implement a counter that stores the count of requests served on the database? I want to count the GET requests, what should I do make it work? my template, <form action="/submit/" method="GET"> <input type="text" name="q"> <input type="submit" value="Submit"> </form> my view def...

how many person visited a specific web page?

javascript,client-server,counter
I know that I can see how many times someone opened a specific page in my website. but What I want is to enter a web page URL like www.example.com/page from the user and see how many times this page was opened. can I do this if the page was...

How to get a counter for a guessing game

java,loops,while-loop,counter
I'm attempting to add a counter to my program to count the number of guesses that the user has taken. I'm not sure how to do this... Below is my code: import java.util.*;//imports the utilities public class WordPyramid { public static void main(String[] args) { int n; Scanner kb =...

Python Counter doesn't count

python,if-statement,counter
import urllib2 f=urllib2.urlopen("http://www.mbnet.com.pl/dl.txt") list = range(1,50) counter={} for lines in f: tab_lines=lines.split(" ") formated_tab=tab_lines[-1].strip().split(',') #print formated_tab for i in formated_tab: if i in list: counter[i]+=1 print counter.items() My counter doesn't work and I don't know why :( This is a list of lottery numbers. I would like count how many...

Increment variable while storing infromation loop bash

bash,variables,while-loop,counter,increment
I need to increment key while also storing information. For example: key1=value key2=value and so on... count = 7 while [ $count -gt -1 ] do key$count=${array[$count]} let count=$count-1 echo $key done Any help is appreciated....

Max MSP. How I initialize a BPM counter/ tempo recognizer with a massage if bmp changes?

max,counter,tempo,max-msp-jitter
i need a bpm counter witch send a message if a tempo of incoming Audiosignal changes. Have anyone an idee?

How could this code enter an infinite loop? aka how to implement a counter in Haskell?

haskell,counter,infinite-loop
I have this code inside a function with side effects ... -> IO() let index_player = (-1) dronePositionByPlayer <- replicateM nb_players $ do let index_player = index_player + 1 dronePositions <- replicateM nb_drones $ do input_line <- getLine let input = words input_line let dx = read (input!!0) :: Int...

clearInterval not working after 6 time setInterval

javascript,counter,setinterval,clearinterval
I want to change an image 6 times to create the illusion of a dice changing the number of dots (a simple animation). But the images don't stop after the 6 time. I think the clearInterval is not working! don't know why var d = [ "images/dado1.svg", "images/dado2.svg", "images/dado3.svg", "images/dado4.svg",...

Creating a program which counts words number in a row of a text file (Python)

python,input,output,counter
I am trying to create a program which takes an input file, counts the number of words in each row and writes a string of that certain number in another output file. I managed to develope this code: in_file = "our_input.txt" out_file = "output.txt" f=open(in_file) g=open(out_file,"w") for line in f:...

Summing list of counters in python

python,python-2.7,counter
I am looking to sum a list of counters in python. For example to sum: counter_list = [Counter({"a":1, "b":2}), Counter({"b":3, "c":4})] to give Counter({'b': 5, 'c': 4, 'a': 1}) I can get the following code to do the summation: counter_master = Counter() for element in counter_list: counter_master = counter_master +...

Javascript Counter for Cumulative Hours

javascript,counter
We need to get a counter to work to show our cumulative hours but I can't seem to get it to go. It was working on an old site but I can't get it to work on the new one. Can anyone tell me if I am missing something important...

Using Cassandra to count a big list of data

sorting,cassandra,nosql,counter,cql
We are using Cassandra to count various analytics metrics, broken down by account and date, which seems to be working well: SELECT COUNT(page_impressions) FROM analytics WHERE account='abc' and MINUTE > '2015-01-01 00:00:00'; We would like to further break down this data by domain, which causes a problem. The number of...

jquery set counter within the function which is called by itself

jquery,function,counter,jquery-callback
I try to make a counters of correct and incorrect given answers. The count happens within the if else construction after the user clicks on the button. (function keerSom(){ //generate and put a random number between 1 and 10 a = Math.floor((Math.random() * 10) + 1); $(".a").html(a); //get the variable...

How to make a counter running on a server?

server,counter
I would like to know how to make a counter that continuously runs on a server and that is accessible by any clients (e.g web browsers) anytime (the counter being running continuously on the server - it means I don't have to connect to the server with the client). I...

PHP - Count lines containing specified string [closed]

php,counter
How can I get: <?php function getLines($file) { $f = fopen($file, 'r'); while ($line = fgets($f)) { yield $line; } } $file = '/home/unfed/public_html/tools/c/accounts.txt'; $lineCount = iterator_count(getLines($file)); ?> To count every line containing the word 'available'? So.. Should count lines like: Hello is available Hello will be available in xxx...

How do i Count based on multiple Conditions

sql,select,sql-server-2008-r2,counter
I have current 4 Columns Id, A, B and C A B C 243 3 1 243 3 2 243 3 3 243 3 1 243 3 2 243 3 3 243 3 1 243 3 2 243 3 3 185 3 1 185 3 2 185 3 3 185...

variable incrementing returns NaN

javascript,variables,counter
I am attempting to create an app in Javascript/HTML/CSS to run board games, so I can teacher my 11th and 12th grades students to do the same. Mostly I've got it working, including a dice roll, but I have a counter that determines whose turn it is that is returning...

Count Edges over specific Period of Time in VHDL

vhdl,counter,reset,encoder
For speedmeasurement of an electric motor I would like to count the amount of rising and falling edges of an encoder-input in a time-intervall of 10ms. To do this I have implementet a clock divider for my 40 MHz Clock as follows: entity SpeedCLK is Port ( CLK : in...

Integrate counters with gatling

scala,counter,gatling,grafana
I want to know if it's possible integrate the Kamon counters placed in my code like mailbox-size with Gatling to obtain graphics of this in the report.

VBA in Excel - If statement Counter wont work

excel,vba,excel-vba,if-statement,counter
I have been trying to get this VBA script to work to automate a task, but I cannot get it to work. Basically, I have a big task list in excel with multiple columns and over 1000 Rows. It contains the task, who it is assigned to, and if it...