Search Results

Search found 4955 results on 199 pages for 'range'.

Page 87/199 | < Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >

  • What are the Ruby equivalent of Python itertools, esp. combinations/permutations/groupby?

    - by Amadeus
    Python's itertools module provides a lots of goodies with respect to processing an iterable/iterator by use of generators. For example, permutations(range(3)) --> 012 021 102 120 201 210 combinations('ABCD', 2) --> AB AC AD BC BD CD [list(g) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D What are the equivalent in Ruby? By equivalent, I mean fast and memory efficient (Python's itertools module is written in C).

    Read the article

  • Frameworks for JavaScript UI Widgets?

    - by ChrisInCambo
    I'm trying to put together a list of JavaScript UI widget frameworks for consideration in a project. Ideally it would be a library that has a range of ready made ui widgets, no dependencies on dom/js extention/manipulation frameworks like JQuery or Prototype, minimal additional cruft, such as Ajax API's and DOM selectors etc. Here's what I have so far: qooxdoo, ScriptClient ExtJs Could anyone suggest any other that are worth a look? Please do not suggest, JQuery, Prototype, Mootools, Dojo etc, their primary focus is not to provide ui widgets.

    Read the article

  • Each request takes 25-30 sec for Google Analytics API?

    - by SODA
    I'm using GAPI library (in PHP) for querying Google Analytics API. I request 2 dimensions (pagePath, date), 2 metric (pageviews, visits), past 365 days time range, and 2 filters for pagePath. Average time to get data for one query is 25-30 sec. When I use only 1 metric (pageviews), average response time is 3 sec. Why would there be such a difference when using 1 or 2 metrics?

    Read the article

  • Error while compiling the Xcode project (IPhone)

    - by Sridhar
    Hello, I added ffmpeg iphone port into my library and I can able to use a few of its functions like avcodec_init(),.. without any errors. But when I include this function call "avcodec_register_all" Xcode is giving error after compilation The error message is : *--------------- ld: ldr 12-bit displacement out of range (4276 max +/-4096) in _CFRelease$stub in _CFRelease$stub from /Users/foxit/Documents/CameraTest/build/CameraTest.build/Debug-iphoneos/CameraTest.build/Objects-normal/armv6/CameraTest Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1 *------------- Does anyone know whats wrong with this ? Regards, Raghu

    Read the article

  • with JQUERY, How to pass a dynamic series of data to the server

    - by nobosh
    What is the recommended way in JQUERY to send a dynamic set of data to the server, the set contains items like: ID: 13 Copy: hello world....hello world....hello world....hello world.... ID: 122 Copy: Ding dong ...Ding dong ...Ding dong ...Ding dong ...Ding dong ... ID: 11233 Copy: mre moremore ajkdkjdksjkjdskjdskjdskjds This could range from 1, to 10 items. What's the best way to structure that data to post to the server with JQUERY? Thanks

    Read the article

  • Induction of graduate programmers

    - by spong
    What are some practical ideas that you have found useful for bringing graduates on to your team in their first job? Some of the things that are working well for us include: Assigning a mentor to assist the learning process Written coding standards/guidelines Spending a period of time with the test team to learn the product Where possible, a broad range of experiences in the first few months Anything else that works well for you? A related question can be found here.

    Read the article

  • Python - excel - xlwt: colouring every second row

    - by konjo
    Hi, i just finish some MYSQL to excel script with xlwt and I need to colour every second row for easy reading. I have tried this: row = easyxf('pattern: pattern solid, fore_colour blue') for i in range(0,10,2): ws0.row(i).set_style(row) Alone this colouring is fine, but when when I write my data rows are again white. Can some please show me some example 'cuz I m lost in coding :/ Best Regards.

    Read the article

  • Faster float to int conversion in Python

    - by culebrón
    Here's a piece of code that takes most time in my program, according to timeit statistics. It's a dirty function to convert floats in [-1.0, 1.0] interval into unsigned integer [0, 2**32]. How can I accelerate floatToInt? piece = [] rng = range(32) for i in rng: piece.append(1.0/2**i) def floatToInt(x): n = x + 1.0 res = 0 for i in rng: if n >= piece[i]: res += 2**(31-i) n -= piece[i] return res

    Read the article

  • determine if intersection of a set with conjunction of two other sets is empty

    - by koen
    For any three given sets A, B and C: is there a way to determine (programmatically) whether there is an element of A that is part of the conjunction of B and C? example: A: all numbers greater than 3 B: all numbers lesser than 7 C: all numbers that equal 5 In this case there is an element in set A, being the number 5, that fits. I'm implementing this as specifications, so this numerical range is just an example. A, B, C could be anything.

    Read the article

  • Matplotlib: plotting discrete values

    - by Arkapravo
    I am trying to plot the following ! from numpy import * from pylab import * import random for x in range(1,500): y = random.randint(1,25000) print(x,y) plot(x,y) show() However, I keep getting a blank graph (?). Just to make sure that the program logic is correct I added the code print(x,y), just the confirm that (x,y) pairs are being generated. (x,y) pairs are being generated, but there is no plot, I keep getting a blank graph. Any help ?

    Read the article

  • Convert SQL server datetime fields to compare date parts only, with indexed lookups

    - by Caveatrob
    I've been doing a convert(varchar,datefield,112) on each date field that I'm using in 'between' queries in SQL server to ensure that I'm only accounting for dates and not missing any based on the time part of datetime fields. Now, I'm hearing that the converts aren't indexable and that there are better methods, in SQL Server 2005, to compare the date part of datetimes in a query to determine if dates fall in a range. What is the optimal, indexable, method of doing something like this: select * from appointments where appointmentDate='08-01-2008' and appointmentDate<'08-15-2008'

    Read the article

  • Is it possible to access variable of subclass using object of superclass in polymorphism

    - by fari
    how can i access state varibale of class keyboard with object of class kalaplayer /** * An abstract class representing a player in Kala. Extend this class * to make your own players (e.g. human players entering moves at the keyboard * or computer players with programmed strategies for making moves). */ public abstract class KalaPlayer { /** * Method by which a player selects a move. * @param gs The current game state * @return A side pit number in the range 1-6 * @throws NoMoveAvailableException if all side pits for the player are empty * (i.e. the game is over) */ public abstract int chooseMove(KalaGameState gs) throws NoMoveAvailableException; } public class KeyBoardPlayer extends KalaPlayer { /** * Method by which a player selects a move. * @param gs The current game state * @return A side pit number in the range 1-6 * @throws NoMoveAvailableException if all side pits for the player are empty * (i.e. the game is over) */ public KalaGameState state; public KeyBoardPlayer() { System.out.println("Enter the number of stones to play with: "); try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int key = Integer.parseInt(br.readLine()); state=new KalaGameState(key); //key=player1.state.turn; } catch(IOException e) { System.out.println(e); } } public int chooseMove(KalaGameState gs) throws NoMoveAvailableException{ return 0; } } import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; public class KalaGame { KalaPlayer player1,player2; public KalaGame(KeyBoardPlayer Player1,KeyBoardPlayer Player2) { //super(0); player1=new KeyBoardPlayer(); player2 = new KeyBoardPlayer(); //player1=Player1; //player2=Player2; //player1.state ****how can i access the stae variable from Keyboard CLass using object from KalaPlayer key=player1.state.turn; } public void play() { System.out.println("Enter the number of stones to play with: "); try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int key = Integer.parseInt(br.readLine()); System.out.println(key); KalaGameState state=new KalaGameState(key); printGame(); } catch(IOException e) { System.out.println(e); } }

    Read the article

  • Java code translation of Python array-splitting code

    - by techventure
    Can someone please give the Java equivalent of the below python (which slices a given array into given parts) which was originally written by ChristopheD here: def split_list(alist, wanted_parts=1): length = len(alist) return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts] for i in range(wanted_parts) ] I don't know any python but can really use the above code in my Java app. Thanks

    Read the article

  • My style/control template out my calendar's blackout dates.

    - by Chris
    Howdy, My C#/WPF project needs a calendar. We're going to be using it to pick a range of dates for appointment scheduling. I'm told the default calendar is too small to be used by some of our reps so I've been working on resizing it. <toolkit:Calendar Grid.Row="1" x:Name="DateWindowCalendar" BorderBrush="White" BorderThickness="0" Style="{StaticResource PopupCalendarStyle}" DisplayMode="Month" SelectionMode="SingleRange" DisplayDateStart="{Binding FirstDayOfMonth}" AutomationProperties.AutomationId="ToolkitCalendarId" VerticalAlignment="Top"> </toolkit:Calendar> And I've created this styling: <Style x:Key="PopupCalendarStyle" TargetType="toolkit:Calendar"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="toolkit:Calendar"> <StackPanel Margin="0" HorizontalAlignment="Center" x:Name="Root"> <toolkit:Calendar x:Name="Calendar" SelectedDate="{TemplateBinding SelectedDate}" DisplayDateStart="{TemplateBinding DisplayDateStart}" SelectionMode="{TemplateBinding SelectionMode}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SelectedDatesChanged="Calendar_SelectedDatesChanged"> <toolkit:Calendar.CalendarDayButtonStyle> <Style> <Setter Property="Button.Height" Value="34"/> <Setter Property="Button.Width" Value="34" /> <Setter Property="Button.FontSize" Value="16" /> </Style> </toolkit:Calendar.CalendarDayButtonStyle> <toolkit:Calendar.CalendarButtonStyle> <Style> <Setter Property="Button.Height" Value="34"/> <Setter Property="Button.Width" Value="34"/> <Setter Property="Button.FontSize" Value="16"/> </Style> </toolkit:Calendar.CalendarButtonStyle> </toolkit:Calendar> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> Everything is almost perfect. I specify my range, I can track the selected dates (granted using the SelectedDatesChanged event instead of the SelectedDates property. The problem is I also need to be able to set blackout dates (usually the period between first of the month and today although sometimes first of the month to a few days from now). Without the styling, this works: DateWindowCalendar.BlackoutDates.Add(new CalendarDateRange( new DateTime(DateTime.Now.Year, DateTime.Now.Month, 01), DateTime.Now)); But when I add the style, I don't get the black out displays being displayed and worse its possible to select the blackout dates. I'm not sure what I missed but I'm hoping someone has an easy answer so that I don't have to rebuild the entire widget. Any help is appreciated. Thanks, Chris

    Read the article

  • How do I get the number of objects per day using django?

    - by Keith
    I have a django model with a DateTimeField. class Point(models.Model): somedata = models.CharField(max_length=256) time = models.DateTimeField() I want to get a count of the number of these objects for each day. I can do this with the following SQL query, but don't know how to do it through django. SELECT DATE(`time`), Count(*) FROM `app_point` GROUP BY DATE(`time`) Being able to restrict the results to a date range would also be good.

    Read the article

  • Python. How to iterate through a list of lists looking for a partial match

    - by Becca Millard
    I'm completely stuck on this, without even an idea about how to wrap my head around the logic of this. In the first half of the code, I have successfully generation a list of (thousands of) lists of players names and efficiency scores: eg name_order_list = [["Bob", "Farley", 12.345], ["Jack", "Donalds", 14.567], ["Jack", "Donalds", 13.421], ["Jack", "Donalds", 15.232],["Mike", "Patricks", 10.543]] What I'm trying to do, is come up with a way to make a list of lists of the average efficiency of each player. So in that example, Jack Donalds appears multiple times, so I'd want to recognize his name somehow and average out the efficiency scores. Then sort that new list by efficiency, rather than name. So then the outcome would be like: average_eff_list = [[12.345, "Bob", "Farley"], [14.407, "Jack", "Donalds"], [10.543, "Mike", "Patricks"]] Here's what I tried (it's kind of a mess, but should be readable): total_list = [] odd_lines = [name_order_list[i] for i in range(len(name_order_list)) if i % 2 == 0] even_lines = [name_order_list[i] for i in range(len(name_order_list)) if i % 2 == 1] i = 0 j = i-1 while i <= 10650: iteration = 2 total_eff = 0 while odd_lines[i][0:2] == even_lines[i][0:2]: if odd_lines[i][0:2] == even_lines[j][0:2]: if odd_lines[j][0:2] != even_lines[j][0:2]: total_eff = even_lines[j][2]/(iteration-1) iteration -= 1 #account fr the single (rather than dual) additional entry else: total_eff = total_eff if iteration == 2: total_eff = (odd_lines[i][2] + even_lines[i][2]) / iteration else: total_eff = ((total_eff * (iteration - 2)) + (odd_lines[i][2] + even_lines[i][2])) / iteration iteration += 2 i += 1 j += 1 if i > 10650: break else: if odd_lines[i][0:2] == even_lines[j][0:2]: if odd_lines[j][0:2] != even_lines[j][0:2]: total_eff = (odd_lines[i][2] + even_lines[j][2]) / iteration else: total_eff = ((total_eff * (iteration -2)) + odd_lines[i][2]) / (iteration - 1) if total_eff == 0: #there's no match at all total_odd = [odd_lines[i][2], odd_lines[i][0], odd_lines[i][1]] total_list.append(total_odd) if even_lines[i][0:2] != odd_lines[i+1][0:2]: total_even = [even_lines[i][2], even_lines[i][0], even_lines[i][1]] else: total = [total_eff, odd_lines[i][0], odd_lines[i][1]] total_list.append(total) i += 1 if i > 10650: break else: print(total_list) Now, this runs well enough (doesn't get stuck or print someone's name multiple times) but the efficiency values are off by a large amount, so I know that scores are getting missed somewhere. This is a problem with my logic, I think, so any help would be greatly appreciated. As would any advice about how to loop through that massive list in a smarter way, since I'm sure there is one... EIDT: for this exercise, I need to keep it all in a list format. I can make new lists, but no using dictionaries, classes, etc.

    Read the article

  • nokogiri vs hpricot?

    - by roshan
    Which one would you choose? My important attributes are (not in order) Support & Future enhancements Community & general knowledge base (on the Internet) Comprehensive (i.e proven to parse a wide range of *.*ml pages) Performance Memory Footprint (runtime, not the code-base)

    Read the article

  • Adjust OSX System Audio Volume in Python

    - by Benson
    I would like to adjust the system audio volume in OSX from a python script. This question about implementing keyboard shortcuts tells me how to do it in applescript, but I'd really like to do it from my python script without using os.system, popen, etc. Ideally I'd like to ramp up the volume slowly with some python code like this: set_volume(0) for i in range(50): set_volume(i*2) time.sleep(1)

    Read the article

  • Switch Statement in C#

    - by pm_2
    Does anyone know if it's possible to include a range in a switch statement (and if so, how)? For example: switch (x) { case 1: //do something break; case 2..8: //do something else break; default: break; } The compiler doesn't seem to like this kind of syntax - neither does it like: case <= 8:

    Read the article

< Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >