Daily Archives

Articles indexed Saturday January 15 2011

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

  • Parent-child height problem

    - by Vector
    I have a parent div that has position: relative and his child has position: absolute. Such positions is a must. The problem is the parent does not stretch to the height of the child. The question is how to make it stretch to the height of the child? The mark-up is similar to this: <!DOCTYPE HTML> <html> <head> <style> .parent { position: relative; border: solid 1px red; } .child { position: absolute; border: solid 1px red; } </style> </head> <body> <div class="parent"> <div class="child">Hello World!</div> </div> </body> </html>

    Read the article

  • Does it exist: smart pointer, owned by one object allowing access.

    - by Noah Roberts
    I'm wondering if anyone's run across anything that exists which would fill this need. Object A contains an object B. It wants to provide access to that B to clients through a pointer (maybe there's the option it could be 0, or maybe the clients need to be copiable and yet hold references...whatever). Clients, lets call them object C, would normally, if we're perfect developers, be written carefully so as to not violate the lifetime semantics of any pointer to B they might have...but we're not perfect, in fact we're pretty dumb half the time. So what we want is for object C to have a pointer to object B that is not "shared" ownership but that is smart enough to recognize a situation in which the pointer is no longer valid, such as when object A is destroyed or it destroys object B. Accessing this pointer when it's no longer valid would cause an assertion/exception/whatever. In other words, I wish to share access to data in a safe, clear way but retain the original ownership semantics. Currently, because I've not been able to find any shared pointer in which one of the objects owns it, I've been using shared_ptr in place of having such a thing. But I want clear owneship and shared/weak pointer doesn't really provide that. Would be nice further if this smart pointer could be attached to member variables and not just hold pointers to dynamically allocated memory regions. If it doesn't exist I'm going to make it, so I first want to know if someone's already released something out there that does it. And, BTW, I do realize that things like references and pointers do provide this sort of thing...I'm looking for something smarter.

    Read the article

  • Rails 3 Form For Custom Action

    - by Andrew
    I'm having trouble routing a form to a custom action in Rails 3. Here are my routes: resources :photos do resources :comments collection do get 'update_states' end member do put 'upload' end end Here's the form_for: form_for @photo, :remote => true, :url => { :action => upload_photo_path(@photo) }, :html => { :multipart => :true, :method => 'put' } do |f| And here's the error message: No route matches {:action=>"/photos/42/upload", :controller=>"photos"} ... this is especially frustrating because "photos/:id/upload" is exactly the correct action for this form. What am I missing? EDITS - Here are the original Photo-related routes: photo_comments GET /photos/:photo_id/comments(.:format) {:action=>"index", :controller=>"comments"} POST /photos/:photo_id/comments(.:format) {:action=>"create", :controller=>"comments"} new_photo_comment GET /photos/:photo_id/comments/new(.:format) {:action=>"new", :controller=>"comments"} edit_photo_comment GET /photos/:photo_id/comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"} photo_comment GET /photos/:photo_id/comments/:id(.:format) {:action=>"show", :controller=>"comments"} PUT /photos/:photo_id/comments/:id(.:format) {:action=>"update", :controller=>"comments"} DELETE /photos/:photo_id/comments/:id(.:format) {:action=>"destroy", :controller=>"comments"} update_states_photos GET /photos/update_states(.:format) {:action=>"update_states", :controller=>"photos"} upload_photo PUT /photos/:id/upload(.:format) {:action=>"upload", :controller=>"photos"} photos GET /photos(.:format) {:action=>"index", :controller=>"photos"} POST /photos(.:format) {:action=>"create", :controller=>"photos"} new_photo GET /photos/new(.:format) {:action=>"new", :controller=>"photos"} edit_photo GET /photos/:id/edit(.:format) {:action=>"edit", :controller=>"photos"} photo GET /photos/:id(.:format) {:action=>"show", :controller=>"photos"} PUT /photos/:id(.:format) {:action=>"update", :controller=>"photos"} DELETE /photos/:id(.:format) {:action=>"destroy", :controller=>"photos"} Here are the relevant routes when I changed the route to match 'upload': photo_comments GET /photos/:photo_id/comments(.:format) {:action=>"index", :controller=>"comments"} POST /photos/:photo_id/comments(.:format) {:action=>"create", :controller=>"comments"} } new_photo_comment GET /photos/:photo_id/comments/new(.:format) {:action=>"new", :controller=>"comments"} edit_photo_comment GET /photos/:photo_id/comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"} photo_comment GET /photos/:photo_id/comments/:id(.:format) {:action=>"show", :controller=>"comments"} PUT /photos/:photo_id/comments/:id(.:format) {:action=>"update", :controller=>"comments"} DELETE /photos/:photo_id/comments/:id(.:format) {:action=>"destroy", :controller=>"comments"} update_states_photos GET /photos/update_states(.:format) {:action=>"update_states", :controller=>"photos"} upload_photo /photos/:id/upload(.:format) {:action=>"upload", :controller=>"photos"} photos GET /photos(.:format) {:action=>"index", :controller=>"photos"} POST /photos(.:format) {:action=>"create", :controller=>"photos"} new_photo GET /photos/new(.:format) {:action=>"new", :controller=>"photos"} edit_photo GET /photos/:id/edit(.:format) {:action=>"edit", :controller=>"photos"} photo GET /photos/:id(.:format) {:action=>"show", :controller=>"photos"} PUT /photos/:id(.:format) {:action=>"update", :controller=>"photos"} DELETE /photos/:id(.:format) {:action=>"destroy", :controller=>"photos"} Unfortunately 'match' didn't work any better... -- EDIT -- Just to confirm another scenario here... with this in the routes: resources :photos do resources :comments collection do get 'update_states' end member do match 'upload' end end and this in the view: form_for @photo, :remote => true, :url => { :action => 'upload' }, :html => { :multipart => :true, :id => 'photo_upload' } do |f| I still get: No route matches {:action=>"upload", :controller=>"photos"}

    Read the article

  • perl dancer: passing database info to template

    - by Bubnoff
    Following Dancer tutorial here: http://search.cpan.org/dist/Dancer/lib/Dancer/Tutorial.pod I'm using my own sqlite3 database with this schema CREATE TABLE if not exists location (location_code TEXT PRIMARY KEY, name TEXT, stations INTEGER); CREATE TABLE if not exists session (id INTEGER PRIMARY KEY, date TEXT, sessions INTEGER, location_code TEXT, FOREIGN KEY(location_code) REFERENCES location(location_code)); My dancer code ( helloWorld.pm ) for the database: package helloWorld; use Dancer; use DBI; use File::Spec; use File::Slurp; use Template; our $VERSION = '0.1'; set 'template' => 'template_toolkit'; set 'logger' => 'console'; my $base_dir = qq(/home/automation/scripts/Area51/perl/dancer); # database crap sub connect_db { my $db = qw(/home/automation/scripts/Area51/perl/dancer/sessions.sqlite); my $dbh = DBI->connect("dbi:SQLite:dbname=$db", "", "", { RaiseError => 1, AutoCommit => 1 }); return $dbh; } sub init_db { my $db = connect_db(); my $file = qq($base_dir/schema.sql); my $schema = read_file($file); $db->do($schema) or die $db->errstr; } get '/' => sub { my $branch_code = qq(BPT); my $dbh = connect_db(); my $sql = q(SELECT * FROM session); my $sth = $dbh->prepare($sql) or die $dbh->errstr; $sth->execute or die $dbh->errstr; my $key_field = q(id); template 'show_entries.tt', { 'branch' => $branch_code, 'data' => $sth->fetchall_hashref($key_field), }; }; init_db(); true; Tried the example template on the site, doesn't work. <% FOREACH id IN data.keys.nsort %> <li>Date is: <% data.$id.sessions %> </li> <% END %> Produces page but with no data. How do I troubleshoot this as no clues come up in the console/cli? Thanks Bubnoff

    Read the article

  • Finding easily parseable chemical element data

    - by nickname
    I am writing an application that needs simple data found (mostly) on the periodic table of elements, such as atomic mass, atomic number, state, etc. However, I would prefer not to manually enter this data. I managed to find the NIST website (http://www.nist.gov/pml/data/edi.cfm) with all of the data I need, but not in a downloadable format. Where can I find this data? Preferably, it would be in an XML/YAML/JSON/other documented format, however, any format would be helpful.

    Read the article

  • QT List of Callbacks

    - by Talguy
    I am trying to make a real-time data collection application that has timed task. Each task can have a different or the same update period. I would like to store the task with the common update period in a list where I can iterate through it and call the function that I registered in the list. How would I go about adding callbacks to a data structure like a list or vector? Can I store slots in them?

    Read the article

  • scala currying by nested functions or by multiple parameter lists

    - by Morgan Creighton
    In Scala, I can define a function with two parameter lists. def myAdd(x :Int)(y :Int) = x + y This makes it easy to define a partially applied function. val plusFive = myAdd(5) _ But, I can accomplish something similar by defining and returning a nested function. def myOtherAdd(x :Int) = { def f(y :Int) = x + y f _ } Cosmetically, I've moved the underscore, but this still feels like currying. val otherPlusFive = myOtherAdd(5) What criteria should I use to prefer one approach over the other?

    Read the article

  • Passenger/Rails not releasing memory

    - by michaeldelorenzo
    I have an Ubuntu server running three separate Rails (2.3.8) applications with Passenger, REE and Apache. Recently we started experiencing problems with ruby processes eating up memory and consuming entire cores on our server. Here's what we're getting... %CPU PID USER COMMAND 99.9 1717 nobody Rails: /var/www/api 99.6 5542 nobody Rails: /var/www/api 97.3 1223 nobody Rails: /var/www/api 4.7 5537 nobody Passenger ApplicationSpawner: /var/www/api 10.5 1801 nobody Rails: /var/www/api We've also seen instances where there have been over 100 instances of Apache running. These applications have been running for a few months without an of these issues, but in the last day or so we've been noticing this. The site referenced here is a Rails application that is a RESTful API so it serves many requests every minute. Any guidance on what we should be checking or looking out for would be appreciated.

    Read the article

  • Amazon EC2 as load balanced/failover solution

    - by sugiggs
    Hi All, I'm thinking of an idea but not sure the pros/cons of it. At the moment, we are hosting our website on a dedicated server. As a failover/load balanced solution, I'm thinking to use Amazon EC2+EBS. The files can be rsync and mysql can be setup as master-master replication When the load is high, I can up the machine, given sometime to "sync" and load balanced the traffic there. is it do-able? any link I can read more on this?

    Read the article

  • Merging Two Git Repositories with branches

    - by Joel K
    I realize there's a Stack Overflow question: http://stackoverflow.com/questions/277029/combining-multiple-git-repositories But I haven't found git-stitch-repo to be quite the tool I'm looking for. I also consider this more of a sysadmin task. How do I take code from an external repository and combine it with code from a primary repository while maintaining history/diffs and branches. Use case: An outside development team using SVN has ported to git and now wants to 'merge' their code in to the main company's git repo. I've tried subtree merges, but I lose the history. I've tried git-stitch-repo, but that process results in an entirely new repo that's missing branches. I just want to slot in some outside code as a sub-directory in our current main repo with as little disruption as possible and while maintaining the other project's history. Any success stories out there?

    Read the article

  • Will this increase my VPS failing rate ?

    - by Spencer Lim
    Will this increase my Virtual private Server failing rate if i :- install Microsoft Window Server 2008 Enterprise install SQL server enterprise 2008 install IIS 7.5 install ASP.Net Mvc 2 install Microsoft Exchange install Team foundation server on one mini VPS with specification of DELL Poweredge R710 shared plan DDR3 ECC RAMs 16GB and -- 1GB for this VPS using DELL PERC 6i raid controller (this thing alone about 1.5k-2k) and the SAS HDD (15K RPM) (146GB) -- 33GB to this VPS each hdd is freaking fast over 300MB read / write possible with proper tuning the motherboard is a DELL and it has twin redundant PSU (870watt 85%eff) its running on Intel Xeon 5502 (Quad Core) x2 so about 8 physical proc (fairly share) is there any ruler for this about one VPS can only install what what what service ? Thx for reply

    Read the article

  • how to reinstall Asus notebook using Recovery DVD?

    - by Radek
    a friend of mine asked to reinstall his Asus notebook. He didn't want Vista anymore so I installed XP. Re-partitioned the hdd (no more recovery partition). Everything went fine except I cannot make LAN card work. I created a question for that. And I talked to Asus help desk but it didn't help so we decided to go back to Vista. I have the original Recovery DVD for his notebook. With files like ASUS.SWM and ASUS2.SWM. But I do not know how to use this DVD to reinstall his notebook. Did I mention that his DVD drive mostly doesn't work?

    Read the article

  • Problems using PC as a media server with PS3

    - by Tiger
    I recently got a PS3 and decided to take advantage of the fact that it can be used to stream movies by making my PC a media server. I've done this in the past with the same router I have now before I sold my old PS3, but not on this PC. I've tried using both Tversity and PS3 Media server, but I don't think the problem lies within the configuration of either of those programs because I am unable to ping the PS3. This problem only occurs when I am using a wired connection on my pc, attempting to connect to a WLAN connection on the PS3. If I switch to WLAN on my PC I can successfully ping the PS3 and connect to the media server. Thanks

    Read the article

  • Users can benefit from Session Tracking

    I use to work for a large Dental Plan marketing website a few years ago and they had a large customer-driven website that sold Dental Plans to consumers. Their website started tracking users as soon as they hit their web servers, and then they logged everything they could about the user. There are a lot of benefits for using session tracking for both the user and the website. Users can benefit from session tracking due to the fact that a website can retain pertaining information for the user so that they do not have to re-enter the same information repeatedly. In addition, websites can hold specific items in a cart for each user so that they can pay for all of their  items at once when they are ready to complete their purchases. Websites can also benefit from session tracking because they can determine where a specific user came from and which advertising partner gave them a sale. This information is very useful when deciding on where to spend an advertising budget. There is only one real disadvantage when it comes to session tracking, Users can not really control what is actually tracked by a website. Yes, they can disable cookies and this will help, but that means that no tracking can be done at all. Most sites require users to have cookies enabled in order for users to make purchases or login to their accounts.

    Read the article

  • Will people respect a Masters of Science in IT w/software engineering concentration from RPI?

    - by twneale
    Here's my thing: I got my undergraduate degree in political science, then a law degree. Then I figured out that I love programming and I'm pretty good at it too. It's fun and rewarding enough for me that I'd prefer to do it for a living over almost any form of pure law practice. So I'm looking at getting a masters degree to put some weight behind a possible career switch. If I actually want to develop software (web, in particular), would people in programming circles respect a master's of science in IT? Specifically, consider as an example the MS in IT from Rensselaer Polytechnic Institute (with a concentration in software engineering). Here's the home page: http://www.rpi.edu/IT/graduate/masters_program.html In particular, I mean to draw a contrast between IT as specifically contemplated by the RPI masters program (an interdisciplinary tech/business program) and other MS degrees in computer science or software engineering that focus more on the science and technical aspects. I guess I want to make sure that other programmers would respect my credentials and not consider me as different or underqualified based on the connotations of the phrase "IT". I believe RPI has an unimpeachable reputation for hard science, and the program seems excellent, but it still matters to me how people in industry would perceive it.

    Read the article

  • What to do with database in dev/production phases of a website?

    - by TheLQ
    For a while now I've been keeping a website I'm developing in the standard dev/production phases. Its been pretty simple: Mercurial repo for dev, repo for production. Do work in dev, get approved, push to production. But now I'm trying to apply this process to a new website that has a database and am struggling on how to figure out a development strategy. What I didn't mention above is that I do all my work on my own repo, push it to dev, then later push it to production, so its 3 different servers. So how do I manage my database? The obvious solution of mysqldump every commit isn't going to happen, and a dump at the end of the day isn't all that helpful when you want to undo later one change that happened in the middle of the day. What is the best way to accomplish this?

    Read the article

  • Hopcroft–Karp algorithm in Python

    - by Simon
    I am trying to implement the Hopcroft Karp algorithm in Python using networkx as graph representation. Currently I am as far as this: #Algorithms for bipartite graphs import networkx as nx import collections class HopcroftKarp(object): INFINITY = -1 def __init__(self, G): self.G = G def match(self): self.N1, self.N2 = self.partition() self.pair = {} self.dist = {} self.q = collections.deque() #init for v in self.G: self.pair[v] = None self.dist[v] = HopcroftKarp.INFINITY matching = 0 while self.bfs(): for v in self.N1: if self.pair[v] and self.dfs(v): matching = matching + 1 return matching def dfs(self, v): if v != None: for u in self.G.neighbors_iter(v): if self.dist[ self.pair[u] ] == self.dist[v] + 1 and self.dfs(self.pair[u]): self.pair[u] = v self.pair[v] = u return True self.dist[v] = HopcroftKarp.INFINITY return False return True def bfs(self): for v in self.N1: if self.pair[v] == None: self.dist[v] = 0 self.q.append(v) else: self.dist[v] = HopcroftKarp.INFINITY self.dist[None] = HopcroftKarp.INFINITY while len(self.q) > 0: v = self.q.pop() if v != None: for u in self.G.neighbors_iter(v): if self.dist[ self.pair[u] ] == HopcroftKarp.INFINITY: self.dist[ self.pair[u] ] = self.dist[v] + 1 self.q.append(self.pair[u]) return self.dist[None] != HopcroftKarp.INFINITY def partition(self): return nx.bipartite_sets(self.G) The algorithm is taken from http://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm However it does not work. I use the following test code G = nx.Graph([ (1,"a"), (1,"c"), (2,"a"), (2,"b"), (3,"a"), (3,"c"), (4,"d"), (4,"e"),(4,"f"),(4,"g"), (5,"b"), (5,"c"), (6,"c"), (6,"d") ]) matching = HopcroftKarp(G).match() print matching Unfortunately this does not work, I end up in an endless loop :(. Can someone spot the error, I am out of ideas and I must admit that I have not yet fully understand the algorithm, so it is mostly an implementation of the pseudo code on wikipedia

    Read the article

  • Crossplatform development for iPhone & Android

    - by LeonixSolutions
    As far as I can see there doesn't seem to any mature environment for crossplatform development for iPhone & Android slate (but feel free to correct me). I don't know Ipad, I must admit. Any reason why plain Java wouldn't cut it? (maybe underlying things like database (I am not too concerned with hardware)) I am thinking to try to make everything browser based, although that won't get around the d/b & h/w issues, unless there is JS framework that does so. Any advice?

    Read the article

  • java graphics display help

    - by java
    I know that i am not calling the graphics paint command in the mainframe in order to display it. but i'm not sure how. thanks in advance import java.awt.*; import javax.swing.*; public class MainFrame extends JFrame { private static Panel panel = new Panel(); public MainFrame() { panel.setBackground(Color.white); Container c = getContentPane(); c.add(panel); } public void paint(Graphics g) { g.drawString("abc", 20, 20); } public static void main(String[] args) { MainFrame frame = new MainFrame(); frame.setVisible(true); frame.setSize(600, 400); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }

    Read the article

  • Cakephp Autoconvert find() fields?

    - by Razor Storm
    In cake php I can grab a model's fields by using the find() method. What if I wish to apply a transformation function to the fields? Is there a way to directly accomplish this task? Suppose I have a model called RaceTime with the fields racerId and timeMillis RaceTime +------------+ | Field | +------------+ | id | | racerId | | timeMillis | +------------+ timeMillis is an int specifying how long the race took in milliseconds. Obviously saying a race took 15651 milliseconds isn't very useful to a human reader, and I would wish to convert this to a human readable format. Is there a way to accomplish this directly in find()? Or is the only option to loop through the results after find() finishes?

    Read the article

  • How does one find a '.' in a string object in Object-C

    - by NaZer
    I am working on getting a simple calculator working as part of my adventure to learning Object-C and iOS development. In Object-C using NSString, how does one look for a period in a string? Based on the comments this is what I got so far. NSString * tmp = [display text]; NSLog(@"%@", tmp); // Shows the number on the display correctly int x = [tmp rangeOfString:@"."].location; NSLog(@"%i", x); // Shows some random signed number if (x < 0) { [display setText:[[display text] stringByAppendingFormat:@"."]]; } It is still not working :(

    Read the article

  • Adding figures using contextual menu - Eclipse GEF

    - by darkie15
    All, I am creating a palette less eclipse plugin where am adding figures to the custom editor through the contextual menu, but am not finding a way to do it. Can anyone please guide me as to how to go about adding figures to editor dynamically through context menu i.e. adding actions/commands. Since Eclipse GEF plugin development finds so less examples to look at, I am adding my solution so others find it useful. This code helps to render a node to the editor. Source code for Action class to render figures to the editor: public class AddNodeAction extends EditorPartAction { public static final String ADD_NODE = "ADDNODE"; public AddNodeAction(IEditorPart editor) { super(editor); setText("Add a Node"); setId(ADD_NODE); // Important to set ID } public void run() { <ParentModelClass> parent= (<ParentModelClass>)getEditorPart().getAdapter(<ParentModelClass>.class); if (parent== null) return; CommandStack command = (CommandStack)getEditorPart().getAdapter(CommandStack.class); if (command != null) { CompoundCommand totalCmd = new CompoundCommand(); <ChildModelToRenderFigureCommand>cmd = new <ChildModelToRenderFigureCommand>(parent); cmd.setParent(parent); <ChildModelClass> newNode = new <ChildModelClass>(); cmd.setNode(newNode); cmd.setLocation(getLocation()); // Any location you wish to set to totalCmd.add(cmd); command.execute(totalCmd); } } @Override protected boolean calculateEnabled() { return true; } }

    Read the article

  • Rails3 and `cd somehwere && do something`

    - by Samer Abukhait
    I have a rails project that has other projects under it, sub-projects have rake and bundler files. When I do ruby -e `cd sub-project && rake`, or ruby -e `cd sub-project && bundle`, commands work as expected and use the sub-project rake/bundler files. However, when I do the same thing from a Rails3 console (rails 3.0.3), rake gives the error no such file to load -- initializer, and bundle operates as if it was fired from the root directory. I tried the same commands from a Rails2.3.10 console and they worked as expected. Is Rails3 doing something wrong here? I am using Ruby 1.9.2 via RVM. $ ruby -v ruby 1.9.2p136 (2010-12-25 revision 30365) [i686-linux]

    Read the article

  • How to achieve vertical div alignment in unique situation?

    - by Earl Larson
    Go to my blog and please tell me how to achieve vertical alignment :( My situation truly is different and I need help :) The reason this is so difficult is because holder is the div that contains everything, outer are the icons at the bottom, and tooltip are the divs that pop up. I need tooltip to be vertically aligned but they are actually below outer. Each icon is connected to their post so you can't keep them all in one div.

    Read the article

  • Cocoa Interface Builder object initialization

    - by Stanley
    Base on the documentation and sample code that I have gone through, I got an impression that when a class defined in xcode is read into and configured in Interface Builder, an object based on the class is effectively created and stored in an xib or nib file. So the object is ready to be used when the corresponding application is launched. Alternatively, for classes that have not been handled by Interface Builder, code such as the "new" statements have to be written in xcode explicitly in order for the associated objects to be created and used. It will be very nice to have people who are more knowledgable than me to confirm or to correct my very naive understanding of Interface Builder ...

    Read the article

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