Search Results

Search found 16807 results on 673 pages for 'david given'.

Page 6/673 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • "TypeError: draw() takes exactly 1 non-keyword argument (3 given)"

    - by Amorack
    I wrote this code to open a window with Pyglet in Python... import pyglet from pyglet import window class Window(pyglet.window.Window): def __init__(self): super(Window, self).__init__() myLabel = pyglet.text.Label("Prototype") windowText = myLabel.draw(Window, "Hello World", font_name = "Times New Roman", font_size = 36, color = (193, 205, 193, 255)) def on_draw(self): self.clear() self.label.draw() if __name__ == '__main__': window = Window() pyglet.app.run() however every time I run it I get this error: TypeError: draw() takes exactly 1 non-keyword argument (3 given) AFAIK the "(3 given)" means the problem is with the font_size or color arguments but I'm not sure. Could someone explain what's wrong and help me make this work?

    Read the article

  • Rails and Searchlogic: finding products that matching all given product categories by using searchlo

    - by Roland
    I have a model Publication and a model Category in my Rails app. Both are connected with a has_and_belongs_to_many association. Now I would like to search publications that match one or more categories. If more than one category is given they have all assigned to the publication. I want to specify the categories in a multiple select_box. Publication.released.categories_id_is([1,2]) is not working because the categories are connected with OR. With Publication.categories_id_is_all([1,2]) the categories are connected with AND, but no result is given back. Any idea's on that? Am I mising the right point in the docs. Thanks for your very welcome help!

    Read the article

  • How to determine whether a dependency object implements a given dependency property (C# / WPF)

    - by Tim Coulter
    I am working with the classes in the System.Windows.Documents namespace, trying to write some generic code that will conditionally set the value of certain dependency properties, depending on whether these properties exist on a given class. For example, the following method assigns an arbitrary value to the Padding property of the passed FrameworkContentElement: void SetElementPadding(FrameworkContentElement element) { element.SetValue(Block.PaddingProperty, new Thickness(155d)); } However, not all concrete implementations of FrameworkContentElement have a Padding property (Paragraph does but Span does not) so I would expect the property assignment to succeed for types that implement this property and to be silently ignored for types that do not. But it seems that the above property assignment succeeds for instances of all derivatives of FrameworkContentElement, regardless of whether they implement the Padding property. I make this assumption because I have always been able to read back the assigned value. I assume there is some flaw in the way I am assigning property values. What should I do to ensure that a given dependency property assignment is ignored by classes that do not implement that property? Many thanks for your advice. Tim

    Read the article

  • BFS traversal of directed graph from a given node

    - by p1
    Hi, My understanding of basic BFS traversal for a graph is: BFS { Start from any node . Add it to que. Add it to visited array While(que is not empty) { remove head from queue. Print node; add all unvisited direct subchilds to que; mark them as visited } } However, if we have to traverse a DIRECTED graph from a given node and not all nodes are accessible from the given node [directly or indirectly] how do we use BFS for the same. Can you please explain in this graph as well: a= b = d = e = d a= c = d Here if the starting node is b , we never print a and c. Am I missing something in the algorithm. P.S: I used "HashMap adj = new HashMap();" to create the adjacencey list to store graph Any pointers are greatly appreciated. Thanks.

    Read the article

  • How get all calendar entries for a given using the Notes.Jar for Java

    - by vikramjb
    I am working on a simple java code to extract all calendar entries for a given date. I know it possible using Domingo but I would like to use only Notes.jar for this purpose. It is possible for me to create a session based on a given credentials and get the calendar object. I am looking to extract the current running notes session and use that session object to open the calendar view in the mail file and start playing with it. But I am not able to get it working. Anybody have any idea or links on this ?

    Read the article

  • SQL - Finding continuous entries of a given size.

    - by ByteMR
    I am working on a system for reserving seats. A user inputs how many seats they wish to reserve and the database will return a set of suggested seats that are not previously reserved that matches the number of seats being reserved. For instance if I had the table: SeatID | Reserved ----------------- 1 | false 2 | true 3 | false 4 | false 5 | false 6 | true 7 | true 8 | false 9 | false 10 | true And the user inputs that they wish to reserve 2 seats, I would expect the query to return that seats (3, 4), (4, 5), and (8, 9) are not reserved and match the given number of input seats. Seats are organized into sections and rows. Continuous seats must be in the same row. How would I go about structuring this query to work in such a way that it finds all available continuous seats that match the given input?

    Read the article

  • How to give an error when no options are given with optparse

    - by Acorn
    I'm try to work out how to use optparse, but I've come to a problem. My script (represented by this simplified example) takes a file, and does different things to it depending on options that are parsed to it. If no options are parsed nothing is done. It makes sense to me that because of this, an error should be given if no options are given by the user. I can't work out how to do this. Am I using options in the wrong way? If so, how should I be doing it instead? #!/usr/bin/python from optparse import OptionParser dict = {'name': foo, 'age': bar} parser = OptionParser() parser.add_option("-n", "--name", dest="name") parser.add_option("-a", "--age", dest="age") (options, args) = parser.parse_args() if options.name: dict['name'] = options.name if options.age: dict['age'] = options.age print dict #END

    Read the article

  • Calculate open timeslots given availability and existing appointments - by day

    - by Andre
    Overview: I have a table which stores a persons "availability" for a current day, e.g. Mon - 8:00am - 11:30am Mon - 1:30pm - 6:00pm A second table stores appointments that this person already has for the same day, e.g. Mon - 8:30am - 11:00am Mon - 2:30pm - 4pm Desired result: Doing calculationsI'd like to have the following result - e.g. "this person has availability on the given day": Mon - 8:00am - 8:30am Mon - 11:00am - 11:30am Mon - 1:30pm - 2:30pm Mon - 4:00pm - 6:00pm Any ideas on how to calculate the output given the two inputs (e.g. availability, existing appointments) would be greatly appreciated. Preferably I'd use javascript on the client to do the calculating as I would believe that doing it within the DB (I'm using MSSQL) would be slow for many records, persons, etc. Hope this is enough information to illustrate the problem at hand - Many thanks in advance.

    Read the article

  • Find a variable with a given value in VS2008

    - by Aaron
    I have an instance variable with several members, many of which have their own members and so on. Using the debugger and watch variables, I found a string variable with a specific value that I need by diving into this variable's members. However, after spending some time on other things and coming back to this, I am now unable to find where this value is located. When I have my application paused, is there a way to search the values of variables in the current context for a given value? To clarify, if I have the given structure: myVariable | |--aMember1 | |--subMember = "A value" | |--aMember2 |--subMember = "Another value" Is there a way (possibly using the watch list in VS debugger) to search myVariable for any member or submember with the value "A value", returning to me the path myVariable->aMember->subMember?

    Read the article

  • Return the Largest Span in a given Array -Core Java and Arrays Question

    - by Deepak
    Hi Stack People, Merry Christmas and hope you are in great Spirits,I have a Question in Java-Arrays as shown below.Im stuck up with this struggling to get it rite. Consider the leftmost and righmost appearances of some value in an array. We'll say that the "span" is the number of elements between the two inclusive. A single value has a span of 1. Write a **Java Function** that returns the largest span found in the given array. **Example: maxSpan({1, 2, 1, 1, 3}) ? 4,answer is 4 coz MaxSpan between 1 to 1 is 4 maxSpan({1, 4, 2, 1, 4, 1, 4}) ? 6,answer is 6 coz MaxSpan between 4 to 4 is 6 maxSpan({1, 4, 2, 1, 4, 4, 4}) ? 6,answer is 6 coz Maxspan between 4 to 4 is 6 which is greater than MaxSpan between 1 and 1 which is 4,Hence 64 answer is 6. I have the code which is not working,it includes all the Spans for a given element,im unable to find the MaxSpan for a given element. Please help me out. Results of the above Program are as shown below Expected This Run maxSpan({1, 2, 1, 1, 3}) ? 4 5 X maxSpan({1, 4, 2, 1, 4, 1, 4}) ? 6 8 X maxSpan({1, 4, 2, 1, 4, 4, 4}) ? 6 9 X maxSpan({3, 3, 3}) ? 3 5 X maxSpan({3, 9, 3}) ? 3 3 OK maxSpan({3, 9, 9}) ? 2 3 X maxSpan({3, 9}) ? 1 1 OK maxSpan({3, 3}) ? 2 3 X maxSpan({}) ? 0 1 X maxSpan({1}) ? 1 1 OK ::Code:: public int maxSpan(int[] nums) { int count=1;//keep an intial count of maxspan=1 int maxspan=0;//initialize maxspan=0 for(int i=0;i<nums.length;i++){ for(int j=i+1;j<nums.length;j++){ if(nums[i] == nums[j]){ //check to see if "i" index contents == "j" index contents count++; //increment count maxspan=count; //make maxspan as your final count int number = nums[i]; //number=actual number for maxspan } } } return maxspan+1; //return maxspan }

    Read the article

  • When is a Cocoa callback given controll?

    - by Kaspa
    Hi, I've been searching around the web for an answer to this one, but was unable to find an answer, on the other side I think it's something quite common thus there is a possibility I'm missing some keywords here. Anyhow, the problem is as follows: When is control given to a callback function in ObjC (iPhone)? Does it happen after control is given to a high up in the hierarchy class responsible for the runloop? Can it occur in the middle of another function call being executed? As an example, let's take the NSURLConnection, we don't know or can't predict when it's going to call didReceiveResponse or the other callback methods, can it be the case that didReceiveResponse get's called when I'm in the middle of another function? (highly doubt that but was unable to find information on callbacks wating for the end of the run loop) Cheers, Kaspa

    Read the article

  • How to skew/resize/distort an image given points within that image (iPhone)

    - by user544082
    I want to take an image in which there will be a quadrilateral, and skew or otherwise distort the entire image such that the object that was a quadrilateral is now a square or rectangle. I realize this will distort the image, and that is okay. I know how to skew or manipulate an image, but I can't conceptualize how this would be done given information regarding the coordinates of the four points that define the corners of a quadrilateral within the image itself. I can safely find those coordinates every time, so that part is a given. This is for an experimental iPhone app. Any help would be much appreciated.

    Read the article

  • Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in

    - by alundra00
    hi i am new to php and now i having problem with login Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in... Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in.... coding php: <?php include ("config/koneksi.php"); include ("config/library.php"); $pass = md5($_POST['password']); $login = mysql_query("SELECT * FROM user WHERE id_user='$_POST[username]' AND sesi='$pass'"); $found = mysql_num_rows($login); //error $r = mysql_fetch_array($login); //error if ($r){ session_start(); session_register("username"); session_register("sesi"); session_register("role"); $_SESSION[username] = $r[id_user]; $_SESSION[sesi] = $r[sesi]; $_SESSION[role]= $r[role]; header ('location:home.php'); }

    Read the article

  • How to do Grouping using JPA annotation with mapping given field

    - by hemal
    I am using JPA Annotation mapping with the table given below, but having problem that i am doing mapping on same table but on diffrent field given ProductImpl.java @Entity @Table(name = "Product") public class ProductImpl extends SimpleTagGroup implements Product { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id = -1; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinTable(name = "ProductTagMapping", joinColumns =@JoinColumn(name = "productId"), inverseJoinColumns =@JoinColumn(name = "tagId")) private List<SimpleTag> tags; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinTable(name = "ProductTagMapping", joinColumns =@JoinColumn(name = "productId"), inverseJoinColumns =@JoinColumn(name = "tagId")) private List<SimpleTag> licenses; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JoinTable(name = "ProductTagMapping", joinColumns =@JoinColumn(name = "productId"), inverseJoinColumns =@JoinColumn(name = "tagId")) private List<SimpleTag> os; I want to get values like windows and linux in os , GPLv2 and GPLv3 in licenses ,so we are using TagGroup table . but here i got all tagValues in each of the os,licenses and tag fileds,so how could i do group by or some other things with JPA. and ProductTagMapping is the mapping table between Tag and TagGroup TagGroup Table ID TAGGROUPNAME 1 PRODUCTTYPE 2 LICENSE 3 TAGS 4 OS SimpleTag ID TAGVALUE 1 Application 2 Framework 3 Apache2 4 GPLv2 5 GPLv3 6 learning 7 Linux 8 Windows 9 mature

    Read the article

  • C-macro: set a register field defined by a bit-mask to a given value

    - by geschema
    I've got 32-bit registers with field defined as bit-masks, e.g. #define BM_TEST_FIELD 0x000F0000 I need a macro that allows me to set a field (defined by its bit-mask) of a register (defined by its address) to a given value. Here's what I came up with: #include <stdio.h> #include <assert.h> typedef unsigned int u32; /* * Set a given field defined by a bit-mask MASK of a 32-bit register at address * ADDR to a value VALUE. */ #define SET_REGISTER_FIELD(ADDR, MASK, VALUE) \ { \ u32 mask=(MASK); u32 value=(VALUE); \ u32 mem_reg = *(volatile u32*)(ADDR); /* Get current register value */ \ assert((MASK) != 0); /* Null masks are not supported */ \ while(0 == (mask & 0x01)) /* Shift the value to the left until */ \ { /* it aligns with the bit field */ \ mask = mask >> 1; value = value << 1; \ } \ mem_reg &= ~(MASK); /* Clear previous register field value */ \ mem_reg |= value; /* Update register field with new value */ \ *(volatile u32*)(ADDR) = mem_reg; /* Update actual register */ \ } /* Test case */ #define BM_TEST_FIELD 0x000F0000 int main() { u32 reg = 0x12345678; printf("Register before: 0x%.8X\n", reg);/* should be 0x12345678 */ SET_REGISTER_FIELD(&reg, BM_TEST_FIELD, 0xA); printf("Register after: 0x%.8X\n", reg); /* should be 0x123A5678 */ return 0; } Is there a simpler way to do it?

    Read the article

  • Exception: "Given final block not properly padded" in Linux, but it works in Windows

    - by user1685364
    My application works in windows, but fails in Linux with Given final block not properly padded exception. Configuration: JDK Version: 1.6 Windows : version 7 Linux : CentOS 5.8 64bit My code is below: import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.Key; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.KeyGenerator; import javax.crypto.NoSuchPaddingException; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public class SecurityKey { private static Key key = null; private static String encode = "UTF-8"; private static String cipherKey = "DES/ECB/PKCS5Padding"; static { try { KeyGenerator generator = KeyGenerator.getInstance("DES"); String seedStr = "test"; generator.init(new SecureRandom(seedStr.getBytes())); key = generator.generateKey(); } catch(Exception e) { } } // SecurityKey.decodeKey("password") public static String decodeKey(String str) throws Exception { if(str == null) return str; Cipher cipher = null; byte[] raw = null; BASE64Decoder decoder = new BASE64Decoder(); String result = null; cipher = Cipher.getInstance(cipherKey); cipher.init(Cipher.DECRYPT_MODE, key); raw = decoder.decodeBuffer(str); byte[] stringBytes = null; stringBytes = cipher.doFinal(raw); // Exception!!!! result = new String(stringBytes, encode); return result; } } At the line: ciper.doFilnal(raw); the following exception is thrown: javax.crypto.BadPaddingException: Given final block not properly padded How can I fix this issue?

    Read the article

  • Permutations distinct under given symmetry (Mathematica 8 group theory)

    - by Yaroslav Bulatov
    Given a list of integers like {2,1,1,0} I'd like to list all permutations of that list that are not equivalent under given group. For instance, using symmetry of the square, the result would be {{2, 1, 1, 0}, {2, 1, 0, 1}}. Approach below (Mathematica 8) generates all permutations, then weeds out the equivalent ones. I can't use it because I can't afford to generate all permutations, is there a more efficient way? Update: actually, the bottleneck is in DeleteCases. The following list {2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0} has about a million permutations and takes 0.1 seconds to compute. Apparently there are supposed to be 1292 orderings after removing symmetries, but my approach doesn't finish in 10 minutes removeEquivalent[{}] := {}; removeEquivalent[list_] := ( Sow[First[list]]; equivalents = Permute[First[list], #] & /@ GroupElements[group]; DeleteCases[list, Alternatives @@ equivalents] ); nonequivalentPermutations[list_] := ( reaped = Reap@FixedPoint[removeEquivalent, Permutations@list]; reaped[[2, 1]] ); group = DihedralGroup[4]; nonequivalentPermutations[{2, 1, 1, 0}]

    Read the article

  • Generating all possible subsets of a given QuerySet in Django

    - by Glen
    This is just an example, but given the following model: class Foo(models.model): bar = models.IntegerField() def __str__(self): return str(self.bar) def __unicode__(self): return str(self.bar) And the following QuerySet object: foobar = Foo.objects.filter(bar__lt=20).distinct() (meaning, a set of unique Foo models with bar <= 20), how can I generate all possible subsets of foobar? Ideally, I'd like to further limit the subsets so that, for each subset x of foobar, the sum of all f.bar in x (where f is a model of type Foo) is between some maximum and minimum value. So, for example, given the following instance of foobar: >> print foobar [<Foo: 5>, <Foo: 10>, <Foo: 15>] And min=5, max=25, I'd like to build an object (preferably a QuerySet, but possibly a list) that looks like this: [[<Foo: 5>], [<Foo: 10>], [<Foo: 15>], [<Foo: 5>, <Foo: 10>], [<Foo: 5>, <Foo: 15>], [<Foo: 10>, <Foo: 15>]] I've experimented with itertools but it doesn't seem particularly well-suited to my needs. I think this could be accomplished with a complex QuerySet but I'm not sure how to start.

    Read the article

  • 3D coordinate of 2D point given camera and view plane

    - by Myx
    I wish to generate rays from the camera through the viewing plane. In order to do this, I need my camera position ("eye"), the up, right, and towards vectors (where towards is the vector from the camera in the direction of the object that the camera is looking at) and P, the point on the viewing plane. Once I have these, the ray that's generated is: ray = camera_eye + t*(P-camera_eye); where t is the distance along the ray (assume t = 1 for now). My question is, how do I obtain the 3D coordinates of point P given that it is located at position (i,j) on the viewing plane? Assume that the upper left and lower right corners of the viewing plane are given. NOTE: The viewing plane is not actually a plane in the sense that it doesn't extend infinitely in all directions. Rather, one may think of this plane as a widthxheight image. In the x direction, the range is 0--width and in the y direction the range is 0--height. I wish to find the 3D coordinate of the (i,j)th element, 0

    Read the article

  • No resource found that matches given name in main.xml

    - by AndroidBeginner
    This is really starting to drive me crazy. <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id+/textview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello"/> Produces the following error message: "Error: no resource found that matches the given name (at 'id' with value '@id+/textview'). This is copy and pasted from the Android hello world example.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >