Search Results

Search found 30575 results on 1223 pages for 'number systems'.

Page 80/1223 | < Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >

  • Find and sort by number of ocurrences of tag with Active Admin and act_as_taggable_on

    - by nunopolonia
    I'm using act_as_taggable_on and Active Admin on a Rails project. In that project there are Posts and each Post has Tags. I want to show a list of Tags in Active Admin and the number of ocurrences of each one. The way I found to do this was: index do column :name column :ocurrences do |tag| ocurrences = Post.tag_counts.find(tag.id).count end default_actions end Which will search the Tag List every time for every Post, which performance wise looks really bad. I would also like to be able to sort the tags by ocurrence. Any idea of how I can do it?

    Read the article

  • how to find number of weekdays in array

    - by Chamal
    i hav a array of date. In this array, i want to find how many weekdays in that array. So how can i do that using java.. *here i read lines from csv file & put those into values. *values[2] contain the dates of that csv file. *So now i want to find number of weekdays in values[2]. FileInputStream fis=new FileInputStream("c:/sample.csv"); InputStreamReader isr=new InputStreamReader(fis); BufferedReader bf = new BufferedReader(isr); while (bf.ready()) { String line = bf.readLine(); String[] values=line.split(","); String date=values[2]; }

    Read the article

  • Deterministic random number generator with context?

    - by user653133
    I am looking for a seeded random number generator that creates a pool of numbers as a context. It doesn't have to be too good. It is used for a game, but it is important, that each instance of the Game Engine has it's own pool of numbers, so that different game instances or even other parts of the game that use random numbers don't break the deterministic character of the generated numbers. Currently I am using rand() which obviously doesn't have this feature. Are there any c or objective-c generators that are capable of doing what I want? Best regards, Michael

    Read the article

  • Creating a Doctrine query with a different number of ids

    - by frapet
    Is it possible to create a Doctrine query with a differnt number of ids coming from a submitted form? And if yes how? What I am trying to do is this: .... if ($input->isValid()) { $q = Doctrine_Query::create() ->from('Imm_Model_Images i') ->whereIn('i.ImageID = ?', array($input->ids)); $result = $q->fetchArray(); PS: ids come form the submitted form in an array as ids[]. Added Edit: chaged the above line: ->whereIn('i.ImageID = ?', array($input->ids)); with: ->whereIn('i.ImageID = array($input->ids)'); ...and it seems to work.

    Read the article

  • JSF-JSP cancel button returns a number format exception

    - by Barca
    I have a cancel button on a JSF-JSP page. It is handled by a method on the corresponding java class: public String cancel_action() { return "CANCEL"; This is configured in faces-config.xml as following: <navigation-rule> <from-view-id>/page2.jsp</from-view-id> <navigation-case> <from-outcome>CANCEL</from-outcome> <to-view-id>/page1.jsp</to-view-id> </navigation-case> </navigation-rule> Not sure why it is returning a number format exception. Any help will be highly appreciated.

    Read the article

  • Increment number in string

    - by iform
    Hi, I am stumped... I am trying to get the following output until a certain condition is met. test_1.jpg test_2.jpg .. test_50.jpg The solution (if you could remotely call it that) that I have is fileCount = 0 while (os.path.exists(dstPath)): fileCount += 1 parts = os.path.splitext(dstPath) dstPath = "%s_%d%s" % (parts[0], fileCount, parts[1]) however...this produces the following output. test_1.jpg test_1_2.jpg test_1_2_3.jpg .....etc The Question: How do I get change the number in its current place (without appending numbers to the end)? Ps. I'm using this for a file renaming tool.

    Read the article

  • program to determine number of duplicates in a sentence

    - by bhavna raghuvanshi
    public class duplicate { public static void main(String[] args)throws IOException { System.out.println("Enter words separated by spaces ('.' to quit):"); Set<String> s = new HashSet<String>(); Scanner input = new Scanner(System.in); while (true) { String token = input.next(); if (".".equals(token)) break; if (!s.add(token)) System.out.println("Duplicate detected: " + token); } System.out.println(s.size() + " distinct words:\n" + s); } } my program detects and prints duplicate words but i need to print the number of duplicate words also. pls help me do it.

    Read the article

  • Split a sting array into a number array in javascript

    - by Wesley Skeen
    I am reading a value from a dropdown list depending on what option is selected. I am using jqPlot to graph the values. jqPlot expects an array of values like [91, 6, 2, 57, 29, 40, 95] but when I read the value in from the dropdown box it is coming in as a whole string "[91, 6, 2, 57, 29, 40, 95]" I tried splitting it but I got ["91", "6", "2", "57", "29", "40", "95"] which wont display the graph correctly. Is there anybody that has encountered something like this before and what can I do to make my values convert into a number array. Thanks for any help

    Read the article

  • How to get the number of unread gmail mails (on android)

    - by Lord Otori
    I've been trying to get the number of unread gmail mails with no luck. I've read Gmail.java and gmail4j both links taken out of this site from this question: Android - How can I find out how many unread email the user has? But still after having read all of that and a couple of other sites that talked about this particular subject my question remains: Q: How can I get the Gmail Unread Count? Sorry if it seams a bit insistent but I clearly lack the knowledge to find this out on my own from the source. PS: I would like to clarify that I want to do it without having to ask the user for credentials. Just 2 add some colors to the question let me show you the looks of my app.

    Read the article

  • Pass variable number of variables to a class in PHP

    - by user325282
    I need to pass a variable number of strings to instantiate different classes. I can always do a switch on the size of the array: switch(count($a)) { case 1: new Class(${$a[0]}); break; case 2: new Class(${$a[0]}, ${$a[1]}); break; etc... There has to be a better way to do this. If I have an array of strings ("variable1", "variable2", 'variable3", ...), how can I instantiate a Class without manually accounting for every possibility?

    Read the article

  • Query returning an ascending group number

    - by Dougman
    I have a query like below that has groups (COL1) and that group's values (COL2). select col1, col2 from (select 'A' col1, 1 col2 from dual union all select 'A' col1, 2 col2 from dual union all select 'B' col1, 1 col2 from dual union all select 'B' col1, 2 col2 from dual union all select 'C' col1, 1 col2 from dual union all select 'C' col1, 2 col2 from dual ) order by col1, col2; The output of this query looks like: COL1 COL2 ---- ---- A 1 A 2 B 1 B 2 C 1 C 2 What I need is a query that will return an ordered number increasing for each different group (COL1). It seems like there would be a simple way to accomplish this (maybe with analytics) but for some reason it is escaping me. GRPNUM COL1 COL2 ------ ---- ---- 1 A 1 1 A 2 2 B 1 2 B 2 3 C 1 3 C 2 I am running Oracle 10gR2.

    Read the article

  • How to find the largest power of 2 less than the given number

    - by nazar_art
    I need to find the largest power of 2 less than the given number. And I stuck and can't find any solution. Code: public class MathPow { public int largestPowerOf2 (int n) { int res = 2; while (res < n) { res =(int)Math.pow(res, 2); } return res; } } This doesn't work correctly. Testing output: Arguments Actual Expected ------------------------- 9 16 8 100 256 64 1000 65536 512 64 256 32 How to solve this issue?

    Read the article

  • mysql count(*) left join group by - the number of files in a folder

    - by Flavius
    Hi I have the following tables CREATE TABLE `files` ( `fileid` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(255) NOT NULL, `filesize` int(11) NOT NULL, `folder` int(11) NOT NULL, PRIMARY KEY (`fileid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE `folders` ( `directoryid` int(11) NOT NULL AUTO_INCREMENT, `directoryname` varchar(255) NOT NULL, PRIMARY KEY (`directoryid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; How to get a list of all folders and the number of files they hold, including folders who have no (zero) files? Recursion must not be taken into account. Found it select folders.directoryid, folders.directoryname, count(files.fileid) as no_files from folders left join files on files.folder = folders.directoryid group by folders.directoryid, folders.directoryname I hope it will help someone.

    Read the article

  • Relative probabilities using random number gen

    - by CyberShot
    If I have relative probabilities of events A, B, C occurring. i.e P(A) = 0.45, P(B) = 0.35, P(C) = 0.20, How do I do represent this using a random number generator between 0 and 1? i.e. R = rand(0,1) if (R < 0.45) event A else if(R < 0.35) event B else if(R < 0.20) event C The above works for two events A,B but I think the above is wrong for three or more since there is overlapping. This is obviously a very simple question and the answer should be immediately evident, but I'm just too stupid to see it.

    Read the article

  • Find number of serialized objects

    - by tmosier
    Hello all. My issue is trying to determine a number of objects created, the objects being serialized from an XML document. The XML document should be set up for simplicity, so any developer can add an additional object and need no further modification to the code. However each of these objects need to be handled/updated seperately, and specifically, some of the objects are of different sub-classes, which need to be handled differently. Here is some pseudocode for what I am going for class A { public B myClassB; public void Update() { // for every object of whatever type in myClassB // update logic } } XML: <\data <\object1 etc... So what would be my simplest course of action, allowing other to add objects via the XML, but still ensuring the proper logic happenes for each?

    Read the article

  • Matching two sections same number of times

    - by Leszczu
    Hello, i need a HTML to parse: <span>some text<span><span><span>text</span></span></span></span> I need to remove unnecessary <span> occurrences, so that output is: <span>some text<span>text</span></span> I wrote a regex, which does this once: /<SPAN>[^<]*<\/SPAN>/i How to make this work same number of times on both <span> and </span>?

    Read the article

  • Calculating number of online visitors?

    - by Syom
    i need to show the number of online visitors, but there is a problem with selecting algoritm to do it! maybe i must create a table in DB, where i'll store ip addresses of visitors and time of visit! by so i can show the count of ip addresses, which's time = NOW() - 10 minutes, for example...("now()-10 minutes" is just to show the logic, i know that this is not a function:) is this goog way to go? or maybe it's better to use AJAX methods to store the data? please give me an idea. Thanks

    Read the article

  • count number of rows to be affected before update in trigger

    - by tomaszsobczak
    Hi, I want to know number of rows that will be affected by UPDATE query in BEFORE per statement trigger . Is that possible? The problem is that i want to allow only queries that will update up to 4 rows. If affected rows count is 5 or more i want to raise error. I don't want to do this in code because i need this check on db level. Is this at all possible? Thanks in advance for any clues on that

    Read the article

  • Python: Matching & Stripping port number from socket data

    - by tobywuk
    Hello, I have data coming in to a python server via a socket. Within this data is the string '<port>80</port>' or which ever port is being used. I wish to extract the port number into a variable. The data coming in is not XML, I just used the tag approach to identifying data for future XML use if needed. I do not wish to use an XML python library, but simply use something like regexp and strings. What would you recommend is the best way to match and strip this data? I am currently using this code with no luck: p = re.compile('<port>\w</port>') m = p.search(data) print m Thank you :)

    Read the article

  • Print number in engineering format

    - by jmurrayufo
    I am trying to print a number into engineering format with python, but I cannot seem to get it to work. The syntax SEEMS simple enough, but it just doesn't work. >>> import decimal >>> x = decimal.Decimal(1000000) >>> print x 1000000 >>>> print x.to_eng_string() 1000000 I cannot figure out why this is. The two values are not equal (one is a string, the other is an int). Setting various contexts in decimal doesn't seem to help either. Any clues or ideas?

    Read the article

  • Are UML class diagrams adequated to design javascript systems?

    - by Vandell
    Given that UML is oriented towards a more classic approach to object orientation, is it still usable in a reliable way to design javascript systems? One specific problem that I can see is that class diagrams are, in fact, a structural view of the system, and javascript is more behaviour driven, how can you deal with it? Please, keep in mind that I'm not talking abot the real world domain here, It's a model for the solution that I'm trying to achieve.

    Read the article

  • How to calculate square root in PHP [explained] [on hold]

    - by Enes Imsirovic
    At first code ! Don't forget embed the JQuery ! <html> <head> <title>Simple jQuery and PHP Square Root example</title> <script src="js/jquery-1.10.1.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $('#form').submit(function(){ var number = $('#number').val(); $.ajax({type:"post",url:"calculate.php",data:"number=" +number,success:function(msg){$('#result').hide(); $("#result").html("<h3>" + msg + "</h3>").fadeIn("slow"); } }); return false; }); }); </script> </head> <body> <form id="form" action="calculate.php" method="post"> Enter number: <input id="number" type="text" name="number" /> <input id="submit" type="submit" value="Calculate Square Root" name="submit"/> </form> <p id="result"></p> </body> </html> Second code witch would be connected with first : calculate.php <?php if($_POST['number']==null){ echo "Please Enter a Number"; }else { if (!is_numeric($_POST['number'])) { echo "Please enter only numbers"; }else{ echo "Square Root of " .$_POST['number'] ." is ".sqrt($_POST['number']); } } ?> Chiefly for begginers, to see the power of PHP :) xD Load this on your localhost.. PHP files and JS : https://mega.co.nz/#!Et8zWSBb!KX2PFxa2Pzw_l-wi6QU8xi_eKTlHbtQuBsT_DvXrifk At least it look like this : http://imgur.com/vNnDRQ3

    Read the article

  • Why are source control systems still mostly backed with files?

    - by Andy
    It seems that more source control systems still use files as the means of storing the version data. Vault and TFS use Sql Server as their data store, which I would think would be better for data consistency as well as speed. So why is it that SVN, I believe GIT, CVS, etc still use the file system as essentially a database, (I ask this question as we had our SVN server just corrupt itself during a normal commit) instead of using actual database software (MSSQL, Oracle, Postgre, etc)?

    Read the article

  • How do I count the times each number appears in columns of numbers?

    - by Andy C.
    I am sure this must be easy, but I am inexperienced. About the best way to think of my problem is to think of it as trying to sort and then count lottery numbers. To stay simple, let's do a Pick 3 game. Let's look at 10 drawings. I would split each drawn number into a separate column: DATE BALL#1 BALL#2 BALL#3 3/1 1 3 5 3/2 3 7 8 3/3 2 2 1 3/4 5 7 6 3/5 2 3 1 3/6 0 5 9 3/7 3 7 0 3/8 6 8 4 3/9 2 4 3 3/10 7 1 2 I would like to be able to build formulas into cells that would tell me how many times each number appeared overall, and how many times each number appeared in the position it occurred. Like this (using the above example): Number Overall Count Ball#1 Count Ball#2 Count Ball#3 Count 0 2 1 0 1 1 4 1 1 2 (That is, The number zero appears twice overall, and came up once as the first number drawn; zero times as the middle ball; and once as the third ball. Likewise, the number 1 was drawn four times in our 10-day period. It was the first ball once, the second ball once and the third ball twice.) And so on. All help appreciated. I have access to Excel and Microsoft Works, or of course if there is a Google Docs way to handle this All thanks for any help.

    Read the article

< Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >