Search Results

Search found 354 results on 15 pages for 'circles'.

Page 13/15 | < Previous Page | 9 10 11 12 13 14 15  | Next Page >

  • Show users a list of unique items on Java Google App Engine

    - by James
    I've been going round in circles with what must be a very simple challenge but I want to do it the most efficient way from the start. So, I've watched Brett Slatkin's Google IO videos (2008 & 2009) about building scalable apps including http://www.youtube.com/watch?v=AgaL6NGpkB8 and read the docs but as a n00b, I'm still not sure. I'm trying to build an app on GAEJ similar to the original 'hotornot' where a user is presented with an item which they rate. Once they rate it, they are presented with another one which they haven't seen before. My question is this; is it most efficient to do a query up front to grab x items (say 100) and put them in a list (stored in memcache?) or is it better to simply make a query for a new item after each rating. To keep track of the items a user has seen, I'm planning to keep those items' keys in a list property of the user's entity. Does that sound sensible? I've really got myself confused about this so any help would be much appreciated.

    Read the article

  • PHP Overloading, singleton instance

    - by jamalali81
    I've sort of created my own MVC framework and am curious as to how other frameworks can send properties from the "controller" to the "view". Zend does something along the lines of $this->view->name = 'value'; My code is: file: services_hosting.php class services_hosting extends controller { function __construct($sMvcName) { parent::__construct($sMvcName); $this->setViewSettings(); } public function setViewSettings() { $p = new property; $p->banner = '/path/to/banners/home.jpg'; } } file: controller.php class controller { public $sMvcName = "home"; function __construct($sMvcName) { if ($sMvcName) { $this->sMvcName = $sMvcName; } include('path/to/views/view.phtml'); } public function renderContent() { include('path/to/views/'.$this->sMvcName.'.phtml'); } } file: property.php class property { private $data = array(); protected static $_instance = null; public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } public function __set($name, $value) { $this->data[$name] = $value; } public function __get($name) { if (array_key_exists($name, $this->data)) { return $this->data[$name]; } } public function __isset($name) { return isset($this->data[$name]); } public function __unset($name) { unset($this->data[$name]); } } In my services_hosting.phtml "view" file I have: <img src="<?php echo $this->p->banner ?>" /> This just does not work. Am I doing something fundamentally wrong or is my logic incorrect? I seem to be going round in circles at the moment. Any help would be very much appreciated.

    Read the article

  • Do ORMs normally allow circular relations? If so, how would they handle it?

    - by SeanJA
    I was hacking around trying to make a basic orm that has support for the one => one and one => many relationships. I think I succeeded somewhat, but I am curious about how to handle circular relationships. Say you had something like this: user::hasOne('car'); car::hasMany('wheels'); car::property('type'); wheel::hasOne('car'); You could then do this (theoretically): $u = new user(); echo $u->car->wheels[0]->car->wheels[1]->car->wheels[2]->car->wheels[3]->type; #=> "monster truck" Now, I am not sure why you would want to do this. It seems like it wastes a whole pile of memory and time just to get to something that could have been done in a much shorter way. In my small ORM, I now have 4 copies of the wheel class, and 4 copies of the car class in memory, which causes a problem if I update one of them and save it back to the database, the rest get out of date, and could overwrite the changes that were already made. How do other ORMs handle circular references? Do they even allow it? Do they go back up the tree and create a pointer to one of the parents? DO they let the coder shoot themselves in the foot if they are silly enough to go around in circles?

    Read the article

  • JSF: Showing/Calling a dialog programatically

    - by Sway
    has anybody an idea to show/call a dialog programatically and add this to stage(actual browser window) ?! I am running in circles and cannot find a solution :/ More background what I want to do: I want to trigger a database update every 2 hours. This I have done with a TimerTask... This works fine for me, the Timertask gets all the data I want from the database... Before this TimerTask is triggered I want to "lock" the screen for some seconds that no user(session scoped) can access the database(this I also know how this will work) ... My problem is that I don't know/ cannot find a way/ i am to stupid to call a dialog programatically ... Any tips, hints would be very cool :) Thanks a lot ! UPDATE: I want to set this primefaces dialog: Dialog dialog = new Dialog(); dialog.setAppendToBody(true); dialog.setModal(true); dialog.setVisible(true); dialog.setWidgetVar("generatedDialog"); dialog.setId("fancyDialog"); dialog.setClosable(false); dialog.setHeader("Getting latest information from the database"); dialog.setDynamic(true); dialog.setResizable(false); dialog.setDraggable(false); How can I do that ? :/ How do I display it to my browser ? :o Regards

    Read the article

  • How to specify MQ channel table location for .net web application using web.config

    - by Matt
    I've been going around in circles for a while on this one now. I'm trying to connect to a distributed queue manager using a supplied channel table file. I can get this to work if I specify the environmental variable MQCHLLIB and MQCHLTAB on my server. However the IBM documentation states that the .net config file can override these variables. Here is what I have placed in my web.config file: ... <configSections> <section name="CHANNELS" type="System.Configuration.NameValueSectionHandler" /> </configSections> <CHANNELS> <add key="ChannelDefinitionDirectory" value="C:\temp"></add> <add key="ChannelDefinitionFile" value="DSM_MOM_TEST.tab"></add> </CHANNELS> ... And here is the code that is executing: Hashtable properties = new Hashtable(); //Add managed connection type to parameters. const String connectionType = MQC.TRANSPORT_MQSERIES_CLIENT; properties.Add(MQC.TRANSPORT_PROPERTY, connectionType); return new MQQueueManager(queueManagerName, properties); queueManagerName is set to the generic queue manager "*Q101T". However this isn't working and I get an error returned: 2058 MQRC_Q_MGR_NAME_ERROR I've been unable to find any more documentation on how to get this to work other than the environmental variables and the standard mqclient.ini should be overriden by the channels stanza in the web.config. Is there something that I've missed in the code? Any tips would be greatly appreciated.

    Read the article

  • C++ design related question

    - by Kotti
    Hi! Here is the question's plot: suppose I have some abstract classes for objects, let's call it Object. It's definition would include 2D position and dimensions. Let it also have some virtual void Render(Backend& backend) const = 0 method used for rendering. Now I specialize my inheritance tree and add Rectangle and Ellipse class. Guess they won't have their own properties, but they will have their own virtual void Render method. Let's say I implemented these methods, so that Render for Rectangle actually draws some rectangle, and the same for ellipse. Now, I add some object called Plane, which is defined as class Plane : public Rectangle and has a private member of std::vector<Object*> plane_objects; Right after that I add a method to add some object to my plane. And here comes the question. If I design this method as void AddObject(Object& object) I would face trouble like I won't be able to call virtual functions, because I would have to do something like plane_objects.push_back(new Object(object)); and this should be push_back(new Rectangle(object)) for rectangles and new Circle(...) for circles. If I implement this method as void AddObject(Object* object), it looks good, but then somewhere else this means making call like plane.AddObject(new Rectangle(params)); and this is generally a mess because then it's not clear which part of my program should free the allocated memory. ["when destroying the plane? why? are we sure that calls to AddObject were only done as AddObject(new something).] I guess the problems caused by using the second approach could be solved using smart pointers, but I am sure there have to be something better. Any ideas?

    Read the article

  • How can I correctly calculate the direction for a moving object?

    - by Jakub Hampl
    I'm solving the following problem: I have an object and I know its position now and its position 300ms ago. I assume the object is moving. I have a point to which I want the object to get. What I need is to get the angle from my current object to the destination point in such a format that I know whether to turn left or right. The idea is to assume the current angle from the last known position and the current position. I'm trying to solve this in MATLAB. I've tried using several variations with atan2 but either I get the wrong angle in some situations (like when my object is going in circles) or I get the wrong angle in all situations. Examples of code that screws up: a = new - old; b = dest - new; alpha = atan2(a(2) - b(2), a(1) - b(1); where new is the current position (eg. x = 40; y = 60; new = [x y];), old is the 300ms old position and dest is the destination point. Edit Here's a picture to demonstrate the problem with a few examples: In the above image there are a few points plotted and annotated. The black line indicates our estimated current facing of the object. If the destination point is dest1 I would expect an angle of about 88°. If the destination point is dest2 I would expect an angle of about 110°. If the destination point is dest3 I would expect an angle of about -80°.

    Read the article

  • How to refresh/redraw the screen (not the program window)

    - by mohrphium
    I'm having a bit of a hard time figuring out, how to remove a drawn ellipse after it has been drawn somewhere else. I need a circle to follow my mouse all the time and this is all the program should do. I get the mousepositions and draw my circle but how can I remove the last one? #include <Windows.h> #include <iostream> void drawRect(int a1, int a2){ HDC screenDC = ::GetDC(0); //Draw circle at mouse position ::Ellipse(screenDC, a1, a2+5, a1+9, a2+14); ::ReleaseDC(0, screenDC); //::InvalidateRect(0, NULL, TRUE); //<- I tried that but then everything flickers //Also, the refresh rate is not fast enough... still some circles left } int main(void) { int a1; int a2; bool exit=false; while (exit!=true) { POINT cursorPos; GetCursorPos(&cursorPos); float x = 0; x = cursorPos.x; float y = 0; y = cursorPos.y; a1=(int)cursorPos.x; a2=(int)cursorPos.y; drawRect(a1, a2); } } I am working with graphics and all that stuff for the first time. Im kinda stuck here... once again. Thanks.

    Read the article

  • Why would paperclip not assign an ID to my uploaded photos?

    - by Trip
    I just deployed to a cluster server, and my delayed_jobs recipe was overwritten in the process. I solved that, delayed_jobs is up and running but can't find the ID of images that are uploaded. The images are saved correctly : Processing PhotosController#create (for 173.161.167.41 at 2010-06-01 05:09:14) [POST] Parameters: {"Filename"="1.jpg", "gallery_id"="1298", "action"="create", "amp"=nil, "authenticity_token"="qmbnpwFY8a5E3YtS/4fMWF/Z8evCE4hMxqKVJw0I7Ek=", "Upload"="Submit Query", "controller"="photos", "organization_id"="470", "_hq_channel_session"="BAh7CSIYdXNlcl9jcmVkZW50aWFsc19pZGkHIhV1c2VyX2NyZWRlbnRpYWxzIgGAOGRlZDc0NGJlOWU3NTNlNDFlYmVlMDdjMzIzYjA1ZjQxNGE5ZDY4YjNmYjFmNjNkMDQ2OWY2ZDQyOTljZDhiMDFlNmRkMDljNThmMzBmOWJhMTIwNDhkMDI5MTMxYmU5MDczYjIxZmI4YmQxMDVlMTBmNjZmOWFhODE1ZTBjMGM6EF9jc3JmX3Rva2VuIjFxbWJucHdGWThhNUUzWXRTLzRmTVdGL1o4ZXZDRTRoTXhxS1ZKdzBJN0VrPToPc2Vzc2lvbl9pZCIlMjAwMDQ3ZDQ3ZWUyZTgzODIxYzdjOGI3OTdmZGJiMDM=--ac6aa580262938bf5a4d6b9a740722b680eb5d48", "Filedata"=#} [paperclip] Saving attachments. [paperclip] saving /data/HQ_Channel/releases/20100530153454/public/system/photos/9253/original/1.jpg [paperclip] Saving attachments. [paperclip] Saving attachments. Completed in 127ms (View: 2, DB: 91) | 200 OK [http://invent.hqchannel.com/organizations/470/media/galleries/1298/photos?_hq_channel_session=BAh7CSIYdXNlcl9jcmVkZW50aWFsc19pZGkHIhV1c2VyX2NyZWRlbnRpYWxzIgGAOGRlZDc0NGJlOWU3NTNlNDFlYmVlMDdjMzIzYjA1ZjQxNGE5ZDY4YjNmYjFmNjNkMDQ2OWY2ZDQyOTljZDhiMDFlNmRkMDljNThmMzBmOWJhMTIwNDhkMDI5MTMxYmU5MDczYjIxZmI4YmQxMDVlMTBmNjZmOWFhODE1ZTBjMGM6EF9jc3JmX3Rva2VuIjFxbWJucHdGWThhNUUzWXRTLzRmTVdGL1o4ZXZDRTRoTXhxS1ZKdzBJN0VrPToPc2Vzc2lvbl9pZCIlMjAwMDQ3ZDQ3ZWUyZTgzODIxYzdjOGI3OTdmZGJiMDM%3D--ac6aa580262938bf5a4d6b9a740722b680eb5d48&authenticity_token=qmbnpwFY8a5E3YtS%2F4fMWF%2FZ8evCE4hMxqKVJw0I7Ek%3D] And then delayed_jobs keeps spinning around in circles on this one : 2010-06-01T05:09:02-0700: * [Worker(delayed_job host:ip-10-251-197-159 pid:19994)] acquired lock on PhotoJob 2010-06-01T05:09:02-0700: * [JOB] delayed_job host:ip-10-251-197-159 pid:19994 failed with ActiveRecord::RecordNotFound: Couldn't find Photo with ID=9247 - 0 failed attempts 2010-06-01T05:09:02-0700: * [Worker(delayed_job host:ip-10-251-197-159 pid:19994)] acquired lock on PhotoJob 2010-06-01T05:09:02-0700: * [JOB] delayed_job host:ip-10-251-197-159 pid:19994 failed with ActiveRecord::RecordNotFound: Couldn't find Photo with ID=9245 - 0 failed attempts 2010-06-01T05:09:02-0700: * [Worker(delayed_job host:ip-10-251-197-159 pid:19994)] acquired lock on PhotoJob So what I get is that the photos are not being assigned ID's by paperclip. Anyone know where I could poke and pry from here? UPDATE: I created a clone application on a single server. And there are no problems. The images on the cluster do show up (occassionally). If I keep clicking on the folders that lead to photos, it will 50% of the time return a 404 with it not being able to find the photo, and the other half it will present the photo. So the problem has got to be with the server interaction between the ActiveRecord through multiple servers.

    Read the article

  • Circle to move when mouse clicked Java

    - by Myt
    So I am really new to Java and I need a circle to move around JFrame when it's clicked, but the circle has to get random cordinates. So far this code generates a new circle every time it's clicked, but all the other circles stay there aswell, but I only need one circle to move around the frame. So maybe someone can help me a little :) public class test2 extends JFrame implements MouseListener { int height, width; public test2() { this.setTitle("Click"); this.setSize(400,400); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); addMouseListener(this); width = getSize().width; height = getSize().height; } public void paint (Graphics g) { setBackground (Color.red); g.setColor(Color.yellow); int a, b; a = -50 + (int)(Math.random()*(width+40)); b = (int)(Math.random()*(height+20)); g.fillOval(a, b, 130, 110); } public void mouseClicked(MouseEvent e) { int a, b; a = -50 + (int)(Math.random()*(width+40)); b = (int)(Math.random()*(height+20)); repaint(); } public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mousePressed(MouseEvent e){} public static void main(String arg[]){ new test2(); } }

    Read the article

  • How to add/get Sprite to/from UIComponent

    - by user955399
    How to add Sprite to BorderContainer (UIComponent)? var sprite:Sprite = new Sprite(); sprite.graphics.lineStyle(10,0); sprite.graphics.moveTo(40,40); sprite.graphics.lineTo(60,60); mybordercontainer.addChild(sprite); //mybrodercontainer is id of BorderContainer created in mxml This code doesnt work. I cant see Sprite on my BorderContainer. How can I add Sprites on UIComponents, so I can see them? I tried this and it kinda worked: var comp:UIComponent = new UIComponent(); comp.addChild(sprite); myborderconteiner.addElement(comp); But I dont think, that this is a right way to add Sprites to UIComponents. Is there another method to do that? Second problem: When I have few Sprites added to my UIComponent (lines/circles/images or others) how can I receive an object Sprite from that UIComponent, which is containing all Sprites added before to that UIComponent? I need to create Bitmap from that Sprite and do some things. I hope I make myself clear

    Read the article

  • JTable cells not rendering shapes properly

    - by Andrew
    I'm trying to render my JTable cells with a subclassed JPanel and the cells should appear as coloured rectangles with a circle drawn on them. When the table displays initially everything looks OK but then when a dialog or something is displayed over the cells when it is removed the cells that have been covered do not rendered properly and the circles are broken up etc. I then have to move the scroll bar or extend the window to get them to redraw properly. The paintComponent method of the component I'm using to render the cells is below: protected void paintComponent(Graphics g) { setOpaque(true); super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; GradientPaint gradientPaint = new GradientPaint(new Point2D.Double(0, 0), Color.WHITE, new Point2D.Double(0, getHeight()), paintRatingColour); g2d.setPaint(gradientPaint); g2d.fillRect(0, 0, getWidth(), getHeight()); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); Rectangle clipBounds = g2d.getClipBounds(); int x = new Double(clipBounds.getWidth()).intValue() - 15; int y = (new Double(clipBounds.getHeight()).intValue() / 2) - 6; if (level != null) { g2d.setColor(iconColour); g2d.drawOval(x, y, width, height); g2d.fillOval(x, y, width, height); } }

    Read the article

  • Fast path cache generation for a connected node graph

    - by Sukasa
    I'm trying to get a faster pathfinding mechanism in place in a game I'm working on for a connected node graph. The nodes are classed into two types, "Networks" and "Routers." In this picture, the blue circles represent routers and the grey rectangles networks. Each network keeps a list of which routers it is connected to, and vice-versa. Routers cannot connect directly to other routers, and networks cannot connect directly to other networks. Networks list which routers they're connected to Routers do the same I need to get an algorithm that will map out a path, measured in the number of networks crossed, for each possible source and destination network excluding paths where the source and destination are the same network. I have one right now, however it is unusably slow, taking about two seconds to map the paths, which becomes incredibly noticeable for all connected players. The current algorithm is a depth-first brute-force search (It was thrown together in about an hour to just get the path caching working) which returns an array of networks in the order they are traversed, which explains why it's so slow. Are there any algorithms that are more efficient? As a side note, while these example graphs have four networks, the in-practice graphs have 55 networks and about 20 routers in use. Paths which are not possible also can occur, and as well at any time the network/router graph topography can change, requiring the path cache to be rebuilt. What approach/algorithm would likely provide the best results for this type of a graph?

    Read the article

  • Rails creating users, roles, and projects

    - by Bobby
    I am still fairly new to rails and activerecord, so please excuse any oversights. I have 3 models that I'm trying to tie together (and a 4th to actually do the tying) to create a permission scheme using user-defined roles. class User < ActiveRecord::Base has_many :user_projects has_many :projects, :through => :user_projects has_many :project_roles, :through => :user_projects end class Project < ActiveRecord::Base has_many :user_projects has_many :users, :through => :user_projects has_many :project_roles end class ProjectRole < ActiveRecord::Base belongs_to :projects belongs_to :user_projects end class UserProject < ActiveRecord::Base belongs_to :user belongs_to :project has_one :project_role attr_accessible :project_role_id end The project_roles model contains a user-defined role name, and booleans that define whether the given role has permissions for a specific task. I'm looking for an elegant solution to reference that from anywhere within the project piece of my application easily. I do already have a role system implemented for the entire application. What I'm really looking for though is that the users will be able to manage their own roles on a per-project basis. Every project gets setup with an immutable default admin role, and the project creator gets added upon project creation. Since the users are creating the roles, I would like to be able to pull a list of role names from the project and user models through association (for display purposes), but for testing access, I would like to simply reference them by what they have access to without having reference them by name. Perhaps something like this? def has_perm?(permission, user) # The permission that I'm testing user.current_project.project_roles.each do |role| if role.send(permission) # Not sure that's right... do_stuff end end end I think I'm in over my head on this one because I keep running in circles on how I can best implement this.

    Read the article

  • Compiling scalafx for Java 7u7 (that contains JavaFX 2.2) on OS X

    - by akauppi
    The compilation instructions of scalafx says to do: export JAVAFX_HOME=/Path/To/javafx-sdk2.1.0-beta sbt clean compile package make-pom package-src However, with the new packaging of JavaFX as part of the Java JDK itself (i.e. 7u7 for OS X) there no longer seems to be such a 'javafx-sdkx.x.x' folder. The Oracle docs say that JavaFX JDK is placed alongside the main Java JDK (in same folders). So I do: $ export JAVAFX_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk $ sbt clean [warn] Using project/plugins/ (/Users/asko/Sources/scalafx/project/plugins) for plugin configuration is deprecated. [warn] Put .sbt plugin definitions directly in project/, [warn] .scala plugin definitions in project/project/, [warn] and remove the project/plugins/ directory. [info] Loading project definition from /Users/asko/Sources/scalafx/project/plugins/project [info] Loading project definition from /Users/asko/Sources/scalafx/project/plugins [error] java.lang.NullPointerException [error] Use 'last' for the full log. Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? Am I doing something wrong or is scalafx not yet compatible with the latest Java release (7u7, JavaFX 2.2). What can I do? http://code.google.com/p/scalafx/ Addendum ..and finally (following Igor's solution below) sbt run launches the colorful circles demo easily (well, if one has a supported GPU that is). Oracle claims that "JavaFX supports graphic hardware acceleration on any Mac OS X system that is Lion or later" but I am inclined to think the NVidia powered Mac Mini I'm using does software rendering. A recent MacBook Air (core i7) is a complete different beast! :)

    Read the article

  • C++: Vector of objects vs. vector of pointers to new objects?

    - by metamemetics
    Hello, I am seeking to improve my C++ skills by writing a sample software renderer. It takes objects consisting of points in a 3d space and maps them to a 2d viewport and draws circles of varying size for each point in view. Which is better: class World{ vector<ObjectBaseClass> object_list; public: void generate(){ object_list.clear(); object_list.push_back(DerivedClass1()); object_list.push_back(DerivedClass2()); or... class World{ vector<ObjectBaseClass*> object_list; public: void generate(){ object_list.clear(); object_list.push_back(new DerivedClass1()); object_list.push_back(new DerivedClass2()); ?? Would be using pointers in the 2nd example to create new objects defeat the point of using vectors, because vectors automatically call the DerivedClass destructors in the first example but not in the 2nd? Are pointers to new objects necessary when using vectors because they handle memory management themselves as long as you use their access methods? Now let's say I have another method in world: void drawfrom(Viewport& view){ for (unsigned int i=0;i<object_list.size();++i){ object_list.at(i).draw(view); } } When called this will run the draw method for every object in the world list. Let's say I want derived classes to be able to have their own versions of draw(). Would the list need to be of pointers then in order to use the method selector (-) ?

    Read the article

  • Search for values in nested array

    - by dardub
    I have an array as follows array(2) { ["operator"] => array(2) { ["qty"] => int(2) ["id"] => int(251) } ["accessory209"] => array(2) { ["qty"] => int(1) ["id"] => int(209) } ["accessory211"] => array(2) { ["qty"] => int(1) ["id"] => int(211) } } I'm trying to find a way to verify an id value exists within the array and return bool. I'm trying to figure out a quick way that doesn't require creating a loop. Using the in_array function did not work, and I also read that it is quite slow. In the php manual someone recommended using flip_array() and then isset(), but I can't get it to work for a 2-d array. doing something like if($array['accessory']['id'] == 211) would also work for me, but I need to match all keys containing accessory -- not sure how to do that Anyways, I'm spinning in circles, and could use some help. This seems like it should be easy. Thanks.

    Read the article

  • Python & Pygame: Updating all elements in a list under a loop during iteration

    - by Unit978
    i am working on a program in Python and using Pygame. this is what the basic code looks like: while 1: screen.blit(background, (0,0)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() if event.type == KEYDOWN and event.key == K_c: circle_create = True circle_list.append(Circle()) if event.type == MOUSEBUTTONDOWN and circle_create == True: if clicks == 0: circle_list[i].center() clicks += 1 if event.type == MOUSEMOTION and clicks == 1 and circle_create == True: circle_list[i].stretch() these if statements are under the while loop not the for loop since they dont require input from the user if circle_create == True: circle_list[i].draw_circle() if clicks == 2: clicks = 0 i += 1 circle_create = False pygame.display.update() what i want to do is have the object's function of draw_circle() to be constantly updated by the loop so that the drawn circle is shown for all objects in the list, but since the list is iterated it updates the new object added and the objects already appended are not updated. The program, works, it draws the circles upon user input but the update problem is the only issue i need to solve. Is there any possible way to have all elements in the list of objects being updated by the while loop? i have tried for many days and i have not been able to find a good solution. any ideas are appreciated. Thanks

    Read the article

  • Varnish configuration to only cache for non-logged in users

    - by davidsmalley
    I have a Ruby on Rails application fronted by varnish+nginx. As most of the sites content is static unless you are a logged in user, I want to cache the site heavily with varnish when a user is logged out but only to cache static assets when they are logged in. When a user is logged in they will have the cookie 'user_credentials' present in their Cookie: header, in addition I need to skip caching on /login and /sessions in order that a user can get their 'user_credentials' cookie in the first place. Rails by default does not set a cache friendly Cache-control header, but my application sets a "public,s-max-age=60" header when a user is not logged in. Nginx is set to return 'far future' expires headers for all static assets. The configuration I have at the moment is totally bypassing the cache for everything when logged in, including static assets — and is returning cache MISS for everything when logged out. I've spent hours going around in circles and here is my current default.vcl director rails_director round-robin { { .backend = { .host = "xxx.xxx.xxx.xxx"; .port = "http"; .probe = { .url = "/lbcheck/lbuptest"; .timeout = 0.3 s; .window = 8; .threshold = 3; } } } } sub vcl_recv { if (req.url ~ "^/login") { pipe; } if (req.url ~ "^/sessions") { pipe; } # The regex used here matches the standard rails cache buster urls # e.g. /images/an-image.png?1234567 if (req.url ~ "\.(css|js|jpg|jpeg|gif|ico|png)\??\d*$") { unset req.http.cookie; lookup; } else { if (req.http.cookie ~ "user_credentials") { pipe; } } # Only cache GET and HEAD requests if (req.request != "GET" && req.request != "HEAD") { pipe; } } sub vcl_fetch { if (req.url ~ "^/login") { pass; } if (req.url ~ "^/sessions") { pass; } if (req.http.cookie ~ "user_credentials") { pass; } else { unset req.http.Set-Cookie; } # cache CSS and JS files if (req.url ~ "\.(css|js|jpg|jpeg|gif|ico|png)\??\d*$") { unset req.http.Set-Cookie; } if (obj.status >=400 && obj.status <500) { error 404 "File not found"; } if (obj.status >=500 && obj.status <600) { error 503 "File is Temporarily Unavailable"; } } sub vcl_deliver { if (obj.hits > 0) { set resp.http.X-Cache = "HIT"; } else { set resp.http.X-Cache = "MISS"; } }

    Read the article

  • How to enable caching on Apache / Ubuntu Linux?

    - by Jim Mischel
    I have a large (several megabytes) XML file that's updated rather frequently (every 10 minutes or less) and gets a lot of traffic. I'd like to implement some caching to reduce bandwidth and server load. Looking at the Apache documents, I see a dizzying array of configuration options that involve various combinations of mod_expires, mod_headers, and mod_cache (and variants). I end up running in circles and the results aren't what I expect. I'm comfortable editing the various configuration files if I have some idea what I'm supposed to change. But at the moment I'm poking around in the dark and that's never a comfortable feeling. So, perhaps if I describe what I want, somebody here can take me by the hand and say, "This is what you need to do." Periodically, this file, call it "stuff.xml" is updated and a new version copied to the directory. The external url would be, for example, http://example.com/stuff.xml. Understand, this part works. Whenever I request the file, I get the expected result. But the file is big and I want to save bandwidth, so first I'd like to implement conditional GET semantics with the If-Modified-Since header. How do I do this? I've enabled mod_headers and mod_expired and added the <FilesMatching> section in my httpd.conf as recommended in countless examples I've seen online, but that didn't change the behavior when made a conditional GET request. I always get a status 200 with the entire document. So how the heck do I implement this? That'll cut down on neeless transfers. I'd also like to limit the amount of data transferred. Seeing as this is XML, gzipping it should save me 50% or more. My next step would be to somehow gzip the file and, if it's not too difficult, store it in memory. That'll cut down on per-access data transfer, and also reduce disk transfers. So how do I implement this type of caching? Thanks in advance.

    Read the article

  • GRUB is not Booting Correctly

    - by msknapp
    I have a PC with three hard disks. Windows 7 is installed on the first, Ubuntu 14.04 is installed on the third. After I re-booted, it went straight to Windows 7. So I tried explicitly telling my PC to boot using the third hard disk, but that just takes me to the grub rescue prompt. I followed Scott Severence's instructions here to try and recover. Essentially, I updated grub, reinstalled grub, and then updated it again. After re-booting, absolutely nothing had changed. So instead I tried using the boot-repair tool. In the past it had failed for me, saying that I had programs running and it could not unmount drives, when I was running nothing. I never figured out how to solve that problem, but it went away when I bought another hard drive and used that for my Ubuntu installation, I don't know why. In any case, I ran the boot-repair tool and this time it said it was successful. First time for everything right? I re-booted, only to be taken straight to the grub rescue prompt. So I changed my BIOS settings to use the third hard disk for boot start up. That is the same hard drive where I have Ubuntu and grub installed, and the same one that the grub-repair tool told me to use. It still took me straight to the grub rescue prompt. So I went from not being able to boot Ubuntu, to not being able to boot either OS installed on my system. Thanks boot-repair! Boot repair gave me this URL for future troubleshooting: http://paste.ubuntu.com/8131669 When I try to boot from the third hard disk, this is my console: Loading Operating System ... error: attempt to read or write outside of disk 'hd0'. Entering rescue mode... grub rescue> grub rescue> set cmdpath=(hd0) prefix=(hd0,gpt2)/boot/grub root=hd0,gpt2 grub rescue> ls (hd0) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (hd1) (hd2) (hd2,gpt2) (hd2,gpt1) (hd3) Those values look correct to me. I have also experimented with changing some of those values, but 'insmod normal' always throws the same error. Somebody please tell me how to fix this. I have tried everything, reinstalling grub, and running boot-repair. =========================== Update: I think the problem might be that the ubuntu installer did not partition my hard disk correctly. I booted from live USB and then launched gparted and looked at how it partitioned things. This is what gparted says: Partition, File System, Size, Used, Unused, Flags /dev/sda1 (!), unknown, 1.00 MiB, ---, ---, bios_grub /dev/sda2, ext4, 2.71 TiB, 47.30 GiB, 2.67 TiB, /dev/sda3, linux-swap, 16.00 GiB, 0.00 B, 16.00 GiB, So that first line looks problematic. It is supposed to be the /boot partition. However, it was given only 1 MiB? I am assuming that MiB is actually supposed to mean megabyte, no idea why that 'i' is there. It also says the file system is unknown. I read the answer by andrew here, and he says he had to do a custom install, explicitly configuring the boot partition. So I think that maybe Ubuntu's installer has a bug in it, where it does not set up the boot partition correctly if you are not installing on the first hard disk in your computer. I am going to try reinstalling with a custom partition scheme. I read elsewhere (askubuntu won't let me post another link) that I don't even need a /boot partition any more. So instead of following Andrew's instructions ver batim, I'm first going to try having just two partitions: one for /, and another for my 16GB swap space. Both as primary partitions. The first will be formatted as ext4. If that doesn't work, I may try again using /boot. ======================== So I did my custom install with no /boot partition, and it did not work. When I rebooted, I had an error message saying that some address did not exist. So for the hundredth time, I booted from the live USB, and ran boot-repair. Now I get this message GPT detected. Please create a BIOS-Boot partition (>1MB, unformatted filesystem, bios_grub flag). This can be performed via tools such as Gparted. Then try again. I feel like I'm running in circles and nobody will help me.

    Read the article

  • Android Marketplace Error: "The server could not process your apk. Try again."

    - by jdandrea
    I have an updated apk - tested successfully on various devices and simulator instances - with the following manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myCompany.appName" android:versionCode="2" android:versionName="1.0.1"> <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" /> <uses-permission android:name="android.permission.INTERNET" /> <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" /> <application android:icon="@drawable/icon" android:label="@string/icon_name" android:debuggable="false"> <activity android:name=".myActivity" android:configChanges="keyboardHidden|orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> When I post to Android Marketplace as an upgrade to my existing 1.0 app, I get the aforementioned ambiguous message: "The server could not process your apk. Try again." I've searched elsewhere for this message in hopes of finding out what might be happening, to no avail. (A popular suggestion is to move the uses-sdk element to the top of the manifest, but as you can see it's already at the top.) Clues welcome/appreciated. Update: I just tried to upload the same file again. Now I get a new message: The new apk's versionCode (2) in AndroidManifest.xml must be higher than the old apk's versionCode (2). The server could not process your apk. Try again. Soooo Marketplace did get my upgraded apk after all? (The very first accepted apk's versionCode was 1, so this update was of course bumped to 2.) Confused … Bumping it up to 3 and trying again. Surprise surprise, I get the original "could not process" error all over again. Going in circles. Hmm ... :( Nuther Update: If I exit and re-enter the Marketplace page, now it shows that the app has been uploaded! Except there's no app icon. Curiouser and curiouser ... and this is all happening with a cache-cleared (standards-friendly) browser to boot. So - do I trust the upload? Or start over ... with versionCode="4"? All I want is to get a solid "Upload successful, here's the icon, ready to publish" type of response.

    Read the article

  • Filter chain halted as [:login_required] rendered_or_redirected

    - by Magicked
    Hopefully I can explain this well enough, but please let me know if more information is needed! I'm building a form where a user can create an "incident". This incident has the following relationships: belongs_to: customer (customer has_many incidents) belongs_to: user (user has_many incidents) has_one: incident_status (incident_status belongs to incident) The form allows the user to assign the incident to a user (select form) and then select an incident status. The incident is nested in customer. However, I'm getting the following in the server logs: Processing IncidentsController#create (for 127.0.0.1 at 2010-04-26 10:41:33) [POST] Parameters: {"commit"=>"Create", "action"=>"create", "authenticity_token"=>"YhW++vd/dnLoNV/DSl1DULcaWq/RwP7jvLOVx9jQblA=", "customer_id"=>"4", "controller"=>"incidents", "incident"=>{"title"=>"Some Bad Incident", "incident_status_id"=>"1", "user_id"=>"2", "other_name"=>"SS01-042310-001"}} User Load (0.3ms) SELECT * FROM "users" WHERE ("users"."id" = 2) LIMIT 1 Redirected to http://localhost:3000/session/new Filter chain halted as [:login_required] rendered_or_redirected. Completed in 55ms (DB: 0) | 302 Found [http://localhost/customers/4/incidents] It looks to me like it's trying to gather information about the user, even though it already has the id (which is all it needs to create the incident), and the user may not have permission to do a select statement like that? I'm rather confused. Here is the relevant (I think) information in the Incident controller. before_filter :login_required, :get_customer def new @incident = @customer.incidents.build @users = @customer.users @statuses = IncidentStatus.find(:all) respond_to do |format| format.html # new.html.erb format.xml { render :xml => @incident } end end def create @incident = @customer.incidents.build(params[:incident]) respond_to do |format| if @incident.save flash[:notice] = 'Incident was successfully created.' format.html { redirect_to(@incident) } format.xml { render :xml => @incident, :status => :created, :location => @incident } else format.html { render :action => "new" } format.xml { render :xml => @incident.errors, :status => :unprocessable_entity } end end end Just as an FYI, I am using the restful_authentication plugin. So in summary, when I submit the incident creation form, it does not save the incident because it halts. I'm still very new to rails, so my skill at diagnosing problems like this is still very bad. I'm going in circles. :) Thanks in advance for any help. Please let me know if more information is needed and I'll edit it in!

    Read the article

  • PHP: How to find connections between users so I can create a closed friend circle?

    - by CuSS
    Hi all, First of all, I'm not trying to create a social network, facebook is big enough! (comic) I've chosen this question as example because it fits exactly on what I'm trying to do. Imagine that I have in MySQL a users table and a user_connections table with 'friend requests'. If so, it would be something like this: Users Table: userid username 1 John 2 Amalia 3 Stewie 4 Stuart 5 Ron 6 Harry 7 Joseph 8 Tiago 9 Anselmo 10 Maria User Connections Table: userid_request userid_accepted 2 3 7 2 3 4 7 8 5 6 4 5 8 9 4 7 9 10 6 1 10 7 1 2 Now I want to find circles between friends and create a structure array and put that circle on the database (none of the arrays can include the same friends that another has already). Return Example: // First Circle of Friends Circleid => 1 CircleStructure => Array( 1 => 2, 2 => 3, 3 => 4, 4 => 5, 5 => 6, 6 => 1, ) // Second Circle of Friends Circleid => 2 CircleStructure => Array( 7 => 8, 8 => 9, 9 => 10, 10 => 7, ) I'm trying to think of an algorithm to do that, but I think it will take a lot of processing time because it would randomly search the database until it 'closes' a circle. PS: The minimum structure length of a circle is 3 connections and the limit is 100 (so the daemon doesn't search the entire database) EDIT: I've think on something like this: function browse_user($userget='random',$users_history=array()){ $user = user::get($userget); $users_history[] = $user['userid']; $connections = user::connection::getByUser($user['userid']); foreach($connections as $connection){ $userid = ($connection['userid_request']!=$user['userid']) ? $connection['userid_request'] : $connection['userid_accepted']; // Start the circle array if(in_array($userid,$users_history)) return array($user['userid'] => $userid); $res = browse_user($userid, $users_history); if($res!==false){ // Continue the circle array return $res + array($user['userid'] => $userid); } } return false; } while(true){ $res = browse_user(); // Yuppy, friend circle found! if($res!==false){ user::circle::create($res); } // Start from scratch again! } The problem with this function is that it could search the entire database without finding the biggest circle, or the best match.

    Read the article

  • launching mapview from main activity (button)

    - by arc
    Hi all. Going round in circles here i think. I have an activity called Locate; public class Locate extends Activity { public static String lat; public static String lon; public static String number; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.locate); final Button buttonMaps = (Button) findViewById(R.id.ButtonMaps); buttonMaps.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(getBaseContext(), "Button Pressed", Toast.LENGTH_SHORT).show(); try { Intent i = new Intent(getBaseContext(), displayMap.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); } catch (ActivityNotFoundException e) { Toast.makeText(getBaseContext(), "Activity Not Found", Toast.LENGTH_SHORT).show(); } }}); // Toast.makeText(getBaseContext(), "lat: " + lat + " long: " + lon + " from: " + testname, Toast.LENGTH_LONG).show(); } If I make the displayMap class into a normal Activity, and just have display a toast message confirming it has loaded - then it works fine. If i do this though; public class displayMap extends MapActivity { /** Called when the activity is first created. */ public void onCreate() { setContentView(R.layout.displaymap); Toast.makeText(getBaseContext(), "Display Map", Toast.LENGTH_SHORT).show(); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } Then as soon as I click the Button, I get a force close. I have the correct 'uses-library' tag in my manifest; <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="com.google.android.maps" /> I don't get what it just force closes everytime i try and load it. If I make this my onClick handler then it will fire up a working googlemaps/default mapview public void onClick(View v) { Toast.makeText(getBaseContext(), "Button Pressed", Toast.LENGTH_SHORT).show(); Uri uri=Uri.parse("geo:"+Locate.lat+","+Locate.lon); StartActivity(new Intent(Intent.ACTION_VIEW, uri)); } But that is not what I am trying to do, I want my own - so that I can add overlays etc to it. But it does prove that the permission are set correctly and that the lib is there. The logcat error when the app FCs is a Unexpected DEX error. Can anyone point in the right direction here?

    Read the article

< Previous Page | 9 10 11 12 13 14 15  | Next Page >